dosemantics03.f90
6.38 KB
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
! RUN: %S/test_errors.sh %s %t %f18 -Mstandard -Werror
! Issue 458 -- semantic checks for a normal DO loop. The DO variable
! and the initial, final, and step expressions must be INTEGER if the
! options for standard conformance and turning warnings into errors
! are both in effect. This test turns on the options for standards
! conformance and turning warnings into errors. This produces error
! messages for the cases where REAL and DOUBLE PRECISION variables
! and expressions are used in the DO controls.
! C1120 -- DO variable (and associated expressions) must be INTEGER.
! This is extended by allowing REAL and DOUBLE PRECISION
MODULE share
INTEGER :: intvarshare
REAL :: realvarshare
DOUBLE PRECISION :: dpvarshare
END MODULE share
PROGRAM do_issue_458
USE share
IMPLICIT NONE
INTEGER :: ivar
REAL :: rvar
DOUBLE PRECISION :: dvar
LOGICAL :: lvar
COMPLEX :: cvar
CHARACTER :: chvar
INTEGER, DIMENSION(3) :: avar
TYPE derived
REAL :: first
INTEGER :: second
END TYPE derived
TYPE(derived) :: devar
INTEGER, POINTER :: pivar
REAL, POINTER :: prvar
DOUBLE PRECISION, POINTER :: pdvar
LOGICAL, POINTER :: plvar
INTERFACE
SUBROUTINE sub()
END SUBROUTINE sub
FUNCTION ifunc()
END FUNCTION ifunc
END INTERFACE
PROCEDURE(ifunc), POINTER :: pifunc => NULL()
! DO variables
! INTEGER DO variable
DO ivar = 1, 10, 3
PRINT *, "ivar is: ", ivar
END DO
! REAL DO variable
DO rvar = 1, 10, 3
PRINT *, "rvar is: ", rvar
END DO
! DOUBLE PRECISISON DO variable
DO dvar = 1, 10, 3
PRINT *, "dvar is: ", dvar
END DO
! Pointer to INTEGER DO variable
ALLOCATE(pivar)
DO pivar = 1, 10, 3
PRINT *, "pivar is: ", pivar
END DO
! Pointer to REAL DO variable
ALLOCATE(prvar)
DO prvar = 1, 10, 3
PRINT *, "prvar is: ", prvar
END DO
! Pointer to DOUBLE PRECISION DO variable
ALLOCATE(pdvar)
DO pdvar = 1, 10, 3
PRINT *, "pdvar is: ", pdvar
END DO
! CHARACTER DO variable
!ERROR: DO controls should be INTEGER
DO chvar = 1, 10, 3
PRINT *, "chvar is: ", chvar
END DO
! LOGICAL DO variable
!ERROR: DO controls should be INTEGER
DO lvar = 1, 10, 3
PRINT *, "lvar is: ", lvar
END DO
! COMPLEX DO variable
!ERROR: DO controls should be INTEGER
DO cvar = 1, 10, 3
PRINT *, "cvar is: ", cvar
END DO
! Derived type DO variable
!ERROR: DO controls should be INTEGER
DO devar = 1, 10, 3
PRINT *, "devar is: ", devar
END DO
! Pointer to LOGICAL DO variable
ALLOCATE(plvar)
!ERROR: DO controls should be INTEGER
DO plvar = 1, 10, 3
PRINT *, "plvar is: ", plvar
END DO
! SUBROUTINE DO variable
!ERROR: DO control must be an INTEGER variable
DO sub = 1, 10, 3
PRINT *, "ivar is: ", ivar
END DO
! FUNCTION DO variable
!ERROR: DO control must be an INTEGER variable
DO ifunc = 1, 10, 3
PRINT *, "ivar is: ", ivar
END DO
! POINTER to FUNCTION DO variable
!ERROR: DO control must be an INTEGER variable
DO pifunc = 1, 10, 3
PRINT *, "ivar is: ", ivar
END DO
! Array DO variable
!ERROR: Must be a scalar value, but is a rank-1 array
DO avar = 1, 10, 3
PRINT *, "plvar is: ", plvar
END DO
! Undeclared DO variable
!ERROR: No explicit type declared for 'undeclared'
DO undeclared = 1, 10, 3
PRINT *, "plvar is: ", plvar
END DO
! Shared association INTEGER DO variable
DO intvarshare = 1, 10, 3
PRINT *, "ivar is: ", ivar
END DO
! Shared association REAL DO variable
DO realvarshare = 1, 10, 3
PRINT *, "ivar is: ", ivar
END DO
! Shared association DOUBLE PRECISION DO variable
DO dpvarshare = 1, 10, 3
PRINT *, "ivar is: ", ivar
END DO
! Initial expressions
! REAL initial expression
DO ivar = rvar, 10, 3
PRINT *, "ivar is: ", ivar
END DO
! DOUBLE PRECISION initial expression
DO ivar = dvar, 10, 3
PRINT *, "ivar is: ", ivar
END DO
! Pointer to INTEGER initial expression
DO ivar = pivar, 10, 3
PRINT *, "ivar is: ", ivar
END DO
! Pointer to REAL initial expression
DO ivar = prvar, 10, 3
PRINT *, "ivar is: ", ivar
END DO
! Pointer to DOUBLE PRECISION initial expression
DO ivar = pdvar, 10, 3
PRINT *, "ivar is: ", ivar
END DO
! LOGICAL initial expression
!ERROR: DO controls should be INTEGER
DO ivar = lvar, 10, 3
PRINT *, "ivar is: ", ivar
END DO
! COMPLEX initial expression
!ERROR: DO controls should be INTEGER
DO ivar = cvar, 10, 3
PRINT *, "ivar is: ", ivar
END DO
! Derived type initial expression
!ERROR: DO controls should be INTEGER
DO ivar = devar, 10, 3
PRINT *, "ivar is: ", ivar
END DO
! Pointer to LOGICAL initial expression
!ERROR: DO controls should be INTEGER
DO ivar = plvar, 10, 3
PRINT *, "ivar is: ", ivar
END DO
! Invalid initial expression
!ERROR: Integer literal is too large for INTEGER(KIND=4)
DO ivar = -2147483648_4, 10, 3
PRINT *, "ivar is: ", ivar
END DO
! Final expression
! REAL final expression
DO ivar = 1, rvar, 3
PRINT *, "ivar is: ", ivar
END DO
! DOUBLE PRECISION final expression
DO ivar = 1, dvar, 3
PRINT *, "ivar is: ", ivar
END DO
! Pointer to INTEGER final expression
DO ivar = 1, pivar, 3
PRINT *, "ivar is: ", ivar
END DO
! Pointer to REAL final expression
DO ivar = 1, prvar, 3
PRINT *, "ivar is: ", ivar
END DO
! Pointer to DOUBLE PRECISION final expression
DO ivar = pdvar, 10, 3
PRINT *, "ivar is: ", ivar
END DO
! COMPLEX final expression
!ERROR: DO controls should be INTEGER
DO ivar = 1, cvar, 3
PRINT *, "ivar is: ", ivar
END DO
! Invalid final expression
!ERROR: Integer literal is too large for INTEGER(KIND=4)
DO ivar = 1, -2147483648_4, 3
PRINT *, "ivar is: ", ivar
END DO
! Step expression
! REAL step expression
DO ivar = 1, 10, rvar
PRINT *, "ivar is: ", ivar
END DO
! DOUBLE PRECISION step expression
DO ivar = 1, 10, dvar
PRINT *, "ivar is: ", ivar
END DO
! Pointer to INTEGER step expression
DO ivar = 1, 10, pivar
PRINT *, "ivar is: ", ivar
END DO
! Pointer to REAL step expression
DO ivar = 1, 10, prvar
PRINT *, "ivar is: ", ivar
END DO
! Pointer to DOUBLE PRECISION step expression
DO ivar = 1, 10, pdvar
PRINT *, "ivar is: ", ivar
END DO
! COMPLEX Step expression
!ERROR: DO controls should be INTEGER
DO ivar = 1, 10, cvar
PRINT *, "ivar is: ", ivar
END DO
! Invalid step expression
!ERROR: Integer literal is too large for INTEGER(KIND=4)
DO ivar = 1, 10, -2147483648_4
PRINT *, "ivar is: ", ivar
END DO
END PROGRAM do_issue_458