]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++/coroutines: Fix awaiter var creation [PR116506]
authorIain Sandoe <iains.gcc@gmail.com>
Thu, 31 Oct 2024 08:40:08 +0000 (08:40 +0000)
committerJason Merrill <jason@redhat.com>
Mon, 3 Feb 2025 21:55:17 +0000 (16:55 -0500)
commit4c743798b1d4530b327dad7c606c610f3811fdbf
treeac964a9bf7b1f12a0b26095484f7acba5d7756a5
parentec716ad3f4bdccb6a2780161e74e3168efa68121
c++/coroutines: Fix awaiter var creation [PR116506]

Awaiters always need to have a coroutine state frame copy since
they persist across potential supensions.  It simplifies the later
analysis considerably to assign these early which we do when
building co_await expressions.

The cleanups in r15-3146-g47dbd69b1, unfortunately elided some of
processing used to cater for cases where the var created from an
xvalue, or is a pointer/reference type.

Corrected thus.

PR c++/116506
PR c++/116880

gcc/cp/ChangeLog:

* coroutines.cc (build_co_await): Ensure that xvalues are
materialised.  Handle references/pointer values in awaiter
access expressions.
(is_stable_lvalue): New.
* decl.cc (cxx_maybe_build_cleanup): Handle null arg.

gcc/testsuite/ChangeLog:

* g++.dg/coroutines/pr116506.C: New test.
* g++.dg/coroutines/pr116880.C: New test.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
Co-authored-by: Jason Merrill <jason@redhat.com>
gcc/cp/coroutines.cc
gcc/cp/decl.cc
gcc/testsuite/g++.dg/coroutines/pr116506.C [new file with mode: 0644]
gcc/testsuite/g++.dg/coroutines/pr116880.C [new file with mode: 0644]