blob: 94056b8caac6c060023456d269c6f95317892d0f (
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
/* $NetBSD: msg_206.c,v 1.7 2023/07/07 19:45:22 rillig Exp $ */
# 3 "msg_206.c"
// Test for message: enumeration value(s) not handled in switch [206]
/* lint1-extra-flags: -eh -X 351 */
enum number {
ONE, TWO, THREE
};
void
test(enum number num)
{
switch (num) {
case ONE:
case TWO:
break;
}
/* expect-1: warning: enumeration value(s) not handled in switch [206] */
switch (num) {
case ONE:
case TWO:
case THREE:
break;
}
}
int
too_many(enum number num)
{
switch (num) {
case ONE:
return 1;
case TWO:
return 2;
case THREE:
return 3;
case 3:
return -1;
}
/*
* Before func.c 1.137 from 2022-05-22, lint complained that there
* were enum constants not handled in switch, even though all of them
* are handled. The code smell in this case is that there are _too
* many_ branches that cover "impossible" values.
*/
return 3;
}
|