[OpenACC] Treat 'delete' as a valid clause during parsing in C++ mode
[llvm-project.git] / clang / test / OpenMP / sections_misc_messages.c
blob58e1a816007e01adda8f9508831ec05bf0b42b9e
1 // RUN: %clang_cc1 -fsyntax-only -fopenmp -verify %s -Wuninitialized
3 // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -verify %s -Wuninitialized
5 void xxx(int argc) {
6 int x; // expected-note {{initialize the variable 'x' to silence this warning}}
7 #pragma omp sections
9 argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
13 void foo(void);
15 // expected-error@+1 {{unexpected OpenMP directive '#pragma omp sections'}}
16 #pragma omp sections
18 // expected-error@+1 {{unexpected OpenMP directive '#pragma omp sections'}}
19 #pragma omp sections foo
21 void test_no_clause(void) {
22 int i;
23 #pragma omp sections
25 foo();
28 // expected-error@+2 {{the statement for '#pragma omp sections' must be a compound statement}}
29 #pragma omp sections
30 ++i;
32 #pragma omp sections
34 foo();
35 foo(); // expected-error {{statement in 'omp sections' directive must be enclosed into a section region}}
37 #pragma omp parallel
38 #pragma omp sections
41 if (i == 6)
42 return; // expected-error {{cannot return from OpenMP region}}
44 #pragma omp section
46 if (i == 6)
47 return; // expected-error {{cannot return from OpenMP region}}
53 void test_branch_protected_scope(void) {
54 int i = 0;
55 L1:
56 ++i;
58 int x[24];
60 #pragma omp parallel
61 #pragma omp sections
63 if (i == 5)
64 goto L1; // expected-error {{use of undeclared label 'L1'}}
65 else if (i == 7)
66 goto L2;
67 else if (i == 8) {
68 L2:
69 x[i]++;
71 #pragma omp section
72 if (i == 5)
73 goto L1;
74 else if (i == 7)
75 goto L3;
76 else if (i == 8) {
77 L3:
78 x[i]++;
82 #pragma omp parallel
83 #pragma omp sections
85 #pragma omp section
86 if (i == 5)
87 goto L1; // expected-error {{use of undeclared label 'L1'}}
88 else if (i == 7)
89 goto L3;
90 else if (i == 8) {
91 L3:
92 x[i]++;
96 if (x[0] == 0)
97 goto L2; // expected-error {{use of undeclared label 'L2'}}
98 else if (x[1] == 1)
99 goto L1;
100 goto L3; // expected-error {{use of undeclared label 'L3'}}
103 void test_invalid_clause(void) {
104 int i;
105 #pragma omp parallel
106 // expected-warning@+1 {{extra tokens at the end of '#pragma omp sections' are ignored}}
107 #pragma omp sections foo bar
109 foo();
110 // expected-error@+1 {{unexpected OpenMP clause 'nowait' in directive '#pragma omp section'}}
111 #pragma omp section nowait
116 void test_non_identifiers(void) {
117 int i, x;
119 #pragma omp parallel
120 // expected-warning@+1 {{extra tokens at the end of '#pragma omp sections' are ignored}}
121 #pragma omp sections;
123 foo();
125 #pragma omp parallel
126 // expected-error@+2 {{unexpected OpenMP clause 'linear' in directive '#pragma omp sections'}}
127 // expected-warning@+1 {{extra tokens at the end of '#pragma omp sections' are ignored}}
128 #pragma omp sections linear(x);
130 foo();
133 #pragma omp parallel
134 // expected-warning@+1 {{extra tokens at the end of '#pragma omp sections' are ignored}}
135 #pragma omp sections private(x);
137 foo();
140 #pragma omp parallel
141 // expected-warning@+1 {{extra tokens at the end of '#pragma omp sections' are ignored}}
142 #pragma omp sections, private(x);
144 foo();
148 void test_private(void) {
149 int i;
150 #pragma omp parallel
151 // expected-error@+2 {{expected expression}}
152 // expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
153 #pragma omp sections private(
155 foo();
157 #pragma omp parallel
158 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
159 // expected-error@+1 2 {{expected expression}}
160 #pragma omp sections private(,
162 foo();
164 #pragma omp parallel
165 // expected-error@+1 2 {{expected expression}}
166 #pragma omp sections private(, )
168 foo();
170 #pragma omp parallel
171 // expected-error@+1 {{expected expression}}
172 #pragma omp sections private()
174 foo();
176 #pragma omp parallel
177 // expected-error@+1 {{expected expression}}
178 #pragma omp sections private(int)
180 foo();
182 #pragma omp parallel
183 // expected-error@+1 {{expected variable name}}
184 #pragma omp sections private(0)
186 foo();
189 int x, y, z;
190 #pragma omp parallel
191 #pragma omp sections private(x)
193 foo();
195 #pragma omp parallel
196 #pragma omp sections private(x, y)
198 foo();
200 #pragma omp parallel
201 #pragma omp sections private(x, y, z)
203 foo();
207 void test_lastprivate(void) {
208 int i;
209 #pragma omp parallel
210 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
211 // expected-error@+1 {{expected expression}}
212 #pragma omp sections lastprivate(
214 foo();
217 #pragma omp parallel
218 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
219 // expected-error@+1 2 {{expected expression}}
220 #pragma omp sections lastprivate(,
222 foo();
224 #pragma omp parallel
225 // expected-error@+1 2 {{expected expression}}
226 #pragma omp sections lastprivate(, )
228 foo();
230 #pragma omp parallel
231 // expected-error@+1 {{expected expression}}
232 #pragma omp sections lastprivate()
234 foo();
236 #pragma omp parallel
237 // expected-error@+1 {{expected expression}}
238 #pragma omp sections lastprivate(int)
240 foo();
242 #pragma omp parallel
243 // expected-error@+1 {{expected variable name}}
244 #pragma omp sections lastprivate(0)
246 foo();
249 int x, y, z;
250 #pragma omp parallel
251 #pragma omp sections lastprivate(x)
253 foo();
255 #pragma omp parallel
256 #pragma omp sections lastprivate(x, y)
258 foo();
260 #pragma omp parallel
261 #pragma omp sections lastprivate(x, y, z)
263 foo();
267 void test_firstprivate(void) {
268 int i;
269 #pragma omp parallel
270 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
271 // expected-error@+1 {{expected expression}}
272 #pragma omp sections firstprivate(
274 foo();
277 #pragma omp parallel
278 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
279 // expected-error@+1 2 {{expected expression}}
280 #pragma omp sections firstprivate(,
282 foo();
284 #pragma omp parallel
285 // expected-error@+1 2 {{expected expression}}
286 #pragma omp sections firstprivate(, )
288 foo();
290 #pragma omp parallel
291 // expected-error@+1 {{expected expression}}
292 #pragma omp sections firstprivate()
294 foo();
296 #pragma omp parallel
297 // expected-error@+1 {{expected expression}}
298 #pragma omp sections firstprivate(int)
300 foo();
302 #pragma omp parallel
303 // expected-error@+1 {{expected variable name}}
304 #pragma omp sections firstprivate(0)
306 foo();
309 int x, y, z;
310 #pragma omp parallel
311 #pragma omp sections lastprivate(x) firstprivate(x)
313 foo();
315 #pragma omp parallel
316 #pragma omp sections lastprivate(x, y) firstprivate(x, y)
318 foo();
320 #pragma omp parallel
321 #pragma omp sections lastprivate(x, y, z) firstprivate(x, y, z)
323 foo();
327 void test_nowait(void) {
328 #pragma omp parallel
329 #pragma omp sections nowait nowait // expected-error {{directive '#pragma omp sections' cannot contain more than one 'nowait' clause}}