Home | History | Annotate | Download | only in stmt.switch
      1 // RUN: %clang_cc1 -std=c++11 %s -verify
      2 
      3 struct Value {
      4   constexpr Value(int n) : n(n) {}
      5   constexpr operator short() { return n; }
      6   int n;
      7 };
      8 enum E { E0, E1 };
      9 struct Alt {
     10   constexpr operator E() { return E0; }
     11 };
     12 
     13 constexpr short s = Alt();
     14 
     15 void test(Value v) {
     16   switch (v) {
     17     case Alt():
     18     case E1:
     19     case Value(2):
     20     case 3:
     21       break;
     22   }
     23   switch (Alt a = Alt()) {
     24     case Alt():
     25     case E1:
     26     case Value(2):
     27     case 3:
     28       break;
     29   }
     30   switch (E0) {
     31     case Alt():
     32     case E1:
     33     // FIXME: These should produce a warning that 2 and 3 are not values of the
     34     // enumeration.
     35     case Value(2):
     36     case 3:
     37       break;
     38   }
     39 }
     40