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 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()
33 #pragma omp for 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 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 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 linear(z:B:ib)
43 for (int i
= 0; i
< 10; ++i
) ;
44 #pragma omp for linear(B:B::bfoo())
45 for (int i
= 0; i
< 10; ++i
) ;
46 #pragma omp for linear(X::x : ::z)
47 for (int i
= 0; i
< 10; ++i
) ;
48 #pragma omp for linear(B,::z, X::x)
49 for (int i
= 0; i
< 10; ++i
) ;
50 #pragma omp for linear(::z)
51 for (int i
= 0; i
< 10; ++i
) ;
52 // expected-error@+1 {{expected variable name}}
53 #pragma omp for linear(B::bfoo())
54 for (int i
= 0; i
< 10; ++i
) ;
55 #pragma omp for 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 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 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 linear // expected-error {{expected '(' after 'linear'}}
120 for (int k
= 0; k
< argc
; ++k
) ++k
;
121 #pragma omp for 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 linear () // expected-error {{expected expression}}
124 for (int k
= 0; k
< argc
; ++k
) ++k
;
125 #pragma omp for linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
126 for (int k
= 0; k
< argc
; ++k
) ++k
;
127 #pragma omp for 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 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 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 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 linear (a, b:B::ib)
138 for (int k
= 0; k
< argc
; ++k
) ++k
;
139 #pragma omp for linear (argv[1]) // expected-error {{expected variable name}}
140 for (int k
= 0; k
< argc
; ++k
) ++k
;
141 #pragma omp for linear(e, g, k)
142 for (int k
= 0; k
< argc
; ++k
) ++k
;
143 #pragma omp for 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 linear(i)
146 for (int k
= 0; k
< argc
; ++k
) ++k
;
151 #pragma omp for linear(v:i)
152 for (int k
= 0; k
< argc
; ++k
) { i
= k
; v
+= i
; }
154 #pragma omp for linear(j)
155 for (int k
= 0; k
< argc
; ++k
) ++k
;
157 #pragma omp for linear(v:j)
158 for (int k
= 0; k
< argc
; ++k
) { ++k
; v
+= j
; }
159 #pragma omp for linear(i)
160 for (int k
= 0; k
< argc
; ++k
) ++k
;
161 #pragma omp for linear(i) ordered(1) // expected-error {{'linear' clause cannot be specified along with 'ordered' clause with a parameter}}
162 for (int k
= 0; k
< argc
; ++k
) ++k
;
168 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
174 int main(int argc
, char **argv
) {
176 // expected-note@+1 {{in instantiation of function template specialization 'test_template<-4, double, int>' requested here}}
177 test_template
<-4>(darr
, 4);
178 // expected-note@+1 {{in instantiation of function template specialization 'test_warn<0>' requested here}}
181 S4
e(4); // expected-note {{'e' defined here}}
182 S5
g(5); // expected-note {{'g' defined here}}
185 #pragma omp for linear // expected-error {{expected '(' after 'linear'}}
186 for (int k
= 0; k
< argc
; ++k
) ++k
;
187 #pragma omp for linear ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
188 for (int k
= 0; k
< argc
; ++k
) ++k
;
189 #pragma omp for linear () // expected-error {{expected expression}}
190 for (int k
= 0; k
< argc
; ++k
) ++k
;
191 #pragma omp for linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
192 for (int k
= 0; k
< argc
; ++k
) ++k
;
193 #pragma omp for linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
194 for (int k
= 0; k
< argc
; ++k
) ++k
;
195 #pragma omp for linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
196 for (int k
= 0; k
< argc
; ++k
) ++k
;
197 #pragma omp for linear (argc)
198 for (int k
= 0; k
< argc
; ++k
) ++k
;
199 #pragma omp for linear (S1) // expected-error {{'S1' does not refer to a value}}
200 for (int k
= 0; k
< argc
; ++k
) ++k
;
201 // expected-error@+2 {{linear variable with incomplete type 'S1'}}
202 // expected-error@+1 {{argument of a linear clause should be of integral or pointer type, not 'S2'}}
203 #pragma omp for linear(a, b, k)
204 for (int k
= 0; k
< argc
; ++k
) ++k
;
205 #pragma omp for linear (argv[1]) // expected-error {{expected variable name}}
206 for (int k
= 0; k
< argc
; ++k
) ++k
;
207 // expected-error@+2 {{argument of a linear clause should be of integral or pointer type, not 'S4'}}
208 // expected-error@+1 {{argument of a linear clause should be of integral or pointer type, not 'S5'}}
209 #pragma omp for linear(e, g)
210 for (int k
= 0; k
< argc
; ++k
) ++k
;
211 #pragma omp for linear(h, C::x) // expected-error 2 {{threadprivate or thread local variable cannot be linear}}
212 for (int k
= 0; k
< argc
; ++k
) ++k
;
216 #pragma omp for linear(i)
217 for (int k
= 0; k
< argc
; ++k
) ++k
;
218 #pragma omp for linear(val(i)) // omp52-error {{old syntax 'linear-modifier(list)' on 'linear' clause was deprecated, use new syntax 'linear(list: [linear-modifier,] step(step-size))'}}
219 for (int k
= 0; k
< argc
; ++k
) ++k
;
221 #pragma omp for linear(i : step(4))
223 #pragma omp for linear(i : 4)
225 for (int k
= 0; k
< argc
; ++k
) { ++k
; i
+= 4; }
228 #pragma omp for linear(j: step() //omp52-error 2 {{expected expression}} omp52-error{{expected ')'}} omp52-note{{to match this '('}}
230 #pragma omp for linear(j)
232 for (int k
= 0; k
< argc
; ++k
) ++k
;
234 #pragma omp for linear(i: step(1), val)
236 #pragma omp for linear(i)
238 for (int k
= 0; k
< argc
; ++k
) ++k
;
239 #pragma omp for linear(i) ordered(1) // expected-error {{'linear' clause cannot be specified along with 'ordered' clause with a parameter}}
240 for (int k
= 0; k
< argc
; ++k
) ++k
;
242 #pragma omp for linear(j: step()) // omp52-error 2 {{expected expression}}
243 for (int k
= 0; k
< argc
; ++k
) ++k
;
244 #pragma omp for linear(j: step(1), step(2)) // omp52-error {{multiple 'step size' found in linear clause}}
245 for (int k
= 0; k
< argc
; ++k
) ++k
;
246 #pragma omp for linear(j: val, val) // omp52-error {{multiple 'linear modifier' found in linear clause}}
247 for (int k
= 0; k
< argc
; ++k
) ++k
;
248 #pragma omp for linear(j: pval) // omp52-error{{use of undeclared identifier 'pval'}}
249 for (int k
= 0; k
< argc
; ++k
) ++k
;
250 #pragma omp for linear(i: val, step(2 // omp52-error 3 {{expected ')'}} omp52-note 2 {{to match this '('}}
251 for (int k
= 0; k
< argc
; ++k
) ++k
;
254 foomain
<int,char>(argc
,argv
); // expected-note {{n instantiation of function template specialization 'foomain<int, char>' requested here}}