1 | // RUN: %clang_cc1 -verify -fopenmp %s |
2 | |
3 | // RUN: %clang_cc1 -verify -fopenmp-simd %s |
4 | |
5 | extern int omp_default_mem_alloc; |
6 | namespace X { |
7 | int x; |
8 | }; |
9 | |
10 | struct B { |
11 | static int ib; // expected-note {{'B::ib' declared here}} |
12 | static int bfoo() { return 8; } |
13 | }; |
14 | |
15 | int bfoo() { return 4; } |
16 | |
17 | int z; |
18 | const int C1 = 1; |
19 | const int C2 = 2; |
20 | void test_linear_colons() |
21 | { |
22 | int B = 0; |
23 | |
24 | // expected-error@+2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}} |
25 | #pragma omp target |
26 | #pragma omp teams distribute simd linear(B:bfoo()) |
27 | for (int i = 0; i < 10; ++i) ; |
28 | |
29 | // expected-error@+2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}} |
30 | #pragma omp target |
31 | #pragma omp teams distribute simd linear(B::ib:B:bfoo()) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'}} |
32 | for (int i = 0; i < 10; ++i) ; |
33 | |
34 | // expected-error@+2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}} |
35 | #pragma omp target |
36 | #pragma omp teams distribute simd linear(B:ib) // expected-error {{use of undeclared identifier 'ib'; did you mean 'B::ib'}} |
37 | for (int i = 0; i < 10; ++i) ; |
38 | |
39 | // expected-error@+2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}} |
40 | #pragma omp target |
41 | #pragma omp teams distribute simd linear(z:B:ib) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'?}} |
42 | for (int i = 0; i < 10; ++i) ; |
43 | |
44 | // expected-error@+2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}} |
45 | #pragma omp target |
46 | #pragma omp teams distribute simd linear(B:B::bfoo()) |
47 | for (int i = 0; i < 10; ++i) ; |
48 | |
49 | // expected-error@+2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}} |
50 | #pragma omp target |
51 | #pragma omp teams distribute simd linear(X::x : ::z) |
52 | for (int i = 0; i < 10; ++i) ; |
53 | |
54 | // expected-error@+2 3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}} |
55 | #pragma omp target |
56 | #pragma omp teams distribute simd linear(B,::z, X::x) |
57 | for (int i = 0; i < 10; ++i) ; |
58 | |
59 | // expected-error@+2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}} |
60 | #pragma omp target |
61 | #pragma omp teams distribute simd linear(::z) |
62 | for (int i = 0; i < 10; ++i) ; |
63 | |
64 | #pragma omp target |
65 | #pragma omp teams distribute simd linear(B::bfoo()) // expected-error {{expected variable name}} |
66 | for (int i = 0; i < 10; ++i) ; |
67 | |
68 | // expected-error@+2 2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}} |
69 | #pragma omp target |
70 | #pragma omp teams distribute simd linear(B::ib,B:C1+C2) |
71 | for (int i = 0; i < 10; ++i) ; |
72 | } |
73 | |
74 | template<int L, class T, class N> T test_template(T* arr, N num) { |
75 | N i; |
76 | T sum = (T)0; |
77 | T ind2 = - num * L; // expected-note {{'ind2' defined here}} |
78 | |
79 | #pragma omp target |
80 | #pragma omp teams distribute simd linear(ind2:L) // expected-error {{argument of a linear clause should be of integral or pointer type}} |
81 | for (i = 0; i < num; ++i) { |
82 | T cur = arr[(int)ind2]; |
83 | ind2 += L; |
84 | sum += cur; |
85 | } |
86 | return T(); |
87 | } |
88 | |
89 | template<int LEN> int test_warn() { |
90 | int ind2 = 0; |
91 | // expected-error@+2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}} |
92 | #pragma omp target |
93 | #pragma omp teams distribute simd linear(ind2:LEN) // expected-warning {{zero linear step (ind2 should probably be const)}} |
94 | for (int i = 0; i < 100; i++) { |
95 | ind2 += LEN; |
96 | } |
97 | return ind2; |
98 | } |
99 | |
100 | struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}} |
101 | extern S1 a; |
102 | class S2 { |
103 | mutable int a; |
104 | public: |
105 | S2():a(0) { } |
106 | }; |
107 | const S2 b; // expected-note 2 {{'b' defined here}} |
108 | const S2 ba[5]; |
109 | class S3 { |
110 | int a; |
111 | public: |
112 | S3():a(0) { } |
113 | }; |
114 | const S3 ca[5]; |
115 | class S4 { |
116 | int a; |
117 | S4(); |
118 | public: |
119 | S4(int v):a(v) { } |
120 | }; |
121 | class S5 { |
122 | int a; |
123 | S5():a(0) {} |
124 | public: |
125 | S5(int v):a(v) { } |
126 | }; |
127 | |
128 | S3 h; |
129 | #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}} |
130 | |
131 | template<class I, class C> int foomain(I argc, C **argv) { |
132 | I e(4); |
133 | I g(5); |
134 | int i; |
135 | int &j = i; |
136 | |
137 | #pragma omp target |
138 | #pragma omp teams distribute simd linear // expected-error {{expected '(' after 'linear'}} |
139 | for (int k = 0; k < argc; ++k) ++k; |
140 | |
141 | #pragma omp target |
142 | #pragma omp teams distribute simd linear ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
143 | for (int k = 0; k < argc; ++k) ++k; |
144 | |
145 | #pragma omp target |
146 | #pragma omp teams distribute simd linear () // expected-error {{expected expression}} |
147 | for (int k = 0; k < argc; ++k) ++k; |
148 | |
149 | // expected-error@+2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}} |
150 | #pragma omp target |
151 | #pragma omp teams distribute simd linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} |
152 | for (int k = 0; k < argc; ++k) ++k; |
153 | |
154 | // expected-error@+2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}} |
155 | #pragma omp target |
156 | #pragma omp teams distribute simd linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
157 | for (int k = 0; k < argc; ++k) ++k; |
158 | |
159 | #pragma omp target |
160 | #pragma omp teams distribute simd linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} |
161 | for (int k = 0; k < argc; ++k) ++k; |
162 | |
163 | // expected-error@+2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}} |
164 | #pragma omp target |
165 | #pragma omp teams distribute 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 '('}} |
166 | for (int k = 0; k < argc; ++k) ++k; |
167 | |
168 | #pragma omp target |
169 | #pragma omp teams distribute simd linear (S1) // expected-error {{'S1' does not refer to a value}} |
170 | for (int k = 0; k < argc; ++k) ++k; |
171 | |
172 | #pragma omp target |
173 | #pragma omp teams distribute simd linear (a, b:B::ib) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{argument of a linear clause should be of integral or pointer type, not 'S2'}} |
174 | for (int k = 0; k < argc; ++k) ++k; |
175 | |
176 | #pragma omp target |
177 | #pragma omp teams distribute simd linear (argv[1]) // expected-error {{expected variable name}} |
178 | for (int k = 0; k < argc; ++k) ++k; |
179 | |
180 | // expected-error@+2 2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}} |
181 | #pragma omp target |
182 | #pragma omp teams distribute simd linear(e, g) |
183 | for (int k = 0; k < argc; ++k) ++k; |
184 | |
185 | #pragma omp target |
186 | #pragma omp teams distribute simd linear(h) // expected-error {{threadprivate or thread local variable cannot be linear}} |
187 | for (int k = 0; k < argc; ++k) ++k; |
188 | |
189 | // expected-error@+2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}} |
190 | #pragma omp target |
191 | #pragma omp teams distribute simd linear(i) |
192 | for (int k = 0; k < argc; ++k) ++k; |
193 | |
194 | return 0; |
195 | } |
196 | |
197 | namespace A { |
198 | double x; |
199 | #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}} |
200 | } |
201 | namespace C { |
202 | using A::x; |
203 | } |
204 | |
205 | int main(int argc, char **argv) { |
206 | double darr[100]; |
207 | // expected-note@+1 {{in instantiation of function template specialization 'test_template<-4, double, int>' requested here}} |
208 | test_template<-4>(darr, 4); |
209 | // expected-note@+1 {{in instantiation of function template specialization 'test_warn<0>' requested here}} |
210 | test_warn<0>(); |
211 | |
212 | S4 e(4); // expected-note {{'e' defined here}} |
213 | S5 g(5); // expected-note {{'g' defined here}} |
214 | int i; |
215 | int &j = i; |
216 | |
217 | #pragma omp target |
218 | #pragma omp teams distribute simd linear // expected-error {{expected '(' after 'linear'}} |
219 | for (int k = 0; k < argc; ++k) ++k; |
220 | |
221 | #pragma omp target |
222 | #pragma omp teams distribute simd linear ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
223 | for (int k = 0; k < argc; ++k) ++k; |
224 | |
225 | #pragma omp target |
226 | #pragma omp teams distribute simd linear () // expected-error {{expected expression}} |
227 | for (int k = 0; k < argc; ++k) ++k; |
228 | |
229 | // expected-error@+2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}} |
230 | #pragma omp target |
231 | #pragma omp teams distribute simd linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} |
232 | for (int k = 0; k < argc; ++k) ++k; |
233 | |
234 | // expected-error@+2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}} |
235 | #pragma omp target |
236 | #pragma omp teams distribute simd linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
237 | for (int k = 0; k < argc; ++k) ++k; |
238 | |
239 | #pragma omp target |
240 | #pragma omp teams distribute simd linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} |
241 | for (int k = 0; k < argc; ++k) ++k; |
242 | |
243 | // expected-error@+2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}} |
244 | #pragma omp target |
245 | #pragma omp teams distribute simd linear (argc) |
246 | for (int k = 0; k < argc; ++k) ++k; |
247 | |
248 | #pragma omp target |
249 | #pragma omp teams distribute simd linear (S1) // expected-error {{'S1' does not refer to a value}} |
250 | for (int k = 0; k < argc; ++k) ++k; |
251 | |
252 | |
253 | #pragma omp target |
254 | #pragma omp teams distribute simd linear (a, b) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{argument of a linear clause should be of integral or pointer type, not 'S2'}} |
255 | for (int k = 0; k < argc; ++k) ++k; |
256 | |
257 | #pragma omp target |
258 | #pragma omp teams distribute simd linear (argv[1]) // expected-error {{expected variable name}} |
259 | for (int k = 0; k < argc; ++k) ++k; |
260 | |
261 | #pragma omp target |
262 | #pragma omp 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'}} |
263 | for (int k = 0; k < argc; ++k) ++k; |
264 | |
265 | #pragma omp target |
266 | #pragma omp teams distribute simd linear(h, C::x) // expected-error 2 {{threadprivate or thread local variable cannot be linear}} |
267 | for (int k = 0; k < argc; ++k) ++k; |
268 | |
269 | foomain<int,char>(argc,argv); // expected-note {{in instantiation of function template specialization 'foomain<int, char>' requested here}} |
270 | return 0; |
271 | } |
272 | |
273 | |