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 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}}
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()
33 #pragma omp for simd linear(B:bfoo())
34 for (int i
= 0; i
< 10; ++i
) ;
35 // expected-error@+1 {{unexpected ':' in nested name specifier; did you mean '::'}}
36 #pragma omp for simd linear(B::ib:B:bfoo())
37 for (int i
= 0; i
< 10; ++i
) ;
38 // expected-error@+1 {{use of undeclared identifier 'ib'; did you mean 'B::ib'}}
39 #pragma omp for simd linear(B:ib)
40 for (int i
= 0; i
< 10; ++i
) ;
41 // expected-error@+1 {{unexpected ':' in nested name specifier; did you mean '::'?}}
42 #pragma omp for simd linear(z:B:ib)
43 for (int i
= 0; i
< 10; ++i
) ;
44 #pragma omp for simd linear(B:B::bfoo())
45 for (int i
= 0; i
< 10; ++i
) ;
46 #pragma omp for simd linear(X::x : ::z)
47 for (int i
= 0; i
< 10; ++i
) ;
48 #pragma omp for simd linear(B,::z, X::x)
49 for (int i
= 0; i
< 10; ++i
) ;
50 #pragma omp for simd linear(::z)
51 for (int i
= 0; i
< 10; ++i
) ;
52 // expected-error@+1 {{expected variable name}}
53 #pragma omp for simd linear(B::bfoo())
54 for (int i
= 0; i
< 10; ++i
) ;
55 #pragma omp for simd linear(B::ib,B:C1+C2)
56 for (int i
= 0; i
< 10; ++i
) ;
59 template<int L
, class T
, class N
> T
test_template(T
* arr
, N num
) {
62 T ind2
= - num
* L
; // expected-note {{'ind2' defined here}}
63 // expected-error@+1 {{argument of a linear clause should be of integral or pointer type}}
64 #pragma omp for simd linear(ind2:L)
65 for (i
= 0; i
< num
; ++i
) {
66 T cur
= arr
[(int)ind2
];
73 template<int LEN
> int test_warn() {
75 // expected-warning@+1 {{zero linear step (ind2 should probably be const)}}
76 #pragma omp for simd linear(ind2:LEN)
77 for (int i
= 0; i
< 100; i
++) {
83 struct S1
; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
90 const S2 b
; // expected-note 2 {{'b' defined here}}
112 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
114 template<class I
, class C
> int foomain(I argc
, C
**argv
) {
119 #pragma omp for simd linear // expected-error {{expected '(' after 'linear'}}
120 for (int k
= 0; k
< argc
; ++k
) ++k
;
121 #pragma omp for simd linear ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
122 for (int k
= 0; k
< argc
; ++k
) ++k
;
123 #pragma omp for simd linear () // expected-error {{expected expression}}
124 for (int k
= 0; k
< argc
; ++k
) ++k
;
125 #pragma omp for simd linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
126 for (int k
= 0; k
< argc
; ++k
) ++k
;
127 #pragma omp for simd linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
128 for (int k
= 0; k
< argc
; ++k
) ++k
;
129 #pragma omp for simd linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
130 for (int k
= 0; k
< argc
; ++k
) ++k
;
131 #pragma omp 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 '('}}
132 for (int k
= 0; k
< argc
; ++k
) ++k
;
133 #pragma omp for simd linear (S1) // expected-error {{'S1' does not refer to a value}}
134 for (int k
= 0; k
< argc
; ++k
) ++k
;
135 // expected-error@+2 {{linear variable with incomplete type 'S1'}}
136 // expected-error@+1 {{argument of a linear clause should be of integral or pointer type, not 'S2'}}
137 #pragma omp for simd linear (a, b:B::ib)
138 for (int k
= 0; k
< argc
; ++k
) ++k
;
139 #pragma omp for simd linear (argv[1]) // expected-error {{expected variable name}}
140 for (int k
= 0; k
< argc
; ++k
) ++k
;
141 #pragma omp for simd linear(e, g)
142 for (int k
= 0; k
< argc
; ++k
) ++k
;
143 #pragma omp for simd linear(h) // expected-error {{threadprivate or thread local variable cannot be linear}}
144 for (int k
= 0; k
< argc
; ++k
) ++k
;
145 #pragma omp for simd linear(i)
146 for (int k
= 0; k
< argc
; ++k
) ++k
;
152 #pragma omp for simd linear(z, v:i)
153 for (int k
= 0; k
< argc
; ++k
) { i
= k
; v
+= i
; }
155 #pragma omp for simd linear(j)
156 for (int k
= 0; k
< argc
; ++k
) ++k
;
158 #pragma omp for simd linear(v:j)
159 for (int k
= 0; k
< argc
; ++k
) { ++k
; v
+= j
; }
160 #pragma omp for simd linear(i)
161 for (int k
= 0; k
< argc
; ++k
) ++k
;
167 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
173 int main(int argc
, char **argv
) {
175 // expected-note@+1 {{in instantiation of function template specialization 'test_template<-4, double, int>' requested here}}
176 test_template
<-4>(darr
, 4);
177 // expected-note@+1 {{in instantiation of function template specialization 'test_warn<0>' requested here}}
180 S4
e(4); // expected-note {{'e' defined here}}
181 S5
g(5); // expected-note {{'g' defined here}}
184 #pragma omp for simd linear // expected-error {{expected '(' after 'linear'}}
185 for (int k
= 0; k
< argc
; ++k
) ++k
;
186 #pragma omp for simd linear ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
187 for (int k
= 0; k
< argc
; ++k
) ++k
;
188 #pragma omp for simd linear () // expected-error {{expected expression}}
189 for (int k
= 0; k
< argc
; ++k
) ++k
;
190 #pragma omp for simd linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
191 for (int k
= 0; k
< argc
; ++k
) ++k
;
192 #pragma omp for simd linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
193 for (int k
= 0; k
< argc
; ++k
) ++k
;
194 #pragma omp for simd linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
195 for (int k
= 0; k
< argc
; ++k
) ++k
;
196 #pragma omp for simd linear (argc)
197 for (int k
= 0; k
< argc
; ++k
) ++k
;
198 #pragma omp for simd linear (S1) // expected-error {{'S1' does not refer to a value}}
199 for (int k
= 0; k
< argc
; ++k
) ++k
;
200 // expected-error@+2 {{linear variable with incomplete type 'S1'}}
201 // expected-error@+1 {{argument of a linear clause should be of integral or pointer type, not 'S2'}}
202 #pragma omp for simd linear(a, b)
203 for (int k
= 0; k
< argc
; ++k
) ++k
;
204 #pragma omp for simd linear (argv[1]) // expected-error {{expected variable name}}
205 for (int k
= 0; k
< argc
; ++k
) ++k
;
206 // expected-error@+2 {{argument of a linear clause should be of integral or pointer type, not 'S4'}}
207 // expected-error@+1 {{argument of a linear clause should be of integral or pointer type, not 'S5'}}
208 #pragma omp for simd linear(e, g)
209 for (int k
= 0; k
< argc
; ++k
) ++k
;
210 #pragma omp for simd linear(h, C::x) // expected-error 2 {{threadprivate or thread local variable cannot be linear}}
211 for (int k
= 0; k
< argc
; ++k
) ++k
;
215 #pragma omp for simd linear(i)
216 for (int k
= 0; k
< argc
; ++k
) ++k
;
218 #pragma omp for simd linear(i : step(4))
220 #pragma omp for simd linear(i : 4)
222 for (int k
= 0; k
< argc
; ++k
) { ++k
; i
+= 4; }
225 #pragma omp for simd linear(j: step() //omp52-error 2 {{expected expression}} omp52-error{{expected ')'}} omp52-note{{to match this '('}}
227 #pragma omp for simd linear(j)
229 for (int k
= 0; k
< argc
; ++k
) ++k
;
231 #pragma omp for simd linear(i: step(1), step(2)) // omp52-error {{multiple 'step size' found in linear clause}}
233 #pragma omp for simd linear(i)
235 for (int k
= 0; k
< argc
; ++k
) ++k
;
237 #pragma omp for simd linear(j: step()) // omp52-error 2 {{expected expression}}
238 for (int k
= 0; k
< argc
; ++k
) ++k
;
239 #pragma omp for simd linear(j: pval) // omp52-error {{use of undeclared identifier 'pval'}}
240 for (int k
= 0; k
< argc
; ++k
) ++k
;
241 #pragma omp for simd linear(i: val, step(2 // omp52-error 3 {{expected ')'}} omp52-note 2 {{to match this '('}}
242 for (int k
= 0; k
< argc
; ++k
) ++k
;
245 foomain
<int,char>(argc
,argv
); // expected-note {{in instantiation of function template specialization 'foomain<int, char>' requested here}}