xref: /netbsd-src/tests/usr.bin/xlint/lint1/msg_252.c (revision db3c6112752d8c8c254951ed7b1eb44ec567275f)
1 /*	$NetBSD: msg_252.c,v 1.8 2024/06/08 06:42:59 rillig Exp $	*/
2 # 3 "msg_252.c"
3 
4 // Test for message: integer constant out of range [252]
5 
6 /*
7  * See also:
8  *	platform_ilp32_trad.c
9  *	platform_ilp32_c90.c
10  *	platform_ilp32_c99.c
11  *	platform_lp64_trad.c
12  *	platform_lp64_c90.c
13  *	platform_lp64_c99.c
14  */
15 
16 /*
17  * On ILP32 platforms, lint additionally and unnecessarily warns:
18  *
19  *	conversion of 'unsigned long' to 'int' is out of range [119]
20  *
21  * On an ILP32 platform, lex_integer_constant interprets this number as
22  * having type ULONG, which is stored as 'ULONG 0x0000_0000_ffff_ffff'.
23  * This number is passed to convert_constant, which calls convert_integer,
24  * which sign-extends the number to 'INT 0xffff_ffff_ffff_ffff'.  This
25  * converted number is passed to convert_constant_check_range, and at this
26  * point, v->u.integer != nv->u.integer, due to the sign extension.  This
27  * triggers an additional warning 119.
28  *
29  * On a 64-bit platform, lex_integer_constant stores the number as
30  * 'ULONG 0xffff_ffff_ffff_ffff', which has the same representation as the
31  * 'INT 0xffff_ffff_ffff_ffff', therefore no warning.
32  *
33  * Due to this unnecessary difference, disable this test on ILP32 platforms
34  * for now (2021-08-28).
35  */
36 /* lint1-only-if: lp64 */
37 
38 /* lint1-extra-flags: -X 351 */
39 
40 /* expect+1: warning: integer constant out of range [252] */
41 int constant = 1111111111111111111111111111111111111111111111111111;
42