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: don't warn about negative '>>' whe...
details: https://anonhg.NetBSD.org/src/rev/59e9403263e9
branches: trunk
changeset: 373284:59e9403263e9
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Jan 29 17:13:10 2023 +0000
description:
lint: don't warn about negative '>>' when the actual value is positive
diffstat:
tests/usr.bin/xlint/lint1/msg_117.c | 9 +++++----
usr.bin/xlint/lint1/tree.c | 8 ++++++--
2 files changed, 11 insertions(+), 6 deletions(-)
diffs (52 lines):
diff -r c93b5f3146ec -r 59e9403263e9 tests/usr.bin/xlint/lint1/msg_117.c
--- a/tests/usr.bin/xlint/lint1/msg_117.c Sun Jan 29 17:02:09 2023 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_117.c Sun Jan 29 17:13:10 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_117.c,v 1.12 2023/01/29 17:02:09 rillig Exp $ */
+/* $NetBSD: msg_117.c,v 1.13 2023/01/29 17:13:10 rillig Exp $ */
# 3 "msg_117.c"
// Test for message: bitwise '%s' on signed value possibly nonportable [117]
@@ -139,9 +139,10 @@
if (((x >> 31) & 2) != 0)
return;
- /* The result of '&' is guaranteed to be positive. */
- /* XXX: Don't warn here. */
- /* expect+1: warning: bitwise '>>' on signed value possibly nonportable [117] */
+ /*
+ * The result of '&' is guaranteed to be positive, so don't warn.
+ * Code like this typically occurs in hexdump functions.
+ */
if ((x & 0xf0) >> 4 != 0)
return;
}
diff -r c93b5f3146ec -r 59e9403263e9 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c Sun Jan 29 17:02:09 2023 +0000
+++ b/usr.bin/xlint/lint1/tree.c Sun Jan 29 17:13:10 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tree.c,v 1.501 2023/01/29 13:57:35 rillig Exp $ */
+/* $NetBSD: tree.c,v 1.502 2023/01/29 17:13:10 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
-__RCSID("$NetBSD: tree.c,v 1.501 2023/01/29 13:57:35 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.502 2023/01/29 17:13:10 rillig Exp $");
#endif
#include <float.h>
@@ -1161,6 +1161,10 @@
/* operands have integer types (checked in typeok) */
if (pflag && !is_uinteger(olt)) {
+ integer_constraints lc = ic_expr(ln);
+ if (!ic_maybe_signed(ln->tn_type, &lc))
+ return;
+
/*
* The left operand is signed. This means that
* the operation is (possibly) nonportable.
Home |
Main Index |
Thread Index |
Old Index