aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/tree.cc
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2024-07-22 21:30:49 -0400
committerThomas Koenig <tkoenig@gcc.gnu.org>2024-07-28 19:05:46 +0200
commit78f1f323ffbd45edf3faafb8f66b76f627c5b460 (patch)
tree9b4a4009478a87fb2b0347c6a2bd2c888a805e6d /gcc/cp/tree.cc
parent46e5eb062eda5bfdd0b416c32983769091b75947 (diff)
downloadgcc-78f1f323ffbd45edf3faafb8f66b76f627c5b460.zip
gcc-78f1f323ffbd45edf3faafb8f66b76f627c5b460.tar.gz
gcc-78f1f323ffbd45edf3faafb8f66b76f627c5b460.tar.bz2
c++/coroutines: correct passing *this to promise type [PR104981]
When passing *this to the promise type ctor (or to its operator new) (as per [dcl.fct.def.coroutine]/4), we add an explicit cast to lvalue reference. But this is unnecessary since *this is already always an lvalue. And doing so means we need to call convert_from_reference afterward to lower the reference expression to an implicit dereference, which we're currently neglecting to do and which causes overload resolution to get confused when computing argument conversions. So this patch removes this unneeded reference cast when passing *this to the promise ctor, and removes both the cast and implicit deref when passing *this to operator new, for consistency. While we're here, use cp_build_fold_indirect_ref instead of directly building INDIRECT_REF. PR c++/104981 PR c++/115550 gcc/cp/ChangeLog: * coroutines.cc (morph_fn_to_coro): Remove unneeded calls to convert_to_reference and convert_from_reference when passing *this. Use cp_build_fold_indirect_ref instead of directly building INDIRECT_REF. gcc/testsuite/ChangeLog: * g++.dg/coroutines/pr104981-preview-this.C: New test. * g++.dg/coroutines/pr115550-preview-this.C: New test. Reviewed-by: Iain Sandoe <iain@sandoe.co.uk> Reviewed-by: Jason Merrill <jason@redhat.com>
Diffstat (limited to 'gcc/cp/tree.cc')
0 files changed, 0 insertions, 0 deletions