When I compile the following file with the snapshot of July 24, 2010: MODULE GA_commons INTEGER :: nichflg(2) END MODULE GA_commons PROGRAM gafortran USE GA_commons NAMELIST /ga/ nichflg READ (23, nml=ga) END PROGRAM gafortran I get the following message: g.f90: In function gafortran: g.f90:7:0: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions.
Confirmed. Works with -fno-whole-file.
This patchlet at least works for the reduce test case. Assuming there is nothing left to translate. I am not sure this is the right approach, bu the -fdump-tree-original matches for with and without -fno-whole-file. Index: trans-io.c =================================================================== --- trans-io.c (revision 162507) +++ trans-io.c (working copy) @@ -1499,6 +1499,9 @@ gcc_assert (sym || c); + if (base_addr == NULL) + return; + /* Build the namelist object name. */ string = gfc_build_cstring_const (var_name);
The patchlet also works for the full-size problem (Ga170.f90 from Alan Miller's ga.zip)
Naturally the patch in #2 breaks everything else for namelists at run time unless I messed up something else here.
At runtime it produces the message: At line 1200 of file ga170.f90 (unit = 23, file = 'ga.inp') Fortran runtime error: Missing format for FORMATTED data transfer
Here is another possibility. Only one namelist regression with this on. Index: trans-io.c =================================================================== --- trans-io.c (revision 162507) +++ trans-io.c (working copy) @@ -1759,8 +1759,11 @@ build_dt (tree function, gfc_code * code) dt_parm = var; for (nml = dt->namelist->namelist; nml; nml = nml->next) - transfer_namelist_element (&block, nml->sym->name, nml->sym, - NULL, NULL); + { + if (nml->sym->backend_decl) + transfer_namelist_element (&block, nml->sym->name, nml->sym, + NULL, NULL); + } } else set_parameter_const (&block, var, IOPARM_common_flags, mask);
It compiles but doesn't run, as with your Comment #2 patch
(In reply to comment #2) > --- trans-io.c (revision 162507) > +++ trans-io.c (working copy) > + if (base_addr == NULL) > + return; > + This does not make sense if you call transfer_namelist_element in build_dt with the arguments: transfer_namelist_element (&block, nml->sym->name, nml->sym, NULL, NULL); The last argument is "tree base_addr". (By the way, I think that should be NULL_TREE and not NULL.) Besides, the issue seems to be rather: dt = TREE_TYPE ((sym) ? sym->backend_decl : c->backend_decl); dtype = gfc_get_dtype (dt); which makes more sense in terms of fwhole-file; the problem is that sym->backend_decl = NULL. It seems as if the following patch fixes this. With -fno-whole-file the sym->backend_decl is set and one returns the decl. With -fwhole-file only the decl was returned. I wonder how many other issues this patch fixes. Note: I tested it for the example in comment 0, but I have not yet tested it against gfortran's test suite. Index: trans-io.c =================================================================== --- trans-io.c (revision 162526) +++ trans-io.c (working copy) @@ -1760,7 +1760,7 @@ build_dt (tree function, gfc_code * code for (nml = dt->namelist->namelist; nml; nml = nml->next) transfer_namelist_element (&block, nml->sym->name, nml->sym, - NULL, NULL); + NULL, NULL_TREE); } else set_parameter_const (&block, var, IOPARM_common_flags, mask); Index: trans-decl.c =================================================================== --- trans-decl.c (revision 162526) +++ trans-decl.c (working copy) @@ -1150,7 +1150,8 @@ gfc_get_symbol_decl (gfc_symbol * sym) true); if (sym->ts.type == BT_CHARACTER) sym->ts.u.cl->backend_decl = s->ts.u.cl->backend_decl; - return s->backend_decl; + sym->backend_decl = s->backend_decl; + return sym->backend_decl; } } }
Subject: Bug 45066 Author: burnus Date: Mon Jul 26 10:30:45 2010 New Revision: 162532 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=162532 Log: 2010-07-26 Tobias Burnus <burnus@net-b.de> PR fortran/45066 * trans-io.c (build_dt): Use NULL_TREE rather than NULL for call to transfer_namelist_element. * trans-decl.c (gfc_get_symbol_decl): Also set sym->backend_decl for -fwhole-file. 2010-07-26 Tobias Burnus <burnus@net-b.de> PR fortran/45066 * gfortran.dg/namelist_62.f90: New. Added: trunk/gcc/testsuite/gfortran.dg/namelist_62.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/trans-decl.c trunk/gcc/fortran/trans-io.c trunk/gcc/testsuite/ChangeLog
(In reply to comment #8) > I wonder how many other issues this patch fixes. Seemingly none of those -fwhole-file/-fwhole-program issues which I wanted to see fixed :-( Well, at least this PR is now FIXED. Thanks for the bug report! (As with all -fwhole-file patches: I think I won't backport them to 4.5. Howvever, if someone wants to do it, feel free to do so.)