]> gcc.gnu.org Git - gcc.git/commit
c++: implicit operator== adjustments from P2002.
authorJason Merrill <jason@redhat.com>
Mon, 15 Jun 2020 21:11:38 +0000 (17:11 -0400)
committerJason Merrill <jason@redhat.com>
Mon, 22 Jun 2020 19:33:35 +0000 (15:33 -0400)
commit1271bdf0d17442040ee4b0ec66da9cab2d4dd3e9
treeca178cc4a17eba114736cd3031fc71a152525312
parent4dd2fd9c4350529947fffc6bf257b5e22379554b
c++: implicit operator== adjustments from P2002.

P2002R1, adopted at the February C++ meeting, made several refinements to
the wording for operator<=>.  This implements clarifications in how the
implicit operator== is declared: as a duplicate of the operator<=>, with
only the return type and name changed.  To that end I factored out the
declaration copying from build_clone.  For GCC 10 I'm leaving build_clone
alone, to reduce the chance of non-C++20-mode regressions.

The decl.c changes are a hack to avoid complaining about constraints on a
non-template friend that isn't defined in the class.  In this case the
defaulted comparison operator should be considered defined, but we weren't
setting funcdef_flag properly.  For GCC 11 I fixed it properly.

gcc/cp/ChangeLog:

* cp-tree.h (copy_fndecl_with_name): Declare.
* class.c (copy_fndecl_with_name): Copy from build_clone.
(add_implicitly_declared_members): Add op== to TYPE_FIELDS.
* method.c (implicitly_declare_fn): Use copy_fndecl_with_name.
* decl.c (grokfndecl): Add initialized parm.
(grokdeclarator): Pass it down.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/spaceship-synth9.C: New test.
gcc/cp/class.c
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/method.c
gcc/testsuite/g++.dg/cpp2a/spaceship-synth9.C [new file with mode: 0644]
This page took 0.057331 seconds and 5 git commands to generate.