Merge from mainline.
[official-gcc.git] / gcc / testsuite / gfortran.dg / read_eof_3.f90
blob5cca802c2a66f90d47b5ba5d7044347060cfbc3f
1 ! { dg-do run }
2 ! PR25835 Check that reading from a file that is at end-of-file does not
3 ! segfault or give error. Test case derived from example in PR from Dale Ranta.
4 ! Contributed by Jerry DeLisle <jvdelisle@gcc.gnu.org>
5 integer data(5000)
6 data=-256
7 open(unit=11,status='scratch', form='unformatted')
8 write(11)data
9 write(11)data
10 read(11,end= 1000 )data
11 call abort()
12 1000 continue
13 backspace 11
14 rewind 11
15 write(11)data
16 read(11,end= 1001 )data
17 call abort()
18 1001 continue
19 data = 0
20 backspace 11
21 rewind 11
22 read(11,end= 1002 )data
23 if (.not. all(data == -256)) call abort()
24 1002 continue
25 read(11,end= 1003 )data
26 call abort()
27 1003 continue
28 close(11)
29 end