Fix MODDUP with duplicate packages to take first package (#6222).

This commit is contained in:
Wilson Snyder
2025-07-28 01:45:03 -04:00
parent 47c5b220b3
commit e69df457fd
6 changed files with 67 additions and 11 deletions
+4 -8
View File
@@ -628,20 +628,16 @@ class LinkCellsVisitor final : public VNVisitor {
if (!(libFoundp->fileline()->warnIsOff(V3ErrorCode::MODDUP)
|| nodep->fileline()->warnIsOff(V3ErrorCode::MODDUP)
|| hierBlocks.find(nodep->name()) != hierBlocks.end())) {
nodep->v3warn(MODDUP, "Duplicate declaration of module: "
nodep->v3warn(MODDUP, "Duplicate declaration of "
<< nodep->verilogKwd() << ": "
<< nodep->prettyNameQ() << '\n'
<< nodep->warnContextPrimary() << '\n'
<< libFoundp->warnOther()
<< "... Location of original declaration\n"
<< libFoundp->warnContextSecondary());
}
if (VN_IS(nodep, Package)) {
// Packages may be imported, we instead rename to be unique
nodep->name(nodep->name() + "__Vdedup" + cvtToStr(m_dedupNum++));
} else {
nodep->unlinkFrBack();
VL_DO_DANGLING(pushDeletep(nodep), nodep);
}
nodep->unlinkFrBack();
VL_DO_DANGLING(pushDeletep(nodep), nodep);
} else if (!libFoundp && globalFoundp && globalFoundp != nodep) {
// ...__LIB__ stripped by prettyName
const string newName = nodep->libname() + "__LIB__" + nodep->origName();