Report error when calling void function in an expression
Unlike normal functions void functions can not be called as part of an expression. Trying so will currently hit an internal assert. Make sure an error is reported instead. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
parent
2a15489e9d
commit
abc26eeaeb
11
elab_expr.cc
11
elab_expr.cc
|
|
@ -1642,6 +1642,9 @@ unsigned PECallFunction::test_width(Design*des, NetScope*scope,
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (def->is_void())
|
||||
return 0;
|
||||
|
||||
NetScope*dscope = def->scope();
|
||||
assert(dscope);
|
||||
|
||||
|
|
@ -2860,6 +2863,14 @@ NetExpr* PECallFunction::elaborate_base_(Design*des, NetScope*scope, NetScope*ds
|
|||
if (parm_errors)
|
||||
return 0;
|
||||
|
||||
if (def->is_void()) {
|
||||
cerr << get_fileline() << ": error: void function `"
|
||||
<< dscope->basename() << "` can not be called in an expression."
|
||||
<< endl;
|
||||
des->errors++;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* Look for the return value signal for the called
|
||||
function. This return value is a magic signal in the scope
|
||||
of the function, that has the name of the function. The
|
||||
|
|
|
|||
Loading…
Reference in New Issue