TREE_OPERAND (body_start, 0) = push_stmt_list ();
}
- /* If the original function has a return value with a non-trivial DTOR
- and the body contains a var with a DTOR that might throw, the decl is
- marked "throwing_cleanup".
- We do not [in the ramp, which is synthesised here], use any body var
- types with DTORs that might throw.
- The original body is transformed into the actor function which only
- contains void returns, and is also wrapped in a try-catch block.
- So (a) the 'throwing_cleanup' is not correct for the ramp and (b) we do
- not need to transfer it to the actor which only contains void returns. */
- cp_function_chain->throwing_cleanup = false;
-
/* Create the coro frame type, as far as it can be known at this stage.
1. Types we already know. */
either as the return value (if it's the same type) or to the CTOR
for an object of the return type. */
+ /* We must manage the cleanups ourselves, because the responsibility for
+ them changes after the initial suspend. However, any use of
+ cxx_maybe_build_cleanup () can set the throwing_cleanup flag. */
+ cp_function_chain->throwing_cleanup = false;
if (same_type_p (gro_type, fn_return_type))
r = void_ramp_p ? NULL_TREE : DECL_RESULT (orig);
else
--- /dev/null
+#include <coroutine>
+
+struct Foo {
+ ~Foo() noexcept(false); // true succeeds
+ struct promise_type {
+ Foo get_return_object() { return {}; }
+ std::suspend_never initial_suspend() { return {}; }
+ void return_void() {}
+ void unhandled_exception() {}
+ std::suspend_always final_suspend() noexcept { return {}; }
+ };
+};
+
+Foo bar() {
+ co_return;
+}