(yylex): Diagnose 1.0fl'. Issue just one diagnostic for 1e1000000f'.

From-SVN: r1685
This commit is contained in:
Richard Stallman 1992-07-25 08:18:47 +00:00
parent 9282f2f99b
commit 63ea33ce94

View File

@ -1313,8 +1313,7 @@ yylex ()
if (floatflag != NOT_FLOAT) if (floatflag != NOT_FLOAT)
{ {
tree type = double_type_node; tree type = double_type_node;
char f_seen = 0; int garbage_chars = 0, exceeds_double = 0;
char l_seen = 0;
REAL_VALUE_TYPE value; REAL_VALUE_TYPE value;
jmp_buf handler; jmp_buf handler;
@ -1378,53 +1377,40 @@ yylex ()
/* ERANGE is also reported for underflow, /* ERANGE is also reported for underflow,
so test the value to distinguish overflow from that. */ so test the value to distinguish overflow from that. */
if (*p1 != 0 && (value > 1.0 || value < -1.0)) if (*p1 != 0 && (value > 1.0 || value < -1.0))
pedwarn ("floating point number exceeds range of `double'"); {
pedwarn ("floating point number exceeds range of `double'");
exceeds_double = 1;
}
} }
#endif #endif
/* Read the suffixes to choose a data type. */ /* Read the suffixes to choose a data type. */
while (1) switch (c)
{
case 'f': case 'F':
type = float_type_node;
value = REAL_VALUE_TRUNCATE (TYPE_MODE (type), value);
if (REAL_VALUE_ISINF (value) && ! exceeds_double && pedantic)
pedwarn ("floating point number exceeds range of `float'");
garbage_chars = -1;
break;
case 'l': case 'L':
type = long_double_type_node;
garbage_chars = -1;
break;
}
/* Note: garbage_chars is -1 if first char is *not* garbage. */
while (isalnum (c))
{ {
if (c == 'f' || c == 'F')
{
if (f_seen)
error ("two `f's in floating constant");
else
{
f_seen = 1;
type = float_type_node;
value = real_value_truncate (TYPE_MODE (type), value);
if (REAL_VALUE_ISINF (value) && pedantic)
pedwarn ("floating point number exceeds range of `float'");
}
}
else if (c == 'l' || c == 'L')
{
if (l_seen)
error ("two `l's in floating constant");
l_seen = 1;
type = long_double_type_node;
}
else
{
if (isalnum (c))
{
error ("garbage at end of number");
while (isalnum (c))
{
if (p >= token_buffer + maxtoken - 3)
p = extend_token_buffer (p);
*p++ = c;
c = getc (finput);
}
}
break;
}
if (p >= token_buffer + maxtoken - 3) if (p >= token_buffer + maxtoken - 3)
p = extend_token_buffer (p); p = extend_token_buffer (p);
*p++ = c; *p++ = c;
c = getc (finput); c = getc (finput);
garbage_chars++;
} }
if (garbage_chars > 0)
error ("garbage at end of number");
/* Create a node with determined type and value. */ /* Create a node with determined type and value. */
yylval.ttype = build_real (type, value); yylval.ttype = build_real (type, value);