Merge pull request #1401 from larsclausen/fix-bad-member-lval-proc-crash

Handle bogus member l-value paths
This commit is contained in:
Cary R. 2026-06-21 21:12:43 -07:00 committed by GitHub
commit e9bc3488fb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 24 additions and 0 deletions

View File

@ -298,6 +298,15 @@ NetAssign_*PEIdent::elaborate_lval_var_(Design *des, NetScope *scope,
// Past this point, we should have taken care of the cases
// where the name is a member/method of a struct/class.
// XXXX ivl_assert(*this, method_name.nil());
if (!tail_path.empty()) {
cerr << get_fileline() << ": error: Variable "
<< reg->name()
<< " does not have a field named: "
<< tail_path << "." << endl;
des->errors += 1;
return nullptr;
}
ivl_assert(*this, tail_path.empty());
bool need_const_idx = is_cassign || is_force;

View File

@ -0,0 +1,9 @@
// Check that bogus member access on procedural l-values reports an error.
module test;
logic r;
initial begin
r.bad = 1'b1;
end
endmodule

View File

@ -256,6 +256,7 @@ sv_array_cassign10 vvp_tests/sv_array_cassign10.json
sv_array_cassign_single vvp_tests/sv_array_cassign_single.json
sv_array_cassign_single_fail1 vvp_tests/sv_array_cassign_single_fail1.json
sv_automatic_2state vvp_tests/sv_automatic_2state.json
sv_bad_member_lval_proc_fail vvp_tests/sv_bad_member_lval_proc_fail.json
sv_byte_array_string1 vvp_tests/sv_byte_array_string1.json
sv_byte_array_string2 vvp_tests/sv_byte_array_string2.json
sv_byte_array_string3 vvp_tests/sv_byte_array_string3.json

View File

@ -0,0 +1,5 @@
{
"type" : "CE",
"source" : "sv_bad_member_lval_proc_fail.v",
"iverilog-args" : [ "-g2005-sv" ]
}