This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
cpplib cleanup: scrap CPP_INT and CPP_FLOAT token types
- To: gcc-patches at gcc dot gnu dot org
- Subject: cpplib cleanup: scrap CPP_INT and CPP_FLOAT token types
- From: Neil Booth <neil at daikokuya dot demon dot co dot uk>
- Date: Wed, 18 Jul 2001 22:23:11 +0100
These have existed for a while and never really done much; I think we
originally intended them to be separate types if we did preprocessing
number parsing in cpplib, but it is not appropriate.
Further, I notice their existence has already confused Mark once
during his parser development :-)
So, this gets rid of them. When it's bootstrapped and made check,
I'll commit it.
Neil.
* 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.
============================================================
Index: gcc/c-lex.c
--- gcc/c-lex.c 2001/07/11 20:51:45 1.143
+++ gcc/c-lex.c 2001/07/18 21:16:38
@@ -775,8 +775,6 @@ c_lex (value)
*value = HT_IDENT_TO_GCC_IDENT (HT_NODE (tok.val.node));
break;
- case CPP_INT:
- case CPP_FLOAT:
case CPP_NUMBER:
*value = lex_number ((const char *)tok.val.str.text, tok.val.str.len);
break;
============================================================
Index: gcc/c-parse.in
--- gcc/c-parse.in 2001/07/17 11:58:52 1.98
+++ gcc/c-parse.in 2001/07/18 21:16:50
@@ -3603,9 +3603,7 @@ yyerror (msgid)
else if (last_token == CPP_STRING
|| last_token == CPP_WSTRING)
error ("%s before string constant", string);
- else if (last_token == CPP_NUMBER
- || last_token == CPP_INT
- || last_token == CPP_FLOAT)
+ else if (last_token == CPP_NUMBER)
error ("%s before numeric constant", string);
else if (last_token == CPP_NAME)
error ("%s before \"%s\"", string, IDENTIFIER_POINTER (yylval.ttype));
@@ -3735,7 +3733,6 @@ _yylex ()
return yylexname ();
case CPP_INT:
- case CPP_FLOAT:
case CPP_NUMBER:
case CPP_CHAR:
case CPP_WCHAR:
============================================================
Index: gcc/cppexp.c
--- gcc/cppexp.c 2001/05/16 22:02:03 1.92
+++ gcc/cppexp.c 2001/07/18 21:16:51
@@ -61,8 +61,6 @@ struct op
#define SYNTAX_ERROR2(msgid, arg) \
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
{
unsigned char s[4];
@@ -87,6 +85,10 @@ const struct suffix vsuf_3[] = {
};
#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
parse_number (pfile, tok)
cpp_reader *pfile;
@@ -198,7 +200,7 @@ parse_number (pfile, tok)
}
op.value = n;
- op.op = CPP_INT;
+ op.op = CPP_NUMBER;
return op;
invalid_suffix:
@@ -263,7 +265,7 @@ parse_defined (pfile)
{
op.value = node->type == NT_MACRO;
op.unsignedp = 0;
- op.op = CPP_INT;
+ op.op = CPP_NUMBER;
/* No macros? At top of file? */
if (pfile->mi_state == MI_OUTSIDE && pfile->mi_cmacro == 0
@@ -281,7 +283,10 @@ parse_defined (pfile)
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
lex (pfile, skip_evaluation, token)
@@ -295,7 +300,6 @@ lex (pfile, skip_evaluation, token)
switch (token->type)
{
- case CPP_INT:
case CPP_NUMBER:
return parse_number (pfile, token);
@@ -306,7 +310,7 @@ lex (pfile, skip_evaluation, token)
/* This is always a signed type. */
op.unsignedp = 0;
- op.op = CPP_INT;
+ op.op = CPP_NUMBER;
op.value = cpp_interpret_charconst (pfile, token, 1, 0, &chars_seen);
return op;
}
@@ -315,9 +319,6 @@ lex (pfile, skip_evaluation, token)
case CPP_WSTRING:
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:
if (ISGRAPH (token->val.c))
SYNTAX_ERROR2 ("invalid character '%c' in #if", token->val.c);
@@ -336,7 +337,7 @@ lex (pfile, skip_evaluation, token)
&& (token->val.node == pfile->spec_nodes.n_true
|| token->val.node == pfile->spec_nodes.n_false))
{
- op.op = CPP_INT;
+ op.op = CPP_NUMBER;
op.unsignedp = 0;
op.value = (token->val.node == pfile->spec_nodes.n_true);
@@ -354,7 +355,7 @@ lex (pfile, skip_evaluation, token)
could become macros in the future). */
pfile->mi_state = MI_FAILED;
- op.op = CPP_INT;
+ op.op = CPP_NUMBER;
op.unsignedp = 0;
op.value = 0;
@@ -368,7 +369,7 @@ lex (pfile, skip_evaluation, token)
{
int temp;
- op.op = CPP_INT;
+ op.op = CPP_NUMBER;
if (_cpp_test_assertion (pfile, &temp))
op.op = CPP_ERROR;
op.unsignedp = 0;
@@ -627,7 +628,7 @@ _cpp_parse_expr (pfile)
case CPP_ERROR:
goto syntax_error;
push_immediate:
- case CPP_INT:
+ case CPP_NUMBER:
/* Push a value onto the stack. */
if (top->flags & HAVE_VALUE)
SYNTAX_ERROR ("missing binary operator");
============================================================
Index: gcc/cpplib.h
--- gcc/cpplib.h 2001/05/26 01:31:34 1.176
+++ gcc/cpplib.h 2001/07/18 21:16:56
@@ -124,8 +124,6 @@ struct ht;
OP(CPP_ATSIGN, "@") /* used in Objective C */ \
\
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_CHAR, SPELL_STRING) /* 'char' */ \
============================================================
Index: gcc/cp/spew.c
--- gcc/cp/spew.c 2001/05/16 09:37:20 1.48
+++ gcc/cp/spew.c 2001/07/18 21:16:58
@@ -340,8 +340,6 @@ read_token (t)
t->yychar = read_process_identifier (&t->yylval);
break;
- case CPP_INT:
- case CPP_FLOAT:
case CPP_NUMBER:
case CPP_CHAR:
case CPP_WCHAR:
@@ -1490,9 +1488,7 @@ yyerror (msgid)
else if (last_token == CPP_STRING
|| last_token == CPP_WSTRING)
error ("%s before string constant", string);
- else if (last_token == CPP_NUMBER
- || last_token == CPP_INT
- || last_token == CPP_FLOAT)
+ else if (last_token == CPP_NUMBER)
error ("%s before numeric constant", string);
else if (last_token == CPP_NAME)
{