OSDN Git Service

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