From aec78e730e868938b44e1c73eb248595a6a97fd9 Mon Sep 17 00:00:00 2001 From: Paul Thomas Date: Mon, 29 Jan 2007 10:27:50 +0000 Subject: [PATCH] re PR fortran/30554 ([4.1 only] ICE in mio_pointer_ref at module.c:1945) 2007-01-29 Paul Thomas PR fortran/30554 * module.c (read_module): If a symbol is excluded by an ONLY clause, check to see if there is a symtree already loaded. If so, attach the symtree to the pointer_info. 2007-01-29 Paul Thomas PR fortran/30554 * gfortran.dg/used_dummy_types_6.f90: New test. From-SVN: r121281 --- gcc/fortran/ChangeLog | 7 ++++++ gcc/fortran/module.c | 13 +++++++--- gcc/testsuite/ChangeLog | 5 ++++ .../gfortran.dg/used_dummy_types_6.f90 | 25 +++++++++++++++++++ 4 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/used_dummy_types_6.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 12287bf57833..1ff3a6042869 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2007-01-29 Paul Thomas + + PR fortran/30554 + * module.c (read_module): If a symbol is excluded by an ONLY + clause, check to see if there is a symtree already loaded. If + so, attach the symtree to the pointer_info. + 2007-01-28 Thomas Koenig PR libfortran/30389 diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c index 1eed5e777bf8..e76bd0e92db4 100644 --- a/gcc/fortran/module.c +++ b/gcc/fortran/module.c @@ -3394,15 +3394,22 @@ read_module (void) /* Get the jth local name for this symbol. */ p = find_use_name_n (name, &j); - /* Skip symtree nodes not in an ONLY clause. */ + /* Skip symtree nodes not in an ONLY clause, unless there + is an existing symtree loaded from another USE + statement. */ if (p == NULL) - continue; + { + st = gfc_find_symtree (gfc_current_ns->sym_root, name); + if (st != NULL) + info->u.rsym.symtree = st; + continue; + } - /* Check for ambiguous symbols. */ st = gfc_find_symtree (gfc_current_ns->sym_root, p); if (st != NULL) { + /* Check for ambiguous symbols. */ if (st->n.sym != info->u.rsym.sym) st->ambiguous = 1; info->u.rsym.symtree = st; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4482ad8e3d9a..66501a914bce 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-01-29 Paul Thomas + + PR fortran/30554 + * gfortran.dg/used_dummy_types_6.f90: New test. + 2007-01-28 Jan Hubicka * gcc.dg/tree-prof/val-prof-6.c: New test. diff --git a/gcc/testsuite/gfortran.dg/used_dummy_types_6.f90 b/gcc/testsuite/gfortran.dg/used_dummy_types_6.f90 new file mode 100644 index 000000000000..bcee65ac3198 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/used_dummy_types_6.f90 @@ -0,0 +1,25 @@ +! { dg-do compile } +! Tests the fix for PR30554, the USE statements in potential_energy +! would cause a segfault because the pointer_info for nfree coming +! from constraint would not find the existing symtree coming directly +! from atom. +! +! Contributed by Tobias Burnus + +MODULE ATOMS +INTEGER :: NFREE = 0 +END MODULE ATOMS + +MODULE CONSTRAINT +USE ATOMS, ONLY: NFREE +CONTAINS + SUBROUTINE ENERGY_CONSTRAINT ( HESSIAN ) + REAL , DIMENSION(1:(3*NFREE*(3*NFREE+1))/2):: HESSIAN + END SUBROUTINE ENERGY_CONSTRAINT +END MODULE CONSTRAINT + +MODULE POTENTIAL_ENERGY +USE ATOMS +USE CONSTRAINT, ONLY : ENERGY_CONSTRAINT +END MODULE POTENTIAL_ENERGY +! { dg-final { cleanup-modules "atoms constraint potential_energy" } }