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 extern int omp_default_mem_alloc
;
10 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}}
11 #pragma omp 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}}
12 for (i
= 0; i
< 10; ++i
)
21 static int ib
; // expected-note {{'B::ib' declared here}}
22 static int bfoo() { return 8; }
25 int bfoo() { return 4; }
30 void test_linear_colons() {
32 #pragma omp parallel for linear(B : bfoo())
33 for (int i
= 0; i
< 10; ++i
)
35 // expected-error@+1 {{unexpected ':' in nested name specifier; did you mean '::'}}
36 #pragma omp parallel for linear(B::ib : B : bfoo())
37 for (int i
= 0; i
< 10; ++i
)
39 // expected-error@+1 {{use of undeclared identifier 'ib'; did you mean 'B::ib'}}
40 #pragma omp parallel for linear(B : ib)
41 for (int i
= 0; i
< 10; ++i
)
43 // expected-error@+1 {{unexpected ':' in nested name specifier; did you mean '::'?}}
44 #pragma omp parallel for linear(z : B : ib)
45 for (int i
= 0; i
< 10; ++i
)
47 #pragma omp parallel for linear(B : B::bfoo())
48 for (int i
= 0; i
< 10; ++i
)
50 #pragma omp parallel for linear(X::x : ::z)
51 for (int i
= 0; i
< 10; ++i
)
53 #pragma omp parallel for linear(B, ::z, X::x)
54 for (int i
= 0; i
< 10; ++i
)
56 #pragma omp parallel for linear(::z) 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 '('}}
57 for (int i
= 0; i
< 10; ++i
)
59 // expected-error@+1 {{expected variable name}}
60 #pragma omp parallel for linear(B::bfoo())
61 for (int i
= 0; i
< 10; ++i
)
63 #pragma omp parallel for linear(B::ib, B : C1 + C2)
64 for (int i
= 0; i
< 10; ++i
)
68 template <int L
, class T
, class N
>
69 T
test_template(T
*arr
, N num
) {
72 T ind2
= -num
* L
; // expected-note {{'ind2' defined here}}
73 // expected-error@+1 {{argument of a linear clause should be of integral or pointer type}}
74 #pragma omp parallel for linear(ind2 : L)
75 for (i
= 0; i
< num
; ++i
) {
76 T cur
= arr
[(int)ind2
];
86 // expected-warning@+1 {{zero linear step (ind2 should probably be const)}}
87 #pragma omp parallel for linear(ind2 : LEN)
88 for (int i
= 0; i
< 100; i
++) {
94 struct S1
; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
102 const S2 b
; // expected-note 2 {{'b' defined here}}
127 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
129 template <class I
, class C
>
130 int foomain(I argc
, C
**argv
) {
135 #pragma omp parallel for linear // expected-error {{expected '(' after 'linear'}}
136 for (int k
= 0; k
< argc
; ++k
)
138 #pragma omp parallel for linear( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
139 for (int k
= 0; k
< argc
; ++k
)
141 #pragma omp parallel for linear() // expected-error {{expected expression}}
142 for (int k
= 0; k
< argc
; ++k
)
144 #pragma omp parallel for linear(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
145 for (int k
= 0; k
< argc
; ++k
)
147 #pragma omp parallel for linear(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
148 for (int k
= 0; k
< argc
; ++k
)
150 #pragma omp parallel for linear(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
151 for (int k
= 0; k
< argc
; ++k
)
153 #pragma omp parallel for linear(argc, z : 5)
154 for (int k
= 0; k
< argc
; ++k
)
156 #pragma omp parallel for linear(S1) // expected-error {{'S1' does not refer to a value}}
157 for (int k
= 0; k
< argc
; ++k
)
159 // expected-error@+2 {{linear variable with incomplete type 'S1'}}
160 // expected-error@+1 {{argument of a linear clause should be of integral or pointer type, not 'S2'}}
161 #pragma omp parallel for linear(a, b : B::ib)
162 for (int k
= 0; k
< argc
; ++k
)
164 #pragma omp parallel for linear(argv[1]) // expected-error {{expected variable name}}
165 for (int k
= 0; k
< argc
; ++k
)
167 #pragma omp parallel for linear(e, g)
168 for (int k
= 0; k
< argc
; ++k
)
170 #pragma omp parallel for linear(h) // expected-error {{threadprivate or thread local variable cannot be linear}}
171 for (int k
= 0; k
< argc
; ++k
)
173 #pragma omp parallel for linear(i)
174 for (int k
= 0; k
< argc
; ++k
)
180 #pragma omp parallel for linear(v : i)
181 for (int k
= 0; k
< argc
; ++k
) {
186 #pragma omp parallel for linear(j)
187 for (int k
= 0; k
< argc
; ++k
)
190 #pragma omp parallel for linear(v : j)
191 for (int k
= 0; k
< argc
; ++k
) {
195 #pragma omp parallel for linear(i)
196 for (int k
= 0; k
< argc
; ++k
)
203 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
209 int main(int argc
, char **argv
) {
211 // expected-note@+1 {{in instantiation of function template specialization 'test_template<-4, double, int>' requested here}}
212 test_template
<-4>(darr
, 4);
213 // expected-note@+1 {{in instantiation of function template specialization 'test_warn<0>' requested here}}
216 S4
e(4); // expected-note {{'e' defined here}}
217 S5
g(5); // expected-note {{'g' defined here}}
220 #pragma omp parallel for linear // expected-error {{expected '(' after 'linear'}}
221 for (int k
= 0; k
< argc
; ++k
)
223 #pragma omp parallel for linear( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
224 for (int k
= 0; k
< argc
; ++k
)
226 #pragma omp parallel for linear() // expected-error {{expected expression}}
227 for (int k
= 0; k
< argc
; ++k
)
229 #pragma omp parallel for linear(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
230 for (int k
= 0; k
< argc
; ++k
)
232 #pragma omp parallel for linear(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
233 for (int k
= 0; k
< argc
; ++k
)
235 #pragma omp parallel for linear(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
236 for (int k
= 0; k
< argc
; ++k
)
238 #pragma omp parallel for linear(argc, z)
239 for (int k
= 0; k
< argc
; ++k
)
241 #pragma omp parallel for linear(S1) // expected-error {{'S1' does not refer to a value}}
242 for (int k
= 0; k
< argc
; ++k
)
244 // expected-error@+2 {{linear variable with incomplete type 'S1'}}
245 // expected-error@+1 {{argument of a linear clause should be of integral or pointer type, not 'S2'}}
246 #pragma omp parallel for linear(a, b)
247 for (int k
= 0; k
< argc
; ++k
)
249 #pragma omp parallel for linear(argv[1]) // expected-error {{expected variable name}}
250 for (int k
= 0; k
< argc
; ++k
)
252 // expected-error@+2 {{argument of a linear clause should be of integral or pointer type, not 'S4'}}
253 // expected-error@+1 {{argument of a linear clause should be of integral or pointer type, not 'S5'}}
254 #pragma omp parallel for linear(e, g)
255 for (int k
= 0; k
< argc
; ++k
)
257 #pragma omp parallel for linear(h, C::x) // expected-error 2 {{threadprivate or thread local variable cannot be linear}}
258 for (int k
= 0; k
< argc
; ++k
)
263 #pragma omp parallel for linear(i)
264 for (int k
= 0; k
< argc
; ++k
)
267 #pragma omp parallel for linear(i : step(4))
269 #pragma omp parallel for linear(i : 4)
271 for (int k
= 0; k
< argc
; ++k
) {
277 #pragma omp for linear(j: step() //omp52-error 2 {{expected expression}} omp52-error{{expected ')'}} omp52-note{{to match this '('}}
279 #pragma omp for linear(j)
281 for (int k
= 0; k
< argc
; ++k
)
284 #pragma omp for linear(i: step(1), step(2)) // omp52-error {{multiple 'step size' found in linear clause}}
286 #pragma omp for linear(i)
288 for (int k
= 0; k
< argc
; ++k
)
291 foomain
<int, char>(argc
, argv
); // expected-note {{in instantiation of function template specialization 'foomain<int, char>' requested here}}