aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-lex.c
diff options
context:
space:
mode:
authorZack Weinberg <zack@gcc.gnu.org>2002-03-25 20:52:28 +0000
committerZack Weinberg <zack@gcc.gnu.org>2002-03-25 20:52:28 +0000
commit15e5ad7698ca582197d816b0e864d55bc0bdb607 (patch)
tree8c35b0cf468101ecc396f5eb7631e99dc328e79c /gcc/c-lex.c
parent99ffa1e37aad3fafd771f47b56c0085ce5544727 (diff)
downloadgcc-15e5ad7698ca582197d816b0e864d55bc0bdb607.zip
gcc-15e5ad7698ca582197d816b0e864d55bc0bdb607.tar.gz
gcc-15e5ad7698ca582197d816b0e864d55bc0bdb607.tar.bz2
toplev.c: Don't include setjmp.h.
* toplev.c: Don't include setjmp.h. Kill float_handler_set, float_handled, float_handler, float_signal, set_float_handler, and do_float_handler. Set handler for SIGFPE to crash_signal. * toplev.h: Don't prototype do_float_handler. * c-lex.c: Fold parse_float into lex_number. Make warning about portability of hex float constants more informative, and don't issue it on top of a syntax error. * fold-const.c: Fold const_binop_1 and fold_convert_1 into their callers. * real.h: Define REAL_VALUE_ABS here... * simplify-rtx.c: ... not here. Fold check_fold_consts, simplify_unary_real, simplify_binary_real, and simplify_binary_is2orm1 into their callers. * tree.c: Fold build_real_from_int_cst_1 into caller. * doc/tm.texi: Document REAL_VALUE_ABS and REAL_VALUE_NEGATIVE. * tsystem.h: Include float.h here... * libgcc2.c: ... not here. java: * lex.c: Change java_perform_atof to take normal parameters instead of a pointer to a parameter block. Call it directly from java_lex. testsuite: * gcc.dg/c90-hexfloat-1.c: Adjust error regexps. From-SVN: r51336
Diffstat (limited to 'gcc/c-lex.c')
-rw-r--r--gcc/c-lex.c126
1 files changed, 36 insertions, 90 deletions
diff --git a/gcc/c-lex.c b/gcc/c-lex.c
index cf5141b..29c15e7 100644
--- a/gcc/c-lex.c
+++ b/gcc/c-lex.c
@@ -84,7 +84,6 @@ int c_header_level; /* depth in C headers - C++ only */
/* Nonzero tells yylex to ignore \ in string constants. */
static int ignore_escape_flag;
-static void parse_float PARAMS ((PTR));
static tree lex_number PARAMS ((const char *, unsigned int));
static tree lex_string PARAMS ((const unsigned char *, unsigned int,
int));
@@ -703,67 +702,6 @@ struct try_type type_sequence[] =
};
#endif /* 0 */
-struct pf_args
-{
- /* Input */
- const char *str;
- int fflag;
- int lflag;
- int base;
- /* Output */
- int conversion_errno;
- REAL_VALUE_TYPE value;
- tree type;
-};
-
-static void
-parse_float (data)
- PTR data;
-{
- struct pf_args * args = (struct pf_args *) data;
- const char *typename;
-
- args->conversion_errno = 0;
- args->type = double_type_node;
- typename = "double";
-
- /* The second argument, machine_mode, of REAL_VALUE_ATOF
- tells the desired precision of the binary result
- of decimal-to-binary conversion. */
-
- if (args->fflag)
- {
- if (args->lflag)
- error ("both 'f' and 'l' suffixes on floating constant");
-
- args->type = float_type_node;
- typename = "float";
- }
- else if (args->lflag)
- {
- args->type = long_double_type_node;
- typename = "long double";
- }
- else if (flag_single_precision_constant)
- {
- args->type = float_type_node;
- typename = "float";
- }
-
- errno = 0;
- if (args->base == 16)
- args->value = REAL_VALUE_HTOF (args->str, TYPE_MODE (args->type));
- else
- args->value = REAL_VALUE_ATOF (args->str, TYPE_MODE (args->type));
-
- args->conversion_errno = errno;
- /* A diagnostic is required here by some ISO C testsuites.
- This is not pedwarn, because some people don't want
- an error for this. */
- if (REAL_VALUE_ISINF (args->value) && pedantic)
- warning ("floating point number exceeds range of '%s'", typename);
-}
-
int
c_lex (value)
tree *value;
@@ -974,14 +912,11 @@ lex_number (str, len)
if (floatflag != NOT_FLOAT)
{
tree type;
- int imag, fflag, lflag, conversion_errno;
+ const char *typename;
+ int imag, fflag, lflag;
REAL_VALUE_TYPE real;
- struct pf_args args;
char *copy;
- if (base == 16 && pedantic && !flag_isoc99)
- pedwarn ("floating constant may not be in radix 16");
-
if (base == 16 && floatflag != AFTER_EXPON)
ERROR ("hexadecimal floating constant has no exponent");
@@ -1046,34 +981,45 @@ lex_number (str, len)
ERROR ("invalid suffix on floating constant");
}
- /* Setup input for parse_float() */
- args.str = copy;
- args.fflag = fflag;
- args.lflag = lflag;
- args.base = base;
+ type = double_type_node;
+ typename = "double";
+
+ if (fflag)
+ {
+ if (lflag)
+ ERROR ("both 'f' and 'l' suffixes on floating constant");
- /* Convert string to a double, checking for overflow. */
- if (do_float_handler (parse_float, (PTR) &args))
+ type = float_type_node;
+ typename = "float";
+ }
+ else if (lflag)
{
- /* Receive output from parse_float() */
- real = args.value;
+ type = long_double_type_node;
+ typename = "long double";
}
+ else if (flag_single_precision_constant)
+ {
+ type = float_type_node;
+ typename = "float";
+ }
+
+ /* Warn about this only after we know we're not issuing an error. */
+ if (base == 16 && pedantic && !flag_isoc99)
+ pedwarn ("hexadecimal floating constants are only valid in C99");
+
+ /* The second argument, machine_mode, of REAL_VALUE_ATOF
+ tells the desired precision of the binary result
+ of decimal-to-binary conversion. */
+ if (base == 16)
+ real = REAL_VALUE_HTOF (copy, TYPE_MODE (type));
else
- /* We got an exception from parse_float() */
- ERROR ("floating constant out of range");
-
- /* Receive output from parse_float() */
- conversion_errno = args.conversion_errno;
- type = args.type;
-
-#ifdef ERANGE
- /* ERANGE is also reported for underflow,
- so test the value to distinguish overflow from that. */
- if (conversion_errno == ERANGE && pedantic
- && (REAL_VALUES_LESS (dconst1, real)
- || REAL_VALUES_LESS (real, dconstm1)))
+ real = REAL_VALUE_ATOF (copy, TYPE_MODE (type));
+
+ /* A diagnostic is required here by some ISO C testsuites.
+ This is not pedwarn, because some people don't want
+ an error for this. */
+ if (REAL_VALUE_ISINF (real) && pedantic)
warning ("floating point number exceeds range of 'double'");
-#endif
/* Create a node with determined type and value. */
if (imag)