summaryrefslogtreecommitdiff
path: root/gcc/c-lex.c
diff options
context:
space:
mode:
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>1998-12-01 21:05:17 +0000
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>1998-12-01 21:05:17 +0000
commit75bd5adae1072ec96f2b05f35147891f977ab2b2 (patch)
tree8180a32dab64f00b8c46fedcdc5e7b9928102158 /gcc/c-lex.c
parentc50a498ccf40a4f355b138f6e51e500095895ba0 (diff)
downloadgcc-75bd5adae1072ec96f2b05f35147891f977ab2b2.tar.gz
* c-common.c (declare_function_name): Declare predefinied variable
`__func__'. * c-decl.c (flag_isoc9x): Set to 1 by default. (c_decode_option): Handle -std= option. Remove -flang-isoc9x. (grokdeclarator): Always emit warning about implicit int for ISO C 9x. * c-parse.in: Allow constructors in ISO C 9x. Rewrite designator list handling. Allow [*] parameters. Don't warn about comma at end of enum definition for ISO C 9x. * cccp.c (c9x): New variable. (rest_extension): New variable. (print_help): Document new -std= option. (main): Recognize -std= option. Set c9x appropriately. (create_definition): Recognize ISO C 9x vararg macros. * gcc.c (default_compilers): Adjust specs for -std options. (option_map): Add --std. (display_help): Document -std. * toplev.c (documented_lang_options): Add -std and remove -flang-isoc9x. * c-lex.c (yylex): Recognize hex FP constants and call REAL_VALUE_ATOF or REAL_VALUE_HTOF based on base of the constants. * fold-const.c (real_hex_to_f): New function. Replacement function for hex FP conversion if REAL_ARITHMETIC is not defined. * real.c (asctoeg): Add handling of hex FP constants. * real.h: Define REAL_VALUE_HTOF if necessary using ereal_atof or real_hex_to_f. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@24049 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-lex.c')
-rw-r--r--gcc/c-lex.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/gcc/c-lex.c b/gcc/c-lex.c
index 934f251b354..8ba053f55f1 100644
--- a/gcc/c-lex.c
+++ b/gcc/c-lex.c
@@ -1333,8 +1333,8 @@ yylex ()
int parts[TOTAL_PARTS];
int overflow = 0;
- enum anon1 { NOT_FLOAT, AFTER_POINT, TOO_MANY_POINTS} floatflag
- = NOT_FLOAT;
+ enum anon1 { NOT_FLOAT, AFTER_POINT, TOO_MANY_POINTS, AFTER_EXPON}
+ floatflag = NOT_FLOAT;
for (count = 0; count < TOTAL_PARTS; count++)
parts[count] = 0;
@@ -1370,12 +1370,12 @@ yylex ()
{
if (c == '.')
{
- if (base == 16)
+ if (base == 16 && pedantic)
error ("floating constant may not be in radix 16");
if (floatflag == TOO_MANY_POINTS)
/* We have already emitted an error. Don't need another. */
;
- else if (floatflag == AFTER_POINT)
+ else if (floatflag == AFTER_POINT || floatflag == AFTER_EXPON)
{
error ("malformed floating constant");
floatflag = TOO_MANY_POINTS;
@@ -1386,6 +1386,7 @@ yylex ()
else
floatflag = AFTER_POINT;
+ if (base == 8)
base = 10;
*p++ = c = GETC();
/* Accept '.' as the start of a floating-point number
@@ -1425,12 +1426,17 @@ yylex ()
if (c == 'e' || c == 'E')
{
base = 10;
- floatflag = AFTER_POINT;
+ floatflag = AFTER_EXPON;
break; /* start of exponent */
}
error ("nondigits in number and not hexadecimal");
c = 0;
}
+ else if (base == 16 && (c == 'p' || c == 'P'))
+ {
+ floatflag = AFTER_EXPON;
+ break; /* start of exponent */
+ }
else if (c >= 'a')
{
c = c - 'a' + 10;
@@ -1487,7 +1493,8 @@ yylex ()
/* Read explicit exponent if any, and put it in tokenbuf. */
- if ((c == 'e') || (c == 'E'))
+ if ((base == 10 && ((c == 'e') || (c == 'E')))
+ || (base == 16 && (c == 'p' || c == 'P')))
{
if (p >= token_buffer + maxtoken - 3)
p = extend_token_buffer (p);
@@ -1498,6 +1505,7 @@ yylex ()
*p++ = c;
c = GETC();
}
+ /* Exponent is decimal, even if string is a hex float. */
if (! ISDIGIT (c))
error ("floating constant exponent has no digits");
while (ISDIGIT (c))
@@ -1508,6 +1516,8 @@ yylex ()
c = GETC();
}
}
+ if (base == 16 && floatflag != AFTER_EXPON)
+ error ("hexadecimal floating constant has no exponent");
*p = 0;
@@ -1580,10 +1590,13 @@ yylex ()
type = float_type_node;
errno = 0;
+ if (base == 16)
+ value = REAL_VALUE_HTOF (copy, TYPE_MODE (type));
+ else
value = REAL_VALUE_ATOF (copy, TYPE_MODE (type));
conversion_errno = errno;
/* A diagnostic is required here by some ANSI C testsuites.
- This is not pedwarn, become some people don't want
+ This is not pedwarn, because some people don't want
an error for this. */
if (REAL_VALUE_ISINF (value) && pedantic)
warning ("floating point number exceeds range of `float'");
@@ -1592,6 +1605,9 @@ yylex ()
{
type = long_double_type_node;
errno = 0;
+ if (base == 16)
+ value = REAL_VALUE_HTOF (copy, TYPE_MODE (type));
+ else
value = REAL_VALUE_ATOF (copy, TYPE_MODE (type));
conversion_errno = errno;
if (REAL_VALUE_ISINF (value) && pedantic)
@@ -1600,6 +1616,9 @@ yylex ()
else
{
errno = 0;
+ if (base == 16)
+ value = REAL_VALUE_HTOF (copy, TYPE_MODE (type));
+ else
value = REAL_VALUE_ATOF (copy, TYPE_MODE (type));
conversion_errno = errno;
if (REAL_VALUE_ISINF (value) && pedantic)