expr_fold_strict_bool.c revision 1.1
1/*	$NetBSD: expr_fold_strict_bool.c,v 1.1 2021/08/22 20:56:51 rillig Exp $	*/
2# 3 "expr_fold_strict_bool.c"
3
4/*
5 * Test constant folding in strict bool mode.
6 *
7 * In this mode, _Bool is not an unsigned integer type.  In fact, it is not
8 * an arithmetic type at all.
9 */
10
11/* lint1-extra-flags: -T */
12/* lint1-only-if: lp64 */
13
14typedef long long int64_t;
15typedef unsigned long long uint64_t;
16
17struct fold_64_bit {
18
19	_Bool lt_signed_small_ok: -3LL < 1LL ? 1 : -1;
20	/* expect+1: error: illegal bit-field size: 255 [36] */
21	_Bool lt_signed_small_bad: 1LL < -3LL ? 1 : -1;
22
23	_Bool lt_signed_big_ok: (int64_t)(1ULL << 63) < 1LL ? 1 : -1;
24	/* expect+1: error: illegal bit-field size: 255 [36] */
25	_Bool lt_signed_big_bad: 1LL < (int64_t)(1ULL << 63) ? 1 : -1;
26
27	_Bool lt_unsigned_small_ok: 1ULL < 3ULL ? 1 : -1;
28	/* expect+1: error: illegal bit-field size: 255 [36] */
29	_Bool lt_unsigned_small_bad: 3ULL < 1ULL ? 1 : -1;
30
31	/* FIXME: 1 is much smaller than 1ULL << 63. */
32	/* expect+1: error: illegal bit-field size: 255 [36] */
33	_Bool lt_unsigned_big_ok: 1ULL < 1ULL << 63 ? 1 : -1;
34	_Bool lt_unsigned_big_bad: 1ULL << 63 < 1ULL ? 1 : -1;
35};
36