]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++, coroutines: Address CWG2563 return value init [PR119916].
authorIain Sandoe <iain@sandoe.co.uk>
Mon, 12 May 2025 18:47:42 +0000 (19:47 +0100)
committerIain Sandoe <iain@sandoe.co.uk>
Wed, 21 May 2025 07:54:58 +0000 (08:54 +0100)
commite06555a40c051d5062405b02f93b89b01a397f97
treeb106f7225745dbe8537d681e1cc705be40168d10
parent36c20fee22d40c6d25f52e929b42f5eab62cb1eb
c++, coroutines: Address CWG2563 return value init [PR119916].

This addresses the clarification that, when the get_return_object is of a
different type from the ramp return, any necessary conversions should be
performed on the return expression (so that they typically occur after the
function body has started execution).

PR c++/119916

gcc/cp/ChangeLog:

* coroutines.cc
(cp_coroutine_transform::wrap_original_function_body): Do not
initialise initial_await_resume_called here...
(cp_coroutine_transform::build_ramp_function): ... but here.
When the coroutine is not void, initialize a GRO object from
promise.get_return_object().  Use this as the argument to the
return expression.  Use a regular cleanup for the GRO, since
it is ramp-local.

gcc/testsuite/ChangeLog:

* g++.dg/coroutines/torture/special-termination-00-sync-completion.C:
Amend for CWG2563 expected behaviour.
* g++.dg/coroutines/torture/special-termination-01-self-destruct.C:
Likewise.
* g++.dg/coroutines/torture/pr119916.C: New test.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/cp/coroutines.cc
gcc/testsuite/g++.dg/coroutines/torture/pr119916.C [new file with mode: 0644]
gcc/testsuite/g++.dg/coroutines/torture/special-termination-00-sync-completion.C
gcc/testsuite/g++.dg/coroutines/torture/special-termination-01-self-destruct.C