for future use with defer statements, as they do not have a declaration
associated, and are bound to the scope with a BIND_EXPR
gcc/c/ChangeLog:
* c-typeck.cc (push_cleanup): Adjust.
Signed-off-by: Anna (navi) Figueiredo Gomes <[email protected]>
---
gcc/c/c-typeck.cc | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc
index ed6e56e7279..f26184e5603 100644
--- a/gcc/c/c-typeck.cc
+++ b/gcc/c/c-typeck.cc
@@ -13586,14 +13586,20 @@ c_end_compound_stmt (location_t loc, tree stmt, bool
do_scope)
meant to apply to normal control flow transfer. */
void
-push_cleanup (tree decl, tree cleanup, bool eh_only)
+push_cleanup (tree node, tree cleanup, bool eh_only)
{
+ location_t loc = UNKNOWN_LOCATION;
enum tree_code code;
tree stmt, list;
bool stmt_expr;
+ if (DECL_P (node))
+ loc = DECL_SOURCE_LOCATION (node);
+ else if (EXPR_P (node))
+ loc = EXPR_LOCATION (node);
+
code = eh_only ? TRY_CATCH_EXPR : TRY_FINALLY_EXPR;
- stmt = build_stmt (DECL_SOURCE_LOCATION (decl), code, NULL, cleanup);
+ stmt = build_stmt (loc, code, NULL, cleanup);
add_stmt (stmt);
stmt_expr = STATEMENT_LIST_STMT_EXPR (cur_stmt_list);
list = push_stmt_list ();
--
2.51.0