From dc203a20ba415ee7bf8c91f6561a2cb5cfa343e8 Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Sat, 23 Apr 2022 18:52:15 -0700 Subject: [PATCH] Handle the error case that the rval fails There are some cases where the r-value for an assignment just can't be elaborated. Instead of segfaulting on the error, handle it by assuming that the nullptr came from an error message, and ignore it going forward. --- design_dump.cc | 10 ++++++++-- net_func_eval.cc | 7 +++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/design_dump.cc b/design_dump.cc index 9fa0ba876..f6540a6da 100644 --- a/design_dump.cc +++ b/design_dump.cc @@ -1124,7 +1124,10 @@ void NetAssign::dump(ostream&o, unsigned ind) const if (const NetExpr*de = get_delay()) o << "#(" << *de << ") "; - o << *rval() << ";" << endl; + if (rval()) + o << *rval() << ";" << endl; + else + o << ";" << endl; } void NetAssignNB::dump(ostream&o, unsigned ind) const @@ -1142,7 +1145,10 @@ void NetAssignNB::dump(ostream&o, unsigned ind) const o << *event_; } - o << *rval() << ";" << endl; + if (rval()) + o << *rval() << ";" << endl; + else + o << "rval elaboration error>;" << endl; } diff --git a/net_func_eval.cc b/net_func_eval.cc index 136be7805..58b7d629d 100644 --- a/net_func_eval.cc +++ b/net_func_eval.cc @@ -441,8 +441,11 @@ bool NetAssign::eval_func_lval_(const LineInfo&loc, bool NetAssign::evaluate_function(const LineInfo&loc, map&context_map) const { - // Evaluate the r-value expression. - NetExpr*rval_result = rval()->evaluate_function(loc, context_map); + // Evaluate the r-value expression. + const NetExpr*use_rval = rval(); + if (use_rval == 0) + return false; + NetExpr*rval_result = use_rval->evaluate_function(loc, context_map); if (rval_result == 0) return false;