From c5fdf8cc544f9647e2cf28a2da431bfa1faacd15 Mon Sep 17 00:00:00 2001 From: lrh2000 Date: Sat, 10 Apr 2021 22:53:32 +0800 Subject: The trailing expression is not necessarily without a block --- gcc/rust/backend/rust-compile.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'gcc/rust/backend') 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 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); -- cgit v1.1