With --Wpedantic, report forward typedefs that are unused.
This commit is contained in:
parent
926209706f
commit
dcde026bac
|
|
@ -1089,6 +1089,12 @@ class LinkDotFindVisitor : public AstNVisitor {
|
||||||
iterateChildren(nodep);
|
iterateChildren(nodep);
|
||||||
m_statep->insertSym(m_curSymp, nodep->name(), nodep, m_packagep);
|
m_statep->insertSym(m_curSymp, nodep->name(), nodep, m_packagep);
|
||||||
}
|
}
|
||||||
|
virtual void visit(AstTypedefFwd* nodep) VL_OVERRIDE {
|
||||||
|
UASSERT_OBJ(m_curSymp, nodep, "Typedef not under module/package/$unit");
|
||||||
|
iterateChildren(nodep);
|
||||||
|
// No need to insert, only the real typedef matters, but need to track for errors
|
||||||
|
nodep->user1p(m_curSymp);
|
||||||
|
}
|
||||||
virtual void visit(AstParamTypeDType* nodep) VL_OVERRIDE {
|
virtual void visit(AstParamTypeDType* nodep) VL_OVERRIDE {
|
||||||
UASSERT_OBJ(m_curSymp, nodep, "Parameter type not under module/package/$unit");
|
UASSERT_OBJ(m_curSymp, nodep, "Parameter type not under module/package/$unit");
|
||||||
iterateChildren(nodep);
|
iterateChildren(nodep);
|
||||||
|
|
@ -1339,6 +1345,19 @@ private:
|
||||||
// We're done with implicit gates
|
// We're done with implicit gates
|
||||||
VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep);
|
VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep);
|
||||||
}
|
}
|
||||||
|
virtual void visit(AstTypedefFwd* nodep) VL_OVERRIDE {
|
||||||
|
VSymEnt* foundp = m_statep->getNodeSym(nodep)->findIdFallback(nodep->name());
|
||||||
|
if (!foundp && v3Global.opt.pedantic()) {
|
||||||
|
// We only check it was ever really defined in pedantic mode, as it
|
||||||
|
// might have been in a header file referring to a module we never
|
||||||
|
// needed so there are false positives
|
||||||
|
nodep->v3error(
|
||||||
|
"Forward typedef unused or does not resolve to a data type (IEEE 1800-2017 6.18): "
|
||||||
|
<< nodep->prettyNameQ());
|
||||||
|
}
|
||||||
|
// We only needed the forward declaration in order to parse correctly.
|
||||||
|
VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep);
|
||||||
|
}
|
||||||
virtual void visit(AstNode* nodep) VL_OVERRIDE {
|
virtual void visit(AstNode* nodep) VL_OVERRIDE {
|
||||||
// Default: Just iterate
|
// Default: Just iterate
|
||||||
iterateChildren(nodep);
|
iterateChildren(nodep);
|
||||||
|
|
|
||||||
|
|
@ -382,13 +382,6 @@ private:
|
||||||
VL_DO_DANGLING(nodep->deleteTree(), nodep);
|
VL_DO_DANGLING(nodep->deleteTree(), nodep);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void visit(AstTypedefFwd* nodep) VL_OVERRIDE {
|
|
||||||
// We only needed the forward declaration in order to parse correctly.
|
|
||||||
// We won't even check it was ever really defined, as it might have been in a header
|
|
||||||
// file referring to a module we never needed
|
|
||||||
VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void visit(AstForeach* nodep) VL_OVERRIDE {
|
virtual void visit(AstForeach* nodep) VL_OVERRIDE {
|
||||||
// FOREACH(array,loopvars,body)
|
// FOREACH(array,loopvars,body)
|
||||||
// -> BEGIN(declare vars, loopa=lowest; WHILE(loopa<=highest, ... body))
|
// -> BEGIN(declare vars, loopa=lowest; WHILE(loopa<=highest, ... body))
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
%Error: t/t_typedef_unused_bad.v:9:9: Forward typedef unused or does not resolve to a data type (IEEE 1800-2017 6.18): 'fwd_undecl_t'
|
||||||
|
typedef fwd_undecl_t;
|
||||||
|
^~~~~~~~~~~~
|
||||||
|
%Error: Exiting due to
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
|
||||||
|
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||||
|
#
|
||||||
|
# Copyright 2003 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(linter => 1);
|
||||||
|
|
||||||
|
lint(
|
||||||
|
verilator_flags2 => ["--Wpedantic"],
|
||||||
|
fails => 1,
|
||||||
|
expect_filename => $Self->{golden_filename},
|
||||||
|
);
|
||||||
|
|
||||||
|
ok(1);
|
||||||
|
1;
|
||||||
|
|
@ -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, 2020 by Wilson Snyder.
|
||||||
|
// SPDX-License-Identifier: CC0-1.0
|
||||||
|
|
||||||
|
typedef logic ok_t;
|
||||||
|
|
||||||
|
typedef fwd_undecl_t;
|
||||||
Loading…
Reference in New Issue