Source-Changes-HG archive

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

[src/trunk]: src lint: add tests for newly added messages for strict bool mode



details:   https://anonhg.NetBSD.org/src/rev/4b94e749ae53
branches:  trunk
changeset: 958624:4b94e749ae53
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Jan 14 22:18:13 2021 +0000

description:
lint: add tests for newly added messages for strict bool mode

diffstat:

 distrib/sets/lists/tests/mi                |  18 +++++++++++++++++-
 tests/usr.bin/xlint/lint1/Makefile         |   4 ++--
 tests/usr.bin/xlint/lint1/msg_330.c        |  22 ++++++++++++++++++++++
 tests/usr.bin/xlint/lint1/msg_330.exp      |   2 ++
 tests/usr.bin/xlint/lint1/msg_331.c        |  24 ++++++++++++++++++++++++
 tests/usr.bin/xlint/lint1/msg_331.exp      |   2 ++
 tests/usr.bin/xlint/lint1/msg_332.c        |  24 ++++++++++++++++++++++++
 tests/usr.bin/xlint/lint1/msg_332.exp      |   2 ++
 tests/usr.bin/xlint/lint1/msg_333.c        |  24 ++++++++++++++++++++++++
 tests/usr.bin/xlint/lint1/msg_333.exp      |   2 ++
 tests/usr.bin/xlint/lint1/msg_334.c        |  24 ++++++++++++++++++++++++
 tests/usr.bin/xlint/lint1/msg_334.exp      |   2 ++
 tests/usr.bin/xlint/lint1/msg_335.c        |  22 ++++++++++++++++++++++
 tests/usr.bin/xlint/lint1/msg_335.exp      |   6 ++++++
 tests/usr.bin/xlint/lint1/msg_336.c        |  21 +++++++++++++++++++++
 tests/usr.bin/xlint/lint1/msg_336.exp      |   1 +
 tests/usr.bin/xlint/lint1/msg_337.c        |  21 +++++++++++++++++++++
 tests/usr.bin/xlint/lint1/msg_337.exp      |   1 +
 tests/usr.bin/xlint/lint1/t_integration.sh |   4 ++--
 19 files changed, 221 insertions(+), 5 deletions(-)

diffs (truncated from 332 to 300 lines):

diff -r 9554dd665faa -r 4b94e749ae53 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Thu Jan 14 19:11:48 2021 +0000
+++ b/distrib/sets/lists/tests/mi       Thu Jan 14 22:18:13 2021 +0000
@@ -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
diff -r 9554dd665faa -r 4b94e749ae53 tests/usr.bin/xlint/lint1/Makefile
--- a/tests/usr.bin/xlint/lint1/Makefile        Thu Jan 14 19:11:48 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/Makefile        Thu Jan 14 22:18:13 2021 +0000
@@ -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_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.
diff -r 9554dd665faa -r 4b94e749ae53 tests/usr.bin/xlint/lint1/msg_330.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_330.c       Thu Jan 14 22:18:13 2021 +0000
@@ -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 */
+}
diff -r 9554dd665faa -r 4b94e749ae53 tests/usr.bin/xlint/lint1/msg_330.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_330.exp     Thu Jan 14 22:18:13 2021 +0000
@@ -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]
diff -r 9554dd665faa -r 4b94e749ae53 tests/usr.bin/xlint/lint1/msg_331.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_331.c       Thu Jan 14 22:18:13 2021 +0000
@@ -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);
+}
diff -r 9554dd665faa -r 4b94e749ae53 tests/usr.bin/xlint/lint1/msg_331.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_331.exp     Thu Jan 14 22:18:13 2021 +0000
@@ -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]
diff -r 9554dd665faa -r 4b94e749ae53 tests/usr.bin/xlint/lint1/msg_332.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_332.c       Thu Jan 14 22:18:13 2021 +0000
@@ -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);
+}
diff -r 9554dd665faa -r 4b94e749ae53 tests/usr.bin/xlint/lint1/msg_332.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_332.exp     Thu Jan 14 22:18:13 2021 +0000
@@ -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]
diff -r 9554dd665faa -r 4b94e749ae53 tests/usr.bin/xlint/lint1/msg_333.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_333.c       Thu Jan 14 22:18:13 2021 +0000
@@ -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;
+}
diff -r 9554dd665faa -r 4b94e749ae53 tests/usr.bin/xlint/lint1/msg_333.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_333.exp     Thu Jan 14 22:18:13 2021 +0000
@@ -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]
diff -r 9554dd665faa -r 4b94e749ae53 tests/usr.bin/xlint/lint1/msg_334.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_334.c       Thu Jan 14 22:18:13 2021 +0000
@@ -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);
+}
diff -r 9554dd665faa -r 4b94e749ae53 tests/usr.bin/xlint/lint1/msg_334.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_334.exp     Thu Jan 14 22:18:13 2021 +0000
@@ -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]
diff -r 9554dd665faa -r 4b94e749ae53 tests/usr.bin/xlint/lint1/msg_335.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_335.c       Thu Jan 14 22:18:13 2021 +0000
@@ -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 */
+}
diff -r 9554dd665faa -r 4b94e749ae53 tests/usr.bin/xlint/lint1/msg_335.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_335.exp     Thu Jan 14 22:18:13 2021 +0000
@@ -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]
diff -r 9554dd665faa -r 4b94e749ae53 tests/usr.bin/xlint/lint1/msg_336.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_336.c       Thu Jan 14 22:18:13 2021 +0000
@@ -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);
+}
diff -r 9554dd665faa -r 4b94e749ae53 tests/usr.bin/xlint/lint1/msg_336.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_336.exp     Thu Jan 14 22:18:13 2021 +0000
@@ -0,0 +1,1 @@
+msg_336.c(18): left operand of '+' must not be bool [336]
diff -r 9554dd665faa -r 4b94e749ae53 tests/usr.bin/xlint/lint1/msg_337.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_337.c       Thu Jan 14 22:18:13 2021 +0000
@@ -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



Home | Main Index | Thread Index | Old Index