1 // RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
2 // RUN: %clang_cc1 -verify=expected,omp52 -fopenmp -fopenmp-version=52 -DOMP52 %s -Wuninitialized
4 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
5 // RUN: %clang_cc1 -verify=expected,omp52 -fopenmp-simd -fopenmp-version=52 -DOMP52 %s -Wuninitialized
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
;
19 int i
, lin
, step_sz
; // expected-note {{initialize the variable 'lin' to silence this warning}} expected-note {{initialize the variable 'step_sz' to silence this warning}}
20 #pragma omp target parallel for linear(lin : step_sz) // expected-warning {{variable 'lin' is uninitialized when used here}} expected-warning {{variable 'step_sz' is uninitialized when used here}}
21 for (i
= 0; i
< 10; ++i
)
30 static int ib
; // expected-note {{'B::ib' declared here}}
31 static int bfoo() { return 8; }
34 int bfoo() { return 4; }
39 void test_linear_colons() {
41 #pragma omp target parallel for linear(B : bfoo())
42 for (int i
= 0; i
< 10; ++i
)
44 // expected-error@+1 {{unexpected ':' in nested name specifier; did you mean '::'}}
45 #pragma omp target parallel for linear(B::ib : B : bfoo())
46 for (int i
= 0; i
< 10; ++i
)
48 // expected-error@+1 {{use of undeclared identifier 'ib'; did you mean 'B::ib'}}
49 #pragma omp target parallel for linear(B : ib)
50 for (int i
= 0; i
< 10; ++i
)
52 // expected-error@+1 {{unexpected ':' in nested name specifier; did you mean '::'?}}
53 #pragma omp target parallel for linear(z : B : ib)
54 for (int i
= 0; i
< 10; ++i
)
56 #pragma omp target parallel for linear(B : B::bfoo())
57 for (int i
= 0; i
< 10; ++i
)
59 #pragma omp target parallel for linear(X::x : ::z)
60 for (int i
= 0; i
< 10; ++i
)
62 #pragma omp target parallel for linear(B, ::z, X::x)
63 for (int i
= 0; i
< 10; ++i
)
65 #pragma omp target parallel for linear(::z)
66 for (int i
= 0; i
< 10; ++i
)
68 // expected-error@+1 {{expected variable name}}
69 #pragma omp target parallel for linear(B::bfoo())
70 for (int i
= 0; i
< 10; ++i
)
72 #pragma omp target parallel for linear(B::ib, B : C1 + C2)
73 for (int i
= 0; i
< 10; ++i
)
77 template <int L
, class T
, class N
>
78 T
test_template(T
*arr
, N num
) {
81 T ind2
= -num
* L
; // expected-note {{'ind2' defined here}}
82 // expected-error@+1 {{argument of a linear clause should be of integral or pointer type}}
83 #pragma omp target parallel for linear(ind2 : L)
84 for (i
= 0; i
< num
; ++i
) {
85 T cur
= arr
[(int)ind2
];
95 // expected-warning@+1 {{zero linear step (ind2 should probably be const)}}
96 #pragma omp target parallel for linear(ind2 : LEN)
97 for (int i
= 0; i
< 100; i
++) {
103 struct S1
; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
111 const S2 b
; // expected-note 2 {{'b' defined here}}
136 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
138 template <class I
, class C
>
139 int foomain(I argc
, C
**argv
) {
144 #pragma omp target parallel for linear // expected-error {{expected '(' after 'linear'}}
145 for (int k
= 0; k
< argc
; ++k
)
147 #pragma omp target parallel for linear( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
148 for (int k
= 0; k
< argc
; ++k
)
150 #pragma omp target parallel for linear() // expected-error {{expected expression}}
151 for (int k
= 0; k
< argc
; ++k
)
153 #pragma omp target parallel for linear(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
154 for (int k
= 0; k
< argc
; ++k
)
156 #pragma omp target parallel for linear(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
157 for (int k
= 0; k
< argc
; ++k
)
159 #pragma omp target parallel for linear(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
160 for (int k
= 0; k
< argc
; ++k
)
162 #pragma omp target parallel for linear(argc : 5) 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 '('}}
163 for (int k
= 0; k
< argc
; ++k
)
165 #pragma omp target parallel for linear(S1) // expected-error {{'S1' does not refer to a value}}
166 for (int k
= 0; k
< argc
; ++k
)
168 // expected-error@+2 {{linear variable with incomplete type 'S1'}}
169 // expected-error@+1 {{argument of a linear clause should be of integral or pointer type, not 'S2'}}
170 #pragma omp target parallel for linear(a, b : B::ib)
171 for (int k
= 0; k
< argc
; ++k
)
173 #pragma omp target parallel for linear(argv[1]) // expected-error {{expected variable name}}
174 for (int k
= 0; k
< argc
; ++k
)
176 #pragma omp target parallel for allocate(omp_thread_mem_alloc: e) linear(e, g) // expected-warning {{allocator with the 'thread' trait access has unspecified behavior on 'target parallel for' directive}} expected-error {{allocator must be specified in the 'uses_allocators' clause}}
177 for (int k
= 0; k
< argc
; ++k
)
179 #pragma omp target parallel for linear(z, h) // expected-error {{threadprivate or thread local variable cannot be linear}}
180 for (int k
= 0; k
< argc
; ++k
)
182 #pragma omp target parallel for linear(i)
183 for (int k
= 0; k
< argc
; ++k
)
189 #pragma omp target parallel for linear(v : i)
190 for (int k
= 0; k
< argc
; ++k
) {
195 #pragma omp target parallel for linear(j)
196 for (int k
= 0; k
< argc
; ++k
)
199 #pragma omp target parallel for linear(v : j)
200 for (int k
= 0; k
< argc
; ++k
) {
204 #pragma omp target parallel for linear(i)
205 for (int k
= 0; k
< argc
; ++k
)
212 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
218 int main(int argc
, char **argv
) {
220 // expected-note@+1 {{in instantiation of function template specialization 'test_template<-4, double, int>' requested here}}
221 test_template
<-4>(darr
, 4);
222 // expected-note@+1 {{in instantiation of function template specialization 'test_warn<0>' requested here}}
225 S4
e(4); // expected-note {{'e' defined here}}
226 S5
g(5); // expected-note {{'g' defined here}}
229 #pragma omp target parallel for linear // expected-error {{expected '(' after 'linear'}}
230 for (int k
= 0; k
< argc
; ++k
)
232 #pragma omp target parallel for linear( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
233 for (int k
= 0; k
< argc
; ++k
)
235 #pragma omp target parallel for linear() // expected-error {{expected expression}}
236 for (int k
= 0; k
< argc
; ++k
)
238 #pragma omp target parallel for linear(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
239 for (int k
= 0; k
< argc
; ++k
)
241 #pragma omp target parallel for linear(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
242 for (int k
= 0; k
< argc
; ++k
)
244 #pragma omp target parallel for linear(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
245 for (int k
= 0; k
< argc
; ++k
)
247 #pragma omp target parallel for linear(argc, z)
248 for (int k
= 0; k
< argc
; ++k
)
250 #pragma omp target parallel for linear(S1) // expected-error {{'S1' does not refer to a value}}
251 for (int k
= 0; k
< argc
; ++k
)
253 // expected-error@+2 {{linear variable with incomplete type 'S1'}}
254 // expected-error@+1 {{argument of a linear clause should be of integral or pointer type, not 'S2'}}
255 #pragma omp target parallel for linear(a, b)
256 for (int k
= 0; k
< argc
; ++k
)
258 #pragma omp target parallel for linear(argv[1]) // expected-error {{expected variable name}}
259 for (int k
= 0; k
< argc
; ++k
)
261 // expected-error@+2 {{argument of a linear clause should be of integral or pointer type, not 'S4'}}
262 // expected-error@+1 {{argument of a linear clause should be of integral or pointer type, not 'S5'}}
263 #pragma omp target parallel for linear(e, g)
264 for (int k
= 0; k
< argc
; ++k
)
266 #pragma omp target parallel for linear(h, C::x) // expected-error 2 {{threadprivate or thread local variable cannot be linear}}
267 for (int k
= 0; k
< argc
; ++k
)
272 #pragma omp target parallel for linear(i)
273 for (int k
= 0; k
< argc
; ++k
)
276 #pragma omp target parallel for linear(i : uval, step(4)) // expected-error {{variable of non-reference type 'int' can be used only with 'val' modifier, but used with 'uval'}}
278 #pragma omp target parallel for linear(i : 4)
280 for (int k
= 0; k
< argc
; ++k
) {
286 #pragma omp target parallel for linear(j: step() //omp52-error 2 {{expected expression}} omp52-error{{expected ')'}} omp52-note{{to match this '('}}
288 #pragma omp target parallel for linear(j)
290 for (int k
= 0; k
< argc
; ++k
)
293 #pragma omp target parallel for linear(i: step(1), step(2)) // omp52-error {{multiple 'step size' found in linear clause}}
295 #pragma omp target parallel for linear(i)
297 for (int k
= 0; k
< argc
; ++k
)
300 foomain
<int, char>(argc
, argv
); // expected-note {{in instantiation of function template specialization 'foomain<int, char>' requested here}}