aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gfortran.dg/io_constraints_3.f90
blob: dfba53baad6812dc331412c38fcf7bdd972830eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
! Test some restrictions on the specifiers of OPEN and CLOSE statements.
! Contributed by Francois-Xavier Coudert (coudert@clipper.ens.fr)
!
! { dg-do compile }
! { dg-options "-ffree-line-length-none -pedantic -fmax-errors=50" }
  integer,parameter :: mone = -1, zero = 0
  character(len=*),parameter :: foo = "foo"
  character(len=20) :: str
  integer :: u

! Test for warnings, when IOSTAT is used

  open(10, iostat=u,access="sequential   ")
  open(10, iostat=u,access="sequential   u") ! { dg-warning "ACCESS specifier in OPEN statement" }
  open(10, iostat=u,access=foo) ! { dg-warning "ACCESS specifier in OPEN statement" }
  open(10, iostat=u,access="direct")
  open(10, iostat=u,access="stream")
  open(10, iostat=u,access="append") ! { dg-warning "Extension: ACCESS specifier in OPEN statement" }

  open(10, iostat=u,action="read")
  open(10, iostat=u,action="write")
  open(10, iostat=u,action="readwrite")
  open(10, iostat=u,action=foo) ! { dg-warning "ACTION specifier in OPEN statement" }

  open(10, iostat=u,blank="ZERO")
  open(10, iostat=u,blank="nUlL")
  open(10, iostat=u,blank="NULLL") ! { dg-warning "BLANK specifier in OPEN statement" }

  open(10, iostat=u,delim="apostrophe")
  open(10, iostat=u,delim="quote")
  open(10, iostat=u,delim="none")
  open(10, iostat=u,delim="") ! { dg-warning "DELIM specifier in OPEN statement" }

  open(10, iostat=u,form="formatted")
  open(10, iostat=u,form="unformatted")
  open(10, iostat=u,form="default") ! { dg-warning "FORM specifier in OPEN statement" }

  open(10, iostat=u,pad="yes")
  open(10, iostat=u,pad="no")
  open(10, iostat=u,pad=foo) ! { dg-warning "PAD specifier in OPEN statement" }

  open(10, iostat=u,position="asis")
  open(10, iostat=u,position="rewind")
  open(10, iostat=u,position="append")
  open(10, iostat=u,position=foo) ! { dg-warning "POSITION specifier in OPEN statement" }

  open(10, iostat=u,recl="ee") ! { dg-error "must be of type INTEGER" }
  open(10, iostat=u,recl=0.4) ! { dg-error "must be of type INTEGER" }
  open(10, iostat=u,recl=zero) ! { dg-warning "must be positive" }
  open(10, iostat=u,recl=mone) ! { dg-warning "must be positive" }

  open(10, iostat=u,status="unknown")
  open(10, iostat=u,status="old")
  open(10, iostat=u,status=foo) ! { dg-warning "STATUS specifier in OPEN statement" }
  
  open(10, iostat=u,status="new") ! { dg-warning "no FILE specifier is present" }
  open(10, iostat=u,status="replace   ") ! { dg-warning "no FILE specifier is present" }
  open(10, iostat=u,status="scratch",file=str) ! { dg-warning "cannot have the value SCRATCH if a FILE specifier is present" }

  open(10, iostat=u,form="unformatted",delim="none") ! { dg-warning "not allowed in OPEN statement for unformatted I/O" }
  open(10, iostat=u,form="unformatted",pad="yes") ! { dg-warning "not allowed in OPEN statement for unformatted I/O" }
  open(10, iostat=u,form="unformatted",blank="null") ! { dg-warning "not allowed in OPEN statement for unformatted I/O" }

  open(10, iostat=u,access="direct",position="append") ! { dg-warning "only allowed for stream or sequential ACCESS" }

  close(10, iostat=u,status="keep")
  close(10, iostat=u,status="delete")
  close(10, iostat=u,status=foo) ! { dg-warning "STATUS specifier in CLOSE statement" }
  close(iostat=u) ! { dg-error "requires a UNIT number" }



! Test for warnings, when an ERR label is specified

  open(10, err=99,access="sequential   ")
  open(10, err=99,access="sequential   u") ! { dg-warning "ACCESS specifier in OPEN statement" }
  open(10, err=99,access=foo) ! { dg-warning "ACCESS specifier in OPEN statement" }
  open(10, err=99,access="direct")
  open(10, err=99,access="stream")
  open(10, err=99,access="append") ! { dg-warning "Extension: ACCESS specifier in OPEN statement" }

  open(10, err=99,action="read")
  open(10, err=99,action="write")
  open(10, err=99,action="readwrite")
  open(10, err=99,action=foo) ! { dg-warning "ACTION specifier in OPEN statement" }

  open(10, err=99,blank="ZERO")
  open(10, err=99,blank="nUlL")
  open(10, err=99,blank="NULLL") ! { dg-warning "BLANK specifier in OPEN statement" }

  open(10, err=99,delim="apostrophe")
  open(10, err=99,delim="quote")
  open(10, err=99,delim="none")
  open(10, err=99,delim="") ! { dg-warning "DELIM specifier in OPEN statement" }

  open(10, err=99,form="formatted")
  open(10, err=99,form="unformatted")
  open(10, err=99,form="default") ! { dg-warning "FORM specifier in OPEN statement" }

  open(10, err=99,pad="yes")
  open(10, err=99,pad="no")
  open(10, err=99,pad=foo) ! { dg-warning "PAD specifier in OPEN statement" }

  open(10, err=99,position="asis")
  open(10, err=99,position="rewind")
  open(10, err=99,position="append")
  open(10, err=99,position=foo) ! { dg-warning "POSITION specifier in OPEN statement" }

  open(10, err=99,recl="ee") ! { dg-error "must be of type INTEGER" }
  open(10, err=99,recl=0.4) ! { dg-error "must be of type INTEGER" }
  open(10, err=99,recl=zero) ! { dg-warning "must be positive" }
  open(10, err=99,recl=mone) ! { dg-warning "must be positive" }

  open(10, err=99,status="unknown")
  open(10, err=99,status="old")
  open(10, err=99,status=foo) ! { dg-warning "STATUS specifier in OPEN statement" }
  
  open(10, err=99,status="new") ! { dg-warning "no FILE specifier is present" }
  open(10, err=99,status="replace   ") ! { dg-warning "no FILE specifier is present" }
  open(10, err=99,status="scratch",file=str) ! { dg-warning "cannot have the value SCRATCH if a FILE specifier is present" }

  open(10, err=99,form="unformatted",delim="none") ! { dg-warning "not allowed in OPEN statement for unformatted I/O" }
  open(10, err=99,form="unformatted",pad="yes") ! { dg-warning "not allowed in OPEN statement for unformatted I/O" }
  open(10, err=99,form="unformatted",blank="null") ! { dg-warning "not allowed in OPEN statement for unformatted I/O" }

  open(10, err=99,access="direct",position="append") ! { dg-warning "only allowed for stream or sequential ACCESS" }

  close(10, err=99,status="keep")
  close(10, err=99,status="delete")
  close(10, err=99,status=foo) ! { dg-warning "STATUS specifier in CLOSE statement" }

 99 continue

! Test for errors

  open(10,access="sequential   ")
  open(10,access="sequential   u") ! { dg-error "ACCESS specifier in OPEN statement" }
  open(10,access=foo) ! { dg-error "ACCESS specifier in OPEN statement" }
  open(10,access="direct")
  open(10,access="stream")
  open(10,access="append") ! { dg-warning "Extension: ACCESS specifier in OPEN statement" }

  open(10,action="read")
  open(10,action="write")
  open(10,action="readwrite")
  open(10,action=foo) ! { dg-error "ACTION specifier in OPEN statement" }

  open(10,blank="ZERO")
  open(10,blank="nUlL")
  open(10,blank="NULLL") ! { dg-error "BLANK specifier in OPEN statement" }

  open(10,delim="apostrophe")
  open(10,delim="quote")
  open(10,delim="none")
  open(10,delim="") ! { dg-error "DELIM specifier in OPEN statement" }

  open(10,form="formatted")
  open(10,form="unformatted")
  open(10,form="default") ! { dg-error "FORM specifier in OPEN statement" }

  open(10,pad="yes")
  open(10,pad="no")
  open(10,pad=foo) ! { dg-error "PAD specifier in OPEN statement" }

  open(10,position="asis")
  open(10,position="rewind")
  open(10,position="append")
  open(10,position=foo) ! { dg-error "POSITION specifier in OPEN statement" }

  open(10,recl="ee") ! { dg-error "must be of type INTEGER" }
  open(10,recl=0.4) ! { dg-error "must be of type INTEGER" }
  open(10,recl=zero) ! { dg-error "must be positive" }
  open(10,recl=mone) ! { dg-error "must be positive" }

  open(10,status="unknown")
  open(10,status="old")
  open(10,status=foo) ! { dg-error "STATUS specifier in OPEN statement" }
  
  open(10,status="new") ! { dg-error "no FILE specifier is present" }
  open(10,status="replace   ") ! { dg-error "no FILE specifier is present" }
  open(10,status="scratch",file=str) ! { dg-error "cannot have the value SCRATCH if a FILE specifier is present" }

  open(10,form="unformatted",delim="none") ! { dg-error "not allowed in OPEN statement for unformatted I/O" }
  open(10,form="unformatted",pad="yes") ! { dg-error "not allowed in OPEN statement for unformatted I/O" }
  open(10,form="unformatted",blank="null") ! { dg-error "not allowed in OPEN statement for unformatted I/O" }

  open(10,access="direct",position="append") ! { dg-error "only allowed for stream or sequential ACCESS" }

  close(10,status="keep")
  close(10,status="delete")
  close(10,status=foo) ! { dg-error "STATUS specifier in CLOSE statement" }
end