[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / Sema / ppc-pair-mma-types.c
blob6a7cfac03105870779f3f4dd3021cb996400b484
1 // RUN: %clang_cc1 -triple powerpc64le-unknown-unknown -fsyntax-only \
2 // RUN: -target-cpu pwr10 %s -verify
3 // RUN: %clang_cc1 -triple powerpc64-unknown-unknown -fsyntax-only \
4 // RUN: -target-cpu pwr10 %s -verify
6 // The use of PPC MMA types is strongly restricted. Non-pointer MMA variables
7 // can only be declared in functions and a limited number of operations are
8 // supported on these types. This test case checks that invalid uses of MMA
9 // types are correctly prevented.
11 // vector quad
13 // typedef
14 typedef __vector_quad vq_t;
16 // function argument
17 void testVQArg1(__vector_quad vq, int *ptr) { // expected-error {{invalid use of PPC MMA type}}
18 __vector_quad *vqp = (__vector_quad *)ptr;
19 *vqp = vq;
22 void testVQArg2(const __vector_quad vq, int *ptr) { // expected-error {{invalid use of PPC MMA type}}
23 __vector_quad *vqp = (__vector_quad *)ptr;
24 *vqp = vq;
27 void testVQArg6(const vq_t vq, int *ptr) { // expected-error {{invalid use of PPC MMA type}}
28 __vector_quad *vqp = (__vector_quad *)ptr;
29 *vqp = vq;
32 // function return
33 __vector_quad testVQRet1(int *ptr) { // expected-error {{invalid use of PPC MMA type}}
34 __vector_quad *vqp = (__vector_quad *)ptr;
35 return *vqp; // expected-error {{invalid use of PPC MMA type}}
38 const vq_t testVQRet4(int *ptr) { // expected-error {{invalid use of PPC MMA type}}
39 __vector_quad *vqp = (__vector_quad *)ptr;
40 return *vqp; // expected-error {{invalid use of PPC MMA type}}
43 // global
44 __vector_quad globalvq; // expected-error {{invalid use of PPC MMA type}}
45 const __vector_quad globalvq2; // expected-error {{invalid use of PPC MMA type}}
46 __vector_quad *globalvqp;
47 const __vector_quad *const globalvqp2;
48 vq_t globalvq_t; // expected-error {{invalid use of PPC MMA type}}
51 // struct field
52 struct TestVQStruct {
53 int a;
54 float b;
55 __vector_quad c; // expected-error {{invalid use of PPC MMA type}}
56 __vector_quad *vq;
59 // operators
60 int testVQOperators1(int *ptr) {
61 __vector_quad *vqp = (__vector_quad *)ptr;
62 __vector_quad vq1 = *(vqp + 0);
63 __vector_quad vq2 = *(vqp + 1);
64 __vector_quad vq3 = *(vqp + 2);
65 if (vq1) // expected-error {{statement requires expression of scalar type ('__vector_quad' invalid)}}
66 *(vqp + 10) = vq1;
67 if (!vq2) // expected-error {{invalid argument type '__vector_quad' to unary expression}}
68 *(vqp + 11) = vq3;
69 int c1 = vq1 && vq2; // expected-error {{invalid operands to binary expression ('__vector_quad' and '__vector_quad')}}
70 int c2 = vq2 == vq3; // expected-error {{invalid operands to binary expression ('__vector_quad' and '__vector_quad')}}
71 int c3 = vq2 < vq1; // expected-error {{invalid operands to binary expression ('__vector_quad' and '__vector_quad')}}
72 return c1 || c2 || c3;
75 void testVQOperators2(int *ptr) {
76 __vector_quad *vqp = (__vector_quad *)ptr;
77 __vector_quad vq1 = *(vqp + 0);
78 __vector_quad vq2 = *(vqp + 1);
79 __vector_quad vq3 = *(vqp + 2);
80 vq1 = -vq1; // expected-error {{invalid argument type '__vector_quad' to unary expression}}
81 vq2 = vq1 + vq3; // expected-error {{invalid operands to binary expression ('__vector_quad' and '__vector_quad')}}
82 vq2 = vq2 * vq3; // expected-error {{invalid operands to binary expression ('__vector_quad' and '__vector_quad')}}
83 vq3 = vq3 | vq3; // expected-error {{invalid operands to binary expression ('__vector_quad' and '__vector_quad')}}
84 vq3 = vq3 << 2; // expected-error {{invalid operands to binary expression ('__vector_quad' and 'int')}}
85 *(vqp + 10) = vq1;
86 *(vqp + 11) = vq2;
87 *(vqp + 12) = vq3;
90 vector unsigned char testVQOperators3(int *ptr) {
91 __vector_quad *vqp = (__vector_quad *)ptr;
92 __vector_quad vq1 = *(vqp + 0);
93 __vector_quad vq2 = *(vqp + 1);
94 __vector_quad vq3 = *(vqp + 2);
95 vq1 ? *(vqp + 10) = vq2 : *(vqp + 11) = vq3; // expected-error {{used type '__vector_quad' where arithmetic or pointer type is required}}
96 vq2 = vq3;
97 return vq2[1]; // expected-error {{subscripted value is not an array, pointer, or vector}}
100 void testVQOperators4(int v, void *ptr) {
101 __vector_quad *vqp = (__vector_quad *)ptr;
102 __vector_quad vq1 = (__vector_quad)v; // expected-error {{used type '__vector_quad' where arithmetic or pointer type is required}}
103 __vector_quad vq2 = (__vector_quad)vqp; // expected-error {{used type '__vector_quad' where arithmetic or pointer type is required}}
106 // vector pair
108 // typedef
109 typedef __vector_pair vp_t;
111 // function argument
112 void testVPArg1(__vector_pair vp, int *ptr) { // expected-error {{invalid use of PPC MMA type}}
113 __vector_pair *vpp = (__vector_pair *)ptr;
114 *vpp = vp;
117 void testVPArg2(const __vector_pair vp, int *ptr) { // expected-error {{invalid use of PPC MMA type}}
118 __vector_pair *vpp = (__vector_pair *)ptr;
119 *vpp = vp;
122 void testVPArg6(const vp_t vp, int *ptr) { // expected-error {{invalid use of PPC MMA type}}
123 __vector_pair *vpp = (__vector_pair *)ptr;
124 *vpp = vp;
127 // function return
128 __vector_pair testVPRet1(int *ptr) { // expected-error {{invalid use of PPC MMA type}}
129 __vector_pair *vpp = (__vector_pair *)ptr;
130 return *vpp; // expected-error {{invalid use of PPC MMA type}}
133 const vp_t testVPRet4(int *ptr) { // expected-error {{invalid use of PPC MMA type}}
134 __vector_pair *vpp = (__vector_pair *)ptr;
135 return *vpp; // expected-error {{invalid use of PPC MMA type}}
138 // global
139 __vector_pair globalvp; // expected-error {{invalid use of PPC MMA type}}
140 const __vector_pair globalvp2; // expected-error {{invalid use of PPC MMA type}}
141 __vector_pair *globalvpp;
142 const __vector_pair *const globalvpp2;
143 vp_t globalvp_t; // expected-error {{invalid use of PPC MMA type}}
145 // struct field
146 struct TestVPStruct {
147 int a;
148 float b;
149 __vector_pair c; // expected-error {{invalid use of PPC MMA type}}
150 __vector_pair *vp;
153 // operators
154 int testVPOperators1(int *ptr) {
155 __vector_pair *vpp = (__vector_pair *)ptr;
156 __vector_pair vp1 = *(vpp + 0);
157 __vector_pair vp2 = *(vpp + 1);
158 __vector_pair vp3 = *(vpp + 2);
159 if (vp1) // expected-error {{statement requires expression of scalar type ('__vector_pair' invalid)}}
160 *(vpp + 10) = vp1;
161 if (!vp2) // expected-error {{invalid argument type '__vector_pair' to unary expression}}
162 *(vpp + 11) = vp3;
163 int c1 = vp1 && vp2; // expected-error {{invalid operands to binary expression ('__vector_pair' and '__vector_pair')}}
164 int c2 = vp2 == vp3; // expected-error {{invalid operands to binary expression ('__vector_pair' and '__vector_pair')}}
165 int c3 = vp2 < vp1; // expected-error {{invalid operands to binary expression ('__vector_pair' and '__vector_pair')}}
166 return c1 || c2 || c3;
169 void testVPOperators2(int *ptr) {
170 __vector_pair *vpp = (__vector_pair *)ptr;
171 __vector_pair vp1 = *(vpp + 0);
172 __vector_pair vp2 = *(vpp + 1);
173 __vector_pair vp3 = *(vpp + 2);
174 vp1 = -vp1; // expected-error {{invalid argument type '__vector_pair' to unary expression}}
175 vp2 = vp1 + vp3; // expected-error {{invalid operands to binary expression ('__vector_pair' and '__vector_pair')}}
176 vp2 = vp2 * vp3; // expected-error {{invalid operands to binary expression ('__vector_pair' and '__vector_pair')}}
177 vp3 = vp3 | vp3; // expected-error {{invalid operands to binary expression ('__vector_pair' and '__vector_pair')}}
178 vp3 = vp3 << 2; // expected-error {{invalid operands to binary expression ('__vector_pair' and 'int')}}
179 *(vpp + 10) = vp1;
180 *(vpp + 11) = vp2;
181 *(vpp + 12) = vp3;
184 vector unsigned char testVPOperators3(int *ptr) {
185 __vector_pair *vpp = (__vector_pair *)ptr;
186 __vector_pair vp1 = *(vpp + 0);
187 __vector_pair vp2 = *(vpp + 1);
188 __vector_pair vp3 = *(vpp + 2);
189 vp1 ? *(vpp + 10) = vp2 : *(vpp + 11) = vp3; // expected-error {{used type '__vector_pair' where arithmetic or pointer type is required}}
190 vp2 = vp3;
191 return vp2[1]; // expected-error {{subscripted value is not an array, pointer, or vector}}
194 void testVPOperators4(int v, void *ptr) {
195 __vector_pair *vpp = (__vector_pair *)ptr;
196 __vector_pair vp1 = (__vector_pair)v; // expected-error {{used type '__vector_pair' where arithmetic or pointer type is required}}
197 __vector_pair vp2 = (__vector_pair)vpp; // expected-error {{used type '__vector_pair' where arithmetic or pointer type is required}}
200 void testBuiltinTypes1(const __vector_pair *vpp, const __vector_pair *vp2, float f) {
201 __vector_pair vp = __builtin_vsx_lxvp(f, vpp); // expected-error {{passing 'float' to parameter of incompatible type 'long'}}
202 __builtin_vsx_stxvp(vp, 32799, vp2); // expected-error {{passing 'int' to parameter of incompatible type 'long'}}
205 void testBuiltinTypes2(__vector_pair *vpp, const __vector_pair *vp2, unsigned char c) {
206 __vector_pair vp = __builtin_vsx_lxvp(6L, vpp); // expected-error {{passing '__vector_pair *' to parameter of incompatible type 'const __vector_pair *'}}
207 __builtin_vsx_stxvp(vp, c, vp2); // expected-error {{passing 'unsigned char' to parameter of incompatible type 'long'}}
210 void testBuiltinTypes3(vector int v, __vector_pair *vp2, signed long l, unsigned short s) {
211 __vector_pair vp = __builtin_vsx_lxvp(l, v); // expected-error {{passing '__vector int' (vector of 4 'int' values) to parameter of incompatible type 'const __vector_pair *'}}
212 __builtin_vsx_stxvp(vp, l, s); // expected-error {{passing 'unsigned short' to parameter of incompatible type '__vector_pair *'}}
215 void testRestrictQualifiedPointer1(int *__restrict acc) {
216 vector float arr[4];
217 __builtin_mma_disassemble_acc(arr, acc); // expected-error {{passing 'int *restrict' to parameter of incompatible type '__vector_quad *'}}
220 void testVolatileQualifiedPointer1(int *__volatile acc) {
221 vector float arr[4];
222 __builtin_mma_disassemble_acc(arr, acc); // expected-error {{passing 'int *volatile' to parameter of incompatible type '__vector_quad *'}}