From f36202620b428c45a1c8d91743727c9313424fb2 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sat, 28 Jul 2018 11:07:56 +0000 Subject: Vendor import of libc++ trunk r338150: https://llvm.org/svn/llvm-project/libcxx/trunk@338150 --- .../func.wrap.func.con/move_reentrant.pass.cpp | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/move_reentrant.pass.cpp (limited to 'test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/move_reentrant.pass.cpp') 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 new file mode 100644 index 000000000000..0813c48f322e --- /dev/null +++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/move_reentrant.pass.cpp @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// class function + +// function& operator=(function &&); + +#include +#include + +#include "test_macros.h" + +struct A +{ + static std::function global; + static bool cancel; + + ~A() { + DoNotOptimize(cancel); + if (cancel) + global = std::function(nullptr); + } + void operator()() {} +}; + +std::function A::global; +bool A::cancel = false; + +int main() +{ + A::global = A(); + assert(A::global.target()); + + // Check that we don't recurse in A::~A(). + A::cancel = true; + A::global = std::function(nullptr); + assert(!A::global.target()); +} -- cgit v1.3