msg_230.c revision 1.6 1 /* $NetBSD: msg_230.c,v 1.6 2021/08/23 17:47:34 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 /* lint1-only-if: schar */
8
9 void example(char c, unsigned char uc, signed char sc)
10 {
11 if (c < 0)
12 return;
13 /* expect+1: warning: comparison of unsigned char with 0, op < [162] */
14 if (uc < 0)
15 return;
16 if (sc < 0)
17 return;
18
19 /*
20 * XXX: The comparison "<= -1" looks very similar to "< 0",
21 * nevertheless "< 0" does not generate a warning.
22 *
23 * The comparisons may actually differ subtly because of the usual
24 * arithmetic promotions.
25 */
26 /* expect+1: warning: nonportable character comparison, op <= [230] */
27 if (c <= -1)
28 return;
29 /* expect+1: warning: comparison of unsigned char with negative constant, op <= [162] */
30 if (uc <= -1)
31 return;
32 if (sc <= -1)
33 return;
34
35 /* expect+1: warning: nonportable character comparison, op <= [230] */
36 if (-1 <= c)
37 return;
38 /* expect+1: warning: nonportable character comparison, op <= [230] */
39 if (256 <= c)
40 return;
41 }
42