diff options
author | Thomas Koenig <Thomas.Koenig@online.de> | 2006-12-06 19:25:44 +0000 |
---|---|---|
committer | Thomas Koenig <tkoenig@gcc.gnu.org> | 2006-12-06 19:25:44 +0000 |
commit | b4c811bd14e0b3ea5a995b711aae60ee1d3daaab (patch) | |
tree | ca8a396e07dee2ad42be8eab7d5520d8281b63b1 /gcc | |
parent | 0307c64eea66674bd3dd9a42fed80cf748e2acf8 (diff) | |
download | gcc-b4c811bd14e0b3ea5a995b711aae60ee1d3daaab.zip gcc-b4c811bd14e0b3ea5a995b711aae60ee1d3daaab.tar.gz gcc-b4c811bd14e0b3ea5a995b711aae60ee1d3daaab.tar.bz2 |
re PR libfortran/30009 ([4.1 only] Unformatted reads exceeding storage units gives EOF instead of ERR)
2006-12-06 Thomas Koenig <Thomas.Koenig@online.de>
PR libfortran/30009
PR libfortran/30056
* gfortran.dg/read_eof_4.f90: Add tests.
* gfortran.dg/readwrite_unf_direct_eor_1.f90: New test.
* gfortran.dg/unf_read_corrupted_1.f90: New test.
2006-12-06 Thomas Koenig <Thomas.Koenig@online.de>
PR libfortran/30009
PR libfortran/30056
* libgfortran.h: Add ERROR_CORRUPT_FILE to error_codes.
* runtime/error.c (translate_error): Add handling for
ERROR_CORRUPT_FILE.
* io/transfer.c (read_block_direct): Add comment about
EOR for stream files.
Remove test for no bytes left for direct access files.
Generate an ERROR_SHORT_RECORD if the read was short.
For unformatted sequential files: Check endfile condition.
Remove test for no bytes left. End of file here means
that the file structure has been corrupted. Pre-position
the file for the next record in case of error.
(write_buf): Whitespace fix. Subtract the number of bytes
written from bytes_left.
From-SVN: r119592
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/read_eof_4.f90 | 28 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/readwrite_unf_direct_eor_1.f90 | 13 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/unf_read_corrupted_1.f90 | 27 |
4 files changed, 69 insertions, 7 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 089232f..58837bc 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2006-12-06 Thomas Koenig <Thomas.Koenig@online.de> + + PR libfortran/30009 + PR libfortran/30056 + * gfortran.dg/read_eof_4.f90: Add tests. + * gfortran.dg/readwrite_unf_direct_eor_1.f90: New test. + * gfortran.dg/unf_read_corrupted_1.f90: New test. + 2006-12-05 Mark Mitchell <mark@codesourcery.com> PR c++/29729 diff --git a/gcc/testsuite/gfortran.dg/read_eof_4.f90 b/gcc/testsuite/gfortran.dg/read_eof_4.f90 index b8ca5a7..ee95268 100644 --- a/gcc/testsuite/gfortran.dg/read_eof_4.f90 +++ b/gcc/testsuite/gfortran.dg/read_eof_4.f90 @@ -1,16 +1,30 @@ ! { dg-do run } -! PR 27575 : This test checks the error checking for end of file condition. +! PR 27575 and PR 30009: This test checks the error checking for end +! of file condition. ! Derived from test case in PR. -! Submitted by Jerry DeLisle <jvdelisle@verizon.net>. +! Submitted by Jerry DeLisle <jvdelisle@verizon.net>, modified by +! Thomas Koenig <Thomas.Koenig@online.de> + program test integer i1,i2,i3 open(unit=11,form='unformatted') - write(11)i1, i2 + write (11) 1, 2 + write (11) 3, 4 close(11,status='keep') + open(unit=11,form='unformatted') - read(11, eND=100) i1, i2, i3 + + read(11, ERR=100) i1, i2, i3 call abort() - 100 read(11, end=110) i3 - call abort() - 110 close(11,status='delete') + 100 continue + if (i1 /= 1 .or. i2 /= 2) call abort + + read(11, ERR=110) i1, i2, i3 + call abort() + 110 continue + if (i1 /= 3 .or. i2 /= 4) call abort + + read(11, end=120) i3 + call abort() + 120 close(11,status='delete') end diff --git a/gcc/testsuite/gfortran.dg/readwrite_unf_direct_eor_1.f90 b/gcc/testsuite/gfortran.dg/readwrite_unf_direct_eor_1.f90 new file mode 100644 index 0000000..2c19eba --- /dev/null +++ b/gcc/testsuite/gfortran.dg/readwrite_unf_direct_eor_1.f90 @@ -0,0 +1,13 @@ +! { dg-do run } +! PR 30056 - exceeding the record length was misrepresented as an EOF +! on read and ignored on write + program main + integer i,j + open (10, form="unformatted", access="direct", recl=4) + write (10, rec=1, err=10) 1,2 + call abort() + 10 continue + read (10, rec=1, err=20) i, j + call abort() + 20 continue + end diff --git a/gcc/testsuite/gfortran.dg/unf_read_corrupted_1.f90 b/gcc/testsuite/gfortran.dg/unf_read_corrupted_1.f90 new file mode 100644 index 0000000..166d529 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/unf_read_corrupted_1.f90 @@ -0,0 +1,27 @@ +! { dg-do run } +! Test the error message when an unformatted file has become +! corrupted. +program main + implicit none + integer :: i1, i2 + integer :: ios + character(len=50) :: msg + + ! Write out a truncated unformatted sequential file by + ! using unformatted stream. + + open (10, form="unformatted", access="stream", file="foo.dat", & + status="unknown") + write (10) 16, 1 + close (10, status="keep") + + ! Try to read + open (10, file="foo.dat", form="unformatted", access="sequential") + i1 = 0 + i2 = 0 + read (10, iostat=ios, iomsg=msg) i1, i2 + if (ios == 0) call abort + if (i1 /= 1) call abort + if (msg /= "Unformatted file structure has been corrupted") call abort + close (10, status="delete") +end program main |