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