Module Name:    src
Committed By:   rillig
Date:           Sat Mar 20 17:18:50 UTC 2021

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

Log Message:
lint: in strict bool mode, check initialization as well

C99 6.7.8p11 says for initialization that "the same type constraints and
conversions as for simple assignments apply", so actually apply them.
(I had just forgotten this "operator" when I first implemented strict
bool mode.)


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c
cvs rdiff -u -r1.19 -r1.20 \
    src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp
cvs rdiff -u -r1.237 -r1.238 src/usr.bin/xlint/lint1/tree.c

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.23 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c:1.24
--- src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c:1.23	Sat Mar 20 17:08:08 2021
+++ src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c	Sat Mar 20 17:18:50 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: d_c99_bool_strict.c,v 1.23 2021/03/20 17:08:08 rillig Exp $	*/
+/*	$NetBSD: d_c99_bool_strict.c,v 1.24 2021/03/20 17:18:50 rillig Exp $	*/
 # 3 "d_c99_bool_strict.c"
 
 /*
@@ -218,7 +218,7 @@ strict_bool_bit_fields_operand_conversio
 		bool bit_field: 1;
 	};
 
-	struct s s = { 0 };
+	struct s s = { 0 > 0 };
 
 	s.ordinary = s.ordinary | s.ordinary;
 	s.bit_field = s.bit_field | s.bit_field;
@@ -765,7 +765,7 @@ initialization(void)
 	} var[] = {
 	    { __lint_false },
 	    { __lint_true },
-	    { 0 },		/* FIXME: type mismatch */
-	    { 1 },		/* FIXME: type mismatch */
+	    { 0 },		/* expect: 107 */
+	    { 1 },		/* expect: 107 */
 	};
 }

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.19 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp:1.20
--- src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp:1.19	Sat Feb 20 18:55:10 2021
+++ src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp	Sat Mar 20 17:18:50 2021
@@ -163,3 +163,5 @@ d_c99_bool_strict.c(716): operands of '=
 d_c99_bool_strict.c(728): warning: expression has null effect [129]
 d_c99_bool_strict.c(740): right operand of '+' must not be bool [337]
 d_c99_bool_strict.c(757): warning: constant in conditional context [161]
+d_c99_bool_strict.c(768): operands of 'init' have incompatible types (_Bool != int) [107]
+d_c99_bool_strict.c(769): operands of 'init' have incompatible types (_Bool != int) [107]

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.237 src/usr.bin/xlint/lint1/tree.c:1.238
--- src/usr.bin/xlint/lint1/tree.c:1.237	Fri Mar 19 08:21:26 2021
+++ src/usr.bin/xlint/lint1/tree.c	Sat Mar 20 17:18:50 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.237 2021/03/19 08:21:26 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.238 2021/03/20 17:18:50 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.237 2021/03/19 08:21:26 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.238 2021/03/20 17:18:50 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -1112,7 +1112,7 @@ is_assignment_bool_or_other(op_t op)
 {
 	return op == ASSIGN ||
 	       op == ANDASS || op == XORASS || op == ORASS ||
-	       op == RETURN || op == FARG;
+	       op == RETURN || op == INIT || op == FARG;
 }
 
 static bool

Reply via email to