Record the actual data type when a module port has an enum type.

This fixes assignment compatibility problems (issue #498).
This commit is contained in:
Martin Whitaker 2021-04-28 20:18:04 +01:00
parent a7cb93842e
commit cf0bf4d9aa
1 changed files with 6 additions and 2 deletions

View File

@ -2571,6 +2571,7 @@ void pform_module_define_port(const struct vlltype&li,
bool keep_attr)
{
struct_type_t*struct_type = 0;
enum_type_t*enum_type = 0;
ivl_variable_type_t data_type = IVL_VT_NO_TYPE;
bool signed_flag = false;
@ -2623,10 +2624,10 @@ void pform_module_define_port(const struct vlltype&li,
signed_flag = false;
prange = 0;
} else if (enum_type_t*enum_type = dynamic_cast<enum_type_t*>(vtype)) {
} else if ((enum_type = dynamic_cast<enum_type_t*>(vtype))) {
data_type = enum_type->base_type;
signed_flag = enum_type->signed_flag;
prange = enum_type->range.get();
prange = 0;
} else if (vtype) {
VLerror(li, "sorry: Given type %s not supported here (%s:%d).",
@ -2646,6 +2647,9 @@ void pform_module_define_port(const struct vlltype&li,
if (struct_type) {
cur->set_data_type(struct_type);
} else if (enum_type) {
cur->set_data_type(enum_type);
} else if (prange == 0) {
cur->set_range_scalar((type == NetNet::IMPLICIT) ? SR_PORT : SR_BOTH);