Fix assertion failure for function body with single null statement (GH issue #411)

(cherry picked from commit 94b503fc64)
This commit is contained in:
Martin Whitaker 2020-12-10 17:40:30 +00:00
parent 27986477fb
commit bfac44a630
1 changed files with 12 additions and 8 deletions

View File

@ -5275,14 +5275,18 @@ void PFunction::elaborate(Design*des, NetScope*scope) const
}
assert(def);
ivl_assert(*this, statement_);
NetProc*st = statement_->elaborate(des, scope);
if (st == 0) {
cerr << statement_->get_fileline() << ": error: Unable to elaborate "
"statement in function " << scope->basename() << "." << endl;
scope->is_const_func(true); // error recovery
des->errors += 1;
return;
NetProc*st;
if (statement_ == 0) {
st = new NetBlock(NetBlock::SEQU, 0);
} else {
st = statement_->elaborate(des, scope);
if (st == 0) {
cerr << statement_->get_fileline() << ": error: Unable to elaborate "
"statement in function " << scope->basename() << "." << endl;
scope->is_const_func(true); // error recovery
des->errors += 1;
return;
}
}
// Handle any variable initialization statements in this scope.