1 // RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
3 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
5 typedef void **omp_allocator_handle_t
;
6 extern const omp_allocator_handle_t omp_null_allocator
;
7 extern const omp_allocator_handle_t omp_default_mem_alloc
;
8 extern const omp_allocator_handle_t omp_large_cap_mem_alloc
;
9 extern const omp_allocator_handle_t omp_const_mem_alloc
;
10 extern const omp_allocator_handle_t omp_high_bw_mem_alloc
;
11 extern const omp_allocator_handle_t omp_low_lat_mem_alloc
;
12 extern const omp_allocator_handle_t omp_cgroup_mem_alloc
;
13 extern const omp_allocator_handle_t omp_pteam_mem_alloc
;
14 extern const omp_allocator_handle_t omp_thread_mem_alloc
;
19 bool foobool(int argc
) {
24 int fp
; // expected-note {{initialize the variable 'fp' to silence this warning}}
25 #pragma omp taskloop simd firstprivate(fp) // expected-warning {{variable 'fp' is uninitialized when used here}}
26 for (int i
= 0; i
< 10; ++i
)
30 struct S1
; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
37 S2(const S2
&s2
) : a(s2
.a
) {}
39 static const float S2sc
;
41 const float S2::S2sc
= 0;
46 S3
&operator=(const S3
&s3
);
49 S3() : a(0) {} // expected-note 2 {{candidate constructor not viable: requires 0 arguments, but 1 was provided}}
50 S3(S3
&s3
) : a(s3
.a
) {} // expected-note 2 {{candidate constructor not viable: 1st argument ('const S3') would lose const qualifier}}
58 S4(const S4
&s4
); // expected-note 2 {{implicitly declared private here}}
65 S5(const S5
&s5
) : a(s5
.a
) {} // expected-note 4 {{implicitly declared private here}}
76 S6(const S6
&s6
) : a(s6
.a
) {}
81 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
83 template <class I
, class C
>
84 int foomain(int argc
, char **argv
) {
90 #pragma omp taskloop simd firstprivate // expected-error {{expected '(' after 'firstprivate'}}
91 for (int k
= 0; k
< argc
; ++k
)
94 #pragma omp taskloop simd firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
95 for (int k
= 0; k
< argc
; ++k
)
98 #pragma omp taskloop simd firstprivate() // expected-error {{expected expression}}
99 for (int k
= 0; k
< argc
; ++k
)
102 #pragma omp taskloop simd firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
103 for (int k
= 0; k
< argc
; ++k
)
106 #pragma omp taskloop simd firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
107 for (int k
= 0; k
< argc
; ++k
)
110 #pragma omp taskloop simd firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
111 for (int k
= 0; k
< argc
; ++k
)
114 #pragma omp taskloop simd 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 '('}}
115 for (int k
= 0; k
< argc
; ++k
)
118 #pragma omp taskloop simd firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
119 for (int k
= 0; k
< argc
; ++k
)
122 #pragma omp taskloop simd firstprivate(a, b) // expected-error {{firstprivate variable with incomplete type 'S1'}}
123 for (int k
= 0; k
< argc
; ++k
)
126 #pragma omp taskloop simd firstprivate(z, argv[1]) // expected-error {{expected variable name}}
127 for (int k
= 0; k
< argc
; ++k
)
130 #pragma omp taskloop simd firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
131 for (int k
= 0; k
< argc
; ++k
)
134 #pragma omp taskloop simd firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
135 for (int k
= 0; k
< argc
; ++k
)
141 #pragma omp taskloop simd allocate(omp_thread_mem_alloc: i) firstprivate(i) // expected-warning {{allocator with the 'thread' trait access has unspecified behavior on 'taskloop simd' directive}}
142 for (int k
= 0; k
< argc
; ++k
) {
147 #pragma omp parallel shared(i)
148 #pragma omp parallel private(i)
149 #pragma omp taskloop simd firstprivate(j)
150 for (int k
= 0; k
< argc
; ++k
)
153 #pragma omp taskloop simd firstprivate(i)
154 for (int k
= 0; k
< argc
; ++k
)
157 #pragma omp taskloop simd lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
158 for (i
= 0; i
< argc
; ++i
)
160 #pragma omp parallel private(i)
161 #pragma omp taskloop simd firstprivate(i) // expected-note 2 {{defined as firstprivate}}
162 for (i
= 0; i
< argc
; ++i
) // expected-error 2 {{loop iteration variable in the associated loop of 'omp taskloop simd' directive may not be firstprivate, predetermined as linear}}
164 #pragma omp parallel reduction(+ : i) // expected-note {{defined as reduction}}
165 #pragma omp taskloop simd firstprivate(i) // expected-note {{defined as firstprivate}} expected-error {{argument of a reduction clause of a parallel construct must not appear in a firstprivate clause on a task construct}}
166 for (i
= 0; i
< argc
; ++i
) // expected-error {{loop iteration variable in the associated loop of 'omp taskloop simd' directive may not be firstprivate, predetermined as linear}}
173 #pragma omp taskloop simd firstprivate(a)
174 for (int i
= 0; i
< 2; ++i
)
180 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
186 int main(int argc
, char **argv
) {
188 const int da
[5] = {0};
196 #pragma omp taskloop simd firstprivate // expected-error {{expected '(' after 'firstprivate'}}
197 for (i
= 0; i
< argc
; ++i
)
200 #pragma omp taskloop simd firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
201 for (i
= 0; i
< argc
; ++i
)
204 #pragma omp taskloop simd firstprivate() // expected-error {{expected expression}}
205 for (i
= 0; i
< argc
; ++i
)
208 #pragma omp taskloop simd firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
209 for (i
= 0; i
< argc
; ++i
)
212 #pragma omp taskloop simd firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
213 for (i
= 0; i
< argc
; ++i
)
216 #pragma omp taskloop simd firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
217 for (i
= 0; i
< argc
; ++i
)
220 #pragma omp taskloop simd firstprivate(argc, z)
221 for (i
= 0; i
< argc
; ++i
)
224 #pragma omp taskloop simd firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
225 for (i
= 0; i
< argc
; ++i
)
228 #pragma omp taskloop simd firstprivate(a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}} expected-error {{no matching constructor for initialization of 'S3'}}
229 for (i
= 0; i
< argc
; ++i
)
232 #pragma omp taskloop simd firstprivate(argv[1]) // expected-error {{expected variable name}}
233 for (i
= 0; i
< argc
; ++i
)
236 #pragma omp taskloop simd firstprivate(2 * 2) // expected-error {{expected variable name}}
237 for (i
= 0; i
< argc
; ++i
)
240 #pragma omp taskloop simd firstprivate(ba) // OK
241 for (i
= 0; i
< argc
; ++i
)
244 #pragma omp taskloop simd firstprivate(ca) // expected-error {{no matching constructor for initialization of 'S3'}}
245 for (i
= 0; i
< argc
; ++i
)
248 #pragma omp taskloop simd firstprivate(da) // OK
249 for (i
= 0; i
< argc
; ++i
)
253 #pragma omp taskloop simd firstprivate(xa) // OK
254 for (i
= 0; i
< argc
; ++i
)
257 #pragma omp taskloop simd firstprivate(S2::S2s) // OK
258 for (i
= 0; i
< argc
; ++i
)
261 #pragma omp taskloop simd firstprivate(S2::S2sc) // OK
262 for (i
= 0; i
< argc
; ++i
)
265 #pragma omp taskloop simd safelen(5)
266 for (i
= 0; i
< argc
; ++i
)
269 #pragma omp taskloop simd firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
270 for (i
= 0; i
< argc
; ++i
)
273 #pragma omp taskloop simd firstprivate(m) // OK
274 for (i
= 0; i
< argc
; ++i
)
277 #pragma omp taskloop simd firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
278 for (i
= 0; i
< argc
; ++i
)
281 #pragma omp taskloop simd private(xa), firstprivate(xa) // expected-error {{private variable cannot be firstprivate}} expected-note {{defined as private}}
282 for (i
= 0; i
< argc
; ++i
)
285 #pragma omp taskloop simd firstprivate(i) // expected-note {{defined as firstprivate}}
286 for (i
= 0; i
< argc
; ++i
) // expected-error {{loop iteration variable in the associated loop of 'omp taskloop simd' directive may not be firstprivate, predetermined as linear}}
288 #pragma omp parallel shared(xa)
289 #pragma omp taskloop simd firstprivate(xa) // OK: may be firstprivate
290 for (i
= 0; i
< argc
; ++i
)
293 #pragma omp taskloop simd firstprivate(j)
294 for (i
= 0; i
< argc
; ++i
)
297 #pragma omp taskloop simd lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
298 for (i
= 0; i
< argc
; ++i
)
301 #pragma omp taskloop simd lastprivate(n) firstprivate(n) // OK
302 for (i
= 0; i
< argc
; ++i
)
308 #pragma omp taskloop simd firstprivate(i)
309 for (int k
= 0; k
< argc
; ++k
) {
314 #pragma omp parallel private(i)
315 #pragma omp taskloop simd 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 taskloop simd' directive may not be firstprivate, predetermined as linear}}
318 #pragma omp parallel reduction(+ : i) // expected-note {{defined as reduction}}
319 #pragma omp taskloop simd firstprivate(i) // expected-error {{argument of a reduction clause of a parallel construct must not appear in a firstprivate clause on a task construct}}
320 for (i
= 0; i
< argc
; ++i
)
322 #pragma omp taskloop simd firstprivate(i) //expected-note {{defined as firstprivate}}
323 for (i
= 0; i
< argc
; ++i
) // expected-error {{loop iteration variable in the associated loop of 'omp taskloop simd' directive may not be firstprivate, predetermined as linear}}
326 #pragma omp taskloop simd firstprivate(B::x) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
327 for (i
= 0; i
< argc
; ++i
)
330 #pragma omp taskloop simd firstprivate(si) // OK
331 for (i
= 0; i
< argc
; ++i
)
334 return foomain
<S4
, S5
>(argc
, argv
); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}