diff mbox

[Fortran,4.8/4.9/5,Regression] PR59513 READ or WRITE not allowed after EOF

Message ID 550C9E2A.2060501@charter.net
State New
Headers show

Commit Message

Jerry DeLisle March 20, 2015, 10:24 p.m. UTC
The attached patch allows the attempt to READ or WRITE after an EOF for legacy 
code.  The runtime error is suppressed for -std=legacy and -std=gnu. For 
standard conformance the error is retained as is now.

Regression tested on x86-64.  Test case endfile_3.f90 is updated by the patch.

OK for trunk and then 4.9, 4.8?

Regards,

Jerry

2015-03-20 Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/59513
	* io/transfer.c (data_transfer_init): Only error if -std=f95 or
	higher.

Comments

Janne Blomqvist March 22, 2015, 3:47 p.m. UTC | #1
On Sat, Mar 21, 2015 at 12:24 AM, Jerry DeLisle <jvdelisle@charter.net> wrote:
> The attached patch allows the attempt to READ or WRITE after an EOF for
> legacy code.  The runtime error is suppressed for -std=legacy and -std=gnu.
> For standard conformance the error is retained as is now.

Since it's a standard violation rather than a GNU extension, I'd
prefer if it were enabled only with -std=legacy.

Ok with this change.
Jerry DeLisle March 22, 2015, 6:47 p.m. UTC | #2
On 03/22/2015 08:47 AM, Janne Blomqvist wrote:
> On Sat, Mar 21, 2015 at 12:24 AM, Jerry DeLisle <jvdelisle@charter.net> wrote:
>> The attached patch allows the attempt to READ or WRITE after an EOF for
>> legacy code.  The runtime error is suppressed for -std=legacy and -std=gnu.
>> For standard conformance the error is retained as is now.
>
> Since it's a standard violation rather than a GNU extension, I'd
> prefer if it were enabled only with -std=legacy.
>
> Ok with this change.
>
>

Done.  No need for new test case, it is covered by endfile_3.f90 as is.

Sending        ChangeLog
Sending        io/transfer.c
Transmitting file data ..
Committed revision 221572.

Thanks and best regards,

Jerry
diff mbox

Patch

Index: libgfortran/io/transfer.c
===================================================================
--- libgfortran/io/transfer.c	(revision 221543)
+++ libgfortran/io/transfer.c	(working copy)
@@ -2533,7 +2533,8 @@  data_transfer_init (st_parameter_dt *dtp, int read
 	  return;
 	}
 
-      if (dtp->u.p.current_unit->endfile == AFTER_ENDFILE)
+      if (!(compile_options.allow_std & GFC_STD_GNU) &&
+	  dtp->u.p.current_unit->endfile == AFTER_ENDFILE)
       	{
 	  generate_error (&dtp->common, LIBERROR_OPTION_CONFLICT,
 			"Sequential READ or WRITE not allowed after "
Index: gcc/testsuite/gfortran.dg/endfile_3.f90
===================================================================
--- gcc/testsuite/gfortran.dg/endfile_3.f90	(revision 221473)
+++ gcc/testsuite/gfortran.dg/endfile_3.f90	(working copy)
@@ -1,9 +1,10 @@ 
 ! { dg-do run { target fd_truncate } }
+! { dg-options -std=f95 }
 ! pr44477 READ/WRITE not allowed after ENDFILE 
 !-------------------------------------------
   open(10, form='formatted', &
     action='write', position='rewind', status="scratch")
   endfile(10)
-  write(10,'(a)') "aa" ! { dg-shouldfail "Cannot perform ENDFILE" }
+  write(10,'(a)')"aa"! { dg-shouldfail "not allowed after EOF marker" }
 end