[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.
This commit is contained in:
Stephan T. Lavavej 2025-08-21 00:28:17 -07:00 committed by GitHub
parent b69fd34e76
commit f60ff00939
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 6 deletions

View File

@ -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;
}

View File

@ -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

View File

@ -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