diff options
author | Jason Merrill <jason@redhat.com> | 2020-12-04 21:48:43 -0500 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2020-12-08 15:12:25 -0500 |
commit | 4ed1dc1275bba89af92bfc7d97c21b376e4c29c3 (patch) | |
tree | 03acc5cf7dbc5e9e56aa34664cdd835c803cd181 /gcc/cp/cp-tree.h | |
parent | a988a398d6daef3072cd2d07a21980911d8f93fc (diff) | |
download | gcc-4ed1dc1275bba89af92bfc7d97c21b376e4c29c3.zip gcc-4ed1dc1275bba89af92bfc7d97c21b376e4c29c3.tar.gz gcc-4ed1dc1275bba89af92bfc7d97c21b376e4c29c3.tar.bz2 |
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 'gcc/cp/cp-tree.h')
-rw-r--r-- | gcc/cp/cp-tree.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 66ad114..6270fad 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -6335,6 +6335,13 @@ extern tree build_new_op (const op_location_t &, enum tree_code, int, tree, tree, tree, tree *, tsubst_flags_t); +/* Wrapper that leaves out the usually-null op3 and overload parms. */ +inline tree build_new_op (const op_location_t &loc, enum tree_code code, + int flags, tree arg1, tree arg2, + tsubst_flags_t complain) +{ + return build_new_op (loc, code, flags, arg1, arg2, NULL_TREE, NULL, complain); +} extern tree build_op_call (tree, vec<tree, va_gc> **, tsubst_flags_t); extern bool aligned_allocation_fn_p (tree); @@ -7807,7 +7814,7 @@ extern tree merge_types (tree, tree); extern tree strip_array_domain (tree); extern tree check_return_expr (tree, bool *); extern tree spaceship_type (tree, tsubst_flags_t = tf_warning_or_error); -extern tree genericize_spaceship (tree, tree, tree); +extern tree genericize_spaceship (location_t, tree, tree, tree); extern tree cp_build_binary_op (const op_location_t &, enum tree_code, tree, tree, tsubst_flags_t); |