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
207 %type <itype> components notype_components
208 %type <ttype> component_decl component_decl_1
209 %type <ttype> component_declarator component_declarator0
210 %type <ttype> notype_component_declarator notype_component_declarator0
211 %type <ttype> after_type_component_declarator after_type_component_declarator0
212 %type <ttype> enumlist enumerator
213 %type <ttype> absdcl cv_qualifiers
214 %type <ttype> direct_abstract_declarator conversion_declarator
215 %type <ttype> new_declarator direct_new_declarator
216 %type <ttype> xexpr parmlist parms bad_parm
217 %type <ttype> identifiers_or_typenames
218 %type <ttype> fcast_or_absdcl regcast_or_absdcl
219 %type <ttype> expr_or_declarator complex_notype_declarator
220 %type <ttype> notype_unqualified_id unqualified_id qualified_id
221 %type <ttype> template_id do_id object_template_id notype_template_declarator
222 %type <ttype> overqualified_id notype_qualified_id any_id
223 %type <ttype> complex_direct_notype_declarator functional_cast
224 %type <ttype> complex_parmlist parms_comma
225 %type <ttype> namespace_qualifier namespace_using_decl
227 %type <ftype> type_id new_type_id typed_typespecs typespec typed_declspecs
228 %type <ftype> typed_declspecs1 type_specifier_seq nonempty_cv_qualifiers
229 %type <ftype> structsp typespecqual_reserved parm named_parm full_parm
232 %token <ttype> PTYPENAME
233 %token <ttype> PRE_PARSED_FUNCTION_DECL EXTERN_LANG_STRING ALL
234 %token <ttype> PRE_PARSED_CLASS_DECL DEFARG DEFARG_MARKER
235 %type <ttype> component_constructor_declarator
236 %type <ttype> fn.def2 return_id fn.defpen constructor_declarator
237 %type <itype> ctor_initializer_opt
238 %type <ttype> named_class_head named_class_head_sans_basetype
239 %type <ttype> named_complex_class_head_sans_basetype
240 %type <ttype> unnamed_class_head
241 %type <ttype> class_head base_class_list
242 %type <ttype> base_class_access_list
243 %type <ttype> base_class maybe_base_class_list base_class.1
244 %type <ttype> exception_specification_opt ansi_raise_identifier ansi_raise_identifiers
245 %type <ttype> operator_name
246 %type <ttype> object aggr
247 %type <itype> new delete .begin_new_placement
248 /* %type <ttype> primary_no_id */
249 %type <ttype> nonmomentary_expr maybe_parmlist
250 %type <itype> initdcl0 notype_initdcl0 member_init_list initdcl0_innards
251 %type <ttype> template_header template_parm_list template_parm
252 %type <ttype> template_type_parm template_template_parm
253 %type <code> template_close_bracket
254 %type <ttype> template_type template_arg_list template_arg_list_opt
255 %type <ttype> template_arg
256 %type <ttype> condition xcond paren_cond_or_null
257 %type <ttype> type_name nested_name_specifier nested_type ptr_to_mem
258 %type <ttype> complete_type_name notype_identifier nonnested_type
259 %type <ttype> complex_type_name nested_name_specifier_1
260 %type <ttype> new_initializer new_placement
261 %type <ttype> using_decl
262 %type <ttype> typename_sub typename_sub0 typename_sub1 typename_sub2
263 %type <ttype> explicit_template_type
264 /* in order to recognize aggr tags as defining and thus shadowing. */
265 %token TYPENAME_DEFN IDENTIFIER_DEFN PTYPENAME_DEFN
266 %type <ttype> named_class_head_sans_basetype_defn
267 %type <ttype> identifier_defn IDENTIFIER_DEFN TYPENAME_DEFN PTYPENAME_DEFN
269 %type <ttype> self_template_type .finish_template_type
274 /* Used in lex.c for parsing pragmas. */
277 /* lex.c and pt.c depend on this being the last token. Define
278 any new tokens before this one! */
279 %token END_OF_SAVED_INPUT
282 /* List of types and structure classes of the current declaration. */
283 static tree current_declspecs;
285 /* List of prefix attributes in effect.
286 Prefix attributes are parsed by the reserved_declspecs and declmods
287 rules. They create a list that contains *both* declspecs and attrs. */
288 /* ??? It is not clear yet that all cases where an attribute can now appear in
289 a declspec list have been updated. */
290 static tree prefix_attributes;
292 /* When defining an aggregate, this is the kind of the most recent one
293 being defined. (For example, this might be class_type_node.) */
294 static tree current_aggr;
296 /* When defining an enumeration, this is the type of the enumeration. */
297 static tree current_enum_type;
299 /* Tell yyparse how to print a token's value, if yydebug is set. */
301 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
302 extern void yyprint PROTO((FILE *, int, YYSTYPE));
303 extern tree combine_strings PROTO((tree));
306 parse_decl(declarator, specs_attrs, attributes, initialized, decl)
315 split_specs_attrs (specs_attrs, ¤t_declspecs, &prefix_attributes);
316 if (current_declspecs
317 && TREE_CODE (current_declspecs) != TREE_LIST)
318 current_declspecs = get_decl_list (current_declspecs);
319 if (have_extern_spec && !used_extern_spec)
321 current_declspecs = decl_tree_cons (NULL_TREE,
322 get_identifier ("extern"),
324 used_extern_spec = 1;
326 sm = suspend_momentary ();
327 *decl = start_decl (declarator, current_declspecs, initialized,
328 attributes, prefix_attributes);
337 { finish_translation_unit (); }
340 /* the reason for the strange actions in this rule
341 is so that notype_initdecls when reached via datadef
342 can find a valid list of type and sc specs in $0. */
345 { $<ttype>$ = NULL_TREE; }
347 { $<ttype>$ = NULL_TREE; }
348 | extdefs lang_extdef
349 { $<ttype>$ = NULL_TREE; }
358 { have_extern_spec = 1;
359 used_extern_spec = 0;
360 $<ttype>$ = NULL_TREE; }
363 { have_extern_spec = 0; }
368 { $<itype>$ = pedantic;
377 { if (pending_lang_change) do_pending_lang_change(); }
379 { if (! toplevel_bindings_p () && ! pseudo_global_level_p())
384 fndef eat_saved_input
385 { if (pending_inlines) do_pending_inlines (); }
387 { if (pending_inlines) do_pending_inlines (); }
389 { if (pending_inlines) do_pending_inlines (); }
390 | asm_keyword '(' string ')' ';'
391 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
393 | extern_lang_string '{' extdefs_opt '}'
394 { pop_lang_context (); }
395 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
396 { if (pending_inlines) do_pending_inlines ();
397 pop_lang_context (); }
398 | extern_lang_string .hush_warning datadef .warning_ok
399 { if (pending_inlines) do_pending_inlines ();
400 pop_lang_context (); }
401 | NAMESPACE identifier '{'
402 { push_namespace ($2); }
404 { pop_namespace (); }
406 { push_namespace (NULL_TREE); }
408 { pop_namespace (); }
411 { do_toplevel_using_decl ($1); }
414 { pedantic = $<itype>1; }
418 NAMESPACE identifier '='
419 { begin_only_namespace_names (); }
422 end_only_namespace_names ();
425 do_namespace_alias ($2, $5);
432 | USING global_scope qualified_id
434 | USING global_scope unqualified_id
438 namespace_using_decl:
439 USING namespace_qualifier identifier
440 { $$ = build_parse_node (SCOPE_REF, $2, $3); }
441 | USING global_scope identifier
442 { $$ = build_parse_node (SCOPE_REF, global_namespace, $3); }
443 | USING global_scope namespace_qualifier identifier
444 { $$ = build_parse_node (SCOPE_REF, $3, $4); }
449 { begin_only_namespace_names (); }
452 end_only_namespace_names ();
453 /* If no declaration was found, the using-directive is
454 invalid. Since that was not reported, we need the
455 identifier for the error message. */
456 if (TREE_CODE ($4) == IDENTIFIER_NODE && lastiddecl)
458 do_using_directive ($4);
465 if (TREE_CODE ($$) == IDENTIFIER_NODE)
469 | namespace_qualifier NSNAME SCOPE
472 if (TREE_CODE ($$) == IDENTIFIER_NODE)
480 | global_scope qualified_id
482 | global_scope unqualified_id
488 { push_lang_context ($1); }
489 | extern_lang_string EXTERN_LANG_STRING
490 { if (current_lang_name != $2)
491 cp_error ("use of linkage spec `%D' is different from previous spec `%D'", $2, current_lang_name);
492 pop_lang_context (); push_lang_context ($2); }
497 { begin_template_parm_list (); }
498 template_parm_list '>'
499 { $$ = end_template_parm_list ($4); }
501 { begin_specialization();
507 { $$ = process_template_parm (NULL_TREE, $1); }
508 | template_parm_list ',' template_parm
509 { $$ = process_template_parm ($1, $3); }
519 aggr maybe_identifier
520 { $$ = finish_template_type_parm ($1, $2); }
521 | TYPENAME_KEYWORD maybe_identifier
522 { $$ = finish_template_type_parm (class_type_node, $2); }
525 template_template_parm:
526 template_header aggr maybe_identifier
527 { $$ = finish_template_template_parm ($2, $3); }
531 /* The following rules introduce a new reduce/reduce
532 conflict on the ',' and '>' input tokens: they are valid
533 prefixes for a `structsp', which means they could match a
534 nameless parameter. See 14.6, paragraph 3.
535 By putting them before the `parm' rule, we get
536 their match before considering them nameless parameter
539 { $$ = build_tree_list (NULL_TREE, $1); }
540 | template_type_parm '=' type_id
541 { $$ = build_tree_list (groktypename ($3.t), $1); }
543 { $$ = build_tree_list (NULL_TREE, $1.t); }
544 | parm '=' expr_no_commas %prec ARITHCOMPARE
545 { $$ = build_tree_list ($3, $1.t); }
546 | template_template_parm
547 { $$ = build_tree_list (NULL_TREE, $1); }
548 | template_template_parm '=' template_arg
550 if (TREE_CODE ($3) != TEMPLATE_DECL
551 && TREE_CODE ($3) != TEMPLATE_TEMPLATE_PARM
552 && TREE_CODE ($3) != TYPE_DECL)
554 error ("invalid default template argument");
555 $3 = error_mark_node;
557 $$ = build_tree_list ($3, $1);
562 template_header template_extdef
563 { finish_template_decl ($1); }
564 | template_header error %prec EMPTY
565 { finish_template_decl ($1); }
569 fndef eat_saved_input
570 { if (pending_inlines) do_pending_inlines (); }
572 { if (pending_inlines) do_pending_inlines (); }
574 { if (pending_inlines) do_pending_inlines (); }
575 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
576 { if (pending_inlines) do_pending_inlines ();
577 pop_lang_context (); }
578 | extern_lang_string .hush_warning template_datadef .warning_ok
579 { if (pending_inlines) do_pending_inlines ();
580 pop_lang_context (); }
581 | extension template_extdef
582 { pedantic = $<itype>1; }
587 | declmods notype_initdecls ';'
589 | typed_declspecs initdecls ';'
590 { note_list_got_semicolon ($1.t); }
592 { maybe_process_partial_specialization ($1.t);
593 note_got_semicolon ($1.t); }
598 | declmods notype_initdecls ';'
600 | typed_declspecs initdecls ';'
601 { note_list_got_semicolon ($1.t); }
603 { pedwarn ("empty declaration"); }
604 | explicit_instantiation ';'
605 | typed_declspecs ';'
608 split_specs_attrs ($1.t, &t, &attrs);
610 note_list_got_semicolon ($1.t);
617 ctor_initializer_opt:
636 fn.def1 maybe_return_init ctor_initializer_opt compstmt_or_error
637 { finish_function (lineno, (int)$3, 0); }
638 | fn.def1 maybe_return_init function_try_block
640 | fn.def1 maybe_return_init error
644 constructor_declarator:
645 nested_name_specifier SELFNAME '('
646 { $$ = begin_constructor_declarator ($1, $2); }
647 parmlist ')' cv_qualifiers exception_specification_opt
648 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
649 | nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
650 { $$ = begin_constructor_declarator ($1, $2);
651 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
653 | global_scope nested_name_specifier SELFNAME '('
654 { $$ = begin_constructor_declarator ($2, $3); }
655 parmlist ')' cv_qualifiers exception_specification_opt
656 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
657 | global_scope nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
658 { $$ = begin_constructor_declarator ($2, $3);
659 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
661 | nested_name_specifier self_template_type '('
662 { $$ = begin_constructor_declarator ($1, $2); }
663 parmlist ')' cv_qualifiers exception_specification_opt
664 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
665 | nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
666 { $$ = begin_constructor_declarator ($1, $2);
667 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
669 | global_scope nested_name_specifier self_template_type '('
670 { $$ = begin_constructor_declarator ($2, $3); }
671 parmlist ')' cv_qualifiers exception_specification_opt
672 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
673 | global_scope nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
674 { $$ = begin_constructor_declarator ($2, $3);
675 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
680 typed_declspecs declarator
681 { if (!begin_function_definition ($1.t, $2))
683 | declmods notype_declarator
684 { if (!begin_function_definition ($1, $2))
687 { if (!begin_function_definition (NULL_TREE, $1))
689 | declmods constructor_declarator
690 { if (!begin_function_definition ($1, $2))
692 | constructor_declarator
693 { if (!begin_function_definition (NULL_TREE, $1))
697 component_constructor_declarator:
698 SELFNAME '(' parmlist ')' cv_qualifiers exception_specification_opt
699 { $$ = make_call_declarator ($1, $3, $5, $6); }
700 | SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
701 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
702 | self_template_type '(' parmlist ')' cv_qualifiers exception_specification_opt
703 { $$ = make_call_declarator ($1, $3, $5, $6); }
704 | self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
705 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
708 /* more C++ complexity. See component_decl for a comment on the
709 reduce/reduce conflict introduced by these rules. */
711 declmods component_constructor_declarator
712 { tree specs = strip_attrs ($1);
713 $$ = start_method (specs, $2);
717 if (yychar == YYEMPTY)
719 reinit_parse_for_method (yychar, $$); }
720 | component_constructor_declarator
721 { $$ = start_method (NULL_TREE, $1); goto rest_of_mdef; }
722 | typed_declspecs declarator
723 { tree specs = strip_attrs ($1.t);
724 $$ = start_method (specs, $2); goto rest_of_mdef; }
725 | declmods notype_declarator
726 { tree specs = strip_attrs ($1);
727 $$ = start_method (specs, $2); goto rest_of_mdef; }
729 { $$ = start_method (NULL_TREE, $$); goto rest_of_mdef; }
730 | declmods constructor_declarator
731 { tree specs = strip_attrs ($1);
732 $$ = start_method (specs, $2); goto rest_of_mdef; }
733 | constructor_declarator
734 { $$ = start_method (NULL_TREE, $$); goto rest_of_mdef; }
740 if (! current_function_parms_stored)
748 { store_return_init ($<ttype>$, $2); }
749 | return_id '(' nonnull_exprlist ')'
750 { store_return_init ($<ttype>$, $3); }
751 | return_id LEFT_RIGHT
752 { store_return_init ($<ttype>$, NULL_TREE); }
756 ':' .set_base_init member_init_list
759 error ("no base initializers given following ':'");
761 /* Always keep the BLOCK node associated with the outermost
762 pair of curley braces of a function. These are needed
763 for correct operation of dwarfout.c. */
771 if (! current_function_parms_stored)
774 if (DECL_CONSTRUCTOR_P (current_function_decl))
776 /* Make a contour for the initializer list. */
779 expand_start_bindings (0);
781 else if (current_class_type == NULL_TREE)
782 error ("base initializers not allowed for non-member functions");
783 else if (! DECL_CONSTRUCTOR_P (current_function_decl))
784 error ("only constructors take base initializers");
793 | member_init_list ',' member_init
794 | member_init_list error
798 '(' nonnull_exprlist ')'
800 if (current_class_name)
801 pedwarn ("anachronistic old style base class initializer");
802 expand_member_init (current_class_ref, NULL_TREE, $2);
806 if (current_class_name)
807 pedwarn ("anachronistic old style base class initializer");
808 expand_member_init (current_class_ref, NULL_TREE, void_type_node);
810 | notype_identifier '(' nonnull_exprlist ')'
811 { expand_member_init (current_class_ref, $1, $3); }
812 | notype_identifier LEFT_RIGHT
813 { expand_member_init (current_class_ref, $1, void_type_node); }
814 | nonnested_type '(' nonnull_exprlist ')'
815 { expand_member_init (current_class_ref, $1, $3); }
816 | nonnested_type LEFT_RIGHT
817 { expand_member_init (current_class_ref, $1, void_type_node); }
818 | typename_sub '(' nonnull_exprlist ')'
819 { expand_member_init (current_class_ref, TYPE_MAIN_DECL ($1),
821 | typename_sub LEFT_RIGHT
822 { expand_member_init (current_class_ref, TYPE_MAIN_DECL ($1),
846 explicit_instantiation:
847 TEMPLATE begin_explicit_instantiation typespec ';'
848 { do_type_instantiation ($3.t, NULL_TREE);
850 end_explicit_instantiation
851 | TEMPLATE begin_explicit_instantiation typed_declspecs declarator
852 { tree specs = strip_attrs ($3.t);
853 do_decl_instantiation (specs, $4, NULL_TREE); }
854 end_explicit_instantiation
855 | TEMPLATE begin_explicit_instantiation notype_declarator
856 { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
857 end_explicit_instantiation
858 | TEMPLATE begin_explicit_instantiation constructor_declarator
859 { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
860 end_explicit_instantiation
861 | SCSPEC TEMPLATE begin_explicit_instantiation typespec ';'
862 { do_type_instantiation ($4.t, $1);
864 end_explicit_instantiation
865 | SCSPEC TEMPLATE begin_explicit_instantiation typed_declspecs
867 { tree specs = strip_attrs ($4.t);
868 do_decl_instantiation (specs, $5, $1); }
869 end_explicit_instantiation
870 | SCSPEC TEMPLATE begin_explicit_instantiation notype_declarator
871 { do_decl_instantiation (NULL_TREE, $4, $1); }
872 end_explicit_instantiation
873 | SCSPEC TEMPLATE begin_explicit_instantiation constructor_declarator
874 { do_decl_instantiation (NULL_TREE, $4, $1); }
875 end_explicit_instantiation
878 begin_explicit_instantiation:
879 { begin_explicit_instantiation(); }
881 end_explicit_instantiation:
882 { end_explicit_instantiation(); }
884 /* The TYPENAME expansions are to deal with use of a template class name as
885 a template within the class itself, where the template decl is hidden by
886 a type decl. Got all that? */
889 PTYPENAME '<' template_arg_list_opt template_close_bracket
890 .finish_template_type
892 | TYPENAME '<' template_arg_list_opt template_close_bracket
893 .finish_template_type
899 SELFNAME '<' template_arg_list_opt template_close_bracket
900 .finish_template_type
904 .finish_template_type:
906 if (yychar == YYEMPTY)
909 $$ = finish_template_type ($<ttype>-3, $<ttype>-1,
913 template_close_bracket:
917 /* Handle `Class<Class<Type>>' without space in the `>>' */
918 pedwarn ("`>>' should be `> >' in template class name");
923 template_arg_list_opt:
931 { $$ = build_tree_list (NULL_TREE, $$); }
932 | template_arg_list ',' template_arg
933 { $$ = chainon ($$, build_tree_list (NULL_TREE, $3)); }
938 { $$ = groktypename ($1.t); }
941 | expr_no_commas %prec ARITHCOMPARE
946 { $$ = NEGATE_EXPR; }
948 { $$ = CONVERT_EXPR; }
950 { $$ = PREINCREMENT_EXPR; }
952 { $$ = PREDECREMENT_EXPR; }
954 { $$ = TRUTH_NOT_EXPR; }
959 { $$ = build_x_compound_expr ($$); }
965 { error ("ANSI C++ forbids an empty condition for `%s'",
967 $$ = integer_zero_node; }
974 { error ("ANSI C++ forbids an empty condition for `%s'",
976 $$ = integer_zero_node; }
990 type_specifier_seq declarator maybeasm maybe_attribute '='
993 for (d = getdecls (); d; d = TREE_CHAIN (d))
994 if (TREE_CODE (d) == TYPE_DECL) {
995 tree s = TREE_TYPE (d);
996 if (TREE_CODE (s) == RECORD_TYPE)
997 cp_error ("definition of class `%T' in condition", s);
998 else if (TREE_CODE (s) == ENUMERAL_TYPE)
999 cp_error ("definition of enum `%T' in condition", s);
1002 current_declspecs = $1.t;
1003 $<itype>5 = suspend_momentary ();
1004 $<ttype>$ = start_decl ($<ttype>2, current_declspecs, 1,
1005 $4, /*prefix_attributes*/ NULL_TREE);
1009 cp_finish_decl ($<ttype>6, $7, $4, 1, LOOKUP_ONLYCONVERTING);
1010 resume_momentary ($<itype>5);
1012 if (TREE_CODE (TREE_TYPE ($$)) == ARRAY_TYPE)
1013 cp_error ("definition of array `%#D' in condition", $$);
1020 | maybe_label_decls stmts '}'
1021 | maybe_label_decls stmts error '}'
1022 | maybe_label_decls error '}'
1025 already_scoped_stmt:
1027 { $<ttype>$ = begin_compound_stmt (1); }
1029 { finish_compound_stmt (1, $<ttype>2); }
1034 nontrivial_exprlist:
1035 expr_no_commas ',' expr_no_commas
1036 { $$ = expr_tree_cons (NULL_TREE, $$,
1037 build_expr_list (NULL_TREE, $3)); }
1038 | expr_no_commas ',' error
1039 { $$ = expr_tree_cons (NULL_TREE, $$,
1040 build_expr_list (NULL_TREE, error_mark_node)); }
1041 | nontrivial_exprlist ',' expr_no_commas
1042 { chainon ($$, build_expr_list (NULL_TREE, $3)); }
1043 | nontrivial_exprlist ',' error
1044 { chainon ($$, build_expr_list (NULL_TREE, error_mark_node)); }
1049 { $$ = build_expr_list (NULL_TREE, $$); }
1050 | nontrivial_exprlist
1056 /* __extension__ turns off -pedantic for following primary. */
1057 | extension cast_expr %prec UNARY
1059 pedantic = $<itype>1; }
1060 | '*' cast_expr %prec UNARY
1061 { $$ = build_x_indirect_ref ($2, "unary *"); }
1062 | '&' cast_expr %prec UNARY
1063 { $$ = build_x_unary_op (ADDR_EXPR, $2); }
1065 { $$ = build_x_unary_op (BIT_NOT_EXPR, $2); }
1066 | unop cast_expr %prec UNARY
1067 { $$ = finish_unary_op_expr ($1, $2); }
1068 /* Refer to the address of a label as a pointer. */
1071 pedwarn ("ANSI C++ forbids `&&'");
1072 $$ = finish_label_address_expr ($2); }
1073 | SIZEOF unary_expr %prec UNARY
1074 { $$ = expr_sizeof ($2); }
1075 | SIZEOF '(' type_id ')' %prec HYPERUNARY
1076 { $$ = c_sizeof (groktypename ($3.t)); }
1077 | ALIGNOF unary_expr %prec UNARY
1078 { $$ = grok_alignof ($2); }
1079 | ALIGNOF '(' type_id ')' %prec HYPERUNARY
1080 { $$ = c_alignof (groktypename ($3.t));
1081 check_for_new_type ("alignof", $3); }
1083 /* The %prec EMPTY's here are required by the = init initializer
1084 syntax extension; see below. */
1085 | new new_type_id %prec EMPTY
1086 { $$ = build_new (NULL_TREE, $2.t, NULL_TREE, $1);
1087 check_for_new_type ("new", $2); }
1088 | new new_type_id new_initializer
1089 { $$ = build_new (NULL_TREE, $2.t, $3, $1);
1090 check_for_new_type ("new", $2); }
1091 | new new_placement new_type_id %prec EMPTY
1092 { $$ = build_new ($2, $3.t, NULL_TREE, $1);
1093 check_for_new_type ("new", $3); }
1094 | new new_placement new_type_id new_initializer
1095 { $$ = build_new ($2, $3.t, $4, $1);
1096 check_for_new_type ("new", $3); }
1097 /* The .begin_new_placement in the following rules is
1098 necessary to avoid shift/reduce conflicts that lead to
1099 mis-parsing some expressions. Of course, these constructs
1100 are not really new-placement and it is bogus to call
1101 begin_new_placement. But, the parser cannot always tell at this
1102 point whether the next thing is an expression or a type-id,
1103 so there is nothing we can do. Fortunately,
1104 begin_new_placement does nothing harmful. When we rewrite
1105 the parser, this lossage should be removed, of course. */
1106 | new '(' .begin_new_placement type_id .finish_new_placement
1108 { $$ = build_new (NULL_TREE, groktypename($4.t),
1110 check_for_new_type ("new", $4); }
1111 | new '(' .begin_new_placement type_id .finish_new_placement
1113 { $$ = build_new (NULL_TREE, groktypename($4.t), $6, $1);
1114 check_for_new_type ("new", $4); }
1115 | new new_placement '(' .begin_new_placement type_id
1116 .finish_new_placement %prec EMPTY
1117 { $$ = build_new ($2, groktypename($5.t), NULL_TREE, $1);
1118 check_for_new_type ("new", $5); }
1119 | new new_placement '(' .begin_new_placement type_id
1120 .finish_new_placement new_initializer
1121 { $$ = build_new ($2, groktypename($5.t), $7, $1);
1122 check_for_new_type ("new", $5); }
1124 | delete cast_expr %prec UNARY
1125 { $$ = delete_sanity ($2, NULL_TREE, 0, $1); }
1126 | delete '[' ']' cast_expr %prec UNARY
1127 { $$ = delete_sanity ($4, NULL_TREE, 1, $1);
1128 if (yychar == YYEMPTY)
1130 | delete '[' expr ']' cast_expr %prec UNARY
1131 { $$ = delete_sanity ($5, $3, 2, $1);
1132 if (yychar == YYEMPTY)
1134 | REALPART cast_expr %prec UNARY
1135 { $$ = build_x_unary_op (REALPART_EXPR, $2); }
1136 | IMAGPART cast_expr %prec UNARY
1137 { $$ = build_x_unary_op (IMAGPART_EXPR, $2); }
1140 /* Note this rule is not suitable for use in new_placement
1141 since it uses NULL_TREE as the argument to
1142 finish_new_placement. This rule serves only to avoid
1143 reduce/reduce conflicts in unary_expr. See the comments
1144 there on the use of begin/finish_new_placement. */
1145 .finish_new_placement:
1147 { finish_new_placement (NULL_TREE, $<itype>-1); }
1149 .begin_new_placement:
1150 { $$ = begin_new_placement (); }
1153 '(' .begin_new_placement nonnull_exprlist ')'
1154 { $$ = finish_new_placement ($3, $2); }
1155 | '{' .begin_new_placement nonnull_exprlist '}'
1156 { cp_pedwarn ("old style placement syntax, use () instead");
1157 $$ = finish_new_placement ($3, $2); }
1161 '(' nonnull_exprlist ')'
1167 cp_error ("`%T' is not a valid expression", $2.t);
1168 $$ = error_mark_node;
1170 /* GNU extension so people can use initializer lists. Note that
1171 this alters the meaning of `new int = 1', which was previously
1172 syntactically valid but semantically invalid. */
1176 pedwarn ("ANSI C++ forbids initialization of new expression with `='");
1177 if (TREE_CODE ($2) != TREE_LIST
1178 && TREE_CODE ($2) != CONSTRUCTOR)
1179 $$ = build_expr_list (NULL_TREE, $2);
1185 /* This is necessary to postpone reduction of `int ((int)(int)(int))'. */
1187 '(' type_id ')' %prec EMPTY
1188 { $2.t = finish_parmlist (build_tree_list (NULL_TREE, $2.t), 0);
1189 $$ = make_call_declarator (NULL_TREE, $2.t, NULL_TREE, NULL_TREE);
1190 check_for_new_type ("cast", $2); }
1191 | regcast_or_absdcl '(' type_id ')' %prec EMPTY
1192 { $3.t = finish_parmlist (build_tree_list (NULL_TREE, $3.t), 0);
1193 $$ = make_call_declarator ($$, $3.t, NULL_TREE, NULL_TREE);
1194 check_for_new_type ("cast", $3); }
1199 | regcast_or_absdcl unary_expr %prec UNARY
1200 { $$ = reparse_absdcl_as_casts ($$, $2); }
1201 | regcast_or_absdcl '{' initlist maybecomma '}' %prec UNARY
1203 tree init = build_nt (CONSTRUCTOR, NULL_TREE,
1206 pedwarn ("ANSI C++ forbids constructor-expressions");
1207 /* Indicate that this was a GNU C constructor expression. */
1208 TREE_HAS_CONSTRUCTOR (init) = 1;
1210 $$ = reparse_absdcl_as_casts ($$, init);
1216 /* Handle general members. */
1217 | expr_no_commas POINTSAT_STAR expr_no_commas
1218 { $$ = build_x_binary_op (MEMBER_REF, $$, $3); }
1219 | expr_no_commas DOT_STAR expr_no_commas
1220 { $$ = build_m_component_ref ($$, $3); }
1221 | expr_no_commas '+' expr_no_commas
1222 { $$ = build_x_binary_op ($2, $$, $3); }
1223 | expr_no_commas '-' expr_no_commas
1224 { $$ = build_x_binary_op ($2, $$, $3); }
1225 | expr_no_commas '*' expr_no_commas
1226 { $$ = build_x_binary_op ($2, $$, $3); }
1227 | expr_no_commas '/' expr_no_commas
1228 { $$ = build_x_binary_op ($2, $$, $3); }
1229 | expr_no_commas '%' expr_no_commas
1230 { $$ = build_x_binary_op ($2, $$, $3); }
1231 | expr_no_commas LSHIFT expr_no_commas
1232 { $$ = build_x_binary_op ($2, $$, $3); }
1233 | expr_no_commas RSHIFT expr_no_commas
1234 { $$ = build_x_binary_op ($2, $$, $3); }
1235 | expr_no_commas ARITHCOMPARE expr_no_commas
1236 { $$ = build_x_binary_op ($2, $$, $3); }
1237 | expr_no_commas '<' expr_no_commas
1238 { $$ = build_x_binary_op (LT_EXPR, $$, $3); }
1239 | expr_no_commas '>' expr_no_commas
1240 { $$ = build_x_binary_op (GT_EXPR, $$, $3); }
1241 | expr_no_commas EQCOMPARE expr_no_commas
1242 { $$ = build_x_binary_op ($2, $$, $3); }
1243 | expr_no_commas MIN_MAX expr_no_commas
1244 { $$ = build_x_binary_op ($2, $$, $3); }
1245 | expr_no_commas '&' expr_no_commas
1246 { $$ = build_x_binary_op ($2, $$, $3); }
1247 | expr_no_commas '|' expr_no_commas
1248 { $$ = build_x_binary_op ($2, $$, $3); }
1249 | expr_no_commas '^' expr_no_commas
1250 { $$ = build_x_binary_op ($2, $$, $3); }
1251 | expr_no_commas ANDAND expr_no_commas
1252 { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $$, $3); }
1253 | expr_no_commas OROR expr_no_commas
1254 { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $$, $3); }
1255 | expr_no_commas '?' xexpr ':' expr_no_commas
1256 { $$ = build_x_conditional_expr ($$, $3, $5); }
1257 | expr_no_commas '=' expr_no_commas
1258 { $$ = build_x_modify_expr ($$, NOP_EXPR, $3);
1259 if ($$ != error_mark_node)
1260 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
1261 | expr_no_commas ASSIGN expr_no_commas
1262 { $$ = build_x_modify_expr ($$, $2, $3); }
1264 { $$ = build_throw (NULL_TREE); }
1265 | THROW expr_no_commas
1266 { $$ = build_throw ($2); }
1267 /* These extensions are not defined. The second arg to build_m_component_ref
1268 is old, build_m_component_ref now does an implicit
1269 build_indirect_ref (x, NULL_PTR) on the second argument.
1270 | object '&' expr_no_commas %prec UNARY
1271 { $$ = build_m_component_ref ($$, build_x_unary_op (ADDR_EXPR, $3)); }
1272 | object unop expr_no_commas %prec UNARY
1273 { $$ = build_m_component_ref ($$, build_x_unary_op ($2, $3)); }
1274 | object '(' type_id ')' expr_no_commas %prec UNARY
1275 { tree type = groktypename ($3.t);
1276 $$ = build_m_component_ref ($$, build_c_cast (type, $5)); }
1277 | object primary_no_id %prec UNARY
1278 { $$ = build_m_component_ref ($$, $2); }
1282 notype_unqualified_id:
1283 '~' see_typename identifier
1284 { $$ = build_parse_node (BIT_NOT_EXPR, $3); }
1285 | '~' see_typename template_type
1286 { $$ = build_parse_node (BIT_NOT_EXPR, $3); }
1291 | NSNAME %prec EMPTY
1295 { $$ = do_identifier ($<ttype>-1, 1, NULL_TREE); }
1298 PFUNCNAME '<' do_id template_arg_list_opt template_close_bracket
1299 { $$ = lookup_template_function ($3, $4); }
1300 | operator_name '<' do_id template_arg_list_opt template_close_bracket
1301 { $$ = lookup_template_function ($3, $4); }
1305 TEMPLATE identifier '<' template_arg_list_opt template_close_bracket
1306 { $$ = lookup_template_function ($2, $4); }
1307 | TEMPLATE PFUNCNAME '<' template_arg_list_opt template_close_bracket
1308 { $$ = lookup_template_function ($2, $4); }
1309 | TEMPLATE operator_name '<' template_arg_list_opt
1310 template_close_bracket
1311 { $$ = lookup_template_function ($2, $4); }
1315 notype_unqualified_id
1321 notype_unqualified_id
1322 | '*' expr_or_declarator %prec UNARY
1323 { $$ = build_parse_node (INDIRECT_REF, $2); }
1324 | '&' expr_or_declarator %prec UNARY
1325 { $$ = build_parse_node (ADDR_EXPR, $2); }
1326 | '(' expr_or_declarator ')'
1330 notype_template_declarator:
1331 IDENTIFIER '<' template_arg_list_opt template_close_bracket
1332 { $$ = lookup_template_function ($1, $3); }
1333 | NSNAME '<' template_arg_list template_close_bracket
1334 { $$ = lookup_template_function ($1, $3); }
1337 direct_notype_declarator:
1338 complex_direct_notype_declarator
1339 /* This precedence declaration is to prefer this reduce
1340 to the Koenig lookup shift in primary, below. I hate yacc. */
1341 | notype_unqualified_id %prec '('
1342 | notype_template_declarator
1343 | '(' expr_or_declarator ')'
1344 { $$ = finish_decl_parsing ($2); }
1348 notype_unqualified_id
1350 if (TREE_CODE ($1) == BIT_NOT_EXPR)
1351 $$ = build_x_unary_op (BIT_NOT_EXPR, TREE_OPERAND ($1, 0));
1353 $$ = finish_id_expr ($1);
1359 if (processing_template_decl)
1360 push_obstacks (&permanent_obstack, &permanent_obstack);
1361 $$ = combine_strings ($$);
1362 /* combine_strings doesn't set up TYPE_MAIN_VARIANT of
1363 a const array the way we want, so fix it. */
1364 if (flag_const_strings)
1365 TREE_TYPE ($$) = build_cplus_array_type
1366 (TREE_TYPE (TREE_TYPE ($$)),
1367 TYPE_DOMAIN (TREE_TYPE ($$)));
1368 if (processing_template_decl)
1372 { $$ = finish_parenthesized_expr ($2); }
1373 | '(' expr_or_declarator ')'
1374 { $2 = reparse_decl_as_expr (NULL_TREE, $2);
1375 $$ = finish_parenthesized_expr ($2); }
1377 { $$ = error_mark_node; }
1379 { tree scope = current_scope ();
1380 if (!scope || TREE_CODE (scope) != FUNCTION_DECL)
1382 error ("braced-group within expression allowed only inside a function");
1386 pedwarn ("ANSI C++ forbids braced-groups within expressions");
1387 $<ttype>$ = begin_stmt_expr ();
1390 { $$ = finish_stmt_expr ($<ttype>2, $3); }
1391 /* Koenig lookup support
1392 We could store lastiddecl in $1 to avoid another lookup,
1393 but that would result in many additional reduce/reduce conflicts. */
1394 | notype_unqualified_id '(' nonnull_exprlist ')'
1395 { $$ = finish_call_expr ($1, $3, 1); }
1396 | notype_unqualified_id LEFT_RIGHT
1397 { $$ = finish_call_expr ($1, NULL_TREE, 1); }
1398 | primary '(' nonnull_exprlist ')'
1399 { $$ = finish_call_expr ($1, $3, 0); }
1400 | primary LEFT_RIGHT
1401 { $$ = finish_call_expr ($1, NULL_TREE, 0); }
1402 | primary '[' expr ']'
1403 { $$ = grok_array_decl ($$, $3); }
1405 { $$ = finish_increment_expr ($1, POSTINCREMENT_EXPR); }
1406 | primary MINUSMINUS
1407 { $$ = finish_increment_expr ($1, POSTDECREMENT_EXPR); }
1408 /* C++ extensions */
1410 { $$ = finish_this_expr (); }
1411 | CV_QUALIFIER '(' nonnull_exprlist ')'
1413 tree type = NULL_TREE;
1416 /* This is a C cast in C++'s `functional' notation. */
1417 if ($3 == error_mark_node)
1419 $$ = error_mark_node;
1423 if ($3 == NULL_TREE)
1425 error ("cannot cast null list to type `%s'",
1426 IDENTIFIER_POINTER (TYPE_NAME (id)));
1427 $$ = error_mark_node;
1432 /* type is not set! (mrs) */
1433 if (type == error_mark_node)
1434 $$ = error_mark_node;
1438 if (id == ridpointers[(int) RID_CONST])
1439 type = build_type_variant (integer_type_node, 1, 0);
1440 else if (id == ridpointers[(int) RID_VOLATILE])
1441 type = build_type_variant (integer_type_node, 0, 1);
1443 /* should not be able to get here (mrs) */
1444 else if (id == ridpointers[(int) RID_FRIEND])
1446 error ("cannot cast expression to `friend' type");
1447 $$ = error_mark_node;
1451 else my_friendly_abort (79);
1452 $$ = build_c_cast (type, build_compound_expr ($3));
1456 | DYNAMIC_CAST '<' type_id '>' '(' expr ')'
1457 { tree type = groktypename ($3.t);
1458 check_for_new_type ("dynamic_cast", $3);
1459 $$ = build_dynamic_cast (type, $6); }
1460 | STATIC_CAST '<' type_id '>' '(' expr ')'
1461 { tree type = groktypename ($3.t);
1462 check_for_new_type ("static_cast", $3);
1463 $$ = build_static_cast (type, $6); }
1464 | REINTERPRET_CAST '<' type_id '>' '(' expr ')'
1465 { tree type = groktypename ($3.t);
1466 check_for_new_type ("reinterpret_cast", $3);
1467 $$ = build_reinterpret_cast (type, $6); }
1468 | CONST_CAST '<' type_id '>' '(' expr ')'
1469 { tree type = groktypename ($3.t);
1470 check_for_new_type ("const_cast", $3);
1471 $$ = build_const_cast (type, $6); }
1472 | TYPEID '(' expr ')'
1473 { $$ = build_x_typeid ($3); }
1474 | TYPEID '(' type_id ')'
1475 { tree type = groktypename ($3.t);
1476 check_for_new_type ("typeid", $3);
1477 $$ = get_typeid (TYPE_MAIN_VARIANT (type)); }
1478 | global_scope IDENTIFIER
1479 { $$ = do_scoped_id ($2, 1); }
1480 | global_scope template_id
1482 | global_scope operator_name
1484 got_scope = NULL_TREE;
1485 if (TREE_CODE ($2) == IDENTIFIER_NODE)
1486 $$ = do_scoped_id ($2, 1);
1490 | overqualified_id %prec HYPERUNARY
1491 { $$ = build_offset_ref (OP0 ($$), OP1 ($$)); }
1492 | overqualified_id '(' nonnull_exprlist ')'
1493 { $$ = finish_qualified_call_expr ($1, $3); }
1494 | overqualified_id LEFT_RIGHT
1495 { $$ = finish_qualified_call_expr ($1, NULL_TREE); }
1496 | object object_template_id %prec UNARY
1498 $$ = build_x_component_ref ($$, $2, NULL_TREE, 1);
1500 | object object_template_id '(' nonnull_exprlist ')'
1501 { $$ = finish_object_call_expr ($2, $1, $4); }
1502 | object object_template_id LEFT_RIGHT
1503 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1504 | object unqualified_id %prec UNARY
1505 { $$ = build_x_component_ref ($$, $2, NULL_TREE, 1); }
1506 | object overqualified_id %prec UNARY
1507 { if (processing_template_decl)
1508 $$ = build_min_nt (COMPONENT_REF, $1, copy_to_permanent ($2));
1510 $$ = build_object_ref ($$, OP0 ($2), OP1 ($2)); }
1511 | object unqualified_id '(' nonnull_exprlist ')'
1512 { $$ = finish_object_call_expr ($2, $1, $4); }
1513 | object unqualified_id LEFT_RIGHT
1514 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1515 | object overqualified_id '(' nonnull_exprlist ')'
1516 { $$ = finish_qualified_object_call_expr ($2, $1, $4); }
1517 | object overqualified_id LEFT_RIGHT
1518 { $$ = finish_qualified_object_call_expr ($2, $1, NULL_TREE); }
1519 /* p->int::~int() is valid -- 12.4 */
1520 | object '~' TYPESPEC LEFT_RIGHT
1521 { $$ = finish_pseudo_destructor_call_expr ($1, NULL_TREE, $3); }
1522 | object TYPESPEC SCOPE '~' TYPESPEC LEFT_RIGHT
1523 { $$ = finish_pseudo_destructor_call_expr ($1, $2, $5); }
1526 $$ = error_mark_node;
1530 /* Not needed for now.
1536 { $$ = error_mark_node; }
1538 { if (current_function_decl == 0)
1540 error ("braced-group within expression allowed only inside a function");
1543 $<ttype>$ = expand_start_stmt_expr (); }
1546 pedwarn ("ANSI C++ forbids braced-groups within expressions");
1547 $$ = expand_end_stmt_expr ($<ttype>2); }
1548 | primary_no_id '(' nonnull_exprlist ')'
1549 { $$ = build_x_function_call ($$, $3, current_class_ref); }
1550 | primary_no_id LEFT_RIGHT
1551 { $$ = build_x_function_call ($$, NULL_TREE, current_class_ref); }
1552 | primary_no_id '[' expr ']'
1554 | primary_no_id PLUSPLUS
1555 { $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); }
1556 | primary_no_id MINUSMINUS
1557 { $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); }
1559 { goto do_scoped_id; }
1560 | SCOPE operator_name
1561 { if (TREE_CODE ($2) == IDENTIFIER_NODE)
1563 goto do_scoped_operator;
1572 { got_scope = NULL_TREE; $$ = 1; }
1578 | global_scope delete
1579 { got_scope = NULL_TREE; $$ = 1; }
1584 { $$ = boolean_true_node; }
1586 { $$ = boolean_false_node; }
1589 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
1593 { $$ = chainon ($$, $2); }
1599 if (! current_function_parms_stored)
1600 store_parm_decls ();
1602 /* Always keep the BLOCK node associated with the outermost
1603 pair of curley braces of a function. These are needed
1604 for correct operation of dwarfout.c. */
1611 { got_object = TREE_TYPE ($$); }
1614 $$ = build_x_arrow ($$);
1615 got_object = TREE_TYPE ($$);
1620 typespec initdecls ';'
1622 resume_momentary ($2);
1623 if ($1.t && IS_AGGR_TYPE_CODE (TREE_CODE ($1.t)))
1624 note_got_semicolon ($1.t);
1626 | typed_declspecs initdecls ';'
1628 resume_momentary ($2);
1629 note_list_got_semicolon ($1.t);
1631 | declmods notype_initdecls ';'
1632 { resume_momentary ($2); }
1633 | typed_declspecs ';'
1636 note_list_got_semicolon ($1.t);
1639 { warning ("empty declaration"); }
1641 { pedantic = $<itype>1; }
1644 /* Any kind of declarator (thus, all declarators allowed
1645 after an explicit typespec). */
1648 after_type_declarator %prec EMPTY
1649 | notype_declarator %prec EMPTY
1652 /* This is necessary to postpone reduction of `int()()()()'. */
1654 LEFT_RIGHT %prec EMPTY
1655 { $$ = make_call_declarator (NULL_TREE, empty_parms (),
1656 NULL_TREE, NULL_TREE); }
1657 | fcast_or_absdcl LEFT_RIGHT %prec EMPTY
1658 { $$ = make_call_declarator ($$, empty_parms (), NULL_TREE,
1662 /* ANSI type-id (8.1) */
1664 typed_typespecs absdcl
1665 { $$.t = build_decl_list ($1.t, $2);
1666 $$.new_type_flag = $1.new_type_flag; }
1667 | nonempty_cv_qualifiers absdcl
1668 { $$.t = build_decl_list ($1.t, $2);
1669 $$.new_type_flag = $1.new_type_flag; }
1671 { $$.t = build_decl_list (get_decl_list ($1.t), $2);
1672 $$.new_type_flag = $1.new_type_flag; }
1673 | typed_typespecs %prec EMPTY
1674 { $$.t = build_decl_list ($1.t, NULL_TREE);
1675 $$.new_type_flag = $1.new_type_flag; }
1676 | nonempty_cv_qualifiers %prec EMPTY
1677 { $$.t = build_decl_list ($1.t, NULL_TREE);
1678 $$.new_type_flag = $1.new_type_flag; }
1681 /* Declspecs which contain at least one type specifier or typedef name.
1682 (Just `const' or `volatile' is not enough.)
1683 A typedef'd name following these is taken as a name to be declared.
1684 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1687 typed_typespecs %prec EMPTY
1693 { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1);
1694 $$.new_type_flag = $2.new_type_flag; }
1695 | typespec reserved_declspecs %prec HYPERUNARY
1696 { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2);
1697 $$.new_type_flag = $1.new_type_flag; }
1698 | typespec reserved_typespecquals reserved_declspecs
1699 { $$.t = decl_tree_cons (NULL_TREE, $1.t, chainon ($2, $3));
1700 $$.new_type_flag = $1.new_type_flag; }
1701 | declmods typespec reserved_declspecs
1702 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1));
1703 $$.new_type_flag = $2.new_type_flag; }
1704 | declmods typespec reserved_typespecquals
1705 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1));
1706 $$.new_type_flag = $2.new_type_flag; }
1707 | declmods typespec reserved_typespecquals reserved_declspecs
1708 { $$.t = decl_tree_cons (NULL_TREE, $2.t,
1709 chainon ($3, chainon ($4, $1)));
1710 $$.new_type_flag = $2.new_type_flag; }
1715 { if (extra_warnings)
1716 warning ("`%s' is not at beginning of declaration",
1717 IDENTIFIER_POINTER ($$));
1718 $$ = build_decl_list (NULL_TREE, $$); }
1719 | reserved_declspecs typespecqual_reserved
1720 { $$ = decl_tree_cons (NULL_TREE, $2.t, $$); }
1721 | reserved_declspecs SCSPEC
1722 { if (extra_warnings)
1723 warning ("`%s' is not at beginning of declaration",
1724 IDENTIFIER_POINTER ($2));
1725 $$ = decl_tree_cons (NULL_TREE, $2, $$); }
1726 | reserved_declspecs attributes
1727 { $$ = decl_tree_cons ($2, NULL_TREE, $1); }
1729 { $$ = decl_tree_cons ($1, NULL_TREE, NULL_TREE); }
1732 /* List of just storage classes and type modifiers.
1733 A declaration can start with just this, but then it cannot be used
1734 to redeclare a typedef-name.
1735 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1738 nonempty_cv_qualifiers %prec EMPTY
1739 { $$ = $1.t; TREE_STATIC ($$) = 1; }
1741 { $$ = IDENTIFIER_AS_LIST ($$); }
1742 | declmods CV_QUALIFIER
1743 { $$ = decl_tree_cons (NULL_TREE, $2, $$);
1744 TREE_STATIC ($$) = 1; }
1746 { if (extra_warnings && TREE_STATIC ($$))
1747 warning ("`%s' is not at beginning of declaration",
1748 IDENTIFIER_POINTER ($2));
1749 $$ = decl_tree_cons (NULL_TREE, $2, $$);
1750 TREE_STATIC ($$) = TREE_STATIC ($1); }
1751 | declmods attributes
1752 { $$ = decl_tree_cons ($2, NULL_TREE, $1); }
1754 { $$ = decl_tree_cons ($1, NULL_TREE, NULL_TREE); }
1757 /* Used instead of declspecs where storage classes are not allowed
1758 (that is, for typenames and structure components).
1760 C++ can takes storage classes for structure components.
1761 Don't accept a typedef-name if anything but a modifier precedes it. */
1764 typespec %prec EMPTY
1765 { $$.t = get_decl_list ($1.t);
1766 $$.new_type_flag = $1.new_type_flag; }
1767 | nonempty_cv_qualifiers typespec
1768 { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1.t);
1769 $$.new_type_flag = $2.new_type_flag; }
1770 | typespec reserved_typespecquals
1771 { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2);
1772 $$.new_type_flag = $1.new_type_flag; }
1773 | nonempty_cv_qualifiers typespec reserved_typespecquals
1774 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1775 $$.new_type_flag = $1.new_type_flag; }
1778 reserved_typespecquals:
1779 typespecqual_reserved
1780 { $$ = build_decl_list (NULL_TREE, $1.t); }
1781 | reserved_typespecquals typespecqual_reserved
1782 { $$ = decl_tree_cons (NULL_TREE, $2.t, $1); }
1785 /* A typespec (but not a type qualifier).
1786 Once we have seen one of these in a declaration,
1787 if a typedef name appears then it is being redeclared. */
1791 | TYPESPEC %prec EMPTY
1792 { $$.t = $1; $$.new_type_flag = 0; }
1793 | complete_type_name
1794 { $$.t = $1; $$.new_type_flag = 0; }
1795 | TYPEOF '(' expr ')'
1796 { $$.t = TREE_TYPE ($3);
1797 $$.new_type_flag = 0; }
1798 | TYPEOF '(' type_id ')'
1799 { $$.t = groktypename ($3.t);
1800 $$.new_type_flag = 0; }
1801 | SIGOF '(' expr ')'
1802 { tree type = TREE_TYPE ($3);
1804 $$.new_type_flag = 0;
1805 if (IS_AGGR_TYPE (type))
1807 sorry ("sigof type specifier");
1812 error ("`sigof' applied to non-aggregate expression");
1813 $$.t = error_mark_node;
1816 | SIGOF '(' type_id ')'
1817 { tree type = groktypename ($3.t);
1819 $$.new_type_flag = 0;
1820 if (IS_AGGR_TYPE (type))
1822 sorry ("sigof type specifier");
1827 error("`sigof' applied to non-aggregate type");
1828 $$.t = error_mark_node;
1833 /* A typespec that is a reserved word, or a type qualifier. */
1835 typespecqual_reserved:
1837 { $$.t = $1; $$.new_type_flag = 0; }
1839 { $$.t = $1; $$.new_type_flag = 0; }
1845 | initdecls ',' initdcl
1846 { check_multiple_declarators (); }
1851 | notype_initdecls ',' initdcl
1852 { check_multiple_declarators (); }
1857 | nomods_initdecls ',' initdcl
1858 { check_multiple_declarators (); }
1864 | asm_keyword '(' string ')'
1865 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3); $$ = $3; }
1869 declarator maybeasm maybe_attribute '='
1870 { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1,
1871 $3, prefix_attributes); }
1873 /* Note how the declaration of the variable is in effect while its init is parsed! */
1874 { cp_finish_decl ($<ttype>5, $6, $2, 1, LOOKUP_ONLYCONVERTING); }
1875 | declarator maybeasm maybe_attribute
1876 { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 0,
1877 $3, prefix_attributes);
1878 cp_finish_decl ($<ttype>$, NULL_TREE, $2, 1, 0); }
1881 /* This rule assumes a certain configuration of the parser stack.
1882 In particular, $0, the element directly before the beginning of
1883 this rule on the stack, must be a maybeasm. $-1 must be a
1884 declarator or notype_declarator. And $-2 must be some declmods
1885 or declspecs. We can't move the maybeasm into this rule because
1886 we need that reduce so we prefer fn.def1 when appropriate. */
1889 { $<itype>2 = parse_decl ($<ttype>-1, $<ttype>-2,
1890 $1, 1, &$<ttype>$); }
1891 /* Note how the declaration of the variable is in effect
1892 while its init is parsed! */
1894 { cp_finish_decl ($<ttype>3, $4, $<ttype>0, 1,
1895 LOOKUP_ONLYCONVERTING);
1899 $$ = parse_decl ($<ttype>-1, $<ttype>-2, $1, 0, &d);
1900 cp_finish_decl (d, NULL_TREE, $<ttype>0, 1, 0); }
1904 declarator maybeasm initdcl0_innards
1908 notype_declarator maybeasm initdcl0_innards
1913 notype_declarator maybeasm
1914 { /* Set things up as initdcl0_innards expects. */
1919 | constructor_declarator maybeasm maybe_attribute
1921 parse_decl($1, NULL_TREE, $3, 0, &d);
1922 cp_finish_decl (d, NULL_TREE, $2, 1, 0); }
1925 /* the * rules are dummies to accept the Apollo extended syntax
1926 so that the header files compile. */
1937 | attributes attribute
1938 { $$ = chainon ($1, $2); }
1942 ATTRIBUTE '(' '(' attribute_list ')' ')'
1949 | attribute_list ',' attrib
1950 { $$ = chainon ($1, $3); }
1957 { $$ = build_tree_list ($1, NULL_TREE); }
1958 | any_word '(' IDENTIFIER ')'
1959 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1960 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1961 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1962 | any_word '(' nonnull_exprlist ')'
1963 { $$ = build_tree_list ($1, $3); }
1966 /* This still leaves out most reserved keywords,
1967 shouldn't we include them? */
1976 /* A nonempty list of identifiers, including typenames. */
1977 identifiers_or_typenames:
1979 { $$ = build_tree_list (NULL_TREE, $1); }
1980 | identifiers_or_typenames ',' identifier
1981 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
1985 /* empty */ %prec EMPTY
1990 /* If we are processing a template, we don't want to expand this
1994 expr_no_commas %prec '='
1996 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, NULL_TREE);
1997 TREE_HAS_CONSTRUCTOR ($$) = 1; }
1999 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2000 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2001 | '{' initlist ',' '}'
2002 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2003 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2008 /* This chain is built in reverse order,
2009 and put in forward order where initlist is used. */
2012 { $$ = build_tree_list (NULL_TREE, $$); }
2014 { $$ = expr_tree_cons (NULL_TREE, $3, $$); }
2015 /* These are for labeled elements. */
2016 | '[' expr_no_commas ']' init
2017 { $$ = build_expr_list ($2, $4); }
2018 | identifier ':' init
2019 { $$ = build_expr_list ($$, $3); }
2020 | initlist ',' identifier ':' init
2021 { $$ = expr_tree_cons ($3, $5, $$); }
2025 PRE_PARSED_FUNCTION_DECL
2026 { start_function (NULL_TREE, TREE_VALUE ($1),
2028 reinit_parse_for_function (); }
2031 fn.defpen maybe_return_init ctor_initializer_opt compstmt_or_error
2033 int nested = (hack_decl_function_context
2034 (current_function_decl) != NULL_TREE);
2035 finish_function (lineno, (int)$3, nested);
2036 process_next_inline ($1);
2038 | fn.defpen maybe_return_init function_try_block
2039 { process_next_inline ($1); }
2040 | fn.defpen maybe_return_init error
2041 { process_next_inline ($1); }
2046 | pending_inlines pending_inline eat_saved_input
2049 /* A regurgitated default argument. The value of DEFARG_MARKER will be
2050 the TREE_LIST node for the parameter in question. */
2052 DEFARG_MARKER expr_no_commas END_OF_SAVED_INPUT
2053 { replace_defarg ($1, $2); }
2054 | DEFARG_MARKER error END_OF_SAVED_INPUT
2055 { replace_defarg ($1, error_mark_node); }
2058 /* empty */ %prec EMPTY
2059 | pending_defargs defarg_again
2060 { do_pending_defargs (); }
2061 | pending_defargs error
2062 { do_pending_defargs (); }
2067 { $<itype>3 = suspend_momentary ();
2068 $<ttype>$ = current_enum_type;
2069 current_enum_type = start_enum ($2); }
2070 enumlist maybecomma_warn '}'
2071 { TYPE_VALUES (current_enum_type) = $5;
2072 $$.t = finish_enum (current_enum_type);
2073 $$.new_type_flag = 1;
2074 current_enum_type = $<ttype>4;
2075 resume_momentary ((int) $<itype>3);
2076 check_for_missing_semicolon ($$.t); }
2077 | ENUM identifier '{' '}'
2078 { $$.t = finish_enum (start_enum ($2));
2079 $$.new_type_flag = 1;
2080 check_for_missing_semicolon ($$.t); }
2082 { $<itype>2 = suspend_momentary ();
2083 $<ttype>$ = current_enum_type;
2084 current_enum_type = start_enum (make_anon_name ()); }
2085 enumlist maybecomma_warn '}'
2086 { TYPE_VALUES (current_enum_type) = $4;
2087 $$.t = finish_enum (current_enum_type);
2088 $$.new_type_flag = 1;
2089 current_enum_type = $<ttype>4;
2090 resume_momentary ((int) $<itype>1);
2091 check_for_missing_semicolon ($$.t); }
2093 { $$.t = finish_enum (start_enum (make_anon_name()));
2094 $$.new_type_flag = 1;
2095 check_for_missing_semicolon ($$.t); }
2097 { $$.t = xref_tag (enum_type_node, $2, 1);
2098 $$.new_type_flag = 0; }
2099 | ENUM complex_type_name
2100 { $$.t = xref_tag (enum_type_node, $2, 1);
2101 $$.new_type_flag = 0; }
2102 | TYPENAME_KEYWORD typename_sub
2104 $$.new_type_flag = 0;
2105 if (!processing_template_decl)
2106 cp_pedwarn ("using `typename' outside of template"); }
2107 /* C++ extensions, merged with C to avoid shift/reduce conflicts */
2108 | class_head left_curly
2109 opt.component_decl_list '}' maybe_attribute
2113 if (yychar == YYEMPTY)
2115 semi = yychar == ';';
2117 $<ttype>$ = finish_class_definition ($1, $5, semi);
2120 { finish_default_args (); }
2123 $$.new_type_flag = 1;
2124 begin_inline_definitions (); }
2125 | class_head %prec EMPTY
2127 $$.new_type_flag = 0;
2128 if (TYPE_BINFO ($1) == NULL_TREE)
2130 cp_error ("%T is not a class type", $1);
2131 $$.t = error_mark_node;
2136 /* struct B: public A; is not accepted by the WP grammar. */
2137 if (TYPE_BINFO_BASETYPES ($$.t) && !TYPE_SIZE ($$.t)
2138 && ! TYPE_BEING_DEFINED ($$.t))
2139 cp_error ("base clause without member specification for `%#T'",
2153 { if (pedantic && !in_system_header)
2154 pedwarn ("comma at end of enumerator list"); }
2160 { error ("storage class specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2162 { error ("type specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2164 { error ("type qualifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2166 { error ("no body nor ';' separates two class, struct or union declarations"); }
2168 { $$ = build_decl_list ($2, $1); }
2171 named_class_head_sans_basetype:
2179 named_class_head_sans_basetype_defn:
2180 aggr identifier_defn %prec EMPTY
2181 { current_aggr = $$; $$ = $2; }
2182 | named_class_head_sans_basetype '{'
2183 { yyungetc ('{', 1); }
2184 | named_class_head_sans_basetype ':'
2185 { yyungetc (':', 1); }
2188 named_complex_class_head_sans_basetype:
2189 aggr nested_name_specifier identifier
2192 $$ = handle_class_head ($1, $2, $3);
2194 | aggr global_scope nested_name_specifier identifier
2197 $$ = handle_class_head ($1, $3, $4);
2199 | aggr global_scope identifier
2202 $$ = handle_class_head ($1, NULL_TREE, $3);
2204 | aggr template_type
2205 { current_aggr = $$; $$ = $2; }
2206 | aggr nested_name_specifier template_type
2207 { current_aggr = $$; $$ = $3; }
2211 named_class_head_sans_basetype %prec EMPTY
2212 { $$ = xref_tag (current_aggr, $1, 1); }
2213 | named_class_head_sans_basetype_defn
2214 { $<ttype>$ = xref_tag (current_aggr, $1, 0); }
2215 maybe_base_class_list %prec EMPTY
2219 xref_basetypes (current_aggr, $1, $<ttype>2, $3);
2221 | named_complex_class_head_sans_basetype maybe_base_class_list
2223 $$ = TREE_TYPE ($1);
2224 if (TREE_INT_CST_LOW (current_aggr) == union_type
2225 && TREE_CODE ($$) != UNION_TYPE)
2226 cp_pedwarn ("`union' tag used in declaring `%#T'", $$);
2227 else if (TREE_CODE ($$) == UNION_TYPE
2228 && TREE_INT_CST_LOW (current_aggr) != union_type)
2229 cp_pedwarn ("non-`union' tag used in declaring `%#T'", $$);
2232 maybe_process_partial_specialization ($$);
2233 xref_basetypes (current_aggr, $1, $$, $2);
2240 { $$ = xref_tag ($$, make_anon_name (), 0);
2241 yyungetc ('{', 1); }
2249 maybe_base_class_list:
2250 /* empty */ %prec EMPTY
2252 | ':' see_typename %prec EMPTY
2253 { yyungetc(':', 1); $$ = NULL_TREE; }
2254 | ':' see_typename base_class_list %prec EMPTY
2260 | base_class_list ',' see_typename base_class
2261 { $$ = chainon ($$, $4); }
2266 { $$ = finish_base_specifier (access_default_node, $1,
2268 == signature_type_node); }
2269 | base_class_access_list see_typename base_class.1
2270 { $$ = finish_base_specifier ($1, $3,
2272 == signature_type_node); }
2277 { if ($$ != error_mark_node) $$ = TYPE_MAIN_DECL ($1); }
2279 | SIGOF '(' expr ')'
2281 if (current_aggr == signature_type_node)
2283 if (IS_AGGR_TYPE (TREE_TYPE ($3)))
2285 sorry ("`sigof' as base signature specifier");
2286 $$ = TREE_TYPE ($3);
2290 error ("`sigof' applied to non-aggregate expression");
2291 $$ = error_mark_node;
2296 error ("`sigof' in struct or class declaration");
2297 $$ = error_mark_node;
2300 | SIGOF '(' type_id ')'
2302 if (current_aggr == signature_type_node)
2304 if (IS_AGGR_TYPE (groktypename ($3.t)))
2306 sorry ("`sigof' as base signature specifier");
2307 $$ = groktypename ($3.t);
2311 error ("`sigof' applied to non-aggregate expression");
2312 $$ = error_mark_node;
2317 error ("`sigof' in struct or class declaration");
2318 $$ = error_mark_node;
2323 base_class_access_list:
2324 VISSPEC see_typename
2325 | SCSPEC see_typename
2326 { if ($1 != ridpointers[(int)RID_VIRTUAL])
2327 cp_error ("`%D' access", $1);
2328 $$ = access_default_virtual_node; }
2329 | base_class_access_list VISSPEC see_typename
2331 if ($1 != access_default_virtual_node)
2332 error ("multiple access specifiers");
2333 else if ($2 == access_public_node)
2334 $$ = access_public_virtual_node;
2335 else if ($2 == access_protected_node)
2336 $$ = access_protected_virtual_node;
2337 else /* $2 == access_private_node */
2338 $$ = access_private_virtual_node;
2340 | base_class_access_list SCSPEC see_typename
2341 { if ($2 != ridpointers[(int)RID_VIRTUAL])
2342 cp_error ("`%D' access", $2);
2343 else if ($$ == access_public_node)
2344 $$ = access_public_virtual_node;
2345 else if ($$ == access_protected_node)
2346 $$ = access_protected_virtual_node;
2347 else if ($$ == access_private_node)
2348 $$ = access_private_virtual_node;
2350 error ("multiple `virtual' specifiers");
2356 { $<ttype>0 = begin_class_definition ($<ttype>0); }
2362 finish_member_declaration (build_self_reference ());
2366 opt.component_decl_list:
2368 | self_reference component_decl_list
2369 | opt.component_decl_list access_specifier component_decl_list
2370 | opt.component_decl_list access_specifier
2376 if (current_aggr == signature_type_node)
2378 error ("access specifier not allowed in signature");
2379 $1 = access_public_node;
2382 current_access_specifier = $1;
2386 /* Note: we no longer warn about the semicolon after a component_decl_list.
2387 ARM $9.2 says that the semicolon is optional, and therefore allowed. */
2388 component_decl_list:
2391 finish_member_declaration ($1);
2393 | component_decl_list component_decl
2395 finish_member_declaration ($2);
2400 component_decl_1 ';'
2401 | component_decl_1 '}'
2402 { error ("missing ';' before right brace");
2403 yyungetc ('}', 0); }
2404 /* C++: handle constructors, destructors and inline functions */
2405 /* note that INLINE is like a TYPESPEC */
2406 | fn.def2 ':' /* base_init compstmt */
2407 { $$ = finish_method ($$); }
2408 | fn.def2 TRY /* base_init compstmt */
2409 { $$ = finish_method ($$); }
2410 | fn.def2 RETURN /* base_init compstmt */
2411 { $$ = finish_method ($$); }
2412 | fn.def2 '{' /* nodecls compstmt */
2413 { $$ = finish_method ($$); }
2416 | extension component_decl
2418 pedantic = $<itype>1; }
2419 | template_header component_decl
2422 $$ = finish_member_template_decl ($2);
2424 /* The component was already processed. */
2427 finish_template_decl ($1);
2429 | template_header typed_declspecs ';'
2431 $$ = finish_member_class_template ($2.t);
2432 finish_template_decl ($1);
2437 /* Do not add a "typed_declspecs declarator" rule here for
2438 speed; we need to call grok_x_components for enums, so the
2439 speedup would be insignificant. */
2440 typed_declspecs components
2442 /* Most of the productions for component_decl only
2443 allow the creation of one new member, so we call
2444 finish_member_declaration in component_decl_list.
2445 For this rule and the next, however, there can be
2446 more than one member, e.g.:
2450 and we need the first member to be fully
2451 registered before the second is processed.
2452 Therefore, the rules for components take care of
2453 this processing. To avoid registering the
2454 components more than once, we send NULL_TREE up
2455 here; that lets finish_member_declaration now
2456 that there is nothing to do. */
2458 grok_x_components ($1.t);
2461 | declmods notype_components
2464 grok_x_components ($1);
2467 | notype_declarator maybeasm maybe_attribute maybe_init
2468 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2469 build_tree_list ($3, NULL_TREE)); }
2470 | constructor_declarator maybeasm maybe_attribute maybe_init
2471 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2472 build_tree_list ($3, NULL_TREE)); }
2473 | ':' expr_no_commas
2474 { $$ = grokbitfield (NULL_TREE, NULL_TREE, $2); }
2478 /* These rules introduce a reduce/reduce conflict; in
2479 typedef int foo, bar;
2483 should "A::foo" be declared as a function or "A::bar" as a data
2484 member? In other words, is "bar" an after_type_declarator or a
2486 | declmods component_constructor_declarator maybeasm maybe_attribute maybe_init
2487 { tree specs, attrs;
2488 split_specs_attrs ($1, &specs, &attrs);
2489 $$ = grokfield ($2, specs, $5, $3,
2490 build_tree_list ($4, attrs)); }
2491 | component_constructor_declarator maybeasm maybe_attribute maybe_init
2492 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2493 build_tree_list ($3, NULL_TREE)); }
2495 { $$ = do_class_using_decl ($1); }
2497 /* The case of exactly one component is handled directly by component_decl. */
2500 /* empty: possibly anonymous */
2502 | component_declarator0
2504 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2505 $1 = finish_member_template_decl ($1);
2506 finish_member_declaration ($1);
2509 | components ',' component_declarator
2511 check_multiple_declarators ();
2512 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2513 $3 = finish_member_template_decl ($3);
2514 finish_member_declaration ($3);
2520 /* empty: possibly anonymous */
2522 | notype_component_declarator0
2524 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2525 $1 = finish_member_template_decl ($1);
2526 finish_member_declaration ($1);
2529 | notype_components ',' notype_component_declarator
2531 check_multiple_declarators ();
2532 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2533 $3 = finish_member_template_decl ($3);
2534 finish_member_declaration ($3);
2539 component_declarator0:
2540 after_type_component_declarator0
2541 | notype_component_declarator0
2544 component_declarator:
2545 after_type_component_declarator
2546 | notype_component_declarator
2549 after_type_component_declarator0:
2550 after_type_declarator maybeasm maybe_attribute maybe_init
2551 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2552 &prefix_attributes);
2553 $<ttype>0 = current_declspecs;
2554 $$ = grokfield ($$, current_declspecs, $4, $2,
2555 build_tree_list ($3, prefix_attributes)); }
2556 | TYPENAME ':' expr_no_commas maybe_attribute
2557 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2558 &prefix_attributes);
2559 $<ttype>0 = current_declspecs;
2560 $$ = grokbitfield ($$, current_declspecs, $3);
2561 cplus_decl_attributes ($$, $4, prefix_attributes); }
2564 notype_component_declarator0:
2565 notype_declarator maybeasm maybe_attribute maybe_init
2566 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2567 &prefix_attributes);
2568 $<ttype>0 = current_declspecs;
2569 $$ = grokfield ($$, current_declspecs, $4, $2,
2570 build_tree_list ($3, prefix_attributes)); }
2571 | constructor_declarator maybeasm maybe_attribute maybe_init
2572 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2573 &prefix_attributes);
2574 $<ttype>0 = current_declspecs;
2575 $$ = grokfield ($$, current_declspecs, $4, $2,
2576 build_tree_list ($3, prefix_attributes)); }
2577 | IDENTIFIER ':' expr_no_commas maybe_attribute
2578 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2579 &prefix_attributes);
2580 $<ttype>0 = current_declspecs;
2581 $$ = grokbitfield ($$, current_declspecs, $3);
2582 cplus_decl_attributes ($$, $4, prefix_attributes); }
2583 | ':' expr_no_commas maybe_attribute
2584 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2585 &prefix_attributes);
2586 $<ttype>0 = current_declspecs;
2587 $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
2588 cplus_decl_attributes ($$, $3, prefix_attributes); }
2591 after_type_component_declarator:
2592 after_type_declarator maybeasm maybe_attribute maybe_init
2593 { $$ = grokfield ($$, current_declspecs, $4, $2,
2594 build_tree_list ($3, prefix_attributes)); }
2595 | TYPENAME ':' expr_no_commas maybe_attribute
2596 { $$ = grokbitfield ($$, current_declspecs, $3);
2597 cplus_decl_attributes ($$, $4, prefix_attributes); }
2600 notype_component_declarator:
2601 notype_declarator maybeasm maybe_attribute maybe_init
2602 { $$ = grokfield ($$, current_declspecs, $4, $2,
2603 build_tree_list ($3, prefix_attributes)); }
2604 | IDENTIFIER ':' expr_no_commas maybe_attribute
2605 { $$ = grokbitfield ($$, current_declspecs, $3);
2606 cplus_decl_attributes ($$, $4, prefix_attributes); }
2607 | ':' expr_no_commas maybe_attribute
2608 { $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
2609 cplus_decl_attributes ($$, $3, prefix_attributes); }
2612 /* We chain the enumerators in reverse order.
2613 Because of the way enums are built, the order is
2614 insignificant. Take advantage of this fact. */
2618 | enumlist ',' enumerator
2619 { TREE_CHAIN ($3) = $$; $$ = $3; }
2624 { $$ = build_enumerator ($$, NULL_TREE, current_enum_type); }
2625 | identifier '=' expr_no_commas
2626 { $$ = build_enumerator ($$, $3, current_enum_type); }
2629 /* ANSI new-type-id (5.3.4) */
2631 type_specifier_seq new_declarator
2632 { $$.t = build_decl_list ($1.t, $2);
2633 $$.new_type_flag = $1.new_type_flag; }
2634 | type_specifier_seq %prec EMPTY
2635 { $$.t = build_decl_list ($1.t, NULL_TREE);
2636 $$.new_type_flag = $1.new_type_flag; }
2637 /* GNU extension to allow arrays of arbitrary types with
2638 non-constant dimension. For the use of begin_new_placement
2639 here, see the comments in unary_expr above. */
2640 | '(' .begin_new_placement type_id .finish_new_placement
2644 pedwarn ("ANSI C++ forbids array dimensions with parenthesized type in new");
2645 $$.t = build_parse_node (ARRAY_REF, TREE_VALUE ($3.t), $6);
2646 $$.t = build_decl_list (TREE_PURPOSE ($3.t), $$.t);
2647 $$.new_type_flag = $3.new_type_flag;
2652 /* empty */ %prec EMPTY
2654 | cv_qualifiers CV_QUALIFIER
2655 { $$ = decl_tree_cons (NULL_TREE, $2, $$); }
2658 nonempty_cv_qualifiers:
2660 { $$.t = IDENTIFIER_AS_LIST ($1);
2661 $$.new_type_flag = 0; }
2662 | nonempty_cv_qualifiers CV_QUALIFIER
2663 { $$.t = decl_tree_cons (NULL_TREE, $2, $1.t);
2664 $$.new_type_flag = $1.new_type_flag; }
2667 /* These rules must follow the rules for function declarations
2668 and component declarations. That way, longer rules are preferred. */
2672 { $<itype>$ = suspend_momentary (); }
2674 /* An expression which will not live on the momentary obstack. */
2677 { resume_momentary ((int) $<itype>1); $$ = $2; }
2680 /* An expression which will not live on the momentary obstack. */
2682 suspend_mom '(' nonnull_exprlist ')'
2683 { resume_momentary ((int) $<itype>1); $$ = $3; }
2684 | suspend_mom '(' parmlist ')'
2685 { resume_momentary ((int) $<itype>1); $$ = $3; }
2686 | suspend_mom LEFT_RIGHT
2687 { resume_momentary ((int) $<itype>1); $$ = empty_parms (); }
2688 | suspend_mom '(' error ')'
2689 { resume_momentary ((int) $<itype>1); $$ = NULL_TREE; }
2692 /* A declarator that is allowed only after an explicit typespec. */
2693 /* may all be followed by prec '.' */
2694 after_type_declarator:
2695 '*' nonempty_cv_qualifiers after_type_declarator %prec UNARY
2696 { $$ = make_pointer_declarator ($2.t, $3); }
2697 | '&' nonempty_cv_qualifiers after_type_declarator %prec UNARY
2698 { $$ = make_reference_declarator ($2.t, $3); }
2699 | '*' after_type_declarator %prec UNARY
2700 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2701 | '&' after_type_declarator %prec UNARY
2702 { $$ = make_reference_declarator (NULL_TREE, $2); }
2703 | ptr_to_mem cv_qualifiers after_type_declarator
2704 { tree arg = make_pointer_declarator ($2, $3);
2705 $$ = build_parse_node (SCOPE_REF, $1, arg);
2707 | direct_after_type_declarator
2711 type_name %prec EMPTY
2713 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2715 $$ = lookup_name ($1, 1);
2716 if (current_class_type
2717 && TYPE_BEING_DEFINED (current_class_type)
2718 && ! IDENTIFIER_CLASS_VALUE ($1))
2720 /* Remember that this name has been used in the class
2721 definition, as per [class.scope0] */
2722 pushdecl_class_level ($$);
2728 | global_scope type_name
2730 if (TREE_CODE ($2) == IDENTIFIER_NODE)
2731 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
2734 got_scope = NULL_TREE;
2741 | global_scope nested_type
2746 nested_name_specifier type_name %prec EMPTY
2747 { $$ = get_type_decl ($2); }
2750 direct_after_type_declarator:
2751 direct_after_type_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2752 { $$ = make_call_declarator ($$, $2, $3, $4); }
2753 | direct_after_type_declarator '[' nonmomentary_expr ']'
2754 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
2755 | direct_after_type_declarator '[' ']'
2756 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
2757 | '(' after_type_declarator ')'
2759 | nested_name_specifier type_name %prec EMPTY
2760 { push_nested_class ($1, 3);
2761 $$ = build_parse_node (SCOPE_REF, $$, $2);
2762 TREE_COMPLEXITY ($$) = current_class_depth; }
2763 | type_name %prec EMPTY
2766 /* A declarator allowed whether or not there has been
2767 an explicit typespec. These cannot redeclare a typedef-name. */
2770 '*' nonempty_cv_qualifiers notype_declarator %prec UNARY
2771 { $$ = make_pointer_declarator ($2.t, $3); }
2772 | '&' nonempty_cv_qualifiers notype_declarator %prec UNARY
2773 { $$ = make_reference_declarator ($2.t, $3); }
2774 | '*' notype_declarator %prec UNARY
2775 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2776 | '&' notype_declarator %prec UNARY
2777 { $$ = make_reference_declarator (NULL_TREE, $2); }
2778 | ptr_to_mem cv_qualifiers notype_declarator
2779 { tree arg = make_pointer_declarator ($2, $3);
2780 $$ = build_parse_node (SCOPE_REF, $1, arg);
2782 | direct_notype_declarator
2785 complex_notype_declarator:
2786 '*' nonempty_cv_qualifiers notype_declarator %prec UNARY
2787 { $$ = make_pointer_declarator ($2.t, $3); }
2788 | '&' nonempty_cv_qualifiers notype_declarator %prec UNARY
2789 { $$ = make_reference_declarator ($2.t, $3); }
2790 | '*' complex_notype_declarator %prec UNARY
2791 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2792 | '&' complex_notype_declarator %prec UNARY
2793 { $$ = make_reference_declarator (NULL_TREE, $2); }
2794 | ptr_to_mem cv_qualifiers notype_declarator
2795 { tree arg = make_pointer_declarator ($2, $3);
2796 $$ = build_parse_node (SCOPE_REF, $1, arg);
2798 | complex_direct_notype_declarator
2801 complex_direct_notype_declarator:
2802 direct_notype_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2803 { $$ = make_call_declarator ($$, $2, $3, $4); }
2804 | '(' complex_notype_declarator ')'
2806 | direct_notype_declarator '[' nonmomentary_expr ']'
2807 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
2808 | direct_notype_declarator '[' ']'
2809 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
2810 | notype_qualified_id
2811 { enter_scope_of ($1); }
2812 | nested_name_specifier notype_template_declarator
2813 { got_scope = NULL_TREE;
2814 $$ = build_parse_node (SCOPE_REF, $1, $2);
2815 enter_scope_of ($$);
2820 nested_name_specifier unqualified_id
2821 { got_scope = NULL_TREE;
2822 $$ = build_parse_node (SCOPE_REF, $$, $2); }
2823 | nested_name_specifier object_template_id
2824 { got_scope = NULL_TREE;
2825 $$ = build_parse_node (SCOPE_REF, $1, $2); }
2828 notype_qualified_id:
2829 nested_name_specifier notype_unqualified_id
2830 { got_scope = NULL_TREE;
2831 $$ = build_parse_node (SCOPE_REF, $$, $2); }
2832 | nested_name_specifier object_template_id
2833 { got_scope = NULL_TREE;
2834 $$ = build_parse_node (SCOPE_REF, $1, $2); }
2839 | global_scope notype_qualified_id
2844 typespec '(' nonnull_exprlist ')'
2845 { $$ = build_functional_cast ($1.t, $3); }
2846 | typespec '(' expr_or_declarator ')'
2847 { $$ = reparse_decl_as_expr ($1.t, $3); }
2848 | typespec fcast_or_absdcl %prec EMPTY
2849 { $$ = reparse_absdcl_as_expr ($1.t, $2); }
2854 | template_type %prec EMPTY
2857 nested_name_specifier:
2858 nested_name_specifier_1
2859 | nested_name_specifier nested_name_specifier_1
2861 | nested_name_specifier TEMPLATE explicit_template_type SCOPE
2862 { got_scope = $$ = make_typename_type ($1, $3); }
2865 /* Why the @#$%^& do type_name and notype_identifier need to be expanded
2866 inline here?!? (jason) */
2867 nested_name_specifier_1:
2870 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2873 /* Remember that this name has been used in the class
2874 definition, as per [class.scope0] */
2875 if (current_class_type
2876 && TYPE_BEING_DEFINED (current_class_type)
2877 && ! IDENTIFIER_CLASS_VALUE ($1))
2878 pushdecl_class_level ($$);
2880 got_scope = $$ = TYPE_MAIN_VARIANT (TREE_TYPE ($$));
2884 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2886 got_scope = $$ = TREE_TYPE ($$);
2890 if (TREE_CODE ($$) == IDENTIFIER_NODE)
2894 | template_type SCOPE
2895 { got_scope = $$ = complete_type (TREE_TYPE ($1)); }
2896 /* These break 'const i;'
2900 cp_error ("`%D' is not an aggregate typedef",
2901 lastiddecl ? lastiddecl : $$);
2902 $$ = error_mark_node;
2905 { goto failed_scope; } */
2910 | global_scope typename_sub0
2915 typename_sub1 identifier %prec EMPTY
2917 if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't')
2918 $$ = make_typename_type ($1, $2);
2919 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
2920 cp_error ("`%T' is not a class or namespace", $2);
2924 if (TREE_CODE ($$) == TYPE_DECL)
2925 $$ = TREE_TYPE ($$);
2928 | typename_sub1 template_type %prec EMPTY
2929 { $$ = TREE_TYPE ($2); }
2930 | typename_sub1 explicit_template_type %prec EMPTY
2931 { $$ = make_typename_type ($1, $2); }
2932 | typename_sub1 TEMPLATE explicit_template_type %prec EMPTY
2933 { $$ = make_typename_type ($1, $3); }
2939 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2940 cp_error ("`%T' is not a class or namespace", $1);
2942 | typename_sub1 typename_sub2
2944 if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't')
2945 $$ = make_typename_type ($1, $2);
2946 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
2947 cp_error ("`%T' is not a class or namespace", $2);
2951 if (TREE_CODE ($$) == TYPE_DECL)
2952 $$ = TREE_TYPE ($$);
2955 | typename_sub1 explicit_template_type SCOPE
2956 { got_scope = $$ = make_typename_type ($1, $2); }
2957 | typename_sub1 TEMPLATE explicit_template_type SCOPE
2958 { got_scope = $$ = make_typename_type ($1, $3); }
2964 if (TREE_CODE ($1) != IDENTIFIER_NODE)
2967 /* Retrieve the type for the identifier, which might involve
2968 some computation. */
2969 got_scope = $$ = complete_type (IDENTIFIER_TYPE_VALUE ($1));
2971 if ($$ == error_mark_node)
2972 cp_error ("`%T' is not a class or namespace", $1);
2976 if (TREE_CODE ($1) != IDENTIFIER_NODE)
2978 got_scope = $$ = complete_type (TREE_TYPE ($$));
2980 | template_type SCOPE
2981 { got_scope = $$ = complete_type (TREE_TYPE ($$)); }
2986 if (TREE_CODE ($$) == IDENTIFIER_NODE)
2992 explicit_template_type:
2993 identifier '<' template_arg_list_opt template_close_bracket
2994 { $$ = build_min_nt (TEMPLATE_ID_EXPR, $1, $3); }
2998 global_scope type_name
3000 if (TREE_CODE ($2) == IDENTIFIER_NODE)
3001 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
3004 got_scope = NULL_TREE;
3007 | global_scope nested_type
3012 nested_name_specifier '*'
3013 { got_scope = NULL_TREE; }
3014 | global_scope nested_name_specifier '*'
3015 { $$ = $2; got_scope = NULL_TREE; }
3018 /* All uses of explicit global scope must go through this nonterminal so
3019 that got_scope will be set before yylex is called to get the next token. */
3022 { got_scope = void_type_node; }
3025 /* ANSI new-declarator (5.3.4) */
3027 '*' cv_qualifiers new_declarator
3028 { $$ = make_pointer_declarator ($2, $3); }
3029 | '*' cv_qualifiers %prec EMPTY
3030 { $$ = make_pointer_declarator ($2, NULL_TREE); }
3031 | '&' cv_qualifiers new_declarator %prec EMPTY
3032 { $$ = make_reference_declarator ($2, $3); }
3033 | '&' cv_qualifiers %prec EMPTY
3034 { $$ = make_reference_declarator ($2, NULL_TREE); }
3035 | ptr_to_mem cv_qualifiers %prec EMPTY
3036 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3037 $$ = build_parse_node (SCOPE_REF, $1, arg);
3039 | ptr_to_mem cv_qualifiers new_declarator
3040 { tree arg = make_pointer_declarator ($2, $3);
3041 $$ = build_parse_node (SCOPE_REF, $1, arg);
3043 | direct_new_declarator %prec EMPTY
3046 /* ANSI direct-new-declarator (5.3.4) */
3047 direct_new_declarator:
3049 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3050 | direct_new_declarator '[' nonmomentary_expr ']'
3051 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3054 /* ANSI abstract-declarator (8.1) */
3056 '*' nonempty_cv_qualifiers absdcl
3057 { $$ = make_pointer_declarator ($2.t, $3); }
3059 { $$ = make_pointer_declarator (NULL_TREE, $2); }
3060 | '*' nonempty_cv_qualifiers %prec EMPTY
3061 { $$ = make_pointer_declarator ($2.t, NULL_TREE); }
3063 { $$ = make_pointer_declarator (NULL_TREE, NULL_TREE); }
3064 | '&' nonempty_cv_qualifiers absdcl
3065 { $$ = make_reference_declarator ($2.t, $3); }
3067 { $$ = make_reference_declarator (NULL_TREE, $2); }
3068 | '&' nonempty_cv_qualifiers %prec EMPTY
3069 { $$ = make_reference_declarator ($2.t, NULL_TREE); }
3071 { $$ = make_reference_declarator (NULL_TREE, NULL_TREE); }
3072 | ptr_to_mem cv_qualifiers %prec EMPTY
3073 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3074 $$ = build_parse_node (SCOPE_REF, $1, arg);
3076 | ptr_to_mem cv_qualifiers absdcl
3077 { tree arg = make_pointer_declarator ($2, $3);
3078 $$ = build_parse_node (SCOPE_REF, $1, arg);
3080 | direct_abstract_declarator %prec EMPTY
3083 /* ANSI direct-abstract-declarator (8.1) */
3084 direct_abstract_declarator:
3087 /* `(typedef)1' is `int'. */
3089 | direct_abstract_declarator '(' parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3090 { $$ = make_call_declarator ($$, $3, $5, $6); }
3091 | direct_abstract_declarator LEFT_RIGHT cv_qualifiers exception_specification_opt %prec '.'
3092 { $$ = make_call_declarator ($$, empty_parms (), $3, $4); }
3093 | direct_abstract_declarator '[' nonmomentary_expr ']' %prec '.'
3094 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3095 | direct_abstract_declarator '[' ']' %prec '.'
3096 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
3097 | '(' complex_parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3098 { $$ = make_call_declarator (NULL_TREE, $2, $4, $5); }
3099 | regcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3100 { set_quals_and_spec ($$, $2, $3); }
3101 | fcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3102 { set_quals_and_spec ($$, $2, $3); }
3103 | '[' nonmomentary_expr ']' %prec '.'
3104 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3106 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, NULL_TREE); }
3109 /* For C++, decls and stmts can be intermixed, so we don't need to
3110 have a special rule that won't start parsing the stmt section
3111 until we have a stmt that parses without errors. */
3124 /* Read zero or more forward-declarations for labels
3125 that nested functions can jump to. */
3130 pedwarn ("ANSI C++ forbids label declarations"); }
3135 | label_decls label_decl
3139 LABEL identifiers_or_typenames ';'
3141 for (link = $2; link; link = TREE_CHAIN (link))
3143 tree label = shadow_label (TREE_VALUE (link));
3144 C_DECLARED_LABEL_FLAG (label) = 1;
3145 declare_nonlocal_label (label);
3150 /* This is the body of a function definition.
3151 It causes syntax errors to ignore to the next openbrace. */
3160 { $<ttype>$ = begin_compound_stmt (0); }
3162 { $$ = finish_compound_stmt (0, $<ttype>2); }
3168 $<ttype>$ = begin_if_stmt ();
3169 cond_stmt_keyword = "if";
3172 { finish_if_stmt_cond ($3, $<ttype>2); }
3173 implicitly_scoped_stmt
3174 { $<ttype>$ = finish_then_clause ($<ttype>2); }
3177 implicitly_scoped_stmt:
3179 | { $<ttype>$ = begin_compound_stmt (0); }
3181 { $$ = finish_compound_stmt (0, $<ttype>1); }
3194 { finish_expr_stmt ($1); }
3196 { begin_else_clause (); }
3197 implicitly_scoped_stmt
3199 finish_else_clause ($<ttype>1);
3202 | simple_if %prec IF
3203 { finish_if_stmt (); }
3206 $<ttype>$ = begin_while_stmt ();
3207 cond_stmt_keyword = "while";
3210 { finish_while_stmt_cond ($3, $<ttype>2); }
3212 { finish_while_stmt ($<ttype>2); }
3214 { $<ttype>$ = begin_do_stmt (); }
3215 implicitly_scoped_stmt WHILE
3217 finish_do_body ($<ttype>2);
3218 cond_stmt_keyword = "do";
3220 paren_expr_or_null ';'
3221 { finish_do_stmt ($6, $<ttype>2); }
3223 { $<ttype>$ = begin_for_stmt (); }
3224 '(' for.init.statement
3225 { finish_for_init_stmt ($<ttype>2); }
3227 { finish_for_cond ($6, $<ttype>2); }
3229 { finish_for_expr ($9, $<ttype>2); }
3231 { finish_for_stmt ($9, $<ttype>2); }
3233 { begin_switch_stmt (); }
3235 { $<ttype>$ = finish_switch_cond ($4); }
3236 implicitly_scoped_stmt
3237 { finish_switch_stmt ($4, $<ttype>6); }
3238 | CASE expr_no_commas ':'
3239 { finish_case_label ($2, NULL_TREE); }
3241 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
3242 { finish_case_label ($2, $4); }
3245 { finish_case_label (NULL_TREE, NULL_TREE); }
3248 { finish_break_stmt (); }
3250 { finish_continue_stmt (); }
3252 { finish_return_stmt (NULL_TREE); }
3254 { finish_return_stmt ($2); }
3255 | asm_keyword maybe_cv_qualifier '(' string ')' ';'
3257 finish_asm_stmt ($2, $4, NULL_TREE, NULL_TREE,
3260 /* This is the case with just output operands. */
3261 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ')' ';'
3263 finish_asm_stmt ($2, $4, $6, NULL_TREE,
3266 /* This is the case with input operands as well. */
3267 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':' asm_operands ')' ';'
3268 { finish_asm_stmt ($2, $4, $6, $8, NULL_TREE); }
3269 /* This is the case with clobbered registers as well. */
3270 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':'
3271 asm_operands ':' asm_clobbers ')' ';'
3272 { finish_asm_stmt ($2, $4, $6, $8, $10); }
3276 pedwarn ("ANSI C++ forbids computed gotos");
3277 finish_goto_stmt ($3);
3279 | GOTO identifier ';'
3280 { finish_goto_stmt ($2); }
3284 { error ("label must be followed by statement");
3291 | namespace_using_decl
3292 { do_local_using_decl ($1); }
3299 if (! current_function_parms_stored)
3300 store_parm_decls ();
3301 expand_start_early_try_stmts ();
3303 ctor_initializer_opt compstmt
3305 expand_start_all_catch ();
3309 int nested = (hack_decl_function_context
3310 (current_function_decl) != NULL_TREE);
3311 expand_end_all_catch ();
3312 finish_function (lineno, (int)$3, nested);
3318 { $<ttype>$ = begin_try_block (); }
3320 { finish_try_block ($<ttype>2); }
3322 { finish_handler_sequence ($<ttype>2); }
3327 | handler_seq handler
3332 { $<ttype>$ = begin_handler(); }
3334 { finish_handler_parms ($<ttype>2); }
3336 { finish_handler ($<ttype>2); }
3340 typed_typespecs %prec EMPTY
3341 | nonempty_cv_qualifiers %prec EMPTY
3346 { expand_start_catch_block (NULL_TREE, NULL_TREE); }
3347 /* This doesn't allow reference parameters, the below does.
3348 | '(' type_specifier_seq absdcl ')'
3349 { check_for_new_type ("inside exception declarations", $2);
3350 expand_start_catch_block ($2.t, $3); }
3351 | '(' type_specifier_seq ')'
3352 { check_for_new_type ("inside exception declarations", $2);
3353 expand_start_catch_block ($2.t, NULL_TREE); }
3354 | '(' type_specifier_seq notype_declarator ')'
3355 { check_for_new_type ("inside exception declarations", $2);
3356 expand_start_catch_block ($2.t, $3); }
3357 | '(' typed_typespecs after_type_declarator ')'
3358 { check_for_new_type ("inside exception declarations", $2);
3359 expand_start_catch_block ($2.t, $3); }
3360 This allows reference parameters... */
3362 { check_for_new_type ("inside exception declarations", $2);
3363 expand_start_catch_block (TREE_PURPOSE ($2.t),
3364 TREE_VALUE ($2.t)); }
3371 label = define_label (input_filename, lineno, $1);
3372 if (label && ! minimal_parse_mode)
3373 expand_label (label);
3385 { if ($1) cplus_expand_expr_stmt ($1); }
3389 pedwarn ("ANSI C++ forbids compound statements inside for initializations");
3393 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
3397 { emit_line_note (input_filename, lineno);
3400 { emit_line_note (input_filename, lineno); }
3411 /* These are the operands other than the first string and colon
3412 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
3416 | nonnull_asm_operands
3419 nonnull_asm_operands:
3421 | nonnull_asm_operands ',' asm_operand
3422 { $$ = chainon ($$, $3); }
3427 { $$ = build_tree_list ($$, $3); }
3432 { $$ = tree_cons (NULL_TREE, $$, NULL_TREE); }
3433 | asm_clobbers ',' STRING
3434 { $$ = tree_cons (NULL_TREE, $3, $$); }
3437 /* This is what appears inside the parens in a function declarator.
3438 Its value is represented in the format that grokdeclarator expects.
3440 In C++, declaring a function with no parameters
3441 means that that function takes *no* parameters. */
3450 { $$ = finish_parmlist (build_tree_list (NULL_TREE, $1.t), 0);
3451 check_for_new_type ("inside parameter list", $1); }
3454 /* This nonterminal does not include the common sequence '(' type_id ')',
3455 as it is ambiguous and must be disambiguated elsewhere. */
3458 { $$ = finish_parmlist ($$, 0); }
3459 | parms_comma ELLIPSIS
3460 { $$ = finish_parmlist ($1, 1); }
3461 /* C++ allows an ellipsis without a separating ',' */
3463 { $$ = finish_parmlist ($1, 1); }
3465 { $$ = finish_parmlist (build_tree_list (NULL_TREE,
3468 { $$ = finish_parmlist (NULL_TREE, 1); }
3471 /* This helps us recover from really nasty
3472 parse errors, for example, a missing right
3474 yyerror ("possibly missing ')'");
3475 $$ = finish_parmlist ($1, 0);
3481 /* This helps us recover from really nasty
3482 parse errors, for example, a missing right
3484 yyerror ("possibly missing ')'");
3485 $$ = finish_parmlist (build_tree_list (NULL_TREE,
3492 /* A default argument to a */
3495 { maybe_snarf_defarg (); }
3505 /* A nonempty list of parameter declarations or type names. */
3508 { check_for_new_type ("in a parameter list", $1);
3509 $$ = build_tree_list (NULL_TREE, $1.t); }
3511 { check_for_new_type ("in a parameter list", $1);
3512 $$ = build_tree_list ($2, $1.t); }
3513 | parms_comma full_parm
3514 { check_for_new_type ("in a parameter list", $2);
3515 $$ = chainon ($$, $2.t); }
3516 | parms_comma bad_parm
3517 { $$ = chainon ($$, build_tree_list (NULL_TREE, $2)); }
3518 | parms_comma bad_parm '=' init
3519 { $$ = chainon ($$, build_tree_list ($4, $2)); }
3525 { check_for_new_type ("in a parameter list", $1);
3526 $$ = build_tree_list (NULL_TREE, $1.t); }
3529 /* A single parameter declaration or parameter type name,
3530 as found in a parmlist. */
3532 /* Here we expand typed_declspecs inline to avoid mis-parsing of
3533 TYPESPEC IDENTIFIER. */
3534 typed_declspecs1 declarator
3535 { tree specs = strip_attrs ($1.t);
3536 $$.new_type_flag = $1.new_type_flag;
3537 $$.t = build_tree_list (specs, $2); }
3538 | typed_typespecs declarator
3539 { $$.t = build_tree_list ($1.t, $2);
3540 $$.new_type_flag = $1.new_type_flag; }
3541 | typespec declarator
3542 { $$.t = build_tree_list (get_decl_list ($1.t), $2);
3543 $$.new_type_flag = $1.new_type_flag; }
3544 | typed_declspecs1 absdcl
3545 { tree specs = strip_attrs ($1.t);
3546 $$.t = build_tree_list (specs, $2);
3547 $$.new_type_flag = $1.new_type_flag; }
3548 | typed_declspecs1 %prec EMPTY
3549 { tree specs = strip_attrs ($1.t);
3550 $$.t = build_tree_list (specs, NULL_TREE);
3551 $$.new_type_flag = $1.new_type_flag; }
3552 | declmods notype_declarator
3553 { tree specs = strip_attrs ($1);
3554 $$.t = build_tree_list (specs, $2);
3555 $$.new_type_flag = 0; }
3560 { $$.t = build_tree_list (NULL_TREE, $1.t);
3561 $$.new_type_flag = $1.new_type_flag; }
3563 { $$.t = build_tree_list ($2, $1.t);
3564 $$.new_type_flag = $1.new_type_flag; }
3573 /* empty */ %prec EMPTY
3574 { see_typename (); }
3578 /* empty */ %prec EMPTY
3580 error ("type specifier omitted for parameter");
3581 $$ = build_tree_list (integer_type_node, NULL_TREE);
3585 error ("type specifier omitted for parameter");
3586 if (TREE_CODE ($$) == SCOPE_REF
3587 && (TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TYPE_PARM
3588 || TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TEMPLATE_PARM))
3589 cp_error (" perhaps you want `typename %E' to make it a type", $$);
3590 $$ = build_tree_list (integer_type_node, $$);
3594 exception_specification_opt:
3595 /* empty */ %prec EMPTY
3597 | THROW '(' ansi_raise_identifiers ')' %prec EMPTY
3599 | THROW LEFT_RIGHT %prec EMPTY
3600 { $$ = build_decl_list (NULL_TREE, NULL_TREE); }
3603 ansi_raise_identifier:
3605 { $$ = build_decl_list (NULL_TREE, groktypename($1.t)); }
3608 ansi_raise_identifiers:
3609 ansi_raise_identifier
3610 | ansi_raise_identifiers ',' ansi_raise_identifier
3612 TREE_CHAIN ($3) = $$;
3617 conversion_declarator:
3618 /* empty */ %prec EMPTY
3620 | '*' cv_qualifiers conversion_declarator
3621 { $$ = make_pointer_declarator ($2, $3); }
3622 | '&' cv_qualifiers conversion_declarator
3623 { $$ = make_reference_declarator ($2, $3); }
3624 | ptr_to_mem cv_qualifiers conversion_declarator
3625 { tree arg = make_pointer_declarator ($2, $3);
3626 $$ = build_parse_node (SCOPE_REF, $1, arg);
3632 { got_scope = NULL_TREE; }
3637 { $$ = ansi_opname[MULT_EXPR]; }
3639 { $$ = ansi_opname[TRUNC_DIV_EXPR]; }
3641 { $$ = ansi_opname[TRUNC_MOD_EXPR]; }
3643 { $$ = ansi_opname[PLUS_EXPR]; }
3645 { $$ = ansi_opname[MINUS_EXPR]; }
3647 { $$ = ansi_opname[BIT_AND_EXPR]; }
3649 { $$ = ansi_opname[BIT_IOR_EXPR]; }
3651 { $$ = ansi_opname[BIT_XOR_EXPR]; }
3653 { $$ = ansi_opname[BIT_NOT_EXPR]; }
3655 { $$ = ansi_opname[COMPOUND_EXPR]; }
3656 | operator ARITHCOMPARE
3657 { $$ = ansi_opname[$2]; }
3659 { $$ = ansi_opname[LT_EXPR]; }
3661 { $$ = ansi_opname[GT_EXPR]; }
3662 | operator EQCOMPARE
3663 { $$ = ansi_opname[$2]; }
3665 { $$ = ansi_assopname[$2]; }
3667 { $$ = ansi_opname [MODIFY_EXPR]; }
3669 { $$ = ansi_opname[$2]; }
3671 { $$ = ansi_opname[$2]; }
3673 { $$ = ansi_opname[POSTINCREMENT_EXPR]; }
3674 | operator MINUSMINUS
3675 { $$ = ansi_opname[PREDECREMENT_EXPR]; }
3677 { $$ = ansi_opname[TRUTH_ANDIF_EXPR]; }
3679 { $$ = ansi_opname[TRUTH_ORIF_EXPR]; }
3681 { $$ = ansi_opname[TRUTH_NOT_EXPR]; }
3683 { $$ = ansi_opname[COND_EXPR]; }
3685 { $$ = ansi_opname[$2]; }
3686 | operator POINTSAT %prec EMPTY
3687 { $$ = ansi_opname[COMPONENT_REF]; }
3688 | operator POINTSAT_STAR %prec EMPTY
3689 { $$ = ansi_opname[MEMBER_REF]; }
3690 | operator LEFT_RIGHT
3691 { $$ = ansi_opname[CALL_EXPR]; }
3693 { $$ = ansi_opname[ARRAY_REF]; }
3694 | operator NEW %prec EMPTY
3695 { $$ = ansi_opname[NEW_EXPR]; }
3696 | operator DELETE %prec EMPTY
3697 { $$ = ansi_opname[DELETE_EXPR]; }
3698 | operator NEW '[' ']'
3699 { $$ = ansi_opname[VEC_NEW_EXPR]; }
3700 | operator DELETE '[' ']'
3701 { $$ = ansi_opname[VEC_DELETE_EXPR]; }
3702 /* Names here should be looked up in class scope ALSO. */
3703 | operator type_specifier_seq conversion_declarator
3704 { $$ = grokoptypename ($2.t, $3); }
3706 { $$ = ansi_opname[ERROR_MARK]; }
3713 debug_yytranslate (value)
3716 return yytname[YYTRANSLATE (value)];