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
;
9 int i
, step_sz
; // expected-note {{initialize the variable 'step_sz' to silence this warning}}
11 #pragma omp teams distribute parallel for simd linear(i : step_sz) // 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()
34 // expected-error@+2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
36 #pragma omp teams distribute parallel for simd linear(B:bfoo())
37 for (int i
= 0; i
< 10; ++i
) ;
39 // expected-error@+2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
41 #pragma omp teams distribute parallel for simd linear(B::ib:B:bfoo()) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'}}
42 for (int i
= 0; i
< 10; ++i
) ;
44 // expected-error@+2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
46 #pragma omp teams distribute parallel for simd linear(B:ib) // expected-error {{use of undeclared identifier 'ib'; did you mean 'B::ib'}}
47 for (int i
= 0; i
< 10; ++i
) ;
49 // expected-error@+2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
51 #pragma omp teams distribute parallel for simd linear(z:B:ib) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'?}}
52 for (int i
= 0; i
< 10; ++i
) ;
54 // expected-error@+2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
56 #pragma omp teams distribute parallel for simd linear(B:B::bfoo())
57 for (int i
= 0; i
< 10; ++i
) ;
59 // expected-error@+2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
61 #pragma omp teams distribute parallel for simd linear(X::x : ::z)
62 for (int i
= 0; i
< 10; ++i
) ;
64 // expected-error@+2 3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
66 #pragma omp teams distribute parallel for simd linear(B,::z, X::x)
67 for (int i
= 0; i
< 10; ++i
) ;
69 // expected-error@+2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
71 #pragma omp teams distribute parallel for simd linear(::z)
72 for (int i
= 0; i
< 10; ++i
) ;
75 #pragma omp teams distribute parallel for simd linear(B::bfoo()) // expected-error {{expected variable name}}
76 for (int i
= 0; i
< 10; ++i
) ;
78 // expected-error@+2 2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
80 #pragma omp teams distribute parallel for simd linear(B::ib,B:C1+C2)
81 for (int i
= 0; i
< 10; ++i
) ;
84 template<int L
, class T
, class N
> T
test_template(T
* arr
, N num
) {
87 T ind2
= - num
* L
; // expected-note {{'ind2' defined here}}
90 #pragma omp teams distribute parallel for simd linear(ind2:L) // expected-error {{argument of a linear clause should be of integral or pointer type}}
91 for (i
= 0; i
< num
; ++i
) {
92 T cur
= arr
[(int)ind2
];
99 template<int LEN
> int test_warn() {
101 // expected-error@+2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
103 #pragma omp teams distribute parallel for simd linear(ind2:LEN) // expected-warning {{zero linear step (ind2 should probably be const)}}
104 for (int i
= 0; i
< 100; i
++) {
110 struct S1
; // expected-note 2 {{declared here}} expected-note 3 {{forward declaration of 'S1'}}
117 const S2 b
; // expected-note 2 {{'b' defined here}}
139 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
141 template<class I
, class C
> int foomain(I argc
, C
**argv
) {
148 #pragma omp teams distribute parallel for simd linear // expected-error {{expected '(' after 'linear'}}
149 for (int k
= 0; k
< argc
; ++k
) ++k
;
152 #pragma omp teams distribute parallel for simd linear ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
153 for (int k
= 0; k
< argc
; ++k
) ++k
;
156 #pragma omp teams distribute parallel for simd linear () // expected-error {{expected expression}}
157 for (int k
= 0; k
< argc
; ++k
) ++k
;
159 // expected-error@+2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
161 #pragma omp teams distribute parallel for simd linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
162 for (int k
= 0; k
< argc
; ++k
) ++k
;
164 // expected-error@+2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
166 #pragma omp teams distribute parallel for simd linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
167 for (int k
= 0; k
< argc
; ++k
) ++k
;
170 #pragma omp teams distribute parallel for simd linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
171 for (int k
= 0; k
< argc
; ++k
) ++k
;
173 // expected-error@+2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
175 #pragma omp teams distribute 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 '('}}
176 for (int k
= 0; k
< argc
; ++k
) ++k
;
179 #pragma omp teams distribute parallel for simd linear (S1) // expected-error {{'S1' does not refer to a value}}
180 for (int k
= 0; k
< argc
; ++k
) ++k
;
183 #pragma omp teams distribute parallel for simd linear (a, b:B::ib) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{argument of a linear clause should be of integral or pointer type, not 'S2'}}
184 for (int k
= 0; k
< argc
; ++k
) ++k
;
187 #pragma omp teams distribute parallel for simd linear (argv[1]) // expected-error {{expected variable name}}
188 for (int k
= 0; k
< argc
; ++k
) ++k
;
190 // expected-error@+2 2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
192 #pragma omp teams distribute parallel for simd linear(e, g)
193 for (int k
= 0; k
< argc
; ++k
) ++k
;
196 #pragma omp teams distribute parallel for simd linear(h) // expected-error {{threadprivate or thread local variable cannot be linear}}
197 for (int k
= 0; k
< argc
; ++k
) ++k
;
199 // expected-error@+2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
201 #pragma omp teams distribute parallel for simd linear(i)
202 for (int k
= 0; k
< argc
; ++k
) ++k
;
209 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
215 int main(int argc
, char **argv
) {
217 // expected-note@+1 {{in instantiation of function template specialization 'test_template<-4, double, int>' requested here}}
218 test_template
<-4>(darr
, 4);
219 // expected-note@+1 {{in instantiation of function template specialization 'test_warn<0>' requested here}}
222 S4
e(4); // expected-note {{'e' defined here}}
223 S5
g(5); // expected-note {{'g' defined here}}
228 #pragma omp teams distribute parallel for simd linear // expected-error {{expected '(' after 'linear'}}
229 for (int k
= 0; k
< argc
; ++k
) ++k
;
232 #pragma omp teams distribute parallel for simd linear ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
233 for (int k
= 0; k
< argc
; ++k
) ++k
;
236 #pragma omp teams distribute parallel for simd linear () // expected-error {{expected expression}}
237 for (int k
= 0; k
< argc
; ++k
) ++k
;
239 // expected-error@+2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
241 #pragma omp teams distribute parallel for simd linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
242 for (int k
= 0; k
< argc
; ++k
) ++k
;
244 // expected-error@+2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
246 #pragma omp teams distribute parallel for simd linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
247 for (int k
= 0; k
< argc
; ++k
) ++k
;
250 #pragma omp teams distribute parallel for simd linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
251 for (int k
= 0; k
< argc
; ++k
) ++k
;
253 // expected-error@+2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
255 #pragma omp teams distribute parallel for simd linear (argc)
256 for (int k
= 0; k
< argc
; ++k
) ++k
;
259 #pragma omp teams distribute parallel for simd linear (S1) // expected-error {{'S1' does not refer to a value}}
260 for (int k
= 0; k
< argc
; ++k
) ++k
;
264 #pragma omp teams distribute parallel for simd linear (a, b) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{argument of a linear clause should be of integral or pointer type, not 'S2'}} expected-error {{incomplete type 'S1' where a complete type is required}}
265 for (int k
= 0; k
< argc
; ++k
) ++k
;
268 #pragma omp teams distribute parallel for simd linear (argv[1]) // expected-error {{expected variable name}}
269 for (int k
= 0; k
< argc
; ++k
) ++k
;
272 #pragma omp teams distribute parallel for simd linear(e, g) // expected-error {{argument of a linear clause should be of integral or pointer type, not 'S4'}} expected-error {{argument of a linear clause should be of integral or pointer type, not 'S5'}}
273 for (int k
= 0; k
< argc
; ++k
) ++k
;
276 #pragma omp teams distribute parallel for simd linear(h, C::x) // expected-error 2 {{threadprivate or thread local variable cannot be linear}}
277 for (int k
= 0; k
< argc
; ++k
) ++k
;
279 foomain
<int,char>(argc
,argv
); // expected-note {{in instantiation of function template specialization 'foomain<int, char>' requested here}}