tests/lint: explain difference between i386 and sparc for 259
Seen in usr.bin/make/cond.c 1.278 from 2021-09-21, line 800, the call to is_token, where unsigned char gets converted to unsigned int or unsigned long, depending on the platform.
This commit is contained in:
parent
37daf3edb4
commit
501dcc9296
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: platform_int.c,v 1.2 2021/09/26 14:28:22 rillig Exp $ */
|
||||
/* $NetBSD: platform_int.c,v 1.3 2021/09/26 14:52:37 rillig Exp $ */
|
||||
# 3 "platform_int.c"
|
||||
|
||||
/*
|
||||
|
@ -11,9 +11,16 @@
|
|||
|
||||
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 UINT. The portable bit size of INT
|
||||
* and UINT is the same, 32, but the signedness changes, therefore
|
||||
* the warning.
|
||||
*/
|
||||
/* expect+1: warning: argument #1 is converted from 'unsigned char' to 'unsigned int' due to prototype [259] */
|
||||
to_size(uc);
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
platform_int.c(18): warning: argument #1 is converted from 'unsigned char' to 'unsigned int' due to prototype [259]
|
||||
platform_int.c(25): warning: argument #1 is converted from 'unsigned char' to 'unsigned int' due to prototype [259]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: platform_long.c,v 1.2 2021/09/26 14:28:22 rillig Exp $ */
|
||||
/* $NetBSD: platform_long.c,v 1.3 2021/09/26 14:52:37 rillig Exp $ */
|
||||
# 3 "platform_long.c"
|
||||
|
||||
/*
|
||||
|
@ -11,10 +11,22 @@
|
|||
|
||||
void to_size(typeof(sizeof(int)));
|
||||
|
||||
/* See should_warn_about_prototype_conversion. */
|
||||
void
|
||||
convert_unsigned_char_to_size(unsigned char uc)
|
||||
{
|
||||
/* no warning, unlike in platform_int */
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
platform_long.c(22): warning: static variable unused_variable unused [226]
|
||||
platform_long.c(34): warning: static variable unused_variable unused [226]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: tree.c,v 1.382 2021/09/18 10:46:17 jmcneill Exp $ */
|
||||
/* $NetBSD: tree.c,v 1.383 2021/09/26 14:52:37 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
|
@ -37,7 +37,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(__RCSID) && !defined(lint)
|
||||
__RCSID("$NetBSD: tree.c,v 1.382 2021/09/18 10:46:17 jmcneill Exp $");
|
||||
__RCSID("$NetBSD: tree.c,v 1.383 2021/09/26 14:52:37 rillig Exp $");
|
||||
#endif
|
||||
|
||||
#include <float.h>
|
||||
|
@ -2035,6 +2035,10 @@ should_warn_about_prototype_conversion(tspec_t nt,
|
|||
/* representation and/or width change */
|
||||
if (!is_integer(ot))
|
||||
return true;
|
||||
/*
|
||||
* XXX: Investigate whether this rule makes sense; see
|
||||
* tests/usr.bin/xlint/lint1/platform_long.c.
|
||||
*/
|
||||
return portable_size_in_bits(ot) > portable_size_in_bits(INT);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue