float: fix bogus pass flags for errors and warnings

Formatting errors -- syntax errors -- are errors, no matter which pass
they end up in.  ERR_PASS1 is just plain crazy: if we end up with a
formatting error on the code-generation pass, we are in a world of
hurt.

Defer warnings to the code-generation pass; that's the pass which
matters value-wise, and that way we get the warnings in the list file,
too.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This commit is contained in:
H. Peter Anvin 2018-07-06 03:11:52 -07:00
parent c7c28357c8
commit af59af466a

View File

@ -182,7 +182,7 @@ static int32_t read_exponent(const char *string, int32_t max)
} else if (*string == '_') {
/* do nothing */
} else {
nasm_error(ERR_NONFATAL|ERR_PASS1,
nasm_error(ERR_NONFATAL,
"invalid character in floating-point constant %s: '%c'",
"exponent", *string);
return INT32_MAX;
@ -219,7 +219,7 @@ static bool ieee_flconvert(const char *string, fp_limb *mant,
if (!seendot) {
seendot = true;
} else {
nasm_error(ERR_NONFATAL|ERR_PASS1,
nasm_error(ERR_NONFATAL,
"too many periods in floating-point constant");
return false;
}
@ -234,7 +234,7 @@ static bool ieee_flconvert(const char *string, fp_limb *mant,
*p++ = *string - '0';
} else {
if (!warned) {
nasm_error(ERR_WARNING|ERR_WARN_FL_TOOLONG|ERR_PASS1,
nasm_error(ERR_WARNING|ERR_WARN_FL_TOOLONG|ERR_PASS2,
"floating-point constant significand contains "
"more than %i digits", MANT_DIGITS);
warned = true;
@ -247,7 +247,7 @@ static bool ieee_flconvert(const char *string, fp_limb *mant,
} else if (*string == '_') {
/* do nothing */
} else {
nasm_error(ERR_NONFATAL|ERR_PASS1,
nasm_error(ERR_NONFATAL|ERR_PASS2,
"invalid character in floating-point constant %s: '%c'",
"significand", *string);
return false;
@ -533,7 +533,7 @@ static bool ieee_flconvert_bin(const char *string, int bits,
if (!seendot)
seendot = true;
else {
nasm_error(ERR_NONFATAL|ERR_PASS1,
nasm_error(ERR_NONFATAL,
"too many periods in floating-point constant");
return false;
}
@ -575,7 +575,7 @@ static bool ieee_flconvert_bin(const char *string, int bits,
} else if (c == '_') {
/* ignore */
} else {
nasm_error(ERR_NONFATAL|ERR_PASS1,
nasm_error(ERR_NONFATAL,
"floating-point constant: `%c' is invalid character", c);
return false;
}
@ -675,7 +675,7 @@ static int to_packed_bcd(const char *str, const char *p,
int tv = -1;
if (fmt != &ieee_80) {
nasm_error(ERR_NONFATAL|ERR_PASS1,
nasm_error(ERR_NONFATAL,
"packed BCD requires an 80-bit format");
return 0;
}
@ -685,7 +685,7 @@ static int to_packed_bcd(const char *str, const char *p,
if (c >= '0' && c <= '9') {
if (tv < 0) {
if (n == 9) {
nasm_error(ERR_WARNING|ERR_PASS1,
nasm_error(ERR_WARNING|ERR_PASS2,
"packed BCD truncated to 18 digits");
}
tv = c-'0';
@ -698,7 +698,7 @@ static int to_packed_bcd(const char *str, const char *p,
} else if (c == '_') {
/* do nothing */
} else {
nasm_error(ERR_NONFATAL|ERR_PASS1,
nasm_error(ERR_NONFATAL,
"invalid character `%c' in packed BCD constant", c);
return 0;
}
@ -763,7 +763,7 @@ static int to_float(const char *str, int s, uint8_t *result,
type = FL_INFINITY;
break;
default:
nasm_error(ERR_NONFATAL|ERR_PASS1,
nasm_error(ERR_NONFATAL,
"internal error: unknown FP constant token `%s'\n", str);
type = FL_QNAN;
break;
@ -811,7 +811,7 @@ static int to_float(const char *str, int s, uint8_t *result,
type = FL_NORMAL;
} else if (exponent > 0) {
if (pass0 == 1)
nasm_error(ERR_WARNING|ERR_WARN_FL_OVERFLOW|ERR_PASS1,
nasm_error(ERR_WARNING|ERR_WARN_FL_OVERFLOW|ERR_PASS2,
"overflow in floating-point constant");
type = FL_INFINITY;
} else {
@ -846,11 +846,11 @@ static int to_float(const char *str, int s, uint8_t *result,
} else {
if (daz || is_zero(mant)) {
/* Flush denormals to zero */
nasm_error(ERR_WARNING|ERR_WARN_FL_UNDERFLOW|ERR_PASS1,
nasm_error(ERR_WARNING|ERR_WARN_FL_UNDERFLOW|ERR_PASS2,
"underflow in floating-point constant");
goto zero;
} else {
nasm_error(ERR_WARNING|ERR_WARN_FL_DENORM|ERR_PASS1,
nasm_error(ERR_WARNING|ERR_WARN_FL_DENORM|ERR_PASS2,
"denormal floating-point constant");
}
}
@ -866,7 +866,7 @@ static int to_float(const char *str, int s, uint8_t *result,
ieee_shr(mant, 1);
exponent++;
if (exponent >= (expmax << 1)-1) {
nasm_error(ERR_WARNING|ERR_WARN_FL_OVERFLOW|ERR_PASS1,
nasm_error(ERR_WARNING|ERR_WARN_FL_OVERFLOW|ERR_PASS2,
"overflow in floating-point constant");
type = FL_INFINITY;
goto overflow;