Update concepts branch to revision 131834
[official-gcc.git] / gcc / testsuite / gfortran.dg / io_constraints_3.f90
blobae9acce67847fa15667b634ad4451123b8527c3b
1 ! Test some restrictions on the specifiers of OPEN and CLOSE statements.
2 ! Contributed by Francois-Xavier Coudert (coudert@clipper.ens.fr)
4 ! { dg-do compile }
5 ! { dg-options "-ffree-line-length-none -pedantic -fmax-errors=50" }
6 integer,parameter :: mone = -1, zero = 0
7 character(len=*),parameter :: foo = "foo"
8 character(len=20) :: str
9 integer :: u
11 ! Test for warnings, when IOSTAT is used
13 open(10, iostat=u,access="sequential ")
14 open(10, iostat=u,access="sequential u") ! { dg-warning "ACCESS specifier in OPEN statement" }
15 open(10, iostat=u,access=foo) ! { dg-warning "ACCESS specifier in OPEN statement" }
16 open(10, iostat=u,access="direct")
17 open(10, iostat=u,access="stream")
18 open(10, iostat=u,access="append") ! { dg-warning "Extension: ACCESS specifier in OPEN statement" }
20 open(10, iostat=u,action="read")
21 open(10, iostat=u,action="write")
22 open(10, iostat=u,action="readwrite")
23 open(10, iostat=u,action=foo) ! { dg-warning "ACTION specifier in OPEN statement" }
25 open(10, iostat=u,blank="ZERO")
26 open(10, iostat=u,blank="nUlL")
27 open(10, iostat=u,blank="NULLL") ! { dg-warning "BLANK specifier in OPEN statement" }
29 open(10, iostat=u,delim="apostrophe")
30 open(10, iostat=u,delim="quote")
31 open(10, iostat=u,delim="none")
32 open(10, iostat=u,delim="") ! { dg-warning "DELIM specifier in OPEN statement" }
34 open(10, iostat=u,form="formatted")
35 open(10, iostat=u,form="unformatted")
36 open(10, iostat=u,form="default") ! { dg-warning "FORM specifier in OPEN statement" }
38 open(10, iostat=u,pad="yes")
39 open(10, iostat=u,pad="no")
40 open(10, iostat=u,pad=foo) ! { dg-warning "PAD specifier in OPEN statement" }
42 open(10, iostat=u,position="asis")
43 open(10, iostat=u,position="rewind")
44 open(10, iostat=u,position="append")
45 open(10, iostat=u,position=foo) ! { dg-warning "POSITION specifier in OPEN statement" }
47 open(10, iostat=u,recl="ee") ! { dg-warning "must be of type INTEGER" }
48 open(10, iostat=u,recl=0.4) ! { dg-warning "must be of type INTEGER" }
49 open(10, iostat=u,recl=zero) ! { dg-warning "must be positive" }
50 open(10, iostat=u,recl=mone) ! { dg-warning "must be positive" }
52 open(10, iostat=u,status="unknown")
53 open(10, iostat=u,status="old")
54 open(10, iostat=u,status=foo) ! { dg-warning "STATUS specifier in OPEN statement" }
56 open(10, iostat=u,status="new") ! { dg-warning "no FILE specifier is present" }
57 open(10, iostat=u,status="replace ") ! { dg-warning "no FILE specifier is present" }
58 open(10, iostat=u,status="scratch",file=str) ! { dg-warning "cannot have the value SCRATCH if a FILE specifier is present" }
60 open(10, iostat=u,form="unformatted",delim="none") ! { dg-warning "not allowed in OPEN statement for unformatted I/O" }
61 open(10, iostat=u,form="unformatted",pad="yes") ! { dg-warning "not allowed in OPEN statement for unformatted I/O" }
62 open(10, iostat=u,form="unformatted",blank="null") ! { dg-warning "not allowed in OPEN statement for unformatted I/O" }
64 open(10, iostat=u,access="direct",position="append") ! { dg-warning "only allowed for stream or sequential ACCESS" }
66 close(10, iostat=u,status="keep")
67 close(10, iostat=u,status="delete")
68 close(10, iostat=u,status=foo) ! { dg-warning "STATUS specifier in CLOSE statement" }
72 ! Test for warnings, when an ERR label is specified
74 open(10, err=99,access="sequential ")
75 open(10, err=99,access="sequential u") ! { dg-warning "ACCESS specifier in OPEN statement" }
76 open(10, err=99,access=foo) ! { dg-warning "ACCESS specifier in OPEN statement" }
77 open(10, err=99,access="direct")
78 open(10, err=99,access="stream")
79 open(10, err=99,access="append") ! { dg-warning "Extension: ACCESS specifier in OPEN statement" }
81 open(10, err=99,action="read")
82 open(10, err=99,action="write")
83 open(10, err=99,action="readwrite")
84 open(10, err=99,action=foo) ! { dg-warning "ACTION specifier in OPEN statement" }
86 open(10, err=99,blank="ZERO")
87 open(10, err=99,blank="nUlL")
88 open(10, err=99,blank="NULLL") ! { dg-warning "BLANK specifier in OPEN statement" }
90 open(10, err=99,delim="apostrophe")
91 open(10, err=99,delim="quote")
92 open(10, err=99,delim="none")
93 open(10, err=99,delim="") ! { dg-warning "DELIM specifier in OPEN statement" }
95 open(10, err=99,form="formatted")
96 open(10, err=99,form="unformatted")
97 open(10, err=99,form="default") ! { dg-warning "FORM specifier in OPEN statement" }
99 open(10, err=99,pad="yes")
100 open(10, err=99,pad="no")
101 open(10, err=99,pad=foo) ! { dg-warning "PAD specifier in OPEN statement" }
103 open(10, err=99,position="asis")
104 open(10, err=99,position="rewind")
105 open(10, err=99,position="append")
106 open(10, err=99,position=foo) ! { dg-warning "POSITION specifier in OPEN statement" }
108 open(10, err=99,recl="ee") ! { dg-warning "must be of type INTEGER" }
109 open(10, err=99,recl=0.4) ! { dg-warning "must be of type INTEGER" }
110 open(10, err=99,recl=zero) ! { dg-warning "must be positive" }
111 open(10, err=99,recl=mone) ! { dg-warning "must be positive" }
113 open(10, err=99,status="unknown")
114 open(10, err=99,status="old")
115 open(10, err=99,status=foo) ! { dg-warning "STATUS specifier in OPEN statement" }
117 open(10, err=99,status="new") ! { dg-warning "no FILE specifier is present" }
118 open(10, err=99,status="replace ") ! { dg-warning "no FILE specifier is present" }
119 open(10, err=99,status="scratch",file=str) ! { dg-warning "cannot have the value SCRATCH if a FILE specifier is present" }
121 open(10, err=99,form="unformatted",delim="none") ! { dg-warning "not allowed in OPEN statement for unformatted I/O" }
122 open(10, err=99,form="unformatted",pad="yes") ! { dg-warning "not allowed in OPEN statement for unformatted I/O" }
123 open(10, err=99,form="unformatted",blank="null") ! { dg-warning "not allowed in OPEN statement for unformatted I/O" }
125 open(10, err=99,access="direct",position="append") ! { dg-warning "only allowed for stream or sequential ACCESS" }
127 close(10, err=99,status="keep")
128 close(10, err=99,status="delete")
129 close(10, err=99,status=foo) ! { dg-warning "STATUS specifier in CLOSE statement" }
131 99 continue
133 ! Test for errors
135 open(10,access="sequential ")
136 open(10,access="sequential u") ! { dg-error "ACCESS specifier in OPEN statement" }
137 open(10,access=foo) ! { dg-error "ACCESS specifier in OPEN statement" }
138 open(10,access="direct")
139 open(10,access="stream")
140 open(10,access="append") ! { dg-warning "Extension: ACCESS specifier in OPEN statement" }
142 open(10,action="read")
143 open(10,action="write")
144 open(10,action="readwrite")
145 open(10,action=foo) ! { dg-error "ACTION specifier in OPEN statement" }
147 open(10,blank="ZERO")
148 open(10,blank="nUlL")
149 open(10,blank="NULLL") ! { dg-error "BLANK specifier in OPEN statement" }
151 open(10,delim="apostrophe")
152 open(10,delim="quote")
153 open(10,delim="none")
154 open(10,delim="") ! { dg-error "DELIM specifier in OPEN statement" }
156 open(10,form="formatted")
157 open(10,form="unformatted")
158 open(10,form="default") ! { dg-error "FORM specifier in OPEN statement" }
160 open(10,pad="yes")
161 open(10,pad="no")
162 open(10,pad=foo) ! { dg-error "PAD specifier in OPEN statement" }
164 open(10,position="asis")
165 open(10,position="rewind")
166 open(10,position="append")
167 open(10,position=foo) ! { dg-error "POSITION specifier in OPEN statement" }
169 open(10,recl="ee") ! { dg-error "must be of type INTEGER" }
170 open(10,recl=0.4) ! { dg-error "must be of type INTEGER" }
171 open(10,recl=zero) ! { dg-error "must be positive" }
172 open(10,recl=mone) ! { dg-error "must be positive" }
174 open(10,status="unknown")
175 open(10,status="old")
176 open(10,status=foo) ! { dg-error "STATUS specifier in OPEN statement" }
178 open(10,status="new") ! { dg-error "no FILE specifier is present" }
179 open(10,status="replace ") ! { dg-error "no FILE specifier is present" }
180 open(10,status="scratch",file=str) ! { dg-error "cannot have the value SCRATCH if a FILE specifier is present" }
182 open(10,form="unformatted",delim="none") ! { dg-error "not allowed in OPEN statement for unformatted I/O" }
183 open(10,form="unformatted",pad="yes") ! { dg-error "not allowed in OPEN statement for unformatted I/O" }
184 open(10,form="unformatted",blank="null") ! { dg-error "not allowed in OPEN statement for unformatted I/O" }
186 open(10,access="direct",position="append") ! { dg-error "only allowed for stream or sequential ACCESS" }
188 close(10,status="keep")
189 close(10,status="delete")
190 close(10,status=foo) ! { dg-error "STATUS specifier in CLOSE statement" }