OSDN Git Service

2008-03-04 Uros Bizjak <ubizjak@gmail.com>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gfortran.dg / endfile.f90
1 ! { dg-do run } 
2 ! pr18364 endfile does not truncate file.
3 !   write out 20 records
4 !   rewind
5 !   read 10 records
6 !   endfile
7 !   close file
8 !   open file
9 !   detect file has only 10 records  
10       implicit none
11       integer i,j
12       open(unit=10,file='test.dat',access='sequential',status='replace')
13       do i=1, 20
14         write (10,'(I4)') i
15       end do
16       rewind(10)
17       do i=1,10
18         read (10,'(I4)') j
19       end do
20       endfile(10)
21       close(10)
22       open(unit=10,file='test.dat',access='sequential',status='old')
23       do i=1,20 
24         read (10,'(I4)',end=99) j 
25       end do
26       ! should never get here
27       call abort
28   99  continue ! end of file
29       if (j.ne.10) call abort   
30       close(10,status='delete')
31       end