c++: local class memfn synth from uneval context [PR113063]
commitfced59166f95e9922a72392955e4fed095afd47e
authorPatrick Palka <ppalka@redhat.com>
Tue, 19 Dec 2023 21:33:55 +0000 (19 16:33 -0500)
committerPatrick Palka <ppalka@redhat.com>
Tue, 19 Dec 2023 21:33:55 +0000 (19 16:33 -0500)
tree9e9bd0d84e6ca93ac374907e719083c246f456c7
parent7f26997e6479920c8c6f40894f7d02931f983f82
c++: local class memfn synth from uneval context [PR113063]

Here we first use and therefore synthesize the local class operator<=>
from an unevaluated context, which inadvertently affects synthesization
by preventing functions used within the definition (such as the copy
constructor of std::strong_ordering) from getting marked as odr-used.

This patch fixes this by using maybe_push_to_top_level in synthesize_method
which ensures cp_unevaluated_operand gets cleared even in the function-local
case.

PR c++/113063

gcc/cp/ChangeLog:

* method.cc (synthesize_method): Use maybe_push_to_top_level
and maybe_pop_from_top_level.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/spaceship-synth16.C: New test.
gcc/cp/method.cc
gcc/testsuite/g++.dg/cpp2a/spaceship-synth16.C [new file with mode: 0644]