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
8 typedef void **omp_allocator_handle_t
;
9 extern const omp_allocator_handle_t omp_null_allocator
;
10 extern const omp_allocator_handle_t omp_default_mem_alloc
;
11 extern const omp_allocator_handle_t omp_large_cap_mem_alloc
;
12 extern const omp_allocator_handle_t omp_const_mem_alloc
;
13 extern const omp_allocator_handle_t omp_high_bw_mem_alloc
;
14 extern const omp_allocator_handle_t omp_low_lat_mem_alloc
;
15 extern const omp_allocator_handle_t omp_cgroup_mem_alloc
;
16 extern const omp_allocator_handle_t omp_pteam_mem_alloc
;
17 extern const omp_allocator_handle_t omp_thread_mem_alloc
;
20 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}}
21 #pragma omp target 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}}
22 for (i
= 0; i
< 10; ++i
)
31 static int ib
; // expected-note {{'B::ib' declared here}}
32 static int bfoo() { return 8; }
35 int bfoo() { return 4; }
40 void test_linear_colons() {
42 #pragma omp target simd linear(B : bfoo())
43 for (int i
= 0; i
< 10; ++i
)
45 // expected-error@+1 {{unexpected ':' in nested name specifier; did you mean '::'}}
46 #pragma omp target simd linear(B::ib : B : bfoo())
47 for (int i
= 0; i
< 10; ++i
)
49 // expected-error@+1 {{use of undeclared identifier 'ib'; did you mean 'B::ib'}}
50 #pragma omp target simd linear(B : ib)
51 for (int i
= 0; i
< 10; ++i
)
53 // expected-error@+1 {{unexpected ':' in nested name specifier; did you mean '::'?}}
54 #pragma omp target simd linear(z : B : ib)
55 for (int i
= 0; i
< 10; ++i
)
57 #pragma omp target simd linear(B : B::bfoo())
58 for (int i
= 0; i
< 10; ++i
)
60 #pragma omp target simd linear(X::x : ::z)
61 for (int i
= 0; i
< 10; ++i
)
63 #pragma omp target simd linear(B, ::z, X::x)
64 for (int i
= 0; i
< 10; ++i
)
66 #pragma omp target simd linear(::z)
67 for (int i
= 0; i
< 10; ++i
)
69 // expected-error@+1 {{expected variable name}}
70 #pragma omp target simd linear(B::bfoo())
71 for (int i
= 0; i
< 10; ++i
)
73 #pragma omp target simd linear(B::ib, B : C1 + C2)
74 for (int i
= 0; i
< 10; ++i
)
78 template <int L
, class T
, class N
>
79 T
test_template(T
*arr
, N num
) {
82 T ind2
= -num
* L
; // expected-note {{'ind2' defined here}}
83 // expected-error@+1 {{argument of a linear clause should be of integral or pointer type}}
84 #pragma omp target simd linear(ind2 : L)
85 for (i
= 0; i
< num
; ++i
) {
86 T cur
= arr
[(int)ind2
];
96 // expected-warning@+1 {{zero linear step (ind2 should probably be const)}}
97 #pragma omp target simd linear(ind2 : LEN)
98 for (int i
= 0; i
< 100; i
++) {
104 struct S1
; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
112 const S2 b
; // expected-note 2 {{'b' defined here}}
137 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
139 template <class I
, class C
>
140 int foomain(I argc
, C
**argv
) {
145 #pragma omp target simd linear // expected-error {{expected '(' after 'linear'}}
146 for (int k
= 0; k
< argc
; ++k
)
148 #pragma omp target simd linear( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
149 for (int k
= 0; k
< argc
; ++k
)
151 #pragma omp target simd linear() // expected-error {{expected expression}}
152 for (int k
= 0; k
< argc
; ++k
)
154 #pragma omp target simd linear(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
155 for (int k
= 0; k
< argc
; ++k
)
157 #pragma omp target simd linear(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
158 for (int k
= 0; k
< argc
; ++k
)
160 #pragma omp target simd linear(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
161 for (int k
= 0; k
< argc
; ++k
)
163 #pragma omp target 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 '('}}
164 for (int k
= 0; k
< argc
; ++k
)
166 #pragma omp target simd linear(S1) // expected-error {{'S1' does not refer to a value}}
167 for (int k
= 0; k
< argc
; ++k
)
169 // expected-error@+2 {{linear variable with incomplete type 'S1'}}
170 // expected-error@+1 {{argument of a linear clause should be of integral or pointer type, not 'S2'}}
171 #pragma omp target simd linear(a, b : B::ib)
172 for (int k
= 0; k
< argc
; ++k
)
174 #pragma omp target simd linear(argv[1]) // expected-error {{expected variable name}}
175 for (int k
= 0; k
< argc
; ++k
)
177 #pragma omp target simd allocate(omp_thread_mem_alloc: e) linear(e, g) // expected-warning {{allocator with the 'thread' trait access has unspecified behavior on 'target simd' directive}}
178 for (int k
= 0; k
< argc
; ++k
)
180 #pragma omp target simd linear(h) // expected-error {{threadprivate or thread local variable cannot be linear}}
181 for (int k
= 0; k
< argc
; ++k
)
183 #pragma omp target simd linear(i, z)
184 for (int k
= 0; k
< argc
; ++k
)
190 #pragma omp target simd linear(v : i)
191 for (int k
= 0; k
< argc
; ++k
) {
196 #pragma omp target simd linear(j)
197 for (int k
= 0; k
< argc
; ++k
)
200 #pragma omp target simd linear(v : j)
201 for (int k
= 0; k
< argc
; ++k
) {
205 #pragma omp target simd linear(i)
206 for (int k
= 0; k
< argc
; ++k
)
213 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
219 int main(int argc
, char **argv
) {
221 // expected-note@+1 {{in instantiation of function template specialization 'test_template<-4, double, int>' requested here}}
222 test_template
<-4>(darr
, 4);
223 // expected-note@+1 {{in instantiation of function template specialization 'test_warn<0>' requested here}}
226 S4
e(4); // expected-note {{'e' defined here}}
227 S5
g(5); // expected-note {{'g' defined here}}
230 #pragma omp target simd linear // expected-error {{expected '(' after 'linear'}}
231 for (int k
= 0; k
< argc
; ++k
)
233 #pragma omp target simd linear( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
234 for (int k
= 0; k
< argc
; ++k
)
236 #pragma omp target simd linear() // expected-error {{expected expression}}
237 for (int k
= 0; k
< argc
; ++k
)
239 #pragma omp target simd linear(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
240 for (int k
= 0; k
< argc
; ++k
)
242 #pragma omp target simd linear(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
243 for (int k
= 0; k
< argc
; ++k
)
245 #pragma omp target simd linear(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
246 for (int k
= 0; k
< argc
; ++k
)
248 #pragma omp target simd linear(argc, z)
249 for (int k
= 0; k
< argc
; ++k
)
251 #pragma omp target simd linear(S1) // expected-error {{'S1' does not refer to a value}}
252 for (int k
= 0; k
< argc
; ++k
)
254 // expected-error@+2 {{linear variable with incomplete type 'S1'}}
255 // expected-error@+1 {{argument of a linear clause should be of integral or pointer type, not 'S2'}}
256 #pragma omp target simd linear(a, b)
257 for (int k
= 0; k
< argc
; ++k
)
259 #pragma omp target simd linear(argv[1]) // expected-error {{expected variable name}}
260 for (int k
= 0; k
< argc
; ++k
)
262 // expected-error@+2 {{argument of a linear clause should be of integral or pointer type, not 'S4'}}
263 // expected-error@+1 {{argument of a linear clause should be of integral or pointer type, not 'S5'}}
264 #pragma omp target simd linear(e, g)
265 for (int k
= 0; k
< argc
; ++k
)
267 #pragma omp target simd linear(h, C::x) // expected-error 2 {{threadprivate or thread local variable cannot be linear}}
268 for (int k
= 0; k
< argc
; ++k
)
273 #pragma omp target simd linear(i)
274 for (int k
= 0; k
< argc
; ++k
)
277 #pragma omp target 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'}}
279 #pragma omp target simd linear(i : 4)
281 for (int k
= 0; k
< argc
; ++k
) {
287 #pragma omp target simd linear(j: step() //omp52-error 2 {{expected expression}} omp52-error{{expected ')'}} omp52-note{{to match this '('}}
289 #pragma omp target simd linear(j)
291 for (int k
= 0; k
< argc
; ++k
)
294 #pragma omp target simd linear(i: step(1), step(2)) // omp52-error {{multiple 'step size' found in linear clause}}
296 #pragma omp target simd linear(i)
298 for (int k
= 0; k
< argc
; ++k
)
301 foomain
<int, char>(argc
, argv
); // expected-note {{in instantiation of function template specialization 'foomain<int, char>' requested here}}