From 68a6fa06a2300c02ad3d79604d4abaa76551ab00 Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Sun, 6 Oct 2019 18:03:37 +0100 Subject: [PATCH] Improve old code for detecting missing explicit cast. --- netmisc.cc | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/netmisc.cc b/netmisc.cc index 450eb6c05..36ac0ced0 100644 --- a/netmisc.cc +++ b/netmisc.cc @@ -925,20 +925,18 @@ static NetExpr* do_elab_and_eval(Design*des, NetScope*scope, PExpr*pe, if (tmp == 0) return 0; if ((cast_type != IVL_VT_NO_TYPE) && (cast_type != tmp->expr_type())) { - if (cast_type != pe->expr_type()) { - switch (pe->expr_type()) { - case IVL_VT_BOOL: - case IVL_VT_LOGIC: - case IVL_VT_REAL: - break; - default: - cerr << tmp->get_fileline() << ": error: " - "this expression cannot be implicitly " - "cast to the target type." << endl; - des->errors += 1; - delete tmp; - return 0; - } + switch (tmp->expr_type()) { + case IVL_VT_BOOL: + case IVL_VT_LOGIC: + case IVL_VT_REAL: + break; + default: + cerr << tmp->get_fileline() << ": error: " + "The expression '" << *pe << "' cannot be implicitly " + "cast to the target type." << endl; + des->errors += 1; + delete tmp; + return 0; } switch (cast_type) { case IVL_VT_REAL: