aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend/rust-compile.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/rust/backend/rust-compile.cc')
-rw-r--r--gcc/rust/backend/rust-compile.cc37
1 files changed, 21 insertions, 16 deletions
diff --git a/gcc/rust/backend/rust-compile.cc b/gcc/rust/backend/rust-compile.cc
index 600b2f9..dd87d45 100644
--- a/gcc/rust/backend/rust-compile.cc
+++ b/gcc/rust/backend/rust-compile.cc
@@ -236,23 +236,28 @@ CompileBlock::visit (HIR::BlockExpr &expr)
// the previous passes will ensure this is a valid return
// dead code elimination should remove any bad trailing expressions
Bexpression *compiled_expr = CompileExpr::Compile (expr.expr.get (), ctx);
- rust_assert (compiled_expr != nullptr);
-
- if (result == nullptr)
- {
- Bstatement *final_stmt
- = ctx->get_backend ()->expression_statement (fnctx.fndecl,
- compiled_expr);
- ctx->add_statement (final_stmt);
- }
- else
+ if (compiled_expr != nullptr)
{
- Bexpression *result_reference = ctx->get_backend ()->var_expression (
- result, expr.get_final_expr ()->get_locus_slow ());
-
- Bstatement *assignment = ctx->get_backend ()->assignment_statement (
- fnctx.fndecl, result_reference, compiled_expr, expr.get_locus ());
- ctx->add_statement (assignment);
+ if (result == nullptr)
+ {
+ Bstatement *final_stmt
+ = ctx->get_backend ()->expression_statement (fnctx.fndecl,
+ compiled_expr);
+ ctx->add_statement (final_stmt);
+ }
+ else
+ {
+ Bexpression *result_reference
+ = ctx->get_backend ()->var_expression (
+ result, expr.get_final_expr ()->get_locus_slow ());
+
+ Bstatement *assignment
+ = ctx->get_backend ()->assignment_statement (fnctx.fndecl,
+ result_reference,
+ compiled_expr,
+ expr.get_locus ());
+ ctx->add_statement (assignment);
+ }
}
}