1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -fopenmp=libiomp5 -verify %s
2*0a6a1f1dSLionel Sambuc
3*0a6a1f1dSLionel Sambuc void foo();
4*0a6a1f1dSLionel Sambuc
5*0a6a1f1dSLionel Sambuc // expected-error@+1 {{unexpected OpenMP directive '#pragma omp sections'}}
6*0a6a1f1dSLionel Sambuc #pragma omp sections
7*0a6a1f1dSLionel Sambuc
8*0a6a1f1dSLionel Sambuc // expected-error@+1 {{unexpected OpenMP directive '#pragma omp sections'}}
9*0a6a1f1dSLionel Sambuc #pragma omp sections foo
10*0a6a1f1dSLionel Sambuc
test_no_clause()11*0a6a1f1dSLionel Sambuc void test_no_clause() {
12*0a6a1f1dSLionel Sambuc int i;
13*0a6a1f1dSLionel Sambuc #pragma omp sections
14*0a6a1f1dSLionel Sambuc {
15*0a6a1f1dSLionel Sambuc foo();
16*0a6a1f1dSLionel Sambuc }
17*0a6a1f1dSLionel Sambuc
18*0a6a1f1dSLionel Sambuc // expected-error@+2 {{the statement for '#pragma omp sections' must be a compound statement}}
19*0a6a1f1dSLionel Sambuc #pragma omp sections
20*0a6a1f1dSLionel Sambuc ++i;
21*0a6a1f1dSLionel Sambuc
22*0a6a1f1dSLionel Sambuc #pragma omp sections
23*0a6a1f1dSLionel Sambuc {
24*0a6a1f1dSLionel Sambuc foo();
25*0a6a1f1dSLionel Sambuc foo(); // expected-error {{statement in 'omp sections' directive must be enclosed into a section region}}
26*0a6a1f1dSLionel Sambuc }
27*0a6a1f1dSLionel Sambuc }
28*0a6a1f1dSLionel Sambuc
test_branch_protected_scope()29*0a6a1f1dSLionel Sambuc void test_branch_protected_scope() {
30*0a6a1f1dSLionel Sambuc int i = 0;
31*0a6a1f1dSLionel Sambuc L1:
32*0a6a1f1dSLionel Sambuc ++i;
33*0a6a1f1dSLionel Sambuc
34*0a6a1f1dSLionel Sambuc int x[24];
35*0a6a1f1dSLionel Sambuc
36*0a6a1f1dSLionel Sambuc #pragma omp parallel
37*0a6a1f1dSLionel Sambuc #pragma omp sections
38*0a6a1f1dSLionel Sambuc {
39*0a6a1f1dSLionel Sambuc if (i == 5)
40*0a6a1f1dSLionel Sambuc goto L1; // expected-error {{use of undeclared label 'L1'}}
41*0a6a1f1dSLionel Sambuc else if (i == 6)
42*0a6a1f1dSLionel Sambuc return; // expected-error {{cannot return from OpenMP region}}
43*0a6a1f1dSLionel Sambuc else if (i == 7)
44*0a6a1f1dSLionel Sambuc goto L2;
45*0a6a1f1dSLionel Sambuc else if (i == 8) {
46*0a6a1f1dSLionel Sambuc L2:
47*0a6a1f1dSLionel Sambuc x[i]++;
48*0a6a1f1dSLionel Sambuc }
49*0a6a1f1dSLionel Sambuc #pragma omp section
50*0a6a1f1dSLionel Sambuc if (i == 5)
51*0a6a1f1dSLionel Sambuc goto L1; // expected-error {{use of undeclared label 'L1'}}
52*0a6a1f1dSLionel Sambuc else if (i == 6)
53*0a6a1f1dSLionel Sambuc return; // expected-error {{cannot return from OpenMP region}}
54*0a6a1f1dSLionel Sambuc else if (i == 7)
55*0a6a1f1dSLionel Sambuc goto L3;
56*0a6a1f1dSLionel Sambuc else if (i == 8) {
57*0a6a1f1dSLionel Sambuc L3:
58*0a6a1f1dSLionel Sambuc x[i]++;
59*0a6a1f1dSLionel Sambuc }
60*0a6a1f1dSLionel Sambuc }
61*0a6a1f1dSLionel Sambuc
62*0a6a1f1dSLionel Sambuc if (x[0] == 0)
63*0a6a1f1dSLionel Sambuc goto L2; // expected-error {{use of undeclared label 'L2'}}
64*0a6a1f1dSLionel Sambuc else if (x[1] == 1)
65*0a6a1f1dSLionel Sambuc goto L1;
66*0a6a1f1dSLionel Sambuc goto L3; // expected-error {{use of undeclared label 'L3'}}
67*0a6a1f1dSLionel Sambuc }
68*0a6a1f1dSLionel Sambuc
test_invalid_clause()69*0a6a1f1dSLionel Sambuc void test_invalid_clause() {
70*0a6a1f1dSLionel Sambuc int i;
71*0a6a1f1dSLionel Sambuc #pragma omp parallel
72*0a6a1f1dSLionel Sambuc // expected-warning@+1 {{extra tokens at the end of '#pragma omp sections' are ignored}}
73*0a6a1f1dSLionel Sambuc #pragma omp sections foo bar
74*0a6a1f1dSLionel Sambuc {
75*0a6a1f1dSLionel Sambuc foo();
76*0a6a1f1dSLionel Sambuc // expected-error@+1 {{unexpected OpenMP clause 'nowait' in directive '#pragma omp section'}}
77*0a6a1f1dSLionel Sambuc #pragma omp section nowait
78*0a6a1f1dSLionel Sambuc ;
79*0a6a1f1dSLionel Sambuc }
80*0a6a1f1dSLionel Sambuc }
81*0a6a1f1dSLionel Sambuc
test_non_identifiers()82*0a6a1f1dSLionel Sambuc void test_non_identifiers() {
83*0a6a1f1dSLionel Sambuc int i, x;
84*0a6a1f1dSLionel Sambuc
85*0a6a1f1dSLionel Sambuc #pragma omp parallel
86*0a6a1f1dSLionel Sambuc // expected-warning@+1 {{extra tokens at the end of '#pragma omp sections' are ignored}}
87*0a6a1f1dSLionel Sambuc #pragma omp sections;
88*0a6a1f1dSLionel Sambuc {
89*0a6a1f1dSLionel Sambuc foo();
90*0a6a1f1dSLionel Sambuc }
91*0a6a1f1dSLionel Sambuc #pragma omp parallel
92*0a6a1f1dSLionel Sambuc // expected-error@+2 {{unexpected OpenMP clause 'linear' in directive '#pragma omp sections'}}
93*0a6a1f1dSLionel Sambuc // expected-warning@+1 {{extra tokens at the end of '#pragma omp sections' are ignored}}
94*0a6a1f1dSLionel Sambuc #pragma omp sections linear(x);
95*0a6a1f1dSLionel Sambuc {
96*0a6a1f1dSLionel Sambuc foo();
97*0a6a1f1dSLionel Sambuc }
98*0a6a1f1dSLionel Sambuc
99*0a6a1f1dSLionel Sambuc #pragma omp parallel
100*0a6a1f1dSLionel Sambuc // expected-warning@+1 {{extra tokens at the end of '#pragma omp sections' are ignored}}
101*0a6a1f1dSLionel Sambuc #pragma omp sections private(x);
102*0a6a1f1dSLionel Sambuc {
103*0a6a1f1dSLionel Sambuc foo();
104*0a6a1f1dSLionel Sambuc }
105*0a6a1f1dSLionel Sambuc
106*0a6a1f1dSLionel Sambuc #pragma omp parallel
107*0a6a1f1dSLionel Sambuc // expected-warning@+1 {{extra tokens at the end of '#pragma omp sections' are ignored}}
108*0a6a1f1dSLionel Sambuc #pragma omp sections, private(x);
109*0a6a1f1dSLionel Sambuc {
110*0a6a1f1dSLionel Sambuc foo();
111*0a6a1f1dSLionel Sambuc }
112*0a6a1f1dSLionel Sambuc }
113*0a6a1f1dSLionel Sambuc
test_private()114*0a6a1f1dSLionel Sambuc void test_private() {
115*0a6a1f1dSLionel Sambuc int i;
116*0a6a1f1dSLionel Sambuc #pragma omp parallel
117*0a6a1f1dSLionel Sambuc // expected-error@+2 {{expected expression}}
118*0a6a1f1dSLionel Sambuc // expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
119*0a6a1f1dSLionel Sambuc #pragma omp sections private(
120*0a6a1f1dSLionel Sambuc {
121*0a6a1f1dSLionel Sambuc foo();
122*0a6a1f1dSLionel Sambuc }
123*0a6a1f1dSLionel Sambuc #pragma omp parallel
124*0a6a1f1dSLionel Sambuc // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
125*0a6a1f1dSLionel Sambuc // expected-error@+1 2 {{expected expression}}
126*0a6a1f1dSLionel Sambuc #pragma omp sections private(,
127*0a6a1f1dSLionel Sambuc {
128*0a6a1f1dSLionel Sambuc foo();
129*0a6a1f1dSLionel Sambuc }
130*0a6a1f1dSLionel Sambuc #pragma omp parallel
131*0a6a1f1dSLionel Sambuc // expected-error@+1 2 {{expected expression}}
132*0a6a1f1dSLionel Sambuc #pragma omp sections private(, )
133*0a6a1f1dSLionel Sambuc {
134*0a6a1f1dSLionel Sambuc foo();
135*0a6a1f1dSLionel Sambuc }
136*0a6a1f1dSLionel Sambuc #pragma omp parallel
137*0a6a1f1dSLionel Sambuc // expected-error@+1 {{expected expression}}
138*0a6a1f1dSLionel Sambuc #pragma omp sections private()
139*0a6a1f1dSLionel Sambuc {
140*0a6a1f1dSLionel Sambuc foo();
141*0a6a1f1dSLionel Sambuc }
142*0a6a1f1dSLionel Sambuc #pragma omp parallel
143*0a6a1f1dSLionel Sambuc // expected-error@+1 {{expected expression}}
144*0a6a1f1dSLionel Sambuc #pragma omp sections private(int)
145*0a6a1f1dSLionel Sambuc {
146*0a6a1f1dSLionel Sambuc foo();
147*0a6a1f1dSLionel Sambuc }
148*0a6a1f1dSLionel Sambuc #pragma omp parallel
149*0a6a1f1dSLionel Sambuc // expected-error@+1 {{expected variable name}}
150*0a6a1f1dSLionel Sambuc #pragma omp sections private(0)
151*0a6a1f1dSLionel Sambuc {
152*0a6a1f1dSLionel Sambuc foo();
153*0a6a1f1dSLionel Sambuc }
154*0a6a1f1dSLionel Sambuc
155*0a6a1f1dSLionel Sambuc int x, y, z;
156*0a6a1f1dSLionel Sambuc #pragma omp parallel
157*0a6a1f1dSLionel Sambuc #pragma omp sections private(x)
158*0a6a1f1dSLionel Sambuc {
159*0a6a1f1dSLionel Sambuc foo();
160*0a6a1f1dSLionel Sambuc }
161*0a6a1f1dSLionel Sambuc #pragma omp parallel
162*0a6a1f1dSLionel Sambuc #pragma omp sections private(x, y)
163*0a6a1f1dSLionel Sambuc {
164*0a6a1f1dSLionel Sambuc foo();
165*0a6a1f1dSLionel Sambuc }
166*0a6a1f1dSLionel Sambuc #pragma omp parallel
167*0a6a1f1dSLionel Sambuc #pragma omp sections private(x, y, z)
168*0a6a1f1dSLionel Sambuc {
169*0a6a1f1dSLionel Sambuc foo();
170*0a6a1f1dSLionel Sambuc }
171*0a6a1f1dSLionel Sambuc }
172*0a6a1f1dSLionel Sambuc
test_lastprivate()173*0a6a1f1dSLionel Sambuc void test_lastprivate() {
174*0a6a1f1dSLionel Sambuc int i;
175*0a6a1f1dSLionel Sambuc #pragma omp parallel
176*0a6a1f1dSLionel Sambuc // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
177*0a6a1f1dSLionel Sambuc // expected-error@+1 {{expected expression}}
178*0a6a1f1dSLionel Sambuc #pragma omp sections lastprivate(
179*0a6a1f1dSLionel Sambuc {
180*0a6a1f1dSLionel Sambuc foo();
181*0a6a1f1dSLionel Sambuc }
182*0a6a1f1dSLionel Sambuc
183*0a6a1f1dSLionel Sambuc #pragma omp parallel
184*0a6a1f1dSLionel Sambuc // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
185*0a6a1f1dSLionel Sambuc // expected-error@+1 2 {{expected expression}}
186*0a6a1f1dSLionel Sambuc #pragma omp sections lastprivate(,
187*0a6a1f1dSLionel Sambuc {
188*0a6a1f1dSLionel Sambuc foo();
189*0a6a1f1dSLionel Sambuc }
190*0a6a1f1dSLionel Sambuc #pragma omp parallel
191*0a6a1f1dSLionel Sambuc // expected-error@+1 2 {{expected expression}}
192*0a6a1f1dSLionel Sambuc #pragma omp sections lastprivate(, )
193*0a6a1f1dSLionel Sambuc {
194*0a6a1f1dSLionel Sambuc foo();
195*0a6a1f1dSLionel Sambuc }
196*0a6a1f1dSLionel Sambuc #pragma omp parallel
197*0a6a1f1dSLionel Sambuc // expected-error@+1 {{expected expression}}
198*0a6a1f1dSLionel Sambuc #pragma omp sections lastprivate()
199*0a6a1f1dSLionel Sambuc {
200*0a6a1f1dSLionel Sambuc foo();
201*0a6a1f1dSLionel Sambuc }
202*0a6a1f1dSLionel Sambuc #pragma omp parallel
203*0a6a1f1dSLionel Sambuc // expected-error@+1 {{expected expression}}
204*0a6a1f1dSLionel Sambuc #pragma omp sections lastprivate(int)
205*0a6a1f1dSLionel Sambuc {
206*0a6a1f1dSLionel Sambuc foo();
207*0a6a1f1dSLionel Sambuc }
208*0a6a1f1dSLionel Sambuc #pragma omp parallel
209*0a6a1f1dSLionel Sambuc // expected-error@+1 {{expected variable name}}
210*0a6a1f1dSLionel Sambuc #pragma omp sections lastprivate(0)
211*0a6a1f1dSLionel Sambuc {
212*0a6a1f1dSLionel Sambuc foo();
213*0a6a1f1dSLionel Sambuc }
214*0a6a1f1dSLionel Sambuc
215*0a6a1f1dSLionel Sambuc int x, y, z;
216*0a6a1f1dSLionel Sambuc #pragma omp parallel
217*0a6a1f1dSLionel Sambuc #pragma omp sections lastprivate(x)
218*0a6a1f1dSLionel Sambuc {
219*0a6a1f1dSLionel Sambuc foo();
220*0a6a1f1dSLionel Sambuc }
221*0a6a1f1dSLionel Sambuc #pragma omp parallel
222*0a6a1f1dSLionel Sambuc #pragma omp sections lastprivate(x, y)
223*0a6a1f1dSLionel Sambuc {
224*0a6a1f1dSLionel Sambuc foo();
225*0a6a1f1dSLionel Sambuc }
226*0a6a1f1dSLionel Sambuc #pragma omp parallel
227*0a6a1f1dSLionel Sambuc #pragma omp sections lastprivate(x, y, z)
228*0a6a1f1dSLionel Sambuc {
229*0a6a1f1dSLionel Sambuc foo();
230*0a6a1f1dSLionel Sambuc }
231*0a6a1f1dSLionel Sambuc }
232*0a6a1f1dSLionel Sambuc
test_firstprivate()233*0a6a1f1dSLionel Sambuc void test_firstprivate() {
234*0a6a1f1dSLionel Sambuc int i;
235*0a6a1f1dSLionel Sambuc #pragma omp parallel
236*0a6a1f1dSLionel Sambuc // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
237*0a6a1f1dSLionel Sambuc // expected-error@+1 {{expected expression}}
238*0a6a1f1dSLionel Sambuc #pragma omp sections firstprivate(
239*0a6a1f1dSLionel Sambuc {
240*0a6a1f1dSLionel Sambuc foo();
241*0a6a1f1dSLionel Sambuc }
242*0a6a1f1dSLionel Sambuc
243*0a6a1f1dSLionel Sambuc #pragma omp parallel
244*0a6a1f1dSLionel Sambuc // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
245*0a6a1f1dSLionel Sambuc // expected-error@+1 2 {{expected expression}}
246*0a6a1f1dSLionel Sambuc #pragma omp sections firstprivate(,
247*0a6a1f1dSLionel Sambuc {
248*0a6a1f1dSLionel Sambuc foo();
249*0a6a1f1dSLionel Sambuc }
250*0a6a1f1dSLionel Sambuc #pragma omp parallel
251*0a6a1f1dSLionel Sambuc // expected-error@+1 2 {{expected expression}}
252*0a6a1f1dSLionel Sambuc #pragma omp sections firstprivate(, )
253*0a6a1f1dSLionel Sambuc {
254*0a6a1f1dSLionel Sambuc foo();
255*0a6a1f1dSLionel Sambuc }
256*0a6a1f1dSLionel Sambuc #pragma omp parallel
257*0a6a1f1dSLionel Sambuc // expected-error@+1 {{expected expression}}
258*0a6a1f1dSLionel Sambuc #pragma omp sections firstprivate()
259*0a6a1f1dSLionel Sambuc {
260*0a6a1f1dSLionel Sambuc foo();
261*0a6a1f1dSLionel Sambuc }
262*0a6a1f1dSLionel Sambuc #pragma omp parallel
263*0a6a1f1dSLionel Sambuc // expected-error@+1 {{expected expression}}
264*0a6a1f1dSLionel Sambuc #pragma omp sections firstprivate(int)
265*0a6a1f1dSLionel Sambuc {
266*0a6a1f1dSLionel Sambuc foo();
267*0a6a1f1dSLionel Sambuc }
268*0a6a1f1dSLionel Sambuc #pragma omp parallel
269*0a6a1f1dSLionel Sambuc // expected-error@+1 {{expected variable name}}
270*0a6a1f1dSLionel Sambuc #pragma omp sections firstprivate(0)
271*0a6a1f1dSLionel Sambuc {
272*0a6a1f1dSLionel Sambuc foo();
273*0a6a1f1dSLionel Sambuc }
274*0a6a1f1dSLionel Sambuc
275*0a6a1f1dSLionel Sambuc int x, y, z;
276*0a6a1f1dSLionel Sambuc #pragma omp parallel
277*0a6a1f1dSLionel Sambuc #pragma omp sections lastprivate(x) firstprivate(x)
278*0a6a1f1dSLionel Sambuc {
279*0a6a1f1dSLionel Sambuc foo();
280*0a6a1f1dSLionel Sambuc }
281*0a6a1f1dSLionel Sambuc #pragma omp parallel
282*0a6a1f1dSLionel Sambuc #pragma omp sections lastprivate(x, y) firstprivate(x, y)
283*0a6a1f1dSLionel Sambuc {
284*0a6a1f1dSLionel Sambuc foo();
285*0a6a1f1dSLionel Sambuc }
286*0a6a1f1dSLionel Sambuc #pragma omp parallel
287*0a6a1f1dSLionel Sambuc #pragma omp sections lastprivate(x, y, z) firstprivate(x, y, z)
288*0a6a1f1dSLionel Sambuc {
289*0a6a1f1dSLionel Sambuc foo();
290*0a6a1f1dSLionel Sambuc }
291*0a6a1f1dSLionel Sambuc }
292*0a6a1f1dSLionel Sambuc
test_nowait()293*0a6a1f1dSLionel Sambuc void test_nowait() {
294*0a6a1f1dSLionel Sambuc #pragma omp parallel
295*0a6a1f1dSLionel Sambuc #pragma omp sections nowait nowait // expected-error {{directive '#pragma omp sections' cannot contain more than one 'nowait' clause}}
296*0a6a1f1dSLionel Sambuc {
297*0a6a1f1dSLionel Sambuc ;
298*0a6a1f1dSLionel Sambuc }
299*0a6a1f1dSLionel Sambuc }
300