Merge from mainline.
[official-gcc.git] / gcc / testsuite / gfortran.dg / append-1.f90
blob8b81bc38484de3fe92405913fe6cddf04dda94d7
1 ! PR libfortran/21471
2 ! Testing POSITION="APPEND"
4 ! { dg-do run }
5 subroutine failed
6 close (10,status='delete')
7 call abort
8 end subroutine failed
10 integer,parameter :: n = 13
11 integer :: i, j, error
13 open (10, file='foo')
14 close (10)
16 do i = 1, n
17 open (10, file='foo',position='append')
18 write (10,*) i
19 close (10)
20 end do
22 open (10,file='foo',status='old')
23 error = 0
24 i = -1
25 do while (error == 0)
26 i = i + 1
27 read (10,*,iostat=error) j
28 if (error == 0) then
29 if (i + 1 /= j) call failed
30 end if
31 if (i > n + 1) call failed
32 end do
33 if (i /= n) call failed
34 close (10,status='delete')
35 end