public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, Fortran, 4.8/4.9/5 Regression] PR59513 READ or WRITE not allowed after EOF
@ 2015-03-20 22:24 Jerry DeLisle
  2015-03-22 15:47 ` Janne Blomqvist
  0 siblings, 1 reply; 5+ messages in thread
From: Jerry DeLisle @ 2015-03-20 22:24 UTC (permalink / raw)
  To: gfortran; +Cc: gcc patches

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

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.

[-- Attachment #2: pr59513.diff --]
[-- Type: text/x-patch, Size: 1244 bytes --]

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
 

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

* Re: [Patch, Fortran, 4.8/4.9/5 Regression] PR59513 READ or WRITE not allowed after EOF
  2015-03-20 22:24 [Patch, Fortran, 4.8/4.9/5 Regression] PR59513 READ or WRITE not allowed after EOF Jerry DeLisle
@ 2015-03-22 15:47 ` Janne Blomqvist
  2015-03-22 18:47   ` Jerry DeLisle
  2015-03-22 21:05   ` Jerry DeLisle
  0 siblings, 2 replies; 5+ messages in thread
From: Janne Blomqvist @ 2015-03-22 15:47 UTC (permalink / raw)
  To: Jerry DeLisle; +Cc: gfortran, gcc patches

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.


-- 
Janne Blomqvist

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

* Re: [Patch, Fortran, 4.8/4.9/5 Regression] PR59513 READ or WRITE not allowed after EOF
  2015-03-22 15:47 ` Janne Blomqvist
@ 2015-03-22 18:47   ` Jerry DeLisle
  2015-03-22 21:05   ` Jerry DeLisle
  1 sibling, 0 replies; 5+ messages in thread
From: Jerry DeLisle @ 2015-03-22 18:47 UTC (permalink / raw)
  To: Janne Blomqvist; +Cc: gfortran, gcc patches

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

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

* Re: [Patch, Fortran, 4.8/4.9/5 Regression] PR59513 READ or WRITE not allowed after EOF
  2015-03-22 15:47 ` Janne Blomqvist
  2015-03-22 18:47   ` Jerry DeLisle
@ 2015-03-22 21:05   ` Jerry DeLisle
  1 sibling, 0 replies; 5+ messages in thread
From: Jerry DeLisle @ 2015-03-22 21:05 UTC (permalink / raw)
  To: Janne Blomqvist; +Cc: gfortran, gcc patches

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

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.
>
>

The attached patch adds documentation under 'extensions' in gfortran.texi.

Tested with make html.

I will commit soon with a ChangeLog entry

Regards,

Jerry

[-- Attachment #2: gfctexi.diff --]
[-- Type: text/x-patch, Size: 1181 bytes --]

Index: gfortran.texi
===================================================================
--- gfortran.texi	(revision 221544)
+++ gfortran.texi	(working copy)
@@ -1404,6 +1404,7 @@ without warning.
 * OpenMP::
 * OpenACC::
 * Argument list functions::
+* Read/Write after EOF marker::
 @end menu
 
 @node Old-style kind specifications
@@ -2049,7 +2050,19 @@ For details refer to the g77 manual
 Also, @code{c_by_val.f} and its partner @code{c_by_val.c} of the
 GNU Fortran testsuite are worth a look.
 
+@node Read/Write after EOF marker
+@subsection Read/Write after EOF marker
+@cindex @code{EOF}
+@cindex @code{BACKSPACE}
+@cindex @code{REWIND}
 
+Some legacy codes rely on allowing @code{READ} or @code{WRITE} after the
+EOF file marker in order to find the end of a file. GNU Fortran normally
+rejects these codes with a run-time error message and suggests the user
+consider @code{BACKSPACE} or @code{REWIND} to properly position
+the file before the EOF marker.  As an extension, the run-time error may
+be disabled using -std=legacy.
+
 @node Extensions not implemented in GNU Fortran
 @section Extensions not implemented in GNU Fortran
 @cindex extensions, not implemented

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

* Re: [Patch, Fortran, 4.8/4.9/5 Regression] PR59513 READ or WRITE not allowed after EOF
@ 2015-03-22 14:06 Dominique Dhumieres
  0 siblings, 0 replies; 5+ messages in thread
From: Dominique Dhumieres @ 2015-03-22 14:06 UTC (permalink / raw)
  To: jvdelisle; +Cc: gcc-patches, fortran

Dear Jerry,

IMO the patch is in the obvious range, but needs to document the extension and may be
a test case.

Cheers,

Dominique

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

end of thread, other threads:[~2015-03-22 21:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-20 22:24 [Patch, Fortran, 4.8/4.9/5 Regression] PR59513 READ or WRITE not allowed after EOF Jerry DeLisle
2015-03-22 15:47 ` Janne Blomqvist
2015-03-22 18:47   ` Jerry DeLisle
2015-03-22 21:05   ` Jerry DeLisle
2015-03-22 14:06 Dominique Dhumieres

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).