public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch, libfortran] Bug 65596 - [4.9,5.0 Regression] NAMELIST bug with f2003: reads too far
@ 2015-03-28  1:18 Jerry DeLisle
  0 siblings, 0 replies; only message in thread
From: Jerry DeLisle @ 2015-03-28  1:18 UTC (permalink / raw)
  To: gfortran; +Cc: gcc patches

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

At first glance this looked like only a regression in 4.9.  While searching for 
the regression I noticed an error in unit.c (probably a copy/paste error). Upon 
correcting that obvious error, the regression found in 4.9 also appeared in 5.0.

The fix is simple and obvious and I have regression tested on 4.9 and 5.0.

I will commit in the next few days, giving others a chance to review.

New test case attached. I used STOP rather than abort just to change things up a 
bit if the case fails. (yes I could have used -fall-intrinsics)

Regards

Jerry

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

	PR libgfortran/65596
	* io/transfer.c (data_transfer_init): If in namelist mode and
	delimiter is not specified, set it to DELIM_QUOTE, independent
	of -std.
	* io/unit.c (init_units): Set flags.delim to the correct
	initial value of DELIM_UNSPECIFIED.




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

Index: io/transfer.c
===================================================================
--- io/transfer.c	(revision 221744)
+++ io/transfer.c	(working copy)
@@ -2675,8 +2675,7 @@ data_transfer_init (st_parameter_dt *dtp, int read
   if (dtp->u.p.current_unit->delim_status == DELIM_UNSPECIFIED)
     {
       if (ionml && dtp->u.p.current_unit->flags.delim == DELIM_UNSPECIFIED)
-	dtp->u.p.current_unit->delim_status =
-	  compile_options.allow_std & GFC_STD_GNU ? DELIM_QUOTE : DELIM_NONE;
+	dtp->u.p.current_unit->delim_status = DELIM_QUOTE;
       else
 	dtp->u.p.current_unit->delim_status = dtp->u.p.current_unit->flags.delim;
     }
Index: io/unit.c
===================================================================
--- io/unit.c	(revision 221744)
+++ io/unit.c	(working copy)
@@ -608,7 +608,7 @@ init_units (void)
       u->flags.position = POSITION_ASIS;
       u->flags.sign = SIGN_SUPPRESS;
       u->flags.decimal = DECIMAL_POINT;
-      u->flags.delim = DECIMAL_UNSPECIFIED;
+      u->flags.delim = DELIM_UNSPECIFIED;
       u->flags.encoding = ENCODING_DEFAULT;
       u->flags.async = ASYNC_NO;
       u->flags.round = ROUND_UNSPECIFIED;

[-- Attachment #3: pr65596.f90 --]
[-- Type: text/x-fortran, Size: 997 bytes --]

! { dg-do run }
! { dg-options "-std=f2003 -fall-intrinsics" }
! PR65596 Namelist reads too far.
integer ,parameter :: CL=80
integer ,parameter :: AL=4

character(CL) :: mode
character(CL) :: cats(AL)
character(CL) :: dogs(AL)
character(CL) :: rslt(AL)
integer       :: ierr, k

namelist / theList / cats, dogs, mode

open(27,status="scratch")

write(27,'(A)')  "&theList"
write(27,'(A)')  " mode      = 'on'"
write(27,'(A)')  " dogs      = 'Rover',"
write(27,'(A)')  "             'Spot'"
write(27,'(A)')  " cats      = 'Fluffy',"
write(27,'(A)')  "             'Hairball'"
write(27,'(A)') "/"
rewind(27)

mode    = 'off'
cats(:) = '________'
dogs(:) = '________'

read (27, nml=theList, iostat=ierr)

if (ierr .ne. 0) call abort

rslt = ['Rover   ','Spot    ','________','________']
if (any(dogs.ne.rslt)) call abort

rslt = ['Fluffy  ','Hairball','________','________']
if (any(cats.ne.rslt)) call abort

close(27)

contains

subroutine abort()
  close(27)
  stop 500
end subroutine abort

end

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-03-28  1:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-28  1:18 [patch, libfortran] Bug 65596 - [4.9,5.0 Regression] NAMELIST bug with f2003: reads too far Jerry DeLisle

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