summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrms <rms@138bc75d-0d04-0410-961f-82ee72b054a4>1993-03-31 05:44:03 +0000
committerrms <rms@138bc75d-0d04-0410-961f-82ee72b054a4>1993-03-31 05:44:03 +0000
commitcf2b871879db537baba19bf64e6b308671d56f3b (patch)
tree90547e4ef900e45f4354aa036f216a3bff93c8dd
parent6d9f2c4c328afe78c639f4d4609dc61274dd058b (diff)
downloadgcc-cf2b871879db537baba19bf64e6b308671d56f3b.tar.gz
(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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@3936 138bc75d-0d04-0410-961f-82ee72b054a4
-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 3fbe3d715d8..0504800ea83 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 == '-')