From: Lishin <[email protected]>
Use the Drop cleanup as the normal cleanup and an empty statement as
the exceptional cleanup.
This keeps block-scope Drop cleanup on normal control-flow exits without
requiring the gccrs EH personality while stack unwinding is not implemented.
gcc/rust/ChangeLog:
* backend/rust-compile-context.h:
(Context::pop_block_impl): Wrap Drop cleanup in an EH_ELSE_EXPR.
Signed-off-by: Lishin <[email protected]>
---
gcc/rust/backend/rust-compile-context.h | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/gcc/rust/backend/rust-compile-context.h
b/gcc/rust/backend/rust-compile-context.h
index 25a27ca9628..7f67b9382e0 100644
--- a/gcc/rust/backend/rust-compile-context.h
+++ b/gcc/rust/backend/rust-compile-context.h
@@ -437,8 +437,14 @@ private:
if (body == NULL_TREE)
body = build_empty_stmt (cleanup_locus);
+ tree exceptional_cleanup = build_empty_stmt (cleanup_locus);
+ tree cleanup_selector
+ = build2_loc (cleanup_locus, EH_ELSE_EXPR, void_type_node, cleanup,
+ exceptional_cleanup);
+
tree try_finally
- = Backend::exception_handler_statement (body, NULL_TREE, cleanup,
+ = Backend::exception_handler_statement (body, NULL_TREE,
+ cleanup_selector,
cleanup_locus);
Backend::block_add_statements (block, {try_finally});
}
--
2.50.1