From 103f1fa4bb8fb9688f6dfb0a8162f6bc2975e2fa Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Fri, 20 Nov 2020 17:01:15 +0000 Subject: [PATCH] Add enumeration assignment compatibility check for continuous assignments. (cherry picked from commit 1b3f0dd689092d69f7a7407a7f2b311c3365825e) --- elaborate.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/elaborate.cc b/elaborate.cc index 81d4174b2..ae3345cde 100644 --- a/elaborate.cc +++ b/elaborate.cc @@ -110,6 +110,18 @@ void PGAssign::elaborate(Design*des, NetScope*scope) const return; } + if (lval->enumeration()) { + if (! rval_expr->enumeration()) { + cerr << get_fileline() << ": error: " + "This assignment requires an explicit cast." << endl; + des->errors += 1; + } else if (! lval->enumeration()->matches(rval_expr->enumeration())) { + cerr << get_fileline() << ": error: " + "Enumeration type mismatch in assignment." << endl; + des->errors += 1; + } + } + NetNet*rval = rval_expr->synthesize(des, scope, rval_expr); if (rval == 0) {