1 // RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
3 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
5 #pragma omp requires dynamic_allocators
7 typedef void **omp_allocator_handle_t
;
8 extern const omp_allocator_handle_t omp_null_allocator
;
9 extern const omp_allocator_handle_t omp_default_mem_alloc
;
10 extern const omp_allocator_handle_t omp_large_cap_mem_alloc
;
11 extern const omp_allocator_handle_t omp_const_mem_alloc
;
12 extern const omp_allocator_handle_t omp_high_bw_mem_alloc
;
13 extern const omp_allocator_handle_t omp_low_lat_mem_alloc
;
14 extern const omp_allocator_handle_t omp_cgroup_mem_alloc
;
15 extern const omp_allocator_handle_t omp_pteam_mem_alloc
;
16 extern const omp_allocator_handle_t omp_thread_mem_alloc
;
21 bool foobool(int argc
) {
26 int fp
; // expected-note {{initialize the variable 'fp' to silence this warning}}
27 #pragma omp target parallel for simd firstprivate(fp) // expected-warning {{variable 'fp' is uninitialized when used here}}
28 for (int i
= 0; i
< 10; ++i
)
32 struct S1
; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
39 S2(const S2
&s2
) : a(s2
.a
) {}
41 static const float S2sc
;
43 const float S2::S2sc
= 0;
48 S3
&operator=(const S3
&s3
);
52 S3(const S3
&s3
) : a(s3
.a
) {}
60 S4(const S4
&s4
); // expected-note 2 {{implicitly declared private here}}
67 S5(const S5
&s5
) : a(s5
.a
) {} // expected-note 4 {{implicitly declared private here}}
78 S6(const S6
&s6
) : a(s6
.a
) {}
83 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
85 template <class I
, class C
>
86 int foomain(int argc
, char **argv
) {
91 #pragma omp target parallel for simd firstprivate // expected-error {{expected '(' after 'firstprivate'}}
92 for (int k
= 0; k
< argc
; ++k
)
94 #pragma omp target parallel for simd firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
95 for (int k
= 0; k
< argc
; ++k
)
97 #pragma omp target parallel for simd firstprivate() // expected-error {{expected expression}}
98 for (int k
= 0; k
< argc
; ++k
)
100 #pragma omp target parallel for simd firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
101 for (int k
= 0; k
< argc
; ++k
)
103 #pragma omp target parallel for simd firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
104 for (int k
= 0; k
< argc
; ++k
)
106 #pragma omp target parallel for simd firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
107 for (int k
= 0; k
< argc
; ++k
)
109 #pragma omp target parallel for simd firstprivate(argc) allocate(omp_thread_mem_alloc: argc) // expected-warning {{allocator with the 'thread' trait access has unspecified behavior on 'target parallel for simd' directive}}
110 for (int k
= 0; k
< argc
; ++k
)
112 #pragma omp target parallel for simd firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
113 for (int k
= 0; k
< argc
; ++k
)
115 #pragma omp target parallel for simd firstprivate(z, a, b) // expected-error {{firstprivate variable with incomplete type 'S1'}}
116 for (int k
= 0; k
< argc
; ++k
)
118 #pragma omp target parallel for simd firstprivate(argv[1]) // expected-error {{expected variable name}}
119 for (int k
= 0; k
< argc
; ++k
)
121 #pragma omp target parallel for simd firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
122 for (int k
= 0; k
< argc
; ++k
)
124 #pragma omp target parallel for simd firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
125 for (int k
= 0; k
< argc
; ++k
)
131 #pragma omp target parallel for simd firstprivate(i)
132 for (int k
= 0; k
< argc
; ++k
) {
137 #pragma omp parallel shared(i)
138 #pragma omp parallel private(i)
139 #pragma omp target parallel for simd firstprivate(j)
140 for (int k
= 0; k
< argc
; ++k
)
142 #pragma omp target parallel for simd firstprivate(i)
143 for (int k
= 0; k
< argc
; ++k
)
145 #pragma omp target parallel for simd lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
146 for (i
= 0; i
< argc
; ++i
)
148 #pragma omp parallel private(i)
149 #pragma omp target parallel for simd firstprivate(i) // expected-note 2 {{defined as firstprivate}}
150 for (i
= 0; i
< argc
; ++i
) // expected-error 2 {{loop iteration variable in the associated loop of 'omp target parallel for simd' directive may not be firstprivate, predetermined as linear}}
152 #pragma omp parallel reduction(+ : i)
153 #pragma omp target parallel for simd firstprivate(i) // expected-note 2 {{defined as firstprivate}}
154 for (i
= 0; i
< argc
; ++i
) // expected-error 2 {{loop iteration variable in the associated loop of 'omp target parallel for simd' directive may not be firstprivate, predetermined as linear}}
161 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
167 int main(int argc
, char **argv
) {
169 const int da
[5] = {0};
176 #pragma omp target parallel for simd firstprivate // expected-error {{expected '(' after 'firstprivate'}}
177 for (i
= 0; i
< argc
; ++i
)
179 #pragma omp target parallel for simd firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
180 for (i
= 0; i
< argc
; ++i
)
182 #pragma omp target parallel for simd firstprivate() // expected-error {{expected expression}}
183 for (i
= 0; i
< argc
; ++i
)
185 #pragma omp target parallel for simd firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
186 for (i
= 0; i
< argc
; ++i
)
188 #pragma omp target parallel for simd firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
189 for (i
= 0; i
< argc
; ++i
)
191 #pragma omp target parallel for simd firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
192 for (i
= 0; i
< argc
; ++i
)
194 #pragma omp target parallel for 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 '('}}
195 for (i
= 0; i
< argc
; ++i
)
197 #pragma omp target parallel for simd firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
198 for (i
= 0; i
< argc
; ++i
)
200 #pragma omp target parallel for simd firstprivate(z, a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}}
201 for (i
= 0; i
< argc
; ++i
)
203 #pragma omp target parallel for simd firstprivate(argv[1]) // expected-error {{expected variable name}}
204 for (i
= 0; i
< argc
; ++i
)
206 #pragma omp target parallel for simd firstprivate(2 * 2) // expected-error {{expected variable name}}
207 for (i
= 0; i
< argc
; ++i
)
209 #pragma omp target parallel for simd firstprivate(ba) // OK
210 for (i
= 0; i
< argc
; ++i
)
212 #pragma omp target parallel for simd firstprivate(ca) // OK
213 for (i
= 0; i
< argc
; ++i
)
215 #pragma omp target parallel for simd firstprivate(da) // OK
216 for (i
= 0; i
< argc
; ++i
)
219 #pragma omp target parallel for simd firstprivate(xa) // OK
220 for (i
= 0; i
< argc
; ++i
)
222 #pragma omp target parallel for simd firstprivate(S2::S2s) // OK
223 for (i
= 0; i
< argc
; ++i
)
225 #pragma omp target parallel for simd firstprivate(S2::S2sc) // OK
226 for (i
= 0; i
< argc
; ++i
)
228 #pragma omp target parallel for simd safelen(5) // OK
229 for (i
= 0; i
< argc
; ++i
)
231 #pragma omp target parallel for simd firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
232 for (i
= 0; i
< argc
; ++i
)
234 #pragma omp target parallel for simd firstprivate(m) // OK
235 for (i
= 0; i
< argc
; ++i
)
237 #pragma omp target parallel for simd firstprivate(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be firstprivate}}
238 for (i
= 0; i
< argc
; ++i
)
240 #pragma omp target parallel for simd private(xa), firstprivate(xa) // expected-error {{private variable cannot be firstprivate}} expected-note {{defined as private}}
241 for (i
= 0; i
< argc
; ++i
)
243 #pragma omp target parallel for simd firstprivate(i) // expected-note {{defined as firstprivate}}
244 for (i
= 0; i
< argc
; ++i
) // expected-error {{loop iteration variable in the associated loop of 'omp target parallel for simd' directive may not be firstprivate, predetermined as linear}}
246 #pragma omp parallel shared(xa)
247 #pragma omp target parallel for simd firstprivate(xa) // OK: may be firstprivate
248 for (i
= 0; i
< argc
; ++i
)
250 #pragma omp target parallel for simd firstprivate(j)
251 for (i
= 0; i
< argc
; ++i
)
253 #pragma omp target parallel for simd lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
254 for (i
= 0; i
< argc
; ++i
)
256 #pragma omp target parallel for simd lastprivate(n) firstprivate(n) // OK
257 for (i
= 0; i
< argc
; ++i
)
263 #pragma omp target parallel for simd firstprivate(i)
264 for (int k
= 0; k
< argc
; ++k
) {
269 #pragma omp parallel private(i)
270 #pragma omp target parallel for simd firstprivate(i) // expected-note {{defined as firstprivate}}
271 for (i
= 0; i
< argc
; ++i
) // expected-error {{loop iteration variable in the associated loop of 'omp target parallel for simd' directive may not be firstprivate, predetermined as linear}}
273 #pragma omp parallel reduction(+ : i)
274 #pragma omp target parallel for simd firstprivate(i) // expected-note {{defined as firstprivate}}
275 for (i
= 0; i
< argc
; ++i
) // expected-error {{loop iteration variable in the associated loop of 'omp target parallel for simd' directive may not be firstprivate, predetermined as linear}}
278 #pragma omp target parallel for simd firstprivate(si) // OK
279 for (i
= 0; i
< argc
; ++i
)
282 return foomain
<S4
, S5
>(argc
, argv
); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}