2018-11-07 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / g++.dg / opt / switch4.C
blob1542f310ca47375fbc0d1a2a3bbbb180edeeca07
1 // { dg-do compile }
2 // { dg-options "-fshort-enums -w" }
4 // PR c++/20008
6 // We failed to compile this because CFG cleanup left the switch
7 // statement intact, whereas expand_case expected at least one
8 // in-range case to remain.
10 typedef enum _SECStatus {
11   SECWouldBlock = -2,
12   SECFailure = -1,
13   SECSuccess = 0
14 } SECStatus;
16 typedef enum {
17   SEC_ERROR_BAD_SIGNATURE = (-0x2000) + 10
18 } SECErrorCodes;
20 void g(void);
21 void f(SECStatus status)
23   switch( status )
24     {
25     case SEC_ERROR_BAD_SIGNATURE :
26       // This case can be optimized away in C++ (but apparently not in
27       // C), because the enum type is defined with a narrow range.
28       g();
29       break ;
30     }