From 19d8f43e9b75f8ce31dba2a680a1362a1afb2939 Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Fri, 25 Nov 2016 21:53:35 +0000 Subject: [PATCH] Fix for GitHub issue #130 part 1 - null dereference when assigning int to enum. (cherry picked from commit 002f118bb5a55c19193ba761bc6a03966a4f8191) --- elaborate.cc | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/elaborate.cc b/elaborate.cc index f4f99f85f..f0b440f0c 100644 --- a/elaborate.cc +++ b/elaborate.cc @@ -2717,11 +2717,16 @@ NetProc* PAssign::elaborate(Design*des, NetScope*scope) const return bl; } - if (lv->enumeration() && - ! lv->enumeration()->matches(rv->enumeration())) { - cerr << get_fileline() << ": error: " - << "Enumeration type mismatch in assignment." << endl; - des->errors += 1; + if (lv->enumeration()) { + if (! rv->enumeration()) { + cerr << get_fileline() << ": error: " + "This assignment requires an explicit cast." << endl; + des->errors += 1; + } else if (! lv->enumeration()->matches(rv->enumeration())) { + cerr << get_fileline() << ": error: " + "Enumeration type mismatch in assignment." << endl; + des->errors += 1; + } } NetAssign*cur = new NetAssign(lv, rv);