Only a literal constant size has to match the enumeration width.
This commit is contained in:
parent
4660e0bf2f
commit
cc9fcfd13d
|
|
@ -168,7 +168,7 @@ static void elaborate_scope_enumeration(Design*des, NetScope*scope,
|
||||||
assert(enum_type->range->size() == 1);
|
assert(enum_type->range->size() == 1);
|
||||||
pform_range_t&range = enum_type->range->front();
|
pform_range_t&range = enum_type->range->front();
|
||||||
NetExpr*msb_ex = elab_and_eval(des, scope, range.first, -1);
|
NetExpr*msb_ex = elab_and_eval(des, scope, range.first, -1);
|
||||||
NetExpr*lsb_ex = elab_and_eval(des, scope, range.second, -1);
|
NetExpr*lsb_ex = elab_and_eval(des, scope, range.second, -1);
|
||||||
|
|
||||||
long msb = 0;
|
long msb = 0;
|
||||||
rc_flag = eval_as_long(msb, msb_ex);
|
rc_flag = eval_as_long(msb, msb_ex);
|
||||||
|
|
@ -221,7 +221,8 @@ static void elaborate_scope_enumeration(Design*des, NetScope*scope,
|
||||||
if (val_const == 0) {
|
if (val_const == 0) {
|
||||||
cerr << use_enum->get_fileline()
|
cerr << use_enum->get_fileline()
|
||||||
<< ": error: Enumeration expression for "
|
<< ": error: Enumeration expression for "
|
||||||
<< cur->name <<" is not constant." << endl;
|
<< cur->name <<" is not an integral constant."
|
||||||
|
<< endl;
|
||||||
des->errors += 1;
|
des->errors += 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -237,18 +238,19 @@ static void elaborate_scope_enumeration(Design*des, NetScope*scope,
|
||||||
<< " can not have an undefined value." << endl;
|
<< " can not have an undefined value." << endl;
|
||||||
des->errors += 1;
|
des->errors += 1;
|
||||||
}
|
}
|
||||||
// If the constant has a defined width then it must match
|
// If the literal constant has a defined width then it
|
||||||
// the enumeration width. In strict mode unsized integers
|
// must match the enumeration width. In strict mode
|
||||||
// are incorrectly given a defined size of integer width so
|
// unsized integers are incorrectly given a defined size
|
||||||
// handle that. Unfortunately this allows 32'd0 to work
|
// of integer width so handle that. Unfortunately this
|
||||||
// just like 0 which is wrong.
|
// allows 32'd0 to work just like 0 which is wrong.
|
||||||
if (cur_value.has_len() &&
|
if (dynamic_cast<PENumber*>(cur->parm) &&
|
||||||
(cur_value.len() != enum_width) &&
|
cur_value.has_len() &&
|
||||||
(! gn_strict_expr_width_flag ||
|
(cur_value.len() != enum_width) &&
|
||||||
(cur_value.len() != integer_width))) {
|
(! gn_strict_expr_width_flag ||
|
||||||
|
(cur_value.len() != integer_width))) {
|
||||||
cerr << use_enum->get_fileline()
|
cerr << use_enum->get_fileline()
|
||||||
<< ": error: Enumeration name " << cur->name
|
<< ": error: Enumeration name " << cur->name
|
||||||
<< " has an incorrectly sized value." << endl;
|
<< " has an incorrectly sized constant." << endl;
|
||||||
des->errors += 1;
|
des->errors += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue