diff --git a/libcxx/test/libcxx/containers/sequences/forwardlist/bool-conversion.pass.cpp b/libcxx/test/libcxx/containers/sequences/forwardlist/bool-conversion.pass.cpp deleted file mode 100644 index 237b0f155c7be..0000000000000 --- a/libcxx/test/libcxx/containers/sequences/forwardlist/bool-conversion.pass.cpp +++ /dev/null @@ -1,37 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// REQUIRES: std-at-least-c++20 - -// - -// This test shows the effect of implementing `LWG4135`, before it this code -// was ill-formed, as the predicate is not bool. `LWG4135` suggests that -// std::erase explicitly specifying the lambda's return type as bool. - -#include - -struct Bool { - Bool() = default; - Bool(const Bool&) = delete; - operator bool() const { return true; } -}; - -struct Int { - Bool& operator==(Int) const { - static Bool b; - return b; - } -}; - -int main(int, char**) { - std::forward_list l; - std::erase(l, Int{}); - - return 0; -} diff --git a/libcxx/test/libcxx/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp deleted file mode 100644 index 9e3fb886e6075..0000000000000 --- a/libcxx/test/libcxx/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp +++ /dev/null @@ -1,56 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// template vector(InputIter first, InputIter last); - -#include -#include - -#include "test_macros.h" -#include "min_allocator.h" - -void test_ctor_under_alloc() { - int arr1[] = {42}; - int arr2[] = {1, 101, 42}; - { - typedef std::vector > C; - typedef C::allocator_type Alloc; - { - Alloc::construct_called = false; - C v(arr1, arr1 + 1); - assert(Alloc::construct_called); - } - { - Alloc::construct_called = false; - C v(arr2, arr2 + 3); - assert(Alloc::construct_called); - } - } - { - typedef std::vector > C; - typedef C::allocator_type Alloc; - { - Alloc::construct_called = false; - C v(arr1, arr1 + 1); - assert(Alloc::construct_called); - } - { - Alloc::construct_called = false; - C v(arr2, arr2 + 3); - assert(Alloc::construct_called); - } - } -} - -int main(int, char**) { - test_ctor_under_alloc(); - - return 0; -} diff --git a/libcxx/test/libcxx/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp deleted file mode 100644 index fa1bd2d4fda32..0000000000000 --- a/libcxx/test/libcxx/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp +++ /dev/null @@ -1,59 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// template vector(InputIter first, InputIter last, -// const allocator_type& a); - -#include -#include - -#include "test_macros.h" -#include "min_allocator.h" - -void test_ctor_under_alloc() { - int arr1[] = {42}; - int arr2[] = {1, 101, 42}; - { - typedef std::vector > C; - typedef C::allocator_type Alloc; - Alloc a; - { - Alloc::construct_called = false; - C v(arr1, arr1 + 1, a); - assert(Alloc::construct_called); - } - { - Alloc::construct_called = false; - C v(arr2, arr2 + 3, a); - assert(Alloc::construct_called); - } - } - { - typedef std::vector > C; - typedef C::allocator_type Alloc; - Alloc a; - { - Alloc::construct_called = false; - C v(arr1, arr1 + 1, a); - assert(Alloc::construct_called); - } - { - Alloc::construct_called = false; - C v(arr2, arr2 + 3, a); - assert(Alloc::construct_called); - } - } -} - -int main(int, char**) { - test_ctor_under_alloc(); - - return 0; -} diff --git a/libcxx/test/libcxx/containers/associative/map/find.modules.compile.pass.mm b/libcxx/test/std/containers/associative/map/find.modules.compile.pass.mm similarity index 100% rename from libcxx/test/libcxx/containers/associative/map/find.modules.compile.pass.mm rename to libcxx/test/std/containers/associative/map/find.modules.compile.pass.mm diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.erasure/erase.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.erasure/erase.pass.cpp index 86d7769fe16ee..30312760fa917 100644 --- a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.erasure/erase.pass.cpp +++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.erasure/erase.pass.cpp @@ -69,6 +69,25 @@ TEST_CONSTEXPR_CXX26 bool test() { test>(); test>(); + { // Ensure that the result of operator== is converted to bool + // See LWG4135. + struct Bool { + Bool() = default; + Bool(const Bool&) = delete; + operator bool() const { return true; } + }; + + struct Int { + Bool& operator==(Int) const { + static Bool b; + return b; + } + }; + + std::forward_list l; + std::erase(l, Int{}); + } + return true; } diff --git a/libcxx/test/libcxx/containers/sequences/vector/erase.modules.compile.pass.mm b/libcxx/test/std/containers/sequences/vector/erase.modules.compile.pass.mm similarity index 100% rename from libcxx/test/libcxx/containers/sequences/vector/erase.modules.compile.pass.mm rename to libcxx/test/std/containers/sequences/vector/erase.modules.compile.pass.mm diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp index bac2ea2b4ca1e..6549735f7b511 100644 --- a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp @@ -127,9 +127,9 @@ TEST_CONSTEXPR_CXX20 void emplaceable_concept_tests() { } void test_ctor_under_alloc() { -#if TEST_STD_VER >= 11 int arr1[] = {42}; int arr2[] = {1, 101, 42}; +#if TEST_STD_VER >= 11 { using C = TCT::vector<>; using It = forward_iterator; @@ -155,6 +155,35 @@ void test_ctor_under_alloc() { } } #endif + // FIXME: This is mostly the same test as above, just worse. They should be merged. + { + typedef std::vector > C; + typedef C::allocator_type Alloc; + { + Alloc::construct_called = false; + C v(arr1, arr1 + 1); + assert(Alloc::construct_called); + } + { + Alloc::construct_called = false; + C v(arr2, arr2 + 3); + assert(Alloc::construct_called); + } + } + { + typedef std::vector > C; + typedef C::allocator_type Alloc; + { + Alloc::construct_called = false; + C v(arr1, arr1 + 1); + assert(Alloc::construct_called); + } + { + Alloc::construct_called = false; + C v(arr2, arr2 + 3); + assert(Alloc::construct_called); + } + } } // In C++03, you can't instantiate a template with a local type. diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp index de325040f4a19..019f427c006a1 100644 --- a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp @@ -141,9 +141,9 @@ TEST_CONSTEXPR_CXX20 void emplaceable_concept_tests() { } void test_ctor_under_alloc() { -#if TEST_STD_VER >= 11 int arr1[] = {42}; int arr2[] = {1, 101, 42}; +#if TEST_STD_VER >= 11 { using C = TCT::vector<>; using It = forward_iterator; @@ -173,6 +173,37 @@ void test_ctor_under_alloc() { } } #endif + // FIXME: This is mostly the same test as above, just worse. They should be merged. + { + typedef std::vector > C; + typedef C::allocator_type Alloc; + Alloc a; + { + Alloc::construct_called = false; + C v(arr1, arr1 + 1, a); + assert(Alloc::construct_called); + } + { + Alloc::construct_called = false; + C v(arr2, arr2 + 3, a); + assert(Alloc::construct_called); + } + } + { + typedef std::vector > C; + typedef C::allocator_type Alloc; + Alloc a; + { + Alloc::construct_called = false; + C v(arr1, arr1 + 1, a); + assert(Alloc::construct_called); + } + { + Alloc::construct_called = false; + C v(arr2, arr2 + 3, a); + assert(Alloc::construct_called); + } + } } TEST_CONSTEXPR_CXX20 bool test() {