This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gfortran] Re: PR14066 Allow infinite loops with label-do-stmt
- From: Tobias Schlüter <tobias dot schlueter at physik dot uni-muenchen dot de>
- To: GCC Fortran mailing list <fortran at gcc dot gnu dot org>
- Cc: patch <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 10 May 2004 17:43:50 +0200
- Subject: [gfortran] Re: PR14066 Allow infinite loops with label-do-stmt
- References: <409CD229.9030807@physik.uni-muenchen.de>
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. */
! test various forms of the DO statement
! inspired by PR14066
LOGICAL L
DO i=1,10
END DO
DO 10 i=1,20
DO 20,j=1,10,2
20 CONTINUE
10 END DO
L = .TRUE.
DO WHILE(L)
L = .FALSE.
END DO
DO 50 WHILE(.NOT.L)
L = .TRUE.
50 CONTINUE
DO
DO 30
DO 40
40 CONTINUE
30 END DO
END DO
outer: DO i=1,20
inner: DO,j=i,30
IF (j.EQ.2*i) CYCLE outer
END DO inner
END DO outer
END