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 for 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 for 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 for 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 for linear(z:B:ib)
32 for (int i = 0; i < 10; ++i) ;
33 #pragma omp for linear(B:B::bfoo())
34 for (int i = 0; i < 10; ++i) ;
35 #pragma omp for linear(X::x : ::z)
36 for (int i = 0; i < 10; ++i) ;
37 #pragma omp for linear(B,::z, X::x)
38 for (int i = 0; i < 10; ++i) ;
39 #pragma omp for linear(::z)
40 for (int i = 0; i < 10; ++i) ;
41 // expected-error@+1 {{expected variable name}}
42 #pragma omp for linear(B::bfoo())
43 for (int i = 0; i < 10; ++i) ;
44 #pragma omp for 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 for 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 for 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 for linear // expected-error {{expected '(' after 'linear'}}
109 for (int k = 0; k < argc; ++k) ++k;
110 #pragma omp for 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 for linear () // expected-error {{expected expression}}
113 for (int k = 0; k < argc; ++k) ++k;
114 #pragma omp for linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
115 for (int k = 0; k < argc; ++k) ++k;
116 #pragma omp for linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
117 for (int k = 0; k < argc; ++k) ++k;
118 #pragma omp for linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
119 for (int k = 0; k < argc; ++k) ++k;
120 #pragma omp for linear (argc : 5)
121 for (int k = 0; k < argc; ++k) ++k;
122 #pragma omp for linear (S1) // expected-error {{'S1' does not refer to a value}}
123 for (int k = 0; k < argc; ++k) ++k;
124 // expected-error@+2 {{linear variable with incomplete type 'S1'}}
125 // expected-error@+1 {{const-qualified variable cannot be linear}}
126 #pragma omp for linear (a, b:B::ib)
127 for (int k = 0; k < argc; ++k) ++k;
128 #pragma omp for linear (argv[1]) // expected-error {{expected variable name}}
129 for (int k = 0; k < argc; ++k) ++k;
130 #pragma omp for linear(e, g)
131 for (int k = 0; k < argc; ++k) ++k;
132 #pragma omp for linear(h) // expected-error {{threadprivate or thread local variable cannot be linear}}
133 for (int k = 0; k < argc; ++k) ++k;
134 #pragma omp for linear(i)
135 for (int k = 0; k < argc; ++k) ++k;
140 #pragma omp for linear(v:i)
141 for (int k = 0; k < argc; ++k) { i = k; v += i; }
143 #pragma omp for linear(j)
144 for (int k = 0; k < argc; ++k) ++k;
146 #pragma omp for linear(v:j)
147 for (int k = 0; k < argc; ++k) { ++k; v += j; }
148 #pragma omp for linear(i)
149 for (int k = 0; k < argc; ++k) ++k;
150 #pragma omp for linear(i) ordered(1) // expected-error {{'linear' clause cannot be specified along with 'ordered' clause with a parameter}}
151 for (int k = 0; k < argc; ++k) ++k;
157 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
163 int main(int argc, char **argv) {
165 // expected-note@+1 {{in instantiation of function template specialization 'test_template<-4, double, int>' requested here}}
166 test_template<-4>(darr, 4);
167 // expected-note@+1 {{in instantiation of function template specialization 'test_warn<0>' requested here}}
170 S4 e(4); // expected-note {{'e' defined here}}
171 S5 g(5); // expected-note {{'g' defined here}}
174 #pragma omp for linear // expected-error {{expected '(' after 'linear'}}
175 for (int k = 0; k < argc; ++k) ++k;
176 #pragma omp for linear ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
177 for (int k = 0; k < argc; ++k) ++k;
178 #pragma omp for linear () // expected-error {{expected expression}}
179 for (int k = 0; k < argc; ++k) ++k;
180 #pragma omp for linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
181 for (int k = 0; k < argc; ++k) ++k;
182 #pragma omp for linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
183 for (int k = 0; k < argc; ++k) ++k;
184 #pragma omp for linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
185 for (int k = 0; k < argc; ++k) ++k;
186 #pragma omp for linear (argc)
187 for (int k = 0; k < argc; ++k) ++k;
188 #pragma omp for linear (S1) // expected-error {{'S1' does not refer to a value}}
189 for (int k = 0; k < argc; ++k) ++k;
190 // expected-error@+2 {{linear variable with incomplete type 'S1'}}
191 // expected-error@+1 {{const-qualified variable cannot be linear}}
192 #pragma omp for linear(a, b)
193 for (int k = 0; k < argc; ++k) ++k;
194 #pragma omp for linear (argv[1]) // expected-error {{expected variable name}}
195 for (int k = 0; k < argc; ++k) ++k;
196 // expected-error@+2 {{argument of a linear clause should be of integral or pointer type, not 'S4'}}
197 // expected-error@+1 {{argument of a linear clause should be of integral or pointer type, not 'S5'}}
198 #pragma omp for linear(e, g)
199 for (int k = 0; k < argc; ++k) ++k;
200 #pragma omp for linear(h, C::x) // expected-error 2 {{threadprivate or thread local variable cannot be linear}}
201 for (int k = 0; k < argc; ++k) ++k;
205 #pragma omp for linear(i)
206 for (int k = 0; k < argc; ++k) ++k;
207 #pragma omp for linear(i : 4)
208 for (int k = 0; k < argc; ++k) { ++k; i += 4; }
210 #pragma omp for linear(j)
211 for (int k = 0; k < argc; ++k) ++k;
212 #pragma omp for linear(i)
213 for (int k = 0; k < argc; ++k) ++k;
214 #pragma omp for linear(i) ordered(1) // expected-error {{'linear' clause cannot be specified along with 'ordered' clause with a parameter}}
215 for (int k = 0; k < argc; ++k) ++k;
217 foomain<int,char>(argc,argv); // expected-note {{n instantiation of function template specialization 'foomain<int, char>' requested here}}