From Matt Thomas, suggested upstream:
* atof-generic.c (atof_generic): recognize snan and qnan in addition to nan and inf. * atof-vax.c (flonum_gen2vax): deal properly with nan, snan, qnan, and +Inf and -Inf codes. This fixes PR toolchain/43303.
This commit is contained in:
parent
120678dcc8
commit
5a6d00fa0a
26
external/gpl3/binutils/dist/gas/atof-generic.c
vendored
26
external/gpl3/binutils/dist/gas/atof-generic.c
vendored
@ -121,6 +121,32 @@ atof_generic (/* return pointer to just AFTER number we read. */
|
||||
|
||||
switch (first_digit[0])
|
||||
{
|
||||
case 's':
|
||||
case 'S':
|
||||
if (!strncasecmp ("snan", first_digit, 4))
|
||||
{
|
||||
address_of_generic_floating_point_number->sign = 0;
|
||||
address_of_generic_floating_point_number->exponent = 0;
|
||||
address_of_generic_floating_point_number->leader =
|
||||
address_of_generic_floating_point_number->low;
|
||||
*address_of_string_pointer = first_digit + 4;
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'q':
|
||||
case 'Q':
|
||||
if (!strncasecmp ("qnan", first_digit, 4))
|
||||
{
|
||||
address_of_generic_floating_point_number->sign = 0;
|
||||
address_of_generic_floating_point_number->exponent = 0;
|
||||
address_of_generic_floating_point_number->leader =
|
||||
address_of_generic_floating_point_number->low;
|
||||
*address_of_string_pointer = first_digit + 4;
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
case 'N':
|
||||
if (!strncasecmp ("nan", first_digit, 3))
|
||||
|
@ -268,10 +268,27 @@ flonum_gen2vax (int format_letter, /* One of 'd' 'f' 'g' 'h'. */
|
||||
int exponent_skippage;
|
||||
LITTLENUM_TYPE word1;
|
||||
|
||||
/* JF: Deal with new Nan, +Inf and -Inf codes. */
|
||||
if (f->sign != '-' && f->sign != '+')
|
||||
{
|
||||
make_invalid_floating_point_number (words);
|
||||
if (f->sign == 0)
|
||||
{
|
||||
/* All NaNs are 0. */
|
||||
memset (words, 0x00, sizeof (LITTLENUM_TYPE) * precision);
|
||||
}
|
||||
else if (f->sign == 'P')
|
||||
{
|
||||
/* Positive Infinity. */
|
||||
memset (words, 0xff, sizeof (LITTLENUM_TYPE) * precision);
|
||||
words[0] &= 0x7fff;
|
||||
}
|
||||
else if (f->sign == 'N')
|
||||
{
|
||||
/* Negative Infinity. */
|
||||
memset (words, 0x00, sizeof (LITTLENUM_TYPE) * precision);
|
||||
words[0] = 0x0080;
|
||||
}
|
||||
else
|
||||
make_invalid_floating_point_number (words);
|
||||
return return_value;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user