1 /* YACC parser for C++ syntax.
2 Copyright (C) 1988, 89, 93-98, 1999, 2000 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. */
47 /* Since parsers are distinct for each language, put the language string
48 definition here. (fnf) */
49 const char * const language_string = "GNU C++";
51 extern struct obstack permanent_obstack;
53 extern int end_of_file;
55 /* Like YYERROR but do call yyerror. */
56 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
58 #define OP0(NODE) (TREE_OPERAND (NODE, 0))
59 #define OP1(NODE) (TREE_OPERAND (NODE, 1))
61 /* Contains the statement keyword (if/while/do) to include in an
62 error message if the user supplies an empty conditional expression. */
63 static const char *cond_stmt_keyword;
65 static tree empty_parms PARAMS ((void));
66 static void parse_decl PARAMS ((tree, tree, tree, int, tree *));
68 /* Nonzero if we have an `extern "C"' acting as an extern specifier. */
72 /* Cons up an empty parameter list. */
79 || current_class_type != NULL)
80 parms = void_list_node;
95 flagged_type_tree ftype;
96 struct pending_inline *pi;
99 /* All identifiers that are not reserved words
100 and are not declared typedefs in the current block */
103 /* All identifiers that are declared typedefs in the current block.
104 In some contexts, they are treated just like IDENTIFIER,
105 but they can also serve as typespecs in declarations. */
109 /* A template function. */
112 /* Reserved words that specify storage class.
113 yylval contains an IDENTIFIER_NODE which indicates which one. */
116 /* Reserved words that specify type.
117 yylval contains an IDENTIFIER_NODE which indicates which one. */
120 /* Reserved words that qualify type: "const" or "volatile".
121 yylval contains an IDENTIFIER_NODE which indicates which one. */
124 /* Character or numeric constants.
125 yylval is the node for the constant. */
128 /* String constants in raw form.
129 yylval is a STRING_CST node. */
132 /* "...", used for functions with variable arglists. */
135 /* the reserved words */
136 /* SCO include files test "ASM", so use something else. */
137 %token SIZEOF ENUM /* STRUCT UNION */ IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
138 %token BREAK CONTINUE RETURN_KEYWORD GOTO ASM_KEYWORD TYPEOF ALIGNOF
140 %token ATTRIBUTE EXTENSION LABEL
141 %token REALPART IMAGPART VA_ARG
143 /* the reserved words... C++ extensions */
145 %token <ttype> VISSPEC
146 %token DELETE NEW THIS OPERATOR CXX_TRUE CXX_FALSE
147 %token NAMESPACE TYPENAME_KEYWORD USING
148 %token LEFT_RIGHT TEMPLATE
149 %token TYPEID DYNAMIC_CAST STATIC_CAST REINTERPRET_CAST CONST_CAST
152 /* Define the operator tokens and their precedences.
153 The value is an integer because, if used, it is the tree code
154 to use in the expression made from the operator. */
156 %left EMPTY /* used to resolve s/r with epsilon */
160 /* Add precedence rules to solve dangling else s/r conflict */
164 %left IDENTIFIER PFUNCNAME TYPENAME SELFNAME PTYPENAME SCSPEC TYPESPEC CV_QUALIFIER ENUM AGGR ELLIPSIS TYPEOF SIGOF OPERATOR NSNAME TYPENAME_KEYWORD
170 %right <code> ASSIGN '='
178 %left <code> EQCOMPARE
179 %left <code> ARITHCOMPARE '<' '>'
180 %left <code> LSHIFT RSHIFT
182 %left <code> '*' '/' '%'
183 %left <code> POINTSAT_STAR DOT_STAR
184 %right <code> UNARY PLUSPLUS MINUSMINUS '~'
186 %left <ttype> LEFT_RIGHT
187 %left <code> POINTSAT '.' '(' '['
189 %right SCOPE /* C++ extension */
190 %nonassoc NEW DELETE TRY CATCH
194 %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist
195 %type <ttype> PFUNCNAME maybe_identifier
196 %type <ttype> paren_expr_or_null nontrivial_exprlist SELFNAME
197 %type <ttype> expr_no_commas cast_expr unary_expr primary string STRING
198 %type <ttype> reserved_declspecs boolean.literal
199 %type <ttype> reserved_typespecquals
200 %type <ttype> declmods
201 %type <ttype> SCSPEC TYPESPEC CV_QUALIFIER maybe_cv_qualifier
202 %type <ttype> init initlist maybeasm maybe_init defarg defarg1
203 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
204 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
205 %type <ttype> any_word
207 %type <ttype> compstmt implicitly_scoped_stmt
209 %type <ttype> declarator notype_declarator after_type_declarator
210 %type <ttype> notype_declarator_intern absdcl_intern
211 %type <ttype> after_type_declarator_intern
212 %type <ttype> direct_notype_declarator direct_after_type_declarator
213 %type <itype> components notype_components
214 %type <ttype> component_decl component_decl_1
215 %type <ttype> component_declarator component_declarator0
216 %type <ttype> notype_component_declarator notype_component_declarator0
217 %type <ttype> after_type_component_declarator after_type_component_declarator0
218 %type <ttype> absdcl cv_qualifiers
219 %type <ttype> direct_abstract_declarator conversion_declarator
220 %type <ttype> new_declarator direct_new_declarator
221 %type <ttype> xexpr parmlist parms bad_parm
222 %type <ttype> identifiers_or_typenames
223 %type <ttype> fcast_or_absdcl regcast_or_absdcl
224 %type <ttype> expr_or_declarator expr_or_declarator_intern
225 %type <ttype> complex_notype_declarator
226 %type <ttype> notype_unqualified_id unqualified_id qualified_id
227 %type <ttype> template_id do_id object_template_id notype_template_declarator
228 %type <ttype> overqualified_id notype_qualified_id any_id
229 %type <ttype> complex_direct_notype_declarator functional_cast
230 %type <ttype> complex_parmlist parms_comma
231 %type <ttype> namespace_qualifier namespace_using_decl
233 %type <ftype> type_id new_type_id typed_typespecs typespec typed_declspecs
234 %type <ftype> typed_declspecs1 type_specifier_seq nonempty_cv_qualifiers
235 %type <ftype> structsp typespecqual_reserved parm named_parm full_parm
237 %type <itype> extension
240 %token <ttype> PTYPENAME
241 %token <ttype> EXTERN_LANG_STRING ALL
242 %token <ttype> PRE_PARSED_CLASS_DECL DEFARG DEFARG_MARKER
243 %token <pi> PRE_PARSED_FUNCTION_DECL
244 %type <ttype> component_constructor_declarator
245 %type <ttype> fn.def2 return_id constructor_declarator
247 %type <itype> ctor_initializer_opt function_try_block
248 %type <ttype> named_class_head_sans_basetype
249 %type <ftype> class_head named_class_head
250 %type <ftype> named_complex_class_head_sans_basetype
251 %type <ttype> unnamed_class_head
252 %type <ttype> base_class_list
253 %type <ttype> base_class_access_list
254 %type <ttype> base_class maybe_base_class_list base_class.1
255 %type <ttype> exception_specification_opt ansi_raise_identifier ansi_raise_identifiers
256 %type <ttype> operator_name
257 %type <ttype> object aggr
258 %type <itype> new delete
259 /* %type <ttype> primary_no_id */
260 %type <ttype> maybe_parmlist
261 %type <itype> member_init_list
262 %type <ttype> template_header template_parm_list template_parm
263 %type <ttype> template_type_parm template_template_parm
264 %type <code> template_close_bracket
265 %type <ttype> apparent_template_type
266 %type <ttype> template_type template_arg_list template_arg_list_opt
267 %type <ttype> template_arg
268 %type <ttype> condition xcond paren_cond_or_null
269 %type <ttype> type_name nested_name_specifier nested_type ptr_to_mem
270 %type <ttype> complete_type_name notype_identifier nonnested_type
271 %type <ttype> complex_type_name nested_name_specifier_1
272 %type <ttype> new_initializer new_placement
273 %type <ttype> using_decl
274 %type <ttype> typename_sub typename_sub0 typename_sub1 typename_sub2
275 %type <ttype> explicit_template_type
276 /* in order to recognize aggr tags as defining and thus shadowing. */
277 %token TYPENAME_DEFN IDENTIFIER_DEFN PTYPENAME_DEFN
278 %type <ttype> named_class_head_sans_basetype_defn
279 %type <ttype> identifier_defn IDENTIFIER_DEFN TYPENAME_DEFN PTYPENAME_DEFN
280 %type <ttype> handler_args
281 %type <ttype> self_template_type .finish_template_type
286 /* Used in lex.c for parsing pragmas. */
289 /* lex.c and pt.c depend on this being the last token. Define
290 any new tokens before this one! */
291 %token END_OF_SAVED_INPUT
294 /* List of types and structure classes of the current declaration. */
295 static tree current_declspecs;
297 /* List of prefix attributes in effect.
298 Prefix attributes are parsed by the reserved_declspecs and declmods
299 rules. They create a list that contains *both* declspecs and attrs. */
300 /* ??? It is not clear yet that all cases where an attribute can now appear in
301 a declspec list have been updated. */
302 static tree prefix_attributes;
304 /* When defining an aggregate, this is the kind of the most recent one
305 being defined. (For example, this might be class_type_node.) */
306 static tree current_aggr;
308 /* When defining an enumeration, this is the type of the enumeration. */
309 static tree current_enum_type;
311 /* Tell yyparse how to print a token's value, if yydebug is set. */
313 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
314 extern void yyprint PARAMS ((FILE *, int, YYSTYPE));
315 extern tree combine_strings PARAMS ((tree));
318 parse_decl (declarator, specs_attrs, attributes, initialized, decl)
325 split_specs_attrs (specs_attrs, ¤t_declspecs, &prefix_attributes);
326 if (current_declspecs
327 && TREE_CODE (current_declspecs) != TREE_LIST)
328 current_declspecs = build_decl_list (NULL_TREE, current_declspecs);
329 if (have_extern_spec && !used_extern_spec)
331 current_declspecs = decl_tree_cons (NULL_TREE,
332 get_identifier ("extern"),
334 used_extern_spec = 1;
336 *decl = start_decl (declarator, current_declspecs, initialized,
337 attributes, prefix_attributes);
343 ggc_add_tree_root (¤t_declspecs, 1);
344 ggc_add_tree_root (&prefix_attributes, 1);
345 ggc_add_tree_root (¤t_aggr, 1);
346 ggc_add_tree_root (¤t_enum_type, 1);
354 { finish_translation_unit (); }
357 /* the reason for the strange actions in this rule
358 is so that notype_initdecls when reached via datadef
359 can find a valid list of type and sc specs in $0. */
362 { $<ttype>$ = NULL_TREE; }
364 { $<ttype>$ = NULL_TREE; }
365 | extdefs lang_extdef
366 { $<ttype>$ = NULL_TREE; }
375 { have_extern_spec = 1;
376 used_extern_spec = 0;
377 $<ttype>$ = NULL_TREE; }
380 { have_extern_spec = 0; }
394 { if (pending_lang_change) do_pending_lang_change(); }
396 { if (! toplevel_bindings_p ())
401 fndef eat_saved_input
402 { if (pending_inlines) do_pending_inlines (); }
404 { if (pending_inlines) do_pending_inlines (); }
406 { if (pending_inlines) do_pending_inlines (); }
407 | asm_keyword '(' string ')' ';'
408 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
410 | extern_lang_string '{' extdefs_opt '}'
411 { pop_lang_context (); }
412 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
413 { if (pending_inlines) do_pending_inlines ();
414 pop_lang_context (); }
415 | extern_lang_string .hush_warning datadef .warning_ok
416 { if (pending_inlines) do_pending_inlines ();
417 pop_lang_context (); }
418 | NAMESPACE identifier '{'
419 { push_namespace ($2); }
421 { pop_namespace (); }
423 { push_namespace (NULL_TREE); }
425 { pop_namespace (); }
428 { do_toplevel_using_decl ($1); }
435 NAMESPACE identifier '='
436 { begin_only_namespace_names (); }
439 end_only_namespace_names ();
442 do_namespace_alias ($2, $5);
449 | USING global_scope qualified_id
451 | USING global_scope unqualified_id
455 namespace_using_decl:
456 USING namespace_qualifier identifier
457 { $$ = build_parse_node (SCOPE_REF, $2, $3); }
458 | USING global_scope identifier
459 { $$ = build_parse_node (SCOPE_REF, global_namespace, $3); }
460 | USING global_scope namespace_qualifier identifier
461 { $$ = build_parse_node (SCOPE_REF, $3, $4); }
466 { begin_only_namespace_names (); }
469 end_only_namespace_names ();
470 /* If no declaration was found, the using-directive is
471 invalid. Since that was not reported, we need the
472 identifier for the error message. */
473 if (TREE_CODE ($4) == IDENTIFIER_NODE && lastiddecl)
475 do_using_directive ($4);
482 if (TREE_CODE ($$) == IDENTIFIER_NODE)
486 | namespace_qualifier NSNAME SCOPE
489 if (TREE_CODE ($$) == IDENTIFIER_NODE)
497 | global_scope qualified_id
499 | global_scope unqualified_id
505 { push_lang_context ($1); }
506 | extern_lang_string EXTERN_LANG_STRING
507 { if (current_lang_name != $2)
508 cp_error ("use of linkage spec `%D' is different from previous spec `%D'", $2, current_lang_name);
509 pop_lang_context (); push_lang_context ($2); }
514 { begin_template_parm_list (); }
515 template_parm_list '>'
516 { $$ = end_template_parm_list ($4); }
518 { begin_specialization();
524 { $$ = process_template_parm (NULL_TREE, $1); }
525 | template_parm_list ',' template_parm
526 { $$ = process_template_parm ($1, $3); }
536 aggr maybe_identifier
537 { $$ = finish_template_type_parm ($1, $2); }
538 | TYPENAME_KEYWORD maybe_identifier
539 { $$ = finish_template_type_parm (class_type_node, $2); }
542 template_template_parm:
543 template_header aggr maybe_identifier
544 { $$ = finish_template_template_parm ($2, $3); }
548 /* The following rules introduce a new reduce/reduce
549 conflict on the ',' and '>' input tokens: they are valid
550 prefixes for a `structsp', which means they could match a
551 nameless parameter. See 14.6, paragraph 3.
552 By putting them before the `parm' rule, we get
553 their match before considering them nameless parameter
556 { $$ = build_tree_list (NULL_TREE, $1); }
557 | template_type_parm '=' type_id
558 { $$ = build_tree_list (groktypename ($3.t), $1); }
560 { $$ = build_tree_list (NULL_TREE, $1.t); }
561 | parm '=' expr_no_commas %prec ARITHCOMPARE
562 { $$ = build_tree_list ($3, $1.t); }
563 | template_template_parm
564 { $$ = build_tree_list (NULL_TREE, $1); }
565 | template_template_parm '=' template_arg
567 if (TREE_CODE ($3) != TEMPLATE_DECL
568 && TREE_CODE ($3) != TEMPLATE_TEMPLATE_PARM
569 && TREE_CODE ($3) != TYPE_DECL)
571 error ("invalid default template argument");
572 $3 = error_mark_node;
574 $$ = build_tree_list ($3, $1);
579 template_header template_extdef
580 { finish_template_decl ($1); }
581 | template_header error %prec EMPTY
582 { finish_template_decl ($1); }
586 fndef eat_saved_input
587 { if (pending_inlines) do_pending_inlines (); }
589 { if (pending_inlines) do_pending_inlines (); }
591 { if (pending_inlines) do_pending_inlines (); }
592 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
593 { if (pending_inlines) do_pending_inlines ();
594 pop_lang_context (); }
595 | extern_lang_string .hush_warning template_datadef .warning_ok
596 { if (pending_inlines) do_pending_inlines ();
597 pop_lang_context (); }
598 | extension template_extdef
604 | declmods notype_initdecls ';'
606 | typed_declspecs initdecls ';'
607 { note_list_got_semicolon ($1.t); }
609 { maybe_process_partial_specialization ($1.t);
610 note_got_semicolon ($1.t); }
615 | declmods notype_initdecls ';'
617 | typed_declspecs initdecls ';'
618 { note_list_got_semicolon ($1.t); }
620 { pedwarn ("empty declaration"); }
621 | explicit_instantiation ';'
622 | typed_declspecs ';'
625 split_specs_attrs ($1.t, &t, &attrs);
627 note_list_got_semicolon ($1.t);
634 ctor_initializer_opt:
653 fn.def1 maybe_return_init ctor_initializer_opt compstmt_or_error
654 { expand_body (finish_function (lineno, (int)$3)); }
655 | fn.def1 maybe_return_init function_try_block
656 { expand_body (finish_function (lineno, (int)$3)); }
657 | fn.def1 maybe_return_init error
661 constructor_declarator:
662 nested_name_specifier SELFNAME '('
663 { $$ = begin_constructor_declarator ($1, $2); }
664 parmlist ')' cv_qualifiers exception_specification_opt
665 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
666 | nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
667 { $$ = begin_constructor_declarator ($1, $2);
668 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
670 | global_scope nested_name_specifier SELFNAME '('
671 { $$ = begin_constructor_declarator ($2, $3); }
672 parmlist ')' cv_qualifiers exception_specification_opt
673 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
674 | global_scope nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
675 { $$ = begin_constructor_declarator ($2, $3);
676 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
678 | nested_name_specifier self_template_type '('
679 { $$ = begin_constructor_declarator ($1, $2); }
680 parmlist ')' cv_qualifiers exception_specification_opt
681 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
682 | nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
683 { $$ = begin_constructor_declarator ($1, $2);
684 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
686 | global_scope nested_name_specifier self_template_type '('
687 { $$ = begin_constructor_declarator ($2, $3); }
688 parmlist ')' cv_qualifiers exception_specification_opt
689 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
690 | global_scope nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
691 { $$ = begin_constructor_declarator ($2, $3);
692 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
697 typed_declspecs declarator
698 { if (!begin_function_definition ($1.t, $2))
700 | declmods notype_declarator
701 { if (!begin_function_definition ($1, $2))
704 { if (!begin_function_definition (NULL_TREE, $1))
706 | declmods constructor_declarator
707 { if (!begin_function_definition ($1, $2))
709 | constructor_declarator
710 { if (!begin_function_definition (NULL_TREE, $1))
714 component_constructor_declarator:
715 SELFNAME '(' parmlist ')' cv_qualifiers exception_specification_opt
716 { $$ = make_call_declarator ($1, $3, $5, $6); }
717 | SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
718 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
719 | self_template_type '(' parmlist ')' cv_qualifiers exception_specification_opt
720 { $$ = make_call_declarator ($1, $3, $5, $6); }
721 | self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
722 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
725 /* more C++ complexity. See component_decl for a comment on the
726 reduce/reduce conflict introduced by these rules. */
728 declmods component_constructor_declarator
730 split_specs_attrs ($1, &specs, &attrs);
731 attrs = build_tree_list (attrs, NULL_TREE);
732 $$ = start_method (specs, $2, attrs);
736 if (yychar == YYEMPTY)
738 reinit_parse_for_method (yychar, $$); }
739 | component_constructor_declarator
740 { $$ = start_method (NULL_TREE, $1, NULL_TREE);
742 | typed_declspecs declarator
744 split_specs_attrs ($1.t, &specs, &attrs);
745 attrs = build_tree_list (attrs, NULL_TREE);
746 $$ = start_method (specs, $2, attrs); goto rest_of_mdef; }
747 | declmods notype_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; }
753 { $$ = start_method (NULL_TREE, $$, NULL_TREE);
755 | declmods constructor_declarator
757 split_specs_attrs ($1, &specs, &attrs);
758 attrs = build_tree_list (attrs, NULL_TREE);
759 $$ = start_method (specs, $2, attrs); goto rest_of_mdef; }
760 | constructor_declarator
761 { $$ = start_method (NULL_TREE, $$, NULL_TREE);
766 RETURN_KEYWORD IDENTIFIER
768 if (! current_function_parms_stored)
776 { finish_named_return_value ($<ttype>$, $2); }
777 | return_id '(' nonnull_exprlist ')'
778 { finish_named_return_value ($<ttype>$, $3); }
779 | return_id LEFT_RIGHT
780 { finish_named_return_value ($<ttype>$, NULL_TREE); }
784 ':' .set_base_init member_init_list
787 error ("no base initializers given following ':'");
795 if (! current_function_parms_stored)
798 if (DECL_CONSTRUCTOR_P (current_function_decl))
799 /* Make a contour for the initializer list. */
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),
867 explicit_instantiation:
868 TEMPLATE begin_explicit_instantiation typespec ';'
869 { do_type_instantiation ($3.t, NULL_TREE);
871 end_explicit_instantiation
872 | TEMPLATE begin_explicit_instantiation typed_declspecs declarator
873 { tree specs = strip_attrs ($3.t);
874 do_decl_instantiation (specs, $4, NULL_TREE); }
875 end_explicit_instantiation
876 | TEMPLATE begin_explicit_instantiation notype_declarator
877 { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
878 end_explicit_instantiation
879 | TEMPLATE begin_explicit_instantiation constructor_declarator
880 { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
881 end_explicit_instantiation
882 | SCSPEC TEMPLATE begin_explicit_instantiation typespec ';'
883 { do_type_instantiation ($4.t, $1);
885 end_explicit_instantiation
886 | SCSPEC TEMPLATE begin_explicit_instantiation typed_declspecs
888 { tree specs = strip_attrs ($4.t);
889 do_decl_instantiation (specs, $5, $1); }
890 end_explicit_instantiation
891 | SCSPEC TEMPLATE begin_explicit_instantiation notype_declarator
892 { do_decl_instantiation (NULL_TREE, $4, $1); }
893 end_explicit_instantiation
894 | SCSPEC TEMPLATE begin_explicit_instantiation constructor_declarator
895 { do_decl_instantiation (NULL_TREE, $4, $1); }
896 end_explicit_instantiation
899 begin_explicit_instantiation:
900 { begin_explicit_instantiation(); }
902 end_explicit_instantiation:
903 { end_explicit_instantiation(); }
905 /* The TYPENAME expansions are to deal with use of a template class name as
906 a template within the class itself, where the template decl is hidden by
907 a type decl. Got all that? */
910 PTYPENAME '<' template_arg_list_opt template_close_bracket
911 .finish_template_type
913 | TYPENAME '<' template_arg_list_opt template_close_bracket
914 .finish_template_type
919 apparent_template_type:
921 | identifier '<' template_arg_list_opt '>'
922 .finish_template_type
926 SELFNAME '<' template_arg_list_opt template_close_bracket
927 .finish_template_type
931 .finish_template_type:
933 if (yychar == YYEMPTY)
936 $$ = finish_template_type ($<ttype>-3, $<ttype>-1,
940 template_close_bracket:
944 /* Handle `Class<Class<Type>>' without space in the `>>' */
945 pedwarn ("`>>' should be `> >' in template class name");
950 template_arg_list_opt:
958 { $$ = build_tree_list (NULL_TREE, $$); }
959 | template_arg_list ',' template_arg
960 { $$ = chainon ($$, build_tree_list (NULL_TREE, $3)); }
965 { $$ = groktypename ($1.t); }
968 | expr_no_commas %prec ARITHCOMPARE
973 { $$ = NEGATE_EXPR; }
975 { $$ = CONVERT_EXPR; }
977 { $$ = PREINCREMENT_EXPR; }
979 { $$ = PREDECREMENT_EXPR; }
981 { $$ = TRUTH_NOT_EXPR; }
986 { $$ = build_x_compound_expr ($$); }
992 { error ("ANSI C++ forbids an empty condition for `%s'",
994 $$ = integer_zero_node; }
1001 { error ("ANSI C++ forbids an empty condition for `%s'",
1003 $$ = integer_zero_node; }
1017 type_specifier_seq declarator maybeasm maybe_attribute '='
1020 for (d = getdecls (); d; d = TREE_CHAIN (d))
1021 if (TREE_CODE (d) == TYPE_DECL) {
1022 tree s = TREE_TYPE (d);
1023 if (TREE_CODE (s) == RECORD_TYPE)
1024 cp_error ("definition of class `%T' in condition", s);
1025 else if (TREE_CODE (s) == ENUMERAL_TYPE)
1026 cp_error ("definition of enum `%T' in condition", s);
1029 current_declspecs = $1.t;
1030 $<ttype>$ = start_decl ($<ttype>2, current_declspecs, 1,
1031 $4, /*prefix_attributes*/ NULL_TREE);
1035 cp_finish_decl ($<ttype>6, $7, $4, LOOKUP_ONLYCONVERTING);
1036 $$ = convert_from_reference ($<ttype>6);
1037 if (TREE_CODE (TREE_TYPE ($$)) == ARRAY_TYPE)
1038 cp_error ("definition of array `%#D' in condition", $$);
1045 | maybe_label_decls stmts '}'
1046 | maybe_label_decls stmts error '}'
1047 | maybe_label_decls error '}'
1050 already_scoped_stmt:
1052 { $<ttype>$ = begin_compound_stmt (1); }
1054 { finish_compound_stmt (1, $<ttype>2); }
1059 nontrivial_exprlist:
1060 expr_no_commas ',' expr_no_commas
1061 { $$ = tree_cons (NULL_TREE, $$,
1062 build_tree_list (NULL_TREE, $3)); }
1063 | expr_no_commas ',' error
1064 { $$ = tree_cons (NULL_TREE, $$,
1065 build_tree_list (NULL_TREE, error_mark_node)); }
1066 | nontrivial_exprlist ',' expr_no_commas
1067 { chainon ($$, build_tree_list (NULL_TREE, $3)); }
1068 | nontrivial_exprlist ',' error
1069 { chainon ($$, build_tree_list (NULL_TREE, error_mark_node)); }
1074 { $$ = build_tree_list (NULL_TREE, $$); }
1075 | nontrivial_exprlist
1081 /* __extension__ turns off -pedantic for following primary. */
1082 | extension cast_expr %prec UNARY
1085 | '*' cast_expr %prec UNARY
1086 { $$ = build_x_indirect_ref ($2, "unary *"); }
1087 | '&' cast_expr %prec UNARY
1088 { $$ = build_x_unary_op (ADDR_EXPR, $2); }
1090 { $$ = build_x_unary_op (BIT_NOT_EXPR, $2); }
1091 | unop cast_expr %prec UNARY
1092 { $$ = finish_unary_op_expr ($1, $2); }
1093 /* Refer to the address of a label as a pointer. */
1096 pedwarn ("ANSI C++ forbids `&&'");
1097 $$ = finish_label_address_expr ($2); }
1098 | SIZEOF unary_expr %prec UNARY
1099 { $$ = expr_sizeof ($2); }
1100 | SIZEOF '(' type_id ')' %prec HYPERUNARY
1101 { $$ = c_sizeof (groktypename ($3.t));
1102 check_for_new_type ("sizeof", $3); }
1103 | ALIGNOF unary_expr %prec UNARY
1104 { $$ = grok_alignof ($2); }
1105 | ALIGNOF '(' type_id ')' %prec HYPERUNARY
1106 { $$ = c_alignof (groktypename ($3.t));
1107 check_for_new_type ("alignof", $3); }
1109 /* The %prec EMPTY's here are required by the = init initializer
1110 syntax extension; see below. */
1111 | new new_type_id %prec EMPTY
1112 { $$ = build_new (NULL_TREE, $2.t, NULL_TREE, $1);
1113 check_for_new_type ("new", $2); }
1114 | new new_type_id new_initializer
1115 { $$ = build_new (NULL_TREE, $2.t, $3, $1);
1116 check_for_new_type ("new", $2); }
1117 | new new_placement new_type_id %prec EMPTY
1118 { $$ = build_new ($2, $3.t, NULL_TREE, $1);
1119 check_for_new_type ("new", $3); }
1120 | new new_placement new_type_id new_initializer
1121 { $$ = build_new ($2, $3.t, $4, $1);
1122 check_for_new_type ("new", $3); }
1123 | new '(' type_id ')'
1125 { $$ = build_new (NULL_TREE, groktypename($3.t),
1127 check_for_new_type ("new", $3); }
1128 | new '(' type_id ')' new_initializer
1129 { $$ = build_new (NULL_TREE, groktypename($3.t), $5, $1);
1130 check_for_new_type ("new", $3); }
1131 | new new_placement '(' type_id ')' %prec EMPTY
1132 { $$ = build_new ($2, groktypename($4.t), NULL_TREE, $1);
1133 check_for_new_type ("new", $4); }
1134 | new new_placement '(' type_id ')' new_initializer
1135 { $$ = build_new ($2, groktypename($4.t), $6, $1);
1136 check_for_new_type ("new", $4); }
1138 | delete cast_expr %prec UNARY
1139 { $$ = delete_sanity ($2, NULL_TREE, 0, $1); }
1140 | delete '[' ']' cast_expr %prec UNARY
1141 { $$ = delete_sanity ($4, NULL_TREE, 1, $1);
1142 if (yychar == YYEMPTY)
1144 | delete '[' expr ']' cast_expr %prec UNARY
1145 { $$ = delete_sanity ($5, $3, 2, $1);
1146 if (yychar == YYEMPTY)
1148 | REALPART cast_expr %prec UNARY
1149 { $$ = build_x_unary_op (REALPART_EXPR, $2); }
1150 | IMAGPART cast_expr %prec UNARY
1151 { $$ = build_x_unary_op (IMAGPART_EXPR, $2); }
1152 | VA_ARG '(' expr_no_commas ',' type_id ')'
1153 { $$ = build_x_va_arg ($3, groktypename ($5.t));
1154 check_for_new_type ("__builtin_va_arg", $5); }
1158 '(' nonnull_exprlist ')'
1160 | '{' nonnull_exprlist '}'
1161 { cp_pedwarn ("old style placement syntax, use () instead");
1166 '(' nonnull_exprlist ')'
1172 cp_error ("`%T' is not a valid expression", $2.t);
1173 $$ = error_mark_node;
1175 /* GNU extension so people can use initializer lists. Note that
1176 this alters the meaning of `new int = 1', which was previously
1177 syntactically valid but semantically invalid. */
1181 pedwarn ("ANSI C++ forbids initialization of new expression with `='");
1182 if (TREE_CODE ($2) != TREE_LIST
1183 && TREE_CODE ($2) != CONSTRUCTOR)
1184 $$ = build_tree_list (NULL_TREE, $2);
1190 /* This is necessary to postpone reduction of `int ((int)(int)(int))'. */
1192 '(' type_id ')' %prec EMPTY
1193 { $2.t = finish_parmlist (build_tree_list (NULL_TREE, $2.t), 0);
1194 $$ = make_call_declarator (NULL_TREE, $2.t, NULL_TREE, NULL_TREE);
1195 check_for_new_type ("cast", $2); }
1196 | regcast_or_absdcl '(' type_id ')' %prec EMPTY
1197 { $3.t = finish_parmlist (build_tree_list (NULL_TREE, $3.t), 0);
1198 $$ = make_call_declarator ($$, $3.t, NULL_TREE, NULL_TREE);
1199 check_for_new_type ("cast", $3); }
1204 | regcast_or_absdcl unary_expr %prec UNARY
1205 { $$ = reparse_absdcl_as_casts ($$, $2); }
1206 | regcast_or_absdcl '{' initlist maybecomma '}' %prec UNARY
1208 tree init = build_nt (CONSTRUCTOR, NULL_TREE,
1211 pedwarn ("ANSI C++ forbids constructor-expressions");
1212 /* Indicate that this was a GNU C constructor expression. */
1213 TREE_HAS_CONSTRUCTOR (init) = 1;
1215 $$ = reparse_absdcl_as_casts ($$, init);
1221 /* Handle general members. */
1222 | expr_no_commas POINTSAT_STAR expr_no_commas
1223 { $$ = build_x_binary_op (MEMBER_REF, $$, $3); }
1224 | expr_no_commas DOT_STAR expr_no_commas
1225 { $$ = build_m_component_ref ($$, $3); }
1226 | expr_no_commas '+' expr_no_commas
1227 { $$ = build_x_binary_op ($2, $$, $3); }
1228 | expr_no_commas '-' expr_no_commas
1229 { $$ = build_x_binary_op ($2, $$, $3); }
1230 | expr_no_commas '*' expr_no_commas
1231 { $$ = build_x_binary_op ($2, $$, $3); }
1232 | expr_no_commas '/' expr_no_commas
1233 { $$ = build_x_binary_op ($2, $$, $3); }
1234 | expr_no_commas '%' expr_no_commas
1235 { $$ = build_x_binary_op ($2, $$, $3); }
1236 | expr_no_commas LSHIFT expr_no_commas
1237 { $$ = build_x_binary_op ($2, $$, $3); }
1238 | expr_no_commas RSHIFT expr_no_commas
1239 { $$ = build_x_binary_op ($2, $$, $3); }
1240 | expr_no_commas ARITHCOMPARE expr_no_commas
1241 { $$ = build_x_binary_op ($2, $$, $3); }
1242 | expr_no_commas '<' expr_no_commas
1243 { $$ = build_x_binary_op (LT_EXPR, $$, $3); }
1244 | expr_no_commas '>' expr_no_commas
1245 { $$ = build_x_binary_op (GT_EXPR, $$, $3); }
1246 | expr_no_commas EQCOMPARE expr_no_commas
1247 { $$ = build_x_binary_op ($2, $$, $3); }
1248 | expr_no_commas MIN_MAX expr_no_commas
1249 { $$ = build_x_binary_op ($2, $$, $3); }
1250 | expr_no_commas '&' expr_no_commas
1251 { $$ = build_x_binary_op ($2, $$, $3); }
1252 | expr_no_commas '|' expr_no_commas
1253 { $$ = build_x_binary_op ($2, $$, $3); }
1254 | expr_no_commas '^' expr_no_commas
1255 { $$ = build_x_binary_op ($2, $$, $3); }
1256 | expr_no_commas ANDAND expr_no_commas
1257 { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $$, $3); }
1258 | expr_no_commas OROR expr_no_commas
1259 { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $$, $3); }
1260 | expr_no_commas '?' xexpr ':' expr_no_commas
1261 { $$ = build_x_conditional_expr ($$, $3, $5); }
1262 | expr_no_commas '=' expr_no_commas
1263 { $$ = build_x_modify_expr ($$, NOP_EXPR, $3);
1264 if ($$ != error_mark_node)
1265 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
1266 | expr_no_commas ASSIGN expr_no_commas
1267 { $$ = build_x_modify_expr ($$, $2, $3); }
1269 { $$ = build_throw (NULL_TREE); }
1270 | THROW expr_no_commas
1271 { $$ = build_throw ($2); }
1272 /* These extensions are not defined. The second arg to build_m_component_ref
1273 is old, build_m_component_ref now does an implicit
1274 build_indirect_ref (x, NULL_PTR) on the second argument.
1275 | object '&' expr_no_commas %prec UNARY
1276 { $$ = build_m_component_ref ($$, build_x_unary_op (ADDR_EXPR, $3)); }
1277 | object unop expr_no_commas %prec UNARY
1278 { $$ = build_m_component_ref ($$, build_x_unary_op ($2, $3)); }
1279 | object '(' type_id ')' expr_no_commas %prec UNARY
1280 { tree type = groktypename ($3.t);
1281 $$ = build_m_component_ref ($$, build_c_cast (type, $5)); }
1282 | object primary_no_id %prec UNARY
1283 { $$ = build_m_component_ref ($$, $2); }
1287 notype_unqualified_id:
1288 '~' see_typename identifier
1289 { $$ = build_parse_node (BIT_NOT_EXPR, $3); }
1290 | '~' see_typename template_type
1291 { $$ = build_parse_node (BIT_NOT_EXPR, $3); }
1296 | NSNAME %prec EMPTY
1301 /* If lastiddecl is a TREE_LIST, it's a baselink, which
1302 means that we're in an expression like S::f<int>, so
1303 don't do_identifier; we only do that for unqualified
1305 if (lastiddecl && TREE_CODE (lastiddecl) != TREE_LIST)
1306 $$ = do_identifier ($<ttype>-1, 1, NULL_TREE);
1312 PFUNCNAME '<' do_id template_arg_list_opt template_close_bracket
1313 { $$ = lookup_template_function ($3, $4); }
1314 | operator_name '<' do_id template_arg_list_opt template_close_bracket
1315 { $$ = lookup_template_function ($3, $4); }
1319 TEMPLATE identifier '<' template_arg_list_opt template_close_bracket
1320 { $$ = lookup_template_function ($2, $4); }
1321 | TEMPLATE PFUNCNAME '<' template_arg_list_opt template_close_bracket
1322 { $$ = lookup_template_function ($2, $4); }
1323 | TEMPLATE operator_name '<' template_arg_list_opt
1324 template_close_bracket
1325 { $$ = lookup_template_function ($2, $4); }
1329 notype_unqualified_id
1334 expr_or_declarator_intern:
1336 | attributes expr_or_declarator
1338 /* Provide support for '(' attributes '*' declarator ')'
1340 $$ = decl_tree_cons ($1, $2, NULL_TREE);
1345 notype_unqualified_id
1346 | '*' expr_or_declarator_intern %prec UNARY
1347 { $$ = build_parse_node (INDIRECT_REF, $2); }
1348 | '&' expr_or_declarator_intern %prec UNARY
1349 { $$ = build_parse_node (ADDR_EXPR, $2); }
1350 | '(' expr_or_declarator_intern ')'
1354 notype_template_declarator:
1355 IDENTIFIER '<' template_arg_list_opt template_close_bracket
1356 { $$ = lookup_template_function ($1, $3); }
1357 | NSNAME '<' template_arg_list template_close_bracket
1358 { $$ = lookup_template_function ($1, $3); }
1361 direct_notype_declarator:
1362 complex_direct_notype_declarator
1363 /* This precedence declaration is to prefer this reduce
1364 to the Koenig lookup shift in primary, below. I hate yacc. */
1365 | notype_unqualified_id %prec '('
1366 | notype_template_declarator
1367 | '(' expr_or_declarator_intern ')'
1368 { $$ = finish_decl_parsing ($2); }
1372 notype_unqualified_id
1374 if (TREE_CODE ($1) == BIT_NOT_EXPR)
1375 $$ = build_x_unary_op (BIT_NOT_EXPR, TREE_OPERAND ($1, 0));
1377 $$ = finish_id_expr ($1);
1383 $$ = combine_strings ($$);
1384 /* combine_strings doesn't set up TYPE_MAIN_VARIANT of
1385 a const array the way we want, so fix it. */
1386 if (flag_const_strings)
1387 TREE_TYPE ($$) = build_cplus_array_type
1388 (TREE_TYPE (TREE_TYPE ($$)),
1389 TYPE_DOMAIN (TREE_TYPE ($$)));
1392 { $$ = finish_parenthesized_expr ($2); }
1393 | '(' expr_or_declarator_intern ')'
1394 { $2 = reparse_decl_as_expr (NULL_TREE, $2);
1395 $$ = finish_parenthesized_expr ($2); }
1397 { $$ = error_mark_node; }
1399 { tree scope = current_scope ();
1400 if (!scope || TREE_CODE (scope) != FUNCTION_DECL)
1402 error ("braced-group within expression allowed only inside a function");
1406 pedwarn ("ANSI C++ forbids braced-groups within expressions");
1407 $<ttype>$ = begin_stmt_expr ();
1410 { $$ = finish_stmt_expr ($<ttype>2); }
1411 /* Koenig lookup support
1412 We could store lastiddecl in $1 to avoid another lookup,
1413 but that would result in many additional reduce/reduce conflicts. */
1414 | notype_unqualified_id '(' nonnull_exprlist ')'
1415 { $$ = finish_call_expr ($1, $3, 1); }
1416 | notype_unqualified_id LEFT_RIGHT
1417 { $$ = finish_call_expr ($1, NULL_TREE, 1); }
1418 | primary '(' nonnull_exprlist ')'
1419 { $$ = finish_call_expr ($1, $3, 0); }
1420 | primary LEFT_RIGHT
1421 { $$ = finish_call_expr ($1, NULL_TREE, 0); }
1422 | primary '[' expr ']'
1423 { $$ = grok_array_decl ($$, $3); }
1425 { $$ = finish_increment_expr ($1, POSTINCREMENT_EXPR); }
1426 | primary MINUSMINUS
1427 { $$ = finish_increment_expr ($1, POSTDECREMENT_EXPR); }
1428 /* C++ extensions */
1430 { $$ = finish_this_expr (); }
1431 | CV_QUALIFIER '(' nonnull_exprlist ')'
1433 /* This is a C cast in C++'s `functional' notation
1434 using the "implicit int" extension so that:
1435 `const (3)' is equivalent to `const int (3)'. */
1438 type = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
1439 type = groktypename (build_decl_list (type, NULL_TREE));
1440 $$ = build_functional_cast (type, $3);
1443 | DYNAMIC_CAST '<' type_id '>' '(' expr ')'
1444 { tree type = groktypename ($3.t);
1445 check_for_new_type ("dynamic_cast", $3);
1446 $$ = build_dynamic_cast (type, $6); }
1447 | STATIC_CAST '<' type_id '>' '(' expr ')'
1448 { tree type = groktypename ($3.t);
1449 check_for_new_type ("static_cast", $3);
1450 $$ = build_static_cast (type, $6); }
1451 | REINTERPRET_CAST '<' type_id '>' '(' expr ')'
1452 { tree type = groktypename ($3.t);
1453 check_for_new_type ("reinterpret_cast", $3);
1454 $$ = build_reinterpret_cast (type, $6); }
1455 | CONST_CAST '<' type_id '>' '(' expr ')'
1456 { tree type = groktypename ($3.t);
1457 check_for_new_type ("const_cast", $3);
1458 $$ = build_const_cast (type, $6); }
1459 | TYPEID '(' expr ')'
1460 { $$ = build_typeid ($3); }
1461 | TYPEID '(' type_id ')'
1462 { tree type = groktypename ($3.t);
1463 check_for_new_type ("typeid", $3);
1464 $$ = get_typeid (TYPE_MAIN_VARIANT (type)); }
1465 | global_scope IDENTIFIER
1466 { $$ = do_scoped_id ($2, 1); }
1467 | global_scope template_id
1469 | global_scope operator_name
1471 got_scope = NULL_TREE;
1472 if (TREE_CODE ($2) == IDENTIFIER_NODE)
1473 $$ = do_scoped_id ($2, 1);
1477 | overqualified_id %prec HYPERUNARY
1478 { $$ = build_offset_ref (OP0 ($$), OP1 ($$)); }
1479 | overqualified_id '(' nonnull_exprlist ')'
1480 { $$ = finish_qualified_call_expr ($1, $3); }
1481 | overqualified_id LEFT_RIGHT
1482 { $$ = finish_qualified_call_expr ($1, NULL_TREE); }
1483 | object object_template_id %prec UNARY
1485 $$ = build_x_component_ref ($$, $2, NULL_TREE, 1);
1487 | object object_template_id '(' nonnull_exprlist ')'
1488 { $$ = finish_object_call_expr ($2, $1, $4); }
1489 | object object_template_id LEFT_RIGHT
1490 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1491 | object unqualified_id %prec UNARY
1492 { $$ = build_x_component_ref ($$, $2, NULL_TREE, 1); }
1493 | object overqualified_id %prec UNARY
1494 { if (processing_template_decl)
1495 $$ = build_min_nt (COMPONENT_REF, $1, $2);
1497 $$ = build_object_ref ($$, OP0 ($2), OP1 ($2)); }
1498 | object unqualified_id '(' nonnull_exprlist ')'
1499 { $$ = finish_object_call_expr ($2, $1, $4); }
1500 | object unqualified_id LEFT_RIGHT
1501 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1502 | object overqualified_id '(' nonnull_exprlist ')'
1503 { $$ = finish_qualified_object_call_expr ($2, $1, $4); }
1504 | object overqualified_id LEFT_RIGHT
1505 { $$ = finish_qualified_object_call_expr ($2, $1, NULL_TREE); }
1506 /* p->int::~int() is valid -- 12.4 */
1507 | object '~' TYPESPEC LEFT_RIGHT
1508 { $$ = finish_pseudo_destructor_call_expr ($1, NULL_TREE, $3); }
1509 | object TYPESPEC SCOPE '~' TYPESPEC LEFT_RIGHT
1510 { $$ = finish_pseudo_destructor_call_expr ($1, $2, $5); }
1513 $$ = error_mark_node;
1517 /* Not needed for now.
1523 { $$ = error_mark_node; }
1525 { if (current_function_decl == 0)
1527 error ("braced-group within expression allowed only inside a function");
1530 $<ttype>$ = expand_start_stmt_expr (); }
1533 pedwarn ("ANSI C++ forbids braced-groups within expressions");
1534 $$ = expand_end_stmt_expr ($<ttype>2); }
1535 | primary_no_id '(' nonnull_exprlist ')'
1536 { $$ = build_x_function_call ($$, $3, current_class_ref); }
1537 | primary_no_id LEFT_RIGHT
1538 { $$ = build_x_function_call ($$, NULL_TREE, current_class_ref); }
1539 | primary_no_id '[' expr ']'
1541 | primary_no_id PLUSPLUS
1542 { $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); }
1543 | primary_no_id MINUSMINUS
1544 { $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); }
1546 { goto do_scoped_id; }
1547 | SCOPE operator_name
1548 { if (TREE_CODE ($2) == IDENTIFIER_NODE)
1550 goto do_scoped_operator;
1559 { got_scope = NULL_TREE; $$ = 1; }
1565 | global_scope delete
1566 { got_scope = NULL_TREE; $$ = 1; }
1571 { $$ = boolean_true_node; }
1573 { $$ = boolean_false_node; }
1576 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
1580 { $$ = chainon ($$, $2); }
1586 if (! current_function_parms_stored)
1587 store_parm_decls ();
1594 { got_object = TREE_TYPE ($$); }
1597 $$ = build_x_arrow ($$);
1598 got_object = TREE_TYPE ($$);
1603 typespec initdecls ';'
1605 if ($1.t && IS_AGGR_TYPE_CODE (TREE_CODE ($1.t)))
1606 note_got_semicolon ($1.t);
1608 | typed_declspecs initdecls ';'
1610 note_list_got_semicolon ($1.t);
1612 | declmods notype_initdecls ';'
1614 | typed_declspecs ';'
1617 note_list_got_semicolon ($1.t);
1620 { warning ("empty declaration"); }
1625 /* Any kind of declarator (thus, all declarators allowed
1626 after an explicit typespec). */
1629 after_type_declarator %prec EMPTY
1630 | notype_declarator %prec EMPTY
1633 /* This is necessary to postpone reduction of `int()()()()'. */
1635 LEFT_RIGHT %prec EMPTY
1636 { $$ = make_call_declarator (NULL_TREE, empty_parms (),
1637 NULL_TREE, NULL_TREE); }
1638 | fcast_or_absdcl LEFT_RIGHT %prec EMPTY
1639 { $$ = make_call_declarator ($$, empty_parms (), NULL_TREE,
1643 /* ANSI type-id (8.1) */
1645 typed_typespecs absdcl
1646 { $$.t = build_decl_list ($1.t, $2);
1647 $$.new_type_flag = $1.new_type_flag; }
1648 | nonempty_cv_qualifiers absdcl
1649 { $$.t = build_decl_list ($1.t, $2);
1650 $$.new_type_flag = $1.new_type_flag; }
1652 { $$.t = build_decl_list (build_decl_list (NULL_TREE, $1.t),
1654 $$.new_type_flag = $1.new_type_flag; }
1655 | typed_typespecs %prec EMPTY
1656 { $$.t = build_decl_list ($1.t, NULL_TREE);
1657 $$.new_type_flag = $1.new_type_flag; }
1658 | nonempty_cv_qualifiers %prec EMPTY
1659 { $$.t = build_decl_list ($1.t, NULL_TREE);
1660 $$.new_type_flag = $1.new_type_flag; }
1663 /* Declspecs which contain at least one type specifier or typedef name.
1664 (Just `const' or `volatile' is not enough.)
1665 A typedef'd name following these is taken as a name to be declared.
1666 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1669 typed_typespecs %prec EMPTY
1675 { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1);
1676 $$.new_type_flag = $2.new_type_flag; }
1677 | typespec reserved_declspecs %prec HYPERUNARY
1678 { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2);
1679 $$.new_type_flag = $1.new_type_flag; }
1680 | typespec reserved_typespecquals reserved_declspecs
1681 { $$.t = decl_tree_cons (NULL_TREE, $1.t, chainon ($2, $3));
1682 $$.new_type_flag = $1.new_type_flag; }
1683 | declmods typespec reserved_declspecs
1684 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1));
1685 $$.new_type_flag = $2.new_type_flag; }
1686 | declmods typespec reserved_typespecquals
1687 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1));
1688 $$.new_type_flag = $2.new_type_flag; }
1689 | declmods typespec reserved_typespecquals reserved_declspecs
1690 { $$.t = decl_tree_cons (NULL_TREE, $2.t,
1691 chainon ($3, chainon ($4, $1)));
1692 $$.new_type_flag = $2.new_type_flag; }
1697 { if (extra_warnings)
1698 warning ("`%s' is not at beginning of declaration",
1699 IDENTIFIER_POINTER ($$));
1700 $$ = build_decl_list (NULL_TREE, $$); }
1701 | reserved_declspecs typespecqual_reserved
1702 { $$ = decl_tree_cons (NULL_TREE, $2.t, $$); }
1703 | reserved_declspecs SCSPEC
1704 { if (extra_warnings)
1705 warning ("`%s' is not at beginning of declaration",
1706 IDENTIFIER_POINTER ($2));
1707 $$ = decl_tree_cons (NULL_TREE, $2, $$); }
1708 | reserved_declspecs attributes
1709 { $$ = decl_tree_cons ($2, NULL_TREE, $1); }
1711 { $$ = decl_tree_cons ($1, NULL_TREE, NULL_TREE); }
1714 /* List of just storage classes and type modifiers.
1715 A declaration can start with just this, but then it cannot be used
1716 to redeclare a typedef-name.
1717 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1719 /* We use hash_tree_cons for lists of typeless declspecs so that they end
1720 up on a persistent obstack. Otherwise, they could appear at the
1721 beginning of something like
1723 static const struct { int foo () { } } b;
1725 and would be discarded after we finish compiling foo. We don't need to
1726 worry once we see a type. */
1729 nonempty_cv_qualifiers %prec EMPTY
1730 { $$ = $1.t; TREE_STATIC ($$) = 1; }
1732 { $$ = hash_tree_cons (NULL_TREE, $$, NULL_TREE); }
1733 | declmods CV_QUALIFIER
1734 { $$ = hash_tree_cons (NULL_TREE, $2, $$);
1735 TREE_STATIC ($$) = 1; }
1737 { if (extra_warnings && TREE_STATIC ($$))
1738 warning ("`%s' is not at beginning of declaration",
1739 IDENTIFIER_POINTER ($2));
1740 $$ = hash_tree_cons (NULL_TREE, $2, $$);
1741 TREE_STATIC ($$) = TREE_STATIC ($1); }
1742 | declmods attributes
1743 { $$ = hash_tree_cons ($2, NULL_TREE, $1); }
1744 | attributes %prec EMPTY
1745 { $$ = hash_tree_cons ($1, NULL_TREE, NULL_TREE); }
1748 /* Used instead of declspecs where storage classes are not allowed
1749 (that is, for typenames and structure components).
1751 C++ can takes storage classes for structure components.
1752 Don't accept a typedef-name if anything but a modifier precedes it. */
1755 typespec %prec EMPTY
1756 { $$.t = build_decl_list (NULL_TREE, $1.t);
1757 $$.new_type_flag = $1.new_type_flag; }
1758 | nonempty_cv_qualifiers typespec
1759 { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1.t);
1760 $$.new_type_flag = $2.new_type_flag; }
1761 | typespec reserved_typespecquals
1762 { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2);
1763 $$.new_type_flag = $1.new_type_flag; }
1764 | nonempty_cv_qualifiers typespec reserved_typespecquals
1765 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1766 $$.new_type_flag = $1.new_type_flag; }
1769 reserved_typespecquals:
1770 typespecqual_reserved
1771 { $$ = build_decl_list (NULL_TREE, $1.t); }
1772 | reserved_typespecquals typespecqual_reserved
1773 { $$ = decl_tree_cons (NULL_TREE, $2.t, $1); }
1776 /* A typespec (but not a type qualifier).
1777 Once we have seen one of these in a declaration,
1778 if a typedef name appears then it is being redeclared. */
1782 | TYPESPEC %prec EMPTY
1783 { $$.t = $1; $$.new_type_flag = 0; }
1784 | complete_type_name
1785 { $$.t = $1; $$.new_type_flag = 0; }
1786 | TYPEOF '(' expr ')'
1787 { $$.t = finish_typeof ($3);
1788 $$.new_type_flag = 0; }
1789 | TYPEOF '(' type_id ')'
1790 { $$.t = groktypename ($3.t);
1791 $$.new_type_flag = 0; }
1792 | SIGOF '(' expr ')'
1793 { tree type = TREE_TYPE ($3);
1795 $$.new_type_flag = 0;
1796 if (IS_AGGR_TYPE (type))
1798 sorry ("sigof type specifier");
1803 error ("`sigof' applied to non-aggregate expression");
1804 $$.t = error_mark_node;
1807 | SIGOF '(' type_id ')'
1808 { tree type = groktypename ($3.t);
1810 $$.new_type_flag = 0;
1811 if (IS_AGGR_TYPE (type))
1813 sorry ("sigof type specifier");
1818 error("`sigof' applied to non-aggregate type");
1819 $$.t = error_mark_node;
1824 /* A typespec that is a reserved word, or a type qualifier. */
1826 typespecqual_reserved:
1828 { $$.t = $1; $$.new_type_flag = 0; }
1830 { $$.t = $1; $$.new_type_flag = 0; }
1836 | initdecls ',' initdcl
1837 { check_multiple_declarators (); }
1842 | notype_initdecls ',' initdcl
1843 { check_multiple_declarators (); }
1848 | nomods_initdecls ',' initdcl
1849 { check_multiple_declarators (); }
1855 | asm_keyword '(' string ')'
1856 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3); $$ = $3; }
1860 declarator maybeasm maybe_attribute '='
1861 { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1,
1862 $3, prefix_attributes); }
1864 /* Note how the declaration of the variable is in effect while its init is parsed! */
1865 { cp_finish_decl ($<ttype>5, $6, $2, LOOKUP_ONLYCONVERTING); }
1866 | declarator maybeasm maybe_attribute
1867 { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 0,
1868 $3, prefix_attributes);
1869 cp_finish_decl ($<ttype>$, NULL_TREE, $2, 0); }
1872 /* This rule assumes a certain configuration of the parser stack.
1873 In particular, $0, the element directly before the beginning of
1874 this rule on the stack, must be a maybeasm. $-1 must be a
1875 declarator or notype_declarator. And $-2 must be some declmods
1876 or declspecs. We can't move the maybeasm into this rule because
1877 we need that reduce so we prefer fn.def1 when appropriate. */
1880 { parse_decl ($<ttype>-1, $<ttype>-2, $1, 1, &$<ttype>$); }
1881 /* Note how the declaration of the variable is in effect
1882 while its init is parsed! */
1884 { cp_finish_decl ($<ttype>3, $4, $<ttype>0,
1885 LOOKUP_ONLYCONVERTING); }
1888 parse_decl ($<ttype>-1, $<ttype>-2, $1, 0, &d);
1889 cp_finish_decl (d, NULL_TREE, $<ttype>0, 0); }
1893 declarator maybeasm initdcl0_innards
1898 notype_declarator maybeasm initdcl0_innards
1903 notype_declarator maybeasm
1904 { /* Set things up as initdcl0_innards expects. */
1909 | constructor_declarator maybeasm maybe_attribute
1911 parse_decl($1, NULL_TREE, $3, 0, &d);
1912 cp_finish_decl (d, NULL_TREE, $2, 0); }
1915 /* the * rules are dummies to accept the Apollo extended syntax
1916 so that the header files compile. */
1927 | attributes attribute
1928 { $$ = chainon ($1, $2); }
1932 ATTRIBUTE '(' '(' attribute_list ')' ')'
1939 | attribute_list ',' attrib
1940 { $$ = chainon ($1, $3); }
1947 { $$ = build_tree_list ($1, NULL_TREE); }
1948 | any_word '(' IDENTIFIER ')'
1949 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1950 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1951 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1952 | any_word '(' nonnull_exprlist ')'
1953 { $$ = build_tree_list ($1, $3); }
1956 /* This still leaves out most reserved keywords,
1957 shouldn't we include them? */
1966 /* A nonempty list of identifiers, including typenames. */
1967 identifiers_or_typenames:
1969 { $$ = build_tree_list (NULL_TREE, $1); }
1970 | identifiers_or_typenames ',' identifier
1971 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
1975 /* empty */ %prec EMPTY
1980 /* If we are processing a template, we don't want to expand this
1984 expr_no_commas %prec '='
1986 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, NULL_TREE);
1987 TREE_HAS_CONSTRUCTOR ($$) = 1; }
1989 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
1990 TREE_HAS_CONSTRUCTOR ($$) = 1; }
1991 | '{' initlist ',' '}'
1992 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
1993 TREE_HAS_CONSTRUCTOR ($$) = 1; }
1998 /* This chain is built in reverse order,
1999 and put in forward order where initlist is used. */
2002 { $$ = build_tree_list (NULL_TREE, $$); }
2004 { $$ = tree_cons (NULL_TREE, $3, $$); }
2005 /* These are for labeled elements. */
2006 | '[' expr_no_commas ']' init
2007 { $$ = build_tree_list ($2, $4); }
2008 | identifier ':' init
2009 { $$ = build_tree_list ($$, $3); }
2010 | initlist ',' identifier ':' init
2011 { $$ = tree_cons ($3, $5, $$); }
2015 PRE_PARSED_FUNCTION_DECL
2016 { start_function (NULL_TREE, $1->fndecl, NULL_TREE,
2017 (SF_DEFAULT | SF_PRE_PARSED
2018 | SF_INCLASS_INLINE));
2019 reinit_parse_for_function (); }
2022 fn.defpen maybe_return_init ctor_initializer_opt compstmt_or_error
2024 expand_body (finish_function (lineno, (int)$3 | 2));
2025 process_next_inline ($1);
2027 | fn.defpen maybe_return_init function_try_block
2029 expand_body (finish_function (lineno, (int)$3 | 2));
2030 process_next_inline ($1);
2032 | fn.defpen maybe_return_init error
2034 finish_function (lineno, 2);
2035 process_next_inline ($1); }
2040 | pending_inlines pending_inline eat_saved_input
2043 /* A regurgitated default argument. The value of DEFARG_MARKER will be
2044 the TREE_LIST node for the parameter in question. */
2046 DEFARG_MARKER expr_no_commas END_OF_SAVED_INPUT
2047 { replace_defarg ($1, $2); }
2048 | DEFARG_MARKER error END_OF_SAVED_INPUT
2049 { replace_defarg ($1, error_mark_node); }
2052 /* empty */ %prec EMPTY
2053 | pending_defargs defarg_again
2054 { do_pending_defargs (); }
2055 | pending_defargs error
2056 { do_pending_defargs (); }
2061 { $<ttype>$ = current_enum_type;
2062 current_enum_type = start_enum ($2); }
2064 { $$.t = finish_enum (current_enum_type);
2065 $$.new_type_flag = 1;
2066 current_enum_type = $<ttype>4;
2067 check_for_missing_semicolon ($$.t); }
2069 { $<ttype>$ = current_enum_type;
2070 current_enum_type = start_enum (make_anon_name ()); }
2072 { $$.t = finish_enum (current_enum_type);
2073 $$.new_type_flag = 1;
2074 current_enum_type = $<ttype>3;
2075 check_for_missing_semicolon ($$.t); }
2077 { $$.t = xref_tag (enum_type_node, $2, 1);
2078 $$.new_type_flag = 0; }
2079 | ENUM complex_type_name
2080 { $$.t = xref_tag (enum_type_node, $2, 1);
2081 $$.new_type_flag = 0; }
2082 | TYPENAME_KEYWORD typename_sub
2084 $$.new_type_flag = 0;
2085 if (!processing_template_decl)
2086 cp_pedwarn ("using `typename' outside of template"); }
2087 /* C++ extensions, merged with C to avoid shift/reduce conflicts */
2089 { $1.t = begin_class_definition ($1.t); }
2090 opt.component_decl_list '}' maybe_attribute
2094 if (yychar == YYEMPTY)
2096 semi = yychar == ';';
2098 $<ttype>$ = finish_class_definition ($1.t, $6, semi,
2103 begin_inline_definitions ();
2107 finish_inline_definitions ();
2109 $$.new_type_flag = 1;
2111 | class_head %prec EMPTY
2113 if ($1.new_type_flag && $1.t != error_mark_node)
2114 pop_scope (CP_DECL_CONTEXT (TYPE_MAIN_DECL ($1.t)));
2115 $$.new_type_flag = 0;
2116 if ($1.t == error_mark_node)
2118 else if (TYPE_BINFO ($1.t) == NULL_TREE)
2120 cp_error ("%T is not a class type", $1.t);
2121 $$.t = error_mark_node;
2126 /* struct B: public A; is not accepted by the WP grammar. */
2127 if (CLASS_TYPE_P ($$.t)
2128 && TYPE_BINFO_BASETYPES ($$.t)
2129 && !TYPE_SIZE ($$.t)
2130 && ! TYPE_BEING_DEFINED ($$.t))
2131 cp_error ("base clause without member specification for `%#T'",
2145 { if (pedantic && !in_system_header)
2146 pedwarn ("comma at end of enumerator list"); }
2152 { error ("storage class specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2154 { error ("type specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2156 { error ("type qualifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2158 { error ("no body nor ';' separates two class, struct or union declarations"); }
2160 { $$ = build_decl_list ($2, $1); }
2163 named_class_head_sans_basetype:
2171 named_class_head_sans_basetype_defn:
2172 aggr identifier_defn %prec EMPTY
2173 { current_aggr = $$; $$ = $2; }
2174 | named_class_head_sans_basetype '{'
2175 { yyungetc ('{', 1); }
2176 | named_class_head_sans_basetype ':'
2177 { yyungetc (':', 1); }
2180 named_complex_class_head_sans_basetype:
2181 aggr nested_name_specifier identifier
2184 $$.t = handle_class_head ($1, $2, $3);
2185 $$.new_type_flag = 1;
2187 | aggr global_scope nested_name_specifier identifier
2190 $$.t = handle_class_head ($1, $3, $4);
2191 $$.new_type_flag = 1;
2193 | aggr global_scope identifier
2196 $$.t = handle_class_head ($1, NULL_TREE, $3);
2197 $$.new_type_flag = 1;
2199 | aggr apparent_template_type
2203 $$.new_type_flag = 0;
2205 | aggr nested_name_specifier apparent_template_type
2209 if (CP_DECL_CONTEXT ($$.t))
2210 push_scope (CP_DECL_CONTEXT ($$.t));
2211 $$.new_type_flag = 1;
2216 named_class_head_sans_basetype %prec EMPTY
2218 $$.t = xref_tag (current_aggr, $1, 1);
2219 $$.new_type_flag = 0;
2221 | named_class_head_sans_basetype_defn
2222 { $<ttype>$ = xref_tag (current_aggr, $1, 0); }
2223 /* Class name is unqualified, so we look for base classes
2224 in the current scope. */
2225 maybe_base_class_list %prec EMPTY
2228 $$.new_type_flag = 0;
2230 xref_basetypes (current_aggr, $1, $<ttype>2, $3);
2232 | named_complex_class_head_sans_basetype
2233 maybe_base_class_list
2235 if ($1.t != error_mark_node)
2237 $$.t = TREE_TYPE ($1.t);
2238 $$.new_type_flag = $1.new_type_flag;
2239 if (current_aggr == union_type_node
2240 && TREE_CODE ($$.t) != UNION_TYPE)
2241 cp_pedwarn ("`union' tag used in declaring `%#T'",
2243 else if (TREE_CODE ($$.t) == UNION_TYPE
2244 && current_aggr != union_type_node)
2245 cp_pedwarn ("non-`union' tag used in declaring `%#T'", $$);
2246 else if (TREE_CODE ($$.t) == RECORD_TYPE)
2247 /* We might be specializing a template with a different
2249 CLASSTYPE_DECLARED_CLASS ($$.t)
2250 = (current_aggr == class_type_node);
2253 maybe_process_partial_specialization ($$.t);
2254 xref_basetypes (current_aggr, $1.t, $$.t, $2);
2262 { $$ = xref_tag ($$, make_anon_name (), 0);
2263 yyungetc ('{', 1); }
2266 /* The tree output of this nonterminal a declarationf or the type
2267 named. If NEW_TYPE_FLAG is set, then the name used in this
2268 class-head was explicitly qualified, e.g.: `struct X::Y'. We have
2269 already called push_scope for X. */
2274 $$.new_type_flag = 0;
2279 maybe_base_class_list:
2280 /* empty */ %prec EMPTY
2282 | ':' see_typename %prec EMPTY
2283 { yyungetc(':', 1); $$ = NULL_TREE; }
2284 | ':' see_typename base_class_list %prec EMPTY
2290 | base_class_list ',' see_typename base_class
2291 { $$ = chainon ($$, $4); }
2296 { $$ = finish_base_specifier (access_default_node, $1); }
2297 | base_class_access_list see_typename base_class.1
2298 { $$ = finish_base_specifier ($1, $3); }
2303 { if ($$ == error_mark_node)
2305 else if (!TYPE_P ($$))
2306 $$ = error_mark_node;
2308 $$ = TYPE_MAIN_DECL ($1); }
2312 base_class_access_list:
2313 VISSPEC see_typename
2314 | SCSPEC see_typename
2315 { if ($1 != ridpointers[(int)RID_VIRTUAL])
2316 cp_error ("`%D' access", $1);
2317 $$ = access_default_virtual_node; }
2318 | base_class_access_list VISSPEC see_typename
2320 if ($1 != access_default_virtual_node)
2321 error ("multiple access specifiers");
2322 else if ($2 == access_public_node)
2323 $$ = access_public_virtual_node;
2324 else if ($2 == access_protected_node)
2325 $$ = access_protected_virtual_node;
2326 else /* $2 == access_private_node */
2327 $$ = access_private_virtual_node;
2329 | base_class_access_list SCSPEC see_typename
2330 { if ($2 != ridpointers[(int)RID_VIRTUAL])
2331 cp_error ("`%D' access", $2);
2332 else if ($$ == access_public_node)
2333 $$ = access_public_virtual_node;
2334 else if ($$ == access_protected_node)
2335 $$ = access_protected_virtual_node;
2336 else if ($$ == access_private_node)
2337 $$ = access_private_virtual_node;
2339 error ("multiple `virtual' specifiers");
2343 opt.component_decl_list:
2344 | component_decl_list
2345 | opt.component_decl_list access_specifier component_decl_list
2346 | opt.component_decl_list access_specifier
2352 current_access_specifier = $1;
2356 /* Note: we no longer warn about the semicolon after a component_decl_list.
2357 ARM $9.2 says that the semicolon is optional, and therefore allowed. */
2358 component_decl_list:
2361 finish_member_declaration ($1);
2363 | component_decl_list component_decl
2365 finish_member_declaration ($2);
2370 component_decl_1 ';'
2371 | component_decl_1 '}'
2372 { error ("missing ';' before right brace");
2373 yyungetc ('}', 0); }
2374 /* C++: handle constructors, destructors and inline functions */
2375 /* note that INLINE is like a TYPESPEC */
2376 | fn.def2 ':' /* base_init compstmt */
2377 { $$ = finish_method ($$); }
2378 | fn.def2 TRY /* base_init compstmt */
2379 { $$ = finish_method ($$); }
2380 | fn.def2 RETURN_KEYWORD /* base_init compstmt */
2381 { $$ = finish_method ($$); }
2382 | fn.def2 '{' /* nodecls compstmt */
2383 { $$ = finish_method ($$); }
2386 | extension component_decl
2389 | template_header component_decl
2392 $$ = finish_member_template_decl ($2);
2394 /* The component was already processed. */
2397 finish_template_decl ($1);
2399 | template_header typed_declspecs ';'
2401 $$ = finish_member_class_template ($2.t);
2402 finish_template_decl ($1);
2407 /* Do not add a "typed_declspecs declarator" rule here for
2408 speed; we need to call grok_x_components for enums, so the
2409 speedup would be insignificant. */
2410 typed_declspecs components
2412 /* Most of the productions for component_decl only
2413 allow the creation of one new member, so we call
2414 finish_member_declaration in component_decl_list.
2415 For this rule and the next, however, there can be
2416 more than one member, e.g.:
2420 and we need the first member to be fully
2421 registered before the second is processed.
2422 Therefore, the rules for components take care of
2423 this processing. To avoid registering the
2424 components more than once, we send NULL_TREE up
2425 here; that lets finish_member_declaration know
2426 that there is nothing to do. */
2428 grok_x_components ($1.t);
2431 | declmods notype_components
2434 grok_x_components ($1);
2437 | notype_declarator maybeasm maybe_attribute maybe_init
2438 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2439 build_tree_list ($3, NULL_TREE)); }
2440 | constructor_declarator maybeasm maybe_attribute maybe_init
2441 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2442 build_tree_list ($3, NULL_TREE)); }
2443 | ':' expr_no_commas
2444 { $$ = grokbitfield (NULL_TREE, NULL_TREE, $2); }
2448 /* These rules introduce a reduce/reduce conflict; in
2449 typedef int foo, bar;
2453 should "A::foo" be declared as a function or "A::bar" as a data
2454 member? In other words, is "bar" an after_type_declarator or a
2456 | declmods component_constructor_declarator maybeasm maybe_attribute maybe_init
2457 { tree specs, attrs;
2458 split_specs_attrs ($1, &specs, &attrs);
2459 $$ = grokfield ($2, specs, $5, $3,
2460 build_tree_list ($4, attrs)); }
2461 | component_constructor_declarator maybeasm maybe_attribute maybe_init
2462 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2463 build_tree_list ($3, NULL_TREE)); }
2465 { $$ = do_class_using_decl ($1); }
2467 /* The case of exactly one component is handled directly by component_decl. */
2470 /* empty: possibly anonymous */
2472 | component_declarator0
2474 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2475 $1 = finish_member_template_decl ($1);
2476 finish_member_declaration ($1);
2479 | components ',' component_declarator
2481 check_multiple_declarators ();
2482 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2483 $3 = finish_member_template_decl ($3);
2484 finish_member_declaration ($3);
2490 /* empty: possibly anonymous */
2492 | notype_component_declarator0
2494 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2495 $1 = finish_member_template_decl ($1);
2496 finish_member_declaration ($1);
2499 | notype_components ',' notype_component_declarator
2501 check_multiple_declarators ();
2502 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2503 $3 = finish_member_template_decl ($3);
2504 finish_member_declaration ($3);
2509 component_declarator0:
2510 after_type_component_declarator0
2511 | notype_component_declarator0
2514 component_declarator:
2515 after_type_component_declarator
2516 | notype_component_declarator
2519 after_type_component_declarator0:
2520 after_type_declarator maybeasm maybe_attribute maybe_init
2521 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2522 &prefix_attributes);
2523 $<ttype>0 = current_declspecs;
2524 $$ = grokfield ($$, current_declspecs, $4, $2,
2525 build_tree_list ($3, prefix_attributes)); }
2526 | TYPENAME ':' expr_no_commas maybe_attribute
2527 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2528 &prefix_attributes);
2529 $<ttype>0 = current_declspecs;
2530 $$ = grokbitfield ($$, current_declspecs, $3);
2531 cplus_decl_attributes ($$, $4, prefix_attributes); }
2534 notype_component_declarator0:
2535 notype_declarator maybeasm maybe_attribute maybe_init
2536 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2537 &prefix_attributes);
2538 $<ttype>0 = current_declspecs;
2539 $$ = grokfield ($$, current_declspecs, $4, $2,
2540 build_tree_list ($3, prefix_attributes)); }
2541 | constructor_declarator maybeasm maybe_attribute maybe_init
2542 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2543 &prefix_attributes);
2544 $<ttype>0 = current_declspecs;
2545 $$ = grokfield ($$, current_declspecs, $4, $2,
2546 build_tree_list ($3, prefix_attributes)); }
2547 | IDENTIFIER ':' expr_no_commas maybe_attribute
2548 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2549 &prefix_attributes);
2550 $<ttype>0 = current_declspecs;
2551 $$ = grokbitfield ($$, current_declspecs, $3);
2552 cplus_decl_attributes ($$, $4, prefix_attributes); }
2553 | ':' expr_no_commas maybe_attribute
2554 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2555 &prefix_attributes);
2556 $<ttype>0 = current_declspecs;
2557 $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
2558 cplus_decl_attributes ($$, $3, prefix_attributes); }
2561 after_type_component_declarator:
2562 after_type_declarator maybeasm maybe_attribute maybe_init
2563 { $$ = grokfield ($$, current_declspecs, $4, $2,
2564 build_tree_list ($3, prefix_attributes)); }
2565 | TYPENAME ':' expr_no_commas maybe_attribute
2566 { $$ = grokbitfield ($$, current_declspecs, $3);
2567 cplus_decl_attributes ($$, $4, prefix_attributes); }
2570 notype_component_declarator:
2571 notype_declarator maybeasm maybe_attribute maybe_init
2572 { $$ = grokfield ($$, current_declspecs, $4, $2,
2573 build_tree_list ($3, prefix_attributes)); }
2574 | IDENTIFIER ':' expr_no_commas maybe_attribute
2575 { $$ = grokbitfield ($$, current_declspecs, $3);
2576 cplus_decl_attributes ($$, $4, prefix_attributes); }
2577 | ':' expr_no_commas maybe_attribute
2578 { $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
2579 cplus_decl_attributes ($$, $3, prefix_attributes); }
2583 enumlist maybecomma_warn
2587 /* We chain the enumerators in reverse order.
2588 Because of the way enums are built, the order is
2589 insignificant. Take advantage of this fact. */
2593 | enumlist ',' enumerator
2598 { build_enumerator ($1, NULL_TREE, current_enum_type); }
2599 | identifier '=' expr_no_commas
2600 { build_enumerator ($1, $3, current_enum_type); }
2603 /* ANSI new-type-id (5.3.4) */
2605 type_specifier_seq new_declarator
2606 { $$.t = build_decl_list ($1.t, $2);
2607 $$.new_type_flag = $1.new_type_flag; }
2608 | type_specifier_seq %prec EMPTY
2609 { $$.t = build_decl_list ($1.t, NULL_TREE);
2610 $$.new_type_flag = $1.new_type_flag; }
2611 /* GNU extension to allow arrays of arbitrary types with
2612 non-constant dimension. */
2613 | '(' type_id ')' '[' expr ']'
2616 pedwarn ("ANSI C++ forbids array dimensions with parenthesized type in new");
2617 $$.t = build_parse_node (ARRAY_REF, TREE_VALUE ($2.t), $5);
2618 $$.t = build_decl_list (TREE_PURPOSE ($2.t), $$.t);
2619 $$.new_type_flag = $2.new_type_flag;
2624 /* empty */ %prec EMPTY
2626 | cv_qualifiers CV_QUALIFIER
2627 { $$ = decl_tree_cons (NULL_TREE, $2, $$); }
2630 nonempty_cv_qualifiers:
2632 { $$.t = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
2633 $$.new_type_flag = 0; }
2634 | nonempty_cv_qualifiers CV_QUALIFIER
2635 { $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
2636 $$.new_type_flag = $1.new_type_flag; }
2639 /* These rules must follow the rules for function declarations
2640 and component declarations. That way, longer rules are preferred. */
2642 /* An expression which will not live on the momentary obstack. */
2644 '(' nonnull_exprlist ')'
2649 { $$ = empty_parms (); }
2654 /* A declarator that is allowed only after an explicit typespec. */
2656 after_type_declarator_intern:
2657 after_type_declarator
2658 | attributes after_type_declarator
2660 /* Provide support for '(' attributes '*' declarator ')'
2662 $$ = decl_tree_cons ($1, $2, NULL_TREE);
2666 /* may all be followed by prec '.' */
2667 after_type_declarator:
2668 '*' nonempty_cv_qualifiers after_type_declarator_intern %prec UNARY
2669 { $$ = make_pointer_declarator ($2.t, $3); }
2670 | '&' nonempty_cv_qualifiers after_type_declarator_intern %prec UNARY
2671 { $$ = make_reference_declarator ($2.t, $3); }
2672 | '*' after_type_declarator_intern %prec UNARY
2673 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2674 | '&' after_type_declarator_intern %prec UNARY
2675 { $$ = make_reference_declarator (NULL_TREE, $2); }
2676 | ptr_to_mem cv_qualifiers after_type_declarator_intern
2677 { tree arg = make_pointer_declarator ($2, $3);
2678 $$ = build_parse_node (SCOPE_REF, $1, arg);
2680 | direct_after_type_declarator
2683 direct_after_type_declarator:
2684 direct_after_type_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2685 { $$ = make_call_declarator ($$, $2, $3, $4); }
2686 | direct_after_type_declarator '[' expr ']'
2687 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
2688 | direct_after_type_declarator '[' ']'
2689 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
2690 | '(' after_type_declarator_intern ')'
2692 | nested_name_specifier type_name %prec EMPTY
2693 { push_nested_class ($1, 3);
2694 $$ = build_parse_node (SCOPE_REF, $$, $2);
2695 TREE_COMPLEXITY ($$) = current_class_depth; }
2696 | type_name %prec EMPTY
2700 type_name %prec EMPTY
2702 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2704 $$ = lookup_name ($1, 1);
2705 maybe_note_name_used_in_class ($1, $$);
2710 | global_scope type_name
2712 if (TREE_CODE ($2) == IDENTIFIER_NODE)
2713 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
2716 got_scope = NULL_TREE;
2723 | global_scope nested_type
2728 nested_name_specifier type_name %prec EMPTY
2729 { $$ = get_type_decl ($2); }
2732 /* A declarator allowed whether or not there has been
2733 an explicit typespec. These cannot redeclare a typedef-name. */
2735 notype_declarator_intern:
2737 | attributes notype_declarator
2739 /* Provide support for '(' attributes '*' declarator ')'
2741 $$ = decl_tree_cons ($1, $2, NULL_TREE);
2746 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2747 { $$ = make_pointer_declarator ($2.t, $3); }
2748 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2749 { $$ = make_reference_declarator ($2.t, $3); }
2750 | '*' notype_declarator_intern %prec UNARY
2751 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2752 | '&' notype_declarator_intern %prec UNARY
2753 { $$ = make_reference_declarator (NULL_TREE, $2); }
2754 | ptr_to_mem cv_qualifiers notype_declarator_intern
2755 { tree arg = make_pointer_declarator ($2, $3);
2756 $$ = build_parse_node (SCOPE_REF, $1, arg);
2758 | direct_notype_declarator
2761 complex_notype_declarator:
2762 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2763 { $$ = make_pointer_declarator ($2.t, $3); }
2764 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2765 { $$ = make_reference_declarator ($2.t, $3); }
2766 | '*' complex_notype_declarator %prec UNARY
2767 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2768 | '&' complex_notype_declarator %prec UNARY
2769 { $$ = make_reference_declarator (NULL_TREE, $2); }
2770 | ptr_to_mem cv_qualifiers notype_declarator_intern
2771 { tree arg = make_pointer_declarator ($2, $3);
2772 $$ = build_parse_node (SCOPE_REF, $1, arg);
2774 | complex_direct_notype_declarator
2777 complex_direct_notype_declarator:
2778 direct_notype_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2779 { $$ = make_call_declarator ($$, $2, $3, $4); }
2780 | '(' complex_notype_declarator ')'
2782 | direct_notype_declarator '[' expr ']'
2783 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
2784 | direct_notype_declarator '[' ']'
2785 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
2786 | notype_qualified_id
2787 { enter_scope_of ($1); }
2788 | nested_name_specifier notype_template_declarator
2789 { got_scope = NULL_TREE;
2790 $$ = build_parse_node (SCOPE_REF, $1, $2);
2791 enter_scope_of ($$);
2796 nested_name_specifier unqualified_id
2797 { got_scope = NULL_TREE;
2798 $$ = build_parse_node (SCOPE_REF, $$, $2); }
2799 | nested_name_specifier object_template_id
2800 { got_scope = NULL_TREE;
2801 $$ = build_parse_node (SCOPE_REF, $1, $2); }
2804 notype_qualified_id:
2805 nested_name_specifier notype_unqualified_id
2806 { got_scope = NULL_TREE;
2807 $$ = build_parse_node (SCOPE_REF, $$, $2); }
2808 | nested_name_specifier object_template_id
2809 { got_scope = NULL_TREE;
2810 $$ = build_parse_node (SCOPE_REF, $1, $2); }
2815 | global_scope notype_qualified_id
2820 typespec '(' nonnull_exprlist ')'
2821 { $$ = build_functional_cast ($1.t, $3); }
2822 | typespec '(' expr_or_declarator_intern ')'
2823 { $$ = reparse_decl_as_expr ($1.t, $3); }
2824 | typespec fcast_or_absdcl %prec EMPTY
2825 { $$ = reparse_absdcl_as_expr ($1.t, $2); }
2830 | template_type %prec EMPTY
2833 nested_name_specifier:
2834 nested_name_specifier_1
2835 | nested_name_specifier nested_name_specifier_1
2837 | nested_name_specifier TEMPLATE explicit_template_type SCOPE
2839 = make_typename_type ($1, $3, /*complain=*/1); }
2842 /* Why the @#$%^& do type_name and notype_identifier need to be expanded
2843 inline here?!? (jason) */
2844 nested_name_specifier_1:
2847 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2850 maybe_note_name_used_in_class ($1, $$);
2853 complete_type (TYPE_MAIN_VARIANT (TREE_TYPE ($$)));
2857 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2859 got_scope = $$ = TREE_TYPE ($$);
2863 if (TREE_CODE ($$) == IDENTIFIER_NODE)
2867 | template_type SCOPE
2868 { got_scope = $$ = complete_type (TREE_TYPE ($1)); }
2869 /* These break 'const i;'
2873 cp_error ("`%D' is not an aggregate typedef",
2874 lastiddecl ? lastiddecl : $$);
2875 $$ = error_mark_node;
2878 { goto failed_scope; } */
2883 | global_scope typename_sub0
2888 typename_sub1 identifier %prec EMPTY
2890 if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't')
2891 $$ = make_typename_type ($1, $2, /*complain=*/1);
2892 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
2893 cp_error ("`%T' is not a class or namespace", $2);
2897 if (TREE_CODE ($$) == TYPE_DECL)
2898 $$ = TREE_TYPE ($$);
2901 | typename_sub1 template_type %prec EMPTY
2902 { $$ = TREE_TYPE ($2); }
2903 | typename_sub1 explicit_template_type %prec EMPTY
2904 { $$ = make_typename_type ($1, $2, /*complain=*/1); }
2905 | typename_sub1 TEMPLATE explicit_template_type %prec EMPTY
2906 { $$ = make_typename_type ($1, $3, /*complain=*/1); }
2912 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2913 cp_error ("`%T' is not a class or namespace", $1);
2915 | typename_sub1 typename_sub2
2917 if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't')
2918 $$ = make_typename_type ($1, $2, /*complain=*/1);
2919 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
2920 cp_error ("`%T' is not a class or namespace", $2);
2924 if (TREE_CODE ($$) == TYPE_DECL)
2925 $$ = TREE_TYPE ($$);
2928 | typename_sub1 explicit_template_type SCOPE
2930 = make_typename_type ($1, $2, /*complain=*/1); }
2931 | typename_sub1 TEMPLATE explicit_template_type SCOPE
2933 = make_typename_type ($1, $3, /*complain=*/1); }
2939 if (TREE_CODE ($1) != IDENTIFIER_NODE)
2942 /* Retrieve the type for the identifier, which might involve
2943 some computation. */
2944 got_scope = $$ = complete_type (IDENTIFIER_TYPE_VALUE ($1));
2946 if ($$ == error_mark_node)
2947 cp_error ("`%T' is not a class or namespace", $1);
2951 if (TREE_CODE ($1) != IDENTIFIER_NODE)
2953 got_scope = $$ = complete_type (TREE_TYPE ($$));
2955 | template_type SCOPE
2956 { got_scope = $$ = complete_type (TREE_TYPE ($$)); }
2961 if (TREE_CODE ($$) == IDENTIFIER_NODE)
2967 explicit_template_type:
2968 identifier '<' template_arg_list_opt template_close_bracket
2969 { $$ = build_min_nt (TEMPLATE_ID_EXPR, $1, $3); }
2973 global_scope type_name
2975 if (TREE_CODE ($2) == IDENTIFIER_NODE)
2976 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
2979 got_scope = NULL_TREE;
2982 | global_scope nested_type
2987 nested_name_specifier '*'
2988 { got_scope = NULL_TREE; }
2989 | global_scope nested_name_specifier '*'
2990 { $$ = $2; got_scope = NULL_TREE; }
2993 /* All uses of explicit global scope must go through this nonterminal so
2994 that got_scope will be set before yylex is called to get the next token. */
2997 { got_scope = void_type_node; }
3000 /* ANSI new-declarator (5.3.4) */
3002 '*' cv_qualifiers new_declarator
3003 { $$ = make_pointer_declarator ($2, $3); }
3004 | '*' cv_qualifiers %prec EMPTY
3005 { $$ = make_pointer_declarator ($2, NULL_TREE); }
3006 | '&' cv_qualifiers new_declarator %prec EMPTY
3007 { $$ = make_reference_declarator ($2, $3); }
3008 | '&' cv_qualifiers %prec EMPTY
3009 { $$ = make_reference_declarator ($2, NULL_TREE); }
3010 | ptr_to_mem cv_qualifiers %prec EMPTY
3011 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3012 $$ = build_parse_node (SCOPE_REF, $1, arg);
3014 | ptr_to_mem cv_qualifiers new_declarator
3015 { tree arg = make_pointer_declarator ($2, $3);
3016 $$ = build_parse_node (SCOPE_REF, $1, arg);
3018 | direct_new_declarator %prec EMPTY
3021 /* ANSI direct-new-declarator (5.3.4) */
3022 direct_new_declarator:
3024 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3025 | direct_new_declarator '[' expr ']'
3026 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3033 /* Provide support for '(' attributes '*' declarator ')'
3035 $$ = decl_tree_cons ($1, $2, NULL_TREE);
3039 /* ANSI abstract-declarator (8.1) */
3041 '*' nonempty_cv_qualifiers absdcl_intern
3042 { $$ = make_pointer_declarator ($2.t, $3); }
3044 { $$ = make_pointer_declarator (NULL_TREE, $2); }
3045 | '*' nonempty_cv_qualifiers %prec EMPTY
3046 { $$ = make_pointer_declarator ($2.t, NULL_TREE); }
3048 { $$ = make_pointer_declarator (NULL_TREE, NULL_TREE); }
3049 | '&' nonempty_cv_qualifiers absdcl_intern
3050 { $$ = make_reference_declarator ($2.t, $3); }
3052 { $$ = make_reference_declarator (NULL_TREE, $2); }
3053 | '&' nonempty_cv_qualifiers %prec EMPTY
3054 { $$ = make_reference_declarator ($2.t, NULL_TREE); }
3056 { $$ = make_reference_declarator (NULL_TREE, NULL_TREE); }
3057 | ptr_to_mem cv_qualifiers %prec EMPTY
3058 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3059 $$ = build_parse_node (SCOPE_REF, $1, arg);
3061 | ptr_to_mem cv_qualifiers absdcl_intern
3062 { tree arg = make_pointer_declarator ($2, $3);
3063 $$ = build_parse_node (SCOPE_REF, $1, arg);
3065 | direct_abstract_declarator %prec EMPTY
3068 /* ANSI direct-abstract-declarator (8.1) */
3069 direct_abstract_declarator:
3070 '(' absdcl_intern ')'
3072 /* `(typedef)1' is `int'. */
3073 | direct_abstract_declarator '(' parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3074 { $$ = make_call_declarator ($$, $3, $5, $6); }
3075 | direct_abstract_declarator LEFT_RIGHT cv_qualifiers exception_specification_opt %prec '.'
3076 { $$ = make_call_declarator ($$, empty_parms (), $3, $4); }
3077 | direct_abstract_declarator '[' expr ']' %prec '.'
3078 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3079 | direct_abstract_declarator '[' ']' %prec '.'
3080 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
3081 | '(' complex_parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3082 { $$ = make_call_declarator (NULL_TREE, $2, $4, $5); }
3083 | regcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3084 { set_quals_and_spec ($$, $2, $3); }
3085 | fcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3086 { set_quals_and_spec ($$, $2, $3); }
3087 | '[' expr ']' %prec '.'
3088 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3090 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, NULL_TREE); }
3093 /* For C++, decls and stmts can be intermixed, so we don't need to
3094 have a special rule that won't start parsing the stmt section
3095 until we have a stmt that parses without errors. */
3108 /* Read zero or more forward-declarations for labels
3109 that nested functions can jump to. */
3114 pedwarn ("ANSI C++ forbids label declarations"); }
3119 | label_decls label_decl
3123 LABEL identifiers_or_typenames ';'
3127 finish_label_decl (TREE_VALUE ($2));
3128 $2 = TREE_CHAIN ($2);
3133 /* This is the body of a function definition.
3134 It causes syntax errors to ignore to the next openbrace. */
3143 { $<ttype>$ = begin_compound_stmt (0); }
3145 { $$ = finish_compound_stmt (0, $<ttype>2); }
3151 $<ttype>$ = begin_if_stmt ();
3152 cond_stmt_keyword = "if";
3155 { finish_if_stmt_cond ($3, $<ttype>2); }
3156 implicitly_scoped_stmt
3157 { $<ttype>$ = finish_then_clause ($<ttype>2); }
3160 implicitly_scoped_stmt:
3162 | { $<ttype>$ = begin_compound_stmt (0); }
3164 { $$ = finish_compound_stmt (0, $<ttype>1); }
3177 { finish_expr_stmt ($1); }
3179 { begin_else_clause (); }
3180 implicitly_scoped_stmt
3182 finish_else_clause ($<ttype>1);
3185 | simple_if %prec IF
3186 { finish_if_stmt (); }
3189 $<ttype>$ = begin_while_stmt ();
3190 cond_stmt_keyword = "while";
3193 { finish_while_stmt_cond ($3, $<ttype>2); }
3195 { finish_while_stmt ($<ttype>2); }
3197 { $<ttype>$ = begin_do_stmt (); }
3198 implicitly_scoped_stmt WHILE
3200 finish_do_body ($<ttype>2);
3201 cond_stmt_keyword = "do";
3203 paren_expr_or_null ';'
3204 { finish_do_stmt ($6, $<ttype>2); }
3206 { $<ttype>$ = begin_for_stmt (); }
3207 '(' for.init.statement
3208 { finish_for_init_stmt ($<ttype>2); }
3210 { finish_for_cond ($6, $<ttype>2); }
3212 { finish_for_expr ($9, $<ttype>2); }
3214 { finish_for_stmt ($9, $<ttype>2); }
3216 { $<ttype>$ = begin_switch_stmt (); }
3218 { finish_switch_cond ($4, $<ttype>2); }
3219 implicitly_scoped_stmt
3220 { finish_switch_stmt ($4, $<ttype>2); }
3221 | CASE expr_no_commas ':'
3222 { finish_case_label ($2, NULL_TREE); }
3224 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
3225 { finish_case_label ($2, $4); }
3228 { finish_case_label (NULL_TREE, NULL_TREE); }
3231 { finish_break_stmt (); }
3233 { finish_continue_stmt (); }
3234 | RETURN_KEYWORD ';'
3235 { finish_return_stmt (NULL_TREE); }
3236 | RETURN_KEYWORD expr ';'
3237 { finish_return_stmt ($2); }
3238 | asm_keyword maybe_cv_qualifier '(' string ')' ';'
3240 finish_asm_stmt ($2, $4, NULL_TREE, NULL_TREE,
3243 /* This is the case with just output operands. */
3244 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ')' ';'
3246 finish_asm_stmt ($2, $4, $6, NULL_TREE,
3249 /* This is the case with input operands as well. */
3250 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':' asm_operands ')' ';'
3251 { finish_asm_stmt ($2, $4, $6, $8, NULL_TREE); }
3252 /* This is the case with clobbered registers as well. */
3253 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':'
3254 asm_operands ':' asm_clobbers ')' ';'
3255 { finish_asm_stmt ($2, $4, $6, $8, $10); }
3259 pedwarn ("ANSI C++ forbids computed gotos");
3260 finish_goto_stmt ($3);
3262 | GOTO identifier ';'
3263 { finish_goto_stmt ($2); }
3266 { error ("label must be followed by statement");
3267 yyungetc ('}', 0); }
3272 | namespace_using_decl
3273 { do_local_using_decl ($1); }
3279 { $<ttype>$ = begin_function_try_block (); }
3280 ctor_initializer_opt compstmt
3281 { finish_function_try_block ($<ttype>2); }
3284 finish_function_handler_sequence ($<ttype>2);
3291 { $<ttype>$ = begin_try_block (); }
3293 { finish_try_block ($<ttype>2); }
3295 { finish_handler_sequence ($<ttype>2); }
3300 | handler_seq handler
3305 { $<ttype>$ = begin_handler(); }
3307 { $<ttype>$ = finish_handler_parms ($3, $<ttype>2); }
3309 { finish_handler ($<ttype>4, $<ttype>2); }
3313 typed_typespecs %prec EMPTY
3314 | nonempty_cv_qualifiers %prec EMPTY
3320 /* This doesn't allow reference parameters, the below does.
3321 | '(' type_specifier_seq absdcl ')'
3322 { check_for_new_type ("inside exception declarations", $2);
3323 expand_start_catch_block ($2.t, $3); }
3324 | '(' type_specifier_seq ')'
3325 { check_for_new_type ("inside exception declarations", $2);
3326 expand_start_catch_block ($2.t, NULL_TREE); }
3327 | '(' type_specifier_seq notype_declarator ')'
3328 { check_for_new_type ("inside exception declarations", $2);
3329 expand_start_catch_block ($2.t, $3); }
3330 | '(' typed_typespecs after_type_declarator ')'
3331 { check_for_new_type ("inside exception declarations", $2);
3332 expand_start_catch_block ($2.t, $3); }
3333 This allows reference parameters... */
3336 check_for_new_type ("inside exception declarations", $2);
3337 $$ = start_handler_parms (TREE_PURPOSE ($2.t),
3344 { finish_label_stmt ($1); }
3346 { finish_label_stmt ($1); }
3348 { finish_label_stmt ($1); }
3350 { finish_label_stmt ($1); }
3355 { finish_expr_stmt ($1); }
3359 pedwarn ("ANSI C++ forbids compound statements inside for initializations");
3363 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
3367 { emit_line_note (input_filename, lineno);
3370 { emit_line_note (input_filename, lineno); }
3381 /* These are the operands other than the first string and colon
3382 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
3386 | nonnull_asm_operands
3389 nonnull_asm_operands:
3391 | nonnull_asm_operands ',' asm_operand
3392 { $$ = chainon ($$, $3); }
3397 { $$ = build_tree_list ($$, $3); }
3402 { $$ = tree_cons (NULL_TREE, $$, NULL_TREE); }
3403 | asm_clobbers ',' STRING
3404 { $$ = tree_cons (NULL_TREE, $3, $$); }
3407 /* This is what appears inside the parens in a function declarator.
3408 Its value is represented in the format that grokdeclarator expects.
3410 In C++, declaring a function with no parameters
3411 means that that function takes *no* parameters. */
3420 { $$ = finish_parmlist (build_tree_list (NULL_TREE, $1.t), 0);
3421 check_for_new_type ("inside parameter list", $1); }
3424 /* This nonterminal does not include the common sequence '(' type_id ')',
3425 as it is ambiguous and must be disambiguated elsewhere. */
3428 { $$ = finish_parmlist ($$, 0); }
3429 | parms_comma ELLIPSIS
3430 { $$ = finish_parmlist ($1, 1); }
3431 /* C++ allows an ellipsis without a separating ',' */
3433 { $$ = finish_parmlist ($1, 1); }
3435 { $$ = finish_parmlist (build_tree_list (NULL_TREE,
3438 { $$ = finish_parmlist (NULL_TREE, 1); }
3441 /* This helps us recover from really nasty
3442 parse errors, for example, a missing right
3444 yyerror ("possibly missing ')'");
3445 $$ = finish_parmlist ($1, 0);
3451 /* This helps us recover from really nasty
3452 parse errors, for example, a missing right
3454 yyerror ("possibly missing ')'");
3455 $$ = finish_parmlist (build_tree_list (NULL_TREE,
3462 /* A default argument to a */
3465 { maybe_snarf_defarg (); }
3475 /* A nonempty list of parameter declarations or type names. */
3478 { check_for_new_type ("in a parameter list", $1);
3479 $$ = build_tree_list (NULL_TREE, $1.t); }
3481 { check_for_new_type ("in a parameter list", $1);
3482 $$ = build_tree_list ($2, $1.t); }
3483 | parms_comma full_parm
3484 { check_for_new_type ("in a parameter list", $2);
3485 $$ = chainon ($$, $2.t); }
3486 | parms_comma bad_parm
3487 { $$ = chainon ($$, build_tree_list (NULL_TREE, $2)); }
3488 | parms_comma bad_parm '=' init
3489 { $$ = chainon ($$, build_tree_list ($4, $2)); }
3495 { check_for_new_type ("in a parameter list", $1);
3496 $$ = build_tree_list (NULL_TREE, $1.t); }
3499 /* A single parameter declaration or parameter type name,
3500 as found in a parmlist. */
3502 /* Here we expand typed_declspecs inline to avoid mis-parsing of
3503 TYPESPEC IDENTIFIER. */
3504 typed_declspecs1 declarator
3505 { tree specs = strip_attrs ($1.t);
3506 $$.new_type_flag = $1.new_type_flag;
3507 $$.t = build_tree_list (specs, $2); }
3508 | typed_typespecs declarator
3509 { $$.t = build_tree_list ($1.t, $2);
3510 $$.new_type_flag = $1.new_type_flag; }
3511 | typespec declarator
3512 { $$.t = build_tree_list (build_decl_list (NULL_TREE, $1.t),
3514 $$.new_type_flag = $1.new_type_flag; }
3515 | typed_declspecs1 absdcl
3516 { tree specs = strip_attrs ($1.t);
3517 $$.t = build_tree_list (specs, $2);
3518 $$.new_type_flag = $1.new_type_flag; }
3519 | typed_declspecs1 %prec EMPTY
3520 { tree specs = strip_attrs ($1.t);
3521 $$.t = build_tree_list (specs, NULL_TREE);
3522 $$.new_type_flag = $1.new_type_flag; }
3523 | declmods notype_declarator
3524 { tree specs = strip_attrs ($1);
3525 $$.t = build_tree_list (specs, $2);
3526 $$.new_type_flag = 0; }
3531 { $$.t = build_tree_list (NULL_TREE, $1.t);
3532 $$.new_type_flag = $1.new_type_flag; }
3534 { $$.t = build_tree_list ($2, $1.t);
3535 $$.new_type_flag = $1.new_type_flag; }
3544 /* empty */ %prec EMPTY
3545 { see_typename (); }
3549 /* empty */ %prec EMPTY
3551 error ("type specifier omitted for parameter");
3552 $$ = build_tree_list (integer_type_node, NULL_TREE);
3556 error ("type specifier omitted for parameter");
3557 if (TREE_CODE ($$) == SCOPE_REF
3558 && (TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TYPE_PARM
3559 || TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TEMPLATE_PARM))
3560 cp_error (" perhaps you want `typename %E' to make it a type", $$);
3561 $$ = build_tree_list (integer_type_node, $$);
3565 exception_specification_opt:
3566 /* empty */ %prec EMPTY
3568 | THROW '(' ansi_raise_identifiers ')' %prec EMPTY
3570 | THROW LEFT_RIGHT %prec EMPTY
3571 { $$ = empty_except_spec; }
3574 ansi_raise_identifier:
3577 check_for_new_type ("exception specifier", $1);
3578 $$ = groktypename ($1.t);
3582 ansi_raise_identifiers:
3583 ansi_raise_identifier
3584 { $$ = add_exception_specifier (NULL_TREE, $1, 1); }
3585 | ansi_raise_identifiers ',' ansi_raise_identifier
3586 { $$ = add_exception_specifier ($1, $3, 1); }
3589 conversion_declarator:
3590 /* empty */ %prec EMPTY
3592 | '*' cv_qualifiers conversion_declarator
3593 { $$ = make_pointer_declarator ($2, $3); }
3594 | '&' cv_qualifiers conversion_declarator
3595 { $$ = make_reference_declarator ($2, $3); }
3596 | ptr_to_mem cv_qualifiers conversion_declarator
3597 { tree arg = make_pointer_declarator ($2, $3);
3598 $$ = build_parse_node (SCOPE_REF, $1, arg);
3604 { got_scope = NULL_TREE; }
3609 { $$ = ansi_opname[MULT_EXPR]; }
3611 { $$ = ansi_opname[TRUNC_DIV_EXPR]; }
3613 { $$ = ansi_opname[TRUNC_MOD_EXPR]; }
3615 { $$ = ansi_opname[PLUS_EXPR]; }
3617 { $$ = ansi_opname[MINUS_EXPR]; }
3619 { $$ = ansi_opname[BIT_AND_EXPR]; }
3621 { $$ = ansi_opname[BIT_IOR_EXPR]; }
3623 { $$ = ansi_opname[BIT_XOR_EXPR]; }
3625 { $$ = ansi_opname[BIT_NOT_EXPR]; }
3627 { $$ = ansi_opname[COMPOUND_EXPR]; }
3628 | operator ARITHCOMPARE
3629 { $$ = ansi_opname[$2]; }
3631 { $$ = ansi_opname[LT_EXPR]; }
3633 { $$ = ansi_opname[GT_EXPR]; }
3634 | operator EQCOMPARE
3635 { $$ = ansi_opname[$2]; }
3637 { $$ = ansi_assopname[$2]; }
3639 { $$ = ansi_opname [MODIFY_EXPR]; }
3641 { $$ = ansi_opname[$2]; }
3643 { $$ = ansi_opname[$2]; }
3645 { $$ = ansi_opname[POSTINCREMENT_EXPR]; }
3646 | operator MINUSMINUS
3647 { $$ = ansi_opname[PREDECREMENT_EXPR]; }
3649 { $$ = ansi_opname[TRUTH_ANDIF_EXPR]; }
3651 { $$ = ansi_opname[TRUTH_ORIF_EXPR]; }
3653 { $$ = ansi_opname[TRUTH_NOT_EXPR]; }
3655 { $$ = ansi_opname[COND_EXPR]; }
3657 { $$ = ansi_opname[$2]; }
3658 | operator POINTSAT %prec EMPTY
3659 { $$ = ansi_opname[COMPONENT_REF]; }
3660 | operator POINTSAT_STAR %prec EMPTY
3661 { $$ = ansi_opname[MEMBER_REF]; }
3662 | operator LEFT_RIGHT
3663 { $$ = ansi_opname[CALL_EXPR]; }
3665 { $$ = ansi_opname[ARRAY_REF]; }
3666 | operator NEW %prec EMPTY
3667 { $$ = ansi_opname[NEW_EXPR]; }
3668 | operator DELETE %prec EMPTY
3669 { $$ = ansi_opname[DELETE_EXPR]; }
3670 | operator NEW '[' ']'
3671 { $$ = ansi_opname[VEC_NEW_EXPR]; }
3672 | operator DELETE '[' ']'
3673 { $$ = ansi_opname[VEC_DELETE_EXPR]; }
3674 /* Names here should be looked up in class scope ALSO. */
3675 | operator type_specifier_seq conversion_declarator
3676 { $$ = grokoptypename ($2.t, $3); }
3678 { $$ = ansi_opname[ERROR_MARK]; }
3685 debug_yytranslate (value)
3688 return yytname[YYTRANSLATE (value)];