+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
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;
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;
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);
--- /dev/null
+! { 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
+