mirror of
https://github.com/verilator/verilator.git
synced 2026-09-03 16:28:53 +02:00
With --Wpedantic, report forward typedefs that are unused.
This commit is contained in:
@@ -1089,6 +1089,12 @@ class LinkDotFindVisitor : public AstNVisitor {
|
||||
iterateChildren(nodep);
|
||||
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 {
|
||||
UASSERT_OBJ(m_curSymp, nodep, "Parameter type not under module/package/$unit");
|
||||
iterateChildren(nodep);
|
||||
@@ -1339,6 +1345,19 @@ private:
|
||||
// We're done with implicit gates
|
||||
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 {
|
||||
// Default: Just iterate
|
||||
iterateChildren(nodep);
|
||||
|
||||
@@ -382,13 +382,6 @@ private:
|
||||
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 {
|
||||
// FOREACH(array,loopvars,body)
|
||||
// -> BEGIN(declare vars, loopa=lowest; WHILE(loopa<=highest, ... body))
|
||||
|
||||
Reference in New Issue
Block a user