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