Merged r157653 through r157895 into branch.
[official-gcc.git] / gcc / testsuite / gfortran.dg / read_eof_8.f90
blob7436a2b1b6d9ea6ea4638f0c80be72d71ead3552
1 ! { dg-do run }
2 ! PR43265: See comment #26 in the PR. Before patch,
3 ! the test case would fail to read the last line of the file.
4 ! Thanks to Jean-Baptiste Faure for providing the initial test case.
5 program test
6 character (len=6) :: line
7 integer :: n, k=0
8 open(unit=25,file="test.dat",status="replace", &
9 & form="unformatted", access="stream")
10 write(25) "Line 1" // char(10)
11 write(25) "Line 2" // char(10)
12 write(25) "Line 3" // char(10)
13 write(25) "Line 4" // char(10)
14 write(25) "Line 5" ! No EOR marker on the last line.
15 close(25, status="keep")
16 open(25, file="test.dat", status="old")
17 do n=1,10
18 read(25,'(a)',end=100,err=101) line
19 k = k+1
20 enddo
21 call abort
22 100 if (k /= 5) call abort
23 stop
24 101 call abort
25 end program test