diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/complexity.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/complexity.pass.cpp index dbf7b53406951..3b7c0ae0b80f0 100644 --- a/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/complexity.pass.cpp +++ b/libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/complexity.pass.cpp @@ -61,6 +61,7 @@ int main(int, char**) { const int debug_elements = std::min(100, n); // Multiplier 2 because of comp(a,b) comp(b, a) checks. const int debug_comparisons = 2 * (debug_elements + 1) * debug_elements; + (void)debug_comparisons; std::shuffle(first, last, g); std::make_heap(first, last); // The exact stats of our current implementation are recorded here. @@ -70,7 +71,6 @@ int main(int, char**) { LIBCPP_ASSERT(stats.moved <= 2 * n + n * logn); #if _LIBCPP_HARDENING_MODE != _LIBCPP_HARDENING_MODE_DEBUG LIBCPP_ASSERT(stats.compared <= n * logn); - (void)debug_comparisons; #else LIBCPP_ASSERT(stats.compared <= 2 * n * logn + debug_comparisons); #endif diff --git a/libcxx/test/std/containers/sequences/deque/deque.cons/from_range.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.cons/from_range.pass.cpp index 0ea7c17d7659c..cfc07ab7bc797 100644 --- a/libcxx/test/std/containers/sequences/deque/deque.cons/from_range.pass.cpp +++ b/libcxx/test/std/containers/sequences/deque/deque.cons/from_range.pass.cpp @@ -19,7 +19,7 @@ int main(int, char**) { for_all_iterators_and_allocators([]() { - test_sequence_container([](const auto& c) { + test_sequence_container([]([[maybe_unused]] const auto& c) { LIBCPP_ASSERT(c.__invariants()); }); }); diff --git a/libcxx/test/std/containers/sequences/deque/deque.modifiers/append_range.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.modifiers/append_range.pass.cpp index e6fe8c8b9e232..56a1d226db46f 100644 --- a/libcxx/test/std/containers/sequences/deque/deque.modifiers/append_range.pass.cpp +++ b/libcxx/test/std/containers/sequences/deque/deque.modifiers/append_range.pass.cpp @@ -26,7 +26,7 @@ int main(int, char**) { static_assert(test_constraints_append_range()); for_all_iterators_and_allocators([]() { - test_sequence_append_range, Iter, Sent>([](auto&& c) { + test_sequence_append_range, Iter, Sent>([]([[maybe_unused]] auto&& c) { LIBCPP_ASSERT(c.__invariants()); }); }); diff --git a/libcxx/test/std/containers/sequences/deque/deque.modifiers/assign_range.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.modifiers/assign_range.pass.cpp index b830000518d54..744e03a7b983e 100644 --- a/libcxx/test/std/containers/sequences/deque/deque.modifiers/assign_range.pass.cpp +++ b/libcxx/test/std/containers/sequences/deque/deque.modifiers/assign_range.pass.cpp @@ -25,7 +25,7 @@ int main(int, char**) { static_assert(test_constraints_assign_range()); for_all_iterators_and_allocators([]() { - test_sequence_assign_range, Iter, Sent>([](auto&& c) { + test_sequence_assign_range, Iter, Sent>([]([[maybe_unused]] auto&& c) { LIBCPP_ASSERT(c.__invariants()); }); }); diff --git a/libcxx/test/std/containers/sequences/deque/deque.modifiers/insert_range.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.modifiers/insert_range.pass.cpp index 7d0b3b9db28f8..a5f5455297ad4 100644 --- a/libcxx/test/std/containers/sequences/deque/deque.modifiers/insert_range.pass.cpp +++ b/libcxx/test/std/containers/sequences/deque/deque.modifiers/insert_range.pass.cpp @@ -26,7 +26,7 @@ int main(int, char**) { static_assert(test_constraints_insert_range()); for_all_iterators_and_allocators([]() { - test_sequence_insert_range, Iter, Sent>([](auto&& c) { + test_sequence_insert_range, Iter, Sent>([]([[maybe_unused]] auto&& c) { LIBCPP_ASSERT(c.__invariants()); }); }); diff --git a/libcxx/test/std/containers/sequences/deque/deque.modifiers/prepend_range.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.modifiers/prepend_range.pass.cpp index 08c9c02a8b699..3154cd389d2f0 100644 --- a/libcxx/test/std/containers/sequences/deque/deque.modifiers/prepend_range.pass.cpp +++ b/libcxx/test/std/containers/sequences/deque/deque.modifiers/prepend_range.pass.cpp @@ -26,7 +26,7 @@ int main(int, char**) { static_assert(test_constraints_prepend_range()); for_all_iterators_and_allocators([]() { - test_sequence_prepend_range, Iter, Sent>([](auto&& c) { + test_sequence_prepend_range, Iter, Sent>([]([[maybe_unused]] auto&& c) { LIBCPP_ASSERT(c.__invariants()); }); }); diff --git a/libcxx/test/std/containers/sequences/vector.bool/append_range.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/append_range.pass.cpp index e76f9bcd3110a..aafeec7669449 100644 --- a/libcxx/test/std/containers/sequences/vector.bool/append_range.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/append_range.pass.cpp @@ -25,7 +25,7 @@ constexpr bool test() { static_assert(test_constraints_append_range()); for_all_iterators_and_allocators([]() { - test_sequence_append_range, Iter, Sent>([](auto&& c) { + test_sequence_append_range, Iter, Sent>([]([[maybe_unused]] auto&& c) { LIBCPP_ASSERT(c.__invariants()); // `is_contiguous_container_asan_correct` doesn't work on `vector`. }); diff --git a/libcxx/test/std/containers/sequences/vector.bool/assign_range.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/assign_range.pass.cpp index 6ae5aa46d6cc1..e5d0454a844d5 100644 --- a/libcxx/test/std/containers/sequences/vector.bool/assign_range.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/assign_range.pass.cpp @@ -25,7 +25,7 @@ constexpr bool test() { static_assert(test_constraints_assign_range()); for_all_iterators_and_allocators([]() { - test_sequence_assign_range, Iter, Sent>([](auto&& c) { + test_sequence_assign_range, Iter, Sent>([]([[maybe_unused]] auto&& c) { LIBCPP_ASSERT(c.__invariants()); // `is_contiguous_container_asan_correct` doesn't work on `vector`. }); diff --git a/libcxx/test/std/containers/sequences/vector.bool/construct_from_range.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/construct_from_range.pass.cpp index d1f0bf06ed575..03f3100b92883 100644 --- a/libcxx/test/std/containers/sequences/vector.bool/construct_from_range.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/construct_from_range.pass.cpp @@ -18,7 +18,7 @@ constexpr bool test() { for_all_iterators_and_allocators([]() { - test_vector_bool([](const auto& c) { + test_vector_bool([]([[maybe_unused]] const auto& c) { LIBCPP_ASSERT(c.__invariants()); // `is_contiguous_container_asan_correct` doesn't work on `vector`. }); diff --git a/libcxx/test/std/containers/sequences/vector.bool/insert_range.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/insert_range.pass.cpp index 260a1037173e1..65d085fa1f083 100644 --- a/libcxx/test/std/containers/sequences/vector.bool/insert_range.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/insert_range.pass.cpp @@ -25,7 +25,7 @@ constexpr bool test() { static_assert(test_constraints_insert_range()); for_all_iterators_and_allocators([]() { - test_sequence_insert_range, Iter, Sent>([](auto&& c) { + test_sequence_insert_range, Iter, Sent>([]([[maybe_unused]] auto&& c) { LIBCPP_ASSERT(c.__invariants()); // `is_contiguous_container_asan_correct` doesn't work on `vector`. }); diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_from_range.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_from_range.pass.cpp index 2acdcc35da6f4..5fb2b46f7e942 100644 --- a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_from_range.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_from_range.pass.cpp @@ -19,7 +19,7 @@ constexpr bool test() { for_all_iterators_and_allocators([]() { - test_sequence_container([](const auto& c) { + test_sequence_container([]([[maybe_unused]] const auto& c) { LIBCPP_ASSERT(c.__invariants()); LIBCPP_ASSERT(is_contiguous_container_asan_correct(c)); }); diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/append_range.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/append_range.pass.cpp index 0a94534287534..69e6df6fcffa8 100644 --- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/append_range.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/append_range.pass.cpp @@ -27,7 +27,7 @@ constexpr bool test() { static_assert(test_constraints_append_range()); for_all_iterators_and_allocators([]() { - test_sequence_append_range, Iter, Sent>([](auto&& c) { + test_sequence_append_range, Iter, Sent>([]([[maybe_unused]] auto&& c) { LIBCPP_ASSERT(c.__invariants()); LIBCPP_ASSERT(is_contiguous_container_asan_correct(c)); }); diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/assign_range.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/assign_range.pass.cpp index 891c6df4474dc..8ab3dc10aed99 100644 --- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/assign_range.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/assign_range.pass.cpp @@ -27,7 +27,7 @@ constexpr bool test() { static_assert(test_constraints_assign_range()); for_all_iterators_and_allocators([]() { - test_sequence_assign_range, Iter, Sent>([](auto&& c) { + test_sequence_assign_range, Iter, Sent>([]([[maybe_unused]] auto&& c) { LIBCPP_ASSERT(c.__invariants()); LIBCPP_ASSERT(is_contiguous_container_asan_correct(c)); }); diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_range.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_range.pass.cpp index 3b900ce73e98f..0e26cb1546277 100644 --- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_range.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_range.pass.cpp @@ -26,7 +26,7 @@ constexpr bool test() { for_all_iterators_and_allocators([]() { - test_sequence_insert_range, Iter, Sent>([](auto&& c) { + test_sequence_insert_range, Iter, Sent>([]([[maybe_unused]] auto&& c) { LIBCPP_ASSERT(c.__invariants()); LIBCPP_ASSERT(is_contiguous_container_asan_correct(c)); }); diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/append_range.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/append_range.pass.cpp index 68327f65bdb38..d88e9f9573600 100644 --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/append_range.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/append_range.pass.cpp @@ -23,9 +23,8 @@ constexpr bool test_constexpr() { for_all_iterators_and_allocators_constexpr([]() { - test_sequence_append_range, Alloc>, Iter, Sent>([](auto&& c) { - LIBCPP_ASSERT(c.__invariants()); - }); + test_sequence_append_range, Alloc>, Iter, Sent>( + []([[maybe_unused]] auto&& c) { LIBCPP_ASSERT(c.__invariants()); }); }); return true; @@ -35,9 +34,8 @@ int main(int, char**) { static_assert(test_constraints_append_range()); for_all_iterators_and_allocators([]() { - test_sequence_append_range, Alloc>, Iter, Sent>([](auto&& c) { - LIBCPP_ASSERT(c.__invariants()); - }); + test_sequence_append_range, Alloc>, Iter, Sent>( + []([[maybe_unused]] auto&& c) { LIBCPP_ASSERT(c.__invariants()); }); }); static_assert(test_constexpr()); diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/assign_range.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/assign_range.pass.cpp index 5c43eeaf39dff..d51326f383304 100644 --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/assign_range.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/assign_range.pass.cpp @@ -23,9 +23,8 @@ constexpr bool test_constexpr() { for_all_iterators_and_allocators_constexpr([]() { - test_sequence_assign_range, Alloc>, Iter, Sent>([](auto&& c) { - LIBCPP_ASSERT(c.__invariants()); - }); + test_sequence_assign_range, Alloc>, Iter, Sent>( + []([[maybe_unused]] auto&& c) { LIBCPP_ASSERT(c.__invariants()); }); }); return true; @@ -35,9 +34,8 @@ int main(int, char**) { static_assert(test_constraints_assign_range()); for_all_iterators_and_allocators([]() { - test_sequence_assign_range, Alloc>, Iter, Sent>([](auto&& c) { - LIBCPP_ASSERT(c.__invariants()); - }); + test_sequence_assign_range, Alloc>, Iter, Sent>( + []([[maybe_unused]] auto&& c) { LIBCPP_ASSERT(c.__invariants()); }); }); static_assert(test_constexpr()); diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/insert_range.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/insert_range.pass.cpp index aefe73a9a507f..45d1f620e9054 100644 --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/insert_range.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/insert_range.pass.cpp @@ -23,9 +23,8 @@ constexpr bool test_constexpr() { for_all_iterators_and_allocators_constexpr([]() { - test_sequence_insert_range, Alloc>, Iter, Sent>([](auto&& c) { - LIBCPP_ASSERT(c.__invariants()); - }); + test_sequence_insert_range, Alloc>, Iter, Sent>( + []([[maybe_unused]] auto&& c) { LIBCPP_ASSERT(c.__invariants()); }); }); return true; @@ -35,9 +34,8 @@ int main(int, char**) { static_assert(test_constraints_insert_range()); for_all_iterators_and_allocators([]() { - test_sequence_insert_range, Alloc>, Iter, Sent>([](auto&& c) { - LIBCPP_ASSERT(c.__invariants()); - }); + test_sequence_insert_range, Alloc>, Iter, Sent>( + []([[maybe_unused]] auto&& c) { LIBCPP_ASSERT(c.__invariants()); }); }); static_assert(test_constexpr()); diff --git a/libcxx/test/std/thread/futures/futures.future_error/what.pass.cpp b/libcxx/test/std/thread/futures/futures.future_error/what.pass.cpp index fba2bd80d7f89..2e971a940c509 100644 --- a/libcxx/test/std/thread/futures/futures.future_error/what.pass.cpp +++ b/libcxx/test/std/thread/futures/futures.future_error/what.pass.cpp @@ -38,24 +38,24 @@ int main(int, char**) { #if TEST_STD_VER >= 17 { std::future_error const f(std::future_errc::broken_promise); - char const* what = f.what(); + [[maybe_unused]] char const* what = f.what(); LIBCPP_ASSERT(what == std::string_view{"The associated promise has been destructed prior " "to the associated state becoming ready."}); } { std::future_error f(std::future_errc::future_already_retrieved); - char const* what = f.what(); + [[maybe_unused]] char const* what = f.what(); LIBCPP_ASSERT(what == std::string_view{"The future has already been retrieved from " "the promise or packaged_task."}); } { std::future_error f(std::future_errc::promise_already_satisfied); - char const* what = f.what(); + [[maybe_unused]] char const* what = f.what(); LIBCPP_ASSERT(what == std::string_view{"The state of the promise has already been set."}); } { std::future_error f(std::future_errc::no_state); - char const* what = f.what(); + [[maybe_unused]] char const* what = f.what(); LIBCPP_ASSERT(what == std::string_view{"Operation not permitted on an object without " "an associated state."}); } diff --git a/libcxx/test/std/utilities/function.objects/func.invoke/invoke_r.pass.cpp b/libcxx/test/std/utilities/function.objects/func.invoke/invoke_r.pass.cpp index af4c0baf8c60c..8a08d3636d1e2 100644 --- a/libcxx/test/std/utilities/function.objects/func.invoke/invoke_r.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/func.invoke/invoke_r.pass.cpp @@ -91,7 +91,7 @@ constexpr bool test() { { bool was_called = false; auto f = [&](NonCopyable) -> int { was_called = true; return 0; }; - std::invoke_r(f, NonCopyable()); + (void)std::invoke_r(f, NonCopyable()); assert(was_called); } // Forward function object, with void return @@ -111,7 +111,7 @@ constexpr bool test() { constexpr int operator()() && { was_called = true; return 0; } }; bool was_called = false; - std::invoke_r(MoveOnlyIntFunction{was_called}); + (void)std::invoke_r(MoveOnlyIntFunction{was_called}); assert(was_called); } } diff --git a/libcxx/test/support/deduction_guides_sfinae_checks.h b/libcxx/test/support/deduction_guides_sfinae_checks.h index 8d1365848eafc..8b715da5a34e2 100644 --- a/libcxx/test/support/deduction_guides_sfinae_checks.h +++ b/libcxx/test/support/deduction_guides_sfinae_checks.h @@ -116,10 +116,10 @@ constexpr void SequenceContainerDeductionGuidesSfinaeAway() { template class Container, typename InstantiatedContainer> constexpr void ContainerAdaptorDeductionGuidesSfinaeAway() { using T = typename InstantiatedContainer::value_type; - using Alloc = std::allocator; + using Alloc [[maybe_unused]] = std::allocator; using Iter = T*; - using BadIter = int; + using BadIter [[maybe_unused]] = int; using BadAlloc = Empty; // (container) -- no constraints.