388 lines · cpp
1// RUN: %clang_cc1 -triple powerpc64le-unknown-unknown -fsyntax-only \2// RUN: -fcxx-exceptions -target-cpu pwr10 %s -verify3// RUN: %clang_cc1 -triple powerpc64-unknown-unknown -fsyntax-only \4// RUN: -fcxx-exceptions -target-cpu pwr10 %s -verify5 6// vector quad7 8// alias9using vq_t = __vector_quad;10void testVQAlias(int *inp, int *outp) {11 vq_t *vqin = (vq_t *)inp;12 vq_t *vqout = (vq_t *)outp;13 *vqout = *vqin;14}15 16class TestClassVQ {17 // method argument18public: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 }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 }29 void testVQArg3(__vector_quad *vq, int *ptr) {30 __vector_quad *vqp = (__vector_quad *)ptr;31 *vqp = *vq;32 vqp1 = vqp;33 }34 void testVQArg4(const __vector_quad *const vq, int *ptr) {35 __vector_quad *vqp = (__vector_quad *)ptr;36 *vqp = *vq;37 vqp2 = vqp;38 }39 void testVQArg5(__vector_quad vqa[], int *ptr) {40 __vector_quad *vqp = (__vector_quad *)ptr;41 *vqp = vqa[0];42 *vqp1 = vqa[1];43 }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 }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 return56 __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 62 __vector_quad *testVQRet2(int *ptr) {63 __vector_quad *vqp = (__vector_quad *)ptr;64 vq2 = *vqp;65 return vqp + 2;66 }67 68 const __vector_quad *testVQRet3(int *ptr) {69 __vector_quad *vqp = (__vector_quad *)ptr;70 vqp1 = vqp;71 return vqp + 2;72 }73 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 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 argument87 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;91 }92 93 // class field94public:95 __vector_quad vq1; // expected-error {{invalid use of PPC MMA type}}96 __vector_quad *vqp1;97 98private:99 vq_t vq2; // expected-error {{invalid use of PPC MMA type}}100 vq_t *vqp2;101};102 103// template104template <typename T>105class ClassTemplateVQ1 {106 T t; // expected-error {{invalid use of PPC MMA type}}107};108template <typename T>109class ClassTemplateVQ2 {110 T *t;111};112template <typename T>113class ClassTemplateVQ3 {114 int foo(T t) { return 10; }115};116template <typename T, typename... Ts>117class ClassTemplateVQ4 {118public:119 T operator()(Ts...) const {} // expected-error {{invalid use of PPC MMA type}}120};121void 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 be129 // 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 type146auto testVQTrailing1() {147 __vector_quad vq;148 return vq; // expected-error {{invalid use of PPC MMA type}}149}150auto testVQTrailing2() {151 __vector_quad *vqp;152 return vqp;153}154auto 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}158auto testVQTrailing4() -> vq_t * {159 __vector_quad *vqp;160 return vqp;161}162 163// new/delete164void 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 expressions172void 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// cast185void TestVQCast() {186 __vector_quad vq;187 int *ip = reinterpret_cast<int *>(&vq);188 __vector_quad *vq2 = reinterpret_cast<__vector_quad *>(ip);189}190 191// throw192void TestVQThrow() {193 __vector_quad vq;194 throw vq; // expected-error {{invalid use of PPC MMA type}}195}196 197// vector pair198 199// alias200using vp_t = __vector_pair;201void testVPAlias(int *inp, int *outp) {202 vp_t *vpin = (vp_t *)inp;203 vp_t *vpout = (vp_t *)outp;204 *vpout = *vpin;205}206 207class TestClassVP {208 // method argument209public: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 }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 }220 void testVPArg3(__vector_pair *vp, int *ptr) {221 __vector_pair *vpp = (__vector_pair *)ptr;222 *vpp = *vp;223 vpp1 = vpp;224 }225 void testVPArg4(const __vector_pair *const vp, int *ptr) {226 __vector_pair *vpp = (__vector_pair *)ptr;227 *vpp = *vp;228 vpp2 = vpp;229 }230 void testVPArg5(__vector_pair vpa[], int *ptr) {231 __vector_pair *vpp = (__vector_pair *)ptr;232 *vpp = vpa[0];233 *vpp1 = vpa[1];234 }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 }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 return247 __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 253 __vector_pair *testVPRet2(int *ptr) {254 __vector_pair *vpp = (__vector_pair *)ptr;255 vp2 = *vpp;256 return vpp + 2;257 }258 259 const __vector_pair *testVPRet3(int *ptr) {260 __vector_pair *vpp = (__vector_pair *)ptr;261 vpp1 = vpp;262 return vpp + 2;263 }264 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 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 argument278 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;282 }283 284 // class field285public:286 __vector_pair vp1; // expected-error {{invalid use of PPC MMA type}}287 __vector_pair *vpp1;288 289private:290 vp_t vp2; // expected-error {{invalid use of PPC MMA type}}291 vp_t *vpp2;292};293 294// template295template <typename T>296class ClassTemplateVP1 {297 T t; // expected-error {{invalid use of PPC MMA type}}298};299template <typename T>300class ClassTemplateVP2 {301 T *t;302};303template <typename T>304class ClassTemplateVP3 {305 int foo(T t) { return 10; }306};307template <typename T, typename... Ts>308class ClassTemplateVP4 {309public:310 T operator()(Ts...) const {} // expected-error {{invalid use of PPC MMA type}}311};312void 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 be320 // 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 type337auto testVPTrailing1() {338 __vector_pair vp;339 return vp; // expected-error {{invalid use of PPC MMA type}}340}341auto testVPTrailing2() {342 __vector_pair *vpp;343 return vpp;344}345auto 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}349auto testVPTrailing4() -> vp_t * {350 __vector_pair *vpp;351 return vpp;352}353 354// new/delete355void 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 expressions363void 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// cast377void TestVPCast() {378 __vector_pair vp;379 int *ip = reinterpret_cast<int *>(&vp);380 __vector_pair *vp2 = reinterpret_cast<__vector_pair *>(ip);381}382 383// throw384void TestVPThrow() {385 __vector_pair vp;386 throw vp; // expected-error {{invalid use of PPC MMA type}}387}388