This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gfortran] Fix PR17708: Fix jumps to END DO label
- 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>,patch <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 28 Sep 2004 18:44:11 +0200
- Subject: [gfortran] Fix PR17708: Fix jumps to END DO label
END DO is different from END IF and END SELECT in that, if it is the target of
a branch execution remains within the construct it encloses, i.e. the loop
should continue looping. We treated it the same as END IF and END SELECT,
thereby creating the breakage reported in the PR. The attached simple patch
fixes this by generating the label within the loop, instead of behind it. We
now also correctly warn about the use of this obsolescent feature.
Built and tested. New testcase attached.
- Tobi
Index: parse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/parse.c,v
retrieving revision 1.19
diff -u -p -r1.19 parse.c
--- parse.c 15 Sep 2004 14:19:12 -0000 1.19
+++ parse.c 28 Sep 2004 16:37:28 -0000
@@ -1033,7 +1033,6 @@ accept_statement (gfc_statement st)
construct. */
case ST_ENDIF:
- case ST_ENDDO:
case ST_END_SELECT:
if (gfc_statement_label != NULL)
{
@@ -2003,7 +2002,13 @@ loop:
&& s.ext.end_do_label != gfc_statement_label)
gfc_error_now
("Statement label in ENDDO at %C doesn't match DO label");
- /* Fall through */
+
+ if (gfc_statement_label != NULL)
+ {
+ new_st.op = EXEC_NOP;
+ add_statement ();
+ }
+ break;
case ST_IMPLIED_ENDDO:
break;
! { dg-do run }
program test
j = 0
do 10 i=1,3
if(i == 2) goto 10 ! { dg-warning "" "" }
j = j+1
10 enddo
if (j/=2) call abort
end