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()
22 #pragma omp taskloop simd linear(B:bfoo())
23 for (int i = 0; i < 10; ++i) ;
24 // expected-error@+1 {{unexpected ':' in nested name specifier; did you mean '::'}}
25 #pragma omp taskloop simd linear(B::ib:B:bfoo())
26 for (int i = 0; i < 10; ++i) ;
27 // expected-error@+1 {{use of undeclared identifier 'ib'; did you mean 'B::ib'}}
28 #pragma omp taskloop simd linear(B:ib)
29 for (int i = 0; i < 10; ++i) ;
30 // expected-error@+1 {{unexpected ':' in nested name specifier; did you mean '::'?}}
31 #pragma omp taskloop simd linear(z:B:ib)
32 for (int i = 0; i < 10; ++i) ;
33 #pragma omp taskloop simd linear(B:B::bfoo())
34 for (int i = 0; i < 10; ++i) ;
35 #pragma omp taskloop simd linear(X::x : ::z)
36 for (int i = 0; i < 10; ++i) ;
37 #pragma omp taskloop simd linear(B,::z, X::x)
38 for (int i = 0; i < 10; ++i) ;
39 #pragma omp taskloop simd linear(::z)
40 for (int i = 0; i < 10; ++i) ;
41 // expected-error@+1 {{expected variable name}}
42 #pragma omp taskloop simd linear(B::bfoo())
43 for (int i = 0; i < 10; ++i) ;
44 #pragma omp taskloop simd linear(B::ib,B:C1+C2)
45 for (int i = 0; i < 10; ++i) ;
48 template<int L, class T, class N> T test_template(T* arr, N num) {
51 T ind2 = - num * L; // expected-note {{'ind2' defined here}}
52 // expected-error@+1 {{argument of a linear clause should be of integral or pointer type}}
53 #pragma omp taskloop simd linear(ind2:L)
54 for (i = 0; i < num; ++i) {
55 T cur = arr[(int)ind2];
62 template<int LEN> int test_warn() {
64 // expected-warning@+1 {{zero linear step (ind2 should probably be const)}}
65 #pragma omp taskloop simd linear(ind2:LEN)
66 for (int i = 0; i < 100; i++) {
72 struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
79 const S2 b; // expected-note 2 {{'b' defined here}}
101 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
103 template<class I, class C> int foomain(I argc, C **argv) {
108 #pragma omp taskloop simd linear // expected-error {{expected '(' after 'linear'}}
109 for (int k = 0; k < argc; ++k) ++k;
110 #pragma omp taskloop simd linear ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
111 for (int k = 0; k < argc; ++k) ++k;
112 #pragma omp taskloop simd linear (val // expected-error {{use of undeclared identifier 'val'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
113 for (int k = 0; k < argc; ++k) ++k;
114 #pragma omp taskloop simd linear (uval( // expected-error {{expected expression}} expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}}
115 for (int k = 0; k < argc; ++k) ++k;
116 #pragma omp taskloop simd linear (ref() // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
117 for (int k = 0; k < argc; ++k) ++k;
118 #pragma omp taskloop simd linear (foo() // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
119 for (int k = 0; k < argc; ++k) ++k;
120 #pragma omp taskloop simd linear () // expected-error {{expected expression}}
121 for (int k = 0; k < argc; ++k) ++k;
122 #pragma omp taskloop simd linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
123 for (int k = 0; k < argc; ++k) ++k;
124 #pragma omp taskloop simd linear (val argc // expected-error {{use of undeclared identifier 'val'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
125 for (int k = 0; k < argc; ++k) ++k;
126 #pragma omp taskloop simd linear (val(argc, // expected-error {{expected expression}} expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}}
127 for (int k = 0; k < argc; ++k) ++k;
128 #pragma omp taskloop 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 taskloop simd linear (argc : 5)
131 for (int k = 0; k < argc; ++k) ++k;
132 #pragma omp taskloop 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 {{const-qualified variable cannot be linear}}
136 #pragma omp taskloop simd linear (val(a, b):B::ib)
137 for (int k = 0; k < argc; ++k) ++k;
138 #pragma omp taskloop simd linear (argv[1]) // expected-error {{expected variable name}}
139 for (int k = 0; k < argc; ++k) ++k;
140 #pragma omp taskloop simd linear(ref(e, g)) // expected-error 2 {{variable of non-reference type 'int' can be used only with 'val' modifier, but used with 'ref'}}
141 for (int k = 0; k < argc; ++k) ++k;
142 #pragma omp taskloop 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 taskloop simd linear(uval(i)) // expected-error {{variable of non-reference type 'int' can be used only with 'val' modifier, but used with 'uval'}}
145 for (int k = 0; k < argc; ++k) ++k;
150 #pragma omp taskloop simd linear(v:i)
151 for (int k = 0; k < argc; ++k) { i = k; v += i; }
153 #pragma omp taskloop simd linear(ref(j))
154 for (int k = 0; k < argc; ++k) ++k;
155 #pragma omp taskloop simd linear(uval(j))
156 for (int k = 0; k < argc; ++k) ++k;
158 #pragma omp taskloop simd linear(v:j)
159 for (int k = 0; k < argc; ++k) { ++k; v += j; }
160 #pragma omp taskloop 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 void linear_modifiers(int argc) {
175 #pragma omp taskloop simd linear(f)
176 for (int k = 0; k < argc; ++k) ++k;
177 #pragma omp taskloop simd linear(val(f))
178 for (int k = 0; k < argc; ++k) ++k;
179 #pragma omp taskloop simd linear(uval(f))
180 for (int k = 0; k < argc; ++k) ++k;
181 #pragma omp taskloop simd linear(ref(f))
182 for (int k = 0; k < argc; ++k) ++k;
183 #pragma omp taskloop simd linear(foo(f)) // expected-error {{expected one of 'ref', val' or 'uval' modifiers}}
184 for (int k = 0; k < argc; ++k) ++k;
188 int main(int argc, char **argv) {
190 // expected-note@+1 {{in instantiation of function template specialization 'test_template<-4, double, int>' requested here}}
191 test_template<-4>(darr, 4);
192 // expected-note@+1 {{in instantiation of function template specialization 'test_warn<0>' requested here}}
195 S4 e(4); // expected-note {{'e' defined here}}
196 S5 g(5); // expected-note {{'g' defined here}}
199 #pragma omp taskloop simd linear(f) linear(f) // expected-error {{linear variable cannot be linear}} expected-note {{defined as linear}}
200 for (int k = 0; k < argc; ++k) ++k;
201 #pragma omp taskloop simd linear // expected-error {{expected '(' after 'linear'}}
202 for (int k = 0; k < argc; ++k) ++k;
203 #pragma omp taskloop simd linear ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
204 for (int k = 0; k < argc; ++k) ++k;
205 #pragma omp taskloop simd linear () // expected-error {{expected expression}}
206 for (int k = 0; k < argc; ++k) ++k;
207 #pragma omp taskloop simd linear (val // expected-error {{use of undeclared identifier 'val'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
208 for (int k = 0; k < argc; ++k) ++k;
209 #pragma omp taskloop simd linear (ref()) // expected-error {{expected expression}}
210 for (int k = 0; k < argc; ++k) ++k;
211 #pragma omp taskloop simd linear (foo()) // expected-error {{expected expression}}
212 for (int k = 0; k < argc; ++k) ++k;
213 #pragma omp taskloop simd linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
214 for (int k = 0; k < argc; ++k) ++k;
215 #pragma omp taskloop simd linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
216 for (int k = 0; k < argc; ++k) ++k;
217 #pragma omp taskloop simd linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
218 for (int k = 0; k < argc; ++k) ++k;
219 #pragma omp taskloop simd linear (argc)
220 for (int k = 0; k < argc; ++k) ++k;
221 #pragma omp taskloop simd linear (S1) // expected-error {{'S1' does not refer to a value}}
222 for (int k = 0; k < argc; ++k) ++k;
223 // expected-error@+2 {{linear variable with incomplete type 'S1'}}
224 // expected-error@+1 {{const-qualified variable cannot be linear}}
225 #pragma omp taskloop simd linear(a, b)
226 for (int k = 0; k < argc; ++k) ++k;
227 #pragma omp taskloop simd linear (argv[1]) // expected-error {{expected variable name}}
228 for (int k = 0; k < argc; ++k) ++k;
229 // expected-error@+2 {{argument of a linear clause should be of integral or pointer type, not 'S4'}}
230 // expected-error@+1 {{argument of a linear clause should be of integral or pointer type, not 'S5'}}
231 #pragma omp taskloop simd linear(val(e, g))
232 for (int k = 0; k < argc; ++k) ++k;
233 #pragma omp taskloop simd linear(h, C::x) // expected-error 2 {{threadprivate or thread local variable cannot be linear}}
234 for (int k = 0; k < argc; ++k) ++k;
238 #pragma omp taskloop simd linear(val(i))
239 for (int k = 0; k < argc; ++k) ++k;
240 #pragma omp taskloop simd linear(uval(i) : 4) // expected-error {{variable of non-reference type 'int' can be used only with 'val' modifier, but used with 'uval'}}
241 for (int k = 0; k < argc; ++k) { ++k; i += 4; }
243 #pragma omp taskloop simd linear(ref(j))
244 for (int k = 0; k < argc; ++k) ++k;
245 #pragma omp taskloop simd linear(i)
246 for (int k = 0; k < argc; ++k) ++k;
248 foomain<int,char>(argc,argv); // expected-note {{in instantiation of function template specialization 'foomain<int, char>' requested here}}