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