summaryrefslogtreecommitdiff
path: root/tests/usr.bin/xlint/lint1/msg_243.c
blob: 41a6e21d9670ffdf77f1e58ccb8cbf8f8873753c (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
/*	$NetBSD: msg_243.c,v 1.5 2023/03/28 14:44:35 rillig Exp $	*/
# 3 "msg_243.c"

// Test for message: dubious comparison of enums, op '%s' [243]

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

enum color {
	RED, GREEN, BLUE
};

void eval(_Bool);

/* TODO: There should be a way to declare an enum type as "ordered ok". */

void
example(enum color a, enum color b)
{
	/* expect+1: warning: dubious comparison of enums, op '<' [243] */
	eval(a < b);
	/* expect+1: warning: dubious comparison of enums, op '<=' [243] */
	eval(a <= b);
	/* expect+1: warning: dubious comparison of enums, op '>' [243] */
	eval(a > b);
	/* expect+1: warning: dubious comparison of enums, op '>=' [243] */
	eval(a >= b);
	eval(a == b);
	eval(a != b);
}