aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend/rust-compile-expr.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/rust/backend/rust-compile-expr.cc')
-rw-r--r--gcc/rust/backend/rust-compile-expr.cc16
1 files changed, 15 insertions, 1 deletions
diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc
index 9358ce2..0e2d92b 100644
--- a/gcc/rust/backend/rust-compile-expr.cc
+++ b/gcc/rust/backend/rust-compile-expr.cc
@@ -1341,9 +1341,23 @@ CompileExpr::visit (HIR::MatchExpr &expr)
ctx->add_statement (ret_var_stmt);
// lets compile the scrutinee expression
- tree match_scrutinee_expr
+ tree match_scrutinee_rval
= CompileExpr::Compile (expr.get_scrutinee_expr ().get (), ctx);
+ Bvariable *match_scrutinee_tmp_var = ctx->get_backend ()->temporary_variable (
+ fnctx.fndecl, enclosing_scope, TREE_TYPE (match_scrutinee_rval), NULL,
+ is_address_taken, expr.get_locus (), &ret_var_stmt);
+ ctx->add_statement (ret_var_stmt);
+
+ tree match_scrutinee_expr = match_scrutinee_tmp_var->get_tree (
+ expr.get_scrutinee_expr ()->get_locus ());
+
+ tree assignment
+ = ctx->get_backend ()->assignment_statement (match_scrutinee_expr,
+ match_scrutinee_rval,
+ expr.get_locus ());
+ ctx->add_statement (assignment);
+
tree match_scrutinee_expr_qualifier_expr;
if (TyTy::is_primitive_type_kind (scrutinee_kind))
{