[#99211] Static virtual ftasks detection

Signed-off-by: Igor Zaworski <izaworski@antmicro.com>
This commit is contained in:
Igor Zaworski 2026-07-06 17:43:53 +02:00
parent dde8de0a0d
commit 6902c3ade5
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