Commit c60e94a7 by Neil Booth Committed by Neil Booth

c-lex.c (c_lex): Remove CPP_INT, CPP_FLOAT cases.

	* c-lex.c (c_lex): Remove CPP_INT, CPP_FLOAT cases.
	* c-parse.in (yyerror, _yylex): Similarly.
	* cppexp.c (parse_number, parse_defined, lex, _cpp_parse_expr):
	Don't use CPP_INT, CPP_FLOAT; CPP_NUMBER is enough.
	Update comments.
	* cpplib.h (CPP_INT, CPP_FLOAT): Remove.
	* cp/spew.c (read_token, yyerror): Remove CPP_INT, CPP_FLOAT cases.

From-SVN: r44144
parent dbc957f1
2001-07-19 Neil Booth <neil@daikokuya.demon.co.uk>
* c-lex.c (c_lex): Remove CPP_INT, CPP_FLOAT cases.
* c-parse.in (yyerror, _yylex): Similarly.
* cppexp.c (parse_number, parse_defined, lex, _cpp_parse_expr):
Don't use CPP_INT, CPP_FLOAT; CPP_NUMBER is enough.
Update comments.
* cpplib.h (CPP_INT, CPP_FLOAT): Remove.
* cp/spew.c (read_token, yyerror): Remove CPP_INT, CPP_FLOAT cases.
2001-07-18 Jeff Sturm <jsturm@one-point.com> 2001-07-18 Jeff Sturm <jsturm@one-point.com>
* dwarf2out.c (dwarf2out_abstract_function): Don't emit * dwarf2out.c (dwarf2out_abstract_function): Don't emit
......
...@@ -775,8 +775,6 @@ c_lex (value) ...@@ -775,8 +775,6 @@ c_lex (value)
*value = HT_IDENT_TO_GCC_IDENT (HT_NODE (tok.val.node)); *value = HT_IDENT_TO_GCC_IDENT (HT_NODE (tok.val.node));
break; break;
case CPP_INT:
case CPP_FLOAT:
case CPP_NUMBER: case CPP_NUMBER:
*value = lex_number ((const char *)tok.val.str.text, tok.val.str.len); *value = lex_number ((const char *)tok.val.str.text, tok.val.str.len);
break; break;
......
...@@ -3603,9 +3603,7 @@ yyerror (msgid) ...@@ -3603,9 +3603,7 @@ yyerror (msgid)
else if (last_token == CPP_STRING else if (last_token == CPP_STRING
|| last_token == CPP_WSTRING) || last_token == CPP_WSTRING)
error ("%s before string constant", string); error ("%s before string constant", string);
else if (last_token == CPP_NUMBER else if (last_token == CPP_NUMBER)
|| last_token == CPP_INT
|| last_token == CPP_FLOAT)
error ("%s before numeric constant", string); error ("%s before numeric constant", string);
else if (last_token == CPP_NAME) else if (last_token == CPP_NAME)
error ("%s before \"%s\"", string, IDENTIFIER_POINTER (yylval.ttype)); error ("%s before \"%s\"", string, IDENTIFIER_POINTER (yylval.ttype));
...@@ -3734,8 +3732,6 @@ _yylex () ...@@ -3734,8 +3732,6 @@ _yylex ()
case CPP_NAME: case CPP_NAME:
return yylexname (); return yylexname ();
case CPP_INT:
case CPP_FLOAT:
case CPP_NUMBER: case CPP_NUMBER:
case CPP_CHAR: case CPP_CHAR:
case CPP_WCHAR: case CPP_WCHAR:
......
2001-07-19 Neil Booth <neil@daikokuya.demon.co.uk>
* spew.c (read_token, yyerror): Remove CPP_INT, CPP_FLOAT cases.
2001-07-18 Mark Mitchell <mark@codesourcery.com> 2001-07-18 Mark Mitchell <mark@codesourcery.com>
* class.c (type_requires_array_cookie): New function. * class.c (type_requires_array_cookie): New function.
......
...@@ -340,8 +340,6 @@ read_token (t) ...@@ -340,8 +340,6 @@ read_token (t)
t->yychar = read_process_identifier (&t->yylval); t->yychar = read_process_identifier (&t->yylval);
break; break;
case CPP_INT:
case CPP_FLOAT:
case CPP_NUMBER: case CPP_NUMBER:
case CPP_CHAR: case CPP_CHAR:
case CPP_WCHAR: case CPP_WCHAR:
...@@ -1490,9 +1488,7 @@ yyerror (msgid) ...@@ -1490,9 +1488,7 @@ yyerror (msgid)
else if (last_token == CPP_STRING else if (last_token == CPP_STRING
|| last_token == CPP_WSTRING) || last_token == CPP_WSTRING)
error ("%s before string constant", string); error ("%s before string constant", string);
else if (last_token == CPP_NUMBER else if (last_token == CPP_NUMBER)
|| last_token == CPP_INT
|| last_token == CPP_FLOAT)
error ("%s before numeric constant", string); error ("%s before numeric constant", string);
else if (last_token == CPP_NAME) else if (last_token == CPP_NAME)
{ {
......
...@@ -61,8 +61,6 @@ struct op ...@@ -61,8 +61,6 @@ struct op
#define SYNTAX_ERROR2(msgid, arg) \ #define SYNTAX_ERROR2(msgid, arg) \
do { cpp_error (pfile, msgid, arg); goto syntax_error; } while(0) do { cpp_error (pfile, msgid, arg); goto syntax_error; } while(0)
/* Parse and convert an integer for #if. Accepts decimal, hex, or octal
with or without size suffixes. */
struct suffix struct suffix
{ {
unsigned char s[4]; unsigned char s[4];
...@@ -87,6 +85,10 @@ const struct suffix vsuf_3[] = { ...@@ -87,6 +85,10 @@ const struct suffix vsuf_3[] = {
}; };
#define Nsuff(tab) (sizeof tab / sizeof (struct suffix)) #define Nsuff(tab) (sizeof tab / sizeof (struct suffix))
/* Parse and convert an integer for #if. Accepts decimal, hex, or
octal with or without size suffixes. Returned op is CPP_ERROR on
error, otherwise it is a CPP_NUMBER. */
static struct op static struct op
parse_number (pfile, tok) parse_number (pfile, tok)
cpp_reader *pfile; cpp_reader *pfile;
...@@ -198,7 +200,7 @@ parse_number (pfile, tok) ...@@ -198,7 +200,7 @@ parse_number (pfile, tok)
} }
op.value = n; op.value = n;
op.op = CPP_INT; op.op = CPP_NUMBER;
return op; return op;
invalid_suffix: invalid_suffix:
...@@ -263,7 +265,7 @@ parse_defined (pfile) ...@@ -263,7 +265,7 @@ parse_defined (pfile)
{ {
op.value = node->type == NT_MACRO; op.value = node->type == NT_MACRO;
op.unsignedp = 0; op.unsignedp = 0;
op.op = CPP_INT; op.op = CPP_NUMBER;
/* No macros? At top of file? */ /* No macros? At top of file? */
if (pfile->mi_state == MI_OUTSIDE && pfile->mi_cmacro == 0 if (pfile->mi_state == MI_OUTSIDE && pfile->mi_cmacro == 0
...@@ -281,7 +283,10 @@ parse_defined (pfile) ...@@ -281,7 +283,10 @@ parse_defined (pfile)
return op; return op;
} }
/* Read one token. */ /* Read a token. The returned type is CPP_NUMBER for a valid number
(an interpreted preprocessing number or character constant, or the
result of the "defined" or "#" operators), CPP_ERROR on error,
CPP_EOF, or the type of an operator token. */
static struct op static struct op
lex (pfile, skip_evaluation, token) lex (pfile, skip_evaluation, token)
...@@ -295,7 +300,6 @@ lex (pfile, skip_evaluation, token) ...@@ -295,7 +300,6 @@ lex (pfile, skip_evaluation, token)
switch (token->type) switch (token->type)
{ {
case CPP_INT:
case CPP_NUMBER: case CPP_NUMBER:
return parse_number (pfile, token); return parse_number (pfile, token);
...@@ -306,7 +310,7 @@ lex (pfile, skip_evaluation, token) ...@@ -306,7 +310,7 @@ lex (pfile, skip_evaluation, token)
/* This is always a signed type. */ /* This is always a signed type. */
op.unsignedp = 0; op.unsignedp = 0;
op.op = CPP_INT; op.op = CPP_NUMBER;
op.value = cpp_interpret_charconst (pfile, token, 1, 0, &chars_seen); op.value = cpp_interpret_charconst (pfile, token, 1, 0, &chars_seen);
return op; return op;
} }
...@@ -315,9 +319,6 @@ lex (pfile, skip_evaluation, token) ...@@ -315,9 +319,6 @@ lex (pfile, skip_evaluation, token)
case CPP_WSTRING: case CPP_WSTRING:
SYNTAX_ERROR ("string constants are not valid in #if"); SYNTAX_ERROR ("string constants are not valid in #if");
case CPP_FLOAT:
SYNTAX_ERROR ("floating point numbers are not valid in #if");
case CPP_OTHER: case CPP_OTHER:
if (ISGRAPH (token->val.c)) if (ISGRAPH (token->val.c))
SYNTAX_ERROR2 ("invalid character '%c' in #if", token->val.c); SYNTAX_ERROR2 ("invalid character '%c' in #if", token->val.c);
...@@ -336,7 +337,7 @@ lex (pfile, skip_evaluation, token) ...@@ -336,7 +337,7 @@ lex (pfile, skip_evaluation, token)
&& (token->val.node == pfile->spec_nodes.n_true && (token->val.node == pfile->spec_nodes.n_true
|| token->val.node == pfile->spec_nodes.n_false)) || token->val.node == pfile->spec_nodes.n_false))
{ {
op.op = CPP_INT; op.op = CPP_NUMBER;
op.unsignedp = 0; op.unsignedp = 0;
op.value = (token->val.node == pfile->spec_nodes.n_true); op.value = (token->val.node == pfile->spec_nodes.n_true);
...@@ -354,7 +355,7 @@ lex (pfile, skip_evaluation, token) ...@@ -354,7 +355,7 @@ lex (pfile, skip_evaluation, token)
could become macros in the future). */ could become macros in the future). */
pfile->mi_state = MI_FAILED; pfile->mi_state = MI_FAILED;
op.op = CPP_INT; op.op = CPP_NUMBER;
op.unsignedp = 0; op.unsignedp = 0;
op.value = 0; op.value = 0;
...@@ -368,7 +369,7 @@ lex (pfile, skip_evaluation, token) ...@@ -368,7 +369,7 @@ lex (pfile, skip_evaluation, token)
{ {
int temp; int temp;
op.op = CPP_INT; op.op = CPP_NUMBER;
if (_cpp_test_assertion (pfile, &temp)) if (_cpp_test_assertion (pfile, &temp))
op.op = CPP_ERROR; op.op = CPP_ERROR;
op.unsignedp = 0; op.unsignedp = 0;
...@@ -627,7 +628,7 @@ _cpp_parse_expr (pfile) ...@@ -627,7 +628,7 @@ _cpp_parse_expr (pfile)
case CPP_ERROR: case CPP_ERROR:
goto syntax_error; goto syntax_error;
push_immediate: push_immediate:
case CPP_INT: case CPP_NUMBER:
/* Push a value onto the stack. */ /* Push a value onto the stack. */
if (top->flags & HAVE_VALUE) if (top->flags & HAVE_VALUE)
SYNTAX_ERROR ("missing binary operator"); SYNTAX_ERROR ("missing binary operator");
......
...@@ -124,8 +124,6 @@ struct ht; ...@@ -124,8 +124,6 @@ struct ht;
OP(CPP_ATSIGN, "@") /* used in Objective C */ \ OP(CPP_ATSIGN, "@") /* used in Objective C */ \
\ \
TK(CPP_NAME, SPELL_IDENT) /* word */ \ TK(CPP_NAME, SPELL_IDENT) /* word */ \
TK(CPP_INT, SPELL_STRING) /* 23 */ \
TK(CPP_FLOAT, SPELL_STRING) /* 3.14159 */ \
TK(CPP_NUMBER, SPELL_STRING) /* 34_be+ta */ \ TK(CPP_NUMBER, SPELL_STRING) /* 34_be+ta */ \
\ \
TK(CPP_CHAR, SPELL_STRING) /* 'char' */ \ TK(CPP_CHAR, SPELL_STRING) /* 'char' */ \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment