xref: /netbsd/tests/usr.bin/xlint/lint1/expr_binary.c (revision 9d5f3d15)
1 /*	$NetBSD: expr_binary.c,v 1.2 2021/08/01 13:45:14 rillig Exp $	*/
2 # 3 "expr_binary.c"
3 
4 /*
5  * Test binary operators, in particular the usual arithmetic conversions.
6  *
7  * C99 6.3.1.8 "Usual arithmetic conversions"
8  */
9 
10 /* lint1-extra-flags: -Ac11 */
11 /* lint1-only-if: lp64 */
12 
13 struct incompatible {		/* just to generate the error message */
14 	int member;
15 };
16 void sink(struct incompatible);
17 
18 void
19 cover_balance(void)
20 {
21 	/* expect+1: 'int' */
22 	sink(1 + '\0');
23 
24 	/* expect+1: 'int' */
25 	sink((char)'\0' + (char)'\0');
26 
27 	/* expect+1: 'float' */
28 	sink(1 + 1.0f);
29 
30 	/* expect+1: 'double' */
31 	sink(1 + 1.0);
32 
33 	/* expect+1: 'float' */
34 	sink((long long)1 + 1.0f);
35 
36 	/* expect+1: 'float' */
37 	sink((long long)1 + 1.0f);
38 
39 	/* expect+1: 'float' */
40 	sink((__uint128_t)1 + 1.0f);
41 
42 	/* expect+1: '__uint128_t' */
43 	sink((__uint128_t)1 + 1);
44 
45 	/* expect+1: '__int128_t' */
46 	sink((__int128_t)1 + 1);
47 
48 	/* expect+1: 'unsigned int' *//* FIXME */
49 	sink((__uint128_t)1 + (__int128_t)1);
50 
51 	/* expect+1: 'unsigned int' *//* FIXME */
52 	sink((__int128_t)1 + (__uint128_t)1);
53 }
54