[cfe-commits] r131670 - /cfe/trunk/test/SemaCXX/underlying_type.cpp

Sean Hunt scshunt at csclub.uwaterloo.ca
Thu May 19 13:36:08 PDT 2011


Author: coppro
Date: Thu May 19 15:36:08 2011
New Revision: 131670

URL: http://llvm.org/viewvc/llvm-project?rev=131670&view=rev
Log:
Add a test for __underlying_type

Added:
    cfe/trunk/test/SemaCXX/underlying_type.cpp

Added: cfe/trunk/test/SemaCXX/underlying_type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/underlying_type.cpp?rev=131670&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/underlying_type.cpp (added)
+++ cfe/trunk/test/SemaCXX/underlying_type.cpp Thu May 19 15:36:08 2011
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
+
+#include "limits.h"
+
+template<typename T, typename U>
+struct is_same_type {
+  static const bool value = false;
+};
+template <typename T>
+struct is_same_type<T, T> {
+  static const bool value = true;
+};
+
+__underlying_type(int) a; // expected-error {{only enumeration types}}
+__underlying_type(struct b) c; // expected-error {{only enumeration types}}
+
+enum class f : char;
+static_assert(is_same_type<char, __underlying_type(f)>::value,
+              "f has the wrong underlying type");
+
+enum g {d = INT_MIN };
+static_assert(is_same_type<int, __underlying_type(g)>::value,
+              "g has the wrong underlying type");
+
+__underlying_type(f) h;
+static_assert(is_same_type<char, decltype(h)>::value,
+              "h has the wrong type");





More information about the cfe-commits mailing list