Source-Changes-HG archive

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

[src/trunk]: src tests/lint: add test for suppressing errors in strict bool mode



details:   https://anonhg.NetBSD.org/src/rev/9eb0f1ecb62b
branches:  trunk
changeset: 1022093:9eb0f1ecb62b
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jul 04 07:50:53 2021 +0000

description:
tests/lint: add test for suppressing errors in strict bool mode

diffstat:

 distrib/sets/lists/tests/mi                              |   4 +-
 tests/usr.bin/xlint/lint1/Makefile                       |   4 +-
 tests/usr.bin/xlint/lint1/c99_bool_strict_suppressed.c   |  43 ++++++++++++++++
 tests/usr.bin/xlint/lint1/c99_bool_strict_suppressed.exp |   5 +
 4 files changed, 54 insertions(+), 2 deletions(-)

diffs (92 lines):

diff -r bce58d0183e4 -r 9eb0f1ecb62b distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Sun Jul 04 07:09:39 2021 +0000
+++ b/distrib/sets/lists/tests/mi       Sun Jul 04 07:50:53 2021 +0000
@@ -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
diff -r bce58d0183e4 -r 9eb0f1ecb62b tests/usr.bin/xlint/lint1/Makefile
--- a/tests/usr.bin/xlint/lint1/Makefile        Sun Jul 04 07:09:39 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/Makefile        Sun Jul 04 07:50:53 2021 +0000
@@ -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 @@
 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
diff -r bce58d0183e4 -r 9eb0f1ecb62b tests/usr.bin/xlint/lint1/c99_bool_strict_suppressed.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/c99_bool_strict_suppressed.c    Sun Jul 04 07:50:53 2021 +0000
@@ -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;
+}
diff -r bce58d0183e4 -r 9eb0f1ecb62b tests/usr.bin/xlint/lint1/c99_bool_strict_suppressed.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/c99_bool_strict_suppressed.exp  Sun Jul 04 07:50:53 2021 +0000
@@ -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]



Home | Main Index | Thread Index | Old Index