Commit de893677 by Jerry DeLisle

re PR fortran/18923 (segfault after subroutine name confusion)

2007-06-05  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/18923
	* parse.c (decode_statement): Don't call gfc_undo_symbols on MATCH_ERROR
	for ST_FUNCTION since it is called in reject_statement.
	(parse_contained): If error, loop back after reject_statement and try
	again.  Free the namespace if an error occured.

From-SVN: r125342
parent 52ff33d0
2007-06-05 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/18923
* parse.c (decode_statement): Don't call gfc_undo_symbols on MATCH_ERROR
for ST_FUNCTION since it is called in reject_statement.
(parse_contained): If error, loop back after reject_statement and try
again. Free the namespace if an error occured.
2007-06-04 Lee Millward <lee.millward@codesourcery.com> 2007-06-04 Lee Millward <lee.millward@codesourcery.com>
* trans-intrinsic.c (gfc_conv_intrinsic_function_args): Adjust * trans-intrinsic.c (gfc_conv_intrinsic_function_args): Adjust
......
...@@ -117,8 +117,8 @@ decode_statement (void) ...@@ -117,8 +117,8 @@ decode_statement (void)
return ST_FUNCTION; return ST_FUNCTION;
else if (m == MATCH_ERROR) else if (m == MATCH_ERROR)
reject_statement (); reject_statement ();
else
gfc_undo_symbols (); gfc_undo_symbols ();
gfc_current_locus = old_locus; gfc_current_locus = old_locus;
} }
...@@ -2775,12 +2775,13 @@ gfc_fixup_sibling_symbols (gfc_symbol *sym, gfc_namespace *siblings) ...@@ -2775,12 +2775,13 @@ gfc_fixup_sibling_symbols (gfc_symbol *sym, gfc_namespace *siblings)
static void static void
parse_contained (int module) parse_contained (int module)
{ {
gfc_namespace *ns, *parent_ns; gfc_namespace *ns, *parent_ns, *tmp;
gfc_state_data s1, s2; gfc_state_data s1, s2;
gfc_statement st; gfc_statement st;
gfc_symbol *sym; gfc_symbol *sym;
gfc_entry_list *el; gfc_entry_list *el;
int contains_statements = 0; int contains_statements = 0;
int seen_error = 0;
push_state (&s1, COMP_CONTAINS, NULL); push_state (&s1, COMP_CONTAINS, NULL);
parent_ns = gfc_current_ns; parent_ns = gfc_current_ns;
...@@ -2792,6 +2793,9 @@ parse_contained (int module) ...@@ -2792,6 +2793,9 @@ parse_contained (int module)
gfc_current_ns->sibling = parent_ns->contained; gfc_current_ns->sibling = parent_ns->contained;
parent_ns->contained = gfc_current_ns; parent_ns->contained = gfc_current_ns;
next:
/* Process the next available statement. We come here if we got an error
and rejected the last statement. */
st = next_statement (); st = next_statement ();
switch (st) switch (st)
...@@ -2867,6 +2871,8 @@ parse_contained (int module) ...@@ -2867,6 +2871,8 @@ parse_contained (int module)
gfc_error ("Unexpected %s statement in CONTAINS section at %C", gfc_error ("Unexpected %s statement in CONTAINS section at %C",
gfc_ascii_statement (st)); gfc_ascii_statement (st));
reject_statement (); reject_statement ();
seen_error = 1;
goto next;
break; break;
} }
} }
...@@ -2875,8 +2881,10 @@ parse_contained (int module) ...@@ -2875,8 +2881,10 @@ parse_contained (int module)
/* The first namespace in the list is guaranteed to not have /* The first namespace in the list is guaranteed to not have
anything (worthwhile) in it. */ anything (worthwhile) in it. */
tmp = gfc_current_ns;
gfc_current_ns = parent_ns; gfc_current_ns = parent_ns;
if (seen_error && tmp->refs > 1)
gfc_free_namespace (tmp);
ns = gfc_current_ns->contained; ns = gfc_current_ns->contained;
gfc_current_ns->contained = ns->sibling; gfc_current_ns->contained = ns->sibling;
......
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