Add error recovery for invalid cast expressions.

(cherry picked from commit 9f7dc732ab)
This commit is contained in:
Martin Whitaker 2019-10-11 19:04:23 +01:00
parent c965e14cd7
commit daf6b7a132
1 changed files with 5 additions and 0 deletions

View File

@ -2542,6 +2542,8 @@ NetExpr* PECastSize::elaborate_expr(Design*des, NetScope*scope,
cast_width = expr_width_;
NetExpr*sub = base_->elaborate_expr(des, scope, cast_width, flags);
if (sub == 0)
return 0;
// Perform the cast. The extension method (zero/sign), if needed,
// depends on the type of the base expression.
@ -2622,6 +2624,8 @@ NetExpr* PECastType::elaborate_expr(Design*des, NetScope*scope,
cast_width = expr_width_;
NetExpr*sub = base_->elaborate_expr(des, scope, cast_width, flags);
if (sub == 0)
return 0;
if (dynamic_cast<const real_type_t*>(target_)) {
return cast_to_real(sub);
@ -2669,6 +2673,7 @@ NetExpr* PECastType::elaborate_expr(Design*des, NetScope*scope,
}
cerr << get_fileline() << ": sorry: This cast operation is not yet supported." << endl;
des->errors += 1;
return 0;
}