Insert default return_void at the end of coroutine body
Exception in coroutine is not correctly handled because the default
return_void call is now inserted before the finish suspend point,
rather than at the end of the original coroutine body. This patch
fixes the issue by expanding code as following:
co_await promise.initial_suspend();
try {
// The original coroutine body
promise.return_void(); // The default return_void call.
} catch (...) {
promise.unhandled_exception();
}
final_suspend:
// ...
gcc/cp/
* coroutines.cc (build_actor_fn): Factor out code inserting the
default return_void call to...
(morph_fn_to_coro): ...here, also hoist local var declarations.
gcc/testsuite/
* g++.dg/coroutines/torture/co-ret-15-default-return_void.C: New.