1 // RUN: %clang_cc1 %s -verify -fsyntax-only -Wvector-conversion -triple x86_64-apple-darwin10
3 typedef unsigned int v2u
__attribute__ ((ext_vector_type(2)));
4 typedef int v2s
__attribute__ ((ext_vector_type(2)));
5 typedef float v2f
__attribute__ ((ext_vector_type(2)));
7 void test1(v2u v2ua
, v2s v2sa
, v2f v2fa
) {
8 // Bitwise binary operators
10 (void)(v2fa
& v2fa
); // expected-error{{invalid operands to binary expression}}
14 (void)(~v2fa
); // expected-error{{invalid argument type 'v2f' (vector of 2 'float' values) to unary}}
16 // Comparison operators
20 int array1
[v2ua
]; // expected-error{{size of array has non-integer type 'v2u' (vector of 2 'unsigned int' values}}
22 // FIXME: error message below needs type!
23 (void)(array2
[v2ua
]); // expected-error{{array subscript is not an integer}}
29 void test_int_vector_scalar(unsigned int ua
, v2u v2ua
) {
30 // Operations with one integer vector and one scalar. These splat the scalar.
81 ua
+= v2ua
; // expected-error{{assigning to 'unsigned int' from incompatible type 'v2u'}}
82 ua
-= v2ua
; // expected-error{{assigning to 'unsigned int' from incompatible type 'v2u'}}
83 ua
*= v2ua
; // expected-error{{assigning to 'unsigned int' from incompatible type 'v2u'}}
84 ua
/= v2ua
; // expected-error{{assigning to 'unsigned int' from incompatible type 'v2u'}}
85 ua
%= v2ua
; // expected-error{{assigning to 'unsigned int' from incompatible type 'v2u'}}
86 ua
&= v2ua
; // expected-error{{assigning to 'unsigned int' from incompatible type 'v2u'}}
87 ua
|= v2ua
; // expected-error{{assigning to 'unsigned int' from incompatible type 'v2u'}}
88 ua
^= v2ua
; // expected-error{{assigning to 'unsigned int' from incompatible type 'v2u'}}
89 ua
>>= v2ua
; // expected-error{{assigning to 'unsigned int' from incompatible type 'v2u'}}
90 ua
<<= v2ua
; // expected-error{{assigning to 'unsigned int' from incompatible type 'v2u'}}
93 void test_float_vector_scalar(float fa
, unsigned int ua
, v2f v2fa
) {
94 // Operations with one float vector and one scalar. These splat the scalar.
103 (void)(v2fa
% fa
); // expected-error{{invalid operands to binary expression}}
104 (void)(fa
% v2fa
); // expected-error{{invalid operands to binary expression}}
123 (void)(v2fa
& fa
); // expected-error{{invalid operands to binary expression}}
124 (void)(fa
& v2fa
); // expected-error{{invalid operands to binary expression}}
125 (void)(v2fa
| fa
); // expected-error{{invalid operands to binary expression}}
126 (void)(fa
| v2fa
); // expected-error{{invalid operands to binary expression}}
127 (void)(v2fa
^ fa
); // expected-error{{invalid operands to binary expression}}
128 (void)(fa
^ v2fa
); // expected-error{{invalid operands to binary expression}}
129 (void)(v2fa
<< fa
); // expected-error{{used type 'v2f' (vector of 2 'float' values) where integer is required}}
130 (void)(v2fa
<< ua
); // expected-error{{used type 'v2f' (vector of 2 'float' values) where integer is required}}
131 (void)(fa
<< v2fa
); // expected-error{{used type 'float' where integer is required}}
132 (void)(ua
<< v2fa
); // expected-error{{used type 'v2f' (vector of 2 'float' values) where integer is required}}
133 (void)(v2fa
>> fa
); // expected-error{{used type 'v2f' (vector of 2 'float' values) where integer is required}}
134 (void)(v2fa
>> ua
); // expected-error{{used type 'v2f' (vector of 2 'float' values) where integer is required}}
135 (void)(fa
>> v2fa
); // expected-error{{used type 'float' where integer is required}}
136 (void)(ua
>> v2fa
); // expected-error{{used type 'v2f' (vector of 2 'float' values) where integer is required}}
142 v2fa
%= fa
; // expected-error{{invalid operands to binary expression}}
143 v2fa
&= fa
; // expected-error{{invalid operands to binary expression}}
144 v2fa
|= fa
; // expected-error{{invalid operands to binary expression}}
145 v2fa
^= fa
; // expected-error{{invalid operands to binary expression}}
146 v2fa
>>= fa
; // expected-error{{used type 'v2f' (vector of 2 'float' values) where integer is required}}
147 v2fa
<<= fa
; // expected-error{{used type 'v2f' (vector of 2 'float' values) where integer is required}}
149 fa
+= v2fa
; // expected-error{{assigning to 'float' from incompatible type 'v2f'}}
150 fa
-= v2fa
; // expected-error{{assigning to 'float' from incompatible type 'v2f'}}
151 fa
*= v2fa
; // expected-error{{assigning to 'float' from incompatible type 'v2f'}}
152 fa
/= v2fa
; // expected-error{{assigning to 'float' from incompatible type 'v2f'}}
153 fa
%= v2fa
; // expected-error{{invalid operands to binary expression}}
154 fa
&= v2fa
; // expected-error{{invalid operands to binary expression}}
155 fa
|= v2fa
; // expected-error{{invalid operands to binary expression}}
156 fa
^= v2fa
; // expected-error{{invalid operands to binary expression}}
157 fa
>>= v2fa
; // expected-error{{used type 'float' where integer is required}}
158 fa
<<= v2fa
; // expected-error{{used type 'float' where integer is required}}
163 void test_enum_vector_scalar(enum Enum ea
, v2u v2ua
) {
164 // Operations with one integer vector and one enum scalar.
165 // These splat the scalar and do implicit integral conversions.
216 ea
+= v2ua
; // expected-error{{assigning to 'enum Enum' from incompatible type 'v2u'}}
217 ea
-= v2ua
; // expected-error{{assigning to 'enum Enum' from incompatible type 'v2u'}}
218 ea
*= v2ua
; // expected-error{{assigning to 'enum Enum' from incompatible type 'v2u'}}
219 ea
/= v2ua
; // expected-error{{assigning to 'enum Enum' from incompatible type 'v2u'}}
220 ea
%= v2ua
; // expected-error{{assigning to 'enum Enum' from incompatible type 'v2u'}}
221 ea
&= v2ua
; // expected-error{{assigning to 'enum Enum' from incompatible type 'v2u'}}
222 ea
|= v2ua
; // expected-error{{assigning to 'enum Enum' from incompatible type 'v2u'}}
223 ea
^= v2ua
; // expected-error{{assigning to 'enum Enum' from incompatible type 'v2u'}}
224 ea
>>= v2ua
; // expected-error{{assigning to 'enum Enum' from incompatible type 'v2u'}}
225 ea
<<= v2ua
; // expected-error{{assigning to 'enum Enum' from incompatible type 'v2u'}}
229 // An incomplete enum type doesn't count as an integral type.
232 void test_incomplete_enum(enum Enum2
*ea
, v2u v2ua
) {
233 (void)(v2ua
+ *ea
); // expected-error{{cannot convert between vector and non-scalar values}}
234 (void)(*ea
+ v2ua
); // expected-error{{cannot convert between vector and non-scalar values}}