PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gfortran.dg / read_no_eor.f90
bloba313e3051949cf827d2ce1a2e2d67dc9d6dfac7a
1 ! { dg-do run }
2 ! Handle eor and eof conditions with missing eor in file.
3 ! Test case modified from case presented by Ian Harvey on clf.
4 program eieio_stat
5 use, intrinsic :: iso_fortran_env, only: iostat_end, iostat_eor
6 implicit none
7 integer, parameter :: unit=10
8 integer :: ios1, ios2, ios3
9 character(25) :: buffer
10 character(100) :: themessage
11 !****
12 open(10,file="eieio", form="unformatted", access="stream", status="replace")
13 write(10) "Line-1" // char(10)
14 write(10) "Line-2"
15 close(10)
17 open(10,file="eieio")
19 buffer = 'abcdefg'
20 read (unit,"(a)",advance="no",iostat=ios1, pad="yes") buffer
21 if (ios1 /= iostat_eor .and. buffer /= "Line-1") STOP 1
23 buffer = '<'
24 read (unit,"(a)",advance="no",iostat=ios2,pad="yes") buffer
25 if (ios2 /= iostat_eor .and. buffer /= "Line-2") STOP 2
27 buffer = '5678'
28 read (unit,"(a)",advance="no",iostat=ios3, iomsg=themessage) buffer
29 if (ios3 /= iostat_end .and. buffer /= "5678") STOP 3
31 rewind(10)
33 buffer = "abcdefg"
34 read (unit,"(a)",advance="no",iostat=ios1, pad="no") buffer
35 if (ios1 /= iostat_eor .and. buffer /= "abcdefg") STOP 4
37 buffer = '<'
38 read (unit,"(a)",advance="no",iostat=ios2,pad="no") buffer
39 if (ios2 /= iostat_eor .and. buffer /= "<") STOP 5
41 buffer = '1234'
42 read (unit,"(a)",advance="no",iostat=ios3, iomsg=themessage) buffer
43 if (ios3 <= 0 .and. buffer /= "1234") STOP 6
45 close(unit, status="delete")
46 end program eieio_stat