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
4 
5 vector signed char sc, sc2;
6 vector unsigned char uc, uc2;
7 vector bool char bc, bc2;
8 
9 vector signed short ss, ss2;
10 vector unsigned short us, us2;
11 vector bool short bs, bs2;
12 
13 vector signed int si, si2;
14 vector unsigned int ui, ui2;
15 vector bool int bi, bi2;
16 
17 vector signed long long sl, sl2;
18 vector unsigned long long ul, ul2;
19 vector bool long long bl, bl2;
20 
21 vector double fd, fd2;
22 
23 vector float ff, ff2;
24 
25 // Verify that __vector is also recognized
26 __vector float ff3;
27 
28 // Verify operation of vec_step
29 int res_ff[vec_step(ff) == 4 ? 1 : -1];
30 
31 
foo(void)32 void foo(void)
33 {
34   // -------------------------------------------------------------------------
35   // Test assignment.
36   // -------------------------------------------------------------------------
37 
38   ff = ff2;
39 
40   sc = ff2; // expected-error {{incompatible type}}
41   ff = sc2; // expected-error {{incompatible type}}
42 
43   uc = ff2; // expected-error {{incompatible type}}
44   ff = uc2; // expected-error {{incompatible type}}
45 
46   bc = ff2; // expected-error {{incompatible type}}
47   ff = bc2; // expected-error {{incompatible type}}
48 
49   fd = ff2; // expected-error {{incompatible type}}
50   ff = fd2; // expected-error {{incompatible type}}
51 
52   // -------------------------------------------------------------------------
53   // Test casts to same element width.
54   // -------------------------------------------------------------------------
55 
56   ui = (vector unsigned int)ff2;
57   ff = (vector float)si2;
58 
59   // -------------------------------------------------------------------------
60   // Test casts to different element width.
61   // -------------------------------------------------------------------------
62 
63   uc = (vector unsigned char)ff2;
64   us = (vector unsigned short)ff2;
65   ul = (vector unsigned long long)ff2;
66 
67   ff = (vector float)sc2;
68   ff = (vector float)ss2;
69   ff = (vector float)sl2;
70 
71   // -------------------------------------------------------------------------
72   // Test unary operators.
73   // -------------------------------------------------------------------------
74 
75   ++ff2;
76   ff++;
77 
78   --ff2;
79   ff--;
80 
81   ff = +ff2;
82 
83   ff = -ff2;
84 
85   ff = ~ff2; // expected-error {{invalid argument}}
86 
87   // -------------------------------------------------------------------------
88   // Test binary arithmetic operators.
89   // -------------------------------------------------------------------------
90 
91   ff = ff + ff2;
92   ff = ff + ui2; // expected-error {{cannot convert}}
93   ff = si + ff2; // expected-error {{cannot convert}}
94   ff = fd + ff2; // expected-error {{cannot convert}}
95   ff += ff2;
96   ff += fd2; // expected-error {{cannot convert}}
97   sc += ff2; // expected-error {{cannot convert}}
98 
99   ff = ff - ff2;
100   ff = ff - ui2; // expected-error {{cannot convert}}
101   ff = si - ff2; // expected-error {{cannot convert}}
102   ff = fd - ff2; // expected-error {{cannot convert}}
103   ff -= ff2;
104   ff -= fd2; // expected-error {{cannot convert}}
105   sc -= ff2; // expected-error {{cannot convert}}
106 
107   ff = ff * ff2;
108   ff = ff * ui2; // expected-error {{cannot convert}}
109   ff = si * ff2; // expected-error {{cannot convert}}
110   ff = fd * ff2; // expected-error {{cannot convert}}
111   ff *= ff2;
112   ff *= fd2; // expected-error {{cannot convert}}
113   sc *= ff2; // expected-error {{cannot convert}}
114 
115   ff = ff / ff2;
116   ff = ff / ui2; // expected-error {{cannot convert}}
117   ff = si / ff2; // expected-error {{cannot convert}}
118   ff = fd / ff2; // expected-error {{cannot convert}}
119   ff /= ff2;
120   ff /= fd2; // expected-error {{cannot convert}}
121   sc /= ff2; // expected-error {{cannot convert}}
122 
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}}
130 
131   // -------------------------------------------------------------------------
132   // Test bitwise binary operators.
133   // -------------------------------------------------------------------------
134 
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}}
144 
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}}
154 
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}}
164 
165   // -------------------------------------------------------------------------
166   // Test shift operators.
167   // -------------------------------------------------------------------------
168 
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}}
176 
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}}
184 
185   // -------------------------------------------------------------------------
186   // Test comparison operators.
187   // -------------------------------------------------------------------------
188 
189   (void)(ff == ff2);
190   (void)(ff == fd2); // expected-error {{cannot convert}}
191   (void)(ff == ui2); // expected-error {{cannot convert}}
192   (void)(ui == ff2); // expected-error {{cannot convert}}
193 
194   (void)(ff != ff2);
195   (void)(ff != fd2); // expected-error {{cannot convert}}
196   (void)(ff != ui2); // expected-error {{cannot convert}}
197   (void)(ui != ff2); // expected-error {{cannot convert}}
198 
199   (void)(ff <= ff2);
200   (void)(ff <= fd2); // expected-error {{cannot convert}}
201   (void)(ff <= ui2); // expected-error {{cannot convert}}
202   (void)(ui <= ff2); // expected-error {{cannot convert}}
203 
204   (void)(ff >= ff2);
205   (void)(ff >= fd2); // expected-error {{cannot convert}}
206   (void)(ff >= ui2); // expected-error {{cannot convert}}
207   (void)(ui >= ff2); // expected-error {{cannot convert}}
208 
209   (void)(ff < ff2);
210   (void)(ff < fd2); // expected-error {{cannot convert}}
211   (void)(ff < ui2); // expected-error {{cannot convert}}
212   (void)(ui < ff2); // expected-error {{cannot convert}}
213 
214   (void)(ff > ff2);
215   (void)(ff > fd2); // expected-error {{cannot convert}}
216   (void)(ff > ui2); // expected-error {{cannot convert}}
217   (void)(ui > ff2); // expected-error {{cannot convert}}
218 }
219