xref: /netbsd-src/tests/usr.bin/xlint/lint1/msg_243.c (revision 7d62b00eb9ad855ffcd7da46b41e23feb5476fac)
1 /*	$NetBSD: msg_243.c,v 1.4 2022/06/22 19:23:18 rillig Exp $	*/
2 # 3 "msg_243.c"
3 
4 // Test for message: dubious comparison of enums, op '%s' [243]
5 
6 /* lint1-extra-flags: -eP */
7 
8 enum color {
9 	RED, GREEN, BLUE
10 };
11 
12 void eval(_Bool);
13 
14 /* TODO: There should be a way to declare an enum type as "ordered ok". */
15 
16 void
17 example(enum color a, enum color b)
18 {
19 	/* expect+1: warning: dubious comparison of enums, op '<' [243] */
20 	eval(a < b);
21 	/* expect+1: warning: dubious comparison of enums, op '<=' [243] */
22 	eval(a <= b);
23 	/* expect+1: warning: dubious comparison of enums, op '>' [243] */
24 	eval(a > b);
25 	/* expect+1: warning: dubious comparison of enums, op '>=' [243] */
26 	eval(a >= b);
27 	eval(a == b);
28 	eval(a != b);
29 }
30