re PR libfortran/18778 (ENDFILE is not functionnal)
authorBud Davis <bdavis9659@comcast.net>
Sun, 16 Jan 2005 20:44:01 +0000 (20:44 +0000)
committerBud Davis <bdavis@gcc.gnu.org>
Sun, 16 Jan 2005 20:44:01 +0000 (20:44 +0000)
2005-01-16  Bud Davis  <bdavis9659@comcast.net>

        PR fortran/18778
        * gfortran.dg/endfile_2.f90: New test.

        * io/transfer.c (us_read): no bytes available is not a
        runtime error.

From-SVN: r93737

gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/endfile_2.f90 [new file with mode: 0644]
libgfortran/ChangeLog
libgfortran/io/transfer.c

index ba894d9..b7a5f61 100644 (file)
@@ -1,3 +1,8 @@
+2005-01-16  Bud Davis  <bdavis9659@comcast.net>
+
+       PR fortran/18778
+       * gfortran.dg/endfile_2.f90: New test.
+
 2005-01-16  Steven G. Kargl  <kargls@comcast.net>
 
        PR 19168
diff --git a/gcc/testsuite/gfortran.dg/endfile_2.f90 b/gcc/testsuite/gfortran.dg/endfile_2.f90
new file mode 100644 (file)
index 0000000..7f366f1
--- /dev/null
@@ -0,0 +1,12 @@
+! { dg-do run }
+! pr18778 abort on endfile without opening unit 
+      program test
+      implicit none
+      integer i
+      endfile(8)
+      rewind(8)
+      read(8,end=0023)i
+      call abort ! should never get here
+      stop
+ 0023 continue
+      end
index c0534b8..d6bcb8d 100644 (file)
@@ -1,3 +1,9 @@
+2004-01-16  Bud Davis  <bdavis9659@comcast.net>
+
+       PR fortran/18778
+       * io/transfer.c (us_read): no bytes available is not a
+       runtime error.
+
 2005-01-15  Bud Davis  <bdavis9659@comcast.net>
 
        PR fortran/18983
index 5454407..73ae853 100644 (file)
@@ -843,6 +843,9 @@ us_read (void)
   n = sizeof (gfc_offset);
   p = salloc_r (current_unit->s, &n);
 
+  if (n == 0)
+    return;  /* end of file */
+
   if (p == NULL || n != sizeof (gfc_offset))
     {
       generate_error (ERROR_BAD_US, NULL);