1// { dg-do compile { target c++11 } }
2
3enum E1 : unsigned { E1_en = 1 };
4enum E2 : char { E2_en = 1 };
5enum class E3 { a = -1 };
6enum class E4 : unsigned char { c = 1 };
7enum class E5 : int { a = -1, b = 1 };
8enum class E6 : long { c = __LONG_MAX__ };
9
10template<typename T1, typename T2>
11  struct is_same
12  { static const bool value = false; };
13
14template<typename T>
15  struct is_same<T, T>
16  { static const bool value = true; };
17
18template<typename>
19  struct underlying_type;
20
21template<typename T, typename U>
22  void
23  test(T, U, typename underlying_type<T>::type);
24
25template<typename T>
26  struct underlying_type
27  { typedef __underlying_type(T) type; };
28
29template<typename T, typename U>
30  void
31  test(T, U, typename underlying_type<T>::type)
32  {
33    static_assert(is_same<typename underlying_type<T>::type, U>::value,
34		  "Error");
35  }
36
37int main()
38{
39  test(E1::E1_en, unsigned(), 1);
40  test(E2::E2_en, char(), 1);
41  test(E3::a, int(), -1);
42  test(E4::c, (unsigned char)(1), 1);
43  test(E5::a, int(), -1);
44  test(E6::c, long(), __LONG_MAX__);
45}
46