c99_bool_strict_suppressed.c revision 1.2
1/*	$NetBSD: c99_bool_strict_suppressed.c,v 1.2 2021/07/04 08:19:06 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().
18 */
19
20/* lint1-extra-flags: -T -X 107,330,331,332,333 */
21
22/* ARGSUSED */
23void
24test(_Bool b, int i, const char *p)
25{
26
27	/* expect+1: error: controlling expression must be bool, not 'int' [333] */
28	while (1)
29		break;
30
31	/* expect+1: error: operands of '=' have incompatible types (_Bool != int) [107] */
32	b = i;
33
34	/* expect+1: error: operand of '!' must be bool, not 'int' [330] */
35	b = !i;
36
37	/* expect+1: error: left operand of '&&' must be bool, not 'int' [331] */
38	b = i && b;
39
40	/* expect+1: error: right operand of '&&' must be bool, not 'int' [332] */
41	b = b && i;
42}
43