From a1836ff1ea8b6349d434bf6058211a7136441720 Mon Sep 17 00:00:00 2001 From: rguenth Date: Thu, 24 Feb 2011 09:53:26 +0000 Subject: [PATCH] 2011-02-24 Richard Guenther 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@170463 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/f95-lang.c | 17 ++++++++++++----- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/gfortran.dg/lto/pr47839_0.f90 | 8 ++++++++ gcc/testsuite/gfortran.dg/lto/pr47839_1.f90 | 7 +++++++ 5 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/lto/pr47839_0.f90 create mode 100644 gcc/testsuite/gfortran.dg/lto/pr47839_1.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 96c5411..7bef41b 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2011-02-24 Richard Guenther + + 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 PR fortran/40850 diff --git a/gcc/fortran/f95-lang.c b/gcc/fortran/f95-lang.c index a3ac860..3340dc4 100644 --- a/gcc/fortran/f95-lang.c +++ b/gcc/fortran/f95-lang.c @@ -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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 13d54ed..4f097e2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2011-02-24 Richard Guenther + + PR fortran/47839 + * gfortran.dg/lto/pr47839_0.f90: New testcase. + * gfortran.dg/lto/pr47839_1.f90: Likewise. + 2011-02-23 Jerry DeLisle 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 index 0000000..9ea9315 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/lto/pr47839_0.f90 @@ -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 index 0000000..5c94ff1 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/lto/pr47839_1.f90 @@ -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 -- 2.7.4