diff options
author | kenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4> | 1995-12-28 12:17:30 +0000 |
---|---|---|
committer | kenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4> | 1995-12-28 12:17:30 +0000 |
commit | 51f4e6bd36343a85b8e10dfc8f28158afb9ce478 (patch) | |
tree | a5d42e3e6fd8929f300eb7280a1c4dc684cecf27 /gcc/cexp.y | |
parent | e0a7c658fd2b7a4a1eff055840a52ae95f453f04 (diff) | |
download | gcc-51f4e6bd36343a85b8e10dfc8f28158afb9ce478.tar.gz |
(parse_number): Improve error message for bogus numbers.
(yylex): Consider `0xe-1' to be a (bogus) number if not traditional.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@10891 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cexp.y')
-rw-r--r-- | gcc/cexp.y | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/gcc/cexp.y b/gcc/cexp.y index d83de803364..bdc61c8d1d9 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); } |