Fix associative array of events causes C++ compile error (#6962).

This commit is contained in:
Wilson Snyder 2026-01-29 20:38:50 -05:00
parent 7e56a2334a
commit 996ae35a1b
4 changed files with 76 additions and 0 deletions

View File

@ -53,6 +53,7 @@ Verilator 5.045 devel
* Fix null pointer dereference in class member trigger expressions (#6946). [Cameron Waite]
* Fix type assignments for arrays of parameter types (#6955). [Todd Strader]
* Fix accessing non-rand struct member in constraints (#6960). [Pawel Kojma, Antmicro Ltd.]
* Fix associative array of events causes C++ compile error (#6962).
Verilator 5.044 2026-01-01

View File

@ -666,6 +666,8 @@ string EmitCFunc::emitVarResetRecurse(const AstVar* varp, bool constructing,
return "";
} else if (basicp && (basicp->isRandomGenerator() || basicp->isStdRandomGenerator())) {
return "";
} else if (basicp && (basicp->isEvent())) {
return "VlAssignableEvent{};\n";
} else if (basicp) {
const bool zeroit
= (varp->attrFileDescr() // Zero so we don't do file IO if never $fopen

18
test_regress/t/t_array_event.py Executable file
View File

@ -0,0 +1,18 @@
#!/usr/bin/env python3
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of either the GNU Lesser General Public License Version 3
# or the Perl Artistic License Version 2.0.
# SPDX-FileCopyrightText: 2026 Wilson Snyder
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
import vltest_bootstrap
test.scenarios('simulator')
test.compile(verilator_flags2=['--binary'])
test.execute()
test.passes()

View File

@ -0,0 +1,55 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain.
// SPDX-FileCopyrightText: 2026 Wilson Snyder
// SPDX-License-Identifier: CC0-1.0
class Foo;
event write_events[int];
function void add_event(int index, event in);
write_events[index] = in;
endfunction
task trigger_event(int index);
->write_events[index];
endtask
function void delete_event(int index);
write_events.delete(index);
endfunction
endclass
class Bar;
Foo foo;
event baz;
function new(Foo foo);
this.foo = foo;
endfunction
task go();
foo.add_event(3, baz);
@baz;
$display("got here");
foo.delete_event(3);
endtask
endclass
module top;
Bar bar;
Foo foo;
initial begin
foo = new();
bar = new(foo);
bar.go();
end
initial begin
#10;
foo.trigger_event(3);
$finish;
end
endmodule