From cf0bf4d9aa84f75aa628ecdfe10a814699a232e4 Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Wed, 28 Apr 2021 20:18:04 +0100 Subject: [PATCH] Record the actual data type when a module port has an enum type. This fixes assignment compatibility problems (issue #498). --- pform.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pform.cc b/pform.cc index dc0b84582..34cd4042b 100644 --- a/pform.cc +++ b/pform.cc @@ -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(vtype)) { + } else if ((enum_type = dynamic_cast(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);