aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2021-03-01 12:02:47 +0000
committerPhilip Herron <herron.philip@googlemail.com>2021-03-01 12:41:45 +0000
commit65e06883b05627eeca556b2df22bd125ebd7eb42 (patch)
tree9c690d9bba34a1b1ec6132bf00d8a891af933ced
parent2a7cbe4fd99513fdf85f77a80eb04a3d99924162 (diff)
downloadgcc-65e06883b05627eeca556b2df22bd125ebd7eb42.zip
gcc-65e06883b05627eeca556b2df22bd125ebd7eb42.tar.gz
gcc-65e06883b05627eeca556b2df22bd125ebd7eb42.tar.bz2
Fix bad type resolution on deadcode1.rs and implicit_return_err1.rs
There was a subtle tweak to checking wether this is the actual final statement of the block to verify the types.
-rw-r--r--gcc/rust/hir/rust-ast-lower.cc2
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check.cc6
2 files changed, 4 insertions, 4 deletions
diff --git a/gcc/rust/hir/rust-ast-lower.cc b/gcc/rust/hir/rust-ast-lower.cc
index 355d570..b54c5ce 100644
--- a/gcc/rust/hir/rust-ast-lower.cc
+++ b/gcc/rust/hir/rust-ast-lower.cc
@@ -115,7 +115,7 @@ ASTLoweringBlock::visit (AST::BlockExpr &expr)
tail_reachable, std::move (inner_attribs),
std::move (outer_attribs), expr.get_locus ());
- terminated = block_did_terminate || expr.has_tail_expr ();
+ terminated = block_did_terminate;
}
void
diff --git a/gcc/rust/typecheck/rust-hir-type-check.cc b/gcc/rust/typecheck/rust-hir-type-check.cc
index 69f13db..15f82e2 100644
--- a/gcc/rust/typecheck/rust-hir-type-check.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check.cc
@@ -110,8 +110,8 @@ TypeCheckExpr::visit (HIR::BlockExpr &expr)
expr.iterate_stmts ([&] (HIR::Stmt *s) mutable -> bool {
bool is_final_stmt = expr.is_final_stmt (s);
- bool is_final_expr
- = is_final_stmt && (!expr.has_expr () || !expr.tail_expr_reachable ());
+ bool has_final_expr = expr.has_expr () && expr.tail_expr_reachable ();
+ bool stmt_is_final_expr = is_final_stmt && !has_final_expr;
auto resolved = TypeCheckStmt::Resolve (s, inside_loop);
if (resolved == nullptr)
@@ -120,7 +120,7 @@ TypeCheckExpr::visit (HIR::BlockExpr &expr)
return false;
}
- if (is_final_expr)
+ if (stmt_is_final_expr)
{
delete block_tyty;
block_tyty = resolved;