Fix internal fault when cross-class calling with DPI (#6735) (#6742)

Signed-off-by: Matthew Ballance <[email protected]>
This commit is contained in:
Matthew Ballance
2025-12-02 22:05:59 -05:00
committed by GitHub
parent 9a1dba357e
commit 3fc70b61d0
4 changed files with 108 additions and 4 deletions
+12 -4
View File
@@ -1520,14 +1520,22 @@ class TaskVisitor final : public VNVisitor {
if (m_inNew) {
AstVar* varp = outvscp->varp();
varp->funcLocal(true);
// Create a new var that will be inside the lambda
AstVar* newvarp = varp->cloneTree(false);
newvarp->funcLocal(true);
// Replace all references so they point to the new var
lambdap->stmtsp()->foreachAndNext([varp, newvarp](AstVarRef* refp) {
if (refp->varp() == varp) refp->varp(newvarp);
// Create a new VarScope for the new variable
AstVarScope* const newvscp
= new AstVarScope{newvarp->fileline(), m_scopep, newvarp};
m_scopep->addVarsp(newvscp);
// Replace all references so they point to the new var and varscope
lambdap->stmtsp()->foreachAndNext([outvscp, newvscp](AstVarRef* refp) {
if (refp->varScopep() == outvscp) {
refp->varScopep(newvscp);
refp->varp(newvscp->varp());
}
});
// Add variable initialization