Fix rand fields of reference types (#4627)

This commit is contained in:
Ryszard Rozak
2023-10-26 17:17:23 -04:00
committed by GitHub
parent 98252634fc
commit 64af83161a
3 changed files with 34 additions and 7 deletions
+3 -2
View File
@@ -55,7 +55,8 @@ private:
for (auto* memberp = classp->stmtsp(); memberp; memberp = memberp->nextp()) {
// If member is rand and of class type, mark its class
if (VN_IS(memberp, Var) && VN_AS(memberp, Var)->isRand()) {
if (const auto* const classRefp = VN_CAST(memberp->dtypep(), ClassRefDType)) {
if (const auto* const classRefp
= VN_CAST(memberp->dtypep()->skipRefp(), ClassRefDType)) {
auto* const rclassp = classRefp->classp();
if (!rclassp->user1()) {
rclassp->user1(true);
@@ -100,7 +101,7 @@ private:
iterateChildrenConst(nodep);
if (nodep->name() != "randomize") return;
if (const AstClassRefDType* const classRefp
= VN_CAST(nodep->fromp()->dtypep(), ClassRefDType)) {
= VN_CAST(nodep->fromp()->dtypep()->skipRefp(), ClassRefDType)) {
AstClass* const classp = classRefp->classp();
classp->user1(true);
markMembers(classp);