This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch,gfortran] PR 24245: ICE with -fdump-parse-tree
- From: Steven Bosscher <stevenb at suse dot de>
- To: fortran at gcc dot gnu dot org
- Cc: Erik Edelmann <erik dot edelmann at iki dot fi>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 29 Oct 2005 19:42:50 +0200
- Subject: Re: [patch,gfortran] PR 24245: ICE with -fdump-parse-tree
- References: <20051011221034.GA23777@acclab.helsinki.fi>
:REVIEWMAIL:
On Wednesday 12 October 2005 00:10, Erik Edelmann wrote:
> 2005-10-12 Erik Edelmann <erik.edelmann@iki.fi>
>
> PR 24245
> * trans.c (gfc_generate_code): Move code to create a main
> program symbol from here ...
> * parse.c (main_program_symbol): ... to here (new function).
> (accept_statement): Call main_program_symbol from here ...
> (gfc_parse_file): ... and here.
This is not yet OK.
When I wrote this (sorry I broke something with it too ;-) I had this code
here because I knew that we would have parsed some statements already:
+ /* Set the location to the first line of code. */
+ if (ns->code)
+ main_program->declared_at = ns->code->loc;
+ ns->proc_name = main_program;
But in your case, I think ns->code is always NULL, so you're not getting
the declared_at right here. And I wasn't getting it right for an empty
main program. This code was only there because I had no other locus to
work with ;-)
IIUC you add the symbol at parse time, so you can use gfc_current_locus
instead of my hack.
Also, you seem to be calling main_program_symbol twice for the same main
program: Once from accept_statement, and once from gfc_parse_file. It
would be better to only call it from gfc_parse_file. One call can go in
under "case ST_PROGRAM:" and the other one under "default:", which is
where we end up for unnamed main programs. The call from accept_statement
should go away.
Thanks for looking at this bug.
Gr.
Steven