aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/std/ranges
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2024-11-27 18:00:24 -0500
committerMarek Polacek <polacek@redhat.com>2024-12-10 10:17:07 -0500
commitc628def52c87b40b6270618252488bcd731e1843 (patch)
treeba9a8b2575cfc30f26ccc830add1bf0ae591d1b9 /libstdc++-v3/testsuite/std/ranges
parent7a12dc695b1ae70f9fc99baf95b7188af6515ed3 (diff)
downloadgcc-c628def52c87b40b6270618252488bcd731e1843.zip
gcc-c628def52c87b40b6270618252488bcd731e1843.tar.gz
gcc-c628def52c87b40b6270618252488bcd731e1843.tar.bz2
c++: P2865R5, Remove Deprecated Array Comparisons from C++26 [PR117788]
This patch implements P2865R5 by promoting the warning to permerror in C++26 only. In C++20 we should warn even without -Wall. Jason fixed this in r15-5713 but let's add a test that doesn't use -Wall. This caused a FAIL in conditionally_borrowed.cc because we end up comparing two array types in equality_comparable_with -> __weakly_eq_cmp_with. That could be fixed in libstc++, perhaps by adding std::decay in the appropriate place. PR c++/117788 gcc/c-family/ChangeLog: * c-warn.cc (do_warn_array_compare): Emit a permerror in C++26. gcc/cp/ChangeLog: * typeck.cc (cp_build_binary_op) <case EQ_EXPR>: Don't check warn_array_compare. Check tf_warning_or_error instead of just tf_warning. Maybe return an error_mark_node in C++26. <case LE_EXPR>: Likewise. gcc/testsuite/ChangeLog: * c-c++-common/Warray-compare-1.c: Expect an error in C++26. * c-c++-common/Warray-compare-3.c: Likewise. * c-c++-common/Warray-compare-4.c: New test. * c-c++-common/Warray-compare-5.c: New test. * g++.dg/warn/Warray-compare-1.C: New test. libstdc++-v3/ChangeLog: * testsuite/std/ranges/adaptors/conditionally_borrowed.cc: Add a FIXME, adjust. Reviewed-by: Jason Merrill <jason@redhat.com>
Diffstat (limited to 'libstdc++-v3/testsuite/std/ranges')
-rw-r--r--libstdc++-v3/testsuite/std/ranges/adaptors/conditionally_borrowed.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/conditionally_borrowed.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/conditionally_borrowed.cc
index 4a0d1ff..4bc0d2d 100644
--- a/libstdc++-v3/testsuite/std/ranges/adaptors/conditionally_borrowed.cc
+++ b/libstdc++-v3/testsuite/std/ranges/adaptors/conditionally_borrowed.cc
@@ -61,7 +61,10 @@ void
test02()
{
std::pair<int, std::string_view> a[2]{ {1,"two"}, {3,"four"}};
- auto pos = ranges::find(a | views::values, "four");
+ // FIXME: We should be able to get rid of the decay via the + here.
+ // But we'd end up comparing two array types in equality_comparable_with
+ // -> __weakly_eq_cmp_with which is ill-formed in C++26 due to P2865.
+ auto pos = ranges::find(a | views::values, +"four");
VERIFY( *pos == "four" );
static_assert( ranges::borrowed_range<decltype(a | views::keys)> );