From 439688fa461da2fbba77059d00a1dd1ab28fe68f Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Fri, 27 Sep 2019 21:29:50 +0100 Subject: [PATCH] Add anonymous enums to the scope local symbols. --- pform.cc | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/pform.cc b/pform.cc index fa44f4a28..0cd341133 100644 --- a/pform.cc +++ b/pform.cc @@ -787,6 +787,23 @@ static void pform_put_wire_in_scope(perm_string name, PWire*net) static void pform_put_enum_type_in_scope(enum_type_t*enum_set) { + if (lexical_scope->enum_sets.count(enum_set)) + return; + + set enum_names; + list::const_iterator cur; + for (cur = enum_set->names->begin(); cur != enum_set->names->end(); ++cur) { + if (enum_names.count(cur->name)) { + cerr << enum_set->get_fileline() << ": error: " + "Duplicate enumeration name '" + << cur->name << "'." << endl; + error_count += 1; + } else { + add_local_symbol(lexical_scope, cur->name, enum_set); + enum_names.insert(cur->name); + } + } + lexical_scope->enum_sets.insert(enum_set); } @@ -829,13 +846,8 @@ void pform_set_typedef(perm_string name, data_type_t*data_type, std::list(data_type)) { + if (enum_type_t*enum_type = dynamic_cast(data_type)) pform_put_enum_type_in_scope(enum_type); - - list::const_iterator cur; - for (cur = enum_type->names->begin(); cur != enum_type->names->end(); ++cur) - add_local_symbol(lexical_scope, cur->name, enum_type); - } } data_type_t* pform_test_type_identifier(const struct vlltype&loc, const char*txt)