Merge pull request #700 from steveicarus/steveicarus/gh_pr699-fix-segfault

Fix issue 699: segfault when rvalue to elaboration fails.
This commit is contained in:
Stephen Williams 2022-04-23 19:24:13 -07:00 committed by GitHub
commit e7b700f48e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 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

@ -0,0 +1,9 @@
// This should generate an error reporting the undef_func, but not segfault.
module test1;
function [31:0] func1 (input [31:0] x);
return undef_func(x);
endfunction : func1
localparam X = func1(1);
endmodule : test1

View File

@ -210,6 +210,7 @@ br_gh568 normal,-g2009 ivltests
br_gh661a normal,-g2009 ivltests
br_gh661b normal,-g2009 ivltests
br_gh672 normal,-g2009 ivltests
br_gh699 CE,-g2009 ivltests
br_ml20171017 normal,-g2009 ivltests
br_ml20180227 CE,-g2009 ivltests
br_ml20180309a normal,-g2009 ivltests

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;