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