Be consistent on allowing calling non-void function as task
When calling non-void functions or non-void methods of built-in types as a task a warning is issued. But when calling a non-void method of a user defined class as a task an error is generated. Be consistent here and generate a warning in both cases. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
parent
2d6243ea6c
commit
54956f0f29
|
|
@ -235,6 +235,7 @@ class PCallTask : public Statement {
|
||||||
NetProc*elaborate_function_(Design*des, NetScope*scope) const;
|
NetProc*elaborate_function_(Design*des, NetScope*scope) const;
|
||||||
NetProc*elaborate_void_function_(Design*des, NetScope*scope,
|
NetProc*elaborate_void_function_(Design*des, NetScope*scope,
|
||||||
NetFuncDef*def) const;
|
NetFuncDef*def) const;
|
||||||
|
NetProc *elaborate_non_void_function_(Design *des, NetScope *scope) const;
|
||||||
|
|
||||||
NetProc*elaborate_build_call_(Design*des, NetScope*scope,
|
NetProc*elaborate_build_call_(Design*des, NetScope*scope,
|
||||||
NetScope*task, NetExpr*use_this) const;
|
NetScope*task, NetExpr*use_this) const;
|
||||||
|
|
|
||||||
32
elaborate.cc
32
elaborate.cc
|
|
@ -3896,16 +3896,8 @@ bool PCallTask::test_task_calls_ok_(Design*des, NetScope*scope) const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetProc* PCallTask::elaborate_function_(Design*des, NetScope*scope) const
|
NetProc *PCallTask::elaborate_non_void_function_(Design *des, NetScope *scope) const
|
||||||
{
|
{
|
||||||
NetFuncDef*func = des->find_function(scope, path_);
|
|
||||||
// This is not a function, so this task call cannot be a function
|
|
||||||
// call with a missing return assignment.
|
|
||||||
if (! func) return 0;
|
|
||||||
|
|
||||||
if (gn_system_verilog() && func->is_void())
|
|
||||||
return elaborate_void_function_(des, scope, func);
|
|
||||||
|
|
||||||
// Generate a function call version of this task call.
|
// Generate a function call version of this task call.
|
||||||
PExpr*rval = new PECallFunction(package_, path_, parms_);
|
PExpr*rval = new PECallFunction(package_, path_, parms_);
|
||||||
rval->set_file(get_file());
|
rval->set_file(get_file());
|
||||||
|
|
@ -3920,6 +3912,21 @@ NetProc* PCallTask::elaborate_function_(Design*des, NetScope*scope) const
|
||||||
return tmp->elaborate(des, scope);
|
return tmp->elaborate(des, scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NetProc* PCallTask::elaborate_function_(Design*des, NetScope*scope) const
|
||||||
|
{
|
||||||
|
NetFuncDef*func = des->find_function(scope, path_);
|
||||||
|
|
||||||
|
// This is not a function, so this task call cannot be a function
|
||||||
|
// call with a missing return assignment.
|
||||||
|
if (!func)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
if (gn_system_verilog() && func->is_void())
|
||||||
|
return elaborate_void_function_(des, scope, func);
|
||||||
|
|
||||||
|
return elaborate_non_void_function_(des, scope);
|
||||||
|
}
|
||||||
|
|
||||||
NetProc* PCallTask::elaborate_void_function_(Design*des, NetScope*scope,
|
NetProc* PCallTask::elaborate_void_function_(Design*des, NetScope*scope,
|
||||||
NetFuncDef*def) const
|
NetFuncDef*def) const
|
||||||
{
|
{
|
||||||
|
|
@ -3957,11 +3964,8 @@ NetProc* PCallTask::elaborate_build_call_(Design*des, NetScope*scope,
|
||||||
|
|
||||||
} else if (task->type() == NetScope::FUNC) {
|
} else if (task->type() == NetScope::FUNC) {
|
||||||
NetFuncDef*tmp = task->func_def();
|
NetFuncDef*tmp = task->func_def();
|
||||||
if (!tmp->is_void()) {
|
if (!tmp->is_void())
|
||||||
cerr << get_fileline() << ": error: "
|
return elaborate_non_void_function_(des, scope);
|
||||||
<< "Calling a non-void function as a task." << endl;
|
|
||||||
des->errors += 1;
|
|
||||||
}
|
|
||||||
def = tmp;
|
def = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue