1161030Ssam/*	$NetBSD: c99_bool_strict_suppressed.c,v 1.6 2023/07/07 19:45:22 rillig Exp $	*/
2161030Ssam# 3 "c99_bool_strict_suppressed.c"
3161030Ssam
4161030Ssam/*
5161030Ssam * In strict bool mode, like everywhere else, individual errors can be
6161030Ssam * suppressed.  Suppressing a message affects lint's output as well as the
7161030Ssam * exit status.  Lint's control flow stays the same as before though.
8161030Ssam *
9161030Ssam * This can result in assertion failures later.  One such assertion has been
10161030Ssam * there since at least 1995, at the beginning of expr(), ensuring that the
11161030Ssam * expression is either non-null or an error message has been _printed_.
12161030Ssam * In 1995, it was not possible to suppress error messages, which means that
13161030Ssam * the number of printed errors equaled the number of occurred errors.
14161030Ssam *
15161030Ssam * In err.c 1.12 from 2000-07-06, the option -X was added, allowing to
16161030Ssam * suppress individual error messages.  That commit did not mention any
17161030Ssam * interaction with the assertion in expr().  The assertion was removed in
18161030Ssam * tree.c 1.305 from 2021-07-04.
19161030Ssam */
20161030Ssam
21161030Ssam/* lint1-extra-flags: -T -X 107,330,331,332,333 -X 351 */
22161030Ssam
23161030Ssam/* ARGSUSED */
24161030Ssamvoid
25161030Ssamtest(_Bool b, int i, const char *p)
26161030Ssam{
27161030Ssam
28161030Ssam	/* suppressed+1: error: controlling expression must be bool, not 'int' [333] */
29161030Ssam	while (1)
30161030Ssam		break;
31161030Ssam
32161030Ssam	/* suppressed+1: error: operands of '=' have incompatible types '_Bool' and 'int' [107] */
33161030Ssam	b = i;
34161030Ssam
35161030Ssam	/* suppressed+1: error: operand of '!' must be bool, not 'int' [330] */
36161030Ssam	b = !i;
37161030Ssam
38161030Ssam	/* suppressed+1: error: left operand of '&&' must be bool, not 'int' [331] */
39161030Ssam	b = i && b;
40161030Ssam
41161030Ssam	/* suppressed+1: error: right operand of '&&' must be bool, not 'int' [332] */
42161030Ssam	b = b && i;
43161030Ssam}
44161030Ssam