Module Name:    src
Committed By:   rillig
Date:           Sat Jul  3 19:31:23 UTC 2021

Modified Files:
        src/distrib/sets/lists/tests: mi
        src/tests/usr.bin/xlint/lint1: Makefile msg_230.c msg_230.exp
Added Files:
        src/tests/usr.bin/xlint/lint1: msg_230_uchar.c msg_230_uchar.exp

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.1071 -r1.1072 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.73 -r1.74 src/tests/usr.bin/xlint/lint1/Makefile
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_230.c \
    src/tests/usr.bin/xlint/lint1/msg_230.exp
cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/xlint/lint1/msg_230_uchar.c \
    src/tests/usr.bin/xlint/lint1/msg_230_uchar.exp

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.1071 src/distrib/sets/lists/tests/mi:1.1072
--- src/distrib/sets/lists/tests/mi:1.1071	Fri Jul  2 21:52:36 2021
+++ src/distrib/sets/lists/tests/mi	Sat Jul  3 19:31:22 2021
@@ -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

Index: src/tests/usr.bin/xlint/lint1/Makefile
diff -u src/tests/usr.bin/xlint/lint1/Makefile:1.73 src/tests/usr.bin/xlint/lint1/Makefile:1.74
--- src/tests/usr.bin/xlint/lint1/Makefile:1.73	Fri Jul  2 21:52:36 2021
+++ src/tests/usr.bin/xlint/lint1/Makefile	Sat Jul  3 19:31:22 2021
@@ -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

Index: src/tests/usr.bin/xlint/lint1/msg_230.c
diff -u src/tests/usr.bin/xlint/lint1/msg_230.c:1.3 src/tests/usr.bin/xlint/lint1/msg_230.c:1.4
--- src/tests/usr.bin/xlint/lint1/msg_230.c:1.3	Sun Jan 31 11:12:07 2021
+++ src/tests/usr.bin/xlint/lint1/msg_230.c	Sat Jul  3 19:31:22 2021
@@ -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;
 }
Index: src/tests/usr.bin/xlint/lint1/msg_230.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_230.exp:1.3 src/tests/usr.bin/xlint/lint1/msg_230.exp:1.4
--- src/tests/usr.bin/xlint/lint1/msg_230.exp:1.3	Tue Jan  5 23:07:49 2021
+++ src/tests/usr.bin/xlint/lint1/msg_230.exp	Sat Jul  3 19:31:22 2021
@@ -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]

Added files:

Index: src/tests/usr.bin/xlint/lint1/msg_230_uchar.c
diff -u /dev/null src/tests/usr.bin/xlint/lint1/msg_230_uchar.c:1.1
--- /dev/null	Sat Jul  3 19:31:23 2021
+++ src/tests/usr.bin/xlint/lint1/msg_230_uchar.c	Sat Jul  3 19:31:22 2021
@@ -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;
+}
Index: src/tests/usr.bin/xlint/lint1/msg_230_uchar.exp
diff -u /dev/null src/tests/usr.bin/xlint/lint1/msg_230_uchar.exp:1.1
--- /dev/null	Sat Jul  3 19:31:23 2021
+++ src/tests/usr.bin/xlint/lint1/msg_230_uchar.exp	Sat Jul  3 19:31:22 2021
@@ -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]

Reply via email to