Debian Codegraph @

gcc/testsuite/g++.dg/warn/Wswitch-4.C

raw
1 // PR c++/105497
2 // { dg-do compile { target c++11 } }
3 // { dg-options "-Wswitch" }
4
5 enum class Button
6 {
7 Left,
8 Right,
9 Middle,
10 NumberOfButtons [[maybe_unused]]
11 };
12
13 enum class Sound
14 {
15 Bark,
16 Meow,
17 Hiss,
18 Moo __attribute((unused))
19 };
20
21 enum class Chordata
22 {
23 Urochordata,
24 Cephalochordata,
25 Vertebrata
26 };
27
28 int main()
29 {
30 Button b = Button::Left;
31 switch (b) { // { dg-bogus "not handled" }
32 case Button::Left:
33 case Button::Right:
34 case Button::Middle:
35 break;
36 }
37
38 Sound s = Sound::Bark;
39 switch (s) { // { dg-bogus "not handled" }
40 case Sound::Bark:
41 case Sound::Meow:
42 case Sound::Hiss:
43 break;
44 }
45
46 Chordata c = Chordata::Vertebrata;
47 switch (c) { // { dg-warning "not handled" }
48 case Chordata::Cephalochordata:
49 case Chordata::Vertebrata:
50 break;
51 }
52 }