aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-lex.c
diff options
context:
space:
mode:
authorRichard Stallman <rms@gnu.org>1993-03-31 05:44:03 +0000
committerRichard Stallman <rms@gnu.org>1993-03-31 05:44:03 +0000
commit1454a5ba185887d58409c98864f4ad0d87e3a3fc (patch)
tree90547e4ef900e45f4354aa036f216a3bff93c8dd /gcc/c-lex.c
parentee7e54412fdb94e350e6548c9a28d310ed0ac533 (diff)
downloadgcc-1454a5ba185887d58409c98864f4ad0d87e3a3fc.zip
gcc-1454a5ba185887d58409c98864f4ad0d87e3a3fc.tar.gz
gcc-1454a5ba185887d58409c98864f4ad0d87e3a3fc.tar.bz2
(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
Diffstat (limited to 'gcc/c-lex.c')
-rw-r--r--gcc/c-lex.c48
1 files changed, 30 insertions, 18 deletions
diff --git a/gcc/c-lex.c b/gcc/c-lex.c
index 3fbe3d7..0504800 100644
--- a/gcc/c-lex.c
+++ b/gcc/c-lex.c
@@ -1398,36 +1398,27 @@ yylex ()
else
{
set_float_handler (handler);
- value = REAL_VALUE_ATOF (token_buffer);
- 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
+
+/* The second argument, machine_mode, of REAL_VALUE_ATOF tells the
+ desired precision of the binary result of decimal-to-binary conversion. */
/* Read the suffixes to choose a data type. */
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)
+ value = REAL_VALUE_ATOF (token_buffer, TYPE_MODE (type));
+ if (REAL_VALUE_ISINF (value) && pedantic)
pedwarn ("floating point number exceeds range of `float'");
garbage_chars = -1;
break;
case 'l': case 'L':
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;
break;
@@ -1436,7 +1427,28 @@ yylex ()
error ("more than one `i' or `j' in numeric constant");
imag = 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. */
while (isalnum (c) || c == '.' || c == '_'
|| (!flag_traditional && (c == '+' || c == '-')