[libcxx-commits] [libcxx] f60ff00 - [libcxx][test] Silence nodiscard warnings (#154622)
via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Aug 21 00:28:20 PDT 2025
Author: Stephan T. Lavavej
Date: 2025-08-21T00:28:17-07:00
New Revision: f60ff00939a50065c45a32276e90f367c7e2c22a
URL: https://github.com/llvm/llvm-project/commit/f60ff00939a50065c45a32276e90f367c7e2c22a
DIFF: https://github.com/llvm/llvm-project/commit/f60ff00939a50065c45a32276e90f367c7e2c22a.diff
LOG: [libcxx][test] Silence nodiscard warnings (#154622)
MSVC's STL marks `std::make_shared`, `std::allocate_shared`,
`std::bitset::to_ulong`, and `std::bitset::to_ullong` as
`[[nodiscard]]`, which causes these libcxx tests to emit righteous
warnings. They should use the traditional `(void)` cast technique to
ignore the return values.
Added:
Modified:
libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/shared_ptr_array.pass.cpp
libcxx/test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp
libcxx/test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp
Removed:
################################################################################
diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/shared_ptr_array.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/shared_ptr_array.pass.cpp
index 9bc695cd7fb76..f71f688afc52e 100644
--- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/shared_ptr_array.pass.cpp
+++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/shared_ptr_array.pass.cpp
@@ -20,11 +20,11 @@
#include <memory>
int main(int, char**) {
- std::allocate_shared<int[]>(std::allocator<int>{}, 10);
- std::make_shared<int[]>(10);
+ (void)std::allocate_shared<int[]>(std::allocator<int>{}, 10);
+ (void)std::make_shared<int[]>(10);
- std::allocate_shared<int[10]>(std::allocator<int>{});
- std::make_shared<int[10]>();
+ (void)std::allocate_shared<int[10]>(std::allocator<int>{});
+ (void)std::make_shared<int[10]>();
return 0;
}
diff --git a/libcxx/test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp
index 3c5a57d1c7fec..980dbe9ba15d0 100644
--- a/libcxx/test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp
+++ b/libcxx/test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp
@@ -65,7 +65,7 @@ TEST_CONSTEXPR_CXX23 bool test() {
std::bitset<std::numeric_limits<unsigned long long>::digits + 1> q(0);
q.flip();
try {
- q.to_ullong(); // throws
+ (void)q.to_ullong(); // throws
assert(false);
} catch (const std::overflow_error&) {
// expected
diff --git a/libcxx/test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp
index d943030a16287..47ad127513ade 100644
--- a/libcxx/test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp
+++ b/libcxx/test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp
@@ -64,7 +64,7 @@ TEST_CONSTEXPR_CXX23 bool test() {
std::bitset<std::numeric_limits<unsigned long>::digits + 1> q(0);
q.flip();
try {
- q.to_ulong(); // throws
+ (void)q.to_ulong(); // throws
assert(false);
} catch (const std::overflow_error&) {
// expected
More information about the libcxx-commits
mailing list