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