xref: /illumos-gate/usr/src/tools/smatch/src/validation/linear/cast-constants.c (revision c85f09cc92abd00c84e58ec9f0f5d942906cb713)
1*c85f09ccSJohn Levon typedef unsigned int uint;
2*c85f09ccSJohn Levon typedef unsigned long ulong;
3*c85f09ccSJohn Levon 
uint_2_int(void)4*c85f09ccSJohn Levon static int uint_2_int(void) { return (int)123U; }
long_2_int(void)5*c85f09ccSJohn Levon static int long_2_int(void) { return (int)123L; }
ulong_2_int(void)6*c85f09ccSJohn Levon static int ulong_2_int(void) { return (int)123UL; }
vptr_2_int(void)7*c85f09ccSJohn Levon static int vptr_2_int(void) { return (int)((void*)123); }
iptr_2_int(void)8*c85f09ccSJohn Levon static int iptr_2_int(void) { return (int)((int*)128); }
float_2_int(void)9*c85f09ccSJohn Levon static int float_2_int(void) { return (int)1.123F; }
double_2_int(void)10*c85f09ccSJohn Levon static int double_2_int(void) { return (int)1.123L; }
int_2_uint(void)11*c85f09ccSJohn Levon static uint int_2_uint(void) { return (uint)123; }
long_2_uint(void)12*c85f09ccSJohn Levon static uint long_2_uint(void) { return (uint)123L; }
ulong_2_uint(void)13*c85f09ccSJohn Levon static uint ulong_2_uint(void) { return (uint)123UL; }
vptr_2_uint(void)14*c85f09ccSJohn Levon static uint vptr_2_uint(void) { return (uint)((void*)123); }
iptr_2_uint(void)15*c85f09ccSJohn Levon static uint iptr_2_uint(void) { return (uint)((int*)128); }
float_2_uint(void)16*c85f09ccSJohn Levon static uint float_2_uint(void) { return (uint)1.123F; }
double_2_uint(void)17*c85f09ccSJohn Levon static uint double_2_uint(void) { return (uint)1.123L; }
int_2_long(void)18*c85f09ccSJohn Levon static long int_2_long(void) { return (long)123; }
uint_2_long(void)19*c85f09ccSJohn Levon static long uint_2_long(void) { return (long)123U; }
ulong_2_long(void)20*c85f09ccSJohn Levon static long ulong_2_long(void) { return (long)123UL; }
vptr_2_long(void)21*c85f09ccSJohn Levon static long vptr_2_long(void) { return (long)((void*)123); }
iptr_2_long(void)22*c85f09ccSJohn Levon static long iptr_2_long(void) { return (long)((int*)128); }
float_2_long(void)23*c85f09ccSJohn Levon static long float_2_long(void) { return (long)1.123F; }
double_2_long(void)24*c85f09ccSJohn Levon static long double_2_long(void) { return (long)1.123L; }
int_2_ulong(void)25*c85f09ccSJohn Levon static ulong int_2_ulong(void) { return (ulong)123; }
uint_2_ulong(void)26*c85f09ccSJohn Levon static ulong uint_2_ulong(void) { return (ulong)123U; }
long_2_ulong(void)27*c85f09ccSJohn Levon static ulong long_2_ulong(void) { return (ulong)123L; }
vptr_2_ulong(void)28*c85f09ccSJohn Levon static ulong vptr_2_ulong(void) { return (ulong)((void*)123); }
iptr_2_ulong(void)29*c85f09ccSJohn Levon static ulong iptr_2_ulong(void) { return (ulong)((int*)128); }
float_2_ulong(void)30*c85f09ccSJohn Levon static ulong float_2_ulong(void) { return (ulong)1.123F; }
double_2_ulong(void)31*c85f09ccSJohn Levon static ulong double_2_ulong(void) { return (ulong)1.123L; }
int_2_vptr(void)32*c85f09ccSJohn Levon static void * int_2_vptr(void) { return (void *)123; }
uint_2_vptr(void)33*c85f09ccSJohn Levon static void * uint_2_vptr(void) { return (void *)123U; }
long_2_vptr(void)34*c85f09ccSJohn Levon static void * long_2_vptr(void) { return (void *)123L; }
ulong_2_vptr(void)35*c85f09ccSJohn Levon static void * ulong_2_vptr(void) { return (void *)123UL; }
iptr_2_vptr(void)36*c85f09ccSJohn Levon static void * iptr_2_vptr(void) { return (void *)((int*)128); }
int_2_iptr(void)37*c85f09ccSJohn Levon static int * int_2_iptr(void) { return (int *)123; }
uint_2_iptr(void)38*c85f09ccSJohn Levon static int * uint_2_iptr(void) { return (int *)123U; }
long_2_iptr(void)39*c85f09ccSJohn Levon static int * long_2_iptr(void) { return (int *)123L; }
ulong_2_iptr(void)40*c85f09ccSJohn Levon static int * ulong_2_iptr(void) { return (int *)123UL; }
vptr_2_iptr(void)41*c85f09ccSJohn Levon static int * vptr_2_iptr(void) { return (int *)((void*)123); }
int_2_float(void)42*c85f09ccSJohn Levon static float int_2_float(void) { return (float)123; }
uint_2_float(void)43*c85f09ccSJohn Levon static float uint_2_float(void) { return (float)123U; }
long_2_float(void)44*c85f09ccSJohn Levon static float long_2_float(void) { return (float)123L; }
ulong_2_float(void)45*c85f09ccSJohn Levon static float ulong_2_float(void) { return (float)123UL; }
double_2_float(void)46*c85f09ccSJohn Levon static float double_2_float(void) { return (float)1.123L; }
int_2_double(void)47*c85f09ccSJohn Levon static double int_2_double(void) { return (double)123; }
uint_2_double(void)48*c85f09ccSJohn Levon static double uint_2_double(void) { return (double)123U; }
long_2_double(void)49*c85f09ccSJohn Levon static double long_2_double(void) { return (double)123L; }
ulong_2_double(void)50*c85f09ccSJohn Levon static double ulong_2_double(void) { return (double)123UL; }
float_2_double(void)51*c85f09ccSJohn Levon static double float_2_double(void) { return (double)1.123F; }
52*c85f09ccSJohn Levon 
53*c85f09ccSJohn Levon /*
54*c85f09ccSJohn Levon  * check-name: cast-constants.c
55*c85f09ccSJohn Levon  * check-command: test-linearize -m64 $file
56*c85f09ccSJohn Levon  * check-assert: sizeof(void *) == 8 && sizeof(long) == 8 && sizeof(double) == 8
57*c85f09ccSJohn Levon  *
58*c85f09ccSJohn Levon  * check-output-start
59*c85f09ccSJohn Levon uint_2_int:
60*c85f09ccSJohn Levon .L0:
61*c85f09ccSJohn Levon 	<entry-point>
62*c85f09ccSJohn Levon 	ret.32      $123
63*c85f09ccSJohn Levon 
64*c85f09ccSJohn Levon 
65*c85f09ccSJohn Levon long_2_int:
66*c85f09ccSJohn Levon .L2:
67*c85f09ccSJohn Levon 	<entry-point>
68*c85f09ccSJohn Levon 	ret.32      $123
69*c85f09ccSJohn Levon 
70*c85f09ccSJohn Levon 
71*c85f09ccSJohn Levon ulong_2_int:
72*c85f09ccSJohn Levon .L4:
73*c85f09ccSJohn Levon 	<entry-point>
74*c85f09ccSJohn Levon 	ret.32      $123
75*c85f09ccSJohn Levon 
76*c85f09ccSJohn Levon 
77*c85f09ccSJohn Levon vptr_2_int:
78*c85f09ccSJohn Levon .L6:
79*c85f09ccSJohn Levon 	<entry-point>
80*c85f09ccSJohn Levon 	ret.32      $123
81*c85f09ccSJohn Levon 
82*c85f09ccSJohn Levon 
83*c85f09ccSJohn Levon iptr_2_int:
84*c85f09ccSJohn Levon .L8:
85*c85f09ccSJohn Levon 	<entry-point>
86*c85f09ccSJohn Levon 	ret.32      $128
87*c85f09ccSJohn Levon 
88*c85f09ccSJohn Levon 
89*c85f09ccSJohn Levon float_2_int:
90*c85f09ccSJohn Levon .L10:
91*c85f09ccSJohn Levon 	<entry-point>
92*c85f09ccSJohn Levon 	ret.32      $1
93*c85f09ccSJohn Levon 
94*c85f09ccSJohn Levon 
95*c85f09ccSJohn Levon double_2_int:
96*c85f09ccSJohn Levon .L12:
97*c85f09ccSJohn Levon 	<entry-point>
98*c85f09ccSJohn Levon 	ret.32      $1
99*c85f09ccSJohn Levon 
100*c85f09ccSJohn Levon 
101*c85f09ccSJohn Levon int_2_uint:
102*c85f09ccSJohn Levon .L14:
103*c85f09ccSJohn Levon 	<entry-point>
104*c85f09ccSJohn Levon 	ret.32      $123
105*c85f09ccSJohn Levon 
106*c85f09ccSJohn Levon 
107*c85f09ccSJohn Levon long_2_uint:
108*c85f09ccSJohn Levon .L16:
109*c85f09ccSJohn Levon 	<entry-point>
110*c85f09ccSJohn Levon 	ret.32      $123
111*c85f09ccSJohn Levon 
112*c85f09ccSJohn Levon 
113*c85f09ccSJohn Levon ulong_2_uint:
114*c85f09ccSJohn Levon .L18:
115*c85f09ccSJohn Levon 	<entry-point>
116*c85f09ccSJohn Levon 	ret.32      $123
117*c85f09ccSJohn Levon 
118*c85f09ccSJohn Levon 
119*c85f09ccSJohn Levon vptr_2_uint:
120*c85f09ccSJohn Levon .L20:
121*c85f09ccSJohn Levon 	<entry-point>
122*c85f09ccSJohn Levon 	ret.32      $123
123*c85f09ccSJohn Levon 
124*c85f09ccSJohn Levon 
125*c85f09ccSJohn Levon iptr_2_uint:
126*c85f09ccSJohn Levon .L22:
127*c85f09ccSJohn Levon 	<entry-point>
128*c85f09ccSJohn Levon 	ret.32      $128
129*c85f09ccSJohn Levon 
130*c85f09ccSJohn Levon 
131*c85f09ccSJohn Levon float_2_uint:
132*c85f09ccSJohn Levon .L24:
133*c85f09ccSJohn Levon 	<entry-point>
134*c85f09ccSJohn Levon 	ret.32      $1
135*c85f09ccSJohn Levon 
136*c85f09ccSJohn Levon 
137*c85f09ccSJohn Levon double_2_uint:
138*c85f09ccSJohn Levon .L26:
139*c85f09ccSJohn Levon 	<entry-point>
140*c85f09ccSJohn Levon 	ret.32      $1
141*c85f09ccSJohn Levon 
142*c85f09ccSJohn Levon 
143*c85f09ccSJohn Levon int_2_long:
144*c85f09ccSJohn Levon .L28:
145*c85f09ccSJohn Levon 	<entry-point>
146*c85f09ccSJohn Levon 	ret.64      $123
147*c85f09ccSJohn Levon 
148*c85f09ccSJohn Levon 
149*c85f09ccSJohn Levon uint_2_long:
150*c85f09ccSJohn Levon .L30:
151*c85f09ccSJohn Levon 	<entry-point>
152*c85f09ccSJohn Levon 	ret.64      $123
153*c85f09ccSJohn Levon 
154*c85f09ccSJohn Levon 
155*c85f09ccSJohn Levon ulong_2_long:
156*c85f09ccSJohn Levon .L32:
157*c85f09ccSJohn Levon 	<entry-point>
158*c85f09ccSJohn Levon 	ret.64      $123
159*c85f09ccSJohn Levon 
160*c85f09ccSJohn Levon 
161*c85f09ccSJohn Levon vptr_2_long:
162*c85f09ccSJohn Levon .L34:
163*c85f09ccSJohn Levon 	<entry-point>
164*c85f09ccSJohn Levon 	ret.64      $123
165*c85f09ccSJohn Levon 
166*c85f09ccSJohn Levon 
167*c85f09ccSJohn Levon iptr_2_long:
168*c85f09ccSJohn Levon .L36:
169*c85f09ccSJohn Levon 	<entry-point>
170*c85f09ccSJohn Levon 	ret.64      $128
171*c85f09ccSJohn Levon 
172*c85f09ccSJohn Levon 
173*c85f09ccSJohn Levon float_2_long:
174*c85f09ccSJohn Levon .L38:
175*c85f09ccSJohn Levon 	<entry-point>
176*c85f09ccSJohn Levon 	ret.64      $1
177*c85f09ccSJohn Levon 
178*c85f09ccSJohn Levon 
179*c85f09ccSJohn Levon double_2_long:
180*c85f09ccSJohn Levon .L40:
181*c85f09ccSJohn Levon 	<entry-point>
182*c85f09ccSJohn Levon 	ret.64      $1
183*c85f09ccSJohn Levon 
184*c85f09ccSJohn Levon 
185*c85f09ccSJohn Levon int_2_ulong:
186*c85f09ccSJohn Levon .L42:
187*c85f09ccSJohn Levon 	<entry-point>
188*c85f09ccSJohn Levon 	ret.64      $123
189*c85f09ccSJohn Levon 
190*c85f09ccSJohn Levon 
191*c85f09ccSJohn Levon uint_2_ulong:
192*c85f09ccSJohn Levon .L44:
193*c85f09ccSJohn Levon 	<entry-point>
194*c85f09ccSJohn Levon 	ret.64      $123
195*c85f09ccSJohn Levon 
196*c85f09ccSJohn Levon 
197*c85f09ccSJohn Levon long_2_ulong:
198*c85f09ccSJohn Levon .L46:
199*c85f09ccSJohn Levon 	<entry-point>
200*c85f09ccSJohn Levon 	ret.64      $123
201*c85f09ccSJohn Levon 
202*c85f09ccSJohn Levon 
203*c85f09ccSJohn Levon vptr_2_ulong:
204*c85f09ccSJohn Levon .L48:
205*c85f09ccSJohn Levon 	<entry-point>
206*c85f09ccSJohn Levon 	ret.64      $123
207*c85f09ccSJohn Levon 
208*c85f09ccSJohn Levon 
209*c85f09ccSJohn Levon iptr_2_ulong:
210*c85f09ccSJohn Levon .L50:
211*c85f09ccSJohn Levon 	<entry-point>
212*c85f09ccSJohn Levon 	ret.64      $128
213*c85f09ccSJohn Levon 
214*c85f09ccSJohn Levon 
215*c85f09ccSJohn Levon float_2_ulong:
216*c85f09ccSJohn Levon .L52:
217*c85f09ccSJohn Levon 	<entry-point>
218*c85f09ccSJohn Levon 	ret.64      $1
219*c85f09ccSJohn Levon 
220*c85f09ccSJohn Levon 
221*c85f09ccSJohn Levon double_2_ulong:
222*c85f09ccSJohn Levon .L54:
223*c85f09ccSJohn Levon 	<entry-point>
224*c85f09ccSJohn Levon 	ret.64      $1
225*c85f09ccSJohn Levon 
226*c85f09ccSJohn Levon 
227*c85f09ccSJohn Levon int_2_vptr:
228*c85f09ccSJohn Levon .L56:
229*c85f09ccSJohn Levon 	<entry-point>
230*c85f09ccSJohn Levon 	ret.64      $123
231*c85f09ccSJohn Levon 
232*c85f09ccSJohn Levon 
233*c85f09ccSJohn Levon uint_2_vptr:
234*c85f09ccSJohn Levon .L58:
235*c85f09ccSJohn Levon 	<entry-point>
236*c85f09ccSJohn Levon 	ret.64      $123
237*c85f09ccSJohn Levon 
238*c85f09ccSJohn Levon 
239*c85f09ccSJohn Levon long_2_vptr:
240*c85f09ccSJohn Levon .L60:
241*c85f09ccSJohn Levon 	<entry-point>
242*c85f09ccSJohn Levon 	ret.64      $123
243*c85f09ccSJohn Levon 
244*c85f09ccSJohn Levon 
245*c85f09ccSJohn Levon ulong_2_vptr:
246*c85f09ccSJohn Levon .L62:
247*c85f09ccSJohn Levon 	<entry-point>
248*c85f09ccSJohn Levon 	ret.64      $123
249*c85f09ccSJohn Levon 
250*c85f09ccSJohn Levon 
251*c85f09ccSJohn Levon iptr_2_vptr:
252*c85f09ccSJohn Levon .L64:
253*c85f09ccSJohn Levon 	<entry-point>
254*c85f09ccSJohn Levon 	ret.64      $128
255*c85f09ccSJohn Levon 
256*c85f09ccSJohn Levon 
257*c85f09ccSJohn Levon int_2_iptr:
258*c85f09ccSJohn Levon .L66:
259*c85f09ccSJohn Levon 	<entry-point>
260*c85f09ccSJohn Levon 	ret.64      $123
261*c85f09ccSJohn Levon 
262*c85f09ccSJohn Levon 
263*c85f09ccSJohn Levon uint_2_iptr:
264*c85f09ccSJohn Levon .L68:
265*c85f09ccSJohn Levon 	<entry-point>
266*c85f09ccSJohn Levon 	ret.64      $123
267*c85f09ccSJohn Levon 
268*c85f09ccSJohn Levon 
269*c85f09ccSJohn Levon long_2_iptr:
270*c85f09ccSJohn Levon .L70:
271*c85f09ccSJohn Levon 	<entry-point>
272*c85f09ccSJohn Levon 	ret.64      $123
273*c85f09ccSJohn Levon 
274*c85f09ccSJohn Levon 
275*c85f09ccSJohn Levon ulong_2_iptr:
276*c85f09ccSJohn Levon .L72:
277*c85f09ccSJohn Levon 	<entry-point>
278*c85f09ccSJohn Levon 	ret.64      $123
279*c85f09ccSJohn Levon 
280*c85f09ccSJohn Levon 
281*c85f09ccSJohn Levon vptr_2_iptr:
282*c85f09ccSJohn Levon .L74:
283*c85f09ccSJohn Levon 	<entry-point>
284*c85f09ccSJohn Levon 	ret.64      $123
285*c85f09ccSJohn Levon 
286*c85f09ccSJohn Levon 
287*c85f09ccSJohn Levon int_2_float:
288*c85f09ccSJohn Levon .L76:
289*c85f09ccSJohn Levon 	<entry-point>
290*c85f09ccSJohn Levon 	setfval.32  %r39 <- 1.230000e+02
291*c85f09ccSJohn Levon 	ret.32      %r39
292*c85f09ccSJohn Levon 
293*c85f09ccSJohn Levon 
294*c85f09ccSJohn Levon uint_2_float:
295*c85f09ccSJohn Levon .L78:
296*c85f09ccSJohn Levon 	<entry-point>
297*c85f09ccSJohn Levon 	setfval.32  %r41 <- 1.230000e+02
298*c85f09ccSJohn Levon 	ret.32      %r41
299*c85f09ccSJohn Levon 
300*c85f09ccSJohn Levon 
301*c85f09ccSJohn Levon long_2_float:
302*c85f09ccSJohn Levon .L80:
303*c85f09ccSJohn Levon 	<entry-point>
304*c85f09ccSJohn Levon 	setfval.32  %r43 <- 1.230000e+02
305*c85f09ccSJohn Levon 	ret.32      %r43
306*c85f09ccSJohn Levon 
307*c85f09ccSJohn Levon 
308*c85f09ccSJohn Levon ulong_2_float:
309*c85f09ccSJohn Levon .L82:
310*c85f09ccSJohn Levon 	<entry-point>
311*c85f09ccSJohn Levon 	setfval.32  %r45 <- 1.230000e+02
312*c85f09ccSJohn Levon 	ret.32      %r45
313*c85f09ccSJohn Levon 
314*c85f09ccSJohn Levon 
315*c85f09ccSJohn Levon double_2_float:
316*c85f09ccSJohn Levon .L84:
317*c85f09ccSJohn Levon 	<entry-point>
318*c85f09ccSJohn Levon 	setfval.32  %r47 <- 1.123000e+00
319*c85f09ccSJohn Levon 	ret.32      %r47
320*c85f09ccSJohn Levon 
321*c85f09ccSJohn Levon 
322*c85f09ccSJohn Levon int_2_double:
323*c85f09ccSJohn Levon .L86:
324*c85f09ccSJohn Levon 	<entry-point>
325*c85f09ccSJohn Levon 	setfval.64  %r49 <- 1.230000e+02
326*c85f09ccSJohn Levon 	ret.64      %r49
327*c85f09ccSJohn Levon 
328*c85f09ccSJohn Levon 
329*c85f09ccSJohn Levon uint_2_double:
330*c85f09ccSJohn Levon .L88:
331*c85f09ccSJohn Levon 	<entry-point>
332*c85f09ccSJohn Levon 	setfval.64  %r51 <- 1.230000e+02
333*c85f09ccSJohn Levon 	ret.64      %r51
334*c85f09ccSJohn Levon 
335*c85f09ccSJohn Levon 
336*c85f09ccSJohn Levon long_2_double:
337*c85f09ccSJohn Levon .L90:
338*c85f09ccSJohn Levon 	<entry-point>
339*c85f09ccSJohn Levon 	setfval.64  %r53 <- 1.230000e+02
340*c85f09ccSJohn Levon 	ret.64      %r53
341*c85f09ccSJohn Levon 
342*c85f09ccSJohn Levon 
343*c85f09ccSJohn Levon ulong_2_double:
344*c85f09ccSJohn Levon .L92:
345*c85f09ccSJohn Levon 	<entry-point>
346*c85f09ccSJohn Levon 	setfval.64  %r55 <- 1.230000e+02
347*c85f09ccSJohn Levon 	ret.64      %r55
348*c85f09ccSJohn Levon 
349*c85f09ccSJohn Levon 
350*c85f09ccSJohn Levon float_2_double:
351*c85f09ccSJohn Levon .L94:
352*c85f09ccSJohn Levon 	<entry-point>
353*c85f09ccSJohn Levon 	setfval.64  %r57 <- 1.123000e+00
354*c85f09ccSJohn Levon 	ret.64      %r57
355*c85f09ccSJohn Levon 
356*c85f09ccSJohn Levon 
357*c85f09ccSJohn Levon  * check-output-end
358*c85f09ccSJohn Levon  */
359