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