OSDN Git Service

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