diff --git a/pform.cc b/pform.cc index 56dcd0349..ecb81b721 100644 --- a/pform.cc +++ b/pform.cc @@ -567,6 +567,9 @@ PWire*pform_get_make_wire_in_scope(perm_string name, NetNet::Type net_type, NetN cur = new PWire(name, net_type, port_type, vt_type); pform_put_wire_in_scope(name, cur); } else { + // If this is a duplicate wire, the data type has already + // been set, then return NULL. + if (cur->get_data_type() != IVL_VT_NO_TYPE) return 0; bool rc = cur->set_wire_type(net_type); assert(rc); rc = cur->set_data_type(vt_type); @@ -3144,6 +3147,7 @@ template static void pform_set2_data_type(const struct vlltype&li, T*d } PWire*net = pform_get_make_wire_in_scope(name, net_type, NetNet::NOT_A_PORT, base_type); + assert(net); net->set_data_type(data_type); pform_bind_attributes(net->attributes, attr, true); } @@ -3160,9 +3164,14 @@ static void pform_set_enum(const struct vlltype&li, enum_type_t*enum_type, perm_string name, NetNet::Type net_type, std::list*attr) { - (void) li; // The line information is not currently needed. PWire*cur = pform_get_make_wire_in_scope(name, net_type, NetNet::NOT_A_PORT, enum_type->base_type); - assert(cur); + // 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; + } cur->set_signed(enum_type->signed_flag); diff --git a/pform_class_type.cc b/pform_class_type.cc index 44f0d3555..ec2f99de4 100644 --- a/pform_class_type.cc +++ b/pform_class_type.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012 Picture Elements, Inc. + * Copyright (c) 2012-2014 Picture Elements, Inc. * Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it @@ -25,6 +25,7 @@ static void pform_set_class_type(class_type_t*class_type, perm_string name, NetNet::Type net_type, list*attr) { PWire*net = pform_get_make_wire_in_scope(name, net_type, NetNet::NOT_A_PORT, IVL_VT_CLASS); + assert(net); net->set_data_type(class_type); pform_bind_attributes(net->attributes, attr, true); } diff --git a/pform_string_type.cc b/pform_string_type.cc index 4d1f1d2dc..50a7f4fce 100644 --- a/pform_string_type.cc +++ b/pform_string_type.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2013 Stephen Williams (steve@icarus.com) + * Copyright (c) 2012-2014 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -24,6 +24,7 @@ static void pform_set_string_type(const string_type_t*, perm_string name, NetNet::Type net_type, list*attr) { PWire*net = pform_get_make_wire_in_scope(name, net_type, NetNet::NOT_A_PORT, IVL_VT_STRING); + assert(net); pform_bind_attributes(net->attributes, attr, true); } diff --git a/pform_struct_type.cc b/pform_struct_type.cc index 4a4d91251..766fc77e3 100644 --- a/pform_struct_type.cc +++ b/pform_struct_type.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2012 Stephen Williams (steve@icarus.com) + * Copyright (c) 2011-2014 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -67,6 +67,7 @@ static void pform_set_packed_struct(struct_type_t*struct_type, perm_string name, ivl_variable_type_t base_type = struct_type->figure_packed_base_type(); PWire*net = pform_get_make_wire_in_scope(name, net_type, NetNet::NOT_A_PORT, base_type); + assert(net); net->set_data_type(struct_type); pform_bind_attributes(net->attributes, attr, true); } @@ -99,6 +100,7 @@ static void pform_makewire(const struct vlltype&li, ivl_variable_type_t base_type = struct_type->figure_packed_base_type(); PWire*cur = pform_get_make_wire_in_scope(name, NetNet::WIRE, ptype, base_type); + assert(cur); FILE_NAME(cur, li); cur->set_data_type(struct_type); }