public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, Fortran] PR56696 - Fix EOF detection for listed-directed real_read
@ 2013-03-23 14:01 Tobias Burnus
  2013-03-23 21:48 ` Janne Blomqvist
  0 siblings, 1 reply; 2+ messages in thread
From: Tobias Burnus @ 2013-03-23 14:01 UTC (permalink / raw)
  To: gcc patches, gfortran

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

This patch fixes the 4.8/4.9 regression, reported by Keith Refson.

The patch which caused the regression (PR55818, Rev. 194809) allowed to 
list-direct read "1<EOF>" as real variable. Seemingly, the handling went 
to far to also affect reading a real from "<EOF>".

I am not completely sure whether the patch is correct, but I think it 
is. I tried character, complex and integer, but those are seemingly not 
affected from the regression.

OK for the trunk and the 4.8 branch?

Tobias

[-- Attachment #2: eof-fix.diff --]
[-- Type: text/x-patch, Size: 1473 bytes --]

2013-03-23  Tobias Burnus  <burnus@net-b.de>

	PR fortran/56696
	* io/list_read.c (read_real): Fix EOF diagnostic.

2013-03-23  Tobias Burnus  <burnus@net-b.de>

	PR fortran/56696
	* gfortran.dg/eof_5.f90: New.

diff --git a/libgfortran/io/list_read.c b/libgfortran/io/list_read.c
index aa7c8c0..ec45570 100644
--- a/libgfortran/io/list_read.c
+++ b/libgfortran/io/list_read.c
@@ -1423,27 +1423,26 @@ read_real (st_parameter_dt *dtp, void * dest, int length)
       push_char (dtp, c);
       break;
 
     case '.':
       push_char (dtp, c);
       seen_dp = 1;
       break;
 
     case '+':
     case '-':
       goto got_sign;
 
     CASE_SEPARATORS:
-    case EOF:
       unget_char (dtp, c);		/* Single null.  */
       eat_separator (dtp);
       return;
 
     case 'i':
     case 'I':
     case 'n':
     case 'N':
       goto inf_nan;
 
     default:
       goto bad_real;
     }

--- /dev/null	2013-03-23 13:45:03.324112203 +0100
+++ gcc/gcc/testsuite/gfortran.dg/eof_5.f90	2013-03-23 14:55:47.783990895 +0100
@@ -0,0 +1,21 @@
+! { dg-do run }
+!
+! PR fortran/56696
+!
+! Contributed by Keith Refson
+!
+
+program iotest
+   character(len=258) :: inp = ' 1.0 1.0 1.0'
+   character(len=7) :: inp2 = '1 2 3 4'
+   integer :: ios
+   real :: a1, a2, a3, a4
+
+   read(inp2,*,iostat=ios) a1, a2, a3, a4
+   if (ios /= 0) call abort ()
+
+   read(inp,*,iostat=ios) a1, a2, a3, a4
+   if (ios == 0) call abort ()
+!   write(*,*) 'IOSTAT=',ios
+end program iotest
+

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

* Re: [Patch, Fortran] PR56696 - Fix EOF detection for listed-directed real_read
  2013-03-23 14:01 [Patch, Fortran] PR56696 - Fix EOF detection for listed-directed real_read Tobias Burnus
@ 2013-03-23 21:48 ` Janne Blomqvist
  0 siblings, 0 replies; 2+ messages in thread
From: Janne Blomqvist @ 2013-03-23 21:48 UTC (permalink / raw)
  To: Tobias Burnus; +Cc: gcc patches, gfortran

On Sat, Mar 23, 2013 at 4:00 PM, Tobias Burnus <burnus@net-b.de> wrote:
> This patch fixes the 4.8/4.9 regression, reported by Keith Refson.
>
> The patch which caused the regression (PR55818, Rev. 194809) allowed to
> list-direct read "1<EOF>" as real variable. Seemingly, the handling went to
> far to also affect reading a real from "<EOF>".
>
> I am not completely sure whether the patch is correct, but I think it is. I
> tried character, complex and integer, but those are seemingly not affected
> from the regression.
>
> OK for the trunk and the 4.8 branch?

Ok, thanks for the patch, and to Keith as well for reporting and the testcase.

-- 
Janne Blomqvist

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

end of thread, other threads:[~2013-03-23 21:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-23 14:01 [Patch, Fortran] PR56696 - Fix EOF detection for listed-directed real_read Tobias Burnus
2013-03-23 21:48 ` Janne Blomqvist

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