aboutsummaryrefslogtreecommitdiff
path: root/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-08-20 18:01:01 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-08-20 18:01:01 +0000
commitb7332b04df5d50c92640c74cfeb138ecb7e3f7ae (patch)
treeb1b49faa0cab1482905e0cda6f0ee5d97e3fe08f /test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con
parent6012fe9abb1f01b1b5b4ca908464804c21ff8602 (diff)
Notes
Diffstat (limited to 'test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con')
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp115
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp119
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp64
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_nullptr.pass.cpp247
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.fail.cpp25
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp30
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.fail.cpp29
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp130
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.fail.cpp30
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp125
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.fail.cpp27
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp28
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.fail.cpp60
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp109
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_assign.pass.cpp138
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_move.pass.cpp165
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/default.pass.cpp23
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/move_reentrant.pass.cpp46
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t.pass.cpp23
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign.pass.cpp72
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign_reentrant.pass.cpp46
21 files changed, 0 insertions, 1651 deletions
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp
deleted file mode 100644
index fd296a7367b8..000000000000
--- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <functional>
-
-// class function<R(ArgTypes...)>
-
-// function(F);
-
-#include <functional>
-#include <cassert>
-
-#include "test_macros.h"
-#include "count_new.hpp"
-
-class A
-{
- int data_[10];
-public:
- static int count;
-
- A()
- {
- ++count;
- for (int i = 0; i < 10; ++i)
- data_[i] = i;
- }
-
- A(const A&) {++count;}
-
- ~A() {--count;}
-
- int operator()(int i) const
- {
- for (int j = 0; j < 10; ++j)
- i += data_[j];
- return i;
- }
-
- int foo(int) const {return 1;}
-};
-
-int A::count = 0;
-
-int g(int) {return 0;}
-
-#if TEST_STD_VER >= 11
-struct RValueCallable {
- template <class ...Args>
- void operator()(Args&&...) && {}
-};
-struct LValueCallable {
- template <class ...Args>
- void operator()(Args&&...) & {}
-};
-#endif
-
-int main()
-{
- assert(globalMemCounter.checkOutstandingNewEq(0));
- {
- std::function<int(int)> f = A();
- assert(A::count == 1);
- assert(globalMemCounter.checkOutstandingNewEq(1));
- assert(f.target<A>());
- assert(f.target<int(*)(int)>() == 0);
- }
- assert(A::count == 0);
- assert(globalMemCounter.checkOutstandingNewEq(0));
- {
- std::function<int(int)> f = g;
- assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f.target<int(*)(int)>());
- assert(f.target<A>() == 0);
- }
- assert(globalMemCounter.checkOutstandingNewEq(0));
- {
- std::function<int(int)> f = (int (*)(int))0;
- assert(!f);
- assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f.target<int(*)(int)>() == 0);
- assert(f.target<A>() == 0);
- }
- {
- std::function<int(const A*, int)> f = &A::foo;
- assert(f);
- assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f.target<int (A::*)(int) const>() != 0);
- }
- {
- std::function<void(int)> f(&g);
- assert(f);
- assert(f.target<int(*)(int)>() != 0);
- f(1);
- }
- {
- std::function <void()> f(static_cast<void (*)()>(0));
- assert(!f);
- }
-#if TEST_STD_VER >= 11
- {
- using Fn = std::function<void(int, int, int)>;
- static_assert(std::is_constructible<Fn, LValueCallable&>::value, "");
- static_assert(std::is_constructible<Fn, LValueCallable>::value, "");
- static_assert(!std::is_constructible<Fn, RValueCallable&>::value, "");
- static_assert(!std::is_constructible<Fn, RValueCallable>::value, "");
- }
-#endif
-}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp
deleted file mode 100644
index e927ad42c06b..000000000000
--- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp
+++ /dev/null
@@ -1,119 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <functional>
-
-// class function<R(ArgTypes...)>
-
-// template<class F>
-// requires CopyConstructible<F> && Callable<F, ArgTypes..>
-// && Convertible<Callable<F, ArgTypes...>::result_type
-// operator=(F f);
-
-#include <functional>
-#include <cassert>
-
-#include "test_macros.h"
-#include "count_new.hpp"
-
-class A
-{
- int data_[10];
-public:
- static int count;
-
- A()
- {
- ++count;
- for (int i = 0; i < 10; ++i)
- data_[i] = i;
- }
-
- A(const A&) {++count;}
-
- ~A() {--count;}
-
- int operator()(int i) const
- {
- for (int j = 0; j < 10; ++j)
- i += data_[j];
- return i;
- }
-
- int foo(int) const {return 1;}
-};
-
-int A::count = 0;
-
-int g(int) {return 0;}
-
-#if TEST_STD_VER >= 11
-struct RValueCallable {
- template <class ...Args>
- void operator()(Args&&...) && {}
-};
-struct LValueCallable {
- template <class ...Args>
- void operator()(Args&&...) & {}
-};
-#endif
-
-int main()
-{
- assert(globalMemCounter.checkOutstandingNewEq(0));
- {
- std::function<int(int)> f;
- f = A();
- assert(A::count == 1);
- assert(globalMemCounter.checkOutstandingNewEq(1));
- assert(f.target<A>());
- assert(f.target<int(*)(int)>() == 0);
- }
- assert(A::count == 0);
- assert(globalMemCounter.checkOutstandingNewEq(0));
- {
- std::function<int(int)> f;
- f = g;
- assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f.target<int(*)(int)>());
- assert(f.target<A>() == 0);
- }
- assert(globalMemCounter.checkOutstandingNewEq(0));
- {
- std::function<int(int)> f;
- f = (int (*)(int))0;
- assert(!f);
- assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f.target<int(*)(int)>() == 0);
- assert(f.target<A>() == 0);
- }
- {
- std::function<int(const A*, int)> f;
- f = &A::foo;
- assert(f);
- assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f.target<int (A::*)(int) const>() != 0);
- }
- {
- std::function<void(int)> f;
- f = &g;
- assert(f);
- assert(f.target<int(*)(int)>() != 0);
- f(1);
- }
-#if TEST_STD_VER >= 11
- {
- using Fn = std::function<void(int, int, int)>;
- static_assert(std::is_assignable<Fn&, LValueCallable&>::value, "");
- static_assert(std::is_assignable<Fn&, LValueCallable>::value, "");
- static_assert(!std::is_assignable<Fn&, RValueCallable&>::value, "");
- static_assert(!std::is_assignable<Fn&, RValueCallable>::value, "");
- }
-#endif
-}
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
deleted file mode 100644
index 75e2ecac3c41..000000000000
--- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <functional>
-
-// class function<R(ArgTypes...)>
-
-// template<class F> function(F);
-
-// Allow incomplete argument types in the __is_callable check
-
-#include <functional>
-#include <cassert>
-
-struct X{
- typedef std::function<void(X&)> callback_type;
- virtual ~X() {}
-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()
-{
- 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);
- }
- {
- IncompleteReturnType Empty;
- IncompleteReturnType X2 = Empty;
- assert(!X2.fn);
- }
-}
-
-int main() {
- test_pr34298();
-}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_nullptr.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_nullptr.pass.cpp
deleted file mode 100644
index 3affd984af60..000000000000
--- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_nullptr.pass.cpp
+++ /dev/null
@@ -1,247 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <functional>
-
-// class function<R(ArgTypes...)>
-
-// function(Fp);
-
-// Ensure that __not_null works for all function types.
-// See https://bugs.llvm.org/show_bug.cgi?id=23589
-
-//------------------------------------------------------------------------------
-// TESTING std::function<...>::__not_null(Callable)
-//
-// Concerns:
-// 1) The call __not_null(Callable) is well formed and correct for each
-// possible 'Callable' type category. These categories include:
-// 1a) function pointers
-// 1b) member function pointer
-// 1c) member data pointer
-// 1d) callable class type
-// 1e) lambdas
-// Categories 1a, 1b, and 1c are 'Nullable' types. Only objects of these
-// types can be null. The other categories are not tested here.
-// 3) '__not_null(Callable)' is well formed when the call signature includes
-// varargs.
-// 4) '__not_null(Callable)' works for Callable types with all arities less
-// than or equal to 3 in C++03.
-// 5) '__not_null(Callable)' works when 'Callable' is a member function
-// pointer to a cv or ref qualified function type.
-//
-// Plan:
-// 1 For categories 1a, 1b and 1c define a set of
-// 'Callable' objects for this category. This set should include examples
-// of arity 0, 1, 2 and possible 3 including versions with varargs as the
-// last parameter.
-//
-// 2 For each 'Callable' object in categories 1a, 1b and 1c do the following.
-//
-// 1 Define a type 'std::function<Sig>' as 'F' where 'Sig' is compatible with
-// the signature of the 'Callable' object.
-//
-// 2 Create an object of type 'F' using a null pointer of type 'Callable'.
-// Check that 'F.target<Callable>()' is null.
-//
-// 3 Create an object of type 'F' that is not null. Check that
-// 'F.target<Callable>()' is not null and is equal to the original
-// argument.
-
-#include <functional>
-#include <type_traits>
-#include <cassert>
-
-#include "test_macros.h"
-
-///////////////////////////////////////////////////////////////////////////////
-int foo() { return 42; }
-int foo(int) { return 42; }
-int foo(int, int) { return 42; }
-int foo(int, int, int) { return 42; }
-
-int foo(...) { return 42; }
-int foo(int, ...) { return 42; }
-int foo(int, int, ...) { return 42; }
-int foo(int, int, int, ...) { return 42; }
-
-///////////////////////////////////////////////////////////////////////////////
-struct MemFun03 {
- int foo() { return 42; }
- int foo() const { return 42; }
- int foo() volatile { return 42; }
- int foo() const volatile { return 42; }
-
- int foo(int) { return 42; }
- int foo(int) const { return 42; }
- int foo(int) volatile { return 42; }
- int foo(int) const volatile { return 42; }
-
- int foo(int, int) { return 42; }
- int foo(int, int) const { return 42; }
- int foo(int, int) volatile { return 42; }
- int foo(int, int) const volatile { return 42; }
-
- int foo(int, int, int) { return 42; }
- int foo(int, int, int) const { return 42; }
- int foo(int, int, int) volatile { return 42; }
- int foo(int, int, int) const volatile { return 42; }
-
- int foo(...) { return 42; }
- int foo(...) const { return 42; }
- int foo(...) volatile { return 42; }
- int foo(...) const volatile { return 42; }
-
- int foo(int, ...) { return 42; }
- int foo(int, ...) const { return 42; }
- int foo(int, ...) volatile { return 42; }
- int foo(int, ...) const volatile { return 42; }
-
- int foo(int, int, ...) { return 42; }
- int foo(int, int, ...) const { return 42; }
- int foo(int, int, ...) volatile { return 42; }
- int foo(int, int, ...) const volatile { return 42; }
-
- int foo(int, int, int, ...) { return 42; }
- int foo(int, int, int, ...) const { return 42; }
- int foo(int, int, int, ...) volatile { return 42; }
- int foo(int, int, int, ...) const volatile { return 42; }
-};
-
-#if TEST_STD_VER >= 11
-struct MemFun11 {
- int foo() & { return 42; }
- int foo() const & { return 42; }
- int foo() volatile & { return 42; }
- int foo() const volatile & { return 42; }
-
- int foo(...) & { return 42; }
- int foo(...) const & { return 42; }
- int foo(...) volatile & { return 42; }
- int foo(...) const volatile & { return 42; }
-
- int foo() && { return 42; }
- int foo() const && { return 42; }
- int foo() volatile && { return 42; }
- int foo() const volatile && { return 42; }
-
- int foo(...) && { return 42; }
- int foo(...) const && { return 42; }
- int foo(...) volatile && { return 42; }
- int foo(...) const volatile && { return 42; }
-};
-#endif // TEST_STD_VER >= 11
-
-struct MemData {
- int foo;
-};
-
-// Create a non-null free function by taking the address of
-// &static_cast<Tp&>(foo);
-template <class Tp>
-struct Creator {
- static Tp create() {
- return &foo;
- }
-};
-
-// Create a non-null member pointer.
-template <class Ret, class Class>
-struct Creator<Ret Class::*> {
- typedef Ret Class::*ReturnType;
- static ReturnType create() {
- return &Class::foo;
- }
-};
-
-template <class TestFn, class Fn>
-void test_imp() {
- { // Check that the null value is detected
- TestFn tf = nullptr;
- std::function<Fn> f = tf;
- assert(f.template target<TestFn>() == nullptr);
- }
- { // Check that the non-null value is detected.
- TestFn tf = Creator<TestFn>::create();
- assert(tf != nullptr);
- std::function<Fn> f = tf;
- assert(f.template target<TestFn>() != nullptr);
- assert(*f.template target<TestFn>() == tf);
- }
-}
-
-void test_func() {
- test_imp<int(*)(), int()>();
- test_imp<int(*)(...), int()>();
- test_imp<int(*)(int), int(int)>();
- test_imp<int(*)(int, ...), int(int)>();
- test_imp<int(*)(int, int), int(int, int)>();
- test_imp<int(*)(int, int, ...), int(int, int)>();
- test_imp<int(*)(int, int, int), int(int, int, int)>();
- test_imp<int(*)(int, int, int, ...), int(int, int, int)>();
-}
-
-void test_mf() {
- test_imp<int(MemFun03::*)(), int(MemFun03&)>();
- test_imp<int(MemFun03::*)(...), int(MemFun03&)>();
- test_imp<int(MemFun03::*)() const, int(MemFun03&)>();
- test_imp<int(MemFun03::*)(...) const, int(MemFun03&)>();
- test_imp<int(MemFun03::*)() volatile, int(MemFun03&)>();
- test_imp<int(MemFun03::*)(...) volatile, int(MemFun03&)>();
- test_imp<int(MemFun03::*)() const volatile, int(MemFun03&)>();
- test_imp<int(MemFun03::*)(...) const volatile, int(MemFun03&)>();
-
- test_imp<int(MemFun03::*)(int), int(MemFun03&, int)>();
- test_imp<int(MemFun03::*)(int, ...), int(MemFun03&, int)>();
- test_imp<int(MemFun03::*)(int) const, int(MemFun03&, int)>();
- test_imp<int(MemFun03::*)(int, ...) const, int(MemFun03&, int)>();
- test_imp<int(MemFun03::*)(int) volatile, int(MemFun03&, int)>();
- test_imp<int(MemFun03::*)(int, ...) volatile, int(MemFun03&, int)>();
- test_imp<int(MemFun03::*)(int) const volatile, int(MemFun03&, int)>();
- test_imp<int(MemFun03::*)(int, ...) const volatile, int(MemFun03&, int)>();
-
- test_imp<int(MemFun03::*)(int, int), int(MemFun03&, int, int)>();
- test_imp<int(MemFun03::*)(int, int, ...), int(MemFun03&, int, int)>();
- test_imp<int(MemFun03::*)(int, int) const, int(MemFun03&, int, int)>();
- test_imp<int(MemFun03::*)(int, int, ...) const, int(MemFun03&, int, int)>();
- test_imp<int(MemFun03::*)(int, int) volatile, int(MemFun03&, int, int)>();
- test_imp<int(MemFun03::*)(int, int, ...) volatile, int(MemFun03&, int, int)>();
- test_imp<int(MemFun03::*)(int, int) const volatile, int(MemFun03&, int, int)>();
- test_imp<int(MemFun03::*)(int, int, ...) const volatile, int(MemFun03&, int, int)>();
-
-#if TEST_STD_VER >= 11
- test_imp<int(MemFun11::*)() &, int(MemFun11&)>();
- test_imp<int(MemFun11::*)(...) &, int(MemFun11&)>();
- test_imp<int(MemFun11::*)() const &, int(MemFun11&)>();
- test_imp<int(MemFun11::*)(...) const &, int(MemFun11&)>();
- test_imp<int(MemFun11::*)() volatile &, int(MemFun11&)>();
- test_imp<int(MemFun11::*)(...) volatile &, int(MemFun11&)>();
- test_imp<int(MemFun11::*)() const volatile &, int(MemFun11&)>();
- test_imp<int(MemFun11::*)(...) const volatile &, int(MemFun11&)>();
-
- test_imp<int(MemFun11::*)() &&, int(MemFun11&&)>();
- test_imp<int(MemFun11::*)(...) &&, int(MemFun11&&)>();
- test_imp<int(MemFun11::*)() const &&, int(MemFun11&&)>();
- test_imp<int(MemFun11::*)(...) const &&, int(MemFun11&&)>();
- test_imp<int(MemFun11::*)() volatile &&, int(MemFun11&&)>();
- test_imp<int(MemFun11::*)(...) volatile &&, int(MemFun11&&)>();
- test_imp<int(MemFun11::*)() const volatile &&, int(MemFun11&&)>();
- test_imp<int(MemFun11::*)(...) const volatile &&, int(MemFun11&&)>();
-#endif
-}
-
-void test_md() {
- test_imp<int MemData::*, int(MemData&)>();
-}
-
-int main() {
- test_func();
- test_mf();
- test_md();
-}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.fail.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.fail.cpp
deleted file mode 100644
index f455f0311847..000000000000
--- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.fail.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <functional>
-// XFAIL: c++98, c++03, c++11, c++14
-
-// class function<R(ArgTypes...)>
-
-// template<class A> function(allocator_arg_t, const A&);
-
-#include <functional>
-#include <cassert>
-
-#include "min_allocator.h"
-
-int main()
-{
- std::function<int(int)> f(std::allocator_arg, std::allocator<int>());
-}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp
deleted file mode 100644
index adc7856357e7..000000000000
--- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <functional>
-// REQUIRES: c++98 || c++03 || c++11 || c++14
-
-// class function<R(ArgTypes...)>
-
-// template<class A> function(allocator_arg_t, const A&);
-//
-// This signature was removed in C++17
-
-#include <functional>
-#include <cassert>
-
-#include "min_allocator.h"
-
-int main()
-{
- {
- std::function<int(int)> f(std::allocator_arg, bare_allocator<int>());
- assert(!f);
- }
-}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.fail.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.fail.cpp
deleted file mode 100644
index b23153465168..000000000000
--- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.fail.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <functional>
-// XFAIL: c++98, c++03, c++11, c++14
-
-// class function<R(ArgTypes...)>
-
-// template<class F, class A> function(allocator_arg_t, const A&, F);
-//
-// This signature was removed in C++17
-
-#include <functional>
-#include <cassert>
-
-#include "test_macros.h"
-
-void foo(int) {}
-
-int main()
-{
- std::function<void(int)> f(std::allocator_arg, std::allocator<int>(), foo);
-}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp
deleted file mode 100644
index 8a2a12e0f789..000000000000
--- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <functional>
-// REQUIRES: c++98 || c++03 || c++11 || c++14
-
-// class function<R(ArgTypes...)>
-
-// template<class F, class A> function(allocator_arg_t, const A&, F);
-
-#include <functional>
-#include <cassert>
-
-#include "test_macros.h"
-#include "min_allocator.h"
-#include "test_allocator.h"
-#include "count_new.hpp"
-#include "../function_types.h"
-
-
-#if TEST_STD_VER >= 11
-struct RValueCallable {
- template <class ...Args>
- void operator()(Args&&...) && {}
-};
-struct LValueCallable {
- template <class ...Args>
- void operator()(Args&&...) & {}
-};
-#endif
-
-class DummyClass {};
-
-template <class FuncType, class AllocType>
-void test_FunctionObject(AllocType& alloc)
-{
- assert(globalMemCounter.checkOutstandingNewEq(0));
- {
- FunctionObject target;
- assert(FunctionObject::count == 1);
- assert(globalMemCounter.checkOutstandingNewEq(0));
- std::function<FuncType> f2(std::allocator_arg, alloc, target);
- assert(FunctionObject::count == 2);
- assert(globalMemCounter.checkOutstandingNewEq(1));
- assert(f2.template target<FunctionObject>());
- assert(f2.template target<FuncType>() == 0);
- assert(f2.template target<FuncType*>() == 0);
- }
- assert(FunctionObject::count == 0);
- assert(globalMemCounter.checkOutstandingNewEq(0));
-}
-
-
-template <class FuncType, class AllocType>
-void test_FreeFunction(AllocType& alloc)
-{
- assert(globalMemCounter.checkOutstandingNewEq(0));
- {
- FuncType* target = &FreeFunction;
- assert(globalMemCounter.checkOutstandingNewEq(0));
- std::function<FuncType> f2(std::allocator_arg, alloc, target);
- assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f2.template target<FuncType*>());
- assert(*f2.template target<FuncType*>() == target);
- assert(f2.template target<FuncType>() == 0);
- assert(f2.template target<DummyClass>() == 0);
- }
- assert(globalMemCounter.checkOutstandingNewEq(0));
-}
-
-template <class TargetType, class FuncType, class AllocType>
-void test_MemFunClass(AllocType& alloc)
-{
- assert(globalMemCounter.checkOutstandingNewEq(0));
- {
- TargetType target = &MemFunClass::foo;
- assert(globalMemCounter.checkOutstandingNewEq(0));
- std::function<FuncType> f2(std::allocator_arg, alloc, target);
- assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f2.template target<TargetType>());
- assert(*f2.template target<TargetType>() == target);
- assert(f2.template target<FuncType*>() == 0);
- }
- assert(globalMemCounter.checkOutstandingNewEq(0));
-}
-
-template <class Alloc>
-void test_for_alloc(Alloc& alloc) {
- test_FunctionObject<int()>(alloc);
- test_FunctionObject<int(int)>(alloc);
- test_FunctionObject<int(int, int)>(alloc);
- test_FunctionObject<int(int, int, int)>(alloc);
-
- test_FreeFunction<int()>(alloc);
- test_FreeFunction<int(int)>(alloc);
- test_FreeFunction<int(int, int)>(alloc);
- test_FreeFunction<int(int, int, int)>(alloc);
-
- test_MemFunClass<int(MemFunClass::*)() const, int(MemFunClass&)>(alloc);
- test_MemFunClass<int(MemFunClass::*)(int) const, int(MemFunClass&, int)>(alloc);
- test_MemFunClass<int(MemFunClass::*)(int, int) const, int(MemFunClass&, int, int)>(alloc);
-}
-
-int main()
-{
- {
- bare_allocator<DummyClass> bare_alloc;
- test_for_alloc(bare_alloc);
- }
- {
- non_default_test_allocator<DummyClass> non_default_alloc(42);
- test_for_alloc(non_default_alloc);
- }
-#if TEST_STD_VER >= 11
- {
- using Fn = std::function<void(int, int, int)>;
- static_assert(std::is_constructible<Fn, std::allocator_arg_t, std::allocator<int>, LValueCallable&>::value, "");
- static_assert(std::is_constructible<Fn, std::allocator_arg_t, std::allocator<int>, LValueCallable>::value, "");
- static_assert(!std::is_constructible<Fn, std::allocator_arg_t, std::allocator<int>, RValueCallable&>::value, "");
- static_assert(!std::is_constructible<Fn, std::allocator_arg_t, std::allocator<int>, RValueCallable>::value, "");
- }
-#endif
-
-}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.fail.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.fail.cpp
deleted file mode 100644
index 2e4633b11693..000000000000
--- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.fail.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <functional>
-// XFAIL: c++98, c++03, c++11, c++14
-
-// class function<R(ArgTypes...)>
-
-// template<class A> function(allocator_arg_t, const A&, const function&);
-//
-// This signature was removed in C++17
-
-
-#include <functional>
-#include <cassert>
-
-#include "test_macros.h"
-
-int main()
-{
- typedef std::function<void(int)> F;
- F f1;
- F f2(std::allocator_arg, std::allocator<int>(), f1);
-}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp
deleted file mode 100644
index 8b0e831287a5..000000000000
--- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <functional>
-// REQUIRES: c++98 || c++03 || c++11 || c++14
-
-// class function<R(ArgTypes...)>
-
-// template<class A> function(allocator_arg_t, const A&, const function&);
-
-
-#include <functional>
-#include <cassert>
-
-#include "min_allocator.h"
-#include "test_allocator.h"
-#include "count_new.hpp"
-#include "../function_types.h"
-
-class DummyClass {};
-
-template <class FuncType, class AllocType>
-void test_FunctionObject(AllocType& alloc)
-{
- assert(globalMemCounter.checkOutstandingNewEq(0));
- {
- // Construct function from FunctionObject.
- std::function<FuncType> f = FunctionObject();
- assert(FunctionObject::count == 1);
- assert(globalMemCounter.checkOutstandingNewEq(1));
- assert(f.template target<FunctionObject>());
- assert(f.template target<FuncType>() == 0);
- assert(f.template target<FuncType*>() == 0);
- // Copy function with allocator
- std::function<FuncType> f2(std::allocator_arg, alloc, f);
- assert(FunctionObject::count == 2);
- assert(globalMemCounter.checkOutstandingNewEq(2));
- assert(f2.template target<FunctionObject>());
- assert(f2.template target<FuncType>() == 0);
- assert(f2.template target<FuncType*>() == 0);
- }
- assert(FunctionObject::count == 0);
- assert(globalMemCounter.checkOutstandingNewEq(0));
-}
-
-template <class FuncType, class AllocType>
-void test_FreeFunction(AllocType& alloc)
-{
- assert(globalMemCounter.checkOutstandingNewEq(0));
- {
- // Construct function from function pointer.
- FuncType* target = &FreeFunction;
- std::function<FuncType> f = target;
- assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f.template target<FuncType*>());
- assert(*f.template target<FuncType*>() == target);
- assert(f.template target<FuncType>() == 0);
- // Copy function with allocator
- std::function<FuncType> f2(std::allocator_arg, alloc, f);
- assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f2.template target<FuncType*>());
- assert(*f2.template target<FuncType*>() == target);
- assert(f2.template target<FuncType>() == 0);
- }
- assert(globalMemCounter.checkOutstandingNewEq(0));
-}
-
-template <class TargetType, class FuncType, class AllocType>
-void test_MemFunClass(AllocType& alloc)
-{
- assert(globalMemCounter.checkOutstandingNewEq(0));
- {
- // Construct function from function pointer.
- TargetType target = &MemFunClass::foo;
- std::function<FuncType> f = target;
- assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f.template target<TargetType>());
- assert(*f.template target<TargetType>() == target);
- assert(f.template target<FuncType*>() == 0);
- // Copy function with allocator
- std::function<FuncType> f2(std::allocator_arg, alloc, f);
- assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f2.template target<TargetType>());
- assert(*f2.template target<TargetType>() == target);
- assert(f2.template target<FuncType*>() == 0);
- }
- assert(globalMemCounter.checkOutstandingNewEq(0));
-}
-
-template <class Alloc>
-void test_for_alloc(Alloc& alloc)
-{
- // Large FunctionObject -- Allocation should occur
- test_FunctionObject<int()>(alloc);
- test_FunctionObject<int(int)>(alloc);
- test_FunctionObject<int(int, int)>(alloc);
- test_FunctionObject<int(int, int, int)>(alloc);
- // Free function -- No allocation should occur
- test_FreeFunction<int()>(alloc);
- test_FreeFunction<int(int)>(alloc);
- test_FreeFunction<int(int, int)>(alloc);
- test_FreeFunction<int(int, int, int)>(alloc);
- // Member function -- No allocation should occur.
- test_MemFunClass<int(MemFunClass::*)() const, int(MemFunClass&)>(alloc);
- test_MemFunClass<int(MemFunClass::*)(int) const, int(MemFunClass&, int)>(alloc);
- test_MemFunClass<int(MemFunClass::*)(int, int) const, int(MemFunClass&, int, int)>(alloc);
-}
-
-int main()
-{
- {
- bare_allocator<DummyClass> alloc;
- test_for_alloc(alloc);
- }
- {
- non_default_test_allocator<DummyClass> alloc(42);
- test_for_alloc(alloc);
- }
-}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.fail.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.fail.cpp
deleted file mode 100644
index cc4ecce75138..000000000000
--- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.fail.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <functional>
-// XFAIL: c++98, c++03, c++11, c++14
-
-// class function<R(ArgTypes...)>
-
-// template<class A> function(allocator_arg_t, const A&, nullptr_t);
-//
-// This signature was removed in C++17
-
-#include <functional>
-#include <cassert>
-
-#include "min_allocator.h"
-
-int main()
-{
- std::function<int(int)> f(std::allocator_arg, std::allocator<int>(), nullptr);
-}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp
deleted file mode 100644
index 943e170878f2..000000000000
--- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <functional>
-// REQUIRES: c++98 || c++03 || c++11 || c++14
-
-// class function<R(ArgTypes...)>
-
-// template<class A> function(allocator_arg_t, const A&, nullptr_t);
-//
-// This signature was removed in C++17
-
-#include <functional>
-#include <cassert>
-
-#include "min_allocator.h"
-
-int main()
-{
- std::function<int(int)> f(std::allocator_arg, bare_allocator<int>(), nullptr);
- assert(!f);
-}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.fail.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.fail.cpp
deleted file mode 100644
index cb9fb9afad2b..000000000000
--- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.fail.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <functional>
-// XFAIL: c++98, c++03, c++11, c++14
-
-// class function<R(ArgTypes...)>
-
-// template<class A> function(allocator_arg_t, const A&, function&&);
-//
-// This signature was removed in C++17
-
-#include <functional>
-#include <memory>
-#include <cassert>
-
-#include "test_macros.h"
-
-class A
-{
- int data_[10];
-public:
- static int count;
-
- A()
- {
- ++count;
- for (int i = 0; i < 10; ++i)
- data_[i] = i;
- }
-
- A(const A&) {++count;}
-
- ~A() {--count;}
-
- int operator()(int i) const
- {
- for (int j = 0; j < 10; ++j)
- i += data_[j];
- return i;
- }
-};
-
-int A::count = 0;
-
-int g(int) { return 0; }
-
-int main()
-{
- {
- std::function<int(int)> f = A();
- std::function<int(int)> f2(std::allocator_arg, std::allocator<A>(), std::move(f));
- }
-}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp
deleted file mode 100644
index 3e5435da1a16..000000000000
--- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// UNSUPPORTED: c++98, c++03
-// REQUIRES: c++11 || c++14
-
-// <functional>
-
-// class function<R(ArgTypes...)>
-
-// template<class A> function(allocator_arg_t, const A&, function&&);
-//
-// This signature was removed in C++17
-
-#include <functional>
-#include <memory>
-#include <cassert>
-
-#include "test_macros.h"
-#include "min_allocator.h"
-#include "count_new.hpp"
-
-class A
-{
- int data_[10];
-public:
- static int count;
-
- A()
- {
- ++count;
- for (int i = 0; i < 10; ++i)
- data_[i] = i;
- }
-
- A(const A&) {++count;}
-
- ~A() {--count;}
-
- int operator()(int i) const
- {
- for (int j = 0; j < 10; ++j)
- i += data_[j];
- return i;
- }
-};
-
-int A::count = 0;
-
-int g(int) { return 0; }
-
-int main()
-{
- assert(globalMemCounter.checkOutstandingNewEq(0));
- {
- std::function<int(int)> f = A();
- assert(A::count == 1);
- assert(globalMemCounter.checkOutstandingNewEq(1));
- assert(f.target<A>());
- assert(f.target<int(*)(int)>() == 0);
- std::function<int(int)> f2(std::allocator_arg, bare_allocator<A>(), std::move(f));
- assert(A::count == 1);
- assert(globalMemCounter.checkOutstandingNewEq(1));
- assert(f2.target<A>());
- assert(f2.target<int(*)(int)>() == 0);
- assert(f.target<A>() == 0);
- assert(f.target<int(*)(int)>() == 0);
- }
- assert(globalMemCounter.checkOutstandingNewEq(0));
- {
- // Test that moving a function constructed from a reference wrapper
- // is done without allocating.
- DisableAllocationGuard g;
- using Ref = std::reference_wrapper<A>;
- A a;
- Ref aref(a);
- std::function<int(int)> f(aref);
- assert(A::count == 1);
- assert(f.target<A>() == nullptr);
- assert(f.target<Ref>());
- std::function<int(int)> f2(std::allocator_arg, std::allocator<void>{},
- std::move(f));
- assert(A::count == 1);
- assert(f2.target<A>() == nullptr);
- assert(f2.target<Ref>());
- assert(f.target<Ref>()); // f is unchanged because the target is small
- }
- {
- // Test that moving a function constructed from a function pointer
- // is done without allocating
- DisableAllocationGuard guard;
- using Ptr = int(*)(int);
- Ptr p = g;
- std::function<int(int)> f(p);
- assert(f.target<A>() == nullptr);
- assert(f.target<Ptr>());
- std::function<int(int)> f2(std::allocator_arg, std::allocator<void>(),
- std::move(f));
- assert(f2.target<A>() == nullptr);
- assert(f2.target<Ptr>());
- assert(f.target<Ptr>()); // f is unchanged because the target is small
- }
-}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_assign.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_assign.pass.cpp
deleted file mode 100644
index 1c2be02c6212..000000000000
--- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_assign.pass.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <functional>
-
-// class function<R(ArgTypes...)>
-
-// function& operator=(const function& f);
-
-#include <functional>
-#include <cassert>
-
-#include "test_macros.h"
-#include "count_new.hpp"
-
-class A {
- int data_[10];
-
-public:
- static int count;
-
- A() {
- ++count;
- for (int i = 0; i < 10; ++i)
- data_[i] = i;
- }
-
- A(const A &) { ++count; }
-
- ~A() { --count; }
-
- int operator()(int i) const {
- for (int j = 0; j < 10; ++j)
- i += data_[j];
- return i;
- }
-};
-
-int A::count = 0;
-
-int g0() { return 0; }
-int g(int) { return 0; }
-int g2(int, int) { return 2; }
-int g3(int, int, int) { return 3; }
-
-int main() {
- assert(globalMemCounter.checkOutstandingNewEq(0));
- {
- std::function<int(int)> f = A();
- assert(A::count == 1);
- assert(globalMemCounter.checkOutstandingNewEq(1));
- assert(f.target<A>());
- assert(f.target<int (*)(int)>() == 0);
- std::function<int(int)> f2;
- f2 = f;
- assert(A::count == 2);
- assert(globalMemCounter.checkOutstandingNewEq(2));
- assert(f2.target<A>());
- assert(f2.target<int (*)(int)>() == 0);
- }
- assert(A::count == 0);
- assert(globalMemCounter.checkOutstandingNewEq(0));
- {
- std::function<int(int)> f = g;
- assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f.target<int (*)(int)>());
- assert(f.target<A>() == 0);
- std::function<int(int)> f2;
- f2 = f;
- assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f2.target<int (*)(int)>());
- assert(f2.target<A>() == 0);
- }
- assert(globalMemCounter.checkOutstandingNewEq(0));
- {
- std::function<int(int)> f;
- assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f.target<int (*)(int)>() == 0);
- assert(f.target<A>() == 0);
- std::function<int(int)> f2;
- f2 = f;
- assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f2.target<int (*)(int)>() == 0);
- assert(f2.target<A>() == 0);
- }
- {
- typedef std::function<int()> Func;
- Func f = g0;
- Func& fr = (f = (Func &)f);
- assert(&fr == &f);
- assert(*f.target<int(*)()>() == g0);
- }
- {
- typedef std::function<int(int)> Func;
- Func f = g;
- Func& fr = (f = (Func &)f);
- assert(&fr == &f);
- assert(*f.target<int(*)(int)>() == g);
- }
- {
- typedef std::function<int(int, int)> Func;
- Func f = g2;
- Func& fr = (f = (Func &)f);
- assert(&fr == &f);
- assert(*f.target<int(*)(int, int)>() == g2);
- }
- {
- typedef std::function<int(int, int, int)> Func;
- Func f = g3;
- Func& fr = (f = (Func &)f);
- assert(&fr == &f);
- assert(*f.target<int(*)(int, int, int)>() == g3);
- }
-#if TEST_STD_VER >= 11
- assert(globalMemCounter.checkOutstandingNewEq(0));
- {
- std::function<int(int)> f = A();
- assert(A::count == 1);
- assert(globalMemCounter.checkOutstandingNewEq(1));
- assert(f.target<A>());
- assert(f.target<int (*)(int)>() == 0);
- std::function<int(int)> f2;
- f2 = std::move(f);
- assert(A::count == 1);
- assert(globalMemCounter.checkOutstandingNewEq(1));
- assert(f2.target<A>());
- assert(f2.target<int (*)(int)>() == 0);
- assert(f.target<A>() == 0);
- assert(f.target<int (*)(int)>() == 0);
- }
-#endif
-}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_move.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_move.pass.cpp
deleted file mode 100644
index e9b399a2edd2..000000000000
--- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_move.pass.cpp
+++ /dev/null
@@ -1,165 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <functional>
-
-// class function<R(ArgTypes...)>
-
-// function(const function& f);
-// function(function&& f); // noexcept in C++20
-
-#include <functional>
-#include <memory>
-#include <cstdlib>
-#include <cassert>
-
-#include "test_macros.h"
-#include "count_new.hpp"
-
-class A
-{
- int data_[10];
-public:
- static int count;
-
- A()
- {
- ++count;
- for (int i = 0; i < 10; ++i)
- data_[i] = i;
- }
-
- A(const A&) {++count;}
-
- ~A() {--count;}
-
- int operator()(int i) const
- {
- for (int j = 0; j < 10; ++j)
- i += data_[j];
- return i;
- }
-};
-
-int A::count = 0;
-
-int g(int) {return 0;}
-
-int main()
-{
- assert(globalMemCounter.checkOutstandingNewEq(0));
- {
- std::function<int(int)> f = A();
- assert(A::count == 1);
- assert(globalMemCounter.checkOutstandingNewEq(1));
- assert(f.target<A>());
- assert(f.target<int(*)(int)>() == 0);
- std::function<int(int)> f2 = f;
- assert(A::count == 2);
- assert(globalMemCounter.checkOutstandingNewEq(2));
- assert(f2.target<A>());
- assert(f2.target<int(*)(int)>() == 0);
- }
- assert(A::count == 0);
- assert(globalMemCounter.checkOutstandingNewEq(0));
- {
- std::function<int(int)> f = g;
- assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f.target<int(*)(int)>());
- assert(f.target<A>() == 0);
- std::function<int(int)> f2 = f;
- assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f2.target<int(*)(int)>());
- assert(f2.target<A>() == 0);
- }
- assert(globalMemCounter.checkOutstandingNewEq(0));
- {
- std::function<int(int)> f;
- assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f.target<int(*)(int)>() == 0);
- assert(f.target<A>() == 0);
- std::function<int(int)> f2 = f;
- assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f2.target<int(*)(int)>() == 0);
- assert(f2.target<A>() == 0);
- }
- {
- std::function<int(int)> f;
- assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f.target<int(*)(int)>() == 0);
- assert(f.target<A>() == 0);
- assert(!f);
- std::function<long(int)> g = f;
- assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(g.target<long(*)(int)>() == 0);
- assert(g.target<A>() == 0);
- assert(!g);
- }
-#if TEST_STD_VER >= 11
- assert(globalMemCounter.checkOutstandingNewEq(0));
- { // Test rvalue references
- std::function<int(int)> f = A();
- assert(A::count == 1);
- assert(globalMemCounter.checkOutstandingNewEq(1));
- assert(f.target<A>());
- assert(f.target<int(*)(int)>() == 0);
- LIBCPP_ASSERT_NOEXCEPT(std::function<int(int)>(std::move(f)));
-#if TEST_STD_VER > 17
- ASSERT_NOEXCEPT(std::function<int(int)>(std::move(f)));
-#endif
- std::function<int(int)> f2 = std::move(f);
- assert(A::count == 1);
- assert(globalMemCounter.checkOutstandingNewEq(1));
- assert(f2.target<A>());
- assert(f2.target<int(*)(int)>() == 0);
- assert(f.target<A>() == 0);
- assert(f.target<int(*)(int)>() == 0);
- }
- assert(globalMemCounter.checkOutstandingNewEq(0));
- {
- // Test that moving a function constructed from a reference wrapper
- // is done without allocating.
- DisableAllocationGuard g;
- using Ref = std::reference_wrapper<A>;
- A a;
- Ref aref(a);
- std::function<int(int)> f(aref);
- assert(A::count == 1);
- assert(f.target<A>() == nullptr);
- assert(f.target<Ref>());
- LIBCPP_ASSERT_NOEXCEPT(std::function<int(int)>(std::move(f)));
-#if TEST_STD_VER > 17
- ASSERT_NOEXCEPT(std::function<int(int)>(std::move(f)));
-#endif
- std::function<int(int)> f2(std::move(f));
- assert(A::count == 1);
- assert(f2.target<A>() == nullptr);
- assert(f2.target<Ref>());
- LIBCPP_ASSERT(f.target<Ref>()); // f is unchanged because the target is small
- }
- {
- // Test that moving a function constructed from a function pointer
- // is done without allocating
- DisableAllocationGuard guard;
- using Ptr = int(*)(int);
- Ptr p = g;
- std::function<int(int)> f(p);
- assert(f.target<A>() == nullptr);
- assert(f.target<Ptr>());
- LIBCPP_ASSERT_NOEXCEPT(std::function<int(int)>(std::move(f)));
-#if TEST_STD_VER > 17
- ASSERT_NOEXCEPT(std::function<int(int)>(std::move(f)));
-#endif
- std::function<int(int)> f2(std::move(f));
- assert(f2.target<A>() == nullptr);
- assert(f2.target<Ptr>());
- LIBCPP_ASSERT(f.target<Ptr>()); // f is unchanged because the target is small
- }
-#endif // TEST_STD_VER >= 11
-}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/default.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/default.pass.cpp
deleted file mode 100644
index 83d61b6b2d89..000000000000
--- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/default.pass.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <functional>
-
-// class function<R(ArgTypes...)>
-
-// explicit function();
-
-#include <functional>
-#include <cassert>
-
-int main()
-{
- std::function<int(int)> f;
- assert(!f);
-}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/move_reentrant.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/move_reentrant.pass.cpp
deleted file mode 100644
index 0813c48f322e..000000000000
--- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/move_reentrant.pass.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <functional>
-
-// class function<R(ArgTypes...)>
-
-// function& operator=(function &&);
-
-#include <functional>
-#include <cassert>
-
-#include "test_macros.h"
-
-struct A
-{
- static std::function<void()> global;
- static bool cancel;
-
- ~A() {
- DoNotOptimize(cancel);
- if (cancel)
- global = std::function<void()>(nullptr);
- }
- void operator()() {}
-};
-
-std::function<void()> A::global;
-bool A::cancel = false;
-
-int main()
-{
- A::global = A();
- assert(A::global.target<A>());
-
- // Check that we don't recurse in A::~A().
- A::cancel = true;
- A::global = std::function<void()>(nullptr);
- assert(!A::global.target<A>());
-}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t.pass.cpp
deleted file mode 100644
index f0d6402d185e..000000000000
--- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t.pass.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <functional>
-
-// class function<R(ArgTypes...)>
-
-// function(nullptr_t);
-
-#include <functional>
-#include <cassert>
-
-int main()
-{
- std::function<int(int)> f(nullptr);
- assert(!f);
-}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign.pass.cpp
deleted file mode 100644
index 9b2482fb9d54..000000000000
--- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign.pass.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <functional>
-
-// class function<R(ArgTypes...)>
-
-// function& operator=(nullptr_t);
-
-#include <functional>
-#include <cassert>
-
-#include "count_new.hpp"
-
-class A
-{
- int data_[10];
-public:
- static int count;
-
- A()
- {
- ++count;
- for (int i = 0; i < 10; ++i)
- data_[i] = i;
- }
-
- A(const A&) {++count;}
-
- ~A() {--count;}
-
- int operator()(int i) const
- {
- for (int j = 0; j < 10; ++j)
- i += data_[j];
- return i;
- }
-};
-
-int A::count = 0;
-
-int g(int) {return 0;}
-
-int main()
-{
- assert(globalMemCounter.checkOutstandingNewEq(0));
- {
- std::function<int(int)> f = A();
- assert(A::count == 1);
- assert(globalMemCounter.checkOutstandingNewEq(1));
- assert(f.target<A>());
- f = nullptr;
- assert(A::count == 0);
- assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f.target<A>() == 0);
- }
- {
- std::function<int(int)> f = g;
- assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f.target<int(*)(int)>());
- assert(f.target<A>() == 0);
- f = nullptr;
- assert(globalMemCounter.checkOutstandingNewEq(0));
- assert(f.target<int(*)(int)>() == 0);
- }
-}
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign_reentrant.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign_reentrant.pass.cpp
deleted file mode 100644
index eeb181928eaf..000000000000
--- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign_reentrant.pass.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <functional>
-
-// class function<R(ArgTypes...)>
-
-// function& operator=(nullptr_t);
-
-#include <functional>
-#include <cassert>
-
-#include "test_macros.h"
-
-struct A
-{
- static std::function<void()> global;
- static bool cancel;
-
- ~A() {
- DoNotOptimize(cancel);
- if (cancel)
- global = nullptr;
- }
- void operator()() {}
-};
-
-std::function<void()> A::global;
-bool A::cancel = false;
-
-int main()
-{
- A::global = A();
- assert(A::global.target<A>());
-
- // Check that we don't recurse in A::~A().
- A::cancel = true;
- A::global = nullptr;
- assert(!A::global.target<A>());
-}