PR middle-end/77674
[official-gcc.git] / gcc / testsuite / gfortran.dg / read_eof_all.f90
blobdb6def48716a76e062befa06f9686fd242c98ca7
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 = ''
10 open(99,file='test.dat',access='stream',form='unformatted', status='replace')
11 write(99) ' '
12 close(99)
14 open(99,file='test.dat')
15 read(99, '(T7,i2)') i
16 close(99, status="delete")
17 if (i /= 0) call abort
19 read(str(1:0), '(T7,i1)') i
20 if (i /= 0) call abort
22 read(str,'(i2,/,i2)',end=111) a, b
23 call abort !stop 'ERROR: Expected EOF error (1)'
24 111 continue
26 read(str2,'(i2,/,i2)',end=112) a, b
28 read(str2,'(i2,/,i2,/,i2)',end=113) a, b, c
29 call abort !stop 'ERROR: Expected EOF error (2)'
31 112 call abort !stop 'ERROR: Unexpected EOF (3)'
33 113 continue
34 read(str,'(i2,/,i2)',end=121,pad='no') a, b
35 call abort !stop 'ERROR: Expected EOF error (1)'
36 121 continue
38 read(str2(:),'(i2,/,i2)', end=122, pad='no') a, b
39 goto 125
40 122 call abort !stop 'ERROR: Expected no EOF error (2)'
41 125 continue
43 read(str2(:),'(i2,/,i2,/,i2)',end=123,pad='no') a, b, c
44 call abort !stop 'ERROR: Expected EOF error (3)'
45 123 continue
47 read(str(2:1),'(i2,/,i2)',end=131, pad='no') a, b
48 call abort !stop 'ERROR: Expected EOF error (1)'
49 131 continue
51 read(str2(:)(2:1),'(i2,/,i2)',end=132, pad='no') a, b
52 call abort !stop 'ERROR: Expected EOF error (2)'
53 132 continue
55 read(str2(:)(2:1),'(i2,/,i2,/,i2)',end=133,pad='no') a, b, c
56 call abort !stop 'ERROR: Expected EOF error (3)'
57 133 continue
59 read(str(2:1),'(i2,/,i2)',iostat=ios, pad='no') a, b
60 if (ios /= IOSTAT_END) call abort !stop 'ERROR: expected iostat /= 0 (1)'
62 read(str2(:)(2:1),'(i2,/,i2)',iostat=ios, pad='no') a, b
63 if (ios /= IOSTAT_END) call abort !stop 'ERROR: expected iostat /= 0 (2)'
65 read(str2(:)(2:1),'(i2,/,i2,/,i2)',iostat=ios,pad='no') a, b, c
66 if (ios /= IOSTAT_END) call abort !stop 'ERROR: expected iostat /= 0 (2)'
68 ! print *, "success"
69 end