From 7e33d332035bed444fb7a00d8f40ed50bdfc2739 Mon Sep 17 00:00:00 2001 From: pault Date: Wed, 26 May 2010 05:11:04 +0000 Subject: [PATCH] 2010-05-26 Paul Thomas PR fortran/40011 * resolve.c (resolve_global_procedure): Resolve the gsymbol's namespace before trying to reorder the gsymbols. 2010-05-26 Paul Thomas PR fortran/40011 * gfortran.dg/whole_file_19.f90 : New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159852 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/resolve.c | 29 +++++++++++++++-------------- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/whole_file_19.f90 | 25 +++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 14 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/whole_file_19.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index a28bb25f817..14a2edaec85 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2010-05-26 Paul Thomas + + PR fortran/40011 + * resolve.c (resolve_global_procedure): Resolve the gsymbol's + namespace before trying to reorder the gsymbols. + 2010-05-25 Daniel Franke PR fortran/30668 diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index f2c24409cc8..1538ea0c9ab 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -1824,20 +1824,7 @@ resolve_global_procedure (gfc_symbol *sym, locus *where, && not_in_recursive (sym, gsym->ns) && not_entry_self_reference (sym, gsym->ns)) { - /* Make sure that translation for the gsymbol occurs before - the procedure currently being resolved. */ - ns = gsym->ns->resolved ? NULL : gfc_global_ns_list; - for (; ns && ns != gsym->ns; ns = ns->sibling) - { - if (ns->sibling == gsym->ns) - { - ns->sibling = gsym->ns->sibling; - gsym->ns->sibling = gfc_global_ns_list; - gfc_global_ns_list = gsym->ns; - break; - } - } - + /* Resolve the gsymbol namespace if needed. */ if (!gsym->ns->resolved) { gfc_dt_list *old_dt_list; @@ -1857,6 +1844,20 @@ resolve_global_procedure (gfc_symbol *sym, locus *where, gfc_derived_types = old_dt_list; } + /* Make sure that translation for the gsymbol occurs before + the procedure currently being resolved. */ + ns = gfc_global_ns_list; + for (; ns && ns != gsym->ns; ns = ns->sibling) + { + if (ns->sibling == gsym->ns) + { + ns->sibling = gsym->ns->sibling; + gsym->ns->sibling = gfc_global_ns_list; + gfc_global_ns_list = gsym->ns; + break; + } + } + if (gsym->ns->proc_name->attr.function && gsym->ns->proc_name->as && gsym->ns->proc_name->as->rank diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 08d1136281b..abfdca5d413 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-05-26 Paul Thomas + + PR fortran/40011 + * gfortran.dg/whole_file_19.f90 : New test. + 2010-05-25 Daniel Franke PR fortran/30668 diff --git a/gcc/testsuite/gfortran.dg/whole_file_19.f90 b/gcc/testsuite/gfortran.dg/whole_file_19.f90 new file mode 100644 index 00000000000..56f3cb69d8f --- /dev/null +++ b/gcc/testsuite/gfortran.dg/whole_file_19.f90 @@ -0,0 +1,25 @@ +! { dg-do compile } +! { dg-options "-fwhole-file" } +! Test the fix for pr40011 comment #42, in which the subroutine +! would just get lost with -fwhole-file. +! +! Contributed by Joost VandeVandole +! +SUBROUTINE c() + CALL a() +END SUBROUTINE c + +SUBROUTINE a() +END SUBROUTINE a + +MODULE M +CONTAINS + SUBROUTINE b() + CALL c() + END SUBROUTINE +END MODULE + +USE M +CALL b() +END +! { dg-final { cleanup-modules "m" } } -- 2.11.4.GIT