OSDN Git Service

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