Module Name:    src
Committed By:   rillig
Date:           Sun Jan 17 21:19:06 UTC 2021

Modified Files:
        src/tests/usr.bin/xlint/lint1: d_c99_bool_strict.c
            d_c99_bool_strict.exp

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c
cvs rdiff -u -r1.13 -r1.14 \
    src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c
diff -u src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c:1.15 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c:1.16
--- src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c:1.15	Sun Jan 17 13:50:33 2021
+++ src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c	Sun Jan 17 21:19:06 2021
@@ -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 @@ strict_bool_assign_bit_field_then_compar
 
 	(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 */
+}

Index: src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp
diff -u src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp:1.13 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp:1.14
--- src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp:1.13	Sun Jan 17 13:50:33 2021
+++ src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp	Sun Jan 17 21:19:06 2021
@@ -146,3 +146,6 @@ d_c99_bool_strict.c(670): operands of '=
 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]

Reply via email to