OSDN Git Service

2005-09-18 Paul Thomas <pault@gcc.gnu.org>
authorpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 18 Sep 2005 05:18:54 +0000 (05:18 +0000)
committerpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 18 Sep 2005 05:18:54 +0000 (05:18 +0000)
PR fortran/16861
* module.c (read_module): Give symbols from module procedures
different true_name entries to those from the module proper.

2005-09-18  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/16861
* gfortran.dg/nested_modules_2.f90: New test.

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

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

index 69168e5..ca4a80d 100644 (file)
@@ -1,3 +1,9 @@
+2005-09-18  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/16861
+       * module.c (read_module): Give symbols from module procedures
+       different true_name entries to those from the module proper.
+
 2005-09-17  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
 
        PR fortran/15586
index 5117050..8f225aa 100644 (file)
@@ -3099,7 +3099,7 @@ read_module (void)
   const char *p;
   char name[GFC_MAX_SYMBOL_LEN + 1];
   gfc_intrinsic_op i;
-  int ambiguous, symbol, j, nuse;
+  int ambiguous, j, nuse, series, symbol;
   pointer_info *info;
   gfc_use_rename *u;
   gfc_symtree *st;
@@ -3142,6 +3142,14 @@ read_module (void)
          being loaded again.  */
 
       sym = find_true_name (info->u.rsym.true_name, info->u.rsym.module);
+
+      /* If a module contains subroutines with assumed shape dummy
+       arguments, the symbols for indices need to be different from
+       from those in the module proper(ns = 1).  */
+      if (sym !=NULL && info->u.rsym.ns != 1)
+       sym = find_true_name (info->u.rsym.true_name,
+               gfc_get_string ("%s@%d",module_name, series++));
+
       if (sym == NULL)
        continue;
 
@@ -3485,11 +3493,6 @@ write_symbol1 (pointer_info * p)
   if (p->type != P_SYMBOL || p->u.wsym.state != NEEDS_WRITE)
     return 0;
 
-  /* FIXME: This shouldn't be necessary, but it works around
-     deficiencies in the module loader or/and symbol handling.  */
-  if (p->u.wsym.sym->module == NULL && p->u.wsym.sym->attr.dummy)
-    p->u.wsym.sym->module = gfc_get_string (module_name);
-
   p->u.wsym.state = WRITTEN;
   write_symbol (p->integer, p->u.wsym.sym);
 
index b69d38e..c60cb55 100644 (file)
@@ -1,3 +1,8 @@
+2005-09-18  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/16861
+       * gfortran.dg/nested_modules_2.f90: New test.
+
 2005-09-17  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        PR c++/18368
diff --git a/gcc/testsuite/gfortran.dg/nested_modules_2.f90 b/gcc/testsuite/gfortran.dg/nested_modules_2.f90
new file mode 100644 (file)
index 0000000..91ab766
--- /dev/null
@@ -0,0 +1,38 @@
+! { dg do-run }
+! This tests the patch for PR16861.
+!
+! Contributed by Paul Thomas <pault@gcc.gnu.org>
+!
+module foo
+INTEGER :: i
+end module foo
+
+module bar
+contains
+subroutine sub1 (j)
+  use foo
+  integer, dimension(i) :: j
+  j = 42
+end subroutine sub1
+subroutine sub2 (k)
+  use foo
+  integer, dimension(i) :: k
+  k = 84
+end subroutine sub2
+end module bar
+
+module foobar
+  use foo                      !This used to cause an ICE
+  use bar
+end module foobar
+
+program testfoobar
+  use foobar
+  integer, dimension(3)  :: l = 0
+  i = 2
+  call sub1 (l)
+  i = 1
+  call sub2 (l)
+  if (all (l.ne.(/84,42,0/))) call abort ()
+end program testfoobar
+