mirror of
https://github.com/verilator/verilator.git
synced 2026-10-06 10:03:44 +02:00
Fix passing typedef value as parameter (#6543)
This commit is contained in:
@@ -62,6 +62,7 @@
|
||||
|
||||
#include <cctype>
|
||||
#include <deque>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
@@ -1265,6 +1266,7 @@ public:
|
||||
class ParamVisitor final : public VNVisitor {
|
||||
// NODE STATE
|
||||
// AstNodeModule::user1 -> bool: already fixed level (temporary)
|
||||
// AstNodeDType::user2 -> bool: already visited from typedef
|
||||
|
||||
// STATE - across all visitors
|
||||
ParamState& m_state; // Common state
|
||||
@@ -1279,6 +1281,8 @@ class ParamVisitor final : public VNVisitor {
|
||||
// STATE - for current visit position (use VL_RESTORER)
|
||||
AstNodeModule* m_modp; // Module iterating
|
||||
string m_generateHierName; // Generate portion of hierarchy name
|
||||
std::map<const AstRefDType*, bool>
|
||||
m_isCircularTypeCache; // Caches return values of `V3Width::isCircularType` calls
|
||||
|
||||
// METHODS
|
||||
|
||||
@@ -1413,6 +1417,25 @@ class ParamVisitor final : public VNVisitor {
|
||||
processWorkQ();
|
||||
}
|
||||
}
|
||||
void visit(AstRefDType* nodep) override {
|
||||
const auto iter = m_isCircularTypeCache.find(nodep);
|
||||
bool isCircular;
|
||||
if (iter != m_isCircularTypeCache.end()) {
|
||||
isCircular = iter->second;
|
||||
} else {
|
||||
isCircular = V3Width::isCircularType(nodep);
|
||||
m_isCircularTypeCache.emplace(nodep, isCircular);
|
||||
}
|
||||
if (isCircular) {
|
||||
nodep->v3error("Typedef's type is circular: " << nodep->prettyName());
|
||||
} else if (nodep->typedefp() && nodep->subDTypep()
|
||||
&& (VN_IS(nodep->subDTypep()->skipRefOrNullp(), IfaceRefDType)
|
||||
|| VN_IS(nodep->subDTypep()->skipRefOrNullp(), ClassRefDType))
|
||||
&& !nodep->skipRefp()->user2SetOnce()) {
|
||||
iterate(nodep->skipRefp());
|
||||
}
|
||||
iterateChildren(nodep);
|
||||
}
|
||||
void visit(AstCell* nodep) override {
|
||||
checkParamNotHier(nodep->paramsp());
|
||||
visitCellOrClassRef(nodep, VN_IS(nodep->modp(), Iface));
|
||||
|
||||
Reference in New Issue
Block a user