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
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
;
19 void testVQArg1(__vector_quad vq
, int *ptr
) { // expected-error {{invalid use of PPC MMA type}}
20 __vector_quad
*vqp
= (__vector_quad
*)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
;
29 void testVQArg3(__vector_quad
*vq
, int *ptr
) {
30 __vector_quad
*vqp
= (__vector_quad
*)ptr
;
34 void testVQArg4(const __vector_quad
*const vq
, int *ptr
) {
35 __vector_quad
*vqp
= (__vector_quad
*)ptr
;
39 void testVQArg5(__vector_quad vqa
[], int *ptr
) {
40 __vector_quad
*vqp
= (__vector_quad
*)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
;
49 void testVQArg7(const vq_t
*vq
, int *ptr
) {
50 __vector_quad
*vqp
= (__vector_quad
*)ptr
;
56 __vector_quad
testVQRet1(int *ptr
) { // expected-error {{invalid use of PPC MMA type}}
57 __vector_quad
*vqp
= (__vector_quad
*)ptr
;
59 return *vqp
; // expected-error {{invalid use of PPC MMA type}}
62 __vector_quad
*testVQRet2(int *ptr
) {
63 __vector_quad
*vqp
= (__vector_quad
*)ptr
;
68 const __vector_quad
*testVQRet3(int *ptr
) {
69 __vector_quad
*vqp
= (__vector_quad
*)ptr
;
74 const vq_t
testVQRet4(int *ptr
) { // expected-error {{invalid use of PPC MMA type}}
75 __vector_quad
*vqp
= (__vector_quad
*)ptr
;
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
;
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
}}
95 __vector_quad vq1
; // expected-error {{invalid use of PPC MMA type}}
99 vq_t vq2
; // expected-error {{invalid use of PPC MMA type}}
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
{
112 template <typename T
>
113 class ClassTemplateVQ3
{
114 int foo(T t
) { return 10; }
116 template <typename T
, typename
... Ts
>
117 class ClassTemplateVQ4
{
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
;
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() {
148 return vq
; // expected-error {{invalid use of PPC MMA type}}
150 auto testVQTrailing2() {
154 auto testVQTrailing3() -> vq_t
{ // expected-error {{invalid use of PPC MMA type}}
156 return vq
; // expected-error {{invalid use of PPC MMA type}}
158 auto testVQTrailing4() -> vq_t
* {
164 void testVQNewDelete() {
165 __vector_quad
*vqp1
= new __vector_quad
;
166 __vector_quad
*vqp2
= new __vector_quad
[100];
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}}
187 int *ip
= reinterpret_cast<int *>(&vq
);
188 __vector_quad
*vq2
= reinterpret_cast<__vector_quad
*>(ip
);
194 throw vq
; // expected-error {{invalid use of PPC MMA type}}
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
;
210 void testVPArg1(__vector_pair vp
, int *ptr
) { // expected-error {{invalid use of PPC MMA type}}
211 __vector_pair
*vpp
= (__vector_pair
*)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
;
220 void testVPArg3(__vector_pair
*vp
, int *ptr
) {
221 __vector_pair
*vpp
= (__vector_pair
*)ptr
;
225 void testVPArg4(const __vector_pair
*const vp
, int *ptr
) {
226 __vector_pair
*vpp
= (__vector_pair
*)ptr
;
230 void testVPArg5(__vector_pair vpa
[], int *ptr
) {
231 __vector_pair
*vpp
= (__vector_pair
*)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
;
240 void testVPArg7(const vp_t
*vp
, int *ptr
) {
241 __vector_pair
*vpp
= (__vector_pair
*)ptr
;
247 __vector_pair
testVPRet1(int *ptr
) { // expected-error {{invalid use of PPC MMA type}}
248 __vector_pair
*vpp
= (__vector_pair
*)ptr
;
250 return *vpp
; // expected-error {{invalid use of PPC MMA type}}
253 __vector_pair
*testVPRet2(int *ptr
) {
254 __vector_pair
*vpp
= (__vector_pair
*)ptr
;
259 const __vector_pair
*testVPRet3(int *ptr
) {
260 __vector_pair
*vpp
= (__vector_pair
*)ptr
;
265 const vp_t
testVPRet4(int *ptr
) { // expected-error {{invalid use of PPC MMA type}}
266 __vector_pair
*vpp
= (__vector_pair
*)ptr
;
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
;
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
}}
286 __vector_pair vp1
; // expected-error {{invalid use of PPC MMA type}}
290 vp_t vp2
; // expected-error {{invalid use of PPC MMA type}}
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
{
303 template <typename T
>
304 class ClassTemplateVP3
{
305 int foo(T t
) { return 10; }
307 template <typename T
, typename
... Ts
>
308 class ClassTemplateVP4
{
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
;
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() {
339 return vp
; // expected-error {{invalid use of PPC MMA type}}
341 auto testVPTrailing2() {
345 auto testVPTrailing3() -> vp_t
{ // expected-error {{invalid use of PPC MMA type}}
347 return vp
; // expected-error {{invalid use of PPC MMA type}}
349 auto testVPTrailing4() -> vp_t
* {
355 void testVPNewDelete() {
356 __vector_pair
*vpp1
= new __vector_pair
;
357 __vector_pair
*vpp2
= new __vector_pair
[100];
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}}
379 int *ip
= reinterpret_cast<int *>(&vp
);
380 __vector_pair
*vp2
= reinterpret_cast<__vector_pair
*>(ip
);
386 throw vp
; // expected-error {{invalid use of PPC MMA type}}