Module Name: src
Committed By: rillig
Date: Sun Aug 15 13:08:20 UTC 2021
Modified Files:
src/tests/usr.bin/xlint/lint1: msg_117.c msg_117.exp
src/usr.bin/xlint/lint1: tree.c
Log Message:
lint: fix wrong warning about 'unsigned char >> constant'
To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/msg_117.c
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/msg_117.exp
cvs rdiff -u -r1.334 -r1.335 src/usr.bin/xlint/lint1/tree.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/usr.bin/xlint/lint1/msg_117.c
diff -u src/tests/usr.bin/xlint/lint1/msg_117.c:1.6 src/tests/usr.bin/xlint/lint1/msg_117.c:1.7
--- src/tests/usr.bin/xlint/lint1/msg_117.c:1.6 Sun Aug 15 13:02:20 2021
+++ src/tests/usr.bin/xlint/lint1/msg_117.c Sun Aug 15 13:08:20 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_117.c,v 1.6 2021/08/15 13:02:20 rillig Exp $ */
+/* $NetBSD: msg_117.c,v 1.7 2021/08/15 13:08:20 rillig Exp $ */
# 3 "msg_117.c"
// Test for message: bitwise '%s' on signed value possibly nonportable [117]
@@ -38,7 +38,10 @@ shr_rhs_constant_negative(int a)
unsigned int
shr_unsigned_char(unsigned char uc)
{
- /* FIXME: This value cannot actually be negative. */
- /* expect+1: warning: bitwise '>>' on signed value possibly nonportable [117] */
+ /*
+ * Even though 'uc' is promoted to 'int', it cannot be negative.
+ * Before tree.c 1.335 from 2021-08-15, lint wrongly warned that
+ * 'uc >> 4' might be a bitwise '>>' on signed value.
+ */
return uc >> 4;
}
Index: src/tests/usr.bin/xlint/lint1/msg_117.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_117.exp:1.5 src/tests/usr.bin/xlint/lint1/msg_117.exp:1.6
--- src/tests/usr.bin/xlint/lint1/msg_117.exp:1.5 Sun Aug 15 13:02:20 2021
+++ src/tests/usr.bin/xlint/lint1/msg_117.exp Sun Aug 15 13:08:20 2021
@@ -4,4 +4,3 @@ msg_117.c(29): warning: bitwise '>>' on
msg_117.c(29): warning: shift amount 4660 is greater than bit-size 32 of 'int' [122]
msg_117.c(35): warning: bitwise '>>' on signed value possibly nonportable [117]
msg_117.c(35): warning: negative shift [121]
-msg_117.c(43): warning: bitwise '>>' on signed value possibly nonportable [117]
Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.334 src/usr.bin/xlint/lint1/tree.c:1.335
--- src/usr.bin/xlint/lint1/tree.c:1.334 Sat Aug 14 13:00:55 2021
+++ src/usr.bin/xlint/lint1/tree.c Sun Aug 15 13:08:19 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: tree.c,v 1.334 2021/08/14 13:00:55 rillig Exp $ */
+/* $NetBSD: tree.c,v 1.335 2021/08/15 13:08:19 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.334 2021/08/14 13:00:55 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.335 2021/08/15 13:08:19 rillig Exp $");
#endif
#include <float.h>
@@ -849,7 +849,7 @@ typeok_shr(const mod_t *mp,
ort = before_conversion(rn)->tn_type->t_tspec;
/* operands have integer types (checked above) */
- if (pflag && !is_uinteger(lt)) {
+ if (pflag && !is_uinteger(olt)) {
/*
* The left operand is signed. This means that
* the operation is (possibly) nonportable.