c99_bool_strict_suppressed.c revision 1.6
1/* $NetBSD: c99_bool_strict_suppressed.c,v 1.6 2023/07/07 19:45:22 rillig Exp $ */ 2# 3 "c99_bool_strict_suppressed.c" 3 4/* 5 * In strict bool mode, like everywhere else, individual errors can be 6 * suppressed. Suppressing a message affects lint's output as well as the 7 * exit status. Lint's control flow stays the same as before though. 8 * 9 * This can result in assertion failures later. One such assertion has been 10 * there since at least 1995, at the beginning of expr(), ensuring that the 11 * expression is either non-null or an error message has been _printed_. 12 * In 1995, it was not possible to suppress error messages, which means that 13 * the number of printed errors equaled the number of occurred errors. 14 * 15 * In err.c 1.12 from 2000-07-06, the option -X was added, allowing to 16 * suppress individual error messages. That commit did not mention any 17 * interaction with the assertion in expr(). The assertion was removed in 18 * tree.c 1.305 from 2021-07-04. 19 */ 20 21/* lint1-extra-flags: -T -X 107,330,331,332,333 -X 351 */ 22 23/* ARGSUSED */ 24void 25test(_Bool b, int i, const char *p) 26{ 27 28 /* suppressed+1: error: controlling expression must be bool, not 'int' [333] */ 29 while (1) 30 break; 31 32 /* suppressed+1: error: operands of '=' have incompatible types '_Bool' and 'int' [107] */ 33 b = i; 34 35 /* suppressed+1: error: operand of '!' must be bool, not 'int' [330] */ 36 b = !i; 37 38 /* suppressed+1: error: left operand of '&&' must be bool, not 'int' [331] */ 39 b = i && b; 40 41 /* suppressed+1: error: right operand of '&&' must be bool, not 'int' [332] */ 42 b = b && i; 43} 44