From 9f8fcaf827c6a64cd3ece5481f74dc7973397fc9 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Fri, 29 Nov 2024 16:09:39 -0500 Subject: [PATCH] Fix linking types of typedefs --- src/V3AstNodes.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/V3AstNodes.cpp b/src/V3AstNodes.cpp index 324715d98..72c5689bc 100644 --- a/src/V3AstNodes.cpp +++ b/src/V3AstNodes.cpp @@ -2598,9 +2598,14 @@ void AstClassOrPackageRef::dump(std::ostream& str) const { void AstClassOrPackageRef::dumpJson(std::ostream& str) const { dumpJsonGen(str); } AstNodeModule* AstClassOrPackageRef::classOrPackagep() const { AstNode* foundp = m_classOrPackageNodep; - if (auto* const anodep = VN_CAST(foundp, Typedef)) foundp = anodep->subDTypep(); - if (auto* const anodep = VN_CAST(foundp, NodeDType)) foundp = anodep->skipRefp(); - if (auto* const anodep = VN_CAST(foundp, ClassRefDType)) foundp = anodep->classp(); + AstNode* lastp = nullptr; + while (foundp != lastp) { + lastp = foundp; + if (AstNodeDType* const anodep = VN_CAST(foundp, NodeDType)) foundp = anodep->skipRefp(); + if (AstTypedef* const anodep = VN_CAST(foundp, Typedef)) foundp = anodep->subDTypep(); + if (AstClassRefDType* const anodep = VN_CAST(foundp, ClassRefDType)) + foundp = anodep->classp(); + } return VN_CAST(foundp, NodeModule); }