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