1 // RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
2 // RUN: %clang_cc1 -verify=expected,omp52 -fopenmp -fopenmp-version=52 -DOMP52 %s -Wno-openmp-mapping -Wuninitialized
4 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
5 // RUN: %clang_cc1 -verify=expected,omp52 -fopenmp-simd -fopenmp-version=52 -DOMP52 %s -Wno-openmp-mapping -Wuninitialized
7 extern int omp_default_mem_alloc
;
11 #pragma omp distribute simd linear(i)
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@+3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
37 #pragma omp distribute simd linear(B:bfoo())
38 for (int i
= 0; i
< 10; ++i
) ;
40 // expected-error@+3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
43 #pragma omp distribute simd linear(B::ib:B:bfoo()) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'}}
44 for (int i
= 0; i
< 10; ++i
) ;
46 // expected-error@+3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
49 #pragma omp distribute simd linear(B:ib) // expected-error {{use of undeclared identifier 'ib'; did you mean 'B::ib'}}
50 for (int i
= 0; i
< 10; ++i
) ;
52 // expected-error@+3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
55 #pragma omp distribute simd linear(z:B:ib) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'?}}
56 for (int i
= 0; i
< 10; ++i
) ;
58 // expected-error@+3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
61 #pragma omp distribute simd linear(B:B::bfoo())
62 for (int i
= 0; i
< 10; ++i
) ;
64 // expected-error@+3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
67 #pragma omp distribute simd linear(X::x : ::z)
68 for (int i
= 0; i
< 10; ++i
) ;
70 // expected-error@+3 3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
73 #pragma omp distribute simd linear(B,::z, X::x)
74 for (int i
= 0; i
< 10; ++i
) ;
76 // expected-error@+3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
79 #pragma omp distribute simd linear(::z)
80 for (int i
= 0; i
< 10; ++i
) ;
84 #pragma omp distribute simd linear(B::bfoo()) // expected-error {{expected variable name}}
85 for (int i
= 0; i
< 10; ++i
) ;
87 // expected-error@+3 2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
90 #pragma omp distribute simd linear(B::ib,B:C1+C2)
91 for (int i
= 0; i
< 10; ++i
) ;
94 template<int L
, class T
, class N
> T
test_template(T
* arr
, N num
) {
97 T ind2
= - num
* L
; // expected-note {{'ind2' defined here}}
101 #pragma omp distribute simd linear(ind2:L) // expected-error {{argument of a linear clause should be of integral or pointer type}}
102 for (i
= 0; i
< num
; ++i
) {
103 T cur
= arr
[(int)ind2
];
110 template<int LEN
> int test_warn() {
114 #pragma omp parallel for simd linear(ind2:LEN) // expected-warning {{zero linear step (ind2 should probably be const)}}
115 for (int i
= 0; i
< 100; i
++) {
121 struct S1
; // expected-note 2 {{declared here}} expected-note 3 {{forward declaration of 'S1'}}
128 const S2 b
; // expected-note 2 {{'b' defined here}}
150 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
152 template<class I
, class C
> int foomain(I argc
, C
**argv
) {
160 #pragma omp distribute simd linear // expected-error {{expected '(' after 'linear'}}
161 for (int k
= 0; k
< argc
; ++k
) ++k
;
165 #pragma omp distribute simd linear ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
166 for (int k
= 0; k
< argc
; ++k
) ++k
;
170 #pragma omp distribute simd linear () // expected-error {{expected expression}}
171 for (int k
= 0; k
< argc
; ++k
) ++k
;
173 // expected-error@+3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
176 #pragma omp distribute simd linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
177 for (int k
= 0; k
< argc
; ++k
) ++k
;
179 // expected-error@+3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
182 #pragma omp distribute simd linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
183 for (int k
= 0; k
< argc
; ++k
) ++k
;
187 #pragma omp distribute simd linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
188 for (int k
= 0; k
< argc
; ++k
) ++k
;
190 // expected-error@+3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
193 #pragma omp distribute simd linear (argc : 5)
194 for (int k
= 0; k
< argc
; ++k
) ++k
;
198 #pragma omp distribute simd linear (S1) // expected-error {{'S1' does not refer to a value}}
199 for (int k
= 0; k
< argc
; ++k
) ++k
;
203 #pragma omp distribute 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'}}
204 for (int k
= 0; k
< argc
; ++k
) ++k
;
208 #pragma omp distribute simd linear (argv[1]) // expected-error {{expected variable name}}
209 for (int k
= 0; k
< argc
; ++k
) ++k
;
211 // expected-error@+3 2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
214 #pragma omp distribute simd linear(e, g)
215 for (int k
= 0; k
< argc
; ++k
) ++k
;
219 #pragma omp distribute simd linear(h) // expected-error {{threadprivate or thread local variable cannot be linear}}
220 for (int k
= 0; k
< argc
; ++k
) ++k
;
222 // expected-error@+3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
225 #pragma omp distribute simd linear(i)
226 for (int k
= 0; k
< argc
; ++k
) ++k
;
233 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
239 int main(int argc
, char **argv
) {
241 // expected-note@+1 {{in instantiation of function template specialization 'test_template<-4, double, int>' requested here}}
242 test_template
<-4>(darr
, 4);
243 // expected-note@+1 {{in instantiation of function template specialization 'test_warn<0>' requested here}}
246 S4
e(4); // expected-note {{'e' defined here}}
247 S5
g(5); // expected-note {{'g' defined here}}
253 #pragma omp distribute simd linear // expected-error {{expected '(' after 'linear'}}
254 for (int k
= 0; k
< argc
; ++k
) ++k
;
258 #pragma omp distribute simd linear ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
259 for (int k
= 0; k
< argc
; ++k
) ++k
;
263 #pragma omp distribute simd linear () // expected-error {{expected expression}}
264 for (int k
= 0; k
< argc
; ++k
) ++k
;
266 // expected-error@+3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
269 #pragma omp distribute simd linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
270 for (int k
= 0; k
< argc
; ++k
) ++k
;
272 // expected-error@+3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
275 #pragma omp distribute simd linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
276 for (int k
= 0; k
< argc
; ++k
) ++k
;
280 #pragma omp distribute simd linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
281 for (int k
= 0; k
< argc
; ++k
) ++k
;
283 // expected-error@+3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
286 #pragma omp distribute simd linear (argc) 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 '('}}
287 for (int k
= 0; k
< argc
; ++k
) ++k
;
291 #pragma omp distribute simd linear (S1) // expected-error {{'S1' does not refer to a value}}
292 for (int k
= 0; k
< argc
; ++k
) ++k
;
297 #pragma omp distribute 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}}
298 for (int k
= 0; k
< argc
; ++k
) ++k
;
302 #pragma omp distribute simd linear (argv[1]) // expected-error {{expected variable name}}
303 for (int k
= 0; k
< argc
; ++k
) ++k
;
307 #pragma omp distribute 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'}}
308 for (int k
= 0; k
< argc
; ++k
) ++k
;
312 #pragma omp distribute simd linear(h, C::x) // expected-error 2 {{threadprivate or thread local variable cannot be linear}}
313 for (int k
= 0; k
< argc
; ++k
) ++k
;
320 #pragma omp distribute simd linear(k)
321 for (k
= 0; k
< argc
; ++k
) ++k
;
325 #pragma omp distribute simd linear(k : 4)
326 for (k
= 0; k
< argc
; k
+=4) { }
331 #pragma omp distribute simd linear(k: step() //omp52-error 2 {{expected expression}} omp52-error{{expected ')'}} omp52-note{{to match this '('}}
332 for (k
= 0; k
< argc
; ++k
) ++k
;
335 #pragma omp distribute simd linear(k: step(1), step(2)) // omp52-error {{multiple 'step size' found in linear clause}}
336 for (k
= 0; k
< argc
; ++k
) ++k
;
339 #pragma omp distribute simd linear(k: val, val) // omp52-error {{multiple 'linear modifier' found in linear clause}}
340 for (k
= 0; k
< argc
; ++k
) ++k
;
343 #pragma omp distribute simd linear(k: step()) // omp52-error 2 {{expected expression}}
344 for (k
= 0; k
< argc
; ++k
) ++k
;
347 #pragma omp distribute simd linear(k: pval) // omp52-error {{use of undeclared identifier 'pval'}}
348 for (k
= 0; k
< argc
; ++k
) ++k
;
351 #pragma omp distribute simd linear(i: val, step(2 // omp52-error {{expected ')' or ',' after 'step expression'}} omp52-error 2 {{expected ')'}} omp52-note 2 {{to match this '('}}
352 for (i
= 0; i
< argc
; ++i
) ++i
;
356 foomain
<int,char>(argc
,argv
); // expected-note {{in instantiation of function template specialization 'foomain<int, char>' requested here}}