Commit 1454a5ba by Richard Stallman

(yylex): Convert real decimal constants directly to the precision specified by…

(yylex): Convert real decimal constants directly to the precision specified by the letter at the end of the number.

(yylex): Convert real decimal constants directly
to the precision specified by the letter at the end of the number.
Pass mode arg to REAL_VALUE_ATOF to specify precision.
Move the "out of range of double" error check.

From-SVN: r3936
parent ee7e5441
...@@ -1398,36 +1398,27 @@ yylex () ...@@ -1398,36 +1398,27 @@ yylex ()
else else
{ {
set_float_handler (handler); set_float_handler (handler);
value = REAL_VALUE_ATOF (token_buffer);
set_float_handler (NULL_PTR); /* The second argument, machine_mode, of REAL_VALUE_ATOF tells the
} desired precision of the binary result of decimal-to-binary conversion. */
#ifdef ERANGE
if (errno == ERANGE && !flag_traditional && pedantic)
{
/* ERANGE is also reported for underflow,
so test the value to distinguish overflow from that. */
if (REAL_VALUES_LESS (dconst1, value)
|| REAL_VALUES_LESS (value, dconstm1))
{
pedwarn ("floating point number exceeds range of `double'");
exceeds_double = 1;
}
}
#endif
/* Read the suffixes to choose a data type. */ /* Read the suffixes to choose a data type. */
switch (c) switch (c)
{ {
case 'f': case 'F': case 'f': case 'F':
type = float_type_node; type = float_type_node;
value = REAL_VALUE_TRUNCATE (TYPE_MODE (type), value); value = REAL_VALUE_ATOF (token_buffer, TYPE_MODE (type));
if (REAL_VALUE_ISINF (value) && ! exceeds_double && pedantic) if (REAL_VALUE_ISINF (value) && pedantic)
pedwarn ("floating point number exceeds range of `float'"); pedwarn ("floating point number exceeds range of `float'");
garbage_chars = -1; garbage_chars = -1;
break; break;
case 'l': case 'L': case 'l': case 'L':
type = long_double_type_node; type = long_double_type_node;
value = REAL_VALUE_ATOF (token_buffer, TYPE_MODE (type));
if (REAL_VALUE_ISINF (value) && pedantic)
pedwarn (
"floating point number exceeds range of `long double'");
garbage_chars = -1; garbage_chars = -1;
break; break;
...@@ -1436,7 +1427,28 @@ yylex () ...@@ -1436,7 +1427,28 @@ yylex ()
error ("more than one `i' or `j' in numeric constant"); error ("more than one `i' or `j' in numeric constant");
imag = 1; imag = 1;
garbage_chars = -1; garbage_chars = -1;
break;
default:
value = REAL_VALUE_ATOF (token_buffer, TYPE_MODE (type));
if (REAL_VALUE_ISINF (value) && pedantic)
pedwarn ("floating point number exceeds range of `double'");
} }
set_float_handler (NULL_PTR);
}
#ifdef ERANGE
if (errno == ERANGE && !flag_traditional && pedantic)
{
/* ERANGE is also reported for underflow,
so test the value to distinguish overflow from that. */
if (REAL_VALUES_LESS (dconst1, value)
|| REAL_VALUES_LESS (value, dconstm1))
{
pedwarn ("floating point number exceeds range of `double'");
exceeds_double = 1;
}
}
#endif
/* Note: garbage_chars is -1 if first char is *not* garbage. */ /* Note: garbage_chars is -1 if first char is *not* garbage. */
while (isalnum (c) || c == '.' || c == '_' while (isalnum (c) || c == '.' || c == '_'
|| (!flag_traditional && (c == '+' || c == '-') || (!flag_traditional && (c == '+' || c == '-')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment