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 lint: move a condition into should_warn_...
details: https://anonhg.NetBSD.org/src/rev/75b85d73235b
branches: trunk
changeset: 1023304:75b85d73235b
user: rillig <rillig%NetBSD.org@localhost>
date: Thu Sep 02 16:31:01 2021 +0000
description:
lint: move a condition into should_warn_about_prototype_conversion
No functional change.
diffstat:
usr.bin/xlint/lint1/tree.c | 29 ++++++++++++-----------------
1 files changed, 12 insertions(+), 17 deletions(-)
diffs (72 lines):
diff -r ba8c2b736293 -r 75b85d73235b usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c Thu Sep 02 16:16:49 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c Thu Sep 02 16:31:01 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tree.c,v 1.366 2021/09/02 16:16:49 rillig Exp $ */
+/* $NetBSD: tree.c,v 1.367 2021/09/02 16:31:01 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.366 2021/09/02 16:16:49 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.367 2021/09/02 16:31:01 rillig Exp $");
#endif
#include <float.h>
@@ -1978,18 +1978,17 @@
return ntn;
}
-/*
- * The types differ in sign or base type (char, short, int, long, long long,
- * int128_t, float, double, long double).
- *
- * If they differ only in sign and the argument is representable in both
- * types, print no warning.
- */
static bool
should_warn_about_prototype_conversion(tspec_t nt,
tspec_t ot, const tnode_t *ptn)
{
+ if (nt == ot)
+ return false;
+
+ if (nt == ENUM && ot == INT)
+ return false;
+
if (is_floating(nt) != is_floating(ot) ||
portable_size_in_bits(nt) != portable_size_in_bits(ot)) {
/* representation and/or width change */
@@ -2014,9 +2013,9 @@
}
/*
- * Print a warning if a prototype causes a type conversion that is
- * different from what would happen to the same argument in the
- * absence of a prototype.
+ * Warn if a prototype causes a type conversion that is different from what
+ * would happen to the same argument in the absence of a prototype. This
+ * check is intended for code that needs to stay compatible with pre-C90 C.
*
* Errors/warnings about illegal type combinations are already printed
* in check_assign_types_compatible().
@@ -2039,14 +2038,10 @@
if (nt == CHAR || nt == UCHAR || nt == SHORT || nt == USHORT)
return;
- /* get default promotion */
+ /* apply the default promotion */
ptn = promote(NOOP, true, tn);
ot = ptn->tn_type->t_tspec;
- /* return if types are the same with and without prototype */
- if (nt == ot || (nt == ENUM && ot == INT))
- return;
-
if (should_warn_about_prototype_conversion(nt, ot, ptn)) {
/* argument #%d is converted from '%s' to '%s' ... */
warning(259, arg, type_name(tn->tn_type), type_name(tp));
Home |
Main Index |
Thread Index |
Old Index