c-common.c (struct c_common_resword): Add __underlying_type.
[platform/upstream/gcc.git] / gcc / testsuite / g++.dg / ext / underlying_type10.C
1 // { dg-do run }
2 // { dg-options "-std=c++0x" }
3
4 #include <cassert>
5
6 enum E1 : unsigned { E1_en = 1 };
7 enum E2 : char { E2_en = 1 };
8 enum class E3 { a = -1 };
9 enum class E4 : unsigned char { c = 1 };
10 enum class E5 : int { a = -1, b = 1 };
11 enum class E6 : long { c = __LONG_MAX__ };
12
13 template<typename T>
14   struct underlying_type
15   { typedef __underlying_type(T) type; };
16
17 template<typename T>
18   void
19   test(T t, typename underlying_type<T>::type v)
20   {
21     assert( t == T(v) );
22   }
23
24 int main()
25 {
26   test(E1::E1_en, 1);
27   test(E2::E2_en, 1);
28   test(E3::a, -1);
29   test(E4::c, 1);
30   test(E5::a, -1);
31   test(E6::c, __LONG_MAX__);
32 }