summaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2020-12-04 21:48:43 -0500
committerJason Merrill <jason@redhat.com>2020-12-08 15:12:25 -0500
commit4ed1dc1275bba89af92bfc7d97c21b376e4c29c3 (patch)
tree03acc5cf7dbc5e9e56aa34664cdd835c803cd181 /libstdc++-v3
parenta988a398d6daef3072cd2d07a21980911d8f93fc (diff)
downloadgcc-4ed1dc1275bba89af92bfc7d97c21b376e4c29c3.tar.gz
c++: Fix defaulted <=> fallback to < and == [PR96299]
I thought I had implemented P1186R3, but apparently I didn't read it closely enough to understand the point of the paper, namely that for a defaulted operator<=>, if a member type doesn't have a viable operator<=>, we will use its operator< and operator== if the defaulted operator has an specific comparison category as its return type; the compiler can't guess if it should be strong_ordering or something else, but the user can make that choice explicit. The libstdc++ test change was necessary because of the change in genericize_spaceship from op0 > op1 to op1 < op0; this should be equivalent, but isn't because of PR88173. gcc/cp/ChangeLog: PR c++/96299 * cp-tree.h (build_new_op): Add overload that omits some parms. (genericize_spaceship): Add location_t parm. * constexpr.c (cxx_eval_binary_expression): Pass it. * cp-gimplify.c (genericize_spaceship): Pass it. * method.c (genericize_spaceship): Handle class-type arguments. (build_comparison_op): Fall back to op</== when appropriate. gcc/testsuite/ChangeLog: PR c++/96299 * g++.dg/cpp2a/spaceship-synth-neg2.C: Move error. * g++.dg/cpp2a/spaceship-p1186.C: New test. libstdc++-v3/ChangeLog: PR c++/96299 * testsuite/18_support/comparisons/algorithms/partial_order.cc: One more line needs to use VERIFY instead of static_assert.
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/testsuite/18_support/comparisons/algorithms/partial_order.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/libstdc++-v3/testsuite/18_support/comparisons/algorithms/partial_order.cc b/libstdc++-v3/testsuite/18_support/comparisons/algorithms/partial_order.cc
index 62b379a98cb..094ac702874 100644
--- a/libstdc++-v3/testsuite/18_support/comparisons/algorithms/partial_order.cc
+++ b/libstdc++-v3/testsuite/18_support/comparisons/algorithms/partial_order.cc
@@ -70,7 +70,7 @@ test03()
constexpr double epsilon = std::numeric_limits<double>::epsilon();
static_assert( partial_order(denorm, smallest) == partial_ordering::less );
static_assert( partial_order(denorm, 0.0) == partial_ordering::greater );
- // FIXME: these should all use static_assert
+ // FIXME: these should all use static_assert. See PR88173.
VERIFY( partial_order(0.0, nan) == partial_ordering::unordered );
VERIFY( partial_order(nan, nan) == partial_ordering::unordered );
VERIFY( partial_order(nan, 0.0) == partial_ordering::unordered );
@@ -81,7 +81,7 @@ test03()
VERIFY( partial_order(-inf, -nan) == partial_ordering::unordered );
static_assert( partial_order(max, inf) == partial_ordering::less );
static_assert( partial_order(inf, max) == partial_ordering::greater );
- static_assert( partial_order(inf, nan) == partial_ordering::unordered );
+ VERIFY( partial_order(inf, nan) == partial_ordering::unordered );
static_assert( partial_order(1.0, 1.0+epsilon) == partial_ordering::less );
}