]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: P2865R5, Remove Deprecated Array Comparisons from C++26 [PR117788]
authorMarek Polacek <polacek@redhat.com>
Wed, 27 Nov 2024 23:00:24 +0000 (18:00 -0500)
committerMarek Polacek <polacek@redhat.com>
Tue, 10 Dec 2024 15:17:07 +0000 (10:17 -0500)
commitc628def52c87b40b6270618252488bcd731e1843
treeba9a8b2575cfc30f26ccc830add1bf0ae591d1b9
parent7a12dc695b1ae70f9fc99baf95b7188af6515ed3
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>
gcc/c-family/c-warn.cc
gcc/cp/typeck.cc
gcc/testsuite/c-c++-common/Warray-compare-1.c
gcc/testsuite/c-c++-common/Warray-compare-3.c
gcc/testsuite/c-c++-common/Warray-compare-4.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/Warray-compare-5.c [new file with mode: 0644]
gcc/testsuite/g++.dg/warn/Warray-compare-1.C [new file with mode: 0644]
libstdc++-v3/testsuite/std/ranges/adaptors/conditionally_borrowed.cc