1 ! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic
3 ! C1120 -- DO variable (and associated expressions) must be INTEGER.
4 ! This is extended by allowing REAL and DOUBLE PRECISION
6 ! The standard requires the DO variable and the initial, final, and step
7 ! expressions to be INTEGER. As an extension, we do however allow them to be
8 ! REAL or DOUBLE PRECISION. This test turns on the option for standard
9 ! conformance checking to test that we get portability warnings for these
10 ! cases. We also check that other types, such as CHARACTER and LOGICAL, yield
11 ! errors when used in the DO controls.
14 INTEGER :: intvarshare
16 DOUBLE PRECISION :: dpvarshare
24 DOUBLE PRECISION :: dvar
28 INTEGER, DIMENSION(3) :: avar
33 TYPE(derived
) :: devar
34 INTEGER, POINTER :: pivar
35 REAL, POINTER :: prvar
36 DOUBLE PRECISION, POINTER :: pdvar
37 LOGICAL, POINTER :: plvar
44 PROCEDURE(ifunc
), POINTER :: pifunc
=> NULL()
49 PRINT *, "ivar is: ", ivar
53 !PORTABILITY: DO controls should be INTEGER
55 PRINT *, "rvar is: ", rvar
58 ! DOUBLE PRECISISON DO variable
59 !PORTABILITY: DO controls should be INTEGER
61 PRINT *, "dvar is: ", dvar
64 ! Pointer to INTEGER DO variable
67 PRINT *, "pivar is: ", pivar
70 ! Pointer to REAL DO variable
72 !PORTABILITY: DO controls should be INTEGER
74 PRINT *, "prvar is: ", prvar
77 ! Pointer to DOUBLE PRECISION DO variable
79 !PORTABILITY: DO controls should be INTEGER
81 PRINT *, "pdvar is: ", pdvar
84 ! CHARACTER DO variable
85 !ERROR: DO controls should be INTEGER
87 PRINT *, "chvar is: ", chvar
91 !ERROR: DO controls should be INTEGER
93 PRINT *, "lvar is: ", lvar
97 !ERROR: DO controls should be INTEGER
99 PRINT *, "cvar is: ", cvar
102 ! Derived type DO variable
103 !ERROR: DO controls should be INTEGER
105 PRINT *, "devar is: ", devar
108 ! Pointer to LOGICAL DO variable
110 !ERROR: DO controls should be INTEGER
112 PRINT *, "plvar is: ", plvar
115 ! SUBROUTINE DO variable
116 !ERROR: DO control must be an INTEGER variable
118 PRINT *, "ivar is: ", ivar
121 ! FUNCTION DO variable
122 !ERROR: DO control must be an INTEGER variable
124 PRINT *, "ivar is: ", ivar
127 ! POINTER to FUNCTION DO variable
128 !ERROR: DO control must be an INTEGER variable
130 PRINT *, "ivar is: ", ivar
134 !ERROR: Must be a scalar value, but is a rank-1 array
136 PRINT *, "plvar is: ", plvar
139 ! Undeclared DO variable
140 !ERROR: No explicit type declared for 'undeclared'
141 DO undeclared
= 1, 10, 3
142 PRINT *, "plvar is: ", plvar
145 ! Shared association INTEGER DO variable
146 DO intvarshare
= 1, 10, 3
147 PRINT *, "ivar is: ", ivar
150 ! Shared association REAL DO variable
151 !PORTABILITY: DO controls should be INTEGER
152 DO realvarshare
= 1, 10, 3
153 PRINT *, "ivar is: ", ivar
156 ! Shared association DOUBLE PRECISION DO variable
157 !PORTABILITY: DO controls should be INTEGER
158 DO dpvarshare
= 1, 10, 3
159 PRINT *, "ivar is: ", ivar
162 ! Initial expressions
163 ! REAL initial expression
164 !PORTABILITY: DO controls should be INTEGER
165 DO ivar
= rvar
, 10, 3
166 PRINT *, "ivar is: ", ivar
169 ! DOUBLE PRECISION initial expression
170 !PORTABILITY: DO controls should be INTEGER
171 DO ivar
= dvar
, 10, 3
172 PRINT *, "ivar is: ", ivar
175 ! Pointer to INTEGER initial expression
176 DO ivar
= pivar
, 10, 3
177 PRINT *, "ivar is: ", ivar
180 ! Pointer to REAL initial expression
181 !PORTABILITY: DO controls should be INTEGER
182 DO ivar
= prvar
, 10, 3
183 PRINT *, "ivar is: ", ivar
186 ! Pointer to DOUBLE PRECISION initial expression
187 !PORTABILITY: DO controls should be INTEGER
188 DO ivar
= pdvar
, 10, 3
189 PRINT *, "ivar is: ", ivar
192 ! LOGICAL initial expression
193 !ERROR: DO controls should be INTEGER
194 DO ivar
= lvar
, 10, 3
195 PRINT *, "ivar is: ", ivar
198 ! COMPLEX initial expression
199 !ERROR: DO controls should be INTEGER
200 DO ivar
= cvar
, 10, 3
201 PRINT *, "ivar is: ", ivar
204 ! Derived type initial expression
205 !ERROR: DO controls should be INTEGER
206 DO ivar
= devar
, 10, 3
207 PRINT *, "ivar is: ", ivar
210 ! Pointer to LOGICAL initial expression
211 !ERROR: DO controls should be INTEGER
212 DO ivar
= plvar
, 10, 3
213 PRINT *, "ivar is: ", ivar
216 ! Invalid initial expression
217 !ERROR: Integer literal is too large for INTEGER(KIND=4)
218 DO ivar
= -2147483649_4, 10, 3
219 PRINT *, "ivar is: ", ivar
223 ! REAL final expression
224 !PORTABILITY: DO controls should be INTEGER
226 PRINT *, "ivar is: ", ivar
229 ! DOUBLE PRECISION final expression
230 !PORTABILITY: DO controls should be INTEGER
232 PRINT *, "ivar is: ", ivar
235 ! Pointer to INTEGER final expression
236 DO ivar
= 1, pivar
, 3
237 PRINT *, "ivar is: ", ivar
240 ! Pointer to REAL final expression
241 !PORTABILITY: DO controls should be INTEGER
242 DO ivar
= 1, prvar
, 3
243 PRINT *, "ivar is: ", ivar
246 ! Pointer to DOUBLE PRECISION final expression
247 !PORTABILITY: DO controls should be INTEGER
248 DO ivar
= pdvar
, 10, 3
249 PRINT *, "ivar is: ", ivar
252 ! COMPLEX final expression
253 !ERROR: DO controls should be INTEGER
255 PRINT *, "ivar is: ", ivar
258 ! Invalid final expression
259 !ERROR: Integer literal is too large for INTEGER(KIND=4)
260 DO ivar
= 1, -2147483649_4, 3
261 PRINT *, "ivar is: ", ivar
265 ! REAL step expression
266 !PORTABILITY: DO controls should be INTEGER
267 DO ivar
= 1, 10, rvar
268 PRINT *, "ivar is: ", ivar
271 ! DOUBLE PRECISION step expression
272 !PORTABILITY: DO controls should be INTEGER
273 DO ivar
= 1, 10, dvar
274 PRINT *, "ivar is: ", ivar
277 ! Pointer to INTEGER step expression
278 DO ivar
= 1, 10, pivar
279 PRINT *, "ivar is: ", ivar
282 ! Pointer to REAL step expression
283 !PORTABILITY: DO controls should be INTEGER
284 DO ivar
= 1, 10, prvar
285 PRINT *, "ivar is: ", ivar
288 ! Pointer to DOUBLE PRECISION step expression
289 !PORTABILITY: DO controls should be INTEGER
290 DO ivar
= 1, 10, pdvar
291 PRINT *, "ivar is: ", ivar
294 ! COMPLEX Step expression
295 !ERROR: DO controls should be INTEGER
296 DO ivar
= 1, 10, cvar
297 PRINT *, "ivar is: ", ivar
300 ! Invalid step expression
301 !ERROR: Integer literal is too large for INTEGER(KIND=4)
302 DO ivar
= 1, 10, -2147483649_4
303 PRINT *, "ivar is: ", ivar
306 END PROGRAM do_issue_458