Add error on static virtual functions (#7932)

This commit is contained in:
Igor Zaworski 2026-07-14 14:12:26 +02:00 committed by GitHub
parent 3afb7e1a21
commit 3b43b304a3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 35 additions and 0 deletions

View File

@ -1740,6 +1740,10 @@ class TaskVisitor final : public VNVisitor {
<< nodep->prettyNameQ()); << nodep->prettyNameQ());
} }
if (nodep->isStatic() && nodep->isVirtual()) {
nodep->v3error("Static methods cannot be virtual");
}
const bool noInline = m_statep->ftaskNoInline(nodep); const bool noInline = m_statep->ftaskNoInline(nodep);
const bool needsNonInlineCFunc = m_statep->ftaskNeedsNonInlineCFunc(nodep); const bool needsNonInlineCFunc = m_statep->ftaskNeedsNonInlineCFunc(nodep);
// Warn if not inlining an impure ftask (unless method, recursive, // Warn if not inlining an impure ftask (unless method, recursive,

View File

@ -0,0 +1,6 @@
%Error: t/t_class_static_virtual_method_bad.v:8:23: Static methods cannot be virtual
: ... note: In instance '$unit.Foo'
8 | static virtual task foo(); endtask
| ^~~
... 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
#
# 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('linter')
test.lint(fails=True, expect_filename=test.golden_filename)
test.passes()

View File

@ -0,0 +1,9 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain.
// SPDX-FileCopyrightText: 2026 Antmicro
// SPDX-License-Identifier: CC0-1.0
class Foo;
static virtual task foo(); endtask
endclass