OSDN Git Service

gcp/ChangeLog:
[pf3gnuchains/gcc-fork.git] / gcc / cp / spew.c
1 /* Type Analyzer for GNU C++.
2    Copyright (C) 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3    1999, 2000 Free Software Foundation, Inc.
4    Hacked... nay, bludgeoned... by Mark Eichin (eichin@cygnus.com)
5
6 This file is part of GNU CC.
7
8 GNU CC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 GNU CC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GNU CC; see the file COPYING.  If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA.  */
22
23 /* This file is the type analyzer for GNU C++.  To debug it, define SPEW_DEBUG
24    when compiling parse.c and spew.c.  */
25
26 #include "config.h"
27 #include "system.h"
28 #include "input.h"
29 #include "tree.h"
30 #include "cp-tree.h"
31 #include "cpplib.h"
32 #include "c-lex.h"
33 #include "lex.h"
34 #include "parse.h"
35 #include "flags.h"
36 #include "obstack.h"
37 #include "toplev.h"
38 #include "ggc.h"
39 #include "intl.h"
40 #include "timevar.h"
41
42 #ifdef SPEW_DEBUG
43 #define SPEW_INLINE
44 #else
45 #define SPEW_INLINE inline
46 #endif
47
48 #if USE_CPPLIB
49 extern cpp_reader parse_in;
50 #endif
51
52 /* This takes a token stream that hasn't decided much about types and
53    tries to figure out as much as it can, with excessive lookahead and
54    backtracking.  */
55
56 /* fifo of tokens recognized and available to parser.  */
57 struct token
58 {
59   /* The values for YYCHAR will fit in a short.  */
60   short         yychar;
61   unsigned int  lineno;
62   YYSTYPE       yylval;
63 };
64
65 /* Since inline methods can refer to text which has not yet been seen,
66    we store the text of the method in a structure which is placed in the
67    DECL_PENDING_INLINE_INFO field of the FUNCTION_DECL.
68    After parsing the body of the class definition, the FUNCTION_DECL's are
69    scanned to see which ones have this field set.  Those are then digested
70    one at a time.
71
72    This function's FUNCTION_DECL will have a bit set in its common so
73    that we know to watch out for it.  */
74
75 struct unparsed_text
76 {
77   struct unparsed_text *next;   /* process this one next */
78   tree decl;            /* associated declaration */
79   const char *filename; /* name of file we were processing */
80   int lineno;           /* line number we got the text from */
81   int interface;        /* remembering interface_unknown and interface_only */
82
83   struct token *pos;    /* current position, when rescanning */
84   struct token *limit;  /* end of saved text */
85 };
86
87 /* Stack of state saved off when we return to an inline method or
88    default argument that has been stored for later parsing.  */
89 struct feed
90 {
91   struct unparsed_text *input;
92   const char *filename;
93   int lineno;
94   int yychar;
95   YYSTYPE yylval;
96   int first_token;
97   struct obstack token_obstack;
98   struct feed *next;
99 };  
100
101 static struct obstack feed_obstack;
102 static struct feed *feed;
103
104 static SPEW_INLINE void do_aggr PARAMS ((void));
105 static SPEW_INLINE int identifier_type PARAMS ((tree));
106 static void scan_tokens PARAMS ((int));
107 static void feed_defarg PARAMS ((tree));
108 static void finish_defarg PARAMS ((void));
109 static int read_token PARAMS ((struct token *));
110
111 static SPEW_INLINE int num_tokens PARAMS ((void));
112 static SPEW_INLINE struct token *nth_token PARAMS ((int));
113 static SPEW_INLINE int add_token PARAMS ((struct token *));
114 static SPEW_INLINE int shift_token PARAMS ((void));
115 static SPEW_INLINE void push_token PARAMS ((struct token *));
116 static SPEW_INLINE void consume_token PARAMS ((void));
117 static SPEW_INLINE int read_process_identifier PARAMS ((YYSTYPE *));
118
119 static SPEW_INLINE void feed_input PARAMS ((struct unparsed_text *));
120 static SPEW_INLINE void end_input PARAMS ((void));
121 static SPEW_INLINE void snarf_block PARAMS ((const char *, int));
122 static tree snarf_defarg PARAMS ((void));
123 static int frob_id PARAMS ((int, int, tree *));
124
125 /* The list of inline functions being held off until we reach the end of
126    the current class declaration.  */
127 struct unparsed_text *pending_inlines;
128 struct unparsed_text *pending_inlines_tail;
129
130 /* The list of previously-deferred inline functions currently being parsed.
131    This exists solely to be a GC root.  */
132 struct unparsed_text *processing_these_inlines;
133
134 static void begin_parsing_inclass_inline PARAMS ((struct unparsed_text *));
135 static void mark_pending_inlines PARAMS ((PTR));
136
137 #ifdef SPEW_DEBUG
138 int spew_debug = 0;
139 static unsigned int yylex_ctr = 0;
140
141 static void debug_yychar PARAMS ((int));
142
143 /* In parse.y: */
144 extern char *debug_yytranslate PARAMS ((int));
145 #endif
146 static enum cpp_ttype last_token;
147
148 /* From lex.c: */
149 /* the declaration found for the last IDENTIFIER token read in.
150    yylex must look this up to detect typedefs, which get token type TYPENAME,
151    so it is left around in case the identifier is not a typedef but is
152    used in a context which makes it a reference to a variable.  */
153 extern tree lastiddecl;         /* let our brains leak out here too */
154 extern int      yychar;         /*  the lookahead symbol                */
155 extern YYSTYPE  yylval;         /*  the semantic value of the           */
156                                 /*  lookahead symbol                    */
157 /* The token fifo lives in this obstack.  */
158 struct obstack token_obstack;
159 int first_token;
160
161 /* Sometimes we need to save tokens for later parsing.  If so, they are
162    stored on this obstack.  */
163 struct obstack inline_text_obstack;
164 char *inline_text_firstobj;
165
166 /* When we see a default argument in a method declaration, we snarf it as
167    text using snarf_defarg.  When we get up to namespace scope, we then go
168    through and parse all of them using do_pending_defargs.  Since yacc
169    parsers are not reentrant, we retain defargs state in these two
170    variables so that subsequent calls to do_pending_defargs can resume
171    where the previous call left off.  */
172
173 static tree defarg_fns;
174 static tree defarg_parm;
175
176 /* Initialize obstacks. Called once, from init_parse.  */
177
178 void
179 init_spew ()
180 {
181   gcc_obstack_init (&inline_text_obstack);
182   inline_text_firstobj = (char *) obstack_alloc (&inline_text_obstack, 0);
183   gcc_obstack_init (&token_obstack);
184   gcc_obstack_init (&feed_obstack);
185   ggc_add_tree_root (&defarg_fns, 1);
186   ggc_add_tree_root (&defarg_parm, 1);
187
188   ggc_add_root (&pending_inlines, 1, sizeof (struct unparsed_text *),
189                 mark_pending_inlines);
190   ggc_add_root (&processing_these_inlines, 1, sizeof (struct unparsed_text *),
191                 mark_pending_inlines);
192 }
193
194 void
195 clear_inline_text_obstack ()
196 {
197   obstack_free (&inline_text_obstack, inline_text_firstobj);
198 }
199
200 /* Subroutine of read_token.  */
201 static SPEW_INLINE int
202 read_process_identifier (pyylval)
203      YYSTYPE *pyylval;
204 {
205   tree id = pyylval->ttype;
206
207   if (C_IS_RESERVED_WORD (id))
208     {
209       /* Possibly replace the IDENTIFIER_NODE with a magic cookie.
210          Can't put yylval.code numbers in ridpointers[].  Bleah.  */
211
212       switch (C_RID_CODE (id))
213         {
214         case RID_BITAND: pyylval->code = BIT_AND_EXPR;  return '&';
215         case RID_AND_EQ: pyylval->code = BIT_AND_EXPR;  return ASSIGN;
216         case RID_BITOR:  pyylval->code = BIT_IOR_EXPR;  return '|';
217         case RID_OR_EQ:  pyylval->code = BIT_IOR_EXPR;  return ASSIGN;
218         case RID_XOR:    pyylval->code = BIT_XOR_EXPR;  return '^';
219         case RID_XOR_EQ: pyylval->code = BIT_XOR_EXPR;  return ASSIGN;
220         case RID_NOT_EQ: pyylval->code = NE_EXPR;       return EQCOMPARE;
221
222         default:
223           if (C_RID_YYCODE (id) == TYPESPEC)
224             GNU_xref_ref (current_function_decl, IDENTIFIER_POINTER (id));
225
226           pyylval->ttype = ridpointers[C_RID_CODE (id)];
227           return C_RID_YYCODE (id);
228         }
229     }
230
231   GNU_xref_ref (current_function_decl, IDENTIFIER_POINTER (id));
232
233   /* Make sure that user does not collide with our internal naming
234      scheme.  This is not necessary if '.' is used to remove them from
235      the user's namespace, but is if '$' or double underscores are.  */
236
237 #if !defined(JOINER) || JOINER == '$'
238   if (THIS_NAME_P (id)
239       || VPTR_NAME_P (id)
240       || DESTRUCTOR_NAME_P (id)
241       || VTABLE_NAME_P (id)
242       || TEMP_NAME_P (id)
243       || ANON_AGGRNAME_P (id)
244       || ANON_PARMNAME_P (id))
245      warning (
246 "identifier name `%s' conflicts with GNU C++ internal naming strategy",
247               IDENTIFIER_POINTER (id));
248 #endif
249   return IDENTIFIER;
250 }
251
252 /* Read the next token from the input file.  The token is written into
253    T, and its type number is returned.  */
254 static int
255 read_token (t)
256      struct token *t;
257 {
258  retry:
259
260   last_token = c_lex (&t->yylval.ttype);
261
262   switch (last_token)
263     {
264 #define YYCHAR(yy)      t->yychar = yy; break;
265 #define YYCODE(c)       t->yylval.code = c;
266
267     case CPP_EQ:                                YYCHAR('=');
268     case CPP_NOT:                               YYCHAR('!');
269     case CPP_GREATER:   YYCODE(GT_EXPR);        YYCHAR('>');
270     case CPP_LESS:      YYCODE(LT_EXPR);        YYCHAR('<');
271     case CPP_PLUS:      YYCODE(PLUS_EXPR);      YYCHAR('+');
272     case CPP_MINUS:     YYCODE(MINUS_EXPR);     YYCHAR('-');
273     case CPP_MULT:      YYCODE(MULT_EXPR);      YYCHAR('*');
274     case CPP_DIV:       YYCODE(TRUNC_DIV_EXPR); YYCHAR('/');
275     case CPP_MOD:       YYCODE(TRUNC_MOD_EXPR); YYCHAR('%');
276     case CPP_AND:       YYCODE(BIT_AND_EXPR);   YYCHAR('&');
277     case CPP_OR:        YYCODE(BIT_IOR_EXPR);   YYCHAR('|');
278     case CPP_XOR:       YYCODE(BIT_XOR_EXPR);   YYCHAR('^');
279     case CPP_RSHIFT:    YYCODE(RSHIFT_EXPR);    YYCHAR(RSHIFT);
280     case CPP_LSHIFT:    YYCODE(LSHIFT_EXPR);    YYCHAR(LSHIFT);
281
282     case CPP_COMPL:                             YYCHAR('~');
283     case CPP_AND_AND:                           YYCHAR(ANDAND);
284     case CPP_OR_OR:                             YYCHAR(OROR);
285     case CPP_QUERY:                             YYCHAR('?');
286     case CPP_COLON:                             YYCHAR(':');
287     case CPP_COMMA:                             YYCHAR(',');
288     case CPP_OPEN_PAREN:                        YYCHAR('(');
289     case CPP_CLOSE_PAREN:                       YYCHAR(')');
290     case CPP_EQ_EQ:     YYCODE(EQ_EXPR);        YYCHAR(EQCOMPARE);
291     case CPP_NOT_EQ:    YYCODE(NE_EXPR);        YYCHAR(EQCOMPARE);
292     case CPP_GREATER_EQ:YYCODE(GE_EXPR);        YYCHAR(ARITHCOMPARE);
293     case CPP_LESS_EQ:   YYCODE(LE_EXPR);        YYCHAR(ARITHCOMPARE);
294
295     case CPP_PLUS_EQ:   YYCODE(PLUS_EXPR);      YYCHAR(ASSIGN);
296     case CPP_MINUS_EQ:  YYCODE(MINUS_EXPR);     YYCHAR(ASSIGN);
297     case CPP_MULT_EQ:   YYCODE(MULT_EXPR);      YYCHAR(ASSIGN);
298     case CPP_DIV_EQ:    YYCODE(TRUNC_DIV_EXPR); YYCHAR(ASSIGN);
299     case CPP_MOD_EQ:    YYCODE(TRUNC_MOD_EXPR); YYCHAR(ASSIGN);
300     case CPP_AND_EQ:    YYCODE(BIT_AND_EXPR);   YYCHAR(ASSIGN);
301     case CPP_OR_EQ:     YYCODE(BIT_IOR_EXPR);   YYCHAR(ASSIGN);
302     case CPP_XOR_EQ:    YYCODE(BIT_XOR_EXPR);   YYCHAR(ASSIGN);
303     case CPP_RSHIFT_EQ: YYCODE(RSHIFT_EXPR);    YYCHAR(ASSIGN);
304     case CPP_LSHIFT_EQ: YYCODE(LSHIFT_EXPR);    YYCHAR(ASSIGN);
305
306     case CPP_OPEN_SQUARE:                       YYCHAR('[');
307     case CPP_CLOSE_SQUARE:                      YYCHAR(']');
308     case CPP_OPEN_BRACE:                        YYCHAR('{');
309     case CPP_CLOSE_BRACE:                       YYCHAR('}');
310     case CPP_SEMICOLON:                         YYCHAR(';');
311     case CPP_ELLIPSIS:                          YYCHAR(ELLIPSIS);
312
313     case CPP_PLUS_PLUS:                         YYCHAR(PLUSPLUS);
314     case CPP_MINUS_MINUS:                       YYCHAR(MINUSMINUS);
315     case CPP_DEREF:                             YYCHAR(POINTSAT);
316     case CPP_DOT:                               YYCHAR('.');
317
318     /* These tokens are C++ specific.  */
319     case CPP_SCOPE:                             YYCHAR(SCOPE);
320     case CPP_DEREF_STAR:                        YYCHAR(POINTSAT_STAR);
321     case CPP_DOT_STAR:                          YYCHAR(DOT_STAR);
322     case CPP_MIN_EQ:    YYCODE(MIN_EXPR);       YYCHAR(ASSIGN);
323     case CPP_MAX_EQ:    YYCODE(MAX_EXPR);       YYCHAR(ASSIGN);
324     case CPP_MIN:       YYCODE(MIN_EXPR);       YYCHAR(MIN_MAX);
325     case CPP_MAX:       YYCODE(MAX_EXPR);       YYCHAR(MIN_MAX);
326 #undef YYCHAR
327 #undef YYCODE
328
329     case CPP_EOF:
330 #if USE_CPPLIB
331       cpp_pop_buffer (&parse_in);
332       if (CPP_BUFFER (&parse_in))
333         goto retry;
334 #endif
335       t->yychar = 0;
336       break;
337       
338     case CPP_NAME:
339       t->yychar = read_process_identifier (&t->yylval);
340       break;
341
342     case CPP_INT:
343     case CPP_FLOAT:
344     case CPP_NUMBER:
345     case CPP_CHAR:
346     case CPP_WCHAR:
347       t->yychar = CONSTANT;
348       break;
349
350     case CPP_STRING:
351     case CPP_WSTRING:
352       t->yychar = STRING;
353       break;
354
355       /* This token should not be generated in C++ mode.  */
356     case CPP_OSTRING:
357
358       /* These tokens should not survive translation phase 4.  */
359     case CPP_HASH:
360     case CPP_PASTE:
361       error ("syntax error before '#' token");
362       goto retry;
363
364     default:
365       abort ();
366     }
367
368   t->lineno = lineno;
369   return t->yychar;
370 }
371
372 static SPEW_INLINE void
373 feed_input (input)
374      struct unparsed_text *input;
375 {
376   struct feed *f;
377 #if 0
378   if (feed)
379     abort ();
380 #endif
381
382   f = obstack_alloc (&feed_obstack, sizeof (struct feed));
383
384   /* The token list starts just after the struct unparsed_text in memory.  */
385   input->pos = (struct token *) (input + 1);
386
387 #ifdef SPEW_DEBUG
388   if (spew_debug)
389     fprintf (stderr, "\tfeeding %s:%d [%d tokens]\n",
390              input->filename, input->lineno, input->limit - input->pos);
391 #endif
392
393   f->input = input;
394   f->filename = input_filename;
395   f->lineno = lineno;
396   f->yychar = yychar;
397   f->yylval = yylval;
398   f->first_token = first_token;
399   f->token_obstack = token_obstack;
400   f->next = feed;
401
402   input_filename = input->filename;
403   lineno = input->lineno;
404   yychar = YYEMPTY;
405   yylval.ttype = NULL_TREE;
406   first_token = 0;
407   gcc_obstack_init (&token_obstack);
408   feed = f;
409 }
410
411 static SPEW_INLINE void
412 end_input ()
413 {
414   struct feed *f = feed;
415
416   input_filename = f->filename;
417   lineno = f->lineno;
418   yychar = f->yychar;
419   yylval = f->yylval;
420   first_token = f->first_token;
421   obstack_free (&token_obstack, 0);
422   token_obstack = f->token_obstack;
423   feed = f->next;
424
425   obstack_free (&feed_obstack, f);
426
427 #ifdef SPEW_DEBUG
428   if (spew_debug)
429     fprintf (stderr, "\treturning to %s:%d\n", input_filename, lineno);
430 #endif
431 }
432
433 /* GC callback to mark memory pointed to by the pending inline queue.  */
434 static void
435 mark_pending_inlines (pi)
436      PTR pi;
437 {
438   struct unparsed_text *up = * (struct unparsed_text **)pi;
439
440   while (up)
441     {
442       struct token *t = (struct token *) (up + 1);
443       struct token *l = up->limit;
444
445       while (t < l)
446         {
447           /* Some of the possible values for yychar use yylval.code
448              instead of yylval.ttype.  We only have to worry about
449              yychars that could have been returned by read_token.  */
450           switch (t->yychar)
451             {
452             case '+':       case '-':       case '*':       case '/':
453             case '%':       case '&':       case '|':       case '^':
454             case '>':       case '<':       case LSHIFT:    case RSHIFT:
455             case ASSIGN:    case MIN_MAX:   case EQCOMPARE: case ARITHCOMPARE:
456               t++;
457               continue;
458             }
459           if (t->yylval.ttype)
460             ggc_mark_tree (t->yylval.ttype);
461           t++;
462         }
463       up = up->next;
464     }
465 }
466   
467 /* Token queue management.  */
468
469 /* Return the number of tokens available on the fifo.  */
470 static SPEW_INLINE int
471 num_tokens ()
472 {
473   return (obstack_object_size (&token_obstack) / sizeof (struct token))
474     - first_token;
475 }
476
477 /* Fetch the token N down the line from the head of the fifo.  */
478
479 static SPEW_INLINE struct token*
480 nth_token (n)
481      int n;
482 {
483 #ifdef ENABLE_CHECKING
484   /* could just have this do slurp_ implicitly, but this way is easier
485      to debug...  */
486   my_friendly_assert (n >= 0 && n < num_tokens (), 298);
487 #endif
488   return ((struct token*)obstack_base (&token_obstack)) + n + first_token;
489 }
490
491 static const struct token Teosi = { END_OF_SAVED_INPUT, 0 UNION_INIT_ZERO };
492 static const struct token Tpad = { EMPTY, 0 UNION_INIT_ZERO };
493
494 /* Copy the next token into T and return its value.  */
495 static SPEW_INLINE int
496 add_token (t)
497      struct token *t;
498 {
499   if (!feed)
500     return read_token (t);
501
502   if (feed->input->pos < feed->input->limit)
503     {
504       memcpy (t, feed->input->pos, sizeof (struct token));
505       return (feed->input->pos++)->yychar;
506     }
507   
508   memcpy (t, &Teosi, sizeof (struct token));
509   return END_OF_SAVED_INPUT;
510 }
511
512 /* Shift the next token onto the fifo.  */
513 static SPEW_INLINE int
514 shift_token ()
515 {
516   size_t point = obstack_object_size (&token_obstack);
517   obstack_blank (&token_obstack, sizeof (struct token));
518   return add_token ((struct token *) (obstack_base (&token_obstack) + point));
519 }
520
521 /* Consume the next token out of the fifo.  */
522
523 static SPEW_INLINE void
524 consume_token ()
525 {
526   if (num_tokens () == 1)
527     {
528       obstack_free (&token_obstack, obstack_base (&token_obstack));
529       first_token = 0;
530     }
531   else
532     first_token++;
533 }
534
535 /* Push a token at the head of the queue; it will be the next token read.  */
536 static SPEW_INLINE void
537 push_token (t)
538      struct token *t;
539 {
540   if (first_token == 0)  /* We hope this doesn't happen often.  */
541     {
542       size_t active = obstack_object_size (&token_obstack);
543       obstack_blank (&token_obstack, sizeof (struct token));
544       if (active)
545         memmove (obstack_base (&token_obstack) + sizeof (struct token),
546                  obstack_base (&token_obstack), active);
547       first_token++;
548     }
549   first_token--;
550   memcpy (nth_token (0), t, sizeof (struct token));
551 }
552
553
554 /* Pull in enough tokens that the queue is N long beyond the current
555    token.  */
556
557 static void
558 scan_tokens (n)
559      int n;
560 {
561   int i;
562   int num = num_tokens ();
563   int yychar;
564
565   /* First, prune any empty tokens at the end.  */
566   i = num;
567   while (i > 0 && nth_token (i - 1)->yychar == EMPTY)
568     i--;
569   if (i < num)
570     {
571       obstack_blank (&token_obstack, -((num - i) * sizeof (struct token)));
572       num = i;
573     }
574
575   /* Now, if we already have enough tokens, return.  */
576   if (num > n)
577     return;
578
579   /* Never read past these characters: they might separate
580      the current input stream from one we save away later.  */
581   for (i = 0; i < num; i++)
582     {
583       yychar = nth_token (i)->yychar;
584       if (yychar == '{' || yychar == ':' || yychar == ';')
585         goto pad_tokens;
586     }
587
588   while (num_tokens () <= n)
589     {
590       yychar = shift_token ();
591       if (yychar == '{' || yychar == ':' || yychar == ';')
592         goto pad_tokens;
593     }
594   return;
595   
596  pad_tokens:
597   while (num_tokens () <= n)
598     obstack_grow (&token_obstack, &Tpad, sizeof (struct token));
599 }
600
601 int looking_for_typename;
602 int looking_for_template;
603
604 static int after_friend;
605 static int after_new;
606 static int do_snarf_defarg;
607
608 tree got_scope;
609 tree got_object;
610
611 static SPEW_INLINE int
612 identifier_type (decl)
613      tree decl;
614 {
615   tree t;
616
617   if (TREE_CODE (decl) == TEMPLATE_DECL)
618     {
619       if (TREE_CODE (DECL_TEMPLATE_RESULT (decl)) == TYPE_DECL)
620         return PTYPENAME;
621       else if (looking_for_template) 
622         return PFUNCNAME;
623     }
624   if (looking_for_template && really_overloaded_fn (decl))
625     {
626       /* See through a baselink.  */
627       if (TREE_CODE (decl) == TREE_LIST)
628         decl = TREE_VALUE (decl);
629
630       for (t = decl; t != NULL_TREE; t = OVL_CHAIN (t))
631         if (DECL_FUNCTION_TEMPLATE_P (OVL_FUNCTION (t))) 
632           return PFUNCNAME;
633     }
634   if (TREE_CODE (decl) == NAMESPACE_DECL)
635     return NSNAME;
636   if (TREE_CODE (decl) != TYPE_DECL)
637     return IDENTIFIER;
638   if (DECL_ARTIFICIAL (decl) && TREE_TYPE (decl) == current_class_type)
639     return SELFNAME;
640
641   /* A constructor declarator for a template type will get here as an
642      implicit typename, a TYPENAME_TYPE with a type.  */
643   t = got_scope;
644   if (t && TREE_CODE (t) == TYPENAME_TYPE)
645     t = TREE_TYPE (t);
646   decl = TREE_TYPE (decl);
647   if (TREE_CODE (decl) == TYPENAME_TYPE)
648     decl = TREE_TYPE (decl);
649   if (t && t == decl)
650     return SELFNAME;
651
652   return TYPENAME;
653 }
654
655 /* token[0] == AGGR (struct/union/enum)
656    Thus, token[1] is either a TYPENAME or a TYPENAME_DEFN.
657    If token[2] == '{' or ':' then it's TYPENAME_DEFN.
658    It's also a definition if it's a forward declaration (as in 'struct Foo;')
659    which we can tell if token[2] == ';' *and* token[-1] != FRIEND or NEW.  */
660
661 static SPEW_INLINE void
662 do_aggr ()
663 {
664   int yc1, yc2;
665   
666   scan_tokens (2);
667   yc1 = nth_token (1)->yychar;
668   if (yc1 != TYPENAME && yc1 != IDENTIFIER && yc1 != PTYPENAME)
669     return;
670   yc2 = nth_token (2)->yychar;
671   if (yc2 == ';')
672     {
673       /* It's a forward declaration iff we were not preceded by
674          'friend' or `new'.  */
675       if (after_friend || after_new)
676         return;
677     }
678   else if (yc2 != '{' && yc2 != ':')
679     return;
680
681   switch (yc1)
682     {
683     case TYPENAME:
684       nth_token (1)->yychar = TYPENAME_DEFN;
685       break;
686     case PTYPENAME:
687       nth_token (1)->yychar = PTYPENAME_DEFN;
688       break;
689     case IDENTIFIER:
690       nth_token (1)->yychar = IDENTIFIER_DEFN;
691       break;
692     default:
693       my_friendly_abort (102);
694     }
695 }  
696
697 void
698 see_typename ()
699 {
700   /* Only types expected, not even namespaces. */
701   looking_for_typename = 2;
702   if (yychar < 0)
703     if ((yychar = yylex ()) < 0) yychar = 0;
704   looking_for_typename = 0;
705   if (yychar == IDENTIFIER)
706     {
707       lastiddecl = lookup_name (yylval.ttype, -2);
708       if (lastiddecl == 0)
709         {
710           if (flag_labels_ok)
711             lastiddecl = IDENTIFIER_LABEL_VALUE (yylval.ttype);
712         }
713       else
714         yychar = identifier_type (lastiddecl);
715     }
716 }
717
718 int
719 yylex ()
720 {
721   int yychr;
722   int old_looking_for_typename = 0;
723
724   timevar_push (TV_LEX);
725
726  retry:
727 #ifdef SPEW_DEBUG
728   if (spew_debug)
729   {
730     yylex_ctr ++;
731     fprintf (stderr, "\t\t## %d @%d ", yylex_ctr, lineno);
732   }
733 #endif
734
735   if (do_snarf_defarg)
736     {
737       do_snarf_defarg = 0;
738       yylval.ttype = snarf_defarg ();
739       yychar = DEFARG;
740       got_object = NULL_TREE;
741       timevar_pop (TV_LEX);
742       return DEFARG;
743     }
744
745   /* if we've got tokens, send them */
746   else if (num_tokens ())
747     yychr = nth_token (0)->yychar;
748   else
749     yychr = shift_token ();
750
751   /* many tokens just need to be returned. At first glance, all we
752      have to do is send them back up, but some of them are needed to
753      figure out local context.  */
754   switch (yychr)
755     {
756     case EMPTY:
757       /* This is a lexical no-op.  */
758 #ifdef SPEW_DEBUG    
759       if (spew_debug)
760         debug_yychar (yychr);
761 #endif
762       consume_token ();
763       goto retry;
764
765     case '(':
766       scan_tokens (1);
767       if (nth_token (1)->yychar == ')')
768         {
769           consume_token ();
770           yychr = LEFT_RIGHT;
771         }
772       break;
773
774     case IDENTIFIER:
775     {
776       int peek;
777       
778       scan_tokens (1);
779       peek = nth_token (1)->yychar;
780       yychr = frob_id (yychr, peek, &nth_token (0)->yylval.ttype);
781       break;
782     }
783     case IDENTIFIER_DEFN:
784     case TYPENAME:
785     case TYPENAME_DEFN:
786     case PTYPENAME:
787     case PTYPENAME_DEFN:
788       /* If we see a SCOPE next, restore the old value.
789          Otherwise, we got what we want. */
790       looking_for_typename = old_looking_for_typename;
791       looking_for_template = 0;
792       break;
793
794     case SCSPEC:
795       if (nth_token (0)->yylval.ttype == ridpointers[RID_EXTERN])
796         {
797           scan_tokens (1);
798           if (nth_token (1)->yychar == STRING)
799             {
800               yychr = EXTERN_LANG_STRING;
801               nth_token (1)->yylval.ttype = get_identifier
802                 (TREE_STRING_POINTER (nth_token (1)->yylval.ttype));
803               consume_token ();
804             }
805         }
806       /* If export, warn that it's unimplemented and go on. */
807       else if (nth_token (0)->yylval.ttype == ridpointers[RID_EXPORT])
808         {
809           warning ("keyword 'export' not implemented and will be ignored");
810 #ifdef SPEW_DEBUG    
811           if (spew_debug)
812             debug_yychar (yychr);
813 #endif
814           consume_token ();
815           goto retry;
816         }
817       /* do_aggr needs to know if the previous token was `friend'.  */
818       else if (nth_token (0)->yylval.ttype == ridpointers[RID_FRIEND])
819         after_friend = 1;
820
821       break;
822
823     case NEW:
824       /* do_aggr needs to know if the previous token was `new'.  */
825       after_new = 1;
826       break;
827
828     case TYPESPEC:
829     case '{':
830     case ':':
831     case ';':
832       /* If this provides a type for us, then revert lexical
833          state to standard state.  */
834       looking_for_typename = 0;
835       break;
836
837     case AGGR:
838       do_aggr ();
839       after_friend = after_new = 0;
840       break;
841
842     case ENUM:
843       /* Set this again, in case we are rescanning.  */
844       looking_for_typename = 2;
845       break;
846
847     default:
848       break;
849     }
850
851   /* class member lookup only applies to the first token after the object
852      expression, except for explicit destructor calls.  */
853   if (yychr != '~')
854     got_object = NULL_TREE;
855
856   yychar = yychr;
857   yylval = nth_token (0)->yylval;
858   lineno = nth_token (0)->lineno;
859
860 #ifdef SPEW_DEBUG    
861   if (spew_debug)
862     debug_yychar (yychr);
863 #endif
864   consume_token ();
865
866   timevar_pop (TV_LEX);
867   return yychr;
868 }
869
870 /* Unget character CH from the input stream.
871    If RESCAN is non-zero, then we want to `see' this
872    character as the next input token.  */
873
874 void
875 yyungetc (ch, rescan)
876      int ch;
877      int rescan;
878 {
879   /* Unget a character from the input stream.  */
880   if (yychar == YYEMPTY || rescan == 0)
881     {
882       struct token fake;
883
884       /* If we're putting back a brace, undo the change in indent_level
885          from the first time we saw it.  */
886       if (ch == '{')
887         indent_level--;
888       else if (ch == '}')
889         indent_level++;
890
891       fake.yychar = ch;
892       fake.yylval.ttype = 0;
893       fake.lineno = lineno;
894
895       push_token (&fake);
896     }
897   else
898     {
899       yychar = ch;
900     }
901 }
902
903 /* Lexer hackery to determine what *IDP really is.  */
904
905 static int
906 frob_id (yyc, peek, idp)
907      int yyc;
908      int peek;
909      tree *idp;
910 {
911   tree trrr;
912   int old_looking_for_typename = 0;
913   
914   if (peek == SCOPE)
915     {
916       /* Don't interfere with the setting from an 'aggr' prefix.  */
917       old_looking_for_typename = looking_for_typename;
918       looking_for_typename = 1;
919     }
920   else if (peek == '<')
921     looking_for_template = 1;
922   trrr = lookup_name (*idp, -2);
923   if (trrr)
924     {
925       yyc = identifier_type (trrr);
926       switch(yyc)
927         {
928           case TYPENAME:
929           case SELFNAME:
930           case NSNAME:
931           case PTYPENAME:
932             /* If this got special lookup, remember it.  In these
933                cases, we know it can't be a declarator-id. */
934             if (got_scope || got_object)
935               *idp = trrr;
936             /* FALLTHROUGH */
937           case PFUNCNAME:
938           case IDENTIFIER:
939             lastiddecl = trrr;
940             break;
941           default:
942             my_friendly_abort (20000907);
943         }
944     }
945   else
946     lastiddecl = NULL_TREE;
947   got_scope = NULL_TREE;
948   looking_for_typename = old_looking_for_typename;
949   looking_for_template = 0;
950   return yyc;
951 }
952
953 /* ID is an operator name. Duplicate the hackery in yylex to determine what
954    it really is.  */
955
956 tree frob_opname (id)
957      tree id;
958 {
959   scan_tokens (0);
960   frob_id (0, nth_token (0)->yychar, &id);
961   got_object = NULL_TREE;
962   return id;
963 }
964
965 /* Set up the state required to correctly handle the definition of the
966    inline function whose preparsed state has been saved in PI.  */
967
968 static void
969 begin_parsing_inclass_inline (pi)
970      struct unparsed_text *pi;
971 {
972   tree context;
973
974   /* Record that we are processing the chain of inlines starting at
975      PI in a special GC root.  */
976   processing_these_inlines = pi;
977
978   ggc_collect ();
979
980   /* If this is an inline function in a local class, we must make sure
981      that we save all pertinent information about the function
982      surrounding the local class.  */
983   context = decl_function_context (pi->decl);
984   if (context)
985     push_function_context_to (context);
986
987   feed_input (pi);
988   interface_unknown = pi->interface == 1;
989   interface_only  = pi->interface == 0;
990   DECL_PENDING_INLINE_P (pi->decl) = 0;
991   DECL_PENDING_INLINE_INFO (pi->decl) = 0;
992
993   /* Pass back a handle to the rest of the inline functions, so that they
994      can be processed later.  */
995   yychar = PRE_PARSED_FUNCTION_DECL;
996   yylval.pi = pi;
997
998   start_function (NULL_TREE, pi->decl, NULL_TREE,
999                   (SF_DEFAULT | SF_PRE_PARSED | SF_INCLASS_INLINE));
1000 }
1001
1002 /* Called from the top level: if there are any pending inlines to
1003    do, set up to process them now.  This function sets up the first function
1004    to be parsed; after it has been, the rule for fndef in parse.y will
1005    call process_next_inline to start working on the next one.  */
1006
1007 void
1008 do_pending_inlines ()
1009 {
1010   /* Oops, we're still dealing with the last batch.  */
1011   if (yychar == PRE_PARSED_FUNCTION_DECL)
1012     return;
1013
1014   if (pending_inlines)
1015     {
1016       /* Clear the chain, so that any inlines nested inside the batch
1017          we're to process now don't refer to this batch.  See e.g.
1018          g++.other/lookup6.C.  */
1019       struct unparsed_text *first = pending_inlines;
1020       pending_inlines = pending_inlines_tail = 0;
1021
1022       begin_parsing_inclass_inline (first);
1023     }
1024 }
1025
1026 /* Called from the fndecl rule in the parser when the function just parsed
1027    was declared using a PRE_PARSED_FUNCTION_DECL (i.e. came from
1028    do_pending_inlines).  */
1029
1030 void
1031 process_next_inline (i)
1032      struct unparsed_text *i;
1033 {
1034   tree decl = i->decl;
1035   tree context = decl_function_context (decl);
1036
1037   if (context)
1038     pop_function_context_from (context);
1039   if (yychar == YYEMPTY)
1040     yychar = yylex ();
1041   if (yychar != END_OF_SAVED_INPUT)
1042     error ("parse error at end of saved function text");
1043   end_input ();
1044
1045   i = i->next;
1046   if (i)
1047     begin_parsing_inclass_inline (i);
1048   else
1049     {
1050       processing_these_inlines = 0;
1051       extract_interface_info ();
1052     }
1053 }
1054
1055
1056 /* Subroutine of snarf_method, deals with actual absorption of the block.  */
1057
1058 static SPEW_INLINE void
1059 snarf_block (starting_file, starting_line)
1060      const char *starting_file;
1061      int starting_line;
1062 {
1063   int blev = 1;
1064   int look_for_semicolon = 0;
1065   int look_for_lbrac = 0;
1066   int look_for_catch = 0;
1067   int yyc;
1068   struct token tmp;
1069   size_t point;
1070
1071   if (yychar == '{')
1072     /* We incremented indent_level in yylex; undo that.  */
1073     indent_level--;
1074   else if (yychar == '=')
1075     look_for_semicolon = 1;
1076   else if (yychar == ':' || yychar == RETURN_KEYWORD || yychar == TRY)
1077     {
1078       if (yychar == TRY)
1079         look_for_catch = 1;
1080       look_for_lbrac = 1;
1081       blev = 0;
1082     }
1083   else
1084     yyerror ("parse error in method specification");
1085
1086   /* The current token is the first one to be recorded.  */
1087   tmp.yychar = yychar;
1088   tmp.yylval = yylval;
1089   tmp.lineno = lineno;
1090   obstack_grow (&inline_text_obstack, &tmp, sizeof (struct token));
1091
1092   for (;;)
1093     {
1094       point = obstack_object_size (&inline_text_obstack);
1095       obstack_blank (&inline_text_obstack, sizeof (struct token));
1096       yyc = add_token ((struct token *)
1097                        (obstack_base (&inline_text_obstack) + point));
1098
1099       if (yyc == '{')
1100         {
1101           look_for_lbrac = 0;
1102           blev++;
1103         }
1104       else if (yyc == '}')
1105         {
1106           blev--;
1107           if (blev == 0 && !look_for_semicolon)
1108             {
1109               if (!look_for_catch)
1110                 break;
1111               
1112               if (add_token (&tmp) != CATCH)
1113                 {
1114                   push_token (&tmp);
1115                   break;
1116                 }
1117
1118               look_for_lbrac = 1;
1119               obstack_grow (&inline_text_obstack, &tmp, sizeof (struct token));
1120             }
1121         }
1122       else if (yyc == ';')
1123         {
1124           if (look_for_lbrac)
1125             {
1126               error ("function body for constructor missing");
1127               /* fake a { } to avoid further errors */
1128               tmp.yylval.ttype = 0;
1129               tmp.yychar = '{';
1130               obstack_grow (&inline_text_obstack, &tmp, sizeof (struct token));
1131               tmp.yychar = '}';
1132               obstack_grow (&inline_text_obstack, &tmp, sizeof (struct token));
1133               break;
1134             }
1135           else if (look_for_semicolon && blev == 0)
1136             break;
1137         }
1138       else if (yyc == 0)
1139         {
1140           error_with_file_and_line (starting_file, starting_line,
1141                                     "end of file read inside definition");
1142           break;
1143         }
1144     }
1145 }
1146
1147 /* This function stores away the text for an inline function that should
1148    be processed later (by do_pending_inlines).  */
1149 void
1150 snarf_method (decl)
1151      tree decl;
1152 {
1153   int starting_lineno = lineno;
1154   const char *starting_filename = input_filename;
1155   size_t len;
1156
1157   struct unparsed_text *meth;
1158
1159   /* Leave room for the header, then absorb the block.  */
1160   obstack_blank (&inline_text_obstack, sizeof (struct unparsed_text));
1161   snarf_block (starting_filename, starting_lineno);
1162
1163   len = obstack_object_size (&inline_text_obstack);
1164   meth = (struct unparsed_text *) obstack_finish (&inline_text_obstack);
1165
1166   /* Happens when we get two declarations of the same function in the
1167      same scope.  */
1168   if (decl == void_type_node
1169       || (current_class_type && TYPE_REDEFINED (current_class_type)))
1170     {
1171       obstack_free (&inline_text_obstack, (char *)meth);
1172       return;
1173     }
1174
1175   meth->decl = decl;
1176   meth->filename = starting_filename;
1177   meth->lineno = starting_lineno;
1178   meth->limit = (struct token *) ((char *)meth + len);
1179   meth->interface = (interface_unknown ? 1 : (interface_only ? 0 : 2));
1180   meth->next = 0;
1181
1182 #ifdef SPEW_DEBUG
1183   if (spew_debug)
1184     fprintf (stderr, "\tsaved method of %d tokens from %s:%d\n",
1185              meth->limit - (struct token *) (meth + 1),
1186              starting_filename, starting_lineno);
1187 #endif
1188
1189   DECL_PENDING_INLINE_INFO (decl) = meth;
1190   DECL_PENDING_INLINE_P (decl) = 1;
1191
1192   if (pending_inlines_tail)
1193     pending_inlines_tail->next = meth;
1194   else
1195     pending_inlines = meth;
1196   pending_inlines_tail = meth;
1197 }
1198
1199 /* Consume a no-commas expression - a default argument - and save it
1200    on the inline_text_obstack.  */
1201
1202 static tree
1203 snarf_defarg ()
1204 {
1205   int starting_lineno = lineno;
1206   const char *starting_filename = input_filename;
1207   int yyc;
1208   int plev = 0;
1209   size_t point;
1210   size_t len;
1211   struct unparsed_text *buf;
1212   tree arg;
1213
1214   obstack_blank (&inline_text_obstack, sizeof (struct unparsed_text));
1215
1216   for (;;)
1217     {
1218       point = obstack_object_size (&inline_text_obstack);
1219       obstack_blank (&inline_text_obstack, sizeof (struct token));
1220       yyc = add_token ((struct token *)
1221                        (obstack_base (&inline_text_obstack) + point));
1222
1223       if (plev <= 0 && (yyc == ')' || yyc == ','))
1224         break;
1225       else if (yyc == '(' || yyc == '[')
1226         ++plev;
1227       else if (yyc == ']' || yyc == ')')
1228         --plev;
1229       else if (yyc == 0)
1230         {
1231           error_with_file_and_line (starting_filename, starting_lineno,
1232                                     "end of file read inside default argument");
1233           goto done;
1234         }
1235     }
1236
1237   /* Unget the last token.  */
1238   push_token ((struct token *) (obstack_base (&inline_text_obstack) + point));
1239   /* This is the documented way to shrink a growing obstack block.  */
1240   obstack_blank (&inline_text_obstack, - (int) sizeof (struct token));
1241
1242  done:
1243   len = obstack_object_size (&inline_text_obstack);
1244   buf = (struct unparsed_text *) obstack_finish (&inline_text_obstack);
1245
1246   buf->decl = 0;
1247   buf->filename = starting_filename;
1248   buf->lineno = starting_lineno;
1249   buf->limit = (struct token *) ((char *)buf + len);
1250   buf->next = 0;
1251   
1252 #ifdef SPEW_DEBUG
1253   if (spew_debug)
1254     fprintf (stderr, "\tsaved defarg of %d tokens from %s:%d\n",
1255              buf->limit - (struct token *) (buf + 1),
1256              starting_filename, starting_lineno);
1257 #endif
1258
1259   arg = make_node (DEFAULT_ARG);
1260   DEFARG_POINTER (arg) = (char *)buf;
1261
1262   return arg;
1263 }
1264
1265 /* Decide whether the default argument we are about to see should be
1266    gobbled up as text for later parsing.  */
1267
1268 void
1269 maybe_snarf_defarg ()
1270 {
1271   if (current_class_type && TYPE_BEING_DEFINED (current_class_type))
1272     do_snarf_defarg = 1;
1273 }
1274
1275 /* Called from grokfndecl to note a function decl with unparsed default
1276    arguments for later processing.  Also called from grokdeclarator
1277    for function types with unparsed defargs; the call from grokfndecl
1278    will always come second, so we can overwrite the entry from the type.  */
1279
1280 void
1281 add_defarg_fn (decl)
1282      tree decl;
1283 {
1284   if (TREE_CODE (decl) == FUNCTION_DECL)
1285     TREE_VALUE (defarg_fns) = decl;
1286   else
1287     defarg_fns = tree_cons (current_class_type, decl, defarg_fns);  
1288 }
1289
1290 /* Helper for do_pending_defargs.  Starts the parsing of a default arg.  */
1291
1292 static void
1293 feed_defarg (p)
1294      tree p;
1295 {
1296   tree d = TREE_PURPOSE (p);
1297
1298   feed_input ((struct unparsed_text *)DEFARG_POINTER (d));
1299   yychar = DEFARG_MARKER;
1300   yylval.ttype = p;
1301 }
1302
1303 /* Helper for do_pending_defargs.  Ends the parsing of a default arg.  */
1304
1305 static void
1306 finish_defarg ()
1307 {
1308   if (yychar == YYEMPTY)
1309     yychar = yylex ();
1310   if (yychar != END_OF_SAVED_INPUT)
1311     error ("parse error at end of saved function text");
1312
1313   end_input ();
1314 }  
1315
1316 /* Main function for deferred parsing of default arguments.  Called from
1317    the parser.  */
1318
1319 void
1320 do_pending_defargs ()
1321 {
1322   if (defarg_parm)
1323     finish_defarg ();
1324
1325   for (; defarg_fns; defarg_fns = TREE_CHAIN (defarg_fns))
1326     {
1327       tree defarg_fn = TREE_VALUE (defarg_fns);
1328       if (defarg_parm == NULL_TREE)
1329         {
1330           push_nested_class (TREE_PURPOSE (defarg_fns), 1);
1331           pushlevel (0);
1332           if (TREE_CODE (defarg_fn) == FUNCTION_DECL)
1333             maybe_begin_member_template_processing (defarg_fn);
1334
1335           if (TREE_CODE (defarg_fn) == FUNCTION_DECL)
1336             defarg_parm = TYPE_ARG_TYPES (TREE_TYPE (defarg_fn));
1337           else
1338             defarg_parm = TYPE_ARG_TYPES (defarg_fn);
1339         }
1340       else
1341         defarg_parm = TREE_CHAIN (defarg_parm);
1342
1343       for (; defarg_parm; defarg_parm = TREE_CHAIN (defarg_parm))
1344         if (TREE_PURPOSE (defarg_parm)
1345             && TREE_CODE (TREE_PURPOSE (defarg_parm)) == DEFAULT_ARG)
1346           {
1347             feed_defarg (defarg_parm);
1348
1349             /* Return to the parser, which will process this defarg
1350                and call us again.  */
1351             return;
1352           }
1353
1354       if (TREE_CODE (defarg_fn) == FUNCTION_DECL)
1355         {
1356           maybe_end_member_template_processing ();
1357           check_default_args (defarg_fn);
1358         }
1359
1360       poplevel (0, 0, 0);
1361       pop_nested_class ();
1362     }
1363 }
1364
1365 #ifdef SPEW_DEBUG    
1366 /* debug_yychar takes a yychar (token number) value and prints its name.  */
1367
1368 static void
1369 debug_yychar (yy)
1370      int yy;
1371 {
1372   if (yy<256)
1373     fprintf (stderr, "->%d < %c >\n", lineno, yy);
1374   else if (yy == IDENTIFIER || yy == TYPENAME)
1375     {
1376       const char *id;
1377       if (TREE_CODE (yylval.ttype) == IDENTIFIER_NODE)
1378         id = IDENTIFIER_POINTER (yylval.ttype);
1379       else if (TREE_CODE_CLASS (TREE_CODE (yylval.ttype)) == 'd')
1380         id = IDENTIFIER_POINTER (DECL_NAME (yylval.ttype));
1381       else
1382         id = "";
1383       fprintf (stderr, "->%d <%s `%s'>\n", lineno, debug_yytranslate (yy), id);
1384     }
1385   else
1386     fprintf (stderr, "->%d <%s>\n", lineno, debug_yytranslate (yy));
1387 }
1388
1389 #endif
1390
1391 #if USE_CPPLIB
1392 #define NAME(type) cpp_type2name (type)
1393 #else
1394 /* Bleah */
1395 #include "symcat.h"
1396 #define OP(e, s) s,
1397 #define TK(e, s) STRINGX(e),
1398
1399 static const char *type2name[N_TTYPES] = { TTYPE_TABLE };
1400 #define NAME(type) type2name[type]
1401 #endif
1402
1403 void
1404 yyerror (msgid)
1405      const char *msgid;
1406 {
1407   const char *string = _(msgid);
1408
1409   if (last_token == CPP_EOF)
1410     error ("%s at end of input", string);
1411   else if (last_token == CPP_CHAR || last_token == CPP_WCHAR)
1412     {
1413       unsigned int val = TREE_INT_CST_LOW (yylval.ttype);
1414       const char *ell = (last_token == CPP_CHAR) ? "" : "L";
1415       if (val <= UCHAR_MAX && ISGRAPH (val))
1416         error ("%s before %s'%c'", string, ell, val);
1417       else
1418         error ("%s before %s'\\x%x'", string, ell, val);
1419     }
1420   else if (last_token == CPP_STRING
1421            || last_token == CPP_WSTRING
1422            || last_token == CPP_OSTRING)
1423     error ("%s before string constant", string);
1424   else if (last_token == CPP_NUMBER
1425            || last_token == CPP_INT
1426            || last_token == CPP_FLOAT)
1427     error ("%s before numeric constant", string);
1428   else if (last_token == CPP_NAME
1429            && TREE_CODE (yylval.ttype) == IDENTIFIER_NODE)
1430     error ("%s before \"%s\"", string, IDENTIFIER_POINTER (yylval.ttype));
1431   else
1432     error ("%s before '%s' token", string, NAME(last_token));
1433 }