aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/semantics.cc
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2024-08-15 10:20:18 -0400
committerPatrick Palka <ppalka@redhat.com>2024-08-15 10:20:18 -0400
commit303bed670af962c01b77a4f0c51de97f70e8167e (patch)
treeb5534298e53cad71bffdeba8eab67197dcf609a9 /gcc/cp/semantics.cc
parentee4a6343225b6e44b3d2b2c90c355c21f7ec6855 (diff)
downloadgcc-303bed670af962c01b77a4f0c51de97f70e8167e.zip
gcc-303bed670af962c01b77a4f0c51de97f70e8167e.tar.gz
gcc-303bed670af962c01b77a4f0c51de97f70e8167e.tar.bz2
c++/coroutines: fix passing *this to promise type, again [PR116327]
In r15-2210 we got rid of the unnecessary cast to lvalue reference when passing *this to the promise type ctor, and as a drive-by change we also simplified the code to use cp_build_fold_indirect_ref. But it turns out cp_build_fold_indirect_ref does too much here, namely it has a shortcut for returning current_class_ref if the operand is current_class_ptr. The problem with that shortcut is current_class_ref might have gotten clobbered earlier if it appeared in the function body, since rewrite_param_uses walks and rewrites in-place all local variable uses to their corresponding frame copy. So later cp_build_fold_indirect_ref for *this will instead return the clobbered current_class_ref i.e. *frame_ptr->this, which doesn't make sense here since we're in the ramp function and not the actor function where frame_ptr is in scope. This patch fixes this by using the build_fold_indirect_ref instead of cp_build_fold_indirect_ref. PR c++/116327 PR c++/104981 PR c++/115550 gcc/cp/ChangeLog: * coroutines.cc (morph_fn_to_coro): Use build_fold_indirect_ref instead of cp_build_fold_indirect_ref. gcc/testsuite/ChangeLog: * g++.dg/coroutines/pr104981-preview-this.C: Improve coverage by adding a non-static data member use within the coroutine member function. * g++.dg/coroutines/pr116327-preview-this.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com>
Diffstat (limited to 'gcc/cp/semantics.cc')
0 files changed, 0 insertions, 0 deletions