Module Name: src
Committed By: rillig
Date: Sun Jul 4 07:50:53 UTC 2021
Modified Files:
src/distrib/sets/lists/tests: mi
src/tests/usr.bin/xlint/lint1: Makefile
Added Files:
src/tests/usr.bin/xlint/lint1: c99_bool_strict_suppressed.c
c99_bool_strict_suppressed.exp
Log Message:
tests/lint: add test for suppressing errors in strict bool mode
To generate a diff of this commit:
cvs rdiff -u -r1.1072 -r1.1073 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.74 -r1.75 src/tests/usr.bin/xlint/lint1/Makefile
cvs rdiff -u -r0 -r1.1 \
src/tests/usr.bin/xlint/lint1/c99_bool_strict_suppressed.c \
src/tests/usr.bin/xlint/lint1/c99_bool_strict_suppressed.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.1072 src/distrib/sets/lists/tests/mi:1.1073
--- src/distrib/sets/lists/tests/mi:1.1072 Sat Jul 3 19:31:22 2021
+++ src/distrib/sets/lists/tests/mi Sun Jul 4 07:50:53 2021
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1072 2021/07/03 19:31:22 rillig Exp $
+# $NetBSD: mi,v 1.1073 2021/07/04 07:50:53 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -6107,6 +6107,8 @@
./usr/tests/usr.bin/xlint/lint1/Kyuafile tests-usr.bin-tests compattestfile,atf,kyua
./usr/tests/usr.bin/xlint/lint1/c11_generic_expression.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/c11_generic_expression.exp tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/c99_bool_strict_suppressed.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/c99_bool_strict_suppressed.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/c99_init_array.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/c99_init_array.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/c99_init_designator.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.74 src/tests/usr.bin/xlint/lint1/Makefile:1.75
--- src/tests/usr.bin/xlint/lint1/Makefile:1.74 Sat Jul 3 19:31:22 2021
+++ src/tests/usr.bin/xlint/lint1/Makefile Sun Jul 4 07:50:53 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.74 2021/07/03 19:31:22 rillig Exp $
+# $NetBSD: Makefile,v 1.75 2021/07/04 07:50:53 rillig Exp $
NOMAN= # defined
MAX_MESSAGE= 345 # see lint1/err.c
@@ -12,6 +12,8 @@ TESTS_SH= t_integration
FILESDIR= ${TESTSDIR}
FILES+= c11_generic_expression.c
FILES+= c11_generic_expression.exp
+FILES+= c99_bool_strict_suppressed.c
+FILES+= c99_bool_strict_suppressed.exp
FILES+= c99_init_array.c
FILES+= c99_init_array.exp
FILES+= c99_init_designator.c
Added files:
Index: src/tests/usr.bin/xlint/lint1/c99_bool_strict_suppressed.c
diff -u /dev/null src/tests/usr.bin/xlint/lint1/c99_bool_strict_suppressed.c:1.1
--- /dev/null Sun Jul 4 07:50:53 2021
+++ src/tests/usr.bin/xlint/lint1/c99_bool_strict_suppressed.c Sun Jul 4 07:50:53 2021
@@ -0,0 +1,43 @@
+/* $NetBSD: c99_bool_strict_suppressed.c,v 1.1 2021/07/04 07:50:53 rillig Exp $ */
+# 3 "c99_bool_strict_suppressed.c"
+
+/*
+ * In strict bool mode, like everywhere else, individual errors can be
+ * suppressed. Suppressing a message affects lint's output as well as the
+ * exit status. Lint's control flow stays the same as before though.
+ *
+ * This can result in assertion failures later. One such assertion has been
+ * there since at least 1995, at the beginning of expr(), ensuring that the
+ * expression is either non-null or an error message has been _printed_.
+ * In 1995 it was not possible to suppress error messages, which means that
+ * the number of printed errors equaled the number of occurred errors.
+ *
+ * In err.c 1.12 from 2000-07-06, the option -X was added, allowing to
+ * suppress individual error messages. That commit did not mention any
+ * interaction with the assertion in expr().
+ */
+
+/* lint1-extra-flags: -T */
+/* TODO: -X 107,330,331,332,333 */
+
+/* ARGSUSED */
+void
+test(_Bool b, int i, const char *p)
+{
+
+ /* expect+1: error: controlling expression must be bool, not 'int' [333] */
+ while (1)
+ break;
+
+ /* expect+1: error: operands of '=' have incompatible types (_Bool != int) [107] */
+ b = i;
+
+ /* expect+1: error: operand of '!' must be bool, not 'int' [330] */
+ b = !i;
+
+ /* expect+1: error: left operand of '&&' must be bool, not 'int' [331] */
+ b = i && b;
+
+ /* expect+1: error: right operand of '&&' must be bool, not 'int' [332] */
+ b = b && i;
+}
Index: src/tests/usr.bin/xlint/lint1/c99_bool_strict_suppressed.exp
diff -u /dev/null src/tests/usr.bin/xlint/lint1/c99_bool_strict_suppressed.exp:1.1
--- /dev/null Sun Jul 4 07:50:53 2021
+++ src/tests/usr.bin/xlint/lint1/c99_bool_strict_suppressed.exp Sun Jul 4 07:50:53 2021
@@ -0,0 +1,5 @@
+c99_bool_strict_suppressed.c(29): error: controlling expression must be bool, not 'int' [333]
+c99_bool_strict_suppressed.c(33): error: operands of '=' have incompatible types (_Bool != int) [107]
+c99_bool_strict_suppressed.c(36): error: operand of '!' must be bool, not 'int' [330]
+c99_bool_strict_suppressed.c(39): error: left operand of '&&' must be bool, not 'int' [331]
+c99_bool_strict_suppressed.c(42): error: right operand of '&&' must be bool, not 'int' [332]