Commit 6a869706 by Erik Edelmann

re PR fortran/24245 (-fdump-parse-tree gives ICE for CONTAINED functions)

fortran/
2005-11-01  Erik Edelmann  <eedelman@gcc.gnu.org>

        PR 24245
        * trans.c (gfc_generate_code): Move code to create a main
        program symbol from here ...
        * parse.c (main_program_symbol): ... to this new
        function, setting the locus from gfc_current_locus
        instead of ns->code->loc.
        (gfc_parse_file):  Call main_program_symbol for main programs.

From-SVN: r106353
parent 92119f26
2005-11-01 Erik Edelmann <eedelman@gcc.gnu.org>
PR 24245
* trans.c (gfc_generate_code): Move code to create a main
program symbol from here ...
* parse.c (main_program_symbol): ... to this new
function, setting the locus from gfc_current_locus
instead of ns->code->loc.
(gfc_parse_file): Call main_program_symbol for main programs.
2005-11-01 Tobias Schl"uter <tobias.schlueter@physik.uni-muenchen.de> 2005-11-01 Tobias Schl"uter <tobias.schlueter@physik.uni-muenchen.de>
PR fortran/24404 PR fortran/24404
......
...@@ -970,6 +970,28 @@ gfc_ascii_statement (gfc_statement st) ...@@ -970,6 +970,28 @@ gfc_ascii_statement (gfc_statement st)
} }
/* Create a symbol for the main program and assign it to ns->proc_name. */
static void
main_program_symbol (gfc_namespace * ns)
{
gfc_symbol *main_program;
symbol_attribute attr;
gfc_get_symbol ("MAIN__", ns, &main_program);
gfc_clear_attr (&attr);
attr.flavor = FL_PROCEDURE;
attr.proc = PROC_UNKNOWN;
attr.subroutine = 1;
attr.access = ACCESS_PUBLIC;
attr.is_main_program = 1;
main_program->attr = attr;
main_program->declared_at = gfc_current_locus;
ns->proc_name = main_program;
gfc_commit_symbols ();
}
/* Do whatever is necessary to accept the last statement. */ /* Do whatever is necessary to accept the last statement. */
static void static void
...@@ -2590,6 +2612,7 @@ loop: ...@@ -2590,6 +2612,7 @@ loop:
prog_locus = gfc_current_locus; prog_locus = gfc_current_locus;
push_state (&s, COMP_PROGRAM, gfc_new_block); push_state (&s, COMP_PROGRAM, gfc_new_block);
main_program_symbol(gfc_current_ns);
accept_statement (st); accept_statement (st);
add_global_program (); add_global_program ();
parse_progunit (ST_NONE); parse_progunit (ST_NONE);
...@@ -2631,6 +2654,7 @@ loop: ...@@ -2631,6 +2654,7 @@ loop:
prog_locus = gfc_current_locus; prog_locus = gfc_current_locus;
push_state (&s, COMP_PROGRAM, gfc_new_block); push_state (&s, COMP_PROGRAM, gfc_new_block);
main_program_symbol(gfc_current_ns);
parse_progunit (st); parse_progunit (st);
break; break;
} }
......
...@@ -656,30 +656,6 @@ gfc_generate_code (gfc_namespace * ns) ...@@ -656,30 +656,6 @@ gfc_generate_code (gfc_namespace * ns)
return; return;
} }
/* Main program subroutine. */
if (!ns->proc_name)
{
gfc_symbol *main_program;
symbol_attribute attr;
/* Lots of things get upset if a subroutine doesn't have a symbol, so we
make one now. Hopefully we've set all the required fields. */
gfc_get_symbol ("MAIN__", ns, &main_program);
gfc_clear_attr (&attr);
attr.flavor = FL_PROCEDURE;
attr.proc = PROC_UNKNOWN;
attr.subroutine = 1;
attr.access = ACCESS_PUBLIC;
attr.is_main_program = 1;
main_program->attr = attr;
/* Set the location to the first line of code. */
if (ns->code)
main_program->declared_at = ns->code->loc;
ns->proc_name = main_program;
gfc_commit_symbols ();
}
gfc_generate_function_code (ns); gfc_generate_function_code (ns);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment