111
|
1 ! { dg-do run }
|
|
2 ! PR43265 Followup patch for miscellaneous EOF conditions.
|
|
3 ! Eaxamples from Tobius Burnus
|
|
4 use iso_fortran_env
|
|
5 character(len=2) :: str, str2(2)
|
|
6 integer :: a, b, c, ios
|
|
7 str = ''
|
|
8 str2 = ''
|
|
9
|
|
10 open(99,file='test.dat',access='stream',form='unformatted', status='replace')
|
|
11 write(99) ' '
|
|
12 close(99)
|
|
13
|
|
14 open(99,file='test.dat')
|
|
15 read(99, '(T7,i2)') i
|
|
16 close(99, status="delete")
|
131
|
17 if (i /= 0) STOP 1
|
111
|
18
|
|
19 read(str(1:0), '(T7,i1)') i
|
131
|
20 if (i /= 0) STOP 2
|
111
|
21
|
|
22 read(str,'(i2,/,i2)',end=111) a, b
|
131
|
23 STOP 3!stop 'ERROR: Expected EOF error (1)'
|
111
|
24 111 continue
|
|
25
|
|
26 read(str2,'(i2,/,i2)',end=112) a, b
|
|
27
|
|
28 read(str2,'(i2,/,i2,/,i2)',end=113) a, b, c
|
131
|
29 STOP 4!stop 'ERROR: Expected EOF error (2)'
|
111
|
30
|
131
|
31 112 STOP 5!stop 'ERROR: Unexpected EOF (3)'
|
111
|
32
|
|
33 113 continue
|
|
34 read(str,'(i2,/,i2)',end=121,pad='no') a, b
|
131
|
35 STOP 6!stop 'ERROR: Expected EOF error (1)'
|
111
|
36 121 continue
|
|
37
|
|
38 read(str2(:),'(i2,/,i2)', end=122, pad='no') a, b
|
|
39 goto 125
|
131
|
40 122 STOP 7!stop 'ERROR: Expected no EOF error (2)'
|
111
|
41 125 continue
|
|
42
|
|
43 read(str2(:),'(i2,/,i2,/,i2)',end=123,pad='no') a, b, c
|
131
|
44 STOP 8!stop 'ERROR: Expected EOF error (3)'
|
111
|
45 123 continue
|
|
46
|
|
47 read(str(2:1),'(i2,/,i2)',end=131, pad='no') a, b
|
131
|
48 STOP 9!stop 'ERROR: Expected EOF error (1)'
|
111
|
49 131 continue
|
|
50
|
|
51 read(str2(:)(2:1),'(i2,/,i2)',end=132, pad='no') a, b
|
131
|
52 STOP 10!stop 'ERROR: Expected EOF error (2)'
|
111
|
53 132 continue
|
|
54
|
|
55 read(str2(:)(2:1),'(i2,/,i2,/,i2)',end=133,pad='no') a, b, c
|
131
|
56 STOP 11!stop 'ERROR: Expected EOF error (3)'
|
111
|
57 133 continue
|
|
58
|
|
59 read(str(2:1),'(i2,/,i2)',iostat=ios, pad='no') a, b
|
131
|
60 if (ios /= IOSTAT_END) STOP 12!stop 'ERROR: expected iostat /= 0 (1)'
|
111
|
61
|
|
62 read(str2(:)(2:1),'(i2,/,i2)',iostat=ios, pad='no') a, b
|
131
|
63 if (ios /= IOSTAT_END) STOP 13!stop 'ERROR: expected iostat /= 0 (2)'
|
111
|
64
|
|
65 read(str2(:)(2:1),'(i2,/,i2,/,i2)',iostat=ios,pad='no') a, b, c
|
131
|
66 if (ios /= IOSTAT_END) STOP 14!stop 'ERROR: expected iostat /= 0 (2)'
|
111
|
67
|
|
68 ! print *, "success"
|
|
69 end
|
|
70
|
|
71
|