Module Name: src
Committed By: rillig
Date: Thu Jan 14 22:18:14 UTC 2021
Modified Files:
src/distrib/sets/lists/tests: mi
src/tests/usr.bin/xlint/lint1: Makefile t_integration.sh
Added Files:
src/tests/usr.bin/xlint/lint1: msg_330.c msg_330.exp msg_331.c
msg_331.exp msg_332.c msg_332.exp msg_333.c msg_333.exp msg_334.c
msg_334.exp msg_335.c msg_335.exp msg_336.c msg_336.exp msg_337.c
msg_337.exp
Log Message:
lint: add tests for newly added messages for strict bool mode
To generate a diff of this commit:
cvs rdiff -u -r1.1010 -r1.1011 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.28 -r1.29 src/tests/usr.bin/xlint/lint1/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/xlint/lint1/msg_330.c \
src/tests/usr.bin/xlint/lint1/msg_330.exp \
src/tests/usr.bin/xlint/lint1/msg_331.c \
src/tests/usr.bin/xlint/lint1/msg_331.exp \
src/tests/usr.bin/xlint/lint1/msg_332.c \
src/tests/usr.bin/xlint/lint1/msg_332.exp \
src/tests/usr.bin/xlint/lint1/msg_333.c \
src/tests/usr.bin/xlint/lint1/msg_333.exp \
src/tests/usr.bin/xlint/lint1/msg_334.c \
src/tests/usr.bin/xlint/lint1/msg_334.exp \
src/tests/usr.bin/xlint/lint1/msg_335.c \
src/tests/usr.bin/xlint/lint1/msg_335.exp \
src/tests/usr.bin/xlint/lint1/msg_336.c \
src/tests/usr.bin/xlint/lint1/msg_336.exp \
src/tests/usr.bin/xlint/lint1/msg_337.c \
src/tests/usr.bin/xlint/lint1/msg_337.exp
cvs rdiff -u -r1.25 -r1.26 src/tests/usr.bin/xlint/lint1/t_integration.sh
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.1010 src/distrib/sets/lists/tests/mi:1.1011
--- src/distrib/sets/lists/tests/mi:1.1010 Sun Jan 10 18:06:38 2021
+++ src/distrib/sets/lists/tests/mi Thu Jan 14 22:18:13 2021
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1010 2021/01/10 18:06:38 rillig Exp $
+# $NetBSD: mi,v 1.1011 2021/01/14 22:18:13 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -6481,6 +6481,22 @@
./usr/tests/usr.bin/xlint/lint1/msg_328.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/msg_329.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/msg_329.exp tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_330.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_330.exp tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_331.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_331.exp tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_332.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_332.exp tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_333.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_333.exp tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_334.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_334.exp tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_335.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_335.exp tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_336.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_336.exp tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_337.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_337.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/t_integration tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/ztest tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/ztest/Atffile tests-usr.bin-tests compattestfile,atf
Index: src/tests/usr.bin/xlint/lint1/Makefile
diff -u src/tests/usr.bin/xlint/lint1/Makefile:1.28 src/tests/usr.bin/xlint/lint1/Makefile:1.29
--- src/tests/usr.bin/xlint/lint1/Makefile:1.28 Sun Jan 10 18:06:38 2021
+++ src/tests/usr.bin/xlint/lint1/Makefile Thu Jan 14 22:18:14 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.28 2021/01/10 18:06:38 rillig Exp $
+# $NetBSD: Makefile,v 1.29 2021/01/14 22:18:14 rillig Exp $
NOMAN= # defined
@@ -89,7 +89,7 @@ FILES+= d_type_question_colon.c
FILES+= d_typefun.c
FILES+= d_typename_as_var.c
FILES+= d_zero_sized_arrays.c
-FILES+= ${:U0 ${:U:range=329}:C,^.$,0&,:C,^..$,0&,:@msg@msg_${msg}.c msg_${msg}.exp@}
+FILES+= ${:U0 ${:U:range=337}:C,^.$,0&,:C,^..$,0&,:@msg@msg_${msg}.c msg_${msg}.exp@}
# Note: only works for adding tests.
# To remove a test, the $$mi file must be edited manually.
Index: src/tests/usr.bin/xlint/lint1/t_integration.sh
diff -u src/tests/usr.bin/xlint/lint1/t_integration.sh:1.25 src/tests/usr.bin/xlint/lint1/t_integration.sh:1.26
--- src/tests/usr.bin/xlint/lint1/t_integration.sh:1.25 Sun Jan 10 21:26:12 2021
+++ src/tests/usr.bin/xlint/lint1/t_integration.sh Thu Jan 14 22:18:14 2021
@@ -1,4 +1,4 @@
-# $NetBSD: t_integration.sh,v 1.25 2021/01/10 21:26:12 rillig Exp $
+# $NetBSD: t_integration.sh,v 1.26 2021/01/14 22:18:14 rillig Exp $
#
# Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -182,7 +182,7 @@ all_messages_body() {
srcdir="$(atf_get_srcdir)"
ok="true"
- for msg in $(seq 0 329); do
+ for msg in $(seq 0 337); do
base="$(printf '%s/msg_%03d' "${srcdir}" "${msg}")"
flags="$(extract_flags "${base}.c")"
Added files:
Index: src/tests/usr.bin/xlint/lint1/msg_330.c
diff -u /dev/null src/tests/usr.bin/xlint/lint1/msg_330.c:1.1
--- /dev/null Thu Jan 14 22:18:14 2021
+++ src/tests/usr.bin/xlint/lint1/msg_330.c Thu Jan 14 22:18:14 2021
@@ -0,0 +1,22 @@
+/* $NetBSD: msg_330.c,v 1.1 2021/01/14 22:18:14 rillig Exp $ */
+# 3 "msg_330.c"
+
+// Test for message: operand of '%s' must be bool, not '%s' [330]
+//
+// See d_c99_bool_strict.c for many more examples.
+
+/* lint1-extra-flags: -T */
+
+typedef _Bool bool;
+
+void
+called(bool);
+
+/*ARGSUSED*/
+void
+example(bool b, char c, int i)
+{
+ called(!b);
+ called(!c); /* expect: 330 */
+ called(!i); /* expect: 330 */
+}
Index: src/tests/usr.bin/xlint/lint1/msg_330.exp
diff -u /dev/null src/tests/usr.bin/xlint/lint1/msg_330.exp:1.1
--- /dev/null Thu Jan 14 22:18:14 2021
+++ src/tests/usr.bin/xlint/lint1/msg_330.exp Thu Jan 14 22:18:14 2021
@@ -0,0 +1,2 @@
+msg_330.c(20): operand of '!' must be bool, not 'char' [330]
+msg_330.c(21): operand of '!' must be bool, not 'int' [330]
Index: src/tests/usr.bin/xlint/lint1/msg_331.c
diff -u /dev/null src/tests/usr.bin/xlint/lint1/msg_331.c:1.1
--- /dev/null Thu Jan 14 22:18:14 2021
+++ src/tests/usr.bin/xlint/lint1/msg_331.c Thu Jan 14 22:18:14 2021
@@ -0,0 +1,24 @@
+/* $NetBSD: msg_331.c,v 1.1 2021/01/14 22:18:14 rillig Exp $ */
+# 3 "msg_331.c"
+
+// Test for message: left operand of '%s' must be bool, not '%s' [331]
+//
+// See d_c99_bool_strict.c for many more examples.
+
+/* lint1-extra-flags: -T */
+
+typedef _Bool bool;
+
+void
+test(bool);
+
+void
+example(bool b, char c, int i)
+{
+ test(b && b);
+ test(c && b); /* expect: 331 */
+ test(i && b); /* expect: 331 */
+
+ test(c != '\0');
+ test(i != 0);
+}
Index: src/tests/usr.bin/xlint/lint1/msg_331.exp
diff -u /dev/null src/tests/usr.bin/xlint/lint1/msg_331.exp:1.1
--- /dev/null Thu Jan 14 22:18:14 2021
+++ src/tests/usr.bin/xlint/lint1/msg_331.exp Thu Jan 14 22:18:14 2021
@@ -0,0 +1,2 @@
+msg_331.c(19): left operand of '&&' must be bool, not 'char' [331]
+msg_331.c(20): left operand of '&&' must be bool, not 'int' [331]
Index: src/tests/usr.bin/xlint/lint1/msg_332.c
diff -u /dev/null src/tests/usr.bin/xlint/lint1/msg_332.c:1.1
--- /dev/null Thu Jan 14 22:18:14 2021
+++ src/tests/usr.bin/xlint/lint1/msg_332.c Thu Jan 14 22:18:14 2021
@@ -0,0 +1,24 @@
+/* $NetBSD: msg_332.c,v 1.1 2021/01/14 22:18:14 rillig Exp $ */
+# 3 "msg_332.c"
+
+// Test for message: right operand of '%s' must be bool, not '%s' [332]
+//
+// See d_c99_bool_strict.c for many more examples.
+
+/* lint1-extra-flags: -T */
+
+typedef _Bool bool;
+
+void
+test(bool);
+
+void
+example(bool b, char c, int i)
+{
+ test(b && b);
+ test(b && c); /* expect: 332 */
+ test(b && i); /* expect: 332 */
+
+ test(c != '\0');
+ test(i != 0);
+}
Index: src/tests/usr.bin/xlint/lint1/msg_332.exp
diff -u /dev/null src/tests/usr.bin/xlint/lint1/msg_332.exp:1.1
--- /dev/null Thu Jan 14 22:18:14 2021
+++ src/tests/usr.bin/xlint/lint1/msg_332.exp Thu Jan 14 22:18:14 2021
@@ -0,0 +1,2 @@
+msg_332.c(19): right operand of '&&' must be bool, not 'char' [332]
+msg_332.c(20): right operand of '&&' must be bool, not 'int' [332]
Index: src/tests/usr.bin/xlint/lint1/msg_333.c
diff -u /dev/null src/tests/usr.bin/xlint/lint1/msg_333.c:1.1
--- /dev/null Thu Jan 14 22:18:14 2021
+++ src/tests/usr.bin/xlint/lint1/msg_333.c Thu Jan 14 22:18:14 2021
@@ -0,0 +1,24 @@
+/* $NetBSD: msg_333.c,v 1.1 2021/01/14 22:18:14 rillig Exp $ */
+# 3 "msg_333.c"
+
+// Test for message: controlling expression must be bool, not '%s' [333]
+//
+// See d_c99_bool_strict.c for many more examples.
+
+/* lint1-extra-flags: -T */
+
+typedef _Bool bool;
+
+const char *
+example(bool b, int i, const char *p)
+{
+ if (b)
+ return "bool";
+ if (i) /* expect: 333 */
+ return "int";
+ if (p) /* expect: 333 */
+ return "pointer";
+ if (0)
+ return "constant int or bool";
+ return p + i;
+}
Index: src/tests/usr.bin/xlint/lint1/msg_333.exp
diff -u /dev/null src/tests/usr.bin/xlint/lint1/msg_333.exp:1.1
--- /dev/null Thu Jan 14 22:18:14 2021
+++ src/tests/usr.bin/xlint/lint1/msg_333.exp Thu Jan 14 22:18:14 2021
@@ -0,0 +1,2 @@
+msg_333.c(17): controlling expression must be bool, not 'int' [333]
+msg_333.c(19): controlling expression must be bool, not 'pointer' [333]
Index: src/tests/usr.bin/xlint/lint1/msg_334.c
diff -u /dev/null src/tests/usr.bin/xlint/lint1/msg_334.c:1.1
--- /dev/null Thu Jan 14 22:18:14 2021
+++ src/tests/usr.bin/xlint/lint1/msg_334.c Thu Jan 14 22:18:14 2021
@@ -0,0 +1,24 @@
+/* $NetBSD: msg_334.c,v 1.1 2021/01/14 22:18:14 rillig Exp $ */
+# 3 "msg_334.c"
+
+// Test for message: argument #%d expects '%s', gets passed '%s' [334]
+//
+// See d_c99_bool_strict.c for many more examples.
+
+/* lint1-extra-flags: -T */
+
+typedef _Bool bool;
+
+void
+test_bool(bool);
+void
+test_int(int);
+
+void
+caller(bool b, int i)
+{
+ test_bool(b);
+ test_bool(i); /* expect: 334 */
+ test_int(b); /* expect: 334 */
+ test_int(i);
+}
Index: src/tests/usr.bin/xlint/lint1/msg_334.exp
diff -u /dev/null src/tests/usr.bin/xlint/lint1/msg_334.exp:1.1
--- /dev/null Thu Jan 14 22:18:14 2021
+++ src/tests/usr.bin/xlint/lint1/msg_334.exp Thu Jan 14 22:18:14 2021
@@ -0,0 +1,2 @@
+msg_334.c(21): argument #1 expects '_Bool', gets passed 'int' [334]
+msg_334.c(22): argument #1 expects 'int', gets passed '_Bool' [334]
Index: src/tests/usr.bin/xlint/lint1/msg_335.c
diff -u /dev/null src/tests/usr.bin/xlint/lint1/msg_335.c:1.1
--- /dev/null Thu Jan 14 22:18:14 2021
+++ src/tests/usr.bin/xlint/lint1/msg_335.c Thu Jan 14 22:18:14 2021
@@ -0,0 +1,22 @@
+/* $NetBSD: msg_335.c,v 1.1 2021/01/14 22:18:14 rillig Exp $ */
+# 3 "msg_335.c"
+
+// Test for message: operand of '%s' must not be bool [335]
+//
+// See d_c99_bool_strict.c for many more examples.
+
+/* lint1-extra-flags: -T */
+
+typedef _Bool bool;
+
+void
+example(bool b)
+{
+ b = +b; /* expect: 335 */
+ b = -b; /* expect: 335 */
+ b = !b;
+ b++; /* expect: 335 */
+ ++b; /* expect: 335 */
+ b--; /* expect: 335 */
+ --b; /* expect: 335 */
+}
Index: src/tests/usr.bin/xlint/lint1/msg_335.exp
diff -u /dev/null src/tests/usr.bin/xlint/lint1/msg_335.exp:1.1
--- /dev/null Thu Jan 14 22:18:14 2021
+++ src/tests/usr.bin/xlint/lint1/msg_335.exp Thu Jan 14 22:18:14 2021
@@ -0,0 +1,6 @@
+msg_335.c(15): operand of '+' must not be bool [335]
+msg_335.c(16): operand of '-' must not be bool [335]
+msg_335.c(18): operand of 'x++' must not be bool [335]
+msg_335.c(19): operand of '++x' must not be bool [335]
+msg_335.c(20): operand of 'x--' must not be bool [335]
+msg_335.c(21): operand of '--x' must not be bool [335]
Index: src/tests/usr.bin/xlint/lint1/msg_336.c
diff -u /dev/null src/tests/usr.bin/xlint/lint1/msg_336.c:1.1
--- /dev/null Thu Jan 14 22:18:14 2021
+++ src/tests/usr.bin/xlint/lint1/msg_336.c Thu Jan 14 22:18:14 2021
@@ -0,0 +1,21 @@
+/* $NetBSD: msg_336.c,v 1.1 2021/01/14 22:18:14 rillig Exp $ */
+# 3 "msg_336.c"
+
+// Test for message: left operand of '%s' must not be bool [336]
+//
+// See d_c99_bool_strict.c for many more examples.
+
+/* lint1-extra-flags: -T */
+
+typedef _Bool bool;
+
+void
+test(bool);
+
+void
+example(bool b, int i)
+{
+ test(b + i); /* expect: 336 */
+ test(b);
+ test(i != 0);
+}
Index: src/tests/usr.bin/xlint/lint1/msg_336.exp
diff -u /dev/null src/tests/usr.bin/xlint/lint1/msg_336.exp:1.1
--- /dev/null Thu Jan 14 22:18:14 2021
+++ src/tests/usr.bin/xlint/lint1/msg_336.exp Thu Jan 14 22:18:14 2021
@@ -0,0 +1 @@
+msg_336.c(18): left operand of '+' must not be bool [336]
Index: src/tests/usr.bin/xlint/lint1/msg_337.c
diff -u /dev/null src/tests/usr.bin/xlint/lint1/msg_337.c:1.1
--- /dev/null Thu Jan 14 22:18:14 2021
+++ src/tests/usr.bin/xlint/lint1/msg_337.c Thu Jan 14 22:18:14 2021
@@ -0,0 +1,21 @@
+/* $NetBSD: msg_337.c,v 1.1 2021/01/14 22:18:14 rillig Exp $ */
+# 3 "msg_337.c"
+
+// Test for message: right operand of '%s' must not be bool [337]
+//
+// See d_c99_bool_strict.c for many more examples.
+
+/* lint1-extra-flags: -T */
+
+typedef _Bool bool;
+
+void
+test(bool);
+
+void
+example(bool b, int i)
+{
+ test(i + b); /* expect: 337 */
+ test(b);
+ test(i != 0);
+}
Index: src/tests/usr.bin/xlint/lint1/msg_337.exp
diff -u /dev/null src/tests/usr.bin/xlint/lint1/msg_337.exp:1.1
--- /dev/null Thu Jan 14 22:18:14 2021
+++ src/tests/usr.bin/xlint/lint1/msg_337.exp Thu Jan 14 22:18:14 2021
@@ -0,0 +1 @@
+msg_337.c(18): right operand of '+' must not be bool [337]