diff options
Diffstat (limited to 'gcc/fortran/match.c')
-rw-r--r-- | gcc/fortran/match.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index d81686b..741e1a3 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -1983,12 +1983,7 @@ gfc_match_return (void) gfc_expr *e; match m; gfc_compile_state s; - - gfc_enclosing_unit (&s); - if (s == COMP_PROGRAM - && gfc_notify_std (GFC_STD_GNU, "Extension: RETURN statement in " - "main program at %C") == FAILURE) - return MATCH_ERROR; + int c; e = NULL; if (gfc_match_eos () == MATCH_YES) @@ -2001,7 +1996,18 @@ gfc_match_return (void) goto cleanup; } - m = gfc_match ("% %e%t", &e); + if (gfc_current_form == FORM_FREE) + { + /* The following are valid, so we can't require a blank after the + RETURN keyword: + return+1 + return(1) */ + c = gfc_peek_char (); + if (ISALPHA (c) || ISDIGIT (c)) + return MATCH_NO; + } + + m = gfc_match (" %e%t", &e); if (m == MATCH_YES) goto done; if (m == MATCH_ERROR) @@ -2014,6 +2020,12 @@ cleanup: return MATCH_ERROR; done: + gfc_enclosing_unit (&s); + if (s == COMP_PROGRAM + && gfc_notify_std (GFC_STD_GNU, "Extension: RETURN statement in " + "main program at %C") == FAILURE) + return MATCH_ERROR; + new_st.op = EXEC_RETURN; new_st.expr = e; |