summaryrefslogtreecommitdiffstats
path: root/libcxx/test
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2017-01-05 01:15:42 +0000
committerEric Fiselier <eric@efcs.ca>2017-01-05 01:15:42 +0000
commit528600c41ffb6afc9d95f5ba808ed5e6b348d7a3 (patch)
tree4c29d45e1c7949c1e587c33e257810c52099d8eb /libcxx/test
parent61195e12fc5cc128e5908cfb76a91ee6860659e5 (diff)
downloadbcm5719-llvm-528600c41ffb6afc9d95f5ba808ed5e6b348d7a3.tar.gz
bcm5719-llvm-528600c41ffb6afc9d95f5ba808ed5e6b348d7a3.zip
Fix std::pointer_safety type in ABI v2
In the C++ standard `std::pointer_safety` is defined as a C++11 strongly typed enum. However libc++ currently defines it as a class type which simulates a C++11 enumeration. This can be detected in valid C++ code. This patch introduces an the _LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE ABI option. When defined `std::pointer_safety` is implemented as an enum type. Unfortunatly this also means it can no longer be provided as an extension in C++03. Additionally this patch moves the definition for `get_pointer_safety()` out of the dylib, and into the headers. New usages of `get_pointer_safety()` will now use the inline version instead of the dylib version. However in order to keep the dylib ABI compatible the old definition is explicitly compiled into it. llvm-svn: 291046
Diffstat (limited to 'libcxx/test')
-rw-r--r--libcxx/test/libcxx/utilities/memory/util.dynamic.safety/get_pointer_safety_cxx03.pass.cpp26
-rw-r--r--libcxx/test/libcxx/utilities/memory/util.dynamic.safety/get_pointer_safety_new_abi.pass.cpp38
-rw-r--r--libcxx/test/std/utilities/memory/util.dynamic.safety/get_pointer_safety.pass.cpp2
3 files changed, 66 insertions, 0 deletions
diff --git a/libcxx/test/libcxx/utilities/memory/util.dynamic.safety/get_pointer_safety_cxx03.pass.cpp b/libcxx/test/libcxx/utilities/memory/util.dynamic.safety/get_pointer_safety_cxx03.pass.cpp
new file mode 100644
index 00000000000..04671c3a967
--- /dev/null
+++ b/libcxx/test/libcxx/utilities/memory/util.dynamic.safety/get_pointer_safety_cxx03.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// pointer_safety get_pointer_safety();
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ // Test that std::pointer_safety is still offered in C++03 under the old ABI.
+#ifndef _LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE
+ std::pointer_safety r = std::get_pointer_safety();
+ assert(r == std::pointer_safety::relaxed ||
+ r == std::pointer_safety::preferred ||
+ r == std::pointer_safety::strict);
+#endif
+}
diff --git a/libcxx/test/libcxx/utilities/memory/util.dynamic.safety/get_pointer_safety_new_abi.pass.cpp b/libcxx/test/libcxx/utilities/memory/util.dynamic.safety/get_pointer_safety_new_abi.pass.cpp
new file mode 100644
index 00000000000..752edb6dadd
--- /dev/null
+++ b/libcxx/test/libcxx/utilities/memory/util.dynamic.safety/get_pointer_safety_new_abi.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// pointer_safety get_pointer_safety();
+
+// The pointer_safety interface is no longer provided in C++03 in the new ABI.
+// XFAIL: c++98, c++03
+
+// MODULES_DEFINES: _LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE
+#define _LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ {
+ static_assert(std::is_enum<std::pointer_safety>::value, "");
+ static_assert(!std::is_convertible<std::pointer_safety, int>::value, "");
+ static_assert(std::is_same<
+ std::underlying_type<std::pointer_safety>::type,
+ unsigned char
+ >::value, "");
+ }
+ {
+ std::pointer_safety r = std::get_pointer_safety();
+ assert(r == std::pointer_safety::relaxed ||
+ r == std::pointer_safety::preferred ||
+ r == std::pointer_safety::strict);
+ }
+}
diff --git a/libcxx/test/std/utilities/memory/util.dynamic.safety/get_pointer_safety.pass.cpp b/libcxx/test/std/utilities/memory/util.dynamic.safety/get_pointer_safety.pass.cpp
index 1f27b45e8ab..ee2f81713b2 100644
--- a/libcxx/test/std/utilities/memory/util.dynamic.safety/get_pointer_safety.pass.cpp
+++ b/libcxx/test/std/utilities/memory/util.dynamic.safety/get_pointer_safety.pass.cpp
@@ -11,6 +11,8 @@
// pointer_safety get_pointer_safety();
+// UNSUPPORTED: c++98, c++03
+
#include <memory>
#include <cassert>
OpenPOWER on IntegriCloud