Revert "Fix PR34298 - Allow std::function with an incomplete return type."

This reverts commit r312890 because the test case fails to compile for
older versions of Clang that reject initializing a const object without
a user defined constructor.

Since this patch should go into 5.0.1, I want to keep it an atomic change,
and will re-commit it with a fixed test case.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@312891 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2017-09-10 23:37:47 +00:00
parent f83132a4d1
commit d5a494e058
3 changed files with 26 additions and 54 deletions

View File

@@ -16,7 +16,6 @@
// Allow incomplete argument types in the __is_callable check
#include <functional>
#include <cassert>
struct X{
typedef std::function<void(X&)> callback_type;
@@ -25,40 +24,6 @@ private:
callback_type _cb;
};
struct IncompleteReturnType {
std::function<IncompleteReturnType ()> fn;
};
int called = 0;
IncompleteReturnType test_fn() {
++called;
IncompleteReturnType I;
return I;
}
// See llvm.org/PR34298
void test_pr34298()
int main()
{
static_assert(std::is_copy_constructible<IncompleteReturnType>::value, "");
static_assert(std::is_copy_assignable<IncompleteReturnType>::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);
}
{
const IncompleteReturnType Empty;
IncompleteReturnType X2 = Empty;
assert(!X2.fn);
}
}
int main() {
test_pr34298();
}