blob: 2fcd1ddd5bd2dc0148ad5c0bd4d2e5b0376e6e81 (
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
/* { dg-do compile } */
/* { dg-options "-Werror=switch -Wswitch-enum" } */
enum e { e1, e2 };
int
foo (int i, int j, enum e ei, enum e ej, enum e ek, enum e el,
enum e em, enum e en, enum e eo, enum e ep)
{
switch (i)
{
case 1: return 1;
case 2: return 2;
}
switch (j)
{
case 3: return 4;
case 4: return 3;
default: break;
}
switch (ei) /* { dg-error "enumeration value 'e1' not handled in switch" "enum e1" } */
{ /* { dg-error "enumeration value 'e2' not handled in switch" "enum e2" { target *-*-* } 22 } */
}
switch (ej) /* { dg-warning "enumeration value 'e1' not handled in switch" "enum e1" } */
{ /* { dg-warning "enumeration value 'e2' not handled in switch" "enum e2" { target *-*-* } 25 } */
default: break;
}
switch (ek) /* { dg-error "enumeration value 'e2' not handled in switch" "enum e2" } */
{
case e1: return 1;
}
switch (el) /* { dg-warning "enumeration value 'e2' not handled in switch" "enum e2" } */
{
case e1: return 1;
default: break;
}
switch (em)
{
case e1: return 1;
case e2: return 2;
}
switch (en)
{
case e1: return 1;
case e2: return 2;
default: break;
}
switch (eo)
{
case e1: return 1;
case e2: return 2;
case 3: return 3; /* { dg-error "case value '3' not in enumerated type 'enum e'" "excess 3" } */
}
switch (ep)
{
case e1: return 1;
case e2: return 2;
case 3: return 3; /* { dg-error "case value '3' not in enumerated type 'enum e'" "excess 3" } */
default: break;
}
return 0;
}
/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
|