public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] fortran/66039 -- Check for mangled file positioning
@ 2015-05-15 14:58 Steve Kargl
  2015-05-15 20:42 ` FX
  0 siblings, 1 reply; 2+ messages in thread
From: Steve Kargl @ 2015-05-15 14:58 UTC (permalink / raw)
  To: fortran, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 433 bytes --]

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

[-- Attachment #2: pr66039.diff --]
[-- Type: text/x-diff, Size: 1443 bytes --]

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
+

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] fortran/66039 -- Check for mangled file positioning
  2015-05-15 14:58 [PATCH] fortran/66039 -- Check for mangled file positioning Steve Kargl
@ 2015-05-15 20:42 ` FX
  0 siblings, 0 replies; 2+ messages in thread
From: FX @ 2015-05-15 20:42 UTC (permalink / raw)
  To: Steve Kargl; +Cc: fortran, gcc-patches

> 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

OK

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-05-15 20:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-15 14:58 [PATCH] fortran/66039 -- Check for mangled file positioning Steve Kargl
2015-05-15 20:42 ` FX

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).