aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/ast/rust-expr.h
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2023-06-09 17:13:41 +0200
committerArthur Cohen <arthur.cohen@embecosm.com>2024-01-16 18:46:29 +0100
commit0974798a3f5259b14b95edf9ddbe9c81af76ecff (patch)
tree49b893f06ac1e6cf53a300b3f5eaec73542a7aee /gcc/rust/ast/rust-expr.h
parent9035128b75b9c8b4465e33bafed43649046534b6 (diff)
downloadgcc-0974798a3f5259b14b95edf9ddbe9c81af76ecff.zip
gcc-0974798a3f5259b14b95edf9ddbe9c81af76ecff.tar.gz
gcc-0974798a3f5259b14b95edf9ddbe9c81af76ecff.tar.bz2
gccrs: expand: Add tail expr expansion
Tail expression may contain attribute and thus should be expanded. gcc/rust/ChangeLog: * ast/rust-expr.h: Add a function to take tail expr as well as a function to set a tail expression. * expand/rust-expand-visitor.cc (expand_tail_expr): Add tail expression expansion function. (ExpandVisitor::visit): Add call to tail expr expansion in for BlockExpr. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diffstat (limited to 'gcc/rust/ast/rust-expr.h')
-rw-r--r--gcc/rust/ast/rust-expr.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/gcc/rust/ast/rust-expr.h b/gcc/rust/ast/rust-expr.h
index adf9b68..2791a8c 100644
--- a/gcc/rust/ast/rust-expr.h
+++ b/gcc/rust/ast/rust-expr.h
@@ -2487,6 +2487,17 @@ public:
return expr;
}
+ std::unique_ptr<Expr> take_tail_expr ()
+ {
+ rust_assert (has_tail_expr ());
+ return std::move (expr);
+ }
+
+ void set_tail_expr (std::unique_ptr<Expr> expr)
+ {
+ this->expr = std::move (expr);
+ }
+
// Removes the tail expression from the block.
void strip_tail_expr () { expr = nullptr; }
// Normalizes a trailing statement without a semicolon to a tail expression.