aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend
diff options
context:
space:
mode:
authorlrh2000 <lrh2000@pku.edu.cn>2021-04-10 22:53:32 +0800
committerlrh2000 <lrh2000@pku.edu.cn>2021-04-18 10:11:53 +0800
commitc5fdf8cc544f9647e2cf28a2da431bfa1faacd15 (patch)
treef67b95885d2f3573acd86e815750e0e1ec92b58f /gcc/rust/backend
parent498758a1c238a539b364ac2c632742a9b64ab4a5 (diff)
downloadgcc-c5fdf8cc544f9647e2cf28a2da431bfa1faacd15.zip
gcc-c5fdf8cc544f9647e2cf28a2da431bfa1faacd15.tar.gz
gcc-c5fdf8cc544f9647e2cf28a2da431bfa1faacd15.tar.bz2
The trailing expression is not necessarily without a block
Diffstat (limited to 'gcc/rust/backend')
-rw-r--r--gcc/rust/backend/rust-compile.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/gcc/rust/backend/rust-compile.cc b/gcc/rust/backend/rust-compile.cc
index a2f5247..d0e0c66 100644
--- a/gcc/rust/backend/rust-compile.cc
+++ b/gcc/rust/backend/rust-compile.cc
@@ -416,10 +416,11 @@ HIRCompileBase::compile_function_body (
// dead code elimination should remove any bad trailing expressions
Bexpression *compiled_expr
= CompileExpr::Compile (function_body->expr.get (), ctx);
- rust_assert (compiled_expr != nullptr);
if (has_return_type)
{
+ rust_assert (compiled_expr != nullptr);
+
std::vector<Bexpression *> retstmts;
retstmts.push_back (compiled_expr);
@@ -428,7 +429,7 @@ HIRCompileBase::compile_function_body (
function_body->get_final_expr ()->get_locus_slow ());
ctx->add_statement (ret);
}
- else
+ else if (compiled_expr)
{
Bstatement *final_stmt
= ctx->get_backend ()->expression_statement (fndecl, compiled_expr);