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