Fix segfault when modport variable is unresolved (#6386)

This commit is contained in:
Ryszard Rozak 2025-09-05 14:27:46 +02:00 committed by GitHub
parent a966e6aa13
commit 107f64e53b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 65 additions and 0 deletions

View File

@ -3916,6 +3916,15 @@ class LinkDotResolveVisitor final : public VNVisitor {
}
dotSymp = m_statep->findDotted(nodep->fileline(), dotSymp, nodep->dotted(), baddot,
okSymp, true); // Maybe nullptr
if (!dotSymp) {
nodep->v3error(
"Can't find definition of "
<< (!baddot.empty() ? AstNode::prettyNameQ(baddot) : nodep->prettyNameQ())
<< '\n'
<< nodep->warnContextPrimary());
return;
}
bool modport = false;
if (const AstVar* varp = VN_CAST(dotSymp->nodep(), Var)) {
if (const AstIfaceRefDType* const ifaceRefp

View File

@ -0,0 +1,5 @@
%Error: t/t_mod_interface_clocking_bad.v:25:10: Can't find definition of 'cb'
25 | x.cb.reset <= 1;
| ^~~~~
... See the manual at https://verilator.org/verilator_doc.html?v=latest for more assistance.
%Error: Exiting due to

View File

@ -0,0 +1,16 @@
#!/usr/bin/env python3
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2024 by Wilson Snyder. 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-License-Identifier: LGPL-3.0-only OR Artistic-2.0
import vltest_bootstrap
test.scenarios('simulator')
test.lint(fails=True, expect_filename=test.golden_filename)
test.passes()

View File

@ -0,0 +1,35 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain, for
// any use, without warranty, 2025 by Antmicro.
// SPDX-License-Identifier: CC0-1.0
interface mem_if (
input wire clk
);
logic reset;
clocking cb @(posedge clk);
output reset;
endclocking
modport mp(input clk);
endinterface
module sub (
mem_if.mp x
);
initial begin
x.cb.reset <= 1;
end
endmodule
module t ();
logic clk = 0;
mem_if m_if (clk);
sub i_sub (m_if);
endmodule