Fix for GitHub issue #130 part 1 - null dereference when assigning int to enum.

(cherry picked from commit 002f118bb5)
This commit is contained in:
Martin Whitaker 2016-11-25 21:53:35 +00:00
parent ce88deaa97
commit 19d8f43e9b
1 changed files with 10 additions and 5 deletions

View File

@ -2717,11 +2717,16 @@ NetProc* PAssign::elaborate(Design*des, NetScope*scope) const
return bl; return bl;
} }
if (lv->enumeration() && if (lv->enumeration()) {
! lv->enumeration()->matches(rv->enumeration())) { if (! rv->enumeration()) {
cerr << get_fileline() << ": error: " cerr << get_fileline() << ": error: "
<< "Enumeration type mismatch in assignment." << endl; "This assignment requires an explicit cast." << endl;
des->errors += 1; 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); NetAssign*cur = new NetAssign(lv, rv);