blob: c0dda3b31d7001c9501d9ad7ece1b534f69415d0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
/* $NetBSD: expr_binary_trad.c,v 1.3 2023/03/28 14:44:34 rillig Exp $ */
# 3 "expr_binary_trad.c"
/*
* Test binary operators in traditional C.
*/
/* lint1-flags: -tw -X 351 */
struct incompatible { /* just to generate the error message */
int member;
};
struct incompatible sink;
/*
* Test the usual arithmetic conversions.
*
* C99 6.3.1.8 "Usual arithmetic conversions"
*/
void
cover_balance()
{
/* expect+1: ... 'pointer to char' ... */
sink = (char *)0 + 0;
/* expect+1: ... 'pointer to char' ... */
sink = 0 + (char *)0;
/* expect+1: ... 'int' ... */
sink = 1 + 1;
/* expect+1: ... 'double' ... */
sink = 0.0 + 0;
/* expect+1: ... 'double' ... */
sink = 0 + 0.0;
/* expect+1: ... 'double' ... */
sink = 0.0 + (float)0.0;
/* expect+1: ... 'double' ... */
sink = (float)0.0 + 0.0;
/*
* In traditional C, 'float' gets promoted to 'double' before
* applying the usual arithmetic conversions; see 'promote'.
*/
/* expect+1: ... 'double' ... */
sink = (float)0.0 + 0;
/* expect+1: ... 'double' ... */
sink = 0 + (float)0.0;
/* expect+1: ... 'unsigned long' ... */
sink = (unsigned long)0 + 0;
/* expect+1: ... 'unsigned long' ... */
sink = 0 + (unsigned long)0;
/* expect+1: ... 'unsigned long' ... */
sink = (unsigned long)0 + (long)0;
/* expect+1: ... 'unsigned long' ... */
sink = (long)0 + (unsigned long)0;
/*
* In traditional C, if one of the operands is unsigned, the result
* is unsigned as well.
*/
/* expect+1: ... 'unsigned long' ... */
sink = (unsigned)0 + (long)0;
}
|