[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / SemaCXX / ppc-pair-mma-types.cpp
blob933990fa80ba6c67fa1af98680e909520756dfe2
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
6 // vector quad
8 // alias
9 using vq_t = __vector_quad;
10 void testVQAlias(int *inp, int *outp) {
11 vq_t *vqin = (vq_t *)inp;
12 vq_t *vqout = (vq_t *)outp;
13 *vqout = *vqin;
16 class TestClassVQ {
17 // method argument
18 public:
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;
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;
29 void testVQArg3(__vector_quad *vq, int *ptr) {
30 __vector_quad *vqp = (__vector_quad *)ptr;
31 *vqp = *vq;
32 vqp1 = vqp;
34 void testVQArg4(const __vector_quad *const vq, int *ptr) {
35 __vector_quad *vqp = (__vector_quad *)ptr;
36 *vqp = *vq;
37 vqp2 = vqp;
39 void testVQArg5(__vector_quad vqa[], int *ptr) {
40 __vector_quad *vqp = (__vector_quad *)ptr;
41 *vqp = vqa[0];
42 *vqp1 = vqa[1];
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;
49 void testVQArg7(const vq_t *vq, int *ptr) {
50 __vector_quad *vqp = (__vector_quad *)ptr;
51 *vqp = *vq;
52 vqp1 = vqp;
55 // method return
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}}
62 __vector_quad *testVQRet2(int *ptr) {
63 __vector_quad *vqp = (__vector_quad *)ptr;
64 vq2 = *vqp;
65 return vqp + 2;
68 const __vector_quad *testVQRet3(int *ptr) {
69 __vector_quad *vqp = (__vector_quad *)ptr;
70 vqp1 = vqp;
71 return vqp + 2;
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}}
80 const vq_t *testVQRet5(int *ptr) {
81 __vector_quad *vqp = (__vector_quad *)ptr;
82 vq1 = *vqp;
83 return vqp + 2;
86 // template argument
87 template <typename T = __vector_quad>
88 void testVQTemplate(T v, T *p) { // expected-note {{candidate template ignored: substitution failure [with T = vq_t]: 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;
93 // class field
94 public:
95 __vector_quad vq1; // expected-error {{invalid use of PPC MMA type}}
96 __vector_quad *vqp1;
98 private:
99 vq_t vq2; // expected-error {{invalid use of PPC MMA type}}
100 vq_t *vqp2;
103 // template
104 template <typename T>
105 class ClassTemplateVQ1 {
106 T t; // expected-error {{invalid use of PPC MMA type}}
108 template <typename T>
109 class ClassTemplateVQ2 {
110 T *t;
112 template <typename T>
113 class ClassTemplateVQ3 {
114 int foo(T t) { return 10; }
116 template <typename T, typename... Ts>
117 class ClassTemplateVQ4 {
118 public:
119 T operator()(Ts...) const {} // expected-error {{invalid use of PPC MMA type}}
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;
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}}
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;
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'}}
145 // trailing return type
146 auto testVQTrailing1() {
147 __vector_quad vq;
148 return vq; // expected-error {{invalid use of PPC MMA type}}
150 auto testVQTrailing2() {
151 __vector_quad *vqp;
152 return vqp;
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}}
158 auto testVQTrailing4() -> vq_t * {
159 __vector_quad *vqp;
160 return vqp;
163 // new/delete
164 void testVQNewDelete() {
165 __vector_quad *vqp1 = new __vector_quad;
166 __vector_quad *vqp2 = new __vector_quad[100];
167 delete vqp1;
168 delete[] vqp2;
171 // lambdas expressions
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}}
177 auto f2 = [](void *ptr) {
178 __vector_quad *vqp = (__vector_quad *)ptr;
179 return *vqp; // expected-error {{invalid use of PPC MMA type}}
181 auto f3 = [] { __vector_quad vq; __builtin_mma_xxsetaccz(&vq); return vq; }; // expected-error {{invalid use of PPC MMA type}}
184 // cast
185 void TestVQCast() {
186 __vector_quad vq;
187 int *ip = reinterpret_cast<int *>(&vq);
188 __vector_quad *vq2 = reinterpret_cast<__vector_quad *>(ip);
191 // throw
192 void TestVQThrow() {
193 __vector_quad vq;
194 throw vq; // expected-error {{invalid use of PPC MMA type}}
197 // vector pair
199 // alias
200 using vp_t = __vector_pair;
201 void testVPAlias(int *inp, int *outp) {
202 vp_t *vpin = (vp_t *)inp;
203 vp_t *vpout = (vp_t *)outp;
204 *vpout = *vpin;
207 class TestClassVP {
208 // method argument
209 public:
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;
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;
220 void testVPArg3(__vector_pair *vp, int *ptr) {
221 __vector_pair *vpp = (__vector_pair *)ptr;
222 *vpp = *vp;
223 vpp1 = vpp;
225 void testVPArg4(const __vector_pair *const vp, int *ptr) {
226 __vector_pair *vpp = (__vector_pair *)ptr;
227 *vpp = *vp;
228 vpp2 = vpp;
230 void testVPArg5(__vector_pair vpa[], int *ptr) {
231 __vector_pair *vpp = (__vector_pair *)ptr;
232 *vpp = vpa[0];
233 *vpp1 = vpa[1];
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;
240 void testVPArg7(const vp_t *vp, int *ptr) {
241 __vector_pair *vpp = (__vector_pair *)ptr;
242 *vpp = *vp;
243 vpp1 = vpp;
246 // method return
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}}
253 __vector_pair *testVPRet2(int *ptr) {
254 __vector_pair *vpp = (__vector_pair *)ptr;
255 vp2 = *vpp;
256 return vpp + 2;
259 const __vector_pair *testVPRet3(int *ptr) {
260 __vector_pair *vpp = (__vector_pair *)ptr;
261 vpp1 = vpp;
262 return vpp + 2;
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}}
271 const vp_t *testVPRet5(int *ptr) {
272 __vector_pair *vpp = (__vector_pair *)ptr;
273 vp1 = *vpp;
274 return vpp + 2;
277 // template argument
278 template <typename T = __vector_pair>
279 void testVPTemplate(T v, T *p) { // expected-note {{candidate template ignored: substitution failure [with T = vp_t]: 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;
284 // class field
285 public:
286 __vector_pair vp1; // expected-error {{invalid use of PPC MMA type}}
287 __vector_pair *vpp1;
289 private:
290 vp_t vp2; // expected-error {{invalid use of PPC MMA type}}
291 vp_t *vpp2;
294 // template
295 template <typename T>
296 class ClassTemplateVP1 {
297 T t; // expected-error {{invalid use of PPC MMA type}}
299 template <typename T>
300 class ClassTemplateVP2 {
301 T *t;
303 template <typename T>
304 class ClassTemplateVP3 {
305 int foo(T t) { return 10; }
307 template <typename T, typename... Ts>
308 class ClassTemplateVP4 {
309 public:
310 T operator()(Ts...) const {} // expected-error {{invalid use of PPC MMA type}}
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;
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}}
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;
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'}}
336 // trailing return type
337 auto testVPTrailing1() {
338 __vector_pair vp;
339 return vp; // expected-error {{invalid use of PPC MMA type}}
341 auto testVPTrailing2() {
342 __vector_pair *vpp;
343 return vpp;
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}}
349 auto testVPTrailing4() -> vp_t * {
350 __vector_pair *vpp;
351 return vpp;
354 // new/delete
355 void testVPNewDelete() {
356 __vector_pair *vpp1 = new __vector_pair;
357 __vector_pair *vpp2 = new __vector_pair[100];
358 delete vpp1;
359 delete[] vpp2;
362 // lambdas expressions
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}}
368 auto f2 = [](void *ptr) {
369 __vector_pair *vpp = (__vector_pair *)ptr;
370 return *vpp; // expected-error {{invalid use of PPC MMA type}}
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}}
376 // cast
377 void TestVPCast() {
378 __vector_pair vp;
379 int *ip = reinterpret_cast<int *>(&vp);
380 __vector_pair *vp2 = reinterpret_cast<__vector_pair *>(ip);
383 // throw
384 void TestVPThrow() {
385 __vector_pair vp;
386 throw vp; // expected-error {{invalid use of PPC MMA type}}