From 7f42f27f33ae26a2be1c45e919ff25dbc62a3b36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Schl=C3=BCter?= Date: Mon, 9 May 2005 20:26:20 +0200 Subject: match.c (gfc_match_return): Only require space after keyword when it is obligatory. fortran/ * match.c (gfc_match_return): Only require space after keyword when it is obligatory. Only give stdwarn to after matching is successful. * dump-parse-tree.c (gfc_show_symbol): Deal with alternate returns. testsuite/ * gfortran.dg/return_1.f90: New test. From-SVN: r99467 --- gcc/fortran/match.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'gcc/fortran/match.c') diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index d81686bb134..741e1a30607 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; -- cgit v1.2.1