Source-Changes-HG archive

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

[src/trunk]: src tests/lint: fix test for character comparison on macppc



details:   https://anonhg.NetBSD.org/src/rev/e1d5182165c6
branches:  trunk
changeset: 380049:e1d5182165c6
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Jul 03 19:31:22 2021 +0000

description:
tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.

diffstat:

 distrib/sets/lists/tests/mi                 |   4 ++-
 tests/usr.bin/xlint/lint1/Makefile          |   4 ++-
 tests/usr.bin/xlint/lint1/msg_230.c         |  26 ++++++++++++++-------
 tests/usr.bin/xlint/lint1/msg_230.exp       |   6 ++--
 tests/usr.bin/xlint/lint1/msg_230_uchar.c   |  35 +++++++++++++++++++++++++++++
 tests/usr.bin/xlint/lint1/msg_230_uchar.exp |   4 +++
 6 files changed, 65 insertions(+), 14 deletions(-)

diffs (140 lines):

diff -r 6d30a8767dd4 -r e1d5182165c6 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Sat Jul 03 19:18:55 2021 +0000
+++ b/distrib/sets/lists/tests/mi       Sat Jul 03 19:31:22 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1071 2021/07/02 21:52:36 rillig Exp $
+# $NetBSD: mi,v 1.1072 2021/07/03 19:31:22 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -6702,6 +6702,8 @@
 ./usr/tests/usr.bin/xlint/lint1/msg_229.exp                    tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/msg_230.c                      tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/msg_230.exp                    tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_230_uchar.c                        tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_230_uchar.exp              tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/msg_231.c                      tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/msg_231.exp                    tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/msg_232.c                      tests-usr.bin-tests     compattestfile,atf
diff -r 6d30a8767dd4 -r e1d5182165c6 tests/usr.bin/xlint/lint1/Makefile
--- a/tests/usr.bin/xlint/lint1/Makefile        Sat Jul 03 19:18:55 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/Makefile        Sat Jul 03 19:31:22 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.73 2021/07/02 21:52:36 rillig Exp $
+# $NetBSD: Makefile,v 1.74 2021/07/03 19:31:22 rillig Exp $
 
 NOMAN=         # defined
 MAX_MESSAGE=   345             # see lint1/err.c
@@ -143,6 +143,8 @@ FILES+=             lex_wide_char.exp
 FILES+=                lex_wide_string.c
 FILES+=                lex_wide_string.exp
 FILES+=                ${:U0 ${:U:${:Urange=${MAX_MESSAGE}}}:C,^.$,0&,:C,^..$,0&,:@i@msg_${i}.c msg_${i}.exp@:Nmsg_176.exp}
+FILES+=                msg_230_uchar.c
+FILES+=                msg_230_uchar.exp
 FILES+=                msg_259_ilp32.c
 FILES+=                msg_259_ilp32.exp
 FILES+=                op_colon.c
diff -r 6d30a8767dd4 -r e1d5182165c6 tests/usr.bin/xlint/lint1/msg_230.c
--- a/tests/usr.bin/xlint/lint1/msg_230.c       Sat Jul 03 19:18:55 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_230.c       Sat Jul 03 19:31:22 2021 +0000
@@ -1,16 +1,20 @@
-/*     $NetBSD: msg_230.c,v 1.3 2021/01/31 11:12:07 rillig Exp $       */
+/*     $NetBSD: msg_230.c,v 1.4 2021/07/03 19:31:22 rillig Exp $       */
 # 3 "msg_230.c"
 
 // Test for message: nonportable character comparison, op %s [230]
 
 /* lint1-flags: -S -g -p -w */
+/* lint1-only-if schar */
 
 void example(char c, unsigned char uc, signed char sc)
 {
        if (c < 0)
-               if (uc < 0)                     /* expect: 162 */
-                       if (sc < 0)
-                               return;
+               return;
+       /* expect+1: warning: comparison of unsigned char with 0, op < [162] */
+       if (uc < 0)
+               return;
+       if (sc < 0)
+               return;
 
        /*
         * XXX: The comparison "<= -1" looks very similar to "< 0",
@@ -18,9 +22,13 @@ void example(char c, unsigned char uc, s
         *
         * The comparisons may actually differ subtly because of the usual
         * arithmetic promotions.
-        * */
-       if (c <= -1)                            /* expect: 230 */
-               if (uc <= -1)                   /* expect: 162 */
-                       if (sc <= -1)
-                               return;
+        */
+       /* expect+1: warning: nonportable character comparison, op <= [230] */
+       if (c <= -1)
+               return;
+       /* expect+1: warning: comparison of unsigned char with negative constant, op <= [162] */
+       if (uc <= -1)
+               return;
+       if (sc <= -1)
+               return;
 }
diff -r 6d30a8767dd4 -r e1d5182165c6 tests/usr.bin/xlint/lint1/msg_230.exp
--- a/tests/usr.bin/xlint/lint1/msg_230.exp     Sat Jul 03 19:18:55 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_230.exp     Sat Jul 03 19:31:22 2021 +0000
@@ -1,3 +1,3 @@
-msg_230.c(11): warning: comparison of unsigned char with 0, op < [162]
-msg_230.c(22): warning: nonportable character comparison, op <= [230]
-msg_230.c(23): warning: comparison of unsigned char with negative constant, op <= [162]
+msg_230.c(14): warning: comparison of unsigned char with 0, op < [162]
+msg_230.c(27): warning: nonportable character comparison, op <= [230]
+msg_230.c(30): warning: comparison of unsigned char with negative constant, op <= [162]
diff -r 6d30a8767dd4 -r e1d5182165c6 tests/usr.bin/xlint/lint1/msg_230_uchar.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_230_uchar.c Sat Jul 03 19:31:22 2021 +0000
@@ -0,0 +1,35 @@
+/*     $NetBSD: msg_230_uchar.c,v 1.1 2021/07/03 19:31:22 rillig Exp $ */
+# 3 "msg_230_uchar.c"
+
+// Test for message: nonportable character comparison, op %s [230]
+
+/* lint1-flags: -S -g -p -w */
+/* lint1-only-if uchar */
+
+void example(char c, unsigned char uc, signed char sc)
+{
+       /* expect+1: warning: comparison of char with 0, op < [162] */
+       if (c < 0)
+               return;
+       /* expect+1: warning: comparison of unsigned char with 0, op < [162] */
+       if (uc < 0)
+               return;
+       if (sc < 0)
+               return;
+
+       /*
+        * XXX: The comparison "<= -1" looks very similar to "< 0",
+        * nevertheless "< 0" does not generate a warning.
+        *
+        * The comparisons may actually differ subtly because of the usual
+        * arithmetic promotions.
+        * */
+       /* expect+1: warning: nonportable character comparison, op <= [230] */
+       if (c <= -1)
+               return;
+       /* expect+1: warning: comparison of unsigned char with negative constant, op <= [162] */
+       if (uc <= -1)
+               return;
+       if (sc <= -1)
+               return;
+}
diff -r 6d30a8767dd4 -r e1d5182165c6 tests/usr.bin/xlint/lint1/msg_230_uchar.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_230_uchar.exp       Sat Jul 03 19:31:22 2021 +0000
@@ -0,0 +1,4 @@
+msg_230_uchar.c(12): warning: comparison of char with 0, op < [162]
+msg_230_uchar.c(15): warning: comparison of unsigned char with 0, op < [162]
+msg_230_uchar.c(28): warning: nonportable character comparison, op <= [230]
+msg_230_uchar.c(31): warning: comparison of unsigned char with negative constant, op <= [162]



Home | Main Index | Thread Index | Old Index