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: demonstrate wrong warn...



details:   https://anonhg.NetBSD.org/src/rev/e8befe8f9fe4
branches:  trunk
changeset: 989019:e8befe8f9fe4
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Oct 09 22:03:38 2021 +0000

description:
tests/lint: demonstrate wrong warning about nonportable char comparison

Seen in bin/sh/expand.c:273.

diffstat:

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

diffs (40 lines):

diff -r 0d452bc4a6c9 -r e8befe8f9fe4 tests/usr.bin/xlint/lint1/msg_230.c
--- a/tests/usr.bin/xlint/lint1/msg_230.c       Sat Oct 09 21:56:12 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_230.c       Sat Oct 09 22:03:38 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg_230.c,v 1.9 2021/10/09 21:56:12 rillig Exp $       */
+/*     $NetBSD: msg_230.c,v 1.10 2021/10/09 22:03:38 rillig Exp $      */
 # 3 "msg_230.c"
 
 // Test for message: nonportable character comparison '%s %d' [230]
@@ -112,3 +112,21 @@
        if (c >= 129)
                return;
 }
+
+void
+compare_with_character_literal(char ch)
+{
+       /*
+        * FIXME: These comparisons are portable since the character constant
+        *  is interpreted using the type 'char' on the exact same platform
+        *  as where the comparison takes place.
+        */
+       /* expect+1: warning: nonportable character comparison '== -128' [230] */
+       if (ch == '\200')
+               return;
+       /* expect+1: warning: nonportable character comparison '== -1' [230] */
+       if (ch == '\377')
+               return;
+       if (ch == '\000')
+               return;
+}
diff -r 0d452bc4a6c9 -r e8befe8f9fe4 tests/usr.bin/xlint/lint1/msg_230.exp
--- a/tests/usr.bin/xlint/lint1/msg_230.exp     Sat Oct 09 21:56:12 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_230.exp     Sat Oct 09 22:03:38 2021 +0000
@@ -16,3 +16,5 @@
 msg_230.c(105): warning: nonportable character comparison '>= 128' [230]
 msg_230.c(109): warning: nonportable character comparison '> 128' [230]
 msg_230.c(112): warning: nonportable character comparison '>= 129' [230]
+msg_230.c(125): warning: nonportable character comparison '== -128' [230]
+msg_230.c(128): warning: nonportable character comparison '== -1' [230]



Home | Main Index | Thread Index | Old Index