Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/xlint/lint1 tests/lint: explain difference between i...
details: https://anonhg.NetBSD.org/src/rev/9be10dcd696c
branches: trunk
changeset: 1023793:9be10dcd696c
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Sep 26 14:52:37 2021 +0000
description:
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.
diffstat:
tests/usr.bin/xlint/lint1/platform_int.c | 9 ++++++++-
tests/usr.bin/xlint/lint1/platform_int.exp | 2 +-
tests/usr.bin/xlint/lint1/platform_long.c | 16 ++++++++++++++--
tests/usr.bin/xlint/lint1/platform_long.exp | 2 +-
usr.bin/xlint/lint1/tree.c | 8 ++++++--
5 files changed, 30 insertions(+), 7 deletions(-)
diffs (100 lines):
diff -r f53fbdf48025 -r 9be10dcd696c tests/usr.bin/xlint/lint1/platform_int.c
--- a/tests/usr.bin/xlint/lint1/platform_int.c Sun Sep 26 14:32:02 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/platform_int.c Sun Sep 26 14:52:37 2021 +0000
@@ -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);
}
diff -r f53fbdf48025 -r 9be10dcd696c tests/usr.bin/xlint/lint1/platform_int.exp
--- a/tests/usr.bin/xlint/lint1/platform_int.exp Sun Sep 26 14:32:02 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/platform_int.exp Sun Sep 26 14:52:37 2021 +0000
@@ -1,1 +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]
diff -r f53fbdf48025 -r 9be10dcd696c tests/usr.bin/xlint/lint1/platform_long.c
--- a/tests/usr.bin/xlint/lint1/platform_long.c Sun Sep 26 14:32:02 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/platform_long.c Sun Sep 26 14:52:37 2021 +0000
@@ -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);
}
diff -r f53fbdf48025 -r 9be10dcd696c tests/usr.bin/xlint/lint1/platform_long.exp
--- a/tests/usr.bin/xlint/lint1/platform_long.exp Sun Sep 26 14:32:02 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/platform_long.exp Sun Sep 26 14:52:37 2021 +0000
@@ -1,1 +1,1 @@
-platform_long.c(22): warning: static variable unused_variable unused [226]
+platform_long.c(34): warning: static variable unused_variable unused [226]
diff -r f53fbdf48025 -r 9be10dcd696c usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c Sun Sep 26 14:32:02 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c Sun Sep 26 14:52:37 2021 +0000
@@ -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 @@
/* 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);
}
Home |
Main Index |
Thread Index |
Old Index