From aaccb9e13618517803df1230741b02b4c5ee08c7 Mon Sep 17 00:00:00 2001 From: Jakub Mazurkiewicz Date: Tue, 5 Dec 2023 23:36:57 +0100 Subject: [PATCH 01/14] [libc++] P2602R2 Poison Pills are Too Toxic --- libcxx/docs/FeatureTestMacroTable.rst | 2 +- libcxx/docs/Status/Cxx23Papers.csv | 2 +- libcxx/include/__compare/partial_order.h | 2 ++ libcxx/include/__compare/strong_order.h | 2 ++ libcxx/include/__compare/weak_order.h | 2 ++ libcxx/include/__iterator/iter_move.h | 2 +- libcxx/include/__ranges/access.h | 6 ++-- libcxx/include/__ranges/rbegin.h | 3 +- libcxx/include/__ranges/rend.h | 3 +- libcxx/include/__ranges/size.h | 3 +- libcxx/include/version | 4 +-- .../iterator.cust.move/iter_move.pass.cpp | 11 +++++++ .../iterator.cust.swap/iter_swap.pass.cpp | 6 ++++ .../ordinary_unqualified_lookup_helpers.h | 33 +++++++++++++++++++ .../cmp/cmp.alg/partial_order.pass.cpp | 9 +++++ .../cmp/cmp.alg/strong_order.pass.cpp | 9 +++++ .../cmp/cmp.alg/weak_order.pass.cpp | 9 +++++ .../algorithm.version.compile.pass.cpp | 14 ++++---- .../functional.version.compile.pass.cpp | 14 ++++---- .../iterator.version.compile.pass.cpp | 14 ++++---- .../memory.version.compile.pass.cpp | 14 ++++---- .../ranges.version.compile.pass.cpp | 14 ++++---- .../version.version.compile.pass.cpp | 14 ++++---- .../std/ranges/range.access/begin.pass.cpp | 18 +++++++--- .../test/std/ranges/range.access/end.pass.cpp | 20 +++++++---- .../ordinary_unqualified_lookup_helpers.h | 25 ++++++++++++++ .../std/ranges/range.access/rbegin.pass.cpp | 18 +++++++--- .../std/ranges/range.access/rend.pass.cpp | 20 +++++++---- .../std/ranges/range.access/size.pass.cpp | 9 ++++- .../generate_feature_test_macro_components.py | 2 +- 30 files changed, 223 insertions(+), 81 deletions(-) create mode 100644 libcxx/test/std/language.support/cmp/cmp.alg/ordinary_unqualified_lookup_helpers.h create mode 100644 libcxx/test/std/ranges/range.access/ordinary_unqualified_lookup_helpers.h diff --git a/libcxx/docs/FeatureTestMacroTable.rst b/libcxx/docs/FeatureTestMacroTable.rst index d09f65b7cadc0..f4788aa574788 100644 --- a/libcxx/docs/FeatureTestMacroTable.rst +++ b/libcxx/docs/FeatureTestMacroTable.rst @@ -266,7 +266,7 @@ Status --------------------------------------------------- ----------------- ``__cpp_lib_polymorphic_allocator`` ``201902L`` --------------------------------------------------- ----------------- - ``__cpp_lib_ranges`` ``202207L`` + ``__cpp_lib_ranges`` ``202211L`` --------------------------------------------------- ----------------- ``__cpp_lib_remove_cvref`` ``201711L`` --------------------------------------------------- ----------------- diff --git a/libcxx/docs/Status/Cxx23Papers.csv b/libcxx/docs/Status/Cxx23Papers.csv index e03cbff2a08bb..7dc6f36ba1e63 100644 --- a/libcxx/docs/Status/Cxx23Papers.csv +++ b/libcxx/docs/Status/Cxx23Papers.csv @@ -100,7 +100,7 @@ "`P2396R1 `__","LWG", "Concurrency TS 2 fixes ", "November 2022","","","|concurrency TS|" "`P2505R5 `__","LWG", "Monadic Functions for ``std::expected``", "November 2022","|Complete|","17.0","" "`P2539R4 `__","LWG", "Should the output of ``std::print`` to a terminal be synchronized with the underlying stream?", "November 2022","|In Progress|","","|format|" -"`P2602R2 `__","LWG", "Poison Pills are Too Toxic", "November 2022","","","|ranges|" +"`P2602R2 `__","LWG", "Poison Pills are Too Toxic", "November 2022","|Complete|","18.0","|ranges|" "`P2708R1 `__","LWG", "No Further Fundamentals TSes", "November 2022","|Nothing to do|","","" "","","","","","","" "`P0290R4 `__","LWG", "``apply()`` for ``synchronized_value``","February 2023","","","|concurrency TS|" diff --git a/libcxx/include/__compare/partial_order.h b/libcxx/include/__compare/partial_order.h index 36a11dfaa2881..b422bdd4ef841 100644 --- a/libcxx/include/__compare/partial_order.h +++ b/libcxx/include/__compare/partial_order.h @@ -28,6 +28,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD // [cmp.alg] namespace __partial_order { + void partial_order() = delete; + struct __fn { // NOLINTBEGIN(libcpp-robust-against-adl) partial_order should use ADL, but only here template diff --git a/libcxx/include/__compare/strong_order.h b/libcxx/include/__compare/strong_order.h index cbfcf7316de9e..ba59cb51b86d9 100644 --- a/libcxx/include/__compare/strong_order.h +++ b/libcxx/include/__compare/strong_order.h @@ -34,6 +34,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD // [cmp.alg] namespace __strong_order { + void strong_order() = delete; + struct __fn { // NOLINTBEGIN(libcpp-robust-against-adl) strong_order should use ADL, but only here template diff --git a/libcxx/include/__compare/weak_order.h b/libcxx/include/__compare/weak_order.h index e6a42ac4c9235..8d7f939092303 100644 --- a/libcxx/include/__compare/weak_order.h +++ b/libcxx/include/__compare/weak_order.h @@ -28,6 +28,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD // [cmp.alg] namespace __weak_order { + void weak_order() = delete; + struct __fn { // NOLINTBEGIN(libcpp-robust-against-adl) weak_order should use ADL, but only here template diff --git a/libcxx/include/__iterator/iter_move.h b/libcxx/include/__iterator/iter_move.h index d9ff90bf65456..79dcac8f50b9f 100644 --- a/libcxx/include/__iterator/iter_move.h +++ b/libcxx/include/__iterator/iter_move.h @@ -35,7 +35,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { namespace __iter_move { -void iter_move(); +void iter_move() = delete; template concept __unqualified_iter_move = diff --git a/libcxx/include/__ranges/access.h b/libcxx/include/__ranges/access.h index 502bd5e951c4a..01bf8cc2f544f 100644 --- a/libcxx/include/__ranges/access.h +++ b/libcxx/include/__ranges/access.h @@ -49,8 +49,7 @@ namespace __begin { { _LIBCPP_AUTO_CAST(__t.begin()) } -> input_or_output_iterator; }; - void begin(auto&) = delete; - void begin(const auto&) = delete; + void begin() = delete; template concept __unqualified_begin = @@ -121,8 +120,7 @@ namespace __end { { _LIBCPP_AUTO_CAST(__t.end()) } -> sentinel_for>; }; - void end(auto&) = delete; - void end(const auto&) = delete; + void end() = delete; template concept __unqualified_end = diff --git a/libcxx/include/__ranges/rbegin.h b/libcxx/include/__ranges/rbegin.h index 1ceb1116d695f..8fd17a3c016a2 100644 --- a/libcxx/include/__ranges/rbegin.h +++ b/libcxx/include/__ranges/rbegin.h @@ -43,8 +43,7 @@ concept __member_rbegin = { _LIBCPP_AUTO_CAST(__t.rbegin()) } -> input_or_output_iterator; }; -void rbegin(auto&) = delete; -void rbegin(const auto&) = delete; +void rbegin() = delete; template concept __unqualified_rbegin = diff --git a/libcxx/include/__ranges/rend.h b/libcxx/include/__ranges/rend.h index 7ee574ccfa674..1f482963ac749 100644 --- a/libcxx/include/__ranges/rend.h +++ b/libcxx/include/__ranges/rend.h @@ -45,8 +45,7 @@ concept __member_rend = { _LIBCPP_AUTO_CAST(__t.rend()) } -> sentinel_for; }; -void rend(auto&) = delete; -void rend(const auto&) = delete; +void rend() = delete; template concept __unqualified_rend = diff --git a/libcxx/include/__ranges/size.h b/libcxx/include/__ranges/size.h index f22dd1ff7b79f..0ed939e0bd4f9 100644 --- a/libcxx/include/__ranges/size.h +++ b/libcxx/include/__ranges/size.h @@ -41,8 +41,7 @@ namespace ranges { namespace ranges { namespace __size { -void size(auto&) = delete; -void size(const auto&) = delete; +void size() = delete; template concept __size_enabled = !disable_sized_range>; diff --git a/libcxx/include/version b/libcxx/include/version index e84790b888d33..71937c3a3d1c2 100644 --- a/libcxx/include/version +++ b/libcxx/include/version @@ -164,7 +164,7 @@ __cpp_lib_parallel_algorithm 201603L __cpp_lib_print 202207L __cpp_lib_quoted_string_io 201304L -__cpp_lib_ranges 202207L +__cpp_lib_ranges 202211L __cpp_lib_ranges_as_const 202207L __cpp_lib_ranges_as_rvalue 202207L @@ -405,7 +405,7 @@ __cpp_lib_within_lifetime 202306L # if _LIBCPP_AVAILABILITY_HAS_PMR # define __cpp_lib_polymorphic_allocator 201902L # endif -# define __cpp_lib_ranges 202207L +# define __cpp_lib_ranges 202211L # define __cpp_lib_remove_cvref 201711L # if !defined(_LIBCPP_HAS_NO_THREADS) && _LIBCPP_AVAILABILITY_HAS_SYNC # define __cpp_lib_semaphore 201907L diff --git a/libcxx/test/std/iterators/iterator.requirements/iterator.cust/iterator.cust.move/iter_move.pass.cpp b/libcxx/test/std/iterators/iterator.requirements/iterator.cust/iterator.cust.move/iter_move.pass.cpp index 566638263e887..8cd515d8e7fb4 100644 --- a/libcxx/test/std/iterators/iterator.requirements/iterator.cust/iterator.cust.move/iter_move.pass.cpp +++ b/libcxx/test/std/iterators/iterator.requirements/iterator.cust/iterator.cust.move/iter_move.pass.cpp @@ -11,6 +11,14 @@ // template // unspecified iter_move; +// Note: this struct is intentionally defined before any other header is included. +// Custom `iter_move` must be visible to `std::ranges::iter_move` CPO from `` header. +namespace nest { +struct StructWithGlobalIterMove {}; +} // namespace nest + +int&& iter_move(nest::StructWithGlobalIterMove); + #include #include #include @@ -186,6 +194,9 @@ template struct Holder { T t; }; static_assert(std::is_invocable_v**>); static_assert(std::is_invocable_v**&>); +// Ordinary unqualified lookup should not be performed. +static_assert(!std::is_invocable_v); + int main(int, char**) { test(); diff --git a/libcxx/test/std/iterators/iterator.requirements/iterator.cust/iterator.cust.swap/iter_swap.pass.cpp b/libcxx/test/std/iterators/iterator.requirements/iterator.cust/iterator.cust.swap/iter_swap.pass.cpp index dd78707f25409..692ddef195d2c 100644 --- a/libcxx/test/std/iterators/iterator.requirements/iterator.cust/iterator.cust.swap/iter_swap.pass.cpp +++ b/libcxx/test/std/iterators/iterator.requirements/iterator.cust/iterator.cust.swap/iter_swap.pass.cpp @@ -47,6 +47,12 @@ static_assert( std::is_invocable_v); static_assert( std::is_invocable_v); static_assert(!std::is_invocable_v); +struct NotMoreSpecializedIterSwap { + friend void iter_swap(auto&, auto&); +}; + +static_assert(!std::is_invocable_v); + struct NodiscardIterSwap { [[nodiscard]] friend int iter_swap(NodiscardIterSwap&, NodiscardIterSwap&) { return 0; } }; diff --git a/libcxx/test/std/language.support/cmp/cmp.alg/ordinary_unqualified_lookup_helpers.h b/libcxx/test/std/language.support/cmp/cmp.alg/ordinary_unqualified_lookup_helpers.h new file mode 100644 index 0000000000000..4cbe163c312f4 --- /dev/null +++ b/libcxx/test/std/language.support/cmp/cmp.alg/ordinary_unqualified_lookup_helpers.h @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#ifndef TEST_STD_LANGUAGE_SUPPORT_CMP_CMP_ALG_ORDINARY_UNQUALIFIED_LOOKUP_HELPERS_H +#define TEST_STD_LANGUAGE_SUPPORT_CMP_CMP_ALG_ORDINARY_UNQUALIFIED_LOOKUP_HELPERS_H + +// Note: this header should be included before any other header. +// Comparison functions defined here must be visible to CPOs from `` header. + +namespace nest { +struct StructWithGlobalCmpFunctions {}; +} // namespace nest + +struct ConvertibleToComparisonType; + +ConvertibleToComparisonType strong_order(nest::StructWithGlobalCmpFunctions, nest::StructWithGlobalCmpFunctions); +ConvertibleToComparisonType weak_order(nest::StructWithGlobalCmpFunctions, nest::StructWithGlobalCmpFunctions); +ConvertibleToComparisonType partial_order(nest::StructWithGlobalCmpFunctions, nest::StructWithGlobalCmpFunctions); + +#include // Intentionally included here, so we can define `ConvertibleToComparisonType` later. + +struct ConvertibleToComparisonType { + operator std::strong_ordering() const; + operator std::weak_ordering() const; + operator std::partial_ordering() const; +}; + +#endif // TEST_STD_LANGUAGE_SUPPORT_CMP_CMP_ALG_ORDINARY_UNQUALIFIED_LOOKUP_HELPERS_H diff --git a/libcxx/test/std/language.support/cmp/cmp.alg/partial_order.pass.cpp b/libcxx/test/std/language.support/cmp/cmp.alg/partial_order.pass.cpp index bd313889b1a4e..d6376f0a5cb2a 100644 --- a/libcxx/test/std/language.support/cmp/cmp.alg/partial_order.pass.cpp +++ b/libcxx/test/std/language.support/cmp/cmp.alg/partial_order.pass.cpp @@ -12,6 +12,10 @@ // template constexpr partial_ordering partial_order(const T& a, const T& b); +// Note: this header is intentionally included before any other header. +// Comparison functions defined there must be visible to CPOs from `` header. +#include "ordinary_unqualified_lookup_helpers.h" + #include #include @@ -240,6 +244,11 @@ constexpr bool test_1_4() return true; } +// Ordinary unqualified lookup should not be performed. +static_assert(!std::is_invocable_v); + int main(int, char**) { test_1_1(); diff --git a/libcxx/test/std/language.support/cmp/cmp.alg/strong_order.pass.cpp b/libcxx/test/std/language.support/cmp/cmp.alg/strong_order.pass.cpp index ac6b6879f7730..5c26a0be23f0a 100644 --- a/libcxx/test/std/language.support/cmp/cmp.alg/strong_order.pass.cpp +++ b/libcxx/test/std/language.support/cmp/cmp.alg/strong_order.pass.cpp @@ -12,6 +12,10 @@ // template constexpr strong_ordering strong_order(const T& a, const T& b); +// Note: this header is intentionally included before any other header. +// Comparison functions defined there must be visible to CPOs from `` header. +#include "ordinary_unqualified_lookup_helpers.h" + #include #include @@ -448,6 +452,11 @@ constexpr bool test_1_4() return true; } +// Ordinary unqualified lookup should not be performed. +static_assert(!std::is_invocable_v); + int main(int, char**) { test_1_1(); diff --git a/libcxx/test/std/language.support/cmp/cmp.alg/weak_order.pass.cpp b/libcxx/test/std/language.support/cmp/cmp.alg/weak_order.pass.cpp index 09d720196e0b2..0dc79acc99ed9 100644 --- a/libcxx/test/std/language.support/cmp/cmp.alg/weak_order.pass.cpp +++ b/libcxx/test/std/language.support/cmp/cmp.alg/weak_order.pass.cpp @@ -12,6 +12,10 @@ // template constexpr weak_ordering weak_order(const T& a, const T& b); +// Note: this header is intentionally included before any other header. +// Comparison functions defined there must be visible to CPOs from `` header. +#include "ordinary_unqualified_lookup_helpers.h" + #include #include @@ -493,6 +497,11 @@ constexpr bool test_1_5() return true; } +// Ordinary unqualified lookup should not be performed. +static_assert(!std::is_invocable_v); + int main(int, char**) { test_1_1(); diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/algorithm.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/algorithm.version.compile.pass.cpp index ec6503ec23755..918c6d35f730d 100644 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/algorithm.version.compile.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/algorithm.version.compile.pass.cpp @@ -20,7 +20,7 @@ __cpp_lib_constexpr_algorithms 201806L [C++20] __cpp_lib_freestanding_algorithm 202311L [C++26] __cpp_lib_parallel_algorithm 201603L [C++17] - __cpp_lib_ranges 202207L [C++20] + __cpp_lib_ranges 202211L [C++20] __cpp_lib_ranges_starts_ends_with 202106L [C++23] __cpp_lib_robust_nonmodifying_seq_ops 201304L [C++14] __cpp_lib_sample 201603L [C++17] @@ -201,8 +201,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++20" # endif -# if __cpp_lib_ranges != 202207L -# error "__cpp_lib_ranges should have the value 202207L in c++20" +# if __cpp_lib_ranges != 202211L +# error "__cpp_lib_ranges should have the value 202211L in c++20" # endif # ifdef __cpp_lib_ranges_starts_ends_with @@ -266,8 +266,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++23" # endif -# if __cpp_lib_ranges != 202207L -# error "__cpp_lib_ranges should have the value 202207L in c++23" +# if __cpp_lib_ranges != 202211L +# error "__cpp_lib_ranges should have the value 202211L in c++23" # endif # if !defined(_LIBCPP_VERSION) @@ -349,8 +349,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++26" # endif -# if __cpp_lib_ranges != 202207L -# error "__cpp_lib_ranges should have the value 202207L in c++26" +# if __cpp_lib_ranges != 202211L +# error "__cpp_lib_ranges should have the value 202211L in c++26" # endif # if !defined(_LIBCPP_VERSION) diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/functional.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/functional.version.compile.pass.cpp index 72c96c62b64c4..55674d104fab9 100644 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/functional.version.compile.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/functional.version.compile.pass.cpp @@ -28,7 +28,7 @@ __cpp_lib_invoke_r 202106L [C++23] __cpp_lib_move_only_function 202110L [C++23] __cpp_lib_not_fn 201603L [C++17] - __cpp_lib_ranges 202207L [C++20] + __cpp_lib_ranges 202211L [C++20] __cpp_lib_result_of_sfinae 201210L [C++14] __cpp_lib_transparent_operators 201210L [C++14] 201510L [C++17] @@ -293,8 +293,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++20" # endif -# if __cpp_lib_ranges != 202207L -# error "__cpp_lib_ranges should have the value 202207L in c++20" +# if __cpp_lib_ranges != 202211L +# error "__cpp_lib_ranges should have the value 202211L in c++20" # endif # ifndef __cpp_lib_result_of_sfinae @@ -399,8 +399,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++23" # endif -# if __cpp_lib_ranges != 202207L -# error "__cpp_lib_ranges should have the value 202207L in c++23" +# if __cpp_lib_ranges != 202211L +# error "__cpp_lib_ranges should have the value 202211L in c++23" # endif # ifndef __cpp_lib_result_of_sfinae @@ -523,8 +523,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++26" # endif -# if __cpp_lib_ranges != 202207L -# error "__cpp_lib_ranges should have the value 202207L in c++26" +# if __cpp_lib_ranges != 202211L +# error "__cpp_lib_ranges should have the value 202211L in c++26" # endif # ifndef __cpp_lib_result_of_sfinae diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/iterator.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/iterator.version.compile.pass.cpp index 700907ce9bb07..6c652e694f6dd 100644 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/iterator.version.compile.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/iterator.version.compile.pass.cpp @@ -23,7 +23,7 @@ __cpp_lib_move_iterator_concept 202207L [C++20] __cpp_lib_nonmember_container_access 201411L [C++17] __cpp_lib_null_iterators 201304L [C++14] - __cpp_lib_ranges 202207L [C++20] + __cpp_lib_ranges 202211L [C++20] __cpp_lib_ssize 201902L [C++20] */ @@ -197,8 +197,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++20" # endif -# if __cpp_lib_ranges != 202207L -# error "__cpp_lib_ranges should have the value 202207L in c++20" +# if __cpp_lib_ranges != 202211L +# error "__cpp_lib_ranges should have the value 202211L in c++20" # endif # ifndef __cpp_lib_ssize @@ -255,8 +255,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++23" # endif -# if __cpp_lib_ranges != 202207L -# error "__cpp_lib_ranges should have the value 202207L in c++23" +# if __cpp_lib_ranges != 202211L +# error "__cpp_lib_ranges should have the value 202211L in c++23" # endif # ifndef __cpp_lib_ssize @@ -313,8 +313,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++26" # endif -# if __cpp_lib_ranges != 202207L -# error "__cpp_lib_ranges should have the value 202207L in c++26" +# if __cpp_lib_ranges != 202211L +# error "__cpp_lib_ranges should have the value 202211L in c++26" # endif # ifndef __cpp_lib_ssize diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/memory.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/memory.version.compile.pass.cpp index b1f6c76d84739..8ea1173309432 100644 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/memory.version.compile.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/memory.version.compile.pass.cpp @@ -28,7 +28,7 @@ __cpp_lib_make_unique 201304L [C++14] __cpp_lib_out_ptr 202106L [C++23] 202311L [C++26] - __cpp_lib_ranges 202207L [C++20] + __cpp_lib_ranges 202211L [C++20] __cpp_lib_raw_memory_algorithms 201606L [C++17] __cpp_lib_shared_ptr_arrays 201611L [C++17] 201707L [C++20] @@ -364,8 +364,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++20" # endif -# if __cpp_lib_ranges != 202207L -# error "__cpp_lib_ranges should have the value 202207L in c++20" +# if __cpp_lib_ranges != 202211L +# error "__cpp_lib_ranges should have the value 202211L in c++20" # endif # ifndef __cpp_lib_raw_memory_algorithms @@ -501,8 +501,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++23" # endif -# if __cpp_lib_ranges != 202207L -# error "__cpp_lib_ranges should have the value 202207L in c++23" +# if __cpp_lib_ranges != 202211L +# error "__cpp_lib_ranges should have the value 202211L in c++23" # endif # ifndef __cpp_lib_raw_memory_algorithms @@ -638,8 +638,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++26" # endif -# if __cpp_lib_ranges != 202207L -# error "__cpp_lib_ranges should have the value 202207L in c++26" +# if __cpp_lib_ranges != 202211L +# error "__cpp_lib_ranges should have the value 202211L in c++26" # endif # ifndef __cpp_lib_raw_memory_algorithms diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/ranges.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/ranges.version.compile.pass.cpp index aa3a4964ad492..0ea59178e6878 100644 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/ranges.version.compile.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/ranges.version.compile.pass.cpp @@ -16,7 +16,7 @@ // Test the feature test macros defined by /* Constant Value - __cpp_lib_ranges 202207L [C++20] + __cpp_lib_ranges 202211L [C++20] __cpp_lib_ranges_as_const 202207L [C++23] __cpp_lib_ranges_as_rvalue 202207L [C++23] __cpp_lib_ranges_chunk 202202L [C++23] @@ -162,8 +162,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++20" # endif -# if __cpp_lib_ranges != 202207L -# error "__cpp_lib_ranges should have the value 202207L in c++20" +# if __cpp_lib_ranges != 202211L +# error "__cpp_lib_ranges should have the value 202211L in c++20" # endif # ifdef __cpp_lib_ranges_as_const @@ -207,8 +207,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++23" # endif -# if __cpp_lib_ranges != 202207L -# error "__cpp_lib_ranges should have the value 202207L in c++23" +# if __cpp_lib_ranges != 202211L +# error "__cpp_lib_ranges should have the value 202211L in c++23" # endif # if !defined(_LIBCPP_VERSION) @@ -309,8 +309,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++26" # endif -# if __cpp_lib_ranges != 202207L -# error "__cpp_lib_ranges should have the value 202207L in c++26" +# if __cpp_lib_ranges != 202211L +# error "__cpp_lib_ranges should have the value 202211L in c++26" # endif # if !defined(_LIBCPP_VERSION) diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp index 0b00469892f60..9572fac59d79f 100644 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp @@ -153,7 +153,7 @@ __cpp_lib_polymorphic_allocator 201902L [C++20] __cpp_lib_print 202207L [C++23] __cpp_lib_quoted_string_io 201304L [C++14] - __cpp_lib_ranges 202207L [C++20] + __cpp_lib_ranges 202211L [C++20] __cpp_lib_ranges_as_const 202207L [C++23] __cpp_lib_ranges_as_rvalue 202207L [C++23] __cpp_lib_ranges_chunk 202202L [C++23] @@ -3832,8 +3832,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++20" # endif -# if __cpp_lib_ranges != 202207L -# error "__cpp_lib_ranges should have the value 202207L in c++20" +# if __cpp_lib_ranges != 202211L +# error "__cpp_lib_ranges should have the value 202211L in c++20" # endif # ifdef __cpp_lib_ranges_as_const @@ -5272,8 +5272,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++23" # endif -# if __cpp_lib_ranges != 202207L -# error "__cpp_lib_ranges should have the value 202207L in c++23" +# if __cpp_lib_ranges != 202211L +# error "__cpp_lib_ranges should have the value 202211L in c++23" # endif # if !defined(_LIBCPP_VERSION) @@ -6985,8 +6985,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++26" # endif -# if __cpp_lib_ranges != 202207L -# error "__cpp_lib_ranges should have the value 202207L in c++26" +# if __cpp_lib_ranges != 202211L +# error "__cpp_lib_ranges should have the value 202211L in c++26" # endif # if !defined(_LIBCPP_VERSION) diff --git a/libcxx/test/std/ranges/range.access/begin.pass.cpp b/libcxx/test/std/ranges/range.access/begin.pass.cpp index ca25fc297a011..89e1e130c2dfb 100644 --- a/libcxx/test/std/ranges/range.access/begin.pass.cpp +++ b/libcxx/test/std/ranges/range.access/begin.pass.cpp @@ -11,6 +11,10 @@ // std::ranges::begin // std::ranges::cbegin +// Note: this header is intentionally included before any other header. +// Access functions defined here must be visible to accessors from `` header. +#include "ordinary_unqualified_lookup_helpers.h" + #include #include @@ -192,7 +196,7 @@ struct BeginFunction { }; static_assert( std::is_invocable_v); static_assert(!std::is_invocable_v); -static_assert(!std::is_invocable_v); +static_assert( std::is_invocable_v); // Ill-formed before P2602R2 Poison Pills are Too Toxic static_assert( std::is_invocable_v); static_assert( std::is_invocable_v); @@ -245,7 +249,7 @@ struct BeginFunctionWithPrivateBeginMember { constexpr bool testBeginFunction() { BeginFunction a{}; const BeginFunction aa{}; - static_assert(!std::invocable); + assert(std::ranges::begin(a) == &a.x); // Ill-formed before P2602R2 Poison Pills are Too Toxic assert(std::ranges::cbegin(a) == &a.x); assert(std::ranges::begin(aa) == &aa.x); assert(std::ranges::cbegin(aa) == &aa.x); @@ -266,21 +270,21 @@ constexpr bool testBeginFunction() { BeginFunctionReturnsEmptyPtr d{}; const BeginFunctionReturnsEmptyPtr dd{}; - static_assert(!std::invocable); + assert(std::ranges::begin(d) == &d.x); // Ill-formed before P2602R2 Poison Pills are Too Toxic assert(std::ranges::cbegin(d) == &d.x); assert(std::ranges::begin(dd) == &dd.x); assert(std::ranges::cbegin(dd) == &dd.x); BeginFunctionWithDataMember e{}; const BeginFunctionWithDataMember ee{}; - static_assert(!std::invocable); + assert(std::ranges::begin(e) == &e.x); // Ill-formed before P2602R2 Poison Pills are Too Toxic assert(std::ranges::begin(ee) == &ee.x); assert(std::ranges::cbegin(e) == &e.x); assert(std::ranges::cbegin(ee) == &ee.x); BeginFunctionWithPrivateBeginMember f{}; const BeginFunctionWithPrivateBeginMember ff{}; - static_assert(!std::invocable); + assert(std::ranges::begin(f) == &f.y); // Ill-formed before P2602R2 Poison Pills are Too Toxic assert(std::ranges::cbegin(f) == &f.y); assert(std::ranges::begin(ff) == &ff.y); assert(std::ranges::cbegin(ff) == &ff.y); @@ -325,6 +329,10 @@ static_assert(!std::is_invocable_v*&>); static_assert(!std::is_invocable_v*>); static_assert(!std::is_invocable_v*&>); +// Ordinary unqualified lookup should not be performed. +static_assert(!std::is_invocable_v); +static_assert(!std::is_invocable_v); + int main(int, char**) { static_assert(testReturnTypes()); diff --git a/libcxx/test/std/ranges/range.access/end.pass.cpp b/libcxx/test/std/ranges/range.access/end.pass.cpp index 21d97354ef08d..749c20fe4c160 100644 --- a/libcxx/test/std/ranges/range.access/end.pass.cpp +++ b/libcxx/test/std/ranges/range.access/end.pass.cpp @@ -11,6 +11,10 @@ // std::ranges::end // std::ranges::cend +// Note: this header is intentionally included before any other header. +// Access functions defined here must be visible to accessors from `` header. +#include "ordinary_unqualified_lookup_helpers.h" + #include #include @@ -193,7 +197,7 @@ static_assert(!std::is_invocable_v); static_assert( std::is_invocable_v); static_assert(!std::is_invocable_v); -static_assert(!std::is_invocable_v); +static_assert( std::is_invocable_v); // Ill-formed before P2602R2 Poison Pills are Too Toxic static_assert( std::is_invocable_v); static_assert( std::is_invocable_v); @@ -271,7 +275,7 @@ constexpr bool testEndFunction() { assert(std::ranges::end(a) == &a.x); assert(std::ranges::cend(a) == &a.x); EndFunction aa{}; - static_assert(!std::is_invocable_v); + assert(std::ranges::end(aa) == &aa.x); // Ill-formed before P2602R2 Poison Pills are Too Toxic assert(std::ranges::cend(aa) == &aa.x); EndFunctionByValue b; @@ -286,28 +290,28 @@ constexpr bool testEndFunction() { assert(std::ranges::end(d) == &d.x); assert(std::ranges::cend(d) == &d.x); EndFunctionReturnsEmptyPtr dd{}; - static_assert(!std::is_invocable_v); + assert(std::ranges::end(dd) == &dd.x); // Ill-formed before P2602R2 Poison Pills are Too Toxic assert(std::ranges::cend(dd) == &dd.x); const EndFunctionWithDataMember e{}; assert(std::ranges::end(e) == &e.x); assert(std::ranges::cend(e) == &e.x); EndFunctionWithDataMember ee{}; - static_assert(!std::is_invocable_v); + assert(std::ranges::end(ee) == &ee.x); // Ill-formed before P2602R2 Poison Pills are Too Toxic assert(std::ranges::cend(ee) == &ee.x); const EndFunctionWithPrivateEndMember f{}; assert(std::ranges::end(f) == &f.y); assert(std::ranges::cend(f) == &f.y); EndFunctionWithPrivateEndMember ff{}; - static_assert(!std::is_invocable_v); + assert(std::ranges::end(ff) == &ff.y); // Ill-formed before P2602R2 Poison Pills are Too Toxic assert(std::ranges::cend(ff) == &ff.y); const BeginMemberEndFunction g{}; assert(std::ranges::end(g) == &g.x); assert(std::ranges::cend(g) == &g.x); BeginMemberEndFunction gg{}; - static_assert(!std::is_invocable_v); + assert(std::ranges::end(gg) == &gg.x); // Ill-formed before P2602R2 Poison Pills are Too Toxic assert(std::ranges::cend(gg) == &gg.x); return true; @@ -354,6 +358,10 @@ static_assert(!std::is_invocable_v*&>); static_assert(!std::is_invocable_v*>); static_assert(!std::is_invocable_v*&>); +// Ordinary unqualified lookup should not be performed. +static_assert(!std::is_invocable_v); +static_assert(!std::is_invocable_v); + int main(int, char**) { static_assert(testReturnTypes()); diff --git a/libcxx/test/std/ranges/range.access/ordinary_unqualified_lookup_helpers.h b/libcxx/test/std/ranges/range.access/ordinary_unqualified_lookup_helpers.h new file mode 100644 index 0000000000000..34be68aef1f4f --- /dev/null +++ b/libcxx/test/std/ranges/range.access/ordinary_unqualified_lookup_helpers.h @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#ifndef TEST_STD_RANGES_RANGE_ACCESS_ORDINARY_UNQUALIFIED_LOOKUP_HELPERS_H +#define TEST_STD_RANGES_RANGE_ACCESS_ORDINARY_UNQUALIFIED_LOOKUP_HELPERS_H + +// Note: this header should be included before any other header. +// Access functions defined here must be visible to accessors from `` header. + +namespace nest { +struct StructWithGlobalAccess {}; +} // namespace nest + +int* begin(nest::StructWithGlobalAccess); +int* end(nest::StructWithGlobalAccess); +int* rbegin(nest::StructWithGlobalAccess); +int* rend(nest::StructWithGlobalAccess); +unsigned int size(nest::StructWithGlobalAccess); + +#endif // TEST_STD_RANGES_RANGE_ACCESS_ORDINARY_UNQUALIFIED_LOOKUP_HELPERS_H diff --git a/libcxx/test/std/ranges/range.access/rbegin.pass.cpp b/libcxx/test/std/ranges/range.access/rbegin.pass.cpp index e1a564c94ed94..9bd804b59d3b1 100644 --- a/libcxx/test/std/ranges/range.access/rbegin.pass.cpp +++ b/libcxx/test/std/ranges/range.access/rbegin.pass.cpp @@ -11,6 +11,10 @@ // std::ranges::rbegin // std::ranges::crbegin +// Note: this header is intentionally included before any other header. +// Access functions defined here must be visible to accessors from `` header. +#include "ordinary_unqualified_lookup_helpers.h" + #include #include @@ -187,7 +191,7 @@ struct RBeginFunction { }; static_assert( std::is_invocable_v); static_assert(!std::is_invocable_v); -static_assert(!std::is_invocable_v); +static_assert( std::is_invocable_v); // Ill-formed before P2602R2 Poison Pills are Too Toxic static_assert( std::is_invocable_v); static_assert( std::is_invocable_v); @@ -246,7 +250,7 @@ struct RBeginFunctionWithPrivateBeginMember { constexpr bool testRBeginFunction() { RBeginFunction a{}; const RBeginFunction aa{}; - static_assert(!std::invocable); + assert(std::ranges::rbegin(a) == &a.x); // Ill-formed before P2602R2 Poison Pills are Too Toxic assert(std::ranges::crbegin(a) == &a.x); assert(std::ranges::rbegin(aa) == &aa.x); assert(std::ranges::crbegin(aa) == &aa.x); @@ -267,21 +271,21 @@ constexpr bool testRBeginFunction() { RBeginFunctionReturnsEmptyPtr d{}; const RBeginFunctionReturnsEmptyPtr dd{}; - static_assert(!std::invocable); + assert(std::ranges::rbegin(d) == &d.x); // Ill-formed before P2602R2 Poison Pills are Too Toxic assert(std::ranges::crbegin(d) == &d.x); assert(std::ranges::rbegin(dd) == &dd.x); assert(std::ranges::crbegin(dd) == &dd.x); RBeginFunctionWithDataMember e{}; const RBeginFunctionWithDataMember ee{}; - static_assert(!std::invocable); + assert(std::ranges::rbegin(e) == &e.x); // Ill-formed before P2602R2 Poison Pills are Too Toxic assert(std::ranges::rbegin(ee) == &ee.x); assert(std::ranges::crbegin(e) == &e.x); assert(std::ranges::crbegin(ee) == &ee.x); RBeginFunctionWithPrivateBeginMember f{}; const RBeginFunctionWithPrivateBeginMember ff{}; - static_assert(!std::invocable); + assert(std::ranges::rbegin(f) == &f.y); // Ill-formed before P2602R2 Poison Pills are Too Toxic assert(std::ranges::crbegin(f) == &f.y); assert(std::ranges::rbegin(ff) == &ff.y); assert(std::ranges::crbegin(ff) == &ff.y); @@ -501,6 +505,10 @@ static_assert(!std::is_invocable_v*&>); static_assert(!std::is_invocable_v*>); static_assert(!std::is_invocable_v*&>); +// Ordinary unqualified lookup should not be performed. +static_assert(!std::is_invocable_v); +static_assert(!std::is_invocable_v); + int main(int, char**) { static_assert(testReturnTypes()); diff --git a/libcxx/test/std/ranges/range.access/rend.pass.cpp b/libcxx/test/std/ranges/range.access/rend.pass.cpp index 5ba244b6b18cf..eb45889ca70f8 100644 --- a/libcxx/test/std/ranges/range.access/rend.pass.cpp +++ b/libcxx/test/std/ranges/range.access/rend.pass.cpp @@ -11,6 +11,10 @@ // std::ranges::rend // std::ranges::crend +// Note: this header is intentionally included before any other header. +// Access functions defined here must be visible to accessors from `` header. +#include "ordinary_unqualified_lookup_helpers.h" + #include #include @@ -196,7 +200,7 @@ static_assert(!std::is_invocable_v); static_assert( std::is_invocable_v); static_assert(!std::is_invocable_v); -static_assert(!std::is_invocable_v); +static_assert( std::is_invocable_v); // Ill-formed before P2602R2 Poison Pills are Too Toxic static_assert( std::is_invocable_v); static_assert( std::is_invocable_v); @@ -272,7 +276,7 @@ constexpr bool testREndFunction() { assert(std::ranges::rend(a) == &a.x); assert(std::ranges::crend(a) == &a.x); REndFunction aa{}; - static_assert(!std::is_invocable_v); + assert(std::ranges::rend(aa) == &aa.x); // Ill-formed before P2602R2 Poison Pills are Too Toxic assert(std::ranges::crend(aa) == &aa.x); REndFunctionByValue b; @@ -287,28 +291,28 @@ constexpr bool testREndFunction() { assert(std::ranges::rend(d) == &d.x); assert(std::ranges::crend(d) == &d.x); REndFunctionReturnsEmptyPtr dd{}; - static_assert(!std::is_invocable_v); + assert(std::ranges::rend(dd) == &dd.x); // Ill-formed before P2602R2 Poison Pills are Too Toxic assert(std::ranges::crend(dd) == &dd.x); const REndFunctionWithDataMember e{}; assert(std::ranges::rend(e) == &e.x); assert(std::ranges::crend(e) == &e.x); REndFunctionWithDataMember ee{}; - static_assert(!std::is_invocable_v); + assert(std::ranges::rend(ee) == &ee.x); // Ill-formed before P2602R2 Poison Pills are Too Toxic assert(std::ranges::crend(ee) == &ee.x); const REndFunctionWithPrivateEndMember f{}; assert(std::ranges::rend(f) == &f.y); assert(std::ranges::crend(f) == &f.y); REndFunctionWithPrivateEndMember ff{}; - static_assert(!std::is_invocable_v); + assert(std::ranges::rend(ff) == &ff.y); // Ill-formed before P2602R2 Poison Pills are Too Toxic assert(std::ranges::crend(ff) == &ff.y); const RBeginMemberEndFunction g{}; assert(std::ranges::rend(g) == &g.x); assert(std::ranges::crend(g) == &g.x); RBeginMemberEndFunction gg{}; - static_assert(!std::is_invocable_v); + assert(std::ranges::rend(gg) == &gg.x); // Ill-formed before P2602R2 Poison Pills are Too Toxic assert(std::ranges::crend(gg) == &gg.x); return true; @@ -530,6 +534,10 @@ static_assert(!std::is_invocable_v*&>); static_assert(!std::is_invocable_v*>); static_assert(!std::is_invocable_v*&>); +// Ordinary unqualified lookup should not be performed. +static_assert(!std::is_invocable_v); +static_assert(!std::is_invocable_v); + int main(int, char**) { static_assert(testReturnTypes()); diff --git a/libcxx/test/std/ranges/range.access/size.pass.cpp b/libcxx/test/std/ranges/range.access/size.pass.cpp index fd7d0a8b99752..36bd19ba8c579 100644 --- a/libcxx/test/std/ranges/range.access/size.pass.cpp +++ b/libcxx/test/std/ranges/range.access/size.pass.cpp @@ -10,6 +10,10 @@ // std::ranges::size +// Note: this header is intentionally included before any other header. +// Access functions defined here must be visible to accessors from `` header. +#include "ordinary_unqualified_lookup_helpers.h" + #include #include @@ -219,7 +223,7 @@ inline constexpr bool std::ranges::disable_sized_range); static_assert( std::is_invocable_v); -static_assert(!std::is_invocable_v); +static_assert( std::is_invocable_v); // Ill-formed before P2602R2 Poison Pills are Too Toxic static_assert( std::is_invocable_v); // No begin end. @@ -318,6 +322,9 @@ template struct Holder { T t; }; static_assert(!std::is_invocable_v*>); static_assert(!std::is_invocable_v*&>); +// Ordinary unqualified lookup should not be performed. +static_assert(!std::is_invocable_v); + int main(int, char**) { testArrayType(); static_assert(testArrayType()); diff --git a/libcxx/utils/generate_feature_test_macro_components.py b/libcxx/utils/generate_feature_test_macro_components.py index 8943ad2557433..153b7d54a7059 100755 --- a/libcxx/utils/generate_feature_test_macro_components.py +++ b/libcxx/utils/generate_feature_test_macro_components.py @@ -882,7 +882,7 @@ def add_version_header(tc): }, { "name": "__cpp_lib_ranges", - "values": {"c++20": 202207}, + "values": {"c++20": 202211}, # DR P2602R2 Poison Pills are Too Toxic "headers": ["algorithm", "functional", "iterator", "memory", "ranges"], }, { From 912bc3e26f810214f57631f36b9d7899d2360313 Mon Sep 17 00:00:00 2001 From: Jakub Mazurkiewicz Date: Wed, 6 Dec 2023 00:18:46 +0100 Subject: [PATCH 02/14] =?UTF-8?q?Make=20=F0=9F=90=8D=20formatter=20happy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libcxx/utils/generate_feature_test_macro_components.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcxx/utils/generate_feature_test_macro_components.py b/libcxx/utils/generate_feature_test_macro_components.py index 153b7d54a7059..531b8f0863e7a 100755 --- a/libcxx/utils/generate_feature_test_macro_components.py +++ b/libcxx/utils/generate_feature_test_macro_components.py @@ -882,7 +882,7 @@ def add_version_header(tc): }, { "name": "__cpp_lib_ranges", - "values": {"c++20": 202211}, # DR P2602R2 Poison Pills are Too Toxic + "values": {"c++20": 202211}, # DR P2602R2 Poison Pills are Too Toxic "headers": ["algorithm", "functional", "iterator", "memory", "ranges"], }, { From aabffddfe5b976c681315ca0b72c2a0e6dcb06c1 Mon Sep 17 00:00:00 2001 From: Jakub Mazurkiewicz Date: Wed, 10 Jan 2024 23:54:18 +0100 Subject: [PATCH 03/14] Formatting --- libcxx/test/std/ranges/range.access/begin.pass.cpp | 2 +- libcxx/test/std/ranges/range.access/end.pass.cpp | 2 +- libcxx/test/std/ranges/range.access/rbegin.pass.cpp | 3 ++- libcxx/test/std/ranges/range.access/rend.pass.cpp | 2 +- libcxx/test/std/ranges/range.access/size.pass.cpp | 3 ++- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/libcxx/test/std/ranges/range.access/begin.pass.cpp b/libcxx/test/std/ranges/range.access/begin.pass.cpp index 89e1e130c2dfb..c667fcfdce81d 100644 --- a/libcxx/test/std/ranges/range.access/begin.pass.cpp +++ b/libcxx/test/std/ranges/range.access/begin.pass.cpp @@ -196,7 +196,7 @@ struct BeginFunction { }; static_assert( std::is_invocable_v); static_assert(!std::is_invocable_v); -static_assert( std::is_invocable_v); // Ill-formed before P2602R2 Poison Pills are Too Toxic +static_assert(std::is_invocable_v); // Ill-formed before P2602R2 Poison Pills are Too Toxic static_assert( std::is_invocable_v); static_assert( std::is_invocable_v); diff --git a/libcxx/test/std/ranges/range.access/end.pass.cpp b/libcxx/test/std/ranges/range.access/end.pass.cpp index 749c20fe4c160..3047827dd8bcb 100644 --- a/libcxx/test/std/ranges/range.access/end.pass.cpp +++ b/libcxx/test/std/ranges/range.access/end.pass.cpp @@ -197,7 +197,7 @@ static_assert(!std::is_invocable_v); static_assert( std::is_invocable_v); static_assert(!std::is_invocable_v); -static_assert( std::is_invocable_v); // Ill-formed before P2602R2 Poison Pills are Too Toxic +static_assert(std::is_invocable_v); // Ill-formed before P2602R2 Poison Pills are Too Toxic static_assert( std::is_invocable_v); static_assert( std::is_invocable_v); diff --git a/libcxx/test/std/ranges/range.access/rbegin.pass.cpp b/libcxx/test/std/ranges/range.access/rbegin.pass.cpp index 9bd804b59d3b1..dee0445f20eb6 100644 --- a/libcxx/test/std/ranges/range.access/rbegin.pass.cpp +++ b/libcxx/test/std/ranges/range.access/rbegin.pass.cpp @@ -191,7 +191,8 @@ struct RBeginFunction { }; static_assert( std::is_invocable_v); static_assert(!std::is_invocable_v); -static_assert( std::is_invocable_v); // Ill-formed before P2602R2 Poison Pills are Too Toxic +static_assert( + std::is_invocable_v); // Ill-formed before P2602R2 Poison Pills are Too Toxic static_assert( std::is_invocable_v); static_assert( std::is_invocable_v); diff --git a/libcxx/test/std/ranges/range.access/rend.pass.cpp b/libcxx/test/std/ranges/range.access/rend.pass.cpp index eb45889ca70f8..4ec72cd80b743 100644 --- a/libcxx/test/std/ranges/range.access/rend.pass.cpp +++ b/libcxx/test/std/ranges/range.access/rend.pass.cpp @@ -200,7 +200,7 @@ static_assert(!std::is_invocable_v); static_assert( std::is_invocable_v); static_assert(!std::is_invocable_v); -static_assert( std::is_invocable_v); // Ill-formed before P2602R2 Poison Pills are Too Toxic +static_assert(std::is_invocable_v); // Ill-formed before P2602R2 Poison Pills are Too Toxic static_assert( std::is_invocable_v); static_assert( std::is_invocable_v); diff --git a/libcxx/test/std/ranges/range.access/size.pass.cpp b/libcxx/test/std/ranges/range.access/size.pass.cpp index 36bd19ba8c579..f35b2d659c0cf 100644 --- a/libcxx/test/std/ranges/range.access/size.pass.cpp +++ b/libcxx/test/std/ranges/range.access/size.pass.cpp @@ -223,7 +223,8 @@ inline constexpr bool std::ranges::disable_sized_range); static_assert( std::is_invocable_v); -static_assert( std::is_invocable_v); // Ill-formed before P2602R2 Poison Pills are Too Toxic +static_assert(std::is_invocable_v); // Ill-formed before P2602R2 Poison Pills are Too Toxic static_assert( std::is_invocable_v); // No begin end. From ccfae9567b879d2d7bec4d6d0418862369aa4060 Mon Sep 17 00:00:00 2001 From: Jakub Mazurkiewicz Date: Wed, 10 Jan 2024 23:59:28 +0100 Subject: [PATCH 04/14] Formatting (again) --- libcxx/test/std/ranges/range.access/begin.pass.cpp | 2 +- libcxx/test/std/ranges/range.access/end.pass.cpp | 2 +- libcxx/test/std/ranges/range.access/rend.pass.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libcxx/test/std/ranges/range.access/begin.pass.cpp b/libcxx/test/std/ranges/range.access/begin.pass.cpp index c667fcfdce81d..ddf7b37c69df2 100644 --- a/libcxx/test/std/ranges/range.access/begin.pass.cpp +++ b/libcxx/test/std/ranges/range.access/begin.pass.cpp @@ -196,7 +196,7 @@ struct BeginFunction { }; static_assert( std::is_invocable_v); static_assert(!std::is_invocable_v); -static_assert(std::is_invocable_v); // Ill-formed before P2602R2 Poison Pills are Too Toxic +static_assert(std::is_invocable_v); // Ill-formed before P2602R2 Poison Pills are Too Toxic static_assert( std::is_invocable_v); static_assert( std::is_invocable_v); diff --git a/libcxx/test/std/ranges/range.access/end.pass.cpp b/libcxx/test/std/ranges/range.access/end.pass.cpp index 3047827dd8bcb..b137ff0525037 100644 --- a/libcxx/test/std/ranges/range.access/end.pass.cpp +++ b/libcxx/test/std/ranges/range.access/end.pass.cpp @@ -197,7 +197,7 @@ static_assert(!std::is_invocable_v); static_assert( std::is_invocable_v); static_assert(!std::is_invocable_v); -static_assert(std::is_invocable_v); // Ill-formed before P2602R2 Poison Pills are Too Toxic +static_assert(std::is_invocable_v); // Ill-formed before P2602R2 Poison Pills are Too Toxic static_assert( std::is_invocable_v); static_assert( std::is_invocable_v); diff --git a/libcxx/test/std/ranges/range.access/rend.pass.cpp b/libcxx/test/std/ranges/range.access/rend.pass.cpp index 4ec72cd80b743..8db5cf13773a6 100644 --- a/libcxx/test/std/ranges/range.access/rend.pass.cpp +++ b/libcxx/test/std/ranges/range.access/rend.pass.cpp @@ -200,7 +200,7 @@ static_assert(!std::is_invocable_v); static_assert( std::is_invocable_v); static_assert(!std::is_invocable_v); -static_assert(std::is_invocable_v); // Ill-formed before P2602R2 Poison Pills are Too Toxic +static_assert(std::is_invocable_v); // Ill-formed before P2602R2 Poison Pills are Too Toxic static_assert( std::is_invocable_v); static_assert( std::is_invocable_v); From 0b5275c73b64abbe023e897dc44a71fe8d9b3b51 Mon Sep 17 00:00:00 2001 From: Jakub Mazurkiewicz Date: Sat, 3 Feb 2024 17:57:05 +0100 Subject: [PATCH 05/14] Code cleanup --- .../iterator.cust.move/iter_move.pass.cpp | 11 +++++----- .../iterator.cust.swap/iter_swap.pass.cpp | 5 +++-- .../ordinary_unqualified_lookup_helpers.h | 22 +++++++++---------- .../cmp/cmp.alg/partial_order.pass.cpp | 8 +++---- .../cmp/cmp.alg/strong_order.pass.cpp | 8 +++---- .../cmp/cmp.alg/weak_order.pass.cpp | 8 +++---- .../std/ranges/range.access/begin.pass.cpp | 10 ++++----- .../test/std/ranges/range.access/end.pass.cpp | 10 ++++----- .../ordinary_unqualified_lookup_helpers.h | 19 +++++++--------- .../std/ranges/range.access/rbegin.pass.cpp | 10 ++++----- .../std/ranges/range.access/rend.pass.cpp | 10 ++++----- .../std/ranges/range.access/size.pass.cpp | 7 +++--- 12 files changed, 59 insertions(+), 69 deletions(-) diff --git a/libcxx/test/std/iterators/iterator.requirements/iterator.cust/iterator.cust.move/iter_move.pass.cpp b/libcxx/test/std/iterators/iterator.requirements/iterator.cust/iterator.cust.move/iter_move.pass.cpp index d64991bdee546..8bac08cb32e2b 100644 --- a/libcxx/test/std/iterators/iterator.requirements/iterator.cust/iterator.cust.move/iter_move.pass.cpp +++ b/libcxx/test/std/iterators/iterator.requirements/iterator.cust/iterator.cust.move/iter_move.pass.cpp @@ -11,13 +11,12 @@ // template // unspecified iter_move; -// Note: this struct is intentionally defined before any other header is included. -// Custom `iter_move` must be visible to `std::ranges::iter_move` CPO from `` header. -namespace nest { +// Intentionally defined before including headers. +namespace ordinary_unqualified_lookup_helpers { struct StructWithGlobalIterMove {}; -} // namespace nest +} // namespace ordinary_unqualified_lookup_helpers -int&& iter_move(nest::StructWithGlobalIterMove); +int&& iter_move(ordinary_unqualified_lookup_helpers::StructWithGlobalIterMove); #include #include @@ -195,7 +194,7 @@ static_assert(std::is_invocable_v**>); static_assert(std::is_invocable_v**&>); // Ordinary unqualified lookup should not be performed. -static_assert(!std::is_invocable_v); +static_assert(!std::is_invocable_v); int main(int, char**) { diff --git a/libcxx/test/std/iterators/iterator.requirements/iterator.cust/iterator.cust.swap/iter_swap.pass.cpp b/libcxx/test/std/iterators/iterator.requirements/iterator.cust/iterator.cust.swap/iter_swap.pass.cpp index 692ddef195d2c..e6507f7e77673 100644 --- a/libcxx/test/std/iterators/iterator.requirements/iterator.cust/iterator.cust.swap/iter_swap.pass.cpp +++ b/libcxx/test/std/iterators/iterator.requirements/iterator.cust/iterator.cust.swap/iter_swap.pass.cpp @@ -47,11 +47,12 @@ static_assert( std::is_invocable_v); static_assert( std::is_invocable_v); static_assert(!std::is_invocable_v); -struct NotMoreSpecializedIterSwap { +struct StructWithNotMoreSpecializedIterSwap { friend void iter_swap(auto&, auto&); }; -static_assert(!std::is_invocable_v); +static_assert( + !std::is_invocable_v); struct NodiscardIterSwap { [[nodiscard]] friend int iter_swap(NodiscardIterSwap&, NodiscardIterSwap&) { return 0; } diff --git a/libcxx/test/std/language.support/cmp/cmp.alg/ordinary_unqualified_lookup_helpers.h b/libcxx/test/std/language.support/cmp/cmp.alg/ordinary_unqualified_lookup_helpers.h index 4cbe163c312f4..5bd1edeb4b014 100644 --- a/libcxx/test/std/language.support/cmp/cmp.alg/ordinary_unqualified_lookup_helpers.h +++ b/libcxx/test/std/language.support/cmp/cmp.alg/ordinary_unqualified_lookup_helpers.h @@ -9,22 +9,22 @@ #ifndef TEST_STD_LANGUAGE_SUPPORT_CMP_CMP_ALG_ORDINARY_UNQUALIFIED_LOOKUP_HELPERS_H #define TEST_STD_LANGUAGE_SUPPORT_CMP_CMP_ALG_ORDINARY_UNQUALIFIED_LOOKUP_HELPERS_H -// Note: this header should be included before any other header. -// Comparison functions defined here must be visible to CPOs from `` header. - -namespace nest { +namespace ordinary_unqualified_lookup_helpers { struct StructWithGlobalCmpFunctions {}; -} // namespace nest +} // namespace ordinary_unqualified_lookup_helpers -struct ConvertibleToComparisonType; +struct ConvertibleToCmpType; -ConvertibleToComparisonType strong_order(nest::StructWithGlobalCmpFunctions, nest::StructWithGlobalCmpFunctions); -ConvertibleToComparisonType weak_order(nest::StructWithGlobalCmpFunctions, nest::StructWithGlobalCmpFunctions); -ConvertibleToComparisonType partial_order(nest::StructWithGlobalCmpFunctions, nest::StructWithGlobalCmpFunctions); +ConvertibleToCmpType strong_order(ordinary_unqualified_lookup_helpers::StructWithGlobalCmpFunctions, + ordinary_unqualified_lookup_helpers::StructWithGlobalCmpFunctions); +ConvertibleToCmpType weak_order(ordinary_unqualified_lookup_helpers::StructWithGlobalCmpFunctions, + ordinary_unqualified_lookup_helpers::StructWithGlobalCmpFunctions); +ConvertibleToCmpType partial_order(ordinary_unqualified_lookup_helpers::StructWithGlobalCmpFunctions, + ordinary_unqualified_lookup_helpers::StructWithGlobalCmpFunctions); -#include // Intentionally included here, so we can define `ConvertibleToComparisonType` later. +#include // Intentionally included here, so we can define `ConvertibleToCmpType` later. -struct ConvertibleToComparisonType { +struct ConvertibleToCmpType { operator std::strong_ordering() const; operator std::weak_ordering() const; operator std::partial_ordering() const; diff --git a/libcxx/test/std/language.support/cmp/cmp.alg/partial_order.pass.cpp b/libcxx/test/std/language.support/cmp/cmp.alg/partial_order.pass.cpp index d6376f0a5cb2a..a63367f4c351f 100644 --- a/libcxx/test/std/language.support/cmp/cmp.alg/partial_order.pass.cpp +++ b/libcxx/test/std/language.support/cmp/cmp.alg/partial_order.pass.cpp @@ -12,9 +12,7 @@ // template constexpr partial_ordering partial_order(const T& a, const T& b); -// Note: this header is intentionally included before any other header. -// Comparison functions defined there must be visible to CPOs from `` header. -#include "ordinary_unqualified_lookup_helpers.h" +#include "ordinary_unqualified_lookup_helpers.h" // Intentionally included before other headers. #include @@ -246,8 +244,8 @@ constexpr bool test_1_4() // Ordinary unqualified lookup should not be performed. static_assert(!std::is_invocable_v); + ordinary_unqualified_lookup_helpers::StructWithGlobalCmpFunctions, + ordinary_unqualified_lookup_helpers::StructWithGlobalCmpFunctions>); int main(int, char**) { diff --git a/libcxx/test/std/language.support/cmp/cmp.alg/strong_order.pass.cpp b/libcxx/test/std/language.support/cmp/cmp.alg/strong_order.pass.cpp index 5c26a0be23f0a..a6387ccd5a5ef 100644 --- a/libcxx/test/std/language.support/cmp/cmp.alg/strong_order.pass.cpp +++ b/libcxx/test/std/language.support/cmp/cmp.alg/strong_order.pass.cpp @@ -12,9 +12,7 @@ // template constexpr strong_ordering strong_order(const T& a, const T& b); -// Note: this header is intentionally included before any other header. -// Comparison functions defined there must be visible to CPOs from `` header. -#include "ordinary_unqualified_lookup_helpers.h" +#include "ordinary_unqualified_lookup_helpers.h" // Intentionally included before other headers. #include @@ -454,8 +452,8 @@ constexpr bool test_1_4() // Ordinary unqualified lookup should not be performed. static_assert(!std::is_invocable_v); + ordinary_unqualified_lookup_helpers::StructWithGlobalCmpFunctions, + ordinary_unqualified_lookup_helpers::StructWithGlobalCmpFunctions>); int main(int, char**) { diff --git a/libcxx/test/std/language.support/cmp/cmp.alg/weak_order.pass.cpp b/libcxx/test/std/language.support/cmp/cmp.alg/weak_order.pass.cpp index 0dc79acc99ed9..47b1c1d64cead 100644 --- a/libcxx/test/std/language.support/cmp/cmp.alg/weak_order.pass.cpp +++ b/libcxx/test/std/language.support/cmp/cmp.alg/weak_order.pass.cpp @@ -12,9 +12,7 @@ // template constexpr weak_ordering weak_order(const T& a, const T& b); -// Note: this header is intentionally included before any other header. -// Comparison functions defined there must be visible to CPOs from `` header. -#include "ordinary_unqualified_lookup_helpers.h" +#include "ordinary_unqualified_lookup_helpers.h" // Intentionally included before other headers. #include @@ -499,8 +497,8 @@ constexpr bool test_1_5() // Ordinary unqualified lookup should not be performed. static_assert(!std::is_invocable_v); + ordinary_unqualified_lookup_helpers::StructWithGlobalCmpFunctions, + ordinary_unqualified_lookup_helpers::StructWithGlobalCmpFunctions>); int main(int, char**) { diff --git a/libcxx/test/std/ranges/range.access/begin.pass.cpp b/libcxx/test/std/ranges/range.access/begin.pass.cpp index ddf7b37c69df2..bf185f6422efb 100644 --- a/libcxx/test/std/ranges/range.access/begin.pass.cpp +++ b/libcxx/test/std/ranges/range.access/begin.pass.cpp @@ -11,9 +11,7 @@ // std::ranges::begin // std::ranges::cbegin -// Note: this header is intentionally included before any other header. -// Access functions defined here must be visible to accessors from `` header. -#include "ordinary_unqualified_lookup_helpers.h" +#include "ordinary_unqualified_lookup_helpers.h" // Intentionally included before other headers. #include @@ -330,8 +328,10 @@ static_assert(!std::is_invocable_v*>); static_assert(!std::is_invocable_v*&>); // Ordinary unqualified lookup should not be performed. -static_assert(!std::is_invocable_v); -static_assert(!std::is_invocable_v); +static_assert( + !std::is_invocable_v); +static_assert( + !std::is_invocable_v); int main(int, char**) { static_assert(testReturnTypes()); diff --git a/libcxx/test/std/ranges/range.access/end.pass.cpp b/libcxx/test/std/ranges/range.access/end.pass.cpp index b137ff0525037..61ae143001073 100644 --- a/libcxx/test/std/ranges/range.access/end.pass.cpp +++ b/libcxx/test/std/ranges/range.access/end.pass.cpp @@ -11,9 +11,7 @@ // std::ranges::end // std::ranges::cend -// Note: this header is intentionally included before any other header. -// Access functions defined here must be visible to accessors from `` header. -#include "ordinary_unqualified_lookup_helpers.h" +#include "ordinary_unqualified_lookup_helpers.h" // Intentionally included before other headers. #include @@ -359,8 +357,10 @@ static_assert(!std::is_invocable_v*>); static_assert(!std::is_invocable_v*&>); // Ordinary unqualified lookup should not be performed. -static_assert(!std::is_invocable_v); -static_assert(!std::is_invocable_v); +static_assert( + !std::is_invocable_v); +static_assert( + !std::is_invocable_v); int main(int, char**) { static_assert(testReturnTypes()); diff --git a/libcxx/test/std/ranges/range.access/ordinary_unqualified_lookup_helpers.h b/libcxx/test/std/ranges/range.access/ordinary_unqualified_lookup_helpers.h index 34be68aef1f4f..aa5d86588092f 100644 --- a/libcxx/test/std/ranges/range.access/ordinary_unqualified_lookup_helpers.h +++ b/libcxx/test/std/ranges/range.access/ordinary_unqualified_lookup_helpers.h @@ -9,17 +9,14 @@ #ifndef TEST_STD_RANGES_RANGE_ACCESS_ORDINARY_UNQUALIFIED_LOOKUP_HELPERS_H #define TEST_STD_RANGES_RANGE_ACCESS_ORDINARY_UNQUALIFIED_LOOKUP_HELPERS_H -// Note: this header should be included before any other header. -// Access functions defined here must be visible to accessors from `` header. +namespace ordinary_unqualified_lookup_helpers { +struct StructWithGlobalRangeAccessFunctions {}; +} // namespace ordinary_unqualified_lookup_helpers -namespace nest { -struct StructWithGlobalAccess {}; -} // namespace nest - -int* begin(nest::StructWithGlobalAccess); -int* end(nest::StructWithGlobalAccess); -int* rbegin(nest::StructWithGlobalAccess); -int* rend(nest::StructWithGlobalAccess); -unsigned int size(nest::StructWithGlobalAccess); +int* begin(ordinary_unqualified_lookup_helpers::StructWithGlobalRangeAccessFunctions); +int* end(ordinary_unqualified_lookup_helpers::StructWithGlobalRangeAccessFunctions); +int* rbegin(ordinary_unqualified_lookup_helpers::StructWithGlobalRangeAccessFunctions); +int* rend(ordinary_unqualified_lookup_helpers::StructWithGlobalRangeAccessFunctions); +unsigned int size(ordinary_unqualified_lookup_helpers::StructWithGlobalRangeAccessFunctions); #endif // TEST_STD_RANGES_RANGE_ACCESS_ORDINARY_UNQUALIFIED_LOOKUP_HELPERS_H diff --git a/libcxx/test/std/ranges/range.access/rbegin.pass.cpp b/libcxx/test/std/ranges/range.access/rbegin.pass.cpp index dee0445f20eb6..5365ca87ed456 100644 --- a/libcxx/test/std/ranges/range.access/rbegin.pass.cpp +++ b/libcxx/test/std/ranges/range.access/rbegin.pass.cpp @@ -11,9 +11,7 @@ // std::ranges::rbegin // std::ranges::crbegin -// Note: this header is intentionally included before any other header. -// Access functions defined here must be visible to accessors from `` header. -#include "ordinary_unqualified_lookup_helpers.h" +#include "ordinary_unqualified_lookup_helpers.h" // Intentionally included before other headers. #include @@ -507,8 +505,10 @@ static_assert(!std::is_invocable_v*>); static_assert(!std::is_invocable_v*&>); // Ordinary unqualified lookup should not be performed. -static_assert(!std::is_invocable_v); -static_assert(!std::is_invocable_v); +static_assert( + !std::is_invocable_v); +static_assert( + !std::is_invocable_v); int main(int, char**) { static_assert(testReturnTypes()); diff --git a/libcxx/test/std/ranges/range.access/rend.pass.cpp b/libcxx/test/std/ranges/range.access/rend.pass.cpp index 8db5cf13773a6..28cc084435fc6 100644 --- a/libcxx/test/std/ranges/range.access/rend.pass.cpp +++ b/libcxx/test/std/ranges/range.access/rend.pass.cpp @@ -11,9 +11,7 @@ // std::ranges::rend // std::ranges::crend -// Note: this header is intentionally included before any other header. -// Access functions defined here must be visible to accessors from `` header. -#include "ordinary_unqualified_lookup_helpers.h" +#include "ordinary_unqualified_lookup_helpers.h" // Intentionally included before other headers. #include @@ -535,8 +533,10 @@ static_assert(!std::is_invocable_v*>); static_assert(!std::is_invocable_v*&>); // Ordinary unqualified lookup should not be performed. -static_assert(!std::is_invocable_v); -static_assert(!std::is_invocable_v); +static_assert( + !std::is_invocable_v); +static_assert( + !std::is_invocable_v); int main(int, char**) { static_assert(testReturnTypes()); diff --git a/libcxx/test/std/ranges/range.access/size.pass.cpp b/libcxx/test/std/ranges/range.access/size.pass.cpp index f35b2d659c0cf..65c507981768c 100644 --- a/libcxx/test/std/ranges/range.access/size.pass.cpp +++ b/libcxx/test/std/ranges/range.access/size.pass.cpp @@ -10,9 +10,7 @@ // std::ranges::size -// Note: this header is intentionally included before any other header. -// Access functions defined here must be visible to accessors from `` header. -#include "ordinary_unqualified_lookup_helpers.h" +#include "ordinary_unqualified_lookup_helpers.h" // Intentionally included before other headers. #include @@ -324,7 +322,8 @@ static_assert(!std::is_invocable_v*>); static_assert(!std::is_invocable_v*&>); // Ordinary unqualified lookup should not be performed. -static_assert(!std::is_invocable_v); +static_assert( + !std::is_invocable_v); int main(int, char**) { testArrayType(); From 7562e1828e9c7f361f6afe9db425d3e7393c2682 Mon Sep 17 00:00:00 2001 From: Jakub Mazurkiewicz Date: Mon, 5 Feb 2024 15:59:11 +0100 Subject: [PATCH 06/14] Update docs --- libcxx/docs/Status/Cxx23Papers.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcxx/docs/Status/Cxx23Papers.csv b/libcxx/docs/Status/Cxx23Papers.csv index e25a1e9419e3d..7998856bafabb 100644 --- a/libcxx/docs/Status/Cxx23Papers.csv +++ b/libcxx/docs/Status/Cxx23Papers.csv @@ -100,7 +100,7 @@ "`P2396R1 `__","LWG", "Concurrency TS 2 fixes ", "November 2022","","","|concurrency TS|" "`P2505R5 `__","LWG", "Monadic Functions for ``std::expected``", "November 2022","|Complete|","17.0","" "`P2539R4 `__","LWG", "Should the output of ``std::print`` to a terminal be synchronized with the underlying stream?", "November 2022","|Complete|","18.0","|format|" -"`P2602R2 `__","LWG", "Poison Pills are Too Toxic", "November 2022","|Complete|","18.0","|ranges|" +"`P2602R2 `__","LWG", "Poison Pills are Too Toxic", "November 2022","|Complete|","19.0","|ranges|" "`P2708R1 `__","LWG", "No Further Fundamentals TSes", "November 2022","|Nothing to do|","","" "","","","","","","" "`P0290R4 `__","LWG", "``apply()`` for ``synchronized_value``","February 2023","","","|concurrency TS|" From 9429bbffd01eca9f1b09b0e7a852585227624e69 Mon Sep 17 00:00:00 2001 From: Jakub Mazurkiewicz Date: Tue, 20 Feb 2024 13:10:00 +0100 Subject: [PATCH 07/14] Fix value of `__cpp_lib_ranges` FTM --- libcxx/docs/FeatureTestMacroTable.rst | 2 +- libcxx/include/version | 4 ++-- .../algorithm.version.compile.pass.cpp | 14 +++++++------- .../functional.version.compile.pass.cpp | 14 +++++++------- .../iterator.version.compile.pass.cpp | 14 +++++++------- .../memory.version.compile.pass.cpp | 14 +++++++------- .../ranges.version.compile.pass.cpp | 14 +++++++------- .../version.version.compile.pass.cpp | 14 +++++++------- .../generate_feature_test_macro_components.py | 12 +++++++++++- 9 files changed, 56 insertions(+), 46 deletions(-) diff --git a/libcxx/docs/FeatureTestMacroTable.rst b/libcxx/docs/FeatureTestMacroTable.rst index ff7334d17e1a0..89d510a50faaa 100644 --- a/libcxx/docs/FeatureTestMacroTable.rst +++ b/libcxx/docs/FeatureTestMacroTable.rst @@ -266,7 +266,7 @@ Status --------------------------------------------------- ----------------- ``__cpp_lib_polymorphic_allocator`` ``201902L`` --------------------------------------------------- ----------------- - ``__cpp_lib_ranges`` ``202211L`` + ``__cpp_lib_ranges`` ``202110L`` --------------------------------------------------- ----------------- ``__cpp_lib_remove_cvref`` ``201711L`` --------------------------------------------------- ----------------- diff --git a/libcxx/include/version b/libcxx/include/version index 14770f62ae5e7..f2ca6af0467ac 100644 --- a/libcxx/include/version +++ b/libcxx/include/version @@ -164,7 +164,7 @@ __cpp_lib_parallel_algorithm 201603L __cpp_lib_print 202207L __cpp_lib_quoted_string_io 201304L -__cpp_lib_ranges 202211L +__cpp_lib_ranges 202110L __cpp_lib_ranges_as_const 202207L __cpp_lib_ranges_as_rvalue 202207L @@ -406,7 +406,7 @@ __cpp_lib_within_lifetime 202306L # if _LIBCPP_AVAILABILITY_HAS_PMR # define __cpp_lib_polymorphic_allocator 201902L # endif -# define __cpp_lib_ranges 202211L +# define __cpp_lib_ranges 202110L # define __cpp_lib_remove_cvref 201711L # if !defined(_LIBCPP_HAS_NO_THREADS) && _LIBCPP_AVAILABILITY_HAS_SYNC # define __cpp_lib_semaphore 201907L diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/algorithm.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/algorithm.version.compile.pass.cpp index 918c6d35f730d..6c0b333fecc17 100644 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/algorithm.version.compile.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/algorithm.version.compile.pass.cpp @@ -20,7 +20,7 @@ __cpp_lib_constexpr_algorithms 201806L [C++20] __cpp_lib_freestanding_algorithm 202311L [C++26] __cpp_lib_parallel_algorithm 201603L [C++17] - __cpp_lib_ranges 202211L [C++20] + __cpp_lib_ranges 202110L [C++20] __cpp_lib_ranges_starts_ends_with 202106L [C++23] __cpp_lib_robust_nonmodifying_seq_ops 201304L [C++14] __cpp_lib_sample 201603L [C++17] @@ -201,8 +201,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++20" # endif -# if __cpp_lib_ranges != 202211L -# error "__cpp_lib_ranges should have the value 202211L in c++20" +# if __cpp_lib_ranges != 202110L +# error "__cpp_lib_ranges should have the value 202110L in c++20" # endif # ifdef __cpp_lib_ranges_starts_ends_with @@ -266,8 +266,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++23" # endif -# if __cpp_lib_ranges != 202211L -# error "__cpp_lib_ranges should have the value 202211L in c++23" +# if __cpp_lib_ranges != 202110L +# error "__cpp_lib_ranges should have the value 202110L in c++23" # endif # if !defined(_LIBCPP_VERSION) @@ -349,8 +349,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++26" # endif -# if __cpp_lib_ranges != 202211L -# error "__cpp_lib_ranges should have the value 202211L in c++26" +# if __cpp_lib_ranges != 202110L +# error "__cpp_lib_ranges should have the value 202110L in c++26" # endif # if !defined(_LIBCPP_VERSION) diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/functional.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/functional.version.compile.pass.cpp index 55674d104fab9..c24e6b94cd57f 100644 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/functional.version.compile.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/functional.version.compile.pass.cpp @@ -28,7 +28,7 @@ __cpp_lib_invoke_r 202106L [C++23] __cpp_lib_move_only_function 202110L [C++23] __cpp_lib_not_fn 201603L [C++17] - __cpp_lib_ranges 202211L [C++20] + __cpp_lib_ranges 202110L [C++20] __cpp_lib_result_of_sfinae 201210L [C++14] __cpp_lib_transparent_operators 201210L [C++14] 201510L [C++17] @@ -293,8 +293,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++20" # endif -# if __cpp_lib_ranges != 202211L -# error "__cpp_lib_ranges should have the value 202211L in c++20" +# if __cpp_lib_ranges != 202110L +# error "__cpp_lib_ranges should have the value 202110L in c++20" # endif # ifndef __cpp_lib_result_of_sfinae @@ -399,8 +399,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++23" # endif -# if __cpp_lib_ranges != 202211L -# error "__cpp_lib_ranges should have the value 202211L in c++23" +# if __cpp_lib_ranges != 202110L +# error "__cpp_lib_ranges should have the value 202110L in c++23" # endif # ifndef __cpp_lib_result_of_sfinae @@ -523,8 +523,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++26" # endif -# if __cpp_lib_ranges != 202211L -# error "__cpp_lib_ranges should have the value 202211L in c++26" +# if __cpp_lib_ranges != 202110L +# error "__cpp_lib_ranges should have the value 202110L in c++26" # endif # ifndef __cpp_lib_result_of_sfinae diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/iterator.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/iterator.version.compile.pass.cpp index 6c652e694f6dd..228b530dd3228 100644 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/iterator.version.compile.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/iterator.version.compile.pass.cpp @@ -23,7 +23,7 @@ __cpp_lib_move_iterator_concept 202207L [C++20] __cpp_lib_nonmember_container_access 201411L [C++17] __cpp_lib_null_iterators 201304L [C++14] - __cpp_lib_ranges 202211L [C++20] + __cpp_lib_ranges 202110L [C++20] __cpp_lib_ssize 201902L [C++20] */ @@ -197,8 +197,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++20" # endif -# if __cpp_lib_ranges != 202211L -# error "__cpp_lib_ranges should have the value 202211L in c++20" +# if __cpp_lib_ranges != 202110L +# error "__cpp_lib_ranges should have the value 202110L in c++20" # endif # ifndef __cpp_lib_ssize @@ -255,8 +255,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++23" # endif -# if __cpp_lib_ranges != 202211L -# error "__cpp_lib_ranges should have the value 202211L in c++23" +# if __cpp_lib_ranges != 202110L +# error "__cpp_lib_ranges should have the value 202110L in c++23" # endif # ifndef __cpp_lib_ssize @@ -313,8 +313,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++26" # endif -# if __cpp_lib_ranges != 202211L -# error "__cpp_lib_ranges should have the value 202211L in c++26" +# if __cpp_lib_ranges != 202110L +# error "__cpp_lib_ranges should have the value 202110L in c++26" # endif # ifndef __cpp_lib_ssize diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/memory.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/memory.version.compile.pass.cpp index bca701f7a37f4..cf13dff11b34f 100644 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/memory.version.compile.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/memory.version.compile.pass.cpp @@ -28,7 +28,7 @@ __cpp_lib_make_unique 201304L [C++14] __cpp_lib_out_ptr 202106L [C++23] 202311L [C++26] - __cpp_lib_ranges 202211L [C++20] + __cpp_lib_ranges 202110L [C++20] __cpp_lib_raw_memory_algorithms 201606L [C++17] __cpp_lib_shared_ptr_arrays 201611L [C++17] 201707L [C++20] @@ -364,8 +364,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++20" # endif -# if __cpp_lib_ranges != 202211L -# error "__cpp_lib_ranges should have the value 202211L in c++20" +# if __cpp_lib_ranges != 202110L +# error "__cpp_lib_ranges should have the value 202110L in c++20" # endif # ifndef __cpp_lib_raw_memory_algorithms @@ -501,8 +501,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++23" # endif -# if __cpp_lib_ranges != 202211L -# error "__cpp_lib_ranges should have the value 202211L in c++23" +# if __cpp_lib_ranges != 202110L +# error "__cpp_lib_ranges should have the value 202110L in c++23" # endif # ifndef __cpp_lib_raw_memory_algorithms @@ -638,8 +638,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++26" # endif -# if __cpp_lib_ranges != 202211L -# error "__cpp_lib_ranges should have the value 202211L in c++26" +# if __cpp_lib_ranges != 202110L +# error "__cpp_lib_ranges should have the value 202110L in c++26" # endif # ifndef __cpp_lib_raw_memory_algorithms diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/ranges.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/ranges.version.compile.pass.cpp index 0ea59178e6878..a144f48c705d1 100644 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/ranges.version.compile.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/ranges.version.compile.pass.cpp @@ -16,7 +16,7 @@ // Test the feature test macros defined by /* Constant Value - __cpp_lib_ranges 202211L [C++20] + __cpp_lib_ranges 202110L [C++20] __cpp_lib_ranges_as_const 202207L [C++23] __cpp_lib_ranges_as_rvalue 202207L [C++23] __cpp_lib_ranges_chunk 202202L [C++23] @@ -162,8 +162,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++20" # endif -# if __cpp_lib_ranges != 202211L -# error "__cpp_lib_ranges should have the value 202211L in c++20" +# if __cpp_lib_ranges != 202110L +# error "__cpp_lib_ranges should have the value 202110L in c++20" # endif # ifdef __cpp_lib_ranges_as_const @@ -207,8 +207,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++23" # endif -# if __cpp_lib_ranges != 202211L -# error "__cpp_lib_ranges should have the value 202211L in c++23" +# if __cpp_lib_ranges != 202110L +# error "__cpp_lib_ranges should have the value 202110L in c++23" # endif # if !defined(_LIBCPP_VERSION) @@ -309,8 +309,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++26" # endif -# if __cpp_lib_ranges != 202211L -# error "__cpp_lib_ranges should have the value 202211L in c++26" +# if __cpp_lib_ranges != 202110L +# error "__cpp_lib_ranges should have the value 202110L in c++26" # endif # if !defined(_LIBCPP_VERSION) diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp index 859452c657c41..496880ffd1893 100644 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp @@ -153,7 +153,7 @@ __cpp_lib_polymorphic_allocator 201902L [C++20] __cpp_lib_print 202207L [C++23] __cpp_lib_quoted_string_io 201304L [C++14] - __cpp_lib_ranges 202211L [C++20] + __cpp_lib_ranges 202110L [C++20] __cpp_lib_ranges_as_const 202207L [C++23] __cpp_lib_ranges_as_rvalue 202207L [C++23] __cpp_lib_ranges_chunk 202202L [C++23] @@ -3845,8 +3845,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++20" # endif -# if __cpp_lib_ranges != 202211L -# error "__cpp_lib_ranges should have the value 202211L in c++20" +# if __cpp_lib_ranges != 202110L +# error "__cpp_lib_ranges should have the value 202110L in c++20" # endif # ifdef __cpp_lib_ranges_as_const @@ -5277,8 +5277,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++23" # endif -# if __cpp_lib_ranges != 202211L -# error "__cpp_lib_ranges should have the value 202211L in c++23" +# if __cpp_lib_ranges != 202110L +# error "__cpp_lib_ranges should have the value 202110L in c++23" # endif # if !defined(_LIBCPP_VERSION) @@ -6976,8 +6976,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++26" # endif -# if __cpp_lib_ranges != 202211L -# error "__cpp_lib_ranges should have the value 202211L in c++26" +# if __cpp_lib_ranges != 202110L +# error "__cpp_lib_ranges should have the value 202110L in c++26" # endif # if !defined(_LIBCPP_VERSION) diff --git a/libcxx/utils/generate_feature_test_macro_components.py b/libcxx/utils/generate_feature_test_macro_components.py index 9561e2d352f13..ee98739e01d4b 100755 --- a/libcxx/utils/generate_feature_test_macro_components.py +++ b/libcxx/utils/generate_feature_test_macro_components.py @@ -882,7 +882,17 @@ def add_version_header(tc): }, { "name": "__cpp_lib_ranges", - "values": {"c++20": 202211}, # DR P2602R2 Poison Pills are Too Toxic + "values": { + # "c++20": 201811, The One Ranges Proposal + # "c++20": 201907, Input Range Adaptors + # "c++20": 201911, ranges compare algorithm are over-constrained + # "c++20": 202106, Views should not be required to be default constructible + "c++20": 202110, # What is a view? + # "c++23": 202202, Pipe support for user-defined range adaptors (Not implemented) + # "c++23": 202207, Relaxing range adaptors to allow for move only types + # "c++23": 202211, Poison Pills are Too Toxic (C++20 DR) + # "c++23": 202302, Relaxing Ranges Just A Smidge (Not implemented) + }, "headers": ["algorithm", "functional", "iterator", "memory", "ranges"], }, { From d908384346d7d39825ad21232b8f6a37e115e58b Mon Sep 17 00:00:00 2001 From: Jakub Mazurkiewicz Date: Tue, 20 Feb 2024 13:25:56 +0100 Subject: [PATCH 08/14] Python formatting --- .../generate_feature_test_macro_components.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libcxx/utils/generate_feature_test_macro_components.py b/libcxx/utils/generate_feature_test_macro_components.py index 64f95c7ba3f19..51f07b12b2370 100755 --- a/libcxx/utils/generate_feature_test_macro_components.py +++ b/libcxx/utils/generate_feature_test_macro_components.py @@ -887,15 +887,15 @@ def add_version_header(tc): { "name": "__cpp_lib_ranges", "values": { - # "c++20": 201811, The One Ranges Proposal - # "c++20": 201907, Input Range Adaptors - # "c++20": 201911, ranges compare algorithm are over-constrained - # "c++20": 202106, Views should not be required to be default constructible - "c++20": 202110, # What is a view? - # "c++23": 202202, Pipe support for user-defined range adaptors (Not implemented) - # "c++23": 202207, Relaxing range adaptors to allow for move only types - # "c++23": 202211, Poison Pills are Too Toxic (C++20 DR) - # "c++23": 202302, Relaxing Ranges Just A Smidge (Not implemented) + # "c++20": 201811 The One Ranges Proposal + # "c++20": 201907 Input Range Adaptors + # "c++20": 201911 ranges compare algorithm are over-constrained + # "c++20": 202106 Views should not be required to be default constructible + "c++20": 202110, # What is a view? + # "c++23": 202202 Pipe support for user-defined range adaptors (Not implemented) + # "c++23": 202207 Relaxing range adaptors to allow for move only types + # "c++23": 202211 Poison Pills are Too Toxic (C++20 DR) + # "c++23": 202302 Relaxing Ranges Just A Smidge (Not implemented) }, "headers": ["algorithm", "functional", "iterator", "memory", "ranges"], }, From fec693608d6d4df5de91f3bbbfcbc19659078b91 Mon Sep 17 00:00:00 2001 From: Jakub Mazurkiewicz Date: Tue, 20 Feb 2024 23:22:33 +0100 Subject: [PATCH 09/14] Poke CI From f0c2fe582cef071e1ef27e396fb8c0c196acb942 Mon Sep 17 00:00:00 2001 From: Jakub Mazurkiewicz Date: Wed, 21 Feb 2024 10:52:34 +0100 Subject: [PATCH 10/14] Poke CI (again) From 510a91a9fe1301da6a95f82328c47a9959a35ee9 Mon Sep 17 00:00:00 2001 From: Jakub Mazurkiewicz Date: Mon, 26 Feb 2024 16:37:01 +0100 Subject: [PATCH 11/14] Separate ordinary unqualified lookup tests. --- .../iterator.cust.move/iter_move.pass.cpp | 10 ----- ...dinary_unqualified_lookup.compile.pass.cpp | 29 ++++++++++++ .../ordinary_unqualified_lookup_helpers.h | 33 -------------- .../cmp/cmp.alg/partial_order.pass.cpp | 7 --- ...dinary_unqualified_lookup.compile.pass.cpp | 44 +++++++++++++++++++ .../cmp/cmp.alg/strong_order.pass.cpp | 7 --- .../cmp/cmp.alg/weak_order.pass.cpp | 7 --- .../std/ranges/range.access/begin.pass.cpp | 8 ---- .../test/std/ranges/range.access/end.pass.cpp | 8 ---- .../ordinary_unqualified_lookup_helpers.h | 22 ---------- ...rdinary_unqualifed_lookup.compile.pass.cpp | 40 +++++++++++++++++ .../std/ranges/range.access/rbegin.pass.cpp | 8 ---- .../std/ranges/range.access/rend.pass.cpp | 8 ---- .../std/ranges/range.access/size.pass.cpp | 6 --- 14 files changed, 113 insertions(+), 124 deletions(-) create mode 100644 libcxx/test/std/iterators/iterator.requirements/iterator.cust/robust_against_ordinary_unqualified_lookup.compile.pass.cpp delete mode 100644 libcxx/test/std/language.support/cmp/cmp.alg/ordinary_unqualified_lookup_helpers.h create mode 100644 libcxx/test/std/language.support/cmp/cmp.alg/robust_against_ordinary_unqualified_lookup.compile.pass.cpp delete mode 100644 libcxx/test/std/ranges/range.access/ordinary_unqualified_lookup_helpers.h create mode 100644 libcxx/test/std/ranges/range.access/ranges_robust_against_ordinary_unqualifed_lookup.compile.pass.cpp diff --git a/libcxx/test/std/iterators/iterator.requirements/iterator.cust/iterator.cust.move/iter_move.pass.cpp b/libcxx/test/std/iterators/iterator.requirements/iterator.cust/iterator.cust.move/iter_move.pass.cpp index 8bac08cb32e2b..9f293ff483cd8 100644 --- a/libcxx/test/std/iterators/iterator.requirements/iterator.cust/iterator.cust.move/iter_move.pass.cpp +++ b/libcxx/test/std/iterators/iterator.requirements/iterator.cust/iterator.cust.move/iter_move.pass.cpp @@ -11,13 +11,6 @@ // template // unspecified iter_move; -// Intentionally defined before including headers. -namespace ordinary_unqualified_lookup_helpers { -struct StructWithGlobalIterMove {}; -} // namespace ordinary_unqualified_lookup_helpers - -int&& iter_move(ordinary_unqualified_lookup_helpers::StructWithGlobalIterMove); - #include #include #include @@ -193,9 +186,6 @@ template struct Holder { T t; }; static_assert(std::is_invocable_v**>); static_assert(std::is_invocable_v**&>); -// Ordinary unqualified lookup should not be performed. -static_assert(!std::is_invocable_v); - int main(int, char**) { test(); diff --git a/libcxx/test/std/iterators/iterator.requirements/iterator.cust/robust_against_ordinary_unqualified_lookup.compile.pass.cpp b/libcxx/test/std/iterators/iterator.requirements/iterator.cust/robust_against_ordinary_unqualified_lookup.compile.pass.cpp new file mode 100644 index 0000000000000..efac342661e5e --- /dev/null +++ b/libcxx/test/std/iterators/iterator.requirements/iterator.cust/robust_against_ordinary_unqualified_lookup.compile.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17 + +// + +// Ordinary unqualified lookup should not be performed. + +namespace ns { +struct StructWithGlobalIterCustFunctions {}; +} // namespace ns + +int&& iter_move(ns::StructWithGlobalIterCustFunctions); +void iter_swap(ns::StructWithGlobalIterCustFunctions, ns::StructWithGlobalIterCustFunctions); + +#include +#include + +static_assert(!std::is_invocable_v); + +static_assert(!std::is_invocable_v); diff --git a/libcxx/test/std/language.support/cmp/cmp.alg/ordinary_unqualified_lookup_helpers.h b/libcxx/test/std/language.support/cmp/cmp.alg/ordinary_unqualified_lookup_helpers.h deleted file mode 100644 index 5bd1edeb4b014..0000000000000 --- a/libcxx/test/std/language.support/cmp/cmp.alg/ordinary_unqualified_lookup_helpers.h +++ /dev/null @@ -1,33 +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 -// -//===----------------------------------------------------------------------===// - -#ifndef TEST_STD_LANGUAGE_SUPPORT_CMP_CMP_ALG_ORDINARY_UNQUALIFIED_LOOKUP_HELPERS_H -#define TEST_STD_LANGUAGE_SUPPORT_CMP_CMP_ALG_ORDINARY_UNQUALIFIED_LOOKUP_HELPERS_H - -namespace ordinary_unqualified_lookup_helpers { -struct StructWithGlobalCmpFunctions {}; -} // namespace ordinary_unqualified_lookup_helpers - -struct ConvertibleToCmpType; - -ConvertibleToCmpType strong_order(ordinary_unqualified_lookup_helpers::StructWithGlobalCmpFunctions, - ordinary_unqualified_lookup_helpers::StructWithGlobalCmpFunctions); -ConvertibleToCmpType weak_order(ordinary_unqualified_lookup_helpers::StructWithGlobalCmpFunctions, - ordinary_unqualified_lookup_helpers::StructWithGlobalCmpFunctions); -ConvertibleToCmpType partial_order(ordinary_unqualified_lookup_helpers::StructWithGlobalCmpFunctions, - ordinary_unqualified_lookup_helpers::StructWithGlobalCmpFunctions); - -#include // Intentionally included here, so we can define `ConvertibleToCmpType` later. - -struct ConvertibleToCmpType { - operator std::strong_ordering() const; - operator std::weak_ordering() const; - operator std::partial_ordering() const; -}; - -#endif // TEST_STD_LANGUAGE_SUPPORT_CMP_CMP_ALG_ORDINARY_UNQUALIFIED_LOOKUP_HELPERS_H diff --git a/libcxx/test/std/language.support/cmp/cmp.alg/partial_order.pass.cpp b/libcxx/test/std/language.support/cmp/cmp.alg/partial_order.pass.cpp index a63367f4c351f..bd313889b1a4e 100644 --- a/libcxx/test/std/language.support/cmp/cmp.alg/partial_order.pass.cpp +++ b/libcxx/test/std/language.support/cmp/cmp.alg/partial_order.pass.cpp @@ -12,8 +12,6 @@ // template constexpr partial_ordering partial_order(const T& a, const T& b); -#include "ordinary_unqualified_lookup_helpers.h" // Intentionally included before other headers. - #include #include @@ -242,11 +240,6 @@ constexpr bool test_1_4() return true; } -// Ordinary unqualified lookup should not be performed. -static_assert(!std::is_invocable_v); - int main(int, char**) { test_1_1(); diff --git a/libcxx/test/std/language.support/cmp/cmp.alg/robust_against_ordinary_unqualified_lookup.compile.pass.cpp b/libcxx/test/std/language.support/cmp/cmp.alg/robust_against_ordinary_unqualified_lookup.compile.pass.cpp new file mode 100644 index 0000000000000..b9fbaa66a8390 --- /dev/null +++ b/libcxx/test/std/language.support/cmp/cmp.alg/robust_against_ordinary_unqualified_lookup.compile.pass.cpp @@ -0,0 +1,44 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17 + +// + +// Ordinary unqualified lookup should not be performed. + +namespace ns { +struct StructWithGlobalCmpFunctions {}; +} // namespace ns + +struct ConvertibleToCmpType; + +ConvertibleToCmpType strong_order(ns::StructWithGlobalCmpFunctions, ns::StructWithGlobalCmpFunctions); +ConvertibleToCmpType weak_order(ns::StructWithGlobalCmpFunctions, ns::StructWithGlobalCmpFunctions); +ConvertibleToCmpType partial_order(ns::StructWithGlobalCmpFunctions, ns::StructWithGlobalCmpFunctions); + +#include +#include + +struct ConvertibleToCmpType { + operator std::strong_ordering() const; + operator std::weak_ordering() const; + operator std::partial_ordering() const; +}; + +static_assert(!std::is_invocable_v); + +static_assert(!std::is_invocable_v); + +static_assert(!std::is_invocable_v); diff --git a/libcxx/test/std/language.support/cmp/cmp.alg/strong_order.pass.cpp b/libcxx/test/std/language.support/cmp/cmp.alg/strong_order.pass.cpp index a6387ccd5a5ef..ac6b6879f7730 100644 --- a/libcxx/test/std/language.support/cmp/cmp.alg/strong_order.pass.cpp +++ b/libcxx/test/std/language.support/cmp/cmp.alg/strong_order.pass.cpp @@ -12,8 +12,6 @@ // template constexpr strong_ordering strong_order(const T& a, const T& b); -#include "ordinary_unqualified_lookup_helpers.h" // Intentionally included before other headers. - #include #include @@ -450,11 +448,6 @@ constexpr bool test_1_4() return true; } -// Ordinary unqualified lookup should not be performed. -static_assert(!std::is_invocable_v); - int main(int, char**) { test_1_1(); diff --git a/libcxx/test/std/language.support/cmp/cmp.alg/weak_order.pass.cpp b/libcxx/test/std/language.support/cmp/cmp.alg/weak_order.pass.cpp index 47b1c1d64cead..09d720196e0b2 100644 --- a/libcxx/test/std/language.support/cmp/cmp.alg/weak_order.pass.cpp +++ b/libcxx/test/std/language.support/cmp/cmp.alg/weak_order.pass.cpp @@ -12,8 +12,6 @@ // template constexpr weak_ordering weak_order(const T& a, const T& b); -#include "ordinary_unqualified_lookup_helpers.h" // Intentionally included before other headers. - #include #include @@ -495,11 +493,6 @@ constexpr bool test_1_5() return true; } -// Ordinary unqualified lookup should not be performed. -static_assert(!std::is_invocable_v); - int main(int, char**) { test_1_1(); diff --git a/libcxx/test/std/ranges/range.access/begin.pass.cpp b/libcxx/test/std/ranges/range.access/begin.pass.cpp index bf185f6422efb..5ca3d59abb140 100644 --- a/libcxx/test/std/ranges/range.access/begin.pass.cpp +++ b/libcxx/test/std/ranges/range.access/begin.pass.cpp @@ -11,8 +11,6 @@ // std::ranges::begin // std::ranges::cbegin -#include "ordinary_unqualified_lookup_helpers.h" // Intentionally included before other headers. - #include #include @@ -327,12 +325,6 @@ static_assert(!std::is_invocable_v*&>); static_assert(!std::is_invocable_v*>); static_assert(!std::is_invocable_v*&>); -// Ordinary unqualified lookup should not be performed. -static_assert( - !std::is_invocable_v); -static_assert( - !std::is_invocable_v); - int main(int, char**) { static_assert(testReturnTypes()); diff --git a/libcxx/test/std/ranges/range.access/end.pass.cpp b/libcxx/test/std/ranges/range.access/end.pass.cpp index 61ae143001073..3e465b357e985 100644 --- a/libcxx/test/std/ranges/range.access/end.pass.cpp +++ b/libcxx/test/std/ranges/range.access/end.pass.cpp @@ -11,8 +11,6 @@ // std::ranges::end // std::ranges::cend -#include "ordinary_unqualified_lookup_helpers.h" // Intentionally included before other headers. - #include #include @@ -356,12 +354,6 @@ static_assert(!std::is_invocable_v*&>); static_assert(!std::is_invocable_v*>); static_assert(!std::is_invocable_v*&>); -// Ordinary unqualified lookup should not be performed. -static_assert( - !std::is_invocable_v); -static_assert( - !std::is_invocable_v); - int main(int, char**) { static_assert(testReturnTypes()); diff --git a/libcxx/test/std/ranges/range.access/ordinary_unqualified_lookup_helpers.h b/libcxx/test/std/ranges/range.access/ordinary_unqualified_lookup_helpers.h deleted file mode 100644 index aa5d86588092f..0000000000000 --- a/libcxx/test/std/ranges/range.access/ordinary_unqualified_lookup_helpers.h +++ /dev/null @@ -1,22 +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 -// -//===----------------------------------------------------------------------===// - -#ifndef TEST_STD_RANGES_RANGE_ACCESS_ORDINARY_UNQUALIFIED_LOOKUP_HELPERS_H -#define TEST_STD_RANGES_RANGE_ACCESS_ORDINARY_UNQUALIFIED_LOOKUP_HELPERS_H - -namespace ordinary_unqualified_lookup_helpers { -struct StructWithGlobalRangeAccessFunctions {}; -} // namespace ordinary_unqualified_lookup_helpers - -int* begin(ordinary_unqualified_lookup_helpers::StructWithGlobalRangeAccessFunctions); -int* end(ordinary_unqualified_lookup_helpers::StructWithGlobalRangeAccessFunctions); -int* rbegin(ordinary_unqualified_lookup_helpers::StructWithGlobalRangeAccessFunctions); -int* rend(ordinary_unqualified_lookup_helpers::StructWithGlobalRangeAccessFunctions); -unsigned int size(ordinary_unqualified_lookup_helpers::StructWithGlobalRangeAccessFunctions); - -#endif // TEST_STD_RANGES_RANGE_ACCESS_ORDINARY_UNQUALIFIED_LOOKUP_HELPERS_H diff --git a/libcxx/test/std/ranges/range.access/ranges_robust_against_ordinary_unqualifed_lookup.compile.pass.cpp b/libcxx/test/std/ranges/range.access/ranges_robust_against_ordinary_unqualifed_lookup.compile.pass.cpp new file mode 100644 index 0000000000000..12b8c5034e6b7 --- /dev/null +++ b/libcxx/test/std/ranges/range.access/ranges_robust_against_ordinary_unqualifed_lookup.compile.pass.cpp @@ -0,0 +1,40 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17 + +// + +// Ordinary unqualified lookup should not be performed. + +namespace ns { +struct StructWithGlobalRangeAccessFunctions {}; +} // namespace ns + +int* begin(ns::StructWithGlobalRangeAccessFunctions); +int* end(ns::StructWithGlobalRangeAccessFunctions); +int* rbegin(ns::StructWithGlobalRangeAccessFunctions); +int* rend(ns::StructWithGlobalRangeAccessFunctions); +unsigned int size(ns::StructWithGlobalRangeAccessFunctions); + +#include +#include + +static_assert(!std::is_invocable_v); +static_assert(!std::is_invocable_v); + +static_assert(!std::is_invocable_v); +static_assert(!std::is_invocable_v); + +static_assert(!std::is_invocable_v); +static_assert(!std::is_invocable_v); + +static_assert(!std::is_invocable_v); +static_assert(!std::is_invocable_v); + +static_assert(!std::is_invocable_v); diff --git a/libcxx/test/std/ranges/range.access/rbegin.pass.cpp b/libcxx/test/std/ranges/range.access/rbegin.pass.cpp index 5365ca87ed456..3997f38efd029 100644 --- a/libcxx/test/std/ranges/range.access/rbegin.pass.cpp +++ b/libcxx/test/std/ranges/range.access/rbegin.pass.cpp @@ -11,8 +11,6 @@ // std::ranges::rbegin // std::ranges::crbegin -#include "ordinary_unqualified_lookup_helpers.h" // Intentionally included before other headers. - #include #include @@ -504,12 +502,6 @@ static_assert(!std::is_invocable_v*&>); static_assert(!std::is_invocable_v*>); static_assert(!std::is_invocable_v*&>); -// Ordinary unqualified lookup should not be performed. -static_assert( - !std::is_invocable_v); -static_assert( - !std::is_invocable_v); - int main(int, char**) { static_assert(testReturnTypes()); diff --git a/libcxx/test/std/ranges/range.access/rend.pass.cpp b/libcxx/test/std/ranges/range.access/rend.pass.cpp index 28cc084435fc6..f5f59edf19393 100644 --- a/libcxx/test/std/ranges/range.access/rend.pass.cpp +++ b/libcxx/test/std/ranges/range.access/rend.pass.cpp @@ -11,8 +11,6 @@ // std::ranges::rend // std::ranges::crend -#include "ordinary_unqualified_lookup_helpers.h" // Intentionally included before other headers. - #include #include @@ -532,12 +530,6 @@ static_assert(!std::is_invocable_v*&>); static_assert(!std::is_invocable_v*>); static_assert(!std::is_invocable_v*&>); -// Ordinary unqualified lookup should not be performed. -static_assert( - !std::is_invocable_v); -static_assert( - !std::is_invocable_v); - int main(int, char**) { static_assert(testReturnTypes()); diff --git a/libcxx/test/std/ranges/range.access/size.pass.cpp b/libcxx/test/std/ranges/range.access/size.pass.cpp index 65c507981768c..ee44aa815ba99 100644 --- a/libcxx/test/std/ranges/range.access/size.pass.cpp +++ b/libcxx/test/std/ranges/range.access/size.pass.cpp @@ -10,8 +10,6 @@ // std::ranges::size -#include "ordinary_unqualified_lookup_helpers.h" // Intentionally included before other headers. - #include #include @@ -321,10 +319,6 @@ template struct Holder { T t; }; static_assert(!std::is_invocable_v*>); static_assert(!std::is_invocable_v*&>); -// Ordinary unqualified lookup should not be performed. -static_assert( - !std::is_invocable_v); - int main(int, char**) { testArrayType(); static_assert(testArrayType()); From a1dbe7d83476a1dd18f883c0340977806dab572f Mon Sep 17 00:00:00 2001 From: Jakub Mazurkiewicz Date: Mon, 26 Feb 2024 16:39:52 +0100 Subject: [PATCH 12/14] Revert changes to `__cpp_lib_ranges` --- libcxx/docs/FeatureTestMacroTable.rst | 2 +- libcxx/include/version | 4 ++-- .../algorithm.version.compile.pass.cpp | 14 +++++++------- .../functional.version.compile.pass.cpp | 14 +++++++------- .../iterator.version.compile.pass.cpp | 14 +++++++------- .../memory.version.compile.pass.cpp | 14 +++++++------- .../ranges.version.compile.pass.cpp | 14 +++++++------- .../version.version.compile.pass.cpp | 14 +++++++------- .../generate_feature_test_macro_components.py | 12 +----------- 9 files changed, 46 insertions(+), 56 deletions(-) diff --git a/libcxx/docs/FeatureTestMacroTable.rst b/libcxx/docs/FeatureTestMacroTable.rst index 18f7989b46517..468226c0c2ddd 100644 --- a/libcxx/docs/FeatureTestMacroTable.rst +++ b/libcxx/docs/FeatureTestMacroTable.rst @@ -266,7 +266,7 @@ Status --------------------------------------------------- ----------------- ``__cpp_lib_polymorphic_allocator`` ``201902L`` --------------------------------------------------- ----------------- - ``__cpp_lib_ranges`` ``202110L`` + ``__cpp_lib_ranges`` ``202207L`` --------------------------------------------------- ----------------- ``__cpp_lib_remove_cvref`` ``201711L`` --------------------------------------------------- ----------------- diff --git a/libcxx/include/version b/libcxx/include/version index 8f5b5ea8e7574..b18927a2bc38c 100644 --- a/libcxx/include/version +++ b/libcxx/include/version @@ -164,7 +164,7 @@ __cpp_lib_parallel_algorithm 201603L __cpp_lib_print 202207L __cpp_lib_quoted_string_io 201304L -__cpp_lib_ranges 202110L +__cpp_lib_ranges 202207L __cpp_lib_ranges_as_const 202207L __cpp_lib_ranges_as_rvalue 202207L @@ -410,7 +410,7 @@ __cpp_lib_within_lifetime 202306L # if _LIBCPP_AVAILABILITY_HAS_PMR # define __cpp_lib_polymorphic_allocator 201902L # endif -# define __cpp_lib_ranges 202110L +# define __cpp_lib_ranges 202207L # define __cpp_lib_remove_cvref 201711L # if !defined(_LIBCPP_HAS_NO_THREADS) && _LIBCPP_AVAILABILITY_HAS_SYNC # define __cpp_lib_semaphore 201907L diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/algorithm.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/algorithm.version.compile.pass.cpp index 6c0b333fecc17..ec6503ec23755 100644 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/algorithm.version.compile.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/algorithm.version.compile.pass.cpp @@ -20,7 +20,7 @@ __cpp_lib_constexpr_algorithms 201806L [C++20] __cpp_lib_freestanding_algorithm 202311L [C++26] __cpp_lib_parallel_algorithm 201603L [C++17] - __cpp_lib_ranges 202110L [C++20] + __cpp_lib_ranges 202207L [C++20] __cpp_lib_ranges_starts_ends_with 202106L [C++23] __cpp_lib_robust_nonmodifying_seq_ops 201304L [C++14] __cpp_lib_sample 201603L [C++17] @@ -201,8 +201,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++20" # endif -# if __cpp_lib_ranges != 202110L -# error "__cpp_lib_ranges should have the value 202110L in c++20" +# if __cpp_lib_ranges != 202207L +# error "__cpp_lib_ranges should have the value 202207L in c++20" # endif # ifdef __cpp_lib_ranges_starts_ends_with @@ -266,8 +266,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++23" # endif -# if __cpp_lib_ranges != 202110L -# error "__cpp_lib_ranges should have the value 202110L in c++23" +# if __cpp_lib_ranges != 202207L +# error "__cpp_lib_ranges should have the value 202207L in c++23" # endif # if !defined(_LIBCPP_VERSION) @@ -349,8 +349,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++26" # endif -# if __cpp_lib_ranges != 202110L -# error "__cpp_lib_ranges should have the value 202110L in c++26" +# if __cpp_lib_ranges != 202207L +# error "__cpp_lib_ranges should have the value 202207L in c++26" # endif # if !defined(_LIBCPP_VERSION) diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/functional.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/functional.version.compile.pass.cpp index c24e6b94cd57f..72c96c62b64c4 100644 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/functional.version.compile.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/functional.version.compile.pass.cpp @@ -28,7 +28,7 @@ __cpp_lib_invoke_r 202106L [C++23] __cpp_lib_move_only_function 202110L [C++23] __cpp_lib_not_fn 201603L [C++17] - __cpp_lib_ranges 202110L [C++20] + __cpp_lib_ranges 202207L [C++20] __cpp_lib_result_of_sfinae 201210L [C++14] __cpp_lib_transparent_operators 201210L [C++14] 201510L [C++17] @@ -293,8 +293,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++20" # endif -# if __cpp_lib_ranges != 202110L -# error "__cpp_lib_ranges should have the value 202110L in c++20" +# if __cpp_lib_ranges != 202207L +# error "__cpp_lib_ranges should have the value 202207L in c++20" # endif # ifndef __cpp_lib_result_of_sfinae @@ -399,8 +399,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++23" # endif -# if __cpp_lib_ranges != 202110L -# error "__cpp_lib_ranges should have the value 202110L in c++23" +# if __cpp_lib_ranges != 202207L +# error "__cpp_lib_ranges should have the value 202207L in c++23" # endif # ifndef __cpp_lib_result_of_sfinae @@ -523,8 +523,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++26" # endif -# if __cpp_lib_ranges != 202110L -# error "__cpp_lib_ranges should have the value 202110L in c++26" +# if __cpp_lib_ranges != 202207L +# error "__cpp_lib_ranges should have the value 202207L in c++26" # endif # ifndef __cpp_lib_result_of_sfinae diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/iterator.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/iterator.version.compile.pass.cpp index 228b530dd3228..700907ce9bb07 100644 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/iterator.version.compile.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/iterator.version.compile.pass.cpp @@ -23,7 +23,7 @@ __cpp_lib_move_iterator_concept 202207L [C++20] __cpp_lib_nonmember_container_access 201411L [C++17] __cpp_lib_null_iterators 201304L [C++14] - __cpp_lib_ranges 202110L [C++20] + __cpp_lib_ranges 202207L [C++20] __cpp_lib_ssize 201902L [C++20] */ @@ -197,8 +197,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++20" # endif -# if __cpp_lib_ranges != 202110L -# error "__cpp_lib_ranges should have the value 202110L in c++20" +# if __cpp_lib_ranges != 202207L +# error "__cpp_lib_ranges should have the value 202207L in c++20" # endif # ifndef __cpp_lib_ssize @@ -255,8 +255,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++23" # endif -# if __cpp_lib_ranges != 202110L -# error "__cpp_lib_ranges should have the value 202110L in c++23" +# if __cpp_lib_ranges != 202207L +# error "__cpp_lib_ranges should have the value 202207L in c++23" # endif # ifndef __cpp_lib_ssize @@ -313,8 +313,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++26" # endif -# if __cpp_lib_ranges != 202110L -# error "__cpp_lib_ranges should have the value 202110L in c++26" +# if __cpp_lib_ranges != 202207L +# error "__cpp_lib_ranges should have the value 202207L in c++26" # endif # ifndef __cpp_lib_ssize diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/memory.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/memory.version.compile.pass.cpp index cf13dff11b34f..45d9271faa578 100644 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/memory.version.compile.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/memory.version.compile.pass.cpp @@ -28,7 +28,7 @@ __cpp_lib_make_unique 201304L [C++14] __cpp_lib_out_ptr 202106L [C++23] 202311L [C++26] - __cpp_lib_ranges 202110L [C++20] + __cpp_lib_ranges 202207L [C++20] __cpp_lib_raw_memory_algorithms 201606L [C++17] __cpp_lib_shared_ptr_arrays 201611L [C++17] 201707L [C++20] @@ -364,8 +364,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++20" # endif -# if __cpp_lib_ranges != 202110L -# error "__cpp_lib_ranges should have the value 202110L in c++20" +# if __cpp_lib_ranges != 202207L +# error "__cpp_lib_ranges should have the value 202207L in c++20" # endif # ifndef __cpp_lib_raw_memory_algorithms @@ -501,8 +501,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++23" # endif -# if __cpp_lib_ranges != 202110L -# error "__cpp_lib_ranges should have the value 202110L in c++23" +# if __cpp_lib_ranges != 202207L +# error "__cpp_lib_ranges should have the value 202207L in c++23" # endif # ifndef __cpp_lib_raw_memory_algorithms @@ -638,8 +638,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++26" # endif -# if __cpp_lib_ranges != 202110L -# error "__cpp_lib_ranges should have the value 202110L in c++26" +# if __cpp_lib_ranges != 202207L +# error "__cpp_lib_ranges should have the value 202207L in c++26" # endif # ifndef __cpp_lib_raw_memory_algorithms diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/ranges.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/ranges.version.compile.pass.cpp index a144f48c705d1..aa3a4964ad492 100644 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/ranges.version.compile.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/ranges.version.compile.pass.cpp @@ -16,7 +16,7 @@ // Test the feature test macros defined by /* Constant Value - __cpp_lib_ranges 202110L [C++20] + __cpp_lib_ranges 202207L [C++20] __cpp_lib_ranges_as_const 202207L [C++23] __cpp_lib_ranges_as_rvalue 202207L [C++23] __cpp_lib_ranges_chunk 202202L [C++23] @@ -162,8 +162,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++20" # endif -# if __cpp_lib_ranges != 202110L -# error "__cpp_lib_ranges should have the value 202110L in c++20" +# if __cpp_lib_ranges != 202207L +# error "__cpp_lib_ranges should have the value 202207L in c++20" # endif # ifdef __cpp_lib_ranges_as_const @@ -207,8 +207,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++23" # endif -# if __cpp_lib_ranges != 202110L -# error "__cpp_lib_ranges should have the value 202110L in c++23" +# if __cpp_lib_ranges != 202207L +# error "__cpp_lib_ranges should have the value 202207L in c++23" # endif # if !defined(_LIBCPP_VERSION) @@ -309,8 +309,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++26" # endif -# if __cpp_lib_ranges != 202110L -# error "__cpp_lib_ranges should have the value 202110L in c++26" +# if __cpp_lib_ranges != 202207L +# error "__cpp_lib_ranges should have the value 202207L in c++26" # endif # if !defined(_LIBCPP_VERSION) diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp index 27d2b3eaaf72d..14271308624e6 100644 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp @@ -153,7 +153,7 @@ __cpp_lib_polymorphic_allocator 201902L [C++20] __cpp_lib_print 202207L [C++23] __cpp_lib_quoted_string_io 201304L [C++14] - __cpp_lib_ranges 202110L [C++20] + __cpp_lib_ranges 202207L [C++20] __cpp_lib_ranges_as_const 202207L [C++23] __cpp_lib_ranges_as_rvalue 202207L [C++23] __cpp_lib_ranges_chunk 202202L [C++23] @@ -3869,8 +3869,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++20" # endif -# if __cpp_lib_ranges != 202110L -# error "__cpp_lib_ranges should have the value 202110L in c++20" +# if __cpp_lib_ranges != 202207L +# error "__cpp_lib_ranges should have the value 202207L in c++20" # endif # ifdef __cpp_lib_ranges_as_const @@ -5313,8 +5313,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++23" # endif -# if __cpp_lib_ranges != 202110L -# error "__cpp_lib_ranges should have the value 202110L in c++23" +# if __cpp_lib_ranges != 202207L +# error "__cpp_lib_ranges should have the value 202207L in c++23" # endif # if !defined(_LIBCPP_VERSION) @@ -7030,8 +7030,8 @@ # ifndef __cpp_lib_ranges # error "__cpp_lib_ranges should be defined in c++26" # endif -# if __cpp_lib_ranges != 202110L -# error "__cpp_lib_ranges should have the value 202110L in c++26" +# if __cpp_lib_ranges != 202207L +# error "__cpp_lib_ranges should have the value 202207L in c++26" # endif # if !defined(_LIBCPP_VERSION) diff --git a/libcxx/utils/generate_feature_test_macro_components.py b/libcxx/utils/generate_feature_test_macro_components.py index 51f07b12b2370..b688a30cdb792 100755 --- a/libcxx/utils/generate_feature_test_macro_components.py +++ b/libcxx/utils/generate_feature_test_macro_components.py @@ -886,17 +886,7 @@ def add_version_header(tc): }, { "name": "__cpp_lib_ranges", - "values": { - # "c++20": 201811 The One Ranges Proposal - # "c++20": 201907 Input Range Adaptors - # "c++20": 201911 ranges compare algorithm are over-constrained - # "c++20": 202106 Views should not be required to be default constructible - "c++20": 202110, # What is a view? - # "c++23": 202202 Pipe support for user-defined range adaptors (Not implemented) - # "c++23": 202207 Relaxing range adaptors to allow for move only types - # "c++23": 202211 Poison Pills are Too Toxic (C++20 DR) - # "c++23": 202302 Relaxing Ranges Just A Smidge (Not implemented) - }, + "values": {"c++20": 202207}, "headers": ["algorithm", "functional", "iterator", "memory", "ranges"], }, { From 6201b0f70cfb2fae58fdff77e2478668213ee88f Mon Sep 17 00:00:00 2001 From: Jakub Mazurkiewicz Date: Mon, 26 Feb 2024 16:42:52 +0100 Subject: [PATCH 13/14] Whitespace cleanup --- ...obust_against_ordinary_unqualified_lookup.compile.pass.cpp | 1 - ...obust_against_ordinary_unqualified_lookup.compile.pass.cpp | 2 -- ...robust_against_ordinary_unqualifed_lookup.compile.pass.cpp | 4 ---- 3 files changed, 7 deletions(-) diff --git a/libcxx/test/std/iterators/iterator.requirements/iterator.cust/robust_against_ordinary_unqualified_lookup.compile.pass.cpp b/libcxx/test/std/iterators/iterator.requirements/iterator.cust/robust_against_ordinary_unqualified_lookup.compile.pass.cpp index efac342661e5e..482c3f094fc06 100644 --- a/libcxx/test/std/iterators/iterator.requirements/iterator.cust/robust_against_ordinary_unqualified_lookup.compile.pass.cpp +++ b/libcxx/test/std/iterators/iterator.requirements/iterator.cust/robust_against_ordinary_unqualified_lookup.compile.pass.cpp @@ -23,7 +23,6 @@ void iter_swap(ns::StructWithGlobalIterCustFunctions, ns::StructWithGlobalIterCu #include static_assert(!std::is_invocable_v); - static_assert(!std::is_invocable_v); diff --git a/libcxx/test/std/language.support/cmp/cmp.alg/robust_against_ordinary_unqualified_lookup.compile.pass.cpp b/libcxx/test/std/language.support/cmp/cmp.alg/robust_against_ordinary_unqualified_lookup.compile.pass.cpp index b9fbaa66a8390..416776f336b5c 100644 --- a/libcxx/test/std/language.support/cmp/cmp.alg/robust_against_ordinary_unqualified_lookup.compile.pass.cpp +++ b/libcxx/test/std/language.support/cmp/cmp.alg/robust_against_ordinary_unqualified_lookup.compile.pass.cpp @@ -34,11 +34,9 @@ struct ConvertibleToCmpType { static_assert(!std::is_invocable_v); - static_assert(!std::is_invocable_v); - static_assert(!std::is_invocable_v); diff --git a/libcxx/test/std/ranges/range.access/ranges_robust_against_ordinary_unqualifed_lookup.compile.pass.cpp b/libcxx/test/std/ranges/range.access/ranges_robust_against_ordinary_unqualifed_lookup.compile.pass.cpp index 12b8c5034e6b7..4fc6cd63bbb14 100644 --- a/libcxx/test/std/ranges/range.access/ranges_robust_against_ordinary_unqualifed_lookup.compile.pass.cpp +++ b/libcxx/test/std/ranges/range.access/ranges_robust_against_ordinary_unqualifed_lookup.compile.pass.cpp @@ -27,14 +27,10 @@ unsigned int size(ns::StructWithGlobalRangeAccessFunctions); static_assert(!std::is_invocable_v); static_assert(!std::is_invocable_v); - static_assert(!std::is_invocable_v); static_assert(!std::is_invocable_v); - static_assert(!std::is_invocable_v); static_assert(!std::is_invocable_v); - static_assert(!std::is_invocable_v); static_assert(!std::is_invocable_v); - static_assert(!std::is_invocable_v); From 191568d2ffa52273b20cccf4b05cd956bfaf69df Mon Sep 17 00:00:00 2001 From: Jakub Mazurkiewicz Date: Thu, 7 Mar 2024 17:55:36 +0100 Subject: [PATCH 14/14] Merge `robust_against_ordinary_unqualified_lookup.compile.pass.cpp` tests into file Add extra checks too. --- ...dinary_unqualified_lookup.compile.pass.cpp | 28 ----- ...dinary_unqualified_lookup.compile.pass.cpp | 42 -------- ...rdinary_unqualifed_lookup.compile.pass.cpp | 36 ------- ...bust_against_poison_pills.compile.pass.cpp | 102 ++++++++++++++++++ 4 files changed, 102 insertions(+), 106 deletions(-) delete mode 100644 libcxx/test/std/iterators/iterator.requirements/iterator.cust/robust_against_ordinary_unqualified_lookup.compile.pass.cpp delete mode 100644 libcxx/test/std/language.support/cmp/cmp.alg/robust_against_ordinary_unqualified_lookup.compile.pass.cpp delete mode 100644 libcxx/test/std/ranges/range.access/ranges_robust_against_ordinary_unqualifed_lookup.compile.pass.cpp create mode 100644 libcxx/test/std/ranges/robust_against_poison_pills.compile.pass.cpp diff --git a/libcxx/test/std/iterators/iterator.requirements/iterator.cust/robust_against_ordinary_unqualified_lookup.compile.pass.cpp b/libcxx/test/std/iterators/iterator.requirements/iterator.cust/robust_against_ordinary_unqualified_lookup.compile.pass.cpp deleted file mode 100644 index 482c3f094fc06..0000000000000 --- a/libcxx/test/std/iterators/iterator.requirements/iterator.cust/robust_against_ordinary_unqualified_lookup.compile.pass.cpp +++ /dev/null @@ -1,28 +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 -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++03, c++11, c++14, c++17 - -// - -// Ordinary unqualified lookup should not be performed. - -namespace ns { -struct StructWithGlobalIterCustFunctions {}; -} // namespace ns - -int&& iter_move(ns::StructWithGlobalIterCustFunctions); -void iter_swap(ns::StructWithGlobalIterCustFunctions, ns::StructWithGlobalIterCustFunctions); - -#include -#include - -static_assert(!std::is_invocable_v); -static_assert(!std::is_invocable_v); diff --git a/libcxx/test/std/language.support/cmp/cmp.alg/robust_against_ordinary_unqualified_lookup.compile.pass.cpp b/libcxx/test/std/language.support/cmp/cmp.alg/robust_against_ordinary_unqualified_lookup.compile.pass.cpp deleted file mode 100644 index 416776f336b5c..0000000000000 --- a/libcxx/test/std/language.support/cmp/cmp.alg/robust_against_ordinary_unqualified_lookup.compile.pass.cpp +++ /dev/null @@ -1,42 +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 -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++03, c++11, c++14, c++17 - -// - -// Ordinary unqualified lookup should not be performed. - -namespace ns { -struct StructWithGlobalCmpFunctions {}; -} // namespace ns - -struct ConvertibleToCmpType; - -ConvertibleToCmpType strong_order(ns::StructWithGlobalCmpFunctions, ns::StructWithGlobalCmpFunctions); -ConvertibleToCmpType weak_order(ns::StructWithGlobalCmpFunctions, ns::StructWithGlobalCmpFunctions); -ConvertibleToCmpType partial_order(ns::StructWithGlobalCmpFunctions, ns::StructWithGlobalCmpFunctions); - -#include -#include - -struct ConvertibleToCmpType { - operator std::strong_ordering() const; - operator std::weak_ordering() const; - operator std::partial_ordering() const; -}; - -static_assert(!std::is_invocable_v); -static_assert(!std::is_invocable_v); -static_assert(!std::is_invocable_v); diff --git a/libcxx/test/std/ranges/range.access/ranges_robust_against_ordinary_unqualifed_lookup.compile.pass.cpp b/libcxx/test/std/ranges/range.access/ranges_robust_against_ordinary_unqualifed_lookup.compile.pass.cpp deleted file mode 100644 index 4fc6cd63bbb14..0000000000000 --- a/libcxx/test/std/ranges/range.access/ranges_robust_against_ordinary_unqualifed_lookup.compile.pass.cpp +++ /dev/null @@ -1,36 +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 -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++03, c++11, c++14, c++17 - -// - -// Ordinary unqualified lookup should not be performed. - -namespace ns { -struct StructWithGlobalRangeAccessFunctions {}; -} // namespace ns - -int* begin(ns::StructWithGlobalRangeAccessFunctions); -int* end(ns::StructWithGlobalRangeAccessFunctions); -int* rbegin(ns::StructWithGlobalRangeAccessFunctions); -int* rend(ns::StructWithGlobalRangeAccessFunctions); -unsigned int size(ns::StructWithGlobalRangeAccessFunctions); - -#include -#include - -static_assert(!std::is_invocable_v); -static_assert(!std::is_invocable_v); -static_assert(!std::is_invocable_v); -static_assert(!std::is_invocable_v); -static_assert(!std::is_invocable_v); -static_assert(!std::is_invocable_v); -static_assert(!std::is_invocable_v); -static_assert(!std::is_invocable_v); -static_assert(!std::is_invocable_v); diff --git a/libcxx/test/std/ranges/robust_against_poison_pills.compile.pass.cpp b/libcxx/test/std/ranges/robust_against_poison_pills.compile.pass.cpp new file mode 100644 index 0000000000000..1b3da814d0800 --- /dev/null +++ b/libcxx/test/std/ranges/robust_against_poison_pills.compile.pass.cpp @@ -0,0 +1,102 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17 + +// , , + +// ADL should be performed. Ordinary unqualified lookup should not be performed. + +namespace ns { +struct StructWithGlobalFunctions {}; +} // namespace ns + +struct ConvertibleToCmpType; +ConvertibleToCmpType strong_order(const ns::StructWithGlobalFunctions&, const ns::StructWithGlobalFunctions&); +ConvertibleToCmpType weak_order(const ns::StructWithGlobalFunctions&, const ns::StructWithGlobalFunctions&); +ConvertibleToCmpType partial_order(const ns::StructWithGlobalFunctions&, const ns::StructWithGlobalFunctions&); + +int&& iter_move(const ns::StructWithGlobalFunctions&); +void iter_swap(const ns::StructWithGlobalFunctions&, const ns::StructWithGlobalFunctions&); + +int* begin(const ns::StructWithGlobalFunctions&); +int* end(const ns::StructWithGlobalFunctions&); +int* rbegin(const ns::StructWithGlobalFunctions&); +int* rend(const ns::StructWithGlobalFunctions&); +unsigned int size(const ns::StructWithGlobalFunctions&); + +#include +#include +#include + +struct ConvertibleToCmpType { + operator std::strong_ordering() const; + operator std::weak_ordering() const; + operator std::partial_ordering() const; +}; + +struct StructWithHiddenFriends { + friend ConvertibleToCmpType strong_order(const StructWithHiddenFriends&, const StructWithHiddenFriends&); + friend ConvertibleToCmpType weak_order(const StructWithHiddenFriends&, const StructWithHiddenFriends&); + friend ConvertibleToCmpType partial_order(const StructWithHiddenFriends&, const StructWithHiddenFriends&); + + friend int&& iter_move(const StructWithHiddenFriends&); + friend void iter_swap(const StructWithHiddenFriends&, const StructWithHiddenFriends&); + + friend int* begin(const StructWithHiddenFriends&); + friend int* end(const StructWithHiddenFriends&); + friend int* rbegin(const StructWithHiddenFriends&); + friend int* rend(const StructWithHiddenFriends&); + friend unsigned int size(const StructWithHiddenFriends&); +}; + +// [cmp.alg] ADL should be performed. +static_assert(std::is_invocable_v); +static_assert(std::is_invocable_v); +static_assert(std::is_invocable_v); + +// [cmp.alg] Ordinary unqualified lookup should not be performed. +static_assert( + !std::is_invocable_v); +static_assert( + !std::is_invocable_v); +static_assert( + !std::is_invocable_v); + +// [iterator.cust] ADL should be performed. +static_assert(std::is_invocable_v); +static_assert( + std::is_invocable_v); + +// [iterator.cust] Ordinary unqualified lookup should not be performed. +static_assert(!std::is_invocable_v); +static_assert(!std::is_invocable_v); + +// [range.access] ADL should be performed. +static_assert(std::is_invocable_v); +static_assert(std::is_invocable_v); +static_assert(std::is_invocable_v); +static_assert(std::is_invocable_v); +static_assert(std::is_invocable_v); +static_assert(std::is_invocable_v); +static_assert(std::is_invocable_v); +static_assert(std::is_invocable_v); +static_assert(std::is_invocable_v); + +// [range.access] Ordinary unqualified lookup should not be performed. +static_assert(!std::is_invocable_v); +static_assert(!std::is_invocable_v); +static_assert(!std::is_invocable_v); +static_assert(!std::is_invocable_v); +static_assert(!std::is_invocable_v); +static_assert(!std::is_invocable_v); +static_assert(!std::is_invocable_v); +static_assert(!std::is_invocable_v); +static_assert(!std::is_invocable_v);