Merge pull request #1355 from larsclausen/super-member-access-error
Reject super access without a parent class
This commit is contained in:
commit
2449ee2054
|
|
@ -0,0 +1,11 @@
|
|||
// Check that `super` access in a class without a parent class is rejected.
|
||||
|
||||
module test;
|
||||
|
||||
class C;
|
||||
function void f;
|
||||
super.x = 1;
|
||||
endfunction
|
||||
endclass
|
||||
|
||||
endmodule
|
||||
|
|
@ -288,6 +288,7 @@ sv_package_lifetime vvp_tests/sv_package_lifetime.json
|
|||
sv_package_lifetime_fail vvp_tests/sv_package_lifetime_fail.json
|
||||
sv_parameter_type vvp_tests/sv_parameter_type.json
|
||||
sv_queue_assign_op vvp_tests/sv_queue_assign_op.json
|
||||
sv_super_member_fail vvp_tests/sv_super_member_fail.json
|
||||
sv_wildcard_import8 vvp_tests/sv_wildcard_import8.json
|
||||
sdf_header vvp_tests/sdf_header.json
|
||||
task_return1 vvp_tests/task_return1.json
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"type" : "CE",
|
||||
"source" : "sv_super_member_fail.v",
|
||||
"iverilog-args" : [ "-g2005-sv" ]
|
||||
}
|
||||
|
|
@ -153,6 +153,15 @@ bool symbol_search(const LineInfo*li, Design*des, NetScope*scope,
|
|||
if (path_tail.name == "#") {
|
||||
if (NetNet *net = scope->find_signal(perm_string::literal(THIS_TOKEN))) {
|
||||
const netclass_t *class_type = dynamic_cast<const netclass_t*>(net->net_type());
|
||||
ivl_assert(*li, class_type);
|
||||
if (!class_type->get_super()) {
|
||||
cerr << li->get_fileline() << ": error: "
|
||||
<< "Class " << class_type->get_name()
|
||||
<< " uses `super` without a base class."
|
||||
<< endl;
|
||||
des->errors += 1;
|
||||
return false;
|
||||
}
|
||||
path.push_back(path_tail);
|
||||
res->scope = scope;
|
||||
res->net = net;
|
||||
|
|
|
|||
Loading…
Reference in New Issue