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.
This commit is contained in:
Stephen Williams 2022-04-23 18:52:15 -07:00
parent 4679c722e3
commit dc203a20ba
2 changed files with 13 additions and 4 deletions

View File

@ -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 << "<rval elaboration error>;" << 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;
}

View File

@ -441,8 +441,11 @@ bool NetAssign::eval_func_lval_(const LineInfo&loc,
bool NetAssign::evaluate_function(const LineInfo&loc,
map<perm_string,LocalVar>&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;