Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/xlint/lint1 lint: in strict bool mode, check initial...



details:   https://anonhg.NetBSD.org/src/rev/6bdcbd93ad8f
branches:  trunk
changeset: 953777:6bdcbd93ad8f
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Mar 20 17:18:50 2021 +0000

description:
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.)

diffstat:

 tests/usr.bin/xlint/lint1/d_c99_bool_strict.c   |  8 ++++----
 tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp |  2 ++
 usr.bin/xlint/lint1/tree.c                      |  6 +++---
 3 files changed, 9 insertions(+), 7 deletions(-)

diffs (64 lines):

diff -r 854a51ce8b07 -r 6bdcbd93ad8f tests/usr.bin/xlint/lint1/d_c99_bool_strict.c
--- a/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c     Sat Mar 20 17:08:08 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c     Sat Mar 20 17:18:50 2021 +0000
@@ -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 @@
                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 @@
        } var[] = {
            { __lint_false },
            { __lint_true },
-           { 0 },              /* FIXME: type mismatch */
-           { 1 },              /* FIXME: type mismatch */
+           { 0 },              /* expect: 107 */
+           { 1 },              /* expect: 107 */
        };
 }
diff -r 854a51ce8b07 -r 6bdcbd93ad8f tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp
--- a/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp   Sat Mar 20 17:08:08 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp   Sat Mar 20 17:18:50 2021 +0000
@@ -163,3 +163,5 @@
 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]
diff -r 854a51ce8b07 -r 6bdcbd93ad8f usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Sat Mar 20 17:08:08 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Sat Mar 20 17:18:50 2021 +0000
@@ -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 @@
 {
        return op == ASSIGN ||
               op == ANDASS || op == XORASS || op == ORASS ||
-              op == RETURN || op == FARG;
+              op == RETURN || op == INIT || op == FARG;
 }
 
 static bool



Home | Main Index | Thread Index | Old Index