1 // RUN: %clang_cc1 -flax-vector-conversions=all -triple x86_64-apple-darwin10 -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -flax-vector-conversions=all -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=c++98 %s
3 // RUN: %clang_cc1 -flax-vector-conversions=all -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=c++11 %s
4 // RUN: %clang_cc1 -flax-vector-conversions=all -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=c++20 %s
5 // RUN: %clang_cc1 -flax-vector-conversions=integer -triple x86_64-apple-darwin10 -fsyntax-only -verify %s -DNO_LAX_FLOAT
6 // RUN: %clang_cc1 -flax-vector-conversions=none -triple x86_64-apple-darwin10 -fsyntax-only -verify %s -DNO_LAX_FLOAT -DNO_LAX_INT
8 typedef char char16
__attribute__ ((__vector_size__ (16)));
9 typedef long long longlong16
__attribute__ ((__vector_size__ (16)));
10 typedef char char16_e
__attribute__ ((__ext_vector_type__ (16)));
11 typedef long long longlong16_e
__attribute__ ((__ext_vector_type__ (2)));
13 // Test overloading and function calls with vector types.
14 void f0(char16
); // expected-note 0+{{candidate}}
16 void f0_test(char16 c16
, longlong16 ll16
, char16_e c16e
, longlong16_e ll16e
) {
20 // expected-error@-2 {{no matching function}}
25 // expected-error@-2 {{no matching function}}
30 float &f1(longlong16
);
32 void f1_test(char16 c16
, longlong16 ll16
, char16_e c16e
, longlong16_e ll16e
) {
34 float &fr1
= f1(ll16
);
36 float &fr2
= f1(ll16e
);
39 void f2(char16_e
); // expected-note 0+{{candidate}}
41 void f2_test(char16 c16
, longlong16 ll16
, char16_e c16e
, longlong16_e ll16e
) {
45 // expected-error@-2 {{no matching function}}
48 f2(ll16e
); // expected-error{{no matching function}}
53 // Test the conditional operator with vector types.
54 void conditional(bool Cond
, char16 c16
, longlong16 ll16
, char16_e c16e
,
56 // Conditional operators with the same type.
57 __typeof__(Cond
? c16
: c16
) *c16p1
= &c16
;
58 __typeof__(Cond
? ll16
: ll16
) *ll16p1
= &ll16
;
59 __typeof__(Cond
? c16e
: c16e
) *c16ep1
= &c16e
;
60 __typeof__(Cond
? ll16e
: ll16e
) *ll16ep1
= &ll16e
;
62 // Conditional operators with similar types.
63 __typeof__(Cond
? c16
: c16e
) *c16ep2
= &c16e
;
64 __typeof__(Cond
? c16e
: c16
) *c16ep3
= &c16e
;
65 __typeof__(Cond
? ll16
: ll16e
) *ll16ep2
= &ll16e
;
66 __typeof__(Cond
? ll16e
: ll16
) *ll16ep3
= &ll16e
;
68 // Conditional operators with compatible types under -flax-vector-conversions (default)
69 (void)(Cond
? c16
: ll16
);
70 (void)(Cond
? ll16e
: c16e
);
71 (void)(Cond
? ll16e
: c16
);
73 // expected-error@-4 {{cannot convert}}
74 // expected-error@-4 {{cannot convert}}
75 // expected-error@-4 {{cannot convert}}
79 // Test C++ cast'ing of vector types.
80 void casts(longlong16 ll16
, longlong16_e ll16e
) {
84 (void)(longlong16
)ll16
;
85 (void)(longlong16_e
)ll16
;
87 (void)(char16_e
)ll16e
;
88 (void)(longlong16
)ll16e
;
89 (void)(longlong16_e
)ll16e
;
91 // Function-style casts.
94 (void)longlong16(ll16
);
95 (void)longlong16_e(ll16
);
97 (void)char16_e(ll16e
);
98 (void)longlong16(ll16e
);
99 (void)longlong16_e(ll16e
);
102 (void)static_cast<char16
>(ll16
);
103 (void)static_cast<char16_e
>(ll16
);
105 // expected-error@-3 {{not allowed}}
106 // expected-error@-3 {{not allowed}}
108 (void)static_cast<longlong16
>(ll16
);
109 (void)static_cast<longlong16_e
>(ll16
);
110 (void)static_cast<char16
>(ll16e
);
112 // expected-error@-2 {{not allowed}}
114 (void)static_cast<char16_e
>(ll16e
); // expected-error{{static_cast from 'longlong16_e' (vector of 2 'long long' values) to 'char16_e' (vector of 16 'char' values) is not allowed}}
115 (void)static_cast<longlong16
>(ll16e
);
116 (void)static_cast<longlong16_e
>(ll16e
);
119 (void)reinterpret_cast<char16
>(ll16
);
120 (void)reinterpret_cast<char16_e
>(ll16
);
121 (void)reinterpret_cast<longlong16
>(ll16
);
122 (void)reinterpret_cast<longlong16_e
>(ll16
);
123 (void)reinterpret_cast<char16
>(ll16e
);
124 (void)reinterpret_cast<char16_e
>(ll16e
);
125 (void)reinterpret_cast<longlong16
>(ll16e
);
126 (void)reinterpret_cast<longlong16_e
>(ll16e
);
130 struct convertible_to
{ // expected-note 3 {{candidate function (the implicit copy assignment operator) not viable}}
131 #if __cplusplus >= 201103L // C++11 or later
132 // expected-note@-2 3 {{candidate function (the implicit move assignment operator) not viable}}
137 void test_implicit_conversions(bool Cond
, char16 c16
, longlong16 ll16
,
138 char16_e c16e
, longlong16_e ll16e
,
139 convertible_to
<char16
> to_c16
,
140 convertible_to
<longlong16
> to_ll16
,
141 convertible_to
<char16_e
> to_c16e
,
142 convertible_to
<longlong16_e
> to_ll16e
,
143 convertible_to
<char16
&> rto_c16
,
144 convertible_to
<char16_e
&> rto_c16e
) {
148 // expected-error@-2 {{no matching function}}
153 // expected-error@-2 {{no matching function}}
158 // expected-error@-2 {{no matching function}}
161 f2(to_ll16e
); // expected-error{{no matching function}}
164 (void)(c16
== to_c16
);
168 (void)(to_c16
== to_c16e
);
169 (void)(to_c16
!= to_c16e
);
170 (void)(to_c16
< to_c16e
);
171 (void)(to_c16
<= to_c16e
);
172 (void)(to_c16
> to_c16e
);
173 (void)(to_c16
>= to_c16e
);
174 (void)(to_c16
+ to_c16
);
175 (void)(to_c16
- to_c16
);
176 (void)(to_c16
* to_c16
);
177 (void)(to_c16
/ to_c16
);
178 (void)(rto_c16
= to_c16
); // expected-error{{no viable overloaded '='}}
179 (void)(rto_c16
+= to_c16
);
180 (void)(rto_c16
-= to_c16
);
181 (void)(rto_c16
*= to_c16
);
182 (void)(rto_c16
/= to_c16
);
187 (void)(to_c16e
== to_c16e
);
188 (void)(to_c16e
!= to_c16e
);
189 (void)(to_c16e
< to_c16e
);
190 (void)(to_c16e
<= to_c16e
);
191 (void)(to_c16e
> to_c16e
);
192 (void)(to_c16e
>= to_c16e
);
193 (void)(to_c16e
+ to_c16
);
194 (void)(to_c16e
- to_c16
);
195 (void)(to_c16e
* to_c16
);
196 (void)(to_c16e
/ to_c16
);
197 (void)(rto_c16e
= to_c16
); // expected-error{{no viable overloaded '='}}
198 (void)(rto_c16e
+= to_c16
);
199 (void)(rto_c16e
-= to_c16
);
200 (void)(rto_c16e
*= to_c16
);
201 (void)(rto_c16e
/= to_c16
);
206 (void)(to_c16
== to_c16e
);
207 (void)(to_c16
!= to_c16e
);
208 (void)(to_c16
< to_c16e
);
209 (void)(to_c16
<= to_c16e
);
210 (void)(to_c16
> to_c16e
);
211 (void)(to_c16
>= to_c16e
);
212 (void)(to_c16
+ to_c16e
);
213 (void)(to_c16
- to_c16e
);
214 (void)(to_c16
* to_c16e
);
215 (void)(to_c16
/ to_c16e
);
216 (void)(rto_c16
= c16e
); // expected-error{{no viable overloaded '='}}
217 (void)(rto_c16
+= to_c16e
);
218 (void)(rto_c16
-= to_c16e
);
219 (void)(rto_c16
*= to_c16e
);
220 (void)(rto_c16
/= to_c16e
);
222 (void)(Cond
? to_c16
: to_c16e
);
223 (void)(Cond
? to_ll16e
: to_ll16
);
225 // These 2 are convertible with -flax-vector-conversions (default)
226 (void)(Cond
? to_c16
: to_ll16
);
227 (void)(Cond
? to_c16e
: to_ll16e
);
229 // expected-error@-3 {{cannot convert}}
230 // expected-error@-3 {{cannot convert}}
234 typedef float fltx2
__attribute__((__vector_size__(8)));
235 typedef float fltx4
__attribute__((__vector_size__(16)));
236 typedef double dblx2
__attribute__((__vector_size__(16)));
237 typedef double dblx4
__attribute__((__vector_size__(32)));
239 void accept_fltx2(fltx2
); // expected-note{{candidate function not viable: no known conversion from 'double' to 'fltx2' (vector of 2 'float' values) for 1st argument}}
240 void accept_fltx4(fltx4
);
241 void accept_dblx2(dblx2
);
243 // expected-note@-3 {{no known conversion}}
244 // expected-note@-3 {{no known conversion}}
246 void accept_dblx4(dblx4
);
247 void accept_bool(bool); // expected-note{{candidate function not viable: no known conversion from 'fltx2' (vector of 2 'float' values) to 'bool' for 1st argument}}
249 void test(fltx2 fltx2_val
, fltx4 fltx4_val
, dblx2 dblx2_val
, dblx4 dblx4_val
) {
251 accept_fltx2(fltx2_val
);
252 accept_fltx4(fltx4_val
);
253 accept_dblx2(dblx2_val
);
254 accept_dblx4(dblx4_val
);
256 // Same-size conversions
257 accept_fltx4(dblx2_val
);
258 accept_dblx2(fltx4_val
);
260 // expected-error@-3 {{no matching function}}
261 // expected-error@-3 {{no matching function}}
264 // Conversion to bool.
265 accept_bool(fltx2_val
); // expected-error{{no matching function for call to 'accept_bool'}}
267 // Scalar-to-vector conversions.
268 accept_fltx2(1.0); // expected-error{{no matching function for call to 'accept_fltx2'}}
271 typedef int intx4
__attribute__((__vector_size__(16)));
272 typedef int inte4
__attribute__((__ext_vector_type__(4)));
273 typedef float flte4
__attribute__((__ext_vector_type__(4)));
275 void test_mixed_vector_types(fltx4 f
, intx4 n
, flte4 g
, inte4 m
) {
320 template<typename T
> void test_pseudo_dtor_tmpl(T
*ptr
) {
325 void test_pseudo_dtor(fltx4
*f
) {
328 test_pseudo_dtor_tmpl(f
);
332 typedef __attribute__((ext_vector_type(4))) int vi4
;
333 const int &reference_to_vec_element
= vi4(1).x
;
336 typedef bool bad
__attribute__((__vector_size__(16))); // expected-error {{invalid vector element type 'bool'}}
338 namespace Templates
{
339 template <typename Elt
, unsigned long long Size
>
340 struct TemplateVectorType
{
341 typedef Elt
__attribute__((__vector_size__(Size
))) type
; // #1
344 template <int N
, typename T
>
346 typedef T
__attribute__((vector_size(N
* sizeof(T
)))) type
;
347 typedef T
__attribute__((vector_size(0x1000000000))) type2
; // #2
348 typedef T
__attribute__((vector_size(3))) type3
; // #3
352 const TemplateVectorType
<float, 32>::type Works
= {};
353 const TemplateVectorType
<int, 32>::type Works2
= {};
354 // expected-error@#1 {{invalid vector element type 'bool'}}
355 // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType<bool, 32>' requested here}}
356 const TemplateVectorType
<bool, 32>::type NoBool
= {};
357 // expected-error@#1 {{invalid vector element type 'int __attribute__((ext_vector_type(4)))' (vector of 4 'int' values)}}
358 // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType<int __attribute__((ext_vector_type(4))), 32>' requested here}}
359 const TemplateVectorType
<vi4
, 32>::type NoComplex
= {};
360 // expected-error@#1 {{vector size not an integral multiple of component size}}
361 // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType<int, 33>' requested here}}
362 const TemplateVectorType
<int, 33>::type BadSize
= {};
363 const TemplateVectorType
<int, 3200>::type Large
= {};
364 // expected-error@#1 {{vector size too large}}
365 // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType<int, 68719476736>' requested here}}
366 const TemplateVectorType
<int, 0x1000000000>::type TooLarge
= {};
367 // expected-error@#1 {{zero vector size}}
368 // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType<int, 0>' requested here}}
369 const TemplateVectorType
<int, 0>::type Zero
= {};
371 // expected-error@#2 {{vector size too large}}
372 // expected-error@#3 {{vector size not an integral multiple of component size}}
373 // expected-note@+1 {{in instantiation of template class 'Templates::PR15730<8, int>' requested here}}
374 const PR15730
<8, int>::type PR15730_1
= {};
375 // expected-error@#2 {{vector size too large}}
376 // expected-note@+1 {{in instantiation of template class 'Templates::PR15730<8, char>' requested here}}
377 const PR15730
<8, char>::type2 PR15730_2
= {};
380 } // namespace Templates
382 typedef int inte2
__attribute__((__ext_vector_type__(2)));
384 void test_vector_literal(inte4 res
) {
385 inte2 a
= (inte2
)(1, 2); //expected-warning{{left operand of comma operator has no effect}}
386 inte4 b
= (inte4
)(a
, a
); //expected-error{{C-style cast from vector 'inte2' (vector of 2 'int' values) to vector 'inte4' (vector of 4 'int' values) of different size}} //expected-warning{{left operand of comma operator has no effect}}
389 typedef __attribute__((__ext_vector_type__(4))) float vector_float4
;
390 typedef __attribute__((__ext_vector_type__(4))) int vector_int4
;
392 namespace swizzle_template_confusion
{
393 template<typename T
> struct xyzw
{};
394 vector_int4
foo123(vector_float4
&A
, vector_float4
&B
) {
395 return A
.xyzw
< B
.x
&& B
.y
> A
.y
; // OK, not a template-id
399 namespace swizzle_typo_correction
{
400 template<typename T
> struct xyzv
{};
401 vector_int4
foo123(vector_float4
&A
, vector_float4
&B
) {
402 return A
.xyzw
< B
.x
&& B
.y
> A
.y
; // OK, not a typo for 'xyzv'
407 typedef float float4
__attribute__((vector_size(16)));
409 // In this example, 'k' is value dependent. PR45299 reported that this asserted
410 // because of that, since the truncation check attempted to constant evaluate k,
411 // which it could not do because it is dependent.
412 template <typename T
>
413 struct NormalMember
{
420 #if __cplusplus >= 201103L
421 // This should not diagnose, since the constant evaluator (during instantiation)
422 // can tell that this isn't a truncation.
423 template <typename T
>
424 struct ConstantValueNoDiag
{
428 static constexpr double k
= 1;
430 template <typename T
, int N
>
431 struct ConstantValueNoDiagDependentValue
{
435 static constexpr double k
= N
;
438 // The following two both diagnose because they cause a truncation. Test both
439 // the dependent type and non-dependent type versions.
440 template <typename T
>
443 // expected-error@+1{{as implicit conversion would cause truncation}}
446 static constexpr double k
= 1340282346638528859811704183484516925443.000000;
448 template <typename T
, int N
>
449 struct DiagTruncDependentValue
{
451 // expected-error@+1{{as implicit conversion would cause truncation}}
454 static constexpr double k
= N
+ 1340282346638528859811704183484516925443.000000;
456 template <typename T
>
457 struct DiagTruncDependentType
{
459 // expected-error@+1{{as implicit conversion would cause truncation}}
462 static constexpr T k
= 1340282346638528859811704183484516925443.000000;
465 template <typename T
>
470 // Ensure this no longer asserts.
471 template <typename T
>
472 struct PR45298Consumer
{
474 return (float)s
.k1
* x
;
479 #endif // __cplusplus >= 201103L
483 NormalMember
<double>().f(theFloat4
);
484 #if __cplusplus >= 201103L
485 ConstantValueNoDiag
<double>().f(theFloat4
);
486 ConstantValueNoDiagDependentValue
<double, 1>().f(theFloat4
);
487 DiagTrunc
<double>().f(theFloat4
);
488 // expected-note@+1{{in instantiation of member function}}
489 DiagTruncDependentValue
<double, 0>().f(theFloat4
);
490 // expected-note@+1{{in instantiation of member function}}
491 DiagTruncDependentType
<double>().f(theFloat4
);
492 PR45298Consumer
<double>().f(theFloat4
);
493 #endif // __cplusplus >= 201103L
497 namespace rdar60092165
{
498 template <class T
> void f() {
499 typedef T first_type
__attribute__((vector_size(sizeof(T
) * 4)));
500 typedef T second_type
__attribute__((vector_size(sizeof(T
) * 4)));
507 enum E
{ Value
= 15 };
510 c
&Value
; // expected-error{{cannot convert between scalar type 'PR45780::E' and vector type 'char16'}}
511 c
== Value
; // expected-error{{cannot convert between scalar type 'PR45780::E' and vector type 'char16'}}
512 e
| c
; // expected-error{{cannot convert between scalar type 'E' and vector type 'char16'}}
513 e
!= c
; // expected-error{{cannot convert between scalar type 'E' and vector type 'char16'}}
516 } // namespace PR45780
519 // The below used to cause an OOM error, or an assert, make sure it is still
521 int (__attribute__((vector_size(16))) a
);
523 template <typename T
, int I
>
525 T (__attribute__((vector_size(16))) a
);
526 int (__attribute__((vector_size(I
))) b
);
527 T (__attribute__((vector_size(I
))) c
);
533 } // namespace PR48540
535 #if __cplusplus >= 202002L // C++20 or later
536 // Don't crash due to missing integer ranks.
537 char8_t v1
__attribute__((vector_size(16)));
538 char16_t v2
__attribute__((vector_size(16)));
539 char32_t v3
__attribute__((vector_size(16)));
540 wchar_t v4
__attribute__((vector_size(16)));
541 void triggerIntegerRankCheck() {
542 auto b1
= (v1
>= 0x12);
543 auto b2
= (v2
>= 0x12);
544 auto b3
= (v3
>= 0x12);
545 auto b4
= (v4
>= 0x12);
549 namespace all_operators
{
550 typedef unsigned int v2u
__attribute__((ext_vector_type(2)));
551 typedef float v2f
__attribute__((ext_vector_type(2)));
553 void test_int_vector_scalar(unsigned int ua
, v2u v2ua
) {
554 // Operators with one integer vector and one integer scalar operand. The scalar will splat.
605 ua
+= v2ua
; // expected-error{{assigning to 'unsigned int' from incompatible type 'v2u'}}
606 ua
-= v2ua
; // expected-error{{assigning to 'unsigned int' from incompatible type 'v2u'}}
607 ua
*= v2ua
; // expected-error{{assigning to 'unsigned int' from incompatible type 'v2u'}}
608 ua
/= v2ua
; // expected-error{{assigning to 'unsigned int' from incompatible type 'v2u'}}
609 ua
%= v2ua
; // expected-error{{assigning to 'unsigned int' from incompatible type 'v2u'}}
610 ua
&= v2ua
; // expected-error{{assigning to 'unsigned int' from incompatible type 'v2u'}}
611 ua
|= v2ua
; // expected-error{{assigning to 'unsigned int' from incompatible type 'v2u'}}
612 ua
^= v2ua
; // expected-error{{assigning to 'unsigned int' from incompatible type 'v2u'}}
613 ua
>>= v2ua
; // expected-error{{assigning to 'unsigned int' from incompatible type 'v2u'}}
614 ua
<<= v2ua
; // expected-error{{assigning to 'unsigned int' from incompatible type 'v2u'}}
617 void test_float_vector_scalar(float fa
, unsigned int ua
, v2f v2fa
) {
618 // Operators with one float vector and one float scalar operand. The scalar will splat.
627 (void)(v2fa
% fa
); // expected-error{{invalid operands to binary expression}}
628 (void)(fa
% v2fa
); // expected-error{{invalid operands to binary expression}}
647 (void)(v2fa
& fa
); // expected-error{{invalid operands to binary expression}}
648 (void)(fa
& v2fa
); // expected-error{{invalid operands to binary expression}}
649 (void)(v2fa
| fa
); // expected-error{{invalid operands to binary expression}}
650 (void)(fa
| v2fa
); // expected-error{{invalid operands to binary expression}}
651 (void)(v2fa
^ fa
); // expected-error{{invalid operands to binary expression}}
652 (void)(fa
^ v2fa
); // expected-error{{invalid operands to binary expression}}
653 (void)(v2fa
<< fa
); // expected-error{{used type 'v2f' (vector of 2 'float' values) where integer is required}}
654 (void)(v2fa
<< ua
); // expected-error{{used type 'v2f' (vector of 2 'float' values) where integer is required}}
655 (void)(fa
<< v2fa
); // expected-error{{used type 'float' where integer is required}}
656 (void)(ua
<< v2fa
); // expected-error{{used type 'v2f' (vector of 2 'float' values) where integer is required}}
657 (void)(v2fa
>> fa
); // expected-error{{used type 'v2f' (vector of 2 'float' values) where integer is required}}
658 (void)(v2fa
>> ua
); // expected-error{{used type 'v2f' (vector of 2 'float' values) where integer is required}}
659 (void)(fa
>> v2fa
); // expected-error{{used type 'float' where integer is required}}
660 (void)(ua
>> v2fa
); // expected-error{{used type 'v2f' (vector of 2 'float' values) where integer is required}}
666 v2fa
%= fa
; // expected-error{{invalid operands to binary expression}}
667 v2fa
&= fa
; // expected-error{{invalid operands to binary expression}}
668 v2fa
|= fa
; // expected-error{{invalid operands to binary expression}}
669 v2fa
^= fa
; // expected-error{{invalid operands to binary expression}}
670 v2fa
>>= fa
; // expected-error{{used type 'v2f' (vector of 2 'float' values) where integer is required}}
671 v2fa
<<= fa
; // expected-error{{used type 'v2f' (vector of 2 'float' values) where integer is required}}
673 fa
+= v2fa
; // expected-error{{assigning to 'float' from incompatible type 'v2f'}}
674 fa
-= v2fa
; // expected-error{{assigning to 'float' from incompatible type 'v2f'}}
675 fa
*= v2fa
; // expected-error{{assigning to 'float' from incompatible type 'v2f'}}
676 fa
/= v2fa
; // expected-error{{assigning to 'float' from incompatible type 'v2f'}}
677 fa
%= v2fa
; // expected-error{{invalid operands to binary expression}}
678 fa
&= v2fa
; // expected-error{{invalid operands to binary expression}}
679 fa
|= v2fa
; // expected-error{{invalid operands to binary expression}}
680 fa
^= v2fa
; // expected-error{{invalid operands to binary expression}}
681 fa
>>= v2fa
; // expected-error{{used type 'float' where integer is required}}
682 fa
<<= v2fa
; // expected-error{{used type 'float' where integer is required}}
687 void test_enum_vector_scalar(Enum ea
, v2u v2ua
) {
688 // Operators with one integer vector and one enum scalar operand.
689 // The scalar will have an implicit conversion to an integral type and then splat.
690 // FIXME: These should behave the same as in C, they should be accepted via
691 // the enum converting to an integer then splatting to the vector width.
692 // https://github.com/llvm/llvm-project/issues/62869
693 (void)(v2ua
+ ea
); // expected-error{{cannot convert between vector values of different size}}
694 (void)(ea
+ v2ua
); // expected-error{{cannot convert between vector values of different size}}
695 (void)(v2ua
- ea
); // expected-error{{cannot convert between vector values of different size}}
696 (void)(ea
- v2ua
); // expected-error{{cannot convert between vector values of different size}}
697 (void)(v2ua
* ea
); // expected-error{{cannot convert between vector values of different size}}
698 (void)(ea
* v2ua
); // expected-error{{cannot convert between vector values of different size}}
699 (void)(v2ua
/ ea
); // expected-error{{cannot convert between vector values of different size}}
700 (void)(ea
/ v2ua
); // expected-error{{cannot convert between vector values of different size}}
701 (void)(v2ua
% ea
); // expected-error{{cannot convert between vector values of different size}}
702 (void)(ea
% v2ua
); // expected-error{{cannot convert between vector values of different size}}
704 (void)(v2ua
== ea
); // expected-error{{cannot convert between vector values of different size}}
705 (void)(ea
== v2ua
); // expected-error{{cannot convert between vector values of different size}}
706 (void)(v2ua
!= ea
); // expected-error{{cannot convert between vector values of different size}}
707 (void)(ea
!= v2ua
); // expected-error{{cannot convert between vector values of different size}}
708 (void)(v2ua
<= ea
); // expected-error{{cannot convert between vector values of different size}}
709 (void)(ea
<= v2ua
); // expected-error{{cannot convert between vector values of different size}}
710 (void)(v2ua
>= ea
); // expected-error{{cannot convert between vector values of different size}}
711 (void)(ea
>= v2ua
); // expected-error{{cannot convert between vector values of different size}}
712 (void)(v2ua
< ea
); // expected-error{{cannot convert between vector values of different size}}
713 (void)(ea
< v2ua
); // expected-error{{cannot convert between vector values of different size}}
714 (void)(v2ua
> ea
); // expected-error{{cannot convert between vector values of different size}}
715 (void)(ea
> v2ua
); // expected-error{{cannot convert between vector values of different size}}
716 (void)(v2ua
&& ea
); // expected-error{{cannot convert between vector values of different size}}
717 // expected-error@-1{{invalid operands to binary expression}}
718 (void)(ea
&& v2ua
); // expected-error{{cannot convert between vector values of different size}}
719 // expected-error@-1{{invalid operands to binary expression}}
720 (void)(v2ua
|| ea
); // expected-error{{cannot convert between vector values of different size}}
721 // expected-error@-1{{invalid operands to binary expression}}
722 (void)(ea
|| v2ua
); // expected-error{{cannot convert between vector values of different size}}
723 // expected-error@-1{{invalid operands to binary expression}}
725 (void)(v2ua
& ea
); // expected-error{{cannot convert between vector values of different size}}
726 (void)(ea
& v2ua
); // expected-error{{cannot convert between vector values of different size}}
727 (void)(v2ua
| ea
); // expected-error{{cannot convert between vector values of different size}}
728 (void)(ea
| v2ua
); // expected-error{{cannot convert between vector values of different size}}
729 (void)(v2ua
^ ea
); // expected-error{{cannot convert between vector values of different size}}
730 (void)(ea
^ v2ua
); // expected-error{{cannot convert between vector values of different size}}
731 // FIXME: Vector/scalar shifts cause an assertion failure
732 // https://github.com/llvm/llvm-project/issues/62870
733 // (void)(v2ua << ea);
734 // (void)(ea << v2ua);
735 // (void)(v2ua >> ea);
736 // (void)(ea >> v2ua);
738 v2ua
+= ea
; // expected-error{{cannot convert between vector values of different size}}
739 v2ua
-= ea
; // expected-error{{cannot convert between vector values of different size}}
740 v2ua
*= ea
; // expected-error{{cannot convert between vector values of different size}}
741 v2ua
/= ea
; // expected-error{{cannot convert between vector values of different size}}
742 v2ua
%= ea
; // expected-error{{cannot convert between vector values of different size}}
743 v2ua
&= ea
; // expected-error{{cannot convert between vector values of different size}}
744 v2ua
|= ea
; // expected-error{{cannot convert between vector values of different size}}
745 v2ua
^= ea
; // expected-error{{cannot convert between vector values of different size}}
746 // FIXME: Vector/scalar shifts cause an assertion failure
747 // https://github.com/llvm/llvm-project/issues/62870
751 ea
+= v2ua
; // expected-error{{cannot convert between vector values of different size}}
752 ea
-= v2ua
; // expected-error{{cannot convert between vector values of different size}}
753 ea
*= v2ua
; // expected-error{{cannot convert between vector values of different size}}
754 ea
/= v2ua
; // expected-error{{cannot convert between vector values of different size}}
755 ea
%= v2ua
; // expected-error{{cannot convert between vector values of different size}}
756 ea
&= v2ua
; // expected-error{{cannot convert between vector values of different size}}
757 ea
|= v2ua
; // expected-error{{cannot convert between vector values of different size}}
758 ea
^= v2ua
; // expected-error{{cannot convert between vector values of different size}}
759 // FIXME: Vector/scalar shifts cause an assertion failure
760 // https://github.com/llvm/llvm-project/issues/62870
761 // ea >>= v2ua; // not-expected-error{{assigning to 'enum Enum' from incompatible type 'v2u'}}
762 // ea <<= v2ua; // not-expected-error{{assigning to 'enum Enum' from incompatible type 'v2u'}}
765 #if __cplusplus >= 201103L // C++11 or later
766 enum class EnumClass
{ ENUM
};
768 void test_scoped_enum_vector(EnumClass ea
, v2u v2ua
) {
769 // Scoped enumerations are only compatible with exactly matching types. They shouldn't integral promote.
770 (void)(v2ua
+ ea
); // expected-error{{cannot convert between vector and non-scalar values}}
771 (void)(ea
+ v2ua
); // expected-error{{cannot convert between vector and non-scalar values}}
777 __attribute__((__vector_size__(sizeof(double)))) double a
;
778 double b
= a
- (long)(*0); // expected-error {{indirection requires pointer operand ('int' invalid)}} \
779 // expected-error {{cannot initialize a variable of type 'double' with an rvalue of type '__attribute__((__vector_size__(1 * sizeof(double)))) double' (vector of 1 'double' value)}}
781 __attribute__((__vector_size__(sizeof(long)))) long c
;
782 long d
= c
- (long)(*0); // expected-error {{indirection requires pointer operand ('int' invalid)}} \
783 // expected-error {{cannot initialize a variable of type 'long' with an rvalue of type '__attribute__((__vector_size__(1 * sizeof(long)))) long' (vector of 1 'long' value)}}
785 const long long e
= *0; // expected-error {{indirection requires pointer operand ('int' invalid)}}
786 double f
= a
- e
; // expected-error {{cannot initialize a variable of type 'double' with an rvalue of type '__attribute__((__vector_size__(1 * sizeof(double)))) double' (vector of 1 'double' value)}}
787 int h
= c
- e
; // expected-error {{cannot initialize a variable of type 'int' with an rvalue of type '__attribute__((__vector_size__(1 * sizeof(long)))) long' (vector of 1 'long' value)}}