From 81c109530cdca59546cf13346588e5a8e48ec074 Mon Sep 17 00:00:00 2001 From: Paul Thomas Date: Sun, 9 Mar 2008 19:38:51 +0000 Subject: [PATCH] re PR fortran/35474 (Reading module file with COMMON and EQUIVALENCE) 2008-03-09 Paul Thomas PR fortran/35474 * module.c (mio_symtree_ref): After providing a symbol for a missing equivalence member, resolve and NULL the fixups. 2008-03-09 Paul Thomas PR fortran/35474 * gfortran.dg/module_commons_2.f90 : New test. From-SVN: r133063 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/module.c | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ .../gfortran.dg/module_commons_2.f90 | 21 +++++++++++++++++++ 4 files changed, 38 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/module_commons_2.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 72bf5129c44..e660d9cd8ff 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2008-03-09 Paul Thomas + + PR fortran/35474 + * module.c (mio_symtree_ref): After providing a symbol for a + missing equivalence member, resolve and NULL the fixups. + 2008-03-09 Ralf Wildenhues * invoke.texi (Error and Warning Options): Document diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c index e9303a4f367..bc45e9eb9c1 100644 --- a/gcc/fortran/module.c +++ b/gcc/fortran/module.c @@ -2310,6 +2310,12 @@ mio_symtree_ref (gfc_symtree **stp) p->u.rsym.symtree->n.sym = p->u.rsym.sym; p->u.rsym.symtree->n.sym->refs++; p->u.rsym.referenced = 1; + + /* If the symbol is PRIVATE and in COMMON, load_commons will + generate a fixup symbol, which must be associated. */ + if (p->fixup) + resolve_fixups (p->fixup, p->u.rsym.sym); + p->fixup = NULL; } if (p->type == P_UNKNOWN) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ee2790b5141..5db13983855 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-03-09 Paul Thomas + + PR fortran/35474 + * gfortran.dg/module_commons_2.f90: New test. + 2008-03-09 Eric Botcazou * gnat.dg/frame_overflow.adb: Improve portability. diff --git a/gcc/testsuite/gfortran.dg/module_commons_2.f90 b/gcc/testsuite/gfortran.dg/module_commons_2.f90 new file mode 100644 index 00000000000..3c3214c20ff --- /dev/null +++ b/gcc/testsuite/gfortran.dg/module_commons_2.f90 @@ -0,0 +1,21 @@ +! { dg-do compile } +! Tests the fix for PR35474, in which the PRIVATE statement would +! cause the error Internal Error at (1): free_pi_tree(): Unresolved fixup +! This arose because the symbol for 'i' emanating from the COMMON was +! not being fixed-up as the EQUIVALENCE was built. +! +! Contributed by FX Coudert +! +module h5global + integer i + integer j + common /c/ i + equivalence (i, j) + private +end module h5global + +program bug + use h5global +end + +! { dg-final { cleanup-modules "h5global" } } -- 2.30.2