xref: /netbsd-src/tests/usr.bin/xlint/lint1/msg_230.c (revision 82d56013d7b633d116a93943de88e08335357a7c)
1 /*	$NetBSD: msg_230.c,v 1.3 2021/01/31 11:12:07 rillig Exp $	*/
2 # 3 "msg_230.c"
3 
4 // Test for message: nonportable character comparison, op %s [230]
5 
6 /* lint1-flags: -S -g -p -w */
7 
8 void example(char c, unsigned char uc, signed char sc)
9 {
10 	if (c < 0)
11 		if (uc < 0)			/* expect: 162 */
12 			if (sc < 0)
13 				return;
14 
15 	/*
16 	 * XXX: The comparison "<= -1" looks very similar to "< 0",
17 	 * nevertheless "< 0" does not generate a warning.
18 	 *
19 	 * The comparisons may actually differ subtly because of the usual
20 	 * arithmetic promotions.
21 	 * */
22 	if (c <= -1)				/* expect: 230 */
23 		if (uc <= -1)			/* expect: 162 */
24 			if (sc <= -1)
25 				return;
26 }
27