Module Name: src Committed By: rillig Date: Sat Feb 20 18:55:10 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: do not warn about 'do { ... } while (false)' in strict bool mode To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c cvs rdiff -u -r1.18 -r1.19 \ src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp cvs rdiff -u -r1.210 -r1.211 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.20 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c:1.21 --- src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c:1.20 Sat Feb 20 18:52:58 2021 +++ src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c Sat Feb 20 18:55:10 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: d_c99_bool_strict.c,v 1.20 2021/02/20 18:52:58 rillig Exp $ */ +/* $NetBSD: d_c99_bool_strict.c,v 1.21 2021/02/20 18:55:10 rillig Exp $ */ # 3 "d_c99_bool_strict.c" /* @@ -746,7 +746,7 @@ do_while_false(void) { do { - } while (__lint_false); /*FIXME*//* expect: 161 */ + } while (__lint_false); } void 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.18 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.18 Sat Feb 20 18:52:58 2021 +++ src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp Sat Feb 20 18:55:10 2021 @@ -162,5 +162,4 @@ d_c99_bool_strict.c(652): warning: argum d_c99_bool_strict.c(716): operands of '==' have incompatible types (_Bool != int) [107] 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(749): warning: constant in conditional context [161] d_c99_bool_strict.c(757): warning: constant in conditional context [161] Index: src/usr.bin/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.210 src/usr.bin/xlint/lint1/tree.c:1.211 --- src/usr.bin/xlint/lint1/tree.c:1.210 Sat Feb 20 16:34:57 2021 +++ src/usr.bin/xlint/lint1/tree.c Sat Feb 20 18:55:10 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.210 2021/02/20 16:34:57 rillig Exp $ */ +/* $NetBSD: tree.c,v 1.211 2021/02/20 18:55:10 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.210 2021/02/20 16:34:57 rillig Exp $"); +__RCSID("$NetBSD: tree.c,v 1.211 2021/02/20 18:55:10 rillig Exp $"); #endif #include <float.h> @@ -3727,6 +3727,13 @@ constant(tnode_t *tn, bool required) return v; } +static bool +is_constcond_false(const tnode_t *tn, tspec_t t) +{ + return (t == BOOL || t == INT) && + tn->tn_op == CON && tn->tn_val->v_quad == 0; +} + /* * Perform some tests on expressions which can't be done in build() and * functions called by build(). These tests must be done here because @@ -3758,7 +3765,7 @@ expr(tnode_t *tn, bool vctx, bool tctx, } else if (tn->tn_op == CON) { if (hflag && tctx && !constcond_flag && !(constcond_zero_ok && - is_int_constant_zero(tn, tn->tn_type->t_tspec))) + is_constcond_false(tn, tn->tn_type->t_tspec))) /* constant in conditional context */ warning(161); }