Fix for crash when real value assigned to signed type parameter.

A declaration of the form "parameter signed a = 1.0" causes a
compiler crash. The standard is somewhat contradictory on what
type "a" should have, but testing with other compilers shows a
majority in favour of it being a real value.
This commit is contained in:
Martin Whitaker 2011-12-12 23:02:09 +00:00 committed by Cary R
parent 670efb38d9
commit 831b6d3ad6
1 changed files with 3 additions and 1 deletions

View File

@ -409,7 +409,7 @@ void NetScope::evaluate_parameter_logic_(Design*des, param_ref_t cur)
sure the type is set right. Note that if the parameter sure the type is set right. Note that if the parameter
doesn't have an explicit type or range, then it will get doesn't have an explicit type or range, then it will get
the signedness from the expression itself. */ the signedness from the expression itself. */
if ((*cur).second.signed_flag || range_flag) { if (range_flag) {
/* If we have a real value convert it to an integer. */ /* If we have a real value convert it to an integer. */
if(NetECReal*tmp = dynamic_cast<NetECReal*>(expr)) { if(NetECReal*tmp = dynamic_cast<NetECReal*>(expr)) {
verinum nval(tmp->value().as_long64(), (unsigned)lv_width); verinum nval(tmp->value().as_long64(), (unsigned)lv_width);
@ -419,6 +419,8 @@ void NetScope::evaluate_parameter_logic_(Design*des, param_ref_t cur)
} }
(*cur).second.val->cast_signed((*cur).second.signed_flag); (*cur).second.val->cast_signed((*cur).second.signed_flag);
} else if ((*cur).second.signed_flag) {
(*cur).second.val->cast_signed(true);
} }
// If there are no value ranges to test the value against, // If there are no value ranges to test the value against,