re PR fortran/16861 ([4.0 only] segfault with doubly used module)

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-18  Paul Thomas  <pault@gcc.gnu.org>

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

From-SVN: r104388
This commit is contained in:
Paul Thomas 2005-09-18 05:18:54 +00:00
parent b695055179
commit 6cda231ed9
4 changed files with 58 additions and 6 deletions

View 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

View 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);

View 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

View File

@ -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