libstdc++: Fix <ranges> tests that fail in C++23
commitf12e26f3496275a432c6f6a326598db3441a9725
authorJonathan Wakely <jwakely@redhat.com>
Wed, 6 Sep 2023 13:13:18 +0000 (6 14:13 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Thu, 7 Sep 2023 07:09:58 +0000 (7 08:09 +0100)
tree1256418fdf96c1f76147e709c98a2050792751e5
parent6854e3ac71209ac786b878ef4abe6856a50c221d
libstdc++: Fix <ranges> tests that fail in C++23

The tests for the std::ranges access CPOs (ranges::begin etc) use
pathological types with ridiculous overload sets for begin/end/data
members, to exercise all the corner cases in the specification.

Since P2278R4 "cbegin should always return a constant iterator" was
implemented for C++23 mode, some of the range access CPOs now require
the argument to satisfy the range concept, which was not previously
required. The behaviour of the CPO also changes for corner cases where
the type is a range R for which constant_range<R> is satisfied in
addition to constant_range<const R> (meaning there's no need to wrap its
iterators in const_iterator). Adjust the expected results for those
pathological types that changed meaning in C++23, and add some new types
to verify other corner cases.

Some other range adaptor tests fail for C++20 because they assert that
ranges::end and ranges::cend return different types, which is not true
when the type satisfies constant_range.

This fixes the tests to PASS for both C++20 and C++23 (and later).

libstdc++-v3/ChangeLog:

* testsuite/std/ranges/access/cbegin.cc: Adjust for C++23
compatibility.
* testsuite/std/ranges/access/cdata.cc: Likewise.
* testsuite/std/ranges/access/cend.cc: Likewise.
* testsuite/std/ranges/access/crbegin.cc: Likewise.
* testsuite/std/ranges/access/crend.cc: Likewise.
* testsuite/std/ranges/adaptors/take.cc: Likewise.
* testsuite/std/ranges/adaptors/take_while.cc: Likewise.
* testsuite/std/ranges/adaptors/transform.cc: Likewise.
libstdc++-v3/testsuite/std/ranges/access/cbegin.cc
libstdc++-v3/testsuite/std/ranges/access/cdata.cc
libstdc++-v3/testsuite/std/ranges/access/cend.cc
libstdc++-v3/testsuite/std/ranges/access/crbegin.cc
libstdc++-v3/testsuite/std/ranges/access/crend.cc
libstdc++-v3/testsuite/std/ranges/adaptors/take.cc
libstdc++-v3/testsuite/std/ranges/adaptors/take_while.cc
libstdc++-v3/testsuite/std/ranges/adaptors/transform.cc