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