Module Name: src Committed By: rillig Date: Sat Feb 20 18:49:27 UTC 2021
Modified Files: src/tests/usr.bin/xlint/lint1: d_c99_bool_strict.c d_c99_bool_strict.exp Log Message: lint: enable heuristics in test for strict bool mode This is a preparation for allowing 'do { ... } while (false)', in addition to the commonly used 'do { ... } while (0)', without declaring the controlling expression /*CONSTCOND*/. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c cvs rdiff -u -r1.16 -r1.17 \ 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.18 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c:1.19 --- src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c:1.18 Sat Feb 20 18:02:58 2021 +++ src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c Sat Feb 20 18:49:26 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: d_c99_bool_strict.c,v 1.18 2021/02/20 18:02:58 rillig Exp $ */ +/* $NetBSD: d_c99_bool_strict.c,v 1.19 2021/02/20 18:49:26 rillig Exp $ */ # 3 "d_c99_bool_strict.c" /* @@ -97,7 +97,7 @@ * __lint_false and true to __lint_true, two predefined constant expressions. */ -/* lint1-extra-flags: -T */ +/* lint1-extra-flags: -hT */ /* * strict-bool-typedef @@ -130,10 +130,10 @@ strict_bool_constant(void) enum strict_bool_constant_expressions { /* Ok: __lint_false is a boolean constant expression. */ - FALSE = __lint_false ? 100 : 101, + FALSE = __lint_false ? 100 : 101, /* expect: 161 */ /* Ok: __lint_true is a boolean constant expression. */ - TRUE = __lint_true ? 100 : 101, + TRUE = __lint_true ? 100 : 101, /* expect: 161 */ /* Not ok: an integer is not a boolean constant expression. */ INT0 = 0 ? 100 : 101, /* expect: 331 */ @@ -159,13 +159,13 @@ enum strict_bool_constant_expressions { UNARY_PLUS = (+0) ? 100 : 101, /* expect: 331 */ /* The main operator '>' has return type bool. */ - Q1 = (13 > 12) ? 100 : 101, + Q1 = (13 > 12) ? 100 : 101, /* expect: 161 */ /* * The parenthesized expression has type int and thus cannot be * used as the controlling expression in the '?:' operator. */ - Q2 = (13 > 12 ? 1 : 7) ? 100 : 101, /* expect: 331 */ + Q2 = (13 > 12 ? 1 : 7) ? 100 : 101, /* expect: 161, 331 */ BINAND_BOOL = __lint_false & __lint_true, /* expect: 55 */ BINAND_INT = 0 & 1, @@ -176,10 +176,10 @@ enum strict_bool_constant_expressions { BINOR_BOOL = __lint_false | __lint_true, /* expect: 55 */ BINOR_INT = 0 | 1, - LOGOR_BOOL = __lint_false || __lint_true, /* expect: 55 */ + LOGOR_BOOL = __lint_false || __lint_true, /* expect: 161, 55 */ LOGOR_INT = 0 || 1, /* expect: 331, 332 */ - LOGAND_BOOL = __lint_false && __lint_true, /* expect: 55 */ + LOGAND_BOOL = __lint_false && __lint_true, /* expect: 161, 55 */ LOGAND_INT = 0 && 1, /* expect: 331, 332 */ }; @@ -363,10 +363,10 @@ strict_bool_conversion_from_bool_to_scal void strict_bool_controlling_expression(bool b, int i, double d, const void *p) { - if (__lint_false) + if (__lint_false) /* expect: 161 */ do_nothing(); - if (__lint_true) + if (__lint_true) /* expect: 161 */ do_nothing(); if (b) @@ -415,8 +415,8 @@ strict_bool_operand_unary_not(void) b = !b; b = !!!b; - b = !__lint_false; - b = !__lint_true; + b = !__lint_false; /* expect: 161, 239 */ + b = !__lint_true; /* expect: 161, 239 */ int i = 0; @@ -579,8 +579,8 @@ strict_bool_operand_binary_all(bool b, u bool strict_bool_operand_binary_comma(bool b, int i) { - b = (b, !b); - i = (i, i + 1); + b = (b, !b); /* expect: 129 */ + i = (i, i + 1); /* expect: 129 */ return b; } @@ -725,7 +725,7 @@ strict_bool_assign_bit_field_then_compar struct s s = { __lint_false }; - (void)((s.flag = s.flag) != __lint_false); + (void)((s.flag = s.flag) != __lint_false); /* expect: 129 */ } 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.16 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp:1.17 --- src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp:1.16 Sat Feb 20 18:02:58 2021 +++ src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp Sat Feb 20 18:49:26 2021 @@ -1,19 +1,25 @@ d_c99_bool_strict.c(126): argument #1 expects '_Bool', gets passed 'int' [334] d_c99_bool_strict.c(127): argument #1 expects '_Bool', gets passed 'int' [334] d_c99_bool_strict.c(128): argument #1 expects '_Bool', gets passed 'int' [334] +d_c99_bool_strict.c(133): warning: constant in conditional context [161] +d_c99_bool_strict.c(136): warning: constant in conditional context [161] d_c99_bool_strict.c(139): left operand of '?' must be bool, not 'int' [331] d_c99_bool_strict.c(142): left operand of '?' must be bool, not 'int' [331] d_c99_bool_strict.c(145): left operand of '?' must be bool, not 'int' [331] d_c99_bool_strict.c(148): left operand of '?' must be bool, not 'int' [331] d_c99_bool_strict.c(158): left operand of '?' must be bool, not 'int' [331] d_c99_bool_strict.c(159): left operand of '?' must be bool, not 'int' [331] +d_c99_bool_strict.c(162): warning: constant in conditional context [161] +d_c99_bool_strict.c(168): warning: constant in conditional context [161] d_c99_bool_strict.c(168): left operand of '?' must be bool, not 'int' [331] d_c99_bool_strict.c(170): integral constant expression expected [55] d_c99_bool_strict.c(173): integral constant expression expected [55] d_c99_bool_strict.c(176): integral constant expression expected [55] +d_c99_bool_strict.c(179): warning: constant in conditional context [161] d_c99_bool_strict.c(179): integral constant expression expected [55] d_c99_bool_strict.c(180): left operand of '||' must be bool, not 'int' [331] d_c99_bool_strict.c(180): right operand of '||' must be bool, not 'int' [332] +d_c99_bool_strict.c(182): warning: constant in conditional context [161] d_c99_bool_strict.c(182): integral constant expression expected [55] d_c99_bool_strict.c(183): left operand of '&&' must be bool, not 'int' [331] d_c99_bool_strict.c(183): right operand of '&&' must be bool, not 'int' [332] @@ -48,12 +54,18 @@ d_c99_bool_strict.c(352): operands of '= d_c99_bool_strict.c(353): operands of '=' have incompatible types (double != _Bool) [107] d_c99_bool_strict.c(354): operands of '=' have incompatible types (pointer != _Bool) [107] d_c99_bool_strict.c(344): warning: argument b unused in function strict_bool_conversion_from_bool_to_scalar [231] +d_c99_bool_strict.c(366): warning: constant in conditional context [161] +d_c99_bool_strict.c(369): warning: constant in conditional context [161] d_c99_bool_strict.c(375): controlling expression must be bool, not 'int' [333] d_c99_bool_strict.c(378): controlling expression must be bool, not 'int' [333] d_c99_bool_strict.c(381): controlling expression must be bool, not 'int' [333] d_c99_bool_strict.c(385): controlling expression must be bool, not 'int' [333] d_c99_bool_strict.c(391): controlling expression must be bool, not 'double' [333] d_c99_bool_strict.c(397): controlling expression must be bool, not 'pointer' [333] +d_c99_bool_strict.c(418): warning: constant in conditional context [161] +d_c99_bool_strict.c(418): warning: constant argument to NOT [239] +d_c99_bool_strict.c(419): warning: constant in conditional context [161] +d_c99_bool_strict.c(419): warning: constant argument to NOT [239] d_c99_bool_strict.c(423): operand of '!' must be bool, not 'int' [330] d_c99_bool_strict.c(424): operand of '!' must be bool, not 'int' [330] d_c99_bool_strict.c(425): operand of '!' must be bool, not 'int' [330] @@ -128,6 +140,8 @@ d_c99_bool_strict.c(572): left operand o d_c99_bool_strict.c(573): right operand of '>>' must not be bool [337] d_c99_bool_strict.c(575): operands of ':' have incompatible types (_Bool != unsigned int) [107] d_c99_bool_strict.c(576): operands of ':' have incompatible types (unsigned int != _Bool) [107] +d_c99_bool_strict.c(582): warning: expression has null effect [129] +d_c99_bool_strict.c(583): warning: expression has null effect [129] d_c99_bool_strict.c(596): operands of '=' have incompatible types (char != _Bool) [107] d_c99_bool_strict.c(597): operands of '=' have incompatible types (int != _Bool) [107] d_c99_bool_strict.c(598): operands of '=' have incompatible types (double != _Bool) [107] @@ -146,4 +160,5 @@ 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(728): warning: expression has null effect [129] d_c99_bool_strict.c(740): right operand of '+' must not be bool [337]