mirror of
https://github.com/verilator/verilator.git
synced 2026-09-01 10:27:04 +02:00
Fix non-member identifiers used inside constraints (#7033)
This commit is contained in:
+8
-8
@@ -291,8 +291,6 @@ class RandomizeMarkVisitor final : public VNVisitor {
|
||||
targetClassp->foreachMember([&](AstClass* const, AstConstraint* const existingConstrp) {
|
||||
if (existingConstrp->name() == newName) {
|
||||
// Multiple paths lead to same constraint - unsupported pattern
|
||||
std::string fullPath = rootVarRefp->name();
|
||||
for (AstVar* pathVar : newPath) { fullPath += "." + pathVar->name(); }
|
||||
isDuplicate = true;
|
||||
}
|
||||
});
|
||||
@@ -301,12 +299,14 @@ class RandomizeMarkVisitor final : public VNVisitor {
|
||||
AstConstraint* const cloneConstrp = constrp->cloneTree(false);
|
||||
cloneConstrp->name(newName);
|
||||
cloneConstrp->foreach([&](AstVarRef* varRefp) {
|
||||
AstNodeExpr* const chainp = buildMemberSelChain(rootVarRefp, newPath);
|
||||
AstMemberSel* const finalSelp
|
||||
= new AstMemberSel{varRefp->fileline(), chainp, varRefp->varp()};
|
||||
finalSelp->user2p(m_classp);
|
||||
varRefp->replaceWith(finalSelp);
|
||||
VL_DO_DANGLING(varRefp->deleteTree(), varRefp);
|
||||
if (varRefp->varp()->isClassMember()) {
|
||||
AstNodeExpr* const chainp = buildMemberSelChain(rootVarRefp, newPath);
|
||||
AstMemberSel* const finalSelp
|
||||
= new AstMemberSel{varRefp->fileline(), chainp, varRefp->varp()};
|
||||
finalSelp->user2p(m_classp);
|
||||
varRefp->replaceWith(finalSelp);
|
||||
VL_DO_DANGLING(varRefp->deleteTree(), varRefp);
|
||||
}
|
||||
});
|
||||
|
||||
// Add constraint directly to the target class
|
||||
|
||||
Reference in New Issue
Block a user