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 single firstprivate // expected-error {{expected '(' after 'firstprivate'}}
76 #pragma omp single firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
79 #pragma omp single firstprivate() // expected-error {{expected expression}}
82 #pragma omp single firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
85 #pragma omp single firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
88 #pragma omp single firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
91 #pragma omp single 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 '('}}
94 #pragma omp single firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
97 #pragma omp single firstprivate(z, a, b) // expected-error {{firstprivate variable with incomplete type 'S1'}}
100 #pragma omp single firstprivate(argv[1]) // expected-error {{expected variable name}}
103 #pragma omp single firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
106 #pragma omp single firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
109 #pragma omp single linear(i) // expected-error {{unexpected OpenMP clause 'linear' in directive '#pragma omp single'}}
114 int i
; // expected-note {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp single' directive into a parallel or another task region?}}
115 #pragma omp single firstprivate(i) // expected-error {{firstprivate variable must be shared}}
119 #pragma omp parallel shared(i)
120 #pragma omp parallel private(i)
121 #pragma omp single firstprivate(j)
124 #pragma omp single firstprivate(i)
127 #pragma omp single firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
129 #pragma omp parallel private(i) // expected-note {{defined as private}}
130 #pragma omp single firstprivate(i) // expected-error {{firstprivate variable must be shared}}
132 #pragma omp parallel reduction(+ : i) // expected-note {{defined as reduction}}
133 #pragma omp single firstprivate(i) // expected-error {{firstprivate variable must be shared}}
140 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
146 int main(int argc
, char **argv
) {
148 const int da
[5] = {0};
156 #pragma omp single firstprivate // expected-error {{expected '(' after 'firstprivate'}}
159 #pragma omp single firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
162 #pragma omp single firstprivate() // expected-error {{expected expression}}
165 #pragma omp single firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
168 #pragma omp single firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
171 #pragma omp single firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
174 #pragma omp single firstprivate(argc, z)
177 #pragma omp single firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
180 #pragma omp single firstprivate(a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}}
183 #pragma omp single firstprivate(argv[1]) // expected-error {{expected variable name}}
186 #pragma omp single firstprivate(2 * 2) // expected-error {{expected variable name}}
189 #pragma omp single firstprivate(ba) // OK
192 #pragma omp single firstprivate(ca) // OK
195 #pragma omp single firstprivate(da) // OK
199 #pragma omp single firstprivate(xa) // OK
202 #pragma omp single firstprivate(S2::S2s) // OK
205 #pragma omp single firstprivate(S2::S2sc) // OK
208 #pragma omp single safelen(5) // expected-error {{unexpected OpenMP clause 'safelen' in directive '#pragma omp single'}}
211 #pragma omp single firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
214 #pragma omp single firstprivate(m) // OK
217 #pragma omp single firstprivate(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be firstprivate}}
220 #pragma omp single private(xa), firstprivate(xa) // expected-error {{private variable cannot be firstprivate}} expected-note {{defined as private}}
222 #pragma omp parallel shared(xa)
223 #pragma omp single firstprivate(xa) // OK: may be firstprivate
226 #pragma omp single firstprivate(j)
229 #pragma omp single firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
232 #pragma omp single firstprivate(n) // OK
237 int i
; // expected-note {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp single' directive into a parallel or another task region?}}
238 #pragma omp single firstprivate(i) // expected-error {{firstprivate variable must be shared}}
242 #pragma omp parallel private(i) // expected-note {{defined as private}}
243 #pragma omp single firstprivate(i) // expected-error {{firstprivate variable must be shared}}
245 #pragma omp parallel reduction(+ : i) // expected-note {{defined as reduction}}
246 #pragma omp single firstprivate(i) // expected-error {{firstprivate variable must be shared}}
249 #pragma omp single firstprivate(t) // OK
252 return foomain
<S4
, S5
>(argc
, argv
); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}