summaryrefslogtreecommitdiffstats
path: root/clang/test/CXX/expr/expr.post/expr.static.cast/p9-0x.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-02-18 03:01:41 +0000
committerDouglas Gregor <dgregor@apple.com>2011-02-18 03:01:41 +0000
commitb327eac1176a91b90b4755ec4b152ba42c0e2059 (patch)
tree07c79da0668fe27016ac137b419fe02e25f2790c /clang/test/CXX/expr/expr.post/expr.static.cast/p9-0x.cpp
parent53049153cf044fc34e8d1f5516dff6ee7a4d0712 (diff)
downloadbcm5719-llvm-b327eac1176a91b90b4755ec4b152ba42c0e2059.tar.gz
bcm5719-llvm-b327eac1176a91b90b4755ec4b152ba42c0e2059.zip
Implement C++0x [expr.static.cast]p9, which permits explicitly casting
a scoped enumeration type to an integral or floating type, properly. There was an over-eager assertion, and it was missing the floating-point case. Fixes PR9107/<rdar://problem/8937402>. llvm-svn: 125825
Diffstat (limited to 'clang/test/CXX/expr/expr.post/expr.static.cast/p9-0x.cpp')
-rw-r--r--clang/test/CXX/expr/expr.post/expr.static.cast/p9-0x.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/clang/test/CXX/expr/expr.post/expr.static.cast/p9-0x.cpp b/clang/test/CXX/expr/expr.post/expr.static.cast/p9-0x.cpp
new file mode 100644
index 00000000000..4acafb89aca
--- /dev/null
+++ b/clang/test/CXX/expr/expr.post/expr.static.cast/p9-0x.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
+
+enum class EC { ec1 };
+
+void test0(EC ec) {
+ (void)static_cast<bool>(ec);
+ (void)static_cast<bool>(EC::ec1);
+ (void)static_cast<char>(ec);
+ (void)static_cast<char>(EC::ec1);
+ (void)static_cast<int>(ec);
+ (void)static_cast<int>(EC::ec1);
+ (void)static_cast<unsigned long>(ec);
+ (void)static_cast<unsigned long>(EC::ec1);
+ (void)static_cast<float>(ec);
+ (void)static_cast<float>(EC::ec1);
+ (void)static_cast<double>(ec);
+ (void)static_cast<double>(EC::ec1);
+}
+
+namespace PR9107 {
+ enum E {};
+ template <class _Tp> inline _Tp* addressof(_Tp& __x) {
+ return (_Tp*)&(char&)__x;
+ }
+ void test() {
+ E a;
+ addressof(a);
+ }
+}
OpenPOWER on IntegriCloud