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>
This commit is contained in:
Matthew Ballance 2026-03-02 03:23:07 +00:00
parent 68df201260
commit 344586dfa2
1 changed files with 3 additions and 1 deletions

View File

@ -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()) { //