Home | History | Annotate | Line # | Download | only in lint1
      1  1.6  rillig /*	$NetBSD: c99_bool_strict_suppressed.c,v 1.6 2023/07/07 19:45:22 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.4  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.4  rillig  * interaction with the assertion in expr().  The assertion was removed in
     18  1.4  rillig  * tree.c 1.305 from 2021-07-04.
     19  1.1  rillig  */
     20  1.1  rillig 
     21  1.6  rillig /* lint1-extra-flags: -T -X 107,330,331,332,333 -X 351 */
     22  1.1  rillig 
     23  1.1  rillig /* ARGSUSED */
     24  1.1  rillig void
     25  1.1  rillig test(_Bool b, int i, const char *p)
     26  1.1  rillig {
     27  1.1  rillig 
     28  1.3  rillig 	/* suppressed+1: error: controlling expression must be bool, not 'int' [333] */
     29  1.1  rillig 	while (1)
     30  1.1  rillig 		break;
     31  1.1  rillig 
     32  1.5  rillig 	/* suppressed+1: error: operands of '=' have incompatible types '_Bool' and 'int' [107] */
     33  1.1  rillig 	b = i;
     34  1.1  rillig 
     35  1.3  rillig 	/* suppressed+1: error: operand of '!' must be bool, not 'int' [330] */
     36  1.1  rillig 	b = !i;
     37  1.1  rillig 
     38  1.3  rillig 	/* suppressed+1: error: left operand of '&&' must be bool, not 'int' [331] */
     39  1.1  rillig 	b = i && b;
     40  1.1  rillig 
     41  1.3  rillig 	/* suppressed+1: error: right operand of '&&' must be bool, not 'int' [332] */
     42  1.1  rillig 	b = b && i;
     43  1.1  rillig }
     44