From dbabdb5220c44e5938d404eefb84b5ed55667ea8 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sat, 2 Dec 2017 12:47:11 +0000 Subject: Vendor import of libc++ release_50 branch r319231: https://llvm.org/svn/llvm-project/libcxx/branches/release_50@319231 --- .../func.wrap.func.con/F_incomplete.pass.cpp | 37 +++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'test/std/utilities/function.objects') diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp index c8f4178a26bdd..75e2ecac3c415 100644 --- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp +++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp @@ -16,6 +16,7 @@ // Allow incomplete argument types in the __is_callable check #include +#include struct X{ typedef std::function callback_type; @@ -24,6 +25,40 @@ private: callback_type _cb; }; -int main() +struct IncompleteReturnType { + std::function fn; +}; + + +int called = 0; +IncompleteReturnType test_fn() { + ++called; + IncompleteReturnType I; + return I; +} + +// See llvm.org/PR34298 +void test_pr34298() { + static_assert(std::is_copy_constructible::value, ""); + static_assert(std::is_copy_assignable::value, ""); + { + IncompleteReturnType X; + X.fn = test_fn; + const IncompleteReturnType& CX = X; + IncompleteReturnType X2 = CX; + assert(X2.fn); + assert(called == 0); + X2.fn(); + assert(called == 1); + } + { + IncompleteReturnType Empty; + IncompleteReturnType X2 = Empty; + assert(!X2.fn); + } +} + +int main() { + test_pr34298(); } -- cgit v1.2.3