re PR fortran/47839 (ICE in dwarf2out.c:add_AT_specification)
authorRichard Guenther <rguenther@suse.de>
Thu, 24 Feb 2011 09:53:26 +0000 (09:53 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 24 Feb 2011 09:53:26 +0000 (09:53 +0000)
2011-02-24  Richard Guenther  <rguenther@suse.de>

PR fortran/47839
* f95-lang.c (pushdecl): For externs in non-global scope push
a copy of the decl into the BLOCK.

* gfortran.dg/lto/pr47839_0.f90: New testcase.
* gfortran.dg/lto/pr47839_1.f90: Likewise.

From-SVN: r170463

gcc/fortran/ChangeLog
gcc/fortran/f95-lang.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/lto/pr47839_0.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/lto/pr47839_1.f90 [new file with mode: 0644]

index 96c5411e92224623a6bc70334b509c5ecb8b41da..7bef41bd659d91bdd6bb8455f5cf33cea60c4d4d 100644 (file)
@@ -1,3 +1,9 @@
+2011-02-24  Richard Guenther  <rguenther@suse.de>
+
+       PR fortran/47839
+       * f95-lang.c (pushdecl): For externs in non-global scope push
+       a copy of the decl into the BLOCK.
+
 2011-02-23  Mikael Morin  <mikael@gcc.gnu.org>
 
        PR fortran/40850
index a3ac86032c660f029809f5365eb96e16c0ace19f..3340dc4ee247b5573489804ba4d01bbac3c0a007 100644 (file)
@@ -498,13 +498,20 @@ poplevel (int keep, int reverse, int functionbody)
 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
index 13d54eda179d573060f8fb2d5356c2bb7f303635..4f097e27e906943d5aabc7aef915d5b2f404b582 100644 (file)
@@ -1,3 +1,9 @@
+2011-02-24  Richard Guenther  <rguenther@suse.de>
+
+       PR fortran/47839
+       * gfortran.dg/lto/pr47839_0.f90: New testcase.
+       * gfortran.dg/lto/pr47839_1.f90: Likewise.
+
 2011-02-23  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
 
        PR libgfortran/47567
diff --git a/gcc/testsuite/gfortran.dg/lto/pr47839_0.f90 b/gcc/testsuite/gfortran.dg/lto/pr47839_0.f90
new file mode 100644 (file)
index 0000000..9ea9315
--- /dev/null
@@ -0,0 +1,8 @@
+! { dg-lto-do link }
+! { dg-lto-options {{ -g -flto }} }
+! { dg-extra-ld-options "-r -nostdlib" }
+
+MODULE globalvar_mod
+integer        :: xstop
+CONTAINS
+END MODULE globalvar_mod
diff --git a/gcc/testsuite/gfortran.dg/lto/pr47839_1.f90 b/gcc/testsuite/gfortran.dg/lto/pr47839_1.f90
new file mode 100644 (file)
index 0000000..5c94ff1
--- /dev/null
@@ -0,0 +1,7 @@
+MODULE PEC_mod
+CONTAINS
+SUBROUTINE PECapply(Ex)
+USE globalvar_mod, ONLY : xstop
+real(kind=8), dimension(1:xstop), intent(inout) :: Ex
+END SUBROUTINE PECapply
+END MODULE PEC_mod