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