Source-Changes-HG archive

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

[src/trunk]: src/tests/usr.bin/xlint/lint1 lint: add test for macro from syst...



details:   https://anonhg.NetBSD.org/src/rev/f3a6ec8f1753
branches:  trunk
changeset: 949835:f3a6ec8f1753
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jan 17 21:19:06 2021 +0000

description:
lint: add test for macro from system header in strict bool mode

Seen in usr.bin/make/meta.c:1670: FD_ZERO(&readfds).  These macros
cannot be fixed since system headers must not include <stdbool.h>.
Therefore INT constants should be accepted as controlling expressions as
well.

diffstat:

 tests/usr.bin/xlint/lint1/d_c99_bool_strict.c   |  25 ++++++++++++++++++++++++-
 tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp |   3 +++
 2 files changed, 27 insertions(+), 1 deletions(-)

diffs (46 lines):

diff -r dc743e85b6e6 -r f3a6ec8f1753 tests/usr.bin/xlint/lint1/d_c99_bool_strict.c
--- a/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c     Sun Jan 17 21:02:33 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c     Sun Jan 17 21:19:06 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: d_c99_bool_strict.c,v 1.15 2021/01/17 13:50:33 rillig Exp $    */
+/*     $NetBSD: d_c99_bool_strict.c,v 1.16 2021/01/17 21:19:06 rillig Exp $    */
 # 3 "d_c99_bool_strict.c"
 
 /*
@@ -727,3 +727,26 @@
 
        (void)((s.flag = s.flag) != __lint_false);
 }
+
+/*
+ * Macros from system headers that have return type bool may or may not
+ * include the '!= 0' test, that is, their result can have any scalar type.
+ */
+void
+strict_bool_system_header(void)
+{
+
+       do {
+               println("nothing");
+       } while (/*CONSTCOND*/0);       /* expect: 333 */
+
+# 744 "d_c99_bool_strict.c" 3 4
+       do {
+               println("nothing");
+       } while (/*CONSTCOND*/0);       /*TODO*//* expect: 333 */
+
+# 749 "d_c99_bool_strict.c"
+       do {
+               println("nothing");
+       } while (/*CONSTCOND*/0);       /* expect: 333 */
+}
diff -r dc743e85b6e6 -r f3a6ec8f1753 tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp
--- a/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp   Sun Jan 17 21:02:33 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp   Sun Jan 17 21:19:06 2021 +0000
@@ -146,3 +146,6 @@
 d_c99_bool_strict.c(677): operands of '=' have incompatible types (_Bool != int) [107]
 d_c99_bool_strict.c(652): warning: argument flags unused in function strict_bool_bitwise_and_enum [231]
 d_c99_bool_strict.c(716): operands of '==' have incompatible types (_Bool != int) [107]
+d_c99_bool_strict.c(741): controlling expression must be bool, not 'int' [333]
+d_c99_bool_strict.c(746): controlling expression must be bool, not 'int' [333]
+d_c99_bool_strict.c(751): controlling expression must be bool, not 'int' [333]



Home | Main Index | Thread Index | Old Index