1 /* YACC parser for C++ syntax.
2 Copyright (C) 1988, 89, 93-98, 1999 Free Software Foundation, Inc.
3 Hacked by Michael Tiemann (tiemann@cygnus.com)
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 struct obstack permanent_obstack;
52 extern int end_of_file;
54 /* Like YYERROR but do call yyerror. */
55 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
57 #define OP0(NODE) (TREE_OPERAND (NODE, 0))
58 #define OP1(NODE) (TREE_OPERAND (NODE, 1))
60 /* Contains the statement keyword (if/while/do) to include in an
61 error message if the user supplies an empty conditional expression. */
62 static const char *cond_stmt_keyword;
64 static tree empty_parms PROTO((void));
65 static int parse_decl PROTO((tree, tree, tree, int, tree *));
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_KEYWORD GOTO ASM_KEYWORD TYPEOF ALIGNOF
135 %token ATTRIBUTE EXTENSION LABEL
136 %token REALPART IMAGPART VA_ARG
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> 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> notype_declarator_intern absdcl_intern
207 %type <ttype> after_type_declarator_intern
208 %type <ttype> direct_notype_declarator direct_after_type_declarator
209 %type <itype> components notype_components
210 %type <ttype> component_decl component_decl_1
211 %type <ttype> component_declarator component_declarator0
212 %type <ttype> notype_component_declarator notype_component_declarator0
213 %type <ttype> after_type_component_declarator after_type_component_declarator0
214 %type <ttype> enumlist_opt enumlist enumerator
215 %type <ttype> absdcl cv_qualifiers
216 %type <ttype> direct_abstract_declarator conversion_declarator
217 %type <ttype> new_declarator direct_new_declarator
218 %type <ttype> xexpr parmlist parms bad_parm
219 %type <ttype> identifiers_or_typenames
220 %type <ttype> fcast_or_absdcl regcast_or_absdcl
221 %type <ttype> expr_or_declarator expr_or_declarator_intern
222 %type <ttype> complex_notype_declarator
223 %type <ttype> notype_unqualified_id unqualified_id qualified_id
224 %type <ttype> template_id do_id object_template_id notype_template_declarator
225 %type <ttype> overqualified_id notype_qualified_id any_id
226 %type <ttype> complex_direct_notype_declarator functional_cast
227 %type <ttype> complex_parmlist parms_comma
228 %type <ttype> namespace_qualifier namespace_using_decl
230 %type <ftype> type_id new_type_id typed_typespecs typespec typed_declspecs
231 %type <ftype> typed_declspecs1 type_specifier_seq nonempty_cv_qualifiers
232 %type <ftype> structsp typespecqual_reserved parm named_parm full_parm
235 %token <ttype> PTYPENAME
236 %token <ttype> PRE_PARSED_FUNCTION_DECL EXTERN_LANG_STRING ALL
237 %token <ttype> PRE_PARSED_CLASS_DECL DEFARG DEFARG_MARKER
238 %type <ttype> component_constructor_declarator
239 %type <ttype> fn.def2 return_id fn.defpen constructor_declarator
240 %type <itype> ctor_initializer_opt function_try_block
241 %type <ttype> named_class_head_sans_basetype
242 %type <ftype> class_head named_class_head
243 %type <ftype> named_complex_class_head_sans_basetype
244 %type <ttype> unnamed_class_head
245 %type <ttype> base_class_list
246 %type <ttype> base_class_access_list
247 %type <ttype> base_class maybe_base_class_list base_class.1
248 %type <ttype> exception_specification_opt ansi_raise_identifier ansi_raise_identifiers
249 %type <ttype> operator_name
250 %type <ttype> object aggr
251 %type <itype> new delete .begin_new_placement
252 /* %type <ttype> primary_no_id */
253 %type <ttype> nonmomentary_expr maybe_parmlist
254 %type <itype> initdcl0 notype_initdcl0 member_init_list initdcl0_innards
255 %type <ttype> template_header template_parm_list template_parm
256 %type <ttype> template_type_parm template_template_parm
257 %type <code> template_close_bracket
258 %type <ttype> apparent_template_type
259 %type <ttype> template_type template_arg_list template_arg_list_opt
260 %type <ttype> template_arg
261 %type <ttype> condition xcond paren_cond_or_null
262 %type <ttype> type_name nested_name_specifier nested_type ptr_to_mem
263 %type <ttype> complete_type_name notype_identifier nonnested_type
264 %type <ttype> complex_type_name nested_name_specifier_1
265 %type <ttype> new_initializer new_placement
266 %type <ttype> using_decl
267 %type <ttype> typename_sub typename_sub0 typename_sub1 typename_sub2
268 %type <ttype> explicit_template_type
269 /* in order to recognize aggr tags as defining and thus shadowing. */
270 %token TYPENAME_DEFN IDENTIFIER_DEFN PTYPENAME_DEFN
271 %type <ttype> named_class_head_sans_basetype_defn
272 %type <ttype> identifier_defn IDENTIFIER_DEFN TYPENAME_DEFN PTYPENAME_DEFN
274 %type <ttype> self_template_type .finish_template_type
279 /* Used in lex.c for parsing pragmas. */
282 /* lex.c and pt.c depend on this being the last token. Define
283 any new tokens before this one! */
284 %token END_OF_SAVED_INPUT
287 /* List of types and structure classes of the current declaration. */
288 static tree current_declspecs;
290 /* List of prefix attributes in effect.
291 Prefix attributes are parsed by the reserved_declspecs and declmods
292 rules. They create a list that contains *both* declspecs and attrs. */
293 /* ??? It is not clear yet that all cases where an attribute can now appear in
294 a declspec list have been updated. */
295 static tree prefix_attributes;
297 /* When defining an aggregate, this is the kind of the most recent one
298 being defined. (For example, this might be class_type_node.) */
299 static tree current_aggr;
301 /* When defining an enumeration, this is the type of the enumeration. */
302 static tree current_enum_type;
304 /* Tell yyparse how to print a token's value, if yydebug is set. */
306 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
307 extern void yyprint PROTO((FILE *, int, YYSTYPE));
308 extern tree combine_strings PROTO((tree));
311 parse_decl(declarator, specs_attrs, attributes, initialized, decl)
320 split_specs_attrs (specs_attrs, ¤t_declspecs, &prefix_attributes);
321 if (current_declspecs
322 && TREE_CODE (current_declspecs) != TREE_LIST)
323 current_declspecs = build_decl_list (NULL_TREE, current_declspecs);
324 if (have_extern_spec && !used_extern_spec)
326 current_declspecs = decl_tree_cons (NULL_TREE,
327 get_identifier ("extern"),
329 used_extern_spec = 1;
331 sm = suspend_momentary ();
332 *decl = start_decl (declarator, current_declspecs, initialized,
333 attributes, prefix_attributes);
342 { finish_translation_unit (); }
345 /* the reason for the strange actions in this rule
346 is so that notype_initdecls when reached via datadef
347 can find a valid list of type and sc specs in $0. */
350 { $<ttype>$ = NULL_TREE; }
352 { $<ttype>$ = NULL_TREE; }
353 | extdefs lang_extdef
354 { $<ttype>$ = NULL_TREE; }
363 { have_extern_spec = 1;
364 used_extern_spec = 0;
365 $<ttype>$ = NULL_TREE; }
368 { have_extern_spec = 0; }
373 { $<itype>$ = pedantic;
382 { if (pending_lang_change) do_pending_lang_change(); }
384 { if (! toplevel_bindings_p () && ! pseudo_global_level_p())
389 fndef eat_saved_input
390 { if (pending_inlines) do_pending_inlines (); }
392 { if (pending_inlines) do_pending_inlines (); }
394 { if (pending_inlines) do_pending_inlines (); }
395 | asm_keyword '(' string ')' ';'
396 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
398 | extern_lang_string '{' extdefs_opt '}'
399 { pop_lang_context (); }
400 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
401 { if (pending_inlines) do_pending_inlines ();
402 pop_lang_context (); }
403 | extern_lang_string .hush_warning datadef .warning_ok
404 { if (pending_inlines) do_pending_inlines ();
405 pop_lang_context (); }
406 | NAMESPACE identifier '{'
407 { push_namespace ($2); }
409 { pop_namespace (); }
411 { push_namespace (NULL_TREE); }
413 { pop_namespace (); }
416 { do_toplevel_using_decl ($1); }
419 { pedantic = $<itype>1; }
423 NAMESPACE identifier '='
424 { begin_only_namespace_names (); }
427 end_only_namespace_names ();
430 do_namespace_alias ($2, $5);
437 | USING global_scope qualified_id
439 | USING global_scope unqualified_id
443 namespace_using_decl:
444 USING namespace_qualifier identifier
445 { $$ = build_parse_node (SCOPE_REF, $2, $3); }
446 | USING global_scope identifier
447 { $$ = build_parse_node (SCOPE_REF, global_namespace, $3); }
448 | USING global_scope namespace_qualifier identifier
449 { $$ = build_parse_node (SCOPE_REF, $3, $4); }
454 { begin_only_namespace_names (); }
457 end_only_namespace_names ();
458 /* If no declaration was found, the using-directive is
459 invalid. Since that was not reported, we need the
460 identifier for the error message. */
461 if (TREE_CODE ($4) == IDENTIFIER_NODE && lastiddecl)
463 do_using_directive ($4);
470 if (TREE_CODE ($$) == IDENTIFIER_NODE)
474 | namespace_qualifier NSNAME SCOPE
477 if (TREE_CODE ($$) == IDENTIFIER_NODE)
485 | global_scope qualified_id
487 | global_scope unqualified_id
493 { push_lang_context ($1); }
494 | extern_lang_string EXTERN_LANG_STRING
495 { if (current_lang_name != $2)
496 cp_error ("use of linkage spec `%D' is different from previous spec `%D'", $2, current_lang_name);
497 pop_lang_context (); push_lang_context ($2); }
502 { begin_template_parm_list (); }
503 template_parm_list '>'
504 { $$ = end_template_parm_list ($4); }
506 { begin_specialization();
512 { $$ = process_template_parm (NULL_TREE, $1); }
513 | template_parm_list ',' template_parm
514 { $$ = process_template_parm ($1, $3); }
524 aggr maybe_identifier
525 { $$ = finish_template_type_parm ($1, $2); }
526 | TYPENAME_KEYWORD maybe_identifier
527 { $$ = finish_template_type_parm (class_type_node, $2); }
530 template_template_parm:
531 template_header aggr maybe_identifier
532 { $$ = finish_template_template_parm ($2, $3); }
536 /* The following rules introduce a new reduce/reduce
537 conflict on the ',' and '>' input tokens: they are valid
538 prefixes for a `structsp', which means they could match a
539 nameless parameter. See 14.6, paragraph 3.
540 By putting them before the `parm' rule, we get
541 their match before considering them nameless parameter
544 { $$ = build_tree_list (NULL_TREE, $1); }
545 | template_type_parm '=' type_id
546 { $$ = build_tree_list (groktypename ($3.t), $1); }
548 { $$ = build_tree_list (NULL_TREE, $1.t); }
549 | parm '=' expr_no_commas %prec ARITHCOMPARE
550 { $$ = build_tree_list ($3, $1.t); }
551 | template_template_parm
552 { $$ = build_tree_list (NULL_TREE, $1); }
553 | template_template_parm '=' template_arg
555 if (TREE_CODE ($3) != TEMPLATE_DECL
556 && TREE_CODE ($3) != TEMPLATE_TEMPLATE_PARM
557 && TREE_CODE ($3) != TYPE_DECL)
559 error ("invalid default template argument");
560 $3 = error_mark_node;
562 $$ = build_tree_list ($3, $1);
567 template_header template_extdef
568 { finish_template_decl ($1); }
569 | template_header error %prec EMPTY
570 { finish_template_decl ($1); }
574 fndef eat_saved_input
575 { if (pending_inlines) do_pending_inlines (); }
577 { if (pending_inlines) do_pending_inlines (); }
579 { if (pending_inlines) do_pending_inlines (); }
580 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
581 { if (pending_inlines) do_pending_inlines ();
582 pop_lang_context (); }
583 | extern_lang_string .hush_warning template_datadef .warning_ok
584 { if (pending_inlines) do_pending_inlines ();
585 pop_lang_context (); }
586 | extension template_extdef
587 { pedantic = $<itype>1; }
592 | declmods notype_initdecls ';'
594 | typed_declspecs initdecls ';'
595 { note_list_got_semicolon ($1.t); }
597 { maybe_process_partial_specialization ($1.t);
598 note_got_semicolon ($1.t); }
603 | declmods notype_initdecls ';'
605 | typed_declspecs initdecls ';'
606 { note_list_got_semicolon ($1.t); }
608 { pedwarn ("empty declaration"); }
609 | explicit_instantiation ';'
610 | typed_declspecs ';'
613 split_specs_attrs ($1.t, &t, &attrs);
615 note_list_got_semicolon ($1.t);
622 ctor_initializer_opt:
641 fn.def1 maybe_return_init ctor_initializer_opt compstmt_or_error
642 { finish_function (lineno, (int)$3, 0); }
643 | fn.def1 maybe_return_init function_try_block
645 int nested = (hack_decl_function_context
646 (current_function_decl) != NULL_TREE);
647 finish_function (lineno, (int)$3, nested);
649 | fn.def1 maybe_return_init error
653 constructor_declarator:
654 nested_name_specifier SELFNAME '('
655 { $$ = begin_constructor_declarator ($1, $2); }
656 parmlist ')' cv_qualifiers exception_specification_opt
657 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
658 | nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
659 { $$ = begin_constructor_declarator ($1, $2);
660 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
662 | global_scope nested_name_specifier SELFNAME '('
663 { $$ = begin_constructor_declarator ($2, $3); }
664 parmlist ')' cv_qualifiers exception_specification_opt
665 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
666 | global_scope nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
667 { $$ = begin_constructor_declarator ($2, $3);
668 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
670 | nested_name_specifier self_template_type '('
671 { $$ = begin_constructor_declarator ($1, $2); }
672 parmlist ')' cv_qualifiers exception_specification_opt
673 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
674 | nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
675 { $$ = begin_constructor_declarator ($1, $2);
676 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
678 | global_scope nested_name_specifier self_template_type '('
679 { $$ = begin_constructor_declarator ($2, $3); }
680 parmlist ')' cv_qualifiers exception_specification_opt
681 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
682 | global_scope nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
683 { $$ = begin_constructor_declarator ($2, $3);
684 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
689 typed_declspecs declarator
690 { if (!begin_function_definition ($1.t, $2))
692 | declmods notype_declarator
693 { if (!begin_function_definition ($1, $2))
696 { if (!begin_function_definition (NULL_TREE, $1))
698 | declmods constructor_declarator
699 { if (!begin_function_definition ($1, $2))
701 | constructor_declarator
702 { if (!begin_function_definition (NULL_TREE, $1))
706 component_constructor_declarator:
707 SELFNAME '(' parmlist ')' cv_qualifiers exception_specification_opt
708 { $$ = make_call_declarator ($1, $3, $5, $6); }
709 | SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
710 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
711 | self_template_type '(' parmlist ')' cv_qualifiers exception_specification_opt
712 { $$ = make_call_declarator ($1, $3, $5, $6); }
713 | self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
714 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
717 /* more C++ complexity. See component_decl for a comment on the
718 reduce/reduce conflict introduced by these rules. */
720 declmods component_constructor_declarator
722 split_specs_attrs ($1, &specs, &attrs);
723 attrs = build_tree_list (attrs, NULL_TREE);
724 $$ = start_method (specs, $2, attrs);
728 if (yychar == YYEMPTY)
730 reinit_parse_for_method (yychar, $$); }
731 | component_constructor_declarator
732 { $$ = start_method (NULL_TREE, $1, NULL_TREE);
734 | typed_declspecs declarator
736 split_specs_attrs ($1.t, &specs, &attrs);
737 attrs = build_tree_list (attrs, NULL_TREE);
738 $$ = start_method (specs, $2, attrs); goto rest_of_mdef; }
739 | declmods notype_declarator
741 split_specs_attrs ($1, &specs, &attrs);
742 attrs = build_tree_list (attrs, NULL_TREE);
743 $$ = start_method (specs, $2, attrs); goto rest_of_mdef; }
745 { $$ = start_method (NULL_TREE, $$, NULL_TREE);
747 | declmods constructor_declarator
749 split_specs_attrs ($1, &specs, &attrs);
750 attrs = build_tree_list (attrs, NULL_TREE);
751 $$ = start_method (specs, $2, attrs); goto rest_of_mdef; }
752 | constructor_declarator
753 { $$ = start_method (NULL_TREE, $$, NULL_TREE);
758 RETURN_KEYWORD IDENTIFIER
760 if (! current_function_parms_stored)
768 { store_return_init ($<ttype>$, $2); }
769 | return_id '(' nonnull_exprlist ')'
770 { store_return_init ($<ttype>$, $3); }
771 | return_id LEFT_RIGHT
772 { store_return_init ($<ttype>$, NULL_TREE); }
776 ':' .set_base_init member_init_list
779 error ("no base initializers given following ':'");
781 /* Always keep the BLOCK node associated with the outermost
782 pair of curley braces of a function. These are needed
783 for correct operation of dwarfout.c. */
791 if (! current_function_parms_stored)
794 if (DECL_CONSTRUCTOR_P (current_function_decl))
796 /* Make a contour for the initializer list. */
799 expand_start_bindings (0);
801 else if (current_class_type == NULL_TREE)
802 error ("base initializers not allowed for non-member functions");
803 else if (! DECL_CONSTRUCTOR_P (current_function_decl))
804 error ("only constructors take base initializers");
813 | member_init_list ',' member_init
814 | member_init_list error
818 '(' nonnull_exprlist ')'
820 if (current_class_name)
821 pedwarn ("anachronistic old style base class initializer");
822 expand_member_init (current_class_ref, NULL_TREE, $2);
826 if (current_class_name)
827 pedwarn ("anachronistic old style base class initializer");
828 expand_member_init (current_class_ref, NULL_TREE, void_type_node);
830 | notype_identifier '(' nonnull_exprlist ')'
831 { expand_member_init (current_class_ref, $1, $3); }
832 | notype_identifier LEFT_RIGHT
833 { expand_member_init (current_class_ref, $1, void_type_node); }
834 | nonnested_type '(' nonnull_exprlist ')'
835 { expand_member_init (current_class_ref, $1, $3); }
836 | nonnested_type LEFT_RIGHT
837 { expand_member_init (current_class_ref, $1, void_type_node); }
838 | typename_sub '(' nonnull_exprlist ')'
839 { expand_member_init (current_class_ref, TYPE_MAIN_DECL ($1),
841 | typename_sub LEFT_RIGHT
842 { expand_member_init (current_class_ref, TYPE_MAIN_DECL ($1),
866 explicit_instantiation:
867 TEMPLATE begin_explicit_instantiation typespec ';'
868 { do_type_instantiation ($3.t, NULL_TREE);
870 end_explicit_instantiation
871 | TEMPLATE begin_explicit_instantiation typed_declspecs declarator
872 { tree specs = strip_attrs ($3.t);
873 do_decl_instantiation (specs, $4, NULL_TREE); }
874 end_explicit_instantiation
875 | TEMPLATE begin_explicit_instantiation notype_declarator
876 { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
877 end_explicit_instantiation
878 | TEMPLATE begin_explicit_instantiation constructor_declarator
879 { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
880 end_explicit_instantiation
881 | SCSPEC TEMPLATE begin_explicit_instantiation typespec ';'
882 { do_type_instantiation ($4.t, $1);
884 end_explicit_instantiation
885 | SCSPEC TEMPLATE begin_explicit_instantiation typed_declspecs
887 { tree specs = strip_attrs ($4.t);
888 do_decl_instantiation (specs, $5, $1); }
889 end_explicit_instantiation
890 | SCSPEC TEMPLATE begin_explicit_instantiation notype_declarator
891 { do_decl_instantiation (NULL_TREE, $4, $1); }
892 end_explicit_instantiation
893 | SCSPEC TEMPLATE begin_explicit_instantiation constructor_declarator
894 { do_decl_instantiation (NULL_TREE, $4, $1); }
895 end_explicit_instantiation
898 begin_explicit_instantiation:
899 { begin_explicit_instantiation(); }
901 end_explicit_instantiation:
902 { end_explicit_instantiation(); }
904 /* The TYPENAME expansions are to deal with use of a template class name as
905 a template within the class itself, where the template decl is hidden by
906 a type decl. Got all that? */
909 PTYPENAME '<' template_arg_list_opt template_close_bracket
910 .finish_template_type
912 | TYPENAME '<' template_arg_list_opt template_close_bracket
913 .finish_template_type
918 apparent_template_type:
920 | identifier '<' template_arg_list_opt '>'
921 .finish_template_type
925 SELFNAME '<' template_arg_list_opt template_close_bracket
926 .finish_template_type
930 .finish_template_type:
932 if (yychar == YYEMPTY)
935 $$ = finish_template_type ($<ttype>-3, $<ttype>-1,
939 template_close_bracket:
943 /* Handle `Class<Class<Type>>' without space in the `>>' */
944 pedwarn ("`>>' should be `> >' in template class name");
949 template_arg_list_opt:
957 { $$ = build_tree_list (NULL_TREE, $$); }
958 | template_arg_list ',' template_arg
959 { $$ = chainon ($$, build_tree_list (NULL_TREE, $3)); }
964 { $$ = groktypename ($1.t); }
967 | expr_no_commas %prec ARITHCOMPARE
972 { $$ = NEGATE_EXPR; }
974 { $$ = CONVERT_EXPR; }
976 { $$ = PREINCREMENT_EXPR; }
978 { $$ = PREDECREMENT_EXPR; }
980 { $$ = TRUTH_NOT_EXPR; }
985 { $$ = build_x_compound_expr ($$); }
991 { error ("ANSI C++ forbids an empty condition for `%s'",
993 $$ = integer_zero_node; }
1000 { error ("ANSI C++ forbids an empty condition for `%s'",
1002 $$ = integer_zero_node; }
1016 type_specifier_seq declarator maybeasm maybe_attribute '='
1019 for (d = getdecls (); d; d = TREE_CHAIN (d))
1020 if (TREE_CODE (d) == TYPE_DECL) {
1021 tree s = TREE_TYPE (d);
1022 if (TREE_CODE (s) == RECORD_TYPE)
1023 cp_error ("definition of class `%T' in condition", s);
1024 else if (TREE_CODE (s) == ENUMERAL_TYPE)
1025 cp_error ("definition of enum `%T' in condition", s);
1028 current_declspecs = $1.t;
1029 $<itype>5 = suspend_momentary ();
1030 $<ttype>$ = start_decl ($<ttype>2, current_declspecs, 1,
1031 $4, /*prefix_attributes*/ NULL_TREE);
1035 cp_finish_decl ($<ttype>6, $7, $4, 1, LOOKUP_ONLYCONVERTING);
1036 resume_momentary ($<itype>5);
1037 $$ = convert_from_reference ($<ttype>6);
1038 if (TREE_CODE (TREE_TYPE ($$)) == ARRAY_TYPE)
1039 cp_error ("definition of array `%#D' in condition", $$);
1046 | maybe_label_decls stmts '}'
1047 | maybe_label_decls stmts error '}'
1048 | maybe_label_decls error '}'
1051 already_scoped_stmt:
1053 { $<ttype>$ = begin_compound_stmt (1); }
1055 { finish_compound_stmt (1, $<ttype>2); }
1060 nontrivial_exprlist:
1061 expr_no_commas ',' expr_no_commas
1062 { $$ = expr_tree_cons (NULL_TREE, $$,
1063 build_expr_list (NULL_TREE, $3)); }
1064 | expr_no_commas ',' error
1065 { $$ = expr_tree_cons (NULL_TREE, $$,
1066 build_expr_list (NULL_TREE, error_mark_node)); }
1067 | nontrivial_exprlist ',' expr_no_commas
1068 { chainon ($$, build_expr_list (NULL_TREE, $3)); }
1069 | nontrivial_exprlist ',' error
1070 { chainon ($$, build_expr_list (NULL_TREE, error_mark_node)); }
1075 { $$ = build_expr_list (NULL_TREE, $$); }
1076 | nontrivial_exprlist
1082 /* __extension__ turns off -pedantic for following primary. */
1083 | extension cast_expr %prec UNARY
1085 pedantic = $<itype>1; }
1086 | '*' cast_expr %prec UNARY
1087 { $$ = build_x_indirect_ref ($2, "unary *"); }
1088 | '&' cast_expr %prec UNARY
1089 { $$ = build_x_unary_op (ADDR_EXPR, $2); }
1091 { $$ = build_x_unary_op (BIT_NOT_EXPR, $2); }
1092 | unop cast_expr %prec UNARY
1093 { $$ = finish_unary_op_expr ($1, $2); }
1094 /* Refer to the address of a label as a pointer. */
1097 pedwarn ("ANSI C++ forbids `&&'");
1098 $$ = finish_label_address_expr ($2); }
1099 | SIZEOF unary_expr %prec UNARY
1100 { $$ = expr_sizeof ($2); }
1101 | SIZEOF '(' type_id ')' %prec HYPERUNARY
1102 { $$ = c_sizeof (groktypename ($3.t));
1103 check_for_new_type ("sizeof", $3); }
1104 | ALIGNOF unary_expr %prec UNARY
1105 { $$ = grok_alignof ($2); }
1106 | ALIGNOF '(' type_id ')' %prec HYPERUNARY
1107 { $$ = c_alignof (groktypename ($3.t));
1108 check_for_new_type ("alignof", $3); }
1110 /* The %prec EMPTY's here are required by the = init initializer
1111 syntax extension; see below. */
1112 | new new_type_id %prec EMPTY
1113 { $$ = build_new (NULL_TREE, $2.t, NULL_TREE, $1);
1114 check_for_new_type ("new", $2); }
1115 | new new_type_id new_initializer
1116 { $$ = build_new (NULL_TREE, $2.t, $3, $1);
1117 check_for_new_type ("new", $2); }
1118 | new new_placement new_type_id %prec EMPTY
1119 { $$ = build_new ($2, $3.t, NULL_TREE, $1);
1120 check_for_new_type ("new", $3); }
1121 | new new_placement new_type_id new_initializer
1122 { $$ = build_new ($2, $3.t, $4, $1);
1123 check_for_new_type ("new", $3); }
1124 /* The .begin_new_placement in the following rules is
1125 necessary to avoid shift/reduce conflicts that lead to
1126 mis-parsing some expressions. Of course, these constructs
1127 are not really new-placement and it is bogus to call
1128 begin_new_placement. But, the parser cannot always tell at this
1129 point whether the next thing is an expression or a type-id,
1130 so there is nothing we can do. Fortunately,
1131 begin_new_placement does nothing harmful. When we rewrite
1132 the parser, this lossage should be removed, of course. */
1133 | new '(' .begin_new_placement type_id .finish_new_placement
1135 { $$ = build_new (NULL_TREE, groktypename($4.t),
1137 check_for_new_type ("new", $4); }
1138 | new '(' .begin_new_placement type_id .finish_new_placement
1140 { $$ = build_new (NULL_TREE, groktypename($4.t), $6, $1);
1141 check_for_new_type ("new", $4); }
1142 | new new_placement '(' .begin_new_placement type_id
1143 .finish_new_placement %prec EMPTY
1144 { $$ = build_new ($2, groktypename($5.t), NULL_TREE, $1);
1145 check_for_new_type ("new", $5); }
1146 | new new_placement '(' .begin_new_placement type_id
1147 .finish_new_placement new_initializer
1148 { $$ = build_new ($2, groktypename($5.t), $7, $1);
1149 check_for_new_type ("new", $5); }
1151 | delete cast_expr %prec UNARY
1152 { $$ = delete_sanity ($2, NULL_TREE, 0, $1); }
1153 | delete '[' ']' cast_expr %prec UNARY
1154 { $$ = delete_sanity ($4, NULL_TREE, 1, $1);
1155 if (yychar == YYEMPTY)
1157 | delete '[' expr ']' cast_expr %prec UNARY
1158 { $$ = delete_sanity ($5, $3, 2, $1);
1159 if (yychar == YYEMPTY)
1161 | REALPART cast_expr %prec UNARY
1162 { $$ = build_x_unary_op (REALPART_EXPR, $2); }
1163 | IMAGPART cast_expr %prec UNARY
1164 { $$ = build_x_unary_op (IMAGPART_EXPR, $2); }
1165 | VA_ARG '(' expr_no_commas ',' type_id ')'
1166 { $$ = build_va_arg ($3, groktypename ($5.t));
1167 check_for_new_type ("__builtin_va_arg", $5); }
1170 /* Note this rule is not suitable for use in new_placement
1171 since it uses NULL_TREE as the argument to
1172 finish_new_placement. This rule serves only to avoid
1173 reduce/reduce conflicts in unary_expr. See the comments
1174 there on the use of begin/finish_new_placement. */
1175 .finish_new_placement:
1177 { finish_new_placement (NULL_TREE, $<itype>-1); }
1179 .begin_new_placement:
1180 { $$ = begin_new_placement (); }
1183 '(' .begin_new_placement nonnull_exprlist ')'
1184 { $$ = finish_new_placement ($3, $2); }
1185 | '{' .begin_new_placement nonnull_exprlist '}'
1186 { cp_pedwarn ("old style placement syntax, use () instead");
1187 $$ = finish_new_placement ($3, $2); }
1191 '(' nonnull_exprlist ')'
1197 cp_error ("`%T' is not a valid expression", $2.t);
1198 $$ = error_mark_node;
1200 /* GNU extension so people can use initializer lists. Note that
1201 this alters the meaning of `new int = 1', which was previously
1202 syntactically valid but semantically invalid. */
1206 pedwarn ("ANSI C++ forbids initialization of new expression with `='");
1207 if (TREE_CODE ($2) != TREE_LIST
1208 && TREE_CODE ($2) != CONSTRUCTOR)
1209 $$ = build_expr_list (NULL_TREE, $2);
1215 /* This is necessary to postpone reduction of `int ((int)(int)(int))'. */
1217 '(' type_id ')' %prec EMPTY
1218 { $2.t = finish_parmlist (build_tree_list (NULL_TREE, $2.t), 0);
1219 $$ = make_call_declarator (NULL_TREE, $2.t, NULL_TREE, NULL_TREE);
1220 check_for_new_type ("cast", $2); }
1221 | regcast_or_absdcl '(' type_id ')' %prec EMPTY
1222 { $3.t = finish_parmlist (build_tree_list (NULL_TREE, $3.t), 0);
1223 $$ = make_call_declarator ($$, $3.t, NULL_TREE, NULL_TREE);
1224 check_for_new_type ("cast", $3); }
1229 | regcast_or_absdcl unary_expr %prec UNARY
1230 { $$ = reparse_absdcl_as_casts ($$, $2); }
1231 | regcast_or_absdcl '{' initlist maybecomma '}' %prec UNARY
1233 tree init = build_nt (CONSTRUCTOR, NULL_TREE,
1236 pedwarn ("ANSI C++ forbids constructor-expressions");
1237 /* Indicate that this was a GNU C constructor expression. */
1238 TREE_HAS_CONSTRUCTOR (init) = 1;
1240 $$ = reparse_absdcl_as_casts ($$, init);
1246 /* Handle general members. */
1247 | expr_no_commas POINTSAT_STAR expr_no_commas
1248 { $$ = build_x_binary_op (MEMBER_REF, $$, $3); }
1249 | expr_no_commas DOT_STAR expr_no_commas
1250 { $$ = build_m_component_ref ($$, $3); }
1251 | expr_no_commas '+' expr_no_commas
1252 { $$ = build_x_binary_op ($2, $$, $3); }
1253 | expr_no_commas '-' expr_no_commas
1254 { $$ = build_x_binary_op ($2, $$, $3); }
1255 | expr_no_commas '*' expr_no_commas
1256 { $$ = build_x_binary_op ($2, $$, $3); }
1257 | expr_no_commas '/' expr_no_commas
1258 { $$ = build_x_binary_op ($2, $$, $3); }
1259 | expr_no_commas '%' expr_no_commas
1260 { $$ = build_x_binary_op ($2, $$, $3); }
1261 | expr_no_commas LSHIFT expr_no_commas
1262 { $$ = build_x_binary_op ($2, $$, $3); }
1263 | expr_no_commas RSHIFT expr_no_commas
1264 { $$ = build_x_binary_op ($2, $$, $3); }
1265 | expr_no_commas ARITHCOMPARE expr_no_commas
1266 { $$ = build_x_binary_op ($2, $$, $3); }
1267 | expr_no_commas '<' expr_no_commas
1268 { $$ = build_x_binary_op (LT_EXPR, $$, $3); }
1269 | expr_no_commas '>' expr_no_commas
1270 { $$ = build_x_binary_op (GT_EXPR, $$, $3); }
1271 | expr_no_commas EQCOMPARE expr_no_commas
1272 { $$ = build_x_binary_op ($2, $$, $3); }
1273 | expr_no_commas MIN_MAX expr_no_commas
1274 { $$ = build_x_binary_op ($2, $$, $3); }
1275 | expr_no_commas '&' expr_no_commas
1276 { $$ = build_x_binary_op ($2, $$, $3); }
1277 | expr_no_commas '|' expr_no_commas
1278 { $$ = build_x_binary_op ($2, $$, $3); }
1279 | expr_no_commas '^' expr_no_commas
1280 { $$ = build_x_binary_op ($2, $$, $3); }
1281 | expr_no_commas ANDAND expr_no_commas
1282 { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $$, $3); }
1283 | expr_no_commas OROR expr_no_commas
1284 { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $$, $3); }
1285 | expr_no_commas '?' xexpr ':' expr_no_commas
1286 { $$ = build_x_conditional_expr ($$, $3, $5); }
1287 | expr_no_commas '=' expr_no_commas
1288 { $$ = build_x_modify_expr ($$, NOP_EXPR, $3);
1289 if ($$ != error_mark_node)
1290 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
1291 | expr_no_commas ASSIGN expr_no_commas
1292 { $$ = build_x_modify_expr ($$, $2, $3); }
1294 { $$ = build_throw (NULL_TREE); }
1295 | THROW expr_no_commas
1296 { $$ = build_throw ($2); }
1297 /* These extensions are not defined. The second arg to build_m_component_ref
1298 is old, build_m_component_ref now does an implicit
1299 build_indirect_ref (x, NULL_PTR) on the second argument.
1300 | object '&' expr_no_commas %prec UNARY
1301 { $$ = build_m_component_ref ($$, build_x_unary_op (ADDR_EXPR, $3)); }
1302 | object unop expr_no_commas %prec UNARY
1303 { $$ = build_m_component_ref ($$, build_x_unary_op ($2, $3)); }
1304 | object '(' type_id ')' expr_no_commas %prec UNARY
1305 { tree type = groktypename ($3.t);
1306 $$ = build_m_component_ref ($$, build_c_cast (type, $5)); }
1307 | object primary_no_id %prec UNARY
1308 { $$ = build_m_component_ref ($$, $2); }
1312 notype_unqualified_id:
1313 '~' see_typename identifier
1314 { $$ = build_parse_node (BIT_NOT_EXPR, $3); }
1315 | '~' see_typename template_type
1316 { $$ = build_parse_node (BIT_NOT_EXPR, $3); }
1321 | NSNAME %prec EMPTY
1326 /* If lastiddecl is a TREE_LIST, it's a baselink, which
1327 means that we're in an expression like S::f<int>, so
1328 don't do_identifier; we only do that for unqualified
1330 if (lastiddecl && TREE_CODE (lastiddecl) != TREE_LIST)
1331 $$ = do_identifier ($<ttype>-1, 1, NULL_TREE);
1337 PFUNCNAME '<' do_id template_arg_list_opt template_close_bracket
1338 { $$ = lookup_template_function ($3, $4); }
1339 | operator_name '<' do_id template_arg_list_opt template_close_bracket
1340 { $$ = lookup_template_function ($3, $4); }
1344 TEMPLATE identifier '<' template_arg_list_opt template_close_bracket
1345 { $$ = lookup_template_function ($2, $4); }
1346 | TEMPLATE PFUNCNAME '<' template_arg_list_opt template_close_bracket
1347 { $$ = lookup_template_function ($2, $4); }
1348 | TEMPLATE operator_name '<' template_arg_list_opt
1349 template_close_bracket
1350 { $$ = lookup_template_function ($2, $4); }
1354 notype_unqualified_id
1359 expr_or_declarator_intern:
1361 | attributes expr_or_declarator
1363 /* Provide support for '(' attributes '*' declarator ')'
1365 $$ = decl_tree_cons ($1, $2, NULL_TREE);
1370 notype_unqualified_id
1371 | '*' expr_or_declarator_intern %prec UNARY
1372 { $$ = build_parse_node (INDIRECT_REF, $2); }
1373 | '&' expr_or_declarator_intern %prec UNARY
1374 { $$ = build_parse_node (ADDR_EXPR, $2); }
1375 | '(' expr_or_declarator_intern ')'
1379 notype_template_declarator:
1380 IDENTIFIER '<' template_arg_list_opt template_close_bracket
1381 { $$ = lookup_template_function ($1, $3); }
1382 | NSNAME '<' template_arg_list template_close_bracket
1383 { $$ = lookup_template_function ($1, $3); }
1386 direct_notype_declarator:
1387 complex_direct_notype_declarator
1388 /* This precedence declaration is to prefer this reduce
1389 to the Koenig lookup shift in primary, below. I hate yacc. */
1390 | notype_unqualified_id %prec '('
1391 | notype_template_declarator
1392 | '(' expr_or_declarator_intern ')'
1393 { $$ = finish_decl_parsing ($2); }
1397 notype_unqualified_id
1399 if (TREE_CODE ($1) == BIT_NOT_EXPR)
1400 $$ = build_x_unary_op (BIT_NOT_EXPR, TREE_OPERAND ($1, 0));
1402 $$ = finish_id_expr ($1);
1408 if (processing_template_decl)
1409 push_obstacks (&permanent_obstack, &permanent_obstack);
1410 $$ = combine_strings ($$);
1411 /* combine_strings doesn't set up TYPE_MAIN_VARIANT of
1412 a const array the way we want, so fix it. */
1413 if (flag_const_strings)
1414 TREE_TYPE ($$) = build_cplus_array_type
1415 (TREE_TYPE (TREE_TYPE ($$)),
1416 TYPE_DOMAIN (TREE_TYPE ($$)));
1417 if (processing_template_decl)
1421 { $$ = finish_parenthesized_expr ($2); }
1422 | '(' expr_or_declarator_intern ')'
1423 { $2 = reparse_decl_as_expr (NULL_TREE, $2);
1424 $$ = finish_parenthesized_expr ($2); }
1426 { $$ = error_mark_node; }
1428 { tree scope = current_scope ();
1429 if (!scope || TREE_CODE (scope) != FUNCTION_DECL)
1431 error ("braced-group within expression allowed only inside a function");
1435 pedwarn ("ANSI C++ forbids braced-groups within expressions");
1436 $<ttype>$ = begin_stmt_expr ();
1439 { $$ = finish_stmt_expr ($<ttype>2, $3); }
1440 /* Koenig lookup support
1441 We could store lastiddecl in $1 to avoid another lookup,
1442 but that would result in many additional reduce/reduce conflicts. */
1443 | notype_unqualified_id '(' nonnull_exprlist ')'
1444 { $$ = finish_call_expr ($1, $3, 1); }
1445 | notype_unqualified_id LEFT_RIGHT
1446 { $$ = finish_call_expr ($1, NULL_TREE, 1); }
1447 | primary '(' nonnull_exprlist ')'
1448 { $$ = finish_call_expr ($1, $3, 0); }
1449 | primary LEFT_RIGHT
1450 { $$ = finish_call_expr ($1, NULL_TREE, 0); }
1451 | primary '[' expr ']'
1452 { $$ = grok_array_decl ($$, $3); }
1454 { $$ = finish_increment_expr ($1, POSTINCREMENT_EXPR); }
1455 | primary MINUSMINUS
1456 { $$ = finish_increment_expr ($1, POSTDECREMENT_EXPR); }
1457 /* C++ extensions */
1459 { $$ = finish_this_expr (); }
1460 | CV_QUALIFIER '(' nonnull_exprlist ')'
1462 /* This is a C cast in C++'s `functional' notation
1463 using the "implicit int" extension so that:
1464 `const (3)' is equivalent to `const int (3)'. */
1467 if ($3 == error_mark_node)
1469 $$ = error_mark_node;
1473 type = cp_build_qualified_type (integer_type_node,
1474 cp_type_qual_from_rid ($1));
1475 $$ = build_c_cast (type, build_compound_expr ($3));
1478 | DYNAMIC_CAST '<' type_id '>' '(' expr ')'
1479 { tree type = groktypename ($3.t);
1480 check_for_new_type ("dynamic_cast", $3);
1481 $$ = build_dynamic_cast (type, $6); }
1482 | STATIC_CAST '<' type_id '>' '(' expr ')'
1483 { tree type = groktypename ($3.t);
1484 check_for_new_type ("static_cast", $3);
1485 $$ = build_static_cast (type, $6); }
1486 | REINTERPRET_CAST '<' type_id '>' '(' expr ')'
1487 { tree type = groktypename ($3.t);
1488 check_for_new_type ("reinterpret_cast", $3);
1489 $$ = build_reinterpret_cast (type, $6); }
1490 | CONST_CAST '<' type_id '>' '(' expr ')'
1491 { tree type = groktypename ($3.t);
1492 check_for_new_type ("const_cast", $3);
1493 $$ = build_const_cast (type, $6); }
1494 | TYPEID '(' expr ')'
1495 { $$ = build_x_typeid ($3); }
1496 | TYPEID '(' type_id ')'
1497 { tree type = groktypename ($3.t);
1498 check_for_new_type ("typeid", $3);
1499 $$ = get_typeid (TYPE_MAIN_VARIANT (type)); }
1500 | global_scope IDENTIFIER
1501 { $$ = do_scoped_id ($2, 1); }
1502 | global_scope template_id
1504 | global_scope operator_name
1506 got_scope = NULL_TREE;
1507 if (TREE_CODE ($2) == IDENTIFIER_NODE)
1508 $$ = do_scoped_id ($2, 1);
1512 | overqualified_id %prec HYPERUNARY
1513 { $$ = build_offset_ref (OP0 ($$), OP1 ($$)); }
1514 | overqualified_id '(' nonnull_exprlist ')'
1515 { $$ = finish_qualified_call_expr ($1, $3); }
1516 | overqualified_id LEFT_RIGHT
1517 { $$ = finish_qualified_call_expr ($1, NULL_TREE); }
1518 | object object_template_id %prec UNARY
1520 $$ = build_x_component_ref ($$, $2, NULL_TREE, 1);
1522 | object object_template_id '(' nonnull_exprlist ')'
1523 { $$ = finish_object_call_expr ($2, $1, $4); }
1524 | object object_template_id LEFT_RIGHT
1525 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1526 | object unqualified_id %prec UNARY
1527 { $$ = build_x_component_ref ($$, $2, NULL_TREE, 1); }
1528 | object overqualified_id %prec UNARY
1529 { if (processing_template_decl)
1530 $$ = build_min_nt (COMPONENT_REF, $1, copy_to_permanent ($2));
1532 $$ = build_object_ref ($$, OP0 ($2), OP1 ($2)); }
1533 | object unqualified_id '(' nonnull_exprlist ')'
1534 { $$ = finish_object_call_expr ($2, $1, $4); }
1535 | object unqualified_id LEFT_RIGHT
1536 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1537 | object overqualified_id '(' nonnull_exprlist ')'
1538 { $$ = finish_qualified_object_call_expr ($2, $1, $4); }
1539 | object overqualified_id LEFT_RIGHT
1540 { $$ = finish_qualified_object_call_expr ($2, $1, NULL_TREE); }
1541 /* p->int::~int() is valid -- 12.4 */
1542 | object '~' TYPESPEC LEFT_RIGHT
1543 { $$ = finish_pseudo_destructor_call_expr ($1, NULL_TREE, $3); }
1544 | object TYPESPEC SCOPE '~' TYPESPEC LEFT_RIGHT
1545 { $$ = finish_pseudo_destructor_call_expr ($1, $2, $5); }
1548 $$ = error_mark_node;
1552 /* Not needed for now.
1558 { $$ = error_mark_node; }
1560 { if (current_function_decl == 0)
1562 error ("braced-group within expression allowed only inside a function");
1565 $<ttype>$ = expand_start_stmt_expr (); }
1568 pedwarn ("ANSI C++ forbids braced-groups within expressions");
1569 $$ = expand_end_stmt_expr ($<ttype>2); }
1570 | primary_no_id '(' nonnull_exprlist ')'
1571 { $$ = build_x_function_call ($$, $3, current_class_ref); }
1572 | primary_no_id LEFT_RIGHT
1573 { $$ = build_x_function_call ($$, NULL_TREE, current_class_ref); }
1574 | primary_no_id '[' expr ']'
1576 | primary_no_id PLUSPLUS
1577 { $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); }
1578 | primary_no_id MINUSMINUS
1579 { $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); }
1581 { goto do_scoped_id; }
1582 | SCOPE operator_name
1583 { if (TREE_CODE ($2) == IDENTIFIER_NODE)
1585 goto do_scoped_operator;
1594 { got_scope = NULL_TREE; $$ = 1; }
1600 | global_scope delete
1601 { got_scope = NULL_TREE; $$ = 1; }
1606 { $$ = boolean_true_node; }
1608 { $$ = boolean_false_node; }
1611 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
1615 { $$ = chainon ($$, $2); }
1621 if (! current_function_parms_stored)
1622 store_parm_decls ();
1624 /* Always keep the BLOCK node associated with the outermost
1625 pair of curley braces of a function. These are needed
1626 for correct operation of dwarfout.c. */
1633 { got_object = TREE_TYPE ($$); }
1636 $$ = build_x_arrow ($$);
1637 got_object = TREE_TYPE ($$);
1642 typespec initdecls ';'
1644 resume_momentary ($2);
1645 if ($1.t && IS_AGGR_TYPE_CODE (TREE_CODE ($1.t)))
1646 note_got_semicolon ($1.t);
1648 | typed_declspecs initdecls ';'
1650 resume_momentary ($2);
1651 note_list_got_semicolon ($1.t);
1653 | declmods notype_initdecls ';'
1654 { resume_momentary ($2); }
1655 | typed_declspecs ';'
1658 note_list_got_semicolon ($1.t);
1661 { warning ("empty declaration"); }
1663 { pedantic = $<itype>1; }
1666 /* Any kind of declarator (thus, all declarators allowed
1667 after an explicit typespec). */
1670 after_type_declarator %prec EMPTY
1671 | notype_declarator %prec EMPTY
1674 /* This is necessary to postpone reduction of `int()()()()'. */
1676 LEFT_RIGHT %prec EMPTY
1677 { $$ = make_call_declarator (NULL_TREE, empty_parms (),
1678 NULL_TREE, NULL_TREE); }
1679 | fcast_or_absdcl LEFT_RIGHT %prec EMPTY
1680 { $$ = make_call_declarator ($$, empty_parms (), NULL_TREE,
1684 /* ANSI type-id (8.1) */
1686 typed_typespecs absdcl
1687 { $$.t = build_decl_list ($1.t, $2);
1688 $$.new_type_flag = $1.new_type_flag; }
1689 | nonempty_cv_qualifiers absdcl
1690 { $$.t = build_decl_list ($1.t, $2);
1691 $$.new_type_flag = $1.new_type_flag; }
1693 { $$.t = build_decl_list (build_decl_list (NULL_TREE, $1.t),
1695 $$.new_type_flag = $1.new_type_flag; }
1696 | typed_typespecs %prec EMPTY
1697 { $$.t = build_decl_list ($1.t, NULL_TREE);
1698 $$.new_type_flag = $1.new_type_flag; }
1699 | nonempty_cv_qualifiers %prec EMPTY
1700 { $$.t = build_decl_list ($1.t, NULL_TREE);
1701 $$.new_type_flag = $1.new_type_flag; }
1704 /* Declspecs which contain at least one type specifier or typedef name.
1705 (Just `const' or `volatile' is not enough.)
1706 A typedef'd name following these is taken as a name to be declared.
1707 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1710 typed_typespecs %prec EMPTY
1716 { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1);
1717 $$.new_type_flag = $2.new_type_flag; }
1718 | typespec reserved_declspecs %prec HYPERUNARY
1719 { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2);
1720 $$.new_type_flag = $1.new_type_flag; }
1721 | typespec reserved_typespecquals reserved_declspecs
1722 { $$.t = decl_tree_cons (NULL_TREE, $1.t, chainon ($2, $3));
1723 $$.new_type_flag = $1.new_type_flag; }
1724 | declmods typespec reserved_declspecs
1725 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1));
1726 $$.new_type_flag = $2.new_type_flag; }
1727 | declmods typespec reserved_typespecquals
1728 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1));
1729 $$.new_type_flag = $2.new_type_flag; }
1730 | declmods typespec reserved_typespecquals reserved_declspecs
1731 { $$.t = decl_tree_cons (NULL_TREE, $2.t,
1732 chainon ($3, chainon ($4, $1)));
1733 $$.new_type_flag = $2.new_type_flag; }
1738 { if (extra_warnings)
1739 warning ("`%s' is not at beginning of declaration",
1740 IDENTIFIER_POINTER ($$));
1741 $$ = build_decl_list (NULL_TREE, $$); }
1742 | reserved_declspecs typespecqual_reserved
1743 { $$ = decl_tree_cons (NULL_TREE, $2.t, $$); }
1744 | reserved_declspecs SCSPEC
1745 { if (extra_warnings)
1746 warning ("`%s' is not at beginning of declaration",
1747 IDENTIFIER_POINTER ($2));
1748 $$ = decl_tree_cons (NULL_TREE, $2, $$); }
1749 | reserved_declspecs attributes
1750 { $$ = decl_tree_cons ($2, NULL_TREE, $1); }
1752 { $$ = decl_tree_cons ($1, NULL_TREE, NULL_TREE); }
1755 /* List of just storage classes and type modifiers.
1756 A declaration can start with just this, but then it cannot be used
1757 to redeclare a typedef-name.
1758 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1760 /* We use hash_tree_cons for lists of typeless declspecs so that they end
1761 up on a persistent obstack. Otherwise, they could appear at the
1762 beginning of something like
1764 static const struct { int foo () { } } b;
1766 and would be discarded after we finish compiling foo. We don't need to
1767 worry once we see a type. */
1770 nonempty_cv_qualifiers %prec EMPTY
1771 { $$ = $1.t; TREE_STATIC ($$) = 1; }
1773 { $$ = hash_tree_cons (NULL_TREE, $$, NULL_TREE); }
1774 | declmods CV_QUALIFIER
1775 { $$ = hash_tree_cons (NULL_TREE, $2, $$);
1776 TREE_STATIC ($$) = 1; }
1778 { if (extra_warnings && TREE_STATIC ($$))
1779 warning ("`%s' is not at beginning of declaration",
1780 IDENTIFIER_POINTER ($2));
1781 $$ = hash_tree_cons (NULL_TREE, $2, $$);
1782 TREE_STATIC ($$) = TREE_STATIC ($1); }
1783 | declmods attributes
1784 { $$ = hash_tree_cons ($2, NULL_TREE, $1); }
1785 | attributes %prec EMPTY
1786 { $$ = hash_tree_cons ($1, NULL_TREE, NULL_TREE); }
1789 /* Used instead of declspecs where storage classes are not allowed
1790 (that is, for typenames and structure components).
1792 C++ can takes storage classes for structure components.
1793 Don't accept a typedef-name if anything but a modifier precedes it. */
1796 typespec %prec EMPTY
1797 { $$.t = build_decl_list (NULL_TREE, $1.t);
1798 $$.new_type_flag = $1.new_type_flag; }
1799 | nonempty_cv_qualifiers typespec
1800 { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1.t);
1801 $$.new_type_flag = $2.new_type_flag; }
1802 | typespec reserved_typespecquals
1803 { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2);
1804 $$.new_type_flag = $1.new_type_flag; }
1805 | nonempty_cv_qualifiers typespec reserved_typespecquals
1806 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1807 $$.new_type_flag = $1.new_type_flag; }
1810 reserved_typespecquals:
1811 typespecqual_reserved
1812 { $$ = build_decl_list (NULL_TREE, $1.t); }
1813 | reserved_typespecquals typespecqual_reserved
1814 { $$ = decl_tree_cons (NULL_TREE, $2.t, $1); }
1817 /* A typespec (but not a type qualifier).
1818 Once we have seen one of these in a declaration,
1819 if a typedef name appears then it is being redeclared. */
1823 | TYPESPEC %prec EMPTY
1824 { $$.t = $1; $$.new_type_flag = 0; }
1825 | complete_type_name
1826 { $$.t = $1; $$.new_type_flag = 0; }
1827 | TYPEOF '(' expr ')'
1828 { $$.t = finish_typeof ($3);
1829 $$.new_type_flag = 0; }
1830 | TYPEOF '(' type_id ')'
1831 { $$.t = groktypename ($3.t);
1832 $$.new_type_flag = 0; }
1833 | SIGOF '(' expr ')'
1834 { tree type = TREE_TYPE ($3);
1836 $$.new_type_flag = 0;
1837 if (IS_AGGR_TYPE (type))
1839 sorry ("sigof type specifier");
1844 error ("`sigof' applied to non-aggregate expression");
1845 $$.t = error_mark_node;
1848 | SIGOF '(' type_id ')'
1849 { tree type = groktypename ($3.t);
1851 $$.new_type_flag = 0;
1852 if (IS_AGGR_TYPE (type))
1854 sorry ("sigof type specifier");
1859 error("`sigof' applied to non-aggregate type");
1860 $$.t = error_mark_node;
1865 /* A typespec that is a reserved word, or a type qualifier. */
1867 typespecqual_reserved:
1869 { $$.t = $1; $$.new_type_flag = 0; }
1871 { $$.t = $1; $$.new_type_flag = 0; }
1877 | initdecls ',' initdcl
1878 { check_multiple_declarators (); }
1883 | notype_initdecls ',' initdcl
1884 { check_multiple_declarators (); }
1889 | nomods_initdecls ',' initdcl
1890 { check_multiple_declarators (); }
1896 | asm_keyword '(' string ')'
1897 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3); $$ = $3; }
1901 declarator maybeasm maybe_attribute '='
1902 { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1,
1903 $3, prefix_attributes); }
1905 /* Note how the declaration of the variable is in effect while its init is parsed! */
1906 { cp_finish_decl ($<ttype>5, $6, $2, 1, LOOKUP_ONLYCONVERTING); }
1907 | declarator maybeasm maybe_attribute
1908 { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 0,
1909 $3, prefix_attributes);
1910 cp_finish_decl ($<ttype>$, NULL_TREE, $2, 1, 0); }
1913 /* This rule assumes a certain configuration of the parser stack.
1914 In particular, $0, the element directly before the beginning of
1915 this rule on the stack, must be a maybeasm. $-1 must be a
1916 declarator or notype_declarator. And $-2 must be some declmods
1917 or declspecs. We can't move the maybeasm into this rule because
1918 we need that reduce so we prefer fn.def1 when appropriate. */
1921 { $<itype>2 = parse_decl ($<ttype>-1, $<ttype>-2,
1922 $1, 1, &$<ttype>$); }
1923 /* Note how the declaration of the variable is in effect
1924 while its init is parsed! */
1926 { cp_finish_decl ($<ttype>3, $4, $<ttype>0, 1,
1927 LOOKUP_ONLYCONVERTING);
1931 $$ = parse_decl ($<ttype>-1, $<ttype>-2, $1, 0, &d);
1932 cp_finish_decl (d, NULL_TREE, $<ttype>0, 1, 0); }
1936 declarator maybeasm initdcl0_innards
1940 notype_declarator maybeasm initdcl0_innards
1945 notype_declarator maybeasm
1946 { /* Set things up as initdcl0_innards expects. */
1951 | constructor_declarator maybeasm maybe_attribute
1953 parse_decl($1, NULL_TREE, $3, 0, &d);
1954 cp_finish_decl (d, NULL_TREE, $2, 1, 0); }
1957 /* the * rules are dummies to accept the Apollo extended syntax
1958 so that the header files compile. */
1969 | attributes attribute
1970 { $$ = chainon ($1, $2); }
1974 ATTRIBUTE '(' '(' attribute_list ')' ')'
1981 | attribute_list ',' attrib
1982 { $$ = chainon ($1, $3); }
1989 { $$ = build_tree_list ($1, NULL_TREE); }
1990 | any_word '(' IDENTIFIER ')'
1991 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1992 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1993 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1994 | any_word '(' nonnull_exprlist ')'
1995 { $$ = build_tree_list ($1, $3); }
1998 /* This still leaves out most reserved keywords,
1999 shouldn't we include them? */
2008 /* A nonempty list of identifiers, including typenames. */
2009 identifiers_or_typenames:
2011 { $$ = build_tree_list (NULL_TREE, $1); }
2012 | identifiers_or_typenames ',' identifier
2013 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2017 /* empty */ %prec EMPTY
2022 /* If we are processing a template, we don't want to expand this
2026 expr_no_commas %prec '='
2028 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, NULL_TREE);
2029 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2031 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2032 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2033 | '{' initlist ',' '}'
2034 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2035 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2040 /* This chain is built in reverse order,
2041 and put in forward order where initlist is used. */
2044 { $$ = build_tree_list (NULL_TREE, $$); }
2046 { $$ = expr_tree_cons (NULL_TREE, $3, $$); }
2047 /* These are for labeled elements. */
2048 | '[' expr_no_commas ']' init
2049 { $$ = build_expr_list ($2, $4); }
2050 | identifier ':' init
2051 { $$ = build_expr_list ($$, $3); }
2052 | initlist ',' identifier ':' init
2053 { $$ = expr_tree_cons ($3, $5, $$); }
2057 PRE_PARSED_FUNCTION_DECL
2058 { start_function (NULL_TREE, TREE_VALUE ($1),
2060 reinit_parse_for_function (); }
2063 fn.defpen maybe_return_init ctor_initializer_opt compstmt_or_error
2065 int nested = (hack_decl_function_context
2066 (current_function_decl) != NULL_TREE);
2067 finish_function (lineno, (int)$3 | 2, nested);
2068 process_next_inline ($1);
2070 | fn.defpen maybe_return_init function_try_block
2072 int nested = (hack_decl_function_context
2073 (current_function_decl) != NULL_TREE);
2074 finish_function (lineno, (int)$3 | 2, nested);
2075 process_next_inline ($1);
2077 | fn.defpen maybe_return_init error
2078 { process_next_inline ($1); }
2083 | pending_inlines pending_inline eat_saved_input
2086 /* A regurgitated default argument. The value of DEFARG_MARKER will be
2087 the TREE_LIST node for the parameter in question. */
2089 DEFARG_MARKER expr_no_commas END_OF_SAVED_INPUT
2090 { replace_defarg ($1, $2); }
2091 | DEFARG_MARKER error END_OF_SAVED_INPUT
2092 { replace_defarg ($1, error_mark_node); }
2095 /* empty */ %prec EMPTY
2096 | pending_defargs defarg_again
2097 { do_pending_defargs (); }
2098 | pending_defargs error
2099 { do_pending_defargs (); }
2104 { $<itype>3 = suspend_momentary ();
2105 $<ttype>$ = current_enum_type;
2106 current_enum_type = start_enum ($2); }
2108 { TYPE_VALUES (current_enum_type) = $5;
2109 $$.t = finish_enum (current_enum_type);
2110 $$.new_type_flag = 1;
2111 current_enum_type = $<ttype>4;
2112 resume_momentary ((int) $<itype>3);
2113 check_for_missing_semicolon ($$.t); }
2115 { $<itype>2 = suspend_momentary ();
2116 $<ttype>$ = current_enum_type;
2117 current_enum_type = start_enum (make_anon_name ()); }
2119 { TYPE_VALUES (current_enum_type) = $4;
2120 $$.t = finish_enum (current_enum_type);
2121 $$.new_type_flag = 1;
2122 current_enum_type = $<ttype>3;
2123 resume_momentary ((int) $<itype>1);
2124 check_for_missing_semicolon ($$.t); }
2126 { $$.t = xref_tag (enum_type_node, $2, 1);
2127 $$.new_type_flag = 0; }
2128 | ENUM complex_type_name
2129 { $$.t = xref_tag (enum_type_node, $2, 1);
2130 $$.new_type_flag = 0; }
2131 | TYPENAME_KEYWORD typename_sub
2133 $$.new_type_flag = 0;
2134 if (!processing_template_decl)
2135 cp_pedwarn ("using `typename' outside of template"); }
2136 /* C++ extensions, merged with C to avoid shift/reduce conflicts */
2138 { $1.t = begin_class_definition ($1.t); }
2139 opt.component_decl_list '}' maybe_attribute
2143 if (yychar == YYEMPTY)
2145 semi = yychar == ';';
2147 $<ttype>$ = finish_class_definition ($1.t, $6, semi,
2152 begin_inline_definitions ();
2156 finish_inline_definitions ();
2158 $$.new_type_flag = 1;
2160 | class_head %prec EMPTY
2162 if ($1.new_type_flag && $1.t != error_mark_node)
2163 pop_scope (CP_DECL_CONTEXT (TYPE_MAIN_DECL ($1.t)));
2164 $$.new_type_flag = 0;
2165 if ($1.t == error_mark_node)
2167 else if (TYPE_BINFO ($1.t) == NULL_TREE)
2169 cp_error ("%T is not a class type", $1.t);
2170 $$.t = error_mark_node;
2175 /* struct B: public A; is not accepted by the WP grammar. */
2176 if (TYPE_BINFO_BASETYPES ($$.t) && !TYPE_SIZE ($$.t)
2177 && ! TYPE_BEING_DEFINED ($$.t))
2178 cp_error ("base clause without member specification for `%#T'",
2192 { if (pedantic && !in_system_header)
2193 pedwarn ("comma at end of enumerator list"); }
2199 { error ("storage class specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2201 { error ("type specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2203 { error ("type qualifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2205 { error ("no body nor ';' separates two class, struct or union declarations"); }
2207 { $$ = build_decl_list ($2, $1); }
2210 named_class_head_sans_basetype:
2218 named_class_head_sans_basetype_defn:
2219 aggr identifier_defn %prec EMPTY
2220 { current_aggr = $$; $$ = $2; }
2221 | named_class_head_sans_basetype '{'
2222 { yyungetc ('{', 1); }
2223 | named_class_head_sans_basetype ':'
2224 { yyungetc (':', 1); }
2227 named_complex_class_head_sans_basetype:
2228 aggr nested_name_specifier identifier
2231 $$.t = handle_class_head ($1, $2, $3);
2232 $$.new_type_flag = 1;
2234 | aggr global_scope nested_name_specifier identifier
2237 $$.t = handle_class_head ($1, $3, $4);
2238 $$.new_type_flag = 1;
2240 | aggr global_scope identifier
2243 $$.t = handle_class_head ($1, NULL_TREE, $3);
2244 $$.new_type_flag = 1;
2246 | aggr apparent_template_type
2250 $$.new_type_flag = 0;
2252 | aggr nested_name_specifier apparent_template_type
2256 if (CP_DECL_CONTEXT ($$.t))
2257 push_scope (CP_DECL_CONTEXT ($$.t));
2258 $$.new_type_flag = 1;
2263 named_class_head_sans_basetype %prec EMPTY
2265 $$.t = xref_tag (current_aggr, $1, 1);
2266 $$.new_type_flag = 0;
2268 | named_class_head_sans_basetype_defn
2269 { $<ttype>$ = xref_tag (current_aggr, $1, 0); }
2270 /* Class name is unqualified, so we look for base classes
2271 in the current scope. */
2272 maybe_base_class_list %prec EMPTY
2275 $$.new_type_flag = 0;
2277 xref_basetypes (current_aggr, $1, $<ttype>2, $3);
2279 | named_complex_class_head_sans_basetype
2280 maybe_base_class_list
2282 if ($1.t != error_mark_node)
2284 $$.t = TREE_TYPE ($1.t);
2285 $$.new_type_flag = $1.new_type_flag;
2286 if (current_aggr == union_type_node
2287 && TREE_CODE ($$.t) != UNION_TYPE)
2288 cp_pedwarn ("`union' tag used in declaring `%#T'",
2290 else if (TREE_CODE ($$.t) == UNION_TYPE
2291 && current_aggr != union_type_node)
2292 cp_pedwarn ("non-`union' tag used in declaring `%#T'", $$);
2293 else if (TREE_CODE ($$.t) == RECORD_TYPE)
2294 /* We might be specializing a template with a different
2296 CLASSTYPE_DECLARED_CLASS ($$.t)
2297 = (current_aggr == class_type_node);
2300 maybe_process_partial_specialization ($$.t);
2301 xref_basetypes (current_aggr, $1.t, $$.t, $2);
2309 { $$ = xref_tag ($$, make_anon_name (), 0);
2310 yyungetc ('{', 1); }
2313 /* The tree output of this nonterminal a declarationf or the type
2314 named. If NEW_TYPE_FLAG is set, then the name used in this
2315 class-head was explicitly qualified, e.g.: `struct X::Y'. We have
2316 already called push_scope for X. */
2321 $$.new_type_flag = 0;
2326 maybe_base_class_list:
2327 /* empty */ %prec EMPTY
2329 | ':' see_typename %prec EMPTY
2330 { yyungetc(':', 1); $$ = NULL_TREE; }
2331 | ':' see_typename base_class_list %prec EMPTY
2337 | base_class_list ',' see_typename base_class
2338 { $$ = chainon ($$, $4); }
2343 { $$ = finish_base_specifier (access_default_node, $1); }
2344 | base_class_access_list see_typename base_class.1
2345 { $$ = finish_base_specifier ($1, $3); }
2350 { if ($$ != error_mark_node) $$ = TYPE_MAIN_DECL ($1); }
2354 base_class_access_list:
2355 VISSPEC see_typename
2356 | SCSPEC see_typename
2357 { if ($1 != ridpointers[(int)RID_VIRTUAL])
2358 cp_error ("`%D' access", $1);
2359 $$ = access_default_virtual_node; }
2360 | base_class_access_list VISSPEC see_typename
2362 if ($1 != access_default_virtual_node)
2363 error ("multiple access specifiers");
2364 else if ($2 == access_public_node)
2365 $$ = access_public_virtual_node;
2366 else if ($2 == access_protected_node)
2367 $$ = access_protected_virtual_node;
2368 else /* $2 == access_private_node */
2369 $$ = access_private_virtual_node;
2371 | base_class_access_list SCSPEC see_typename
2372 { if ($2 != ridpointers[(int)RID_VIRTUAL])
2373 cp_error ("`%D' access", $2);
2374 else if ($$ == access_public_node)
2375 $$ = access_public_virtual_node;
2376 else if ($$ == access_protected_node)
2377 $$ = access_protected_virtual_node;
2378 else if ($$ == access_private_node)
2379 $$ = access_private_virtual_node;
2381 error ("multiple `virtual' specifiers");
2385 opt.component_decl_list:
2386 | component_decl_list
2387 | opt.component_decl_list access_specifier component_decl_list
2388 | opt.component_decl_list access_specifier
2394 current_access_specifier = $1;
2398 /* Note: we no longer warn about the semicolon after a component_decl_list.
2399 ARM $9.2 says that the semicolon is optional, and therefore allowed. */
2400 component_decl_list:
2403 finish_member_declaration ($1);
2405 | component_decl_list component_decl
2407 finish_member_declaration ($2);
2412 component_decl_1 ';'
2413 | component_decl_1 '}'
2414 { error ("missing ';' before right brace");
2415 yyungetc ('}', 0); }
2416 /* C++: handle constructors, destructors and inline functions */
2417 /* note that INLINE is like a TYPESPEC */
2418 | fn.def2 ':' /* base_init compstmt */
2419 { $$ = finish_method ($$); }
2420 | fn.def2 TRY /* base_init compstmt */
2421 { $$ = finish_method ($$); }
2422 | fn.def2 RETURN_KEYWORD /* base_init compstmt */
2423 { $$ = finish_method ($$); }
2424 | fn.def2 '{' /* nodecls compstmt */
2425 { $$ = finish_method ($$); }
2428 | extension component_decl
2430 pedantic = $<itype>1; }
2431 | template_header component_decl
2434 $$ = finish_member_template_decl ($2);
2436 /* The component was already processed. */
2439 finish_template_decl ($1);
2441 | template_header typed_declspecs ';'
2443 $$ = finish_member_class_template ($2.t);
2444 finish_template_decl ($1);
2449 /* Do not add a "typed_declspecs declarator" rule here for
2450 speed; we need to call grok_x_components for enums, so the
2451 speedup would be insignificant. */
2452 typed_declspecs components
2454 /* Most of the productions for component_decl only
2455 allow the creation of one new member, so we call
2456 finish_member_declaration in component_decl_list.
2457 For this rule and the next, however, there can be
2458 more than one member, e.g.:
2462 and we need the first member to be fully
2463 registered before the second is processed.
2464 Therefore, the rules for components take care of
2465 this processing. To avoid registering the
2466 components more than once, we send NULL_TREE up
2467 here; that lets finish_member_declaration know
2468 that there is nothing to do. */
2470 grok_x_components ($1.t);
2473 | declmods notype_components
2476 grok_x_components ($1);
2479 | notype_declarator maybeasm maybe_attribute maybe_init
2480 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2481 build_tree_list ($3, NULL_TREE)); }
2482 | constructor_declarator maybeasm maybe_attribute maybe_init
2483 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2484 build_tree_list ($3, NULL_TREE)); }
2485 | ':' expr_no_commas
2486 { $$ = grokbitfield (NULL_TREE, NULL_TREE, $2); }
2490 /* These rules introduce a reduce/reduce conflict; in
2491 typedef int foo, bar;
2495 should "A::foo" be declared as a function or "A::bar" as a data
2496 member? In other words, is "bar" an after_type_declarator or a
2498 | declmods component_constructor_declarator maybeasm maybe_attribute maybe_init
2499 { tree specs, attrs;
2500 split_specs_attrs ($1, &specs, &attrs);
2501 $$ = grokfield ($2, specs, $5, $3,
2502 build_tree_list ($4, attrs)); }
2503 | component_constructor_declarator maybeasm maybe_attribute maybe_init
2504 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2505 build_tree_list ($3, NULL_TREE)); }
2507 { $$ = do_class_using_decl ($1); }
2509 /* The case of exactly one component is handled directly by component_decl. */
2512 /* empty: possibly anonymous */
2514 | component_declarator0
2516 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2517 $1 = finish_member_template_decl ($1);
2518 finish_member_declaration ($1);
2521 | components ',' component_declarator
2523 check_multiple_declarators ();
2524 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2525 $3 = finish_member_template_decl ($3);
2526 finish_member_declaration ($3);
2532 /* empty: possibly anonymous */
2534 | notype_component_declarator0
2536 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2537 $1 = finish_member_template_decl ($1);
2538 finish_member_declaration ($1);
2541 | notype_components ',' notype_component_declarator
2543 check_multiple_declarators ();
2544 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2545 $3 = finish_member_template_decl ($3);
2546 finish_member_declaration ($3);
2551 component_declarator0:
2552 after_type_component_declarator0
2553 | notype_component_declarator0
2556 component_declarator:
2557 after_type_component_declarator
2558 | notype_component_declarator
2561 after_type_component_declarator0:
2562 after_type_declarator maybeasm maybe_attribute maybe_init
2563 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2564 &prefix_attributes);
2565 $<ttype>0 = current_declspecs;
2566 $$ = grokfield ($$, current_declspecs, $4, $2,
2567 build_tree_list ($3, prefix_attributes)); }
2568 | TYPENAME ':' expr_no_commas maybe_attribute
2569 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2570 &prefix_attributes);
2571 $<ttype>0 = current_declspecs;
2572 $$ = grokbitfield ($$, current_declspecs, $3);
2573 cplus_decl_attributes ($$, $4, prefix_attributes); }
2576 notype_component_declarator0:
2577 notype_declarator maybeasm maybe_attribute maybe_init
2578 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2579 &prefix_attributes);
2580 $<ttype>0 = current_declspecs;
2581 $$ = grokfield ($$, current_declspecs, $4, $2,
2582 build_tree_list ($3, prefix_attributes)); }
2583 | constructor_declarator maybeasm maybe_attribute maybe_init
2584 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2585 &prefix_attributes);
2586 $<ttype>0 = current_declspecs;
2587 $$ = grokfield ($$, current_declspecs, $4, $2,
2588 build_tree_list ($3, prefix_attributes)); }
2589 | IDENTIFIER ':' expr_no_commas maybe_attribute
2590 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2591 &prefix_attributes);
2592 $<ttype>0 = current_declspecs;
2593 $$ = grokbitfield ($$, current_declspecs, $3);
2594 cplus_decl_attributes ($$, $4, prefix_attributes); }
2595 | ':' expr_no_commas maybe_attribute
2596 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2597 &prefix_attributes);
2598 $<ttype>0 = current_declspecs;
2599 $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
2600 cplus_decl_attributes ($$, $3, prefix_attributes); }
2603 after_type_component_declarator:
2604 after_type_declarator maybeasm maybe_attribute maybe_init
2605 { $$ = grokfield ($$, current_declspecs, $4, $2,
2606 build_tree_list ($3, prefix_attributes)); }
2607 | TYPENAME ':' expr_no_commas maybe_attribute
2608 { $$ = grokbitfield ($$, current_declspecs, $3);
2609 cplus_decl_attributes ($$, $4, prefix_attributes); }
2612 notype_component_declarator:
2613 notype_declarator maybeasm maybe_attribute maybe_init
2614 { $$ = grokfield ($$, current_declspecs, $4, $2,
2615 build_tree_list ($3, prefix_attributes)); }
2616 | IDENTIFIER ':' expr_no_commas maybe_attribute
2617 { $$ = grokbitfield ($$, current_declspecs, $3);
2618 cplus_decl_attributes ($$, $4, prefix_attributes); }
2619 | ':' expr_no_commas maybe_attribute
2620 { $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
2621 cplus_decl_attributes ($$, $3, prefix_attributes); }
2625 enumlist maybecomma_warn
2630 /* We chain the enumerators in reverse order.
2631 Because of the way enums are built, the order is
2632 insignificant. Take advantage of this fact. */
2636 | enumlist ',' enumerator
2637 { TREE_CHAIN ($3) = $$; $$ = $3; }
2642 { $$ = build_enumerator ($$, NULL_TREE, current_enum_type); }
2643 | identifier '=' expr_no_commas
2644 { $$ = build_enumerator ($$, $3, current_enum_type); }
2647 /* ANSI new-type-id (5.3.4) */
2649 type_specifier_seq new_declarator
2650 { $$.t = build_decl_list ($1.t, $2);
2651 $$.new_type_flag = $1.new_type_flag; }
2652 | type_specifier_seq %prec EMPTY
2653 { $$.t = build_decl_list ($1.t, NULL_TREE);
2654 $$.new_type_flag = $1.new_type_flag; }
2655 /* GNU extension to allow arrays of arbitrary types with
2656 non-constant dimension. For the use of begin_new_placement
2657 here, see the comments in unary_expr above. */
2658 | '(' .begin_new_placement type_id .finish_new_placement
2662 pedwarn ("ANSI C++ forbids array dimensions with parenthesized type in new");
2663 $$.t = build_parse_node (ARRAY_REF, TREE_VALUE ($3.t), $6);
2664 $$.t = build_decl_list (TREE_PURPOSE ($3.t), $$.t);
2665 $$.new_type_flag = $3.new_type_flag;
2670 /* empty */ %prec EMPTY
2672 | cv_qualifiers CV_QUALIFIER
2673 { $$ = decl_tree_cons (NULL_TREE, $2, $$); }
2676 nonempty_cv_qualifiers:
2678 { $$.t = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
2679 $$.new_type_flag = 0; }
2680 | nonempty_cv_qualifiers CV_QUALIFIER
2681 { $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
2682 $$.new_type_flag = $1.new_type_flag; }
2685 /* These rules must follow the rules for function declarations
2686 and component declarations. That way, longer rules are preferred. */
2690 { $<itype>$ = suspend_momentary (); }
2692 /* An expression which will not live on the momentary obstack. */
2695 { resume_momentary ((int) $<itype>1); $$ = $2; }
2698 /* An expression which will not live on the momentary obstack. */
2700 suspend_mom '(' nonnull_exprlist ')'
2701 { resume_momentary ((int) $<itype>1); $$ = $3; }
2702 | suspend_mom '(' parmlist ')'
2703 { resume_momentary ((int) $<itype>1); $$ = $3; }
2704 | suspend_mom LEFT_RIGHT
2705 { resume_momentary ((int) $<itype>1); $$ = empty_parms (); }
2706 | suspend_mom '(' error ')'
2707 { resume_momentary ((int) $<itype>1); $$ = NULL_TREE; }
2710 /* A declarator that is allowed only after an explicit typespec. */
2712 after_type_declarator_intern:
2713 after_type_declarator
2714 | attributes after_type_declarator
2716 /* Provide support for '(' attributes '*' declarator ')'
2718 $$ = decl_tree_cons ($1, $2, NULL_TREE);
2722 /* may all be followed by prec '.' */
2723 after_type_declarator:
2724 '*' nonempty_cv_qualifiers after_type_declarator_intern %prec UNARY
2725 { $$ = make_pointer_declarator ($2.t, $3); }
2726 | '&' nonempty_cv_qualifiers after_type_declarator_intern %prec UNARY
2727 { $$ = make_reference_declarator ($2.t, $3); }
2728 | '*' after_type_declarator_intern %prec UNARY
2729 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2730 | '&' after_type_declarator_intern %prec UNARY
2731 { $$ = make_reference_declarator (NULL_TREE, $2); }
2732 | ptr_to_mem cv_qualifiers after_type_declarator_intern
2733 { tree arg = make_pointer_declarator ($2, $3);
2734 $$ = build_parse_node (SCOPE_REF, $1, arg);
2736 | direct_after_type_declarator
2739 direct_after_type_declarator:
2740 direct_after_type_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2741 { $$ = make_call_declarator ($$, $2, $3, $4); }
2742 | direct_after_type_declarator '[' nonmomentary_expr ']'
2743 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
2744 | direct_after_type_declarator '[' ']'
2745 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
2746 | '(' after_type_declarator_intern ')'
2748 | nested_name_specifier type_name %prec EMPTY
2749 { push_nested_class ($1, 3);
2750 $$ = build_parse_node (SCOPE_REF, $$, $2);
2751 TREE_COMPLEXITY ($$) = current_class_depth; }
2752 | type_name %prec EMPTY
2756 type_name %prec EMPTY
2758 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2760 $$ = lookup_name ($1, 1);
2761 maybe_note_name_used_in_class ($1, $$);
2766 | global_scope type_name
2768 if (TREE_CODE ($2) == IDENTIFIER_NODE)
2769 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
2772 got_scope = NULL_TREE;
2779 | global_scope nested_type
2784 nested_name_specifier type_name %prec EMPTY
2785 { $$ = get_type_decl ($2); }
2788 /* A declarator allowed whether or not there has been
2789 an explicit typespec. These cannot redeclare a typedef-name. */
2791 notype_declarator_intern:
2793 | attributes notype_declarator
2795 /* Provide support for '(' attributes '*' declarator ')'
2797 $$ = decl_tree_cons ($1, $2, NULL_TREE);
2802 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2803 { $$ = make_pointer_declarator ($2.t, $3); }
2804 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2805 { $$ = make_reference_declarator ($2.t, $3); }
2806 | '*' notype_declarator_intern %prec UNARY
2807 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2808 | '&' notype_declarator_intern %prec UNARY
2809 { $$ = make_reference_declarator (NULL_TREE, $2); }
2810 | ptr_to_mem cv_qualifiers notype_declarator_intern
2811 { tree arg = make_pointer_declarator ($2, $3);
2812 $$ = build_parse_node (SCOPE_REF, $1, arg);
2814 | direct_notype_declarator
2817 complex_notype_declarator:
2818 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2819 { $$ = make_pointer_declarator ($2.t, $3); }
2820 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2821 { $$ = make_reference_declarator ($2.t, $3); }
2822 | '*' complex_notype_declarator %prec UNARY
2823 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2824 | '&' complex_notype_declarator %prec UNARY
2825 { $$ = make_reference_declarator (NULL_TREE, $2); }
2826 | ptr_to_mem cv_qualifiers notype_declarator_intern
2827 { tree arg = make_pointer_declarator ($2, $3);
2828 $$ = build_parse_node (SCOPE_REF, $1, arg);
2830 | complex_direct_notype_declarator
2833 complex_direct_notype_declarator:
2834 direct_notype_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2835 { $$ = make_call_declarator ($$, $2, $3, $4); }
2836 | '(' complex_notype_declarator ')'
2838 | direct_notype_declarator '[' nonmomentary_expr ']'
2839 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
2840 | direct_notype_declarator '[' ']'
2841 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
2842 | notype_qualified_id
2843 { enter_scope_of ($1); }
2844 | nested_name_specifier notype_template_declarator
2845 { got_scope = NULL_TREE;
2846 $$ = build_parse_node (SCOPE_REF, $1, $2);
2847 enter_scope_of ($$);
2852 nested_name_specifier unqualified_id
2853 { got_scope = NULL_TREE;
2854 $$ = build_parse_node (SCOPE_REF, $$, $2); }
2855 | nested_name_specifier object_template_id
2856 { got_scope = NULL_TREE;
2857 $$ = build_parse_node (SCOPE_REF, $1, $2); }
2860 notype_qualified_id:
2861 nested_name_specifier notype_unqualified_id
2862 { got_scope = NULL_TREE;
2863 $$ = build_parse_node (SCOPE_REF, $$, $2); }
2864 | nested_name_specifier object_template_id
2865 { got_scope = NULL_TREE;
2866 $$ = build_parse_node (SCOPE_REF, $1, $2); }
2871 | global_scope notype_qualified_id
2876 typespec '(' nonnull_exprlist ')'
2877 { $$ = build_functional_cast ($1.t, $3); }
2878 | typespec '(' expr_or_declarator_intern ')'
2879 { $$ = reparse_decl_as_expr ($1.t, $3); }
2880 | typespec fcast_or_absdcl %prec EMPTY
2881 { $$ = reparse_absdcl_as_expr ($1.t, $2); }
2886 | template_type %prec EMPTY
2889 nested_name_specifier:
2890 nested_name_specifier_1
2891 | nested_name_specifier nested_name_specifier_1
2893 | nested_name_specifier TEMPLATE explicit_template_type SCOPE
2894 { got_scope = $$ = make_typename_type ($1, $3); }
2897 /* Why the @#$%^& do type_name and notype_identifier need to be expanded
2898 inline here?!? (jason) */
2899 nested_name_specifier_1:
2902 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2905 maybe_note_name_used_in_class ($1, $$);
2908 complete_type (TYPE_MAIN_VARIANT (TREE_TYPE ($$)));
2912 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2914 got_scope = $$ = TREE_TYPE ($$);
2918 if (TREE_CODE ($$) == IDENTIFIER_NODE)
2922 | template_type SCOPE
2923 { got_scope = $$ = complete_type (TREE_TYPE ($1)); }
2924 /* These break 'const i;'
2928 cp_error ("`%D' is not an aggregate typedef",
2929 lastiddecl ? lastiddecl : $$);
2930 $$ = error_mark_node;
2933 { goto failed_scope; } */
2938 | global_scope typename_sub0
2943 typename_sub1 identifier %prec EMPTY
2945 if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't')
2946 $$ = make_typename_type ($1, $2);
2947 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
2948 cp_error ("`%T' is not a class or namespace", $2);
2952 if (TREE_CODE ($$) == TYPE_DECL)
2953 $$ = TREE_TYPE ($$);
2956 | typename_sub1 template_type %prec EMPTY
2957 { $$ = TREE_TYPE ($2); }
2958 | typename_sub1 explicit_template_type %prec EMPTY
2959 { $$ = make_typename_type ($1, $2); }
2960 | typename_sub1 TEMPLATE explicit_template_type %prec EMPTY
2961 { $$ = make_typename_type ($1, $3); }
2967 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2968 cp_error ("`%T' is not a class or namespace", $1);
2970 | typename_sub1 typename_sub2
2972 if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't')
2973 $$ = make_typename_type ($1, $2);
2974 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
2975 cp_error ("`%T' is not a class or namespace", $2);
2979 if (TREE_CODE ($$) == TYPE_DECL)
2980 $$ = TREE_TYPE ($$);
2983 | typename_sub1 explicit_template_type SCOPE
2984 { got_scope = $$ = make_typename_type ($1, $2); }
2985 | typename_sub1 TEMPLATE explicit_template_type SCOPE
2986 { got_scope = $$ = make_typename_type ($1, $3); }
2992 if (TREE_CODE ($1) != IDENTIFIER_NODE)
2995 /* Retrieve the type for the identifier, which might involve
2996 some computation. */
2997 got_scope = $$ = complete_type (IDENTIFIER_TYPE_VALUE ($1));
2999 if ($$ == error_mark_node)
3000 cp_error ("`%T' is not a class or namespace", $1);
3004 if (TREE_CODE ($1) != IDENTIFIER_NODE)
3006 got_scope = $$ = complete_type (TREE_TYPE ($$));
3008 | template_type SCOPE
3009 { got_scope = $$ = complete_type (TREE_TYPE ($$)); }
3014 if (TREE_CODE ($$) == IDENTIFIER_NODE)
3020 explicit_template_type:
3021 identifier '<' template_arg_list_opt template_close_bracket
3022 { $$ = build_min_nt (TEMPLATE_ID_EXPR, $1, $3); }
3026 global_scope type_name
3028 if (TREE_CODE ($2) == IDENTIFIER_NODE)
3029 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
3032 got_scope = NULL_TREE;
3035 | global_scope nested_type
3040 nested_name_specifier '*'
3041 { got_scope = NULL_TREE; }
3042 | global_scope nested_name_specifier '*'
3043 { $$ = $2; got_scope = NULL_TREE; }
3046 /* All uses of explicit global scope must go through this nonterminal so
3047 that got_scope will be set before yylex is called to get the next token. */
3050 { got_scope = void_type_node; }
3053 /* ANSI new-declarator (5.3.4) */
3055 '*' cv_qualifiers new_declarator
3056 { $$ = make_pointer_declarator ($2, $3); }
3057 | '*' cv_qualifiers %prec EMPTY
3058 { $$ = make_pointer_declarator ($2, NULL_TREE); }
3059 | '&' cv_qualifiers new_declarator %prec EMPTY
3060 { $$ = make_reference_declarator ($2, $3); }
3061 | '&' cv_qualifiers %prec EMPTY
3062 { $$ = make_reference_declarator ($2, NULL_TREE); }
3063 | ptr_to_mem cv_qualifiers %prec EMPTY
3064 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3065 $$ = build_parse_node (SCOPE_REF, $1, arg);
3067 | ptr_to_mem cv_qualifiers new_declarator
3068 { tree arg = make_pointer_declarator ($2, $3);
3069 $$ = build_parse_node (SCOPE_REF, $1, arg);
3071 | direct_new_declarator %prec EMPTY
3074 /* ANSI direct-new-declarator (5.3.4) */
3075 direct_new_declarator:
3077 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3078 | direct_new_declarator '[' nonmomentary_expr ']'
3079 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3086 /* Provide support for '(' attributes '*' declarator ')'
3088 $$ = decl_tree_cons ($1, $2, NULL_TREE);
3092 /* ANSI abstract-declarator (8.1) */
3094 '*' nonempty_cv_qualifiers absdcl_intern
3095 { $$ = make_pointer_declarator ($2.t, $3); }
3097 { $$ = make_pointer_declarator (NULL_TREE, $2); }
3098 | '*' nonempty_cv_qualifiers %prec EMPTY
3099 { $$ = make_pointer_declarator ($2.t, NULL_TREE); }
3101 { $$ = make_pointer_declarator (NULL_TREE, NULL_TREE); }
3102 | '&' nonempty_cv_qualifiers absdcl_intern
3103 { $$ = make_reference_declarator ($2.t, $3); }
3105 { $$ = make_reference_declarator (NULL_TREE, $2); }
3106 | '&' nonempty_cv_qualifiers %prec EMPTY
3107 { $$ = make_reference_declarator ($2.t, NULL_TREE); }
3109 { $$ = make_reference_declarator (NULL_TREE, NULL_TREE); }
3110 | ptr_to_mem cv_qualifiers %prec EMPTY
3111 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3112 $$ = build_parse_node (SCOPE_REF, $1, arg);
3114 | ptr_to_mem cv_qualifiers absdcl_intern
3115 { tree arg = make_pointer_declarator ($2, $3);
3116 $$ = build_parse_node (SCOPE_REF, $1, arg);
3118 | direct_abstract_declarator %prec EMPTY
3121 /* ANSI direct-abstract-declarator (8.1) */
3122 direct_abstract_declarator:
3123 '(' absdcl_intern ')'
3125 /* `(typedef)1' is `int'. */
3126 | direct_abstract_declarator '(' parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3127 { $$ = make_call_declarator ($$, $3, $5, $6); }
3128 | direct_abstract_declarator LEFT_RIGHT cv_qualifiers exception_specification_opt %prec '.'
3129 { $$ = make_call_declarator ($$, empty_parms (), $3, $4); }
3130 | direct_abstract_declarator '[' nonmomentary_expr ']' %prec '.'
3131 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3132 | direct_abstract_declarator '[' ']' %prec '.'
3133 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
3134 | '(' complex_parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3135 { $$ = make_call_declarator (NULL_TREE, $2, $4, $5); }
3136 | regcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3137 { set_quals_and_spec ($$, $2, $3); }
3138 | fcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3139 { set_quals_and_spec ($$, $2, $3); }
3140 | '[' nonmomentary_expr ']' %prec '.'
3141 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3143 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, NULL_TREE); }
3146 /* For C++, decls and stmts can be intermixed, so we don't need to
3147 have a special rule that won't start parsing the stmt section
3148 until we have a stmt that parses without errors. */
3161 /* Read zero or more forward-declarations for labels
3162 that nested functions can jump to. */
3167 pedwarn ("ANSI C++ forbids label declarations"); }
3172 | label_decls label_decl
3176 LABEL identifiers_or_typenames ';'
3178 for (link = $2; link; link = TREE_CHAIN (link))
3180 tree label = shadow_label (TREE_VALUE (link));
3181 C_DECLARED_LABEL_FLAG (label) = 1;
3182 declare_nonlocal_label (label);
3187 /* This is the body of a function definition.
3188 It causes syntax errors to ignore to the next openbrace. */
3197 { $<ttype>$ = begin_compound_stmt (0); }
3199 { $$ = finish_compound_stmt (0, $<ttype>2); }
3205 $<ttype>$ = begin_if_stmt ();
3206 cond_stmt_keyword = "if";
3209 { finish_if_stmt_cond ($3, $<ttype>2); }
3210 implicitly_scoped_stmt
3211 { $<ttype>$ = finish_then_clause ($<ttype>2); }
3214 implicitly_scoped_stmt:
3216 | { $<ttype>$ = begin_compound_stmt (0); }
3218 { $$ = finish_compound_stmt (0, $<ttype>1); }
3231 { finish_expr_stmt ($1); }
3233 { begin_else_clause (); }
3234 implicitly_scoped_stmt
3236 finish_else_clause ($<ttype>1);
3239 | simple_if %prec IF
3240 { finish_if_stmt (); }
3243 $<ttype>$ = begin_while_stmt ();
3244 cond_stmt_keyword = "while";
3247 { finish_while_stmt_cond ($3, $<ttype>2); }
3249 { finish_while_stmt ($<ttype>2); }
3251 { $<ttype>$ = begin_do_stmt (); }
3252 implicitly_scoped_stmt WHILE
3254 finish_do_body ($<ttype>2);
3255 cond_stmt_keyword = "do";
3257 paren_expr_or_null ';'
3258 { finish_do_stmt ($6, $<ttype>2); }
3260 { $<ttype>$ = begin_for_stmt (); }
3261 '(' for.init.statement
3262 { finish_for_init_stmt ($<ttype>2); }
3264 { finish_for_cond ($6, $<ttype>2); }
3266 { finish_for_expr ($9, $<ttype>2); }
3268 { finish_for_stmt ($9, $<ttype>2); }
3270 { begin_switch_stmt (); }
3272 { $<ttype>$ = finish_switch_cond ($4); }
3273 implicitly_scoped_stmt
3274 { finish_switch_stmt ($4, $<ttype>6); }
3275 | CASE expr_no_commas ':'
3276 { finish_case_label ($2, NULL_TREE); }
3278 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
3279 { finish_case_label ($2, $4); }
3282 { finish_case_label (NULL_TREE, NULL_TREE); }
3285 { finish_break_stmt (); }
3287 { finish_continue_stmt (); }
3288 | RETURN_KEYWORD ';'
3289 { finish_return_stmt (NULL_TREE); }
3290 | RETURN_KEYWORD expr ';'
3291 { finish_return_stmt ($2); }
3292 | asm_keyword maybe_cv_qualifier '(' string ')' ';'
3294 finish_asm_stmt ($2, $4, NULL_TREE, NULL_TREE,
3297 /* This is the case with just output operands. */
3298 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ')' ';'
3300 finish_asm_stmt ($2, $4, $6, NULL_TREE,
3303 /* This is the case with input operands as well. */
3304 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':' asm_operands ')' ';'
3305 { finish_asm_stmt ($2, $4, $6, $8, NULL_TREE); }
3306 /* This is the case with clobbered registers as well. */
3307 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':'
3308 asm_operands ':' asm_clobbers ')' ';'
3309 { finish_asm_stmt ($2, $4, $6, $8, $10); }
3313 pedwarn ("ANSI C++ forbids computed gotos");
3314 finish_goto_stmt ($3);
3316 | GOTO identifier ';'
3317 { finish_goto_stmt ($2); }
3321 { error ("label must be followed by statement");
3328 | namespace_using_decl
3329 { do_local_using_decl ($1); }
3335 { $<ttype>$ = begin_function_try_block (); }
3336 ctor_initializer_opt compstmt
3337 { finish_function_try_block ($<ttype>2); }
3340 finish_function_handler_sequence ($<ttype>2);
3347 { $<ttype>$ = begin_try_block (); }
3349 { finish_try_block ($<ttype>2); }
3351 { finish_handler_sequence ($<ttype>2); }
3356 | handler_seq handler
3361 { $<ttype>$ = begin_handler(); }
3363 { finish_handler_parms ($<ttype>2); }
3365 { finish_handler ($<ttype>2); }
3369 typed_typespecs %prec EMPTY
3370 | nonempty_cv_qualifiers %prec EMPTY
3375 { expand_start_catch_block (NULL_TREE, NULL_TREE); }
3376 /* This doesn't allow reference parameters, the below does.
3377 | '(' type_specifier_seq absdcl ')'
3378 { check_for_new_type ("inside exception declarations", $2);
3379 expand_start_catch_block ($2.t, $3); }
3380 | '(' type_specifier_seq ')'
3381 { check_for_new_type ("inside exception declarations", $2);
3382 expand_start_catch_block ($2.t, NULL_TREE); }
3383 | '(' type_specifier_seq notype_declarator ')'
3384 { check_for_new_type ("inside exception declarations", $2);
3385 expand_start_catch_block ($2.t, $3); }
3386 | '(' typed_typespecs after_type_declarator ')'
3387 { check_for_new_type ("inside exception declarations", $2);
3388 expand_start_catch_block ($2.t, $3); }
3389 This allows reference parameters... */
3391 { check_for_new_type ("inside exception declarations", $2);
3392 expand_start_catch_block (TREE_PURPOSE ($2.t),
3393 TREE_VALUE ($2.t)); }
3400 label = define_label (input_filename, lineno, $1);
3401 if (label && ! minimal_parse_mode)
3402 expand_label (label);
3414 { if ($1) cplus_expand_expr_stmt ($1); }
3418 pedwarn ("ANSI C++ forbids compound statements inside for initializations");
3422 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
3426 { emit_line_note (input_filename, lineno);
3429 { emit_line_note (input_filename, lineno); }
3440 /* These are the operands other than the first string and colon
3441 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
3445 | nonnull_asm_operands
3448 nonnull_asm_operands:
3450 | nonnull_asm_operands ',' asm_operand
3451 { $$ = chainon ($$, $3); }
3456 { $$ = build_tree_list ($$, $3); }
3461 { $$ = tree_cons (NULL_TREE, $$, NULL_TREE); }
3462 | asm_clobbers ',' STRING
3463 { $$ = tree_cons (NULL_TREE, $3, $$); }
3466 /* This is what appears inside the parens in a function declarator.
3467 Its value is represented in the format that grokdeclarator expects.
3469 In C++, declaring a function with no parameters
3470 means that that function takes *no* parameters. */
3479 { $$ = finish_parmlist (build_tree_list (NULL_TREE, $1.t), 0);
3480 check_for_new_type ("inside parameter list", $1); }
3483 /* This nonterminal does not include the common sequence '(' type_id ')',
3484 as it is ambiguous and must be disambiguated elsewhere. */
3487 { $$ = finish_parmlist ($$, 0); }
3488 | parms_comma ELLIPSIS
3489 { $$ = finish_parmlist ($1, 1); }
3490 /* C++ allows an ellipsis without a separating ',' */
3492 { $$ = finish_parmlist ($1, 1); }
3494 { $$ = finish_parmlist (build_tree_list (NULL_TREE,
3497 { $$ = finish_parmlist (NULL_TREE, 1); }
3500 /* This helps us recover from really nasty
3501 parse errors, for example, a missing right
3503 yyerror ("possibly missing ')'");
3504 $$ = finish_parmlist ($1, 0);
3510 /* This helps us recover from really nasty
3511 parse errors, for example, a missing right
3513 yyerror ("possibly missing ')'");
3514 $$ = finish_parmlist (build_tree_list (NULL_TREE,
3521 /* A default argument to a */
3524 { maybe_snarf_defarg (); }
3534 /* A nonempty list of parameter declarations or type names. */
3537 { check_for_new_type ("in a parameter list", $1);
3538 $$ = build_tree_list (NULL_TREE, $1.t); }
3540 { check_for_new_type ("in a parameter list", $1);
3541 $$ = build_tree_list ($2, $1.t); }
3542 | parms_comma full_parm
3543 { check_for_new_type ("in a parameter list", $2);
3544 $$ = chainon ($$, $2.t); }
3545 | parms_comma bad_parm
3546 { $$ = chainon ($$, build_tree_list (NULL_TREE, $2)); }
3547 | parms_comma bad_parm '=' init
3548 { $$ = chainon ($$, build_tree_list ($4, $2)); }
3554 { check_for_new_type ("in a parameter list", $1);
3555 $$ = build_tree_list (NULL_TREE, $1.t); }
3558 /* A single parameter declaration or parameter type name,
3559 as found in a parmlist. */
3561 /* Here we expand typed_declspecs inline to avoid mis-parsing of
3562 TYPESPEC IDENTIFIER. */
3563 typed_declspecs1 declarator
3564 { tree specs = strip_attrs ($1.t);
3565 $$.new_type_flag = $1.new_type_flag;
3566 $$.t = build_tree_list (specs, $2); }
3567 | typed_typespecs declarator
3568 { $$.t = build_tree_list ($1.t, $2);
3569 $$.new_type_flag = $1.new_type_flag; }
3570 | typespec declarator
3571 { $$.t = build_tree_list (build_decl_list (NULL_TREE, $1.t),
3573 $$.new_type_flag = $1.new_type_flag; }
3574 | typed_declspecs1 absdcl
3575 { tree specs = strip_attrs ($1.t);
3576 $$.t = build_tree_list (specs, $2);
3577 $$.new_type_flag = $1.new_type_flag; }
3578 | typed_declspecs1 %prec EMPTY
3579 { tree specs = strip_attrs ($1.t);
3580 $$.t = build_tree_list (specs, NULL_TREE);
3581 $$.new_type_flag = $1.new_type_flag; }
3582 | declmods notype_declarator
3583 { tree specs = strip_attrs ($1);
3584 $$.t = build_tree_list (specs, $2);
3585 $$.new_type_flag = 0; }
3590 { $$.t = build_tree_list (NULL_TREE, $1.t);
3591 $$.new_type_flag = $1.new_type_flag; }
3593 { $$.t = build_tree_list ($2, $1.t);
3594 $$.new_type_flag = $1.new_type_flag; }
3603 /* empty */ %prec EMPTY
3604 { see_typename (); }
3608 /* empty */ %prec EMPTY
3610 error ("type specifier omitted for parameter");
3611 $$ = build_tree_list (integer_type_node, NULL_TREE);
3615 error ("type specifier omitted for parameter");
3616 if (TREE_CODE ($$) == SCOPE_REF
3617 && (TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TYPE_PARM
3618 || TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TEMPLATE_PARM))
3619 cp_error (" perhaps you want `typename %E' to make it a type", $$);
3620 $$ = build_tree_list (integer_type_node, $$);
3624 exception_specification_opt:
3625 /* empty */ %prec EMPTY
3627 | THROW '(' ansi_raise_identifiers ')' %prec EMPTY
3629 | THROW LEFT_RIGHT %prec EMPTY
3630 { $$ = empty_except_spec; }
3633 ansi_raise_identifier:
3636 check_for_new_type ("exception specifier", $1);
3637 $$ = groktypename ($1.t);
3641 ansi_raise_identifiers:
3642 ansi_raise_identifier
3643 { $$ = add_exception_specifier (NULL_TREE, $1, 1); }
3644 | ansi_raise_identifiers ',' ansi_raise_identifier
3645 { $$ = add_exception_specifier ($1, $3, 1); }
3648 conversion_declarator:
3649 /* empty */ %prec EMPTY
3651 | '*' cv_qualifiers conversion_declarator
3652 { $$ = make_pointer_declarator ($2, $3); }
3653 | '&' cv_qualifiers conversion_declarator
3654 { $$ = make_reference_declarator ($2, $3); }
3655 | ptr_to_mem cv_qualifiers conversion_declarator
3656 { tree arg = make_pointer_declarator ($2, $3);
3657 $$ = build_parse_node (SCOPE_REF, $1, arg);
3663 { got_scope = NULL_TREE; }
3668 { $$ = ansi_opname[MULT_EXPR]; }
3670 { $$ = ansi_opname[TRUNC_DIV_EXPR]; }
3672 { $$ = ansi_opname[TRUNC_MOD_EXPR]; }
3674 { $$ = ansi_opname[PLUS_EXPR]; }
3676 { $$ = ansi_opname[MINUS_EXPR]; }
3678 { $$ = ansi_opname[BIT_AND_EXPR]; }
3680 { $$ = ansi_opname[BIT_IOR_EXPR]; }
3682 { $$ = ansi_opname[BIT_XOR_EXPR]; }
3684 { $$ = ansi_opname[BIT_NOT_EXPR]; }
3686 { $$ = ansi_opname[COMPOUND_EXPR]; }
3687 | operator ARITHCOMPARE
3688 { $$ = ansi_opname[$2]; }
3690 { $$ = ansi_opname[LT_EXPR]; }
3692 { $$ = ansi_opname[GT_EXPR]; }
3693 | operator EQCOMPARE
3694 { $$ = ansi_opname[$2]; }
3696 { $$ = ansi_assopname[$2]; }
3698 { $$ = ansi_opname [MODIFY_EXPR]; }
3700 { $$ = ansi_opname[$2]; }
3702 { $$ = ansi_opname[$2]; }
3704 { $$ = ansi_opname[POSTINCREMENT_EXPR]; }
3705 | operator MINUSMINUS
3706 { $$ = ansi_opname[PREDECREMENT_EXPR]; }
3708 { $$ = ansi_opname[TRUTH_ANDIF_EXPR]; }
3710 { $$ = ansi_opname[TRUTH_ORIF_EXPR]; }
3712 { $$ = ansi_opname[TRUTH_NOT_EXPR]; }
3714 { $$ = ansi_opname[COND_EXPR]; }
3716 { $$ = ansi_opname[$2]; }
3717 | operator POINTSAT %prec EMPTY
3718 { $$ = ansi_opname[COMPONENT_REF]; }
3719 | operator POINTSAT_STAR %prec EMPTY
3720 { $$ = ansi_opname[MEMBER_REF]; }
3721 | operator LEFT_RIGHT
3722 { $$ = ansi_opname[CALL_EXPR]; }
3724 { $$ = ansi_opname[ARRAY_REF]; }
3725 | operator NEW %prec EMPTY
3726 { $$ = ansi_opname[NEW_EXPR]; }
3727 | operator DELETE %prec EMPTY
3728 { $$ = ansi_opname[DELETE_EXPR]; }
3729 | operator NEW '[' ']'
3730 { $$ = ansi_opname[VEC_NEW_EXPR]; }
3731 | operator DELETE '[' ']'
3732 { $$ = ansi_opname[VEC_DELETE_EXPR]; }
3733 /* Names here should be looked up in class scope ALSO. */
3734 | operator type_specifier_seq conversion_declarator
3735 { $$ = grokoptypename ($2.t, $3); }
3737 { $$ = ansi_opname[ERROR_MARK]; }
3744 debug_yytranslate (value)
3747 return yytname[YYTRANSLATE (value)];