From owner-svn-src-stable@freebsd.org Mon Oct 31 18:37:46 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 50A20C273E9; Mon, 31 Oct 2016 18:37:46 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2A2A31035; Mon, 31 Oct 2016 18:37:46 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9VIbjWb023536; Mon, 31 Oct 2016 18:37:45 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9VIbjhs023532; Mon, 31 Oct 2016 18:37:45 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201610311837.u9VIbjhs023532@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Mon, 31 Oct 2016 18:37:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r308143 - stable/10/contrib/libc++/include X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Oct 2016 18:37:46 -0000 Author: dim Date: Mon Oct 31 18:37:44 2016 New Revision: 308143 URL: https://svnweb.freebsd.org/changeset/base/308143 Log: Pull in r228705 from upstream libc++ trunk (by Eric Fiselier): [libcxx] Fix PR 22468 - std::function does not accept non-void-returning functions Summary: The bug can be found here: https://llvm.org/bugs/show_bug.cgi?id=22468 `__invoke_void_return_wrapper` is needed to properly handle calling a function that returns a value but where the std::function return type is void. Without this '-Wsystem-headers' will cause `function::operator()(...)` to not compile. Reviewers: eugenis, K-ballo, mclow.lists Reviewed By: mclow.lists Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D7444 This should allow newer versions of the graphics/aseprite port to compile without modification. Direct commit to stable/10, since stable/11 and head already have this change. Reported by: yuri@rawbw.com PR: 213773 Modified: stable/10/contrib/libc++/include/__functional_03 stable/10/contrib/libc++/include/__functional_base stable/10/contrib/libc++/include/__functional_base_03 stable/10/contrib/libc++/include/functional Modified: stable/10/contrib/libc++/include/__functional_03 ============================================================================== --- stable/10/contrib/libc++/include/__functional_03 Mon Oct 31 18:37:05 2016 (r308142) +++ stable/10/contrib/libc++/include/__functional_03 Mon Oct 31 18:37:44 2016 (r308143) @@ -369,7 +369,8 @@ template::operator()() { - return __invoke(__f_.first()); + typedef __invoke_void_return_wrapper<_Rp> _Invoker; + return _Invoker::__call(__f_.first()); } #ifndef _LIBCPP_NO_RTTI @@ -452,7 +453,8 @@ template::operator()(_A0 __a0) { - return __invoke(__f_.first(), __a0); + typedef __invoke_void_return_wrapper<_Rp> _Invoker; + return _Invoker::__call(__f_.first(), __a0); } #ifndef _LIBCPP_NO_RTTI @@ -535,7 +537,8 @@ template::operator()(_A0 __a0, _A1 __a1) { - return __invoke(__f_.first(), __a0, __a1); + typedef __invoke_void_return_wrapper<_Rp> _Invoker; + return _Invoker::__call(__f_.first(), __a0, __a1); } #ifndef _LIBCPP_NO_RTTI @@ -618,7 +621,8 @@ template::operator()(_A0 __a0, _A1 __a1, _A2 __a2) { - return __invoke(__f_.first(), __a0, __a1, __a2); + typedef __invoke_void_return_wrapper<_Rp> _Invoker; + return _Invoker::__call(__f_.first(), __a0, __a1, __a2); } #ifndef _LIBCPP_NO_RTTI Modified: stable/10/contrib/libc++/include/__functional_base ============================================================================== --- stable/10/contrib/libc++/include/__functional_base Mon Oct 31 18:37:05 2016 (r308142) +++ stable/10/contrib/libc++/include/__functional_base Mon Oct 31 18:37:44 2016 (r308143) @@ -419,6 +419,26 @@ struct __invoke_return typedef decltype(__invoke(_VSTD::declval<_Tp>(), _VSTD::declval<_Args>()...)) type; }; +template +struct __invoke_void_return_wrapper +{ + template + static _Ret __call(_Args&&... __args) + { + return __invoke(_VSTD::forward<_Args>(__args)...); + } +}; + +template <> +struct __invoke_void_return_wrapper +{ + template + static void __call(_Args&&... __args) + { + __invoke(_VSTD::forward<_Args>(__args)...); + } +}; + template class _LIBCPP_TYPE_VIS_ONLY reference_wrapper : public __weak_result_type<_Tp> Modified: stable/10/contrib/libc++/include/__functional_base_03 ============================================================================== --- stable/10/contrib/libc++/include/__functional_base_03 Mon Oct 31 18:37:05 2016 (r308142) +++ stable/10/contrib/libc++/include/__functional_base_03 Mon Oct 31 18:37:44 2016 (r308143) @@ -995,6 +995,63 @@ struct __invoke_return2 _VSTD::declval<_A2>())) type; }; +template +struct __invoke_void_return_wrapper +{ + template + static _Ret __call(_Fn __f) + { + return __invoke(__f); + } + + template + static _Ret __call(_Fn __f, _A0& __a0) + { + return __invoke(__f, __a0); + } + + template + static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1) + { + return __invoke(__f, __a0, __a1); + } + + template + static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2) + { + return __invoke(__f, __a0, __a1, __a2); + } +}; + + +template <> +struct __invoke_void_return_wrapper +{ + template + static void __call(_Fn __f) + { + __invoke(__f); + } + + template + static void __call(_Fn __f, _A0& __a0) + { + __invoke(__f, __a0); + } + + template + static void __call(_Fn __f, _A0& __a0, _A1& __a1) + { + __invoke(__f, __a0, __a1); + } + + template + static void __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2) + { + __invoke(__f, __a0, __a1, __a2); + } +}; + template class _LIBCPP_TYPE_VIS_ONLY reference_wrapper : public __weak_result_type<_Tp> Modified: stable/10/contrib/libc++/include/functional ============================================================================== --- stable/10/contrib/libc++/include/functional Mon Oct 31 18:37:05 2016 (r308142) +++ stable/10/contrib/libc++/include/functional Mon Oct 31 18:37:44 2016 (r308143) @@ -1367,7 +1367,8 @@ template::operator()(_ArgTypes&& ... __arg) { - return __invoke(__f_.first(), _VSTD::forward<_ArgTypes>(__arg)...); + typedef __invoke_void_return_wrapper<_Rp> _Invoker; + return _Invoker::__call(__f_.first(), _VSTD::forward<_ArgTypes>(__arg)...); } #ifndef _LIBCPP_NO_RTTI @@ -1429,7 +1430,7 @@ class _LIBCPP_TYPE_VIS_ONLY function<_Rp template struct __callable<_Fp, true> { - static const bool value = + static const bool value = is_same::value || is_convertible::type, _Rp>::value; };