1 // RUN: %clang_cc1 -ffreestanding -fsyntax-only -verify -std=c++11 %s
5 template<typename T, typename U>
7 static const bool value = false;
10 struct is_same_type<T, T> {
11 static const bool value = true;
14 __underlying_type(int) a; // expected-error {{only enumeration types}}
15 __underlying_type(struct b) c; // expected-error {{only enumeration types}}
18 static_assert(is_same_type<char, __underlying_type(f)>::value,
19 "f has the wrong underlying type");
21 enum g {d = INT_MIN };
22 static_assert(is_same_type<int, __underlying_type(g)>::value,
23 "g has the wrong underlying type");
25 __underlying_type(f) h;
26 static_assert(is_same_type<char, decltype(h)>::value,
27 "h has the wrong type");
30 struct underlying_type {
31 typedef __underlying_type(T) type; // expected-error {{only enumeration types}}
34 static_assert(is_same_type<underlying_type<f>::type, char>::value,
35 "f has the wrong underlying type in the template");
37 underlying_type<int>::type e; // expected-note {{requested here}}
39 using uint = unsigned;
40 enum class foo : uint { bar };
42 static_assert(is_same_type<underlying_type<foo>::type, unsigned>::value,
43 "foo has the wrong underlying type");