OSDN Git Service

2010-03-10 Jerry DeLisle <jvdelisle@gcc.gnu.org>
authorjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 11 Mar 2010 02:26:36 +0000 (02:26 +0000)
committerjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 11 Mar 2010 02:26:36 +0000 (02:26 +0000)
PR libfortran/43320
PR libfortran/43265
* gfortran.dg/read_eof_6.f: New test
* gfortran.dg/read_x_eof.f90: Update test.
* gfortran.dg/read_x_past.f: Update test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@157378 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/read_eof_6.f [new file with mode: 0644]
gcc/testsuite/gfortran.dg/read_x_eof.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/read_x_past.f

index ebabe97..75a85ee 100644 (file)
@@ -1,3 +1,11 @@
+2010-03-10  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
+
+       PR libfortran/43320
+       PR libfortran/43265
+       * gfortran.dg/read_eof_6.f: New test
+       * gfortran.dg/read_x_eof.f90: Update test.
+       * gfortran.dg/read_x_past.f: Update test.
+
 2010-03-10  Jan Hubicka   <jh@suse.cz>
 
        * gcc.dg/compile/pr43288.c: New test.
diff --git a/gcc/testsuite/gfortran.dg/read_eof_6.f b/gcc/testsuite/gfortran.dg/read_eof_6.f
new file mode 100644 (file)
index 0000000..d407748
--- /dev/null
@@ -0,0 +1,7 @@
+! { dg-do run }
+! PR43320 Missing EOF on read from empty file.
+      open(8,status='scratch',form='formatted')  ! Create empty file
+      read(8,'(a80)', end=123)  ! Reading from an empty file should be an EOF
+      call abort
+123   continue
+      end
diff --git a/gcc/testsuite/gfortran.dg/read_x_eof.f90 b/gcc/testsuite/gfortran.dg/read_x_eof.f90
new file mode 100644 (file)
index 0000000..f79f785
--- /dev/null
@@ -0,0 +1,16 @@
+! { dg-do run }
+! PR43265 No EOF condition if reading with '(x)' from an empty file
+! Test case from the reporter.
+program pr43265
+implicit none
+integer::i
+open(23,status="scratch")
+write(23,'(a)') "Line 1"
+write(23,'(a)') "Line 2"
+write(23,'(a)') "Line 3"
+rewind(23)
+do i=1,10
+  read(23,'(1x)',end=12)
+enddo
+12 if (i.ne.4) call abort
+end
index 3d6b012..eee68d3 100644 (file)
@@ -2,6 +2,7 @@
 ! { dg-options -w }
 ! PR 26661 : Test reading X's past file end with no LF or CR.
 ! PR 26880 : Tests that rewind clears the gfc_unit read_bad flag.
+! PR 43265 : Tests that no error occurs with or without X at end.
 ! Contributed by Jerry DeLisle <jvdelisle@gcc.gnu.org>.
       implicit none
       character(3) a(4)
  10   format(A,$)  ! This is not pedantic
       write(10,10)' abc def ghi jkl'
       rewind(10)
+
+      a = ""
       read(10,20)(a(i),i=1,4)
       if (a(4).ne."jkl") call abort()
+
+      rewind(10)
+
+      a = ""
+      read(10,30)(a(i),i=1,4)
+      if (a(4).ne."jkl") call abort()
+
  20   format(1x,a3,1x,a3,1x,a3,1x,a3,10x)
+ 30   format(1x,a3,1x,a3,1x,a3,1x,a3)
       close(10)
       end