aboutsummaryrefslogtreecommitdiff
path: root/gcc/cexp.y
diff options
context:
space:
mode:
authorRichard Kenner <kenner@gcc.gnu.org>1995-12-28 07:17:30 -0500
committerRichard Kenner <kenner@gcc.gnu.org>1995-12-28 07:17:30 -0500
commit70ce27baada6cf22edc3f1971b57d088e5824557 (patch)
treea5d42e3e6fd8929f300eb7280a1c4dc684cecf27 /gcc/cexp.y
parent9fb1a98e76591ea389ebb0d5529ca0eb4802d889 (diff)
downloadgcc-70ce27baada6cf22edc3f1971b57d088e5824557.zip
gcc-70ce27baada6cf22edc3f1971b57d088e5824557.tar.gz
gcc-70ce27baada6cf22edc3f1971b57d088e5824557.tar.bz2
(parse_number): Improve error message for bogus numbers.
(yylex): Consider `0xe-1' to be a (bogus) number if not traditional. From-SVN: r10891
Diffstat (limited to 'gcc/cexp.y')
-rw-r--r--gcc/cexp.y36
1 files changed, 18 insertions, 18 deletions
diff --git a/gcc/cexp.y b/gcc/cexp.y
index d83de80..bdc61c8 100644
--- a/gcc/cexp.y
+++ b/gcc/cexp.y
@@ -396,13 +396,6 @@ parse_number (olen)
register int digit, largest_digit = 0;
int spec_long = 0;
- for (c = 0; c < len; c++)
- if (p[c] == '.') {
- /* It's a float since it contains a point. */
- yyerror ("floating point numbers not allowed in #if expressions");
- return ERROR;
- }
-
yylval.integer.unsignedp = 0;
if (len >= 3 && (!strncmp (p, "0x", 2) || !strncmp (p, "0X", 2))) {
@@ -439,8 +432,16 @@ parse_number (olen)
yyerror ("two `u's in integer constant");
yylval.integer.unsignedp = 1;
}
- else
- break;
+ else {
+ if (c == '.' || c == 'e' || c == 'E')
+ yyerror ("Floating point numbers not allowed in #if expressions");
+ else {
+ char *buf = (char *) alloca (p - lexptr + 40);
+ sprintf (buf, "missing white space after number `%.*s'",
+ (int) (p - lexptr - 1), lexptr);
+ yyerror (buf);
+ }
+ }
if (--len == 0)
break;
@@ -456,11 +457,6 @@ parse_number (olen)
n = nd;
}
- if (len != 0) {
- yyerror ("Invalid number in #if expression");
- return ERROR;
- }
-
if (base <= largest_digit)
warning ("integer constant contains digits beyond the radix");
@@ -733,10 +729,14 @@ yylex ()
if (c >= '0' && c <= '9' && !keyword_parsing) {
/* It's a number */
- for (namelen = 0;
- c = tokstart[namelen], is_idchar[c] || c == '.';
- namelen++)
- ;
+ for (namelen = 1; ; namelen++) {
+ int d = tokstart[namelen];
+ if (! ((is_idchar[d] || d == '.')
+ || ((d == '-' || d == '+') && (c == 'e' || c == 'E')
+ && ! traditional)))
+ break;
+ c = d;
+ }
return parse_number (namelen);
}