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 #pragma omp requires dynamic_allocators
9 typedef void **omp_allocator_handle_t
;
10 extern const omp_allocator_handle_t omp_null_allocator
;
11 extern const omp_allocator_handle_t omp_default_mem_alloc
;
12 extern const omp_allocator_handle_t omp_large_cap_mem_alloc
;
13 extern const omp_allocator_handle_t omp_const_mem_alloc
;
14 extern const omp_allocator_handle_t omp_high_bw_mem_alloc
;
15 extern const omp_allocator_handle_t omp_low_lat_mem_alloc
;
16 extern const omp_allocator_handle_t omp_cgroup_mem_alloc
;
17 extern const omp_allocator_handle_t omp_pteam_mem_alloc
;
18 extern const omp_allocator_handle_t omp_thread_mem_alloc
;
21 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}}
22 #pragma omp target parallel for simd linear(i, lin : step_sz) // expected-warning {{variable 'lin' is uninitialized when used here}} expected-warning {{variable 'step_sz' is uninitialized when used here}}
23 for (i
= 0; i
< 10; ++i
)
32 static int ib
; // expected-note {{'B::ib' declared here}}
33 static int bfoo() { return 8; }
36 int bfoo() { return 4; }
41 void test_linear_colons() {
43 #pragma omp target parallel for simd linear(B : bfoo())
44 for (int i
= 0; i
< 10; ++i
)
46 // expected-error@+1 {{unexpected ':' in nested name specifier; did you mean '::'}}
47 #pragma omp target parallel for simd linear(B::ib : B : bfoo())
48 for (int i
= 0; i
< 10; ++i
)
50 // expected-error@+1 {{use of undeclared identifier 'ib'; did you mean 'B::ib'}}
51 #pragma omp target parallel for simd linear(B : ib)
52 for (int i
= 0; i
< 10; ++i
)
54 // expected-error@+1 {{unexpected ':' in nested name specifier; did you mean '::'?}}
55 #pragma omp target parallel for simd linear(z : B : ib)
56 for (int i
= 0; i
< 10; ++i
)
58 #pragma omp target parallel for simd linear(B : B::bfoo())
59 for (int i
= 0; i
< 10; ++i
)
61 #pragma omp target parallel for simd linear(X::x : ::z)
62 for (int i
= 0; i
< 10; ++i
)
64 #pragma omp target parallel for simd linear(B, ::z, X::x)
65 for (int i
= 0; i
< 10; ++i
)
67 #pragma omp target parallel for simd linear(::z) allocate(omp_thread_mem_alloc: ::z) // expected-warning {{allocator with the 'thread' trait access has unspecified behavior on 'target parallel for simd' directive}}
68 for (int i
= 0; i
< 10; ++i
)
70 // expected-error@+1 {{expected variable name}}
71 #pragma omp target parallel for simd linear(B::bfoo())
72 for (int i
= 0; i
< 10; ++i
)
74 #pragma omp target parallel for simd linear(B::ib, B : C1 + C2)
75 for (int i
= 0; i
< 10; ++i
)
79 template <int L
, class T
, class N
>
80 T
test_template(T
*arr
, N num
) {
83 T ind2
= -num
* L
; // expected-note {{'ind2' defined here}}
84 // expected-error@+1 {{argument of a linear clause should be of integral or pointer type}}
85 #pragma omp target parallel for simd linear(ind2 : L)
86 for (i
= 0; i
< num
; ++i
) {
87 T cur
= arr
[(int)ind2
];
97 // expected-warning@+1 {{zero linear step (ind2 should probably be const)}}
98 #pragma omp target parallel for simd linear(ind2 : LEN)
99 for (int i
= 0; i
< 100; i
++) {
105 struct S1
; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
113 const S2 b
; // expected-note 2 {{'b' defined here}}
138 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
140 template <class I
, class C
>
141 int foomain(I argc
, C
**argv
) {
146 #pragma omp target parallel for simd linear // expected-error {{expected '(' after 'linear'}}
147 for (int k
= 0; k
< argc
; ++k
)
149 #pragma omp target parallel for simd linear( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
150 for (int k
= 0; k
< argc
; ++k
)
152 #pragma omp target parallel for simd linear() // expected-error {{expected expression}}
153 for (int k
= 0; k
< argc
; ++k
)
155 #pragma omp target parallel for simd linear(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
156 for (int k
= 0; k
< argc
; ++k
)
158 #pragma omp target parallel for simd linear(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
159 for (int k
= 0; k
< argc
; ++k
)
161 #pragma omp target parallel for simd linear(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
162 for (int k
= 0; k
< argc
; ++k
)
164 #pragma omp target parallel for simd 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 '('}}
165 for (int k
= 0; k
< argc
; ++k
)
167 #pragma omp target parallel for simd linear(S1) // expected-error {{'S1' does not refer to a value}}
168 for (int k
= 0; k
< argc
; ++k
)
170 // expected-error@+2 {{linear variable with incomplete type 'S1'}}
171 // expected-error@+1 {{argument of a linear clause should be of integral or pointer type, not 'S2'}}
172 #pragma omp target parallel for simd linear(a, b : B::ib)
173 for (int k
= 0; k
< argc
; ++k
)
175 #pragma omp target parallel for simd linear(argv[1]) // expected-error {{expected variable name}}
176 for (int k
= 0; k
< argc
; ++k
)
178 #pragma omp target parallel for simd linear(e, g, z)
179 for (int k
= 0; k
< argc
; ++k
)
181 #pragma omp target parallel for simd linear(h) // expected-error {{threadprivate or thread local variable cannot be linear}}
182 for (int k
= 0; k
< argc
; ++k
)
184 #pragma omp target parallel for simd linear(i)
185 for (int k
= 0; k
< argc
; ++k
)
191 #pragma omp target parallel for simd linear(v : i)
192 for (int k
= 0; k
< argc
; ++k
) {
197 #pragma omp target parallel for simd linear(j)
198 for (int k
= 0; k
< argc
; ++k
)
201 #pragma omp target parallel for simd linear(v : j)
202 for (int k
= 0; k
< argc
; ++k
) {
206 #pragma omp target parallel for simd linear(i)
207 for (int k
= 0; k
< argc
; ++k
)
214 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
220 int main(int argc
, char **argv
) {
222 // expected-note@+1 {{in instantiation of function template specialization 'test_template<-4, double, int>' requested here}}
223 test_template
<-4>(darr
, 4);
224 // expected-note@+1 {{in instantiation of function template specialization 'test_warn<0>' requested here}}
227 S4
e(4); // expected-note {{'e' defined here}}
228 S5
g(5); // expected-note {{'g' defined here}}
231 #pragma omp target parallel for simd linear // expected-error {{expected '(' after 'linear'}}
232 for (int k
= 0; k
< argc
; ++k
)
234 #pragma omp target parallel for simd linear( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
235 for (int k
= 0; k
< argc
; ++k
)
237 #pragma omp target parallel for simd linear() // expected-error {{expected expression}}
238 for (int k
= 0; k
< argc
; ++k
)
240 #pragma omp target parallel for simd linear(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
241 for (int k
= 0; k
< argc
; ++k
)
243 #pragma omp target parallel for simd linear(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
244 for (int k
= 0; k
< argc
; ++k
)
246 #pragma omp target parallel for simd linear(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
247 for (int k
= 0; k
< argc
; ++k
)
249 #pragma omp target parallel for simd linear(argc, z)
250 for (int k
= 0; k
< argc
; ++k
)
252 #pragma omp target parallel for simd linear(S1) // expected-error {{'S1' does not refer to a value}}
253 for (int k
= 0; k
< argc
; ++k
)
255 // expected-error@+2 {{linear variable with incomplete type 'S1'}}
256 // expected-error@+1 {{argument of a linear clause should be of integral or pointer type, not 'S2'}}
257 #pragma omp target parallel for simd linear(a, b)
258 for (int k
= 0; k
< argc
; ++k
)
260 #pragma omp target parallel for simd linear(argv[1]) // expected-error {{expected variable name}}
261 for (int k
= 0; k
< argc
; ++k
)
263 // expected-error@+2 {{argument of a linear clause should be of integral or pointer type, not 'S4'}}
264 // expected-error@+1 {{argument of a linear clause should be of integral or pointer type, not 'S5'}}
265 #pragma omp target parallel for simd linear(e, g)
266 for (int k
= 0; k
< argc
; ++k
)
268 #pragma omp target parallel for simd linear(h, C::x) // expected-error 2 {{threadprivate or thread local variable cannot be linear}}
269 for (int k
= 0; k
< argc
; ++k
)
274 #pragma omp target parallel for simd linear(i)
275 for (int k
= 0; k
< argc
; ++k
)
278 #pragma omp target parallel for simd linear(i : uval, step(4)) // expected-error {{variable of non-reference type 'int' can be used only with 'val' modifier, but used with 'uval'}}
280 #pragma omp target parallel for simd linear(i : 4)
282 for (int k
= 0; k
< argc
; ++k
) {
288 #pragma omp target parallel for simd linear(j: step() //omp52-error 2 {{expected expression}} omp52-error{{expected ')'}} omp52-note{{to match this '('}}
290 #pragma omp target parallel for simd linear(j)
292 for (int k
= 0; k
< argc
; ++k
)
295 #pragma omp target parallel for simd linear(i: step(1), step(2)) // omp52-error {{multiple 'step size' found in linear clause}}
297 #pragma omp target parallel for simd linear(i)
299 for (int k
= 0; k
< argc
; ++k
)
302 foomain
<int, char>(argc
, argv
); // expected-note {{in instantiation of function template specialization 'foomain<int, char>' requested here}}