Fix compilation failure with C++98 compilers
[official-gcc.git] / gcc / testsuite / gfortran.dg / io_constraints_2.f90
blobe0e0db633243441683395ee9ab460beec9269fcb
1 ! { dg-do compile }
2 ! { dg-options "-std=f95" }
3 ! Part II of the test of the IO constraints patch, which fixes PRs:
4 ! PRs 25053, 25063, 25064, 25066, 25067, 25068, 25069, 25307 and 20862.
5 ! Modified2006-07-08 to check the patch for PR20844.
7 ! Contributed by Paul Thomas <pault@gcc.gnu.org>
10 module global
12 integer :: modvar
13 namelist /NL/ modvar
15 contains
17 subroutine foo (i)
18 integer :: i
19 write (*, 100) i
20 100 format (1h , "i=", i6) ! { dg-warning "H format specifier" }
21 end subroutine foo
23 end module global
25 use global
26 integer :: a,b, c(20)
27 integer(8) :: ierr
28 character(80) :: buffer(3)
31 ! Appending to a USE associated namelist is an extension.
33 NAMELIST /NL/ a,b ! { dg-error "already is USE associated" }
35 a=1 ; b=2
37 write(*, NML=NL) z ! { dg-error "followed by IO-list" }
38 !Was correctly picked up before patch.
39 print NL, z ! { dg-error "PRINT namelist at \\(1\\) is an extension" }
41 ! Not allowed with internal unit
42 !Was correctly picked up before patch.
43 write(buffer, NML=NL) ! { dg-error "Internal file at \\(1\\) with namelist" }
44 !Was correctly picked up before patch.
45 write(buffer, fmt='(i6)', REC=10) a ! { dg-error "REC tag" }
46 write(buffer, fmt='(i6)', END=10) a ! { dg-error "END tag" }
48 ! Not allowed with REC= specifier
49 !Was correctly picked up before patch.
50 read(10, REC=10, END=100) ! { dg-error "END tag is not allowed" }
51 write(*, *, REC=10) ! { dg-error "FMT=" }
53 ! Not allowed with an ADVANCE=specifier
54 READ(buffer, fmt='(i6)', advance='YES') a ! { dg-error "internal file" }
55 READ(1, NML=NL, advance='YES') ! { dg-error "NAMELIST IO is not allowed" }
57 READ(1, fmt='(i6)', advance='NO', size = ierr) ! { dg-error "requires default INTEGER" }
59 READ(1, advance='YES') ! { dg-error "must appear with an explicit format" }
61 write(1, fmt='(i6)', advance='YES', size = c(1)) a ! { dg-error "output" }
62 write(1, fmt='(i6)', advance='YES', eor = 100) a ! { dg-error "output" }
64 read(1, fmt='(i6)', advance='YES', size = c(1)) a ! { dg-error "ADVANCE = 'NO'" }
65 read(1, fmt='(i6)', advance='YES', eor = 100) a ! { dg-error "ADVANCE = 'NO'" }
67 READ(1, fmt='(i6)', advance='NO', size = buffer) a ! { dg-error "INTEGER" }
68 !Was correctly picked up before patch. -correct syntax error
69 READ(1, fmt='(i6)', advance='YES', size = 10) a ! { dg-error "Invalid value for SIZE specification" }
71 READ(1, fmt='(i6)', advance='MAYBE') ! { dg-error "YES or NO" }
73 100 continue
74 200 format (2i6)
75 END