Skip to content
Snippets Groups Projects
Commit 2466a8d0 authored by Iain Sandoe's avatar Iain Sandoe
Browse files

coroutines: Handle initial awaiters with non-void returns [PR 100127].


The way in which a C++20 coroutine is specified discards any value
that might be returned from the initial or final await expressions.

This ICE was caused by an initial await expression with an
await_resume () returning a reference, the function rewrite code
was not set up to expect this.

Fixed by looking through any indirection present and by explicitly
discarding the value, if any, returned by await_resume().

It does not seem useful to make a diagnostic for this, since
the user could define a generic awaiter that usefully returns
values when used in a different position from the initial (or
final) await expressions.

Signed-off-by: default avatarIain Sandoe <iain@sandoe.co.uk>

	PR c++/100127

gcc/cp/ChangeLog:

	* coroutines.cc (coro_rewrite_function_body): Handle initial
	await expressions that try to produce a reference value.

gcc/testsuite/ChangeLog:

	* g++.dg/coroutines/pr100127.C: New test.
parent 921942a8
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment