1 /* YACC parser for C++ syntax.
2 Copyright (C) 1988, 89, 93, 94, 95, 1996 Free Software Foundation, Inc.
3 Hacked by Michael Tiemann (tiemann@cygnus.com)
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
23 /* This grammar is based on the GNU CC grammar. */
25 /* Note: Bison automatically applies a default action of "$$ = $1" for
26 all derivations; this is applied before the explicit action, if one
27 is given. Keep this in mind when reading the actions. */
30 /* Cause the `yydebug' variable to be defined. */
46 /* Since parsers are distinct for each language, put the language string
47 definition here. (fnf) */
48 char *language_string = "GNU C++";
50 extern tree void_list_node;
51 extern struct obstack permanent_obstack;
53 extern int end_of_file;
55 /* Like YYERROR but do call yyerror. */
56 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
58 #define OP0(NODE) (TREE_OPERAND (NODE, 0))
59 #define OP1(NODE) (TREE_OPERAND (NODE, 1))
61 /* Contains the statement keyword (if/while/do) to include in an
62 error message if the user supplies an empty conditional expression. */
63 static char *cond_stmt_keyword;
65 static tree empty_parms PROTO((void));
67 /* Nonzero if we have an `extern "C"' acting as an extern specifier. */
71 /* Cons up an empty parameter list. */
81 || current_class_type != NULL)
82 parms = void_list_node;
92 %union {long itype; tree ttype; char *strtype; enum tree_code code; flagged_type_tree ftype; }
94 /* All identifiers that are not reserved words
95 and are not declared typedefs in the current block */
98 /* All identifiers that are declared typedefs in the current block.
99 In some contexts, they are treated just like IDENTIFIER,
100 but they can also serve as typespecs in declarations. */
104 /* A template function. */
107 /* Reserved words that specify storage class.
108 yylval contains an IDENTIFIER_NODE which indicates which one. */
111 /* Reserved words that specify type.
112 yylval contains an IDENTIFIER_NODE which indicates which one. */
115 /* Reserved words that qualify type: "const" or "volatile".
116 yylval contains an IDENTIFIER_NODE which indicates which one. */
119 /* Character or numeric constants.
120 yylval is the node for the constant. */
123 /* String constants in raw form.
124 yylval is a STRING_CST node. */
127 /* "...", used for functions with variable arglists. */
130 /* the reserved words */
131 /* SCO include files test "ASM", so use something else. */
132 %token SIZEOF ENUM /* STRUCT UNION */ IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
133 %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD TYPEOF ALIGNOF
135 %token ATTRIBUTE EXTENSION LABEL
136 %token REALPART IMAGPART
138 /* the reserved words... C++ extensions */
140 %token <ttype> VISSPEC
141 %token DELETE NEW THIS OPERATOR CXX_TRUE CXX_FALSE
142 %token NAMESPACE TYPENAME_KEYWORD USING
143 %token LEFT_RIGHT TEMPLATE
144 %token TYPEID DYNAMIC_CAST STATIC_CAST REINTERPRET_CAST CONST_CAST
147 /* Define the operator tokens and their precedences.
148 The value is an integer because, if used, it is the tree code
149 to use in the expression made from the operator. */
151 %left EMPTY /* used to resolve s/r with epsilon */
155 /* Add precedence rules to solve dangling else s/r conflict */
159 %left IDENTIFIER PFUNCNAME TYPENAME SELFNAME PTYPENAME SCSPEC TYPESPEC CV_QUALIFIER ENUM AGGR ELLIPSIS TYPEOF SIGOF OPERATOR NSNAME TYPENAME_KEYWORD
165 %right <code> ASSIGN '='
173 %left <code> EQCOMPARE
174 %left <code> ARITHCOMPARE '<' '>'
175 %left <code> LSHIFT RSHIFT
177 %left <code> '*' '/' '%'
178 %left <code> POINTSAT_STAR DOT_STAR
179 %right <code> UNARY PLUSPLUS MINUSMINUS '~'
181 %left <ttype> PAREN_STAR_PAREN LEFT_RIGHT
182 %left <code> POINTSAT '.' '(' '['
184 %right SCOPE /* C++ extension */
185 %nonassoc NEW DELETE TRY CATCH
189 %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist
190 %type <ttype> PFUNCNAME maybe_identifier
191 %type <ttype> paren_expr_or_null nontrivial_exprlist SELFNAME
192 %type <ttype> expr_no_commas cast_expr unary_expr primary string STRING
193 %type <ttype> reserved_declspecs boolean.literal
194 %type <ttype> reserved_typespecquals
195 %type <ttype> declmods
196 %type <ttype> SCSPEC TYPESPEC CV_QUALIFIER maybe_cv_qualifier
197 %type <itype> initdecls notype_initdecls initdcl /* C++ modification */
198 %type <ttype> init initlist maybeasm maybe_init defarg defarg1
199 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
200 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
201 %type <ttype> any_word
203 %type <ttype> compstmt implicitly_scoped_stmt
205 %type <ttype> declarator notype_declarator after_type_declarator
206 %type <ttype> direct_notype_declarator direct_after_type_declarator
208 %type <ttype> opt.component_decl_list component_decl_list
209 %type <ttype> component_decl component_decl_1 components notype_components
210 %type <ttype> component_declarator component_declarator0 self_reference
211 %type <ttype> notype_component_declarator notype_component_declarator0
212 %type <ttype> after_type_component_declarator after_type_component_declarator0
213 %type <ttype> enumlist enumerator
214 %type <ttype> absdcl cv_qualifiers
215 %type <ttype> direct_abstract_declarator conversion_declarator
216 %type <ttype> new_declarator direct_new_declarator
217 %type <ttype> xexpr parmlist parms bad_parm
218 %type <ttype> identifiers_or_typenames
219 %type <ttype> fcast_or_absdcl regcast_or_absdcl
220 %type <ttype> expr_or_declarator complex_notype_declarator
221 %type <ttype> notype_unqualified_id unqualified_id qualified_id
222 %type <ttype> template_id do_id object_template_id notype_template_declarator
223 %type <ttype> overqualified_id notype_qualified_id any_id
224 %type <ttype> complex_direct_notype_declarator functional_cast
225 %type <ttype> complex_parmlist parms_comma
226 %type <ttype> namespace_qualifier namespace_using_decl
228 %type <ftype> type_id new_type_id typed_typespecs typespec typed_declspecs
229 %type <ftype> typed_declspecs1 type_specifier_seq nonempty_cv_qualifiers
230 %type <ftype> structsp typespecqual_reserved parm named_parm full_parm
233 %token <ttype> PTYPENAME
234 %token <ttype> PRE_PARSED_FUNCTION_DECL EXTERN_LANG_STRING ALL
235 %token <ttype> PRE_PARSED_CLASS_DECL DEFARG DEFARG_MARKER
236 %type <ttype> component_constructor_declarator
237 %type <ttype> fn.def2 return_id fn.defpen constructor_declarator
238 %type <itype> ctor_initializer_opt
239 %type <ttype> named_class_head named_class_head_sans_basetype
240 %type <ttype> named_complex_class_head_sans_basetype
241 %type <ttype> unnamed_class_head
242 %type <ttype> class_head base_class_list
243 %type <ttype> base_class_access_list
244 %type <ttype> base_class maybe_base_class_list base_class.1
245 %type <ttype> exception_specification_opt ansi_raise_identifier ansi_raise_identifiers
246 %type <ttype> operator_name
247 %type <ttype> object aggr
248 %type <itype> new delete .begin_new_placement
249 /* %type <ttype> primary_no_id */
250 %type <ttype> nonmomentary_expr maybe_parmlist
251 %type <itype> initdcl0 notype_initdcl0 member_init_list initdcl0_innards
252 %type <ttype> template_header template_parm_list template_parm
253 %type <ttype> template_type_parm template_template_parm
254 %type <code> template_close_bracket
255 %type <ttype> template_type template_arg_list template_arg_list_opt
256 %type <ttype> template_arg
257 %type <ttype> condition xcond paren_cond_or_null
258 %type <ttype> type_name nested_name_specifier nested_type ptr_to_mem
259 %type <ttype> complete_type_name notype_identifier nonnested_type
260 %type <ttype> complex_type_name nested_name_specifier_1
261 %type <ttype> new_initializer new_placement
262 %type <ttype> using_decl
263 %type <ttype> typename_sub typename_sub0 typename_sub1 typename_sub2
264 %type <ttype> explicit_template_type
265 /* in order to recognize aggr tags as defining and thus shadowing. */
266 %token TYPENAME_DEFN IDENTIFIER_DEFN PTYPENAME_DEFN
267 %type <ttype> named_class_head_sans_basetype_defn
268 %type <ttype> identifier_defn IDENTIFIER_DEFN TYPENAME_DEFN PTYPENAME_DEFN
270 %type <ttype> self_template_type
275 /* Used in lex.c for parsing pragmas. */
278 /* lex.c and pt.c depend on this being the last token. Define
279 any new tokens before this one! */
280 %token END_OF_SAVED_INPUT
283 /* List of types and structure classes of the current declaration. */
284 static tree current_declspecs;
286 /* List of prefix attributes in effect.
287 Prefix attributes are parsed by the reserved_declspecs and declmods
288 rules. They create a list that contains *both* declspecs and attrs. */
289 /* ??? It is not clear yet that all cases where an attribute can now appear in
290 a declspec list have been updated. */
291 static tree prefix_attributes;
293 /* When defining an aggregate, this is the most recent one being defined. */
294 static tree current_aggr;
296 /* Tell yyparse how to print a token's value, if yydebug is set. */
298 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
299 extern void yyprint PROTO((FILE *, int, YYSTYPE));
300 extern tree combine_strings PROTO((tree));
303 parse_decl(declarator, specs_attrs, attributes, initialized, decl)
312 split_specs_attrs (specs_attrs, ¤t_declspecs, &prefix_attributes);
313 if (current_declspecs
314 && TREE_CODE (current_declspecs) != TREE_LIST)
315 current_declspecs = get_decl_list (current_declspecs);
316 if (have_extern_spec && !used_extern_spec)
318 current_declspecs = decl_tree_cons (NULL_TREE,
319 get_identifier ("extern"),
321 used_extern_spec = 1;
323 sm = suspend_momentary ();
324 *decl = start_decl (declarator, current_declspecs, initialized,
325 attributes, prefix_attributes);
334 { finish_translation_unit (); }
337 /* the reason for the strange actions in this rule
338 is so that notype_initdecls when reached via datadef
339 can find a valid list of type and sc specs in $0. */
342 { $<ttype>$ = NULL_TREE; }
344 { $<ttype>$ = NULL_TREE; }
345 | extdefs lang_extdef
346 { $<ttype>$ = NULL_TREE; }
355 { have_extern_spec = 1;
356 used_extern_spec = 0;
357 $<ttype>$ = NULL_TREE; }
360 { have_extern_spec = 0; }
365 { $<itype>$ = pedantic;
374 { if (pending_lang_change) do_pending_lang_change(); }
376 { if (! toplevel_bindings_p () && ! pseudo_global_level_p())
381 fndef eat_saved_input
382 { if (pending_inlines) do_pending_inlines (); }
384 { if (pending_inlines) do_pending_inlines (); }
386 { if (pending_inlines) do_pending_inlines (); }
387 | asm_keyword '(' string ')' ';'
388 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
390 | extern_lang_string '{' extdefs_opt '}'
391 { pop_lang_context (); }
392 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
393 { if (pending_inlines) do_pending_inlines ();
394 pop_lang_context (); }
395 | extern_lang_string .hush_warning datadef .warning_ok
396 { if (pending_inlines) do_pending_inlines ();
397 pop_lang_context (); }
398 | NAMESPACE identifier '{'
399 { push_namespace ($2); }
401 { pop_namespace (); }
403 { push_namespace (NULL_TREE); }
405 { pop_namespace (); }
408 { do_toplevel_using_decl ($1); }
411 { pedantic = $<itype>1; }
415 NAMESPACE identifier '='
416 { begin_only_namespace_names (); }
419 end_only_namespace_names ();
422 do_namespace_alias ($2, $5);
429 | USING global_scope qualified_id
431 | USING global_scope unqualified_id
435 namespace_using_decl:
436 USING namespace_qualifier identifier
437 { $$ = build_parse_node (SCOPE_REF, $2, $3); }
438 | USING global_scope identifier
439 { $$ = build_parse_node (SCOPE_REF, global_namespace, $3); }
440 | USING global_scope namespace_qualifier identifier
441 { $$ = build_parse_node (SCOPE_REF, $3, $4); }
446 { begin_only_namespace_names (); }
449 end_only_namespace_names ();
450 /* If no declaration was found, the using-directive is
451 invalid. Since that was not reported, we need the
452 identifier for the error message. */
453 if (TREE_CODE ($4) == IDENTIFIER_NODE && lastiddecl)
455 do_using_directive ($4);
462 if (TREE_CODE ($$) == IDENTIFIER_NODE)
466 | namespace_qualifier NSNAME SCOPE
469 if (TREE_CODE ($$) == IDENTIFIER_NODE)
477 | global_scope qualified_id
479 | global_scope unqualified_id
485 { push_lang_context ($1); }
486 | extern_lang_string EXTERN_LANG_STRING
487 { if (current_lang_name != $2)
488 cp_error ("use of linkage spec `%D' is different from previous spec `%D'", $2, current_lang_name);
489 pop_lang_context (); push_lang_context ($2); }
494 { begin_template_parm_list (); }
495 template_parm_list '>'
496 { $$ = end_template_parm_list ($4); }
498 { begin_specialization();
504 { $$ = process_template_parm (NULL_TREE, $1); }
505 | template_parm_list ',' template_parm
506 { $$ = process_template_parm ($1, $3); }
516 aggr maybe_identifier
517 { $$ = finish_template_type_parm ($1, $2); }
518 | TYPENAME_KEYWORD maybe_identifier
519 { $$ = finish_template_type_parm (class_type_node, $2); }
522 template_template_parm:
523 template_header aggr maybe_identifier
524 { $$ = finish_template_template_parm ($2, $3); }
528 /* The following rules introduce a new reduce/reduce
529 conflict on the ',' and '>' input tokens: they are valid
530 prefixes for a `structsp', which means they could match a
531 nameless parameter. See 14.6, paragraph 3.
532 By putting them before the `parm' rule, we get
533 their match before considering them nameless parameter
536 { $$ = build_tree_list (NULL_TREE, $1); }
537 | template_type_parm '=' type_id
538 { $$ = build_tree_list (groktypename ($3.t), $1); }
540 { $$ = build_tree_list (NULL_TREE, $1.t); }
541 | parm '=' expr_no_commas %prec ARITHCOMPARE
542 { $$ = build_tree_list ($3, $1.t); }
543 | template_template_parm
544 { $$ = build_tree_list (NULL_TREE, $1); }
545 | template_template_parm '=' template_arg
547 if (TREE_CODE ($3) != TEMPLATE_DECL
548 && TREE_CODE ($3) != TEMPLATE_TEMPLATE_PARM
549 && TREE_CODE ($3) != TYPE_DECL)
551 error ("invalid default template argument");
552 $3 = error_mark_node;
554 $$ = build_tree_list ($3, $1);
563 end_template_decl ();
565 end_specialization ();
571 end_template_decl ();
573 end_specialization ();
579 | declmods notype_initdecls ';'
581 | typed_declspecs initdecls ';'
583 note_list_got_semicolon ($1.t);
586 { pedwarn ("empty declaration"); }
587 | explicit_instantiation ';'
588 | typed_declspecs ';'
591 split_specs_attrs ($1.t, &t, &attrs);
593 note_list_got_semicolon ($1.t);
600 ctor_initializer_opt:
619 fn.def1 maybe_return_init ctor_initializer_opt compstmt_or_error
620 { finish_function (lineno, (int)$3, 0); }
621 | fn.def1 maybe_return_init function_try_block
623 | fn.def1 maybe_return_init error
627 constructor_declarator:
628 nested_name_specifier SELFNAME '('
629 { $$ = begin_constructor_declarator ($1, $2); }
630 parmlist ')' cv_qualifiers exception_specification_opt
631 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
632 | nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
633 { $$ = begin_constructor_declarator ($1, $2);
634 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
636 | global_scope nested_name_specifier SELFNAME '('
637 { $$ = begin_constructor_declarator ($2, $3); }
638 parmlist ')' cv_qualifiers exception_specification_opt
639 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
640 | global_scope nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
641 { $$ = begin_constructor_declarator ($2, $3);
642 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
644 | nested_name_specifier self_template_type '('
645 { $$ = begin_constructor_declarator ($1, $2); }
646 parmlist ')' cv_qualifiers exception_specification_opt
647 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
648 | nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
649 { $$ = begin_constructor_declarator ($1, $2);
650 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
652 | global_scope nested_name_specifier self_template_type '('
653 { $$ = begin_constructor_declarator ($2, $3); }
654 parmlist ')' cv_qualifiers exception_specification_opt
655 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
656 | global_scope nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
657 { $$ = begin_constructor_declarator ($2, $3);
658 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
663 typed_declspecs declarator
664 { if (!begin_function_definition ($1.t, $2))
666 | declmods notype_declarator
667 { if (!begin_function_definition ($1, $2))
670 { if (!begin_function_definition (NULL_TREE, $1))
672 | declmods constructor_declarator
673 { if (!begin_function_definition ($1, $2))
675 | constructor_declarator
676 { if (!begin_function_definition (NULL_TREE, $1))
680 component_constructor_declarator:
681 SELFNAME '(' parmlist ')' cv_qualifiers exception_specification_opt
682 { $$ = make_call_declarator ($1, $3, $5, $6); }
683 | SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
684 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
685 | self_template_type '(' parmlist ')' cv_qualifiers exception_specification_opt
686 { $$ = make_call_declarator ($1, $3, $5, $6); }
687 | self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
688 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
691 /* more C++ complexity. See component_decl for a comment on the
692 reduce/reduce conflict introduced by these rules. */
694 declmods component_constructor_declarator
695 { tree specs = strip_attrs ($1);
696 $$ = start_method (specs, $2);
700 if (yychar == YYEMPTY)
702 reinit_parse_for_method (yychar, $$); }
703 | component_constructor_declarator
704 { $$ = start_method (NULL_TREE, $1); goto rest_of_mdef; }
705 | typed_declspecs declarator
706 { tree specs = strip_attrs ($1.t);
707 $$ = start_method (specs, $2); goto rest_of_mdef; }
708 | declmods notype_declarator
709 { tree specs = strip_attrs ($1);
710 $$ = start_method (specs, $2); goto rest_of_mdef; }
712 { $$ = start_method (NULL_TREE, $$); goto rest_of_mdef; }
713 | declmods constructor_declarator
714 { tree specs = strip_attrs ($1);
715 $$ = start_method (specs, $2); goto rest_of_mdef; }
716 | constructor_declarator
717 { $$ = start_method (NULL_TREE, $$); goto rest_of_mdef; }
723 if (! current_function_parms_stored)
731 { store_return_init ($<ttype>$, $2); }
732 | return_id '(' nonnull_exprlist ')'
733 { store_return_init ($<ttype>$, $3); }
734 | return_id LEFT_RIGHT
735 { store_return_init ($<ttype>$, NULL_TREE); }
739 ':' .set_base_init member_init_list
742 error ("no base initializers given following ':'");
744 /* Always keep the BLOCK node associated with the outermost
745 pair of curley braces of a function. These are needed
746 for correct operation of dwarfout.c. */
754 if (! current_function_parms_stored)
757 if (DECL_CONSTRUCTOR_P (current_function_decl))
759 /* Make a contour for the initializer list. */
762 expand_start_bindings (0);
764 else if (current_class_type == NULL_TREE)
765 error ("base initializers not allowed for non-member functions");
766 else if (! DECL_CONSTRUCTOR_P (current_function_decl))
767 error ("only constructors take base initializers");
776 | member_init_list ',' member_init
777 | member_init_list error
781 '(' nonnull_exprlist ')'
783 if (current_class_name)
784 pedwarn ("anachronistic old style base class initializer");
785 expand_member_init (current_class_ref, NULL_TREE, $2);
789 if (current_class_name)
790 pedwarn ("anachronistic old style base class initializer");
791 expand_member_init (current_class_ref, NULL_TREE, void_type_node);
793 | notype_identifier '(' nonnull_exprlist ')'
794 { expand_member_init (current_class_ref, $1, $3); }
795 | notype_identifier LEFT_RIGHT
796 { expand_member_init (current_class_ref, $1, void_type_node); }
797 | nonnested_type '(' nonnull_exprlist ')'
798 { expand_member_init (current_class_ref, $1, $3); }
799 | nonnested_type LEFT_RIGHT
800 { expand_member_init (current_class_ref, $1, void_type_node); }
801 | typename_sub '(' nonnull_exprlist ')'
802 { expand_member_init (current_class_ref, TYPE_MAIN_DECL ($1),
804 | typename_sub LEFT_RIGHT
805 { expand_member_init (current_class_ref, TYPE_MAIN_DECL ($1),
829 explicit_instantiation:
830 TEMPLATE begin_explicit_instantiation typespec ';'
831 { do_type_instantiation ($3.t, NULL_TREE);
833 end_explicit_instantiation
834 | TEMPLATE begin_explicit_instantiation typed_declspecs declarator
835 { tree specs = strip_attrs ($3.t);
836 do_decl_instantiation (specs, $4, NULL_TREE); }
837 end_explicit_instantiation
838 | TEMPLATE begin_explicit_instantiation notype_declarator
839 { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
840 end_explicit_instantiation
841 | TEMPLATE begin_explicit_instantiation constructor_declarator
842 { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
843 end_explicit_instantiation
844 | SCSPEC TEMPLATE begin_explicit_instantiation typespec ';'
845 { do_type_instantiation ($4.t, $1);
847 end_explicit_instantiation
848 | SCSPEC TEMPLATE begin_explicit_instantiation typed_declspecs
850 { tree specs = strip_attrs ($4.t);
851 do_decl_instantiation (specs, $5, $1); }
852 end_explicit_instantiation
853 | SCSPEC TEMPLATE begin_explicit_instantiation notype_declarator
854 { do_decl_instantiation (NULL_TREE, $4, $1); }
855 end_explicit_instantiation
856 | SCSPEC TEMPLATE begin_explicit_instantiation constructor_declarator
857 { do_decl_instantiation (NULL_TREE, $4, $1); }
858 end_explicit_instantiation
861 begin_explicit_instantiation:
862 { begin_explicit_instantiation(); }
864 end_explicit_instantiation:
865 { end_explicit_instantiation(); }
867 /* The TYPENAME expansions are to deal with use of a template class name as
868 a template within the class itself, where the template decl is hidden by
869 a type decl. Got all that? */
872 PTYPENAME '<' template_arg_list_opt template_close_bracket
874 $$ = lookup_template_class ($1, $3, NULL_TREE, NULL_TREE);
875 if ($$ != error_mark_node)
876 $$ = TYPE_STUB_DECL ($$);
878 | TYPENAME '<' template_arg_list_opt template_close_bracket
880 $$ = lookup_template_class ($1, $3, NULL_TREE, NULL_TREE);
881 if ($$ != error_mark_node)
882 $$ = TYPE_STUB_DECL ($$);
888 SELFNAME '<' template_arg_list_opt template_close_bracket
890 $$ = lookup_template_class ($1, $3, NULL_TREE, NULL_TREE);
891 if ($$ != error_mark_node)
892 $$ = TYPE_STUB_DECL ($$);
896 template_close_bracket:
900 /* Handle `Class<Class<Type>>' without space in the `>>' */
901 pedwarn ("`>>' should be `> >' in template class name");
906 template_arg_list_opt:
914 { $$ = build_tree_list (NULL_TREE, $$); }
915 | template_arg_list ',' template_arg
916 { $$ = chainon ($$, build_tree_list (NULL_TREE, $3)); }
921 { $$ = groktypename ($1.t); }
924 | expr_no_commas %prec ARITHCOMPARE
929 { $$ = NEGATE_EXPR; }
931 { $$ = CONVERT_EXPR; }
933 { $$ = PREINCREMENT_EXPR; }
935 { $$ = PREDECREMENT_EXPR; }
937 { $$ = TRUTH_NOT_EXPR; }
942 { $$ = build_x_compound_expr ($$); }
948 { error ("ANSI C++ forbids an empty condition for `%s'",
950 $$ = integer_zero_node; }
957 { error ("ANSI C++ forbids an empty condition for `%s'",
959 $$ = integer_zero_node; }
973 type_specifier_seq declarator maybeasm maybe_attribute '='
976 for (d = getdecls (); d; d = TREE_CHAIN (d))
977 if (TREE_CODE (d) == TYPE_DECL) {
978 tree s = TREE_TYPE (d);
979 if (TREE_CODE (s) == RECORD_TYPE)
980 cp_error ("definition of class `%T' in condition", s);
981 else if (TREE_CODE (s) == ENUMERAL_TYPE)
982 cp_error ("definition of enum `%T' in condition", s);
985 current_declspecs = $1.t;
986 $<itype>5 = suspend_momentary ();
987 $<ttype>$ = start_decl ($<ttype>2, current_declspecs, 1,
988 $4, /*prefix_attributes*/ NULL_TREE);
992 cp_finish_decl ($<ttype>6, $7, $4, 1, LOOKUP_ONLYCONVERTING);
993 resume_momentary ($<itype>5);
995 if (TREE_CODE (TREE_TYPE ($$)) == ARRAY_TYPE)
996 cp_error ("definition of array `%#D' in condition", $$);
1003 | maybe_label_decls stmts '}'
1004 | maybe_label_decls stmts error '}'
1005 | maybe_label_decls error '}'
1008 already_scoped_stmt:
1010 { $<ttype>$ = begin_compound_stmt (1); }
1012 { finish_compound_stmt (1, $<ttype>2); }
1017 nontrivial_exprlist:
1018 expr_no_commas ',' expr_no_commas
1019 { $$ = expr_tree_cons (NULL_TREE, $$,
1020 build_expr_list (NULL_TREE, $3)); }
1021 | expr_no_commas ',' error
1022 { $$ = expr_tree_cons (NULL_TREE, $$,
1023 build_expr_list (NULL_TREE, error_mark_node)); }
1024 | nontrivial_exprlist ',' expr_no_commas
1025 { chainon ($$, build_expr_list (NULL_TREE, $3)); }
1026 | nontrivial_exprlist ',' error
1027 { chainon ($$, build_expr_list (NULL_TREE, error_mark_node)); }
1032 { $$ = build_expr_list (NULL_TREE, $$); }
1033 | nontrivial_exprlist
1039 /* __extension__ turns off -pedantic for following primary. */
1040 | extension cast_expr %prec UNARY
1042 pedantic = $<itype>1; }
1043 | '*' cast_expr %prec UNARY
1044 { $$ = build_x_indirect_ref ($2, "unary *"); }
1045 | '&' cast_expr %prec UNARY
1046 { $$ = build_x_unary_op (ADDR_EXPR, $2); }
1048 { $$ = build_x_unary_op (BIT_NOT_EXPR, $2); }
1049 | unop cast_expr %prec UNARY
1050 { $$ = finish_unary_op_expr ($1, $2); }
1051 /* Refer to the address of a label as a pointer. */
1054 pedwarn ("ANSI C++ forbids `&&'");
1055 $$ = finish_label_address_expr ($2); }
1056 | SIZEOF unary_expr %prec UNARY
1057 { $$ = expr_sizeof ($2); }
1058 | SIZEOF '(' type_id ')' %prec HYPERUNARY
1059 { $$ = c_sizeof (groktypename ($3.t)); }
1060 | ALIGNOF unary_expr %prec UNARY
1061 { $$ = grok_alignof ($2); }
1062 | ALIGNOF '(' type_id ')' %prec HYPERUNARY
1063 { $$ = c_alignof (groktypename ($3.t));
1064 check_for_new_type ("alignof", $3); }
1066 /* The %prec EMPTY's here are required by the = init initializer
1067 syntax extension; see below. */
1068 | new new_type_id %prec EMPTY
1069 { $$ = build_new (NULL_TREE, $2.t, NULL_TREE, $1);
1070 check_for_new_type ("new", $2); }
1071 | new new_type_id new_initializer
1072 { $$ = build_new (NULL_TREE, $2.t, $3, $1);
1073 check_for_new_type ("new", $2); }
1074 | new new_placement new_type_id %prec EMPTY
1075 { $$ = build_new ($2, $3.t, NULL_TREE, $1);
1076 check_for_new_type ("new", $3); }
1077 | new new_placement new_type_id new_initializer
1078 { $$ = build_new ($2, $3.t, $4, $1);
1079 check_for_new_type ("new", $3); }
1080 /* The .begin_new_placement in the following rules is
1081 necessary to avoid shift/reduce conflicts that lead to
1082 mis-parsing some expressions. Of course, these constructs
1083 are not really new-placement and it is bogus to call
1084 begin_new_placement. But, the parser cannot always tell at this
1085 point whether the next thing is an expression or a type-id,
1086 so there is nothing we can do. Fortunately,
1087 begin_new_placement does nothing harmful. When we rewrite
1088 the parser, this lossage should be removed, of course. */
1089 | new '(' .begin_new_placement type_id .finish_new_placement
1091 { $$ = build_new (NULL_TREE, groktypename($4.t),
1093 check_for_new_type ("new", $4); }
1094 | new '(' .begin_new_placement type_id .finish_new_placement
1096 { $$ = build_new (NULL_TREE, groktypename($4.t), $6, $1);
1097 check_for_new_type ("new", $4); }
1098 | new new_placement '(' .begin_new_placement type_id
1099 .finish_new_placement %prec EMPTY
1100 { $$ = build_new ($2, groktypename($5.t), NULL_TREE, $1);
1101 check_for_new_type ("new", $5); }
1102 | new new_placement '(' .begin_new_placement type_id
1103 .finish_new_placement new_initializer
1104 { $$ = build_new ($2, groktypename($5.t), $7, $1);
1105 check_for_new_type ("new", $5); }
1107 | delete cast_expr %prec UNARY
1108 { $$ = delete_sanity ($2, NULL_TREE, 0, $1); }
1109 | delete '[' ']' cast_expr %prec UNARY
1110 { $$ = delete_sanity ($4, NULL_TREE, 1, $1);
1111 if (yychar == YYEMPTY)
1113 | delete '[' expr ']' cast_expr %prec UNARY
1114 { $$ = delete_sanity ($5, $3, 2, $1);
1115 if (yychar == YYEMPTY)
1117 | REALPART cast_expr %prec UNARY
1118 { $$ = build_x_unary_op (REALPART_EXPR, $2); }
1119 | IMAGPART cast_expr %prec UNARY
1120 { $$ = build_x_unary_op (IMAGPART_EXPR, $2); }
1123 /* Note this rule is not suitable for use in new_placement
1124 since it uses NULL_TREE as the argument to
1125 finish_new_placement. This rule serves only to avoid
1126 reduce/reduce conflicts in unary_expr. See the comments
1127 there on the use of begin/finish_new_placement. */
1128 .finish_new_placement:
1130 { finish_new_placement (NULL_TREE, $<itype>-1); }
1132 .begin_new_placement:
1133 { $$ = begin_new_placement (); }
1136 '(' .begin_new_placement nonnull_exprlist ')'
1137 { $$ = finish_new_placement ($3, $2); }
1138 | '{' .begin_new_placement nonnull_exprlist '}'
1139 { cp_pedwarn ("old style placement syntax, use () instead");
1140 $$ = finish_new_placement ($3, $2); }
1144 '(' nonnull_exprlist ')'
1150 cp_error ("`%T' is not a valid expression", $2.t);
1151 $$ = error_mark_node;
1153 /* GNU extension so people can use initializer lists. Note that
1154 this alters the meaning of `new int = 1', which was previously
1155 syntactically valid but semantically invalid. */
1159 pedwarn ("ANSI C++ forbids initialization of new expression with `='");
1160 if (TREE_CODE ($2) != TREE_LIST
1161 && TREE_CODE ($2) != CONSTRUCTOR)
1162 $$ = build_expr_list (NULL_TREE, $2);
1168 /* This is necessary to postpone reduction of `int ((int)(int)(int))'. */
1170 '(' type_id ')' %prec EMPTY
1171 { $2.t = finish_parmlist (build_tree_list (NULL_TREE, $2.t), 0);
1172 $$ = make_call_declarator (NULL_TREE, $2.t, NULL_TREE, NULL_TREE);
1173 check_for_new_type ("cast", $2); }
1174 | regcast_or_absdcl '(' type_id ')' %prec EMPTY
1175 { $3.t = finish_parmlist (build_tree_list (NULL_TREE, $3.t), 0);
1176 $$ = make_call_declarator ($$, $3.t, NULL_TREE, NULL_TREE);
1177 check_for_new_type ("cast", $3); }
1182 | regcast_or_absdcl unary_expr %prec UNARY
1183 { $$ = reparse_absdcl_as_casts ($$, $2); }
1184 | regcast_or_absdcl '{' initlist maybecomma '}' %prec UNARY
1186 tree init = build_nt (CONSTRUCTOR, NULL_TREE,
1189 pedwarn ("ANSI C++ forbids constructor-expressions");
1190 /* Indicate that this was a GNU C constructor expression. */
1191 TREE_HAS_CONSTRUCTOR (init) = 1;
1193 $$ = reparse_absdcl_as_casts ($$, init);
1199 /* Handle general members. */
1200 | expr_no_commas POINTSAT_STAR expr_no_commas
1201 { $$ = build_x_binary_op (MEMBER_REF, $$, $3); }
1202 | expr_no_commas DOT_STAR expr_no_commas
1203 { $$ = build_m_component_ref ($$, $3); }
1204 | expr_no_commas '+' expr_no_commas
1205 { $$ = build_x_binary_op ($2, $$, $3); }
1206 | expr_no_commas '-' expr_no_commas
1207 { $$ = build_x_binary_op ($2, $$, $3); }
1208 | expr_no_commas '*' expr_no_commas
1209 { $$ = build_x_binary_op ($2, $$, $3); }
1210 | expr_no_commas '/' expr_no_commas
1211 { $$ = build_x_binary_op ($2, $$, $3); }
1212 | expr_no_commas '%' expr_no_commas
1213 { $$ = build_x_binary_op ($2, $$, $3); }
1214 | expr_no_commas LSHIFT expr_no_commas
1215 { $$ = build_x_binary_op ($2, $$, $3); }
1216 | expr_no_commas RSHIFT expr_no_commas
1217 { $$ = build_x_binary_op ($2, $$, $3); }
1218 | expr_no_commas ARITHCOMPARE expr_no_commas
1219 { $$ = build_x_binary_op ($2, $$, $3); }
1220 | expr_no_commas '<' expr_no_commas
1221 { $$ = build_x_binary_op (LT_EXPR, $$, $3); }
1222 | expr_no_commas '>' expr_no_commas
1223 { $$ = build_x_binary_op (GT_EXPR, $$, $3); }
1224 | expr_no_commas EQCOMPARE expr_no_commas
1225 { $$ = build_x_binary_op ($2, $$, $3); }
1226 | expr_no_commas MIN_MAX 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 ANDAND expr_no_commas
1235 { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $$, $3); }
1236 | expr_no_commas OROR expr_no_commas
1237 { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $$, $3); }
1238 | expr_no_commas '?' xexpr ':' expr_no_commas
1239 { $$ = build_x_conditional_expr ($$, $3, $5); }
1240 | expr_no_commas '=' expr_no_commas
1241 { $$ = build_x_modify_expr ($$, NOP_EXPR, $3);
1242 if ($$ != error_mark_node)
1243 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
1244 | expr_no_commas ASSIGN expr_no_commas
1245 { $$ = build_x_modify_expr ($$, $2, $3); }
1247 { $$ = build_throw (NULL_TREE); }
1248 | THROW expr_no_commas
1249 { $$ = build_throw ($2); }
1250 /* These extensions are not defined. The second arg to build_m_component_ref
1251 is old, build_m_component_ref now does an implicit
1252 build_indirect_ref (x, NULL_PTR) on the second argument.
1253 | object '&' expr_no_commas %prec UNARY
1254 { $$ = build_m_component_ref ($$, build_x_unary_op (ADDR_EXPR, $3)); }
1255 | object unop expr_no_commas %prec UNARY
1256 { $$ = build_m_component_ref ($$, build_x_unary_op ($2, $3)); }
1257 | object '(' type_id ')' expr_no_commas %prec UNARY
1258 { tree type = groktypename ($3.t);
1259 $$ = build_m_component_ref ($$, build_c_cast (type, $5)); }
1260 | object primary_no_id %prec UNARY
1261 { $$ = build_m_component_ref ($$, $2); }
1265 notype_unqualified_id:
1266 '~' see_typename identifier
1267 { $$ = build_parse_node (BIT_NOT_EXPR, $3); }
1272 | NSNAME %prec EMPTY
1276 { $$ = do_identifier ($<ttype>-1, 1, NULL_TREE); }
1279 PFUNCNAME '<' do_id template_arg_list_opt template_close_bracket
1280 { $$ = lookup_template_function ($3, $4); }
1281 | operator_name '<' do_id template_arg_list_opt template_close_bracket
1282 { $$ = lookup_template_function ($3, $4); }
1286 TEMPLATE identifier '<' template_arg_list_opt template_close_bracket
1287 { $$ = lookup_template_function ($2, $4); }
1288 | TEMPLATE PFUNCNAME '<' template_arg_list_opt template_close_bracket
1289 { $$ = lookup_template_function ($2, $4); }
1290 | TEMPLATE operator_name '<' template_arg_list_opt
1291 template_close_bracket
1292 { $$ = lookup_template_function ($2, $4); }
1296 notype_unqualified_id
1302 notype_unqualified_id
1303 | '*' expr_or_declarator %prec UNARY
1304 { $$ = build_parse_node (INDIRECT_REF, $2); }
1305 | '&' expr_or_declarator %prec UNARY
1306 { $$ = build_parse_node (ADDR_EXPR, $2); }
1307 | '(' expr_or_declarator ')'
1311 notype_template_declarator:
1312 IDENTIFIER '<' template_arg_list_opt template_close_bracket
1313 { $$ = lookup_template_function ($1, $3); }
1314 | NSNAME '<' template_arg_list template_close_bracket
1315 { $$ = lookup_template_function ($1, $3); }
1318 direct_notype_declarator:
1319 complex_direct_notype_declarator
1320 | notype_unqualified_id
1321 | notype_template_declarator
1322 | '(' expr_or_declarator ')'
1323 { $$ = finish_decl_parsing ($2); }
1327 notype_unqualified_id
1329 if (TREE_CODE ($1) == BIT_NOT_EXPR)
1330 $$ = build_x_unary_op (BIT_NOT_EXPR, TREE_OPERAND ($1, 0));
1332 $$ = finish_id_expr ($1);
1338 if (processing_template_decl)
1339 push_obstacks (&permanent_obstack, &permanent_obstack);
1340 $$ = combine_strings ($$);
1341 if (processing_template_decl)
1345 { $$ = finish_parenthesized_expr ($2); }
1346 | '(' expr_or_declarator ')'
1347 { $2 = reparse_decl_as_expr (NULL_TREE, $2);
1348 $$ = finish_parenthesized_expr ($2); }
1350 { $$ = error_mark_node; }
1352 { if (current_function_decl == 0)
1354 error ("braced-group within expression allowed only inside a function");
1358 pedwarn ("ANSI C++ forbids braced-groups within expressions");
1359 $<ttype>$ = begin_stmt_expr ();
1362 { $$ = finish_stmt_expr ($<ttype>2, $3); }
1363 /* Koenig lookup support
1364 We could store lastiddecl in $1 to avoid another lookup,
1365 but that would result in many additional reduce/reduce conflicts. */
1366 | notype_unqualified_id '(' nonnull_exprlist ')'
1367 { $$ = finish_call_expr ($1, $3, 1); }
1368 | notype_unqualified_id LEFT_RIGHT
1369 { $$ = finish_call_expr ($1, NULL_TREE, 1); }
1370 | primary '(' nonnull_exprlist ')'
1371 { $$ = finish_call_expr ($1, $3, 0); }
1372 | primary LEFT_RIGHT
1373 { $$ = finish_call_expr ($1, NULL_TREE, 0); }
1374 | primary '[' expr ']'
1375 { $$ = grok_array_decl ($$, $3); }
1377 { $$ = finish_increment_expr ($1, POSTINCREMENT_EXPR); }
1378 | primary MINUSMINUS
1379 { $$ = finish_increment_expr ($1, POSTDECREMENT_EXPR); }
1380 /* C++ extensions */
1382 { $$ = finish_this_expr (); }
1383 | CV_QUALIFIER '(' nonnull_exprlist ')'
1385 tree type = NULL_TREE;
1388 /* This is a C cast in C++'s `functional' notation. */
1389 if ($3 == error_mark_node)
1391 $$ = error_mark_node;
1395 if ($3 == NULL_TREE)
1397 error ("cannot cast null list to type `%s'",
1398 IDENTIFIER_POINTER (TYPE_NAME (id)));
1399 $$ = error_mark_node;
1404 /* type is not set! (mrs) */
1405 if (type == error_mark_node)
1406 $$ = error_mark_node;
1410 if (id == ridpointers[(int) RID_CONST])
1411 type = build_type_variant (integer_type_node, 1, 0);
1412 else if (id == ridpointers[(int) RID_VOLATILE])
1413 type = build_type_variant (integer_type_node, 0, 1);
1415 /* should not be able to get here (mrs) */
1416 else if (id == ridpointers[(int) RID_FRIEND])
1418 error ("cannot cast expression to `friend' type");
1419 $$ = error_mark_node;
1423 else my_friendly_abort (79);
1424 $$ = build_c_cast (type, build_compound_expr ($3));
1428 | DYNAMIC_CAST '<' type_id '>' '(' expr ')'
1429 { tree type = groktypename ($3.t);
1430 check_for_new_type ("dynamic_cast", $3);
1431 $$ = build_dynamic_cast (type, $6); }
1432 | STATIC_CAST '<' type_id '>' '(' expr ')'
1433 { tree type = groktypename ($3.t);
1434 check_for_new_type ("static_cast", $3);
1435 $$ = build_static_cast (type, $6); }
1436 | REINTERPRET_CAST '<' type_id '>' '(' expr ')'
1437 { tree type = groktypename ($3.t);
1438 check_for_new_type ("reinterpret_cast", $3);
1439 $$ = build_reinterpret_cast (type, $6); }
1440 | CONST_CAST '<' type_id '>' '(' expr ')'
1441 { tree type = groktypename ($3.t);
1442 check_for_new_type ("const_cast", $3);
1443 $$ = build_const_cast (type, $6); }
1444 | TYPEID '(' expr ')'
1445 { $$ = build_x_typeid ($3); }
1446 | TYPEID '(' type_id ')'
1447 { tree type = groktypename ($3.t);
1448 check_for_new_type ("typeid", $3);
1449 $$ = get_typeid (TYPE_MAIN_VARIANT (type)); }
1450 | global_scope IDENTIFIER
1451 { $$ = do_scoped_id ($2, 1); }
1452 | global_scope template_id
1454 | global_scope operator_name
1456 got_scope = NULL_TREE;
1457 if (TREE_CODE ($2) == IDENTIFIER_NODE)
1458 $$ = do_scoped_id ($2, 1);
1462 | overqualified_id %prec HYPERUNARY
1463 { $$ = build_offset_ref (OP0 ($$), OP1 ($$)); }
1464 | overqualified_id '(' nonnull_exprlist ')'
1465 { $$ = finish_globally_qualified_member_call_expr ($1, $3); }
1466 | overqualified_id LEFT_RIGHT
1467 { $$ = finish_globally_qualified_member_call_expr ($1, NULL_TREE); }
1468 | object object_template_id %prec UNARY
1470 $$ = build_x_component_ref ($$, $2, NULL_TREE, 1);
1472 | object object_template_id '(' nonnull_exprlist ')'
1473 { $$ = finish_object_call_expr ($2, $1, $4); }
1474 | object object_template_id LEFT_RIGHT
1475 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1476 | object unqualified_id %prec UNARY
1477 { $$ = build_x_component_ref ($$, $2, NULL_TREE, 1); }
1478 | object overqualified_id %prec UNARY
1479 { if (processing_template_decl)
1480 $$ = build_min_nt (COMPONENT_REF, $1, copy_to_permanent ($2));
1482 $$ = build_object_ref ($$, OP0 ($2), OP1 ($2)); }
1483 | object unqualified_id '(' nonnull_exprlist ')'
1484 { $$ = finish_object_call_expr ($2, $1, $4); }
1485 | object unqualified_id LEFT_RIGHT
1486 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1487 | object overqualified_id '(' nonnull_exprlist ')'
1488 { $$ = finish_qualified_object_call_expr ($2, $1, $4); }
1489 | object overqualified_id LEFT_RIGHT
1490 { $$ = finish_qualified_object_call_expr ($2, $1, NULL_TREE); }
1491 /* p->int::~int() is valid -- 12.4 */
1492 | object '~' TYPESPEC LEFT_RIGHT
1493 { $$ = finish_pseudo_destructor_call_expr ($1, NULL_TREE, $3); }
1494 | object TYPESPEC SCOPE '~' TYPESPEC LEFT_RIGHT
1495 { $$ = finish_pseudo_destructor_call_expr ($1, $2, $5); }
1498 $$ = error_mark_node;
1502 /* Not needed for now.
1508 { $$ = error_mark_node; }
1510 { if (current_function_decl == 0)
1512 error ("braced-group within expression allowed only inside a function");
1515 $<ttype>$ = expand_start_stmt_expr (); }
1518 pedwarn ("ANSI C++ forbids braced-groups within expressions");
1519 $$ = expand_end_stmt_expr ($<ttype>2); }
1520 | primary_no_id '(' nonnull_exprlist ')'
1521 { $$ = build_x_function_call ($$, $3, current_class_ref); }
1522 | primary_no_id LEFT_RIGHT
1523 { $$ = build_x_function_call ($$, NULL_TREE, current_class_ref); }
1524 | primary_no_id '[' expr ']'
1526 | primary_no_id PLUSPLUS
1527 { $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); }
1528 | primary_no_id MINUSMINUS
1529 { $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); }
1531 { goto do_scoped_id; }
1532 | SCOPE operator_name
1533 { if (TREE_CODE ($2) == IDENTIFIER_NODE)
1535 goto do_scoped_operator;
1544 { got_scope = NULL_TREE; $$ = 1; }
1550 | global_scope delete
1551 { got_scope = NULL_TREE; $$ = 1; }
1556 { $$ = boolean_true_node; }
1558 { $$ = boolean_false_node; }
1561 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
1565 { $$ = chainon ($$, $2); }
1571 if (! current_function_parms_stored)
1572 store_parm_decls ();
1574 /* Always keep the BLOCK node associated with the outermost
1575 pair of curley braces of a function. These are needed
1576 for correct operation of dwarfout.c. */
1583 { got_object = TREE_TYPE ($$); }
1586 $$ = build_x_arrow ($$);
1587 got_object = TREE_TYPE ($$);
1592 typespec initdecls ';'
1594 resume_momentary ($2);
1595 if ($1.t && IS_AGGR_TYPE_CODE (TREE_CODE ($1.t)))
1596 note_got_semicolon ($1.t);
1598 | typed_declspecs initdecls ';'
1600 resume_momentary ($2);
1601 note_list_got_semicolon ($1.t);
1603 | declmods notype_initdecls ';'
1604 { resume_momentary ($2); }
1605 | typed_declspecs ';'
1608 note_list_got_semicolon ($1.t);
1611 { warning ("empty declaration"); }
1613 { pedantic = $<itype>1; }
1616 /* Any kind of declarator (thus, all declarators allowed
1617 after an explicit typespec). */
1620 after_type_declarator %prec EMPTY
1621 | notype_declarator %prec EMPTY
1624 /* This is necessary to postpone reduction of `int()()()()'. */
1626 LEFT_RIGHT %prec EMPTY
1627 { $$ = make_call_declarator (NULL_TREE, empty_parms (),
1628 NULL_TREE, NULL_TREE); }
1629 | fcast_or_absdcl LEFT_RIGHT %prec EMPTY
1630 { $$ = make_call_declarator ($$, empty_parms (), NULL_TREE,
1634 /* ANSI type-id (8.1) */
1636 typed_typespecs absdcl
1637 { $$.t = build_decl_list ($1.t, $2);
1638 $$.new_type_flag = $1.new_type_flag; }
1639 | nonempty_cv_qualifiers absdcl
1640 { $$.t = build_decl_list ($1.t, $2);
1641 $$.new_type_flag = $1.new_type_flag; }
1643 { $$.t = build_decl_list (get_decl_list ($1.t), $2);
1644 $$.new_type_flag = $1.new_type_flag; }
1645 | typed_typespecs %prec EMPTY
1646 { $$.t = build_decl_list ($1.t, NULL_TREE);
1647 $$.new_type_flag = $1.new_type_flag; }
1648 | nonempty_cv_qualifiers %prec EMPTY
1649 { $$.t = build_decl_list ($1.t, NULL_TREE);
1650 $$.new_type_flag = $1.new_type_flag; }
1653 /* Declspecs which contain at least one type specifier or typedef name.
1654 (Just `const' or `volatile' is not enough.)
1655 A typedef'd name following these is taken as a name to be declared.
1656 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1659 typed_typespecs %prec EMPTY
1665 { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1);
1666 $$.new_type_flag = $2.new_type_flag; }
1667 | typespec reserved_declspecs %prec HYPERUNARY
1668 { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2);
1669 $$.new_type_flag = $1.new_type_flag; }
1670 | typespec reserved_typespecquals reserved_declspecs
1671 { $$.t = decl_tree_cons (NULL_TREE, $1.t, chainon ($2, $3));
1672 $$.new_type_flag = $1.new_type_flag; }
1673 | declmods typespec reserved_declspecs
1674 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1));
1675 $$.new_type_flag = $2.new_type_flag; }
1676 | declmods typespec reserved_typespecquals
1677 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1));
1678 $$.new_type_flag = $2.new_type_flag; }
1679 | declmods typespec reserved_typespecquals reserved_declspecs
1680 { $$.t = decl_tree_cons (NULL_TREE, $2.t,
1681 chainon ($3, chainon ($4, $1)));
1682 $$.new_type_flag = $2.new_type_flag; }
1687 { if (extra_warnings)
1688 warning ("`%s' is not at beginning of declaration",
1689 IDENTIFIER_POINTER ($$));
1690 $$ = build_decl_list (NULL_TREE, $$); }
1691 | reserved_declspecs typespecqual_reserved
1692 { $$ = decl_tree_cons (NULL_TREE, $2.t, $$); }
1693 | reserved_declspecs SCSPEC
1694 { if (extra_warnings)
1695 warning ("`%s' is not at beginning of declaration",
1696 IDENTIFIER_POINTER ($2));
1697 $$ = decl_tree_cons (NULL_TREE, $2, $$); }
1698 | reserved_declspecs attributes
1699 { $$ = decl_tree_cons ($2, NULL_TREE, $1); }
1701 { $$ = decl_tree_cons ($1, NULL_TREE, NULL_TREE); }
1704 /* List of just storage classes and type modifiers.
1705 A declaration can start with just this, but then it cannot be used
1706 to redeclare a typedef-name.
1707 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1710 nonempty_cv_qualifiers %prec EMPTY
1711 { $$ = $1.t; TREE_STATIC ($$) = 1; }
1713 { $$ = IDENTIFIER_AS_LIST ($$); }
1714 | declmods CV_QUALIFIER
1715 { $$ = decl_tree_cons (NULL_TREE, $2, $$);
1716 TREE_STATIC ($$) = 1; }
1718 { if (extra_warnings && TREE_STATIC ($$))
1719 warning ("`%s' is not at beginning of declaration",
1720 IDENTIFIER_POINTER ($2));
1721 $$ = decl_tree_cons (NULL_TREE, $2, $$);
1722 TREE_STATIC ($$) = TREE_STATIC ($1); }
1723 | declmods attributes
1724 { $$ = decl_tree_cons ($2, NULL_TREE, $1); }
1726 { $$ = decl_tree_cons ($1, NULL_TREE, NULL_TREE); }
1729 /* Used instead of declspecs where storage classes are not allowed
1730 (that is, for typenames and structure components).
1732 C++ can takes storage classes for structure components.
1733 Don't accept a typedef-name if anything but a modifier precedes it. */
1736 typespec %prec EMPTY
1737 { $$.t = get_decl_list ($1.t);
1738 $$.new_type_flag = $1.new_type_flag; }
1739 | nonempty_cv_qualifiers typespec
1740 { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1.t);
1741 $$.new_type_flag = $2.new_type_flag; }
1742 | typespec reserved_typespecquals
1743 { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2);
1744 $$.new_type_flag = $1.new_type_flag; }
1745 | nonempty_cv_qualifiers typespec reserved_typespecquals
1746 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1747 $$.new_type_flag = $1.new_type_flag; }
1750 reserved_typespecquals:
1751 typespecqual_reserved
1752 { $$ = build_decl_list (NULL_TREE, $1.t); }
1753 | reserved_typespecquals typespecqual_reserved
1754 { $$ = decl_tree_cons (NULL_TREE, $2.t, $1); }
1757 /* A typespec (but not a type qualifier).
1758 Once we have seen one of these in a declaration,
1759 if a typedef name appears then it is being redeclared. */
1763 | TYPESPEC %prec EMPTY
1764 { $$.t = $1; $$.new_type_flag = 0; }
1765 | complete_type_name
1766 { $$.t = $1; $$.new_type_flag = 0; }
1767 | TYPEOF '(' expr ')'
1768 { $$.t = TREE_TYPE ($3);
1769 $$.new_type_flag = 0; }
1770 | TYPEOF '(' type_id ')'
1771 { $$.t = groktypename ($3.t);
1772 $$.new_type_flag = 0; }
1773 | SIGOF '(' expr ')'
1774 { tree type = TREE_TYPE ($3);
1776 $$.new_type_flag = 0;
1777 if (IS_AGGR_TYPE (type))
1779 sorry ("sigof type specifier");
1784 error ("`sigof' applied to non-aggregate expression");
1785 $$.t = error_mark_node;
1788 | SIGOF '(' type_id ')'
1789 { tree type = groktypename ($3.t);
1791 $$.new_type_flag = 0;
1792 if (IS_AGGR_TYPE (type))
1794 sorry ("sigof type specifier");
1799 error("`sigof' applied to non-aggregate type");
1800 $$.t = error_mark_node;
1805 /* A typespec that is a reserved word, or a type qualifier. */
1807 typespecqual_reserved:
1809 { $$.t = $1; $$.new_type_flag = 0; }
1811 { $$.t = $1; $$.new_type_flag = 0; }
1817 | initdecls ',' initdcl
1822 | notype_initdecls ',' initdcl
1827 | nomods_initdecls ',' initdcl
1833 | asm_keyword '(' string ')'
1834 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3); $$ = $3; }
1838 declarator maybeasm maybe_attribute '='
1839 { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1,
1840 $3, prefix_attributes); }
1842 /* Note how the declaration of the variable is in effect while its init is parsed! */
1843 { cp_finish_decl ($<ttype>5, $6, $2, 1, LOOKUP_ONLYCONVERTING); }
1844 | declarator maybeasm maybe_attribute
1845 { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 0,
1846 $3, prefix_attributes);
1847 cp_finish_decl ($<ttype>$, NULL_TREE, $2, 1, 0); }
1850 /* This rule assumes a certain configuration of the parser stack.
1851 In particular, $0, the element directly before the beginning of
1852 this rule on the stack, must be a maybeasm. $-1 must be a
1853 declarator or notype_declarator. And $-2 must be some declmods
1854 or declspecs. We can't move the maybeasm into this rule because
1855 we need that reduce so we prefer fn.def1 when appropriate. */
1858 { $<itype>2 = parse_decl ($<ttype>-1, $<ttype>-2,
1859 $1, 1, &$<ttype>$); }
1860 /* Note how the declaration of the variable is in effect
1861 while its init is parsed! */
1863 { cp_finish_decl ($<ttype>3, $4, $<ttype>0, 1,
1864 LOOKUP_ONLYCONVERTING);
1868 $$ = parse_decl ($<ttype>-1, $<ttype>-2, $1, 0, &d);
1869 cp_finish_decl (d, NULL_TREE, $<ttype>0, 1, 0); }
1873 declarator maybeasm initdcl0_innards
1877 notype_declarator maybeasm initdcl0_innards
1882 notype_declarator maybeasm
1883 { /* Set things up as initdcl0_innards expects. */
1888 | constructor_declarator maybeasm maybe_attribute
1890 parse_decl($1, NULL_TREE, $3, 0, &d);
1891 cp_finish_decl (d, NULL_TREE, $2, 1, 0); }
1894 /* the * rules are dummies to accept the Apollo extended syntax
1895 so that the header files compile. */
1906 | attributes attribute
1907 { $$ = chainon ($1, $2); }
1911 ATTRIBUTE '(' '(' attribute_list ')' ')'
1918 | attribute_list ',' attrib
1919 { $$ = chainon ($1, $3); }
1926 { $$ = build_tree_list ($1, NULL_TREE); }
1927 | any_word '(' IDENTIFIER ')'
1928 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1929 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1930 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1931 | any_word '(' nonnull_exprlist ')'
1932 { $$ = build_tree_list ($1, $3); }
1935 /* This still leaves out most reserved keywords,
1936 shouldn't we include them? */
1945 /* A nonempty list of identifiers, including typenames. */
1946 identifiers_or_typenames:
1948 { $$ = build_tree_list (NULL_TREE, $1); }
1949 | identifiers_or_typenames ',' identifier
1950 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
1954 /* empty */ %prec EMPTY
1959 /* If we are processing a template, we don't want to expand this
1963 expr_no_commas %prec '='
1965 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, NULL_TREE);
1966 TREE_HAS_CONSTRUCTOR ($$) = 1; }
1968 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
1969 TREE_HAS_CONSTRUCTOR ($$) = 1; }
1970 | '{' initlist ',' '}'
1971 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
1972 TREE_HAS_CONSTRUCTOR ($$) = 1; }
1977 /* This chain is built in reverse order,
1978 and put in forward order where initlist is used. */
1981 { $$ = build_tree_list (NULL_TREE, $$); }
1983 { $$ = expr_tree_cons (NULL_TREE, $3, $$); }
1984 /* These are for labeled elements. */
1985 | '[' expr_no_commas ']' init
1986 { $$ = build_expr_list ($2, $4); }
1987 | identifier ':' init
1988 { $$ = build_expr_list ($$, $3); }
1989 | initlist ',' identifier ':' init
1990 { $$ = expr_tree_cons ($3, $5, $$); }
1994 PRE_PARSED_FUNCTION_DECL
1995 { start_function (NULL_TREE, TREE_VALUE ($1),
1997 reinit_parse_for_function (); }
2000 fn.defpen maybe_return_init ctor_initializer_opt compstmt_or_error
2002 int nested = (hack_decl_function_context
2003 (current_function_decl) != NULL_TREE);
2004 finish_function (lineno, (int)$3, nested);
2005 process_next_inline ($1);
2007 | fn.defpen maybe_return_init function_try_block
2008 { process_next_inline ($1); }
2009 | fn.defpen maybe_return_init error
2010 { process_next_inline ($1); }
2015 | pending_inlines pending_inline eat_saved_input
2018 /* A regurgitated default argument. The value of DEFARG_MARKER will be
2019 the TREE_LIST node for the parameter in question. */
2021 DEFARG_MARKER expr_no_commas END_OF_SAVED_INPUT
2022 { replace_defarg ($1, $2); }
2023 | DEFARG_MARKER error END_OF_SAVED_INPUT
2024 { replace_defarg ($1, error_mark_node); }
2027 /* empty */ %prec EMPTY
2028 | pending_defargs defarg_again
2029 { do_pending_defargs (); }
2030 | pending_defargs error
2031 { do_pending_defargs (); }
2036 { $<itype>3 = suspend_momentary ();
2037 $<ttype>$ = start_enum ($2); }
2038 enumlist maybecomma_warn '}'
2039 { $$.t = finish_enum ($<ttype>4, $5);
2040 $$.new_type_flag = 1;
2041 resume_momentary ((int) $<itype>3);
2042 check_for_missing_semicolon ($<ttype>4); }
2043 | ENUM identifier '{' '}'
2044 { $$.t = finish_enum (start_enum ($2), NULL_TREE);
2045 $$.new_type_flag = 1;
2046 check_for_missing_semicolon ($$.t); }
2048 { $<itype>2 = suspend_momentary ();
2049 $<ttype>$ = start_enum (make_anon_name ()); }
2050 enumlist maybecomma_warn '}'
2051 { $$.t = finish_enum ($<ttype>3, $4);
2052 resume_momentary ((int) $<itype>1);
2053 check_for_missing_semicolon ($<ttype>3);
2054 $$.new_type_flag = 1; }
2056 { $$.t = finish_enum (start_enum (make_anon_name()), NULL_TREE);
2057 $$.new_type_flag = 1;
2058 check_for_missing_semicolon ($$.t); }
2060 { $$.t = xref_tag (enum_type_node, $2, NULL_TREE, 1);
2061 $$.new_type_flag = 0; }
2062 | ENUM complex_type_name
2063 { $$.t = xref_tag (enum_type_node, $2, NULL_TREE, 1);
2064 $$.new_type_flag = 0; }
2065 | TYPENAME_KEYWORD typename_sub
2067 $$.new_type_flag = 0; }
2068 /* C++ extensions, merged with C to avoid shift/reduce conflicts */
2069 | class_head left_curly
2070 opt.component_decl_list '}' maybe_attribute
2074 if (yychar == YYEMPTY)
2076 semi = yychar == ';';
2078 $<ttype>$ = finish_class_definition ($1, $3, $5, semi);
2081 { finish_default_args (); }
2084 $$.new_type_flag = 1;
2085 begin_inline_definitions (); }
2086 | class_head %prec EMPTY
2088 $$.new_type_flag = 0;
2089 if (TYPE_BINFO ($1) == NULL_TREE)
2091 cp_error ("%T is not a class type", $1);
2092 $$.t = error_mark_node;
2097 /* struct B: public A; is not accepted by the WP grammar. */
2098 if (TYPE_BINFO_BASETYPES ($$.t) && !TYPE_SIZE ($$.t)
2099 && ! TYPE_BEING_DEFINED ($$.t))
2100 cp_error ("base clause without member specification for `%#T'",
2114 { if (pedantic && !in_system_header)
2115 pedwarn ("comma at end of enumerator list"); }
2121 { error ("storage class specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2123 { error ("type specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2125 { error ("type qualifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2127 { error ("no body nor ';' separates two class, struct or union declarations"); }
2129 { $$ = build_decl_list ($2, $1); }
2132 named_class_head_sans_basetype:
2134 { current_aggr = $$; $$ = $2; }
2137 named_class_head_sans_basetype_defn:
2138 aggr identifier_defn %prec EMPTY
2139 { current_aggr = $$; $$ = $2; }
2140 | named_class_head_sans_basetype '{'
2141 { yyungetc ('{', 1); }
2142 | named_class_head_sans_basetype ':'
2143 { yyungetc (':', 1); }
2146 named_complex_class_head_sans_basetype:
2147 aggr nested_name_specifier identifier
2150 $$ = handle_class_head ($1, $2, $3);
2152 | aggr global_scope nested_name_specifier identifier
2155 $$ = handle_class_head ($1, $3, $4);
2157 | aggr global_scope identifier
2160 $$ = handle_class_head ($1, NULL_TREE, $3);
2162 | aggr template_type
2163 { current_aggr = $$; $$ = $2; }
2164 | aggr nested_name_specifier template_type
2165 { current_aggr = $$; $$ = $3; }
2169 /* empty */ %prec EMPTY
2170 { $<ttype>$ = xref_tag (current_aggr, $<ttype>0, NULL_TREE, 0); }
2174 named_class_head_sans_basetype %prec EMPTY
2175 { $$ = xref_tag (current_aggr, $1, NULL_TREE, 1); }
2176 | named_class_head_sans_basetype_defn do_xref_defn
2177 maybe_base_class_list %prec EMPTY
2181 xref_basetypes (current_aggr, $1, $<ttype>2, $3);
2183 | named_complex_class_head_sans_basetype maybe_base_class_list
2185 $$ = TREE_TYPE ($1);
2186 if (TREE_INT_CST_LOW (current_aggr) == union_type
2187 && TREE_CODE ($$) != UNION_TYPE)
2188 cp_pedwarn ("`union' tag used in declaring `%#T'", $$);
2189 else if (TREE_CODE ($$) == UNION_TYPE
2190 && TREE_INT_CST_LOW (current_aggr) != union_type)
2191 cp_pedwarn ("non-`union' tag used in declaring `%#T'", $$);
2194 if (IS_AGGR_TYPE ($$) && CLASSTYPE_USE_TEMPLATE ($$))
2196 if (CLASSTYPE_IMPLICIT_INSTANTIATION ($$)
2197 && TYPE_SIZE ($$) == NULL_TREE)
2199 SET_CLASSTYPE_TEMPLATE_SPECIALIZATION ($$);
2200 if (processing_template_decl)
2201 push_template_decl (TYPE_MAIN_DECL ($$));
2203 else if (CLASSTYPE_TEMPLATE_INSTANTIATION ($$))
2204 cp_error ("specialization after instantiation of `%T'", $$);
2206 xref_basetypes (current_aggr, $1, $$, $2);
2213 { $$ = xref_tag ($$, make_anon_name (), NULL_TREE, 0);
2214 yyungetc ('{', 1); }
2222 maybe_base_class_list:
2223 /* empty */ %prec EMPTY
2225 | ':' see_typename %prec EMPTY
2226 { yyungetc(':', 1); $$ = NULL_TREE; }
2227 | ':' see_typename base_class_list %prec EMPTY
2233 | base_class_list ',' see_typename base_class
2234 { $$ = chainon ($$, $4); }
2241 if ($1 == NULL_TREE)
2243 error ("invalid base class");
2244 type = error_mark_node;
2247 type = TREE_TYPE ($1);
2248 if (! is_aggr_type (type, 1))
2250 else if (current_aggr == signature_type_node
2251 && (! type) && (! IS_SIGNATURE (type)))
2253 error ("class name not allowed as base signature");
2256 else if (current_aggr == signature_type_node)
2258 sorry ("signature inheritance, base type `%s' ignored",
2259 IDENTIFIER_POINTER ($$));
2260 $$ = build_tree_list (access_public_node, type);
2262 else if (type && IS_SIGNATURE (type))
2264 error ("signature name not allowed as base class");
2268 $$ = build_tree_list (access_default_node, type);
2270 | base_class_access_list see_typename base_class.1
2273 if ($3 == NULL_TREE)
2275 error ("invalid base class");
2276 type = error_mark_node;
2279 type = TREE_TYPE ($3);
2280 if (current_aggr == signature_type_node)
2281 error ("access and source specifiers not allowed in signature");
2282 if (! is_aggr_type (type, 1))
2284 else if (current_aggr == signature_type_node
2285 && (! type) && (! IS_SIGNATURE (type)))
2287 error ("class name not allowed as base signature");
2290 else if (current_aggr == signature_type_node)
2292 sorry ("signature inheritance, base type `%s' ignored",
2293 IDENTIFIER_POINTER ($$));
2294 $$ = build_tree_list (access_public_node, type);
2296 else if (type && IS_SIGNATURE (type))
2298 error ("signature name not allowed as base class");
2302 $$ = build_tree_list ($$, type);
2308 { $$ = TYPE_MAIN_DECL ($1); }
2310 | SIGOF '(' expr ')'
2312 if (current_aggr == signature_type_node)
2314 if (IS_AGGR_TYPE (TREE_TYPE ($3)))
2316 sorry ("`sigof' as base signature specifier");
2317 $$ = TREE_TYPE ($3);
2321 error ("`sigof' applied to non-aggregate expression");
2322 $$ = error_mark_node;
2327 error ("`sigof' in struct or class declaration");
2328 $$ = error_mark_node;
2331 | SIGOF '(' type_id ')'
2333 if (current_aggr == signature_type_node)
2335 if (IS_AGGR_TYPE (groktypename ($3.t)))
2337 sorry ("`sigof' as base signature specifier");
2338 $$ = groktypename ($3.t);
2342 error ("`sigof' applied to non-aggregate expression");
2343 $$ = error_mark_node;
2348 error ("`sigof' in struct or class declaration");
2349 $$ = error_mark_node;
2354 base_class_access_list:
2355 VISSPEC see_typename
2356 | SCSPEC see_typename
2357 { if ($1 != ridpointers[(int)RID_VIRTUAL])
2358 cp_error ("`%D' access", $1);
2359 $$ = access_default_virtual_node; }
2360 | base_class_access_list VISSPEC see_typename
2362 if ($1 != access_default_virtual_node)
2363 error ("multiple access specifiers");
2364 else if ($2 == access_public_node)
2365 $$ = access_public_virtual_node;
2366 else if ($2 == access_protected_node)
2367 $$ = access_protected_virtual_node;
2368 else /* $2 == access_private_node */
2369 $$ = access_private_virtual_node;
2371 | base_class_access_list SCSPEC see_typename
2372 { if ($2 != ridpointers[(int)RID_VIRTUAL])
2373 cp_error ("`%D' access", $2);
2374 else if ($$ == access_public_node)
2375 $$ = access_public_virtual_node;
2376 else if ($$ == access_protected_node)
2377 $$ = access_protected_virtual_node;
2378 else if ($$ == access_private_node)
2379 $$ = access_private_virtual_node;
2381 error ("multiple `virtual' specifiers");
2387 { $<ttype>0 = begin_class_definition ($<ttype>0); }
2393 $$ = build_self_reference ();
2397 opt.component_decl_list:
2399 { if ($$) $$ = build_tree_list (access_public_node, $$); }
2400 | self_reference component_decl_list
2402 if (current_aggr == signature_type_node)
2403 $$ = build_tree_list (access_public_node, $2);
2405 $$ = build_tree_list (access_default_node, $2);
2406 if ($1) $$ = tree_cons (access_public_node, $1, $$);
2408 | opt.component_decl_list VISSPEC ':' component_decl_list
2412 if (current_aggr == signature_type_node)
2414 error ("access specifier not allowed in signature");
2415 visspec = access_public_node;
2417 $$ = chainon ($$, build_tree_list (visspec, $4));
2419 | opt.component_decl_list VISSPEC ':'
2421 if (current_aggr == signature_type_node)
2422 error ("access specifier not allowed in signature");
2426 /* Note: we no longer warn about the semicolon after a component_decl_list.
2427 ARM $9.2 says that the semicolon is optional, and therefore allowed. */
2428 component_decl_list:
2430 { if ($$ == void_type_node) $$ = NULL_TREE;
2432 | component_decl_list component_decl
2433 { /* In pushdecl, we created a reverse list of names
2434 in this binding level. Make sure that the chain
2435 of what we're trying to add isn't the item itself
2436 (which can happen with what pushdecl's doing). */
2437 if ($2 != NULL_TREE && $2 != void_type_node)
2439 if (TREE_CHAIN ($2) != $$)
2440 $$ = chainon ($$, $2);
2448 component_decl_1 ';'
2450 | component_decl_1 '}'
2451 { error ("missing ';' before right brace");
2452 yyungetc ('}', 0); }
2453 /* C++: handle constructors, destructors and inline functions */
2454 /* note that INLINE is like a TYPESPEC */
2455 | fn.def2 ':' /* base_init compstmt */
2456 { $$ = finish_method ($$); }
2457 | fn.def2 TRY /* base_init compstmt */
2458 { $$ = finish_method ($$); }
2459 | fn.def2 RETURN /* base_init compstmt */
2460 { $$ = finish_method ($$); }
2461 | fn.def2 '{' /* nodecls compstmt */
2462 { $$ = finish_method ($$); }
2465 | extension component_decl
2467 pedantic = $<itype>1; }
2468 | template_header component_decl
2469 { $$ = finish_member_template_decl ($1, $2); }
2470 | template_header typed_declspecs ';'
2471 { $$ = finish_member_class_template ($1, $2.t); }
2475 /* Do not add a "typed_declspecs declarator" rule here for
2476 speed; we need to call grok_x_components for enums, so the
2477 speedup would be insignificant. */
2478 typed_declspecs components
2479 { $$ = grok_x_components ($1.t, $2); }
2480 | declmods notype_components
2481 { $$ = grok_x_components ($1, $2); }
2482 | notype_declarator maybeasm maybe_attribute maybe_init
2483 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2484 build_tree_list ($3, NULL_TREE)); }
2485 | constructor_declarator maybeasm maybe_attribute maybe_init
2486 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2487 build_tree_list ($3, NULL_TREE)); }
2488 | ':' expr_no_commas
2489 { $$ = grokbitfield (NULL_TREE, NULL_TREE, $2); }
2493 /* These rules introduce a reduce/reduce conflict; in
2494 typedef int foo, bar;
2498 should "A::foo" be declared as a function or "A::bar" as a data
2499 member? In other words, is "bar" an after_type_declarator or a
2501 | declmods component_constructor_declarator maybeasm maybe_attribute maybe_init
2502 { tree specs, attrs;
2503 split_specs_attrs ($1, &specs, &attrs);
2504 $$ = grokfield ($2, specs, $5, $3,
2505 build_tree_list ($4, attrs)); }
2506 | component_constructor_declarator maybeasm maybe_attribute maybe_init
2507 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2508 build_tree_list ($3, NULL_TREE)); }
2510 { $$ = do_class_using_decl ($1); }
2512 /* The case of exactly one component is handled directly by component_decl. */
2515 /* empty: possibly anonymous */
2517 | component_declarator0
2518 | components ',' component_declarator
2520 /* In this context, void_type_node encodes
2521 friends. They have been recorded elsewhere. */
2522 if ($$ == void_type_node)
2525 $$ = chainon ($$, $3);
2530 /* empty: possibly anonymous */
2532 | notype_component_declarator0
2533 | notype_components ',' notype_component_declarator
2535 /* In this context, void_type_node encodes
2536 friends. They have been recorded elsewhere. */
2537 if ($$ == void_type_node)
2540 $$ = chainon ($$, $3);
2544 component_declarator0:
2545 after_type_component_declarator0
2546 | notype_component_declarator0
2549 component_declarator:
2550 after_type_component_declarator
2551 | notype_component_declarator
2554 after_type_component_declarator0:
2555 after_type_declarator maybeasm maybe_attribute maybe_init
2556 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2557 &prefix_attributes);
2558 $<ttype>0 = current_declspecs;
2559 $$ = grokfield ($$, current_declspecs, $4, $2,
2560 build_tree_list ($3, prefix_attributes)); }
2561 | TYPENAME ':' expr_no_commas maybe_attribute
2562 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2563 &prefix_attributes);
2564 $<ttype>0 = current_declspecs;
2565 $$ = grokbitfield ($$, current_declspecs, $3);
2566 cplus_decl_attributes ($$, $4, prefix_attributes); }
2569 notype_component_declarator0:
2570 notype_declarator maybeasm maybe_attribute maybe_init
2571 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2572 &prefix_attributes);
2573 $<ttype>0 = current_declspecs;
2574 $$ = grokfield ($$, current_declspecs, $4, $2,
2575 build_tree_list ($3, prefix_attributes)); }
2576 | constructor_declarator maybeasm maybe_attribute maybe_init
2577 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2578 &prefix_attributes);
2579 $<ttype>0 = current_declspecs;
2580 $$ = grokfield ($$, current_declspecs, $4, $2,
2581 build_tree_list ($3, prefix_attributes)); }
2582 | IDENTIFIER ':' expr_no_commas maybe_attribute
2583 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2584 &prefix_attributes);
2585 $<ttype>0 = current_declspecs;
2586 $$ = grokbitfield ($$, current_declspecs, $3);
2587 cplus_decl_attributes ($$, $4, prefix_attributes); }
2588 | ':' expr_no_commas maybe_attribute
2589 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2590 &prefix_attributes);
2591 $<ttype>0 = current_declspecs;
2592 $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
2593 cplus_decl_attributes ($$, $3, prefix_attributes); }
2596 after_type_component_declarator:
2597 after_type_declarator maybeasm maybe_attribute maybe_init
2598 { $$ = grokfield ($$, current_declspecs, $4, $2,
2599 build_tree_list ($3, prefix_attributes)); }
2600 | TYPENAME ':' expr_no_commas maybe_attribute
2601 { $$ = grokbitfield ($$, current_declspecs, $3);
2602 cplus_decl_attributes ($$, $4, prefix_attributes); }
2605 notype_component_declarator:
2606 notype_declarator maybeasm maybe_attribute maybe_init
2607 { $$ = grokfield ($$, current_declspecs, $4, $2,
2608 build_tree_list ($3, prefix_attributes)); }
2609 | IDENTIFIER ':' expr_no_commas maybe_attribute
2610 { $$ = grokbitfield ($$, current_declspecs, $3);
2611 cplus_decl_attributes ($$, $4, prefix_attributes); }
2612 | ':' expr_no_commas maybe_attribute
2613 { $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
2614 cplus_decl_attributes ($$, $3, prefix_attributes); }
2617 /* We chain the enumerators in reverse order.
2618 Because of the way enums are built, the order is
2619 insignificant. Take advantage of this fact. */
2623 | enumlist ',' enumerator
2624 { TREE_CHAIN ($3) = $$; $$ = $3; }
2629 { $$ = build_enumerator ($$, NULL_TREE); }
2630 | identifier '=' expr_no_commas
2631 { $$ = build_enumerator ($$, $3); }
2634 /* ANSI new-type-id (5.3.4) */
2636 type_specifier_seq new_declarator
2637 { $$.t = build_decl_list ($1.t, $2);
2638 $$.new_type_flag = $1.new_type_flag; }
2639 | type_specifier_seq %prec EMPTY
2640 { $$.t = build_decl_list ($1.t, NULL_TREE);
2641 $$.new_type_flag = $1.new_type_flag; }
2642 /* GNU extension to allow arrays of arbitrary types with
2643 non-constant dimension. For the use of begin_new_placement
2644 here, see the comments in unary_expr above. */
2645 | '(' .begin_new_placement type_id .finish_new_placement
2649 pedwarn ("ANSI C++ forbids array dimensions with parenthesized type in new");
2650 $$.t = build_parse_node (ARRAY_REF, TREE_VALUE ($3.t), $6);
2651 $$.t = build_decl_list (TREE_PURPOSE ($3.t), $$.t);
2652 $$.new_type_flag = $3.new_type_flag;
2657 /* empty */ %prec EMPTY
2659 | cv_qualifiers CV_QUALIFIER
2660 { $$ = decl_tree_cons (NULL_TREE, $2, $$); }
2663 nonempty_cv_qualifiers:
2665 { $$.t = IDENTIFIER_AS_LIST ($1);
2666 $$.new_type_flag = 0; }
2667 | nonempty_cv_qualifiers CV_QUALIFIER
2668 { $$.t = decl_tree_cons (NULL_TREE, $2, $1.t);
2669 $$.new_type_flag = $1.new_type_flag; }
2672 /* These rules must follow the rules for function declarations
2673 and component declarations. That way, longer rules are preferred. */
2677 { $<itype>$ = suspend_momentary (); }
2679 /* An expression which will not live on the momentary obstack. */
2682 { resume_momentary ((int) $<itype>1); $$ = $2; }
2685 /* An expression which will not live on the momentary obstack. */
2687 suspend_mom '(' nonnull_exprlist ')'
2688 { resume_momentary ((int) $<itype>1); $$ = $3; }
2689 | suspend_mom '(' parmlist ')'
2690 { resume_momentary ((int) $<itype>1); $$ = $3; }
2691 | suspend_mom LEFT_RIGHT
2692 { resume_momentary ((int) $<itype>1); $$ = empty_parms (); }
2693 | suspend_mom '(' error ')'
2694 { resume_momentary ((int) $<itype>1); $$ = NULL_TREE; }
2697 /* A declarator that is allowed only after an explicit typespec. */
2698 /* may all be followed by prec '.' */
2699 after_type_declarator:
2700 '*' nonempty_cv_qualifiers after_type_declarator %prec UNARY
2701 { $$ = make_pointer_declarator ($2.t, $3); }
2702 | '&' nonempty_cv_qualifiers after_type_declarator %prec UNARY
2703 { $$ = make_reference_declarator ($2.t, $3); }
2704 | '*' after_type_declarator %prec UNARY
2705 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2706 | '&' after_type_declarator %prec UNARY
2707 { $$ = make_reference_declarator (NULL_TREE, $2); }
2708 | ptr_to_mem cv_qualifiers after_type_declarator
2709 { tree arg = make_pointer_declarator ($2, $3);
2710 $$ = build_parse_node (SCOPE_REF, $1, arg);
2712 | direct_after_type_declarator
2716 type_name %prec EMPTY
2718 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2720 $$ = lookup_name ($1, 1);
2721 if (current_class_type
2722 && TYPE_BEING_DEFINED (current_class_type)
2723 && ! IDENTIFIER_CLASS_VALUE ($1))
2725 /* Remember that this name has been used in the class
2726 definition, as per [class.scope0] */
2727 pushdecl_class_level ($$);
2733 | global_scope type_name
2735 if (TREE_CODE ($2) == IDENTIFIER_NODE)
2736 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
2739 got_scope = NULL_TREE;
2746 | global_scope nested_type
2751 nested_name_specifier type_name %prec EMPTY
2752 { $$ = get_type_decl ($2); }
2755 direct_after_type_declarator:
2756 direct_after_type_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2757 { $$ = make_call_declarator ($$, $2, $3, $4); }
2758 | direct_after_type_declarator '[' nonmomentary_expr ']'
2759 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
2760 | direct_after_type_declarator '[' ']'
2761 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
2762 | '(' after_type_declarator ')'
2764 | nested_name_specifier type_name %prec EMPTY
2765 { push_nested_class ($1, 3);
2766 $$ = build_parse_node (SCOPE_REF, $$, $2);
2767 TREE_COMPLEXITY ($$) = current_class_depth; }
2768 | type_name %prec EMPTY
2771 /* A declarator allowed whether or not there has been
2772 an explicit typespec. These cannot redeclare a typedef-name. */
2775 '*' nonempty_cv_qualifiers notype_declarator %prec UNARY
2776 { $$ = make_pointer_declarator ($2.t, $3); }
2777 | '&' nonempty_cv_qualifiers notype_declarator %prec UNARY
2778 { $$ = make_reference_declarator ($2.t, $3); }
2779 | '*' notype_declarator %prec UNARY
2780 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2781 | '&' notype_declarator %prec UNARY
2782 { $$ = make_reference_declarator (NULL_TREE, $2); }
2783 | ptr_to_mem cv_qualifiers notype_declarator
2784 { tree arg = make_pointer_declarator ($2, $3);
2785 $$ = build_parse_node (SCOPE_REF, $1, arg);
2787 | direct_notype_declarator
2790 complex_notype_declarator:
2791 '*' nonempty_cv_qualifiers notype_declarator %prec UNARY
2792 { $$ = make_pointer_declarator ($2.t, $3); }
2793 | '&' nonempty_cv_qualifiers notype_declarator %prec UNARY
2794 { $$ = make_reference_declarator ($2.t, $3); }
2795 | '*' complex_notype_declarator %prec UNARY
2796 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2797 | '&' complex_notype_declarator %prec UNARY
2798 { $$ = make_reference_declarator (NULL_TREE, $2); }
2799 | ptr_to_mem cv_qualifiers notype_declarator
2800 { tree arg = make_pointer_declarator ($2, $3);
2801 $$ = build_parse_node (SCOPE_REF, $1, arg);
2803 | complex_direct_notype_declarator
2806 complex_direct_notype_declarator:
2807 direct_notype_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2808 { $$ = make_call_declarator ($$, $2, $3, $4); }
2809 | '(' complex_notype_declarator ')'
2811 | direct_notype_declarator '[' nonmomentary_expr ']'
2812 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
2813 | direct_notype_declarator '[' ']'
2814 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
2815 | notype_qualified_id
2816 { if (TREE_CODE (OP0 ($1)) == NAMESPACE_DECL)
2818 push_decl_namespace (OP0 ($1));
2819 TREE_COMPLEXITY ($1) = -1;
2821 else if (OP0 ($1) != current_class_type)
2823 push_nested_class (OP0 ($1), 3);
2824 TREE_COMPLEXITY ($1) = current_class_depth;
2827 | nested_name_specifier notype_template_declarator
2828 { got_scope = NULL_TREE;
2829 $$ = build_parse_node (SCOPE_REF, $1, $2);
2830 if ($1 != current_class_type)
2832 push_nested_class ($1, 3);
2833 TREE_COMPLEXITY ($$) = current_class_depth;
2839 nested_name_specifier unqualified_id
2840 { got_scope = NULL_TREE;
2841 $$ = build_parse_node (SCOPE_REF, $$, $2); }
2842 | nested_name_specifier object_template_id
2843 { got_scope = NULL_TREE;
2844 $$ = build_parse_node (SCOPE_REF, $1, $2); }
2847 notype_qualified_id:
2848 nested_name_specifier notype_unqualified_id
2849 { got_scope = NULL_TREE;
2850 $$ = build_parse_node (SCOPE_REF, $$, $2); }
2851 | nested_name_specifier object_template_id
2852 { got_scope = NULL_TREE;
2853 $$ = build_parse_node (SCOPE_REF, $1, $2); }
2858 | global_scope notype_qualified_id
2863 typespec '(' nonnull_exprlist ')'
2864 { $$ = build_functional_cast ($1.t, $3); }
2865 | typespec '(' expr_or_declarator ')'
2866 { $$ = reparse_decl_as_expr ($1.t, $3); }
2867 | typespec fcast_or_absdcl %prec EMPTY
2868 { $$ = reparse_absdcl_as_expr ($1.t, $2); }
2874 | template_type %prec EMPTY
2877 nested_name_specifier:
2878 nested_name_specifier_1
2879 | nested_name_specifier nested_name_specifier_1
2881 | nested_name_specifier TEMPLATE explicit_template_type SCOPE
2882 { got_scope = $$ = make_typename_type ($1, $3); }
2885 /* Why the @#$%^& do type_name and notype_identifier need to be expanded
2886 inline here?!? (jason) */
2887 nested_name_specifier_1:
2890 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2893 /* Remember that this name has been used in the class
2894 definition, as per [class.scope0] */
2895 if (current_class_type
2896 && TYPE_BEING_DEFINED (current_class_type)
2897 && ! IDENTIFIER_CLASS_VALUE ($1))
2898 pushdecl_class_level ($$);
2900 got_scope = $$ = TYPE_MAIN_VARIANT (TREE_TYPE ($$));
2904 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2906 got_scope = $$ = TREE_TYPE ($$);
2910 if (TREE_CODE ($$) == IDENTIFIER_NODE)
2914 | template_type SCOPE
2915 { got_scope = $$ = complete_type (TREE_TYPE ($1)); }
2916 /* These break 'const i;'
2920 cp_error ("`%D' is not an aggregate typedef",
2921 lastiddecl ? lastiddecl : $$);
2922 $$ = error_mark_node;
2925 { goto failed_scope; } */
2930 | global_scope typename_sub0
2935 typename_sub1 identifier %prec EMPTY
2937 if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't')
2938 $$ = make_typename_type ($1, $2);
2939 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
2940 cp_error ("`%T' is not a class or namespace", $2);
2944 if (TREE_CODE ($$) == TYPE_DECL)
2945 $$ = TREE_TYPE ($$);
2948 | typename_sub1 template_type %prec EMPTY
2949 { $$ = TREE_TYPE ($2); }
2950 | typename_sub1 explicit_template_type %prec EMPTY
2951 { $$ = make_typename_type ($1, $2); }
2952 | typename_sub1 TEMPLATE explicit_template_type %prec EMPTY
2953 { $$ = make_typename_type ($1, $3); }
2959 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2960 cp_error ("`%T' is not a class or namespace", $1);
2962 | typename_sub1 typename_sub2
2964 if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't')
2965 $$ = make_typename_type ($1, $2);
2966 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
2967 cp_error ("`%T' is not a class or namespace", $2);
2971 if (TREE_CODE ($$) == TYPE_DECL)
2972 $$ = TREE_TYPE ($$);
2975 | typename_sub1 explicit_template_type SCOPE
2976 { got_scope = $$ = make_typename_type ($1, $2); }
2977 | typename_sub1 TEMPLATE explicit_template_type SCOPE
2978 { got_scope = $$ = make_typename_type ($1, $3); }
2984 if (TREE_CODE ($1) != IDENTIFIER_NODE)
2987 /* Retrieve the type for the identifier, which might involve
2988 some computation. */
2989 got_scope = $$ = complete_type (IDENTIFIER_TYPE_VALUE ($1));
2991 if ($$ == error_mark_node)
2992 cp_error ("`%T' is not a class or namespace", $1);
2996 if (TREE_CODE ($1) != IDENTIFIER_NODE)
2998 got_scope = $$ = complete_type (TREE_TYPE ($$));
3000 | template_type SCOPE
3001 { got_scope = $$ = complete_type (TREE_TYPE ($$)); }
3006 if (TREE_CODE ($$) == IDENTIFIER_NODE)
3012 explicit_template_type:
3013 identifier '<' template_arg_list_opt template_close_bracket
3014 { $$ = build_min_nt (TEMPLATE_ID_EXPR, $1, $3); }
3018 global_scope type_name
3020 if (TREE_CODE ($2) == IDENTIFIER_NODE)
3021 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
3024 got_scope = NULL_TREE;
3027 | global_scope nested_type
3032 nested_name_specifier '*'
3033 { got_scope = NULL_TREE; }
3034 | global_scope nested_name_specifier '*'
3035 { $$ = $2; got_scope = NULL_TREE; }
3038 /* All uses of explicit global scope must go through this nonterminal so
3039 that got_scope will be set before yylex is called to get the next token. */
3042 { got_scope = void_type_node; }
3045 /* ANSI new-declarator (5.3.4) */
3047 '*' cv_qualifiers new_declarator
3048 { $$ = make_pointer_declarator ($2, $3); }
3049 | '*' cv_qualifiers %prec EMPTY
3050 { $$ = make_pointer_declarator ($2, NULL_TREE); }
3051 | '&' cv_qualifiers new_declarator %prec EMPTY
3052 { $$ = make_reference_declarator ($2, $3); }
3053 | '&' cv_qualifiers %prec EMPTY
3054 { $$ = make_reference_declarator ($2, NULL_TREE); }
3055 | ptr_to_mem cv_qualifiers %prec EMPTY
3056 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3057 $$ = build_parse_node (SCOPE_REF, $1, arg);
3059 | ptr_to_mem cv_qualifiers new_declarator
3060 { tree arg = make_pointer_declarator ($2, $3);
3061 $$ = build_parse_node (SCOPE_REF, $1, arg);
3063 | direct_new_declarator %prec EMPTY
3066 /* ANSI direct-new-declarator (5.3.4) */
3067 direct_new_declarator:
3069 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3070 | direct_new_declarator '[' nonmomentary_expr ']'
3071 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3074 /* ANSI abstract-declarator (8.1) */
3076 '*' nonempty_cv_qualifiers absdcl
3077 { $$ = make_pointer_declarator ($2.t, $3); }
3079 { $$ = make_pointer_declarator (NULL_TREE, $2); }
3080 | '*' nonempty_cv_qualifiers %prec EMPTY
3081 { $$ = make_pointer_declarator ($2.t, NULL_TREE); }
3083 { $$ = make_pointer_declarator (NULL_TREE, NULL_TREE); }
3084 | '&' nonempty_cv_qualifiers absdcl
3085 { $$ = make_reference_declarator ($2.t, $3); }
3087 { $$ = make_reference_declarator (NULL_TREE, $2); }
3088 | '&' nonempty_cv_qualifiers %prec EMPTY
3089 { $$ = make_reference_declarator ($2.t, NULL_TREE); }
3091 { $$ = make_reference_declarator (NULL_TREE, NULL_TREE); }
3092 | ptr_to_mem cv_qualifiers %prec EMPTY
3093 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3094 $$ = build_parse_node (SCOPE_REF, $1, arg);
3096 | ptr_to_mem cv_qualifiers absdcl
3097 { tree arg = make_pointer_declarator ($2, $3);
3098 $$ = build_parse_node (SCOPE_REF, $1, arg);
3100 | direct_abstract_declarator %prec EMPTY
3103 /* ANSI direct-abstract-declarator (8.1) */
3104 direct_abstract_declarator:
3107 /* `(typedef)1' is `int'. */
3109 | direct_abstract_declarator '(' parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3110 { $$ = make_call_declarator ($$, $3, $5, $6); }
3111 | direct_abstract_declarator LEFT_RIGHT cv_qualifiers exception_specification_opt %prec '.'
3112 { $$ = make_call_declarator ($$, empty_parms (), $3, $4); }
3113 | direct_abstract_declarator '[' nonmomentary_expr ']' %prec '.'
3114 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3115 | direct_abstract_declarator '[' ']' %prec '.'
3116 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
3117 | '(' complex_parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3118 { $$ = make_call_declarator (NULL_TREE, $2, $4, $5); }
3119 | regcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3120 { set_quals_and_spec ($$, $2, $3); }
3121 | fcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3122 { set_quals_and_spec ($$, $2, $3); }
3123 | '[' nonmomentary_expr ']' %prec '.'
3124 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3126 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, NULL_TREE); }
3129 /* For C++, decls and stmts can be intermixed, so we don't need to
3130 have a special rule that won't start parsing the stmt section
3131 until we have a stmt that parses without errors. */
3144 /* Read zero or more forward-declarations for labels
3145 that nested functions can jump to. */
3150 pedwarn ("ANSI C++ forbids label declarations"); }
3155 | label_decls label_decl
3159 LABEL identifiers_or_typenames ';'
3161 for (link = $2; link; link = TREE_CHAIN (link))
3163 tree label = shadow_label (TREE_VALUE (link));
3164 C_DECLARED_LABEL_FLAG (label) = 1;
3165 declare_nonlocal_label (label);
3170 /* This is the body of a function definition.
3171 It causes syntax errors to ignore to the next openbrace. */
3180 { $<ttype>$ = begin_compound_stmt (0); }
3182 { $$ = finish_compound_stmt (0, $<ttype>2); }
3188 $<ttype>$ = begin_if_stmt ();
3189 cond_stmt_keyword = "if";
3192 { finish_if_stmt_cond ($3, $<ttype>2); }
3193 implicitly_scoped_stmt
3194 { $<ttype>$ = finish_then_clause ($<ttype>2); }
3197 implicitly_scoped_stmt:
3199 | { $<ttype>$ = begin_compound_stmt (0); }
3201 { $$ = finish_compound_stmt (0, $<ttype>1); }
3214 { finish_expr_stmt ($1); }
3216 { begin_else_clause (); }
3217 implicitly_scoped_stmt
3219 finish_else_clause ($<ttype>1);
3222 | simple_if %prec IF
3223 { finish_if_stmt (); }
3226 $<ttype>$ = begin_while_stmt ();
3227 cond_stmt_keyword = "while";
3230 { finish_while_stmt_cond ($3, $<ttype>2); }
3232 { finish_while_stmt ($<ttype>2); }
3234 { $<ttype>$ = begin_do_stmt (); }
3235 implicitly_scoped_stmt WHILE
3237 finish_do_body ($<ttype>2);
3238 cond_stmt_keyword = "do";
3240 paren_expr_or_null ';'
3241 { finish_do_stmt ($6, $<ttype>2); }
3243 { $<ttype>$ = begin_for_stmt (); }
3244 '(' for.init.statement
3245 { finish_for_init_stmt ($<ttype>2); }
3247 { finish_for_cond ($6, $<ttype>2); }
3249 { finish_for_expr ($9, $<ttype>2); }
3251 { finish_for_stmt ($9, $<ttype>2); }
3253 { begin_switch_stmt (); }
3255 { $<ttype>$ = finish_switch_cond ($4); }
3256 implicitly_scoped_stmt
3257 { finish_switch_stmt ($4, $<ttype>6); }
3258 | CASE expr_no_commas ':'
3259 { finish_case_label ($2, NULL_TREE); }
3261 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
3262 { finish_case_label ($2, $4); }
3265 { finish_case_label (NULL_TREE, NULL_TREE); }
3268 { finish_break_stmt (); }
3270 { finish_continue_stmt (); }
3272 { finish_return_stmt (NULL_TREE); }
3274 { finish_return_stmt ($2); }
3275 | asm_keyword maybe_cv_qualifier '(' string ')' ';'
3277 finish_asm_stmt ($2, $4, NULL_TREE, NULL_TREE,
3280 /* This is the case with just output operands. */
3281 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ')' ';'
3283 finish_asm_stmt ($2, $4, $6, NULL_TREE,
3286 /* This is the case with input operands as well. */
3287 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':' asm_operands ')' ';'
3288 { finish_asm_stmt ($2, $4, $6, $8, NULL_TREE); }
3289 /* This is the case with clobbered registers as well. */
3290 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':'
3291 asm_operands ':' asm_clobbers ')' ';'
3292 { finish_asm_stmt ($2, $4, $6, $8, $10); }
3296 pedwarn ("ANSI C++ forbids computed gotos");
3297 finish_goto_stmt ($3);
3299 | GOTO identifier ';'
3300 { finish_goto_stmt ($2); }
3304 { error ("label must be followed by statement");
3311 | namespace_using_decl
3312 { do_local_using_decl ($1); }
3319 if (! current_function_parms_stored)
3320 store_parm_decls ();
3321 expand_start_early_try_stmts ();
3323 ctor_initializer_opt compstmt
3325 expand_start_all_catch ();
3329 int nested = (hack_decl_function_context
3330 (current_function_decl) != NULL_TREE);
3331 expand_end_all_catch ();
3332 finish_function (lineno, (int)$3, nested);
3338 { $<ttype>$ = begin_try_block (); }
3340 { finish_try_block ($<ttype>2); }
3342 { finish_handler_sequence ($<ttype>2); }
3347 | handler_seq handler
3352 { $<ttype>$ = begin_handler(); }
3354 { finish_handler_parms ($<ttype>2); }
3356 { finish_handler ($<ttype>2); }
3360 typed_typespecs %prec EMPTY
3361 | nonempty_cv_qualifiers %prec EMPTY
3366 { expand_start_catch_block (NULL_TREE, NULL_TREE); }
3367 /* This doesn't allow reference parameters, the below does.
3368 | '(' type_specifier_seq absdcl ')'
3369 { check_for_new_type ("inside exception declarations", $2);
3370 expand_start_catch_block ($2.t, $3); }
3371 | '(' type_specifier_seq ')'
3372 { check_for_new_type ("inside exception declarations", $2);
3373 expand_start_catch_block ($2.t, NULL_TREE); }
3374 | '(' type_specifier_seq notype_declarator ')'
3375 { check_for_new_type ("inside exception declarations", $2);
3376 expand_start_catch_block ($2.t, $3); }
3377 | '(' typed_typespecs after_type_declarator ')'
3378 { check_for_new_type ("inside exception declarations", $2);
3379 expand_start_catch_block ($2.t, $3); }
3380 This allows reference parameters... */
3382 { check_for_new_type ("inside exception declarations", $2);
3383 expand_start_catch_block (TREE_PURPOSE ($2.t),
3384 TREE_VALUE ($2.t)); }
3391 label = define_label (input_filename, lineno, $1);
3392 if (label && ! minimal_parse_mode)
3393 expand_label (label);
3405 { if ($1) cplus_expand_expr_stmt ($1); }
3409 pedwarn ("ANSI C++ forbids compound statements inside for initializations");
3413 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
3417 { emit_line_note (input_filename, lineno);
3420 { emit_line_note (input_filename, lineno); }
3431 /* These are the operands other than the first string and colon
3432 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
3436 | nonnull_asm_operands
3439 nonnull_asm_operands:
3441 | nonnull_asm_operands ',' asm_operand
3442 { $$ = chainon ($$, $3); }
3447 { $$ = build_tree_list ($$, $3); }
3452 { $$ = tree_cons (NULL_TREE, $$, NULL_TREE); }
3453 | asm_clobbers ',' STRING
3454 { $$ = tree_cons (NULL_TREE, $3, $$); }
3457 /* This is what appears inside the parens in a function declarator.
3458 Its value is represented in the format that grokdeclarator expects.
3460 In C++, declaring a function with no parameters
3461 means that that function takes *no* parameters. */
3470 { $$ = finish_parmlist (build_tree_list (NULL_TREE, $1.t), 0);
3471 check_for_new_type ("inside parameter list", $1); }
3474 /* This nonterminal does not include the common sequence '(' type_id ')',
3475 as it is ambiguous and must be disambiguated elsewhere. */
3478 { $$ = finish_parmlist ($$, 0); }
3479 | parms_comma ELLIPSIS
3480 { $$ = finish_parmlist ($1, 1); }
3481 /* C++ allows an ellipsis without a separating ',' */
3483 { $$ = finish_parmlist ($1, 1); }
3485 { $$ = finish_parmlist (build_tree_list (NULL_TREE,
3488 { $$ = finish_parmlist (NULL_TREE, 1); }
3491 /* This helps us recover from really nasty
3492 parse errors, for example, a missing right
3494 yyerror ("possibly missing ')'");
3495 $$ = finish_parmlist ($1, 0);
3501 /* This helps us recover from really nasty
3502 parse errors, for example, a missing right
3504 yyerror ("possibly missing ')'");
3505 $$ = finish_parmlist (build_tree_list (NULL_TREE,
3512 /* A default argument to a */
3515 { maybe_snarf_defarg (); }
3525 /* A nonempty list of parameter declarations or type names. */
3528 { check_for_new_type ("in a parameter list", $1);
3529 $$ = build_tree_list (NULL_TREE, $1.t); }
3531 { check_for_new_type ("in a parameter list", $1);
3532 $$ = build_tree_list ($2, $1.t); }
3533 | parms_comma full_parm
3534 { check_for_new_type ("in a parameter list", $2);
3535 $$ = chainon ($$, $2.t); }
3536 | parms_comma bad_parm
3537 { $$ = chainon ($$, build_tree_list (NULL_TREE, $2)); }
3538 | parms_comma bad_parm '=' init
3539 { $$ = chainon ($$, build_tree_list ($4, $2)); }
3545 { check_for_new_type ("in a parameter list", $1);
3546 $$ = build_tree_list (NULL_TREE, $1.t); }
3549 /* A single parameter declaration or parameter type name,
3550 as found in a parmlist. */
3552 /* Here we expand typed_declspecs inline to avoid mis-parsing of
3553 TYPESPEC IDENTIFIER. */
3554 typed_declspecs1 declarator
3555 { tree specs = strip_attrs ($1.t);
3556 $$.new_type_flag = $1.new_type_flag;
3557 $$.t = build_tree_list (specs, $2); }
3558 | typed_typespecs declarator
3559 { $$.t = build_tree_list ($1.t, $2);
3560 $$.new_type_flag = $1.new_type_flag; }
3561 | typespec declarator
3562 { $$.t = build_tree_list (get_decl_list ($1.t), $2);
3563 $$.new_type_flag = $1.new_type_flag; }
3564 | typed_declspecs1 absdcl
3565 { tree specs = strip_attrs ($1.t);
3566 $$.t = build_tree_list (specs, $2);
3567 $$.new_type_flag = $1.new_type_flag; }
3568 | typed_declspecs1 %prec EMPTY
3569 { tree specs = strip_attrs ($1.t);
3570 $$.t = build_tree_list (specs, NULL_TREE);
3571 $$.new_type_flag = $1.new_type_flag; }
3572 | declmods notype_declarator
3573 { tree specs = strip_attrs ($1);
3574 $$.t = build_tree_list (specs, $2);
3575 $$.new_type_flag = 0; }
3580 { $$.t = build_tree_list (NULL_TREE, $1.t);
3581 $$.new_type_flag = $1.new_type_flag; }
3583 { $$.t = build_tree_list ($2, $1.t);
3584 $$.new_type_flag = $1.new_type_flag; }
3593 /* empty */ %prec EMPTY
3594 { see_typename (); }
3598 /* empty */ %prec EMPTY
3600 error ("type specifier omitted for parameter");
3601 $$ = build_tree_list (integer_type_node, NULL_TREE);
3605 error ("type specifier omitted for parameter");
3606 if (TREE_CODE ($$) == SCOPE_REF
3607 && (TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TYPE_PARM
3608 || TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TEMPLATE_PARM))
3609 cp_error (" perhaps you want `typename %E' to make it a type", $$);
3610 $$ = build_tree_list (integer_type_node, $$);
3614 exception_specification_opt:
3615 /* empty */ %prec EMPTY
3617 | THROW '(' ansi_raise_identifiers ')' %prec EMPTY
3619 | THROW LEFT_RIGHT %prec EMPTY
3620 { $$ = build_decl_list (NULL_TREE, NULL_TREE); }
3623 ansi_raise_identifier:
3625 { $$ = build_decl_list (NULL_TREE, groktypename($1.t)); }
3628 ansi_raise_identifiers:
3629 ansi_raise_identifier
3630 | ansi_raise_identifiers ',' ansi_raise_identifier
3632 TREE_CHAIN ($3) = $$;
3637 conversion_declarator:
3638 /* empty */ %prec EMPTY
3640 | '*' cv_qualifiers conversion_declarator
3641 { $$ = make_pointer_declarator ($2, $3); }
3642 | '&' cv_qualifiers conversion_declarator
3643 { $$ = make_reference_declarator ($2, $3); }
3644 | ptr_to_mem cv_qualifiers conversion_declarator
3645 { tree arg = make_pointer_declarator ($2, $3);
3646 $$ = build_parse_node (SCOPE_REF, $1, arg);
3652 { got_scope = NULL_TREE; }
3657 { $$ = ansi_opname[MULT_EXPR]; }
3659 { $$ = ansi_opname[TRUNC_DIV_EXPR]; }
3661 { $$ = ansi_opname[TRUNC_MOD_EXPR]; }
3663 { $$ = ansi_opname[PLUS_EXPR]; }
3665 { $$ = ansi_opname[MINUS_EXPR]; }
3667 { $$ = ansi_opname[BIT_AND_EXPR]; }
3669 { $$ = ansi_opname[BIT_IOR_EXPR]; }
3671 { $$ = ansi_opname[BIT_XOR_EXPR]; }
3673 { $$ = ansi_opname[BIT_NOT_EXPR]; }
3675 { $$ = ansi_opname[COMPOUND_EXPR]; }
3676 | operator ARITHCOMPARE
3677 { $$ = ansi_opname[$2]; }
3679 { $$ = ansi_opname[LT_EXPR]; }
3681 { $$ = ansi_opname[GT_EXPR]; }
3682 | operator EQCOMPARE
3683 { $$ = ansi_opname[$2]; }
3685 { $$ = ansi_assopname[$2]; }
3687 { $$ = ansi_opname [MODIFY_EXPR]; }
3689 { $$ = ansi_opname[$2]; }
3691 { $$ = ansi_opname[$2]; }
3693 { $$ = ansi_opname[POSTINCREMENT_EXPR]; }
3694 | operator MINUSMINUS
3695 { $$ = ansi_opname[PREDECREMENT_EXPR]; }
3697 { $$ = ansi_opname[TRUTH_ANDIF_EXPR]; }
3699 { $$ = ansi_opname[TRUTH_ORIF_EXPR]; }
3701 { $$ = ansi_opname[TRUTH_NOT_EXPR]; }
3703 { $$ = ansi_opname[COND_EXPR]; }
3705 { $$ = ansi_opname[$2]; }
3706 | operator POINTSAT %prec EMPTY
3707 { $$ = ansi_opname[COMPONENT_REF]; }
3708 | operator POINTSAT_STAR %prec EMPTY
3709 { $$ = ansi_opname[MEMBER_REF]; }
3710 | operator LEFT_RIGHT
3711 { $$ = ansi_opname[CALL_EXPR]; }
3713 { $$ = ansi_opname[ARRAY_REF]; }
3714 | operator NEW %prec EMPTY
3715 { $$ = ansi_opname[NEW_EXPR]; }
3716 | operator DELETE %prec EMPTY
3717 { $$ = ansi_opname[DELETE_EXPR]; }
3718 | operator NEW '[' ']'
3719 { $$ = ansi_opname[VEC_NEW_EXPR]; }
3720 | operator DELETE '[' ']'
3721 { $$ = ansi_opname[VEC_DELETE_EXPR]; }
3722 /* Names here should be looked up in class scope ALSO. */
3723 | operator type_specifier_seq conversion_declarator
3724 { $$ = grokoptypename ($2.t, $3); }
3726 { $$ = ansi_opname[ERROR_MARK]; }
3733 debug_yytranslate (value)
3736 return yytname[YYTRANSLATE (value)];