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