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;
}
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);