xref: /netbsd-src/tests/usr.bin/xlint/lint1/platform_int.c (revision 4a29af3e7e781de02b66d044b90aebd888ee3694)
1*4a29af3eSrillig /*	$NetBSD: platform_int.c,v 1.6 2023/07/09 10:42:07 rillig Exp $	*/
2b6d6b0c5Srillig # 3 "platform_int.c"
3b6d6b0c5Srillig 
4b6d6b0c5Srillig /*
5b6d6b0c5Srillig  * Test features that only apply to platforms on which size_t is unsigned
6b6d6b0c5Srillig  * int and ptr_diff is signed int.
7b6d6b0c5Srillig  */
8b6d6b0c5Srillig 
9b6d6b0c5Srillig /* lint1-only-if: int */
10b2baa501Srillig /* lint1-flags: -g -w -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
convert_unsigned_char_to_size(unsigned char uc)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
20501dcc92Srillig 	 * converted to size_t, which is UINT. The portable bit size of INT
21501dcc92Srillig 	 * and UINT is the same, 32, but the signedness changes, therefore
22501dcc92Srillig 	 * the warning.
23501dcc92Srillig 	 */
24*4a29af3eSrillig 	/* expect+1: warning: argument 1 is converted from 'unsigned char' to 'unsigned int' due to prototype [259] */
25b6d6b0c5Srillig 	to_size(uc);
26b6d6b0c5Srillig }
27