diff options
Diffstat (limited to 'libcxx')
8 files changed, 52 insertions, 52 deletions
diff --git a/libcxx/docs/Status/Cxx17Papers.csv b/libcxx/docs/Status/Cxx17Papers.csv index 1a9d3b0..6bb2982 100644 --- a/libcxx/docs/Status/Cxx17Papers.csv +++ b/libcxx/docs/Status/Cxx17Papers.csv @@ -84,7 +84,7 @@ "`P0508R0 <https://wg21.link/P0508R0>`__","Wording for GB 58 - structured bindings for node_handles","2016-11 (Issaquah)","|Complete|","7","`#99944 <https://github.com/llvm/llvm-project/issues/99944>`__","" "`P0509R1 <https://wg21.link/P0509R1>`__","Updating ""Restrictions on exception handling""","2016-11 (Issaquah)","|Nothing To Do|","n/a","`#103676 <https://github.com/llvm/llvm-project/issues/103676>`__","" "`P0510R0 <https://wg21.link/P0510R0>`__","Disallowing references, incomplete types, arrays, and empty variants","2016-11 (Issaquah)","|Complete|","4","`#103677 <https://github.com/llvm/llvm-project/issues/103677>`__","" -"`P0513R0 <https://wg21.link/P0513R0>`__","Poisoning the Hash","2016-11 (Issaquah)","|Complete|","5","`#103678 <https://github.com/llvm/llvm-project/issues/103678>`__","" +"`P0513R0 <https://wg21.link/P0513R0>`__","Poisoning the Hash","2016-11 (Issaquah)","|Complete|","5","`#103678 <https://github.com/llvm/llvm-project/issues/103678>`__","Implemented as a DR against C++11 since LLVM 22. MSVC STL does the same." "`P0516R0 <https://wg21.link/P0516R0>`__","Clarify That shared_future's Copy Operations have Wide Contracts","2016-11 (Issaquah)","|Complete|","4","`#103679 <https://github.com/llvm/llvm-project/issues/103679>`__","" "`P0517R0 <https://wg21.link/P0517R0>`__","Make future_error Constructible","2016-11 (Issaquah)","|Complete|","4","`#103680 <https://github.com/llvm/llvm-project/issues/103680>`__","" "`P0521R0 <https://wg21.link/P0521R0>`__","Proposed Resolution for CA 14 (shared_ptr use_count/unique)","2016-11 (Issaquah)","|Complete|","18","`#103681 <https://github.com/llvm/llvm-project/issues/103681>`__","" diff --git a/libcxx/include/__functional/hash.h b/libcxx/include/__functional/hash.h index 83bbf1b..f74f25f 100644 --- a/libcxx/include/__functional/hash.h +++ b/libcxx/include/__functional/hash.h @@ -433,13 +433,10 @@ struct __hash_impl<long double> : __scalar_hash<long double> { template <class _Tp> struct hash : public __hash_impl<_Tp> {}; -#if _LIBCPP_STD_VER >= 17 - template <> struct hash<nullptr_t> : public __unary_function<nullptr_t, size_t> { _LIBCPP_HIDE_FROM_ABI size_t operator()(nullptr_t) const _NOEXCEPT { return 662607004ull; } }; -#endif #ifndef _LIBCPP_CXX03_LANG template <class _Key, class _Hash> @@ -452,18 +449,12 @@ template <class _Key, class _Hash = hash<_Key> > using __has_enabled_hash _LIBCPP_NODEBUG = integral_constant<bool, __check_hash_requirements<_Key, _Hash>::value && is_default_constructible<_Hash>::value >; -# if _LIBCPP_STD_VER >= 17 template <class _Type, class> using __enable_hash_helper_imp _LIBCPP_NODEBUG = _Type; template <class _Type, class... _Keys> using __enable_hash_helper _LIBCPP_NODEBUG = __enable_hash_helper_imp<_Type, __enable_if_t<__all<__has_enabled_hash<_Keys>::value...>::value> >; -# else -template <class _Type, class...> -using __enable_hash_helper _LIBCPP_NODEBUG = _Type; -# endif - #endif // !_LIBCPP_CXX03_LANG _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/__numeric/saturation_arithmetic.h b/libcxx/include/__numeric/saturation_arithmetic.h index 7a7410b..4491bab 100644 --- a/libcxx/include/__numeric/saturation_arithmetic.h +++ b/libcxx/include/__numeric/saturation_arithmetic.h @@ -121,27 +121,27 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Rp __saturate_cast(_Tp __x) noexcept { #if _LIBCPP_STD_VER >= 26 template <__signed_or_unsigned_integer _Tp> -_LIBCPP_HIDE_FROM_ABI constexpr _Tp add_sat(_Tp __x, _Tp __y) noexcept { +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp add_sat(_Tp __x, _Tp __y) noexcept { return std::__add_sat(__x, __y); } template <__signed_or_unsigned_integer _Tp> -_LIBCPP_HIDE_FROM_ABI constexpr _Tp sub_sat(_Tp __x, _Tp __y) noexcept { +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp sub_sat(_Tp __x, _Tp __y) noexcept { return std::__sub_sat(__x, __y); } template <__signed_or_unsigned_integer _Tp> -_LIBCPP_HIDE_FROM_ABI constexpr _Tp mul_sat(_Tp __x, _Tp __y) noexcept { +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp mul_sat(_Tp __x, _Tp __y) noexcept { return std::__mul_sat(__x, __y); } template <__signed_or_unsigned_integer _Tp> -_LIBCPP_HIDE_FROM_ABI constexpr _Tp div_sat(_Tp __x, _Tp __y) noexcept { +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp div_sat(_Tp __x, _Tp __y) noexcept { return std::__div_sat(__x, __y); } template <__signed_or_unsigned_integer _Rp, __signed_or_unsigned_integer _Tp> -_LIBCPP_HIDE_FROM_ABI constexpr _Rp saturate_cast(_Tp __x) noexcept { +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Rp saturate_cast(_Tp __x) noexcept { return std::__saturate_cast<_Rp>(__x); } diff --git a/libcxx/test/libcxx/numerics/nodiscard.verify.cpp b/libcxx/test/libcxx/numerics/nodiscard.verify.cpp new file mode 100644 index 0000000..10da62f --- /dev/null +++ b/libcxx/test/libcxx/numerics/nodiscard.verify.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// REQUIRES: std-at-least-c++20 + +// <numeric> + +// Check that functions are marked [[nodiscard]] + +#include <bit> +#include <numeric> + +#include "test_macros.h" + +void test() { + // [bit.rotate] + std::rotl(0u, 0); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::rotr(0u, 0); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + + // clang-format off +#if TEST_STD_VER >= 26 + // [numeric.sat] + std::add_sat(94, 82); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::sub_sat(94, 82); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::mul_sat(94, 82); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::div_sat(94, 82); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::saturate_cast<signed int>(49); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} +#endif // TEST_STD_VER >= 26 + // clang-format on +} diff --git a/libcxx/test/std/numerics/bit/bitops.rot/nodiscard.verify.cpp b/libcxx/test/std/numerics/bit/bitops.rot/nodiscard.verify.cpp deleted file mode 100644 index 885534a..0000000 --- a/libcxx/test/std/numerics/bit/bitops.rot/nodiscard.verify.cpp +++ /dev/null @@ -1,18 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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: c++03, c++11, c++14, c++17 - -// Check that std::rotl and std::rotr are marked [[nodiscard]] - -#include <bit> - -void func() { - std::rotl(0u, 0); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} - std::rotr(0u, 0); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} -} diff --git a/libcxx/test/std/utilities/function.objects/unord.hash/pointer.pass.cpp b/libcxx/test/std/utilities/function.objects/unord.hash/pointer.pass.cpp index 448c5ba..ce331e5 100644 --- a/libcxx/test/std/utilities/function.objects/unord.hash/pointer.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/unord.hash/pointer.pass.cpp @@ -17,6 +17,8 @@ // size_t operator()(T val) const; // }; +// XFAIL: FROZEN-CXX03-HEADERS-FIXME + // Not very portable #include <cassert> @@ -44,18 +46,14 @@ test() assert(h(&i) != h(&j)); } -// can't hash nullptr_t until C++17 -void test_nullptr() -{ -#if TEST_STD_VER > 14 - typedef std::nullptr_t T; - typedef std::hash<T> H; +void test_nullptr() { + typedef std::nullptr_t T; + typedef std::hash<T> H; #if TEST_STD_VER <= 17 - static_assert((std::is_same<typename H::argument_type, T>::value), "" ); - static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" ); -#endif - ASSERT_NOEXCEPT(H()(T())); + static_assert((std::is_same<typename H::argument_type, T>::value), ""); + static_assert((std::is_same<typename H::result_type, std::size_t>::value), ""); #endif + ASSERT_NOEXCEPT(H()(T())); } int main(int, char**) diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp index 32fc949..e754049 100644 --- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp +++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp @@ -90,12 +90,10 @@ int main(int, char**) test_enabled_with_deleter<A, PointerDeleter<A, 1>>(); test_enabled_with_deleter<A[], PointerDeleter<A[], 1>>(); -#if TEST_STD_VER > 14 test_disabled_with_deleter<int, PointerDeleter<int, 0>>(); test_disabled_with_deleter<int[], PointerDeleter<int[], 0>>(); test_disabled_with_deleter<A, PointerDeleter<A, 0>>(); test_disabled_with_deleter<A[], PointerDeleter<A[], 0>>(); -#endif } #endif diff --git a/libcxx/test/support/poisoned_hash_helper.h b/libcxx/test/support/poisoned_hash_helper.h index 93b579d..cd71cd7 100644 --- a/libcxx/test/support/poisoned_hash_helper.h +++ b/libcxx/test/support/poisoned_hash_helper.h @@ -123,13 +123,9 @@ struct Class {}; // Each header that declares the std::hash template provides enabled // specializations of std::hash for std::nullptr_t and all cv-unqualified // arithmetic, enumeration, and pointer types. -#if TEST_STD_VER >= 17 -using MaybeNullptr = types::type_list<std::nullptr_t>; -#else -using MaybeNullptr = types::type_list<>; -#endif -using LibraryHashTypes = types:: - concatenate_t<types::arithmetic_types, types::type_list<Enum, EnumClass, void*, void const*, Class*>, MaybeNullptr>; +using LibraryHashTypes = + types::concatenate_t<types::arithmetic_types, + types::type_list<Enum, EnumClass, void*, void const*, Class*, std::nullptr_t>>; struct TestHashEnabled { template <class T> |
