aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/spew.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp/spew.c')
-rw-r--r--gcc/cp/spew.c46
1 files changed, 20 insertions, 26 deletions
diff --git a/gcc/cp/spew.c b/gcc/cp/spew.c
index ba2013b8142..7b88757db54 100644
--- a/gcc/cp/spew.c
+++ b/gcc/cp/spew.c
@@ -1,6 +1,6 @@
/* Type Analyzer for GNU C++.
Copyright (C) 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000 Free Software Foundation, Inc.
+ 1999, 2000, 2001 Free Software Foundation, Inc.
Hacked... nay, bludgeoned... by Mark Eichin (eichin@cygnus.com)
This file is part of GNU CC.
@@ -140,6 +140,7 @@ static void debug_yychar PARAMS ((int));
extern char *debug_yytranslate PARAMS ((int));
#endif
static enum cpp_ttype last_token;
+static tree last_token_id;
/* From lex.c: */
/* the declaration found for the last IDENTIFIER token read in.
@@ -259,7 +260,8 @@ read_token (t)
{
retry:
- last_token = c_lex (&t->yylval.ttype);
+ last_token = c_lex (&last_token_id);
+ t->yylval.ttype = last_token_id;
switch (last_token)
{
@@ -351,17 +353,9 @@ read_token (t)
t->yychar = STRING;
break;
- /* This token should not be generated in C++ mode. */
- case CPP_OSTRING:
-
- /* These tokens should not survive translation phase 4. */
- case CPP_HASH:
- case CPP_PASTE:
- error ("syntax error before '#' token");
- goto retry;
-
default:
- abort ();
+ yyerror ("parse error");
+ goto retry;
}
t->lineno = lineno;
@@ -704,12 +698,7 @@ see_typename ()
if (yychar == IDENTIFIER)
{
lastiddecl = lookup_name (yylval.ttype, -2);
- if (lastiddecl == 0)
- {
- if (flag_labels_ok)
- lastiddecl = IDENTIFIER_LABEL_VALUE (yylval.ttype);
- }
- else
+ if (lastiddecl)
yychar = identifier_type (lastiddecl);
}
}
@@ -719,6 +708,8 @@ yylex ()
{
int yychr;
int old_looking_for_typename = 0;
+ int just_saw_new = 0;
+ int just_saw_friend = 0;
timevar_push (TV_LEX);
@@ -804,13 +795,13 @@ yylex ()
}
/* do_aggr needs to know if the previous token was `friend'. */
else if (nth_token (0)->yylval.ttype == ridpointers[RID_FRIEND])
- after_friend = 1;
+ just_saw_friend = 1;
break;
case NEW:
/* do_aggr needs to know if the previous token was `new'. */
- after_new = 1;
+ just_saw_new = 1;
break;
case TYPESPEC:
@@ -824,7 +815,6 @@ yylex ()
case AGGR:
do_aggr ();
- after_friend = after_new = 0;
break;
case ENUM:
@@ -836,6 +826,9 @@ yylex ()
break;
}
+ after_friend = just_saw_friend;
+ after_new = just_saw_new;
+
/* class member lookup only applies to the first token after the object
expression, except for explicit destructor calls. */
if (yychr != '~')
@@ -1495,8 +1488,7 @@ yyerror (msgid)
error ("%s before %s'\\x%x'", string, ell, val);
}
else if (last_token == CPP_STRING
- || last_token == CPP_WSTRING
- || last_token == CPP_OSTRING)
+ || last_token == CPP_WSTRING)
error ("%s before string constant", string);
else if (last_token == CPP_NUMBER
|| last_token == CPP_INT
@@ -1504,10 +1496,12 @@ yyerror (msgid)
error ("%s before numeric constant", string);
else if (last_token == CPP_NAME)
{
- if (yylval.ttype && TREE_CODE (yylval.ttype) == IDENTIFIER_NODE)
- error ("%s before `%s'", string, IDENTIFIER_POINTER (yylval.ttype));
- else
+ if (TREE_CODE (last_token_id) == IDENTIFIER_NODE)
+ error ("%s before `%s'", string, IDENTIFIER_POINTER (last_token_id));
+ else if (ISGRAPH (yychar))
error ("%s before `%c'", string, yychar);
+ else
+ error ("%s before `\%o'", string, yychar);
}
else
error ("%s before `%s' token", string, NAME (last_token));