Add support for return statements in void functions.

This commit is contained in:
Martin Whitaker 2020-07-10 23:34:11 +01:00
parent 07256646a5
commit b36bca1f1b
1 changed files with 13 additions and 2 deletions

View File

@ -5339,9 +5339,20 @@ NetProc* PReturn::elaborate(Design*des, NetScope*scope) const
des->errors += 1;
return 0;
}
ivl_assert(*this, target->type() == NetScope::FUNC);
if (target->func_def()->is_void()) {
if (expr_) {
cerr << get_fileline() << ": error: "
<< "A value can't be returned from a void function." << endl;
des->errors += 1;
return 0;
}
NetDisable*disa = new NetDisable(target);
disa->set_line( *this );
return disa;
}
// We don't yet support void functions, so require an
// expression for the return statement.
if (expr_ == 0) {
cerr << get_fileline() << ": error: "
<< "Return from " << scope_path(target)