From 344586dfa23962b3275b74e9ef214423fc6397f6 Mon Sep 17 00:00:00 2001 From: Matthew Ballance Date: Mon, 2 Mar 2026 03:23:07 +0000 Subject: [PATCH] Fix: move removeStd() to after V3LinkParse V3LinkParse's visit(AstCovergroup) creates std:: references and calls setUsesStdPackage(). The previous removeStd() call happened before V3LinkParse ran, so it deleted the std package before those references were created, causing: %Error: Package/class for ':: reference' not found: 'std' Move removeStd() to immediately after V3LinkParse::linkParse() inside process() so the std package is only pruned after all parse-time transformations have had a chance to declare their std:: usage. Fixes test failures: - t_covergroup_option - t_covergroup_with_sample_args_too_many_bad Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/Verilator.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Verilator.cpp b/src/Verilator.cpp index 61169eee3..9e7ebe3ed 100644 --- a/src/Verilator.cpp +++ b/src/Verilator.cpp @@ -155,7 +155,10 @@ static void process() { } // Convert parseref's to varrefs, and other directly post parsing fixups + // Note: must run before removeStd() as it may create std:: references (e.g. covergroups) V3LinkParse::linkParse(v3Global.rootp()); + // Remove std package if unused (must be after V3LinkParse which may set usesStdPackage) + v3Global.removeStd(); // Cross-link signal names // Cross-link dotted hierarchical references V3LinkDot::linkDotPrimary(v3Global.rootp()); @@ -731,7 +734,6 @@ static bool verilate(const string& argString) { // Read first filename v3Global.readFiles(); - v3Global.removeStd(); // Link, etc, if needed if (!v3Global.opt.preprocOnly()) { //