From 08ee9e8569e0742406dd585c2762df31b7ae0f6f Mon Sep 17 00:00:00 2001 From: Paul Thomas Date: Tue, 31 Jul 2007 22:14:29 +0000 Subject: re PR fortran/31609 (module that calls a contained function with an ENTRY point) 2007-08-01 Paul Thomas PR fortran/31609 * resolve.c (resolve_entries): Entries declared to be module procedures must point to the function namespace. 2007-08-01 Paul Thomas PR fortran/31609 * gfortran.dg/entry_12.f90: New test. From-SVN: r127108 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/resolve.c | 9 +++++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/entry_12.f90 | 30 ++++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/entry_12.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index d7de098..4acddfd 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2007-08-01 Paul Thomas + + PR fortran/31609 + * resolve.c (resolve_entries): Entries declared to be module + procedures must point to the function namespace. + 2007-07-31 Francois-Xavier Coudert PR fortran/32938 diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index e2ebc99..4b8d145 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -431,6 +431,15 @@ resolve_entries (gfc_namespace *ns) && ns->parent && ns->parent->proc_name->attr.flavor == FL_MODULE) el->sym->ns = ns; + /* Do the same for entries where the master is not a module + procedure. These are retained in the module namespace because + of the module procedure declaration. */ + for (el = el->next; el; el = el->next) + if (el->sym->ns->proc_name->attr.flavor == FL_MODULE + && el->sym->attr.mod_proc) + el->sym->ns = ns; + el = ns->entries; + /* Add an entry statement for it. */ c = gfc_get_code (); c->op = EXEC_ENTRY; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1c05bf0..2ef4a14 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-08-01 Paul Thomas + + PR fortran/31609 + * gfortran.dg/entry_12.f90: New test. + 2007-07-31 Francois-Xavier Coudert PR fortran/32938 diff --git a/gcc/testsuite/gfortran.dg/entry_12.f90 b/gcc/testsuite/gfortran.dg/entry_12.f90 new file mode 100644 index 0000000..8793b42 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/entry_12.f90 @@ -0,0 +1,30 @@ +! { dg-do run } +! Tests the fix for pr31609, where module procedure entries found +! themselves in the wrong namespace. This test checks that all +! combinations of generic and specific calls work correctly. +! +! Contributed by Paul Thomas as comment #8 to the pr. +! +MODULE ksbin1_aux_mod + interface foo + module procedure j + end interface + interface bar + module procedure k + end interface + interface foobar + module procedure j, k + end interface + CONTAINS + FUNCTION j () + j = 1 + return + ENTRY k (i) + k = 2 + END FUNCTION j +END MODULE ksbin1_aux_mod + + use ksbin1_aux_mod + if (any ((/foo (), bar (99), foobar (), foobar (99), j (), k (99)/) .ne. & + (/1, 2, 1, 2, 1, 2/))) Call abort () +end -- cgit v1.1