aboutsummaryrefslogtreecommitdiff
path: root/libcxx/test
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test')
-rw-r--r--libcxx/test/libcxx/numerics/nodiscard.verify.cpp35
-rw-r--r--libcxx/test/std/numerics/bit/bitops.rot/nodiscard.verify.cpp18
-rw-r--r--libcxx/test/std/utilities/function.objects/unord.hash/pointer.pass.cpp18
-rw-r--r--libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp2
-rw-r--r--libcxx/test/support/poisoned_hash_helper.h10
5 files changed, 46 insertions, 37 deletions
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>