Merge pull request #841 from larsclausen/ps-func-call-error-handling
Improve error handling for package scoped function calls
This commit is contained in:
commit
09e841eee2
3
PExpr.h
3
PExpr.h
|
|
@ -928,9 +928,6 @@ class PECallFunction : public PExpr {
|
|||
NetExpr* elaborate_expr_(Design *des, NetScope *scope,
|
||||
unsigned flags) const;
|
||||
|
||||
NetExpr*elaborate_expr_pkg_(Design*des, NetScope*scope,
|
||||
unsigned flags)const;
|
||||
|
||||
NetExpr* elaborate_expr_method_(Design*des, NetScope*scope,
|
||||
symbol_search_results&search_results)
|
||||
const;
|
||||
|
|
|
|||
39
elab_expr.cc
39
elab_expr.cc
|
|
@ -2606,34 +2606,6 @@ NetExpr* PEIdent::elaborate_expr_class_field_(Design*des, NetScope*scope,
|
|||
return tmp;
|
||||
}
|
||||
|
||||
NetExpr* PECallFunction::elaborate_expr_pkg_(Design*des, NetScope*scope,
|
||||
unsigned flags) const
|
||||
{
|
||||
if (debug_elaborate) {
|
||||
cerr << get_fileline() << ": PECallFunction::elaborate_expr_pkg_: "
|
||||
<< "Elaborate " << path_
|
||||
<< " as function in package " << package_->pscope_name()
|
||||
<< "." << endl;
|
||||
}
|
||||
|
||||
// Find the package that contains this definition, and use the
|
||||
// package scope as the search starting point for the function
|
||||
// definition.
|
||||
NetScope*pscope = des->find_package(package_->pscope_name());
|
||||
ivl_assert(*this, pscope);
|
||||
|
||||
NetFuncDef*def = des->find_function(pscope, path_);
|
||||
ivl_assert(*this, def);
|
||||
|
||||
NetScope*dscope = def->scope();
|
||||
ivl_assert(*this, dscope);
|
||||
|
||||
if (! check_call_matches_definition_(des, dscope))
|
||||
return 0;
|
||||
|
||||
return elaborate_base_(des, scope, dscope, flags);
|
||||
}
|
||||
|
||||
NetExpr* PECallFunction::elaborate_expr(Design*des, NetScope*scope,
|
||||
unsigned expr_wid, unsigned flags) const
|
||||
{
|
||||
|
|
@ -2661,14 +2633,17 @@ NetExpr* PECallFunction::elaborate_expr(Design*des, NetScope*scope,
|
|||
NetExpr* PECallFunction::elaborate_expr_(Design*des, NetScope*scope,
|
||||
unsigned flags) const
|
||||
{
|
||||
if (package_)
|
||||
return elaborate_expr_pkg_(des, scope, flags);
|
||||
|
||||
flags &= ~SYS_TASK_ARG; // don't propagate the SYS_TASK_ARG flag
|
||||
|
||||
NetScope *use_scope = scope;
|
||||
if (package_) {
|
||||
use_scope = des->find_package(package_->pscope_name());
|
||||
ivl_assert(*this, use_scope);
|
||||
}
|
||||
|
||||
// Search for the symbol. This should turn up a scope.
|
||||
symbol_search_results search_results;
|
||||
bool search_flag = symbol_search(this, des, scope, path_, &search_results);
|
||||
bool search_flag = symbol_search(this, des, use_scope, path_, &search_results);
|
||||
|
||||
if (debug_elaborate) {
|
||||
cerr << get_fileline() << ": PECallFunction::elaborate_expr: "
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
// Check that an error is reported when trying to call a package scoped function
|
||||
// that does not exist.
|
||||
|
||||
package P;
|
||||
endpackage
|
||||
|
||||
module test;
|
||||
|
||||
initial begin
|
||||
int y;
|
||||
y = P::f(10); // This should fail, f does not exist
|
||||
$display("FAILED");
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
// Check that trying to call a package scoped variable as a function results in
|
||||
// an error.
|
||||
|
||||
package P;
|
||||
int x;
|
||||
endpackage
|
||||
|
||||
module test;
|
||||
|
||||
initial begin
|
||||
int y;
|
||||
y = P::x(10); // This should fail, x is not a function
|
||||
$display("FAILED");
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
// Check that an error is reported when trying to call a package scoped task as
|
||||
// a function.
|
||||
|
||||
package P;
|
||||
task t(int x);
|
||||
endtask
|
||||
endpackage
|
||||
|
||||
module test;
|
||||
|
||||
initial begin
|
||||
int y;
|
||||
y = P::t(10); // This should fail, t is a task
|
||||
$display("FAILED");
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -692,6 +692,9 @@ sv_ps_function4 normal,-g2009 ivltests
|
|||
sv_ps_function5 normal,-g2009 ivltests
|
||||
sv_ps_function6 normal,-g2009 ivltests
|
||||
sv_ps_function7 normal,-g2009 ivltests
|
||||
sv_ps_function_fail1 CE,-g2009 ivltests
|
||||
sv_ps_function_fail2 CE,-g2009 ivltests
|
||||
sv_ps_function_fail3 CE,-g2009 ivltests
|
||||
sv_ps_member_sel1 normal,-g2009 ivltests
|
||||
sv_ps_member_sel2 normal,-g2009 ivltests
|
||||
sv_ps_member_sel3 normal,-g2009 ivltests
|
||||
|
|
|
|||
Loading…
Reference in New Issue