xref: /netbsd-src/tests/usr.bin/xlint/lint1/platform_long.c (revision 656ffdf2e3864b68d292b6310a83df69189a876a)
1 /*	$NetBSD: platform_long.c,v 1.6 2024/11/05 04:53:28 rillig Exp $	*/
2 # 3 "platform_long.c"
3 
4 /*
5  * Test features that only apply to platforms on which size_t is unsigned
6  * long and ptr_diff is signed long.
7  */
8 
9 /* lint1-only-if: long */
10 /* lint1-extra-flags: -c -h -a -p -b -r -z -X 351 */
11 
12 void to_size(typeof(sizeof(int)));
13 
14 /* See should_warn_about_prototype_conversion. */
15 void
16 convert_unsigned_char_to_size(unsigned char uc)
17 {
18 	/*
19 	 * In this function call, uc is first promoted to INT. It is then
20 	 * converted to size_t, which is ULONG. The portable rank of INT
21 	 * (see INT_RANK in inittyp.c) is lower than the rank of ULONG.
22 	 * Since the portable rank increases, there is no warning.
23 	 *
24 	 * XXX: Investigate whether this rule makes sense. Warning 259 is
25 	 * about prototype mismatch, not about lossy integer conversions,
26 	 * and there is a clear mismatch here between INT and LONG,
27 	 * therefore a warning makes sense.
28 	 */
29 	to_size(uc);
30 }
31 
32 /* expect+1: warning: static variable 'unused_variable' unused [226] */
33 static int unused_variable;
34