1 | // RUN: %clang_cc1 -verify -fopenmp %s |
2 | |
3 | // RUN: %clang_cc1 -verify -fopenmp-simd %s |
4 | |
5 | extern int omp_default_mem_alloc; |
6 | void foo() { |
7 | } |
8 | |
9 | bool foobool(int argc) { |
10 | return argc; |
11 | } |
12 | |
13 | struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}} |
14 | extern S1 a; |
15 | class S2 { |
16 | mutable int a; |
17 | |
18 | public: |
19 | S2() : a(0) {} |
20 | S2(const S2 &s2) : a(s2.a) {} |
21 | static float S2s; |
22 | static const float S2sc; |
23 | }; |
24 | const float S2::S2sc = 0; |
25 | const S2 b; |
26 | const S2 ba[5]; |
27 | class S3 { |
28 | int a; |
29 | S3 &operator=(const S3 &s3); |
30 | |
31 | public: |
32 | S3() : a(0) {} |
33 | S3(const S3 &s3) : a(s3.a) {} |
34 | }; |
35 | const S3 c; |
36 | const S3 ca[5]; |
37 | extern const int f; |
38 | class S4 { |
39 | int a; |
40 | S4(); |
41 | S4(const S4 &s4); // expected-note 2 {{implicitly declared private here}} |
42 | |
43 | public: |
44 | S4(int v) : a(v) {} |
45 | }; |
46 | class S5 { |
47 | int a; |
48 | S5(const S5 &s5) : a(s5.a) {} // expected-note 4 {{implicitly declared private here}} |
49 | |
50 | public: |
51 | S5() : a(0) {} |
52 | S5(int v) : a(v) {} |
53 | }; |
54 | class S6 { |
55 | int a; |
56 | S6() : a(0) {} |
57 | |
58 | public: |
59 | S6(const S6 &s6) : a(s6.a) {} |
60 | S6(int v) : a(v) {} |
61 | }; |
62 | |
63 | S3 h; |
64 | #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}} |
65 | |
66 | template <class I, class C> |
67 | int foomain(int argc, char **argv) { |
68 | I e(4); |
69 | C g(5); |
70 | int i; |
71 | int &j = i; |
72 | #pragma omp parallel sections firstprivate // expected-error {{expected '(' after 'firstprivate'}} |
73 | { |
74 | foo(); |
75 | } |
76 | #pragma omp parallel sections firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
77 | { |
78 | foo(); |
79 | } |
80 | #pragma omp parallel sections firstprivate() // expected-error {{expected expression}} |
81 | { |
82 | foo(); |
83 | } |
84 | #pragma omp parallel sections firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} |
85 | { |
86 | foo(); |
87 | } |
88 | #pragma omp parallel sections firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
89 | { |
90 | foo(); |
91 | } |
92 | #pragma omp parallel sections firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} |
93 | { |
94 | foo(); |
95 | } |
96 | #pragma omp parallel sections firstprivate(argc) allocate , allocate(, allocate(omp_default , allocate(omp_default_mem_alloc, allocate(omp_default_mem_alloc:, allocate(omp_default_mem_alloc: argc, allocate(omp_default_mem_alloc: argv), allocate(argv) // expected-error {{expected '(' after 'allocate'}} expected-error 2 {{expected expression}} expected-error 2 {{expected ')'}} expected-error {{use of undeclared identifier 'omp_default'}} expected-note 2 {{to match this '('}} |
97 | { |
98 | foo(); |
99 | } |
100 | #pragma omp parallel sections firstprivate(S1) // expected-error {{'S1' does not refer to a value}} |
101 | { |
102 | foo(); |
103 | } |
104 | #pragma omp parallel sections firstprivate(a, b) // expected-error {{firstprivate variable with incomplete type 'S1'}} |
105 | { |
106 | foo(); |
107 | } |
108 | #pragma omp parallel sections firstprivate(argv[1]) // expected-error {{expected variable name}} |
109 | { |
110 | foo(); |
111 | } |
112 | #pragma omp parallel sections firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} |
113 | { |
114 | foo(); |
115 | } |
116 | #pragma omp parallel sections firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}} |
117 | { |
118 | foo(); |
119 | } |
120 | #pragma omp parallel sections linear(i) // expected-error {{unexpected OpenMP clause 'linear' in directive '#pragma omp parallel sections'}} |
121 | { |
122 | foo(); |
123 | } |
124 | #pragma omp parallel |
125 | { |
126 | int v = 0; |
127 | int i; |
128 | #pragma omp parallel sections firstprivate(i) |
129 | { |
130 | foo(); |
131 | } |
132 | v += i; |
133 | } |
134 | #pragma omp parallel shared(i) |
135 | #pragma omp parallel private(i) |
136 | #pragma omp parallel sections firstprivate(j) |
137 | { |
138 | foo(); |
139 | } |
140 | #pragma omp parallel sections firstprivate(i) |
141 | { |
142 | foo(); |
143 | } |
144 | #pragma omp parallel sections lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}} |
145 | { |
146 | foo(); |
147 | } |
148 | #pragma omp parallel private(i) |
149 | #pragma omp parallel sections firstprivate(i) |
150 | { |
151 | foo(); |
152 | } |
153 | #pragma omp parallel reduction(+ : i) |
154 | #pragma omp parallel sections firstprivate(i) |
155 | { |
156 | foo(); |
157 | } |
158 | return 0; |
159 | } |
160 | |
161 | namespace A { |
162 | double x; |
163 | #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}} |
164 | } |
165 | namespace B { |
166 | using A::x; |
167 | } |
168 | |
169 | int main(int argc, char **argv) { |
170 | const int d = 5; |
171 | const int da[5] = {0}; |
172 | S4 e(4); |
173 | S5 g(5); |
174 | S3 m; |
175 | S6 n(2); |
176 | int i; |
177 | int &j = i; |
178 | #pragma omp parallel sections firstprivate // expected-error {{expected '(' after 'firstprivate'}} |
179 | { |
180 | foo(); |
181 | } |
182 | #pragma omp parallel sections firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
183 | { |
184 | foo(); |
185 | } |
186 | #pragma omp parallel sections firstprivate() // expected-error {{expected expression}} |
187 | { |
188 | foo(); |
189 | } |
190 | #pragma omp parallel sections firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} |
191 | { |
192 | foo(); |
193 | } |
194 | #pragma omp parallel sections firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
195 | { |
196 | foo(); |
197 | } |
198 | #pragma omp parallel sections firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} |
199 | { |
200 | foo(); |
201 | } |
202 | #pragma omp parallel sections firstprivate(argc) |
203 | { |
204 | foo(); |
205 | } |
206 | #pragma omp parallel sections firstprivate(S1) // expected-error {{'S1' does not refer to a value}} |
207 | { |
208 | foo(); |
209 | } |
210 | #pragma omp parallel sections firstprivate(a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}} |
211 | { |
212 | foo(); |
213 | } |
214 | #pragma omp parallel sections firstprivate(argv[1]) // expected-error {{expected variable name}} |
215 | { |
216 | foo(); |
217 | } |
218 | #pragma omp parallel sections firstprivate(2 * 2) // expected-error {{expected variable name}} |
219 | { |
220 | foo(); |
221 | } |
222 | #pragma omp parallel sections firstprivate(ba) // OK |
223 | { |
224 | foo(); |
225 | } |
226 | #pragma omp parallel sections firstprivate(ca) // OK |
227 | { |
228 | foo(); |
229 | } |
230 | #pragma omp parallel sections firstprivate(da) // OK |
231 | { |
232 | foo(); |
233 | } |
234 | int xa; |
235 | #pragma omp parallel sections firstprivate(xa) // OK |
236 | { |
237 | foo(); |
238 | } |
239 | #pragma omp parallel sections firstprivate(S2::S2s) // OK |
240 | { |
241 | foo(); |
242 | } |
243 | #pragma omp parallel sections firstprivate(S2::S2sc) // OK |
244 | { |
245 | foo(); |
246 | } |
247 | #pragma omp parallel sections safelen(5) // expected-error {{unexpected OpenMP clause 'safelen' in directive '#pragma omp parallel sections'}} |
248 | { |
249 | foo(); |
250 | } |
251 | #pragma omp parallel sections firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} |
252 | { |
253 | foo(); |
254 | } |
255 | #pragma omp parallel sections firstprivate(m) // OK |
256 | { |
257 | foo(); |
258 | } |
259 | #pragma omp parallel sections firstprivate(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be firstprivate}} |
260 | { |
261 | foo(); |
262 | } |
263 | #pragma omp parallel sections private(xa), firstprivate(xa) // expected-error {{private variable cannot be firstprivate}} expected-note {{defined as private}} |
264 | { |
265 | foo(); |
266 | } |
267 | #pragma omp parallel shared(xa) |
268 | #pragma omp parallel sections firstprivate(xa) // OK: may be firstprivate |
269 | { |
270 | foo(); |
271 | } |
272 | #pragma omp parallel sections firstprivate(j) |
273 | { |
274 | foo(); |
275 | } |
276 | #pragma omp parallel sections lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}} |
277 | { |
278 | foo(); |
279 | } |
280 | #pragma omp parallel sections lastprivate(n) firstprivate(n) // OK |
281 | { |
282 | foo(); |
283 | } |
284 | #pragma omp parallel |
285 | { |
286 | int v = 0; |
287 | int i; |
288 | #pragma omp parallel sections firstprivate(i) |
289 | { |
290 | foo(); |
291 | } |
292 | v += i; |
293 | } |
294 | #pragma omp parallel private(i) |
295 | #pragma omp parallel sections firstprivate(i) |
296 | { |
297 | foo(); |
298 | } |
299 | #pragma omp parallel reduction(+ : i) |
300 | #pragma omp parallel sections firstprivate(i) |
301 | { |
302 | foo(); |
303 | } |
304 | static int r; |
305 | #pragma omp parallel sections firstprivate(r) // OK |
306 | { |
307 | foo(); |
308 | } |
309 | |
310 | return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}} |
311 | } |
312 | |