Add error on static virtual functions (#7932)
This commit is contained in:
parent
3afb7e1a21
commit
3b43b304a3
|
|
@ -1740,6 +1740,10 @@ class TaskVisitor final : public VNVisitor {
|
|||
<< nodep->prettyNameQ());
|
||||
}
|
||||
|
||||
if (nodep->isStatic() && nodep->isVirtual()) {
|
||||
nodep->v3error("Static methods cannot be virtual");
|
||||
}
|
||||
|
||||
const bool noInline = m_statep->ftaskNoInline(nodep);
|
||||
const bool needsNonInlineCFunc = m_statep->ftaskNeedsNonInlineCFunc(nodep);
|
||||
// Warn if not inlining an impure ftask (unless method, recursive,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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()
|
||||
|
|
@ -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
|
||||
Loading…
Reference in New Issue