Skip to content

Commit

Permalink
Fix for br975 - assertion failure due to duplicate declaration of str…
Browse files Browse the repository at this point in the history
…uct var.

Added proper error handling for duplicate declarations of all variable
types.
  • Loading branch information
Martin Whitaker committed May 17, 2015
1 parent a479bd6 commit 578a254
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions pform.cc
Expand Up @@ -2422,7 +2422,10 @@ static PWire* pform_get_or_make_wire(const vlltype&li, perm_string name,
ivl_variable_type_t dtype)
{
PWire*cur = pform_get_wire_in_scope(name);
if (cur) {

// If the wire already exists but isn't yet fully defined,
// carry on adding details.
if (cur && cur->get_data_type() == IVL_VT_NO_TYPE) {
// If this is not implicit ("implicit" meaning we don't
// know what the type is yet) then set the type now.
if (type != NetNet::IMPLICIT) {
Expand All @@ -2440,6 +2443,18 @@ static PWire* pform_get_or_make_wire(const vlltype&li, perm_string name,
return cur;
}

// If the wire already exists and is fully defined, this
// must be a redeclaration. Start again with a new wire.
if (cur) {
LineInfo tloc;
FILE_NAME(&tloc, li);
cerr << tloc.get_fileline() << ": error: duplicate declaration "
"for net or variable '" << name << "' in '"
<< pform_cur_module.front()->mod_name() << "'." << endl;
error_count += 1;
delete cur;
}

cur = new PWire(name, type, ptype, dtype);
FILE_NAME(cur, li.text, li.first_line);

Expand Down Expand Up @@ -3224,18 +3239,12 @@ template <class T> static void pform_set2_data_type(const struct vlltype&li, T*d
}
}

static void pform_set_enum(const struct vlltype&li, enum_type_t*enum_type,
static void pform_set_enum(enum_type_t*enum_type,
perm_string name, NetNet::Type net_type,
std::list<named_pexpr_t>*attr)
{
PWire*cur = pform_get_make_wire_in_scope(name, net_type, NetNet::NOT_A_PORT, enum_type->base_type);
// A NULL is returned for a duplicate enumeration.
if (! cur) {
cerr << li.get_fileline() << ": error: Found duplicate "
<< "enumeration named " << name << "." << endl;
error_count += 1;
return;
}
assert(cur);

cur->set_signed(enum_type->signed_flag);

Expand Down Expand Up @@ -3273,7 +3282,7 @@ static void pform_set_enum(const struct vlltype&li, enum_type_t*enum_type,
for (list<perm_string>::iterator cur = names->begin()
; cur != names->end() ; ++ cur) {
perm_string txt = *cur;
pform_set_enum(li, enum_type, txt, net_type, attr);
pform_set_enum(enum_type, txt, net_type, attr);
}

}
Expand Down

0 comments on commit 578a254

Please sign in to comment.