1 // RUN: %clang_cc1 -fsyntax-only -verify -Wassign-enum -Wswitch-enum -Wcovered-switch-default -std=c++11 %s
2 
3 enum Enum {
4   A0 = 1, A1 = 10
5 };
6 
7 enum __attribute__((enum_extensibility(closed))) EnumClosed {
8   B0 = 1, B1 = 10
9 };
10 
11 enum [[clang::enum_extensibility(open)]] EnumOpen {
12   C0 = 1, C1 = 10
13 };
14 
15 enum __attribute__((flag_enum)) EnumFlag {
16   D0 = 1, D1 = 8
17 };
18 
19 enum __attribute__((flag_enum,enum_extensibility(closed))) EnumFlagClosed {
20   E0 = 1, E1 = 8
21 };
22 
23 enum __attribute__((flag_enum,enum_extensibility(open))) EnumFlagOpen {
24   F0 = 1, F1 = 8
25 };
26 
test()27 void test() {
28   enum Enum t0;
29 
30   switch (t0) { // expected-warning{{enumeration value 'A1' not handled in switch}}
31   case A0: break;
32   case 16: break; // expected-warning{{case value not in enumerated type}}
33   }
34 
35   switch (t0) {
36   case A0: break;
37   case A1: break;
38   default: break; // expected-warning{{default label in switch which covers all enumeration}}
39   }
40 
41   enum EnumClosed t1;
42 
43   switch (t1) { // expected-warning{{enumeration value 'B1' not handled in switch}}
44   case B0: break;
45   case 16: break; // expected-warning{{case value not in enumerated type}}
46   }
47 
48   switch (t1) {
49   case B0: break;
50   case B1: break;
51   default: break; // expected-warning{{default label in switch which covers all enumeration}}
52   }
53 
54   enum EnumOpen t2;
55 
56   switch (t2) { // expected-warning{{enumeration value 'C1' not handled in switch}}
57   case C0: break;
58   case 16: break;
59   }
60 
61   switch (t2) {
62   case C0: break;
63   case C1: break;
64   default: break;
65   }
66 
67   enum EnumFlag t3;
68 
69   switch (t3) { // expected-warning{{enumeration value 'D1' not handled in switch}}
70   case D0: break;
71   case 9: break;
72   case 16: break; // expected-warning{{case value not in enumerated type}}
73   }
74 
75   switch (t3) {
76   case D0: break;
77   case D1: break;
78   default: break;
79   }
80 
81   enum EnumFlagClosed t4;
82 
83   switch (t4) { // expected-warning{{enumeration value 'E1' not handled in switch}}
84   case E0: break;
85   case 9: break;
86   case 16: break; // expected-warning{{case value not in enumerated type}}
87   }
88 
89   switch (t4) {
90   case E0: break;
91   case E1: break;
92   default: break;
93   }
94 
95   enum EnumFlagOpen t5;
96 
97   switch (t5) { // expected-warning{{enumeration value 'F1' not handled in switch}}
98   case F0: break;
99   case 9: break;
100   case 16: break;
101   }
102 
103   switch (t5) {
104   case F0: break;
105   case F1: break;
106   default: break;
107   }
108 }
109