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