blob: b151e2310c7c3688ebe5c0e8417787a1295380f7 (
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
|
/* Further -Wswitch tests. */
/* { dg-do compile } */
/* { dg-options "-Wswitch" } */
enum e { e1 = 0, e2 = 1, e3 = 1, e4 = 2 };
int
foo (enum e ei, int j)
{
switch (ei)
{
case e1: return 1;
case e3: return 2;
case e4: return 3;
} /* No warning here since e2 has the same value as e3. */
switch (ei)
{
case e1: return 1;
case e2: return 2;
} /* { dg-warning "enumeration value `e4' not handled in switch" "enum e4" } */
switch ((int) ei)
{
case e1: return 1;
} /* No warning here since switch condition was cast to int. */
switch ((enum e) j)
{
case e2: return 1;
case e4: return 2;
} /* { dg-warning "enumeration value `e1' not handled in switch" "enum e1" } */
return 0;
}
|