1 /* YACC parser for C++ syntax.
2 Copyright (C) 1988, 89, 93, 94, 95, 1996 Free Software Foundation, Inc.
3 Hacked by Michael Tiemann (tiemann@cygnus.com)
5 This file is part of GNU CC.
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)
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.
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. */
23 /* This grammar is based on the GNU CC grammar. */
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. */
30 /* Cause the `yydebug' variable to be defined. */
46 /* Since parsers are distinct for each language, put the language string
47 definition here. (fnf) */
48 char *language_string = "GNU C++";
50 extern tree void_list_node;
51 extern struct obstack permanent_obstack;
53 extern int end_of_file;
55 /* Like YYERROR but do call yyerror. */
56 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
58 #define OP0(NODE) (TREE_OPERAND (NODE, 0))
59 #define OP1(NODE) (TREE_OPERAND (NODE, 1))
61 /* Contains the statement keyword (if/while/do) to include in an
62 error message if the user supplies an empty conditional expression. */
63 static char *cond_stmt_keyword;
65 static tree empty_parms PROTO((void));
67 /* Nonzero if we have an `extern "C"' acting as an extern specifier. */
71 /* Cons up an empty parameter list. */
81 || current_class_type != NULL)
82 parms = void_list_node;
92 %union {long itype; tree ttype; char *strtype; enum tree_code code; flagged_type_tree ftype; }
94 /* All identifiers that are not reserved words
95 and are not declared typedefs in the current block */
98 /* All identifiers that are declared typedefs in the current block.
99 In some contexts, they are treated just like IDENTIFIER,
100 but they can also serve as typespecs in declarations. */
104 /* A template function. */
107 /* Reserved words that specify storage class.
108 yylval contains an IDENTIFIER_NODE which indicates which one. */
111 /* Reserved words that specify type.
112 yylval contains an IDENTIFIER_NODE which indicates which one. */
115 /* Reserved words that qualify type: "const" or "volatile".
116 yylval contains an IDENTIFIER_NODE which indicates which one. */
119 /* Character or numeric constants.
120 yylval is the node for the constant. */
123 /* String constants in raw form.
124 yylval is a STRING_CST node. */
127 /* "...", used for functions with variable arglists. */
130 /* the reserved words */
131 /* SCO include files test "ASM", so use something else. */
132 %token SIZEOF ENUM /* STRUCT UNION */ IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
133 %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD TYPEOF ALIGNOF
135 %token ATTRIBUTE EXTENSION LABEL
136 %token REALPART IMAGPART
138 /* the reserved words... C++ extensions */
140 %token <ttype> VISSPEC
141 %token DELETE NEW THIS OPERATOR CXX_TRUE CXX_FALSE
142 %token NAMESPACE TYPENAME_KEYWORD USING
143 %token LEFT_RIGHT TEMPLATE
144 %token TYPEID DYNAMIC_CAST STATIC_CAST REINTERPRET_CAST CONST_CAST
147 /* Define the operator tokens and their precedences.
148 The value is an integer because, if used, it is the tree code
149 to use in the expression made from the operator. */
151 %left EMPTY /* used to resolve s/r with epsilon */
155 /* Add precedence rules to solve dangling else s/r conflict */
159 %left IDENTIFIER PFUNCNAME TYPENAME SELFNAME PTYPENAME SCSPEC TYPESPEC CV_QUALIFIER ENUM AGGR ELLIPSIS TYPEOF SIGOF OPERATOR NSNAME TYPENAME_KEYWORD
165 %right <code> ASSIGN '='
173 %left <code> EQCOMPARE
174 %left <code> ARITHCOMPARE '<' '>'
175 %left <code> LSHIFT RSHIFT
177 %left <code> '*' '/' '%'
178 %left <code> POINTSAT_STAR DOT_STAR
179 %right <code> UNARY PLUSPLUS MINUSMINUS '~'
181 %left <ttype> PAREN_STAR_PAREN LEFT_RIGHT
182 %left <code> POINTSAT '.' '(' '['
184 %right SCOPE /* C++ extension */
185 %nonassoc NEW DELETE TRY CATCH
189 %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist
190 %type <ttype> PFUNCNAME maybe_identifier
191 %type <ttype> paren_expr_or_null nontrivial_exprlist SELFNAME
192 %type <ttype> expr_no_commas cast_expr unary_expr primary string STRING
193 %type <ttype> reserved_declspecs boolean.literal
194 %type <ttype> reserved_typespecquals
195 %type <ttype> declmods
196 %type <ttype> SCSPEC TYPESPEC CV_QUALIFIER maybe_cv_qualifier
197 %type <itype> initdecls notype_initdecls initdcl /* C++ modification */
198 %type <ttype> init initlist maybeasm maybe_init defarg defarg1
199 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
200 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
201 %type <ttype> any_word
203 %type <ttype> compstmt implicitly_scoped_stmt
205 %type <ttype> declarator notype_declarator after_type_declarator
206 %type <ttype> direct_notype_declarator direct_after_type_declarator
208 %type <ttype> opt.component_decl_list component_decl_list
209 %type <ttype> component_decl component_decl_1 components notype_components
210 %type <ttype> component_declarator component_declarator0 self_reference
211 %type <ttype> notype_component_declarator notype_component_declarator0
212 %type <ttype> after_type_component_declarator after_type_component_declarator0
213 %type <ttype> enumlist enumerator
214 %type <ttype> absdcl cv_qualifiers
215 %type <ttype> direct_abstract_declarator conversion_declarator
216 %type <ttype> new_declarator direct_new_declarator
217 %type <ttype> xexpr parmlist parms bad_parm
218 %type <ttype> identifiers_or_typenames
219 %type <ttype> fcast_or_absdcl regcast_or_absdcl
220 %type <ttype> expr_or_declarator complex_notype_declarator
221 %type <ttype> notype_unqualified_id unqualified_id qualified_id
222 %type <ttype> template_id do_id object_template_id notype_template_declarator
223 %type <ttype> overqualified_id notype_qualified_id any_id
224 %type <ttype> complex_direct_notype_declarator functional_cast
225 %type <ttype> complex_parmlist parms_comma
226 %type <ttype> namespace_qualifier namespace_using_decl
228 %type <ftype> type_id new_type_id typed_typespecs typespec typed_declspecs
229 %type <ftype> typed_declspecs1 type_specifier_seq nonempty_cv_qualifiers
230 %type <ftype> structsp typespecqual_reserved parm named_parm full_parm
233 %token <ttype> PTYPENAME
234 %token <ttype> PRE_PARSED_FUNCTION_DECL EXTERN_LANG_STRING ALL
235 %token <ttype> PRE_PARSED_CLASS_DECL DEFARG DEFARG_MARKER
236 %type <ttype> component_constructor_declarator
237 %type <ttype> fn.def2 return_id fn.defpen constructor_declarator
238 %type <itype> ctor_initializer_opt
239 %type <ttype> named_class_head named_class_head_sans_basetype
240 %type <ttype> named_complex_class_head_sans_basetype
241 %type <ttype> unnamed_class_head
242 %type <ttype> class_head base_class_list
243 %type <ttype> base_class_access_list
244 %type <ttype> base_class maybe_base_class_list base_class.1
245 %type <ttype> exception_specification_opt ansi_raise_identifier ansi_raise_identifiers
246 %type <ttype> operator_name
247 %type <ttype> object aggr
248 %type <itype> new delete .begin_new_placement
249 /* %type <ttype> primary_no_id */
250 %type <ttype> nonmomentary_expr maybe_parmlist
251 %type <itype> initdcl0 notype_initdcl0 member_init_list initdcl0_innards
252 %type <ttype> template_header template_parm_list template_parm
253 %type <ttype> template_type_parm template_template_parm
254 %type <code> template_close_bracket
255 %type <ttype> template_type template_arg_list template_arg_list_opt
256 %type <ttype> template_arg
257 %type <ttype> condition xcond paren_cond_or_null
258 %type <ttype> type_name nested_name_specifier nested_type ptr_to_mem
259 %type <ttype> complete_type_name notype_identifier nonnested_type
260 %type <ttype> complex_type_name nested_name_specifier_1
261 %type <ttype> new_initializer new_placement
262 %type <ttype> using_decl
263 %type <ttype> typename_sub typename_sub0 typename_sub1 typename_sub2
264 %type <ttype> explicit_template_type
265 /* in order to recognize aggr tags as defining and thus shadowing. */
266 %token TYPENAME_DEFN IDENTIFIER_DEFN PTYPENAME_DEFN
267 %type <ttype> named_class_head_sans_basetype_defn
268 %type <ttype> identifier_defn IDENTIFIER_DEFN TYPENAME_DEFN PTYPENAME_DEFN
270 %type <ttype> self_template_type
275 /* Used in lex.c for parsing pragmas. */
278 /* lex.c and pt.c depend on this being the last token. Define
279 any new tokens before this one! */
280 %token END_OF_SAVED_INPUT
283 /* List of types and structure classes of the current declaration. */
284 static tree current_declspecs;
286 /* List of prefix attributes in effect.
287 Prefix attributes are parsed by the reserved_declspecs and declmods
288 rules. They create a list that contains *both* declspecs and attrs. */
289 /* ??? It is not clear yet that all cases where an attribute can now appear in
290 a declspec list have been updated. */
291 static tree prefix_attributes;
293 /* When defining an aggregate, this is the most recent one being defined. */
294 static tree current_aggr;
296 /* Tell yyparse how to print a token's value, if yydebug is set. */
298 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
299 extern void yyprint PROTO((FILE *, int, YYSTYPE));
300 extern tree combine_strings PROTO((tree));
303 parse_decl(declarator, specs_attrs, attributes, initialized, decl)
312 split_specs_attrs (specs_attrs, ¤t_declspecs, &prefix_attributes);
313 if (current_declspecs
314 && TREE_CODE (current_declspecs) != TREE_LIST)
315 current_declspecs = get_decl_list (current_declspecs);
316 if (have_extern_spec && !used_extern_spec)
318 current_declspecs = decl_tree_cons (NULL_TREE,
319 get_identifier ("extern"),
321 used_extern_spec = 1;
323 sm = suspend_momentary ();
324 *decl = start_decl (declarator, current_declspecs, initialized,
325 attributes, prefix_attributes);
334 { finish_translation_unit (); }
337 /* the reason for the strange actions in this rule
338 is so that notype_initdecls when reached via datadef
339 can find a valid list of type and sc specs in $0. */
342 { $<ttype>$ = NULL_TREE; }
344 { $<ttype>$ = NULL_TREE; }
345 | extdefs lang_extdef
346 { $<ttype>$ = NULL_TREE; }
355 { have_extern_spec = 1;
356 used_extern_spec = 0;
357 $<ttype>$ = NULL_TREE; }
360 { have_extern_spec = 0; }
365 { $<itype>$ = pedantic;
374 { if (pending_lang_change) do_pending_lang_change(); }
376 { if (! toplevel_bindings_p () && ! pseudo_global_level_p())
381 fndef eat_saved_input
382 { if (pending_inlines) do_pending_inlines (); }
384 { if (pending_inlines) do_pending_inlines (); }
386 { if (pending_inlines) do_pending_inlines (); }
387 | asm_keyword '(' string ')' ';'
388 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
390 | extern_lang_string '{' extdefs_opt '}'
391 { pop_lang_context (); }
392 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
393 { if (pending_inlines) do_pending_inlines ();
394 pop_lang_context (); }
395 | extern_lang_string .hush_warning datadef .warning_ok
396 { if (pending_inlines) do_pending_inlines ();
397 pop_lang_context (); }
398 | NAMESPACE identifier '{'
399 { push_namespace ($2); }
401 { pop_namespace (); }
403 { push_namespace (NULL_TREE); }
405 { pop_namespace (); }
406 | NAMESPACE identifier '='
407 { begin_only_namespace_names (); }
410 end_only_namespace_names ();
413 do_namespace_alias ($2, $5);
416 { do_toplevel_using_decl ($1); }
419 { pedantic = $<itype>1; }
425 | USING global_scope qualified_id
427 | USING global_scope unqualified_id
431 namespace_using_decl:
432 USING namespace_qualifier identifier
433 { $$ = build_parse_node (SCOPE_REF, $2, $3); }
434 | USING global_scope identifier
435 { $$ = build_parse_node (SCOPE_REF, global_namespace, $3); }
436 | USING global_scope namespace_qualifier identifier
437 { $$ = build_parse_node (SCOPE_REF, $3, $4); }
442 { begin_only_namespace_names (); }
445 end_only_namespace_names ();
446 /* If no declaration was found, the using-directive is
447 invalid. Since that was not reported, we need the
448 identifier for the error message. */
449 if (TREE_CODE ($4) == IDENTIFIER_NODE && lastiddecl)
451 do_using_directive ($4);
458 if (TREE_CODE ($$) == IDENTIFIER_NODE)
462 | namespace_qualifier NSNAME SCOPE
465 if (TREE_CODE ($$) == IDENTIFIER_NODE)
473 | global_scope qualified_id
475 | global_scope unqualified_id
481 { push_lang_context ($1); }
482 | extern_lang_string EXTERN_LANG_STRING
483 { if (current_lang_name != $2)
484 cp_error ("use of linkage spec `%D' is different from previous spec `%D'", $2, current_lang_name);
485 pop_lang_context (); push_lang_context ($2); }
490 { begin_template_parm_list (); }
491 template_parm_list '>'
492 { $$ = end_template_parm_list ($4); }
494 { begin_specialization();
500 { $$ = process_template_parm (NULL_TREE, $1); }
501 | template_parm_list ',' template_parm
502 { $$ = process_template_parm ($1, $3); }
512 aggr maybe_identifier
513 { $$ = finish_template_type_parm ($1, $2); }
514 | TYPENAME_KEYWORD maybe_identifier
515 { $$ = finish_template_type_parm (class_type_node, $2); }
518 template_template_parm:
519 template_header aggr maybe_identifier
520 { $$ = finish_template_template_parm ($2, $3); }
524 /* The following rules introduce a new reduce/reduce
525 conflict on the ',' and '>' input tokens: they are valid
526 prefixes for a `structsp', which means they could match a
527 nameless parameter. See 14.6, paragraph 3.
528 By putting them before the `parm' rule, we get
529 their match before considering them nameless parameter
532 { $$ = build_tree_list (NULL_TREE, $1); }
533 | template_type_parm '=' type_id
534 { $$ = build_tree_list (groktypename ($3.t), $1); }
536 { $$ = build_tree_list (NULL_TREE, $1.t); }
537 | parm '=' expr_no_commas %prec ARITHCOMPARE
538 { $$ = build_tree_list ($3, $1.t); }
539 | template_template_parm
540 { $$ = build_tree_list (NULL_TREE, $1); }
541 | template_template_parm '=' template_arg
543 if (TREE_CODE ($3) != TEMPLATE_DECL
544 && TREE_CODE ($3) != TEMPLATE_TEMPLATE_PARM
545 && TREE_CODE ($3) != TYPE_DECL)
547 error ("invalid default template argument");
548 $3 = error_mark_node;
550 $$ = build_tree_list ($3, $1);
559 end_template_decl ();
561 end_specialization ();
567 end_template_decl ();
569 end_specialization ();
575 | declmods notype_initdecls ';'
577 | typed_declspecs initdecls ';'
579 note_list_got_semicolon ($1.t);
582 { pedwarn ("empty declaration"); }
583 | explicit_instantiation ';'
584 | typed_declspecs ';'
587 split_specs_attrs ($1.t, &t, &attrs);
589 note_list_got_semicolon ($1.t);
596 ctor_initializer_opt:
615 fn.def1 maybe_return_init ctor_initializer_opt compstmt_or_error
616 { finish_function (lineno, (int)$3, 0); }
617 | fn.def1 maybe_return_init function_try_block
619 | fn.def1 maybe_return_init error
623 constructor_declarator:
624 nested_name_specifier SELFNAME '('
625 { $$ = begin_constructor_declarator ($1, $2); }
626 parmlist ')' cv_qualifiers exception_specification_opt
627 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
628 | nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
629 { $$ = begin_constructor_declarator ($1, $2);
630 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
632 | global_scope nested_name_specifier SELFNAME '('
633 { $$ = begin_constructor_declarator ($2, $3); }
634 parmlist ')' cv_qualifiers exception_specification_opt
635 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
636 | global_scope nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
637 { $$ = begin_constructor_declarator ($2, $3);
638 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
640 | nested_name_specifier self_template_type '('
641 { $$ = begin_constructor_declarator ($1, $2); }
642 parmlist ')' cv_qualifiers exception_specification_opt
643 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
644 | nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
645 { $$ = begin_constructor_declarator ($1, $2);
646 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
648 | global_scope nested_name_specifier self_template_type '('
649 { $$ = begin_constructor_declarator ($2, $3); }
650 parmlist ')' cv_qualifiers exception_specification_opt
651 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
652 | global_scope nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
653 { $$ = begin_constructor_declarator ($2, $3);
654 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
659 typed_declspecs declarator
660 { if (!begin_function_definition ($1.t, $2))
662 | declmods notype_declarator
663 { if (!begin_function_definition ($1, $2))
666 { if (!begin_function_definition (NULL_TREE, $1))
668 | declmods constructor_declarator
669 { if (!begin_function_definition ($1, $2))
671 | constructor_declarator
672 { if (!begin_function_definition (NULL_TREE, $1))
676 component_constructor_declarator:
677 SELFNAME '(' parmlist ')' cv_qualifiers exception_specification_opt
678 { $$ = make_call_declarator ($1, $3, $5, $6); }
679 | SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
680 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
681 | self_template_type '(' parmlist ')' cv_qualifiers exception_specification_opt
682 { $$ = make_call_declarator ($1, $3, $5, $6); }
683 | self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
684 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
687 /* more C++ complexity. See component_decl for a comment on the
688 reduce/reduce conflict introduced by these rules. */
690 declmods component_constructor_declarator
691 { tree specs = strip_attrs ($1);
692 $$ = start_method (specs, $2);
696 if (yychar == YYEMPTY)
698 reinit_parse_for_method (yychar, $$); }
699 | component_constructor_declarator
700 { $$ = start_method (NULL_TREE, $1); goto rest_of_mdef; }
701 | typed_declspecs declarator
702 { tree specs = strip_attrs ($1.t);
703 $$ = start_method (specs, $2); goto rest_of_mdef; }
704 | declmods notype_declarator
705 { tree specs = strip_attrs ($1);
706 $$ = start_method (specs, $2); goto rest_of_mdef; }
708 { $$ = start_method (NULL_TREE, $$); goto rest_of_mdef; }
709 | declmods constructor_declarator
710 { tree specs = strip_attrs ($1);
711 $$ = start_method (specs, $2); goto rest_of_mdef; }
712 | constructor_declarator
713 { $$ = start_method (NULL_TREE, $$); goto rest_of_mdef; }
719 if (! current_function_parms_stored)
727 { store_return_init ($<ttype>$, $2); }
728 | return_id '(' nonnull_exprlist ')'
729 { store_return_init ($<ttype>$, $3); }
730 | return_id LEFT_RIGHT
731 { store_return_init ($<ttype>$, NULL_TREE); }
735 ':' .set_base_init member_init_list
738 error ("no base initializers given following ':'");
740 /* Always keep the BLOCK node associated with the outermost
741 pair of curley braces of a function. These are needed
742 for correct operation of dwarfout.c. */
750 if (! current_function_parms_stored)
753 if (DECL_CONSTRUCTOR_P (current_function_decl))
755 /* Make a contour for the initializer list. */
758 expand_start_bindings (0);
760 else if (current_class_type == NULL_TREE)
761 error ("base initializers not allowed for non-member functions");
762 else if (! DECL_CONSTRUCTOR_P (current_function_decl))
763 error ("only constructors take base initializers");
772 | member_init_list ',' member_init
773 | member_init_list error
777 '(' nonnull_exprlist ')'
779 if (current_class_name)
780 pedwarn ("anachronistic old style base class initializer");
781 expand_member_init (current_class_ref, NULL_TREE, $2);
785 if (current_class_name)
786 pedwarn ("anachronistic old style base class initializer");
787 expand_member_init (current_class_ref, NULL_TREE, void_type_node);
789 | notype_identifier '(' nonnull_exprlist ')'
790 { expand_member_init (current_class_ref, $1, $3); }
791 | notype_identifier LEFT_RIGHT
792 { expand_member_init (current_class_ref, $1, void_type_node); }
793 | nonnested_type '(' nonnull_exprlist ')'
794 { expand_member_init (current_class_ref, $1, $3); }
795 | nonnested_type LEFT_RIGHT
796 { expand_member_init (current_class_ref, $1, void_type_node); }
797 | typename_sub '(' nonnull_exprlist ')'
798 { expand_member_init (current_class_ref, TYPE_MAIN_DECL ($1),
800 | typename_sub LEFT_RIGHT
801 { expand_member_init (current_class_ref, TYPE_MAIN_DECL ($1),
825 explicit_instantiation:
826 TEMPLATE begin_explicit_instantiation typespec ';'
827 { do_type_instantiation ($3.t, NULL_TREE);
829 end_explicit_instantiation
830 | TEMPLATE begin_explicit_instantiation typed_declspecs declarator
831 { tree specs = strip_attrs ($3.t);
832 do_decl_instantiation (specs, $4, NULL_TREE); }
833 end_explicit_instantiation
834 | TEMPLATE begin_explicit_instantiation notype_declarator
835 { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
836 end_explicit_instantiation
837 | TEMPLATE begin_explicit_instantiation constructor_declarator
838 { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
839 end_explicit_instantiation
840 | SCSPEC TEMPLATE begin_explicit_instantiation typespec ';'
841 { do_type_instantiation ($4.t, $1);
843 end_explicit_instantiation
844 | SCSPEC TEMPLATE begin_explicit_instantiation typed_declspecs
846 { tree specs = strip_attrs ($4.t);
847 do_decl_instantiation (specs, $5, $1); }
848 end_explicit_instantiation
849 | SCSPEC TEMPLATE begin_explicit_instantiation notype_declarator
850 { do_decl_instantiation (NULL_TREE, $4, $1); }
851 end_explicit_instantiation
852 | SCSPEC TEMPLATE begin_explicit_instantiation constructor_declarator
853 { do_decl_instantiation (NULL_TREE, $4, $1); }
854 end_explicit_instantiation
857 begin_explicit_instantiation:
858 { begin_explicit_instantiation(); }
860 end_explicit_instantiation:
861 { end_explicit_instantiation(); }
863 /* The TYPENAME expansions are to deal with use of a template class name as
864 a template within the class itself, where the template decl is hidden by
865 a type decl. Got all that? */
868 PTYPENAME '<' template_arg_list_opt template_close_bracket
870 $$ = lookup_template_class ($1, $3, NULL_TREE, NULL_TREE);
871 if ($$ != error_mark_node)
872 $$ = TYPE_STUB_DECL ($$);
874 | TYPENAME '<' template_arg_list_opt template_close_bracket
876 $$ = lookup_template_class ($1, $3, NULL_TREE, NULL_TREE);
877 if ($$ != error_mark_node)
878 $$ = TYPE_STUB_DECL ($$);
884 SELFNAME '<' template_arg_list_opt template_close_bracket
886 $$ = lookup_template_class ($1, $3, NULL_TREE, NULL_TREE);
887 if ($$ != error_mark_node)
888 $$ = TYPE_STUB_DECL ($$);
892 template_close_bracket:
896 /* Handle `Class<Class<Type>>' without space in the `>>' */
897 pedwarn ("`>>' should be `> >' in template class name");
902 template_arg_list_opt:
910 { $$ = build_tree_list (NULL_TREE, $$); }
911 | template_arg_list ',' template_arg
912 { $$ = chainon ($$, build_tree_list (NULL_TREE, $3)); }
917 { $$ = groktypename ($1.t); }
920 | expr_no_commas %prec ARITHCOMPARE
925 { $$ = NEGATE_EXPR; }
927 { $$ = CONVERT_EXPR; }
929 { $$ = PREINCREMENT_EXPR; }
931 { $$ = PREDECREMENT_EXPR; }
933 { $$ = TRUTH_NOT_EXPR; }
938 { $$ = build_x_compound_expr ($$); }
944 { error ("ANSI C++ forbids an empty condition for `%s'",
946 $$ = integer_zero_node; }
953 { error ("ANSI C++ forbids an empty condition for `%s'",
955 $$ = integer_zero_node; }
969 type_specifier_seq declarator maybeasm maybe_attribute '='
972 for (d = getdecls (); d; d = TREE_CHAIN (d))
973 if (TREE_CODE (d) == TYPE_DECL) {
974 tree s = TREE_TYPE (d);
975 if (TREE_CODE (s) == RECORD_TYPE)
976 cp_error ("definition of class `%T' in condition", s);
977 else if (TREE_CODE (s) == ENUMERAL_TYPE)
978 cp_error ("definition of enum `%T' in condition", s);
981 current_declspecs = $1.t;
982 $<itype>5 = suspend_momentary ();
983 $<ttype>$ = start_decl ($<ttype>2, current_declspecs, 1,
984 $4, /*prefix_attributes*/ NULL_TREE);
988 cp_finish_decl ($<ttype>6, $7, $4, 1, LOOKUP_ONLYCONVERTING);
989 resume_momentary ($<itype>5);
991 if (TREE_CODE (TREE_TYPE ($$)) == ARRAY_TYPE)
992 cp_error ("definition of array `%#D' in condition", $$);
999 | maybe_label_decls stmts '}'
1000 | maybe_label_decls stmts error '}'
1001 | maybe_label_decls error '}'
1004 already_scoped_stmt:
1006 { $<ttype>$ = begin_compound_stmt (1); }
1008 { finish_compound_stmt (1, $<ttype>2); }
1013 nontrivial_exprlist:
1014 expr_no_commas ',' expr_no_commas
1015 { $$ = expr_tree_cons (NULL_TREE, $$,
1016 build_expr_list (NULL_TREE, $3)); }
1017 | expr_no_commas ',' error
1018 { $$ = expr_tree_cons (NULL_TREE, $$,
1019 build_expr_list (NULL_TREE, error_mark_node)); }
1020 | nontrivial_exprlist ',' expr_no_commas
1021 { chainon ($$, build_expr_list (NULL_TREE, $3)); }
1022 | nontrivial_exprlist ',' error
1023 { chainon ($$, build_expr_list (NULL_TREE, error_mark_node)); }
1028 { $$ = build_expr_list (NULL_TREE, $$); }
1029 | nontrivial_exprlist
1035 /* __extension__ turns off -pedantic for following primary. */
1036 | extension cast_expr %prec UNARY
1038 pedantic = $<itype>1; }
1039 | '*' cast_expr %prec UNARY
1040 { $$ = build_x_indirect_ref ($2, "unary *"); }
1041 | '&' cast_expr %prec UNARY
1042 { $$ = build_x_unary_op (ADDR_EXPR, $2); }
1044 { $$ = build_x_unary_op (BIT_NOT_EXPR, $2); }
1045 | unop cast_expr %prec UNARY
1046 { $$ = finish_unary_op_expr ($1, $2); }
1047 /* Refer to the address of a label as a pointer. */
1050 pedwarn ("ANSI C++ forbids `&&'");
1051 $$ = finish_label_address_expr ($2); }
1052 | SIZEOF unary_expr %prec UNARY
1053 { $$ = expr_sizeof ($2); }
1054 | SIZEOF '(' type_id ')' %prec HYPERUNARY
1055 { $$ = c_sizeof (groktypename ($3.t)); }
1056 | ALIGNOF unary_expr %prec UNARY
1057 { $$ = grok_alignof ($2); }
1058 | ALIGNOF '(' type_id ')' %prec HYPERUNARY
1059 { $$ = c_alignof (groktypename ($3.t));
1060 check_for_new_type ("alignof", $3); }
1062 /* The %prec EMPTY's here are required by the = init initializer
1063 syntax extension; see below. */
1064 | new new_type_id %prec EMPTY
1065 { $$ = build_new (NULL_TREE, $2.t, NULL_TREE, $1);
1066 check_for_new_type ("new", $2); }
1067 | new new_type_id new_initializer
1068 { $$ = build_new (NULL_TREE, $2.t, $3, $1);
1069 check_for_new_type ("new", $2); }
1070 | new new_placement new_type_id %prec EMPTY
1071 { $$ = build_new ($2, $3.t, NULL_TREE, $1);
1072 check_for_new_type ("new", $3); }
1073 | new new_placement new_type_id new_initializer
1074 { $$ = build_new ($2, $3.t, $4, $1);
1075 check_for_new_type ("new", $3); }
1076 /* The .begin_new_placement in the following rules is
1077 necessary to avoid shift/reduce conflicts that lead to
1078 mis-parsing some expressions. Of course, these constructs
1079 are not really new-placement and it is bogus to call
1080 begin_new_placement. But, the parser cannot always tell at this
1081 point whether the next thing is an expression or a type-id,
1082 so there is nothing we can do. Fortunately,
1083 begin_new_placement does nothing harmful. When we rewrite
1084 the parser, this lossage should be removed, of course. */
1085 | new '(' .begin_new_placement type_id .finish_new_placement
1087 { $$ = build_new (NULL_TREE, groktypename($4.t),
1089 check_for_new_type ("new", $4); }
1090 | new '(' .begin_new_placement type_id .finish_new_placement
1092 { $$ = build_new (NULL_TREE, groktypename($4.t), $6, $1);
1093 check_for_new_type ("new", $4); }
1094 | new new_placement '(' .begin_new_placement type_id
1095 .finish_new_placement %prec EMPTY
1096 { $$ = build_new ($2, groktypename($5.t), NULL_TREE, $1);
1097 check_for_new_type ("new", $5); }
1098 | new new_placement '(' .begin_new_placement type_id
1099 .finish_new_placement new_initializer
1100 { $$ = build_new ($2, groktypename($5.t), $7, $1);
1101 check_for_new_type ("new", $5); }
1103 | delete cast_expr %prec UNARY
1104 { $$ = delete_sanity ($2, NULL_TREE, 0, $1); }
1105 | delete '[' ']' cast_expr %prec UNARY
1106 { $$ = delete_sanity ($4, NULL_TREE, 1, $1);
1107 if (yychar == YYEMPTY)
1109 | delete '[' expr ']' cast_expr %prec UNARY
1110 { $$ = delete_sanity ($5, $3, 2, $1);
1111 if (yychar == YYEMPTY)
1113 | REALPART cast_expr %prec UNARY
1114 { $$ = build_x_unary_op (REALPART_EXPR, $2); }
1115 | IMAGPART cast_expr %prec UNARY
1116 { $$ = build_x_unary_op (IMAGPART_EXPR, $2); }
1119 /* Note this rule is not suitable for use in new_placement
1120 since it uses NULL_TREE as the argument to
1121 finish_new_placement. This rule serves only to avoid
1122 reduce/reduce conflicts in unary_expr. See the comments
1123 there on the use of begin/finish_new_placement. */
1124 .finish_new_placement:
1126 { finish_new_placement (NULL_TREE, $<itype>-1); }
1128 .begin_new_placement:
1129 { $$ = begin_new_placement (); }
1132 '(' .begin_new_placement nonnull_exprlist ')'
1133 { $$ = finish_new_placement ($3, $2); }
1134 | '{' .begin_new_placement nonnull_exprlist '}'
1135 { cp_pedwarn ("old style placement syntax, use () instead");
1136 $$ = finish_new_placement ($3, $2); }
1140 '(' nonnull_exprlist ')'
1146 cp_error ("`%T' is not a valid expression", $2.t);
1147 $$ = error_mark_node;
1149 /* GNU extension so people can use initializer lists. Note that
1150 this alters the meaning of `new int = 1', which was previously
1151 syntactically valid but semantically invalid. */
1155 pedwarn ("ANSI C++ forbids initialization of new expression with `='");
1156 if (TREE_CODE ($2) != TREE_LIST
1157 && TREE_CODE ($2) != CONSTRUCTOR)
1158 $$ = build_expr_list (NULL_TREE, $2);
1164 /* This is necessary to postpone reduction of `int ((int)(int)(int))'. */
1166 '(' type_id ')' %prec EMPTY
1167 { $2.t = finish_parmlist (build_tree_list (NULL_TREE, $2.t), 0);
1168 $$ = make_call_declarator (NULL_TREE, $2.t, NULL_TREE, NULL_TREE);
1169 check_for_new_type ("cast", $2); }
1170 | regcast_or_absdcl '(' type_id ')' %prec EMPTY
1171 { $3.t = finish_parmlist (build_tree_list (NULL_TREE, $3.t), 0);
1172 $$ = make_call_declarator ($$, $3.t, NULL_TREE, NULL_TREE);
1173 check_for_new_type ("cast", $3); }
1178 | regcast_or_absdcl unary_expr %prec UNARY
1179 { $$ = reparse_absdcl_as_casts ($$, $2); }
1180 | regcast_or_absdcl '{' initlist maybecomma '}' %prec UNARY
1182 tree init = build_nt (CONSTRUCTOR, NULL_TREE,
1185 pedwarn ("ANSI C++ forbids constructor-expressions");
1186 /* Indicate that this was a GNU C constructor expression. */
1187 TREE_HAS_CONSTRUCTOR (init) = 1;
1189 $$ = reparse_absdcl_as_casts ($$, init);
1195 /* Handle general members. */
1196 | expr_no_commas POINTSAT_STAR expr_no_commas
1197 { $$ = build_x_binary_op (MEMBER_REF, $$, $3); }
1198 | expr_no_commas DOT_STAR expr_no_commas
1199 { $$ = build_m_component_ref ($$, $3); }
1200 | expr_no_commas '+' expr_no_commas
1201 { $$ = build_x_binary_op ($2, $$, $3); }
1202 | expr_no_commas '-' expr_no_commas
1203 { $$ = build_x_binary_op ($2, $$, $3); }
1204 | expr_no_commas '*' expr_no_commas
1205 { $$ = build_x_binary_op ($2, $$, $3); }
1206 | expr_no_commas '/' expr_no_commas
1207 { $$ = build_x_binary_op ($2, $$, $3); }
1208 | expr_no_commas '%' expr_no_commas
1209 { $$ = build_x_binary_op ($2, $$, $3); }
1210 | expr_no_commas LSHIFT expr_no_commas
1211 { $$ = build_x_binary_op ($2, $$, $3); }
1212 | expr_no_commas RSHIFT expr_no_commas
1213 { $$ = build_x_binary_op ($2, $$, $3); }
1214 | expr_no_commas ARITHCOMPARE expr_no_commas
1215 { $$ = build_x_binary_op ($2, $$, $3); }
1216 | expr_no_commas '<' expr_no_commas
1217 { $$ = build_x_binary_op (LT_EXPR, $$, $3); }
1218 | expr_no_commas '>' expr_no_commas
1219 { $$ = build_x_binary_op (GT_EXPR, $$, $3); }
1220 | expr_no_commas EQCOMPARE expr_no_commas
1221 { $$ = build_x_binary_op ($2, $$, $3); }
1222 | expr_no_commas MIN_MAX expr_no_commas
1223 { $$ = build_x_binary_op ($2, $$, $3); }
1224 | expr_no_commas '&' expr_no_commas
1225 { $$ = build_x_binary_op ($2, $$, $3); }
1226 | expr_no_commas '|' expr_no_commas
1227 { $$ = build_x_binary_op ($2, $$, $3); }
1228 | expr_no_commas '^' expr_no_commas
1229 { $$ = build_x_binary_op ($2, $$, $3); }
1230 | expr_no_commas ANDAND expr_no_commas
1231 { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $$, $3); }
1232 | expr_no_commas OROR expr_no_commas
1233 { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $$, $3); }
1234 | expr_no_commas '?' xexpr ':' expr_no_commas
1235 { $$ = build_x_conditional_expr ($$, $3, $5); }
1236 | expr_no_commas '=' expr_no_commas
1237 { $$ = build_x_modify_expr ($$, NOP_EXPR, $3);
1238 if ($$ != error_mark_node)
1239 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
1240 | expr_no_commas ASSIGN expr_no_commas
1241 { $$ = build_x_modify_expr ($$, $2, $3); }
1243 { $$ = build_throw (NULL_TREE); }
1244 | THROW expr_no_commas
1245 { $$ = build_throw ($2); }
1246 /* These extensions are not defined. The second arg to build_m_component_ref
1247 is old, build_m_component_ref now does an implicit
1248 build_indirect_ref (x, NULL_PTR) on the second argument.
1249 | object '&' expr_no_commas %prec UNARY
1250 { $$ = build_m_component_ref ($$, build_x_unary_op (ADDR_EXPR, $3)); }
1251 | object unop expr_no_commas %prec UNARY
1252 { $$ = build_m_component_ref ($$, build_x_unary_op ($2, $3)); }
1253 | object '(' type_id ')' expr_no_commas %prec UNARY
1254 { tree type = groktypename ($3.t);
1255 $$ = build_m_component_ref ($$, build_c_cast (type, $5)); }
1256 | object primary_no_id %prec UNARY
1257 { $$ = build_m_component_ref ($$, $2); }
1261 notype_unqualified_id:
1262 '~' see_typename identifier
1263 { $$ = build_parse_node (BIT_NOT_EXPR, $3); }
1268 | NSNAME %prec EMPTY
1272 { $$ = do_identifier ($<ttype>-1, 1, NULL_TREE); }
1275 PFUNCNAME '<' do_id template_arg_list_opt template_close_bracket
1276 { $$ = lookup_template_function ($3, $4); }
1277 | operator_name '<' do_id template_arg_list_opt template_close_bracket
1278 { $$ = lookup_template_function ($3, $4); }
1282 TEMPLATE identifier '<' template_arg_list_opt template_close_bracket
1283 { $$ = lookup_template_function ($2, $4); }
1284 | TEMPLATE PFUNCNAME '<' template_arg_list_opt template_close_bracket
1285 { $$ = lookup_template_function ($2, $4); }
1286 | TEMPLATE operator_name '<' template_arg_list_opt
1287 template_close_bracket
1288 { $$ = lookup_template_function ($2, $4); }
1292 notype_unqualified_id
1298 notype_unqualified_id
1299 | '*' expr_or_declarator %prec UNARY
1300 { $$ = build_parse_node (INDIRECT_REF, $2); }
1301 | '&' expr_or_declarator %prec UNARY
1302 { $$ = build_parse_node (ADDR_EXPR, $2); }
1303 | '(' expr_or_declarator ')'
1307 notype_template_declarator:
1308 IDENTIFIER '<' template_arg_list_opt template_close_bracket
1309 { $$ = lookup_template_function ($1, $3); }
1310 | NSNAME '<' template_arg_list template_close_bracket
1311 { $$ = lookup_template_function ($1, $3); }
1314 direct_notype_declarator:
1315 complex_direct_notype_declarator
1316 | notype_unqualified_id
1317 | notype_template_declarator
1318 | '(' expr_or_declarator ')'
1319 { $$ = finish_decl_parsing ($2); }
1323 notype_unqualified_id
1325 if (TREE_CODE ($1) == BIT_NOT_EXPR)
1326 $$ = build_x_unary_op (BIT_NOT_EXPR, TREE_OPERAND ($1, 0));
1328 $$ = finish_id_expr ($1);
1334 if (processing_template_decl)
1335 push_obstacks (&permanent_obstack, &permanent_obstack);
1336 $$ = combine_strings ($$);
1337 if (processing_template_decl)
1341 { $$ = finish_parenthesized_expr ($2); }
1342 | '(' expr_or_declarator ')'
1343 { $2 = reparse_decl_as_expr (NULL_TREE, $2);
1344 $$ = finish_parenthesized_expr ($2); }
1346 { $$ = error_mark_node; }
1348 { if (current_function_decl == 0)
1350 error ("braced-group within expression allowed only inside a function");
1354 pedwarn ("ANSI C++ forbids braced-groups within expressions");
1355 $<ttype>$ = begin_stmt_expr ();
1358 { $$ = finish_stmt_expr ($<ttype>2, $3); }
1359 /* Koenig lookup support
1360 We could store lastiddecl in $1 to avoid another lookup,
1361 but that would result in many additional reduce/reduce conflicts. */
1362 | IDENTIFIER '(' nonnull_exprlist ')'
1363 { $$ = finish_call_expr ($1, $3, 1); }
1364 | IDENTIFIER LEFT_RIGHT
1365 { $$ = finish_call_expr ($1, NULL_TREE, 1); }
1366 | primary '(' nonnull_exprlist ')'
1367 { $$ = finish_call_expr ($1, $3, 0); }
1368 | primary LEFT_RIGHT
1369 { $$ = finish_call_expr ($1, NULL_TREE, 0); }
1370 | primary '[' expr ']'
1371 { $$ = grok_array_decl ($$, $3); }
1373 { $$ = finish_increment_expr ($1, POSTINCREMENT_EXPR); }
1374 | primary MINUSMINUS
1375 { $$ = finish_increment_expr ($1, POSTDECREMENT_EXPR); }
1376 /* C++ extensions */
1378 { $$ = finish_this_expr (); }
1379 | CV_QUALIFIER '(' nonnull_exprlist ')'
1381 tree type = NULL_TREE;
1384 /* This is a C cast in C++'s `functional' notation. */
1385 if ($3 == error_mark_node)
1387 $$ = error_mark_node;
1391 if ($3 == NULL_TREE)
1393 error ("cannot cast null list to type `%s'",
1394 IDENTIFIER_POINTER (TYPE_NAME (id)));
1395 $$ = error_mark_node;
1400 /* type is not set! (mrs) */
1401 if (type == error_mark_node)
1402 $$ = error_mark_node;
1406 if (id == ridpointers[(int) RID_CONST])
1407 type = build_type_variant (integer_type_node, 1, 0);
1408 else if (id == ridpointers[(int) RID_VOLATILE])
1409 type = build_type_variant (integer_type_node, 0, 1);
1411 /* should not be able to get here (mrs) */
1412 else if (id == ridpointers[(int) RID_FRIEND])
1414 error ("cannot cast expression to `friend' type");
1415 $$ = error_mark_node;
1419 else my_friendly_abort (79);
1420 $$ = build_c_cast (type, build_compound_expr ($3));
1424 | DYNAMIC_CAST '<' type_id '>' '(' expr ')'
1425 { tree type = groktypename ($3.t);
1426 check_for_new_type ("dynamic_cast", $3);
1427 $$ = build_dynamic_cast (type, $6); }
1428 | STATIC_CAST '<' type_id '>' '(' expr ')'
1429 { tree type = groktypename ($3.t);
1430 check_for_new_type ("static_cast", $3);
1431 $$ = build_static_cast (type, $6); }
1432 | REINTERPRET_CAST '<' type_id '>' '(' expr ')'
1433 { tree type = groktypename ($3.t);
1434 check_for_new_type ("reinterpret_cast", $3);
1435 $$ = build_reinterpret_cast (type, $6); }
1436 | CONST_CAST '<' type_id '>' '(' expr ')'
1437 { tree type = groktypename ($3.t);
1438 check_for_new_type ("const_cast", $3);
1439 $$ = build_const_cast (type, $6); }
1440 | TYPEID '(' expr ')'
1441 { $$ = build_x_typeid ($3); }
1442 | TYPEID '(' type_id ')'
1443 { tree type = groktypename ($3.t);
1444 check_for_new_type ("typeid", $3);
1445 $$ = get_typeid (TYPE_MAIN_VARIANT (type)); }
1446 | global_scope IDENTIFIER
1447 { $$ = do_scoped_id ($2, 1); }
1448 | global_scope template_id
1450 | global_scope operator_name
1452 got_scope = NULL_TREE;
1453 if (TREE_CODE ($2) == IDENTIFIER_NODE)
1454 $$ = do_scoped_id ($2, 1);
1458 | overqualified_id %prec HYPERUNARY
1459 { $$ = build_offset_ref (OP0 ($$), OP1 ($$)); }
1460 | overqualified_id '(' nonnull_exprlist ')'
1461 { $$ = finish_globally_qualified_member_call_expr ($1, $3); }
1462 | overqualified_id LEFT_RIGHT
1463 { $$ = finish_globally_qualified_member_call_expr ($1, NULL_TREE); }
1464 | object object_template_id %prec UNARY
1466 $$ = build_x_component_ref ($$, $2, NULL_TREE, 1);
1468 | object object_template_id '(' nonnull_exprlist ')'
1469 { $$ = finish_object_call_expr ($2, $1, $4); }
1470 | object object_template_id LEFT_RIGHT
1471 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1472 | object unqualified_id %prec UNARY
1473 { $$ = build_x_component_ref ($$, $2, NULL_TREE, 1); }
1474 | object overqualified_id %prec UNARY
1475 { if (processing_template_decl)
1476 $$ = build_min_nt (COMPONENT_REF, $1, copy_to_permanent ($2));
1478 $$ = build_object_ref ($$, OP0 ($2), OP1 ($2)); }
1479 | object unqualified_id '(' nonnull_exprlist ')'
1480 { $$ = finish_object_call_expr ($2, $1, $4); }
1481 | object unqualified_id LEFT_RIGHT
1482 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1483 | object overqualified_id '(' nonnull_exprlist ')'
1484 { $$ = finish_qualified_object_call_expr ($2, $1, $4); }
1485 | object overqualified_id LEFT_RIGHT
1486 { $$ = finish_qualified_object_call_expr ($2, $1, NULL_TREE); }
1487 /* p->int::~int() is valid -- 12.4 */
1488 | object '~' TYPESPEC LEFT_RIGHT
1489 { $$ = finish_pseudo_destructor_call_expr ($1, NULL_TREE, $3); }
1490 | object TYPESPEC SCOPE '~' TYPESPEC LEFT_RIGHT
1491 { $$ = finish_pseudo_destructor_call_expr ($1, $2, $5); }
1494 $$ = error_mark_node;
1498 /* Not needed for now.
1504 { $$ = error_mark_node; }
1506 { if (current_function_decl == 0)
1508 error ("braced-group within expression allowed only inside a function");
1511 $<ttype>$ = expand_start_stmt_expr (); }
1514 pedwarn ("ANSI C++ forbids braced-groups within expressions");
1515 $$ = expand_end_stmt_expr ($<ttype>2); }
1516 | primary_no_id '(' nonnull_exprlist ')'
1517 { $$ = build_x_function_call ($$, $3, current_class_ref); }
1518 | primary_no_id LEFT_RIGHT
1519 { $$ = build_x_function_call ($$, NULL_TREE, current_class_ref); }
1520 | primary_no_id '[' expr ']'
1522 | primary_no_id PLUSPLUS
1523 { $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); }
1524 | primary_no_id MINUSMINUS
1525 { $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); }
1527 { goto do_scoped_id; }
1528 | SCOPE operator_name
1529 { if (TREE_CODE ($2) == IDENTIFIER_NODE)
1531 goto do_scoped_operator;
1540 { got_scope = NULL_TREE; $$ = 1; }
1546 | global_scope delete
1547 { got_scope = NULL_TREE; $$ = 1; }
1552 { $$ = boolean_true_node; }
1554 { $$ = boolean_false_node; }
1557 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
1561 { $$ = chainon ($$, $2); }
1567 if (! current_function_parms_stored)
1568 store_parm_decls ();
1570 /* Always keep the BLOCK node associated with the outermost
1571 pair of curley braces of a function. These are needed
1572 for correct operation of dwarfout.c. */
1579 { got_object = TREE_TYPE ($$); }
1582 $$ = build_x_arrow ($$);
1583 got_object = TREE_TYPE ($$);
1588 typespec initdecls ';'
1590 resume_momentary ($2);
1591 if ($1.t && IS_AGGR_TYPE_CODE (TREE_CODE ($1.t)))
1592 note_got_semicolon ($1.t);
1594 | typed_declspecs initdecls ';'
1596 resume_momentary ($2);
1597 note_list_got_semicolon ($1.t);
1599 | declmods notype_initdecls ';'
1600 { resume_momentary ($2); }
1601 | typed_declspecs ';'
1604 note_list_got_semicolon ($1.t);
1607 { warning ("empty declaration"); }
1609 { pedantic = $<itype>1; }
1612 /* Any kind of declarator (thus, all declarators allowed
1613 after an explicit typespec). */
1616 after_type_declarator %prec EMPTY
1617 | notype_declarator %prec EMPTY
1620 /* This is necessary to postpone reduction of `int()()()()'. */
1622 LEFT_RIGHT %prec EMPTY
1623 { $$ = make_call_declarator (NULL_TREE, empty_parms (),
1624 NULL_TREE, NULL_TREE); }
1625 | fcast_or_absdcl LEFT_RIGHT %prec EMPTY
1626 { $$ = make_call_declarator ($$, empty_parms (), NULL_TREE,
1630 /* ANSI type-id (8.1) */
1632 typed_typespecs absdcl
1633 { $$.t = build_decl_list ($1.t, $2);
1634 $$.new_type_flag = $1.new_type_flag; }
1635 | nonempty_cv_qualifiers absdcl
1636 { $$.t = build_decl_list ($1.t, $2);
1637 $$.new_type_flag = $1.new_type_flag; }
1639 { $$.t = build_decl_list (get_decl_list ($1.t), $2);
1640 $$.new_type_flag = $1.new_type_flag; }
1641 | typed_typespecs %prec EMPTY
1642 { $$.t = build_decl_list ($1.t, NULL_TREE);
1643 $$.new_type_flag = $1.new_type_flag; }
1644 | nonempty_cv_qualifiers %prec EMPTY
1645 { $$.t = build_decl_list ($1.t, NULL_TREE);
1646 $$.new_type_flag = $1.new_type_flag; }
1649 /* Declspecs which contain at least one type specifier or typedef name.
1650 (Just `const' or `volatile' is not enough.)
1651 A typedef'd name following these is taken as a name to be declared.
1652 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1655 typed_typespecs %prec EMPTY
1661 { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1);
1662 $$.new_type_flag = $2.new_type_flag; }
1663 | typespec reserved_declspecs %prec HYPERUNARY
1664 { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2);
1665 $$.new_type_flag = $1.new_type_flag; }
1666 | typespec reserved_typespecquals reserved_declspecs
1667 { $$.t = decl_tree_cons (NULL_TREE, $1.t, chainon ($2, $3));
1668 $$.new_type_flag = $1.new_type_flag; }
1669 | declmods typespec reserved_declspecs
1670 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1));
1671 $$.new_type_flag = $2.new_type_flag; }
1672 | declmods typespec reserved_typespecquals
1673 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1));
1674 $$.new_type_flag = $2.new_type_flag; }
1675 | declmods typespec reserved_typespecquals reserved_declspecs
1676 { $$.t = decl_tree_cons (NULL_TREE, $2.t,
1677 chainon ($3, chainon ($4, $1)));
1678 $$.new_type_flag = $2.new_type_flag; }
1683 { if (extra_warnings)
1684 warning ("`%s' is not at beginning of declaration",
1685 IDENTIFIER_POINTER ($$));
1686 $$ = build_decl_list (NULL_TREE, $$); }
1687 | reserved_declspecs typespecqual_reserved
1688 { $$ = decl_tree_cons (NULL_TREE, $2.t, $$); }
1689 | reserved_declspecs SCSPEC
1690 { if (extra_warnings)
1691 warning ("`%s' is not at beginning of declaration",
1692 IDENTIFIER_POINTER ($2));
1693 $$ = decl_tree_cons (NULL_TREE, $2, $$); }
1694 | reserved_declspecs attributes
1695 { $$ = decl_tree_cons ($2, NULL_TREE, $1); }
1697 { $$ = decl_tree_cons ($1, NULL_TREE, NULL_TREE); }
1700 /* List of just storage classes and type modifiers.
1701 A declaration can start with just this, but then it cannot be used
1702 to redeclare a typedef-name.
1703 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1706 nonempty_cv_qualifiers %prec EMPTY
1707 { $$ = $1.t; TREE_STATIC ($$) = 1; }
1709 { $$ = IDENTIFIER_AS_LIST ($$); }
1710 | declmods CV_QUALIFIER
1711 { $$ = decl_tree_cons (NULL_TREE, $2, $$);
1712 TREE_STATIC ($$) = 1; }
1714 { if (extra_warnings && TREE_STATIC ($$))
1715 warning ("`%s' is not at beginning of declaration",
1716 IDENTIFIER_POINTER ($2));
1717 $$ = decl_tree_cons (NULL_TREE, $2, $$);
1718 TREE_STATIC ($$) = TREE_STATIC ($1); }
1719 | declmods attributes
1720 { $$ = decl_tree_cons ($2, NULL_TREE, $1); }
1722 { $$ = decl_tree_cons ($1, NULL_TREE, NULL_TREE); }
1725 /* Used instead of declspecs where storage classes are not allowed
1726 (that is, for typenames and structure components).
1728 C++ can takes storage classes for structure components.
1729 Don't accept a typedef-name if anything but a modifier precedes it. */
1732 typespec %prec EMPTY
1733 { $$.t = get_decl_list ($1.t);
1734 $$.new_type_flag = $1.new_type_flag; }
1735 | nonempty_cv_qualifiers typespec
1736 { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1.t);
1737 $$.new_type_flag = $2.new_type_flag; }
1738 | typespec reserved_typespecquals
1739 { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2);
1740 $$.new_type_flag = $1.new_type_flag; }
1741 | nonempty_cv_qualifiers typespec reserved_typespecquals
1742 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1743 $$.new_type_flag = $1.new_type_flag; }
1746 reserved_typespecquals:
1747 typespecqual_reserved
1748 { $$ = build_decl_list (NULL_TREE, $1.t); }
1749 | reserved_typespecquals typespecqual_reserved
1750 { $$ = decl_tree_cons (NULL_TREE, $2.t, $1); }
1753 /* A typespec (but not a type qualifier).
1754 Once we have seen one of these in a declaration,
1755 if a typedef name appears then it is being redeclared. */
1759 | TYPESPEC %prec EMPTY
1760 { $$.t = $1; $$.new_type_flag = 0; }
1761 | complete_type_name
1762 { $$.t = $1; $$.new_type_flag = 0; }
1763 | TYPEOF '(' expr ')'
1764 { $$.t = TREE_TYPE ($3);
1765 $$.new_type_flag = 0; }
1766 | TYPEOF '(' type_id ')'
1767 { $$.t = groktypename ($3.t);
1768 $$.new_type_flag = 0; }
1769 | SIGOF '(' expr ')'
1770 { tree type = TREE_TYPE ($3);
1772 $$.new_type_flag = 0;
1773 if (IS_AGGR_TYPE (type))
1775 sorry ("sigof type specifier");
1780 error ("`sigof' applied to non-aggregate expression");
1781 $$.t = error_mark_node;
1784 | SIGOF '(' type_id ')'
1785 { tree type = groktypename ($3.t);
1787 $$.new_type_flag = 0;
1788 if (IS_AGGR_TYPE (type))
1790 sorry ("sigof type specifier");
1795 error("`sigof' applied to non-aggregate type");
1796 $$.t = error_mark_node;
1801 /* A typespec that is a reserved word, or a type qualifier. */
1803 typespecqual_reserved:
1805 { $$.t = $1; $$.new_type_flag = 0; }
1807 { $$.t = $1; $$.new_type_flag = 0; }
1813 | initdecls ',' initdcl
1818 | notype_initdecls ',' initdcl
1823 | nomods_initdecls ',' initdcl
1829 | asm_keyword '(' string ')'
1830 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3); $$ = $3; }
1834 declarator maybeasm maybe_attribute '='
1835 { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1,
1836 $3, prefix_attributes); }
1838 /* Note how the declaration of the variable is in effect while its init is parsed! */
1839 { cp_finish_decl ($<ttype>5, $6, $2, 1, LOOKUP_ONLYCONVERTING); }
1840 | declarator maybeasm maybe_attribute
1841 { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 0,
1842 $3, prefix_attributes);
1843 cp_finish_decl ($<ttype>$, NULL_TREE, $2, 1, 0); }
1846 /* This rule assumes a certain configuration of the parser stack.
1847 In particular, $0, the element directly before the beginning of
1848 this rule on the stack, must be a maybeasm. $-1 must be a
1849 declarator or notype_declarator. And $-2 must be some declmods
1850 or declspecs. We can't move the maybeasm into this rule because
1851 we need that reduce so we prefer fn.def1 when appropriate. */
1854 { $<itype>2 = parse_decl ($<ttype>-1, $<ttype>-2,
1855 $1, 1, &$<ttype>$); }
1856 /* Note how the declaration of the variable is in effect
1857 while its init is parsed! */
1859 { cp_finish_decl ($<ttype>3, $4, $<ttype>0, 1,
1860 LOOKUP_ONLYCONVERTING);
1864 $$ = parse_decl ($<ttype>-1, $<ttype>-2, $1, 0, &d);
1865 cp_finish_decl (d, NULL_TREE, $<ttype>0, 1, 0); }
1869 declarator maybeasm initdcl0_innards
1873 notype_declarator maybeasm initdcl0_innards
1878 notype_declarator maybeasm
1879 { /* Set things up as initdcl0_innards expects. */
1884 | constructor_declarator maybeasm maybe_attribute
1886 parse_decl($1, NULL_TREE, $3, 0, &d);
1887 cp_finish_decl (d, NULL_TREE, $2, 1, 0); }
1890 /* the * rules are dummies to accept the Apollo extended syntax
1891 so that the header files compile. */
1902 | attributes attribute
1903 { $$ = chainon ($1, $2); }
1907 ATTRIBUTE '(' '(' attribute_list ')' ')'
1914 | attribute_list ',' attrib
1915 { $$ = chainon ($1, $3); }
1922 { $$ = build_tree_list ($1, NULL_TREE); }
1923 | any_word '(' IDENTIFIER ')'
1924 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1925 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1926 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1927 | any_word '(' nonnull_exprlist ')'
1928 { $$ = build_tree_list ($1, $3); }
1931 /* This still leaves out most reserved keywords,
1932 shouldn't we include them? */
1941 /* A nonempty list of identifiers, including typenames. */
1942 identifiers_or_typenames:
1944 { $$ = build_tree_list (NULL_TREE, $1); }
1945 | identifiers_or_typenames ',' identifier
1946 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
1950 /* empty */ %prec EMPTY
1955 /* If we are processing a template, we don't want to expand this
1959 expr_no_commas %prec '='
1961 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, NULL_TREE);
1962 TREE_HAS_CONSTRUCTOR ($$) = 1; }
1964 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
1965 TREE_HAS_CONSTRUCTOR ($$) = 1; }
1966 | '{' initlist ',' '}'
1967 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
1968 TREE_HAS_CONSTRUCTOR ($$) = 1; }
1973 /* This chain is built in reverse order,
1974 and put in forward order where initlist is used. */
1977 { $$ = build_tree_list (NULL_TREE, $$); }
1979 { $$ = expr_tree_cons (NULL_TREE, $3, $$); }
1980 /* These are for labeled elements. */
1981 | '[' expr_no_commas ']' init
1982 { $$ = build_expr_list ($2, $4); }
1983 | identifier ':' init
1984 { $$ = build_expr_list ($$, $3); }
1985 | initlist ',' identifier ':' init
1986 { $$ = expr_tree_cons ($3, $5, $$); }
1990 PRE_PARSED_FUNCTION_DECL
1991 { start_function (NULL_TREE, TREE_VALUE ($1),
1993 reinit_parse_for_function (); }
1996 fn.defpen maybe_return_init ctor_initializer_opt compstmt_or_error
1998 int nested = (hack_decl_function_context
1999 (current_function_decl) != NULL_TREE);
2000 finish_function (lineno, (int)$3, nested);
2001 process_next_inline ($1);
2003 | fn.defpen maybe_return_init function_try_block
2004 { process_next_inline ($1); }
2005 | fn.defpen maybe_return_init error
2006 { process_next_inline ($1); }
2011 | pending_inlines pending_inline eat_saved_input
2014 /* A regurgitated default argument. The value of DEFARG_MARKER will be
2015 the TREE_LIST node for the parameter in question. */
2017 DEFARG_MARKER expr_no_commas END_OF_SAVED_INPUT
2018 { replace_defarg ($1, $2); }
2019 | DEFARG_MARKER error END_OF_SAVED_INPUT
2020 { replace_defarg ($1, error_mark_node); }
2023 /* empty */ %prec EMPTY
2024 | pending_defargs defarg_again
2025 { do_pending_defargs (); }
2026 | pending_defargs error
2027 { do_pending_defargs (); }
2032 { $<itype>3 = suspend_momentary ();
2033 $<ttype>$ = start_enum ($2); }
2034 enumlist maybecomma_warn '}'
2035 { $$.t = finish_enum ($<ttype>4, $5);
2036 $$.new_type_flag = 1;
2037 resume_momentary ((int) $<itype>3);
2038 check_for_missing_semicolon ($<ttype>4); }
2039 | ENUM identifier '{' '}'
2040 { $$.t = finish_enum (start_enum ($2), NULL_TREE);
2041 $$.new_type_flag = 1;
2042 check_for_missing_semicolon ($$.t); }
2044 { $<itype>2 = suspend_momentary ();
2045 $<ttype>$ = start_enum (make_anon_name ()); }
2046 enumlist maybecomma_warn '}'
2047 { $$.t = finish_enum ($<ttype>3, $4);
2048 resume_momentary ((int) $<itype>1);
2049 check_for_missing_semicolon ($<ttype>3);
2050 $$.new_type_flag = 1; }
2052 { $$.t = finish_enum (start_enum (make_anon_name()), NULL_TREE);
2053 $$.new_type_flag = 1;
2054 check_for_missing_semicolon ($$.t); }
2056 { $$.t = xref_tag (enum_type_node, $2, NULL_TREE, 1);
2057 $$.new_type_flag = 0; }
2058 | ENUM complex_type_name
2059 { $$.t = xref_tag (enum_type_node, $2, NULL_TREE, 1);
2060 $$.new_type_flag = 0; }
2061 | TYPENAME_KEYWORD typename_sub
2063 $$.new_type_flag = 0; }
2064 /* C++ extensions, merged with C to avoid shift/reduce conflicts */
2065 | class_head left_curly
2066 opt.component_decl_list '}' maybe_attribute
2070 if (yychar == YYEMPTY)
2072 semi = yychar == ';';
2074 $<ttype>$ = finish_class_definition ($1, $3, $5, semi);
2077 { finish_default_args (); }
2080 $$.new_type_flag = 1;
2081 begin_inline_definitions (); }
2082 | class_head %prec EMPTY
2084 $$.new_type_flag = 0;
2085 if (TYPE_BINFO ($1) == NULL_TREE)
2087 cp_error ("%T is not a class type", $1);
2088 $$.t = error_mark_node;
2093 /* struct B: public A; is not accepted by the WP grammar. */
2094 if (TYPE_BINFO_BASETYPES ($$.t) && !TYPE_SIZE ($$.t)
2095 && ! TYPE_BEING_DEFINED ($$.t))
2096 cp_error ("base clause without member specification for `%#T'",
2110 { if (pedantic && !in_system_header)
2111 pedwarn ("comma at end of enumerator list"); }
2117 { error ("storage class specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2119 { error ("type specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2121 { error ("type qualifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2123 { error ("no body nor ';' separates two class, struct or union declarations"); }
2125 { $$ = build_decl_list ($2, $1); }
2128 named_class_head_sans_basetype:
2130 { current_aggr = $$; $$ = $2; }
2133 named_class_head_sans_basetype_defn:
2134 aggr identifier_defn %prec EMPTY
2135 { current_aggr = $$; $$ = $2; }
2138 named_complex_class_head_sans_basetype:
2139 aggr nested_name_specifier identifier
2142 $$ = handle_class_head ($1, $2, $3);
2144 | aggr global_scope nested_name_specifier identifier
2147 $$ = handle_class_head ($1, $3, $4);
2149 | aggr global_scope identifier
2152 $$ = handle_class_head ($1, NULL_TREE, $3);
2154 | aggr template_type
2155 { current_aggr = $$; $$ = $2; }
2156 | aggr nested_name_specifier template_type
2157 { current_aggr = $$; $$ = $3; }
2161 /* empty */ %prec EMPTY
2162 { $<ttype>$ = xref_tag (current_aggr, $<ttype>0, NULL_TREE, 0); }
2166 named_class_head_sans_basetype %prec EMPTY
2167 { $$ = xref_tag (current_aggr, $1, NULL_TREE, 1); }
2168 | named_class_head_sans_basetype_defn do_xref_defn
2169 maybe_base_class_list %prec EMPTY
2173 xref_basetypes (current_aggr, $1, $<ttype>2, $3);
2175 | named_complex_class_head_sans_basetype maybe_base_class_list
2177 $$ = TREE_TYPE ($1);
2178 if (TREE_INT_CST_LOW (current_aggr) == union_type
2179 && TREE_CODE ($$) != UNION_TYPE)
2180 cp_pedwarn ("`union' tag used in declaring `%#T'", $$);
2181 else if (TREE_CODE ($$) == UNION_TYPE
2182 && TREE_INT_CST_LOW (current_aggr) != union_type)
2183 cp_pedwarn ("non-`union' tag used in declaring `%#T'", $$);
2186 if (IS_AGGR_TYPE ($$) && CLASSTYPE_USE_TEMPLATE ($$))
2188 if (CLASSTYPE_IMPLICIT_INSTANTIATION ($$)
2189 && TYPE_SIZE ($$) == NULL_TREE)
2191 SET_CLASSTYPE_TEMPLATE_SPECIALIZATION ($$);
2192 if (processing_template_decl)
2193 push_template_decl (TYPE_MAIN_DECL ($$));
2195 else if (CLASSTYPE_TEMPLATE_INSTANTIATION ($$))
2196 cp_error ("specialization after instantiation of `%T'", $$);
2198 xref_basetypes (current_aggr, $1, $$, $2);
2205 { $$ = xref_tag ($$, make_anon_name (), NULL_TREE, 0);
2206 yyungetc ('{', 1); }
2214 maybe_base_class_list:
2215 /* empty */ %prec EMPTY
2217 | ':' see_typename %prec EMPTY
2218 { yyungetc(':', 1); $$ = NULL_TREE; }
2219 | ':' see_typename base_class_list %prec EMPTY
2225 | base_class_list ',' see_typename base_class
2226 { $$ = chainon ($$, $4); }
2232 tree type = TREE_TYPE ($1);
2233 if (! is_aggr_type (type, 1))
2235 else if (current_aggr == signature_type_node
2236 && (! type) && (! IS_SIGNATURE (type)))
2238 error ("class name not allowed as base signature");
2241 else if (current_aggr == signature_type_node)
2243 sorry ("signature inheritance, base type `%s' ignored",
2244 IDENTIFIER_POINTER ($$));
2245 $$ = build_tree_list (access_public_node, type);
2247 else if (type && IS_SIGNATURE (type))
2249 error ("signature name not allowed as base class");
2253 $$ = build_tree_list (access_default_node, type);
2255 | base_class_access_list see_typename base_class.1
2257 tree type = TREE_TYPE ($3);
2258 if (current_aggr == signature_type_node)
2259 error ("access and source specifiers not allowed in signature");
2260 if (! is_aggr_type (type, 1))
2262 else if (current_aggr == signature_type_node
2263 && (! type) && (! IS_SIGNATURE (type)))
2265 error ("class name not allowed as base signature");
2268 else if (current_aggr == signature_type_node)
2270 sorry ("signature inheritance, base type `%s' ignored",
2271 IDENTIFIER_POINTER ($$));
2272 $$ = build_tree_list (access_public_node, type);
2274 else if (type && IS_SIGNATURE (type))
2276 error ("signature name not allowed as base class");
2280 $$ = build_tree_list ($$, type);
2286 { $$ = TYPE_MAIN_DECL ($1); }
2288 | SIGOF '(' expr ')'
2290 if (current_aggr == signature_type_node)
2292 if (IS_AGGR_TYPE (TREE_TYPE ($3)))
2294 sorry ("`sigof' as base signature specifier");
2295 $$ = TREE_TYPE ($3);
2299 error ("`sigof' applied to non-aggregate expression");
2300 $$ = error_mark_node;
2305 error ("`sigof' in struct or class declaration");
2306 $$ = error_mark_node;
2309 | SIGOF '(' type_id ')'
2311 if (current_aggr == signature_type_node)
2313 if (IS_AGGR_TYPE (groktypename ($3.t)))
2315 sorry ("`sigof' as base signature specifier");
2316 $$ = groktypename ($3.t);
2320 error ("`sigof' applied to non-aggregate expression");
2321 $$ = error_mark_node;
2326 error ("`sigof' in struct or class declaration");
2327 $$ = error_mark_node;
2332 base_class_access_list:
2333 VISSPEC see_typename
2334 | SCSPEC see_typename
2335 { if ($1 != ridpointers[(int)RID_VIRTUAL])
2336 cp_error ("`%D' access", $1);
2337 $$ = access_default_virtual_node; }
2338 | base_class_access_list VISSPEC see_typename
2340 if ($1 != access_default_virtual_node)
2341 error ("multiple access specifiers");
2342 else if ($2 == access_public_node)
2343 $$ = access_public_virtual_node;
2344 else if ($2 == access_protected_node)
2345 $$ = access_protected_virtual_node;
2346 else /* $2 == access_private_node */
2347 $$ = access_private_virtual_node;
2349 | base_class_access_list SCSPEC see_typename
2350 { if ($2 != ridpointers[(int)RID_VIRTUAL])
2351 cp_error ("`%D' access", $2);
2352 else if ($$ == access_public_node)
2353 $$ = access_public_virtual_node;
2354 else if ($$ == access_protected_node)
2355 $$ = access_protected_virtual_node;
2356 else if ($$ == access_private_node)
2357 $$ = access_private_virtual_node;
2359 error ("multiple `virtual' specifiers");
2365 { $<ttype>0 = begin_class_definition ($<ttype>0); }
2371 $$ = build_self_reference ();
2375 opt.component_decl_list:
2377 { if ($$) $$ = build_tree_list (access_public_node, $$); }
2378 | self_reference component_decl_list
2380 if (current_aggr == signature_type_node)
2381 $$ = build_tree_list (access_public_node, $2);
2383 $$ = build_tree_list (access_default_node, $2);
2384 if ($1) $$ = tree_cons (access_public_node, $1, $$);
2386 | opt.component_decl_list VISSPEC ':' component_decl_list
2390 if (current_aggr == signature_type_node)
2392 error ("access specifier not allowed in signature");
2393 visspec = access_public_node;
2395 $$ = chainon ($$, build_tree_list (visspec, $4));
2397 | opt.component_decl_list VISSPEC ':'
2399 if (current_aggr == signature_type_node)
2400 error ("access specifier not allowed in signature");
2404 /* Note: we no longer warn about the semicolon after a component_decl_list.
2405 ARM $9.2 says that the semicolon is optional, and therefore allowed. */
2406 component_decl_list:
2408 { if ($$ == void_type_node) $$ = NULL_TREE;
2410 | component_decl_list component_decl
2411 { /* In pushdecl, we created a reverse list of names
2412 in this binding level. Make sure that the chain
2413 of what we're trying to add isn't the item itself
2414 (which can happen with what pushdecl's doing). */
2415 if ($2 != NULL_TREE && $2 != void_type_node)
2417 if (TREE_CHAIN ($2) != $$)
2418 $$ = chainon ($$, $2);
2426 component_decl_1 ';'
2428 | component_decl_1 '}'
2429 { error ("missing ';' before right brace");
2430 yyungetc ('}', 0); }
2431 /* C++: handle constructors, destructors and inline functions */
2432 /* note that INLINE is like a TYPESPEC */
2433 | fn.def2 ':' /* base_init compstmt */
2434 { $$ = finish_method ($$); }
2435 | fn.def2 TRY /* base_init compstmt */
2436 { $$ = finish_method ($$); }
2437 | fn.def2 RETURN /* base_init compstmt */
2438 { $$ = finish_method ($$); }
2439 | fn.def2 '{' /* nodecls compstmt */
2440 { $$ = finish_method ($$); }
2443 | extension component_decl
2445 pedantic = $<itype>1; }
2446 | template_header component_decl
2447 { $$ = finish_member_template_decl ($1, $2); }
2448 | template_header typed_declspecs ';'
2449 { $$ = finish_member_class_template ($1, $2.t); }
2453 /* Do not add a "typed_declspecs declarator" rule here for
2454 speed; we need to call grok_x_components for enums, so the
2455 speedup would be insignificant. */
2456 typed_declspecs components
2457 { $$ = grok_x_components ($1.t, $2); }
2458 | declmods notype_components
2459 { $$ = grok_x_components ($1, $2); }
2460 | notype_declarator maybeasm maybe_attribute maybe_init
2461 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2462 build_tree_list ($3, NULL_TREE)); }
2463 | constructor_declarator maybeasm maybe_attribute maybe_init
2464 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2465 build_tree_list ($3, NULL_TREE)); }
2466 | ':' expr_no_commas
2467 { $$ = grokbitfield (NULL_TREE, NULL_TREE, $2); }
2471 /* These rules introduce a reduce/reduce conflict; in
2472 typedef int foo, bar;
2476 should "A::foo" be declared as a function or "A::bar" as a data
2477 member? In other words, is "bar" an after_type_declarator or a
2479 | declmods component_constructor_declarator maybeasm maybe_attribute maybe_init
2480 { tree specs, attrs;
2481 split_specs_attrs ($1, &specs, &attrs);
2482 $$ = grokfield ($2, specs, $5, $3,
2483 build_tree_list ($4, attrs)); }
2484 | component_constructor_declarator maybeasm maybe_attribute maybe_init
2485 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2486 build_tree_list ($3, NULL_TREE)); }
2488 { $$ = do_class_using_decl ($1); }
2490 /* The case of exactly one component is handled directly by component_decl. */
2493 /* empty: possibly anonymous */
2495 | component_declarator0
2496 | components ',' component_declarator
2498 /* In this context, void_type_node encodes
2499 friends. They have been recorded elsewhere. */
2500 if ($$ == void_type_node)
2503 $$ = chainon ($$, $3);
2508 /* empty: possibly anonymous */
2510 | notype_component_declarator0
2511 | notype_components ',' notype_component_declarator
2513 /* In this context, void_type_node encodes
2514 friends. They have been recorded elsewhere. */
2515 if ($$ == void_type_node)
2518 $$ = chainon ($$, $3);
2522 component_declarator0:
2523 after_type_component_declarator0
2524 | notype_component_declarator0
2527 component_declarator:
2528 after_type_component_declarator
2529 | notype_component_declarator
2532 after_type_component_declarator0:
2533 after_type_declarator maybeasm maybe_attribute maybe_init
2534 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2535 &prefix_attributes);
2536 $<ttype>0 = current_declspecs;
2537 $$ = grokfield ($$, current_declspecs, $4, $2,
2538 build_tree_list ($3, prefix_attributes)); }
2539 | TYPENAME ':' expr_no_commas maybe_attribute
2540 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2541 &prefix_attributes);
2542 $<ttype>0 = current_declspecs;
2543 $$ = grokbitfield ($$, current_declspecs, $3);
2544 cplus_decl_attributes ($$, $4, prefix_attributes); }
2547 notype_component_declarator0:
2548 notype_declarator maybeasm maybe_attribute maybe_init
2549 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2550 &prefix_attributes);
2551 $<ttype>0 = current_declspecs;
2552 $$ = grokfield ($$, current_declspecs, $4, $2,
2553 build_tree_list ($3, prefix_attributes)); }
2554 | constructor_declarator maybeasm maybe_attribute maybe_init
2555 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2556 &prefix_attributes);
2557 $<ttype>0 = current_declspecs;
2558 $$ = grokfield ($$, current_declspecs, $4, $2,
2559 build_tree_list ($3, prefix_attributes)); }
2560 | IDENTIFIER ':' expr_no_commas maybe_attribute
2561 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2562 &prefix_attributes);
2563 $<ttype>0 = current_declspecs;
2564 $$ = grokbitfield ($$, current_declspecs, $3);
2565 cplus_decl_attributes ($$, $4, prefix_attributes); }
2566 | ':' expr_no_commas maybe_attribute
2567 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2568 &prefix_attributes);
2569 $<ttype>0 = current_declspecs;
2570 $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
2571 cplus_decl_attributes ($$, $3, prefix_attributes); }
2574 after_type_component_declarator:
2575 after_type_declarator maybeasm maybe_attribute maybe_init
2576 { $$ = grokfield ($$, current_declspecs, $4, $2,
2577 build_tree_list ($3, prefix_attributes)); }
2578 | TYPENAME ':' expr_no_commas maybe_attribute
2579 { $$ = grokbitfield ($$, current_declspecs, $3);
2580 cplus_decl_attributes ($$, $4, prefix_attributes); }
2583 notype_component_declarator:
2584 notype_declarator maybeasm maybe_attribute maybe_init
2585 { $$ = grokfield ($$, current_declspecs, $4, $2,
2586 build_tree_list ($3, prefix_attributes)); }
2587 | IDENTIFIER ':' expr_no_commas maybe_attribute
2588 { $$ = grokbitfield ($$, current_declspecs, $3);
2589 cplus_decl_attributes ($$, $4, prefix_attributes); }
2590 | ':' expr_no_commas maybe_attribute
2591 { $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
2592 cplus_decl_attributes ($$, $3, prefix_attributes); }
2595 /* We chain the enumerators in reverse order.
2596 Because of the way enums are built, the order is
2597 insignificant. Take advantage of this fact. */
2601 | enumlist ',' enumerator
2602 { TREE_CHAIN ($3) = $$; $$ = $3; }
2607 { $$ = build_enumerator ($$, NULL_TREE); }
2608 | identifier '=' expr_no_commas
2609 { $$ = build_enumerator ($$, $3); }
2612 /* ANSI new-type-id (5.3.4) */
2614 type_specifier_seq new_declarator
2615 { $$.t = build_decl_list ($1.t, $2);
2616 $$.new_type_flag = $1.new_type_flag; }
2617 | type_specifier_seq %prec EMPTY
2618 { $$.t = build_decl_list ($1.t, NULL_TREE);
2619 $$.new_type_flag = $1.new_type_flag; }
2620 /* GNU extension to allow arrays of arbitrary types with
2621 non-constant dimension. For the use of begin_new_placement
2622 here, see the comments in unary_expr above. */
2623 | '(' .begin_new_placement type_id .finish_new_placement
2627 pedwarn ("ANSI C++ forbids array dimensions with parenthesized type in new");
2628 $$.t = build_parse_node (ARRAY_REF, TREE_VALUE ($3.t), $6);
2629 $$.t = build_decl_list (TREE_PURPOSE ($3.t), $$.t);
2630 $$.new_type_flag = $3.new_type_flag;
2635 /* empty */ %prec EMPTY
2637 | cv_qualifiers CV_QUALIFIER
2638 { $$ = decl_tree_cons (NULL_TREE, $2, $$); }
2641 nonempty_cv_qualifiers:
2643 { $$.t = IDENTIFIER_AS_LIST ($1);
2644 $$.new_type_flag = 0; }
2645 | nonempty_cv_qualifiers CV_QUALIFIER
2646 { $$.t = decl_tree_cons (NULL_TREE, $2, $1.t);
2647 $$.new_type_flag = $1.new_type_flag; }
2650 /* These rules must follow the rules for function declarations
2651 and component declarations. That way, longer rules are preferred. */
2655 { $<itype>$ = suspend_momentary (); }
2657 /* An expression which will not live on the momentary obstack. */
2660 { resume_momentary ((int) $<itype>1); $$ = $2; }
2663 /* An expression which will not live on the momentary obstack. */
2665 suspend_mom '(' nonnull_exprlist ')'
2666 { resume_momentary ((int) $<itype>1); $$ = $3; }
2667 | suspend_mom '(' parmlist ')'
2668 { resume_momentary ((int) $<itype>1); $$ = $3; }
2669 | suspend_mom LEFT_RIGHT
2670 { resume_momentary ((int) $<itype>1); $$ = empty_parms (); }
2671 | suspend_mom '(' error ')'
2672 { resume_momentary ((int) $<itype>1); $$ = NULL_TREE; }
2675 /* A declarator that is allowed only after an explicit typespec. */
2676 /* may all be followed by prec '.' */
2677 after_type_declarator:
2678 '*' nonempty_cv_qualifiers after_type_declarator %prec UNARY
2679 { $$ = make_pointer_declarator ($2.t, $3); }
2680 | '&' nonempty_cv_qualifiers after_type_declarator %prec UNARY
2681 { $$ = make_reference_declarator ($2.t, $3); }
2682 | '*' after_type_declarator %prec UNARY
2683 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2684 | '&' after_type_declarator %prec UNARY
2685 { $$ = make_reference_declarator (NULL_TREE, $2); }
2686 | ptr_to_mem cv_qualifiers after_type_declarator
2687 { tree arg = make_pointer_declarator ($2, $3);
2688 $$ = build_parse_node (SCOPE_REF, $1, arg);
2690 | direct_after_type_declarator
2694 type_name %prec EMPTY
2696 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2698 $$ = lookup_name ($1, 1);
2699 if (current_class_type
2700 && TYPE_BEING_DEFINED (current_class_type)
2701 && ! IDENTIFIER_CLASS_VALUE ($1))
2703 /* Remember that this name has been used in the class
2704 definition, as per [class.scope0] */
2705 pushdecl_class_level ($$);
2711 | global_scope type_name
2713 if (TREE_CODE ($2) == IDENTIFIER_NODE)
2714 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
2717 got_scope = NULL_TREE;
2724 | global_scope nested_type
2729 nested_name_specifier type_name %prec EMPTY
2730 { $$ = get_type_decl ($2); }
2733 direct_after_type_declarator:
2734 direct_after_type_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2735 { $$ = make_call_declarator ($$, $2, $3, $4); }
2736 | direct_after_type_declarator '[' nonmomentary_expr ']'
2737 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
2738 | direct_after_type_declarator '[' ']'
2739 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
2740 | '(' after_type_declarator ')'
2742 | nested_name_specifier type_name %prec EMPTY
2743 { push_nested_class ($1, 3);
2744 $$ = build_parse_node (SCOPE_REF, $$, $2);
2745 TREE_COMPLEXITY ($$) = current_class_depth; }
2746 | type_name %prec EMPTY
2749 /* A declarator allowed whether or not there has been
2750 an explicit typespec. These cannot redeclare a typedef-name. */
2753 '*' nonempty_cv_qualifiers notype_declarator %prec UNARY
2754 { $$ = make_pointer_declarator ($2.t, $3); }
2755 | '&' nonempty_cv_qualifiers notype_declarator %prec UNARY
2756 { $$ = make_reference_declarator ($2.t, $3); }
2757 | '*' notype_declarator %prec UNARY
2758 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2759 | '&' notype_declarator %prec UNARY
2760 { $$ = make_reference_declarator (NULL_TREE, $2); }
2761 | ptr_to_mem cv_qualifiers notype_declarator
2762 { tree arg = make_pointer_declarator ($2, $3);
2763 $$ = build_parse_node (SCOPE_REF, $1, arg);
2765 | direct_notype_declarator
2768 complex_notype_declarator:
2769 '*' nonempty_cv_qualifiers notype_declarator %prec UNARY
2770 { $$ = make_pointer_declarator ($2.t, $3); }
2771 | '&' nonempty_cv_qualifiers notype_declarator %prec UNARY
2772 { $$ = make_reference_declarator ($2.t, $3); }
2773 | '*' complex_notype_declarator %prec UNARY
2774 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2775 | '&' complex_notype_declarator %prec UNARY
2776 { $$ = make_reference_declarator (NULL_TREE, $2); }
2777 | ptr_to_mem cv_qualifiers notype_declarator
2778 { tree arg = make_pointer_declarator ($2, $3);
2779 $$ = build_parse_node (SCOPE_REF, $1, arg);
2781 | complex_direct_notype_declarator
2784 complex_direct_notype_declarator:
2785 direct_notype_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2786 { $$ = make_call_declarator ($$, $2, $3, $4); }
2787 | '(' complex_notype_declarator ')'
2789 | direct_notype_declarator '[' nonmomentary_expr ']'
2790 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
2791 | direct_notype_declarator '[' ']'
2792 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
2793 | notype_qualified_id
2794 { if (TREE_CODE (OP0 ($1)) == NAMESPACE_DECL)
2796 push_decl_namespace (OP0 ($1));
2797 TREE_COMPLEXITY ($1) = -1;
2799 else if (OP0 ($1) != current_class_type)
2801 push_nested_class (OP0 ($1), 3);
2802 TREE_COMPLEXITY ($1) = current_class_depth;
2805 | nested_name_specifier notype_template_declarator
2806 { got_scope = NULL_TREE;
2807 $$ = build_parse_node (SCOPE_REF, $1, $2);
2808 if ($1 != current_class_type)
2810 push_nested_class ($1, 3);
2811 TREE_COMPLEXITY ($$) = current_class_depth;
2817 nested_name_specifier unqualified_id
2818 { got_scope = NULL_TREE;
2819 $$ = build_parse_node (SCOPE_REF, $$, $2); }
2820 | nested_name_specifier object_template_id
2821 { got_scope = NULL_TREE;
2822 $$ = build_parse_node (SCOPE_REF, $1, $2); }
2825 notype_qualified_id:
2826 nested_name_specifier notype_unqualified_id
2827 { got_scope = NULL_TREE;
2828 $$ = build_parse_node (SCOPE_REF, $$, $2); }
2829 | nested_name_specifier object_template_id
2830 { got_scope = NULL_TREE;
2831 $$ = build_parse_node (SCOPE_REF, $1, $2); }
2836 | global_scope notype_qualified_id
2841 typespec '(' nonnull_exprlist ')'
2842 { $$ = build_functional_cast ($1.t, $3); }
2843 | typespec '(' expr_or_declarator ')'
2844 { $$ = reparse_decl_as_expr ($1.t, $3); }
2845 | typespec fcast_or_absdcl %prec EMPTY
2846 { $$ = reparse_absdcl_as_expr ($1.t, $2); }
2852 | template_type %prec EMPTY
2855 nested_name_specifier:
2856 nested_name_specifier_1
2857 | nested_name_specifier nested_name_specifier_1
2859 | nested_name_specifier TEMPLATE explicit_template_type SCOPE
2860 { got_scope = $$ = make_typename_type ($1, $3); }
2863 /* Why the @#$%^& do type_name and notype_identifier need to be expanded
2864 inline here?!? (jason) */
2865 nested_name_specifier_1:
2868 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2871 /* Remember that this name has been used in the class
2872 definition, as per [class.scope0] */
2873 if (current_class_type
2874 && TYPE_BEING_DEFINED (current_class_type)
2875 && ! IDENTIFIER_CLASS_VALUE ($1))
2876 pushdecl_class_level ($$);
2878 got_scope = $$ = TREE_TYPE ($$);
2882 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2884 got_scope = $$ = TREE_TYPE ($$);
2888 if (TREE_CODE ($$) == IDENTIFIER_NODE)
2892 | template_type SCOPE
2893 { got_scope = $$ = complete_type (TREE_TYPE ($1)); }
2894 /* These break 'const i;'
2898 cp_error ("`%D' is not an aggregate typedef",
2899 lastiddecl ? lastiddecl : $$);
2900 $$ = error_mark_node;
2903 { goto failed_scope; } */
2908 | global_scope typename_sub0
2913 typename_sub1 identifier %prec EMPTY
2915 if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't')
2916 $$ = make_typename_type ($1, $2);
2917 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
2918 cp_error ("`%T' is not a class or namespace", $2);
2922 if (TREE_CODE ($$) == TYPE_DECL)
2923 $$ = TREE_TYPE ($$);
2926 | typename_sub1 template_type %prec EMPTY
2927 { $$ = TREE_TYPE ($2); }
2928 | typename_sub1 explicit_template_type %prec EMPTY
2929 { $$ = make_typename_type ($1, $2); }
2930 | typename_sub1 TEMPLATE explicit_template_type %prec EMPTY
2931 { $$ = make_typename_type ($1, $3); }
2937 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2938 cp_error ("`%T' is not a class or namespace", $1);
2940 | typename_sub1 typename_sub2
2942 if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't')
2943 $$ = make_typename_type ($1, $2);
2944 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
2945 cp_error ("`%T' is not a class or namespace", $2);
2949 if (TREE_CODE ($$) == TYPE_DECL)
2950 $$ = TREE_TYPE ($$);
2953 | typename_sub1 explicit_template_type SCOPE
2954 { got_scope = $$ = make_typename_type ($1, $2); }
2955 | typename_sub1 TEMPLATE explicit_template_type SCOPE
2956 { got_scope = $$ = make_typename_type ($1, $3); }
2962 if (TREE_CODE ($1) != IDENTIFIER_NODE)
2965 /* Retrieve the type for the identifier, which might involve
2966 some computation. */
2967 got_scope = $$ = complete_type (IDENTIFIER_TYPE_VALUE ($1));
2969 if ($$ == error_mark_node)
2970 cp_error ("`%T' is not a class or namespace", $1);
2974 if (TREE_CODE ($1) != IDENTIFIER_NODE)
2976 got_scope = $$ = complete_type (TREE_TYPE ($$));
2978 | template_type SCOPE
2979 { got_scope = $$ = complete_type (TREE_TYPE ($$)); }
2984 if (TREE_CODE ($$) == IDENTIFIER_NODE)
2990 explicit_template_type:
2991 identifier '<' template_arg_list_opt template_close_bracket
2992 { $$ = build_min_nt (TEMPLATE_ID_EXPR, $1, $3); }
2996 global_scope type_name
2998 if (TREE_CODE ($2) == IDENTIFIER_NODE)
2999 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
3002 got_scope = NULL_TREE;
3005 | global_scope nested_type
3010 nested_name_specifier '*'
3011 { got_scope = NULL_TREE; }
3012 | global_scope nested_name_specifier '*'
3013 { $$ = $2; got_scope = NULL_TREE; }
3016 /* All uses of explicit global scope must go through this nonterminal so
3017 that got_scope will be set before yylex is called to get the next token. */
3020 { got_scope = void_type_node; }
3023 /* ANSI new-declarator (5.3.4) */
3025 '*' cv_qualifiers new_declarator
3026 { $$ = make_pointer_declarator ($2, $3); }
3027 | '*' cv_qualifiers %prec EMPTY
3028 { $$ = make_pointer_declarator ($2, NULL_TREE); }
3029 | '&' cv_qualifiers new_declarator %prec EMPTY
3030 { $$ = make_reference_declarator ($2, $3); }
3031 | '&' cv_qualifiers %prec EMPTY
3032 { $$ = make_reference_declarator ($2, NULL_TREE); }
3033 | ptr_to_mem cv_qualifiers %prec EMPTY
3034 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3035 $$ = build_parse_node (SCOPE_REF, $1, arg);
3037 | ptr_to_mem cv_qualifiers new_declarator
3038 { tree arg = make_pointer_declarator ($2, $3);
3039 $$ = build_parse_node (SCOPE_REF, $1, arg);
3041 | direct_new_declarator %prec EMPTY
3044 /* ANSI direct-new-declarator (5.3.4) */
3045 direct_new_declarator:
3047 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3048 | direct_new_declarator '[' nonmomentary_expr ']'
3049 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3052 /* ANSI abstract-declarator (8.1) */
3054 '*' nonempty_cv_qualifiers absdcl
3055 { $$ = make_pointer_declarator ($2.t, $3); }
3057 { $$ = make_pointer_declarator (NULL_TREE, $2); }
3058 | '*' nonempty_cv_qualifiers %prec EMPTY
3059 { $$ = make_pointer_declarator ($2.t, NULL_TREE); }
3061 { $$ = make_pointer_declarator (NULL_TREE, NULL_TREE); }
3062 | '&' nonempty_cv_qualifiers absdcl
3063 { $$ = make_reference_declarator ($2.t, $3); }
3065 { $$ = make_reference_declarator (NULL_TREE, $2); }
3066 | '&' nonempty_cv_qualifiers %prec EMPTY
3067 { $$ = make_reference_declarator ($2.t, NULL_TREE); }
3069 { $$ = make_reference_declarator (NULL_TREE, NULL_TREE); }
3070 | ptr_to_mem cv_qualifiers %prec EMPTY
3071 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3072 $$ = build_parse_node (SCOPE_REF, $1, arg);
3074 | ptr_to_mem cv_qualifiers absdcl
3075 { tree arg = make_pointer_declarator ($2, $3);
3076 $$ = build_parse_node (SCOPE_REF, $1, arg);
3078 | direct_abstract_declarator %prec EMPTY
3081 /* ANSI direct-abstract-declarator (8.1) */
3082 direct_abstract_declarator:
3085 /* `(typedef)1' is `int'. */
3087 | direct_abstract_declarator '(' parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3088 { $$ = make_call_declarator ($$, $3, $5, $6); }
3089 | direct_abstract_declarator LEFT_RIGHT cv_qualifiers exception_specification_opt %prec '.'
3090 { $$ = make_call_declarator ($$, empty_parms (), $3, $4); }
3091 | direct_abstract_declarator '[' nonmomentary_expr ']' %prec '.'
3092 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3093 | direct_abstract_declarator '[' ']' %prec '.'
3094 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
3095 | '(' complex_parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3096 { $$ = make_call_declarator (NULL_TREE, $2, $4, $5); }
3097 | regcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3098 { set_quals_and_spec ($$, $2, $3); }
3099 | fcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3100 { set_quals_and_spec ($$, $2, $3); }
3101 | '[' nonmomentary_expr ']' %prec '.'
3102 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3104 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, NULL_TREE); }
3107 /* For C++, decls and stmts can be intermixed, so we don't need to
3108 have a special rule that won't start parsing the stmt section
3109 until we have a stmt that parses without errors. */
3122 /* Read zero or more forward-declarations for labels
3123 that nested functions can jump to. */
3128 pedwarn ("ANSI C++ forbids label declarations"); }
3133 | label_decls label_decl
3137 LABEL identifiers_or_typenames ';'
3139 for (link = $2; link; link = TREE_CHAIN (link))
3141 tree label = shadow_label (TREE_VALUE (link));
3142 C_DECLARED_LABEL_FLAG (label) = 1;
3143 declare_nonlocal_label (label);
3148 /* This is the body of a function definition.
3149 It causes syntax errors to ignore to the next openbrace. */
3158 { $<ttype>$ = begin_compound_stmt (0); }
3160 { $$ = finish_compound_stmt (0, $<ttype>2); }
3166 $<ttype>$ = begin_if_stmt ();
3167 cond_stmt_keyword = "if";
3170 { finish_if_stmt_cond ($3, $<ttype>2); }
3171 implicitly_scoped_stmt
3172 { $<ttype>$ = finish_then_clause ($<ttype>2); }
3175 implicitly_scoped_stmt:
3177 | { $<ttype>$ = begin_compound_stmt (0); }
3179 { $$ = finish_compound_stmt (0, $<ttype>1); }
3192 { finish_expr_stmt ($1); }
3194 { begin_else_clause (); }
3195 implicitly_scoped_stmt
3197 finish_else_clause ($<ttype>1);
3200 | simple_if %prec IF
3201 { finish_if_stmt (); }
3204 $<ttype>$ = begin_while_stmt ();
3205 cond_stmt_keyword = "while";
3208 { finish_while_stmt_cond ($3, $<ttype>2); }
3210 { finish_while_stmt ($<ttype>2); }
3212 { $<ttype>$ = begin_do_stmt (); }
3213 implicitly_scoped_stmt WHILE
3215 finish_do_body ($<ttype>2);
3216 cond_stmt_keyword = "do";
3218 paren_expr_or_null ';'
3219 { finish_do_stmt ($6, $<ttype>2); }
3221 { $<ttype>$ = begin_for_stmt (); }
3222 '(' for.init.statement
3223 { finish_for_init_stmt ($<ttype>2); }
3225 { finish_for_cond ($6, $<ttype>2); }
3227 { finish_for_expr ($9, $<ttype>2); }
3229 { finish_for_stmt ($9, $<ttype>2); }
3231 { begin_switch_stmt (); }
3233 { $<ttype>$ = finish_switch_cond ($4); }
3234 implicitly_scoped_stmt
3235 { finish_switch_stmt ($4, $<ttype>6); }
3236 | CASE expr_no_commas ':'
3237 { finish_case_label ($2, NULL_TREE); }
3239 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
3240 { finish_case_label ($2, $4); }
3243 { finish_case_label (NULL_TREE, NULL_TREE); }
3246 { finish_break_stmt (); }
3248 { finish_continue_stmt (); }
3250 { finish_return_stmt (NULL_TREE); }
3252 { finish_return_stmt ($2); }
3253 | asm_keyword maybe_cv_qualifier '(' string ')' ';'
3255 finish_asm_stmt ($2, $4, NULL_TREE, NULL_TREE,
3258 /* This is the case with just output operands. */
3259 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ')' ';'
3261 finish_asm_stmt ($2, $4, $6, NULL_TREE,
3264 /* This is the case with input operands as well. */
3265 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':' asm_operands ')' ';'
3266 { finish_asm_stmt ($2, $4, $6, $8, NULL_TREE); }
3267 /* This is the case with clobbered registers as well. */
3268 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':'
3269 asm_operands ':' asm_clobbers ')' ';'
3270 { finish_asm_stmt ($2, $4, $6, $8, $10); }
3274 pedwarn ("ANSI C++ forbids computed gotos");
3275 finish_goto_stmt ($3);
3277 | GOTO identifier ';'
3278 { finish_goto_stmt ($2); }
3282 { error ("label must be followed by statement");
3289 | namespace_using_decl
3290 { do_local_using_decl ($1); }
3296 if (! current_function_parms_stored)
3297 store_parm_decls ();
3298 expand_start_early_try_stmts ();
3300 ctor_initializer_opt compstmt
3302 expand_start_all_catch ();
3306 int nested = (hack_decl_function_context
3307 (current_function_decl) != NULL_TREE);
3308 expand_end_all_catch ();
3309 finish_function (lineno, (int)$3, nested);
3315 { $<ttype>$ = begin_try_block (); }
3317 { finish_try_block ($<ttype>2); }
3319 { finish_handler_sequence ($<ttype>2); }
3324 | handler_seq handler
3329 { $<ttype>$ = begin_handler(); }
3331 { finish_handler_parms ($<ttype>2); }
3333 { finish_handler ($<ttype>2); }
3337 typed_typespecs %prec EMPTY
3338 | nonempty_cv_qualifiers %prec EMPTY
3343 { expand_start_catch_block (NULL_TREE, NULL_TREE); }
3344 /* This doesn't allow reference parameters, the below does.
3345 | '(' type_specifier_seq absdcl ')'
3346 { check_for_new_type ("inside exception declarations", $2);
3347 expand_start_catch_block ($2.t, $3); }
3348 | '(' type_specifier_seq ')'
3349 { check_for_new_type ("inside exception declarations", $2);
3350 expand_start_catch_block ($2.t, NULL_TREE); }
3351 | '(' type_specifier_seq notype_declarator ')'
3352 { check_for_new_type ("inside exception declarations", $2);
3353 expand_start_catch_block ($2.t, $3); }
3354 | '(' typed_typespecs after_type_declarator ')'
3355 { check_for_new_type ("inside exception declarations", $2);
3356 expand_start_catch_block ($2.t, $3); }
3357 This allows reference parameters... */
3359 { check_for_new_type ("inside exception declarations", $2);
3360 expand_start_catch_block (TREE_PURPOSE ($2.t),
3361 TREE_VALUE ($2.t)); }
3368 label = define_label (input_filename, lineno, $1);
3369 if (label && ! minimal_parse_mode)
3370 expand_label (label);
3382 { if ($1) cplus_expand_expr_stmt ($1); }
3386 pedwarn ("ANSI C++ forbids compound statements inside for initializations");
3390 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
3394 { emit_line_note (input_filename, lineno);
3397 { emit_line_note (input_filename, lineno); }
3408 /* These are the operands other than the first string and colon
3409 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
3413 | nonnull_asm_operands
3416 nonnull_asm_operands:
3418 | nonnull_asm_operands ',' asm_operand
3419 { $$ = chainon ($$, $3); }
3424 { $$ = build_tree_list ($$, $3); }
3429 { $$ = tree_cons (NULL_TREE, $$, NULL_TREE); }
3430 | asm_clobbers ',' STRING
3431 { $$ = tree_cons (NULL_TREE, $3, $$); }
3434 /* This is what appears inside the parens in a function declarator.
3435 Its value is represented in the format that grokdeclarator expects.
3437 In C++, declaring a function with no parameters
3438 means that that function takes *no* parameters. */
3447 { $$ = finish_parmlist (build_tree_list (NULL_TREE, $1.t), 0);
3448 check_for_new_type ("inside parameter list", $1); }
3451 /* This nonterminal does not include the common sequence '(' type_id ')',
3452 as it is ambiguous and must be disambiguated elsewhere. */
3455 { $$ = finish_parmlist ($$, 0); }
3456 | parms_comma ELLIPSIS
3457 { $$ = finish_parmlist ($1, 1); }
3458 /* C++ allows an ellipsis without a separating ',' */
3460 { $$ = finish_parmlist ($1, 1); }
3462 { $$ = finish_parmlist (build_tree_list (NULL_TREE,
3465 { $$ = finish_parmlist (NULL_TREE, 1); }
3468 /* This helps us recover from really nasty
3469 parse errors, for example, a missing right
3471 yyerror ("possibly missing ')'");
3472 $$ = finish_parmlist ($1, 0);
3478 /* This helps us recover from really nasty
3479 parse errors, for example, a missing right
3481 yyerror ("possibly missing ')'");
3482 $$ = finish_parmlist (build_tree_list (NULL_TREE,
3489 /* A default argument to a */
3492 { maybe_snarf_defarg (); }
3502 /* A nonempty list of parameter declarations or type names. */
3505 { check_for_new_type ("in a parameter list", $1);
3506 $$ = build_tree_list (NULL_TREE, $1.t); }
3508 { check_for_new_type ("in a parameter list", $1);
3509 $$ = build_tree_list ($2, $1.t); }
3510 | parms_comma full_parm
3511 { check_for_new_type ("in a parameter list", $2);
3512 $$ = chainon ($$, $2.t); }
3513 | parms_comma bad_parm
3514 { $$ = chainon ($$, build_tree_list (NULL_TREE, $2)); }
3515 | parms_comma bad_parm '=' init
3516 { $$ = chainon ($$, build_tree_list ($4, $2)); }
3522 { check_for_new_type ("in a parameter list", $1);
3523 $$ = build_tree_list (NULL_TREE, $1.t); }
3526 /* A single parameter declaration or parameter type name,
3527 as found in a parmlist. */
3529 /* Here we expand typed_declspecs inline to avoid mis-parsing of
3530 TYPESPEC IDENTIFIER. */
3531 typed_declspecs1 declarator
3532 { tree specs = strip_attrs ($1.t);
3533 $$.new_type_flag = $1.new_type_flag;
3534 $$.t = build_tree_list (specs, $2); }
3535 | typed_typespecs declarator
3536 { $$.t = build_tree_list ($1.t, $2);
3537 $$.new_type_flag = $1.new_type_flag; }
3538 | typespec declarator
3539 { $$.t = build_tree_list (get_decl_list ($1.t), $2);
3540 $$.new_type_flag = $1.new_type_flag; }
3541 | typed_declspecs1 absdcl
3542 { tree specs = strip_attrs ($1.t);
3543 $$.t = build_tree_list (specs, $2);
3544 $$.new_type_flag = $1.new_type_flag; }
3545 | typed_declspecs1 %prec EMPTY
3546 { tree specs = strip_attrs ($1.t);
3547 $$.t = build_tree_list (specs, NULL_TREE);
3548 $$.new_type_flag = $1.new_type_flag; }
3549 | declmods notype_declarator
3550 { tree specs = strip_attrs ($1);
3551 $$.t = build_tree_list (specs, $2);
3552 $$.new_type_flag = 0; }
3557 { $$.t = build_tree_list (NULL_TREE, $1.t);
3558 $$.new_type_flag = $1.new_type_flag; }
3560 { $$.t = build_tree_list ($2, $1.t);
3561 $$.new_type_flag = $1.new_type_flag; }
3570 /* empty */ %prec EMPTY
3571 { see_typename (); }
3575 /* empty */ %prec EMPTY
3577 error ("type specifier omitted for parameter");
3578 $$ = build_tree_list (integer_type_node, NULL_TREE);
3582 error ("type specifier omitted for parameter");
3583 if (TREE_CODE ($$) == SCOPE_REF
3584 && (TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TYPE_PARM
3585 || TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TEMPLATE_PARM))
3586 cp_error (" perhaps you want `typename %E' to make it a type", $$);
3587 $$ = build_tree_list (integer_type_node, $$);
3591 exception_specification_opt:
3592 /* empty */ %prec EMPTY
3594 | THROW '(' ansi_raise_identifiers ')' %prec EMPTY
3596 | THROW LEFT_RIGHT %prec EMPTY
3597 { $$ = build_decl_list (NULL_TREE, NULL_TREE); }
3600 ansi_raise_identifier:
3602 { $$ = build_decl_list (NULL_TREE, groktypename($1.t)); }
3605 ansi_raise_identifiers:
3606 ansi_raise_identifier
3607 | ansi_raise_identifiers ',' ansi_raise_identifier
3609 TREE_CHAIN ($3) = $$;
3614 conversion_declarator:
3615 /* empty */ %prec EMPTY
3617 | '*' cv_qualifiers conversion_declarator
3618 { $$ = make_pointer_declarator ($2, $3); }
3619 | '&' cv_qualifiers conversion_declarator
3620 { $$ = make_reference_declarator ($2, $3); }
3621 | ptr_to_mem cv_qualifiers conversion_declarator
3622 { tree arg = make_pointer_declarator ($2, $3);
3623 $$ = build_parse_node (SCOPE_REF, $1, arg);
3629 { got_scope = NULL_TREE; }
3634 { $$ = ansi_opname[MULT_EXPR]; }
3636 { $$ = ansi_opname[TRUNC_DIV_EXPR]; }
3638 { $$ = ansi_opname[TRUNC_MOD_EXPR]; }
3640 { $$ = ansi_opname[PLUS_EXPR]; }
3642 { $$ = ansi_opname[MINUS_EXPR]; }
3644 { $$ = ansi_opname[BIT_AND_EXPR]; }
3646 { $$ = ansi_opname[BIT_IOR_EXPR]; }
3648 { $$ = ansi_opname[BIT_XOR_EXPR]; }
3650 { $$ = ansi_opname[BIT_NOT_EXPR]; }
3652 { $$ = ansi_opname[COMPOUND_EXPR]; }
3653 | operator ARITHCOMPARE
3654 { $$ = ansi_opname[$2]; }
3656 { $$ = ansi_opname[LT_EXPR]; }
3658 { $$ = ansi_opname[GT_EXPR]; }
3659 | operator EQCOMPARE
3660 { $$ = ansi_opname[$2]; }
3662 { $$ = ansi_assopname[$2]; }
3664 { $$ = ansi_opname [MODIFY_EXPR]; }
3666 { $$ = ansi_opname[$2]; }
3668 { $$ = ansi_opname[$2]; }
3670 { $$ = ansi_opname[POSTINCREMENT_EXPR]; }
3671 | operator MINUSMINUS
3672 { $$ = ansi_opname[PREDECREMENT_EXPR]; }
3674 { $$ = ansi_opname[TRUTH_ANDIF_EXPR]; }
3676 { $$ = ansi_opname[TRUTH_ORIF_EXPR]; }
3678 { $$ = ansi_opname[TRUTH_NOT_EXPR]; }
3680 { $$ = ansi_opname[COND_EXPR]; }
3682 { $$ = ansi_opname[$2]; }
3683 | operator POINTSAT %prec EMPTY
3684 { $$ = ansi_opname[COMPONENT_REF]; }
3685 | operator POINTSAT_STAR %prec EMPTY
3686 { $$ = ansi_opname[MEMBER_REF]; }
3687 | operator LEFT_RIGHT
3688 { $$ = ansi_opname[CALL_EXPR]; }
3690 { $$ = ansi_opname[ARRAY_REF]; }
3691 | operator NEW %prec EMPTY
3692 { $$ = ansi_opname[NEW_EXPR]; }
3693 | operator DELETE %prec EMPTY
3694 { $$ = ansi_opname[DELETE_EXPR]; }
3695 | operator NEW '[' ']'
3696 { $$ = ansi_opname[VEC_NEW_EXPR]; }
3697 | operator DELETE '[' ']'
3698 { $$ = ansi_opname[VEC_DELETE_EXPR]; }
3699 /* Names here should be looked up in class scope ALSO. */
3700 | operator type_specifier_seq conversion_declarator
3701 { $$ = grokoptypename ($2.t, $3); }
3703 { $$ = ansi_opname[ERROR_MARK]; }
3710 debug_yytranslate (value)
3713 return yytname[YYTRANSLATE (value)];