msg_162.c revision 1.4 1 /* $NetBSD: msg_162.c,v 1.4 2021/08/28 14:45:19 rillig Exp $ */
2 # 3 "msg_162.c"
3
4 // Test for message: comparison of %s with %s, op %s [162]
5
6 /* lint1-extra-flags: -hp */
7
8 void
9 left_unsigned(unsigned int ui)
10 {
11 if (ui < -5.0) {
12 }
13
14 /* expect+1: warning: comparison of unsigned int with negative constant, op < [162] */
15 if (ui < -5) {
16 }
17
18 /* expect+1: warning: comparison of unsigned int with 0, op < [162] */
19 if (ui < 0) {
20 }
21
22 /* expect+1: warning: comparison of unsigned int with 0, op >= [162] */
23 if (ui >= 0) {
24 }
25
26 /* expect+1: warning: comparison of unsigned int with 0, op <= [162] */
27 if (ui <= 0) {
28 }
29 }
30
31 void
32 right_unsigned(unsigned int ui)
33 {
34
35 if (-5.0 > ui) {
36 }
37
38 /* expect+1: warning: comparison of negative constant with unsigned int, op > [162] */
39 if (-5 > ui) {
40 }
41
42 /* expect+1: warning: comparison of 0 with unsigned int, op > [162] */
43 if (0 > ui) {
44 }
45
46 /* expect+1: warning: comparison of 0 with unsigned int, op <= [162] */
47 if (0 <= ui) {
48 }
49
50 /* expect+1: warning: comparison of 0 with unsigned int, op >= [162] */
51 if (0 >= ui) {
52 }
53 }
54
55 /*
56 * Lint does not care about these comparisons, even though they are obviously
57 * out of range.
58 */
59 void
60 compare_signed_char(signed char sc)
61 {
62 if (sc == -129)
63 return;
64 if (sc == -128)
65 return;
66 if (sc == 127)
67 return;
68 if (sc == 128)
69 return;
70 }
71
72 void
73 compare_unsigned_char(unsigned char uc)
74 {
75 /* expect+1: warning: comparison of unsigned char with negative constant, op == [162] */
76 if (uc == -1)
77 return;
78 if (uc == 0)
79 return;
80 if (uc == 255)
81 return;
82 if (uc == 256)
83 return;
84 }
85