summaryrefslogtreecommitdiff
path: root/tests/usr.bin/xlint/lint1/platform_long.c
blob: 9be41273ae51420b17e641a52b69c09698df0815 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*	$NetBSD: platform_long.c,v 1.5 2023/03/28 14:44:35 rillig Exp $	*/
# 3 "platform_long.c"

/*
 * Test features that only apply to platforms on which size_t is unsigned
 * long and ptr_diff is signed long.
 */

/* lint1-only-if: long */
/* lint1-extra-flags: -c -h -a -p -b -r -z -X 351 */

void to_size(typeof(sizeof(int)));

/* See should_warn_about_prototype_conversion. */
void
convert_unsigned_char_to_size(unsigned char uc)
{
	/*
	 * In this function call, uc is first promoted to INT. It is then
	 * converted to size_t, which is ULONG. The portable bit size of INT
	 * is 24 (see INT_RSIZE in inittyp.c), which is less than the 32 of
	 * ULONG. Since the portable bit size increases from 24 to 32, there
	 * is no warning.
	 *
	 * XXX: Investigate whether this rule makes sense. Warning 259 is
	 * about prototype mismatch, not about lossy integer conversions,
	 * and there is a clear mismatch here between INT and LONG,
	 * therefore a warning makes sense.
	 */
	to_size(uc);
}

/* expect+1: warning: static variable 'unused_variable' unused [226] */
static int unused_variable;