1 // RUN: %clang_cc1 -triple s390x-linux-gnu -fzvector -target-cpu z14 \
2 // RUN: -flax-vector-conversions=none -W -Wall -Wconversion \
3 // RUN: -Werror -fsyntax-only -verify %s
5 vector
signed char sc
, sc2
;
6 vector
unsigned char uc
, uc2
;
7 vector
bool char bc
, bc2
;
9 vector
signed short ss
, ss2
;
10 vector
unsigned short us
, us2
;
11 vector
bool short bs
, bs2
;
13 vector
signed int si
, si2
;
14 vector
unsigned int ui
, ui2
;
15 vector
bool int bi
, bi2
;
17 vector
signed long long sl
, sl2
;
18 vector
unsigned long long ul
, ul2
;
19 vector
bool long long bl
, bl2
;
21 vector
double fd
, fd2
;
25 // Verify that __vector is also recognized
28 // Verify operation of vec_step
29 int res_ff
[vec_step(ff
) == 4 ? 1 : -1];
34 // -------------------------------------------------------------------------
36 // -------------------------------------------------------------------------
40 sc
= ff2
; // expected-error {{incompatible type}}
41 ff
= sc2
; // expected-error {{incompatible type}}
43 uc
= ff2
; // expected-error {{incompatible type}}
44 ff
= uc2
; // expected-error {{incompatible type}}
46 bc
= ff2
; // expected-error {{incompatible type}}
47 ff
= bc2
; // expected-error {{incompatible type}}
49 fd
= ff2
; // expected-error {{incompatible type}}
50 ff
= fd2
; // expected-error {{incompatible type}}
52 // -------------------------------------------------------------------------
53 // Test casts to same element width.
54 // -------------------------------------------------------------------------
56 ui
= (vector
unsigned int)ff2
;
57 ff
= (vector
float)si2
;
59 // -------------------------------------------------------------------------
60 // Test casts to different element width.
61 // -------------------------------------------------------------------------
63 uc
= (vector
unsigned char)ff2
;
64 us
= (vector
unsigned short)ff2
;
65 ul
= (vector
unsigned long long)ff2
;
67 ff
= (vector
float)sc2
;
68 ff
= (vector
float)ss2
;
69 ff
= (vector
float)sl2
;
71 // -------------------------------------------------------------------------
72 // Test unary operators.
73 // -------------------------------------------------------------------------
85 ff
= ~ff2
; // expected-error {{invalid argument}}
87 // -------------------------------------------------------------------------
88 // Test binary arithmetic operators.
89 // -------------------------------------------------------------------------
92 ff
= ff
+ ui2
; // expected-error {{cannot convert}}
93 ff
= si
+ ff2
; // expected-error {{cannot convert}}
94 ff
= fd
+ ff2
; // expected-error {{cannot convert}}
96 ff
+= fd2
; // expected-error {{cannot convert}}
97 sc
+= ff2
; // expected-error {{cannot convert}}
100 ff
= ff
- ui2
; // expected-error {{cannot convert}}
101 ff
= si
- ff2
; // expected-error {{cannot convert}}
102 ff
= fd
- ff2
; // expected-error {{cannot convert}}
104 ff
-= fd2
; // expected-error {{cannot convert}}
105 sc
-= ff2
; // expected-error {{cannot convert}}
108 ff
= ff
* ui2
; // expected-error {{cannot convert}}
109 ff
= si
* ff2
; // expected-error {{cannot convert}}
110 ff
= fd
* ff2
; // expected-error {{cannot convert}}
112 ff
*= fd2
; // expected-error {{cannot convert}}
113 sc
*= ff2
; // expected-error {{cannot convert}}
116 ff
= ff
/ ui2
; // expected-error {{cannot convert}}
117 ff
= si
/ ff2
; // expected-error {{cannot convert}}
118 ff
= fd
/ ff2
; // expected-error {{cannot convert}}
120 ff
/= fd2
; // expected-error {{cannot convert}}
121 sc
/= ff2
; // expected-error {{cannot convert}}
123 ff
= ff
% ff2
; // expected-error {{invalid operands}}
124 ff
= ff
% ui2
; // expected-error {{invalid operands}}
125 ff
= si
% ff2
; // expected-error {{invalid operands}}
126 ff
= fd
% ff2
; // expected-error {{invalid operands}}
127 ff
%= ff2
; // expected-error {{invalid operands}}
128 ff
%= fd2
; // expected-error {{invalid operands}}
129 sc
%= ff2
; // expected-error {{invalid operands}}
131 // -------------------------------------------------------------------------
132 // Test bitwise binary operators.
133 // -------------------------------------------------------------------------
135 ff
= ff
& ff2
; // expected-error {{invalid operands}}
136 ff
= bi
& ff2
; // expected-error {{invalid operands}}
137 ff
= fd
& ff2
; // expected-error {{invalid operands}}
138 ff
= ff
& bi2
; // expected-error {{invalid operands}}
139 ff
= ff
& si2
; // expected-error {{invalid operands}}
140 ff
= ff
& ui2
; // expected-error {{invalid operands}}
141 sc
&= ff2
; // expected-error {{invalid operands}}
142 ff
&= bc2
; // expected-error {{invalid operands}}
143 ff
&= fd2
; // expected-error {{invalid operands}}
145 ff
= ff
| ff2
; // expected-error {{invalid operands}}
146 ff
= bi
| ff2
; // expected-error {{invalid operands}}
147 ff
= fd
| ff2
; // expected-error {{invalid operands}}
148 ff
= ff
| bi2
; // expected-error {{invalid operands}}
149 ff
= ff
| si2
; // expected-error {{invalid operands}}
150 ff
= ff
| ui2
; // expected-error {{invalid operands}}
151 sc
|= ff2
; // expected-error {{invalid operands}}
152 ff
|= bc2
; // expected-error {{invalid operands}}
153 ff
|= fd2
; // expected-error {{invalid operands}}
155 ff
= ff
^ ff2
; // expected-error {{invalid operands}}
156 ff
= bi
^ ff2
; // expected-error {{invalid operands}}
157 ff
= fd
^ ff2
; // expected-error {{invalid operands}}
158 ff
= ff
^ bi2
; // expected-error {{invalid operands}}
159 ff
= ff
^ si2
; // expected-error {{invalid operands}}
160 ff
= ff
^ ui2
; // expected-error {{invalid operands}}
161 sc
^= ff2
; // expected-error {{invalid operands}}
162 ff
^= bc2
; // expected-error {{invalid operands}}
163 ff
^= fd2
; // expected-error {{invalid operands}}
165 // -------------------------------------------------------------------------
166 // Test shift operators.
167 // -------------------------------------------------------------------------
169 ff
= ff
<< ff2
; // expected-error {{integer is required}}
170 ff
= ff
<< fd2
; // expected-error {{integer is required}}
171 ff
= ff
<< ui2
; // expected-error {{integer is required}}
172 ff
= sl
<< ff2
; // expected-error {{integer is required}}
173 sc
<<= ff2
; // expected-error {{integer is required}}
174 ff
<<= ff2
; // expected-error {{integer is required}}
175 fd
<<= ff2
; // expected-error {{integer is required}}
177 ff
= ff
>> ff2
; // expected-error {{integer is required}}
178 ff
= ff
>> fd2
; // expected-error {{integer is required}}
179 ff
= ff
>> ui2
; // expected-error {{integer is required}}
180 ff
= sl
>> ff2
; // expected-error {{integer is required}}
181 sc
>>= ff2
; // expected-error {{integer is required}}
182 ff
>>= ff2
; // expected-error {{integer is required}}
183 fd
>>= ff2
; // expected-error {{integer is required}}
185 // -------------------------------------------------------------------------
186 // Test comparison operators.
187 // -------------------------------------------------------------------------
190 (void)(ff
== fd2
); // expected-error {{cannot convert}}
191 (void)(ff
== ui2
); // expected-error {{cannot convert}}
192 (void)(ui
== ff2
); // expected-error {{cannot convert}}
195 (void)(ff
!= fd2
); // expected-error {{cannot convert}}
196 (void)(ff
!= ui2
); // expected-error {{cannot convert}}
197 (void)(ui
!= ff2
); // expected-error {{cannot convert}}
200 (void)(ff
<= fd2
); // expected-error {{cannot convert}}
201 (void)(ff
<= ui2
); // expected-error {{cannot convert}}
202 (void)(ui
<= ff2
); // expected-error {{cannot convert}}
205 (void)(ff
>= fd2
); // expected-error {{cannot convert}}
206 (void)(ff
>= ui2
); // expected-error {{cannot convert}}
207 (void)(ui
>= ff2
); // expected-error {{cannot convert}}
210 (void)(ff
< fd2
); // expected-error {{cannot convert}}
211 (void)(ff
< ui2
); // expected-error {{cannot convert}}
212 (void)(ui
< ff2
); // expected-error {{cannot convert}}
215 (void)(ff
> fd2
); // expected-error {{cannot convert}}
216 (void)(ff
> ui2
); // expected-error {{cannot convert}}
217 (void)(ui
> ff2
); // expected-error {{cannot convert}}