2007-08-01 Paul Thomas <pault@gcc.gnu.org>
authorpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 31 Jul 2007 22:14:29 +0000 (22:14 +0000)
committerpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 31 Jul 2007 22:14:29 +0000 (22:14 +0000)
PR fortran/31609
* resolve.c (resolve_entries): Entries declared to be module
procedures must point to the function namespace.

2007-08-01  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/31609
* gfortran.dg/entry_12.f90: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@127108 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/resolve.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/entry_12.f90 [new file with mode: 0644]

index d7de098..4acddfd 100644 (file)
@@ -1,3 +1,9 @@
+2007-08-01  Paul Thomas  <pault@gcc.gnu.org>
+
+       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  <fxcoudert@gcc.gnu.org>
 
        PR fortran/32938
index e2ebc99..4b8d145 100644 (file)
@@ -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;
index 1c05bf0..2ef4a14 100644 (file)
@@ -1,3 +1,8 @@
+2007-08-01  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/31609
+       * gfortran.dg/entry_12.f90: New test.
+
 2007-07-31  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
 
        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 (file)
index 0000000..8793b42
--- /dev/null
@@ -0,0 +1,30 @@
+! { dg-do run }\r
+! Tests the fix for pr31609, where module procedure entries found\r
+! themselves in the wrong namespace.  This test checks that all\r
+! combinations of generic and specific calls work correctly.\r
+!\r
+! Contributed by Paul Thomas <pault@gcc.gnu.org> as comment #8 to the pr.\r
+!\r
+MODULE ksbin1_aux_mod\r
+  interface foo\r
+    module procedure j\r
+  end interface\r
+  interface bar\r
+    module procedure k\r
+  end interface\r
+  interface foobar\r
+    module procedure j, k\r
+  end interface\r
+  CONTAINS\r
+    FUNCTION j () \r
+    j = 1\r
+    return\r
+    ENTRY k (i) \r
+    k = 2\r
+    END FUNCTION j\r
+END MODULE ksbin1_aux_mod\r
+\r
+    use ksbin1_aux_mod\r
+    if (any ((/foo (), bar (99), foobar (), foobar (99), j (), k (99)/) .ne. &\r
+             (/1, 2, 1, 2, 1, 2/))) Call abort ()\r
+end\r