1 // RUN: %clang_cc1 -verify -fopenmp %s
3 // RUN: %clang_cc1 -verify -fopenmp-simd %s
10 static int ib; // expected-note {{'B::ib' declared here}}
11 static int bfoo() { return 8; }
14 int bfoo() { return 4; }
19 void test_linear_colons()
23 // expected-error@+1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
24 #pragma omp target teams distribute simd linear(B:bfoo())
25 for (int i = 0; i < 10; ++i) ;
27 // expected-error@+1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
28 #pragma omp target teams distribute simd linear(B::ib:B:bfoo()) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'}}
29 for (int i = 0; i < 10; ++i) ;
31 // expected-error@+1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
32 #pragma omp target teams distribute simd linear(B:ib) // expected-error {{use of undeclared identifier 'ib'; did you mean 'B::ib'}}
33 for (int i = 0; i < 10; ++i) ;
35 // expected-error@+1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
36 #pragma omp target teams distribute simd linear(z:B:ib) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'?}}
37 for (int i = 0; i < 10; ++i) ;
39 // expected-error@+1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
40 #pragma omp target teams distribute simd linear(B:B::bfoo())
41 for (int i = 0; i < 10; ++i) ;
43 // expected-error@+1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
44 #pragma omp target teams distribute simd linear(X::x : ::z)
45 for (int i = 0; i < 10; ++i) ;
47 // expected-error@+1 3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
48 #pragma omp target teams distribute simd linear(B,::z, X::x)
49 for (int i = 0; i < 10; ++i) ;
51 // expected-error@+1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
52 #pragma omp target teams distribute simd linear(::z)
53 for (int i = 0; i < 10; ++i) ;
55 #pragma omp target teams distribute simd linear(B::bfoo()) // expected-error {{expected variable name}}
56 for (int i = 0; i < 10; ++i) ;
58 // expected-error@+1 2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
59 #pragma omp target teams distribute simd linear(B::ib,B:C1+C2)
60 for (int i = 0; i < 10; ++i) ;
63 template<int L, class T, class N> T test_template(T* arr, N num) {
66 T ind2 = - num * L; // expected-note {{'ind2' defined here}}
68 #pragma omp target teams distribute simd linear(ind2:L) // expected-error {{argument of a linear clause should be of integral or pointer type}}
69 for (i = 0; i < num; ++i) {
70 T cur = arr[(int)ind2];
77 template<int LEN> int test_warn() {
79 // expected-error@+1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
80 #pragma omp target teams distribute simd linear(ind2:LEN) // expected-warning {{zero linear step (ind2 should probably be const)}}
81 for (int i = 0; i < 100; i++) {
87 struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
94 const S2 b; // expected-note 2 {{'b' defined here}}
116 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
118 template<class I, class C> int foomain(I argc, C **argv) {
124 #pragma omp target teams distribute simd linear // expected-error {{expected '(' after 'linear'}}
125 for (int k = 0; k < argc; ++k) ++k;
127 #pragma omp target teams distribute simd linear ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
128 for (int k = 0; k < argc; ++k) ++k;
130 #pragma omp target teams distribute simd linear () // expected-error {{expected expression}}
131 for (int k = 0; k < argc; ++k) ++k;
133 // expected-error@+1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
134 #pragma omp target teams distribute simd linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
135 for (int k = 0; k < argc; ++k) ++k;
137 // expected-error@+1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
138 #pragma omp target teams distribute simd linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
139 for (int k = 0; k < argc; ++k) ++k;
141 #pragma omp target teams distribute simd linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
142 for (int k = 0; k < argc; ++k) ++k;
144 // expected-error@+1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
145 #pragma omp target teams distribute simd linear (argc : 5)
146 for (int k = 0; k < argc; ++k) ++k;
148 #pragma omp target teams distribute simd linear (S1) // expected-error {{'S1' does not refer to a value}}
149 for (int k = 0; k < argc; ++k) ++k;
151 #pragma omp target teams distribute simd linear (a, b:B::ib) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{const-qualified variable cannot be linear}}
152 for (int k = 0; k < argc; ++k) ++k;
154 #pragma omp target teams distribute simd linear (argv[1]) // expected-error {{expected variable name}}
155 for (int k = 0; k < argc; ++k) ++k;
157 // expected-error@+1 2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
158 #pragma omp target teams distribute simd linear(e, g)
159 for (int k = 0; k < argc; ++k) ++k;
161 #pragma omp target teams distribute simd linear(h) // expected-error {{threadprivate or thread local variable cannot be linear}}
162 for (int k = 0; k < argc; ++k) ++k;
164 // expected-error@+1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
165 #pragma omp target teams distribute simd linear(i)
166 for (int k = 0; k < argc; ++k) ++k;
173 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
179 int main(int argc, char **argv) {
181 // expected-note@+1 {{in instantiation of function template specialization 'test_template<-4, double, int>' requested here}}
182 test_template<-4>(darr, 4);
183 // expected-note@+1 {{in instantiation of function template specialization 'test_warn<0>' requested here}}
186 S4 e(4); // expected-note {{'e' defined here}}
187 S5 g(5); // expected-note {{'g' defined here}}
191 #pragma omp target teams distribute simd linear // expected-error {{expected '(' after 'linear'}}
192 for (int k = 0; k < argc; ++k) ++k;
194 #pragma omp target teams distribute simd linear ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
195 for (int k = 0; k < argc; ++k) ++k;
197 #pragma omp target teams distribute simd linear () // expected-error {{expected expression}}
198 for (int k = 0; k < argc; ++k) ++k;
200 // expected-error@+1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
201 #pragma omp target teams distribute simd linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
202 for (int k = 0; k < argc; ++k) ++k;
204 // expected-error@+1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
205 #pragma omp target teams distribute simd linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
206 for (int k = 0; k < argc; ++k) ++k;
208 #pragma omp target teams distribute simd linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
209 for (int k = 0; k < argc; ++k) ++k;
211 // expected-error@+1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
212 #pragma omp target teams distribute simd linear (argc)
213 for (int k = 0; k < argc; ++k) ++k;
215 #pragma omp target teams distribute simd linear (S1) // expected-error {{'S1' does not refer to a value}}
216 for (int k = 0; k < argc; ++k) ++k;
219 #pragma omp target teams distribute simd linear (a, b) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{const-qualified variable cannot be linear}}
220 for (int k = 0; k < argc; ++k) ++k;
222 #pragma omp target teams distribute simd linear (argv[1]) // expected-error {{expected variable name}}
223 for (int k = 0; k < argc; ++k) ++k;
225 #pragma omp target teams 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'}}
226 for (int k = 0; k < argc; ++k) ++k;
228 #pragma omp target teams distribute simd linear(h, C::x) // expected-error 2 {{threadprivate or thread local variable cannot be linear}}
229 for (int k = 0; k < argc; ++k) ++k;
231 foomain<int,char>(argc,argv); // expected-note {{in instantiation of function template specialization 'foomain<int, char>' requested here}}