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