PR ipa/83051
[official-gcc.git] / gcc / testsuite / gfortran.dg / read_4.f90
blob7a835b124af42bc67a2b44367b6779843b9a4030
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) call abort
23 read(io, *) line
24 if (line.ne.'done') call abort
26 read(io, *, iostat=ios) line
27 if (ios/=iostat_end) call abort
28 rewind(io)
29 x = 0
30 y = 0
31 read(io, test)
32 if (x.ne.10 .or. y.ne.10) call abort
33 read(io, *, iostat=ios) line
34 if (line.ne.'done') call abort
35 end