OSDN Git Service

2002-08-24 Matt Austern <austern@apple.com>
[pf3gnuchains/gcc-fork.git] / gcc / cp / parse.y
1 /* YACC parser for C++ syntax.
2    Copyright (C) 1988, 1989, 1993, 1994, 1995, 1996, 1997, 1998,
3    1999, 2000, 2001, 2002 Free Software Foundation, Inc.
4    Hacked by Michael Tiemann (tiemann@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
24 /* This grammar is based on the GNU CC grammar.  */
25
26 /* Note: Bison automatically applies a default action of "$$ = $1" for
27    all derivations; this is applied before the explicit action, if one
28    is given.  Keep this in mind when reading the actions.  */
29
30 %{
31 #include "config.h"
32
33 #include "system.h"
34
35 #include "tree.h"
36 #include "input.h"
37 #include "flags.h"
38 #include "cp-tree.h"
39 #include "decl.h"
40 #include "lex.h"
41 #include "c-pragma.h"           /* For YYDEBUG definition.  */
42 #include "output.h"
43 #include "except.h"
44 #include "toplev.h"
45 #include "ggc.h"
46
47 /* Like YYERROR but do call yyerror.  */
48 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
49
50 /* Like the default stack expander, except (1) use realloc when possible,
51    (2) impose no hard maxiumum on stack size, (3) REALLY do not use alloca.
52
53    Irritatingly, YYSTYPE is defined after this %{ %} block, so we cannot
54    give malloced_yyvs its proper type.  This is ok since all we need from
55    it is to be able to free it.  */
56
57 static short *malloced_yyss;
58 static void *malloced_yyvs;
59
60 #define yyoverflow(MSG, SS, SSSIZE, VS, VSSIZE, YYSSZ)                  \
61 do {                                                                    \
62   size_t newsize;                                                       \
63   short *newss;                                                         \
64   YYSTYPE *newvs;                                                       \
65   newsize = *(YYSSZ) *= 2;                                              \
66   if (malloced_yyss)                                                    \
67     {                                                                   \
68       newss = (short *)                                                 \
69         really_call_realloc (*(SS), newsize * sizeof (short));          \
70       newvs = (YYSTYPE *)                                               \
71         really_call_realloc (*(VS), newsize * sizeof (YYSTYPE));        \
72     }                                                                   \
73   else                                                                  \
74     {                                                                   \
75       newss = (short *) really_call_malloc (newsize * sizeof (short));  \
76       newvs = (YYSTYPE *) really_call_malloc (newsize * sizeof (YYSTYPE)); \
77       if (newss)                                                        \
78         memcpy (newss, *(SS), (SSSIZE));                                \
79       if (newvs)                                                        \
80         memcpy (newvs, *(VS), (VSSIZE));                                \
81     }                                                                   \
82   if (!newss || !newvs)                                                 \
83     {                                                                   \
84       yyerror (MSG);                                                    \
85       return 2;                                                         \
86     }                                                                   \
87   *(SS) = newss;                                                        \
88   *(VS) = newvs;                                                        \
89   malloced_yyss = newss;                                                \
90   malloced_yyvs = (void *) newvs;                                       \
91 } while (0)
92 #define OP0(NODE) (TREE_OPERAND (NODE, 0))
93 #define OP1(NODE) (TREE_OPERAND (NODE, 1))
94
95 /* Contains the statement keyword (if/while/do) to include in an
96    error message if the user supplies an empty conditional expression.  */
97 static const char *cond_stmt_keyword;
98
99 /* List of types and structure classes of the current declaration.  */
100 static GTY(()) tree current_declspecs;
101
102 /* List of prefix attributes in effect.
103    Prefix attributes are parsed by the reserved_declspecs and declmods
104    rules.  They create a list that contains *both* declspecs and attrs.  */
105 /* ??? It is not clear yet that all cases where an attribute can now appear in
106    a declspec list have been updated.  */
107 static GTY(()) tree prefix_attributes;
108
109 /* When defining an enumeration, this is the type of the enumeration.  */
110 static GTY(()) tree current_enum_type;
111
112 /* When parsing a conversion operator name, this is the scope of the
113    operator itself.  */
114 static GTY(()) tree saved_scopes;
115
116 static tree empty_parms PARAMS ((void));
117 static tree parse_decl0 PARAMS ((tree, tree, tree, tree, int));
118 static tree parse_decl PARAMS ((tree, tree, int));
119 static void parse_end_decl PARAMS ((tree, tree, tree));
120 static tree parse_field0 PARAMS ((tree, tree, tree, tree, tree, tree));
121 static tree parse_field PARAMS ((tree, tree, tree, tree));
122 static tree parse_bitfield0 PARAMS ((tree, tree, tree, tree, tree));
123 static tree parse_bitfield PARAMS ((tree, tree, tree));
124 static tree parse_method PARAMS ((tree, tree, tree));
125 static void frob_specs PARAMS ((tree, tree));
126 static void check_class_key PARAMS ((tree, tree));
127 static tree parse_scoped_id PARAMS ((tree));
128 static tree parse_xref_tag (tree, tree, int);
129 static tree parse_handle_class_head (tree, tree, tree, int, int *);
130 static void parse_decl_instantiation (tree, tree, tree);
131 static int parse_begin_function_definition (tree, tree);
132 static tree parse_finish_call_expr (tree, tree, int);
133
134 /* Cons up an empty parameter list.  */
135 static inline tree
136 empty_parms ()
137 {
138   tree parms;
139
140 #ifndef NO_IMPLICIT_EXTERN_C
141   if (in_system_header && current_class_type == NULL
142       && current_lang_name == lang_name_c)
143     parms = NULL_TREE;
144   else
145 #endif
146   parms = void_list_node;
147   return parms;
148 }
149
150 /* Record the decl-specifiers, attributes and type lookups from the
151    decl-specifier-seq in a declaration.  */
152
153 static void
154 frob_specs (specs_attrs, lookups)
155      tree specs_attrs, lookups;
156 {
157   save_type_access_control (lookups);
158   split_specs_attrs (specs_attrs, &current_declspecs, &prefix_attributes);
159   if (current_declspecs
160       && TREE_CODE (current_declspecs) != TREE_LIST)
161     current_declspecs = build_tree_list (NULL_TREE, current_declspecs);
162   if (have_extern_spec)
163     {
164       /* We have to indicate that there is an "extern", but that it
165          was part of a language specifier.  For instance,
166
167             extern "C" typedef int (*Ptr) ();
168
169          is well formed.  */
170       current_declspecs = tree_cons (error_mark_node,
171                                      get_identifier ("extern"),
172                                      current_declspecs);
173       have_extern_spec = false;
174     }
175 }
176
177 static tree
178 parse_decl (declarator, attributes, initialized)
179      tree declarator, attributes;
180      int initialized;
181 {
182   return start_decl (declarator, current_declspecs, initialized,
183                      attributes, prefix_attributes);
184 }
185
186 static tree
187 parse_decl0 (declarator, specs_attrs, lookups, attributes, initialized)
188      tree declarator, specs_attrs, lookups, attributes;
189      int initialized;
190 {
191   frob_specs (specs_attrs, lookups);
192   return parse_decl (declarator, attributes, initialized);
193 }
194
195 static void
196 parse_end_decl (decl, init, asmspec)
197      tree decl, init, asmspec;
198 {
199   /* If decl is NULL_TREE, then this was a variable declaration using
200      () syntax for the initializer, so we handled it in grokdeclarator.  */
201   if (decl)
202     decl_type_access_control (decl);
203   cp_finish_decl (decl, init, asmspec, init ? LOOKUP_ONLYCONVERTING : 0);
204 }
205
206 static tree
207 parse_field (declarator, attributes, asmspec, init)
208      tree declarator, attributes, asmspec, init;
209 {
210   tree d = grokfield (declarator, current_declspecs, init, asmspec,
211                       chainon (attributes, prefix_attributes));
212   decl_type_access_control (d);
213   return d;
214 }
215
216 static tree
217 parse_field0 (declarator, specs_attrs, lookups, attributes, asmspec, init)
218      tree declarator, specs_attrs, lookups, attributes, asmspec, init;
219 {
220   frob_specs (specs_attrs, lookups);
221   return parse_field (declarator, attributes, asmspec, init);
222 }
223
224 static tree
225 parse_bitfield (declarator, attributes, width)
226      tree declarator, attributes, width;
227 {
228   tree d = grokbitfield (declarator, current_declspecs, width);
229   cplus_decl_attributes (&d, chainon (attributes, prefix_attributes), 0);
230   decl_type_access_control (d);
231   return d;
232 }
233
234 static tree
235 parse_bitfield0 (declarator, specs_attrs, lookups, attributes, width)
236      tree declarator, specs_attrs, lookups, attributes, width;
237 {
238   frob_specs (specs_attrs, lookups);
239   return parse_bitfield (declarator, attributes, width);
240 }
241
242 static tree
243 parse_method (declarator, specs_attrs, lookups)
244      tree declarator, specs_attrs, lookups;
245 {
246   tree d;
247   frob_specs (specs_attrs, lookups);
248   d = start_method (current_declspecs, declarator, prefix_attributes);
249   decl_type_access_control (d);
250   return d;
251 }
252
253 static void
254 check_class_key (key, aggr)
255      tree key;
256      tree aggr;
257 {
258   if (TREE_CODE (key) == TREE_LIST)
259     key = TREE_VALUE (key);
260   if ((key == union_type_node) != (TREE_CODE (aggr) == UNION_TYPE))
261     pedwarn ("`%s' tag used in naming `%#T'",
262              key == union_type_node ? "union"
263              : key == record_type_node ? "struct" : "class", aggr);
264 }
265
266 %}
267
268 %start program
269
270 %union { GTY(())
271   long itype;
272   tree ttype;
273   char *strtype;
274   enum tree_code code;
275   flagged_type_tree ftype;
276   struct unparsed_text *pi;
277 }
278
279 /* All identifiers that are not reserved words
280    and are not declared typedefs in the current block */
281 %token IDENTIFIER
282
283 /* All identifiers that are declared typedefs in the current block.
284    In some contexts, they are treated just like IDENTIFIER,
285    but they can also serve as typespecs in declarations.  */
286 %token tTYPENAME
287 %token SELFNAME
288
289 /* A template function.  */
290 %token PFUNCNAME
291
292 /* Reserved words that specify storage class.
293    yylval contains an IDENTIFIER_NODE which indicates which one.  */
294 %token SCSPEC
295
296 /* Reserved words that specify type.
297    yylval contains an IDENTIFIER_NODE which indicates which one.  */
298 %token TYPESPEC
299
300 /* Reserved words that qualify type: "const" or "volatile".
301    yylval contains an IDENTIFIER_NODE which indicates which one.  */
302 %token CV_QUALIFIER
303
304 /* Character or numeric constants.
305    yylval is the node for the constant.  */
306 %token CONSTANT
307
308 /* __func__, __FUNCTION__ or __PRETTY_FUNCTION__.
309    yylval contains an IDENTIFIER_NODE which indicates which one.  */
310 %token <ttype> VAR_FUNC_NAME
311
312 /* String constants in raw form.
313    yylval is a STRING_CST node.  */
314 %token STRING
315
316 /* "...", used for functions with variable arglists.  */
317 %token ELLIPSIS
318
319 /* the reserved words */
320 /* SCO include files test "ASM", so use something else.  */
321 %token SIZEOF ENUM /* STRUCT UNION */ IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
322 %token BREAK CONTINUE RETURN_KEYWORD GOTO ASM_KEYWORD TYPEOF ALIGNOF
323 %token SIGOF
324 %token ATTRIBUTE EXTENSION LABEL
325 %token REALPART IMAGPART VA_ARG
326
327 /* the reserved words... C++ extensions */
328 %token <ttype> AGGR
329 %token <ttype> VISSPEC
330 %token DELETE NEW THIS OPERATOR CXX_TRUE CXX_FALSE
331 %token NAMESPACE TYPENAME_KEYWORD USING
332 %token LEFT_RIGHT TEMPLATE
333 %token TYPEID DYNAMIC_CAST STATIC_CAST REINTERPRET_CAST CONST_CAST
334 %token SCOPE EXPORT
335
336 /* Define the operator tokens and their precedences.
337    The value is an integer because, if used, it is the tree code
338    to use in the expression made from the operator.  */
339
340 %left EMPTY                     /* used to resolve s/r with epsilon */
341
342 %left error
343
344 /* Add precedence rules to solve dangling else s/r conflict */
345 %nonassoc IF
346 %nonassoc ELSE
347
348 %left IDENTIFIER PFUNCNAME tTYPENAME SELFNAME PTYPENAME SCSPEC TYPESPEC CV_QUALIFIER ENUM AGGR ELLIPSIS TYPEOF SIGOF OPERATOR NSNAME TYPENAME_KEYWORD ATTRIBUTE
349
350 %left '{' ',' ';'
351
352 %nonassoc THROW
353 %right <code> ':'
354 %right <code> ASSIGN '='
355 %right <code> '?'
356 %left <code> OROR
357 %left <code> ANDAND
358 %left <code> '|'
359 %left <code> '^'
360 %left <code> '&'
361 %left <code> MIN_MAX
362 %left <code> EQCOMPARE
363 %left <code> ARITHCOMPARE '<' '>'
364 %left <code> LSHIFT RSHIFT
365 %left <code> '+' '-'
366 %left <code> '*' '/' '%'
367 %left <code> POINTSAT_STAR DOT_STAR
368 %right <code> UNARY PLUSPLUS MINUSMINUS '~'
369 %left HYPERUNARY
370 %left <ttype> LEFT_RIGHT
371 %left <code> POINTSAT '.' '(' '['
372
373 %right SCOPE                    /* C++ extension */
374 %nonassoc NEW DELETE TRY CATCH
375
376 %type <code> unop
377
378 %type <ttype> identifier IDENTIFIER tTYPENAME CONSTANT expr nonnull_exprlist
379 %type <ttype> PFUNCNAME maybe_identifier
380 %type <ttype> paren_expr_or_null nontrivial_exprlist SELFNAME
381 %type <ttype> expr_no_commas expr_no_comma_rangle
382 %type <ttype> cast_expr unary_expr primary STRING
383 %type <ttype> reserved_declspecs boolean_literal
384 %type <ttype> reserved_typespecquals
385 %type <ttype> SCSPEC TYPESPEC CV_QUALIFIER maybe_cv_qualifier
386 %type <ttype> init initlist maybeasm maybe_init defarg defarg1
387 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
388 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
389 %type <ttype> any_word
390
391 %type <itype> save_lineno
392 %type <ttype> simple_stmt simple_if
393
394 %type <ttype> declarator notype_declarator after_type_declarator
395 %type <ttype> notype_declarator_intern absdcl_intern
396 %type <ttype> after_type_declarator_intern
397 %type <ttype> direct_notype_declarator direct_after_type_declarator
398 %type <itype> components notype_components
399 %type <ttype> component_decl component_decl_1
400 %type <ttype> component_declarator component_declarator0
401 %type <ttype> notype_component_declarator notype_component_declarator0
402 %type <ttype> after_type_component_declarator after_type_component_declarator0
403 %type <ttype> absdcl cv_qualifiers
404 %type <ttype> direct_abstract_declarator conversion_declarator
405 %type <ttype> new_declarator direct_new_declarator
406 %type <ttype> xexpr parmlist parms bad_parm
407 %type <ttype> identifiers_or_typenames
408 %type <ttype> fcast_or_absdcl regcast_or_absdcl
409 %type <ttype> expr_or_declarator expr_or_declarator_intern
410 %type <ttype> complex_notype_declarator
411 %type <ttype> notype_unqualified_id unqualified_id qualified_id
412 %type <ttype> template_id do_id object_template_id notype_template_declarator
413 %type <ttype> overqualified_id notype_qualified_id any_id
414 %type <ttype> complex_direct_notype_declarator functional_cast
415 %type <ttype> complex_parmlist parms_comma
416 %type <ttype> namespace_qualifier namespace_using_decl
417
418 %type <ftype> type_id new_type_id typed_typespecs typespec typed_declspecs
419 %type <ftype> typed_declspecs1 type_specifier_seq nonempty_cv_qualifiers
420 %type <ftype> structsp typespecqual_reserved parm named_parm full_parm
421 %type <ftype> declmods
422
423 %type <itype> extension
424
425 /* C++ extensions */
426 %token <ttype> PTYPENAME
427 %token <ttype> EXTERN_LANG_STRING ALL
428 %token <ttype> PRE_PARSED_CLASS_DECL DEFARG DEFARG_MARKER
429 %token <pi> PRE_PARSED_FUNCTION_DECL
430 %type <ttype> component_constructor_declarator
431 %type <ttype> fn_def2 return_id constructor_declarator
432 %type <ttype> begin_function_body_
433 %type <ttype> class_head class_head_apparent_template
434 %type <ftype> class_head_decl class_head_defn
435 %type <ttype> base_class_list
436 %type <ttype> base_class_access_list
437 %type <ttype> base_class maybe_base_class_list base_class_1
438 %type <ttype> exception_specification_opt ansi_raise_identifier ansi_raise_identifiers
439 %type <ttype> operator_name
440 %type <ttype> object aggr
441 %type <itype> new delete
442 /* %type <ttype> primary_no_id */
443 %type <ttype> maybe_parmlist
444 %type <ttype> member_init
445 %type <ftype> member_init_list
446 %type <ttype> template_parm_header template_spec_header template_header
447 %type <ttype> template_parm_list template_parm
448 %type <ttype> template_type_parm template_template_parm
449 %type <code>  template_close_bracket
450 %type <ttype> apparent_template_type
451 %type <ttype> template_type template_arg_list template_arg_list_opt
452 %type <ttype> template_arg
453 %type <ttype> condition xcond paren_cond_or_null
454 %type <ttype> type_name nested_name_specifier nested_type ptr_to_mem
455 %type <ttype> complete_type_name notype_identifier nonnested_type
456 %type <ttype> complex_type_name nested_name_specifier_1
457 %type <ttype> new_initializer new_placement
458 %type <ttype> using_decl
459 %type <ttype> typename_sub typename_sub0 typename_sub1 typename_sub2
460 %type <ttype> explicit_template_type
461 /* in order to recognize aggr tags as defining and thus shadowing.  */
462 %token TYPENAME_DEFN IDENTIFIER_DEFN PTYPENAME_DEFN
463 %type <ttype> identifier_defn IDENTIFIER_DEFN TYPENAME_DEFN PTYPENAME_DEFN
464 %type <ttype> handler_args
465 %type <ttype> self_template_type finish_template_type_
466
467 %token NSNAME
468 %type <ttype> NSNAME
469
470 /* Used in lex.c for parsing pragmas.  */
471 %token END_OF_LINE
472
473 /* lex.c and pt.c depend on this being the last token.  Define
474    any new tokens before this one!  */
475 %token END_OF_SAVED_INPUT
476 \f
477 %{
478 /* Tell yyparse how to print a token's value, if yydebug is set.  */
479 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
480 extern void yyprint                     PARAMS ((FILE *, int, YYSTYPE));
481 %}
482 \f
483 %%
484 program:
485           /* empty */
486                { finish_translation_unit (); }
487         | extdefs
488                { finish_translation_unit (); }
489         ;
490
491 /* the reason for the strange actions in this rule
492  is so that notype_initdecls when reached via datadef
493  can find a valid list of type and sc specs in $0.  */
494
495 extdefs:
496                 { $<ttype>$ = NULL_TREE; }
497           lang_extdef
498                 { $<ttype>$ = NULL_TREE; ggc_collect (); }
499         | extdefs lang_extdef
500                 { $<ttype>$ = NULL_TREE; ggc_collect (); }
501         ;
502
503 extdefs_opt:
504           extdefs
505         | /* empty */
506         ;
507
508 .hush_warning:
509                 { have_extern_spec = true;
510                   $<ttype>$ = NULL_TREE; }
511         ;
512 .warning_ok:
513                 { have_extern_spec = false; }
514         ;
515
516 extension:
517         EXTENSION
518                 { $$ = pedantic;
519                   pedantic = 0; }
520         ;
521
522 asm_keyword:
523           ASM_KEYWORD
524         ;
525
526 lang_extdef:
527                 { if (pending_lang_change) do_pending_lang_change();
528                   type_lookups = NULL_TREE; }
529           extdef
530                 { if (! toplevel_bindings_p ())
531                   pop_everything (); }
532         ;
533
534 extdef:
535           fndef eat_saved_input
536                 { do_pending_inlines (); }
537         | datadef
538                 { do_pending_inlines (); }
539
540         | EXPORT
541                 { warning ("keyword `export' not implemented, and will be ignored"); }
542           template_def
543                 { do_pending_inlines (); }
544         | template_def
545                 { do_pending_inlines (); }
546         | asm_keyword '(' STRING ')' ';'
547                 { assemble_asm ($3); }
548         | extern_lang_string '{' extdefs_opt '}'
549                 { pop_lang_context (); }
550         | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
551                 { do_pending_inlines (); pop_lang_context (); }
552         | extern_lang_string .hush_warning datadef .warning_ok
553                 { do_pending_inlines (); pop_lang_context (); }
554         | NAMESPACE identifier '{'
555                 { push_namespace ($2); }
556           extdefs_opt '}'
557                 { pop_namespace (); }
558         | NAMESPACE '{'
559                 { push_namespace (NULL_TREE); }
560           extdefs_opt '}'
561                 { pop_namespace (); }
562         | namespace_alias
563         | using_decl ';'
564                 { do_toplevel_using_decl ($1); }
565         | using_directive
566         | extension extdef
567                 { pedantic = $1; }
568         ;
569
570 namespace_alias:
571           NAMESPACE identifier '='
572                 { begin_only_namespace_names (); }
573           any_id ';'
574                 {
575                   end_only_namespace_names ();
576                   if (lastiddecl)
577                     $5 = lastiddecl;
578                   do_namespace_alias ($2, $5);
579                 }
580         ;
581
582 using_decl:
583           USING qualified_id
584                 { $$ = $2; }
585         | USING global_scope qualified_id
586                 { $$ = $3; }
587         | USING global_scope unqualified_id
588                 { $$ = $3; }
589         ;
590
591 namespace_using_decl:
592           USING namespace_qualifier identifier
593                 { $$ = build_nt (SCOPE_REF, $2, $3); }
594         | USING global_scope identifier
595                 { $$ = build_nt (SCOPE_REF, global_namespace, $3); }
596         | USING global_scope namespace_qualifier identifier
597                 { $$ = build_nt (SCOPE_REF, $3, $4); }
598         ;
599
600 using_directive:
601           USING NAMESPACE
602                 { begin_only_namespace_names (); }
603           any_id ';'
604                 {
605                   end_only_namespace_names ();
606                   /* If no declaration was found, the using-directive is
607                      invalid. Since that was not reported, we need the
608                      identifier for the error message. */
609                   if (TREE_CODE ($4) == IDENTIFIER_NODE && lastiddecl)
610                     $4 = lastiddecl;
611                   do_using_directive ($4);
612                 }
613         ;
614
615 namespace_qualifier:
616           NSNAME SCOPE
617                 {
618                   if (TREE_CODE ($$) == IDENTIFIER_NODE)
619                     $$ = lastiddecl;
620                   got_scope = $$;
621                 }
622         | namespace_qualifier NSNAME SCOPE
623                 {
624                   $$ = $2;
625                   if (TREE_CODE ($$) == IDENTIFIER_NODE)
626                     $$ = lastiddecl;
627                   got_scope = $$;
628                 }
629         ;
630
631 any_id:
632           unqualified_id
633         | qualified_id
634         | global_scope qualified_id
635                 { $$ = $2; }
636         | global_scope unqualified_id
637                 { $$ = $2; }
638         ;
639
640 extern_lang_string:
641         EXTERN_LANG_STRING
642                 { push_lang_context ($1); }
643         | extern_lang_string EXTERN_LANG_STRING
644                 { if (current_lang_name != $2)
645                     error ("use of linkage spec `%D' is different from previous spec `%D'", $2, current_lang_name);
646                   pop_lang_context (); push_lang_context ($2); }
647         ;
648
649 template_parm_header:
650           TEMPLATE '<'
651                 { begin_template_parm_list (); }
652           template_parm_list '>'
653                 { $$ = end_template_parm_list ($4); }
654         ;
655
656 template_spec_header:
657           TEMPLATE '<' '>'
658                 { begin_specialization();
659                   $$ = NULL_TREE; }
660         ;
661
662 template_header:
663           template_parm_header
664         | template_spec_header
665         ;
666
667 template_parm_list:
668           template_parm
669                 { $$ = process_template_parm (NULL_TREE, $1); }
670         | template_parm_list ',' template_parm
671                 { $$ = process_template_parm ($1, $3); }
672         ;
673
674 maybe_identifier:
675           identifier
676                 { $$ = $1; }
677         |       /* empty */
678                 { $$ = NULL_TREE; }
679         ;
680
681 template_type_parm:
682           aggr maybe_identifier
683                 { $$ = finish_template_type_parm ($1, $2); }
684         | TYPENAME_KEYWORD maybe_identifier
685                 { $$ = finish_template_type_parm (class_type_node, $2); }
686         ;
687
688 template_template_parm:
689           template_parm_header aggr maybe_identifier
690                 { $$ = finish_template_template_parm ($2, $3); }
691         ;
692
693 template_parm:
694         /* The following rules introduce a new reduce/reduce
695            conflict on the ',' and '>' input tokens: they are valid
696            prefixes for a `structsp', which means they could match a
697            nameless parameter.  See 14.6, paragraph 3.
698            By putting them before the `parm' rule, we get
699            their match before considering them nameless parameter
700            declarations.  */
701           template_type_parm
702                 { $$ = build_tree_list (NULL_TREE, $1); }
703         | template_type_parm '=' type_id
704                 { $$ = build_tree_list (groktypename ($3.t), $1); }
705         | parm
706                 { $$ = build_tree_list (NULL_TREE, $1.t); }
707         | parm '=' expr_no_comma_rangle
708                 { $$ = build_tree_list ($3, $1.t); }
709         | template_template_parm
710                 { $$ = build_tree_list (NULL_TREE, $1); }
711         | template_template_parm '=' template_arg
712                 {
713                   $3 = check_template_template_default_arg ($3);
714                   $$ = build_tree_list ($3, $1);
715                 }
716         ;
717
718 template_def:
719           template_header template_extdef
720                 { finish_template_decl ($1); }
721         | template_header error  %prec EMPTY
722                 { finish_template_decl ($1); }
723         ;
724
725 template_extdef:
726           fndef eat_saved_input
727                 { do_pending_inlines (); }
728         | template_datadef
729                 { do_pending_inlines (); }
730         | template_def
731                 { do_pending_inlines (); }
732         | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
733                 { do_pending_inlines ();
734                   pop_lang_context (); }
735         | extern_lang_string .hush_warning template_datadef .warning_ok
736                 { do_pending_inlines ();
737                   pop_lang_context (); }
738         | extension template_extdef
739                 { pedantic = $1; }
740         ;
741
742 template_datadef:
743           nomods_initdecls ';'
744         | declmods notype_initdecls ';'
745                 {}
746         | typed_declspecs initdecls ';'
747                 { note_list_got_semicolon ($1.t); }
748         | structsp ';'
749                 {
750                   if ($1.t != error_mark_node)
751                     {
752                       maybe_process_partial_specialization ($1.t);
753                       note_got_semicolon ($1.t);
754                     }
755                 }
756         ;
757
758 datadef:
759           nomods_initdecls ';'
760         | declmods notype_initdecls ';'
761                 {}
762         | typed_declspecs initdecls ';'
763                 { note_list_got_semicolon ($1.t); }
764         | declmods ';'
765                 { pedwarn ("empty declaration"); }
766         | explicit_instantiation ';'
767         | typed_declspecs ';'
768                 {
769                   tree t, attrs;
770                   split_specs_attrs ($1.t, &t, &attrs);
771                   shadow_tag (t);
772                   note_list_got_semicolon ($1.t);
773                 }
774         | error ';'
775         | error '}'
776         | error END_OF_SAVED_INPUT
777                 { end_input (); }
778         | ';'
779         | bad_decl
780         ;
781
782 ctor_initializer_opt:
783           nodecls
784         | base_init
785         ;
786
787 maybe_return_init:
788           /* empty */
789         | return_init
790         | return_init ';'
791         ;
792
793 eat_saved_input:
794           /* empty */
795         | END_OF_SAVED_INPUT
796         ;
797
798 /* The outermost block of a function really begins before the
799    mem-initializer-list, so we open one there and suppress the one that
800    actually corresponds to the curly braces.  */
801 function_body:
802           begin_function_body_ ctor_initializer_opt save_lineno '{'
803                 { $<ttype>$ = begin_compound_stmt (/*has_no_scope=*/1); }
804           compstmtend
805                 {
806                   STMT_LINENO ($<ttype>5) = $3;
807                   finish_compound_stmt (/*has_no_scope=*/1, $<ttype>5);
808                   finish_function_body ($1);
809                 }
810         ;
811
812 fndef:
813           fn.def1 maybe_return_init function_body
814                 { expand_body (finish_function (0)); }
815         | fn.def1 maybe_return_init function_try_block
816                 { expand_body (finish_function (0)); }
817         | fn.def1 maybe_return_init error
818                 { }
819         ;
820
821 constructor_declarator:
822           nested_name_specifier SELFNAME '('
823                 { $$ = begin_constructor_declarator ($1, $2); }
824           parmlist ')' cv_qualifiers exception_specification_opt
825                 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
826         | nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
827                 { $$ = begin_constructor_declarator ($1, $2);
828                   $$ = make_call_declarator ($$, empty_parms (), $4, $5);
829                 }
830         | global_scope nested_name_specifier SELFNAME '('
831                 { $$ = begin_constructor_declarator ($2, $3); }
832          parmlist ')' cv_qualifiers exception_specification_opt
833                 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
834         | global_scope nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
835                 { $$ = begin_constructor_declarator ($2, $3);
836                   $$ = make_call_declarator ($$, empty_parms (), $5, $6);
837                 }
838         | nested_name_specifier self_template_type '('
839                 { $$ = begin_constructor_declarator ($1, $2); }
840           parmlist ')' cv_qualifiers exception_specification_opt
841                 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
842         | nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
843                 { $$ = begin_constructor_declarator ($1, $2);
844                   $$ = make_call_declarator ($$, empty_parms (), $4, $5);
845                 }
846         | global_scope nested_name_specifier self_template_type '('
847                 { $$ = begin_constructor_declarator ($2, $3); }
848          parmlist ')' cv_qualifiers exception_specification_opt
849                 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
850         | global_scope nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
851                 { $$ = begin_constructor_declarator ($2, $3);
852                   $$ = make_call_declarator ($$, empty_parms (), $5, $6);
853                 }
854         ;
855
856 fn.def1:
857           typed_declspecs declarator
858                 { check_for_new_type ("return type", $1);
859                   if (!parse_begin_function_definition ($1.t, $2))
860                     YYERROR1; }
861         | declmods notype_declarator
862                 { if (!parse_begin_function_definition ($1.t, $2))
863                     YYERROR1; }
864         | notype_declarator
865                 { if (!parse_begin_function_definition (NULL_TREE, $1))
866                     YYERROR1; }
867         | declmods constructor_declarator
868                 { if (!parse_begin_function_definition ($1.t, $2))
869                     YYERROR1; }
870         | constructor_declarator
871                 { if (!parse_begin_function_definition (NULL_TREE, $1))
872                     YYERROR1; }
873         ;
874
875 /* ANSI allows optional parentheses around constructor class names.
876    See ISO/IEC 14882:1998(E) 12.1.  */
877
878 component_constructor_declarator:
879           SELFNAME '(' parmlist ')' cv_qualifiers exception_specification_opt
880                 { $$ = make_call_declarator ($1, $3, $5, $6); }
881         | '(' SELFNAME ')' '(' parmlist ')' cv_qualifiers
882                 exception_specification_opt
883                 { $$ = make_call_declarator ($2, $5, $7, $8); }
884         | SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
885                 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
886         | '(' SELFNAME ')' LEFT_RIGHT cv_qualifiers exception_specification_opt
887                 { $$ = make_call_declarator ($2, empty_parms (), $5, $6); }
888         | self_template_type '(' parmlist ')' cv_qualifiers exception_specification_opt
889                 { $$ = make_call_declarator ($1, $3, $5, $6); }
890         | self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
891                 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
892         ;
893
894 /* more C++ complexity.  See component_decl for a comment on the
895    reduce/reduce conflict introduced by these rules.  */
896 fn_def2:
897           declmods component_constructor_declarator
898                 { $$ = parse_method ($2, $1.t, $1.lookups);
899                  rest_of_mdef:
900                   if (! $$)
901                     YYERROR1;
902                   if (yychar == YYEMPTY)
903                     yychar = YYLEX;
904                   snarf_method ($$); }
905         | component_constructor_declarator
906                 { $$ = parse_method ($1, NULL_TREE, NULL_TREE);
907                   goto rest_of_mdef; }
908         | typed_declspecs declarator
909                 { $$ = parse_method ($2, $1.t, $1.lookups); goto rest_of_mdef;}
910         | declmods notype_declarator
911                 { $$ = parse_method ($2, $1.t, $1.lookups); goto rest_of_mdef;}
912         | notype_declarator
913                 { $$ = parse_method ($1, NULL_TREE, NULL_TREE);
914                   goto rest_of_mdef; }
915         | declmods constructor_declarator
916                 { $$ = parse_method ($2, $1.t, $1.lookups); goto rest_of_mdef;}
917         | constructor_declarator
918                 { $$ = parse_method ($1, NULL_TREE, NULL_TREE);
919                   goto rest_of_mdef; }
920         ;
921
922 return_id:
923           RETURN_KEYWORD IDENTIFIER
924                 {
925                   $$ = $2;
926                 }
927         ;
928
929 return_init:
930           return_id maybe_init
931                 { finish_named_return_value ($<ttype>$, $2); }
932         | return_id '(' nonnull_exprlist ')'
933                 { finish_named_return_value ($<ttype>$, $3); }
934         | return_id LEFT_RIGHT
935                 { finish_named_return_value ($<ttype>$, NULL_TREE); }
936         ;
937
938 base_init:
939           ':' { begin_mem_initializers (); } member_init_list
940                 {
941                   if ($3.new_type_flag == 0)
942                     error ("no base or member initializers given following ':'");
943                   finish_mem_initializers ($3.t);
944                 }
945         ;
946
947 begin_function_body_:
948           /* empty */
949                 {
950                   $$ = begin_function_body ();
951                 }
952         ;
953
954 member_init_list:
955           /* empty */
956                 {
957                   $$.new_type_flag = 0;
958                   $$.t = NULL_TREE;
959                 }
960         | member_init
961                 {
962                   $$.new_type_flag = 1;
963                   $$.t = $1;
964                 }
965         | member_init_list ',' member_init
966                 {
967                   if ($3)
968                     {
969                       $$.new_type_flag = 1;
970                       TREE_CHAIN ($3) = $1.t;
971                       $$.t = $3;
972                     }
973                   else
974                     $$ = $1;
975                 }
976         | member_init_list error
977         ;
978
979 member_init:
980           '(' nonnull_exprlist ')'
981                 {
982                   if (current_class_name)
983                     pedwarn ("anachronistic old style base class initializer");
984                   $$ = expand_member_init (current_class_ref, NULL_TREE, $2);
985                 }
986         | LEFT_RIGHT
987                 {
988                   if (current_class_name)
989                     pedwarn ("anachronistic old style base class initializer");
990                   $$ = expand_member_init (current_class_ref,
991                                            NULL_TREE,
992                                            void_type_node);
993                 }
994         | notype_identifier '(' nonnull_exprlist ')'
995                 { $$ = expand_member_init (current_class_ref, $1, $3); }
996         | notype_identifier LEFT_RIGHT
997                 { $$ = expand_member_init (current_class_ref, $1,
998                                            void_type_node); }
999         | nonnested_type '(' nonnull_exprlist ')'
1000                 { $$ = expand_member_init (current_class_ref, $1, $3); }
1001         | nonnested_type LEFT_RIGHT
1002                 { $$ = expand_member_init (current_class_ref, $1,
1003                                            void_type_node); }
1004         | typename_sub '(' nonnull_exprlist ')'
1005                 { $$ = expand_member_init (current_class_ref, $1, $3); }
1006         | typename_sub LEFT_RIGHT
1007                 { $$ = expand_member_init (current_class_ref, $1,
1008                                            void_type_node); }
1009         | error
1010                 { $$ = NULL_TREE; }
1011         ;
1012
1013 identifier:
1014           IDENTIFIER
1015         | tTYPENAME
1016         | SELFNAME
1017         | PTYPENAME
1018         | NSNAME
1019         ;
1020
1021 notype_identifier:
1022           IDENTIFIER
1023         | PTYPENAME
1024         | NSNAME  %prec EMPTY
1025         ;
1026
1027 identifier_defn:
1028           IDENTIFIER_DEFN
1029         | TYPENAME_DEFN
1030         | PTYPENAME_DEFN
1031         ;
1032
1033 explicit_instantiation:
1034           TEMPLATE begin_explicit_instantiation typespec ';'
1035                 { do_type_instantiation ($3.t, NULL_TREE, 1);
1036                   yyungetc (';', 1); }
1037           end_explicit_instantiation
1038         | TEMPLATE begin_explicit_instantiation typed_declspecs declarator
1039                 { tree specs = strip_attrs ($3.t);
1040                   parse_decl_instantiation (specs, $4, NULL_TREE); }
1041           end_explicit_instantiation
1042         | TEMPLATE begin_explicit_instantiation notype_declarator
1043                 { parse_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
1044           end_explicit_instantiation
1045         | TEMPLATE begin_explicit_instantiation constructor_declarator
1046                 { parse_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
1047           end_explicit_instantiation
1048         | SCSPEC TEMPLATE begin_explicit_instantiation typespec ';'
1049                 { do_type_instantiation ($4.t, $1, 1);
1050                   yyungetc (';', 1); }
1051           end_explicit_instantiation
1052                 {}
1053         | SCSPEC TEMPLATE begin_explicit_instantiation typed_declspecs
1054           declarator
1055                 { tree specs = strip_attrs ($4.t);
1056                   parse_decl_instantiation (specs, $5, $1); }
1057           end_explicit_instantiation
1058                 {}
1059         | SCSPEC TEMPLATE begin_explicit_instantiation notype_declarator
1060                 { parse_decl_instantiation (NULL_TREE, $4, $1); }
1061           end_explicit_instantiation
1062                 {}
1063         | SCSPEC TEMPLATE begin_explicit_instantiation constructor_declarator
1064                 { parse_decl_instantiation (NULL_TREE, $4, $1); }
1065           end_explicit_instantiation
1066                 {}
1067         ;
1068
1069 begin_explicit_instantiation:
1070       { begin_explicit_instantiation(); }
1071         ;
1072
1073 end_explicit_instantiation:
1074       { end_explicit_instantiation(); }
1075         ;
1076
1077 /* The TYPENAME expansions are to deal with use of a template class name as
1078   a template within the class itself, where the template decl is hidden by
1079   a type decl.  Got all that?  */
1080
1081 template_type:
1082           PTYPENAME '<' template_arg_list_opt template_close_bracket
1083             finish_template_type_
1084                 { $$ = $5; }
1085         | tTYPENAME  '<' template_arg_list_opt template_close_bracket
1086             finish_template_type_
1087                 { $$ = $5; }
1088         | self_template_type
1089         ;
1090
1091 apparent_template_type:
1092           template_type
1093         | identifier '<' template_arg_list_opt '>'
1094             finish_template_type_
1095                 { $$ = $5; }
1096         ;
1097
1098 self_template_type:
1099           SELFNAME  '<' template_arg_list_opt template_close_bracket
1100             finish_template_type_
1101                 { $$ = $5; }
1102         ;
1103
1104 finish_template_type_:
1105                 {
1106                   if (yychar == YYEMPTY)
1107                     yychar = YYLEX;
1108
1109                   $$ = finish_template_type ($<ttype>-3, $<ttype>-1,
1110                                              yychar == SCOPE);
1111                 }
1112         ;
1113
1114 template_close_bracket:
1115           '>'
1116         | RSHIFT
1117                 {
1118                   /* Handle `Class<Class<Type>>' without space in the `>>' */
1119                   pedwarn ("`>>' should be `> >' in template class name");
1120                   yyungetc ('>', 1);
1121                 }
1122         ;
1123
1124 template_arg_list_opt:
1125          /* empty */
1126                  { $$ = NULL_TREE; }
1127        | template_arg_list
1128        ;
1129
1130 template_arg_list:
1131         template_arg
1132                 { $$ = build_tree_list (NULL_TREE, $$); }
1133         | template_arg_list ',' template_arg
1134                 { $$ = chainon ($$, build_tree_list (NULL_TREE, $3)); }
1135         ;
1136
1137 template_arg:
1138           type_id
1139                 { $$ = groktypename ($1.t); }
1140         | PTYPENAME
1141                 {
1142                   $$ = lastiddecl;
1143                   if (DECL_TEMPLATE_TEMPLATE_PARM_P ($$))
1144                     $$ = TREE_TYPE ($$);
1145                 }
1146         | global_scope PTYPENAME
1147                 {
1148                   $$ = lastiddecl;
1149                   if (DECL_TEMPLATE_TEMPLATE_PARM_P ($$))
1150                     $$ = TREE_TYPE ($$);
1151                 }
1152         | expr_no_comma_rangle
1153         | nested_name_specifier TEMPLATE identifier
1154                 {
1155                   if (!processing_template_decl)
1156                     {
1157                       error ("use of template qualifier outside template");
1158                       $$ = error_mark_node;
1159                     }
1160                   else
1161                     $$ = make_unbound_class_template ($1, $3, tf_error | tf_parsing);
1162                 }
1163         ;
1164
1165 unop:
1166           '-'
1167                 { $$ = NEGATE_EXPR; }
1168         | '+'
1169                 { $$ = CONVERT_EXPR; }
1170         | PLUSPLUS
1171                 { $$ = PREINCREMENT_EXPR; }
1172         | MINUSMINUS
1173                 { $$ = PREDECREMENT_EXPR; }
1174         | '!'
1175                 { $$ = TRUTH_NOT_EXPR; }
1176         ;
1177
1178 expr:
1179           nontrivial_exprlist
1180                 { $$ = build_x_compound_expr ($$); }
1181         | expr_no_commas
1182         ;
1183
1184 paren_expr_or_null:
1185         LEFT_RIGHT
1186                 { error ("ISO C++ forbids an empty condition for `%s'",
1187                          cond_stmt_keyword);
1188                   $$ = integer_zero_node; }
1189         | '(' expr ')'
1190                 { $$ = $2; }
1191         ;
1192
1193 paren_cond_or_null:
1194         LEFT_RIGHT
1195                 { error ("ISO C++ forbids an empty condition for `%s'",
1196                          cond_stmt_keyword);
1197                   $$ = integer_zero_node; }
1198         | '(' condition ')'
1199                 { $$ = $2; }
1200         ;
1201
1202 xcond:
1203           /* empty */
1204                 { $$ = NULL_TREE; }
1205         | condition
1206         | error
1207                 { $$ = NULL_TREE; }
1208         ;
1209
1210 condition:
1211           type_specifier_seq declarator maybeasm maybe_attribute '='
1212                 { {
1213                   tree d;
1214                   for (d = getdecls (); d; d = TREE_CHAIN (d))
1215                     if (TREE_CODE (d) == TYPE_DECL) {
1216                       tree s = TREE_TYPE (d);
1217                       if (TREE_CODE (s) == RECORD_TYPE)
1218                         error ("definition of class `%T' in condition", s);
1219                       else if (TREE_CODE (s) == ENUMERAL_TYPE)
1220                         error ("definition of enum `%T' in condition", s);
1221                     }
1222                   }
1223                   current_declspecs = $1.t;
1224                   $<ttype>$ = parse_decl ($<ttype>2, $4, 1);
1225                 }
1226           init
1227                 {
1228                   parse_end_decl ($<ttype>6, $7, $4);
1229                   $$ = convert_from_reference ($<ttype>6);
1230                   if (TREE_CODE (TREE_TYPE ($$)) == ARRAY_TYPE)
1231                     error ("definition of array `%#D' in condition", $$);
1232                 }
1233         | expr
1234         ;
1235
1236 compstmtend:
1237           '}'
1238         | maybe_label_decls stmts '}'
1239         | maybe_label_decls stmts error '}'
1240         | maybe_label_decls error '}'
1241         ;
1242
1243 nontrivial_exprlist:
1244           expr_no_commas ',' expr_no_commas
1245                 { $$ = tree_cons (NULL_TREE, $$,
1246                                   build_tree_list (NULL_TREE, $3)); }
1247         | expr_no_commas ',' error
1248                 { $$ = tree_cons (NULL_TREE, $$,
1249                                   build_tree_list (NULL_TREE, error_mark_node)); }
1250         | nontrivial_exprlist ',' expr_no_commas
1251                 { chainon ($$, build_tree_list (NULL_TREE, $3)); }
1252         | nontrivial_exprlist ',' error
1253                 { chainon ($$, build_tree_list (NULL_TREE, error_mark_node)); }
1254         ;
1255
1256 nonnull_exprlist:
1257           expr_no_commas
1258                 { $$ = build_tree_list (NULL_TREE, $$); }
1259         | nontrivial_exprlist
1260         ;
1261
1262 unary_expr:
1263           primary  %prec UNARY
1264                 { $$ = $1; }
1265         /* __extension__ turns off -pedantic for following primary.  */
1266         | extension cast_expr     %prec UNARY
1267                 { $$ = $2;
1268                   pedantic = $1; }
1269         | '*' cast_expr   %prec UNARY
1270                 { $$ = build_x_indirect_ref ($2, "unary *"); }
1271         | '&' cast_expr   %prec UNARY
1272                 { $$ = build_x_unary_op (ADDR_EXPR, $2); }
1273         | '~' cast_expr
1274                 { $$ = build_x_unary_op (BIT_NOT_EXPR, $2); }
1275         | unop cast_expr  %prec UNARY
1276                 { $$ = finish_unary_op_expr ($1, $2); }
1277         /* Refer to the address of a label as a pointer.  */
1278         | ANDAND identifier
1279                 { $$ = finish_label_address_expr ($2); }
1280         | sizeof unary_expr  %prec UNARY
1281                 { $$ = finish_sizeof ($2);
1282                   skip_evaluation--; }
1283         | sizeof '(' type_id ')'  %prec HYPERUNARY
1284                 { $$ = finish_sizeof (groktypename ($3.t));
1285                   check_for_new_type ("sizeof", $3);
1286                   skip_evaluation--; }
1287         | alignof unary_expr  %prec UNARY
1288                 { $$ = finish_alignof ($2);
1289                   skip_evaluation--; }
1290         | alignof '(' type_id ')'  %prec HYPERUNARY
1291                 { $$ = finish_alignof (groktypename ($3.t));
1292                   check_for_new_type ("alignof", $3);
1293                   skip_evaluation--; }
1294
1295         /* The %prec EMPTY's here are required by the = init initializer
1296            syntax extension; see below.  */
1297         | new new_type_id  %prec EMPTY
1298                 { $$ = build_new (NULL_TREE, $2.t, NULL_TREE, $1);
1299                   check_for_new_type ("new", $2); }
1300         | new new_type_id new_initializer
1301                 { $$ = build_new (NULL_TREE, $2.t, $3, $1);
1302                   check_for_new_type ("new", $2); }
1303         | new new_placement new_type_id  %prec EMPTY
1304                 { $$ = build_new ($2, $3.t, NULL_TREE, $1);
1305                   check_for_new_type ("new", $3); }
1306         | new new_placement new_type_id new_initializer
1307                 { $$ = build_new ($2, $3.t, $4, $1);
1308                   check_for_new_type ("new", $3); }
1309         | new '(' type_id ')'
1310             %prec EMPTY
1311                 { $$ = build_new (NULL_TREE, groktypename($3.t),
1312                                   NULL_TREE, $1);
1313                   check_for_new_type ("new", $3); }
1314         | new '(' type_id ')' new_initializer
1315                 { $$ = build_new (NULL_TREE, groktypename($3.t), $5, $1);
1316                   check_for_new_type ("new", $3); }
1317         | new new_placement '(' type_id ')' %prec EMPTY
1318                 { $$ = build_new ($2, groktypename($4.t), NULL_TREE, $1);
1319                   check_for_new_type ("new", $4); }
1320         | new new_placement '(' type_id ')' new_initializer
1321                 { $$ = build_new ($2, groktypename($4.t), $6, $1);
1322                   check_for_new_type ("new", $4); }
1323
1324         | delete cast_expr  %prec UNARY
1325                 { $$ = delete_sanity ($2, NULL_TREE, 0, $1); }
1326         | delete '[' ']' cast_expr  %prec UNARY
1327                 { $$ = delete_sanity ($4, NULL_TREE, 1, $1);
1328                   if (yychar == YYEMPTY)
1329                     yychar = YYLEX; }
1330         | delete '[' expr ']' cast_expr  %prec UNARY
1331                 { $$ = delete_sanity ($5, $3, 2, $1);
1332                   if (yychar == YYEMPTY)
1333                     yychar = YYLEX; }
1334         | REALPART cast_expr %prec UNARY
1335                 { $$ = build_x_unary_op (REALPART_EXPR, $2); }
1336         | IMAGPART cast_expr %prec UNARY
1337                 { $$ = build_x_unary_op (IMAGPART_EXPR, $2); }
1338         ;
1339
1340 new_placement:
1341           '(' nonnull_exprlist ')'
1342                 { $$ = $2; }
1343         | '{' nonnull_exprlist '}'
1344                 { pedwarn ("old style placement syntax, use () instead");
1345                   $$ = $2; }
1346         ;
1347
1348 new_initializer:
1349           '(' nonnull_exprlist ')'
1350                 { $$ = $2; }
1351         | LEFT_RIGHT
1352                 { $$ = void_zero_node; }
1353         | '(' typespec ')'
1354                 {
1355                   error ("`%T' is not a valid expression", $2.t);
1356                   $$ = error_mark_node;
1357                 }
1358         /* GNU extension so people can use initializer lists.  Note that
1359            this alters the meaning of `new int = 1', which was previously
1360            syntactically valid but semantically invalid.
1361            This feature is now deprecated and will be removed in a future
1362            release.  */
1363         | '=' init
1364                 {
1365                   if (pedantic)
1366                     pedwarn ("ISO C++ forbids initialization of new expression with `='");
1367                   cp_deprecated ("new initializer lists extension");
1368                   if (TREE_CODE ($2) != TREE_LIST
1369                       && TREE_CODE ($2) != CONSTRUCTOR)
1370                     $$ = build_tree_list (NULL_TREE, $2);
1371                   else
1372                     $$ = $2;
1373                 }
1374         ;
1375
1376 /* This is necessary to postpone reduction of `int ((int)(int)(int))'.  */
1377 regcast_or_absdcl:
1378           '(' type_id ')'  %prec EMPTY
1379                 { $2.t = finish_parmlist (build_tree_list (NULL_TREE, $2.t), 0);
1380                   $$ = make_call_declarator (NULL_TREE, $2.t, NULL_TREE, NULL_TREE);
1381                   check_for_new_type ("cast", $2); }
1382         | regcast_or_absdcl '(' type_id ')'  %prec EMPTY
1383                 { $3.t = finish_parmlist (build_tree_list (NULL_TREE, $3.t), 0);
1384                   $$ = make_call_declarator ($$, $3.t, NULL_TREE, NULL_TREE);
1385                   check_for_new_type ("cast", $3); }
1386         ;
1387
1388 cast_expr:
1389           unary_expr
1390         | regcast_or_absdcl unary_expr  %prec UNARY
1391                 { $$ = reparse_absdcl_as_casts ($$, $2); }
1392         | regcast_or_absdcl '{' initlist maybecomma '}'  %prec UNARY
1393                 {
1394                   tree init = build_nt (CONSTRUCTOR, NULL_TREE,
1395                                         nreverse ($3));
1396                   if (pedantic)
1397                     pedwarn ("ISO C++ forbids compound literals");
1398                   /* Indicate that this was a C99 compound literal.  */
1399                   TREE_HAS_CONSTRUCTOR (init) = 1;
1400
1401                   $$ = reparse_absdcl_as_casts ($$, init);
1402                 }
1403         ;
1404
1405 expr_no_commas:
1406           cast_expr
1407         /* Handle general members.  */
1408         | expr_no_commas POINTSAT_STAR expr_no_commas
1409                 { $$ = build_x_binary_op (MEMBER_REF, $$, $3); }
1410         | expr_no_commas DOT_STAR expr_no_commas
1411                 { $$ = build_m_component_ref ($$, $3); }
1412         | expr_no_commas '+' expr_no_commas
1413                 { $$ = build_x_binary_op ($2, $$, $3); }
1414         | expr_no_commas '-' expr_no_commas
1415                 { $$ = build_x_binary_op ($2, $$, $3); }
1416         | expr_no_commas '*' expr_no_commas
1417                 { $$ = build_x_binary_op ($2, $$, $3); }
1418         | expr_no_commas '/' expr_no_commas
1419                 { $$ = build_x_binary_op ($2, $$, $3); }
1420         | expr_no_commas '%' expr_no_commas
1421                 { $$ = build_x_binary_op ($2, $$, $3); }
1422         | expr_no_commas LSHIFT expr_no_commas
1423                 { $$ = build_x_binary_op ($2, $$, $3); }
1424         | expr_no_commas RSHIFT expr_no_commas
1425                 { $$ = build_x_binary_op ($2, $$, $3); }
1426         | expr_no_commas ARITHCOMPARE expr_no_commas
1427                 { $$ = build_x_binary_op ($2, $$, $3); }
1428         | expr_no_commas '<' expr_no_commas
1429                 { $$ = build_x_binary_op (LT_EXPR, $$, $3); }
1430         | expr_no_commas '>' expr_no_commas
1431                 { $$ = build_x_binary_op (GT_EXPR, $$, $3); }
1432         | expr_no_commas EQCOMPARE expr_no_commas
1433                 { $$ = build_x_binary_op ($2, $$, $3); }
1434         | expr_no_commas MIN_MAX expr_no_commas
1435                 { $$ = build_x_binary_op ($2, $$, $3); }
1436         | expr_no_commas '&' expr_no_commas
1437                 { $$ = build_x_binary_op ($2, $$, $3); }
1438         | expr_no_commas '|' expr_no_commas
1439                 { $$ = build_x_binary_op ($2, $$, $3); }
1440         | expr_no_commas '^' expr_no_commas
1441                 { $$ = build_x_binary_op ($2, $$, $3); }
1442         | expr_no_commas ANDAND expr_no_commas
1443                 { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $$, $3); }
1444         | expr_no_commas OROR expr_no_commas
1445                 { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $$, $3); }
1446         | expr_no_commas '?' xexpr ':' expr_no_commas
1447                 { $$ = build_x_conditional_expr ($$, $3, $5); }
1448         | expr_no_commas '=' expr_no_commas
1449                 { $$ = build_x_modify_expr ($$, NOP_EXPR, $3);
1450                   if ($$ != error_mark_node)
1451                     C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
1452         | expr_no_commas ASSIGN expr_no_commas
1453                 { $$ = build_x_modify_expr ($$, $2, $3); }
1454         | THROW
1455                 { $$ = build_throw (NULL_TREE); }
1456         | THROW expr_no_commas
1457                 { $$ = build_throw ($2); }
1458         ;
1459
1460 expr_no_comma_rangle:
1461           cast_expr
1462         /* Handle general members.  */
1463         | expr_no_comma_rangle POINTSAT_STAR expr_no_comma_rangle
1464                 { $$ = build_x_binary_op (MEMBER_REF, $$, $3); }
1465         | expr_no_comma_rangle DOT_STAR expr_no_comma_rangle
1466                 { $$ = build_m_component_ref ($$, $3); }
1467         | expr_no_comma_rangle '+' expr_no_comma_rangle
1468                 { $$ = build_x_binary_op ($2, $$, $3); }
1469         | expr_no_comma_rangle '-' expr_no_comma_rangle
1470                 { $$ = build_x_binary_op ($2, $$, $3); }
1471         | expr_no_comma_rangle '*' expr_no_comma_rangle
1472                 { $$ = build_x_binary_op ($2, $$, $3); }
1473         | expr_no_comma_rangle '/' expr_no_comma_rangle
1474                 { $$ = build_x_binary_op ($2, $$, $3); }
1475         | expr_no_comma_rangle '%' expr_no_comma_rangle
1476                 { $$ = build_x_binary_op ($2, $$, $3); }
1477         | expr_no_comma_rangle LSHIFT expr_no_comma_rangle
1478                 { $$ = build_x_binary_op ($2, $$, $3); }
1479         | expr_no_comma_rangle RSHIFT expr_no_comma_rangle
1480                 { $$ = build_x_binary_op ($2, $$, $3); }
1481         | expr_no_comma_rangle ARITHCOMPARE expr_no_comma_rangle
1482                 { $$ = build_x_binary_op ($2, $$, $3); }
1483         | expr_no_comma_rangle '<' expr_no_comma_rangle
1484                 { $$ = build_x_binary_op (LT_EXPR, $$, $3); }
1485         | expr_no_comma_rangle EQCOMPARE expr_no_comma_rangle
1486                 { $$ = build_x_binary_op ($2, $$, $3); }
1487         | expr_no_comma_rangle MIN_MAX expr_no_comma_rangle
1488                 { $$ = build_x_binary_op ($2, $$, $3); }
1489         | expr_no_comma_rangle '&' expr_no_comma_rangle
1490                 { $$ = build_x_binary_op ($2, $$, $3); }
1491         | expr_no_comma_rangle '|' expr_no_comma_rangle
1492                 { $$ = build_x_binary_op ($2, $$, $3); }
1493         | expr_no_comma_rangle '^' expr_no_comma_rangle
1494                 { $$ = build_x_binary_op ($2, $$, $3); }
1495         | expr_no_comma_rangle ANDAND expr_no_comma_rangle
1496                 { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $$, $3); }
1497         | expr_no_comma_rangle OROR expr_no_comma_rangle
1498                 { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $$, $3); }
1499         | expr_no_comma_rangle '?' xexpr ':' expr_no_comma_rangle
1500                 { $$ = build_x_conditional_expr ($$, $3, $5); }
1501         | expr_no_comma_rangle '=' expr_no_comma_rangle
1502                 { $$ = build_x_modify_expr ($$, NOP_EXPR, $3);
1503                   if ($$ != error_mark_node)
1504                     C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
1505         | expr_no_comma_rangle ASSIGN expr_no_comma_rangle
1506                 { $$ = build_x_modify_expr ($$, $2, $3); }
1507         | THROW
1508                 { $$ = build_throw (NULL_TREE); }
1509         | THROW expr_no_comma_rangle
1510                 { $$ = build_throw ($2); }
1511         ;
1512
1513 notype_unqualified_id:
1514           '~' see_typename identifier
1515                 { $$ = build_nt (BIT_NOT_EXPR, $3); }
1516         | '~' see_typename template_type
1517                 { $$ = build_nt (BIT_NOT_EXPR, $3); }
1518         | template_id
1519         | operator_name
1520         | IDENTIFIER
1521         | PTYPENAME
1522         | NSNAME  %prec EMPTY
1523         ;
1524
1525 do_id:
1526                 {
1527                   /* If lastiddecl is a BASELINK we're in an
1528                      expression like S::f<int>, so don't
1529                      do_identifier; we only do that for unqualified
1530                      identifiers.  */
1531                   if (!lastiddecl || !BASELINK_P (lastiddecl))
1532                     $$ = do_identifier ($<ttype>-1, 1, NULL_TREE);
1533                   else
1534                     $$ = $<ttype>-1;
1535                 }
1536         ;
1537
1538 template_id:
1539           PFUNCNAME '<' do_id template_arg_list_opt template_close_bracket
1540                 { 
1541                   tree template_name = $3;
1542                   if (TREE_CODE (template_name) == COMPONENT_REF)
1543                     template_name = TREE_OPERAND (template_name, 1);
1544                   $$ = lookup_template_function (template_name, $4); 
1545                 }
1546         | operator_name '<' do_id template_arg_list_opt template_close_bracket
1547                 { 
1548                   tree template_name = $3;
1549                   if (TREE_CODE (template_name) == COMPONENT_REF)
1550                     template_name = TREE_OPERAND (template_name, 1);
1551                   $$ = lookup_template_function (template_name, $4); 
1552                 }
1553         ;
1554
1555 object_template_id:
1556         TEMPLATE identifier '<' template_arg_list_opt template_close_bracket
1557                 { $$ = lookup_template_function ($2, $4); }
1558         | TEMPLATE PFUNCNAME '<' template_arg_list_opt template_close_bracket
1559                 { $$ = lookup_template_function ($2, $4); }
1560         | TEMPLATE operator_name '<' template_arg_list_opt
1561           template_close_bracket
1562                 { $$ = lookup_template_function ($2, $4); }
1563         ;
1564
1565 unqualified_id:
1566           notype_unqualified_id
1567         | tTYPENAME
1568         | SELFNAME
1569         ;
1570
1571 expr_or_declarator_intern:
1572           expr_or_declarator
1573         | attributes expr_or_declarator
1574                 {
1575                   /* Provide support for '(' attributes '*' declarator ')'
1576                      etc */
1577                   $$ = tree_cons ($1, $2, NULL_TREE);
1578                 }
1579         ;
1580
1581 expr_or_declarator:
1582           notype_unqualified_id
1583         | '*' expr_or_declarator_intern  %prec UNARY
1584                 { $$ = build_nt (INDIRECT_REF, $2); }
1585         | '&' expr_or_declarator_intern  %prec UNARY
1586                 { $$ = build_nt (ADDR_EXPR, $2); }
1587         | '(' expr_or_declarator_intern ')'
1588                 { $$ = $2; }
1589         ;
1590
1591 notype_template_declarator:
1592           IDENTIFIER '<' template_arg_list_opt template_close_bracket
1593                 { $$ = lookup_template_function ($1, $3); }
1594         | NSNAME '<' template_arg_list template_close_bracket
1595                 { $$ = lookup_template_function ($1, $3); }
1596         ;
1597
1598 direct_notype_declarator:
1599           complex_direct_notype_declarator
1600         /* This precedence declaration is to prefer this reduce
1601            to the Koenig lookup shift in primary, below.  I hate yacc.  */
1602         | notype_unqualified_id %prec '('
1603         | notype_template_declarator
1604         | '(' expr_or_declarator_intern ')'
1605                 { $$ = finish_decl_parsing ($2); }
1606         ;
1607
1608 primary:
1609           notype_unqualified_id
1610                 {
1611                   if (TREE_CODE ($1) == BIT_NOT_EXPR)
1612                     $$ = build_x_unary_op (BIT_NOT_EXPR, TREE_OPERAND ($1, 0));
1613                   else
1614                     $$ = finish_id_expr ($1);
1615                 }
1616         | CONSTANT
1617         | boolean_literal
1618         | STRING
1619                 {
1620                   $$ = fix_string_type ($$);
1621                   /* fix_string_type doesn't set up TYPE_MAIN_VARIANT of
1622                      a const array the way we want, so fix it.  */
1623                   if (flag_const_strings)
1624                     TREE_TYPE ($$) = build_cplus_array_type
1625                       (TREE_TYPE (TREE_TYPE ($$)),
1626                        TYPE_DOMAIN (TREE_TYPE ($$)));
1627                 }
1628         | VAR_FUNC_NAME
1629                { $$ = finish_fname ($1); }
1630         | '(' expr ')'
1631                 { $$ = finish_parenthesized_expr ($2); }
1632         | '(' expr_or_declarator_intern ')'
1633                 { $2 = reparse_decl_as_expr (NULL_TREE, $2);
1634                   $$ = finish_parenthesized_expr ($2); }
1635         | '(' error ')'
1636                 { $$ = error_mark_node; }
1637         | '('
1638                 { if (!at_function_scope_p ())
1639                     {
1640                       error ("braced-group within expression allowed only inside a function");
1641                       YYERROR;
1642                     }
1643                   if (pedantic)
1644                     pedwarn ("ISO C++ forbids braced-groups within expressions");
1645                   $<ttype>$ = begin_stmt_expr ();
1646                 }
1647           compstmt_or_stmtexpr ')'
1648                { $$ = finish_stmt_expr ($<ttype>2); }
1649         /* Koenig lookup support
1650            We could store lastiddecl in $1 to avoid another lookup,
1651            but that would result in many additional reduce/reduce conflicts. */
1652         | notype_unqualified_id '(' nonnull_exprlist ')'
1653                { $$ = parse_finish_call_expr ($1, $3, 1); }
1654         | notype_unqualified_id LEFT_RIGHT
1655                { $$ = parse_finish_call_expr ($1, NULL_TREE, 1); }
1656         | primary '(' nonnull_exprlist ')'
1657                { $$ = parse_finish_call_expr ($1, $3, 0); }
1658         | primary LEFT_RIGHT
1659                { $$ = parse_finish_call_expr ($1, NULL_TREE, 0); }
1660         | VA_ARG '(' expr_no_commas ',' type_id ')'
1661                 { $$ = build_x_va_arg ($3, groktypename ($5.t));
1662                   check_for_new_type ("__builtin_va_arg", $5); }
1663         | primary '[' expr ']'
1664                 { $$ = grok_array_decl ($$, $3); }
1665         | primary PLUSPLUS
1666                 { $$ = finish_increment_expr ($1, POSTINCREMENT_EXPR); }
1667         | primary MINUSMINUS
1668                 { $$ = finish_increment_expr ($1, POSTDECREMENT_EXPR); }
1669         /* C++ extensions */
1670         | THIS
1671                 { $$ = finish_this_expr (); }
1672         | CV_QUALIFIER '(' nonnull_exprlist ')'
1673                 {
1674                   /* This is a C cast in C++'s `functional' notation
1675                      using the "implicit int" extension so that:
1676                      `const (3)' is equivalent to `const int (3)'.  */
1677                   tree type;
1678
1679                   type = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
1680                   type = groktypename (build_tree_list (type, NULL_TREE));
1681                   $$ = build_functional_cast (type, $3);
1682                 }
1683         | functional_cast
1684         | DYNAMIC_CAST '<' type_id '>' '(' expr ')'
1685                 { tree type = groktypename ($3.t);
1686                   check_for_new_type ("dynamic_cast", $3);
1687                   $$ = build_dynamic_cast (type, $6); }
1688         | STATIC_CAST '<' type_id '>' '(' expr ')'
1689                 { tree type = groktypename ($3.t);
1690                   check_for_new_type ("static_cast", $3);
1691                   $$ = build_static_cast (type, $6); }
1692         | REINTERPRET_CAST '<' type_id '>' '(' expr ')'
1693                 { tree type = groktypename ($3.t);
1694                   check_for_new_type ("reinterpret_cast", $3);
1695                   $$ = build_reinterpret_cast (type, $6); }
1696         | CONST_CAST '<' type_id '>' '(' expr ')'
1697                 { tree type = groktypename ($3.t);
1698                   check_for_new_type ("const_cast", $3);
1699                   $$ = build_const_cast (type, $6); }
1700         | TYPEID '(' expr ')'
1701                 { $$ = build_typeid ($3); }
1702         | TYPEID '(' type_id ')'
1703                 { tree type = groktypename ($3.t);
1704                   check_for_new_type ("typeid", $3);
1705                   $$ = get_typeid (type); }
1706         | global_scope IDENTIFIER
1707                 { $$ = parse_scoped_id ($2); }
1708         | global_scope template_id
1709                 { $$ = $2; }
1710         | global_scope operator_name
1711                 {
1712                   got_scope = NULL_TREE;
1713                   if (TREE_CODE ($2) == IDENTIFIER_NODE)
1714                     $$ = parse_scoped_id ($2);
1715                   else
1716                     $$ = $2;
1717                 }
1718         | overqualified_id  %prec HYPERUNARY
1719                 { $$ = build_offset_ref (OP0 ($$), OP1 ($$)); }
1720         | overqualified_id '(' nonnull_exprlist ')'
1721                 { $$ = parse_finish_call_expr ($1, $3, 0); }
1722         | overqualified_id LEFT_RIGHT
1723                 { $$ = parse_finish_call_expr ($1, NULL_TREE, 0); }
1724         | object object_template_id %prec UNARY
1725                 { $$ = finish_class_member_access_expr ($$, $2); }
1726         | object object_template_id '(' nonnull_exprlist ')'
1727                 { $$ = finish_object_call_expr ($2, $1, $4); }
1728         | object object_template_id LEFT_RIGHT
1729                 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1730         | object unqualified_id  %prec UNARY
1731                 { $$ = finish_class_member_access_expr ($$, $2); }
1732         | object overqualified_id  %prec UNARY
1733                 { $$ = finish_class_member_access_expr ($1, $2); }
1734         | object unqualified_id '(' nonnull_exprlist ')'
1735                 { $$ = finish_object_call_expr ($2, $1, $4); }
1736         | object unqualified_id LEFT_RIGHT
1737                 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1738         | object overqualified_id '(' nonnull_exprlist ')'
1739                 { $$ = finish_qualified_object_call_expr ($2, $1, $4); }
1740         | object overqualified_id LEFT_RIGHT
1741                 { $$ = finish_qualified_object_call_expr ($2, $1, NULL_TREE); }
1742         /* p->int::~int() is valid -- 12.4 */
1743         | object '~' TYPESPEC LEFT_RIGHT
1744                 { $$ = finish_pseudo_destructor_call_expr ($1, NULL_TREE, $3); }
1745         | object TYPESPEC SCOPE '~' TYPESPEC LEFT_RIGHT
1746                 { $$ = finish_pseudo_destructor_call_expr ($1, $2, $5); }
1747         | object error
1748                 {
1749                   $$ = error_mark_node;
1750                 }
1751         ;
1752
1753 /* Not needed for now.
1754
1755 primary_no_id:
1756           '(' expr ')'
1757                 { $$ = $2; }
1758         | '(' error ')'
1759                 { $$ = error_mark_node; }
1760         | '('
1761                 { if (current_function_decl == 0)
1762                     {
1763                       error ("braced-group within expression allowed only inside a function");
1764                       YYERROR;
1765                     }
1766                   $<ttype>$ = expand_start_stmt_expr (); }
1767           compstmt_or_stmtexpr ')'
1768                 { if (pedantic)
1769                     pedwarn ("ISO C++ forbids braced-groups within expressions");
1770                   $$ = expand_end_stmt_expr ($<ttype>2); }
1771         | primary_no_id '(' nonnull_exprlist ')'
1772                 { $$ = build_x_function_call ($$, $3, current_class_ref); }
1773         | primary_no_id LEFT_RIGHT
1774                 { $$ = build_x_function_call ($$, NULL_TREE, current_class_ref); }
1775         | primary_no_id '[' expr ']'
1776                 { goto do_array; }
1777         | primary_no_id PLUSPLUS
1778                 { $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); }
1779         | primary_no_id MINUSMINUS
1780                 { $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); }
1781         | SCOPE IDENTIFIER
1782                 { goto do_scoped_id; }
1783         | SCOPE operator_name
1784                 { if (TREE_CODE ($2) == IDENTIFIER_NODE)
1785                     goto do_scoped_id;
1786                   goto do_scoped_operator;
1787                 }
1788         ;
1789 */
1790
1791 new:
1792           NEW
1793                 { $$ = 0; }
1794         | global_scope NEW
1795                 { got_scope = NULL_TREE; $$ = 1; }
1796         ;
1797
1798 delete:
1799           DELETE
1800                 { $$ = 0; }
1801         | global_scope delete
1802                 { got_scope = NULL_TREE; $$ = 1; }
1803         ;
1804
1805 boolean_literal:
1806           CXX_TRUE
1807                 { $$ = boolean_true_node; }
1808         | CXX_FALSE
1809                 { $$ = boolean_false_node; }
1810         ;
1811
1812 nodecls:
1813           /* empty */
1814                 {
1815                   if (DECL_CONSTRUCTOR_P (current_function_decl))
1816                     finish_mem_initializers (NULL_TREE);
1817                 }
1818         ;
1819
1820 object:
1821           primary '.'
1822                 { got_object = TREE_TYPE ($$); }
1823         | primary POINTSAT
1824                 {
1825                   $$ = build_x_arrow ($$);
1826                   got_object = TREE_TYPE ($$);
1827                 }
1828         ;
1829
1830 decl:
1831           typespec initdecls ';'
1832                 {
1833                   if ($1.t && IS_AGGR_TYPE_CODE (TREE_CODE ($1.t)))
1834                     note_got_semicolon ($1.t);
1835                 }
1836         | typed_declspecs initdecls ';'
1837                 {
1838                   note_list_got_semicolon ($1.t);
1839                 }
1840         | declmods notype_initdecls ';'
1841                 {}
1842         | typed_declspecs ';'
1843                 {
1844                   shadow_tag ($1.t);
1845                   note_list_got_semicolon ($1.t);
1846                 }
1847         | declmods ';'
1848                 { warning ("empty declaration"); }
1849         | extension decl
1850                 { pedantic = $1; }
1851         ;
1852
1853 /* Any kind of declarator (thus, all declarators allowed
1854    after an explicit typespec).  */
1855
1856 declarator:
1857           after_type_declarator  %prec EMPTY
1858         | notype_declarator  %prec EMPTY
1859         ;
1860
1861 /* This is necessary to postpone reduction of `int()()()()'.  */
1862 fcast_or_absdcl:
1863           LEFT_RIGHT  %prec EMPTY
1864                 { $$ = make_call_declarator (NULL_TREE, empty_parms (),
1865                                              NULL_TREE, NULL_TREE); }
1866         | fcast_or_absdcl LEFT_RIGHT  %prec EMPTY
1867                 { $$ = make_call_declarator ($$, empty_parms (), NULL_TREE,
1868                                              NULL_TREE); }
1869         ;
1870
1871 /* ISO type-id (8.1) */
1872 type_id:
1873           typed_typespecs absdcl
1874                 { $$.t = build_tree_list ($1.t, $2);
1875                   $$.new_type_flag = $1.new_type_flag; }
1876         | nonempty_cv_qualifiers absdcl
1877                 { $$.t = build_tree_list ($1.t, $2);
1878                   $$.new_type_flag = $1.new_type_flag; }
1879         | typespec absdcl
1880                 { $$.t = build_tree_list (build_tree_list (NULL_TREE, $1.t),
1881                                           $2);
1882                   $$.new_type_flag = $1.new_type_flag; }
1883         | typed_typespecs  %prec EMPTY
1884                 { $$.t = build_tree_list ($1.t, NULL_TREE);
1885                   $$.new_type_flag = $1.new_type_flag;  }
1886         | nonempty_cv_qualifiers  %prec EMPTY
1887                 { $$.t = build_tree_list ($1.t, NULL_TREE);
1888                   $$.new_type_flag = $1.new_type_flag; }
1889         ;
1890
1891 /* Declspecs which contain at least one type specifier or typedef name.
1892    (Just `const' or `volatile' is not enough.)
1893    A typedef'd name following these is taken as a name to be declared.
1894    In the result, declspecs have a non-NULL TREE_VALUE, attributes do not.  */
1895
1896 typed_declspecs:
1897           typed_typespecs  %prec EMPTY
1898                 { $$.lookups = type_lookups; }
1899         | typed_declspecs1
1900                 { $$.lookups = type_lookups; }
1901         ;
1902
1903 typed_declspecs1:
1904           declmods typespec
1905                 { $$.t = tree_cons (NULL_TREE, $2.t, $1.t);
1906                   $$.new_type_flag = $2.new_type_flag; }
1907         | typespec reserved_declspecs  %prec HYPERUNARY
1908                 { $$.t = tree_cons (NULL_TREE, $1.t, $2);
1909                   $$.new_type_flag = $1.new_type_flag; }
1910         | typespec reserved_typespecquals reserved_declspecs
1911                 { $$.t = tree_cons (NULL_TREE, $1.t, chainon ($2, $3));
1912                   $$.new_type_flag = $1.new_type_flag; }
1913         | declmods typespec reserved_declspecs
1914                 { $$.t = tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1915                   $$.new_type_flag = $2.new_type_flag; }
1916         | declmods typespec reserved_typespecquals
1917                 { $$.t = tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1918                   $$.new_type_flag = $2.new_type_flag; }
1919         | declmods typespec reserved_typespecquals reserved_declspecs
1920                 { $$.t = tree_cons (NULL_TREE, $2.t,
1921                                     chainon ($3, chainon ($4, $1.t)));
1922                   $$.new_type_flag = $2.new_type_flag; }
1923         ;
1924
1925 reserved_declspecs:
1926           SCSPEC
1927                 { if (extra_warnings)
1928                     warning ("`%s' is not at beginning of declaration",
1929                              IDENTIFIER_POINTER ($$));
1930                   $$ = build_tree_list (NULL_TREE, $$); }
1931         | reserved_declspecs typespecqual_reserved
1932                 { $$ = tree_cons (NULL_TREE, $2.t, $$); }
1933         | reserved_declspecs SCSPEC
1934                 { if (extra_warnings)
1935                     warning ("`%s' is not at beginning of declaration",
1936                              IDENTIFIER_POINTER ($2));
1937                   $$ = tree_cons (NULL_TREE, $2, $$); }
1938         ;
1939
1940 /* List of just storage classes and type modifiers.
1941    A declaration can start with just this, but then it cannot be used
1942    to redeclare a typedef-name.
1943    In the result, declspecs have a non-NULL TREE_VALUE, attributes do not.  */
1944
1945 /* We use hash_tree_cons for lists of typeless declspecs so that they end
1946    up on a persistent obstack.  Otherwise, they could appear at the
1947    beginning of something like
1948
1949       static const struct { int foo () { } } b;
1950
1951    and would be discarded after we finish compiling foo.  We don't need to
1952    worry once we see a type.  */
1953
1954 declmods:
1955           nonempty_cv_qualifiers  %prec EMPTY
1956                 { $$.lookups = NULL_TREE; TREE_STATIC ($$.t) = 1; }
1957         | SCSPEC
1958                 {
1959                   $$.t = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
1960                   $$.new_type_flag = 0; $$.lookups = NULL_TREE;
1961                 }
1962         | declmods CV_QUALIFIER
1963                 {
1964                   $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
1965                   TREE_STATIC ($$.t) = 1;
1966                 }
1967         | declmods SCSPEC
1968                 {
1969                   if (extra_warnings && TREE_STATIC ($$.t))
1970                     warning ("`%s' is not at beginning of declaration",
1971                              IDENTIFIER_POINTER ($2));
1972                   $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
1973                   TREE_STATIC ($$.t) = TREE_STATIC ($1.t);
1974                 }
1975         | declmods attributes
1976                 { $$.t = hash_tree_cons ($2, NULL_TREE, $1.t); }
1977         ;
1978
1979 /* Used instead of declspecs where storage classes are not allowed
1980    (that is, for typenames and structure components).
1981
1982    C++ can takes storage classes for structure components.
1983    Don't accept a typedef-name if anything but a modifier precedes it.  */
1984
1985 typed_typespecs:
1986           typespec  %prec EMPTY
1987                 { $$.t = build_tree_list (NULL_TREE, $1.t);
1988                   $$.new_type_flag = $1.new_type_flag; }
1989         | nonempty_cv_qualifiers typespec
1990                 { $$.t = tree_cons (NULL_TREE, $2.t, $1.t);
1991                   $$.new_type_flag = $2.new_type_flag; }
1992         | typespec reserved_typespecquals
1993                 { $$.t = tree_cons (NULL_TREE, $1.t, $2);
1994                   $$.new_type_flag = $1.new_type_flag; }
1995         | nonempty_cv_qualifiers typespec reserved_typespecquals
1996                 { $$.t = tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1997                   $$.new_type_flag = $2.new_type_flag; }
1998         ;
1999
2000 reserved_typespecquals:
2001           typespecqual_reserved
2002                 { $$ = build_tree_list (NULL_TREE, $1.t); }
2003         | reserved_typespecquals typespecqual_reserved
2004                 { $$ = tree_cons (NULL_TREE, $2.t, $1); }
2005         | reserved_typespecquals attributes
2006                 { $$ = tree_cons ($2, NULL_TREE, $1); }
2007         | attributes %prec EMPTY
2008                 { $$ = tree_cons ($1, NULL_TREE, NULL_TREE); }
2009         ;
2010
2011 sizeof:
2012         SIZEOF { skip_evaluation++; }
2013         ;
2014
2015 alignof:
2016         ALIGNOF { skip_evaluation++; }
2017         ;
2018
2019 typeof:
2020         TYPEOF { skip_evaluation++; }
2021         ;
2022
2023 /* A typespec (but not a type qualifier).
2024    Once we have seen one of these in a declaration,
2025    if a typedef name appears then it is being redeclared.  */
2026
2027 typespec:
2028           structsp
2029                 { $$.lookups = NULL_TREE; }
2030         | TYPESPEC  %prec EMPTY
2031                 { $$.t = $1; $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
2032         | complete_type_name
2033                 { $$.t = $1; $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
2034         | typeof '(' expr ')'
2035                 { $$.t = finish_typeof ($3);
2036                   $$.new_type_flag = 0; $$.lookups = NULL_TREE;
2037                   skip_evaluation--; }
2038         | typeof '(' type_id ')'
2039                 { $$.t = groktypename ($3.t);
2040                   $$.new_type_flag = 0; $$.lookups = NULL_TREE;
2041                   skip_evaluation--; }
2042         | SIGOF '(' expr ')'
2043                 { tree type = TREE_TYPE ($3);
2044
2045                   $$.new_type_flag = 0; $$.lookups = NULL_TREE;
2046                   if (IS_AGGR_TYPE (type))
2047                     {
2048                       sorry ("sigof type specifier");
2049                       $$.t = type;
2050                     }
2051                   else
2052                     {
2053                       error ("`sigof' applied to non-aggregate expression");
2054                       $$.t = error_mark_node;
2055                     }
2056                 }
2057         | SIGOF '(' type_id ')'
2058                 { tree type = groktypename ($3.t);
2059
2060                   $$.new_type_flag = 0; $$.lookups = NULL_TREE;
2061                   if (IS_AGGR_TYPE (type))
2062                     {
2063                       sorry ("sigof type specifier");
2064                       $$.t = type;
2065                     }
2066                   else
2067                     {
2068                       error("`sigof' applied to non-aggregate type");
2069                       $$.t = error_mark_node;
2070                     }
2071                 }
2072         ;
2073
2074 /* A typespec that is a reserved word, or a type qualifier.  */
2075
2076 typespecqual_reserved:
2077           TYPESPEC
2078                 { $$.t = $1; $$.new_type_flag = 0; }
2079         | CV_QUALIFIER
2080                 { $$.t = $1; $$.new_type_flag = 0; }
2081         | structsp
2082         ;
2083
2084 initdecls:
2085           initdcl0
2086         | initdecls ',' initdcl
2087             { check_multiple_declarators (); }
2088         ;
2089
2090 notype_initdecls:
2091           notype_initdcl0
2092         | notype_initdecls ',' initdcl
2093             { check_multiple_declarators (); }
2094         ;
2095
2096 nomods_initdecls:
2097           nomods_initdcl0
2098         | nomods_initdecls ',' initdcl
2099             { check_multiple_declarators (); }
2100         ;
2101
2102 maybeasm:
2103           /* empty */
2104                 { $$ = NULL_TREE; }
2105         | asm_keyword '(' STRING ')'
2106                 { $$ = $3; }
2107         ;
2108
2109 initdcl:
2110           declarator maybeasm maybe_attribute '='
2111                 { $<ttype>$ = parse_decl ($<ttype>1, $3, 1); }
2112           init
2113 /* Note how the declaration of the variable is in effect while its init is parsed! */
2114                 { parse_end_decl ($<ttype>5, $6, $2); }
2115         | declarator maybeasm maybe_attribute
2116                 {
2117                   $<ttype>$ = parse_decl ($<ttype>1, $3, 0);
2118                   parse_end_decl ($<ttype>$, NULL_TREE, $2);
2119                 }
2120         ;
2121
2122         /* This rule assumes a certain configuration of the parser stack.
2123            In particular, $0, the element directly before the beginning of
2124            this rule on the stack, must be a maybeasm.  $-1 must be a
2125            declarator or notype_declarator.  And $-2 must be some declmods
2126            or declspecs.  We can't move the maybeasm into this rule because
2127            we need that reduce so we prefer fn.def1 when appropriate.  */
2128 initdcl0_innards:
2129           maybe_attribute '='
2130                 { $<ttype>$ = parse_decl0 ($<ttype>-1, $<ftype>-2.t,
2131                                            $<ftype>-2.lookups, $1, 1); }
2132           /* Note how the declaration of the variable is in effect
2133              while its init is parsed! */
2134           init
2135                 { parse_end_decl ($<ttype>3, $4, $<ttype>0); }
2136         | maybe_attribute
2137                 { tree d = parse_decl0 ($<ttype>-1, $<ftype>-2.t,
2138                                         $<ftype>-2.lookups, $1, 0);
2139                   parse_end_decl (d, NULL_TREE, $<ttype>0); }
2140         ;
2141
2142 initdcl0:
2143           declarator maybeasm initdcl0_innards
2144                 {}
2145         ;
2146
2147 notype_initdcl0:
2148           notype_declarator maybeasm initdcl0_innards
2149                 {}
2150         ;
2151
2152 nomods_initdcl0:
2153           notype_declarator maybeasm
2154             { /* Set things up as initdcl0_innards expects.  */
2155               $<ttype>$ = $2;
2156               $2 = $1;
2157               $<ftype>1.t = NULL_TREE;
2158               $<ftype>1.lookups = NULL_TREE; }
2159           initdcl0_innards
2160             {}
2161         | constructor_declarator maybeasm maybe_attribute
2162                 { tree d = parse_decl0 ($1, NULL_TREE, NULL_TREE, $3, 0);
2163                   parse_end_decl (d, NULL_TREE, $2); }
2164         ;
2165
2166 /* the * rules are dummies to accept the Apollo extended syntax
2167    so that the header files compile.  */
2168 maybe_attribute:
2169           /* empty */
2170                 { $$ = NULL_TREE; }
2171         | attributes
2172                 { $$ = $1; }
2173         ;
2174
2175 attributes:
2176       attribute
2177                 { $$ = $1; }
2178         | attributes attribute
2179                 { $$ = chainon ($1, $2); }
2180         ;
2181
2182 attribute:
2183       ATTRIBUTE '(' '(' attribute_list ')' ')'
2184                 { $$ = $4; }
2185         ;
2186
2187 attribute_list:
2188       attrib
2189                 { $$ = $1; }
2190         | attribute_list ',' attrib
2191                 { $$ = chainon ($1, $3); }
2192         ;
2193
2194 attrib:
2195           /* empty */
2196                 { $$ = NULL_TREE; }
2197         | any_word
2198                 { $$ = build_tree_list ($1, NULL_TREE); }
2199         | any_word '(' IDENTIFIER ')'
2200                 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
2201         | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
2202                 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
2203         | any_word '(' nonnull_exprlist ')'
2204                 { $$ = build_tree_list ($1, $3); }
2205         ;
2206
2207 /* This still leaves out most reserved keywords,
2208    shouldn't we include them?  */
2209
2210 any_word:
2211           identifier
2212         | SCSPEC
2213         | TYPESPEC
2214         | CV_QUALIFIER
2215         ;
2216
2217 /* A nonempty list of identifiers, including typenames.  */
2218 identifiers_or_typenames:
2219           identifier
2220                 { $$ = build_tree_list (NULL_TREE, $1); }
2221         | identifiers_or_typenames ',' identifier
2222                 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2223         ;
2224
2225 maybe_init:
2226           /* empty */  %prec EMPTY
2227                 { $$ = NULL_TREE; }
2228         | '=' init
2229                 { $$ = $2; }
2230         ;
2231
2232 /* If we are processing a template, we don't want to expand this
2233    initializer yet.  */
2234
2235 init:
2236           expr_no_commas  %prec '='
2237         | '{' '}'
2238                 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, NULL_TREE);
2239                   TREE_HAS_CONSTRUCTOR ($$) = 1; }
2240         | '{' initlist '}'
2241                 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2242                   TREE_HAS_CONSTRUCTOR ($$) = 1; }
2243         | '{' initlist ',' '}'
2244                 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2245                   TREE_HAS_CONSTRUCTOR ($$) = 1; }
2246         | error
2247                 { $$ = NULL_TREE; }
2248         ;
2249
2250 /* This chain is built in reverse order,
2251    and put in forward order where initlist is used.  */
2252 initlist:
2253           init
2254                 { $$ = build_tree_list (NULL_TREE, $$); }
2255         | initlist ',' init
2256                 { $$ = tree_cons (NULL_TREE, $3, $$); }
2257         /* These are for labeled elements.  */
2258         | '[' expr_no_commas ']' init
2259                 { $$ = build_tree_list ($2, $4); }
2260         | identifier ':' init
2261                 { $$ = build_tree_list ($$, $3); }
2262         | initlist ',' identifier ':' init
2263                 { $$ = tree_cons ($3, $5, $$); }
2264         ;
2265
2266 pending_inline:
2267           PRE_PARSED_FUNCTION_DECL maybe_return_init function_body
2268                 {
2269                   expand_body (finish_function (2));
2270                   process_next_inline ($1);
2271                 }
2272         | PRE_PARSED_FUNCTION_DECL maybe_return_init function_try_block
2273                 {
2274                   expand_body (finish_function (2));
2275                   process_next_inline ($1);
2276                 }
2277         | PRE_PARSED_FUNCTION_DECL maybe_return_init error
2278                 {
2279                   finish_function (2);
2280                   process_next_inline ($1); }
2281         ;
2282
2283 pending_inlines:
2284         /* empty */
2285         | pending_inlines pending_inline eat_saved_input
2286         ;
2287
2288 /* A regurgitated default argument.  The value of DEFARG_MARKER will be
2289    the TREE_LIST node for the parameter in question.  */
2290 defarg_again:
2291         DEFARG_MARKER expr_no_commas END_OF_SAVED_INPUT
2292                 { replace_defarg ($1, $2); }
2293         | DEFARG_MARKER error END_OF_SAVED_INPUT
2294                 { replace_defarg ($1, error_mark_node); }
2295         ;
2296
2297 pending_defargs:
2298           /* empty */ %prec EMPTY
2299         | pending_defargs defarg_again
2300                 { do_pending_defargs (); }
2301         | pending_defargs error
2302                 { do_pending_defargs (); }
2303         ;
2304
2305 structsp:
2306           ENUM identifier '{'
2307                 { $<ttype>$ = current_enum_type;
2308                   current_enum_type = start_enum ($2); }
2309           enumlist_opt '}'
2310                 { $$.t = current_enum_type;
2311                   finish_enum (current_enum_type);
2312                   $$.new_type_flag = 1;
2313                   current_enum_type = $<ttype>4;
2314                   check_for_missing_semicolon ($$.t); }
2315         | ENUM '{'
2316                 { $<ttype>$ = current_enum_type;
2317                   current_enum_type = start_enum (make_anon_name ()); }
2318           enumlist_opt '}'
2319                 { $$.t = current_enum_type;
2320                   finish_enum (current_enum_type);
2321                   $$.new_type_flag = 1;
2322                   current_enum_type = $<ttype>3;
2323                   check_for_missing_semicolon ($$.t); }
2324         | ENUM identifier
2325                 { $$.t = parse_xref_tag (enum_type_node, $2, 1);
2326                   $$.new_type_flag = 0; }
2327         | ENUM complex_type_name
2328                 { $$.t = parse_xref_tag (enum_type_node, $2, 1);
2329                   $$.new_type_flag = 0; }
2330         | TYPENAME_KEYWORD typename_sub
2331                 { $$.t = $2;
2332                   $$.new_type_flag = 0;
2333                   if (!processing_template_decl)
2334                     pedwarn ("using `typename' outside of template"); }
2335         /* C++ extensions, merged with C to avoid shift/reduce conflicts */
2336         | class_head_defn maybe_base_class_list '{'
2337                 {
2338                   if ($2 && $1.t != error_mark_node)
2339                     {
2340                       tree type = TREE_TYPE ($1.t);
2341
2342                       if (TREE_CODE (type) == TYPENAME_TYPE)
2343                         /* In a definition of a member class template,
2344                            we will get here with an implicit typename,
2345                            a TYPENAME_TYPE with a type. */
2346                         type = TREE_TYPE (type);
2347                       maybe_process_partial_specialization (type);
2348                       xref_basetypes (type, $2);
2349                     }
2350                   $1.t = begin_class_definition (TREE_TYPE ($1.t));
2351                   check_class_key (current_aggr, $1.t);
2352                   current_aggr = NULL_TREE; }
2353           opt.component_decl_list '}' maybe_attribute
2354                 {
2355                   int semi;
2356                   tree t;
2357
2358                   if (yychar == YYEMPTY)
2359                     yychar = YYLEX;
2360                   semi = yychar == ';';
2361
2362                   t = finish_class_definition ($1.t, $7, semi, $1.new_type_flag);
2363                   $<ttype>$ = t;
2364
2365                   /* restore current_aggr */
2366                   current_aggr = TREE_CODE (t) != RECORD_TYPE
2367                                  ? union_type_node
2368                                  : CLASSTYPE_DECLARED_CLASS (t)
2369                                  ? class_type_node : record_type_node;
2370                 }
2371           pending_defargs
2372                 {
2373                   done_pending_defargs ();
2374                   begin_inline_definitions ();
2375                 }
2376           pending_inlines
2377                 {
2378                   $$.t = $<ttype>8;
2379                   $$.new_type_flag = 1;
2380                 }
2381         | class_head_decl
2382                 {
2383                   $$.t = TREE_TYPE ($1.t);
2384                   $$.new_type_flag = $1.new_type_flag;
2385                   check_class_key (current_aggr, $$.t);
2386                 }
2387         ;
2388
2389 maybecomma:
2390           /* empty */
2391         | ','
2392         ;
2393
2394 maybecomma_warn:
2395           /* empty */
2396         | ','
2397                 { if (pedantic && !in_system_header)
2398                     pedwarn ("comma at end of enumerator list"); }
2399         ;
2400
2401 aggr:
2402           AGGR
2403         | aggr SCSPEC
2404                 { error ("storage class specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2405         | aggr TYPESPEC
2406                 { error ("type specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2407         | aggr CV_QUALIFIER
2408                 { error ("type qualifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2409         | aggr AGGR
2410                 { error ("no body nor ';' separates two class, struct or union declarations"); }
2411         | aggr attributes
2412                 { $$ = build_tree_list ($2, $1); }
2413         ;
2414
2415 class_head:
2416           aggr identifier
2417                 {
2418                   current_aggr = $1;
2419                   $$ = build_tree_list (NULL_TREE, $2);
2420                 }
2421         | aggr nested_name_specifier identifier
2422                 {
2423                   current_aggr = $1;
2424                   $$ = build_tree_list ($2, $3);
2425                 }
2426         | aggr global_scope nested_name_specifier identifier
2427                 {
2428                   current_aggr = $1;
2429                   $$ = build_tree_list ($3, $4);
2430                 }
2431         | aggr global_scope identifier
2432                 {
2433                   current_aggr = $1;
2434                   $$ = build_tree_list (global_namespace, $3);
2435                 }
2436         ;
2437
2438 class_head_apparent_template:
2439           aggr apparent_template_type
2440                 {
2441                   current_aggr = $1;
2442                   $$ = $2;
2443                 }
2444         | aggr nested_name_specifier apparent_template_type
2445                 {
2446                   current_aggr = $1;
2447                   $$ = $3;
2448                 }
2449         | aggr global_scope nested_name_specifier apparent_template_type
2450                 {
2451                   current_aggr = $1;
2452                   $$ = $4;
2453                 }
2454         ;
2455
2456 class_head_decl:
2457           class_head %prec EMPTY
2458                 {
2459                   $$.t = parse_handle_class_head (current_aggr,
2460                                                   TREE_PURPOSE ($1), 
2461                                                   TREE_VALUE ($1),
2462                                                   0, &$$.new_type_flag);
2463                 }
2464         | aggr identifier_defn %prec EMPTY
2465                 {
2466                   current_aggr = $1;
2467                   $$.t = TYPE_MAIN_DECL (parse_xref_tag (current_aggr, $2, 0));
2468                   $$.new_type_flag = 1;
2469                 }
2470         | class_head_apparent_template %prec EMPTY
2471                 {
2472                   $$.t = $1;
2473                   $$.new_type_flag = 0;
2474                 }
2475         ;
2476
2477 class_head_defn:
2478           class_head '{'
2479                 {
2480                   yyungetc ('{', 1);
2481                   $$.t = parse_handle_class_head (current_aggr,
2482                                                   TREE_PURPOSE ($1), 
2483                                                   TREE_VALUE ($1),
2484                                                   1, 
2485                                                   &$$.new_type_flag);
2486                 }
2487         | class_head ':'
2488                 {
2489                   yyungetc (':', 1);
2490                   $$.t = parse_handle_class_head (current_aggr,
2491                                                   TREE_PURPOSE ($1), 
2492                                                   TREE_VALUE ($1),
2493                                                   1, &$$.new_type_flag);
2494                 }
2495         | class_head_apparent_template '{'
2496                 {
2497                   yyungetc ('{', 1);
2498                   $$.t = $1;
2499                   $$.new_type_flag = 0;
2500                   if (TREE_CODE (TREE_TYPE ($1)) == RECORD_TYPE)
2501                     /* We might be specializing a template with a different
2502                        class-key.  */
2503                     CLASSTYPE_DECLARED_CLASS (TREE_TYPE ($1))
2504                       = (current_aggr == class_type_node);
2505                 }
2506         | class_head_apparent_template ':'
2507                 {
2508                   yyungetc (':', 1);
2509                   $$.t = $1;
2510                   $$.new_type_flag = 0;
2511                   if (TREE_CODE (TREE_TYPE ($1)) == RECORD_TYPE)
2512                     /* We might be specializing a template with a different
2513                        class-key.  */
2514                     CLASSTYPE_DECLARED_CLASS (TREE_TYPE ($1))
2515                       = (current_aggr == class_type_node);
2516                 }
2517         | aggr identifier_defn '{'
2518                 {
2519                   yyungetc ('{', 1);
2520                   current_aggr = $1;
2521                   $$.t = parse_handle_class_head (current_aggr,
2522                                                   NULL_TREE, $2,
2523                                                   1, &$$.new_type_flag);
2524                 }
2525         | aggr identifier_defn ':'
2526                 {
2527                   yyungetc (':', 1);
2528                   current_aggr = $1;
2529                   $$.t = parse_handle_class_head (current_aggr,
2530                                                   NULL_TREE, $2,
2531                                                   1, &$$.new_type_flag);
2532                 }
2533         | aggr '{'
2534                 {
2535                   current_aggr = $1;
2536                   $$.t = TYPE_MAIN_DECL (parse_xref_tag ($1, 
2537                                                          make_anon_name (), 
2538                                                          0));
2539                   $$.new_type_flag = 0;
2540                   yyungetc ('{', 1);
2541                 }
2542         ;
2543
2544 maybe_base_class_list:
2545           /* empty */
2546                 { $$ = NULL_TREE; }
2547         | ':' see_typename
2548                 { error ("no bases given following `:'");
2549                   $$ = NULL_TREE; }
2550         | ':' see_typename base_class_list
2551                 { $$ = $3; }
2552         ;
2553
2554 base_class_list:
2555           base_class
2556         | base_class_list ',' see_typename base_class
2557                 { $$ = chainon ($$, $4); }
2558         ;
2559
2560 base_class:
2561           base_class_1
2562                 { $$ = finish_base_specifier (access_default_node, $1); }
2563         | base_class_access_list see_typename base_class_1
2564                 { $$ = finish_base_specifier ($1, $3); }
2565         ;
2566
2567 base_class_1:
2568           typename_sub
2569                 { if (!TYPE_P ($$))
2570                     $$ = error_mark_node; }
2571         | nonnested_type
2572                 { $$ = TREE_TYPE ($$); }
2573         ;
2574
2575 base_class_access_list:
2576           VISSPEC see_typename
2577         | SCSPEC see_typename
2578                 { if ($1 != ridpointers[(int)RID_VIRTUAL])
2579                     error ("`%D' access", $1);
2580                   $$ = access_default_virtual_node; }
2581         | base_class_access_list VISSPEC see_typename
2582                 {
2583                   if ($1 != access_default_virtual_node)
2584                     error ("multiple access specifiers");
2585                   else if ($2 == access_public_node)
2586                     $$ = access_public_virtual_node;
2587                   else if ($2 == access_protected_node)
2588                     $$ = access_protected_virtual_node;
2589                   else /* $2 == access_private_node */
2590                     $$ = access_private_virtual_node;
2591                 }
2592         | base_class_access_list SCSPEC see_typename
2593                 { if ($2 != ridpointers[(int)RID_VIRTUAL])
2594                     error ("`%D' access", $2);
2595                   else if ($$ == access_public_node)
2596                     $$ = access_public_virtual_node;
2597                   else if ($$ == access_protected_node)
2598                     $$ = access_protected_virtual_node;
2599                   else if ($$ == access_private_node)
2600                     $$ = access_private_virtual_node;
2601                   else
2602                     error ("multiple `virtual' specifiers");
2603                 }
2604         ;
2605
2606 opt.component_decl_list:
2607         | component_decl_list
2608         | opt.component_decl_list access_specifier component_decl_list
2609         | opt.component_decl_list access_specifier
2610         ;
2611
2612 access_specifier:
2613           VISSPEC ':'
2614                 {
2615                   current_access_specifier = $1;
2616                 }
2617         ;
2618
2619 /* Note: we no longer warn about the semicolon after a component_decl_list.
2620    ARM $9.2 says that the semicolon is optional, and therefore allowed.  */
2621 component_decl_list:
2622           component_decl
2623                 {
2624                   finish_member_declaration ($1);
2625                   current_aggr = NULL_TREE;
2626                   reset_type_access_control ();
2627                 }
2628         | component_decl_list component_decl
2629                 {
2630                   finish_member_declaration ($2);
2631                   current_aggr = NULL_TREE;
2632                   reset_type_access_control ();
2633                 }
2634         ;
2635
2636 component_decl:
2637           component_decl_1 ';'
2638         | component_decl_1 '}'
2639                 { error ("missing ';' before right brace");
2640                   yyungetc ('}', 0); }
2641         /* C++: handle constructors, destructors and inline functions */
2642         /* note that INLINE is like a TYPESPEC */
2643         | fn_def2 ':' /* base_init compstmt */
2644                 { $$ = finish_method ($$); }
2645         | fn_def2 TRY /* base_init compstmt */
2646                 { $$ = finish_method ($$); }
2647         | fn_def2 RETURN_KEYWORD /* base_init compstmt */
2648                 { $$ = finish_method ($$); }
2649         | fn_def2 '{' /* nodecls compstmt */
2650                 { $$ = finish_method ($$); }
2651         | ';'
2652                 { $$ = NULL_TREE; }
2653         | extension component_decl
2654                 { $$ = $2;
2655                   pedantic = $1; }
2656         | template_header component_decl
2657                 {
2658                   if ($2)
2659                     $$ = finish_member_template_decl ($2);
2660                   else
2661                     /* The component was already processed.  */
2662                     $$ = NULL_TREE;
2663
2664                   finish_template_decl ($1);
2665                 }
2666         | template_header typed_declspecs ';'
2667                 {
2668                   $$ = finish_member_class_template ($2.t);
2669                   finish_template_decl ($1);
2670                 }
2671         | bad_decl
2672                 { $$ = NULL_TREE; }
2673         ;
2674
2675 component_decl_1:
2676         /* Do not add a "typed_declspecs declarator" rule here for
2677            speed; we need to call grok_x_components for enums, so the
2678            speedup would be insignificant.  */
2679           typed_declspecs components
2680                 {
2681                   /* Most of the productions for component_decl only
2682                      allow the creation of one new member, so we call
2683                      finish_member_declaration in component_decl_list.
2684                      For this rule and the next, however, there can be
2685                      more than one member, e.g.:
2686
2687                        int i, j;
2688
2689                      and we need the first member to be fully
2690                      registered before the second is processed.
2691                      Therefore, the rules for components take care of
2692                      this processing.  To avoid registering the
2693                      components more than once, we send NULL_TREE up
2694                      here; that lets finish_member_declaration know
2695                      that there is nothing to do.  */
2696                   if (!$2)
2697                     grok_x_components ($1.t);
2698                   $$ = NULL_TREE;
2699                 }
2700         | declmods notype_components
2701                 {
2702                   if (!$2)
2703                     grok_x_components ($1.t);
2704                   $$ = NULL_TREE;
2705                 }
2706         | notype_declarator maybeasm maybe_attribute maybe_init
2707                 { $$ = grokfield ($$, NULL_TREE, $4, $2, $3); }
2708         | constructor_declarator maybeasm maybe_attribute maybe_init
2709                 { $$ = grokfield ($$, NULL_TREE, $4, $2, $3); }
2710         | ':' expr_no_commas
2711                 { $$ = grokbitfield (NULL_TREE, NULL_TREE, $2); }
2712         | error
2713                 { $$ = NULL_TREE; }
2714
2715         /* These rules introduce a reduce/reduce conflict; in
2716                 typedef int foo, bar;
2717                 class A {
2718                   foo (bar);
2719                 };
2720            should "A::foo" be declared as a function or "A::bar" as a data
2721            member? In other words, is "bar" an after_type_declarator or a
2722            parmlist? */
2723         | declmods component_constructor_declarator maybeasm maybe_attribute maybe_init
2724                 { tree specs, attrs;
2725                   split_specs_attrs ($1.t, &specs, &attrs);
2726                   $$ = grokfield ($2, specs, $5, $3,
2727                                   chainon ($4, attrs)); }
2728         | component_constructor_declarator maybeasm maybe_attribute maybe_init
2729                 { $$ = grokfield ($$, NULL_TREE, $4, $2, $3); }
2730         | using_decl
2731                 { $$ = do_class_using_decl ($1); }
2732         ;
2733
2734 /* The case of exactly one component is handled directly by component_decl.  */
2735 /* ??? Huh? ^^^ */
2736 components:
2737           /* empty: possibly anonymous */
2738                 { $$ = 0; }
2739         | component_declarator0
2740                 {
2741                   if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2742                     $1 = finish_member_template_decl ($1);
2743                   finish_member_declaration ($1);
2744                   $$ = 1;
2745                 }
2746         | components ',' component_declarator
2747                 {
2748                   check_multiple_declarators ();
2749                   if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2750                     $3 = finish_member_template_decl ($3);
2751                   finish_member_declaration ($3);
2752                   $$ = 2;
2753                 }
2754         ;
2755
2756 notype_components:
2757           /* empty: possibly anonymous */
2758                 { $$ = 0; }
2759         | notype_component_declarator0
2760                 {
2761                   if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2762                     $1 = finish_member_template_decl ($1);
2763                   finish_member_declaration ($1);
2764                   $$ = 1;
2765                 }
2766         | notype_components ',' notype_component_declarator
2767                 {
2768                   check_multiple_declarators ();
2769                   if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2770                     $3 = finish_member_template_decl ($3);
2771                   finish_member_declaration ($3);
2772                   $$ = 2;
2773                 }
2774         ;
2775
2776 component_declarator0:
2777           after_type_component_declarator0
2778         | notype_component_declarator0
2779         ;
2780
2781 component_declarator:
2782           after_type_component_declarator
2783         | notype_component_declarator
2784         ;
2785
2786 after_type_component_declarator0:
2787           after_type_declarator maybeasm maybe_attribute maybe_init
2788                 { $$ = parse_field0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2789                                      $3, $2, $4); }
2790         | tTYPENAME ':' expr_no_commas maybe_attribute
2791                 { $$ = parse_bitfield0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2792                                         $4, $3); }
2793         ;
2794
2795 notype_component_declarator0:
2796           notype_declarator maybeasm maybe_attribute maybe_init
2797                 { $$ = parse_field0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2798                                      $3, $2, $4); }
2799         | constructor_declarator maybeasm maybe_attribute maybe_init
2800                 { $$ = parse_field0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2801                                      $3, $2, $4); }
2802         | IDENTIFIER ':' expr_no_commas maybe_attribute
2803                 { $$ = parse_bitfield0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2804                                         $4, $3); }
2805         | ':' expr_no_commas maybe_attribute
2806                 { $$ = parse_bitfield0 (NULL_TREE, $<ftype>0.t,
2807                                         $<ftype>0.lookups, $3, $2); }
2808         ;
2809
2810 after_type_component_declarator:
2811           after_type_declarator maybeasm maybe_attribute maybe_init
2812                 { $$ = parse_field ($1, $3, $2, $4); }
2813         | tTYPENAME ':' expr_no_commas maybe_attribute
2814                 { $$ = parse_bitfield ($1, $4, $3); }
2815         ;
2816
2817 notype_component_declarator:
2818           notype_declarator maybeasm maybe_attribute maybe_init
2819                 { $$ = parse_field ($1, $3, $2, $4); }
2820         | IDENTIFIER ':' expr_no_commas maybe_attribute
2821                 { $$ = parse_bitfield ($1, $4, $3); }
2822         | ':' expr_no_commas maybe_attribute
2823                 { $$ = parse_bitfield (NULL_TREE, $3, $2); }
2824         ;
2825
2826 enumlist_opt:
2827           enumlist maybecomma_warn
2828         | maybecomma_warn
2829         ;
2830
2831 /* We chain the enumerators in reverse order.
2832    Because of the way enums are built, the order is
2833    insignificant.  Take advantage of this fact.  */
2834
2835 enumlist:
2836           enumerator
2837         | enumlist ',' enumerator
2838         ;
2839
2840 enumerator:
2841           identifier
2842                 { build_enumerator ($1, NULL_TREE, current_enum_type); }
2843         | identifier '=' expr_no_commas
2844                 { build_enumerator ($1, $3, current_enum_type); }
2845         ;
2846
2847 /* ISO new-type-id (5.3.4) */
2848 new_type_id:
2849           type_specifier_seq new_declarator
2850                 { $$.t = build_tree_list ($1.t, $2);
2851                   $$.new_type_flag = $1.new_type_flag; }
2852         | type_specifier_seq  %prec EMPTY
2853                 { $$.t = build_tree_list ($1.t, NULL_TREE);
2854                   $$.new_type_flag = $1.new_type_flag; }
2855         /* GNU extension to allow arrays of arbitrary types with
2856            non-constant dimension.  */
2857         | '(' type_id ')' '[' expr ']'
2858                 {
2859                   if (pedantic)
2860                     pedwarn ("ISO C++ forbids array dimensions with parenthesized type in new");
2861                   $$.t = build_nt (ARRAY_REF, TREE_VALUE ($2.t), $5);
2862                   $$.t = build_tree_list (TREE_PURPOSE ($2.t), $$.t);
2863                   $$.new_type_flag = $2.new_type_flag;
2864                 }
2865         ;
2866
2867 cv_qualifiers:
2868           /* empty */  %prec EMPTY
2869                 { $$ = NULL_TREE; }
2870         | cv_qualifiers CV_QUALIFIER
2871                 { $$ = tree_cons (NULL_TREE, $2, $$); }
2872         ;
2873
2874 nonempty_cv_qualifiers:
2875           CV_QUALIFIER
2876                 { $$.t = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
2877                   $$.new_type_flag = 0; }
2878         | nonempty_cv_qualifiers CV_QUALIFIER
2879                 { $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
2880                   $$.new_type_flag = $1.new_type_flag; }
2881         | attributes %prec EMPTY
2882                 { $$.t = hash_tree_cons ($1, NULL_TREE, NULL_TREE);
2883                   $$.new_type_flag = 0; }
2884         | nonempty_cv_qualifiers attributes %prec EMPTY
2885                 { $$.t = hash_tree_cons ($2, NULL_TREE, $1.t);
2886                   $$.new_type_flag = $1.new_type_flag; }
2887         ;
2888
2889 /* These rules must follow the rules for function declarations
2890    and component declarations.  That way, longer rules are preferred.  */
2891
2892 /* An expression which will not live on the momentary obstack.  */
2893 maybe_parmlist:
2894           '(' nonnull_exprlist ')'
2895                 { $$ = $2; }
2896         | '(' parmlist ')'
2897                 { $$ = $2; }
2898         | LEFT_RIGHT
2899                 { $$ = empty_parms (); }
2900         | '(' error ')'
2901                 { $$ = NULL_TREE; }
2902         ;
2903
2904 /* A declarator that is allowed only after an explicit typespec.  */
2905
2906 after_type_declarator_intern:
2907           after_type_declarator
2908         | attributes after_type_declarator
2909                 {
2910                   /* Provide support for '(' attributes '*' declarator ')'
2911                      etc */
2912                   $$ = tree_cons ($1, $2, NULL_TREE);
2913                 }
2914         ;
2915
2916 /* may all be followed by prec '.' */
2917 after_type_declarator:
2918           '*' nonempty_cv_qualifiers after_type_declarator_intern  %prec UNARY
2919                 { $$ = make_pointer_declarator ($2.t, $3); }
2920         | '&' nonempty_cv_qualifiers after_type_declarator_intern  %prec UNARY
2921                 { $$ = make_reference_declarator ($2.t, $3); }
2922         | '*' after_type_declarator_intern  %prec UNARY
2923                 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2924         | '&' after_type_declarator_intern  %prec UNARY
2925                 { $$ = make_reference_declarator (NULL_TREE, $2); }
2926         | ptr_to_mem cv_qualifiers after_type_declarator_intern
2927                 { tree arg = make_pointer_declarator ($2, $3);
2928                   $$ = build_nt (SCOPE_REF, $1, arg);
2929                 }
2930         | direct_after_type_declarator
2931         ;
2932
2933 direct_after_type_declarator:
2934           direct_after_type_declarator maybe_parmlist cv_qualifiers exception_specification_opt  %prec '.'
2935                 { $$ = make_call_declarator ($$, $2, $3, $4); }
2936         | direct_after_type_declarator '[' expr ']'
2937                 { $$ = build_nt (ARRAY_REF, $$, $3); }
2938         | direct_after_type_declarator '[' ']'
2939                 { $$ = build_nt (ARRAY_REF, $$, NULL_TREE); }
2940         | '(' after_type_declarator_intern ')'
2941                 { $$ = $2; }
2942         | nested_name_specifier type_name  %prec EMPTY
2943                 { push_nested_class ($1, 3);
2944                   $$ = build_nt (SCOPE_REF, $$, $2);
2945                   TREE_COMPLEXITY ($$) = current_class_depth; }
2946         | type_name  %prec EMPTY
2947         ;
2948
2949 nonnested_type:
2950           type_name  %prec EMPTY
2951                 {
2952                   if (TREE_CODE ($1) == IDENTIFIER_NODE)
2953                     {
2954                       $$ = lookup_name ($1, 1);
2955                       maybe_note_name_used_in_class ($1, $$);
2956                     }
2957                   else
2958                     $$ = $1;
2959                 }
2960         | global_scope type_name
2961                 {
2962                   if (TREE_CODE ($2) == IDENTIFIER_NODE)
2963                     $$ = IDENTIFIER_GLOBAL_VALUE ($2);
2964                   else
2965                     $$ = $2;
2966                   got_scope = NULL_TREE;
2967                 }
2968         ;
2969
2970 complete_type_name:
2971           nonnested_type
2972         | nested_type
2973         | global_scope nested_type
2974                 { $$ = $2; }
2975         ;
2976
2977 nested_type:
2978           nested_name_specifier type_name  %prec EMPTY
2979                 { $$ = get_type_decl ($2); }
2980         ;
2981
2982 /* A declarator allowed whether or not there has been
2983    an explicit typespec.  These cannot redeclare a typedef-name.  */
2984
2985 notype_declarator_intern:
2986           notype_declarator
2987         | attributes notype_declarator
2988                 {
2989                   /* Provide support for '(' attributes '*' declarator ')'
2990                      etc */
2991                   $$ = tree_cons ($1, $2, NULL_TREE);
2992                 }
2993         ;
2994
2995 notype_declarator:
2996           '*' nonempty_cv_qualifiers notype_declarator_intern  %prec UNARY
2997                 { $$ = make_pointer_declarator ($2.t, $3); }
2998         | '&' nonempty_cv_qualifiers notype_declarator_intern  %prec UNARY
2999                 { $$ = make_reference_declarator ($2.t, $3); }
3000         | '*' notype_declarator_intern  %prec UNARY
3001                 { $$ = make_pointer_declarator (NULL_TREE, $2); }
3002         | '&' notype_declarator_intern  %prec UNARY
3003                 { $$ = make_reference_declarator (NULL_TREE, $2); }
3004         | ptr_to_mem cv_qualifiers notype_declarator_intern
3005                 { tree arg = make_pointer_declarator ($2, $3);
3006                   $$ = build_nt (SCOPE_REF, $1, arg);
3007                 }
3008         | direct_notype_declarator
3009         ;
3010
3011 complex_notype_declarator:
3012           '*' nonempty_cv_qualifiers notype_declarator_intern  %prec UNARY
3013                 { $$ = make_pointer_declarator ($2.t, $3); }
3014         | '&' nonempty_cv_qualifiers notype_declarator_intern  %prec UNARY
3015                 { $$ = make_reference_declarator ($2.t, $3); }
3016         | '*' complex_notype_declarator  %prec UNARY
3017                 { $$ = make_pointer_declarator (NULL_TREE, $2); }
3018         | '&' complex_notype_declarator  %prec UNARY
3019                 { $$ = make_reference_declarator (NULL_TREE, $2); }
3020         | ptr_to_mem cv_qualifiers notype_declarator_intern
3021                 { tree arg = make_pointer_declarator ($2, $3);
3022                   $$ = build_nt (SCOPE_REF, $1, arg);
3023                 }
3024         | complex_direct_notype_declarator
3025         ;
3026
3027 complex_direct_notype_declarator:
3028           direct_notype_declarator maybe_parmlist cv_qualifiers exception_specification_opt  %prec '.'
3029                 { $$ = make_call_declarator ($$, $2, $3, $4); }
3030         | '(' complex_notype_declarator ')'
3031                 { $$ = $2; }
3032         | direct_notype_declarator '[' expr ']'
3033                 { $$ = build_nt (ARRAY_REF, $$, $3); }
3034         | direct_notype_declarator '[' ']'
3035                 { $$ = build_nt (ARRAY_REF, $$, NULL_TREE); }
3036         | notype_qualified_id
3037                 { enter_scope_of ($1); }
3038         | global_scope notype_qualified_id
3039                 { enter_scope_of ($2); $$ = $2;}
3040         | global_scope notype_unqualified_id
3041                 { $$ = build_nt (SCOPE_REF, global_namespace, $2);
3042                   enter_scope_of ($$);
3043                 }
3044         | nested_name_specifier notype_template_declarator
3045                 { got_scope = NULL_TREE;
3046                   $$ = build_nt (SCOPE_REF, $1, $2);
3047                   enter_scope_of ($$);
3048                 }
3049         ;
3050
3051 qualified_id:
3052           nested_name_specifier unqualified_id
3053                 { got_scope = NULL_TREE;
3054                   $$ = build_nt (SCOPE_REF, $$, $2); }
3055         | nested_name_specifier object_template_id
3056                 { got_scope = NULL_TREE;
3057                   $$ = build_nt (SCOPE_REF, $1, $2); }
3058         ;
3059
3060 notype_qualified_id:
3061           nested_name_specifier notype_unqualified_id
3062                 { got_scope = NULL_TREE;
3063                   $$ = build_nt (SCOPE_REF, $$, $2); }
3064         | nested_name_specifier object_template_id
3065                 { got_scope = NULL_TREE;
3066                   $$ = build_nt (SCOPE_REF, $1, $2); }
3067         ;
3068
3069 overqualified_id:
3070           notype_qualified_id
3071         | global_scope notype_qualified_id
3072                 { $$ = $2; }
3073         ;
3074
3075 functional_cast:
3076           typespec '(' nonnull_exprlist ')'
3077                 { $$ = build_functional_cast ($1.t, $3); }
3078         | typespec '(' expr_or_declarator_intern ')'
3079                 { $$ = reparse_decl_as_expr ($1.t, $3); }
3080         | typespec fcast_or_absdcl  %prec EMPTY
3081                 { $$ = reparse_absdcl_as_expr ($1.t, $2); }
3082         ;
3083
3084 type_name:
3085           tTYPENAME
3086         | SELFNAME
3087         | template_type  %prec EMPTY
3088         ;
3089
3090 nested_name_specifier:
3091           nested_name_specifier_1
3092         | nested_name_specifier nested_name_specifier_1
3093                 { $$ = $2; }
3094         | nested_name_specifier TEMPLATE explicit_template_type SCOPE
3095                 { got_scope = $$
3096                     = make_typename_type ($1, $3, tf_error | tf_parsing); }
3097         /* Error handling per Core 125.  */
3098         | nested_name_specifier IDENTIFIER SCOPE
3099                 { got_scope = $$
3100                     = make_typename_type ($1, $2, tf_error | tf_parsing); }
3101         | nested_name_specifier PTYPENAME SCOPE
3102                 { got_scope = $$
3103                     = make_typename_type ($1, $2, tf_error | tf_parsing); }
3104         ;
3105
3106 /* Why the @#$%^& do type_name and notype_identifier need to be expanded
3107    inline here?!?  (jason) */
3108 nested_name_specifier_1:
3109           tTYPENAME SCOPE
3110                 {
3111                   if (TREE_CODE ($1) == IDENTIFIER_NODE)
3112                     {
3113                       $$ = lastiddecl;
3114                       maybe_note_name_used_in_class ($1, $$);
3115                     }
3116                   got_scope = $$ =
3117                     complete_type (TYPE_MAIN_VARIANT (TREE_TYPE ($$)));
3118                 }
3119         | SELFNAME SCOPE
3120                 {
3121                   if (TREE_CODE ($1) == IDENTIFIER_NODE)
3122                     $$ = lastiddecl;
3123                   got_scope = $$ = TREE_TYPE ($$);
3124                 }
3125         | NSNAME SCOPE
3126                 {
3127                   if (TREE_CODE ($$) == IDENTIFIER_NODE)
3128                     $$ = lastiddecl;
3129                   got_scope = $$;
3130                 }
3131         | template_type SCOPE
3132                 { got_scope = $$ = complete_type (TREE_TYPE ($1)); }
3133         ;
3134
3135 typename_sub:
3136           typename_sub0
3137         | global_scope typename_sub0
3138                 { $$ = $2; }
3139         ;
3140
3141 typename_sub0:
3142           typename_sub1 identifier %prec EMPTY
3143                 {
3144                   if (TYPE_P ($1))
3145                     $$ = make_typename_type ($1, $2, tf_error | tf_parsing);
3146                   else if (TREE_CODE ($2) == IDENTIFIER_NODE)
3147                     error ("`%T' is not a class or namespace", $2);
3148                   else
3149                     {
3150                       $$ = $2;
3151                       if (TREE_CODE ($$) == TYPE_DECL)
3152                         $$ = TREE_TYPE ($$);
3153                     }
3154                 }
3155         | typename_sub1 template_type %prec EMPTY
3156                 { $$ = TREE_TYPE ($2); }
3157         | typename_sub1 explicit_template_type %prec EMPTY
3158                 { $$ = make_typename_type ($1, $2, tf_error | tf_parsing); }
3159         | typename_sub1 TEMPLATE explicit_template_type %prec EMPTY
3160                 { $$ = make_typename_type ($1, $3, tf_error | tf_parsing); }
3161         ;
3162
3163 typename_sub1:
3164           typename_sub2
3165                 {
3166                   if (TREE_CODE ($1) == IDENTIFIER_NODE)
3167                     error ("`%T' is not a class or namespace", $1);
3168                   else if (TREE_CODE ($1) == TYPE_DECL)
3169                     $$ = TREE_TYPE ($1);
3170                 }
3171         | typename_sub1 typename_sub2
3172                 {
3173                   if (TYPE_P ($1))
3174                     $$ = make_typename_type ($1, $2, tf_error | tf_parsing);
3175                   else if (TREE_CODE ($2) == IDENTIFIER_NODE)
3176                     error ("`%T' is not a class or namespace", $2);
3177                   else
3178                     {
3179                       $$ = $2;
3180                       if (TREE_CODE ($$) == TYPE_DECL)
3181                         $$ = TREE_TYPE ($$);
3182                     }
3183                 }
3184         | typename_sub1 explicit_template_type SCOPE
3185                 { got_scope = $$
3186                     = make_typename_type ($1, $2, tf_error | tf_parsing); }
3187         | typename_sub1 TEMPLATE explicit_template_type SCOPE
3188                 { got_scope = $$
3189                     = make_typename_type ($1, $3, tf_error | tf_parsing); }
3190         ;
3191
3192 /* This needs to return a TYPE_DECL for simple names so that we don't
3193    forget what name was used.  */
3194 typename_sub2:
3195           tTYPENAME SCOPE
3196                 {
3197                   if (TREE_CODE ($1) != TYPE_DECL)
3198                     $$ = lastiddecl;
3199
3200                   /* Retrieve the type for the identifier, which might involve
3201                      some computation. */
3202                   got_scope = complete_type (TREE_TYPE ($$));
3203
3204                   if ($$ == error_mark_node)
3205                     error ("`%T' is not a class or namespace", $1);
3206                 }
3207         | SELFNAME SCOPE
3208                 {
3209                   if (TREE_CODE ($1) != TYPE_DECL)
3210                     $$ = lastiddecl;
3211                   got_scope = complete_type (TREE_TYPE ($$));
3212                 }
3213         | template_type SCOPE
3214                 { got_scope = $$ = complete_type (TREE_TYPE ($$)); }
3215         | PTYPENAME SCOPE
3216         | IDENTIFIER SCOPE
3217         | NSNAME SCOPE
3218                 {
3219                   if (TREE_CODE ($$) == IDENTIFIER_NODE)
3220                     $$ = lastiddecl;
3221                   got_scope = $$;
3222                 }
3223         ;
3224
3225 explicit_template_type:
3226           identifier '<' template_arg_list_opt template_close_bracket
3227                 { $$ = build_min_nt (TEMPLATE_ID_EXPR, $1, $3); }
3228         ;
3229
3230 complex_type_name:
3231           global_scope type_name
3232                 {
3233                   if (TREE_CODE ($2) == IDENTIFIER_NODE)
3234                     $$ = IDENTIFIER_GLOBAL_VALUE ($2);
3235                   else
3236                     $$ = $2;
3237                   got_scope = NULL_TREE;
3238                 }
3239         | nested_type
3240         | global_scope nested_type
3241                 { $$ = $2; }
3242         ;
3243
3244 ptr_to_mem:
3245           nested_name_specifier '*'
3246                 { got_scope = NULL_TREE; }
3247         | global_scope nested_name_specifier '*'
3248                 { $$ = $2; got_scope = NULL_TREE; }
3249         ;
3250
3251 /* All uses of explicit global scope must go through this nonterminal so
3252    that got_scope will be set before yylex is called to get the next token.  */
3253 global_scope:
3254           SCOPE
3255                 { got_scope = void_type_node; }
3256         ;
3257
3258 /* ISO new-declarator (5.3.4) */
3259 new_declarator:
3260           '*' cv_qualifiers new_declarator
3261                 { $$ = make_pointer_declarator ($2, $3); }
3262         | '*' cv_qualifiers  %prec EMPTY
3263                 { $$ = make_pointer_declarator ($2, NULL_TREE); }
3264         | '&' cv_qualifiers new_declarator  %prec EMPTY
3265                 { $$ = make_reference_declarator ($2, $3); }
3266         | '&' cv_qualifiers  %prec EMPTY
3267                 { $$ = make_reference_declarator ($2, NULL_TREE); }
3268         | ptr_to_mem cv_qualifiers  %prec EMPTY
3269                 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3270                   $$ = build_nt (SCOPE_REF, $1, arg);
3271                 }
3272         | ptr_to_mem cv_qualifiers new_declarator
3273                 { tree arg = make_pointer_declarator ($2, $3);
3274                   $$ = build_nt (SCOPE_REF, $1, arg);
3275                 }
3276         | direct_new_declarator  %prec EMPTY
3277         ;
3278
3279 /* ISO direct-new-declarator (5.3.4) */
3280 direct_new_declarator:
3281           '[' expr ']'
3282                 { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
3283         | direct_new_declarator '[' expr ']'
3284                 { $$ = build_nt (ARRAY_REF, $$, $3); }
3285         ;
3286
3287 absdcl_intern:
3288           absdcl
3289         | attributes absdcl
3290                 {
3291                   /* Provide support for '(' attributes '*' declarator ')'
3292                      etc */
3293                   $$ = tree_cons ($1, $2, NULL_TREE);
3294                 }
3295         ;
3296
3297 /* ISO abstract-declarator (8.1) */
3298 absdcl:
3299           '*' nonempty_cv_qualifiers absdcl_intern
3300                 { $$ = make_pointer_declarator ($2.t, $3); }
3301         | '*' absdcl_intern
3302                 { $$ = make_pointer_declarator (NULL_TREE, $2); }
3303         | '*' nonempty_cv_qualifiers  %prec EMPTY
3304                 { $$ = make_pointer_declarator ($2.t, NULL_TREE); }
3305         | '*'  %prec EMPTY
3306                 { $$ = make_pointer_declarator (NULL_TREE, NULL_TREE); }
3307         | '&' nonempty_cv_qualifiers absdcl_intern
3308                 { $$ = make_reference_declarator ($2.t, $3); }
3309         | '&' absdcl_intern
3310                 { $$ = make_reference_declarator (NULL_TREE, $2); }
3311         | '&' nonempty_cv_qualifiers  %prec EMPTY
3312                 { $$ = make_reference_declarator ($2.t, NULL_TREE); }
3313         | '&'  %prec EMPTY
3314                 { $$ = make_reference_declarator (NULL_TREE, NULL_TREE); }
3315         | ptr_to_mem cv_qualifiers  %prec EMPTY
3316                 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3317                   $$ = build_nt (SCOPE_REF, $1, arg);
3318                 }
3319         | ptr_to_mem cv_qualifiers absdcl_intern
3320                 { tree arg = make_pointer_declarator ($2, $3);
3321                   $$ = build_nt (SCOPE_REF, $1, arg);
3322                 }
3323         | direct_abstract_declarator  %prec EMPTY
3324         ;
3325
3326 /* ISO direct-abstract-declarator (8.1) */
3327 direct_abstract_declarator:
3328           '(' absdcl_intern ')'
3329                 { $$ = $2; }
3330           /* `(typedef)1' is `int'.  */
3331         | direct_abstract_declarator '(' parmlist ')' cv_qualifiers exception_specification_opt  %prec '.'
3332                 { $$ = make_call_declarator ($$, $3, $5, $6); }
3333         | direct_abstract_declarator LEFT_RIGHT cv_qualifiers exception_specification_opt  %prec '.'
3334                 { $$ = make_call_declarator ($$, empty_parms (), $3, $4); }
3335         | direct_abstract_declarator '[' expr ']'  %prec '.'
3336                 { $$ = build_nt (ARRAY_REF, $$, $3); }
3337         | direct_abstract_declarator '[' ']'  %prec '.'
3338                 { $$ = build_nt (ARRAY_REF, $$, NULL_TREE); }
3339         | '(' complex_parmlist ')' cv_qualifiers exception_specification_opt  %prec '.'
3340                 { $$ = make_call_declarator (NULL_TREE, $2, $4, $5); }
3341         | regcast_or_absdcl cv_qualifiers exception_specification_opt  %prec '.'
3342                 { set_quals_and_spec ($$, $2, $3); }
3343         | fcast_or_absdcl cv_qualifiers exception_specification_opt  %prec '.'
3344                 { set_quals_and_spec ($$, $2, $3); }
3345         | '[' expr ']'  %prec '.'
3346                 { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
3347         | '[' ']'  %prec '.'
3348                 { $$ = build_nt (ARRAY_REF, NULL_TREE, NULL_TREE); }
3349         ;
3350
3351 /* For C++, decls and stmts can be intermixed, so we don't need to
3352    have a special rule that won't start parsing the stmt section
3353    until we have a stmt that parses without errors.  */
3354
3355 stmts:
3356           stmt
3357         | errstmt
3358         | stmts stmt
3359         | stmts errstmt
3360         ;
3361
3362 errstmt:
3363           error ';'
3364         ;
3365
3366 /* Read zero or more forward-declarations for labels
3367    that nested functions can jump to.  */
3368 maybe_label_decls:
3369           /* empty */
3370         | label_decls
3371                 { if (pedantic)
3372                     pedwarn ("ISO C++ forbids label declarations"); }
3373         ;
3374
3375 label_decls:
3376           label_decl
3377         | label_decls label_decl
3378         ;
3379
3380 label_decl:
3381           LABEL identifiers_or_typenames ';'
3382                 {
3383                   while ($2)
3384                     {
3385                       finish_label_decl (TREE_VALUE ($2));
3386                       $2 = TREE_CHAIN ($2);
3387                     }
3388                 }
3389         ;
3390
3391 compstmt_or_stmtexpr:
3392           save_lineno '{'
3393                 { $<ttype>$ = begin_compound_stmt (0); }
3394           compstmtend
3395                 { STMT_LINENO ($<ttype>3) = $1;
3396                   finish_compound_stmt (0, $<ttype>3); }
3397         ;
3398
3399 compstmt:
3400           compstmt_or_stmtexpr
3401                 { last_expr_type = NULL_TREE; }
3402         ;
3403
3404 simple_if:
3405           IF
3406                 { $<ttype>$ = begin_if_stmt ();
3407                   cond_stmt_keyword = "if"; }
3408             paren_cond_or_null
3409                 { finish_if_stmt_cond ($3, $<ttype>2); }
3410             implicitly_scoped_stmt
3411                 { $$ = $<ttype>2;
3412                   finish_then_clause ($<ttype>2); }
3413         ;
3414
3415 implicitly_scoped_stmt:
3416           compstmt
3417         |
3418                 { $<ttype>$ = begin_compound_stmt (0); }
3419           save_lineno simple_stmt
3420                 { STMT_LINENO ($<ttype>1) = $2;
3421                   if ($3) STMT_LINENO ($3) = $2;
3422                   finish_compound_stmt (0, $<ttype>1); }
3423         ;
3424
3425 stmt:
3426           compstmt
3427         | save_lineno simple_stmt
3428                 { if ($2) STMT_LINENO ($2) = $1; }
3429         ;
3430
3431 simple_stmt:
3432           decl
3433                 { finish_stmt ();
3434                   $$ = NULL_TREE; }
3435         | expr ';'
3436                 { $$ = finish_expr_stmt ($1); }
3437         | simple_if ELSE
3438                 { begin_else_clause (); }
3439           implicitly_scoped_stmt
3440                 {
3441                   $$ = $1;
3442                   finish_else_clause ($1);
3443                   finish_if_stmt ();
3444                 }
3445         | simple_if  %prec IF
3446                 { $$ = $1;
3447                   finish_if_stmt (); }
3448         | WHILE
3449                 {
3450                   $<ttype>$ = begin_while_stmt ();
3451                   cond_stmt_keyword = "while";
3452                 }
3453           paren_cond_or_null
3454                 { finish_while_stmt_cond ($3, $<ttype>2); }
3455           implicitly_scoped_stmt
3456                 { $$ = $<ttype>2;
3457                   finish_while_stmt ($<ttype>2); }
3458         | DO
3459                 { $<ttype>$ = begin_do_stmt (); }
3460           implicitly_scoped_stmt WHILE
3461                 {
3462                   finish_do_body ($<ttype>2);
3463                   cond_stmt_keyword = "do";
3464                 }
3465           paren_expr_or_null ';'
3466                 { $$ = $<ttype>2;
3467                   finish_do_stmt ($6, $<ttype>2); }
3468         | FOR
3469                 { $<ttype>$ = begin_for_stmt (); }
3470           '(' for.init.statement
3471                 { finish_for_init_stmt ($<ttype>2); }
3472           xcond ';'
3473                 { finish_for_cond ($6, $<ttype>2); }
3474           xexpr ')'
3475                 { finish_for_expr ($9, $<ttype>2); }
3476           implicitly_scoped_stmt
3477                 { $$ = $<ttype>2;
3478                   finish_for_stmt ($<ttype>2); }
3479         | SWITCH
3480                 { $<ttype>$ = begin_switch_stmt (); }
3481             '(' condition ')'
3482                 { finish_switch_cond ($4, $<ttype>2); }
3483           implicitly_scoped_stmt
3484                 { $$ = $<ttype>2;
3485                   finish_switch_stmt ($<ttype>2); }
3486         | CASE expr_no_commas ':'
3487                 { $<ttype>$ = finish_case_label ($2, NULL_TREE); }
3488           stmt
3489                 { $$ = $<ttype>4; }
3490         | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
3491                 { $<ttype>$ = finish_case_label ($2, $4); }
3492           stmt
3493                 { $$ = $<ttype>6; }
3494         | DEFAULT ':'
3495                 { $<ttype>$ = finish_case_label (NULL_TREE, NULL_TREE); }
3496           stmt
3497                 { $$ = $<ttype>3; }
3498         | BREAK ';'
3499                 { $$ = finish_break_stmt (); }
3500         | CONTINUE ';'
3501                 { $$ = finish_continue_stmt (); }
3502         | RETURN_KEYWORD ';'
3503                 { $$ = finish_return_stmt (NULL_TREE); }
3504         | RETURN_KEYWORD expr ';'
3505                 { $$ = finish_return_stmt ($2); }
3506         | asm_keyword maybe_cv_qualifier '(' STRING ')' ';'
3507                 { $$ = finish_asm_stmt ($2, $4, NULL_TREE, NULL_TREE,
3508                                         NULL_TREE);
3509                   ASM_INPUT_P ($$) = 1; }
3510         /* This is the case with just output operands.  */
3511         | asm_keyword maybe_cv_qualifier '(' STRING ':' asm_operands ')' ';'
3512                 { $$ = finish_asm_stmt ($2, $4, $6, NULL_TREE, NULL_TREE); }
3513         /* This is the case with input operands as well.  */
3514         | asm_keyword maybe_cv_qualifier '(' STRING ':' asm_operands ':'
3515           asm_operands ')' ';'
3516                 { $$ = finish_asm_stmt ($2, $4, $6, $8, NULL_TREE); }
3517         | asm_keyword maybe_cv_qualifier '(' STRING SCOPE asm_operands ')' ';'
3518                 { $$ = finish_asm_stmt ($2, $4, NULL_TREE, $6, NULL_TREE); }
3519         /* This is the case with clobbered registers as well.  */
3520         | asm_keyword maybe_cv_qualifier '(' STRING ':' asm_operands ':'
3521           asm_operands ':' asm_clobbers ')' ';'
3522                 { $$ = finish_asm_stmt ($2, $4, $6, $8, $10); }
3523         | asm_keyword maybe_cv_qualifier '(' STRING SCOPE asm_operands ':'
3524           asm_clobbers ')' ';'
3525                 { $$ = finish_asm_stmt ($2, $4, NULL_TREE, $6, $8); }
3526         | asm_keyword maybe_cv_qualifier '(' STRING ':' asm_operands SCOPE
3527           asm_clobbers ')' ';'
3528                 { $$ = finish_asm_stmt ($2, $4, $6, NULL_TREE, $8); }
3529         | GOTO '*' expr ';'
3530                 {
3531                   if (pedantic)
3532                     pedwarn ("ISO C++ forbids computed gotos");
3533                   $$ = finish_goto_stmt ($3);
3534                 }
3535         | GOTO identifier ';'
3536                 { $$ = finish_goto_stmt ($2); }
3537         | label_colon stmt
3538                 { $$ = NULL_TREE; }
3539         | label_colon '}'
3540                 { error ("label must be followed by statement");
3541                   yyungetc ('}', 0);
3542                   $$ = NULL_TREE; }
3543         | ';'
3544                 { finish_stmt ();
3545                   $$ = NULL_TREE; }
3546         | try_block
3547                 { $$ = NULL_TREE; }
3548         | using_directive
3549                 { $$ = NULL_TREE; }
3550         | namespace_using_decl
3551                 { do_local_using_decl ($1);
3552                   $$ = NULL_TREE; }
3553         | namespace_alias
3554                 { $$ = NULL_TREE; }
3555         ;
3556
3557 function_try_block:
3558           TRY
3559                 { $<ttype>$ = begin_function_try_block (); }
3560           function_body
3561                 { finish_function_try_block ($<ttype>2); }
3562           handler_seq
3563                 { finish_function_handler_sequence ($<ttype>2); }
3564         ;
3565
3566 try_block:
3567           TRY
3568                 { $<ttype>$ = begin_try_block (); }
3569           compstmt
3570                 { finish_try_block ($<ttype>2); }
3571           handler_seq
3572                 { finish_handler_sequence ($<ttype>2); }
3573         ;
3574
3575 handler_seq:
3576           handler
3577         | handler_seq handler
3578         | /* empty */
3579                 { /* Generate a fake handler block to avoid later aborts. */
3580                   tree fake_handler = begin_handler ();
3581                   finish_handler_parms (NULL_TREE, fake_handler);
3582                   finish_handler (fake_handler);
3583                   $<ttype>$ = fake_handler;
3584
3585                   error ("must have at least one catch per try block");
3586                 }
3587         ;
3588
3589 handler:
3590           CATCH
3591                 { $<ttype>$ = begin_handler (); }
3592           handler_args
3593                 { finish_handler_parms ($3, $<ttype>2); }
3594           compstmt
3595                 { finish_handler ($<ttype>2); }
3596         ;
3597
3598 type_specifier_seq:
3599           typed_typespecs  %prec EMPTY
3600         | nonempty_cv_qualifiers  %prec EMPTY
3601         ;
3602
3603 handler_args:
3604           '(' ELLIPSIS ')'
3605                 { $$ = NULL_TREE; }
3606         /* This doesn't allow reference parameters, the below does.
3607         | '(' type_specifier_seq absdcl ')'
3608                 { check_for_new_type ("inside exception declarations", $2);
3609                   expand_start_catch_block ($2.t, $3); }
3610         | '(' type_specifier_seq ')'
3611                 { check_for_new_type ("inside exception declarations", $2);
3612                   expand_start_catch_block ($2.t, NULL_TREE); }
3613         | '(' type_specifier_seq notype_declarator ')'
3614                 { check_for_new_type ("inside exception declarations", $2);
3615                   expand_start_catch_block ($2.t, $3); }
3616         | '(' typed_typespecs after_type_declarator ')'
3617                 { check_for_new_type ("inside exception declarations", $2);
3618                   expand_start_catch_block ($2.t, $3); }
3619         This allows reference parameters...  */
3620         | '(' parm ')'
3621                 {
3622                   check_for_new_type ("inside exception declarations", $2);
3623                   $$ = start_handler_parms (TREE_PURPOSE ($2.t),
3624                                             TREE_VALUE ($2.t));
3625                 }
3626         ;
3627
3628 label_colon:
3629           IDENTIFIER ':'
3630                 { finish_label_stmt ($1); }
3631         | PTYPENAME ':'
3632                 { finish_label_stmt ($1); }
3633         | tTYPENAME ':'
3634                 { finish_label_stmt ($1); }
3635         | SELFNAME ':'
3636                 { finish_label_stmt ($1); }
3637         ;
3638
3639 for.init.statement:
3640           xexpr ';'
3641                 { finish_expr_stmt ($1); }
3642         | decl
3643         | '{' compstmtend
3644                 { if (pedantic)
3645                     pedwarn ("ISO C++ forbids compound statements inside for initializations");
3646                 }
3647         ;
3648
3649 /* Either a type-qualifier or nothing.  First thing in an `asm' statement.  */
3650
3651 maybe_cv_qualifier:
3652           /* empty */
3653                 { $$ = NULL_TREE; }
3654         | CV_QUALIFIER
3655         ;
3656
3657 xexpr:
3658           /* empty */
3659                 { $$ = NULL_TREE; }
3660         | expr
3661         | error
3662                 { $$ = NULL_TREE; }
3663         ;
3664
3665 /* These are the operands other than the first string and colon
3666    in  asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x))  */
3667 asm_operands:
3668           /* empty */
3669                 { $$ = NULL_TREE; }
3670         | nonnull_asm_operands
3671         ;
3672
3673 nonnull_asm_operands:
3674           asm_operand
3675         | nonnull_asm_operands ',' asm_operand
3676                 { $$ = chainon ($$, $3); }
3677         ;
3678
3679 asm_operand:
3680           STRING '(' expr ')'
3681                 { $$ = build_tree_list (build_tree_list (NULL_TREE, $1), $3); }
3682         | '[' identifier ']' STRING '(' expr ')'
3683                 { $2 = build_string (IDENTIFIER_LENGTH ($2),
3684                                      IDENTIFIER_POINTER ($2));
3685                   $$ = build_tree_list (build_tree_list ($2, $4), $6); }
3686         ;
3687
3688 asm_clobbers:
3689           STRING
3690                 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);}
3691         | asm_clobbers ',' STRING
3692                 { $$ = tree_cons (NULL_TREE, $3, $1); }
3693         ;
3694
3695 /* This is what appears inside the parens in a function declarator.
3696    Its value is represented in the format that grokdeclarator expects.
3697
3698    In C++, declaring a function with no parameters
3699    means that that function takes *no* parameters.  */
3700
3701 parmlist:
3702           /* empty */
3703                 {
3704                   $$ = empty_parms();
3705                 }
3706         | complex_parmlist
3707         | type_id
3708                 { $$ = finish_parmlist (build_tree_list (NULL_TREE, $1.t), 0);
3709                   check_for_new_type ("inside parameter list", $1); }
3710         ;
3711
3712 /* This nonterminal does not include the common sequence '(' type_id ')',
3713    as it is ambiguous and must be disambiguated elsewhere.  */
3714 complex_parmlist:
3715           parms
3716                 { $$ = finish_parmlist ($$, 0); }
3717         | parms_comma ELLIPSIS
3718                 { $$ = finish_parmlist ($1, 1); }
3719         /* C++ allows an ellipsis without a separating ',' */
3720         | parms ELLIPSIS
3721                 { $$ = finish_parmlist ($1, 1); }
3722         | type_id ELLIPSIS
3723                 { $$ = finish_parmlist (build_tree_list (NULL_TREE,
3724                                                          $1.t), 1); }
3725         | ELLIPSIS
3726                 { $$ = finish_parmlist (NULL_TREE, 1); }
3727         | parms ':'
3728                 {
3729                   /* This helps us recover from really nasty
3730                      parse errors, for example, a missing right
3731                      parenthesis.  */
3732                   yyerror ("possibly missing ')'");
3733                   $$ = finish_parmlist ($1, 0);
3734                   yyungetc (':', 0);
3735                   yychar = ')';
3736                 }
3737         | type_id ':'
3738                 {
3739                   /* This helps us recover from really nasty
3740                      parse errors, for example, a missing right
3741                      parenthesis.  */
3742                   yyerror ("possibly missing ')'");
3743                   $$ = finish_parmlist (build_tree_list (NULL_TREE,
3744                                                          $1.t), 0);
3745                   yyungetc (':', 0);
3746                   yychar = ')';
3747                 }
3748         ;
3749
3750 /* A default argument to a */
3751 defarg:
3752           '='
3753                 { maybe_snarf_defarg (); }
3754           defarg1
3755                 { $$ = $3; }
3756         ;
3757
3758 defarg1:
3759           DEFARG
3760         | init
3761         ;
3762
3763 /* A nonempty list of parameter declarations or type names.  */
3764 parms:
3765           named_parm
3766                 { check_for_new_type ("in a parameter list", $1);
3767                   $$ = build_tree_list (NULL_TREE, $1.t); }
3768         | parm defarg
3769                 { check_for_new_type ("in a parameter list", $1);
3770                   $$ = build_tree_list ($2, $1.t); }
3771         | parms_comma full_parm
3772                 { check_for_new_type ("in a parameter list", $2);
3773                   $$ = chainon ($$, $2.t); }
3774         | parms_comma bad_parm
3775                 { $$ = chainon ($$, build_tree_list (NULL_TREE, $2)); }
3776         | parms_comma bad_parm '=' init
3777                 { $$ = chainon ($$, build_tree_list ($4, $2)); }
3778         ;
3779
3780 parms_comma:
3781           parms ','
3782         | type_id ','
3783                 { check_for_new_type ("in a parameter list", $1);
3784                   $$ = build_tree_list (NULL_TREE, $1.t); }
3785         ;
3786
3787 /* A single parameter declaration or parameter type name,
3788    as found in a parmlist.  */
3789 named_parm:
3790         /* Here we expand typed_declspecs inline to avoid mis-parsing of
3791            TYPESPEC IDENTIFIER.  */
3792           typed_declspecs1 declarator
3793                 { $$.new_type_flag = $1.new_type_flag;
3794                   $$.t = build_tree_list ($1.t, $2); }
3795         | typed_typespecs declarator
3796                 { $$.t = build_tree_list ($1.t, $2);
3797                   $$.new_type_flag = $1.new_type_flag; }
3798         | typespec declarator
3799                 { $$.t = build_tree_list (build_tree_list (NULL_TREE, $1.t),
3800                                           $2);
3801                   $$.new_type_flag = $1.new_type_flag; }
3802         | typed_declspecs1 absdcl
3803                 { $$.t = build_tree_list ($1.t, $2);
3804                   $$.new_type_flag = $1.new_type_flag; }
3805         | typed_declspecs1  %prec EMPTY
3806                 { $$.t = build_tree_list ($1.t, NULL_TREE);
3807                   $$.new_type_flag = $1.new_type_flag; }
3808         | declmods notype_declarator
3809                 { $$.t = build_tree_list ($1.t, $2);
3810                   $$.new_type_flag = 0; }
3811         ;
3812
3813 full_parm:
3814           parm
3815                 { $$.t = build_tree_list (NULL_TREE, $1.t);
3816                   $$.new_type_flag = $1.new_type_flag;  }
3817         | parm defarg
3818                 { $$.t = build_tree_list ($2, $1.t);
3819                   $$.new_type_flag = $1.new_type_flag;  }
3820         ;
3821
3822 parm:
3823           named_parm
3824         | type_id
3825         ;
3826
3827 see_typename:
3828           /* empty */  %prec EMPTY
3829                 { see_typename (); }
3830         ;
3831
3832 bad_parm:
3833           /* empty */ %prec EMPTY
3834                 {
3835                   error ("type specifier omitted for parameter");
3836                   $$ = build_tree_list (integer_type_node, NULL_TREE);
3837                 }
3838         | notype_declarator
3839                 {
3840                   if (TREE_CODE ($$) == SCOPE_REF)
3841                     {
3842                       if (TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TYPE_PARM
3843                           || TREE_CODE (TREE_OPERAND ($$, 0)) == BOUND_TEMPLATE_TEMPLATE_PARM)
3844                         error ("`%E' is not a type, use `typename %E' to make it one", $$);
3845                       else
3846                         error ("no type `%D' in `%T'", TREE_OPERAND ($$, 1), TREE_OPERAND ($$, 0));
3847                     }
3848                   else
3849                     error ("type specifier omitted for parameter `%E'", $$);
3850                   $$ = build_tree_list (integer_type_node, $$);
3851                 }
3852         ;
3853
3854 bad_decl:
3855           IDENTIFIER template_arg_list_ignore IDENTIFIER arg_list_ignore ';'
3856                 {
3857                   error("'%D' is used as a type, but is not defined as a type.", $1);
3858                   $3 = error_mark_node;
3859                 }
3860         ;
3861
3862 template_arg_list_ignore:
3863           '<' template_arg_list_opt template_close_bracket
3864                 { }
3865         | /* empty */
3866         ;
3867
3868 arg_list_ignore:
3869           '(' nonnull_exprlist ')'
3870                 { }
3871         | /* empty */
3872         ;
3873
3874 exception_specification_opt:
3875           /* empty */  %prec EMPTY
3876                 { $$ = NULL_TREE; }
3877         | THROW '(' ansi_raise_identifiers  ')'  %prec EMPTY
3878                 { $$ = $3; }
3879         | THROW LEFT_RIGHT  %prec EMPTY
3880                 { $$ = empty_except_spec; }
3881         ;
3882
3883 ansi_raise_identifier:
3884           type_id
3885                 {
3886                   check_for_new_type ("exception specifier", $1);
3887                   $$ = groktypename ($1.t);
3888                 }
3889           | error
3890                 { $$ = error_mark_node; }
3891         ;
3892
3893 ansi_raise_identifiers:
3894           ansi_raise_identifier
3895                 { $$ = add_exception_specifier (NULL_TREE, $1, 1); }
3896         | ansi_raise_identifiers ',' ansi_raise_identifier
3897                 { $$ = add_exception_specifier ($1, $3, 1); }
3898         ;
3899
3900 conversion_declarator:
3901           /* empty */  %prec EMPTY
3902                 { $$ = NULL_TREE; }
3903         | '*' cv_qualifiers conversion_declarator
3904                 { $$ = make_pointer_declarator ($2, $3); }
3905         | '&' cv_qualifiers conversion_declarator
3906                 { $$ = make_reference_declarator ($2, $3); }
3907         | ptr_to_mem cv_qualifiers conversion_declarator
3908                 { tree arg = make_pointer_declarator ($2, $3);
3909                   $$ = build_nt (SCOPE_REF, $1, arg);
3910                 }
3911         ;
3912
3913 operator:
3914         OPERATOR
3915         {
3916           saved_scopes = tree_cons (got_scope, got_object, saved_scopes);
3917           TREE_LANG_FLAG_0 (saved_scopes) = looking_for_typename;
3918           /* We look for conversion-type-id's in both the class and current
3919              scopes, just as for ID in 'ptr->ID::'.  */
3920           looking_for_typename = 1;
3921           got_object = got_scope;
3922           got_scope = NULL_TREE;
3923         }
3924         ;
3925
3926 unoperator:
3927         { got_scope = TREE_PURPOSE (saved_scopes);
3928           got_object = TREE_VALUE (saved_scopes);
3929           looking_for_typename = TREE_LANG_FLAG_0 (saved_scopes);
3930           saved_scopes = TREE_CHAIN (saved_scopes);
3931         }
3932         ;
3933
3934 operator_name:
3935           operator '*' unoperator
3936                 { $$ = frob_opname (ansi_opname (MULT_EXPR)); }
3937         | operator '/' unoperator
3938                 { $$ = frob_opname (ansi_opname (TRUNC_DIV_EXPR)); }
3939         | operator '%' unoperator
3940                 { $$ = frob_opname (ansi_opname (TRUNC_MOD_EXPR)); }
3941         | operator '+' unoperator
3942                 { $$ = frob_opname (ansi_opname (PLUS_EXPR)); }
3943         | operator '-' unoperator
3944                 { $$ = frob_opname (ansi_opname (MINUS_EXPR)); }
3945         | operator '&' unoperator
3946                 { $$ = frob_opname (ansi_opname (BIT_AND_EXPR)); }
3947         | operator '|' unoperator
3948                 { $$ = frob_opname (ansi_opname (BIT_IOR_EXPR)); }
3949         | operator '^' unoperator
3950                 { $$ = frob_opname (ansi_opname (BIT_XOR_EXPR)); }
3951         | operator '~' unoperator
3952                 { $$ = frob_opname (ansi_opname (BIT_NOT_EXPR)); }
3953         | operator ',' unoperator
3954                 { $$ = frob_opname (ansi_opname (COMPOUND_EXPR)); }
3955         | operator ARITHCOMPARE unoperator
3956                 { $$ = frob_opname (ansi_opname ($2)); }
3957         | operator '<' unoperator
3958                 { $$ = frob_opname (ansi_opname (LT_EXPR)); }
3959         | operator '>' unoperator
3960                 { $$ = frob_opname (ansi_opname (GT_EXPR)); }
3961         | operator EQCOMPARE unoperator
3962                 { $$ = frob_opname (ansi_opname ($2)); }
3963         | operator ASSIGN unoperator
3964                 { $$ = frob_opname (ansi_assopname ($2)); }
3965         | operator '=' unoperator
3966                 { $$ = frob_opname (ansi_assopname (NOP_EXPR)); }
3967         | operator LSHIFT unoperator
3968                 { $$ = frob_opname (ansi_opname ($2)); }
3969         | operator RSHIFT unoperator
3970                 { $$ = frob_opname (ansi_opname ($2)); }
3971         | operator PLUSPLUS unoperator
3972                 { $$ = frob_opname (ansi_opname (POSTINCREMENT_EXPR)); }
3973         | operator MINUSMINUS unoperator
3974                 { $$ = frob_opname (ansi_opname (PREDECREMENT_EXPR)); }
3975         | operator ANDAND unoperator
3976                 { $$ = frob_opname (ansi_opname (TRUTH_ANDIF_EXPR)); }
3977         | operator OROR unoperator
3978                 { $$ = frob_opname (ansi_opname (TRUTH_ORIF_EXPR)); }
3979         | operator '!' unoperator
3980                 { $$ = frob_opname (ansi_opname (TRUTH_NOT_EXPR)); }
3981         | operator '?' ':' unoperator
3982                 { $$ = frob_opname (ansi_opname (COND_EXPR)); }
3983         | operator MIN_MAX unoperator
3984                 { $$ = frob_opname (ansi_opname ($2)); }
3985         | operator POINTSAT  unoperator %prec EMPTY
3986                 { $$ = frob_opname (ansi_opname (COMPONENT_REF)); }
3987         | operator POINTSAT_STAR  unoperator %prec EMPTY
3988                 { $$ = frob_opname (ansi_opname (MEMBER_REF)); }
3989         | operator LEFT_RIGHT unoperator
3990                 { $$ = frob_opname (ansi_opname (CALL_EXPR)); }
3991         | operator '[' ']' unoperator
3992                 { $$ = frob_opname (ansi_opname (ARRAY_REF)); }
3993         | operator NEW  unoperator %prec EMPTY
3994                 { $$ = frob_opname (ansi_opname (NEW_EXPR)); }
3995         | operator DELETE  unoperator %prec EMPTY
3996                 { $$ = frob_opname (ansi_opname (DELETE_EXPR)); }
3997         | operator NEW '[' ']' unoperator
3998                 { $$ = frob_opname (ansi_opname (VEC_NEW_EXPR)); }
3999         | operator DELETE '[' ']' unoperator
4000                 { $$ = frob_opname (ansi_opname (VEC_DELETE_EXPR)); }
4001         | operator type_specifier_seq conversion_declarator unoperator
4002                 { $$ = frob_opname (grokoptypename ($2.t, $3)); }
4003         | operator error unoperator
4004                 { $$ = frob_opname (ansi_opname (ERROR_MARK)); }
4005         ;
4006
4007 /* The forced readahead in here is because we might be at the end of a
4008    line, and lineno won't be bumped until yylex absorbs the first token
4009    on the next line.  */
4010 save_lineno:
4011                 { if (yychar == YYEMPTY)
4012                     yychar = YYLEX;
4013                   $$ = lineno; }
4014         ;
4015 %%
4016
4017 #ifdef SPEW_DEBUG
4018 const char *
4019 debug_yytranslate (value)
4020     int value;
4021 {
4022   return yytname[YYTRANSLATE (value)];
4023 }
4024 #endif
4025
4026 /* Free malloced parser stacks if necessary.  */
4027
4028 void
4029 free_parser_stacks ()
4030 {
4031   if (malloced_yyss)
4032     {
4033       free (malloced_yyss);
4034       free (malloced_yyvs);
4035     }
4036 }
4037
4038 /* Return the value corresponding to TOKEN in the global scope.  */
4039
4040 static tree
4041 parse_scoped_id (token)
4042      tree token;
4043 {
4044   tree id;
4045
4046   id = make_node (CPLUS_BINDING);
4047   if (!qualified_lookup_using_namespace (token, global_namespace, id, 0))
4048     id = NULL_TREE;
4049   else
4050     id = BINDING_VALUE (id);
4051   if (yychar == YYEMPTY)
4052     yychar = yylex();
4053
4054   return do_scoped_id (token, id);
4055 }
4056
4057 /* AGGR may be either a type node (like class_type_node) or a
4058    TREE_LIST whose TREE_PURPOSE is a list of attributes and whose
4059    TREE_VALUE is a type node.  Set *TAG_KIND and *ATTRIBUTES to
4060    represent the information encoded.  */
4061
4062 static void
4063 parse_split_aggr (tree aggr, enum tag_types *tag_kind, tree *attributes)
4064 {
4065   if (TREE_CODE (aggr) == TREE_LIST) 
4066     {
4067       *attributes = TREE_PURPOSE (aggr);
4068       aggr = TREE_VALUE (aggr);
4069     }
4070   else
4071     *attributes = NULL_TREE;
4072   *tag_kind = (enum tag_types) tree_low_cst (aggr, 1);
4073 }
4074
4075 /* Like xref_tag, except that the AGGR may be either a type node (like
4076    class_type_node) or a TREE_LIST whose TREE_PURPOSE is a list of
4077    attributes and whose TREE_VALUE is a type node.  */
4078
4079 static tree
4080 parse_xref_tag (tree aggr, tree name, int globalize)
4081 {
4082   tree attributes;
4083   enum tag_types tag_kind;
4084   parse_split_aggr (aggr, &tag_kind, &attributes);
4085   return xref_tag (tag_kind, name, attributes, globalize);
4086 }
4087
4088 /* Like handle_class_head, but AGGR may be as for parse_xref_tag.  */
4089
4090 static tree
4091 parse_handle_class_head (tree aggr, tree scope, tree id, 
4092                          int defn_p, int *new_type_p)
4093 {
4094   tree attributes;
4095   enum tag_types tag_kind;
4096   parse_split_aggr (aggr, &tag_kind, &attributes);
4097   return handle_class_head (tag_kind, scope, id, attributes, 
4098                             defn_p, new_type_p);
4099 }
4100
4101 /* Like do_decl_instantiation, but the declarator has not yet been
4102    parsed.  */
4103
4104 static void
4105 parse_decl_instantiation (tree declspecs, tree declarator, tree storage)
4106 {
4107   tree decl = grokdeclarator (declarator, declspecs, NORMAL, 0, NULL);
4108   do_decl_instantiation (decl, storage);
4109 }
4110
4111 /* Like begin_function_definition, but SPECS_ATTRS is a combined list
4112    containing both a decl-specifier-seq and attributes.  */
4113
4114 static int
4115 parse_begin_function_definition (tree specs_attrs, tree declarator)
4116 {
4117   tree specs;
4118   tree attrs;
4119   
4120   split_specs_attrs (specs_attrs, &specs, &attrs);
4121   return begin_function_definition (specs, attrs, declarator);
4122 }
4123
4124 /* Like finish_call_expr, but the name for FN has not yet been
4125    resolved.  */
4126
4127 static tree
4128 parse_finish_call_expr (tree fn, tree args, int koenig)
4129 {
4130   bool disallow_virtual;
4131   tree template_args;
4132   tree template_id;
4133   tree f;
4134
4135   if (TREE_CODE (fn) == OFFSET_REF)
4136     return build_offset_ref_call_from_tree (fn, args);
4137
4138   if (TREE_CODE (fn) == SCOPE_REF)
4139     {
4140       tree scope;
4141       tree name;
4142
4143       scope = TREE_OPERAND (fn, 0);
4144       name = TREE_OPERAND (fn, 1);
4145
4146       if (scope == error_mark_node || name == error_mark_node)
4147         return error_mark_node;
4148       if (!processing_template_decl)
4149         {
4150           if (TREE_CODE (scope) == NAMESPACE_DECL)
4151             fn = lookup_namespace_name (scope, name);
4152           else
4153             {
4154               if (!COMPLETE_TYPE_P (scope) && !TYPE_BEING_DEFINED (scope))
4155                 {
4156                   error ("incomplete type '%T' cannot be used to name a scope",
4157                          scope);
4158                   return error_mark_node;
4159                 }
4160               else if (TREE_CODE (name) == TEMPLATE_ID_EXPR)
4161                 {
4162                   template_id = name;
4163                   template_args = TREE_OPERAND (name, 1);
4164                   name = TREE_OPERAND (name, 0);
4165                 }
4166               else 
4167                 {
4168                   template_id = NULL_TREE;
4169                   template_args = NULL_TREE;
4170                 }
4171
4172               if (BASELINK_P (name))
4173                 fn = name;
4174               else 
4175                 {
4176                   if (TREE_CODE (name) == OVERLOAD)
4177                     name = DECL_NAME (get_first_fn (name));
4178                   fn = lookup_member (scope, name, /*protect=*/1, 
4179                                       /*prefer_type=*/0);
4180                   if (BASELINK_P (fn) && template_id)
4181                     BASELINK_FUNCTIONS (fn) 
4182                       = build_nt (TEMPLATE_ID_EXPR,
4183                                   BASELINK_FUNCTIONS (fn),
4184                                   template_args);
4185                 }
4186               if (current_class_type)
4187                 fn = (adjust_result_of_qualified_name_lookup 
4188                       (fn, scope, current_class_type));
4189             }
4190         }
4191       disallow_virtual = true;
4192     }
4193   else
4194     disallow_virtual = false;
4195
4196   if (koenig && TREE_CODE (fn) == IDENTIFIER_NODE)
4197     {
4198       /* Do the Koenig lookup.  */
4199       fn = do_identifier (fn, 2, args);
4200       /* If name lookup didn't find any matching declarations, we've
4201          got an unbound identifier.  */
4202       if (TREE_CODE (fn) == IDENTIFIER_NODE)
4203         {
4204           /* For some reason, do_identifier does not resolve
4205              conversion operator names if the only matches would be
4206              template conversion operators.  So, we do it here.  */
4207           if (IDENTIFIER_TYPENAME_P (fn) && current_class_type)
4208             {
4209               f = lookup_member (current_class_type, fn,
4210                                  /*protect=*/1, /*want_type=*/0);
4211               if (f)
4212                 return finish_call_expr (f, args,
4213                                          /*disallow_virtual=*/false);
4214             }
4215           /* If the name still could not be resolved, then the program
4216              is ill-formed.  */
4217           if (TREE_CODE (fn) == IDENTIFIER_NODE)
4218             {
4219               unqualified_name_lookup_error (fn);
4220               return error_mark_node;
4221             }
4222         }
4223       else if (TREE_CODE (fn) == FUNCTION_DECL
4224                || DECL_FUNCTION_TEMPLATE_P (fn)
4225                || TREE_CODE (fn) == OVERLOAD)
4226         {
4227           tree scope = DECL_CONTEXT (get_first_fn (fn));
4228           if (scope && TYPE_P (scope))
4229             {
4230               tree access_scope;
4231
4232               if (DERIVED_FROM_P (scope, current_class_type)
4233                   && current_class_ref)
4234                 {
4235                   fn = build_baselink (lookup_base (current_class_type,
4236                                                     scope,
4237                                                     ba_any,
4238                                                     NULL),
4239                                        TYPE_BINFO (current_class_type),
4240                                        fn,
4241                                        /*optype=*/NULL_TREE);
4242                   return finish_object_call_expr (fn,
4243                                                   current_class_ref,
4244                                                   args);
4245                 }
4246
4247
4248               access_scope = current_class_type;
4249               while (!DERIVED_FROM_P (scope, access_scope))
4250                 {
4251                   access_scope = TYPE_CONTEXT (access_scope);
4252                   while (DECL_P (access_scope))
4253                     access_scope = DECL_CONTEXT (access_scope);
4254                 }
4255               
4256               fn = build_baselink (NULL_TREE,
4257                                    TYPE_BINFO (access_scope),
4258                                    fn,
4259                                    /*optype=*/NULL_TREE);
4260             }
4261         }
4262     }
4263
4264   if (TREE_CODE (fn) == COMPONENT_REF)
4265     /* If the parser sees `(x->y)(bar)' we get here because the
4266        parentheses confuse the parser.  Treat this like 
4267        `x->y(bar)'.  */
4268     return finish_object_call_expr (TREE_OPERAND (fn, 1),
4269                                     TREE_OPERAND (fn, 0),
4270                                     args);
4271
4272   if (processing_template_decl)
4273     return build_nt (CALL_EXPR, fn, args, NULL_TREE);
4274
4275   return build_call_from_tree (fn, args, disallow_virtual);
4276 }
4277
4278 #include "gt-cp-parse.h"