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
) {
13 struct S1
; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
20 S2(const S2
&s2
) : a(s2
.a
) {}
22 static const float S2sc
;
24 const float S2::S2sc
= 0;
29 S3
&operator=(const S3
&s3
);
33 S3(const S3
&s3
) : a(s3
.a
) {}
41 S4(const S4
&s4
); // expected-note 2 {{implicitly declared private here}}
48 S5(const S5
&s5
) : a(s5
.a
) {} // expected-note 4 {{implicitly declared private here}}
59 S6(const S6
&s6
) : a(s6
.a
) {}
64 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
66 template <class I
, class C
>
67 int foomain(int argc
, char **argv
) {
73 #pragma omp sections firstprivate // expected-error {{expected '(' after 'firstprivate'}}
78 #pragma omp sections firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
83 #pragma omp sections firstprivate() // expected-error {{expected expression}}
88 #pragma omp sections firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
93 #pragma omp sections firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
98 #pragma omp sections firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
103 #pragma omp 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 '('}}
108 #pragma omp sections firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
113 #pragma omp sections firstprivate(z, a, b) // expected-error {{firstprivate variable with incomplete type 'S1'}}
118 #pragma omp sections firstprivate(argv[1]) // expected-error {{expected variable name}}
123 #pragma omp sections firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
128 #pragma omp sections firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
133 #pragma omp sections linear(i) // expected-error {{unexpected OpenMP clause 'linear' in directive '#pragma omp sections'}}
140 int i
; // expected-note {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp sections' directive into a parallel or another task region?}}
141 #pragma omp sections firstprivate(i) // expected-error {{firstprivate variable must be shared}}
147 #pragma omp parallel shared(i)
148 #pragma omp parallel private(i)
149 #pragma omp sections firstprivate(j)
154 #pragma omp sections firstprivate(i)
159 #pragma omp sections lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
163 #pragma omp parallel private(i) // expected-note {{defined as private}}
164 #pragma omp sections firstprivate(i) // expected-error {{firstprivate variable must be shared}}
168 #pragma omp parallel reduction(+ : i) // expected-note {{defined as reduction}}
169 #pragma omp sections firstprivate(i) // expected-error {{firstprivate variable must be shared}}
178 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
184 int main(int argc
, char **argv
) {
186 const int da
[5] = {0};
194 #pragma omp sections firstprivate // expected-error {{expected '(' after 'firstprivate'}}
199 #pragma omp sections firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
204 #pragma omp sections firstprivate() // expected-error {{expected expression}}
209 #pragma omp sections firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
214 #pragma omp sections firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
219 #pragma omp sections firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
224 #pragma omp sections firstprivate(argc, z)
229 #pragma omp sections firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
234 #pragma omp sections firstprivate(a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}}
239 #pragma omp sections firstprivate(argv[1]) // expected-error {{expected variable name}}
244 #pragma omp sections firstprivate(2 * 2) // expected-error {{expected variable name}}
249 #pragma omp sections firstprivate(ba) // OK
254 #pragma omp sections firstprivate(ca) // OK
259 #pragma omp sections firstprivate(da) // OK
265 #pragma omp sections firstprivate(xa) // OK
270 #pragma omp sections firstprivate(S2::S2s) // OK
275 #pragma omp sections firstprivate(S2::S2sc) // OK
280 #pragma omp sections safelen(5) // expected-error {{unexpected OpenMP clause 'safelen' in directive '#pragma omp sections'}}
285 #pragma omp sections firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
290 #pragma omp sections firstprivate(m) // OK
295 #pragma omp sections firstprivate(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be firstprivate}}
300 #pragma omp sections private(xa), firstprivate(xa) // expected-error {{private variable cannot be firstprivate}} expected-note {{defined as private}}
304 #pragma omp parallel shared(xa)
305 #pragma omp sections firstprivate(xa) // OK: may be firstprivate
310 #pragma omp sections firstprivate(j)
315 #pragma omp sections lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
320 #pragma omp sections lastprivate(n) firstprivate(n) // OK
327 int i
; // expected-note {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp sections' directive into a parallel or another task region?}}
328 #pragma omp sections firstprivate(i) // expected-error {{firstprivate variable must be shared}}
334 #pragma omp parallel private(i) // expected-note {{defined as private}}
335 #pragma omp sections firstprivate(i) // expected-error {{firstprivate variable must be shared}}
339 #pragma omp parallel reduction(+ : i) // expected-note {{defined as reduction}}
340 #pragma omp sections firstprivate(i) // expected-error {{firstprivate variable must be shared}}
345 #pragma omp sections firstprivate(r) // OK
350 return foomain
<S4
, S5
>(argc
, argv
); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}