Skip to content

Commit f60ff00

Browse files
[libcxx][test] Silence nodiscard warnings (llvm#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.
1 parent b69fd34 commit f60ff00

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/shared_ptr_array.pass.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
#include <memory>
2121

2222
int main(int, char**) {
23-
std::allocate_shared<int[]>(std::allocator<int>{}, 10);
24-
std::make_shared<int[]>(10);
23+
(void)std::allocate_shared<int[]>(std::allocator<int>{}, 10);
24+
(void)std::make_shared<int[]>(10);
2525

26-
std::allocate_shared<int[10]>(std::allocator<int>{});
27-
std::make_shared<int[10]>();
26+
(void)std::allocate_shared<int[10]>(std::allocator<int>{});
27+
(void)std::make_shared<int[10]>();
2828

2929
return 0;
3030
}

libcxx/test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ TEST_CONSTEXPR_CXX23 bool test() {
6565
std::bitset<std::numeric_limits<unsigned long long>::digits + 1> q(0);
6666
q.flip();
6767
try {
68-
q.to_ullong(); // throws
68+
(void)q.to_ullong(); // throws
6969
assert(false);
7070
} catch (const std::overflow_error&) {
7171
// expected

libcxx/test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ TEST_CONSTEXPR_CXX23 bool test() {
6464
std::bitset<std::numeric_limits<unsigned long>::digits + 1> q(0);
6565
q.flip();
6666
try {
67-
q.to_ulong(); // throws
67+
(void)q.to_ulong(); // throws
6868
assert(false);
6969
} catch (const std::overflow_error&) {
7070
// expected

0 commit comments

Comments
 (0)