From 19772cfe075a049ec51ab5940ed221f12fd683ea Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sun, 2 Aug 2026 12:29:58 -0700 Subject: [PATCH] Activate wildcard imports for implicit named port connections The LRM section 23.3.2.4 says that an implicit `.name` port connection is a reference that can make a name from a preceding wildcard package import visible. Currently `.name` creates its `PEIdent` directly and skips the package import reference bookkeeping, so the imported name can not be resolved. Allow `pform_new_ident()` to suppress implicit net creation and use it for `.name`. This keeps import activation, `PEIdent` construction, and source location handling in one place while preserving the existing behavior that prevents `.name` from creating an implicit net. Signed-off-by: Lars-Peter Clausen --- PExpr.cc | 5 +++-- PExpr.h | 3 ++- parse.y | 7 ++++--- pform.cc | 5 +++-- pform.h | 4 +++- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/PExpr.cc b/PExpr.cc index 7a88f8b07..ebb98449a 100644 --- a/PExpr.cc +++ b/PExpr.cc @@ -406,8 +406,9 @@ const verireal& PEFNumber::value() const return *value_; } -PEIdent::PEIdent(const pform_name_t&that, unsigned lexical_pos) -: path_(that), no_implicit_sig_(false) +PEIdent::PEIdent(const pform_name_t&that, unsigned lexical_pos, + bool no_implicit_sig) +: path_(that), no_implicit_sig_(no_implicit_sig) { LineInfo::lexical_pos(lexical_pos); } diff --git a/PExpr.h b/PExpr.h index 0bae3a2e1..931fd4b30 100644 --- a/PExpr.h +++ b/PExpr.h @@ -346,7 +346,8 @@ class PEIdent : public PExpr { public: explicit PEIdent(perm_string, unsigned lexical_pos, bool no_implicit_sig=false); explicit PEIdent(PPackage*pkg, const pform_name_t&name); - explicit PEIdent(const pform_name_t&, unsigned lexical_pos); + explicit PEIdent(const pform_name_t&, unsigned lexical_pos, + bool no_implicit_sig = false); ~PEIdent() override; // Add another name to the string of hierarchy that is the diff --git a/parse.y b/parse.y index 6270a5fa2..b31b49fde 100644 --- a/parse.y +++ b/parse.y @@ -6460,9 +6460,10 @@ port_name { pform_requires_sv(@3, "Implicit named port connections"); named_pexpr_t*tmp = new named_pexpr_t; FILE_NAME(tmp, @$); - tmp->name = lex_strings.make($3); - tmp->parm = new PEIdent(lex_strings.make($3), @3.lexical_pos, true); - FILE_NAME(tmp->parm, @3); + auto name = lex_strings.make($3); + pform_name_t path = { name_component_t(name) }; + tmp->name = name; + tmp->parm = pform_new_ident(@3, path, true); delete[]$3; delete $1; $$ = tmp; diff --git a/pform.cc b/pform.cc index 955a0651f..c04557c0f 100644 --- a/pform.cc +++ b/pform.cc @@ -737,12 +737,13 @@ PBlock* pform_push_block_scope(const struct vlltype&loc, const char*name, /* * Create a new identifier. */ -PEIdent* pform_new_ident(const struct vlltype&loc, const pform_name_t&name) +PEIdent *pform_new_ident(const struct vlltype&loc, const pform_name_t&name, + bool no_implicit_sig) { if (gn_system_verilog()) check_potential_imports(loc, name.front().name, false); - auto tmp = new PEIdent(name, loc.lexical_pos); + auto tmp = new PEIdent(name, loc.lexical_pos, no_implicit_sig); FILE_NAME(tmp, loc); return tmp; } diff --git a/pform.h b/pform.h index 02a719053..fb1e20d9b 100644 --- a/pform.h +++ b/pform.h @@ -236,7 +236,9 @@ extern void pform_add_modport_port(const struct vlltype&loc, * This creates an identifier aware of names that may have been * imported from other packages. */ -extern PEIdent* pform_new_ident(const struct vlltype&loc, const pform_name_t&name); +extern PEIdent *pform_new_ident(const struct vlltype&loc, + const pform_name_t&name, + bool no_implicit_sig = false); extern PTrigger* pform_new_trigger(const struct vlltype&loc, PPackage*pkg, const pform_name_t&name);