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