From 279aec03456d9d4a0a85f1efb65eae057015076e Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Wed, 27 Aug 2025 22:01:33 +0300 Subject: [PATCH 1/2] [libcxx][test] Avoid warnings about unused variables and typedefs if _LIBCPP_VERSION is not defined Make these tests pass with MSVC STL --- .../flat.map.cons/move_assign_noexcept.compile.pass.cpp | 4 ++++ .../flat.map/flat.map.erasure/erase_if_exceptions.pass.cpp | 2 ++ .../flat.multimap.cons/move_assign_noexcept.compile.pass.cpp | 4 ++++ .../flat.multimap.erasure/erase_if_exceptions.pass.cpp | 2 ++ .../flat.set/flat.set.erasure/erase_if_exceptions.pass.cpp | 2 ++ 5 files changed, 14 insertions(+) diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_assign_noexcept.compile.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_assign_noexcept.compile.pass.cpp index 18d332cf27b5b..ea39686653b08 100644 --- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_assign_noexcept.compile.pass.cpp +++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_assign_noexcept.compile.pass.cpp @@ -50,10 +50,12 @@ struct MoveThrowsComp { }; void test() { +#if defined(_LIBCPP_VERSION) { using C = std::flat_map; LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable_v); } +#endif { using C = std::flat_map>>; static_assert(!std::is_nothrow_move_assignable_v); } +#if defined(_LIBCPP_VERSION) { using C = std::flat_map; LIBCPP_STATIC_ASSERT(!std::is_nothrow_move_assignable_v); } +#endif { // Test with a container that throws on move-assignment. using C = std::flat_map, std::pmr::vector, std::vector>; diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.erasure/erase_if_exceptions.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.erasure/erase_if_exceptions.pass.cpp index 48fdec42db3fc..b15c5755d9bdb 100644 --- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.erasure/erase_if_exceptions.pass.cpp +++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.erasure/erase_if_exceptions.pass.cpp @@ -66,7 +66,9 @@ struct ErasurePredicate { }; int main(int, char**) { +#if defined(_LIBCPP_VERSION) const std::pair expected[] = {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}, {6, 6}, {7, 7}, {8, 8}}; +#endif { using M = std::flat_map; for (int first_throw = 1; first_throw < 99; ++first_throw) { diff --git a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/move_assign_noexcept.compile.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/move_assign_noexcept.compile.pass.cpp index 1aa40759fada9..145c6cb7a0009 100644 --- a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/move_assign_noexcept.compile.pass.cpp +++ b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/move_assign_noexcept.compile.pass.cpp @@ -50,10 +50,12 @@ struct MoveThrowsComp { }; void test() { +#if defined(_LIBCPP_VERSION) { using C = std::flat_multimap; LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable_v); } +#endif { using C = std::flat_multimap>>; static_assert(!std::is_nothrow_move_assignable_v); } +#if defined(_LIBCPP_VERSION) { using C = std::flat_multimap; LIBCPP_STATIC_ASSERT(!std::is_nothrow_move_assignable_v); } +#endif { // Test with a container that throws on move-assignment. using C = std::flat_multimap, std::pmr::vector, std::vector>; diff --git a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.erasure/erase_if_exceptions.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.erasure/erase_if_exceptions.pass.cpp index 13b57202f7862..c7a4c3e632983 100644 --- a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.erasure/erase_if_exceptions.pass.cpp +++ b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.erasure/erase_if_exceptions.pass.cpp @@ -68,7 +68,9 @@ struct ErasurePredicate { }; int main(int, char**) { +#if defined(_LIBCPP_VERSION) const std::pair expected[] = {{1, 1}, {2, 2}, {3, 3}, {3, 3}, {5, 5}, {6, 6}, {7, 7}, {8, 8}}; +#endif { using M = std::flat_multimap; for (int first_throw = 1; first_throw < 99; ++first_throw) { diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.erasure/erase_if_exceptions.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.erasure/erase_if_exceptions.pass.cpp index 37b4a40f0165c..bccb5360878d3 100644 --- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.erasure/erase_if_exceptions.pass.cpp +++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.erasure/erase_if_exceptions.pass.cpp @@ -66,7 +66,9 @@ struct ErasurePredicate { }; void test() { +#if defined(_LIBCPP_VERSION) const int expected[] = {1, 2, 3, 4, 5, 6, 7, 8}; +#endif { using M = std::flat_set; for (int first_throw = 1; first_throw < 99; ++first_throw) { From d395ae4c7e6475d49474a3949e975022910a55cf Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Thu, 28 Aug 2025 11:31:34 +0300 Subject: [PATCH 2/2] [[maybe_unused]] --- .../move_assign_noexcept.compile.pass.cpp | 12 ++++-------- .../flat.map.erasure/erase_if_exceptions.pass.cpp | 5 ++--- .../move_assign_noexcept.compile.pass.cpp | 12 ++++-------- .../erase_if_exceptions.pass.cpp | 5 ++--- .../flat.set.erasure/erase_if_exceptions.pass.cpp | 4 +--- 5 files changed, 13 insertions(+), 25 deletions(-) diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_assign_noexcept.compile.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_assign_noexcept.compile.pass.cpp index ea39686653b08..c727f7e51eb2e 100644 --- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_assign_noexcept.compile.pass.cpp +++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_assign_noexcept.compile.pass.cpp @@ -50,12 +50,10 @@ struct MoveThrowsComp { }; void test() { -#if defined(_LIBCPP_VERSION) { - using C = std::flat_map; + using C [[maybe_unused]] = std::flat_map; LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable_v); } -#endif { using C = std::flat_map>>; static_assert(!std::is_nothrow_move_assignable_v); } -#if defined(_LIBCPP_VERSION) { - using C = + using C [[maybe_unused]] = std::flat_map, @@ -85,7 +82,7 @@ void test() { LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable_v); } { - using C = + using C [[maybe_unused]] = std::flat_map, @@ -95,10 +92,9 @@ void test() { } { // Test with a comparator that throws on move-assignment. - using C = std::flat_map; + using C [[maybe_unused]] = std::flat_map; LIBCPP_STATIC_ASSERT(!std::is_nothrow_move_assignable_v); } -#endif { // Test with a container that throws on move-assignment. using C = std::flat_map, std::pmr::vector, std::vector>; diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.erasure/erase_if_exceptions.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.erasure/erase_if_exceptions.pass.cpp index b15c5755d9bdb..c0e31dc38426c 100644 --- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.erasure/erase_if_exceptions.pass.cpp +++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.erasure/erase_if_exceptions.pass.cpp @@ -66,9 +66,8 @@ struct ErasurePredicate { }; int main(int, char**) { -#if defined(_LIBCPP_VERSION) - const std::pair expected[] = {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}, {6, 6}, {7, 7}, {8, 8}}; -#endif + [[maybe_unused]] const std::pair expected[] = { + {1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}, {6, 6}, {7, 7}, {8, 8}}; { using M = std::flat_map; for (int first_throw = 1; first_throw < 99; ++first_throw) { diff --git a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/move_assign_noexcept.compile.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/move_assign_noexcept.compile.pass.cpp index 145c6cb7a0009..5f86bb336f135 100644 --- a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/move_assign_noexcept.compile.pass.cpp +++ b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/move_assign_noexcept.compile.pass.cpp @@ -50,12 +50,10 @@ struct MoveThrowsComp { }; void test() { -#if defined(_LIBCPP_VERSION) { - using C = std::flat_multimap; + using C [[maybe_unused]] = std::flat_multimap; LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable_v); } -#endif { using C = std::flat_multimap>>; static_assert(!std::is_nothrow_move_assignable_v); } -#if defined(_LIBCPP_VERSION) { - using C = + using C [[maybe_unused]] = std::flat_multimap, @@ -85,7 +82,7 @@ void test() { LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable_v); } { - using C = + using C [[maybe_unused]] = std::flat_multimap, @@ -95,10 +92,9 @@ void test() { } { // Test with a comparator that throws on move-assignment. - using C = std::flat_multimap; + using C [[maybe_unused]] = std::flat_multimap; LIBCPP_STATIC_ASSERT(!std::is_nothrow_move_assignable_v); } -#endif { // Test with a container that throws on move-assignment. using C = std::flat_multimap, std::pmr::vector, std::vector>; diff --git a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.erasure/erase_if_exceptions.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.erasure/erase_if_exceptions.pass.cpp index c7a4c3e632983..95f7e11626a4e 100644 --- a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.erasure/erase_if_exceptions.pass.cpp +++ b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.erasure/erase_if_exceptions.pass.cpp @@ -68,9 +68,8 @@ struct ErasurePredicate { }; int main(int, char**) { -#if defined(_LIBCPP_VERSION) - const std::pair expected[] = {{1, 1}, {2, 2}, {3, 3}, {3, 3}, {5, 5}, {6, 6}, {7, 7}, {8, 8}}; -#endif + [[maybe_unused]] const std::pair expected[] = { + {1, 1}, {2, 2}, {3, 3}, {3, 3}, {5, 5}, {6, 6}, {7, 7}, {8, 8}}; { using M = std::flat_multimap; for (int first_throw = 1; first_throw < 99; ++first_throw) { diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.erasure/erase_if_exceptions.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.erasure/erase_if_exceptions.pass.cpp index bccb5360878d3..11cc12aaeabf9 100644 --- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.erasure/erase_if_exceptions.pass.cpp +++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.erasure/erase_if_exceptions.pass.cpp @@ -66,9 +66,7 @@ struct ErasurePredicate { }; void test() { -#if defined(_LIBCPP_VERSION) - const int expected[] = {1, 2, 3, 4, 5, 6, 7, 8}; -#endif + [[maybe_unused]] const int expected[] = {1, 2, 3, 4, 5, 6, 7, 8}; { using M = std::flat_set; for (int first_throw = 1; first_throw < 99; ++first_throw) {