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