This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] fortran/66039 -- Check for mangled file positioning
- From: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- To: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Fri, 15 May 2015 07:55:12 -0700
- Subject: [PATCH] fortran/66039 -- Check for mangled file positioning
- Authentication-results: sourceware.org; auth=none
The attached patch checks for mangled/incomplete
file positioning statements. Regression tested
on trunk with no new failures? OK to commit
2015-05-XX Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/66039
* io.c (match_filepos): Check for incomplete/mangled REWIND, FLUSH,
BACKSPACE, and ENDFILE statements
2015-05-XX Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/66039
* gfortran.dg/filepos1.f90: New test
--
Steve
Index: gcc/fortran/io.c
===================================================================
--- gcc/fortran/io.c (revision 223094)
+++ gcc/fortran/io.c (working copy)
@@ -2382,9 +2382,7 @@ match_filepos (gfc_statement st, gfc_exe
if (m == MATCH_NO)
{
m = gfc_match_expr (&fp->unit);
- if (m == MATCH_ERROR)
- goto done;
- if (m == MATCH_NO)
+ if (m == MATCH_ERROR || m == MATCH_NO)
goto syntax;
}
Index: gcc/testsuite/gfortran.dg/filepos1.f90
===================================================================
--- gcc/testsuite/gfortran.dg/filepos1.f90 (revision 0)
+++ gcc/testsuite/gfortran.dg/filepos1.f90 (working copy)
@@ -0,0 +1,25 @@
+! { dg-do compile }
+! PR fortran/66039
+!
+! Original code from Gerhard Steinmetz
+! <gerhard dot steinmetz dot fortran at t-online dot de>
+subroutine p1
+ rewind (( ! { dg-error "Syntax error in REWIND" }
+ rewind (- ! { dg-error "Syntax error in REWIND" }
+end subroutine p1
+
+subroutine p2
+ flush (( ! { dg-error "Syntax error in FLUSH" }
+ flush (- ! { dg-error "Syntax error in FLUSH" }
+end subroutine p2
+
+subroutine p4
+ backspace (( ! { dg-error "Syntax error in BACKSPACE" }
+ backspace (- ! { dg-error "Syntax error in BACKSPACE" }
+end subroutine p4
+
+subroutine p3
+ endfile (( ! { dg-error "Expecting END SUBROUTINE" }
+ endfile (- ! { dg-error "Expecting END SUBROUTINE" }
+end subroutine p3
+