blob: a443b1f4e2c26027c7dc2ebc003bd77b89e05f89 (
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
/* $NetBSD: expr_binary.c,v 1.7 2023/03/28 14:44:34 rillig Exp $ */
# 3 "expr_binary.c"
/*
* Test binary operators.
*/
/* lint1-only-if: lp64 */
/* lint1-extra-flags: -X 351 */
struct incompatible { /* just to generate the error message */
int member;
};
void sink(struct incompatible);
/*
* Test the usual arithmetic conversions.
*
* C99 6.3.1.8 "Usual arithmetic conversions"
*/
void
cover_balance(void)
{
/* expect+1: ... 'pointer to void' ... */
sink((void *)0 + 0);
/* expect+1: ... 'pointer to void' ... */
sink(0 + (void *)0);
/* expect+1: ... 'int' ... */
sink(1 + 1);
/* expect+1: ... 'const int' ... */
sink((const int)1 + (volatile int)1);
/* expect+1: ... 'volatile int' ... */
sink((volatile int)1 + (const int)1);
long double _Complex cldbl = 0.0;
double _Complex cdbl = 0.0;
float _Complex cflt = 0.0f;
/* expect+1: error: invalid type for _Complex [308] */
_Complex invalid = 0.0;
/* expect+1: ... 'long double _Complex' ... */
sink(cldbl + 0);
/* expect+1: ... 'long double _Complex' ... */
sink(0 + cldbl);
/* expect+1: ... 'long double _Complex' ... */
sink(cldbl + cdbl);
/* expect+1: ... 'long double _Complex' ... */
sink(cdbl + cldbl);
/* expect+1: ... 'double _Complex' ... */
sink(cdbl + 0);
/* expect+1: ... 'double _Complex' ... */
sink(0 + cdbl);
/* expect+1: ... 'double _Complex' ... */
sink(cdbl + cflt);
/* expect+1: ... 'double _Complex' ... */
sink(cflt + cdbl);
/* expect+1: ... 'float _Complex' ... */
sink(cflt + 0);
/* expect+1: ... 'float _Complex' ... */
sink(0 + cflt);
/* expect+1: ... 'float _Complex' ... */
sink(cflt + (__uint128_t)0);
/* expect+1: ... 'float _Complex' ... */
sink((__uint128_t)0 + cflt);
/*
* The type specifier '_Complex' is only used during parsing, it does
* not make it to the expression.
*/
/* expect+1: ... 'double _Complex' ... */
sink(invalid + 0);
/* expect+1: ... 'long double' ... */
sink(0.0L + 0);
/* expect+1: ... 'long double' ... */
sink(0 + 0.0L);
/* expect+1: ... 'long double' ... */
sink(0.0L + 0.0);
/* expect+1: ... 'long double' ... */
sink(0.0 + 0.0L);
/* expect+1: ... 'double' ... */
sink(0.0 + 0);
/* expect+1: ... 'double' ... */
sink(0 + 0.0);
/* expect+1: ... 'double' ... */
sink(0.0 + 0.0f);
/* expect+1: ... 'double' ... */
sink(0.0f + 0.0);
/* expect+1: ... 'float' ... */
sink(0.0f + 0);
/* expect+1: ... 'float' ... */
sink(0 + 0.0f);
/* expect+1: ... 'float' ... */
sink(0.0f + (__uint128_t)0);
/* expect+1: ... 'float' ... */
sink((__uint128_t)0 + 0.0f);
/* expect+1: ... 'unsigned long long' ... */
sink(0ULL + 0);
/* expect+1: ... 'unsigned long long' ... */
sink(0 + 0ULL);
/* expect+1: ... 'unsigned long long' ... */
sink(0ULL + 0LL);
/* expect+1: ... 'unsigned long long' ... */
sink(0LL + 0ULL);
/* If the bit-width is the same, prefer the unsigned variant. */
/* expect+1: ... 'unsigned long long' ... */
sink(0UL + 0LL);
/* expect+1: ... 'unsigned long long' ... */
sink(0LL + 0UL);
/*
* Ensure that __int128_t is listed in the integer ranks. This table
* only becomes relevant when both operands have the same width.
*/
/* expect+1: ... '__uint128_t' ... */
sink((__uint128_t)1 + (__int128_t)1);
/* expect+1: ... '__uint128_t' ... */
sink((__int128_t)1 + (__uint128_t)1);
}
|