+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>
* trans-intrinsic.c (gfc_conv_intrinsic_function_args): Adjust
return ST_FUNCTION;
else if (m == MATCH_ERROR)
reject_statement ();
-
- gfc_undo_symbols ();
+ else
+ gfc_undo_symbols ();
gfc_current_locus = old_locus;
}
static void
parse_contained (int module)
{
- gfc_namespace *ns, *parent_ns;
+ gfc_namespace *ns, *parent_ns, *tmp;
gfc_state_data s1, s2;
gfc_statement st;
gfc_symbol *sym;
gfc_entry_list *el;
int contains_statements = 0;
+ int seen_error = 0;
push_state (&s1, COMP_CONTAINS, NULL);
parent_ns = gfc_current_ns;
gfc_current_ns->sibling = parent_ns->contained;
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 ();
switch (st)
gfc_error ("Unexpected %s statement in CONTAINS section at %C",
gfc_ascii_statement (st));
reject_statement ();
+ seen_error = 1;
+ goto next;
break;
}
}
/* The first namespace in the list is guaranteed to not have
anything (worthwhile) in it. */
-
+ tmp = gfc_current_ns;
gfc_current_ns = parent_ns;
+ if (seen_error && tmp->refs > 1)
+ gfc_free_namespace (tmp);
ns = gfc_current_ns->contained;
gfc_current_ns->contained = ns->sibling;