1 // RUN: %clang_cc1 -triple powerpc64le-unknown-unknown -fsyntax-only \
2 // RUN: -fcxx-exceptions -target-cpu pwr10 %s -verify
3 // RUN: %clang_cc1 -triple powerpc64-unknown-unknown -fsyntax-only \
4 // RUN: -fcxx-exceptions -target-cpu pwr10 %s -verify
5
6 // vector quad
7
8 // alias
9 using vq_t = __vector_quad;
testVQAlias(int * inp,int * outp)10 void testVQAlias(int *inp, int *outp) {
11 vq_t *vqin = (vq_t *)inp;
12 vq_t *vqout = (vq_t *)outp;
13 *vqout = *vqin;
14 }
15
16 class TestClassVQ {
17 // method argument
18 public:
testVQArg1(__vector_quad vq,int * ptr)19 void testVQArg1(__vector_quad vq, int *ptr) { // expected-error {{invalid use of PPC MMA type}}
20 __vector_quad *vqp = (__vector_quad *)ptr;
21 *vqp = vq;
22 *vqp1 = vq;
23 }
testVQArg2(const __vector_quad vq,int * ptr)24 void testVQArg2(const __vector_quad vq, int *ptr) { // expected-error {{invalid use of PPC MMA type}}
25 __vector_quad *vqp = (__vector_quad *)ptr;
26 *vqp = vq;
27 *vqp2 = vq;
28 }
testVQArg3(__vector_quad * vq,int * ptr)29 void testVQArg3(__vector_quad *vq, int *ptr) {
30 __vector_quad *vqp = (__vector_quad *)ptr;
31 *vqp = *vq;
32 vqp1 = vqp;
33 }
testVQArg4(const __vector_quad * const vq,int * ptr)34 void testVQArg4(const __vector_quad *const vq, int *ptr) {
35 __vector_quad *vqp = (__vector_quad *)ptr;
36 *vqp = *vq;
37 vqp2 = vqp;
38 }
testVQArg5(__vector_quad vqa[],int * ptr)39 void testVQArg5(__vector_quad vqa[], int *ptr) {
40 __vector_quad *vqp = (__vector_quad *)ptr;
41 *vqp = vqa[0];
42 *vqp1 = vqa[1];
43 }
testVQArg6(const vq_t vq,int * ptr)44 void testVQArg6(const vq_t vq, int *ptr) { // expected-error {{invalid use of PPC MMA type}}
45 __vector_quad *vqp = (__vector_quad *)ptr;
46 *vqp = vq;
47 *vqp2 = vq;
48 }
testVQArg7(const vq_t * vq,int * ptr)49 void testVQArg7(const vq_t *vq, int *ptr) {
50 __vector_quad *vqp = (__vector_quad *)ptr;
51 *vqp = *vq;
52 vqp1 = vqp;
53 }
54
55 // method return
testVQRet1(int * ptr)56 __vector_quad testVQRet1(int *ptr) { // expected-error {{invalid use of PPC MMA type}}
57 __vector_quad *vqp = (__vector_quad *)ptr;
58 vq1 = *vqp;
59 return *vqp; // expected-error {{invalid use of PPC MMA type}}
60 }
61
testVQRet2(int * ptr)62 __vector_quad *testVQRet2(int *ptr) {
63 __vector_quad *vqp = (__vector_quad *)ptr;
64 vq2 = *vqp;
65 return vqp + 2;
66 }
67
testVQRet3(int * ptr)68 const __vector_quad *testVQRet3(int *ptr) {
69 __vector_quad *vqp = (__vector_quad *)ptr;
70 vqp1 = vqp;
71 return vqp + 2;
72 }
73
testVQRet4(int * ptr)74 const vq_t testVQRet4(int *ptr) { // expected-error {{invalid use of PPC MMA type}}
75 __vector_quad *vqp = (__vector_quad *)ptr;
76 vqp2 = vqp;
77 return *vqp; // expected-error {{invalid use of PPC MMA type}}
78 }
79
testVQRet5(int * ptr)80 const vq_t *testVQRet5(int *ptr) {
81 __vector_quad *vqp = (__vector_quad *)ptr;
82 vq1 = *vqp;
83 return vqp + 2;
84 }
85
86 // template argument
87 template <typename T = __vector_quad>
testVQTemplate(T v,T * p)88 void testVQTemplate(T v, T *p) { // expected-note {{candidate template ignored: substitution failure [with T = __vector_quad]: invalid use of PPC MMA type}} \
89 expected-note {{candidate template ignored: substitution failure [with T = __vector_quad]: invalid use of PPC MMA type}}
90 *(p + 1) = v;
91 }
92
93 // class field
94 public:
95 __vector_quad vq1; // expected-error {{invalid use of PPC MMA type}}
96 __vector_quad *vqp1;
97
98 private:
99 vq_t vq2; // expected-error {{invalid use of PPC MMA type}}
100 vq_t *vqp2;
101 };
102
103 // template
104 template <typename T>
105 class ClassTemplateVQ1 {
106 T t; // expected-error {{invalid use of PPC MMA type}}
107 };
108 template <typename T>
109 class ClassTemplateVQ2 {
110 T *t;
111 };
112 template <typename T>
113 class ClassTemplateVQ3 {
foo(T t)114 int foo(T t) { return 10; }
115 };
116 template <typename T, typename... Ts>
117 class ClassTemplateVQ4 {
118 public:
operator ()(Ts...) const119 T operator()(Ts...) const {} // expected-error {{invalid use of PPC MMA type}}
120 };
testVQTemplate()121 void testVQTemplate() {
122 ClassTemplateVQ1<__vector_quad> t1; // expected-note {{in instantiation of template class 'ClassTemplateVQ1<__vector_quad>' requested here}}
123 ClassTemplateVQ1<__vector_quad *> t2;
124 ClassTemplateVQ2<__vector_quad> t3;
125 ClassTemplateVQ2<__vector_quad *> t4;
126
127 ClassTemplateVQ3<int(int, int, int)> t5;
128 // The following case is not prevented but it ok, this function type cannot be
129 // instantiated because we prevent any function from returning an MMA type.
130 ClassTemplateVQ3<__vector_quad(int, int, int)> t6;
131 ClassTemplateVQ3<int(__vector_quad, int, int)> t7; // expected-error {{invalid use of PPC MMA type}}
132
133 ClassTemplateVQ4<int, int, int, __vector_quad> t8; // expected-note {{in instantiation of template class 'ClassTemplateVQ4<int, int, int, __vector_quad>' requested here}}
134 ClassTemplateVQ4<int, int, int, __vector_quad *> t9;
135
136 TestClassVQ tc;
137 __vector_quad vq;
138 __vector_quad *vqp = &vq;
139 tc.testVQTemplate(&vq, &vqp);
140 tc.testVQTemplate<vq_t *>(&vq, &vqp);
141 tc.testVQTemplate(vq, vqp); // expected-error {{no matching member function for call to 'testVQTemplate'}}
142 tc.testVQTemplate<vq_t>(vq, vqp); // expected-error {{no matching member function for call to 'testVQTemplate'}}
143 }
144
145 // trailing return type
testVQTrailing1()146 auto testVQTrailing1() {
147 __vector_quad vq;
148 return vq; // expected-error {{invalid use of PPC MMA type}}
149 }
testVQTrailing2()150 auto testVQTrailing2() {
151 __vector_quad *vqp;
152 return vqp;
153 }
testVQTrailing3()154 auto testVQTrailing3() -> vq_t { // expected-error {{invalid use of PPC MMA type}}
155 __vector_quad vq;
156 return vq; // expected-error {{invalid use of PPC MMA type}}
157 }
testVQTrailing4()158 auto testVQTrailing4() -> vq_t * {
159 __vector_quad *vqp;
160 return vqp;
161 }
162
163 // new/delete
testVQNewDelete()164 void testVQNewDelete() {
165 __vector_quad *vqp1 = new __vector_quad;
166 __vector_quad *vqp2 = new __vector_quad[100];
167 delete vqp1;
168 delete[] vqp2;
169 }
170
171 // lambdas expressions
TestVQLambda()172 void TestVQLambda() {
173 auto f1 = [](void *ptr) -> __vector_quad {
174 __vector_quad *vqp = (__vector_quad *)ptr;
175 return *vqp; // expected-error {{invalid use of PPC MMA type}}
176 };
177 auto f2 = [](void *ptr) {
178 __vector_quad *vqp = (__vector_quad *)ptr;
179 return *vqp; // expected-error {{invalid use of PPC MMA type}}
180 };
181 auto f3 = [] { __vector_quad vq; __builtin_mma_xxsetaccz(&vq); return vq; }; // expected-error {{invalid use of PPC MMA type}}
182 }
183
184 // cast
TestVQCast()185 void TestVQCast() {
186 __vector_quad vq;
187 int *ip = reinterpret_cast<int *>(&vq);
188 __vector_quad *vq2 = reinterpret_cast<__vector_quad *>(ip);
189 }
190
191 // throw
TestVQThrow()192 void TestVQThrow() {
193 __vector_quad vq;
194 throw vq; // expected-error {{invalid use of PPC MMA type}}
195 }
196
197 // vector pair
198
199 // alias
200 using vp_t = __vector_pair;
testVPAlias(int * inp,int * outp)201 void testVPAlias(int *inp, int *outp) {
202 vp_t *vpin = (vp_t *)inp;
203 vp_t *vpout = (vp_t *)outp;
204 *vpout = *vpin;
205 }
206
207 class TestClassVP {
208 // method argument
209 public:
testVPArg1(__vector_pair vp,int * ptr)210 void testVPArg1(__vector_pair vp, int *ptr) { // expected-error {{invalid use of PPC MMA type}}
211 __vector_pair *vpp = (__vector_pair *)ptr;
212 *vpp = vp;
213 *vpp1 = vp;
214 }
testVPArg2(const __vector_pair vp,int * ptr)215 void testVPArg2(const __vector_pair vp, int *ptr) { // expected-error {{invalid use of PPC MMA type}}
216 __vector_pair *vpp = (__vector_pair *)ptr;
217 *vpp = vp;
218 *vpp2 = vp;
219 }
testVPArg3(__vector_pair * vp,int * ptr)220 void testVPArg3(__vector_pair *vp, int *ptr) {
221 __vector_pair *vpp = (__vector_pair *)ptr;
222 *vpp = *vp;
223 vpp1 = vpp;
224 }
testVPArg4(const __vector_pair * const vp,int * ptr)225 void testVPArg4(const __vector_pair *const vp, int *ptr) {
226 __vector_pair *vpp = (__vector_pair *)ptr;
227 *vpp = *vp;
228 vpp2 = vpp;
229 }
testVPArg5(__vector_pair vpa[],int * ptr)230 void testVPArg5(__vector_pair vpa[], int *ptr) {
231 __vector_pair *vpp = (__vector_pair *)ptr;
232 *vpp = vpa[0];
233 *vpp1 = vpa[1];
234 }
testVPArg6(const vp_t vp,int * ptr)235 void testVPArg6(const vp_t vp, int *ptr) { // expected-error {{invalid use of PPC MMA type}}
236 __vector_pair *vpp = (__vector_pair *)ptr;
237 *vpp = vp;
238 *vpp2 = vp;
239 }
testVPArg7(const vp_t * vp,int * ptr)240 void testVPArg7(const vp_t *vp, int *ptr) {
241 __vector_pair *vpp = (__vector_pair *)ptr;
242 *vpp = *vp;
243 vpp1 = vpp;
244 }
245
246 // method return
testVPRet1(int * ptr)247 __vector_pair testVPRet1(int *ptr) { // expected-error {{invalid use of PPC MMA type}}
248 __vector_pair *vpp = (__vector_pair *)ptr;
249 vp1 = *vpp;
250 return *vpp; // expected-error {{invalid use of PPC MMA type}}
251 }
252
testVPRet2(int * ptr)253 __vector_pair *testVPRet2(int *ptr) {
254 __vector_pair *vpp = (__vector_pair *)ptr;
255 vp2 = *vpp;
256 return vpp + 2;
257 }
258
testVPRet3(int * ptr)259 const __vector_pair *testVPRet3(int *ptr) {
260 __vector_pair *vpp = (__vector_pair *)ptr;
261 vpp1 = vpp;
262 return vpp + 2;
263 }
264
testVPRet4(int * ptr)265 const vp_t testVPRet4(int *ptr) { // expected-error {{invalid use of PPC MMA type}}
266 __vector_pair *vpp = (__vector_pair *)ptr;
267 vpp2 = vpp;
268 return *vpp; // expected-error {{invalid use of PPC MMA type}}
269 }
270
testVPRet5(int * ptr)271 const vp_t *testVPRet5(int *ptr) {
272 __vector_pair *vpp = (__vector_pair *)ptr;
273 vp1 = *vpp;
274 return vpp + 2;
275 }
276
277 // template argument
278 template <typename T = __vector_pair>
testVPTemplate(T v,T * p)279 void testVPTemplate(T v, T *p) { // expected-note {{candidate template ignored: substitution failure [with T = __vector_pair]: invalid use of PPC MMA type}} \
280 expected-note {{candidate template ignored: substitution failure [with T = __vector_pair]: invalid use of PPC MMA type}}
281 *(p + 1) = v;
282 }
283
284 // class field
285 public:
286 __vector_pair vp1; // expected-error {{invalid use of PPC MMA type}}
287 __vector_pair *vpp1;
288
289 private:
290 vp_t vp2; // expected-error {{invalid use of PPC MMA type}}
291 vp_t *vpp2;
292 };
293
294 // template
295 template <typename T>
296 class ClassTemplateVP1 {
297 T t; // expected-error {{invalid use of PPC MMA type}}
298 };
299 template <typename T>
300 class ClassTemplateVP2 {
301 T *t;
302 };
303 template <typename T>
304 class ClassTemplateVP3 {
foo(T t)305 int foo(T t) { return 10; }
306 };
307 template <typename T, typename... Ts>
308 class ClassTemplateVP4 {
309 public:
operator ()(Ts...) const310 T operator()(Ts...) const {} // expected-error {{invalid use of PPC MMA type}}
311 };
testVPTemplate()312 void testVPTemplate() {
313 ClassTemplateVP1<__vector_pair> t1; // expected-note {{in instantiation of template class 'ClassTemplateVP1<__vector_pair>' requested here}}
314 ClassTemplateVP1<__vector_pair *> t2;
315 ClassTemplateVP2<__vector_pair> t3;
316 ClassTemplateVP2<__vector_pair *> t4;
317
318 ClassTemplateVP3<int(int, int, int)> t5;
319 // The following case is not prevented but it ok, this function type cannot be
320 // instantiated because we prevent any function from returning an MMA type.
321 ClassTemplateVP3<__vector_pair(int, int, int)> t6;
322 ClassTemplateVP3<int(__vector_pair, int, int)> t7; // expected-error {{invalid use of PPC MMA type}}
323
324 ClassTemplateVP4<int, int, int, __vector_pair> t8; // expected-note {{in instantiation of template class 'ClassTemplateVP4<int, int, int, __vector_pair>' requested here}}
325 ClassTemplateVP4<int, int, int, __vector_pair *> t9;
326
327 TestClassVP tc;
328 __vector_pair vp;
329 __vector_pair *vpp = &vp;
330 tc.testVPTemplate(&vp, &vpp);
331 tc.testVPTemplate<vp_t *>(&vp, &vpp);
332 tc.testVPTemplate(vp, vpp); // expected-error {{no matching member function for call to 'testVPTemplate'}}
333 tc.testVPTemplate<vp_t>(vp, vpp); // expected-error {{no matching member function for call to 'testVPTemplate'}}
334 }
335
336 // trailing return type
testVPTrailing1()337 auto testVPTrailing1() {
338 __vector_pair vp;
339 return vp; // expected-error {{invalid use of PPC MMA type}}
340 }
testVPTrailing2()341 auto testVPTrailing2() {
342 __vector_pair *vpp;
343 return vpp;
344 }
testVPTrailing3()345 auto testVPTrailing3() -> vp_t { // expected-error {{invalid use of PPC MMA type}}
346 __vector_pair vp;
347 return vp; // expected-error {{invalid use of PPC MMA type}}
348 }
testVPTrailing4()349 auto testVPTrailing4() -> vp_t * {
350 __vector_pair *vpp;
351 return vpp;
352 }
353
354 // new/delete
testVPNewDelete()355 void testVPNewDelete() {
356 __vector_pair *vpp1 = new __vector_pair;
357 __vector_pair *vpp2 = new __vector_pair[100];
358 delete vpp1;
359 delete[] vpp2;
360 }
361
362 // lambdas expressions
TestVPLambda()363 void TestVPLambda() {
364 auto f1 = [](void *ptr) -> __vector_pair {
365 __vector_pair *vpp = (__vector_pair *)ptr;
366 return *vpp; // expected-error {{invalid use of PPC MMA type}}
367 };
368 auto f2 = [](void *ptr) {
369 __vector_pair *vpp = (__vector_pair *)ptr;
370 return *vpp; // expected-error {{invalid use of PPC MMA type}}
371 };
372 auto f3 = [](vector unsigned char vc) { __vector_pair vp; __builtin_vsx_assemble_pair(&vp, vc, vc); return vp; }; // expected-error {{invalid use of PPC MMA type}}
373 auto f4 = [](vector unsigned char vc) { __vector_pair vp; __builtin_vsx_build_pair(&vp, vc, vc); return vp; }; // expected-error {{invalid use of PPC MMA type}}
374 }
375
376 // cast
TestVPCast()377 void TestVPCast() {
378 __vector_pair vp;
379 int *ip = reinterpret_cast<int *>(&vp);
380 __vector_pair *vp2 = reinterpret_cast<__vector_pair *>(ip);
381 }
382
383 // throw
TestVPThrow()384 void TestVPThrow() {
385 __vector_pair vp;
386 throw vp; // expected-error {{invalid use of PPC MMA type}}
387 }
388