18ef7b203332b0c8d65876a1f5e6d1db4e6f40e4bRichard Smith// RUN: %clang_cc1 -std=c++11 %s -verify
28e8fb3be5bd78f0564444eca02b404566a5f3b5dAndy Gibbs// expected-no-diagnostics
38ef7b203332b0c8d65876a1f5e6d1db4e6f40e4bRichard Smith
48ef7b203332b0c8d65876a1f5e6d1db4e6f40e4bRichard Smithstruct Value {
58ef7b203332b0c8d65876a1f5e6d1db4e6f40e4bRichard Smith  constexpr Value(int n) : n(n) {}
6840462670ba7a6bc26265a2306b35f2f0f01f51cRichard Smith  constexpr operator short() const { return n; }
78ef7b203332b0c8d65876a1f5e6d1db4e6f40e4bRichard Smith  int n;
88ef7b203332b0c8d65876a1f5e6d1db4e6f40e4bRichard Smith};
98ef7b203332b0c8d65876a1f5e6d1db4e6f40e4bRichard Smithenum E { E0, E1 };
108ef7b203332b0c8d65876a1f5e6d1db4e6f40e4bRichard Smithstruct Alt {
11840462670ba7a6bc26265a2306b35f2f0f01f51cRichard Smith  constexpr operator E() const { return E0; }
128ef7b203332b0c8d65876a1f5e6d1db4e6f40e4bRichard Smith};
138ef7b203332b0c8d65876a1f5e6d1db4e6f40e4bRichard Smith
148ef7b203332b0c8d65876a1f5e6d1db4e6f40e4bRichard Smithconstexpr short s = Alt();
158ef7b203332b0c8d65876a1f5e6d1db4e6f40e4bRichard Smith
168ef7b203332b0c8d65876a1f5e6d1db4e6f40e4bRichard Smithvoid test(Value v) {
178ef7b203332b0c8d65876a1f5e6d1db4e6f40e4bRichard Smith  switch (v) {
188ef7b203332b0c8d65876a1f5e6d1db4e6f40e4bRichard Smith    case Alt():
198ef7b203332b0c8d65876a1f5e6d1db4e6f40e4bRichard Smith    case E1:
208ef7b203332b0c8d65876a1f5e6d1db4e6f40e4bRichard Smith    case Value(2):
218ef7b203332b0c8d65876a1f5e6d1db4e6f40e4bRichard Smith    case 3:
228ef7b203332b0c8d65876a1f5e6d1db4e6f40e4bRichard Smith      break;
238ef7b203332b0c8d65876a1f5e6d1db4e6f40e4bRichard Smith  }
248ef7b203332b0c8d65876a1f5e6d1db4e6f40e4bRichard Smith  switch (Alt a = Alt()) {
258ef7b203332b0c8d65876a1f5e6d1db4e6f40e4bRichard Smith    case Alt():
268ef7b203332b0c8d65876a1f5e6d1db4e6f40e4bRichard Smith    case E1:
278ef7b203332b0c8d65876a1f5e6d1db4e6f40e4bRichard Smith    case Value(2):
288ef7b203332b0c8d65876a1f5e6d1db4e6f40e4bRichard Smith    case 3:
298ef7b203332b0c8d65876a1f5e6d1db4e6f40e4bRichard Smith      break;
308ef7b203332b0c8d65876a1f5e6d1db4e6f40e4bRichard Smith  }
318ef7b203332b0c8d65876a1f5e6d1db4e6f40e4bRichard Smith  switch (E0) {
328ef7b203332b0c8d65876a1f5e6d1db4e6f40e4bRichard Smith    case Alt():
338ef7b203332b0c8d65876a1f5e6d1db4e6f40e4bRichard Smith    case E1:
348ef7b203332b0c8d65876a1f5e6d1db4e6f40e4bRichard Smith    // FIXME: These should produce a warning that 2 and 3 are not values of the
358ef7b203332b0c8d65876a1f5e6d1db4e6f40e4bRichard Smith    // enumeration.
368ef7b203332b0c8d65876a1f5e6d1db4e6f40e4bRichard Smith    case Value(2):
378ef7b203332b0c8d65876a1f5e6d1db4e6f40e4bRichard Smith    case 3:
388ef7b203332b0c8d65876a1f5e6d1db4e6f40e4bRichard Smith      break;
398ef7b203332b0c8d65876a1f5e6d1db4e6f40e4bRichard Smith  }
408ef7b203332b0c8d65876a1f5e6d1db4e6f40e4bRichard Smith}
41