OSDN Git Service

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