match.c (gfc_match_return): Only require space after keyword when it is obligatory.
authorTobias Schlüter <tobi@gcc.gnu.org>
Mon, 9 May 2005 18:26:20 +0000 (20:26 +0200)
committerTobias Schlüter <tobi@gcc.gnu.org>
Mon, 9 May 2005 18:26:20 +0000 (20:26 +0200)
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/ChangeLog
gcc/fortran/dump-parse-tree.c
gcc/fortran/match.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/return_1.f90 [new file with mode: 0644]

index 679729b9bf53bdeaaf3bbf6428450157558b5575..1210aabecdadfaa71dce76945e085eaf9585bbf3 100644 (file)
@@ -1,3 +1,9 @@
+2005-05-09  Tobias Schl"uter  <tobias.schlueter@physik.uni-muenchen.de>
+
+       * 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.
+
 2005-05-08  Kazu Hirata  <kazu@cs.umass.edu>
 
        * intrinsic.texi: Fix typos.
index 61e55685a02667514b084d7b0183ce96d8442bf3..70f91e4a52826e2197c74bdc3ff901fda408abf7 100644 (file)
@@ -665,7 +665,12 @@ gfc_show_symbol (gfc_symbol * sym)
       gfc_status ("Formal arglist:");
 
       for (formal = sym->formal; formal; formal = formal->next)
-       gfc_status (" %s", formal->sym->name);
+        {
+          if (formal->sym != NULL)
+            gfc_status (" %s", formal->sym->name);
+          else
+            gfc_status (" [Alt Return]");
+        }
     }
 
   if (sym->formal_ns)
index d81686bb134ee3066412c4cc8cad730de46e965a..741e1a306070ebb6933346102112b04e97566e5e 100644 (file)
@@ -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;
 
index 67d948a842524eba468bb6a34597de24c7651abb..4bd364585bfb258e437a9e0575a942bd1710d22e 100644 (file)
@@ -1,4 +1,8 @@
-2005-05-06  J"orn Rennecke <joern.rennecke@st.com>
+2005-05-09  Tobias Schl"uter  <tobias.schlueter@physik.uni-muenchen.de>
+
+       * gfortran.dg/return_1.f90: New test.
+
+2005-05-09  J"orn Rennecke  <joern.rennecke@st.com>
 
        * gcc.dg/pr15784-3.c: Add -fno-finite-math-only option.
 
diff --git a/gcc/testsuite/gfortran.dg/return_1.f90 b/gcc/testsuite/gfortran.dg/return_1.f90
new file mode 100644 (file)
index 0000000..1358af2
--- /dev/null
@@ -0,0 +1,6 @@
+! { dg-do compile }
+! Test cases where no blank is required after RETURN
+subroutine sub(*)
+return(1)
+return1 ! { dg-error }
+end subroutine