This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Pathch, fortran] PR35474 - [4.3/4.4 regression] Reading module file with COMMON and EQUIVALENCE

:ADDPATCH fortran:

This bug turned up in the compilation of hdf and so is rather urgent.
It appears around the time of my patch for PR32103.  Reverting that by
hand does not fix the problem, however:(  Anyway, it turns out to be
easily fixable, as the enclosed patch shows.

Since all the symbols in the module, in the testcase, are private,
there is no symtree for them, until the equivalence is built.  Thus,
the pointer to 'i', from the head of the common block is added to the
fixup list on the pointer_info structure for 'i'.  The moment that
this symbol is built, the fixups can be resolved and does not leave
them unrequited for the clean up phase.  The testcase is the

Regtested on amd64/Cygwin_NT - OK for trunk?


2008-03-09  Paul Thomas  <>

	PR fortran/35474
	* module.c (mio_symtree_ref): After providing a symbol for a
	missing euivalence member, resolve and NULL the fixups.

2008-03-09  Paul Thomas  <>

	PR fortran/35474
	* gfortran.dg/module_commons_2.f90

The knack of flying is learning how to throw yourself at the ground and miss.
       --Hitchhikers Guide to the Galaxy
Index: gcc/fortran/module.c
--- gcc/fortran/module.c	(revision 133050)
+++ gcc/fortran/module.c	(working copy)
@@ -2310,6 +2310,12 @@
 	  p->u.rsym.symtree->n.sym = p->u.rsym.sym;
 	  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)
Index: gcc/testsuite/gfortran.dg/module_commons_2.f90
--- gcc/testsuite/gfortran.dg/module_commons_2.f90	(revision 0)
+++ gcc/testsuite/gfortran.dg/module_commons_2.f90	(revision 0)
@@ -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
+! { dg-final { cleanup-modules "h5global" } }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]