PR tree-optimization/81303
[official-gcc.git] / gcc / testsuite / gcc.dg / Wswitch-2.c
blob79ba4bdcb84802c8120a76943132a6d8fe36cb5a
1 /* Further -Wswitch tests. */
2 /* { dg-do compile } */
3 /* { dg-options "-Wswitch" } */
5 enum e { e1 = 0, e2 = 1, e3 = 1, e4 = 2 };
7 int
8 foo (enum e ei, int j)
10 switch (ei)
12 case e1: return 1;
13 case e3: return 2;
14 case e4: return 3;
15 } /* No warning here since e2 has the same value as e3. */
16 switch (ei) /* { dg-warning "enumeration value 'e4' not handled in switch" "enum e4" } */
18 case e1: return 1;
19 case e2: return 2;
21 switch ((int) ei)
23 case e1: return 1;
24 } /* No warning here since switch condition was cast to int. */
25 switch ((enum e) j) /* { dg-warning "enumeration value 'e1' not handled in switch" "enum e1" } */
27 case e2: return 1;
28 case e4: return 2;
30 return 0;