summaryrefslogtreecommitdiff
path: root/gcc/c-lex.c
diff options
context:
space:
mode:
authorkenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4>1995-12-28 12:21:45 +0000
committerkenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4>1995-12-28 12:21:45 +0000
commit403428bcd5c64729e741e88fce26048de1b750e6 (patch)
tree48640af19b4a94b0ad8caa83de0ab31c501db18a /gcc/c-lex.c
parent51f4e6bd36343a85b8e10dfc8f28158afb9ce478 (diff)
downloadgcc-403428bcd5c64729e741e88fce26048de1b750e6.tar.gz
(yylex): Improve error message for bogus numbers.
Consolidate duplicated code. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@10892 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-lex.c')
-rw-r--r--gcc/c-lex.c49
1 files changed, 10 insertions, 39 deletions
diff --git a/gcc/c-lex.c b/gcc/c-lex.c
index edb707583db..210c365dda8 100644
--- a/gcc/c-lex.c
+++ b/gcc/c-lex.c
@@ -1282,7 +1282,7 @@ yylex ()
if (floatflag != NOT_FLOAT)
{
tree type = double_type_node;
- int garbage_chars = 0, exceeds_double = 0;
+ int exceeds_double = 0;
int imag = 0;
REAL_VALUE_TYPE value;
jmp_buf handler;
@@ -1418,19 +1418,6 @@ yylex ()
}
}
#endif
- garbage_chars = 0;
- while (isalnum (c) || c == '.' || c == '_'
- || (!flag_traditional && (c == '+' || c == '-')
- && (p[-1] == 'e' || p[-1] == 'E')))
- {
- if (p >= token_buffer + maxtoken - 3)
- p = extend_token_buffer (p);
- *p++ = c;
- c = getc (finput);
- garbage_chars++;
- }
- if (garbage_chars > 0)
- error ("garbage at end of number");
/* If the result is not a number, assume it must have been
due to some error message above, so silently convert
@@ -1444,9 +1431,6 @@ yylex ()
build_real (type, value));
else
yylval.ttype = build_real (type, value);
-
- ungetc (c, finput);
- *p = 0;
}
else
{
@@ -1487,32 +1471,13 @@ yylex ()
spec_imag = 1;
}
else
- {
- if (isalnum (c) || c == '.' || c == '_'
- || (!flag_traditional && (c == '+' || c == '-')
- && (p[-1] == 'e' || p[-1] == 'E')))
- {
- error ("garbage at end of number");
- while (isalnum (c) || c == '.' || c == '_'
- || (!flag_traditional && (c == '+' || c == '-')
- && (p[-1] == 'e' || p[-1] == 'E')))
- {
- if (p >= token_buffer + maxtoken - 3)
- p = extend_token_buffer (p);
- *p++ = c;
- c = getc (finput);
- }
- }
- break;
- }
+ break;
if (p >= token_buffer + maxtoken - 3)
p = extend_token_buffer (p);
*p++ = c;
c = getc (finput);
}
- ungetc (c, finput);
-
/* If the constant is not long long and it won't fit in an
unsigned long, or if the constant is long long and won't fit
in an unsigned long long, then warn that the constant is out
@@ -1648,10 +1613,16 @@ yylex ()
}
else
TREE_TYPE (yylval.ttype) = type;
-
- *p = 0;
}
+ ungetc (c, finput);
+ *p = 0;
+
+ if (isalnum (c) || c == '.' || c == '_'
+ || (!flag_traditional && (c == '-' || c == '+')
+ && (p[-1] == 'e' || p[-1] == 'E')))
+ error ("missing white space after number `%s'", token_buffer);
+
value = CONSTANT; break;
}