From 3c05eef21665a7ee10cf4a4a168adb96deb87063 Mon Sep 17 00:00:00 2001 From: Geza Lore Date: Mon, 21 Sep 2026 01:47:04 +0200 Subject: [PATCH] Fix losing coverage declarations if first in a module body (#8425) --- src/V3CCtors.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/V3CCtors.cpp b/src/V3CCtors.cpp index 27e36a933..f0b3f5196 100644 --- a/src/V3CCtors.cpp +++ b/src/V3CCtors.cpp @@ -167,12 +167,12 @@ class CCtorsVisitor final : public VNVisitor { if (v3Global.opt.coverage()) { V3CCtorsBuilder configure_coverage{nodep, "_configure_coverage", VCtorType::COVERAGE}; - for (AstNode* np = nodep->stmtsp(); np; np = np->nextp()) { + for (AstNode *np = nodep->stmtsp(), *nextp; np; np = nextp) { + nextp = np->nextp(); if (AstNodeCoverDecl* const coverp = VN_CAST(np, NodeCoverDecl)) { // ... else we don't have a static VlSym to be able to coverage insert UASSERT_OBJ(!VN_IS(nodep, Class), coverp, "NodeCoverDecl should be in class's package, not class itself"); - np = coverp->backp(); configure_coverage.add(coverp->unlinkFrBack()); } }