1 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 %s -Wuninitialized
2 // RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
4 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 %s -Wuninitialized
5 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
10 bool foobool(int argc
) {
13 extern int omp_default_mem_alloc
;
14 struct S1
; // expected-note 2 {{declared here}} expected-note 3 {{forward declaration of 'S1'}}
21 S2(S2
&s2
) : a(s2
.a
) {}
22 const S2
&operator =(const S2
&) const;
23 S2
&operator =(const S2
&);
24 static float S2s
; // expected-note {{static data member is predetermined as shared}}
25 static const float S2sc
; // expected-note {{'S2sc' declared here}}
27 const float S2::S2sc
= 0;
32 S3
&operator=(const S3
&s3
); // expected-note {{implicitly declared private here}}
36 S3(S3
&s3
) : a(s3
.a
) {}
38 const S3 c
; // expected-note {{'c' defined here}}
39 const S3 ca
[5]; // expected-note {{'ca' defined here}}
40 extern const int f
; // expected-note {{'f' declared here}}
43 S4(); // expected-note 3 {{implicitly declared private here}}
51 S5() : a(0) {} // expected-note {{implicitly declared private here}}
54 S5(const S5
&s5
) : a(s5
.a
) {}
59 S6() : a(0) {} // expected-note {{implicitly declared private here}}
62 S6(const S6
&s6
) : a(s6
.a
) {}
67 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
69 template <class I
, class C
>
70 int foomain(int argc
, char **argv
) {
77 #pragma omp distribute parallel for lastprivate // expected-error {{expected '(' after 'lastprivate'}}
78 for (int k
= 0; k
< argc
; ++k
)
82 #pragma omp distribute parallel for lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
83 for (int k
= 0; k
< argc
; ++k
)
87 #pragma omp distribute parallel for lastprivate() // expected-error {{expected expression}}
88 for (int k
= 0; k
< argc
; ++k
)
92 #pragma omp distribute parallel for lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
93 for (int k
= 0; k
< argc
; ++k
)
97 #pragma omp distribute parallel for lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
98 for (int k
= 0; k
< argc
; ++k
)
102 #pragma omp distribute parallel for lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
103 for (int k
= 0; k
< argc
; ++k
)
107 #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 '('}}
108 for (int k
= 0; k
< argc
; ++k
)
112 #pragma omp distribute parallel for lastprivate(conditional: argc) lastprivate(conditional: // expected-error 2 {{use of undeclared identifier 'conditional'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
113 for (int k
= 0; k
< argc
; ++k
)
117 #pragma omp distribute parallel for lastprivate(S1) // expected-error {{'S1' does not refer to a value}}
118 for (int k
= 0; k
< argc
; ++k
)
122 #pragma omp distribute parallel for lastprivate(a, b) // expected-error {{lastprivate variable with incomplete type 'S1'}} expected-warning {{Type 'const S2' is not trivially copyable and not guaranteed to be mapped correctly}}
123 for (int k
= 0; k
< argc
; ++k
)
127 #pragma omp distribute parallel for lastprivate(argv[1]) // expected-error {{expected variable name}}
128 for (int k
= 0; k
< argc
; ++k
)
132 #pragma omp distribute parallel for lastprivate(e, g) // expected-error 2 {{calling a private constructor of class 'S4'}} expected-warning 2 {{Type 'S4' is not trivially copyable and not guaranteed to be mapped correctly}}
133 for (int k
= 0; k
< argc
; ++k
)
137 #pragma omp distribute parallel for lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}}
138 for (int k
= 0; k
< argc
; ++k
)
145 #pragma omp distribute parallel for lastprivate(i)
146 for (int k
= 0; k
< argc
; ++k
) {
152 #pragma omp teams private(i)
153 #pragma omp distribute parallel for lastprivate(j)
154 for (int k
= 0; k
< argc
; ++k
)
158 #pragma omp distribute parallel for lastprivate(i)
159 for (int k
= 0; k
< argc
; ++k
)
167 #pragma omp distribute parallel for lastprivate(a)
168 for (int i
= 0; i
< 2; ++i
)
174 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
180 int main(int argc
, char **argv
) {
181 const int d
= 5; // expected-note {{'d' defined here}}
182 const int da
[5] = {0}; // expected-note {{'da' defined here}}
191 #pragma omp distribute parallel for lastprivate // expected-error {{expected '(' after 'lastprivate'}}
192 for (i
= 0; i
< argc
; ++i
)
196 #pragma omp distribute parallel for lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
197 for (i
= 0; i
< argc
; ++i
)
201 #pragma omp distribute parallel for lastprivate() // expected-error {{expected expression}}
202 for (i
= 0; i
< argc
; ++i
)
206 #pragma omp distribute parallel for lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
207 for (i
= 0; i
< argc
; ++i
)
211 #pragma omp distribute parallel for lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
212 for (i
= 0; i
< argc
; ++i
)
216 #pragma omp distribute parallel for lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
217 for (i
= 0; i
< argc
; ++i
)
221 #pragma omp distribute parallel for lastprivate(argc)
222 for (i
= 0; i
< argc
; ++i
)
226 #pragma omp distribute parallel for lastprivate(S1) // expected-error {{'S1' does not refer to a value}}
227 for (i
= 0; i
< argc
; ++i
)
231 #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 {{Type 'const S2' is not trivially copyable and not guaranteed to be mapped correctly}} expected-warning {{Type 'const S3' is not trivially copyable and not guaranteed to be mapped correctly}}
232 for (i
= 0; i
< argc
; ++i
)
236 #pragma omp distribute parallel for lastprivate(argv[1]) // expected-error {{expected variable name}}
237 for (i
= 0; i
< argc
; ++i
)
241 #pragma omp distribute parallel for lastprivate(2 * 2) // expected-error {{expected variable name}}
242 for (i
= 0; i
< argc
; ++i
)
246 #pragma omp distribute parallel for lastprivate(ba) // expected-warning {{Type 'const S2[5]' is not trivially copyable and not guaranteed to be mapped correctly}}
247 for (i
= 0; i
< argc
; ++i
)
251 #pragma omp distribute parallel for lastprivate(ca) // expected-error {{const-qualified variable without mutable fields cannot be lastprivate}} expected-warning {{Type 'const S3[5]' is not trivially copyable and not guaranteed to be mapped correctly}}
252 for (i
= 0; i
< argc
; ++i
)
256 #pragma omp distribute parallel for lastprivate(da) // expected-error {{const-qualified variable cannot be lastprivate}}
257 for (i
= 0; i
< argc
; ++i
)
262 #pragma omp distribute parallel for lastprivate(xa) // OK
263 for (i
= 0; i
< argc
; ++i
)
267 #pragma omp distribute parallel for lastprivate(S2::S2s) // expected-error {{shared variable cannot be lastprivate}}
268 for (i
= 0; i
< argc
; ++i
)
272 #pragma omp distribute parallel for lastprivate(S2::S2sc) // expected-error {{const-qualified variable cannot be lastprivate}}
273 for (i
= 0; i
< argc
; ++i
)
277 #pragma omp distribute parallel for safelen(5) // expected-error {{unexpected OpenMP clause 'safelen' in directive '#pragma omp distribute parallel for'}}
278 for (i
= 0; i
< argc
; ++i
)
282 #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 {{Type 'S4' is not trivially copyable and not guaranteed to be mapped correctly}} expected-warning {{Type 'S5' is not trivially copyable and not guaranteed to be mapped correctly}}
283 for (i
= 0; i
< argc
; ++i
)
287 #pragma omp distribute parallel for lastprivate(m) // expected-error {{'operator=' is a private member of 'S3'}} expected-warning {{Type 'S3' is not trivially copyable and not guaranteed to be mapped correctly}}
288 for (i
= 0; i
< argc
; ++i
)
292 #pragma omp distribute parallel for lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}}
293 for (i
= 0; i
< argc
; ++i
)
297 #pragma omp distribute parallel for lastprivate(B::x) // expected-error {{threadprivate or thread local variable cannot be lastprivate}}
298 for (i
= 0; i
< argc
; ++i
)
302 #pragma omp distribute parallel for private(xa), lastprivate(xa) // expected-error {{private variable cannot be lastprivate}} expected-note {{defined as private}}
303 for (i
= 0; i
< argc
; ++i
)
307 #pragma omp distribute parallel for lastprivate(i)
308 for (i
= 0; i
< argc
; ++i
)
312 #pragma omp distribute parallel for lastprivate(xa)
313 for (i
= 0; i
< argc
; ++i
)
317 #pragma omp distribute parallel for lastprivate(xa)
318 for (i
= 0; i
< argc
; ++i
)
322 #pragma omp distribute parallel for lastprivate(j)
323 for (i
= 0; i
< argc
; ++i
)
325 // expected-error@+3 {{firstprivate variable cannot be lastprivate}} expected-note@+3 {{defined as firstprivate}}
328 #pragma omp distribute parallel for firstprivate(m) lastprivate(m) // expected-warning {{Type 'S3' is not trivially copyable and not guaranteed to be mapped correctly}}
329 for (i
= 0; i
< argc
; ++i
)
331 // expected-error@+3 {{lastprivate variable cannot be firstprivate}} expected-note@+3 {{defined as lastprivate}}
334 #pragma omp distribute parallel for lastprivate(n) firstprivate(n) // expected-error {{calling a private constructor of class 'S6'}} expected-warning {{Type 'S6' is not trivially copyable and not guaranteed to be mapped correctly}}
335 for (i
= 0; i
< argc
; ++i
)
340 #pragma omp distribute parallel for lastprivate(si) // OK
341 for (i
= 0; i
< argc
; ++i
)
343 return foomain
<S4
, S5
>(argc
, argv
); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}