[libcxx-commits] [libcxx] 2b89c34 - [libcxx] Adjust trivial_abi tests for C++03 and C++11 testing
Mikhail Maltsev via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jul 23 06:21:25 PDT 2020
Author: Mikhail Maltsev
Date: 2020-07-23T14:20:49+01:00
New Revision: 2b89c34784fa52b2948d79f31a375011c0218804
URL: https://github.com/llvm/llvm-project/commit/2b89c34784fa52b2948d79f31a375011c0218804
DIFF: https://github.com/llvm/llvm-project/commit/2b89c34784fa52b2948d79f31a375011c0218804.diff
LOG: [libcxx] Adjust trivial_abi tests for C++03 and C++11 testing
This change replaces std::make_unique with manual construction of
std::unique_ptr to make the tests compatible with C++11
(std::make_unique is a C++14 feature).
libc++ supports std::unique_ptr and std::shared_ptr even in C++03 but
with some limitations: unique_ptr_array.pass.cpp and
shared_ptr_arg.pass.cpp fail to compile in C++03 mode and need to be
disabled.
Differential Revision: https://reviews.llvm.org/D84394
Added:
Modified:
libcxx/test/libcxx/memory/trivial_abi/shared_ptr_arg.pass.cpp
libcxx/test/libcxx/memory/trivial_abi/unique_ptr_arg.pass.cpp
libcxx/test/libcxx/memory/trivial_abi/unique_ptr_array.pass.cpp
libcxx/test/libcxx/memory/trivial_abi/unique_ptr_destruction_order.pass.cpp
libcxx/test/libcxx/memory/trivial_abi/unique_ptr_ret.pass.cpp
Removed:
################################################################################
diff --git a/libcxx/test/libcxx/memory/trivial_abi/shared_ptr_arg.pass.cpp b/libcxx/test/libcxx/memory/trivial_abi/shared_ptr_arg.pass.cpp
index f87b9ad04fac..fdf4a172bab2 100644
--- a/libcxx/test/libcxx/memory/trivial_abi/shared_ptr_arg.pass.cpp
+++ b/libcxx/test/libcxx/memory/trivial_abi/shared_ptr_arg.pass.cpp
@@ -14,6 +14,7 @@
// There were assertion failures in both parse and codegen, which are fixed in clang 11.
// UNSUPPORTED: gcc, clang-4, clang-5, clang-6, clang-7, clang-8, clang-9, clang-10
+// UNSUPPORTED: c++03
#include <memory>
#include <cassert>
diff --git a/libcxx/test/libcxx/memory/trivial_abi/unique_ptr_arg.pass.cpp b/libcxx/test/libcxx/memory/trivial_abi/unique_ptr_arg.pass.cpp
index 212d08a4f646..e7336ddcea71 100644
--- a/libcxx/test/libcxx/memory/trivial_abi/unique_ptr_arg.pass.cpp
+++ b/libcxx/test/libcxx/memory/trivial_abi/unique_ptr_arg.pass.cpp
@@ -45,7 +45,7 @@ int main(int, char**) {
//
// With trivial-abi, expect_1 will see shared == 1 because shared_val is
// incremented before get_val returns.
- expect_1(&shared, get_val(std::make_unique<Node>(&shared)));
+ expect_1(&shared, get_val(std::unique_ptr<Node>(new Node(&shared))));
// Check that the shared-value is still 1.
expect_1(&shared, true);
diff --git a/libcxx/test/libcxx/memory/trivial_abi/unique_ptr_array.pass.cpp b/libcxx/test/libcxx/memory/trivial_abi/unique_ptr_array.pass.cpp
index 04b0da6257f0..4e4b521131a2 100644
--- a/libcxx/test/libcxx/memory/trivial_abi/unique_ptr_array.pass.cpp
+++ b/libcxx/test/libcxx/memory/trivial_abi/unique_ptr_array.pass.cpp
@@ -14,6 +14,7 @@
// There were assertion failures in both parse and codegen, which are fixed in clang 11.
// UNSUPPORTED: gcc, clang-4, clang-5, clang-6, clang-7, clang-8, clang-9, clang-10
+// UNSUPPORTED: c++03
#include <memory>
#include <cassert>
diff --git a/libcxx/test/libcxx/memory/trivial_abi/unique_ptr_destruction_order.pass.cpp b/libcxx/test/libcxx/memory/trivial_abi/unique_ptr_destruction_order.pass.cpp
index 82b40a24075c..980349866a98 100644
--- a/libcxx/test/libcxx/memory/trivial_abi/unique_ptr_destruction_order.pass.cpp
+++ b/libcxx/test/libcxx/memory/trivial_abi/unique_ptr_destruction_order.pass.cpp
@@ -53,7 +53,7 @@ int main(int, char**) {
char shared_buf[3] = {'0', '0', '0'};
int cur_idx = 0;
- func(A(shared_buf, &cur_idx), std::make_unique<B>(shared_buf, &cur_idx),
+ func(A(shared_buf, &cur_idx), std::unique_ptr<B>(new B(shared_buf, &cur_idx)),
C(shared_buf, &cur_idx));
// With trivial_abi, the std::unique_ptr<B> arg is always destructed first.
diff --git a/libcxx/test/libcxx/memory/trivial_abi/unique_ptr_ret.pass.cpp b/libcxx/test/libcxx/memory/trivial_abi/unique_ptr_ret.pass.cpp
index 9dbdaa2e9585..73fe18becc3a 100644
--- a/libcxx/test/libcxx/memory/trivial_abi/unique_ptr_ret.pass.cpp
+++ b/libcxx/test/libcxx/memory/trivial_abi/unique_ptr_ret.pass.cpp
@@ -28,7 +28,7 @@ struct Node {
__attribute__((noinline)) std::unique_ptr<Node> make_val(void** local_addr) {
call_something();
- auto ret = std::make_unique<Node>();
+ auto ret = std::unique_ptr<Node>(new Node);
// Capture the local address of ret.
*local_addr = &ret;
More information about the libcxx-commits
mailing list