From 94b503fc642a20cfb810bf93610b776929545f3b Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Thu, 10 Dec 2020 17:40:30 +0000 Subject: [PATCH] Fix assertion failure for function body with single null statement (GH issue #411) --- elaborate.cc | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/elaborate.cc b/elaborate.cc index 3195d3e64..298ee01f9 100644 --- a/elaborate.cc +++ b/elaborate.cc @@ -5296,14 +5296,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.