[gfortran] Re: PR14066 Allow infinite loops with label-do-stmt

Tobias Schlüter tobias.schlueter@physik.uni-muenchen.de
Mon May 10 15:44:00 GMT 2004


This is an updated patch which fixes another bug in the DO matcher. We 
would give a syntax error in free-form code like this:
   DO 10,i=1,10
because we would excpect an obligatory space after the comma. Bug found 
when trying to compile the abinit package.

The appended patch fixes this and includes the previous patch for 
PR14066. Additionally, I have attached an updated testcase which 
verifies this new fix.

- Tobi

2004-05-10  Tobias Schlüter <tobias.schlueter@physik.uni-muenchen.de>

     PR fortran/14066
     * match.c (gfc_match_do): Allow infinite loops with
     label-do-stmt. Do not enforce space after comma.

Index: match.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/fortran/Attic/match.c,v
retrieving revision 1.1.2.8
diff -u -p -r1.1.2.8 match.c
--- match.c     11 Jan 2004 15:21:50 -0000      1.1.2.8
+++ match.c     10 May 2004 15:29:40 -0000
@@ -1202,6 +1211,10 @@ gfc_match_do (void)
    if (gfc_match (" do") != MATCH_YES)
      return MATCH_NO;

+  m = gfc_match_st_label (&label, 0);
+  if (m == MATCH_ERROR)
+    goto cleanup;
+
  /* Match an infinite DO, make it like a DO WHILE(.TRUE.) */

    if (gfc_match_eos () == MATCH_YES)
@@ -1211,13 +1224,9 @@ gfc_match_do (void)
        goto done;
      }

-  m = gfc_match_st_label (&label, 0);
-  if (m == MATCH_ERROR)
-    goto cleanup;
-
-  gfc_match_char (',');
-
-  if (gfc_match ("% ") != MATCH_YES)
+  /* match an optional comma, if no comma is found a space is 
obligatory.  */
+  if (gfc_match_char(',') != MATCH_YES
+      && gfc_match ("% ") != MATCH_YES)
      return MATCH_NO;

    /* See if we have a DO WHILE.  */
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: do.f90
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20040510/c3b7a911/attachment.f90>


More information about the Fortran mailing list