Skip to content

Conversation

AlexGuteniev
Copy link
Contributor

Make these tests pass with MSVC STL

…_LIBCPP_VERSION is not defined

Make these tests pass with MSVC STL
@AlexGuteniev AlexGuteniev requested a review from a team as a code owner August 27, 2025 19:02
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Aug 27, 2025
@llvmbot
Copy link
Member

llvmbot commented Aug 27, 2025

@llvm/pr-subscribers-libcxx

Author: Alex Guteniev (AlexGuteniev)

Changes

Make these tests pass with MSVC STL


Full diff: https://github.com/llvm/llvm-project/pull/155679.diff

5 Files Affected:

  • (modified) libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_assign_noexcept.compile.pass.cpp (+4)
  • (modified) libcxx/test/std/containers/container.adaptors/flat.map/flat.map.erasure/erase_if_exceptions.pass.cpp (+2)
  • (modified) libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/move_assign_noexcept.compile.pass.cpp (+4)
  • (modified) libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.erasure/erase_if_exceptions.pass.cpp (+2)
  • (modified) libcxx/test/std/containers/container.adaptors/flat.set/flat.set.erasure/erase_if_exceptions.pass.cpp (+2)
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<int, int>;
     LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable_v<C>);
   }
+#endif
   {
     using C =
         std::flat_map<MoveOnly,
@@ -72,6 +74,7 @@ void test() {
                       std::vector<MoveOnly, test_allocator<MoveOnly>>>;
     static_assert(!std::is_nothrow_move_assignable_v<C>);
   }
+#if defined(_LIBCPP_VERSION)
   {
     using C =
         std::flat_map<MoveOnly,
@@ -95,6 +98,7 @@ void test() {
     using C = std::flat_map<int, int, MoveThrowsComp>;
     LIBCPP_STATIC_ASSERT(!std::is_nothrow_move_assignable_v<C>);
   }
+#endif
   {
     // Test with a container that throws on move-assignment.
     using C = std::flat_map<int, int, std::less<int>, std::pmr::vector<int>, std::vector<int>>;
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<int, int> expected[] = {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}, {6, 6}, {7, 7}, {8, 8}};
+#endif
   {
     using M = std::flat_map<ThrowingAssignment, int, ThrowingComparator>;
     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<int, int>;
     LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable_v<C>);
   }
+#endif
   {
     using C =
         std::flat_multimap<MoveOnly,
@@ -72,6 +74,7 @@ void test() {
                            std::vector<MoveOnly, test_allocator<MoveOnly>>>;
     static_assert(!std::is_nothrow_move_assignable_v<C>);
   }
+#if defined(_LIBCPP_VERSION)
   {
     using C =
         std::flat_multimap<MoveOnly,
@@ -95,6 +98,7 @@ void test() {
     using C = std::flat_multimap<int, int, MoveThrowsComp>;
     LIBCPP_STATIC_ASSERT(!std::is_nothrow_move_assignable_v<C>);
   }
+#endif
   {
     // Test with a container that throws on move-assignment.
     using C = std::flat_multimap<int, int, std::less<int>, std::pmr::vector<int>, std::vector<int>>;
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<int, int> expected[] = {{1, 1}, {2, 2}, {3, 3}, {3, 3}, {5, 5}, {6, 6}, {7, 7}, {8, 8}};
+#endif
   {
     using M = std::flat_multimap<ThrowingAssignment, int, ThrowingComparator>;
     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<ThrowingAssignment, ThrowingComparator>;
     for (int first_throw = 1; first_throw < 99; ++first_throw) {

Copy link
Contributor

@philnik777 philnik777 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM assuming the CI is happy.

@philnik777
Copy link
Contributor

@AlexGuteniev Do you need the branch to be merged?

@AlexGuteniev
Copy link
Contributor Author

@AlexGuteniev Do you need the branch to be merged?

Yes, please

@philnik777 philnik777 merged commit 0247358 into llvm:main Sep 2, 2025
73 of 78 checks passed
@AlexGuteniev AlexGuteniev deleted the flat-tests-unused-things-non-libcxx branch September 2, 2025 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants