PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gfortran.dg / read_4.f90
blob7229bebcf5795ae4610fc3dee5cec955422dcdf9
1 ! { dg-do run }
2 ! PR80741 wrong code causes incorrect behaviour of namelist READ
3 program p
4 use, intrinsic :: iso_fortran_env, only: iostat_end
5 implicit none
6 integer :: x, y, ios, io
7 character(10) :: line
8 namelist /test/ x, y
10 x = 10
11 y = 10
12 ios = 0
13 io = 10
14 open(unit=io, status='scratch')
15 write(io, test)
16 write(io, *) 'done'
17 rewind(io)
18 x = 0
19 y = 0
20 read(io, test)
21 if (x.ne.10 .or. y.ne.10) STOP 1
23 read(io, *) line
24 if (line.ne.'done') STOP 2
26 read(io, *, iostat=ios) line
27 if (ios/=iostat_end) STOP 3
28 rewind(io)
29 x = 0
30 y = 0
31 read(io, test)
32 if (x.ne.10 .or. y.ne.10) STOP 4
33 read(io, *, iostat=ios) line
34 if (line.ne.'done') STOP 5
35 end