More refined check for enumeration width and constant width
This commit is contained in:
parent
2e8c4e3dbc
commit
2e9c4cde55
|
|
@ -221,7 +221,7 @@ 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 an integral constant."
|
<< cur->name <<" is not an integer constant."
|
||||||
<< endl;
|
<< endl;
|
||||||
des->errors += 1;
|
des->errors += 1;
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -238,20 +238,17 @@ 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 literal constant has a defined width then it
|
// If this is a literal constant and it has a defined
|
||||||
// must match the enumeration width. In strict mode
|
// width then the width must match the enumeration width.
|
||||||
// unsized integers are incorrectly given a defined size
|
if (PENumber *tmp = dynamic_cast<PENumber*>(cur->parm)) {
|
||||||
// of integer width so handle that. Unfortunately this
|
if (tmp->value().has_len() &&
|
||||||
// allows 32'd0 to work just like 0 which is wrong.
|
(tmp->value().len() != enum_width)) {
|
||||||
if (dynamic_cast<PENumber*>(cur->parm) &&
|
cerr << use_enum->get_fileline()
|
||||||
cur_value.has_len() &&
|
<< ": error: Enumeration name " << cur->name
|
||||||
(cur_value.len() != enum_width) &&
|
<< " has an incorrectly sized constant."
|
||||||
(! gn_strict_expr_width_flag ||
|
<< endl;
|
||||||
(cur_value.len() != integer_width))) {
|
des->errors += 1;
|
||||||
cerr << use_enum->get_fileline()
|
}
|
||||||
<< ": error: Enumeration name " << cur->name
|
|
||||||
<< " has an incorrectly sized constant." << endl;
|
|
||||||
des->errors += 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we are padding/truncating a negative value for an
|
// If we are padding/truncating a negative value for an
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue