Lint check for pure virtual in non-virtual class.

This commit is contained in:
Wilson Snyder 2020-11-27 19:53:04 -05:00
parent 123d1af29d
commit ed268805ce
5 changed files with 41 additions and 7 deletions

View File

@ -205,6 +205,15 @@ private:
nodep->virtRefDTypep(editOneDType(nodep->virtRefDTypep()));
nodep->virtRefDType2p(editOneDType(nodep->virtRefDType2p()));
}
virtual void visit(AstNodeFTask* nodep) override {
iterateChildren(nodep);
editDType(nodep);
if (nodep->classMethod() && nodep->pureVirtual() && VN_IS(m_modp, Class)
&& !VN_CAST(m_modp, Class)->isVirtual()) {
nodep->v3error(
"Illegal to have 'pure virtual' in non-virtual class (IEEE 1800-2017 8.21)");
}
}
virtual void visit(AstNodeVarRef* nodep) override {
iterateChildren(nodep);
editDType(nodep);

View File

@ -1,7 +0,0 @@
%Error-UNSUPPORTED: t/t_class_virtual_pure.v:8:22: Unsupported: 'virtual' class method
8 | pure virtual task hello();
| ^~~~~
%Error-UNSUPPORTED: t/t_class_virtual_pure.v:7:9: Unsupported: virtual class
7 | virtual class VC;
| ^~~~~
%Error: Exiting due to

View File

@ -0,0 +1,4 @@
%Error: t/t_class_virtual_pure_bad.v:8:22: Illegal to have 'pure virtual' in non-virtual class (IEEE 1800-2017 8.21)
8 | pure virtual task pure_task;
| ^~~~~~~~~
%Error: Exiting due to

View File

@ -0,0 +1,19 @@
#!/usr/bin/env perl
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2020 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
scenarios(vlt => 1);
lint(
fails => 1,
expect_filename => $Self->{golden_filename},
);
ok(1);
1;

View File

@ -0,0 +1,9 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain, for
// any use, without warranty, 2019 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0
class VBase;
pure virtual task pure_task;
endclass