diff --git a/libcxx/docs/ReleaseNotes/20.rst b/libcxx/docs/ReleaseNotes/20.rst index 228c3f3432c29..15940948655d7 100644 --- a/libcxx/docs/ReleaseNotes/20.rst +++ b/libcxx/docs/ReleaseNotes/20.rst @@ -146,6 +146,8 @@ Deprecations and Removals ``__undeclare_reachable`` have been removed from the library. These functions were never implemented in a non-trivial way, making it very unlikely that any binary depends on them. +- Non-conforming extension ``packaged_task::result_type`` is deprecated. It will be removed in LLVM 21. + Upcoming Deprecations and Removals ---------------------------------- @@ -164,6 +166,8 @@ LLVM 21 - The ``_LIBCPP_VERBOSE_ABORT_NOT_NOEXCEPT`` macro will be removed in LLVM 21, making ``std::__libcpp_verbose_abort`` unconditionally ``noexcept``. +- Non-conforming extension ``packaged_task::result_type`` will be removed in LLVM 21. + ABI Affecting Changes --------------------- diff --git a/libcxx/include/future b/libcxx/include/future index d777ed8d6016f..72f3ed5ca5d27 100644 --- a/libcxx/include/future +++ b/libcxx/include/future @@ -1612,11 +1612,11 @@ inline _Rp __packaged_task_function<_Rp(_ArgTypes...)>::operator()(_ArgTypes... template class _LIBCPP_TEMPLATE_VIS packaged_task<_Rp(_ArgTypes...)> { public: - typedef _Rp result_type; // extension + using result_type _LIBCPP_DEPRECATED = _Rp; // extension private: - __packaged_task_function __f_; - promise __p_; + __packaged_task_function<_Rp(_ArgTypes...)> __f_; + promise<_Rp> __p_; public: // construction and destruction @@ -1653,7 +1653,7 @@ public: _LIBCPP_HIDE_FROM_ABI bool valid() const _NOEXCEPT { return __p_.__state_ != nullptr; } // result retrieval - _LIBCPP_HIDE_FROM_ABI future get_future() { return __p_.get_future(); } + _LIBCPP_HIDE_FROM_ABI future<_Rp> get_future() { return __p_.get_future(); } // execution _LIBCPP_HIDE_FROM_ABI void operator()(_ArgTypes... __args); @@ -1700,17 +1700,17 @@ template void packaged_task<_Rp(_ArgTypes...)>::reset() { if (!valid()) __throw_future_error(future_errc::no_state); - __p_ = promise(); + __p_ = promise<_Rp>(); } template class _LIBCPP_TEMPLATE_VIS packaged_task { public: - typedef void result_type; // extension + using result_type _LIBCPP_DEPRECATED = void; // extension private: - __packaged_task_function __f_; - promise __p_; + __packaged_task_function __f_; + promise __p_; public: // construction and destruction @@ -1745,7 +1745,7 @@ public: _LIBCPP_HIDE_FROM_ABI bool valid() const _NOEXCEPT { return __p_.__state_ != nullptr; } // result retrieval - _LIBCPP_HIDE_FROM_ABI future get_future() { return __p_.get_future(); } + _LIBCPP_HIDE_FROM_ABI future get_future() { return __p_.get_future(); } // execution _LIBCPP_HIDE_FROM_ABI void operator()(_ArgTypes... __args); @@ -1804,7 +1804,7 @@ template void packaged_task::reset() { if (!valid()) __throw_future_error(future_errc::no_state); - __p_ = promise(); + __p_ = promise(); } template diff --git a/libcxx/test/libcxx/thread/futures/futures.task/type.depr.verify.cpp b/libcxx/test/libcxx/thread/futures/futures.task/type.depr.verify.cpp new file mode 100644 index 0000000000000..4065637e9eb2a --- /dev/null +++ b/libcxx/test/libcxx/thread/futures/futures.task/type.depr.verify.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// UNSUPPORTED: no-threads +// UNSUPPORTED: c++03 + +// + +// template +// class packaged_task +// { +// public: +// typedef R result_type; // extension + +// This libc++ extension is deprecated. See https://github.com/llvm/llvm-project/issues/112856. + +#include +#include + +struct A {}; + +using RA = std::packaged_task::result_type; // expected-warning {{'result_type' is deprecated}} +using RV = std::packaged_task::result_type; // expected-warning {{'result_type' is deprecated}} diff --git a/libcxx/test/libcxx/thread/futures/futures.task/types.pass.cpp b/libcxx/test/libcxx/thread/futures/futures.task/types.pass.cpp index 1f17d74513471..659232caa46ec 100644 --- a/libcxx/test/libcxx/thread/futures/futures.task/types.pass.cpp +++ b/libcxx/test/libcxx/thread/futures/futures.task/types.pass.cpp @@ -19,16 +19,16 @@ // This is a libc++ extension. +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS + #include #include -#include "test_macros.h" - struct A {}; -int main(int, char**) -{ - static_assert((std::is_same::result_type, A>::value), ""); +int main(int, char**) { + static_assert((std::is_same::result_type, A>::value), ""); + static_assert((std::is_same::result_type, void>::value), ""); return 0; }