summaryrefslogtreecommitdiff
path: root/tests/usr.bin/xlint/lint1/msg_331.c
blob: bd21007585b75fca10e2312921f9b2d77441d1fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*	$NetBSD: msg_331.c,v 1.5 2023/03/28 14:44:35 rillig Exp $	*/
# 3 "msg_331.c"

// Test for message: left operand of '%s' must be bool, not '%s' [331]
//
// See d_c99_bool_strict.c for many more examples.

/* lint1-extra-flags: -T -X 351 */

typedef _Bool bool;

void
test(bool);

void
example(bool b, char c, int i)
{
	test(b && b);

	/* expect+2: error: left operand of '&&' must be bool, not 'char' [331] */
	/* expect+1: error: argument #1 expects '_Bool', gets passed 'int' [334] */
	test(c && b);

	/* expect+2: error: left operand of '&&' must be bool, not 'int' [331] */
	/* expect+1: error: argument #1 expects '_Bool', gets passed 'int' [334] */
	test(i && b);

	test(c != '\0');
	test(i != 0);
}