OSDN Git Service

PR c++/44157
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / opt / switch4.C
1 // { dg-do compile }
2 // { dg-options "-fshort-enums -w" }
3
4 // PR c++/20008
5
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.
9
10 typedef enum _SECStatus {
11   SECWouldBlock = -2,
12   SECFailure = -1,
13   SECSuccess = 0
14 } SECStatus;
15
16 typedef enum {
17   SEC_ERROR_BAD_SIGNATURE = (-0x2000) + 10
18 } SECErrorCodes;
19
20 void g(void);
21 void f(SECStatus status)
22 {
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     }
31 }