Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/usr.bin/xlint/lint1 tests/lint: test wrong warning for...



details:   https://anonhg.NetBSD.org/src/rev/02d84b2bf57f
branches:  trunk
changeset: 985469:02d84b2bf57f
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Aug 27 17:49:31 2021 +0000

description:
tests/lint: test wrong warning for bitwise '>>'

Seen in /usr/include/netbt/hci.h, function hci_filter_set.

diffstat:

 tests/usr.bin/xlint/lint1/msg_117.c   |  16 +++++++++++++++-
 tests/usr.bin/xlint/lint1/msg_117.exp |   1 +
 2 files changed, 16 insertions(+), 1 deletions(-)

diffs (35 lines):

diff -r 6acbc2fc8cbf -r 02d84b2bf57f tests/usr.bin/xlint/lint1/msg_117.c
--- a/tests/usr.bin/xlint/lint1/msg_117.c       Fri Aug 27 17:41:39 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_117.c       Fri Aug 27 17:49:31 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg_117.c,v 1.7 2021/08/15 13:08:20 rillig Exp $       */
+/*     $NetBSD: msg_117.c,v 1.8 2021/08/27 17:49:31 rillig Exp $       */
 # 3 "msg_117.c"
 
 // Test for message: bitwise '%s' on signed value possibly nonportable [117]
@@ -45,3 +45,17 @@
         */
        return uc >> 4;
 }
+
+unsigned char
+shr_unsigned_char_promoted(unsigned char bit)
+{
+       /*
+        * Before TODO from TODO, lint wrongly warned that the bitwise shift
+        * might be on a signed value, which was wrong.  Even though the
+        * expression has type 'int', the value of the expression cannot be
+        * negative, as long as int is larger than char, which holds for all
+        * platforms supported by lint.
+        */
+       /* expect+1: warning: bitwise '>>' on signed value possibly nonportable [117] */
+       return (unsigned char)((bit - 1) >> 5);
+}
diff -r 6acbc2fc8cbf -r 02d84b2bf57f tests/usr.bin/xlint/lint1/msg_117.exp
--- a/tests/usr.bin/xlint/lint1/msg_117.exp     Fri Aug 27 17:41:39 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_117.exp     Fri Aug 27 17:49:31 2021 +0000
@@ -4,3 +4,4 @@
 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(60): warning: bitwise '>>' on signed value possibly nonportable [117]



Home | Main Index | Thread Index | Old Index