1 // RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
3 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
8 bool foobool(int argc
) {
13 int fp
; // expected-note {{initialize the variable 'fp' to silence this warning}}
14 #pragma omp distribute parallel for firstprivate(fp) // expected-warning {{variable 'fp' is uninitialized when used here}}
15 for (int i
= 0; i
< 10; ++i
)
19 extern int omp_default_mem_alloc
;
21 struct S1
; // expected-note 2 {{declared here}} expected-note 3 {{forward declaration of 'S1'}}
28 S2(const S2
&s2
) : a(s2
.a
) {}
30 static const float S2sc
;
32 const float S2::S2sc
= 0;
37 S3
&operator=(const S3
&s3
);
41 S3(const S3
&s3
) : a(s3
.a
) {}
49 S4(const S4
&s4
); // expected-note 2 {{implicitly declared private here}}
56 S5(const S5
&s5
) : a(s5
.a
) {} // expected-note 2 {{implicitly declared private here}}
64 S6() : a(0) {} // expected-note {{implicitly declared private here}}
67 S6(const S6
&s6
) : a(s6
.a
) {}
72 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
74 template <class I
, class C
>
75 int foomain(int argc
, char **argv
) {
82 #pragma omp distribute parallel for firstprivate // expected-error {{expected '(' after 'firstprivate'}}
83 for (int k
= 0; k
< argc
; ++k
)
87 #pragma omp distribute parallel for firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
88 for (int k
= 0; k
< argc
; ++k
)
92 #pragma omp distribute parallel for firstprivate() // expected-error {{expected expression}}
93 for (int k
= 0; k
< argc
; ++k
)
97 #pragma omp distribute parallel for firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
98 for (int k
= 0; k
< argc
; ++k
)
102 #pragma omp distribute parallel for firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
103 for (int k
= 0; k
< argc
; ++k
)
107 #pragma omp distribute parallel for firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
108 for (int k
= 0; k
< argc
; ++k
)
112 #pragma omp distribute parallel for 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 '('}}
113 for (int k
= 0; k
< argc
; ++k
)
117 #pragma omp distribute parallel for firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
118 for (int k
= 0; k
< argc
; ++k
)
122 #pragma omp distribute parallel for firstprivate(a, b) // expected-error {{firstprivate 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 firstprivate(argv[1]) // expected-error {{expected variable name}}
128 for (int k
= 0; k
< argc
; ++k
)
132 #pragma omp distribute parallel for firstprivate(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}}
133 for (int k
= 0; k
< argc
; ++k
)
137 #pragma omp distribute parallel for firstprivate(k, h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
138 for (int k
= 0; k
< argc
; ++k
)
146 #pragma omp distribute parallel for firstprivate(i)
147 for (int k
= 0; k
< argc
; ++k
) {
152 #pragma omp parallel shared(i)
153 #pragma omp parallel private(i)
156 #pragma omp distribute parallel for firstprivate(j)
157 for (int k
= 0; k
< argc
; ++k
)
161 #pragma omp distribute parallel for firstprivate(i)
162 for (int k
= 0; k
< argc
; ++k
)
164 // expected-error@+3 {{lastprivate variable cannot be firstprivate}} expected-note@+3 {{defined as lastprivate}}
167 #pragma omp distribute parallel for lastprivate(g) firstprivate(g)
168 for (i
= 0; i
< argc
; ++i
)
170 #pragma omp parallel private(i)
173 #pragma omp distribute parallel for firstprivate(i) // expected-note 2 {{defined as firstprivate}}
174 for (i
= 0; i
< argc
; ++i
) // expected-error 2 {{loop iteration variable in the associated loop of 'omp distribute parallel for' directive may not be firstprivate, predetermined as private}}
176 #pragma omp parallel reduction(+ : i)
179 #pragma omp distribute parallel for firstprivate(i) // expected-note 2 {{defined as firstprivate}}
180 for (i
= 0; i
< argc
; ++i
) // expected-error 2 {{loop iteration variable in the associated loop of 'omp distribute parallel for' directive may not be firstprivate, predetermined as private}}
187 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
193 int main(int argc
, char **argv
) {
195 const int da
[5] = {0};
204 #pragma omp distribute parallel for firstprivate // expected-error {{expected '(' after 'firstprivate'}}
205 for (i
= 0; i
< argc
; ++i
)
209 #pragma omp distribute parallel for firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
210 for (i
= 0; i
< argc
; ++i
)
214 #pragma omp distribute parallel for firstprivate() // expected-error {{expected expression}}
215 for (i
= 0; i
< argc
; ++i
)
219 #pragma omp distribute parallel for firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
220 for (i
= 0; i
< argc
; ++i
)
224 #pragma omp distribute parallel for firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
225 for (i
= 0; i
< argc
; ++i
)
229 #pragma omp distribute parallel for firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
230 for (i
= 0; i
< argc
; ++i
)
234 #pragma omp distribute parallel for firstprivate(argc)
235 for (i
= 0; i
< argc
; ++i
)
239 #pragma omp distribute parallel for firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
240 for (i
= 0; i
< argc
; ++i
)
244 #pragma omp distribute parallel for firstprivate(a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}} 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}}
245 for (i
= 0; i
< argc
; ++i
)
249 #pragma omp distribute parallel for firstprivate(argv[1]) // expected-error {{expected variable name}}
250 for (i
= 0; i
< argc
; ++i
)
254 #pragma omp distribute parallel for firstprivate(2 * 2) // expected-error {{expected variable name}}
255 for (i
= 0; i
< argc
; ++i
)
259 #pragma omp distribute parallel for firstprivate(ba) // expected-warning {{Type 'const S2[5]' is not trivially copyable and not guaranteed to be mapped correctly}}
260 for (i
= 0; i
< argc
; ++i
)
264 #pragma omp distribute parallel for firstprivate(ca) // expected-warning {{Type 'const S3[5]' is not trivially copyable and not guaranteed to be mapped correctly}}
265 for (i
= 0; i
< argc
; ++i
)
269 #pragma omp distribute parallel for firstprivate(da) // OK
270 for (i
= 0; i
< argc
; ++i
)
275 #pragma omp distribute parallel for firstprivate(xa) // OK
276 for (i
= 0; i
< argc
; ++i
)
280 #pragma omp distribute parallel for firstprivate(S2::S2s) // OK
281 for (i
= 0; i
< argc
; ++i
)
285 #pragma omp distribute parallel for firstprivate(S2::S2sc) // OK
286 for (i
= 0; i
< argc
; ++i
)
290 #pragma omp distribute parallel for safelen(5) // expected-error {{unexpected OpenMP clause 'safelen' in directive '#pragma omp distribute parallel for'}}
291 for (i
= 0; i
< argc
; ++i
)
295 #pragma omp distribute parallel for firstprivate(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}}
296 for (i
= 0; i
< argc
; ++i
)
300 #pragma omp distribute parallel for firstprivate(m) // expected-warning {{Type 'S3' is not trivially copyable and not guaranteed to be mapped correctly}}
301 for (i
= 0; i
< argc
; ++i
)
305 #pragma omp distribute parallel for firstprivate(k, h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be firstprivate}}
306 for (i
= 0; i
< argc
; ++i
)
310 #pragma omp distribute parallel for private(xa), firstprivate(xa) // expected-error {{private variable cannot be firstprivate}} expected-note {{defined as private}}
311 for (i
= 0; i
< argc
; ++i
)
315 #pragma omp distribute parallel for firstprivate(i) // expected-note {{defined as firstprivate}}
316 for (i
= 0; i
< argc
; ++i
) // expected-error {{loop iteration variable in the associated loop of 'omp distribute parallel for' directive may not be firstprivate, predetermined as private}}
318 #pragma omp parallel shared(xa)
321 #pragma omp distribute parallel for firstprivate(xa) // OK: may be firstprivate
322 for (i
= 0; i
< argc
; ++i
)
326 #pragma omp distribute parallel for firstprivate(j)
327 for (i
= 0; i
< argc
; ++i
)
329 // expected-error@+3 {{lastprivate variable cannot be firstprivate}} expected-note@+3 {{defined as lastprivate}}
332 #pragma omp distribute parallel for lastprivate(g) firstprivate(g) // expected-warning {{Type 'S5' is not trivially copyable and not guaranteed to be mapped correctly}}
333 for (i
= 0; i
< argc
; ++i
)
335 // expected-error@+3 {{lastprivate variable cannot be firstprivate}} expected-note@+3 {{defined as lastprivate}}
338 #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}}
339 for (i
= 0; i
< argc
; ++i
)
347 #pragma omp distribute parallel for firstprivate(i)
348 for (int k
= 0; k
< argc
; ++k
) {
353 #pragma omp parallel private(i)
356 #pragma omp distribute parallel for firstprivate(i) // expected-note {{defined as firstprivate}}
357 for (i
= 0; i
< argc
; ++i
) // expected-error {{loop iteration variable in the associated loop of 'omp distribute parallel for' directive may not be firstprivate, predetermined as private}}
359 #pragma omp parallel reduction(+ : i)
362 #pragma omp distribute parallel for firstprivate(i) // expected-note {{defined as firstprivate}}
363 for (i
= 0; i
< argc
; ++i
) // expected-error {{loop iteration variable in the associated loop of 'omp distribute parallel for' directive may not be firstprivate, predetermined as private}}
368 #pragma omp distribute parallel for firstprivate(si) // OK
369 for (i
= 0; i
< argc
; ++i
)
372 return foomain
<S4
, S5
>(argc
, argv
); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}