1 /* $NetBSD: msg_141.c,v 1.17 2024/03/27 20:09:43 rillig Exp $ */
2 # 3 "msg_141.c"
3
4 // Test for message: '%s' overflows '%s' [141]
5
6 /* lint1-extra-flags: -h -X 351 */
7
8 // Integer overflow occurs when the arbitrary-precision result of an
9 // arithmetic operation cannot be represented by the type of the expression.
10
11 signed int s32;
12 unsigned int u32;
13 signed long long s64;
14 unsigned long long u64;
15 _Bool cond;
16
17 void
compl_s32(void)18 compl_s32(void)
19 {
20 s32 = ~(-0x7fffffff - 1);
21 s32 = ~-1;
22 s32 = ~0;
23 s32 = ~1;
24 s32 = ~0x7fffffff;
25 }
26
27 void
compl_u32(void)28 compl_u32(void)
29 {
30 u32 = ~0x00000000U;
31 u32 = ~0x7fffffffU;
32 u32 = ~0x80000000U;
33 u32 = ~0xffffffffU;
34 }
35
36 void
compl_s64(void)37 compl_s64(void)
38 {
39 s64 = ~(-0x7fffffffffffffffLL - 1LL);
40 s64 = ~-1LL;
41 s64 = ~0LL;
42 s64 = ~0x7fffffffffffffffLL;
43 }
44
45 void
compl_u64(void)46 compl_u64(void)
47 {
48 u64 = ~0ULL;
49 u64 = ~0x7fffffffffffffffULL;
50 u64 = ~0x8000000000000000ULL;
51 u64 = ~0xffffffffffffffffULL;
52 }
53
54 void
uplus_s32(void)55 uplus_s32(void)
56 {
57 s32 = +(-0x7fffffff - 1);
58 s32 = +-1;
59 s32 = +0;
60 s32 = +0x7fffffff;
61 }
62
63 void
uplus_u32(void)64 uplus_u32(void)
65 {
66 u32 = +0x00000000U;
67 u32 = +0x7fffffffU;
68 u32 = +0x80000000U;
69 u32 = +0xffffffffU;
70 }
71
72 void
uplus_s64(void)73 uplus_s64(void)
74 {
75 s64 = +(-0x7fffffffffffffffLL - 1LL);
76 s64 = +-1LL;
77 s64 = +0LL;
78 s64 = +0x7fffffffffffffffLL;
79 }
80
81 void
uplus_u64(void)82 uplus_u64(void)
83 {
84 u64 = +0x0000000000000000ULL;
85 u64 = +0x7fffffffffffffffULL;
86 u64 = +0x8000000000000000ULL;
87 u64 = +0xffffffffffffffffULL;
88 }
89
90 void
uminus_s32(void)91 uminus_s32(void)
92 {
93 /* expect+1: warning: '-(-2147483648)' overflows 'int' [141] */
94 s32 = -(-0x7fffffff - 1);
95 s32 = - -1;
96 s32 = -0;
97 s32 = -0x7fffffff;
98 }
99
100 void
uminus_u32(void)101 uminus_u32(void)
102 {
103 u32 = -0x00000000U;
104 u32 = -0x7fffffffU;
105 u32 = -0x80000000U;
106 u32 = -0xffffffffU;
107 }
108
109 void
uminus_s64(void)110 uminus_s64(void)
111 {
112 /* expect+1: warning: '-(-9223372036854775808)' overflows 'long long' [141] */
113 s64 = -(-0x7fffffffffffffffLL - 1LL);
114 s64 = - -1LL;
115 s64 = -0LL;
116 s64 = -0x7fffffffffffffffLL;
117 }
118
119 void
uminus_u64(void)120 uminus_u64(void)
121 {
122 u64 = -0x0000000000000000ULL;
123 u64 = -0x7fffffffffffffffULL;
124 u64 = -0x8000000000000000ULL;
125 u64 = -0xffffffffffffffffULL;
126 }
127
128 void
mult_s32(void)129 mult_s32(void)
130 {
131 /* expect+1: warning: '-65536 * 65536' overflows 'int' [141] */
132 s32 = -0x00010000 * +0x00010000; // -0x0100000000
133 /* expect+1: warning: '-3 * 715827883' overflows 'int' [141] */
134 s32 = -0x00000003 * +0x2aaaaaab; // -0x80000001
135 /* expect+1: warning: '715827883 * -3' overflows 'int' [141] */
136 s32 = +0x2aaaaaab * -0x00000003; // -0x80000001
137 s32 = -0x00000008 * +0x10000000; // -0x80000000
138 s32 = +0x10000000 * -0x00000008; // -0x80000000
139 s32 = +0x00000002 * +0x3fffffff; // +0x7ffffffe
140 s32 = +0x3fffffff * +0x00000002; // +0x7ffffffe
141 s32 = +0x7fffffff * +0x00000001; // +0x7fffffff
142 s32 = +0x00000001 * +0x7fffffff; // +0x7fffffff
143 /* expect+1: warning: '2 * 1073741824' overflows 'int' [141] */
144 s32 = +0x00000002 * +0x40000000; // +0x80000000
145 /* expect+1: warning: '1073741824 * 2' overflows 'int' [141] */
146 s32 = +0x40000000 * +0x00000002; // +0x80000000
147 /* expect+1: warning: '65535 * 65537' overflows 'int' [141] */
148 s32 = +0x0000ffff * +0x00010001; // +0xffffffff
149 /* expect+1: warning: '65536 * 65536' overflows 'int' [141] */
150 s32 = +0x00010000 * +0x00010000; // +0x0100000000
151 }
152
153 void
mult_u32(void)154 mult_u32(void)
155 {
156 u32 = 0xffffU * 0x10001U; // +0xffffffff
157 /* expect+1: warning: '65536 * 65536' overflows 'unsigned int' [141] */
158 u32 = 0x10000U * 0x10000U; // +0x0100000000
159 }
160
161 void
mult_s64(void)162 mult_s64(void)
163 {
164 /* expect+1: warning: '-4294967296 * 4294967296' overflows 'long long' [141] */
165 s64 = -0x100000000LL * 0x100000000LL; // -0x010000000000000000
166 /* expect+1: warning: '-3 * 3074457345618258603' overflows 'long long' [141] */
167 s64 = -3LL * 0x2aaaaaaaaaaaaaabLL; // -0x8000000000000001
168 /* expect+1: warning: '3074457345618258603 * -3' overflows 'long long' [141] */
169 s64 = 0x2aaaaaaaaaaaaaabLL * -3LL; // -0x8000000000000001
170 s64 = -8LL * +0x1000000000000000LL; // -0x8000000000000000
171 s64 = +0x1000000000000000LL * -8LL; // -0x8000000000000000
172 s64 = +2LL * +0x3fffffffffffffffLL; // +0x7ffffffffffffffe
173 s64 = +0x3fffffffffffffffLL * +2LL; // +0x7ffffffffffffffe
174 s64 = +0x7fffffffffffffffLL * +1LL; // +0x7fffffffffffffff
175 s64 = +1LL * +0x7fffffffffffffffLL; // +0x7fffffffffffffff
176 /* expect+1: warning: '2 * 4611686018427387904' overflows 'long long' [141] */
177 s64 = +2LL * +0x4000000000000000LL; // +0x8000000000000000
178 /* expect+1: warning: '4611686018427387904 * 2' overflows 'long long' [141] */
179 s64 = +0x4000000000000000LL * +2LL; // +0x8000000000000000
180 /* expect+1: warning: '4294967295 * 4294967297' overflows 'long long' [141] */
181 s64 = +0xffffffffLL * +0x100000001LL; // +0xffffffffffffffff
182 /* expect+1: warning: '4294967296 * 4294967296' overflows 'long long' [141] */
183 s64 = +0x100000000LL * +0x100000000LL; // +0x010000000000000000
184 }
185
186 void
mult_u64(void)187 mult_u64(void)
188 {
189 u64 = 0xffffffffULL * 0x100000001ULL; // +0xffffffffffffffff
190 u64 = 0x00010000ULL * 0x00010000ULL; // +0x0100000000
191 /* expect+1: warning: '4294967296 * 4294967296' overflows 'unsigned long long' [141] */
192 u64 = 0x100000000ULL * 0x100000000ULL; // +0x010000000000000000
193 }
194
195 void
div_s32(void)196 div_s32(void)
197 {
198 /* expect+1: warning: '-2147483648 / -1' overflows 'int' [141] */
199 s32 = (-0x7fffffff - 1) / -1;
200 s32 = (-0x7fffffff - 1) / 1;
201 s32 = 0x7fffffff / -1;
202 /* expect+1: error: division by 0 [139] */
203 s32 = 0 / 0;
204 /* expect+1: error: division by 0 [139] */
205 s32 = 0x7fffffff / 0;
206 }
207
208 void
div_u32(void)209 div_u32(void)
210 {
211 u32 = 0xffffffffU / -1U;
212 u32 = 0xffffffffU / 1U;
213 /* expect+1: error: division by 0 [139] */
214 u32 = 0U / 0U;
215 /* expect+1: error: division by 0 [139] */
216 u32 = 0xffffffffU / 0U;
217 }
218
219 void
div_s64(void)220 div_s64(void)
221 {
222 /* expect+1: warning: '-9223372036854775808 / -1' overflows 'long long' [141] */
223 s64 = (-0x7fffffffffffffffLL - 1LL) / -1LL;
224 s64 = (-0x7fffffffffffffffLL - 1LL) / 1LL;
225 s64 = (-0x7fffffffffffffffLL - 1LL) / 0x7fffffffffffffffLL;
226 s64 = 0x7fffffffffffffffLL / -1LL;
227 s64 = (-0x7fffffffLL - 1LL) / -1LL;
228 s64 = (-0x7fffffffLL - 1LL) / 0x7fffffffLL;
229 /* expect+1: error: division by 0 [139] */
230 s64 = 0LL / 0LL;
231 /* expect+1: error: division by 0 [139] */
232 s64 = 0x7fffffffffffffffLL / 0LL;
233 }
234
235 void
div_u64(void)236 div_u64(void)
237 {
238 u64 = 0xffffffffffffffffULL / -1ULL;
239 u64 = 0xffffffffffffffffULL / 1ULL;
240 /* expect+1: error: division by 0 [139] */
241 u64 = 0ULL / 0ULL;
242 /* expect+1: error: division by 0 [139] */
243 u64 = 0xffffffffffffffffULL / 0ULL;
244 }
245
246 void
mod_s32(void)247 mod_s32(void)
248 {
249 s32 = -1 % (-0x7fffffff - 1);
250 s32 = -1 % 0x7fffffff;
251 /* expect+1: warning: '-2147483648 % -1' overflows 'int' [141] */
252 s32 = (-0x7fffffff - 1) % -1;
253 s32 = 0x7fffffff % -1;
254 }
255
256 void
mod_u32(void)257 mod_u32(void)
258 {
259 u64 = 0xffffffffU % -1U;
260 u64 = 0xffffffffU % 1U;
261 /* expect+1: error: modulus by 0 [140] */
262 u64 = 0U % 0U;
263 /* expect+1: error: modulus by 0 [140] */
264 u64 = 0xffffffffU % 0U;
265 }
266
267 void
mod_s64(void)268 mod_s64(void)
269 {
270 s64 = -1LL % (-0x7fffffffffffffffLL - 1LL);
271 s64 = -1LL % 0x7fffffffffffffffLL;
272 /* expect+1: warning: '-9223372036854775808 % -1' overflows 'long long' [141] */
273 s64 = (-0x7fffffffffffffffLL - 1LL) % -1LL;
274 s64 = 0x7fffffffffffffffLL % -1LL;
275 }
276
277 void
mod_u64(void)278 mod_u64(void)
279 {
280 u64 = 0xffffffffffffffffULL % -1ULL;
281 u64 = 0xffffffffffffffffULL % 1ULL;
282 /* expect+1: error: modulus by 0 [140] */
283 u64 = 0ULL % 0ULL;
284 /* expect+1: error: modulus by 0 [140] */
285 u64 = 0xffffffffffffffffULL % 0ULL;
286 }
287
288 void
plus_s32(void)289 plus_s32(void)
290 {
291 /* expect+1: warning: '-2147483647 + -2147483647' overflows 'int' [141] */
292 s32 = -0x7fffffff + -0x7fffffff;
293 /* expect+1: warning: '-2147483647 + -2' overflows 'int' [141] */
294 s32 = -0x7fffffff + -2; // INT_MIN - 1
295 /* expect+1: warning: '-2 + -2147483647' overflows 'int' [141] */
296 s32 = -2 + -0x7fffffff; // INT_MIN - 1
297 s32 = -0x7fffffff + -1; // INT_MIN
298 s32 = -1 + -0x7fffffff; // INT_MIN
299 s32 = -0x7fffffff + 0; // INT_MIN + 1
300 s32 = 0 + -0x7fffffff; // INT_MIN + 1
301 s32 = (-0x7fffffff - 1) + 0x7fffffff; // -1
302 s32 = 0x7fffffff + (-0x7fffffff - 1); // -1
303 s32 = 0x7ffffffe + 1; // INT_MAX
304 s32 = 1 + 0x7ffffffe; // INT_MAX
305 s32 = 0x7fffffff + 0; // INT_MAX
306 s32 = 0 + 0x7fffffff; // INT_MAX
307 /* expect+1: warning: '2147483647 + 1' overflows 'int' [141] */
308 s32 = 0x7fffffff + 1; // INT_MAX + 1
309 /* expect+1: warning: '1 + 2147483647' overflows 'int' [141] */
310 s32 = 1 + 0x7fffffff; // INT_MAX + 1
311 /* expect+1: warning: '1073741824 + 1073741824' overflows 'int' [141] */
312 s32 = 0x40000000 + 0x40000000; // INT_MAX + 1
313 /* expect+1: warning: '2147483647 + 2147483647' overflows 'int' [141] */
314 s32 = 0x7fffffff + 0x7fffffff;
315 }
316
317 void
plus_u32(void)318 plus_u32(void)
319 {
320 u32 = 0x00000000U + 0x00000000U;
321 u32 = 0x40000000U + 0x40000000U;
322 u32 = 0xffffffffU + 0x00000000U;
323 u32 = 0x00000000U + 0xffffffffU;
324 u32 = 0xfffffffeU + 0x00000001U;
325 /* expect+1: warning: '4294967295 + 1' overflows 'unsigned int' [141] */
326 u32 = 0xffffffffU + 0x00000001U;
327 /* expect+1: warning: '1 + 4294967295' overflows 'unsigned int' [141] */
328 u32 = 0x00000001U + 0xffffffffU;
329 /* expect+1: warning: '4294967295 + 4294967295' overflows 'unsigned int' [141] */
330 u32 = 0xffffffffU + 0xffffffffU;
331 }
332
333 void
plus_s64(void)334 plus_s64(void)
335 {
336 /* expect+1: warning: '-9223372036854775807 + -2' overflows 'long long' [141] */
337 s64 = -0x7fffffffffffffffLL + -2LL;
338 s64 = -0x7fffffffffffffffLL + -1LL;
339 s64 = 0x7ffffffffffffffeLL + 1LL;
340 /* expect+1: warning: '9223372036854775807 + 1' overflows 'long long' [141] */
341 s64 = 0x7fffffffffffffffLL + 1LL;
342 }
343
344 void
plus_u64(void)345 plus_u64(void)
346 {
347 u64 = 0x0000000000000000ULL + 0x0000000000000000ULL;
348 u64 = 0xffffffffffffffffULL + 0x0000000000000000ULL;
349 u64 = 0x0000000000000000ULL + 0xffffffffffffffffULL;
350 u64 = 0xfffffffffffffffeULL + 0x0000000000000001ULL;
351 /* expect+1: warning: '18446744073709551615 + 1' overflows 'unsigned long long' [141] */
352 u64 = 0xffffffffffffffffULL + 0x0000000000000001ULL;
353 /* expect+1: warning: '1 + 18446744073709551615' overflows 'unsigned long long' [141] */
354 u64 = 0x0000000000000001ULL + 0xffffffffffffffffULL;
355 /* expect+1: warning: '18446744073709551615 + 18446744073709551615' overflows 'unsigned long long' [141] */
356 u64 = 0xffffffffffffffffULL + 0xffffffffffffffffULL;
357 }
358
359 void
minus_s32(void)360 minus_s32(void)
361 {
362 /* expect+1: warning: '-2147483647 - 2' overflows 'int' [141] */
363 s32 = -0x7fffffff - 2;
364 s32 = -0x7fffffff - 1;
365 s32 = -0x7fffffff - 1 - 0;
366 s32 = -0x7fffffff - 1 - -1;
367 s32 = 0x7fffffff - 0x7fffffff;
368 s32 = 0x7fffffff - 1;
369 s32 = 0x7fffffff - 0;
370 /* expect+1: warning: '2147483647 - -1' overflows 'int' [141] */
371 s32 = 0x7fffffff - -1;
372 }
373
374 void
minus_u32(void)375 minus_u32(void)
376 {
377 u32 = 0x00000000U - 0x00000000U;
378 /* expect+1: warning: '0 - 1' overflows 'unsigned int' [141] */
379 u32 = 0x00000000U - 0x00000001U;
380 /* expect+1: warning: '0 - 2147483648' overflows 'unsigned int' [141] */
381 u32 = 0x00000000U - 0x80000000U;
382 u32 = 0x80000000U - 0x00000001U;
383 /* expect+1: warning: '0 - 4294967295' overflows 'unsigned int' [141] */
384 u32 = 0x00000000U - 0xffffffffU;
385 u32 = 0xffffffffU - 0x00000000U;
386 u32 = 0xffffffffU - 0xffffffffU;
387 }
388
389 void
minus_s64(void)390 minus_s64(void)
391 {
392 /* expect+1: warning: '-9223372036854775807 - 9223372036854775807' overflows 'long long' [141] */
393 s64 = -0x7fffffffffffffffLL - 0x7fffffffffffffffLL;
394 /* expect+1: warning: '-9223372036854775807 - 2' overflows 'long long' [141] */
395 s64 = -0x7fffffffffffffffLL - 2LL;
396 s64 = -0x7fffffffffffffffLL - 1LL;
397 s64 = -0x7fffffffffffffffLL - 0LL;
398 s64 = -0x7fffffffffffffffLL - -1LL;
399 s64 = 0x7fffffffffffffffLL - 1LL;
400 s64 = 0x7fffffffffffffffLL - 0LL;
401 /* expect+1: warning: '9223372036854775807 - -1' overflows 'long long' [141] */
402 s64 = 0x7fffffffffffffffLL - -1LL;
403 /* expect+1: warning: '9223372036854775807 - -9223372036854775807' overflows 'long long' [141] */
404 s64 = 0x7fffffffffffffffLL - -0x7fffffffffffffffLL;
405 }
406
407 void
minus_u64(void)408 minus_u64(void)
409 {
410 u64 = 0x0000000000000000ULL - 0x0000000000000000ULL;
411 /* expect+1: warning: '0 - 1' overflows 'unsigned long long' [141] */
412 u64 = 0x0000000000000000ULL - 0x0000000000000001ULL;
413 /* expect+1: warning: '0 - 9223372036854775808' overflows 'unsigned long long' [141] */
414 u64 = 0x0000000000000000ULL - 0x8000000000000000ULL;
415 u64 = 0x8000000000000000ULL - 0x0000000000000001ULL;
416 /* expect+1: warning: '0 - 18446744073709551615' overflows 'unsigned long long' [141] */
417 u64 = 0x0000000000000000ULL - 0xffffffffffffffffULL;
418 u64 = 0xffffffffffffffffULL - 0x0000000000000000ULL;
419 u64 = 0xffffffffffffffffULL - 0xffffffffffffffffULL;
420 }
421
422 void
shl_s32(void)423 shl_s32(void)
424 {
425 /* expect+1: warning: '256 << 23' overflows 'int' [141] */
426 s32 = 0x0100 << 23;
427 /* expect+1: warning: '256 << 24' overflows 'int' [141] */
428 s32 = 0x0100 << 24;
429 /* expect+1: warning: shift amount 18446744073709551615 is greater than bit-size 32 of 'int' [122] */
430 s32 = 0 << 0xffffffffffffffff;
431 }
432
433 void
shl_u32(void)434 shl_u32(void)
435 {
436 u32 = 0x0100U << 23;
437 /* expect+1: warning: '256 << 24' overflows 'unsigned int' [141] */
438 u32 = 0x0100U << 24;
439 /* expect+1: warning: negative shift [121] */
440 u32 = 0x0000U << -1;
441 /* expect+1: warning: shift amount 256 is greater than bit-size 32 of 'unsigned int' [122] */
442 u32 = 0x0100U << 0x0100U;
443 /* expect+1: warning: shift amount 4294967295 is greater than bit-size 32 of 'unsigned int' [122] */
444 u32 = 0x0100U << 0xffffffffU;
445 /* expect+1: warning: shift amount 18446744073709551615 is greater than bit-size 32 of 'unsigned int' [122] */
446 u32 = 0x0100U << 0xffffffffffffffffULL;
447 }
448
449 void
shl_s64(void)450 shl_s64(void)
451 {
452 s64 = 1LL << 62;
453 s64 = 1LL << 63;
454 /* expect+1: warning: shift amount 64 equals bit-size of 'long long' [267] */
455 s64 = 1LL << 64;
456 }
457
458 void
shl_u64(void)459 shl_u64(void)
460 {
461 s64 = 1ULL << 62;
462 s64 = 1ULL << 63;
463 /* expect+1: warning: shift amount 64 equals bit-size of 'unsigned long long' [267] */
464 s64 = 1ULL << 64;
465 }
466
467 void
shr_s32(void)468 shr_s32(void)
469 {
470 s32 = -0x7fffffff >> 1;
471 s32 = -10 >> 1;
472 s32 = -9 >> 1;
473 s32 = +9 >> 1;
474 s32 = +10 >> 1;
475 s32 = 0x7fffffff >> 1;
476
477 /* expect+1: error: negative array dimension (-16) [20] */
478 typedef int minus_32_shr_1[-32 >> 1];
479 /* expect+1: error: negative array dimension (-16) [20] */
480 typedef int minus_31_shr_1[-31 >> 1];
481 /* expect+1: error: negative array dimension (-15) [20] */
482 typedef int minus_30_shr_1[-30 >> 1];
483 /* expect+1: error: negative array dimension (-1) [20] */
484 typedef int minus_1_shr_1[-1 >> 31];
485 }
486
487 void
shr_u32(void)488 shr_u32(void)
489 {
490 u32 = 0xffffffffU >> 1;
491 /* expect+1: warning: shift amount 32 equals bit-size of 'unsigned int' [267] */
492 u32 = 0xffffffffU >> 32;
493 u32 = 0x00000000U >> 1;
494 }
495
496 void
shr_s64(void)497 shr_s64(void)
498 {
499 // TODO
500
501 /* expect+1: error: negative array dimension (-16) [20] */
502 typedef int minus_16_shr_0[-16LL >> 0];
503 /* expect+1: error: negative array dimension (-8) [20] */
504 typedef int minus_16_shr_1[-16LL >> 1];
505 /* expect+1: error: negative array dimension (-1) [20] */
506 typedef int minus_16_shr_16[-16LL >> 16];
507 /* expect+1: error: negative array dimension (-1) [20] */
508 typedef int minus_16_shr_40[-16LL >> 40];
509 }
510
511 void
shr_u64(void)512 shr_u64(void)
513 {
514 // TODO
515 }
516
517 void
compare_s32(void)518 compare_s32(void)
519 {
520 cond = 0x7fffffff < (-0x7fffffff - 1);
521 cond = 0x7fffffff <= (-0x7fffffff - 1);
522 cond = 0x7fffffff > (-0x7fffffff - 1);
523 cond = 0x7fffffff >= (-0x7fffffff - 1);
524 cond = 0x7fffffff == (-0x7fffffff - 1);
525 cond = 0x7fffffff != (-0x7fffffff - 1);
526 }
527
528 void
compare_u32(void)529 compare_u32(void)
530 {
531 cond = 0xffffffffU < 0x00000000U;
532 cond = 0xffffffffU <= 0x00000000U;
533 cond = 0xffffffffU > 0x00000000U;
534 cond = 0xffffffffU >= 0x00000000U;
535 cond = 0xffffffffU == 0x00000000U;
536 cond = 0xffffffffU != 0x00000000U;
537 }
538
539 void
compare_s64(void)540 compare_s64(void)
541 {
542 cond = 0x7fffffffffffffffLL < (-0x7fffffffffffffffLL - 1);
543 cond = 0x7fffffffffffffffLL <= (-0x7fffffffffffffffLL - 1);
544 cond = 0x7fffffffffffffffLL > (-0x7fffffffffffffffLL - 1);
545 cond = 0x7fffffffffffffffLL >= (-0x7fffffffffffffffLL - 1);
546 cond = 0x7fffffffffffffffLL == (-0x7fffffffffffffffLL - 1);
547 cond = 0x7fffffffffffffffLL != (-0x7fffffffffffffffLL - 1);
548 }
549
550 void
compare_u64(void)551 compare_u64(void)
552 {
553 cond = 0xffffffffffffffffULL < 0x0000000000000000ULL;
554 cond = 0xffffffffffffffffULL <= 0x0000000000000000ULL;
555 cond = 0xffffffffffffffffULL > 0x0000000000000000ULL;
556 cond = 0xffffffffffffffffULL >= 0x0000000000000000ULL;
557 cond = 0xffffffffffffffffULL == 0x0000000000000000ULL;
558 cond = 0xffffffffffffffffULL != 0x0000000000000000ULL;
559 }
560
561 void
bitand_s32(void)562 bitand_s32(void)
563 {
564 s32 = 0x55555555 & -0xff;
565 }
566
567 void
bitand_u32(void)568 bitand_u32(void)
569 {
570 u32 = 0xffffffffU & 0x55555555U;
571 u32 = 0x55555555U & 0xaaaaaaaaU;
572 }
573
574 void
bitand_s64(void)575 bitand_s64(void)
576 {
577 u64 = ~0x7fffeeeeddddccccLL & 0x1111222233334444LL;
578 }
579
580 void
bitand_u64(void)581 bitand_u64(void)
582 {
583 u64 = 0xffffeeeeddddccccULL & 0x1111222233334444ULL;
584 }
585
586 void
bitxor_s32(void)587 bitxor_s32(void)
588 {
589 s32 = 0x12345678 ^ 0x76543210;
590 }
591
592 void
bitxor_u32(void)593 bitxor_u32(void)
594 {
595 u32 = 0xffffffffU ^ 0x55555555U;
596 u32 = 0x55555555U ^ 0xaaaaaaaaU;
597 }
598
599 void
bitxor_s64(void)600 bitxor_s64(void)
601 {
602 s64 = ~0x123456789abcdef0LL ^ 0x0123456789abcdefLL;
603 }
604
605 void
bitxor_u64(void)606 bitxor_u64(void)
607 {
608 u64 = 0xfedcba9876543210ULL ^ 0x0123456789abcdefULL;
609 }
610
611 void
bitor_s32(void)612 bitor_s32(void)
613 {
614 s32 = 0x3333cccc | 0x5555aaaa;
615 }
616
617 void
bitor_u32(void)618 bitor_u32(void)
619 {
620 u32 = 0xffffffffU | 0x00000000U;
621 u32 = 0xffffffffU | 0xffffffffU;
622 u32 = 0x55555555U | 0xaaaaaaaaU;
623 }
624
625 void
bitor_s64(void)626 bitor_s64(void)
627 {
628 s64 = 0x1111222233334444LL | ~0x0000111122223333LL;
629 }
630
631 void
bitor_u64(void)632 bitor_u64(void)
633 {
634 u64 = 0x1111222233334444ULL | 0xffffeeeeddddccccULL;
635 }
636