Fix virtual class inheritance (#7403) (#7405)

Fixes #7403.
This commit is contained in:
Nikolay Puzanov 2026-04-10 19:17:06 +03:00 committed by GitHub
parent 081ecbd095
commit a8f62703ab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 41 additions and 1 deletions

View File

@ -197,6 +197,7 @@ Nathan Graybeal
Nathan Kohagen
Nathan Myers
Nick Brereton
Nikolay Puzanov
Nolan Poe
Oleh Maksymenko
Patrick Stewart

View File

@ -3406,7 +3406,7 @@ class LinkDotResolveVisitor final : public VNVisitor {
if (!baseFuncp || !baseFuncp->pureVirtual()) continue;
const bool existsInDerived = foundp && !foundp->imported();
if (m_statep->forPrimary() && !existsInDerived
&& !derivedClassp->isInterfaceClass()) {
&& !derivedClassp->isInterfaceClass() && !derivedClassp->isVirtual()) {
derivedClassp->v3error(
"Class " << derivedClassp->prettyNameQ() << impOrExtends
<< baseClassp->prettyNameQ()

View File

@ -0,0 +1,16 @@
#!/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('vlt')
test.lint()
test.passes()

View File

@ -0,0 +1,23 @@
// 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
virtual class Base;
pure virtual function void f0();
endclass
virtual class Child extends Base;
pure virtual function void f1();
endclass
class Impl extends Child;
virtual function void f0();
endfunction
virtual function void f1();
endfunction
endclass
module t;
endmodule