2011-05-23 Tom de Vries <tom@codesourcery.com>
[official-gcc.git] / gcc / testsuite / gfortran.dg / backspace_9.f
blob851f518a2a94dc5da9362bd02c6c56ae332fa8a1
1 ! { dg-do run }
2 ! { dg-options "-std=legacy" }
4 ! PR32235 incorrectly position text file after backspace
5 ! Test case from PR, prepared by Jerry DeLisle <jvdelisle@gcc.gnu.org>
6 program main
7 character*10 a
8 ncards=2
9 input=10
10 write(10,"(a)") "One"
11 write(10,"(a)") "Two"
12 write(10,"(a)") "Three"
13 rewind(10)
14 read(input,1000)a
15 read(input,1000)a
17 call inlist(ncards)
19 read(input,1000)a
20 if (a.ne."Three") call abort
21 close(10,status="delete")
22 stop
23 1000 format(a10)
24 2000 format('read =',a10)
25 end
27 subroutine inlist(ncards)
28 character*4 data(20)
29 input=10
31 if (ncards.eq.0) go to 20
32 do 15 i=1,ncards
33 backspace input
34 15 continue
36 20 continue
37 kard = 0
38 30 read(input,1000,end=60) data
39 40 kard=kard + 1
40 50 continue
41 if ((kard .eq. 1) .and. (DATA(1) .ne. "One")) call abort
42 if ((kard .eq. 2) .and. (DATA(1) .ne. "Two")) call abort
43 if ((kard .eq. 3) .and. (DATA(1) .ne. "Thre")) call abort
45 go to 30
46 60 continue
47 kard=kard - ncards + 1
48 do 70 i=1,kard
49 backspace input
50 70 continue
52 return
54 1000 format (20a4)
55 2020 format (8x,i15,8x,20a4)
57 end