This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/47839] ICE in dwarf2out.c:add_AT_specification


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47839

--- Comment #3 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-02-22 11:46:04 UTC ---
I think this also hints at possible DECL issues with imported vars.  You can
see how the C frontend handles the function/block local externs around
c-decl.c:1206

          else if (VAR_OR_FUNCTION_DECL_P (p))
            {
              /* For block local externs add a special
                 DECL_EXTERNAL decl for debug info generation.  */
              tree extp = copy_node (p);
...

The following fixes the testcase for me (not further tested):

Index: gcc/fortran/f95-lang.c
===================================================================
--- gcc/fortran/f95-lang.c      (revision 170359)
+++ gcc/fortran/f95-lang.c      (working copy)
@@ -498,13 +498,20 @@ poplevel (int keep, int reverse, int fun
 tree
 pushdecl (tree decl)
 {
-  /* External objects aren't nested, other objects may be.  */
-  if (DECL_EXTERNAL (decl))
-    DECL_CONTEXT (decl) = NULL_TREE;
-  else if (global_bindings_p ())
+  if (global_bindings_p ())
     DECL_CONTEXT (decl) = current_translation_unit;
   else
-    DECL_CONTEXT (decl) = current_function_decl;
+    {
+      /* External objects aren't nested.  For debug info insert a copy
+         of the decl into the binding level.  */
+      if (DECL_EXTERNAL (decl))
+       {
+         tree orig = decl;
+         decl = copy_node (decl);
+         DECL_CONTEXT (orig) = NULL_TREE;
+       }
+      DECL_CONTEXT (decl) = current_function_decl;
+    }

   /* Put the declaration on the list.  The list of declarations is in reverse
      order. The list will be reversed later if necessary.  This needs to be


there might be still multiple backend-decls for USE associated vars in
different subroutines (they should share a single global one).


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]