msg_206.c revision 1.7
1/*	$NetBSD: msg_206.c,v 1.7 2023/07/07 19:45:22 rillig Exp $	*/
2# 3 "msg_206.c"
3
4// Test for message: enumeration value(s) not handled in switch [206]
5
6/* lint1-extra-flags: -eh -X 351 */
7
8enum number {
9	ONE, TWO, THREE
10};
11
12void
13test(enum number num)
14{
15	switch (num) {
16	case ONE:
17	case TWO:
18		break;
19	}
20	/* expect-1: warning: enumeration value(s) not handled in switch [206] */
21
22	switch (num) {
23	case ONE:
24	case TWO:
25	case THREE:
26		break;
27	}
28}
29
30int
31too_many(enum number num)
32{
33	switch (num) {
34	case ONE:
35		return 1;
36	case TWO:
37		return 2;
38	case THREE:
39		return 3;
40	case 3:
41		return -1;
42	}
43	/*
44	 * Before func.c 1.137 from 2022-05-22, lint complained that there
45	 * were enum constants not handled in switch, even though all of them
46	 * are handled.  The code smell in this case is that there are _too
47	 * many_ branches that cover "impossible" values.
48	 */
49	return 3;
50}
51