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
, lin
, step_sz
; // expected-note {{initialize the variable 'lin' to silence this warning}} expected-note {{initialize the variable 'step_sz' to silence this warning}}
10 #pragma omp parallel 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}}
11 for (i
= 0; i
< 10; ++i
)
20 static int ib
; // expected-note {{'B::ib' declared here}}
21 static int bfoo() { return 8; }
24 int bfoo() { return 4; }
29 void test_linear_colons()
32 #pragma omp parallel for simd linear(B:bfoo())
33 for (int i
= 0; i
< 10; ++i
) ;
34 // expected-error@+1 {{unexpected ':' in nested name specifier; did you mean '::'}}
35 #pragma omp parallel for simd linear(B::ib:B:bfoo())
36 for (int i
= 0; i
< 10; ++i
) ;
37 // expected-error@+1 {{use of undeclared identifier 'ib'; did you mean 'B::ib'}}
38 #pragma omp parallel for simd linear(B:ib)
39 for (int i
= 0; i
< 10; ++i
) ;
40 // expected-error@+1 {{unexpected ':' in nested name specifier; did you mean '::'?}}
41 #pragma omp parallel for simd linear(z:B:ib)
42 for (int i
= 0; i
< 10; ++i
) ;
43 #pragma omp parallel for simd linear(B:B::bfoo())
44 for (int i
= 0; i
< 10; ++i
) ;
45 #pragma omp parallel for simd linear(X::x : ::z)
46 for (int i
= 0; i
< 10; ++i
) ;
47 #pragma omp parallel for simd linear(B,::z, X::x)
48 for (int i
= 0; i
< 10; ++i
) ;
49 #pragma omp parallel for simd linear(::z)
50 for (int i
= 0; i
< 10; ++i
) ;
51 // expected-error@+1 {{expected variable name}}
52 #pragma omp parallel for simd linear(B::bfoo())
53 for (int i
= 0; i
< 10; ++i
) ;
54 #pragma omp parallel for simd linear(B::ib,B:C1+C2)
55 for (int i
= 0; i
< 10; ++i
) ;
58 template<int L
, class T
, class N
> T
test_template(T
* arr
, N num
) {
61 T ind2
= - num
* L
; // expected-note {{'ind2' defined here}}
62 // expected-error@+1 {{argument of a linear clause should be of integral or pointer type}}
63 #pragma omp parallel for simd linear(ind2:L)
64 for (i
= 0; i
< num
; ++i
) {
65 T cur
= arr
[(int)ind2
];
72 template<int LEN
> int test_warn() {
74 // expected-warning@+1 {{zero linear step (ind2 should probably be const)}}
75 #pragma omp parallel for simd linear(ind2:LEN)
76 for (int i
= 0; i
< 100; i
++) {
82 struct S1
; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
89 const S2 b
; // expected-note 2 {{'b' defined here}}
111 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
113 template<class I
, class C
> int foomain(I argc
, C
**argv
) {
118 #pragma omp parallel for simd linear // expected-error {{expected '(' after 'linear'}}
119 for (int k
= 0; k
< argc
; ++k
) ++k
;
120 #pragma omp parallel for simd linear ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
121 for (int k
= 0; k
< argc
; ++k
) ++k
;
122 #pragma omp parallel for simd linear () // expected-error {{expected expression}}
123 for (int k
= 0; k
< argc
; ++k
) ++k
;
124 #pragma omp parallel for simd linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
125 for (int k
= 0; k
< argc
; ++k
) ++k
;
126 #pragma omp parallel for simd linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
127 for (int k
= 0; k
< argc
; ++k
) ++k
;
128 #pragma omp parallel for simd linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
129 for (int k
= 0; k
< argc
; ++k
) ++k
;
130 #pragma omp 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 '('}}
131 for (int k
= 0; k
< argc
; ++k
) ++k
;
132 #pragma omp parallel for simd linear (S1) // expected-error {{'S1' does not refer to a value}}
133 for (int k
= 0; k
< argc
; ++k
) ++k
;
134 // expected-error@+2 {{linear variable with incomplete type 'S1'}}
135 // expected-error@+1 {{argument of a linear clause should be of integral or pointer type, not 'S2'}}
136 #pragma omp parallel for simd linear (a, b:B::ib)
137 for (int k
= 0; k
< argc
; ++k
) ++k
;
138 #pragma omp parallel for simd linear (argv[1]) // expected-error {{expected variable name}}
139 for (int k
= 0; k
< argc
; ++k
) ++k
;
140 #pragma omp parallel for simd linear(e, g)
141 for (int k
= 0; k
< argc
; ++k
) ++k
;
142 #pragma omp parallel for simd linear(h) // expected-error {{threadprivate or thread local variable cannot be linear}}
143 for (int k
= 0; k
< argc
; ++k
) ++k
;
144 #pragma omp parallel for simd linear(i, z)
145 for (int k
= 0; k
< argc
; ++k
) ++k
;
150 #pragma omp parallel for simd linear(v:i)
151 for (int k
= 0; k
< argc
; ++k
) { i
= k
; v
+= i
; }
153 #pragma omp parallel for simd linear(j)
154 for (int k
= 0; k
< argc
; ++k
) ++k
;
156 #pragma omp parallel for simd linear(v:j)
157 for (int k
= 0; k
< argc
; ++k
) { ++k
; v
+= j
; }
158 #pragma omp parallel for simd linear(i)
159 for (int k
= 0; k
< argc
; ++k
) ++k
;
165 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
171 int main(int argc
, char **argv
) {
173 // expected-note@+1 {{in instantiation of function template specialization 'test_template<-4, double, int>' requested here}}
174 test_template
<-4>(darr
, 4);
175 // expected-note@+1 {{in instantiation of function template specialization 'test_warn<0>' requested here}}
178 S4
e(4); // expected-note {{'e' defined here}}
179 S5
g(5); // expected-note {{'g' defined here}}
182 #pragma omp parallel for simd linear // expected-error {{expected '(' after 'linear'}}
183 for (int k
= 0; k
< argc
; ++k
) ++k
;
184 #pragma omp parallel for simd linear ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
185 for (int k
= 0; k
< argc
; ++k
) ++k
;
186 #pragma omp parallel for simd linear () // expected-error {{expected expression}}
187 for (int k
= 0; k
< argc
; ++k
) ++k
;
188 #pragma omp parallel for simd linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
189 for (int k
= 0; k
< argc
; ++k
) ++k
;
190 #pragma omp parallel for simd linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
191 for (int k
= 0; k
< argc
; ++k
) ++k
;
192 #pragma omp parallel for simd linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
193 for (int k
= 0; k
< argc
; ++k
) ++k
;
194 #pragma omp parallel for simd linear (argc, z)
195 for (int k
= 0; k
< argc
; ++k
) ++k
;
196 #pragma omp parallel for simd linear (S1) // expected-error {{'S1' does not refer to a value}}
197 for (int k
= 0; k
< argc
; ++k
) ++k
;
198 // expected-error@+2 {{linear variable with incomplete type 'S1'}}
199 // expected-error@+1 {{argument of a linear clause should be of integral or pointer type, not 'S2'}}
200 #pragma omp parallel for simd linear (a, b)
201 for (int k
= 0; k
< argc
; ++k
) ++k
;
202 #pragma omp parallel for simd linear (argv[1]) // expected-error {{expected variable name}}
203 for (int k
= 0; k
< argc
; ++k
) ++k
;
204 // expected-error@+2 {{argument of a linear clause should be of integral or pointer type, not 'S4'}}
205 // expected-error@+1 {{argument of a linear clause should be of integral or pointer type, not 'S5'}}
206 #pragma omp parallel for simd linear(e, g)
207 for (int k
= 0; k
< argc
; ++k
) ++k
;
208 #pragma omp parallel for simd linear(h, C::x) // expected-error 2 {{threadprivate or thread local variable cannot be linear}}
209 for (int k
= 0; k
< argc
; ++k
) ++k
;
213 #pragma omp parallel for simd linear(i)
214 for (int k
= 0; k
< argc
; ++k
) ++k
;
216 #pragma omp parallel for simd linear(i : step(4))
218 #pragma omp parallel for simd linear(i : 4)
220 for (int k
= 0; k
< argc
; ++k
) { ++k
; i
+= 4; }
223 #pragma omp for linear(j: step() //omp52-error 2 {{expected expression}} omp52-error{{expected ')'}} omp52-note{{to match this '('}}
225 #pragma omp parallel for simd linear(j)
227 for (int k
= 0; k
< argc
; ++k
) ++k
;
229 #pragma omp for linear(i: step(1), step(2)) // omp52-error {{multiple 'step size' found in linear clause}}
231 #pragma omp parallel for simd linear(i)
233 for (int k
= 0; k
< argc
; ++k
) ++k
;
235 foomain
<int,char>(argc
,argv
); // expected-note {{in instantiation of function template specialization 'foomain<int, char>' requested here}}