1 // RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
3 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
5 extern int omp_default_mem_alloc
;
9 bool foobool(int argc
) {
14 int fp
; // expected-note {{initialize the variable 'fp' to silence this warning}}
15 #pragma omp parallel masked firstprivate(fp) // expected-warning {{variable 'fp' is uninitialized when used here}}
17 for (int i
= 0; i
< 10; ++i
)
22 struct S1
; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
29 S2(const S2
&s2
) : a(s2
.a
) {}
31 static const float S2sc
;
33 const float S2::S2sc
= 0;
38 S3
&operator=(const S3
&s3
);
42 S3(const S3
&s3
) : a(s3
.a
) {}
50 S4(const S4
&s4
); // expected-note 2 {{implicitly declared private here}}
57 S5(const S5
&s5
) : a(s5
.a
) {} // expected-note 4 {{implicitly declared private here}}
68 S6(const S6
&s6
) : a(s6
.a
) {}
73 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
75 template <class I
, class C
>
76 int foomain(int argc
, char **argv
) {
81 #pragma omp parallel masked firstprivate // expected-error {{expected '(' after 'firstprivate'}}
85 #pragma omp parallel masked firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
89 #pragma omp parallel masked firstprivate() // expected-error {{expected expression}}
93 #pragma omp parallel masked firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
97 #pragma omp parallel masked firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
101 #pragma omp parallel masked firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
105 #pragma omp parallel masked 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 '('}}
109 #pragma omp parallel masked firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
113 #pragma omp parallel masked firstprivate(z, a, b) // expected-error {{firstprivate variable with incomplete type 'S1'}}
117 #pragma omp parallel masked firstprivate(argv[1]) // expected-error {{expected variable name}}
121 #pragma omp parallel masked firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
125 #pragma omp parallel masked firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
129 #pragma omp parallel masked linear(i) // expected-error {{unexpected OpenMP clause 'linear' in directive '#pragma omp parallel masked'}}
137 #pragma omp parallel masked firstprivate(i)
143 #pragma omp parallel shared(i)
144 #pragma omp parallel private(i)
145 #pragma omp parallel masked firstprivate(j)
149 #pragma omp parallel masked firstprivate(i)
153 #pragma omp parallel masked firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
157 #pragma omp parallel private(i)
158 #pragma omp parallel masked firstprivate(i)
162 #pragma omp parallel reduction(+ : i)
163 #pragma omp parallel masked firstprivate(i)
172 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
178 int main(int argc
, char **argv
) {
180 const int da
[5] = {0};
187 #pragma omp parallel masked firstprivate // expected-error {{expected '(' after 'firstprivate'}}
191 #pragma omp parallel masked firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
195 #pragma omp parallel masked firstprivate() // expected-error {{expected expression}}
199 #pragma omp parallel masked firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
203 #pragma omp parallel masked firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
207 #pragma omp parallel masked firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
211 #pragma omp parallel masked firstprivate(argc, z)
215 #pragma omp parallel masked firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
219 #pragma omp parallel masked firstprivate(a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}}
223 #pragma omp parallel masked firstprivate(argv[1]) // expected-error {{expected variable name}}
227 #pragma omp parallel masked firstprivate(2 * 2) // expected-error {{expected variable name}}
231 #pragma omp parallel masked firstprivate(ba) // OK
235 #pragma omp parallel masked firstprivate(ca) // OK
239 #pragma omp parallel masked firstprivate(da) // OK
244 #pragma omp parallel masked firstprivate(xa) // OK
248 #pragma omp parallel masked firstprivate(S2::S2s) // OK
252 #pragma omp parallel masked firstprivate(S2::S2sc) // OK
256 #pragma omp parallel masked safelen(5) // expected-error {{unexpected OpenMP clause 'safelen' in directive '#pragma omp parallel masked'}}
260 #pragma omp parallel masked firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
264 #pragma omp parallel masked firstprivate(m) // OK
268 #pragma omp parallel masked firstprivate(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be firstprivate}}
272 #pragma omp parallel masked private(xa), firstprivate(xa) // expected-error {{private variable cannot be firstprivate}} expected-note {{defined as private}}
276 #pragma omp parallel shared(xa)
277 #pragma omp parallel masked firstprivate(xa) // OK: may be firstprivate
281 #pragma omp parallel masked firstprivate(j)
285 #pragma omp parallel masked firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
289 #pragma omp parallel masked firstprivate(n) // OK
297 #pragma omp parallel masked firstprivate(i)
303 #pragma omp parallel private(i)
304 #pragma omp parallel masked firstprivate(i)
308 #pragma omp parallel reduction(+ : i)
309 #pragma omp parallel masked firstprivate(i)
314 #pragma omp parallel masked firstprivate(r) // OK
319 return foomain
<S4
, S5
>(argc
, argv
); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}