diff --git a/parse.y b/parse.y index cc99dee27..5186edf3b 100644 --- a/parse.y +++ b/parse.y @@ -819,12 +819,14 @@ class_declaration_endlabel_opt class_declaration_extends_opt /* IEEE1800-2005: A.1.2 */ : K_extends TYPE_IDENTIFIER - { $$.type = $2.type; + { pform_set_type_referenced(@2, $2.text); + $$.type = $2.type; $$.exprs= 0; delete[]$2.text; } | K_extends TYPE_IDENTIFIER '(' expression_list_with_nuls ')' - { $$.type = $2.type; + { pform_set_type_referenced(@2, $2.text); + $$.type = $2.type; $$.exprs = $4; delete[]$2.text; } @@ -1106,7 +1108,8 @@ data_type /* IEEE1800-2005: A.2.2.1 */ $$ = tmp; } | TYPE_IDENTIFIER dimensions_opt - { if ($2) { + { pform_set_type_referenced(@1, $1.text); + if ($2) { parray_type_t*tmp = new parray_type_t($1.type, $2); FILE_NAME(tmp, @1); $$ = tmp; @@ -1990,7 +1993,8 @@ simple_type_or_string /* IEEE1800-2005: A.2.2.1 */ $$ = tmp; } | TYPE_IDENTIFIER - { $$ = $1.type; + { pform_set_type_referenced(@1, $1.text); + $$ = $1.type; delete[]$1.text; } | PACKAGE_IDENTIFIER K_SCOPE_RES @@ -3561,7 +3565,8 @@ expr_primary_or_typename /* There are a few special cases (notably $bits argument) where the expression may be a type name. Let the elaborator sort this out. */ | TYPE_IDENTIFIER - { PETypename*tmp = new PETypename($1.type); + { pform_set_type_referenced(@1, $1.text); + PETypename*tmp = new PETypename($1.type); FILE_NAME(tmp,@1); $$ = tmp; delete[]$1.text; @@ -5320,7 +5325,8 @@ param_type param_active_type = IVL_VT_BOOL; } | TYPE_IDENTIFIER - { pform_set_param_from_type(@1, $1.type, $1.text, param_active_range, + { pform_set_type_referenced(@1, $1.text); + pform_set_param_from_type(@1, $1.type, $1.text, param_active_range, param_active_signed, param_active_type); delete[]$1.text; } diff --git a/pform.cc b/pform.cc index 18f829476..df407724c 100644 --- a/pform.cc +++ b/pform.cc @@ -464,7 +464,7 @@ static void add_local_symbol(LexicalScope*scope, perm_string name, PNamedItem*it } static PPackage*find_potential_import(const struct vlltype&loc, LexicalScope*scope, - perm_string name, PNamedItem::SymbolType st) + perm_string name, bool make_explicit) { assert(scope); @@ -475,10 +475,7 @@ static PPackage*find_potential_import(const struct vlltype&loc, LexicalScope*sco map::const_iterator cur_sym = search_pkg->local_symbols.find(name); if (cur_sym != search_pkg->local_symbols.end()) { - if (st != PNamedItem::ANY && st != cur_sym->second->symbol_type()) - continue; - - if (found_pkg) { + if (found_pkg && make_explicit) { cerr << loc.get_fileline() << ": error: " "Ambiguous use of '" << name << "'. " "It is exported by both '" @@ -489,7 +486,8 @@ static PPackage*find_potential_import(const struct vlltype&loc, LexicalScope*sco error_count += 1; } else { found_pkg = search_pkg; - scope->explicit_imports[name] = found_pkg; + if (make_explicit) + scope->explicit_imports[name] = found_pkg; } } } @@ -504,7 +502,7 @@ static void check_potential_imports(const struct vlltype&loc, perm_string name) return; if (scope->explicit_imports.find(name) != scope->explicit_imports.end()) return; - if (find_potential_import(loc, scope, name, PNamedItem::ANY)) + if (find_potential_import(loc, scope, name, true)) return; scope = scope->parent_scope(); @@ -858,6 +856,12 @@ void pform_set_typedef(perm_string name, data_type_t*data_type, std::listtypedefs.end()) return cur->second; - PPackage*pkg = find_potential_import(loc, cur_scope, name, PNamedItem::TYPE); + PPackage*pkg = find_potential_import(loc, cur_scope, name, false); if (pkg) { cur = pkg->typedefs.find(name); if (cur != cur_scope->typedefs.end()) return cur->second; + + // Not a type. Give up. + return 0; } cur_scope = cur_scope->parent_scope(); diff --git a/pform.h b/pform.h index bf1cd629e..18d514d85 100644 --- a/pform.h +++ b/pform.h @@ -314,6 +314,8 @@ extern PGenerate* pform_parent_generate(void); extern void pform_set_typedef(perm_string name, data_type_t*data_type, std::list*unp_ranges); +extern void pform_set_type_referenced(const struct vlltype&loc, const char*name); + /* * This function makes a PECallFunction of the named function. */