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