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 /* This precedence declaration is to prefer this reduce
1321 to the Koenig lookup shift in primary, below. I hate yacc. */
1322 | notype_unqualified_id %prec '('
1323 | notype_template_declarator
1324 | '(' expr_or_declarator ')'
1325 { $$ = finish_decl_parsing ($2); }
1329 notype_unqualified_id
1331 if (TREE_CODE ($1) == BIT_NOT_EXPR)
1332 $$ = build_x_unary_op (BIT_NOT_EXPR, TREE_OPERAND ($1, 0));
1334 $$ = finish_id_expr ($1);
1340 if (processing_template_decl)
1341 push_obstacks (&permanent_obstack, &permanent_obstack);
1342 $$ = combine_strings ($$);
1343 if (processing_template_decl)
1347 { $$ = finish_parenthesized_expr ($2); }
1348 | '(' expr_or_declarator ')'
1349 { $2 = reparse_decl_as_expr (NULL_TREE, $2);
1350 $$ = finish_parenthesized_expr ($2); }
1352 { $$ = error_mark_node; }
1354 { if (current_function_decl == 0)
1356 error ("braced-group within expression allowed only inside a function");
1360 pedwarn ("ANSI C++ forbids braced-groups within expressions");
1361 $<ttype>$ = begin_stmt_expr ();
1364 { $$ = finish_stmt_expr ($<ttype>2, $3); }
1365 /* Koenig lookup support
1366 We could store lastiddecl in $1 to avoid another lookup,
1367 but that would result in many additional reduce/reduce conflicts. */
1368 | notype_unqualified_id '(' nonnull_exprlist ')'
1369 { $$ = finish_call_expr ($1, $3, 1); }
1370 | notype_unqualified_id LEFT_RIGHT
1371 { $$ = finish_call_expr ($1, NULL_TREE, 1); }
1372 | primary '(' nonnull_exprlist ')'
1373 { $$ = finish_call_expr ($1, $3, 0); }
1374 | primary LEFT_RIGHT
1375 { $$ = finish_call_expr ($1, NULL_TREE, 0); }
1376 | primary '[' expr ']'
1377 { $$ = grok_array_decl ($$, $3); }
1379 { $$ = finish_increment_expr ($1, POSTINCREMENT_EXPR); }
1380 | primary MINUSMINUS
1381 { $$ = finish_increment_expr ($1, POSTDECREMENT_EXPR); }
1382 /* C++ extensions */
1384 { $$ = finish_this_expr (); }
1385 | CV_QUALIFIER '(' nonnull_exprlist ')'
1387 tree type = NULL_TREE;
1390 /* This is a C cast in C++'s `functional' notation. */
1391 if ($3 == error_mark_node)
1393 $$ = error_mark_node;
1397 if ($3 == NULL_TREE)
1399 error ("cannot cast null list to type `%s'",
1400 IDENTIFIER_POINTER (TYPE_NAME (id)));
1401 $$ = error_mark_node;
1406 /* type is not set! (mrs) */
1407 if (type == error_mark_node)
1408 $$ = error_mark_node;
1412 if (id == ridpointers[(int) RID_CONST])
1413 type = build_type_variant (integer_type_node, 1, 0);
1414 else if (id == ridpointers[(int) RID_VOLATILE])
1415 type = build_type_variant (integer_type_node, 0, 1);
1417 /* should not be able to get here (mrs) */
1418 else if (id == ridpointers[(int) RID_FRIEND])
1420 error ("cannot cast expression to `friend' type");
1421 $$ = error_mark_node;
1425 else my_friendly_abort (79);
1426 $$ = build_c_cast (type, build_compound_expr ($3));
1430 | DYNAMIC_CAST '<' type_id '>' '(' expr ')'
1431 { tree type = groktypename ($3.t);
1432 check_for_new_type ("dynamic_cast", $3);
1433 $$ = build_dynamic_cast (type, $6); }
1434 | STATIC_CAST '<' type_id '>' '(' expr ')'
1435 { tree type = groktypename ($3.t);
1436 check_for_new_type ("static_cast", $3);
1437 $$ = build_static_cast (type, $6); }
1438 | REINTERPRET_CAST '<' type_id '>' '(' expr ')'
1439 { tree type = groktypename ($3.t);
1440 check_for_new_type ("reinterpret_cast", $3);
1441 $$ = build_reinterpret_cast (type, $6); }
1442 | CONST_CAST '<' type_id '>' '(' expr ')'
1443 { tree type = groktypename ($3.t);
1444 check_for_new_type ("const_cast", $3);
1445 $$ = build_const_cast (type, $6); }
1446 | TYPEID '(' expr ')'
1447 { $$ = build_x_typeid ($3); }
1448 | TYPEID '(' type_id ')'
1449 { tree type = groktypename ($3.t);
1450 check_for_new_type ("typeid", $3);
1451 $$ = get_typeid (TYPE_MAIN_VARIANT (type)); }
1452 | global_scope IDENTIFIER
1453 { $$ = do_scoped_id ($2, 1); }
1454 | global_scope template_id
1456 | global_scope operator_name
1458 got_scope = NULL_TREE;
1459 if (TREE_CODE ($2) == IDENTIFIER_NODE)
1460 $$ = do_scoped_id ($2, 1);
1464 | overqualified_id %prec HYPERUNARY
1465 { $$ = build_offset_ref (OP0 ($$), OP1 ($$)); }
1466 | overqualified_id '(' nonnull_exprlist ')'
1467 { $$ = finish_globally_qualified_member_call_expr ($1, $3); }
1468 | overqualified_id LEFT_RIGHT
1469 { $$ = finish_globally_qualified_member_call_expr ($1, NULL_TREE); }
1470 | object object_template_id %prec UNARY
1472 $$ = build_x_component_ref ($$, $2, NULL_TREE, 1);
1474 | object object_template_id '(' nonnull_exprlist ')'
1475 { $$ = finish_object_call_expr ($2, $1, $4); }
1476 | object object_template_id LEFT_RIGHT
1477 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1478 | object unqualified_id %prec UNARY
1479 { $$ = build_x_component_ref ($$, $2, NULL_TREE, 1); }
1480 | object overqualified_id %prec UNARY
1481 { if (processing_template_decl)
1482 $$ = build_min_nt (COMPONENT_REF, $1, copy_to_permanent ($2));
1484 $$ = build_object_ref ($$, OP0 ($2), OP1 ($2)); }
1485 | object unqualified_id '(' nonnull_exprlist ')'
1486 { $$ = finish_object_call_expr ($2, $1, $4); }
1487 | object unqualified_id LEFT_RIGHT
1488 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1489 | object overqualified_id '(' nonnull_exprlist ')'
1490 { $$ = finish_qualified_object_call_expr ($2, $1, $4); }
1491 | object overqualified_id LEFT_RIGHT
1492 { $$ = finish_qualified_object_call_expr ($2, $1, NULL_TREE); }
1493 /* p->int::~int() is valid -- 12.4 */
1494 | object '~' TYPESPEC LEFT_RIGHT
1495 { $$ = finish_pseudo_destructor_call_expr ($1, NULL_TREE, $3); }
1496 | object TYPESPEC SCOPE '~' TYPESPEC LEFT_RIGHT
1497 { $$ = finish_pseudo_destructor_call_expr ($1, $2, $5); }
1500 $$ = error_mark_node;
1504 /* Not needed for now.
1510 { $$ = error_mark_node; }
1512 { if (current_function_decl == 0)
1514 error ("braced-group within expression allowed only inside a function");
1517 $<ttype>$ = expand_start_stmt_expr (); }
1520 pedwarn ("ANSI C++ forbids braced-groups within expressions");
1521 $$ = expand_end_stmt_expr ($<ttype>2); }
1522 | primary_no_id '(' nonnull_exprlist ')'
1523 { $$ = build_x_function_call ($$, $3, current_class_ref); }
1524 | primary_no_id LEFT_RIGHT
1525 { $$ = build_x_function_call ($$, NULL_TREE, current_class_ref); }
1526 | primary_no_id '[' expr ']'
1528 | primary_no_id PLUSPLUS
1529 { $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); }
1530 | primary_no_id MINUSMINUS
1531 { $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); }
1533 { goto do_scoped_id; }
1534 | SCOPE operator_name
1535 { if (TREE_CODE ($2) == IDENTIFIER_NODE)
1537 goto do_scoped_operator;
1546 { got_scope = NULL_TREE; $$ = 1; }
1552 | global_scope delete
1553 { got_scope = NULL_TREE; $$ = 1; }
1558 { $$ = boolean_true_node; }
1560 { $$ = boolean_false_node; }
1563 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
1567 { $$ = chainon ($$, $2); }
1573 if (! current_function_parms_stored)
1574 store_parm_decls ();
1576 /* Always keep the BLOCK node associated with the outermost
1577 pair of curley braces of a function. These are needed
1578 for correct operation of dwarfout.c. */
1585 { got_object = TREE_TYPE ($$); }
1588 $$ = build_x_arrow ($$);
1589 got_object = TREE_TYPE ($$);
1594 typespec initdecls ';'
1596 resume_momentary ($2);
1597 if ($1.t && IS_AGGR_TYPE_CODE (TREE_CODE ($1.t)))
1598 note_got_semicolon ($1.t);
1600 | typed_declspecs initdecls ';'
1602 resume_momentary ($2);
1603 note_list_got_semicolon ($1.t);
1605 | declmods notype_initdecls ';'
1606 { resume_momentary ($2); }
1607 | typed_declspecs ';'
1610 note_list_got_semicolon ($1.t);
1613 { warning ("empty declaration"); }
1615 { pedantic = $<itype>1; }
1618 /* Any kind of declarator (thus, all declarators allowed
1619 after an explicit typespec). */
1622 after_type_declarator %prec EMPTY
1623 | notype_declarator %prec EMPTY
1626 /* This is necessary to postpone reduction of `int()()()()'. */
1628 LEFT_RIGHT %prec EMPTY
1629 { $$ = make_call_declarator (NULL_TREE, empty_parms (),
1630 NULL_TREE, NULL_TREE); }
1631 | fcast_or_absdcl LEFT_RIGHT %prec EMPTY
1632 { $$ = make_call_declarator ($$, empty_parms (), NULL_TREE,
1636 /* ANSI type-id (8.1) */
1638 typed_typespecs absdcl
1639 { $$.t = build_decl_list ($1.t, $2);
1640 $$.new_type_flag = $1.new_type_flag; }
1641 | nonempty_cv_qualifiers absdcl
1642 { $$.t = build_decl_list ($1.t, $2);
1643 $$.new_type_flag = $1.new_type_flag; }
1645 { $$.t = build_decl_list (get_decl_list ($1.t), $2);
1646 $$.new_type_flag = $1.new_type_flag; }
1647 | typed_typespecs %prec EMPTY
1648 { $$.t = build_decl_list ($1.t, NULL_TREE);
1649 $$.new_type_flag = $1.new_type_flag; }
1650 | nonempty_cv_qualifiers %prec EMPTY
1651 { $$.t = build_decl_list ($1.t, NULL_TREE);
1652 $$.new_type_flag = $1.new_type_flag; }
1655 /* Declspecs which contain at least one type specifier or typedef name.
1656 (Just `const' or `volatile' is not enough.)
1657 A typedef'd name following these is taken as a name to be declared.
1658 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1661 typed_typespecs %prec EMPTY
1667 { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1);
1668 $$.new_type_flag = $2.new_type_flag; }
1669 | typespec reserved_declspecs %prec HYPERUNARY
1670 { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2);
1671 $$.new_type_flag = $1.new_type_flag; }
1672 | typespec reserved_typespecquals reserved_declspecs
1673 { $$.t = decl_tree_cons (NULL_TREE, $1.t, chainon ($2, $3));
1674 $$.new_type_flag = $1.new_type_flag; }
1675 | declmods typespec reserved_declspecs
1676 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1));
1677 $$.new_type_flag = $2.new_type_flag; }
1678 | declmods typespec reserved_typespecquals
1679 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1));
1680 $$.new_type_flag = $2.new_type_flag; }
1681 | declmods typespec reserved_typespecquals reserved_declspecs
1682 { $$.t = decl_tree_cons (NULL_TREE, $2.t,
1683 chainon ($3, chainon ($4, $1)));
1684 $$.new_type_flag = $2.new_type_flag; }
1689 { if (extra_warnings)
1690 warning ("`%s' is not at beginning of declaration",
1691 IDENTIFIER_POINTER ($$));
1692 $$ = build_decl_list (NULL_TREE, $$); }
1693 | reserved_declspecs typespecqual_reserved
1694 { $$ = decl_tree_cons (NULL_TREE, $2.t, $$); }
1695 | reserved_declspecs SCSPEC
1696 { if (extra_warnings)
1697 warning ("`%s' is not at beginning of declaration",
1698 IDENTIFIER_POINTER ($2));
1699 $$ = decl_tree_cons (NULL_TREE, $2, $$); }
1700 | reserved_declspecs attributes
1701 { $$ = decl_tree_cons ($2, NULL_TREE, $1); }
1703 { $$ = decl_tree_cons ($1, NULL_TREE, NULL_TREE); }
1706 /* List of just storage classes and type modifiers.
1707 A declaration can start with just this, but then it cannot be used
1708 to redeclare a typedef-name.
1709 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1712 nonempty_cv_qualifiers %prec EMPTY
1713 { $$ = $1.t; TREE_STATIC ($$) = 1; }
1715 { $$ = IDENTIFIER_AS_LIST ($$); }
1716 | declmods CV_QUALIFIER
1717 { $$ = decl_tree_cons (NULL_TREE, $2, $$);
1718 TREE_STATIC ($$) = 1; }
1720 { if (extra_warnings && TREE_STATIC ($$))
1721 warning ("`%s' is not at beginning of declaration",
1722 IDENTIFIER_POINTER ($2));
1723 $$ = decl_tree_cons (NULL_TREE, $2, $$);
1724 TREE_STATIC ($$) = TREE_STATIC ($1); }
1725 | declmods attributes
1726 { $$ = decl_tree_cons ($2, NULL_TREE, $1); }
1728 { $$ = decl_tree_cons ($1, NULL_TREE, NULL_TREE); }
1731 /* Used instead of declspecs where storage classes are not allowed
1732 (that is, for typenames and structure components).
1734 C++ can takes storage classes for structure components.
1735 Don't accept a typedef-name if anything but a modifier precedes it. */
1738 typespec %prec EMPTY
1739 { $$.t = get_decl_list ($1.t);
1740 $$.new_type_flag = $1.new_type_flag; }
1741 | nonempty_cv_qualifiers typespec
1742 { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1.t);
1743 $$.new_type_flag = $2.new_type_flag; }
1744 | typespec reserved_typespecquals
1745 { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2);
1746 $$.new_type_flag = $1.new_type_flag; }
1747 | nonempty_cv_qualifiers typespec reserved_typespecquals
1748 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1749 $$.new_type_flag = $1.new_type_flag; }
1752 reserved_typespecquals:
1753 typespecqual_reserved
1754 { $$ = build_decl_list (NULL_TREE, $1.t); }
1755 | reserved_typespecquals typespecqual_reserved
1756 { $$ = decl_tree_cons (NULL_TREE, $2.t, $1); }
1759 /* A typespec (but not a type qualifier).
1760 Once we have seen one of these in a declaration,
1761 if a typedef name appears then it is being redeclared. */
1765 | TYPESPEC %prec EMPTY
1766 { $$.t = $1; $$.new_type_flag = 0; }
1767 | complete_type_name
1768 { $$.t = $1; $$.new_type_flag = 0; }
1769 | TYPEOF '(' expr ')'
1770 { $$.t = TREE_TYPE ($3);
1771 $$.new_type_flag = 0; }
1772 | TYPEOF '(' type_id ')'
1773 { $$.t = groktypename ($3.t);
1774 $$.new_type_flag = 0; }
1775 | SIGOF '(' expr ')'
1776 { tree type = TREE_TYPE ($3);
1778 $$.new_type_flag = 0;
1779 if (IS_AGGR_TYPE (type))
1781 sorry ("sigof type specifier");
1786 error ("`sigof' applied to non-aggregate expression");
1787 $$.t = error_mark_node;
1790 | SIGOF '(' type_id ')'
1791 { tree type = groktypename ($3.t);
1793 $$.new_type_flag = 0;
1794 if (IS_AGGR_TYPE (type))
1796 sorry ("sigof type specifier");
1801 error("`sigof' applied to non-aggregate type");
1802 $$.t = error_mark_node;
1807 /* A typespec that is a reserved word, or a type qualifier. */
1809 typespecqual_reserved:
1811 { $$.t = $1; $$.new_type_flag = 0; }
1813 { $$.t = $1; $$.new_type_flag = 0; }
1819 | initdecls ',' initdcl
1824 | notype_initdecls ',' initdcl
1829 | nomods_initdecls ',' initdcl
1835 | asm_keyword '(' string ')'
1836 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3); $$ = $3; }
1840 declarator maybeasm maybe_attribute '='
1841 { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1,
1842 $3, prefix_attributes); }
1844 /* Note how the declaration of the variable is in effect while its init is parsed! */
1845 { cp_finish_decl ($<ttype>5, $6, $2, 1, LOOKUP_ONLYCONVERTING); }
1846 | declarator maybeasm maybe_attribute
1847 { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 0,
1848 $3, prefix_attributes);
1849 cp_finish_decl ($<ttype>$, NULL_TREE, $2, 1, 0); }
1852 /* This rule assumes a certain configuration of the parser stack.
1853 In particular, $0, the element directly before the beginning of
1854 this rule on the stack, must be a maybeasm. $-1 must be a
1855 declarator or notype_declarator. And $-2 must be some declmods
1856 or declspecs. We can't move the maybeasm into this rule because
1857 we need that reduce so we prefer fn.def1 when appropriate. */
1860 { $<itype>2 = parse_decl ($<ttype>-1, $<ttype>-2,
1861 $1, 1, &$<ttype>$); }
1862 /* Note how the declaration of the variable is in effect
1863 while its init is parsed! */
1865 { cp_finish_decl ($<ttype>3, $4, $<ttype>0, 1,
1866 LOOKUP_ONLYCONVERTING);
1870 $$ = parse_decl ($<ttype>-1, $<ttype>-2, $1, 0, &d);
1871 cp_finish_decl (d, NULL_TREE, $<ttype>0, 1, 0); }
1875 declarator maybeasm initdcl0_innards
1879 notype_declarator maybeasm initdcl0_innards
1884 notype_declarator maybeasm
1885 { /* Set things up as initdcl0_innards expects. */
1890 | constructor_declarator maybeasm maybe_attribute
1892 parse_decl($1, NULL_TREE, $3, 0, &d);
1893 cp_finish_decl (d, NULL_TREE, $2, 1, 0); }
1896 /* the * rules are dummies to accept the Apollo extended syntax
1897 so that the header files compile. */
1908 | attributes attribute
1909 { $$ = chainon ($1, $2); }
1913 ATTRIBUTE '(' '(' attribute_list ')' ')'
1920 | attribute_list ',' attrib
1921 { $$ = chainon ($1, $3); }
1928 { $$ = build_tree_list ($1, NULL_TREE); }
1929 | any_word '(' IDENTIFIER ')'
1930 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1931 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1932 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1933 | any_word '(' nonnull_exprlist ')'
1934 { $$ = build_tree_list ($1, $3); }
1937 /* This still leaves out most reserved keywords,
1938 shouldn't we include them? */
1947 /* A nonempty list of identifiers, including typenames. */
1948 identifiers_or_typenames:
1950 { $$ = build_tree_list (NULL_TREE, $1); }
1951 | identifiers_or_typenames ',' identifier
1952 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
1956 /* empty */ %prec EMPTY
1961 /* If we are processing a template, we don't want to expand this
1965 expr_no_commas %prec '='
1967 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, NULL_TREE);
1968 TREE_HAS_CONSTRUCTOR ($$) = 1; }
1970 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
1971 TREE_HAS_CONSTRUCTOR ($$) = 1; }
1972 | '{' initlist ',' '}'
1973 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
1974 TREE_HAS_CONSTRUCTOR ($$) = 1; }
1979 /* This chain is built in reverse order,
1980 and put in forward order where initlist is used. */
1983 { $$ = build_tree_list (NULL_TREE, $$); }
1985 { $$ = expr_tree_cons (NULL_TREE, $3, $$); }
1986 /* These are for labeled elements. */
1987 | '[' expr_no_commas ']' init
1988 { $$ = build_expr_list ($2, $4); }
1989 | identifier ':' init
1990 { $$ = build_expr_list ($$, $3); }
1991 | initlist ',' identifier ':' init
1992 { $$ = expr_tree_cons ($3, $5, $$); }
1996 PRE_PARSED_FUNCTION_DECL
1997 { start_function (NULL_TREE, TREE_VALUE ($1),
1999 reinit_parse_for_function (); }
2002 fn.defpen maybe_return_init ctor_initializer_opt compstmt_or_error
2004 int nested = (hack_decl_function_context
2005 (current_function_decl) != NULL_TREE);
2006 finish_function (lineno, (int)$3, nested);
2007 process_next_inline ($1);
2009 | fn.defpen maybe_return_init function_try_block
2010 { process_next_inline ($1); }
2011 | fn.defpen maybe_return_init error
2012 { process_next_inline ($1); }
2017 | pending_inlines pending_inline eat_saved_input
2020 /* A regurgitated default argument. The value of DEFARG_MARKER will be
2021 the TREE_LIST node for the parameter in question. */
2023 DEFARG_MARKER expr_no_commas END_OF_SAVED_INPUT
2024 { replace_defarg ($1, $2); }
2025 | DEFARG_MARKER error END_OF_SAVED_INPUT
2026 { replace_defarg ($1, error_mark_node); }
2029 /* empty */ %prec EMPTY
2030 | pending_defargs defarg_again
2031 { do_pending_defargs (); }
2032 | pending_defargs error
2033 { do_pending_defargs (); }
2038 { $<itype>3 = suspend_momentary ();
2039 $<ttype>$ = start_enum ($2); }
2040 enumlist maybecomma_warn '}'
2041 { $$.t = finish_enum ($<ttype>4, $5);
2042 $$.new_type_flag = 1;
2043 resume_momentary ((int) $<itype>3);
2044 check_for_missing_semicolon ($<ttype>4); }
2045 | ENUM identifier '{' '}'
2046 { $$.t = finish_enum (start_enum ($2), NULL_TREE);
2047 $$.new_type_flag = 1;
2048 check_for_missing_semicolon ($$.t); }
2050 { $<itype>2 = suspend_momentary ();
2051 $<ttype>$ = start_enum (make_anon_name ()); }
2052 enumlist maybecomma_warn '}'
2053 { $$.t = finish_enum ($<ttype>3, $4);
2054 resume_momentary ((int) $<itype>1);
2055 check_for_missing_semicolon ($<ttype>3);
2056 $$.new_type_flag = 1; }
2058 { $$.t = finish_enum (start_enum (make_anon_name()), NULL_TREE);
2059 $$.new_type_flag = 1;
2060 check_for_missing_semicolon ($$.t); }
2062 { $$.t = xref_tag (enum_type_node, $2, NULL_TREE, 1);
2063 $$.new_type_flag = 0; }
2064 | ENUM complex_type_name
2065 { $$.t = xref_tag (enum_type_node, $2, NULL_TREE, 1);
2066 $$.new_type_flag = 0; }
2067 | TYPENAME_KEYWORD typename_sub
2069 $$.new_type_flag = 0; }
2070 /* C++ extensions, merged with C to avoid shift/reduce conflicts */
2071 | class_head left_curly
2072 opt.component_decl_list '}' maybe_attribute
2076 if (yychar == YYEMPTY)
2078 semi = yychar == ';';
2080 $<ttype>$ = finish_class_definition ($1, $3, $5, semi);
2083 { finish_default_args (); }
2086 $$.new_type_flag = 1;
2087 begin_inline_definitions (); }
2088 | class_head %prec EMPTY
2090 $$.new_type_flag = 0;
2091 if (TYPE_BINFO ($1) == NULL_TREE)
2093 cp_error ("%T is not a class type", $1);
2094 $$.t = error_mark_node;
2099 /* struct B: public A; is not accepted by the WP grammar. */
2100 if (TYPE_BINFO_BASETYPES ($$.t) && !TYPE_SIZE ($$.t)
2101 && ! TYPE_BEING_DEFINED ($$.t))
2102 cp_error ("base clause without member specification for `%#T'",
2116 { if (pedantic && !in_system_header)
2117 pedwarn ("comma at end of enumerator list"); }
2123 { error ("storage class specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2125 { error ("type specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2127 { error ("type qualifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2129 { error ("no body nor ';' separates two class, struct or union declarations"); }
2131 { $$ = build_decl_list ($2, $1); }
2134 named_class_head_sans_basetype:
2136 { current_aggr = $$; $$ = $2; }
2139 named_class_head_sans_basetype_defn:
2140 aggr identifier_defn %prec EMPTY
2141 { current_aggr = $$; $$ = $2; }
2142 | named_class_head_sans_basetype '{'
2143 { yyungetc ('{', 1); }
2144 | named_class_head_sans_basetype ':'
2145 { yyungetc (':', 1); }
2148 named_complex_class_head_sans_basetype:
2149 aggr nested_name_specifier identifier
2152 $$ = handle_class_head ($1, $2, $3);
2154 | aggr global_scope nested_name_specifier identifier
2157 $$ = handle_class_head ($1, $3, $4);
2159 | aggr global_scope identifier
2162 $$ = handle_class_head ($1, NULL_TREE, $3);
2164 | aggr template_type
2165 { current_aggr = $$; $$ = $2; }
2166 | aggr nested_name_specifier template_type
2167 { current_aggr = $$; $$ = $3; }
2171 /* empty */ %prec EMPTY
2172 { $<ttype>$ = xref_tag (current_aggr, $<ttype>0, NULL_TREE, 0); }
2176 named_class_head_sans_basetype %prec EMPTY
2177 { $$ = xref_tag (current_aggr, $1, NULL_TREE, 1); }
2178 | named_class_head_sans_basetype_defn do_xref_defn
2179 maybe_base_class_list %prec EMPTY
2183 xref_basetypes (current_aggr, $1, $<ttype>2, $3);
2185 | named_complex_class_head_sans_basetype maybe_base_class_list
2187 $$ = TREE_TYPE ($1);
2188 if (TREE_INT_CST_LOW (current_aggr) == union_type
2189 && TREE_CODE ($$) != UNION_TYPE)
2190 cp_pedwarn ("`union' tag used in declaring `%#T'", $$);
2191 else if (TREE_CODE ($$) == UNION_TYPE
2192 && TREE_INT_CST_LOW (current_aggr) != union_type)
2193 cp_pedwarn ("non-`union' tag used in declaring `%#T'", $$);
2196 if (IS_AGGR_TYPE ($$) && CLASSTYPE_USE_TEMPLATE ($$))
2198 if (CLASSTYPE_IMPLICIT_INSTANTIATION ($$)
2199 && TYPE_SIZE ($$) == NULL_TREE)
2201 SET_CLASSTYPE_TEMPLATE_SPECIALIZATION ($$);
2202 if (processing_template_decl)
2203 push_template_decl (TYPE_MAIN_DECL ($$));
2205 else if (CLASSTYPE_TEMPLATE_INSTANTIATION ($$))
2206 cp_error ("specialization after instantiation of `%T'", $$);
2208 xref_basetypes (current_aggr, $1, $$, $2);
2215 { $$ = xref_tag ($$, make_anon_name (), NULL_TREE, 0);
2216 yyungetc ('{', 1); }
2224 maybe_base_class_list:
2225 /* empty */ %prec EMPTY
2227 | ':' see_typename %prec EMPTY
2228 { yyungetc(':', 1); $$ = NULL_TREE; }
2229 | ':' see_typename base_class_list %prec EMPTY
2235 | base_class_list ',' see_typename base_class
2236 { $$ = chainon ($$, $4); }
2243 if ($1 == NULL_TREE)
2245 error ("invalid base class");
2246 type = error_mark_node;
2249 type = TREE_TYPE ($1);
2250 if (! is_aggr_type (type, 1))
2252 else if (current_aggr == signature_type_node
2253 && (! type) && (! IS_SIGNATURE (type)))
2255 error ("class name not allowed as base signature");
2258 else if (current_aggr == signature_type_node)
2260 sorry ("signature inheritance, base type `%s' ignored",
2261 IDENTIFIER_POINTER ($$));
2262 $$ = build_tree_list (access_public_node, type);
2264 else if (type && IS_SIGNATURE (type))
2266 error ("signature name not allowed as base class");
2270 $$ = build_tree_list (access_default_node, type);
2272 | base_class_access_list see_typename base_class.1
2275 if ($3 == NULL_TREE)
2277 error ("invalid base class");
2278 type = error_mark_node;
2281 type = TREE_TYPE ($3);
2282 if (current_aggr == signature_type_node)
2283 error ("access and source specifiers not allowed in signature");
2284 if (! is_aggr_type (type, 1))
2286 else if (current_aggr == signature_type_node
2287 && (! type) && (! IS_SIGNATURE (type)))
2289 error ("class name not allowed as base signature");
2292 else if (current_aggr == signature_type_node)
2294 sorry ("signature inheritance, base type `%s' ignored",
2295 IDENTIFIER_POINTER ($$));
2296 $$ = build_tree_list (access_public_node, type);
2298 else if (type && IS_SIGNATURE (type))
2300 error ("signature name not allowed as base class");
2304 $$ = build_tree_list ($$, type);
2310 { $$ = TYPE_MAIN_DECL ($1); }
2312 | SIGOF '(' expr ')'
2314 if (current_aggr == signature_type_node)
2316 if (IS_AGGR_TYPE (TREE_TYPE ($3)))
2318 sorry ("`sigof' as base signature specifier");
2319 $$ = TREE_TYPE ($3);
2323 error ("`sigof' applied to non-aggregate expression");
2324 $$ = error_mark_node;
2329 error ("`sigof' in struct or class declaration");
2330 $$ = error_mark_node;
2333 | SIGOF '(' type_id ')'
2335 if (current_aggr == signature_type_node)
2337 if (IS_AGGR_TYPE (groktypename ($3.t)))
2339 sorry ("`sigof' as base signature specifier");
2340 $$ = groktypename ($3.t);
2344 error ("`sigof' applied to non-aggregate expression");
2345 $$ = error_mark_node;
2350 error ("`sigof' in struct or class declaration");
2351 $$ = error_mark_node;
2356 base_class_access_list:
2357 VISSPEC see_typename
2358 | SCSPEC see_typename
2359 { if ($1 != ridpointers[(int)RID_VIRTUAL])
2360 cp_error ("`%D' access", $1);
2361 $$ = access_default_virtual_node; }
2362 | base_class_access_list VISSPEC see_typename
2364 if ($1 != access_default_virtual_node)
2365 error ("multiple access specifiers");
2366 else if ($2 == access_public_node)
2367 $$ = access_public_virtual_node;
2368 else if ($2 == access_protected_node)
2369 $$ = access_protected_virtual_node;
2370 else /* $2 == access_private_node */
2371 $$ = access_private_virtual_node;
2373 | base_class_access_list SCSPEC see_typename
2374 { if ($2 != ridpointers[(int)RID_VIRTUAL])
2375 cp_error ("`%D' access", $2);
2376 else if ($$ == access_public_node)
2377 $$ = access_public_virtual_node;
2378 else if ($$ == access_protected_node)
2379 $$ = access_protected_virtual_node;
2380 else if ($$ == access_private_node)
2381 $$ = access_private_virtual_node;
2383 error ("multiple `virtual' specifiers");
2389 { $<ttype>0 = begin_class_definition ($<ttype>0); }
2395 $$ = build_self_reference ();
2399 opt.component_decl_list:
2401 { if ($$) $$ = build_tree_list (access_public_node, $$); }
2402 | self_reference component_decl_list
2404 if (current_aggr == signature_type_node)
2405 $$ = build_tree_list (access_public_node, $2);
2407 $$ = build_tree_list (access_default_node, $2);
2408 if ($1) $$ = tree_cons (access_public_node, $1, $$);
2410 | opt.component_decl_list VISSPEC ':' component_decl_list
2414 if (current_aggr == signature_type_node)
2416 error ("access specifier not allowed in signature");
2417 visspec = access_public_node;
2419 $$ = chainon ($$, build_tree_list (visspec, $4));
2421 | opt.component_decl_list VISSPEC ':'
2423 if (current_aggr == signature_type_node)
2424 error ("access specifier not allowed in signature");
2428 /* Note: we no longer warn about the semicolon after a component_decl_list.
2429 ARM $9.2 says that the semicolon is optional, and therefore allowed. */
2430 component_decl_list:
2432 { if ($$ == void_type_node) $$ = NULL_TREE;
2434 | component_decl_list component_decl
2435 { /* In pushdecl, we created a reverse list of names
2436 in this binding level. Make sure that the chain
2437 of what we're trying to add isn't the item itself
2438 (which can happen with what pushdecl's doing). */
2439 if ($2 != NULL_TREE && $2 != void_type_node)
2441 if (TREE_CHAIN ($2) != $$)
2442 $$ = chainon ($$, $2);
2450 component_decl_1 ';'
2452 | component_decl_1 '}'
2453 { error ("missing ';' before right brace");
2454 yyungetc ('}', 0); }
2455 /* C++: handle constructors, destructors and inline functions */
2456 /* note that INLINE is like a TYPESPEC */
2457 | fn.def2 ':' /* base_init compstmt */
2458 { $$ = finish_method ($$); }
2459 | fn.def2 TRY /* base_init compstmt */
2460 { $$ = finish_method ($$); }
2461 | fn.def2 RETURN /* base_init compstmt */
2462 { $$ = finish_method ($$); }
2463 | fn.def2 '{' /* nodecls compstmt */
2464 { $$ = finish_method ($$); }
2467 | extension component_decl
2469 pedantic = $<itype>1; }
2470 | template_header component_decl
2471 { $$ = finish_member_template_decl ($1, $2); }
2472 | template_header typed_declspecs ';'
2473 { $$ = finish_member_class_template ($1, $2.t); }
2477 /* Do not add a "typed_declspecs declarator" rule here for
2478 speed; we need to call grok_x_components for enums, so the
2479 speedup would be insignificant. */
2480 typed_declspecs components
2481 { $$ = grok_x_components ($1.t, $2); }
2482 | declmods notype_components
2483 { $$ = grok_x_components ($1, $2); }
2484 | notype_declarator maybeasm maybe_attribute maybe_init
2485 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2486 build_tree_list ($3, NULL_TREE)); }
2487 | constructor_declarator maybeasm maybe_attribute maybe_init
2488 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2489 build_tree_list ($3, NULL_TREE)); }
2490 | ':' expr_no_commas
2491 { $$ = grokbitfield (NULL_TREE, NULL_TREE, $2); }
2495 /* These rules introduce a reduce/reduce conflict; in
2496 typedef int foo, bar;
2500 should "A::foo" be declared as a function or "A::bar" as a data
2501 member? In other words, is "bar" an after_type_declarator or a
2503 | declmods component_constructor_declarator maybeasm maybe_attribute maybe_init
2504 { tree specs, attrs;
2505 split_specs_attrs ($1, &specs, &attrs);
2506 $$ = grokfield ($2, specs, $5, $3,
2507 build_tree_list ($4, attrs)); }
2508 | component_constructor_declarator maybeasm maybe_attribute maybe_init
2509 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2510 build_tree_list ($3, NULL_TREE)); }
2512 { $$ = do_class_using_decl ($1); }
2514 /* The case of exactly one component is handled directly by component_decl. */
2517 /* empty: possibly anonymous */
2519 | component_declarator0
2520 | components ',' component_declarator
2522 /* In this context, void_type_node encodes
2523 friends. They have been recorded elsewhere. */
2524 if ($$ == void_type_node)
2527 $$ = chainon ($$, $3);
2532 /* empty: possibly anonymous */
2534 | notype_component_declarator0
2535 | notype_components ',' notype_component_declarator
2537 /* In this context, void_type_node encodes
2538 friends. They have been recorded elsewhere. */
2539 if ($$ == void_type_node)
2542 $$ = chainon ($$, $3);
2546 component_declarator0:
2547 after_type_component_declarator0
2548 | notype_component_declarator0
2551 component_declarator:
2552 after_type_component_declarator
2553 | notype_component_declarator
2556 after_type_component_declarator0:
2557 after_type_declarator maybeasm maybe_attribute maybe_init
2558 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2559 &prefix_attributes);
2560 $<ttype>0 = current_declspecs;
2561 $$ = grokfield ($$, current_declspecs, $4, $2,
2562 build_tree_list ($3, prefix_attributes)); }
2563 | TYPENAME ':' expr_no_commas maybe_attribute
2564 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2565 &prefix_attributes);
2566 $<ttype>0 = current_declspecs;
2567 $$ = grokbitfield ($$, current_declspecs, $3);
2568 cplus_decl_attributes ($$, $4, prefix_attributes); }
2571 notype_component_declarator0:
2572 notype_declarator maybeasm maybe_attribute maybe_init
2573 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2574 &prefix_attributes);
2575 $<ttype>0 = current_declspecs;
2576 $$ = grokfield ($$, current_declspecs, $4, $2,
2577 build_tree_list ($3, prefix_attributes)); }
2578 | constructor_declarator maybeasm maybe_attribute maybe_init
2579 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2580 &prefix_attributes);
2581 $<ttype>0 = current_declspecs;
2582 $$ = grokfield ($$, current_declspecs, $4, $2,
2583 build_tree_list ($3, prefix_attributes)); }
2584 | IDENTIFIER ':' expr_no_commas maybe_attribute
2585 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2586 &prefix_attributes);
2587 $<ttype>0 = current_declspecs;
2588 $$ = grokbitfield ($$, current_declspecs, $3);
2589 cplus_decl_attributes ($$, $4, prefix_attributes); }
2590 | ':' expr_no_commas maybe_attribute
2591 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2592 &prefix_attributes);
2593 $<ttype>0 = current_declspecs;
2594 $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
2595 cplus_decl_attributes ($$, $3, prefix_attributes); }
2598 after_type_component_declarator:
2599 after_type_declarator maybeasm maybe_attribute maybe_init
2600 { $$ = grokfield ($$, current_declspecs, $4, $2,
2601 build_tree_list ($3, prefix_attributes)); }
2602 | TYPENAME ':' expr_no_commas maybe_attribute
2603 { $$ = grokbitfield ($$, current_declspecs, $3);
2604 cplus_decl_attributes ($$, $4, prefix_attributes); }
2607 notype_component_declarator:
2608 notype_declarator maybeasm maybe_attribute maybe_init
2609 { $$ = grokfield ($$, current_declspecs, $4, $2,
2610 build_tree_list ($3, prefix_attributes)); }
2611 | IDENTIFIER ':' expr_no_commas maybe_attribute
2612 { $$ = grokbitfield ($$, current_declspecs, $3);
2613 cplus_decl_attributes ($$, $4, prefix_attributes); }
2614 | ':' expr_no_commas maybe_attribute
2615 { $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
2616 cplus_decl_attributes ($$, $3, prefix_attributes); }
2619 /* We chain the enumerators in reverse order.
2620 Because of the way enums are built, the order is
2621 insignificant. Take advantage of this fact. */
2625 | enumlist ',' enumerator
2626 { TREE_CHAIN ($3) = $$; $$ = $3; }
2631 { $$ = build_enumerator ($$, NULL_TREE); }
2632 | identifier '=' expr_no_commas
2633 { $$ = build_enumerator ($$, $3); }
2636 /* ANSI new-type-id (5.3.4) */
2638 type_specifier_seq new_declarator
2639 { $$.t = build_decl_list ($1.t, $2);
2640 $$.new_type_flag = $1.new_type_flag; }
2641 | type_specifier_seq %prec EMPTY
2642 { $$.t = build_decl_list ($1.t, NULL_TREE);
2643 $$.new_type_flag = $1.new_type_flag; }
2644 /* GNU extension to allow arrays of arbitrary types with
2645 non-constant dimension. For the use of begin_new_placement
2646 here, see the comments in unary_expr above. */
2647 | '(' .begin_new_placement type_id .finish_new_placement
2651 pedwarn ("ANSI C++ forbids array dimensions with parenthesized type in new");
2652 $$.t = build_parse_node (ARRAY_REF, TREE_VALUE ($3.t), $6);
2653 $$.t = build_decl_list (TREE_PURPOSE ($3.t), $$.t);
2654 $$.new_type_flag = $3.new_type_flag;
2659 /* empty */ %prec EMPTY
2661 | cv_qualifiers CV_QUALIFIER
2662 { $$ = decl_tree_cons (NULL_TREE, $2, $$); }
2665 nonempty_cv_qualifiers:
2667 { $$.t = IDENTIFIER_AS_LIST ($1);
2668 $$.new_type_flag = 0; }
2669 | nonempty_cv_qualifiers CV_QUALIFIER
2670 { $$.t = decl_tree_cons (NULL_TREE, $2, $1.t);
2671 $$.new_type_flag = $1.new_type_flag; }
2674 /* These rules must follow the rules for function declarations
2675 and component declarations. That way, longer rules are preferred. */
2679 { $<itype>$ = suspend_momentary (); }
2681 /* An expression which will not live on the momentary obstack. */
2684 { resume_momentary ((int) $<itype>1); $$ = $2; }
2687 /* An expression which will not live on the momentary obstack. */
2689 suspend_mom '(' nonnull_exprlist ')'
2690 { resume_momentary ((int) $<itype>1); $$ = $3; }
2691 | suspend_mom '(' parmlist ')'
2692 { resume_momentary ((int) $<itype>1); $$ = $3; }
2693 | suspend_mom LEFT_RIGHT
2694 { resume_momentary ((int) $<itype>1); $$ = empty_parms (); }
2695 | suspend_mom '(' error ')'
2696 { resume_momentary ((int) $<itype>1); $$ = NULL_TREE; }
2699 /* A declarator that is allowed only after an explicit typespec. */
2700 /* may all be followed by prec '.' */
2701 after_type_declarator:
2702 '*' nonempty_cv_qualifiers after_type_declarator %prec UNARY
2703 { $$ = make_pointer_declarator ($2.t, $3); }
2704 | '&' nonempty_cv_qualifiers after_type_declarator %prec UNARY
2705 { $$ = make_reference_declarator ($2.t, $3); }
2706 | '*' after_type_declarator %prec UNARY
2707 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2708 | '&' after_type_declarator %prec UNARY
2709 { $$ = make_reference_declarator (NULL_TREE, $2); }
2710 | ptr_to_mem cv_qualifiers after_type_declarator
2711 { tree arg = make_pointer_declarator ($2, $3);
2712 $$ = build_parse_node (SCOPE_REF, $1, arg);
2714 | direct_after_type_declarator
2718 type_name %prec EMPTY
2720 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2722 $$ = lookup_name ($1, 1);
2723 if (current_class_type
2724 && TYPE_BEING_DEFINED (current_class_type)
2725 && ! IDENTIFIER_CLASS_VALUE ($1))
2727 /* Remember that this name has been used in the class
2728 definition, as per [class.scope0] */
2729 pushdecl_class_level ($$);
2735 | global_scope type_name
2737 if (TREE_CODE ($2) == IDENTIFIER_NODE)
2738 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
2741 got_scope = NULL_TREE;
2748 | global_scope nested_type
2753 nested_name_specifier type_name %prec EMPTY
2754 { $$ = get_type_decl ($2); }
2757 direct_after_type_declarator:
2758 direct_after_type_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2759 { $$ = make_call_declarator ($$, $2, $3, $4); }
2760 | direct_after_type_declarator '[' nonmomentary_expr ']'
2761 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
2762 | direct_after_type_declarator '[' ']'
2763 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
2764 | '(' after_type_declarator ')'
2766 | nested_name_specifier type_name %prec EMPTY
2767 { push_nested_class ($1, 3);
2768 $$ = build_parse_node (SCOPE_REF, $$, $2);
2769 TREE_COMPLEXITY ($$) = current_class_depth; }
2770 | type_name %prec EMPTY
2773 /* A declarator allowed whether or not there has been
2774 an explicit typespec. These cannot redeclare a typedef-name. */
2777 '*' nonempty_cv_qualifiers notype_declarator %prec UNARY
2778 { $$ = make_pointer_declarator ($2.t, $3); }
2779 | '&' nonempty_cv_qualifiers notype_declarator %prec UNARY
2780 { $$ = make_reference_declarator ($2.t, $3); }
2781 | '*' notype_declarator %prec UNARY
2782 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2783 | '&' notype_declarator %prec UNARY
2784 { $$ = make_reference_declarator (NULL_TREE, $2); }
2785 | ptr_to_mem cv_qualifiers notype_declarator
2786 { tree arg = make_pointer_declarator ($2, $3);
2787 $$ = build_parse_node (SCOPE_REF, $1, arg);
2789 | direct_notype_declarator
2792 complex_notype_declarator:
2793 '*' nonempty_cv_qualifiers notype_declarator %prec UNARY
2794 { $$ = make_pointer_declarator ($2.t, $3); }
2795 | '&' nonempty_cv_qualifiers notype_declarator %prec UNARY
2796 { $$ = make_reference_declarator ($2.t, $3); }
2797 | '*' complex_notype_declarator %prec UNARY
2798 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2799 | '&' complex_notype_declarator %prec UNARY
2800 { $$ = make_reference_declarator (NULL_TREE, $2); }
2801 | ptr_to_mem cv_qualifiers notype_declarator
2802 { tree arg = make_pointer_declarator ($2, $3);
2803 $$ = build_parse_node (SCOPE_REF, $1, arg);
2805 | complex_direct_notype_declarator
2808 complex_direct_notype_declarator:
2809 direct_notype_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2810 { $$ = make_call_declarator ($$, $2, $3, $4); }
2811 | '(' complex_notype_declarator ')'
2813 | direct_notype_declarator '[' nonmomentary_expr ']'
2814 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
2815 | direct_notype_declarator '[' ']'
2816 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
2817 | notype_qualified_id
2818 { if (TREE_CODE (OP0 ($1)) == NAMESPACE_DECL)
2820 push_decl_namespace (OP0 ($1));
2821 TREE_COMPLEXITY ($1) = -1;
2823 else if (OP0 ($1) != current_class_type)
2825 push_nested_class (OP0 ($1), 3);
2826 TREE_COMPLEXITY ($1) = current_class_depth;
2829 | nested_name_specifier notype_template_declarator
2830 { got_scope = NULL_TREE;
2831 $$ = build_parse_node (SCOPE_REF, $1, $2);
2832 if ($1 != current_class_type)
2834 push_nested_class ($1, 3);
2835 TREE_COMPLEXITY ($$) = current_class_depth;
2841 nested_name_specifier unqualified_id
2842 { got_scope = NULL_TREE;
2843 $$ = build_parse_node (SCOPE_REF, $$, $2); }
2844 | nested_name_specifier object_template_id
2845 { got_scope = NULL_TREE;
2846 $$ = build_parse_node (SCOPE_REF, $1, $2); }
2849 notype_qualified_id:
2850 nested_name_specifier notype_unqualified_id
2851 { got_scope = NULL_TREE;
2852 $$ = build_parse_node (SCOPE_REF, $$, $2); }
2853 | nested_name_specifier object_template_id
2854 { got_scope = NULL_TREE;
2855 $$ = build_parse_node (SCOPE_REF, $1, $2); }
2860 | global_scope notype_qualified_id
2865 typespec '(' nonnull_exprlist ')'
2866 { $$ = build_functional_cast ($1.t, $3); }
2867 | typespec '(' expr_or_declarator ')'
2868 { $$ = reparse_decl_as_expr ($1.t, $3); }
2869 | typespec fcast_or_absdcl %prec EMPTY
2870 { $$ = reparse_absdcl_as_expr ($1.t, $2); }
2876 | template_type %prec EMPTY
2879 nested_name_specifier:
2880 nested_name_specifier_1
2881 | nested_name_specifier nested_name_specifier_1
2883 | nested_name_specifier TEMPLATE explicit_template_type SCOPE
2884 { got_scope = $$ = make_typename_type ($1, $3); }
2887 /* Why the @#$%^& do type_name and notype_identifier need to be expanded
2888 inline here?!? (jason) */
2889 nested_name_specifier_1:
2892 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2895 /* Remember that this name has been used in the class
2896 definition, as per [class.scope0] */
2897 if (current_class_type
2898 && TYPE_BEING_DEFINED (current_class_type)
2899 && ! IDENTIFIER_CLASS_VALUE ($1))
2900 pushdecl_class_level ($$);
2902 got_scope = $$ = TYPE_MAIN_VARIANT (TREE_TYPE ($$));
2906 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2908 got_scope = $$ = TREE_TYPE ($$);
2912 if (TREE_CODE ($$) == IDENTIFIER_NODE)
2916 | template_type SCOPE
2917 { got_scope = $$ = complete_type (TREE_TYPE ($1)); }
2918 /* These break 'const i;'
2922 cp_error ("`%D' is not an aggregate typedef",
2923 lastiddecl ? lastiddecl : $$);
2924 $$ = error_mark_node;
2927 { goto failed_scope; } */
2932 | global_scope typename_sub0
2937 typename_sub1 identifier %prec EMPTY
2939 if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't')
2940 $$ = make_typename_type ($1, $2);
2941 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
2942 cp_error ("`%T' is not a class or namespace", $2);
2946 if (TREE_CODE ($$) == TYPE_DECL)
2947 $$ = TREE_TYPE ($$);
2950 | typename_sub1 template_type %prec EMPTY
2951 { $$ = TREE_TYPE ($2); }
2952 | typename_sub1 explicit_template_type %prec EMPTY
2953 { $$ = make_typename_type ($1, $2); }
2954 | typename_sub1 TEMPLATE explicit_template_type %prec EMPTY
2955 { $$ = make_typename_type ($1, $3); }
2961 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2962 cp_error ("`%T' is not a class or namespace", $1);
2964 | typename_sub1 typename_sub2
2966 if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't')
2967 $$ = make_typename_type ($1, $2);
2968 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
2969 cp_error ("`%T' is not a class or namespace", $2);
2973 if (TREE_CODE ($$) == TYPE_DECL)
2974 $$ = TREE_TYPE ($$);
2977 | typename_sub1 explicit_template_type SCOPE
2978 { got_scope = $$ = make_typename_type ($1, $2); }
2979 | typename_sub1 TEMPLATE explicit_template_type SCOPE
2980 { got_scope = $$ = make_typename_type ($1, $3); }
2986 if (TREE_CODE ($1) != IDENTIFIER_NODE)
2989 /* Retrieve the type for the identifier, which might involve
2990 some computation. */
2991 got_scope = $$ = complete_type (IDENTIFIER_TYPE_VALUE ($1));
2993 if ($$ == error_mark_node)
2994 cp_error ("`%T' is not a class or namespace", $1);
2998 if (TREE_CODE ($1) != IDENTIFIER_NODE)
3000 got_scope = $$ = complete_type (TREE_TYPE ($$));
3002 | template_type SCOPE
3003 { got_scope = $$ = complete_type (TREE_TYPE ($$)); }
3008 if (TREE_CODE ($$) == IDENTIFIER_NODE)
3014 explicit_template_type:
3015 identifier '<' template_arg_list_opt template_close_bracket
3016 { $$ = build_min_nt (TEMPLATE_ID_EXPR, $1, $3); }
3020 global_scope type_name
3022 if (TREE_CODE ($2) == IDENTIFIER_NODE)
3023 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
3026 got_scope = NULL_TREE;
3029 | global_scope nested_type
3034 nested_name_specifier '*'
3035 { got_scope = NULL_TREE; }
3036 | global_scope nested_name_specifier '*'
3037 { $$ = $2; got_scope = NULL_TREE; }
3040 /* All uses of explicit global scope must go through this nonterminal so
3041 that got_scope will be set before yylex is called to get the next token. */
3044 { got_scope = void_type_node; }
3047 /* ANSI new-declarator (5.3.4) */
3049 '*' cv_qualifiers new_declarator
3050 { $$ = make_pointer_declarator ($2, $3); }
3051 | '*' cv_qualifiers %prec EMPTY
3052 { $$ = make_pointer_declarator ($2, NULL_TREE); }
3053 | '&' cv_qualifiers new_declarator %prec EMPTY
3054 { $$ = make_reference_declarator ($2, $3); }
3055 | '&' cv_qualifiers %prec EMPTY
3056 { $$ = make_reference_declarator ($2, NULL_TREE); }
3057 | ptr_to_mem cv_qualifiers %prec EMPTY
3058 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3059 $$ = build_parse_node (SCOPE_REF, $1, arg);
3061 | ptr_to_mem cv_qualifiers new_declarator
3062 { tree arg = make_pointer_declarator ($2, $3);
3063 $$ = build_parse_node (SCOPE_REF, $1, arg);
3065 | direct_new_declarator %prec EMPTY
3068 /* ANSI direct-new-declarator (5.3.4) */
3069 direct_new_declarator:
3071 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3072 | direct_new_declarator '[' nonmomentary_expr ']'
3073 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3076 /* ANSI abstract-declarator (8.1) */
3078 '*' nonempty_cv_qualifiers absdcl
3079 { $$ = make_pointer_declarator ($2.t, $3); }
3081 { $$ = make_pointer_declarator (NULL_TREE, $2); }
3082 | '*' nonempty_cv_qualifiers %prec EMPTY
3083 { $$ = make_pointer_declarator ($2.t, NULL_TREE); }
3085 { $$ = make_pointer_declarator (NULL_TREE, NULL_TREE); }
3086 | '&' nonempty_cv_qualifiers absdcl
3087 { $$ = make_reference_declarator ($2.t, $3); }
3089 { $$ = make_reference_declarator (NULL_TREE, $2); }
3090 | '&' nonempty_cv_qualifiers %prec EMPTY
3091 { $$ = make_reference_declarator ($2.t, NULL_TREE); }
3093 { $$ = make_reference_declarator (NULL_TREE, NULL_TREE); }
3094 | ptr_to_mem cv_qualifiers %prec EMPTY
3095 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3096 $$ = build_parse_node (SCOPE_REF, $1, arg);
3098 | ptr_to_mem cv_qualifiers absdcl
3099 { tree arg = make_pointer_declarator ($2, $3);
3100 $$ = build_parse_node (SCOPE_REF, $1, arg);
3102 | direct_abstract_declarator %prec EMPTY
3105 /* ANSI direct-abstract-declarator (8.1) */
3106 direct_abstract_declarator:
3109 /* `(typedef)1' is `int'. */
3111 | direct_abstract_declarator '(' parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3112 { $$ = make_call_declarator ($$, $3, $5, $6); }
3113 | direct_abstract_declarator LEFT_RIGHT cv_qualifiers exception_specification_opt %prec '.'
3114 { $$ = make_call_declarator ($$, empty_parms (), $3, $4); }
3115 | direct_abstract_declarator '[' nonmomentary_expr ']' %prec '.'
3116 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3117 | direct_abstract_declarator '[' ']' %prec '.'
3118 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
3119 | '(' complex_parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3120 { $$ = make_call_declarator (NULL_TREE, $2, $4, $5); }
3121 | regcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3122 { set_quals_and_spec ($$, $2, $3); }
3123 | fcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3124 { set_quals_and_spec ($$, $2, $3); }
3125 | '[' nonmomentary_expr ']' %prec '.'
3126 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3128 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, NULL_TREE); }
3131 /* For C++, decls and stmts can be intermixed, so we don't need to
3132 have a special rule that won't start parsing the stmt section
3133 until we have a stmt that parses without errors. */
3146 /* Read zero or more forward-declarations for labels
3147 that nested functions can jump to. */
3152 pedwarn ("ANSI C++ forbids label declarations"); }
3157 | label_decls label_decl
3161 LABEL identifiers_or_typenames ';'
3163 for (link = $2; link; link = TREE_CHAIN (link))
3165 tree label = shadow_label (TREE_VALUE (link));
3166 C_DECLARED_LABEL_FLAG (label) = 1;
3167 declare_nonlocal_label (label);
3172 /* This is the body of a function definition.
3173 It causes syntax errors to ignore to the next openbrace. */
3182 { $<ttype>$ = begin_compound_stmt (0); }
3184 { $$ = finish_compound_stmt (0, $<ttype>2); }
3190 $<ttype>$ = begin_if_stmt ();
3191 cond_stmt_keyword = "if";
3194 { finish_if_stmt_cond ($3, $<ttype>2); }
3195 implicitly_scoped_stmt
3196 { $<ttype>$ = finish_then_clause ($<ttype>2); }
3199 implicitly_scoped_stmt:
3201 | { $<ttype>$ = begin_compound_stmt (0); }
3203 { $$ = finish_compound_stmt (0, $<ttype>1); }
3216 { finish_expr_stmt ($1); }
3218 { begin_else_clause (); }
3219 implicitly_scoped_stmt
3221 finish_else_clause ($<ttype>1);
3224 | simple_if %prec IF
3225 { finish_if_stmt (); }
3228 $<ttype>$ = begin_while_stmt ();
3229 cond_stmt_keyword = "while";
3232 { finish_while_stmt_cond ($3, $<ttype>2); }
3234 { finish_while_stmt ($<ttype>2); }
3236 { $<ttype>$ = begin_do_stmt (); }
3237 implicitly_scoped_stmt WHILE
3239 finish_do_body ($<ttype>2);
3240 cond_stmt_keyword = "do";
3242 paren_expr_or_null ';'
3243 { finish_do_stmt ($6, $<ttype>2); }
3245 { $<ttype>$ = begin_for_stmt (); }
3246 '(' for.init.statement
3247 { finish_for_init_stmt ($<ttype>2); }
3249 { finish_for_cond ($6, $<ttype>2); }
3251 { finish_for_expr ($9, $<ttype>2); }
3253 { finish_for_stmt ($9, $<ttype>2); }
3255 { begin_switch_stmt (); }
3257 { $<ttype>$ = finish_switch_cond ($4); }
3258 implicitly_scoped_stmt
3259 { finish_switch_stmt ($4, $<ttype>6); }
3260 | CASE expr_no_commas ':'
3261 { finish_case_label ($2, NULL_TREE); }
3263 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
3264 { finish_case_label ($2, $4); }
3267 { finish_case_label (NULL_TREE, NULL_TREE); }
3270 { finish_break_stmt (); }
3272 { finish_continue_stmt (); }
3274 { finish_return_stmt (NULL_TREE); }
3276 { finish_return_stmt ($2); }
3277 | asm_keyword maybe_cv_qualifier '(' string ')' ';'
3279 finish_asm_stmt ($2, $4, NULL_TREE, NULL_TREE,
3282 /* This is the case with just output operands. */
3283 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ')' ';'
3285 finish_asm_stmt ($2, $4, $6, NULL_TREE,
3288 /* This is the case with input operands as well. */
3289 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':' asm_operands ')' ';'
3290 { finish_asm_stmt ($2, $4, $6, $8, NULL_TREE); }
3291 /* This is the case with clobbered registers as well. */
3292 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':'
3293 asm_operands ':' asm_clobbers ')' ';'
3294 { finish_asm_stmt ($2, $4, $6, $8, $10); }
3298 pedwarn ("ANSI C++ forbids computed gotos");
3299 finish_goto_stmt ($3);
3301 | GOTO identifier ';'
3302 { finish_goto_stmt ($2); }
3306 { error ("label must be followed by statement");
3313 | namespace_using_decl
3314 { do_local_using_decl ($1); }
3321 if (! current_function_parms_stored)
3322 store_parm_decls ();
3323 expand_start_early_try_stmts ();
3325 ctor_initializer_opt compstmt
3327 expand_start_all_catch ();
3331 int nested = (hack_decl_function_context
3332 (current_function_decl) != NULL_TREE);
3333 expand_end_all_catch ();
3334 finish_function (lineno, (int)$3, nested);
3340 { $<ttype>$ = begin_try_block (); }
3342 { finish_try_block ($<ttype>2); }
3344 { finish_handler_sequence ($<ttype>2); }
3349 | handler_seq handler
3354 { $<ttype>$ = begin_handler(); }
3356 { finish_handler_parms ($<ttype>2); }
3358 { finish_handler ($<ttype>2); }
3362 typed_typespecs %prec EMPTY
3363 | nonempty_cv_qualifiers %prec EMPTY
3368 { expand_start_catch_block (NULL_TREE, NULL_TREE); }
3369 /* This doesn't allow reference parameters, the below does.
3370 | '(' type_specifier_seq absdcl ')'
3371 { check_for_new_type ("inside exception declarations", $2);
3372 expand_start_catch_block ($2.t, $3); }
3373 | '(' type_specifier_seq ')'
3374 { check_for_new_type ("inside exception declarations", $2);
3375 expand_start_catch_block ($2.t, NULL_TREE); }
3376 | '(' type_specifier_seq notype_declarator ')'
3377 { check_for_new_type ("inside exception declarations", $2);
3378 expand_start_catch_block ($2.t, $3); }
3379 | '(' typed_typespecs after_type_declarator ')'
3380 { check_for_new_type ("inside exception declarations", $2);
3381 expand_start_catch_block ($2.t, $3); }
3382 This allows reference parameters... */
3384 { check_for_new_type ("inside exception declarations", $2);
3385 expand_start_catch_block (TREE_PURPOSE ($2.t),
3386 TREE_VALUE ($2.t)); }
3393 label = define_label (input_filename, lineno, $1);
3394 if (label && ! minimal_parse_mode)
3395 expand_label (label);
3407 { if ($1) cplus_expand_expr_stmt ($1); }
3411 pedwarn ("ANSI C++ forbids compound statements inside for initializations");
3415 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
3419 { emit_line_note (input_filename, lineno);
3422 { emit_line_note (input_filename, lineno); }
3433 /* These are the operands other than the first string and colon
3434 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
3438 | nonnull_asm_operands
3441 nonnull_asm_operands:
3443 | nonnull_asm_operands ',' asm_operand
3444 { $$ = chainon ($$, $3); }
3449 { $$ = build_tree_list ($$, $3); }
3454 { $$ = tree_cons (NULL_TREE, $$, NULL_TREE); }
3455 | asm_clobbers ',' STRING
3456 { $$ = tree_cons (NULL_TREE, $3, $$); }
3459 /* This is what appears inside the parens in a function declarator.
3460 Its value is represented in the format that grokdeclarator expects.
3462 In C++, declaring a function with no parameters
3463 means that that function takes *no* parameters. */
3472 { $$ = finish_parmlist (build_tree_list (NULL_TREE, $1.t), 0);
3473 check_for_new_type ("inside parameter list", $1); }
3476 /* This nonterminal does not include the common sequence '(' type_id ')',
3477 as it is ambiguous and must be disambiguated elsewhere. */
3480 { $$ = finish_parmlist ($$, 0); }
3481 | parms_comma ELLIPSIS
3482 { $$ = finish_parmlist ($1, 1); }
3483 /* C++ allows an ellipsis without a separating ',' */
3485 { $$ = finish_parmlist ($1, 1); }
3487 { $$ = finish_parmlist (build_tree_list (NULL_TREE,
3490 { $$ = finish_parmlist (NULL_TREE, 1); }
3493 /* This helps us recover from really nasty
3494 parse errors, for example, a missing right
3496 yyerror ("possibly missing ')'");
3497 $$ = finish_parmlist ($1, 0);
3503 /* This helps us recover from really nasty
3504 parse errors, for example, a missing right
3506 yyerror ("possibly missing ')'");
3507 $$ = finish_parmlist (build_tree_list (NULL_TREE,
3514 /* A default argument to a */
3517 { maybe_snarf_defarg (); }
3527 /* A nonempty list of parameter declarations or type names. */
3530 { check_for_new_type ("in a parameter list", $1);
3531 $$ = build_tree_list (NULL_TREE, $1.t); }
3533 { check_for_new_type ("in a parameter list", $1);
3534 $$ = build_tree_list ($2, $1.t); }
3535 | parms_comma full_parm
3536 { check_for_new_type ("in a parameter list", $2);
3537 $$ = chainon ($$, $2.t); }
3538 | parms_comma bad_parm
3539 { $$ = chainon ($$, build_tree_list (NULL_TREE, $2)); }
3540 | parms_comma bad_parm '=' init
3541 { $$ = chainon ($$, build_tree_list ($4, $2)); }
3547 { check_for_new_type ("in a parameter list", $1);
3548 $$ = build_tree_list (NULL_TREE, $1.t); }
3551 /* A single parameter declaration or parameter type name,
3552 as found in a parmlist. */
3554 /* Here we expand typed_declspecs inline to avoid mis-parsing of
3555 TYPESPEC IDENTIFIER. */
3556 typed_declspecs1 declarator
3557 { tree specs = strip_attrs ($1.t);
3558 $$.new_type_flag = $1.new_type_flag;
3559 $$.t = build_tree_list (specs, $2); }
3560 | typed_typespecs declarator
3561 { $$.t = build_tree_list ($1.t, $2);
3562 $$.new_type_flag = $1.new_type_flag; }
3563 | typespec declarator
3564 { $$.t = build_tree_list (get_decl_list ($1.t), $2);
3565 $$.new_type_flag = $1.new_type_flag; }
3566 | typed_declspecs1 absdcl
3567 { tree specs = strip_attrs ($1.t);
3568 $$.t = build_tree_list (specs, $2);
3569 $$.new_type_flag = $1.new_type_flag; }
3570 | typed_declspecs1 %prec EMPTY
3571 { tree specs = strip_attrs ($1.t);
3572 $$.t = build_tree_list (specs, NULL_TREE);
3573 $$.new_type_flag = $1.new_type_flag; }
3574 | declmods notype_declarator
3575 { tree specs = strip_attrs ($1);
3576 $$.t = build_tree_list (specs, $2);
3577 $$.new_type_flag = 0; }
3582 { $$.t = build_tree_list (NULL_TREE, $1.t);
3583 $$.new_type_flag = $1.new_type_flag; }
3585 { $$.t = build_tree_list ($2, $1.t);
3586 $$.new_type_flag = $1.new_type_flag; }
3595 /* empty */ %prec EMPTY
3596 { see_typename (); }
3600 /* empty */ %prec EMPTY
3602 error ("type specifier omitted for parameter");
3603 $$ = build_tree_list (integer_type_node, NULL_TREE);
3607 error ("type specifier omitted for parameter");
3608 if (TREE_CODE ($$) == SCOPE_REF
3609 && (TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TYPE_PARM
3610 || TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TEMPLATE_PARM))
3611 cp_error (" perhaps you want `typename %E' to make it a type", $$);
3612 $$ = build_tree_list (integer_type_node, $$);
3616 exception_specification_opt:
3617 /* empty */ %prec EMPTY
3619 | THROW '(' ansi_raise_identifiers ')' %prec EMPTY
3621 | THROW LEFT_RIGHT %prec EMPTY
3622 { $$ = build_decl_list (NULL_TREE, NULL_TREE); }
3625 ansi_raise_identifier:
3627 { $$ = build_decl_list (NULL_TREE, groktypename($1.t)); }
3630 ansi_raise_identifiers:
3631 ansi_raise_identifier
3632 | ansi_raise_identifiers ',' ansi_raise_identifier
3634 TREE_CHAIN ($3) = $$;
3639 conversion_declarator:
3640 /* empty */ %prec EMPTY
3642 | '*' cv_qualifiers conversion_declarator
3643 { $$ = make_pointer_declarator ($2, $3); }
3644 | '&' cv_qualifiers conversion_declarator
3645 { $$ = make_reference_declarator ($2, $3); }
3646 | ptr_to_mem cv_qualifiers conversion_declarator
3647 { tree arg = make_pointer_declarator ($2, $3);
3648 $$ = build_parse_node (SCOPE_REF, $1, arg);
3654 { got_scope = NULL_TREE; }
3659 { $$ = ansi_opname[MULT_EXPR]; }
3661 { $$ = ansi_opname[TRUNC_DIV_EXPR]; }
3663 { $$ = ansi_opname[TRUNC_MOD_EXPR]; }
3665 { $$ = ansi_opname[PLUS_EXPR]; }
3667 { $$ = ansi_opname[MINUS_EXPR]; }
3669 { $$ = ansi_opname[BIT_AND_EXPR]; }
3671 { $$ = ansi_opname[BIT_IOR_EXPR]; }
3673 { $$ = ansi_opname[BIT_XOR_EXPR]; }
3675 { $$ = ansi_opname[BIT_NOT_EXPR]; }
3677 { $$ = ansi_opname[COMPOUND_EXPR]; }
3678 | operator ARITHCOMPARE
3679 { $$ = ansi_opname[$2]; }
3681 { $$ = ansi_opname[LT_EXPR]; }
3683 { $$ = ansi_opname[GT_EXPR]; }
3684 | operator EQCOMPARE
3685 { $$ = ansi_opname[$2]; }
3687 { $$ = ansi_assopname[$2]; }
3689 { $$ = ansi_opname [MODIFY_EXPR]; }
3691 { $$ = ansi_opname[$2]; }
3693 { $$ = ansi_opname[$2]; }
3695 { $$ = ansi_opname[POSTINCREMENT_EXPR]; }
3696 | operator MINUSMINUS
3697 { $$ = ansi_opname[PREDECREMENT_EXPR]; }
3699 { $$ = ansi_opname[TRUTH_ANDIF_EXPR]; }
3701 { $$ = ansi_opname[TRUTH_ORIF_EXPR]; }
3703 { $$ = ansi_opname[TRUTH_NOT_EXPR]; }
3705 { $$ = ansi_opname[COND_EXPR]; }
3707 { $$ = ansi_opname[$2]; }
3708 | operator POINTSAT %prec EMPTY
3709 { $$ = ansi_opname[COMPONENT_REF]; }
3710 | operator POINTSAT_STAR %prec EMPTY
3711 { $$ = ansi_opname[MEMBER_REF]; }
3712 | operator LEFT_RIGHT
3713 { $$ = ansi_opname[CALL_EXPR]; }
3715 { $$ = ansi_opname[ARRAY_REF]; }
3716 | operator NEW %prec EMPTY
3717 { $$ = ansi_opname[NEW_EXPR]; }
3718 | operator DELETE %prec EMPTY
3719 { $$ = ansi_opname[DELETE_EXPR]; }
3720 | operator NEW '[' ']'
3721 { $$ = ansi_opname[VEC_NEW_EXPR]; }
3722 | operator DELETE '[' ']'
3723 { $$ = ansi_opname[VEC_DELETE_EXPR]; }
3724 /* Names here should be looked up in class scope ALSO. */
3725 | operator type_specifier_seq conversion_declarator
3726 { $$ = grokoptypename ($2.t, $3); }
3728 { $$ = ansi_opname[ERROR_MARK]; }
3735 debug_yytranslate (value)
3738 return yytname[YYTRANSLATE (value)];