This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch, libgfortran] PR39528 [4.0/4.1/4.2/4.3/4.4 Regression] repeated entries using list-directed input


All,

This patch is fairly straight forward. It fixes the problem by checking for repeated values before checking for completion of the read.

Regression tested on x86-64-linux-gnu. Test case attached.

OK for trunk and fortran-dev branch? Backport to 4.3?

Regards,

Jerry

2009-03-23 Jerry DeLisle <jvdelisle@gcc.gnu.org>

	PR libfortran/39528
	* io/list_read.c (list_formatted_read_scalar): Move check for read
	completion to just after the check for a repeated value.

Index: list_read.c
===================================================================
--- list_read.c	(revision 144999)
+++ list_read.c	(working copy)
@@ -1723,9 +1723,6 @@ list_formatted_read_scalar (st_parameter
     }
   else
     {
-      if (dtp->u.p.input_complete)
-	goto cleanup;
-
       if (dtp->u.p.repeat_count > 0)
 	{
 	  if (check_type (dtp, type, kind))
@@ -1733,6 +1730,9 @@ list_formatted_read_scalar (st_parameter
 	  goto set_value;
 	}

+      if (dtp->u.p.input_complete)
+	goto cleanup;
+
       if (dtp->u.p.at_eol)
 	finish_separator (dtp);
       else
! { dg-do run }
! PR39528 repeated entries not read when using list-directed input.
! Test case derived from reporters example.
program rread
  implicit none
  integer :: iarr(1:7), ia, ib, i

  iarr = 0
  
  write(10,*) " 2*1  3*2 /"
  write(10,*) " 12"
  write(10,*) " 13"
  rewind(10)

  read(10,*) (iarr(i), i=1,7)
  read(10,*) ia, ib

  if (any(iarr(1:2).ne.1)) call abort
  if (any(iarr(3:5).ne.2)) call abort
  if (any(iarr(6:7).ne.0)) call abort
  if (ia .ne. 12 .or. ib .ne. 13) call abort
  
  close(10, status="delete")
end program rread

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]