Debian Codegraph @

flang/test/Semantics/OpenMP/atomic01.f90

raw
1 ! REQUIRES: openmp_runtime
2
3 ! RUN: %python %S/../test_errors.py %s %flang_fc1 %openmp_flags
4 ! Semantic checks for OpenMP 5.0 standard 2.17.7 atomic Construct.
5
6 use omp_lib
7 implicit none
8 integer :: i, j = 10, k=-100, a
9 ! 2.17.7.1
10 ! Handled inside parser.
11 ! OpenMP constructs may not be encountered during execution of an atomic region
12
13 ! 2.17.7.2
14 ! At most one memory-order-clause may appear on the construct.
15
16 !READ
17 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
18 !ERROR: At most one SEQ_CST clause can appear on the READ directive
19 !$omp atomic seq_cst seq_cst read
20 i = j
21 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
22 !ERROR: At most one SEQ_CST clause can appear on the READ directive
23 !$omp atomic read seq_cst seq_cst
24 i = j
25 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
26 !ERROR: At most one SEQ_CST clause can appear on the READ directive
27 !$omp atomic seq_cst read seq_cst
28 i = j
29
30 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
31 !ERROR: At most one ACQUIRE clause can appear on the READ directive
32 !$omp atomic acquire acquire read
33 i = j
34 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
35 !ERROR: At most one ACQUIRE clause can appear on the READ directive
36 !$omp atomic read acquire acquire
37 i = j
38 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
39 !ERROR: At most one ACQUIRE clause can appear on the READ directive
40 !$omp atomic acquire read acquire
41 i = j
42
43 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
44 !ERROR: At most one RELAXED clause can appear on the READ directive
45 !$omp atomic relaxed relaxed read
46 i = j
47 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
48 !ERROR: At most one RELAXED clause can appear on the READ directive
49 !$omp atomic read relaxed relaxed
50 i = j
51 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
52 !ERROR: At most one RELAXED clause can appear on the READ directive
53 !$omp atomic relaxed read relaxed
54 i = j
55
56 !UPDATE
57 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
58 !ERROR: At most one SEQ_CST clause can appear on the UPDATE directive
59 !$omp atomic seq_cst seq_cst update
60 !ERROR: Invalid or missing operator in atomic update statement
61 i = j
62 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
63 !ERROR: At most one SEQ_CST clause can appear on the UPDATE directive
64 !$omp atomic update seq_cst seq_cst
65 !ERROR: Invalid or missing operator in atomic update statement
66 i = j
67 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
68 !ERROR: At most one SEQ_CST clause can appear on the UPDATE directive
69 !$omp atomic seq_cst update seq_cst
70 !ERROR: Invalid or missing operator in atomic update statement
71 i = j
72
73 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
74 !ERROR: At most one RELEASE clause can appear on the UPDATE directive
75 !$omp atomic release release update
76 !ERROR: Invalid or missing operator in atomic update statement
77 i = j
78 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
79 !ERROR: At most one RELEASE clause can appear on the UPDATE directive
80 !$omp atomic update release release
81 !ERROR: Invalid or missing operator in atomic update statement
82 i = j
83 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
84 !ERROR: At most one RELEASE clause can appear on the UPDATE directive
85 !$omp atomic release update release
86 !ERROR: Invalid or missing operator in atomic update statement
87 i = j
88
89 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
90 !ERROR: At most one RELAXED clause can appear on the UPDATE directive
91 !$omp atomic relaxed relaxed update
92 !ERROR: Invalid or missing operator in atomic update statement
93 i = j
94 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
95 !ERROR: At most one RELAXED clause can appear on the UPDATE directive
96 !$omp atomic update relaxed relaxed
97 !ERROR: Invalid or missing operator in atomic update statement
98 i = j
99 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
100 !ERROR: At most one RELAXED clause can appear on the UPDATE directive
101 !$omp atomic relaxed update relaxed
102 !ERROR: Invalid or missing operator in atomic update statement
103 i = j
104
105 !CAPTURE
106 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
107 !ERROR: At most one SEQ_CST clause can appear on the CAPTURE directive
108 !$omp atomic seq_cst seq_cst capture
109 i = j
110 j = k
111 !$omp end atomic
112 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
113 !ERROR: At most one SEQ_CST clause can appear on the CAPTURE directive
114 !$omp atomic capture seq_cst seq_cst
115 i = j
116 j = k
117 !$omp end atomic
118
119 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
120 !ERROR: At most one SEQ_CST clause can appear on the CAPTURE directive
121 !$omp atomic seq_cst capture seq_cst
122 i = j
123 j = k
124 !$omp end atomic
125
126 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
127 !ERROR: At most one RELEASE clause can appear on the CAPTURE directive
128 !$omp atomic release release capture
129 i = j
130 j = k
131 !$omp end atomic
132
133 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
134 !ERROR: At most one RELEASE clause can appear on the CAPTURE directive
135 !$omp atomic capture release release
136 i = j
137 j = k
138 !$omp end atomic
139
140 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
141 !ERROR: At most one RELEASE clause can appear on the CAPTURE directive
142 !$omp atomic release capture release
143 i = j
144 j = k
145 !$omp end atomic
146
147 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
148 !ERROR: At most one RELAXED clause can appear on the CAPTURE directive
149 !$omp atomic relaxed relaxed capture
150 i = j
151 j = k
152 !$omp end atomic
153
154 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
155 !ERROR: At most one RELAXED clause can appear on the CAPTURE directive
156 !$omp atomic capture relaxed relaxed
157 i = j
158 j = k
159 !$omp end atomic
160
161 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
162 !ERROR: At most one RELAXED clause can appear on the CAPTURE directive
163 !$omp atomic relaxed capture relaxed
164 i = j
165 j = k
166 !$omp end atomic
167
168 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
169 !ERROR: At most one ACQ_REL clause can appear on the CAPTURE directive
170 !$omp atomic acq_rel acq_rel capture
171 i = j
172 j = k
173 !$omp end atomic
174
175 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
176 !ERROR: At most one ACQ_REL clause can appear on the CAPTURE directive
177 !$omp atomic capture acq_rel acq_rel
178 i = j
179 j = k
180 !$omp end atomic
181
182 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
183 !ERROR: At most one ACQ_REL clause can appear on the CAPTURE directive
184 !$omp atomic acq_rel capture acq_rel
185 i = j
186 j = k
187 !$omp end atomic
188
189 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
190 !ERROR: At most one ACQUIRE clause can appear on the CAPTURE directive
191 !$omp atomic acquire acquire capture
192 i = j
193 j = k
194 !$omp end atomic
195
196 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
197 !ERROR: At most one ACQUIRE clause can appear on the CAPTURE directive
198 !$omp atomic capture acquire acquire
199 i = j
200 j = k
201 !$omp end atomic
202
203 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
204 !ERROR: At most one ACQUIRE clause can appear on the CAPTURE directive
205 !$omp atomic acquire capture acquire
206 i = j
207 j = k
208 !$omp end atomic
209
210 !WRITE
211 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
212 !ERROR: At most one SEQ_CST clause can appear on the WRITE directive
213 !$omp atomic seq_cst seq_cst write
214 i = j
215 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
216 !ERROR: At most one SEQ_CST clause can appear on the WRITE directive
217 !$omp atomic write seq_cst seq_cst
218 i = j
219
220 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
221 !ERROR: At most one SEQ_CST clause can appear on the WRITE directive
222 !$omp atomic seq_cst write seq_cst
223 i = j
224
225 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
226 !ERROR: At most one RELEASE clause can appear on the WRITE directive
227 !$omp atomic release release write
228 i = j
229 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
230 !ERROR: At most one RELEASE clause can appear on the WRITE directive
231 !$omp atomic write release release
232 i = j
233 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
234 !ERROR: At most one RELEASE clause can appear on the WRITE directive
235 !$omp atomic release write release
236 i = j
237 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
238 !ERROR: At most one RELAXED clause can appear on the WRITE directive
239 !$omp atomic relaxed relaxed write
240 i = j
241 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
242 !ERROR: At most one RELAXED clause can appear on the WRITE directive
243 !$omp atomic write relaxed relaxed
244 i = j
245 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
246 !ERROR: At most one RELAXED clause can appear on the WRITE directive
247 !$omp atomic relaxed write relaxed
248 i = j
249
250 !No atomic-clause
251 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
252 !ERROR: At most one RELAXED clause can appear on the ATOMIC directive
253 !$omp atomic relaxed relaxed
254 !ERROR: Invalid or missing operator in atomic update statement
255 i = j
256 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
257 !ERROR: At most one SEQ_CST clause can appear on the ATOMIC directive
258 !$omp atomic seq_cst seq_cst
259 !ERROR: Invalid or missing operator in atomic update statement
260 i = j
261 !ERROR: More than one memory order clause not allowed on OpenMP Atomic construct
262 !ERROR: At most one RELEASE clause can appear on the ATOMIC directive
263 !$omp atomic release release
264 !ERROR: Invalid or missing operator in atomic update statement
265 i = j
266
267 ! 2.17.7.3
268 ! At most one hint clause may appear on the construct.
269
270 !ERROR: At most one HINT clause can appear on the READ directive
271 !$omp atomic hint(omp_sync_hint_speculative) hint(omp_sync_hint_speculative) read
272 i = j
273 !ERROR: At most one HINT clause can appear on the READ directive
274 !$omp atomic hint(omp_sync_hint_nonspeculative) read hint(omp_sync_hint_nonspeculative)
275 i = j
276 !ERROR: At most one HINT clause can appear on the READ directive
277 !$omp atomic read hint(omp_sync_hint_uncontended) hint (omp_sync_hint_uncontended)
278 i = j
279 !ERROR: At most one HINT clause can appear on the WRITE directive
280 !$omp atomic hint(omp_sync_hint_contended) hint(omp_sync_hint_speculative) write
281 i = j
282 !ERROR: At most one HINT clause can appear on the WRITE directive
283 !$omp atomic hint(omp_sync_hint_nonspeculative) write hint(omp_sync_hint_nonspeculative)
284 i = j
285 !ERROR: At most one HINT clause can appear on the WRITE directive
286 !$omp atomic write hint(omp_sync_hint_none) hint (omp_sync_hint_uncontended)
287 i = j
288 !ERROR: At most one HINT clause can appear on the WRITE directive
289 !$omp atomic hint(omp_sync_hint_contended) hint(omp_sync_hint_speculative) write
290 i = j
291 !ERROR: At most one HINT clause can appear on the WRITE directive
292 !$omp atomic hint(omp_sync_hint_nonspeculative) write hint(omp_sync_hint_nonspeculative)
293 i = j
294 !ERROR: At most one HINT clause can appear on the WRITE directive
295 !$omp atomic write hint(omp_sync_hint_none) hint (omp_sync_hint_uncontended)
296 i = j
297 !ERROR: At most one HINT clause can appear on the UPDATE directive
298 !$omp atomic hint(omp_sync_hint_contended) hint(omp_sync_hint_speculative) update
299 !ERROR: Invalid or missing operator in atomic update statement
300 i = j
301 !ERROR: At most one HINT clause can appear on the UPDATE directive
302 !$omp atomic hint(omp_sync_hint_nonspeculative) update hint(omp_sync_hint_nonspeculative)
303 !ERROR: Invalid or missing operator in atomic update statement
304 i = j
305 !ERROR: At most one HINT clause can appear on the UPDATE directive
306 !$omp atomic update hint(omp_sync_hint_none) hint (omp_sync_hint_uncontended)
307 !ERROR: Invalid or missing operator in atomic update statement
308 i = j
309 !ERROR: At most one HINT clause can appear on the ATOMIC directive
310 !$omp atomic hint(omp_sync_hint_contended) hint(omp_sync_hint_speculative)
311 !ERROR: Invalid or missing operator in atomic update statement
312 i = j
313 !ERROR: At most one HINT clause can appear on the ATOMIC directive
314 !$omp atomic hint(omp_sync_hint_none) hint(omp_sync_hint_nonspeculative)
315 !ERROR: Invalid or missing operator in atomic update statement
316 i = j
317 !ERROR: At most one HINT clause can appear on the ATOMIC directive
318 !$omp atomic hint(omp_sync_hint_none) hint (omp_sync_hint_uncontended)
319 !ERROR: Invalid or missing operator in atomic update statement
320 i = j
321
322 !ERROR: At most one HINT clause can appear on the CAPTURE directive
323 !$omp atomic hint(omp_sync_hint_contended) hint(omp_sync_hint_speculative) capture
324 i = j
325 j = k
326 !$omp end atomic
327 !ERROR: At most one HINT clause can appear on the CAPTURE directive
328 !$omp atomic hint(omp_sync_hint_nonspeculative) capture hint(omp_sync_hint_nonspeculative)
329 i = j
330 j = k
331 !$omp end atomic
332 !ERROR: At most one HINT clause can appear on the CAPTURE directive
333 !$omp atomic capture hint(omp_sync_hint_none) hint (omp_sync_hint_uncontended)
334 i = j
335 j = k
336 !$omp end atomic
337 ! 2.17.7.4
338 ! If atomic-clause is read then memory-order-clause must not be acq_rel or release.
339
340 !ERROR: Clause ACQ_REL is not allowed if clause READ appears on the ATOMIC directive
341 !$omp atomic acq_rel read
342 i = j
343 !ERROR: Clause ACQ_REL is not allowed if clause READ appears on the ATOMIC directive
344 !$omp atomic read acq_rel
345 i = j
346
347 !ERROR: Clause RELEASE is not allowed if clause READ appears on the ATOMIC directive
348 !$omp atomic release read
349 i = j
350 !ERROR: Clause RELEASE is not allowed if clause READ appears on the ATOMIC directive
351 !$omp atomic read release
352 i = j
353
354 ! 2.17.7.5
355 ! If atomic-clause is write then memory-order-clause must not be acq_rel or acquire.
356
357 !ERROR: Clause ACQ_REL is not allowed if clause WRITE appears on the ATOMIC directive
358 !$omp atomic acq_rel write
359 i = j
360 !ERROR: Clause ACQ_REL is not allowed if clause WRITE appears on the ATOMIC directive
361 !$omp atomic write acq_rel
362 i = j
363
364 !ERROR: Clause ACQUIRE is not allowed if clause WRITE appears on the ATOMIC directive
365 !$omp atomic acquire write
366 i = j
367 !ERROR: Clause ACQUIRE is not allowed if clause WRITE appears on the ATOMIC directive
368 !$omp atomic write acquire
369 i = j
370
371
372 ! 2.17.7.6
373 ! If atomic-clause is update or not present then memory-order-clause must not be acq_rel or acquire.
374
375 !ERROR: Clause ACQ_REL is not allowed if clause UPDATE appears on the ATOMIC directive
376 !$omp atomic acq_rel update
377 !ERROR: Invalid or missing operator in atomic update statement
378 i = j
379 !ERROR: Clause ACQ_REL is not allowed if clause UPDATE appears on the ATOMIC directive
380 !$omp atomic update acq_rel
381 !ERROR: Invalid or missing operator in atomic update statement
382 i = j
383
384 !ERROR: Clause ACQUIRE is not allowed if clause UPDATE appears on the ATOMIC directive
385 !$omp atomic acquire update
386 !ERROR: Invalid or missing operator in atomic update statement
387 i = j
388
389 !ERROR: Clause ACQUIRE is not allowed if clause UPDATE appears on the ATOMIC directive
390 !$omp atomic update acquire
391 !ERROR: Invalid or missing operator in atomic update statement
392 i = j
393
394 !ERROR: Clause ACQ_REL is not allowed on the ATOMIC directive
395 !$omp atomic acq_rel
396 !ERROR: Invalid or missing operator in atomic update statement
397 i = j
398
399 !ERROR: Clause ACQUIRE is not allowed on the ATOMIC directive
400 !$omp atomic acquire
401 !ERROR: Invalid or missing operator in atomic update statement
402 i = j
403 end program
404