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> notype_declarator_intern
207 %type <ttype> direct_notype_declarator direct_after_type_declarator
208 %type <itype> components notype_components
209 %type <ttype> component_decl component_decl_1
210 %type <ttype> component_declarator component_declarator0
211 %type <ttype> notype_component_declarator notype_component_declarator0
212 %type <ttype> after_type_component_declarator after_type_component_declarator0
213 %type <ttype> enumlist enumerator
214 %type <ttype> absdcl cv_qualifiers
215 %type <ttype> direct_abstract_declarator conversion_declarator
216 %type <ttype> new_declarator direct_new_declarator
217 %type <ttype> xexpr parmlist parms bad_parm
218 %type <ttype> identifiers_or_typenames
219 %type <ttype> fcast_or_absdcl regcast_or_absdcl
220 %type <ttype> expr_or_declarator expr_or_declarator_intern
221 %type <ttype> complex_notype_declarator
222 %type <ttype> notype_unqualified_id unqualified_id qualified_id
223 %type <ttype> template_id do_id object_template_id notype_template_declarator
224 %type <ttype> overqualified_id notype_qualified_id any_id
225 %type <ttype> complex_direct_notype_declarator functional_cast
226 %type <ttype> complex_parmlist parms_comma
227 %type <ttype> namespace_qualifier namespace_using_decl
229 %type <ftype> type_id new_type_id typed_typespecs typespec typed_declspecs
230 %type <ftype> typed_declspecs1 type_specifier_seq nonempty_cv_qualifiers
231 %type <ftype> structsp typespecqual_reserved parm named_parm full_parm
234 %token <ttype> PTYPENAME
235 %token <ttype> PRE_PARSED_FUNCTION_DECL EXTERN_LANG_STRING ALL
236 %token <ttype> PRE_PARSED_CLASS_DECL DEFARG DEFARG_MARKER
237 %type <ttype> component_constructor_declarator
238 %type <ttype> fn.def2 return_id fn.defpen constructor_declarator
239 %type <itype> ctor_initializer_opt
240 %type <ttype> named_class_head named_class_head_sans_basetype
241 %type <ttype> named_complex_class_head_sans_basetype
242 %type <ttype> unnamed_class_head
243 %type <ttype> class_head base_class_list
244 %type <ttype> base_class_access_list
245 %type <ttype> base_class maybe_base_class_list base_class.1
246 %type <ttype> exception_specification_opt ansi_raise_identifier ansi_raise_identifiers
247 %type <ttype> operator_name
248 %type <ttype> object aggr
249 %type <itype> new delete .begin_new_placement
250 /* %type <ttype> primary_no_id */
251 %type <ttype> nonmomentary_expr maybe_parmlist
252 %type <itype> initdcl0 notype_initdcl0 member_init_list initdcl0_innards
253 %type <ttype> template_header template_parm_list template_parm
254 %type <ttype> template_type_parm template_template_parm
255 %type <code> template_close_bracket
256 %type <ttype> apparent_template_type
257 %type <ttype> template_type template_arg_list template_arg_list_opt
258 %type <ttype> template_arg
259 %type <ttype> condition xcond paren_cond_or_null
260 %type <ttype> type_name nested_name_specifier nested_type ptr_to_mem
261 %type <ttype> complete_type_name notype_identifier nonnested_type
262 %type <ttype> complex_type_name nested_name_specifier_1
263 %type <ttype> new_initializer new_placement
264 %type <ttype> using_decl
265 %type <ttype> typename_sub typename_sub0 typename_sub1 typename_sub2
266 %type <ttype> explicit_template_type
267 /* in order to recognize aggr tags as defining and thus shadowing. */
268 %token TYPENAME_DEFN IDENTIFIER_DEFN PTYPENAME_DEFN
269 %type <ttype> named_class_head_sans_basetype_defn
270 %type <ttype> identifier_defn IDENTIFIER_DEFN TYPENAME_DEFN PTYPENAME_DEFN
272 %type <ttype> self_template_type .finish_template_type
277 /* Used in lex.c for parsing pragmas. */
280 /* lex.c and pt.c depend on this being the last token. Define
281 any new tokens before this one! */
282 %token END_OF_SAVED_INPUT
285 /* List of types and structure classes of the current declaration. */
286 static tree current_declspecs;
288 /* List of prefix attributes in effect.
289 Prefix attributes are parsed by the reserved_declspecs and declmods
290 rules. They create a list that contains *both* declspecs and attrs. */
291 /* ??? It is not clear yet that all cases where an attribute can now appear in
292 a declspec list have been updated. */
293 static tree prefix_attributes;
295 /* When defining an aggregate, this is the kind of the most recent one
296 being defined. (For example, this might be class_type_node.) */
297 static tree current_aggr;
299 /* When defining an enumeration, this is the type of the enumeration. */
300 static tree current_enum_type;
302 /* Tell yyparse how to print a token's value, if yydebug is set. */
304 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
305 extern void yyprint PROTO((FILE *, int, YYSTYPE));
306 extern tree combine_strings PROTO((tree));
309 parse_decl(declarator, specs_attrs, attributes, initialized, decl)
318 split_specs_attrs (specs_attrs, ¤t_declspecs, &prefix_attributes);
319 if (current_declspecs
320 && TREE_CODE (current_declspecs) != TREE_LIST)
321 current_declspecs = get_decl_list (current_declspecs);
322 if (have_extern_spec && !used_extern_spec)
324 current_declspecs = decl_tree_cons (NULL_TREE,
325 get_identifier ("extern"),
327 used_extern_spec = 1;
329 sm = suspend_momentary ();
330 *decl = start_decl (declarator, current_declspecs, initialized,
331 attributes, prefix_attributes);
340 { finish_translation_unit (); }
343 /* the reason for the strange actions in this rule
344 is so that notype_initdecls when reached via datadef
345 can find a valid list of type and sc specs in $0. */
348 { $<ttype>$ = NULL_TREE; }
350 { $<ttype>$ = NULL_TREE; }
351 | extdefs lang_extdef
352 { $<ttype>$ = NULL_TREE; }
361 { have_extern_spec = 1;
362 used_extern_spec = 0;
363 $<ttype>$ = NULL_TREE; }
366 { have_extern_spec = 0; }
371 { $<itype>$ = pedantic;
380 { if (pending_lang_change) do_pending_lang_change(); }
382 { if (! toplevel_bindings_p () && ! pseudo_global_level_p())
387 fndef eat_saved_input
388 { if (pending_inlines) do_pending_inlines (); }
390 { if (pending_inlines) do_pending_inlines (); }
392 { if (pending_inlines) do_pending_inlines (); }
393 | asm_keyword '(' string ')' ';'
394 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
396 | extern_lang_string '{' extdefs_opt '}'
397 { pop_lang_context (); }
398 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
399 { if (pending_inlines) do_pending_inlines ();
400 pop_lang_context (); }
401 | extern_lang_string .hush_warning datadef .warning_ok
402 { if (pending_inlines) do_pending_inlines ();
403 pop_lang_context (); }
404 | NAMESPACE identifier '{'
405 { push_namespace ($2); }
407 { pop_namespace (); }
409 { push_namespace (NULL_TREE); }
411 { pop_namespace (); }
414 { do_toplevel_using_decl ($1); }
417 { pedantic = $<itype>1; }
421 NAMESPACE identifier '='
422 { begin_only_namespace_names (); }
425 end_only_namespace_names ();
428 do_namespace_alias ($2, $5);
435 | USING global_scope qualified_id
437 | USING global_scope unqualified_id
441 namespace_using_decl:
442 USING namespace_qualifier identifier
443 { $$ = build_parse_node (SCOPE_REF, $2, $3); }
444 | USING global_scope identifier
445 { $$ = build_parse_node (SCOPE_REF, global_namespace, $3); }
446 | USING global_scope namespace_qualifier identifier
447 { $$ = build_parse_node (SCOPE_REF, $3, $4); }
452 { begin_only_namespace_names (); }
455 end_only_namespace_names ();
456 /* If no declaration was found, the using-directive is
457 invalid. Since that was not reported, we need the
458 identifier for the error message. */
459 if (TREE_CODE ($4) == IDENTIFIER_NODE && lastiddecl)
461 do_using_directive ($4);
468 if (TREE_CODE ($$) == IDENTIFIER_NODE)
472 | namespace_qualifier NSNAME SCOPE
475 if (TREE_CODE ($$) == IDENTIFIER_NODE)
483 | global_scope qualified_id
485 | global_scope unqualified_id
491 { push_lang_context ($1); }
492 | extern_lang_string EXTERN_LANG_STRING
493 { if (current_lang_name != $2)
494 cp_error ("use of linkage spec `%D' is different from previous spec `%D'", $2, current_lang_name);
495 pop_lang_context (); push_lang_context ($2); }
500 { begin_template_parm_list (); }
501 template_parm_list '>'
502 { $$ = end_template_parm_list ($4); }
504 { begin_specialization();
510 { $$ = process_template_parm (NULL_TREE, $1); }
511 | template_parm_list ',' template_parm
512 { $$ = process_template_parm ($1, $3); }
522 aggr maybe_identifier
523 { $$ = finish_template_type_parm ($1, $2); }
524 | TYPENAME_KEYWORD maybe_identifier
525 { $$ = finish_template_type_parm (class_type_node, $2); }
528 template_template_parm:
529 template_header aggr maybe_identifier
530 { $$ = finish_template_template_parm ($2, $3); }
534 /* The following rules introduce a new reduce/reduce
535 conflict on the ',' and '>' input tokens: they are valid
536 prefixes for a `structsp', which means they could match a
537 nameless parameter. See 14.6, paragraph 3.
538 By putting them before the `parm' rule, we get
539 their match before considering them nameless parameter
542 { $$ = build_tree_list (NULL_TREE, $1); }
543 | template_type_parm '=' type_id
544 { $$ = build_tree_list (groktypename ($3.t), $1); }
546 { $$ = build_tree_list (NULL_TREE, $1.t); }
547 | parm '=' expr_no_commas %prec ARITHCOMPARE
548 { $$ = build_tree_list ($3, $1.t); }
549 | template_template_parm
550 { $$ = build_tree_list (NULL_TREE, $1); }
551 | template_template_parm '=' template_arg
553 if (TREE_CODE ($3) != TEMPLATE_DECL
554 && TREE_CODE ($3) != TEMPLATE_TEMPLATE_PARM
555 && TREE_CODE ($3) != TYPE_DECL)
557 error ("invalid default template argument");
558 $3 = error_mark_node;
560 $$ = build_tree_list ($3, $1);
565 template_header template_extdef
566 { finish_template_decl ($1); }
567 | template_header error %prec EMPTY
568 { finish_template_decl ($1); }
572 fndef eat_saved_input
573 { if (pending_inlines) do_pending_inlines (); }
575 { if (pending_inlines) do_pending_inlines (); }
577 { if (pending_inlines) do_pending_inlines (); }
578 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
579 { if (pending_inlines) do_pending_inlines ();
580 pop_lang_context (); }
581 | extern_lang_string .hush_warning template_datadef .warning_ok
582 { if (pending_inlines) do_pending_inlines ();
583 pop_lang_context (); }
584 | extension template_extdef
585 { pedantic = $<itype>1; }
590 | declmods notype_initdecls ';'
592 | typed_declspecs initdecls ';'
593 { note_list_got_semicolon ($1.t); }
595 { maybe_process_partial_specialization ($1.t);
596 note_got_semicolon ($1.t); }
601 | declmods notype_initdecls ';'
603 | typed_declspecs initdecls ';'
604 { note_list_got_semicolon ($1.t); }
606 { pedwarn ("empty declaration"); }
607 | explicit_instantiation ';'
608 | typed_declspecs ';'
611 split_specs_attrs ($1.t, &t, &attrs);
613 note_list_got_semicolon ($1.t);
620 ctor_initializer_opt:
639 fn.def1 maybe_return_init ctor_initializer_opt compstmt_or_error
640 { finish_function (lineno, (int)$3, 0); }
641 | fn.def1 maybe_return_init function_try_block
643 | fn.def1 maybe_return_init error
647 constructor_declarator:
648 nested_name_specifier SELFNAME '('
649 { $$ = begin_constructor_declarator ($1, $2); }
650 parmlist ')' cv_qualifiers exception_specification_opt
651 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
652 | nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
653 { $$ = begin_constructor_declarator ($1, $2);
654 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
656 | global_scope nested_name_specifier SELFNAME '('
657 { $$ = begin_constructor_declarator ($2, $3); }
658 parmlist ')' cv_qualifiers exception_specification_opt
659 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
660 | global_scope nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
661 { $$ = begin_constructor_declarator ($2, $3);
662 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
664 | nested_name_specifier self_template_type '('
665 { $$ = begin_constructor_declarator ($1, $2); }
666 parmlist ')' cv_qualifiers exception_specification_opt
667 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
668 | nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
669 { $$ = begin_constructor_declarator ($1, $2);
670 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
672 | global_scope nested_name_specifier self_template_type '('
673 { $$ = begin_constructor_declarator ($2, $3); }
674 parmlist ')' cv_qualifiers exception_specification_opt
675 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
676 | global_scope nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
677 { $$ = begin_constructor_declarator ($2, $3);
678 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
683 typed_declspecs declarator
684 { if (!begin_function_definition ($1.t, $2))
686 | declmods notype_declarator
687 { if (!begin_function_definition ($1, $2))
690 { if (!begin_function_definition (NULL_TREE, $1))
692 | declmods constructor_declarator
693 { if (!begin_function_definition ($1, $2))
695 | constructor_declarator
696 { if (!begin_function_definition (NULL_TREE, $1))
700 component_constructor_declarator:
701 SELFNAME '(' parmlist ')' cv_qualifiers exception_specification_opt
702 { $$ = make_call_declarator ($1, $3, $5, $6); }
703 | SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
704 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
705 | self_template_type '(' parmlist ')' cv_qualifiers exception_specification_opt
706 { $$ = make_call_declarator ($1, $3, $5, $6); }
707 | self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
708 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
711 /* more C++ complexity. See component_decl for a comment on the
712 reduce/reduce conflict introduced by these rules. */
714 declmods component_constructor_declarator
716 split_specs_attrs ($1, &specs, &attrs);
717 attrs = build_tree_list (attrs, NULL_TREE);
718 $$ = start_method (specs, $2, attrs);
722 if (yychar == YYEMPTY)
724 reinit_parse_for_method (yychar, $$); }
725 | component_constructor_declarator
726 { $$ = start_method (NULL_TREE, $1, NULL_TREE);
728 | typed_declspecs declarator
730 split_specs_attrs ($1.t, &specs, &attrs);
731 attrs = build_tree_list (attrs, NULL_TREE);
732 $$ = start_method (specs, $2, attrs); goto rest_of_mdef; }
733 | declmods notype_declarator
735 split_specs_attrs ($1, &specs, &attrs);
736 attrs = build_tree_list (attrs, NULL_TREE);
737 $$ = start_method (specs, $2, attrs); goto rest_of_mdef; }
739 { $$ = start_method (NULL_TREE, $$, NULL_TREE);
741 | declmods constructor_declarator
743 split_specs_attrs ($1, &specs, &attrs);
744 attrs = build_tree_list (attrs, NULL_TREE);
745 $$ = start_method (specs, $2, attrs); goto rest_of_mdef; }
746 | constructor_declarator
747 { $$ = start_method (NULL_TREE, $$, NULL_TREE);
754 if (! current_function_parms_stored)
762 { store_return_init ($<ttype>$, $2); }
763 | return_id '(' nonnull_exprlist ')'
764 { store_return_init ($<ttype>$, $3); }
765 | return_id LEFT_RIGHT
766 { store_return_init ($<ttype>$, NULL_TREE); }
770 ':' .set_base_init member_init_list
773 error ("no base initializers given following ':'");
775 /* Always keep the BLOCK node associated with the outermost
776 pair of curley braces of a function. These are needed
777 for correct operation of dwarfout.c. */
785 if (! current_function_parms_stored)
788 if (DECL_CONSTRUCTOR_P (current_function_decl))
790 /* Make a contour for the initializer list. */
793 expand_start_bindings (0);
795 else if (current_class_type == NULL_TREE)
796 error ("base initializers not allowed for non-member functions");
797 else if (! DECL_CONSTRUCTOR_P (current_function_decl))
798 error ("only constructors take base initializers");
807 | member_init_list ',' member_init
808 | member_init_list error
812 '(' nonnull_exprlist ')'
814 if (current_class_name)
815 pedwarn ("anachronistic old style base class initializer");
816 expand_member_init (current_class_ref, NULL_TREE, $2);
820 if (current_class_name)
821 pedwarn ("anachronistic old style base class initializer");
822 expand_member_init (current_class_ref, NULL_TREE, void_type_node);
824 | notype_identifier '(' nonnull_exprlist ')'
825 { expand_member_init (current_class_ref, $1, $3); }
826 | notype_identifier LEFT_RIGHT
827 { expand_member_init (current_class_ref, $1, void_type_node); }
828 | nonnested_type '(' nonnull_exprlist ')'
829 { expand_member_init (current_class_ref, $1, $3); }
830 | nonnested_type LEFT_RIGHT
831 { expand_member_init (current_class_ref, $1, void_type_node); }
832 | typename_sub '(' nonnull_exprlist ')'
833 { expand_member_init (current_class_ref, TYPE_MAIN_DECL ($1),
835 | typename_sub LEFT_RIGHT
836 { expand_member_init (current_class_ref, TYPE_MAIN_DECL ($1),
860 explicit_instantiation:
861 TEMPLATE begin_explicit_instantiation typespec ';'
862 { do_type_instantiation ($3.t, NULL_TREE);
864 end_explicit_instantiation
865 | TEMPLATE begin_explicit_instantiation typed_declspecs declarator
866 { tree specs = strip_attrs ($3.t);
867 do_decl_instantiation (specs, $4, NULL_TREE); }
868 end_explicit_instantiation
869 | TEMPLATE begin_explicit_instantiation notype_declarator
870 { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
871 end_explicit_instantiation
872 | TEMPLATE begin_explicit_instantiation constructor_declarator
873 { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
874 end_explicit_instantiation
875 | SCSPEC TEMPLATE begin_explicit_instantiation typespec ';'
876 { do_type_instantiation ($4.t, $1);
878 end_explicit_instantiation
879 | SCSPEC TEMPLATE begin_explicit_instantiation typed_declspecs
881 { tree specs = strip_attrs ($4.t);
882 do_decl_instantiation (specs, $5, $1); }
883 end_explicit_instantiation
884 | SCSPEC TEMPLATE begin_explicit_instantiation notype_declarator
885 { do_decl_instantiation (NULL_TREE, $4, $1); }
886 end_explicit_instantiation
887 | SCSPEC TEMPLATE begin_explicit_instantiation constructor_declarator
888 { do_decl_instantiation (NULL_TREE, $4, $1); }
889 end_explicit_instantiation
892 begin_explicit_instantiation:
893 { begin_explicit_instantiation(); }
895 end_explicit_instantiation:
896 { end_explicit_instantiation(); }
898 /* The TYPENAME expansions are to deal with use of a template class name as
899 a template within the class itself, where the template decl is hidden by
900 a type decl. Got all that? */
903 PTYPENAME '<' template_arg_list_opt template_close_bracket
904 .finish_template_type
906 | TYPENAME '<' template_arg_list_opt template_close_bracket
907 .finish_template_type
912 apparent_template_type:
914 | identifier '<' template_arg_list_opt '>'
915 .finish_template_type
917 cp_error ("template class %T was not declared yet", $1);
922 SELFNAME '<' template_arg_list_opt template_close_bracket
923 .finish_template_type
927 .finish_template_type:
929 if (yychar == YYEMPTY)
932 $$ = finish_template_type ($<ttype>-3, $<ttype>-1,
936 template_close_bracket:
940 /* Handle `Class<Class<Type>>' without space in the `>>' */
941 pedwarn ("`>>' should be `> >' in template class name");
946 template_arg_list_opt:
954 { $$ = build_tree_list (NULL_TREE, $$); }
955 | template_arg_list ',' template_arg
956 { $$ = chainon ($$, build_tree_list (NULL_TREE, $3)); }
961 { $$ = groktypename ($1.t); }
964 | expr_no_commas %prec ARITHCOMPARE
969 { $$ = NEGATE_EXPR; }
971 { $$ = CONVERT_EXPR; }
973 { $$ = PREINCREMENT_EXPR; }
975 { $$ = PREDECREMENT_EXPR; }
977 { $$ = TRUTH_NOT_EXPR; }
982 { $$ = build_x_compound_expr ($$); }
988 { error ("ANSI C++ forbids an empty condition for `%s'",
990 $$ = integer_zero_node; }
997 { error ("ANSI C++ forbids an empty condition for `%s'",
999 $$ = integer_zero_node; }
1013 type_specifier_seq declarator maybeasm maybe_attribute '='
1016 for (d = getdecls (); d; d = TREE_CHAIN (d))
1017 if (TREE_CODE (d) == TYPE_DECL) {
1018 tree s = TREE_TYPE (d);
1019 if (TREE_CODE (s) == RECORD_TYPE)
1020 cp_error ("definition of class `%T' in condition", s);
1021 else if (TREE_CODE (s) == ENUMERAL_TYPE)
1022 cp_error ("definition of enum `%T' in condition", s);
1025 current_declspecs = $1.t;
1026 $<itype>5 = suspend_momentary ();
1027 $<ttype>$ = start_decl ($<ttype>2, current_declspecs, 1,
1028 $4, /*prefix_attributes*/ NULL_TREE);
1032 cp_finish_decl ($<ttype>6, $7, $4, 1, LOOKUP_ONLYCONVERTING);
1033 resume_momentary ($<itype>5);
1034 $$ = convert_from_reference ($<ttype>6);
1035 if (TREE_CODE (TREE_TYPE ($$)) == ARRAY_TYPE)
1036 cp_error ("definition of array `%#D' in condition", $$);
1043 | maybe_label_decls stmts '}'
1044 | maybe_label_decls stmts error '}'
1045 | maybe_label_decls error '}'
1048 already_scoped_stmt:
1050 { $<ttype>$ = begin_compound_stmt (1); }
1052 { finish_compound_stmt (1, $<ttype>2); }
1057 nontrivial_exprlist:
1058 expr_no_commas ',' expr_no_commas
1059 { $$ = expr_tree_cons (NULL_TREE, $$,
1060 build_expr_list (NULL_TREE, $3)); }
1061 | expr_no_commas ',' error
1062 { $$ = expr_tree_cons (NULL_TREE, $$,
1063 build_expr_list (NULL_TREE, error_mark_node)); }
1064 | nontrivial_exprlist ',' expr_no_commas
1065 { chainon ($$, build_expr_list (NULL_TREE, $3)); }
1066 | nontrivial_exprlist ',' error
1067 { chainon ($$, build_expr_list (NULL_TREE, error_mark_node)); }
1072 { $$ = build_expr_list (NULL_TREE, $$); }
1073 | nontrivial_exprlist
1079 /* __extension__ turns off -pedantic for following primary. */
1080 | extension cast_expr %prec UNARY
1082 pedantic = $<itype>1; }
1083 | '*' cast_expr %prec UNARY
1084 { $$ = build_x_indirect_ref ($2, "unary *"); }
1085 | '&' cast_expr %prec UNARY
1086 { $$ = build_x_unary_op (ADDR_EXPR, $2); }
1088 { $$ = build_x_unary_op (BIT_NOT_EXPR, $2); }
1089 | unop cast_expr %prec UNARY
1090 { $$ = finish_unary_op_expr ($1, $2); }
1091 /* Refer to the address of a label as a pointer. */
1094 pedwarn ("ANSI C++ forbids `&&'");
1095 $$ = finish_label_address_expr ($2); }
1096 | SIZEOF unary_expr %prec UNARY
1097 { $$ = expr_sizeof ($2); }
1098 | SIZEOF '(' type_id ')' %prec HYPERUNARY
1099 { $$ = c_sizeof (groktypename ($3.t));
1100 check_for_new_type ("sizeof", $3); }
1101 | ALIGNOF unary_expr %prec UNARY
1102 { $$ = grok_alignof ($2); }
1103 | ALIGNOF '(' type_id ')' %prec HYPERUNARY
1104 { $$ = c_alignof (groktypename ($3.t));
1105 check_for_new_type ("alignof", $3); }
1107 /* The %prec EMPTY's here are required by the = init initializer
1108 syntax extension; see below. */
1109 | new new_type_id %prec EMPTY
1110 { $$ = build_new (NULL_TREE, $2.t, NULL_TREE, $1);
1111 check_for_new_type ("new", $2); }
1112 | new new_type_id new_initializer
1113 { $$ = build_new (NULL_TREE, $2.t, $3, $1);
1114 check_for_new_type ("new", $2); }
1115 | new new_placement new_type_id %prec EMPTY
1116 { $$ = build_new ($2, $3.t, NULL_TREE, $1);
1117 check_for_new_type ("new", $3); }
1118 | new new_placement new_type_id new_initializer
1119 { $$ = build_new ($2, $3.t, $4, $1);
1120 check_for_new_type ("new", $3); }
1121 /* The .begin_new_placement in the following rules is
1122 necessary to avoid shift/reduce conflicts that lead to
1123 mis-parsing some expressions. Of course, these constructs
1124 are not really new-placement and it is bogus to call
1125 begin_new_placement. But, the parser cannot always tell at this
1126 point whether the next thing is an expression or a type-id,
1127 so there is nothing we can do. Fortunately,
1128 begin_new_placement does nothing harmful. When we rewrite
1129 the parser, this lossage should be removed, of course. */
1130 | new '(' .begin_new_placement type_id .finish_new_placement
1132 { $$ = build_new (NULL_TREE, groktypename($4.t),
1134 check_for_new_type ("new", $4); }
1135 | new '(' .begin_new_placement type_id .finish_new_placement
1137 { $$ = build_new (NULL_TREE, groktypename($4.t), $6, $1);
1138 check_for_new_type ("new", $4); }
1139 | new new_placement '(' .begin_new_placement type_id
1140 .finish_new_placement %prec EMPTY
1141 { $$ = build_new ($2, groktypename($5.t), NULL_TREE, $1);
1142 check_for_new_type ("new", $5); }
1143 | new new_placement '(' .begin_new_placement type_id
1144 .finish_new_placement new_initializer
1145 { $$ = build_new ($2, groktypename($5.t), $7, $1);
1146 check_for_new_type ("new", $5); }
1148 | delete cast_expr %prec UNARY
1149 { $$ = delete_sanity ($2, NULL_TREE, 0, $1); }
1150 | delete '[' ']' cast_expr %prec UNARY
1151 { $$ = delete_sanity ($4, NULL_TREE, 1, $1);
1152 if (yychar == YYEMPTY)
1154 | delete '[' expr ']' cast_expr %prec UNARY
1155 { $$ = delete_sanity ($5, $3, 2, $1);
1156 if (yychar == YYEMPTY)
1158 | REALPART cast_expr %prec UNARY
1159 { $$ = build_x_unary_op (REALPART_EXPR, $2); }
1160 | IMAGPART cast_expr %prec UNARY
1161 { $$ = build_x_unary_op (IMAGPART_EXPR, $2); }
1164 /* Note this rule is not suitable for use in new_placement
1165 since it uses NULL_TREE as the argument to
1166 finish_new_placement. This rule serves only to avoid
1167 reduce/reduce conflicts in unary_expr. See the comments
1168 there on the use of begin/finish_new_placement. */
1169 .finish_new_placement:
1171 { finish_new_placement (NULL_TREE, $<itype>-1); }
1173 .begin_new_placement:
1174 { $$ = begin_new_placement (); }
1177 '(' .begin_new_placement nonnull_exprlist ')'
1178 { $$ = finish_new_placement ($3, $2); }
1179 | '{' .begin_new_placement nonnull_exprlist '}'
1180 { cp_pedwarn ("old style placement syntax, use () instead");
1181 $$ = finish_new_placement ($3, $2); }
1185 '(' nonnull_exprlist ')'
1191 cp_error ("`%T' is not a valid expression", $2.t);
1192 $$ = error_mark_node;
1194 /* GNU extension so people can use initializer lists. Note that
1195 this alters the meaning of `new int = 1', which was previously
1196 syntactically valid but semantically invalid. */
1200 pedwarn ("ANSI C++ forbids initialization of new expression with `='");
1201 if (TREE_CODE ($2) != TREE_LIST
1202 && TREE_CODE ($2) != CONSTRUCTOR)
1203 $$ = build_expr_list (NULL_TREE, $2);
1209 /* This is necessary to postpone reduction of `int ((int)(int)(int))'. */
1211 '(' type_id ')' %prec EMPTY
1212 { $2.t = finish_parmlist (build_tree_list (NULL_TREE, $2.t), 0);
1213 $$ = make_call_declarator (NULL_TREE, $2.t, NULL_TREE, NULL_TREE);
1214 check_for_new_type ("cast", $2); }
1215 | regcast_or_absdcl '(' type_id ')' %prec EMPTY
1216 { $3.t = finish_parmlist (build_tree_list (NULL_TREE, $3.t), 0);
1217 $$ = make_call_declarator ($$, $3.t, NULL_TREE, NULL_TREE);
1218 check_for_new_type ("cast", $3); }
1223 | regcast_or_absdcl unary_expr %prec UNARY
1224 { $$ = reparse_absdcl_as_casts ($$, $2); }
1225 | regcast_or_absdcl '{' initlist maybecomma '}' %prec UNARY
1227 tree init = build_nt (CONSTRUCTOR, NULL_TREE,
1230 pedwarn ("ANSI C++ forbids constructor-expressions");
1231 /* Indicate that this was a GNU C constructor expression. */
1232 TREE_HAS_CONSTRUCTOR (init) = 1;
1234 $$ = reparse_absdcl_as_casts ($$, init);
1240 /* Handle general members. */
1241 | expr_no_commas POINTSAT_STAR expr_no_commas
1242 { $$ = build_x_binary_op (MEMBER_REF, $$, $3); }
1243 | expr_no_commas DOT_STAR expr_no_commas
1244 { $$ = build_m_component_ref ($$, $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 '/' expr_no_commas
1252 { $$ = build_x_binary_op ($2, $$, $3); }
1253 | expr_no_commas '%' expr_no_commas
1254 { $$ = build_x_binary_op ($2, $$, $3); }
1255 | expr_no_commas LSHIFT expr_no_commas
1256 { $$ = build_x_binary_op ($2, $$, $3); }
1257 | expr_no_commas RSHIFT expr_no_commas
1258 { $$ = build_x_binary_op ($2, $$, $3); }
1259 | expr_no_commas ARITHCOMPARE expr_no_commas
1260 { $$ = build_x_binary_op ($2, $$, $3); }
1261 | expr_no_commas '<' expr_no_commas
1262 { $$ = build_x_binary_op (LT_EXPR, $$, $3); }
1263 | expr_no_commas '>' expr_no_commas
1264 { $$ = build_x_binary_op (GT_EXPR, $$, $3); }
1265 | expr_no_commas EQCOMPARE expr_no_commas
1266 { $$ = build_x_binary_op ($2, $$, $3); }
1267 | expr_no_commas MIN_MAX expr_no_commas
1268 { $$ = build_x_binary_op ($2, $$, $3); }
1269 | expr_no_commas '&' expr_no_commas
1270 { $$ = build_x_binary_op ($2, $$, $3); }
1271 | expr_no_commas '|' expr_no_commas
1272 { $$ = build_x_binary_op ($2, $$, $3); }
1273 | expr_no_commas '^' expr_no_commas
1274 { $$ = build_x_binary_op ($2, $$, $3); }
1275 | expr_no_commas ANDAND expr_no_commas
1276 { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $$, $3); }
1277 | expr_no_commas OROR expr_no_commas
1278 { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $$, $3); }
1279 | expr_no_commas '?' xexpr ':' expr_no_commas
1280 { $$ = build_x_conditional_expr ($$, $3, $5); }
1281 | expr_no_commas '=' expr_no_commas
1282 { $$ = build_x_modify_expr ($$, NOP_EXPR, $3);
1283 if ($$ != error_mark_node)
1284 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
1285 | expr_no_commas ASSIGN expr_no_commas
1286 { $$ = build_x_modify_expr ($$, $2, $3); }
1288 { $$ = build_throw (NULL_TREE); }
1289 | THROW expr_no_commas
1290 { $$ = build_throw ($2); }
1291 /* These extensions are not defined. The second arg to build_m_component_ref
1292 is old, build_m_component_ref now does an implicit
1293 build_indirect_ref (x, NULL_PTR) on the second argument.
1294 | object '&' expr_no_commas %prec UNARY
1295 { $$ = build_m_component_ref ($$, build_x_unary_op (ADDR_EXPR, $3)); }
1296 | object unop expr_no_commas %prec UNARY
1297 { $$ = build_m_component_ref ($$, build_x_unary_op ($2, $3)); }
1298 | object '(' type_id ')' expr_no_commas %prec UNARY
1299 { tree type = groktypename ($3.t);
1300 $$ = build_m_component_ref ($$, build_c_cast (type, $5)); }
1301 | object primary_no_id %prec UNARY
1302 { $$ = build_m_component_ref ($$, $2); }
1306 notype_unqualified_id:
1307 '~' see_typename identifier
1308 { $$ = build_parse_node (BIT_NOT_EXPR, $3); }
1309 | '~' see_typename template_type
1310 { $$ = build_parse_node (BIT_NOT_EXPR, $3); }
1315 | NSNAME %prec EMPTY
1319 { $$ = do_identifier ($<ttype>-1, 1, NULL_TREE); }
1322 PFUNCNAME '<' do_id template_arg_list_opt template_close_bracket
1323 { $$ = lookup_template_function ($3, $4); }
1324 | operator_name '<' do_id template_arg_list_opt template_close_bracket
1325 { $$ = lookup_template_function ($3, $4); }
1329 TEMPLATE identifier '<' template_arg_list_opt template_close_bracket
1330 { $$ = lookup_template_function ($2, $4); }
1331 | TEMPLATE PFUNCNAME '<' template_arg_list_opt template_close_bracket
1332 { $$ = lookup_template_function ($2, $4); }
1333 | TEMPLATE operator_name '<' template_arg_list_opt
1334 template_close_bracket
1335 { $$ = lookup_template_function ($2, $4); }
1339 notype_unqualified_id
1344 expr_or_declarator_intern:
1346 | attributes expr_or_declarator
1348 /* Provide support for '(' attributes '*' declarator ')'
1350 $$ = decl_tree_cons ($1, $2, NULL_TREE);
1355 notype_unqualified_id
1356 | '*' expr_or_declarator_intern %prec UNARY
1357 { $$ = build_parse_node (INDIRECT_REF, $2); }
1358 | '&' expr_or_declarator_intern %prec UNARY
1359 { $$ = build_parse_node (ADDR_EXPR, $2); }
1360 | '(' expr_or_declarator_intern ')'
1364 notype_template_declarator:
1365 IDENTIFIER '<' template_arg_list_opt template_close_bracket
1366 { $$ = lookup_template_function ($1, $3); }
1367 | NSNAME '<' template_arg_list template_close_bracket
1368 { $$ = lookup_template_function ($1, $3); }
1371 direct_notype_declarator:
1372 complex_direct_notype_declarator
1373 /* This precedence declaration is to prefer this reduce
1374 to the Koenig lookup shift in primary, below. I hate yacc. */
1375 | notype_unqualified_id %prec '('
1376 | notype_template_declarator
1377 | '(' expr_or_declarator_intern ')'
1378 { $$ = finish_decl_parsing ($2); }
1382 notype_unqualified_id
1384 if (TREE_CODE ($1) == BIT_NOT_EXPR)
1385 $$ = build_x_unary_op (BIT_NOT_EXPR, TREE_OPERAND ($1, 0));
1387 $$ = finish_id_expr ($1);
1393 if (processing_template_decl)
1394 push_obstacks (&permanent_obstack, &permanent_obstack);
1395 $$ = combine_strings ($$);
1396 /* combine_strings doesn't set up TYPE_MAIN_VARIANT of
1397 a const array the way we want, so fix it. */
1398 if (flag_const_strings)
1399 TREE_TYPE ($$) = build_cplus_array_type
1400 (TREE_TYPE (TREE_TYPE ($$)),
1401 TYPE_DOMAIN (TREE_TYPE ($$)));
1402 if (processing_template_decl)
1406 { $$ = finish_parenthesized_expr ($2); }
1407 | '(' expr_or_declarator_intern ')'
1408 { $2 = reparse_decl_as_expr (NULL_TREE, $2);
1409 $$ = finish_parenthesized_expr ($2); }
1411 { $$ = error_mark_node; }
1413 { tree scope = current_scope ();
1414 if (!scope || TREE_CODE (scope) != FUNCTION_DECL)
1416 error ("braced-group within expression allowed only inside a function");
1420 pedwarn ("ANSI C++ forbids braced-groups within expressions");
1421 $<ttype>$ = begin_stmt_expr ();
1424 { $$ = finish_stmt_expr ($<ttype>2, $3); }
1425 /* Koenig lookup support
1426 We could store lastiddecl in $1 to avoid another lookup,
1427 but that would result in many additional reduce/reduce conflicts. */
1428 | notype_unqualified_id '(' nonnull_exprlist ')'
1429 { $$ = finish_call_expr ($1, $3, 1); }
1430 | notype_unqualified_id LEFT_RIGHT
1431 { $$ = finish_call_expr ($1, NULL_TREE, 1); }
1432 | primary '(' nonnull_exprlist ')'
1433 { $$ = finish_call_expr ($1, $3, 0); }
1434 | primary LEFT_RIGHT
1435 { $$ = finish_call_expr ($1, NULL_TREE, 0); }
1436 | primary '[' expr ']'
1437 { $$ = grok_array_decl ($$, $3); }
1439 { $$ = finish_increment_expr ($1, POSTINCREMENT_EXPR); }
1440 | primary MINUSMINUS
1441 { $$ = finish_increment_expr ($1, POSTDECREMENT_EXPR); }
1442 /* C++ extensions */
1444 { $$ = finish_this_expr (); }
1445 | CV_QUALIFIER '(' nonnull_exprlist ')'
1447 /* This is a C cast in C++'s `functional' notation
1448 using the "implicit int" extension so that:
1449 `const (3)' is equivalent to `const int (3)'. */
1452 if ($3 == error_mark_node)
1454 $$ = error_mark_node;
1458 type = cp_build_qualified_type (integer_type_node,
1459 cp_type_qual_from_rid ($1));
1460 $$ = build_c_cast (type, build_compound_expr ($3));
1463 | DYNAMIC_CAST '<' type_id '>' '(' expr ')'
1464 { tree type = groktypename ($3.t);
1465 check_for_new_type ("dynamic_cast", $3);
1466 $$ = build_dynamic_cast (type, $6); }
1467 | STATIC_CAST '<' type_id '>' '(' expr ')'
1468 { tree type = groktypename ($3.t);
1469 check_for_new_type ("static_cast", $3);
1470 $$ = build_static_cast (type, $6); }
1471 | REINTERPRET_CAST '<' type_id '>' '(' expr ')'
1472 { tree type = groktypename ($3.t);
1473 check_for_new_type ("reinterpret_cast", $3);
1474 $$ = build_reinterpret_cast (type, $6); }
1475 | CONST_CAST '<' type_id '>' '(' expr ')'
1476 { tree type = groktypename ($3.t);
1477 check_for_new_type ("const_cast", $3);
1478 $$ = build_const_cast (type, $6); }
1479 | TYPEID '(' expr ')'
1480 { $$ = build_x_typeid ($3); }
1481 | TYPEID '(' type_id ')'
1482 { tree type = groktypename ($3.t);
1483 check_for_new_type ("typeid", $3);
1484 $$ = get_typeid (TYPE_MAIN_VARIANT (type)); }
1485 | global_scope IDENTIFIER
1486 { $$ = do_scoped_id ($2, 1); }
1487 | global_scope template_id
1489 | global_scope operator_name
1491 got_scope = NULL_TREE;
1492 if (TREE_CODE ($2) == IDENTIFIER_NODE)
1493 $$ = do_scoped_id ($2, 1);
1497 | overqualified_id %prec HYPERUNARY
1498 { $$ = build_offset_ref (OP0 ($$), OP1 ($$)); }
1499 | overqualified_id '(' nonnull_exprlist ')'
1500 { $$ = finish_qualified_call_expr ($1, $3); }
1501 | overqualified_id LEFT_RIGHT
1502 { $$ = finish_qualified_call_expr ($1, NULL_TREE); }
1503 | object object_template_id %prec UNARY
1505 $$ = build_x_component_ref ($$, $2, NULL_TREE, 1);
1507 | object object_template_id '(' nonnull_exprlist ')'
1508 { $$ = finish_object_call_expr ($2, $1, $4); }
1509 | object object_template_id LEFT_RIGHT
1510 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1511 | object unqualified_id %prec UNARY
1512 { $$ = build_x_component_ref ($$, $2, NULL_TREE, 1); }
1513 | object overqualified_id %prec UNARY
1514 { if (processing_template_decl)
1515 $$ = build_min_nt (COMPONENT_REF, $1, copy_to_permanent ($2));
1517 $$ = build_object_ref ($$, OP0 ($2), OP1 ($2)); }
1518 | object unqualified_id '(' nonnull_exprlist ')'
1519 { $$ = finish_object_call_expr ($2, $1, $4); }
1520 | object unqualified_id LEFT_RIGHT
1521 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1522 | object overqualified_id '(' nonnull_exprlist ')'
1523 { $$ = finish_qualified_object_call_expr ($2, $1, $4); }
1524 | object overqualified_id LEFT_RIGHT
1525 { $$ = finish_qualified_object_call_expr ($2, $1, NULL_TREE); }
1526 /* p->int::~int() is valid -- 12.4 */
1527 | object '~' TYPESPEC LEFT_RIGHT
1528 { $$ = finish_pseudo_destructor_call_expr ($1, NULL_TREE, $3); }
1529 | object TYPESPEC SCOPE '~' TYPESPEC LEFT_RIGHT
1530 { $$ = finish_pseudo_destructor_call_expr ($1, $2, $5); }
1533 $$ = error_mark_node;
1537 /* Not needed for now.
1543 { $$ = error_mark_node; }
1545 { if (current_function_decl == 0)
1547 error ("braced-group within expression allowed only inside a function");
1550 $<ttype>$ = expand_start_stmt_expr (); }
1553 pedwarn ("ANSI C++ forbids braced-groups within expressions");
1554 $$ = expand_end_stmt_expr ($<ttype>2); }
1555 | primary_no_id '(' nonnull_exprlist ')'
1556 { $$ = build_x_function_call ($$, $3, current_class_ref); }
1557 | primary_no_id LEFT_RIGHT
1558 { $$ = build_x_function_call ($$, NULL_TREE, current_class_ref); }
1559 | primary_no_id '[' expr ']'
1561 | primary_no_id PLUSPLUS
1562 { $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); }
1563 | primary_no_id MINUSMINUS
1564 { $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); }
1566 { goto do_scoped_id; }
1567 | SCOPE operator_name
1568 { if (TREE_CODE ($2) == IDENTIFIER_NODE)
1570 goto do_scoped_operator;
1579 { got_scope = NULL_TREE; $$ = 1; }
1585 | global_scope delete
1586 { got_scope = NULL_TREE; $$ = 1; }
1591 { $$ = boolean_true_node; }
1593 { $$ = boolean_false_node; }
1596 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
1600 { $$ = chainon ($$, $2); }
1606 if (! current_function_parms_stored)
1607 store_parm_decls ();
1609 /* Always keep the BLOCK node associated with the outermost
1610 pair of curley braces of a function. These are needed
1611 for correct operation of dwarfout.c. */
1618 { got_object = TREE_TYPE ($$); }
1621 $$ = build_x_arrow ($$);
1622 got_object = TREE_TYPE ($$);
1627 typespec initdecls ';'
1629 resume_momentary ($2);
1630 if ($1.t && IS_AGGR_TYPE_CODE (TREE_CODE ($1.t)))
1631 note_got_semicolon ($1.t);
1633 | typed_declspecs initdecls ';'
1635 resume_momentary ($2);
1636 note_list_got_semicolon ($1.t);
1638 | declmods notype_initdecls ';'
1639 { resume_momentary ($2); }
1640 | typed_declspecs ';'
1643 note_list_got_semicolon ($1.t);
1646 { warning ("empty declaration"); }
1648 { pedantic = $<itype>1; }
1651 /* Any kind of declarator (thus, all declarators allowed
1652 after an explicit typespec). */
1655 after_type_declarator %prec EMPTY
1656 | notype_declarator %prec EMPTY
1659 /* This is necessary to postpone reduction of `int()()()()'. */
1661 LEFT_RIGHT %prec EMPTY
1662 { $$ = make_call_declarator (NULL_TREE, empty_parms (),
1663 NULL_TREE, NULL_TREE); }
1664 | fcast_or_absdcl LEFT_RIGHT %prec EMPTY
1665 { $$ = make_call_declarator ($$, empty_parms (), NULL_TREE,
1669 /* ANSI type-id (8.1) */
1671 typed_typespecs absdcl
1672 { $$.t = build_decl_list ($1.t, $2);
1673 $$.new_type_flag = $1.new_type_flag; }
1674 | nonempty_cv_qualifiers absdcl
1675 { $$.t = build_decl_list ($1.t, $2);
1676 $$.new_type_flag = $1.new_type_flag; }
1678 { $$.t = build_decl_list (get_decl_list ($1.t), $2);
1679 $$.new_type_flag = $1.new_type_flag; }
1680 | typed_typespecs %prec EMPTY
1681 { $$.t = build_decl_list ($1.t, NULL_TREE);
1682 $$.new_type_flag = $1.new_type_flag; }
1683 | nonempty_cv_qualifiers %prec EMPTY
1684 { $$.t = build_decl_list ($1.t, NULL_TREE);
1685 $$.new_type_flag = $1.new_type_flag; }
1688 /* Declspecs which contain at least one type specifier or typedef name.
1689 (Just `const' or `volatile' is not enough.)
1690 A typedef'd name following these is taken as a name to be declared.
1691 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1694 typed_typespecs %prec EMPTY
1700 { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1);
1701 $$.new_type_flag = $2.new_type_flag; }
1702 | typespec reserved_declspecs %prec HYPERUNARY
1703 { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2);
1704 $$.new_type_flag = $1.new_type_flag; }
1705 | typespec reserved_typespecquals reserved_declspecs
1706 { $$.t = decl_tree_cons (NULL_TREE, $1.t, chainon ($2, $3));
1707 $$.new_type_flag = $1.new_type_flag; }
1708 | declmods typespec reserved_declspecs
1709 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1));
1710 $$.new_type_flag = $2.new_type_flag; }
1711 | declmods typespec reserved_typespecquals
1712 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1));
1713 $$.new_type_flag = $2.new_type_flag; }
1714 | declmods typespec reserved_typespecquals reserved_declspecs
1715 { $$.t = decl_tree_cons (NULL_TREE, $2.t,
1716 chainon ($3, chainon ($4, $1)));
1717 $$.new_type_flag = $2.new_type_flag; }
1722 { if (extra_warnings)
1723 warning ("`%s' is not at beginning of declaration",
1724 IDENTIFIER_POINTER ($$));
1725 $$ = build_decl_list (NULL_TREE, $$); }
1726 | reserved_declspecs typespecqual_reserved
1727 { $$ = decl_tree_cons (NULL_TREE, $2.t, $$); }
1728 | reserved_declspecs SCSPEC
1729 { if (extra_warnings)
1730 warning ("`%s' is not at beginning of declaration",
1731 IDENTIFIER_POINTER ($2));
1732 $$ = decl_tree_cons (NULL_TREE, $2, $$); }
1733 | reserved_declspecs attributes
1734 { $$ = decl_tree_cons ($2, NULL_TREE, $1); }
1736 { $$ = decl_tree_cons ($1, NULL_TREE, NULL_TREE); }
1739 /* List of just storage classes and type modifiers.
1740 A declaration can start with just this, but then it cannot be used
1741 to redeclare a typedef-name.
1742 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1745 nonempty_cv_qualifiers %prec EMPTY
1746 { $$ = $1.t; TREE_STATIC ($$) = 1; }
1748 { $$ = IDENTIFIER_AS_LIST ($$); }
1749 | declmods CV_QUALIFIER
1750 { $$ = decl_tree_cons (NULL_TREE, $2, $$);
1751 TREE_STATIC ($$) = 1; }
1753 { if (extra_warnings && TREE_STATIC ($$))
1754 warning ("`%s' is not at beginning of declaration",
1755 IDENTIFIER_POINTER ($2));
1756 $$ = decl_tree_cons (NULL_TREE, $2, $$);
1757 TREE_STATIC ($$) = TREE_STATIC ($1); }
1758 | declmods attributes
1759 { $$ = decl_tree_cons ($2, NULL_TREE, $1); }
1761 { $$ = decl_tree_cons ($1, NULL_TREE, NULL_TREE); }
1764 /* Used instead of declspecs where storage classes are not allowed
1765 (that is, for typenames and structure components).
1767 C++ can takes storage classes for structure components.
1768 Don't accept a typedef-name if anything but a modifier precedes it. */
1771 typespec %prec EMPTY
1772 { $$.t = get_decl_list ($1.t);
1773 $$.new_type_flag = $1.new_type_flag; }
1774 | nonempty_cv_qualifiers typespec
1775 { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1.t);
1776 $$.new_type_flag = $2.new_type_flag; }
1777 | typespec reserved_typespecquals
1778 { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2);
1779 $$.new_type_flag = $1.new_type_flag; }
1780 | nonempty_cv_qualifiers typespec reserved_typespecquals
1781 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1782 $$.new_type_flag = $1.new_type_flag; }
1785 reserved_typespecquals:
1786 typespecqual_reserved
1787 { $$ = build_decl_list (NULL_TREE, $1.t); }
1788 | reserved_typespecquals typespecqual_reserved
1789 { $$ = decl_tree_cons (NULL_TREE, $2.t, $1); }
1792 /* A typespec (but not a type qualifier).
1793 Once we have seen one of these in a declaration,
1794 if a typedef name appears then it is being redeclared. */
1798 | TYPESPEC %prec EMPTY
1799 { $$.t = $1; $$.new_type_flag = 0; }
1800 | complete_type_name
1801 { $$.t = $1; $$.new_type_flag = 0; }
1802 | TYPEOF '(' expr ')'
1803 { $$.t = finish_typeof ($3);
1804 $$.new_type_flag = 0; }
1805 | TYPEOF '(' type_id ')'
1806 { $$.t = groktypename ($3.t);
1807 $$.new_type_flag = 0; }
1808 | SIGOF '(' expr ')'
1809 { tree type = TREE_TYPE ($3);
1811 $$.new_type_flag = 0;
1812 if (IS_AGGR_TYPE (type))
1814 sorry ("sigof type specifier");
1819 error ("`sigof' applied to non-aggregate expression");
1820 $$.t = error_mark_node;
1823 | SIGOF '(' type_id ')'
1824 { tree type = groktypename ($3.t);
1826 $$.new_type_flag = 0;
1827 if (IS_AGGR_TYPE (type))
1829 sorry ("sigof type specifier");
1834 error("`sigof' applied to non-aggregate type");
1835 $$.t = error_mark_node;
1840 /* A typespec that is a reserved word, or a type qualifier. */
1842 typespecqual_reserved:
1844 { $$.t = $1; $$.new_type_flag = 0; }
1846 { $$.t = $1; $$.new_type_flag = 0; }
1852 | initdecls ',' initdcl
1853 { check_multiple_declarators (); }
1858 | notype_initdecls ',' initdcl
1859 { check_multiple_declarators (); }
1864 | nomods_initdecls ',' initdcl
1865 { check_multiple_declarators (); }
1871 | asm_keyword '(' string ')'
1872 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3); $$ = $3; }
1876 declarator maybeasm maybe_attribute '='
1877 { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1,
1878 $3, prefix_attributes); }
1880 /* Note how the declaration of the variable is in effect while its init is parsed! */
1881 { cp_finish_decl ($<ttype>5, $6, $2, 1, LOOKUP_ONLYCONVERTING); }
1882 | declarator maybeasm maybe_attribute
1883 { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 0,
1884 $3, prefix_attributes);
1885 cp_finish_decl ($<ttype>$, NULL_TREE, $2, 1, 0); }
1888 /* This rule assumes a certain configuration of the parser stack.
1889 In particular, $0, the element directly before the beginning of
1890 this rule on the stack, must be a maybeasm. $-1 must be a
1891 declarator or notype_declarator. And $-2 must be some declmods
1892 or declspecs. We can't move the maybeasm into this rule because
1893 we need that reduce so we prefer fn.def1 when appropriate. */
1896 { $<itype>2 = parse_decl ($<ttype>-1, $<ttype>-2,
1897 $1, 1, &$<ttype>$); }
1898 /* Note how the declaration of the variable is in effect
1899 while its init is parsed! */
1901 { cp_finish_decl ($<ttype>3, $4, $<ttype>0, 1,
1902 LOOKUP_ONLYCONVERTING);
1906 $$ = parse_decl ($<ttype>-1, $<ttype>-2, $1, 0, &d);
1907 cp_finish_decl (d, NULL_TREE, $<ttype>0, 1, 0); }
1911 declarator maybeasm initdcl0_innards
1915 notype_declarator maybeasm initdcl0_innards
1920 notype_declarator maybeasm
1921 { /* Set things up as initdcl0_innards expects. */
1926 | constructor_declarator maybeasm maybe_attribute
1928 parse_decl($1, NULL_TREE, $3, 0, &d);
1929 cp_finish_decl (d, NULL_TREE, $2, 1, 0); }
1932 /* the * rules are dummies to accept the Apollo extended syntax
1933 so that the header files compile. */
1944 | attributes attribute
1945 { $$ = chainon ($1, $2); }
1949 ATTRIBUTE '(' '(' attribute_list ')' ')'
1956 | attribute_list ',' attrib
1957 { $$ = chainon ($1, $3); }
1964 { $$ = build_tree_list ($1, NULL_TREE); }
1965 | any_word '(' IDENTIFIER ')'
1966 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1967 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1968 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1969 | any_word '(' nonnull_exprlist ')'
1970 { $$ = build_tree_list ($1, $3); }
1973 /* This still leaves out most reserved keywords,
1974 shouldn't we include them? */
1983 /* A nonempty list of identifiers, including typenames. */
1984 identifiers_or_typenames:
1986 { $$ = build_tree_list (NULL_TREE, $1); }
1987 | identifiers_or_typenames ',' identifier
1988 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
1992 /* empty */ %prec EMPTY
1997 /* If we are processing a template, we don't want to expand this
2001 expr_no_commas %prec '='
2003 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, NULL_TREE);
2004 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2006 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2007 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2008 | '{' initlist ',' '}'
2009 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2010 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2015 /* This chain is built in reverse order,
2016 and put in forward order where initlist is used. */
2019 { $$ = build_tree_list (NULL_TREE, $$); }
2021 { $$ = expr_tree_cons (NULL_TREE, $3, $$); }
2022 /* These are for labeled elements. */
2023 | '[' expr_no_commas ']' init
2024 { $$ = build_expr_list ($2, $4); }
2025 | identifier ':' init
2026 { $$ = build_expr_list ($$, $3); }
2027 | initlist ',' identifier ':' init
2028 { $$ = expr_tree_cons ($3, $5, $$); }
2032 PRE_PARSED_FUNCTION_DECL
2033 { start_function (NULL_TREE, TREE_VALUE ($1),
2035 reinit_parse_for_function (); }
2038 fn.defpen maybe_return_init ctor_initializer_opt compstmt_or_error
2040 int nested = (hack_decl_function_context
2041 (current_function_decl) != NULL_TREE);
2042 finish_function (lineno, (int)$3, nested);
2043 process_next_inline ($1);
2045 | fn.defpen maybe_return_init function_try_block
2046 { process_next_inline ($1); }
2047 | fn.defpen maybe_return_init error
2048 { process_next_inline ($1); }
2053 | pending_inlines pending_inline eat_saved_input
2056 /* A regurgitated default argument. The value of DEFARG_MARKER will be
2057 the TREE_LIST node for the parameter in question. */
2059 DEFARG_MARKER expr_no_commas END_OF_SAVED_INPUT
2060 { replace_defarg ($1, $2); }
2061 | DEFARG_MARKER error END_OF_SAVED_INPUT
2062 { replace_defarg ($1, error_mark_node); }
2065 /* empty */ %prec EMPTY
2066 | pending_defargs defarg_again
2067 { do_pending_defargs (); }
2068 | pending_defargs error
2069 { do_pending_defargs (); }
2074 { $<itype>3 = suspend_momentary ();
2075 $<ttype>$ = current_enum_type;
2076 current_enum_type = start_enum ($2); }
2077 enumlist maybecomma_warn '}'
2078 { TYPE_VALUES (current_enum_type) = $5;
2079 $$.t = finish_enum (current_enum_type);
2080 $$.new_type_flag = 1;
2081 current_enum_type = $<ttype>4;
2082 resume_momentary ((int) $<itype>3);
2083 check_for_missing_semicolon ($$.t); }
2084 | ENUM identifier '{' '}'
2085 { $$.t = finish_enum (start_enum ($2));
2086 $$.new_type_flag = 1;
2087 check_for_missing_semicolon ($$.t); }
2089 { $<itype>2 = suspend_momentary ();
2090 $<ttype>$ = current_enum_type;
2091 current_enum_type = start_enum (make_anon_name ()); }
2092 enumlist maybecomma_warn '}'
2093 { TYPE_VALUES (current_enum_type) = $4;
2094 $$.t = finish_enum (current_enum_type);
2095 $$.new_type_flag = 1;
2096 current_enum_type = $<ttype>3;
2097 resume_momentary ((int) $<itype>1);
2098 check_for_missing_semicolon ($$.t); }
2100 { $$.t = finish_enum (start_enum (make_anon_name()));
2101 $$.new_type_flag = 1;
2102 check_for_missing_semicolon ($$.t); }
2104 { $$.t = xref_tag (enum_type_node, $2, 1);
2105 $$.new_type_flag = 0; }
2106 | ENUM complex_type_name
2107 { $$.t = xref_tag (enum_type_node, $2, 1);
2108 $$.new_type_flag = 0; }
2109 | TYPENAME_KEYWORD typename_sub
2111 $$.new_type_flag = 0;
2112 if (!processing_template_decl)
2113 cp_pedwarn ("using `typename' outside of template"); }
2114 /* C++ extensions, merged with C to avoid shift/reduce conflicts */
2115 | class_head left_curly
2116 opt.component_decl_list '}' maybe_attribute
2120 if (yychar == YYEMPTY)
2122 semi = yychar == ';';
2124 $<ttype>$ = finish_class_definition ($1, $5, semi);
2127 { finish_default_args (); }
2130 $$.new_type_flag = 1;
2131 begin_inline_definitions (); }
2132 | class_head %prec EMPTY
2134 $$.new_type_flag = 0;
2135 if (TYPE_BINFO ($1) == NULL_TREE)
2137 cp_error ("%T is not a class type", $1);
2138 $$.t = error_mark_node;
2143 /* struct B: public A; is not accepted by the WP grammar. */
2144 if (TYPE_BINFO_BASETYPES ($$.t) && !TYPE_SIZE ($$.t)
2145 && ! TYPE_BEING_DEFINED ($$.t))
2146 cp_error ("base clause without member specification for `%#T'",
2160 { if (pedantic && !in_system_header)
2161 pedwarn ("comma at end of enumerator list"); }
2167 { error ("storage class specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2169 { error ("type specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2171 { error ("type qualifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2173 { error ("no body nor ';' separates two class, struct or union declarations"); }
2175 { $$ = build_decl_list ($2, $1); }
2178 named_class_head_sans_basetype:
2186 named_class_head_sans_basetype_defn:
2187 aggr identifier_defn %prec EMPTY
2188 { current_aggr = $$; $$ = $2; }
2189 | named_class_head_sans_basetype '{'
2190 { yyungetc ('{', 1); }
2191 | named_class_head_sans_basetype ':'
2192 { yyungetc (':', 1); }
2195 named_complex_class_head_sans_basetype:
2196 aggr nested_name_specifier identifier
2199 $$ = handle_class_head ($1, $2, $3);
2201 | aggr global_scope nested_name_specifier identifier
2204 $$ = handle_class_head ($1, $3, $4);
2206 | aggr global_scope identifier
2209 $$ = handle_class_head ($1, NULL_TREE, $3);
2211 | aggr apparent_template_type
2212 { current_aggr = $$; $$ = $2; }
2213 | aggr nested_name_specifier apparent_template_type
2214 { current_aggr = $$; $$ = $3; }
2218 named_class_head_sans_basetype %prec EMPTY
2219 { $$ = xref_tag (current_aggr, $1, 1); }
2220 | named_class_head_sans_basetype_defn
2221 { $<ttype>$ = xref_tag (current_aggr, $1, 0); }
2222 /* Class name is unqualified, so we look for base classes
2223 in the current scope. */
2224 maybe_base_class_list %prec EMPTY
2228 xref_basetypes (current_aggr, $1, $<ttype>2, $3);
2230 | named_complex_class_head_sans_basetype
2231 { push_scope (CP_DECL_CONTEXT ($1)); }
2232 maybe_base_class_list
2234 pop_scope (CP_DECL_CONTEXT ($1));
2235 $$ = TREE_TYPE ($1);
2236 if (TREE_INT_CST_LOW (current_aggr) == union_type
2237 && TREE_CODE ($$) != UNION_TYPE)
2238 cp_pedwarn ("`union' tag used in declaring `%#T'", $$);
2239 else if (TREE_CODE ($$) == UNION_TYPE
2240 && TREE_INT_CST_LOW (current_aggr) != union_type)
2241 cp_pedwarn ("non-`union' tag used in declaring `%#T'", $$);
2244 maybe_process_partial_specialization ($$);
2245 xref_basetypes (current_aggr, $1, $$, $3);
2252 { $$ = xref_tag ($$, make_anon_name (), 0);
2253 yyungetc ('{', 1); }
2261 maybe_base_class_list:
2262 /* empty */ %prec EMPTY
2264 | ':' see_typename %prec EMPTY
2265 { yyungetc(':', 1); $$ = NULL_TREE; }
2266 | ':' see_typename base_class_list %prec EMPTY
2272 | base_class_list ',' see_typename base_class
2273 { $$ = chainon ($$, $4); }
2278 { $$ = finish_base_specifier (access_default_node, $1,
2280 == signature_type_node); }
2281 | base_class_access_list see_typename base_class.1
2282 { $$ = finish_base_specifier ($1, $3,
2284 == signature_type_node); }
2289 { if ($$ != error_mark_node) $$ = TYPE_MAIN_DECL ($1); }
2291 | SIGOF '(' expr ')'
2293 if (current_aggr == signature_type_node)
2295 if (IS_AGGR_TYPE (TREE_TYPE ($3)))
2297 sorry ("`sigof' as base signature specifier");
2298 $$ = TREE_TYPE ($3);
2302 error ("`sigof' applied to non-aggregate expression");
2303 $$ = error_mark_node;
2308 error ("`sigof' in struct or class declaration");
2309 $$ = error_mark_node;
2312 | SIGOF '(' type_id ')'
2314 if (current_aggr == signature_type_node)
2316 if (IS_AGGR_TYPE (groktypename ($3.t)))
2318 sorry ("`sigof' as base signature specifier");
2319 $$ = groktypename ($3.t);
2323 error ("`sigof' applied to non-aggregate expression");
2324 $$ = error_mark_node;
2329 error ("`sigof' in struct or class declaration");
2330 $$ = error_mark_node;
2335 base_class_access_list:
2336 VISSPEC see_typename
2337 | SCSPEC see_typename
2338 { if ($1 != ridpointers[(int)RID_VIRTUAL])
2339 cp_error ("`%D' access", $1);
2340 $$ = access_default_virtual_node; }
2341 | base_class_access_list VISSPEC see_typename
2343 if ($1 != access_default_virtual_node)
2344 error ("multiple access specifiers");
2345 else if ($2 == access_public_node)
2346 $$ = access_public_virtual_node;
2347 else if ($2 == access_protected_node)
2348 $$ = access_protected_virtual_node;
2349 else /* $2 == access_private_node */
2350 $$ = access_private_virtual_node;
2352 | base_class_access_list SCSPEC see_typename
2353 { if ($2 != ridpointers[(int)RID_VIRTUAL])
2354 cp_error ("`%D' access", $2);
2355 else if ($$ == access_public_node)
2356 $$ = access_public_virtual_node;
2357 else if ($$ == access_protected_node)
2358 $$ = access_protected_virtual_node;
2359 else if ($$ == access_private_node)
2360 $$ = access_private_virtual_node;
2362 error ("multiple `virtual' specifiers");
2368 { $<ttype>0 = begin_class_definition ($<ttype>0); }
2374 finish_member_declaration (build_self_reference ());
2378 opt.component_decl_list:
2380 | self_reference component_decl_list
2381 | opt.component_decl_list access_specifier component_decl_list
2382 | opt.component_decl_list access_specifier
2388 if (current_aggr == signature_type_node)
2390 error ("access specifier not allowed in signature");
2391 $1 = access_public_node;
2394 current_access_specifier = $1;
2398 /* Note: we no longer warn about the semicolon after a component_decl_list.
2399 ARM $9.2 says that the semicolon is optional, and therefore allowed. */
2400 component_decl_list:
2403 finish_member_declaration ($1);
2405 | component_decl_list component_decl
2407 finish_member_declaration ($2);
2412 component_decl_1 ';'
2413 | component_decl_1 '}'
2414 { error ("missing ';' before right brace");
2415 yyungetc ('}', 0); }
2416 /* C++: handle constructors, destructors and inline functions */
2417 /* note that INLINE is like a TYPESPEC */
2418 | fn.def2 ':' /* base_init compstmt */
2419 { $$ = finish_method ($$); }
2420 | fn.def2 TRY /* base_init compstmt */
2421 { $$ = finish_method ($$); }
2422 | fn.def2 RETURN /* base_init compstmt */
2423 { $$ = finish_method ($$); }
2424 | fn.def2 '{' /* nodecls compstmt */
2425 { $$ = finish_method ($$); }
2428 | extension component_decl
2430 pedantic = $<itype>1; }
2431 | template_header component_decl
2434 $$ = finish_member_template_decl ($2);
2436 /* The component was already processed. */
2439 finish_template_decl ($1);
2441 | template_header typed_declspecs ';'
2443 $$ = finish_member_class_template ($2.t);
2444 finish_template_decl ($1);
2449 /* Do not add a "typed_declspecs declarator" rule here for
2450 speed; we need to call grok_x_components for enums, so the
2451 speedup would be insignificant. */
2452 typed_declspecs components
2454 /* Most of the productions for component_decl only
2455 allow the creation of one new member, so we call
2456 finish_member_declaration in component_decl_list.
2457 For this rule and the next, however, there can be
2458 more than one member, e.g.:
2462 and we need the first member to be fully
2463 registered before the second is processed.
2464 Therefore, the rules for components take care of
2465 this processing. To avoid registering the
2466 components more than once, we send NULL_TREE up
2467 here; that lets finish_member_declaration now
2468 that there is nothing to do. */
2470 grok_x_components ($1.t);
2473 | declmods notype_components
2476 grok_x_components ($1);
2479 | notype_declarator maybeasm maybe_attribute maybe_init
2480 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2481 build_tree_list ($3, NULL_TREE)); }
2482 | constructor_declarator maybeasm maybe_attribute maybe_init
2483 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2484 build_tree_list ($3, NULL_TREE)); }
2485 | ':' expr_no_commas
2486 { $$ = grokbitfield (NULL_TREE, NULL_TREE, $2); }
2490 /* These rules introduce a reduce/reduce conflict; in
2491 typedef int foo, bar;
2495 should "A::foo" be declared as a function or "A::bar" as a data
2496 member? In other words, is "bar" an after_type_declarator or a
2498 | declmods component_constructor_declarator maybeasm maybe_attribute maybe_init
2499 { tree specs, attrs;
2500 split_specs_attrs ($1, &specs, &attrs);
2501 $$ = grokfield ($2, specs, $5, $3,
2502 build_tree_list ($4, attrs)); }
2503 | component_constructor_declarator maybeasm maybe_attribute maybe_init
2504 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2505 build_tree_list ($3, NULL_TREE)); }
2507 { $$ = do_class_using_decl ($1); }
2509 /* The case of exactly one component is handled directly by component_decl. */
2512 /* empty: possibly anonymous */
2514 | component_declarator0
2516 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2517 $1 = finish_member_template_decl ($1);
2518 finish_member_declaration ($1);
2521 | components ',' component_declarator
2523 check_multiple_declarators ();
2524 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2525 $3 = finish_member_template_decl ($3);
2526 finish_member_declaration ($3);
2532 /* empty: possibly anonymous */
2534 | notype_component_declarator0
2536 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2537 $1 = finish_member_template_decl ($1);
2538 finish_member_declaration ($1);
2541 | notype_components ',' notype_component_declarator
2543 check_multiple_declarators ();
2544 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2545 $3 = finish_member_template_decl ($3);
2546 finish_member_declaration ($3);
2551 component_declarator0:
2552 after_type_component_declarator0
2553 | notype_component_declarator0
2556 component_declarator:
2557 after_type_component_declarator
2558 | notype_component_declarator
2561 after_type_component_declarator0:
2562 after_type_declarator maybeasm maybe_attribute maybe_init
2563 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2564 &prefix_attributes);
2565 $<ttype>0 = current_declspecs;
2566 $$ = grokfield ($$, current_declspecs, $4, $2,
2567 build_tree_list ($3, prefix_attributes)); }
2568 | TYPENAME ':' expr_no_commas maybe_attribute
2569 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2570 &prefix_attributes);
2571 $<ttype>0 = current_declspecs;
2572 $$ = grokbitfield ($$, current_declspecs, $3);
2573 cplus_decl_attributes ($$, $4, prefix_attributes); }
2576 notype_component_declarator0:
2577 notype_declarator maybeasm maybe_attribute maybe_init
2578 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2579 &prefix_attributes);
2580 $<ttype>0 = current_declspecs;
2581 $$ = grokfield ($$, current_declspecs, $4, $2,
2582 build_tree_list ($3, prefix_attributes)); }
2583 | constructor_declarator maybeasm maybe_attribute maybe_init
2584 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2585 &prefix_attributes);
2586 $<ttype>0 = current_declspecs;
2587 $$ = grokfield ($$, current_declspecs, $4, $2,
2588 build_tree_list ($3, prefix_attributes)); }
2589 | IDENTIFIER ':' expr_no_commas maybe_attribute
2590 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2591 &prefix_attributes);
2592 $<ttype>0 = current_declspecs;
2593 $$ = grokbitfield ($$, current_declspecs, $3);
2594 cplus_decl_attributes ($$, $4, prefix_attributes); }
2595 | ':' expr_no_commas maybe_attribute
2596 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2597 &prefix_attributes);
2598 $<ttype>0 = current_declspecs;
2599 $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
2600 cplus_decl_attributes ($$, $3, prefix_attributes); }
2603 after_type_component_declarator:
2604 after_type_declarator maybeasm maybe_attribute maybe_init
2605 { $$ = grokfield ($$, current_declspecs, $4, $2,
2606 build_tree_list ($3, prefix_attributes)); }
2607 | TYPENAME ':' expr_no_commas maybe_attribute
2608 { $$ = grokbitfield ($$, current_declspecs, $3);
2609 cplus_decl_attributes ($$, $4, prefix_attributes); }
2612 notype_component_declarator:
2613 notype_declarator maybeasm maybe_attribute maybe_init
2614 { $$ = grokfield ($$, current_declspecs, $4, $2,
2615 build_tree_list ($3, prefix_attributes)); }
2616 | IDENTIFIER ':' expr_no_commas maybe_attribute
2617 { $$ = grokbitfield ($$, current_declspecs, $3);
2618 cplus_decl_attributes ($$, $4, prefix_attributes); }
2619 | ':' expr_no_commas maybe_attribute
2620 { $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
2621 cplus_decl_attributes ($$, $3, prefix_attributes); }
2624 /* We chain the enumerators in reverse order.
2625 Because of the way enums are built, the order is
2626 insignificant. Take advantage of this fact. */
2630 | enumlist ',' enumerator
2631 { TREE_CHAIN ($3) = $$; $$ = $3; }
2636 { $$ = build_enumerator ($$, NULL_TREE, current_enum_type); }
2637 | identifier '=' expr_no_commas
2638 { $$ = build_enumerator ($$, $3, current_enum_type); }
2641 /* ANSI new-type-id (5.3.4) */
2643 type_specifier_seq new_declarator
2644 { $$.t = build_decl_list ($1.t, $2);
2645 $$.new_type_flag = $1.new_type_flag; }
2646 | type_specifier_seq %prec EMPTY
2647 { $$.t = build_decl_list ($1.t, NULL_TREE);
2648 $$.new_type_flag = $1.new_type_flag; }
2649 /* GNU extension to allow arrays of arbitrary types with
2650 non-constant dimension. For the use of begin_new_placement
2651 here, see the comments in unary_expr above. */
2652 | '(' .begin_new_placement type_id .finish_new_placement
2656 pedwarn ("ANSI C++ forbids array dimensions with parenthesized type in new");
2657 $$.t = build_parse_node (ARRAY_REF, TREE_VALUE ($3.t), $6);
2658 $$.t = build_decl_list (TREE_PURPOSE ($3.t), $$.t);
2659 $$.new_type_flag = $3.new_type_flag;
2664 /* empty */ %prec EMPTY
2666 | cv_qualifiers CV_QUALIFIER
2667 { $$ = decl_tree_cons (NULL_TREE, $2, $$); }
2670 nonempty_cv_qualifiers:
2672 { $$.t = IDENTIFIER_AS_LIST ($1);
2673 $$.new_type_flag = 0; }
2674 | nonempty_cv_qualifiers CV_QUALIFIER
2675 { $$.t = decl_tree_cons (NULL_TREE, $2, $1.t);
2676 $$.new_type_flag = $1.new_type_flag; }
2679 /* These rules must follow the rules for function declarations
2680 and component declarations. That way, longer rules are preferred. */
2684 { $<itype>$ = suspend_momentary (); }
2686 /* An expression which will not live on the momentary obstack. */
2689 { resume_momentary ((int) $<itype>1); $$ = $2; }
2692 /* An expression which will not live on the momentary obstack. */
2694 suspend_mom '(' nonnull_exprlist ')'
2695 { resume_momentary ((int) $<itype>1); $$ = $3; }
2696 | suspend_mom '(' parmlist ')'
2697 { resume_momentary ((int) $<itype>1); $$ = $3; }
2698 | suspend_mom LEFT_RIGHT
2699 { resume_momentary ((int) $<itype>1); $$ = empty_parms (); }
2700 | suspend_mom '(' error ')'
2701 { resume_momentary ((int) $<itype>1); $$ = NULL_TREE; }
2704 /* A declarator that is allowed only after an explicit typespec. */
2705 /* may all be followed by prec '.' */
2706 after_type_declarator:
2707 '*' nonempty_cv_qualifiers after_type_declarator %prec UNARY
2708 { $$ = make_pointer_declarator ($2.t, $3); }
2709 | '&' nonempty_cv_qualifiers after_type_declarator %prec UNARY
2710 { $$ = make_reference_declarator ($2.t, $3); }
2711 | '*' after_type_declarator %prec UNARY
2712 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2713 | '&' after_type_declarator %prec UNARY
2714 { $$ = make_reference_declarator (NULL_TREE, $2); }
2715 | ptr_to_mem cv_qualifiers after_type_declarator
2716 { tree arg = make_pointer_declarator ($2, $3);
2717 $$ = build_parse_node (SCOPE_REF, $1, arg);
2719 | direct_after_type_declarator
2723 type_name %prec EMPTY
2725 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2727 $$ = lookup_name ($1, 1);
2728 if (current_class_type
2729 && TYPE_BEING_DEFINED (current_class_type)
2730 && ! IDENTIFIER_CLASS_VALUE ($1))
2732 /* Remember that this name has been used in the class
2733 definition, as per [class.scope0] */
2734 pushdecl_class_level ($$);
2740 | global_scope type_name
2742 if (TREE_CODE ($2) == IDENTIFIER_NODE)
2743 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
2746 got_scope = NULL_TREE;
2753 | global_scope nested_type
2758 nested_name_specifier type_name %prec EMPTY
2759 { $$ = get_type_decl ($2); }
2762 direct_after_type_declarator:
2763 direct_after_type_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2764 { $$ = make_call_declarator ($$, $2, $3, $4); }
2765 | direct_after_type_declarator '[' nonmomentary_expr ']'
2766 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
2767 | direct_after_type_declarator '[' ']'
2768 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
2769 | '(' after_type_declarator ')'
2771 | nested_name_specifier type_name %prec EMPTY
2772 { push_nested_class ($1, 3);
2773 $$ = build_parse_node (SCOPE_REF, $$, $2);
2774 TREE_COMPLEXITY ($$) = current_class_depth; }
2775 | type_name %prec EMPTY
2778 /* A declarator allowed whether or not there has been
2779 an explicit typespec. These cannot redeclare a typedef-name. */
2781 notype_declarator_intern:
2783 | attributes notype_declarator
2785 /* Provide support for '(' attributes '*' declarator ')'
2787 $$ = decl_tree_cons ($1, $2, NULL_TREE);
2792 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2793 { $$ = make_pointer_declarator ($2.t, $3); }
2794 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2795 { $$ = make_reference_declarator ($2.t, $3); }
2796 | '*' notype_declarator_intern %prec UNARY
2797 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2798 | '&' notype_declarator_intern %prec UNARY
2799 { $$ = make_reference_declarator (NULL_TREE, $2); }
2800 | ptr_to_mem cv_qualifiers notype_declarator_intern
2801 { tree arg = make_pointer_declarator ($2, $3);
2802 $$ = build_parse_node (SCOPE_REF, $1, arg);
2804 | direct_notype_declarator
2807 complex_notype_declarator:
2808 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2809 { $$ = make_pointer_declarator ($2.t, $3); }
2810 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2811 { $$ = make_reference_declarator ($2.t, $3); }
2812 | '*' complex_notype_declarator %prec UNARY
2813 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2814 | '&' complex_notype_declarator %prec UNARY
2815 { $$ = make_reference_declarator (NULL_TREE, $2); }
2816 | ptr_to_mem cv_qualifiers notype_declarator_intern
2817 { tree arg = make_pointer_declarator ($2, $3);
2818 $$ = build_parse_node (SCOPE_REF, $1, arg);
2820 | complex_direct_notype_declarator
2823 complex_direct_notype_declarator:
2824 direct_notype_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2825 { $$ = make_call_declarator ($$, $2, $3, $4); }
2826 | '(' complex_notype_declarator ')'
2828 | direct_notype_declarator '[' nonmomentary_expr ']'
2829 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
2830 | direct_notype_declarator '[' ']'
2831 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
2832 | notype_qualified_id
2833 { enter_scope_of ($1); }
2834 | nested_name_specifier notype_template_declarator
2835 { got_scope = NULL_TREE;
2836 $$ = build_parse_node (SCOPE_REF, $1, $2);
2837 enter_scope_of ($$);
2842 nested_name_specifier unqualified_id
2843 { got_scope = NULL_TREE;
2844 $$ = build_parse_node (SCOPE_REF, $$, $2); }
2845 | nested_name_specifier object_template_id
2846 { got_scope = NULL_TREE;
2847 $$ = build_parse_node (SCOPE_REF, $1, $2); }
2850 notype_qualified_id:
2851 nested_name_specifier notype_unqualified_id
2852 { got_scope = NULL_TREE;
2853 $$ = build_parse_node (SCOPE_REF, $$, $2); }
2854 | nested_name_specifier object_template_id
2855 { got_scope = NULL_TREE;
2856 $$ = build_parse_node (SCOPE_REF, $1, $2); }
2861 | global_scope notype_qualified_id
2866 typespec '(' nonnull_exprlist ')'
2867 { $$ = build_functional_cast ($1.t, $3); }
2868 | typespec '(' expr_or_declarator_intern ')'
2869 { $$ = reparse_decl_as_expr ($1.t, $3); }
2870 | typespec fcast_or_absdcl %prec EMPTY
2871 { $$ = reparse_absdcl_as_expr ($1.t, $2); }
2876 | template_type %prec EMPTY
2879 nested_name_specifier:
2880 nested_name_specifier_1
2881 | nested_name_specifier nested_name_specifier_1
2883 | nested_name_specifier TEMPLATE explicit_template_type SCOPE
2884 { got_scope = $$ = make_typename_type ($1, $3); }
2887 /* Why the @#$%^& do type_name and notype_identifier need to be expanded
2888 inline here?!? (jason) */
2889 nested_name_specifier_1:
2892 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2895 /* Remember that this name has been used in the class
2896 definition, as per [class.scope0] */
2897 if (current_class_type
2898 && TYPE_BEING_DEFINED (current_class_type)
2899 && ! IDENTIFIER_CLASS_VALUE ($1))
2900 pushdecl_class_level ($$);
2902 got_scope = $$ = TYPE_MAIN_VARIANT (TREE_TYPE ($$));
2906 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2908 got_scope = $$ = TREE_TYPE ($$);
2912 if (TREE_CODE ($$) == IDENTIFIER_NODE)
2916 | template_type SCOPE
2917 { got_scope = $$ = complete_type (TREE_TYPE ($1)); }
2918 /* These break 'const i;'
2922 cp_error ("`%D' is not an aggregate typedef",
2923 lastiddecl ? lastiddecl : $$);
2924 $$ = error_mark_node;
2927 { goto failed_scope; } */
2932 | global_scope typename_sub0
2937 typename_sub1 identifier %prec EMPTY
2939 if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't')
2940 $$ = make_typename_type ($1, $2);
2941 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
2942 cp_error ("`%T' is not a class or namespace", $2);
2946 if (TREE_CODE ($$) == TYPE_DECL)
2947 $$ = TREE_TYPE ($$);
2950 | typename_sub1 template_type %prec EMPTY
2951 { $$ = TREE_TYPE ($2); }
2952 | typename_sub1 explicit_template_type %prec EMPTY
2953 { $$ = make_typename_type ($1, $2); }
2954 | typename_sub1 TEMPLATE explicit_template_type %prec EMPTY
2955 { $$ = make_typename_type ($1, $3); }
2961 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2962 cp_error ("`%T' is not a class or namespace", $1);
2964 | typename_sub1 typename_sub2
2966 if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't')
2967 $$ = make_typename_type ($1, $2);
2968 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
2969 cp_error ("`%T' is not a class or namespace", $2);
2973 if (TREE_CODE ($$) == TYPE_DECL)
2974 $$ = TREE_TYPE ($$);
2977 | typename_sub1 explicit_template_type SCOPE
2978 { got_scope = $$ = make_typename_type ($1, $2); }
2979 | typename_sub1 TEMPLATE explicit_template_type SCOPE
2980 { got_scope = $$ = make_typename_type ($1, $3); }
2986 if (TREE_CODE ($1) != IDENTIFIER_NODE)
2989 /* Retrieve the type for the identifier, which might involve
2990 some computation. */
2991 got_scope = $$ = complete_type (IDENTIFIER_TYPE_VALUE ($1));
2993 if ($$ == error_mark_node)
2994 cp_error ("`%T' is not a class or namespace", $1);
2998 if (TREE_CODE ($1) != IDENTIFIER_NODE)
3000 got_scope = $$ = complete_type (TREE_TYPE ($$));
3002 | template_type SCOPE
3003 { got_scope = $$ = complete_type (TREE_TYPE ($$)); }
3008 if (TREE_CODE ($$) == IDENTIFIER_NODE)
3014 explicit_template_type:
3015 identifier '<' template_arg_list_opt template_close_bracket
3016 { $$ = build_min_nt (TEMPLATE_ID_EXPR, $1, $3); }
3020 global_scope type_name
3022 if (TREE_CODE ($2) == IDENTIFIER_NODE)
3023 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
3026 got_scope = NULL_TREE;
3029 | global_scope nested_type
3034 nested_name_specifier '*'
3035 { got_scope = NULL_TREE; }
3036 | global_scope nested_name_specifier '*'
3037 { $$ = $2; got_scope = NULL_TREE; }
3040 /* All uses of explicit global scope must go through this nonterminal so
3041 that got_scope will be set before yylex is called to get the next token. */
3044 { got_scope = void_type_node; }
3047 /* ANSI new-declarator (5.3.4) */
3049 '*' cv_qualifiers new_declarator
3050 { $$ = make_pointer_declarator ($2, $3); }
3051 | '*' cv_qualifiers %prec EMPTY
3052 { $$ = make_pointer_declarator ($2, NULL_TREE); }
3053 | '&' cv_qualifiers new_declarator %prec EMPTY
3054 { $$ = make_reference_declarator ($2, $3); }
3055 | '&' cv_qualifiers %prec EMPTY
3056 { $$ = make_reference_declarator ($2, NULL_TREE); }
3057 | ptr_to_mem cv_qualifiers %prec EMPTY
3058 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3059 $$ = build_parse_node (SCOPE_REF, $1, arg);
3061 | ptr_to_mem cv_qualifiers new_declarator
3062 { tree arg = make_pointer_declarator ($2, $3);
3063 $$ = build_parse_node (SCOPE_REF, $1, arg);
3065 | direct_new_declarator %prec EMPTY
3068 /* ANSI direct-new-declarator (5.3.4) */
3069 direct_new_declarator:
3071 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3072 | direct_new_declarator '[' nonmomentary_expr ']'
3073 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3076 /* ANSI abstract-declarator (8.1) */
3078 '*' nonempty_cv_qualifiers absdcl
3079 { $$ = make_pointer_declarator ($2.t, $3); }
3081 { $$ = make_pointer_declarator (NULL_TREE, $2); }
3082 | '*' nonempty_cv_qualifiers %prec EMPTY
3083 { $$ = make_pointer_declarator ($2.t, NULL_TREE); }
3085 { $$ = make_pointer_declarator (NULL_TREE, NULL_TREE); }
3086 | '&' nonempty_cv_qualifiers absdcl
3087 { $$ = make_reference_declarator ($2.t, $3); }
3089 { $$ = make_reference_declarator (NULL_TREE, $2); }
3090 | '&' nonempty_cv_qualifiers %prec EMPTY
3091 { $$ = make_reference_declarator ($2.t, NULL_TREE); }
3093 { $$ = make_reference_declarator (NULL_TREE, NULL_TREE); }
3094 | ptr_to_mem cv_qualifiers %prec EMPTY
3095 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3096 $$ = build_parse_node (SCOPE_REF, $1, arg);
3098 | ptr_to_mem cv_qualifiers absdcl
3099 { tree arg = make_pointer_declarator ($2, $3);
3100 $$ = build_parse_node (SCOPE_REF, $1, arg);
3102 | direct_abstract_declarator %prec EMPTY
3105 /* ANSI direct-abstract-declarator (8.1) */
3106 direct_abstract_declarator:
3109 /* `(typedef)1' is `int'. */
3111 | direct_abstract_declarator '(' parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3112 { $$ = make_call_declarator ($$, $3, $5, $6); }
3113 | direct_abstract_declarator LEFT_RIGHT cv_qualifiers exception_specification_opt %prec '.'
3114 { $$ = make_call_declarator ($$, empty_parms (), $3, $4); }
3115 | direct_abstract_declarator '[' nonmomentary_expr ']' %prec '.'
3116 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3117 | direct_abstract_declarator '[' ']' %prec '.'
3118 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
3119 | '(' complex_parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3120 { $$ = make_call_declarator (NULL_TREE, $2, $4, $5); }
3121 | regcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3122 { set_quals_and_spec ($$, $2, $3); }
3123 | fcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3124 { set_quals_and_spec ($$, $2, $3); }
3125 | '[' nonmomentary_expr ']' %prec '.'
3126 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3128 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, NULL_TREE); }
3131 /* For C++, decls and stmts can be intermixed, so we don't need to
3132 have a special rule that won't start parsing the stmt section
3133 until we have a stmt that parses without errors. */
3146 /* Read zero or more forward-declarations for labels
3147 that nested functions can jump to. */
3152 pedwarn ("ANSI C++ forbids label declarations"); }
3157 | label_decls label_decl
3161 LABEL identifiers_or_typenames ';'
3163 for (link = $2; link; link = TREE_CHAIN (link))
3165 tree label = shadow_label (TREE_VALUE (link));
3166 C_DECLARED_LABEL_FLAG (label) = 1;
3167 declare_nonlocal_label (label);
3172 /* This is the body of a function definition.
3173 It causes syntax errors to ignore to the next openbrace. */
3182 { $<ttype>$ = begin_compound_stmt (0); }
3184 { $$ = finish_compound_stmt (0, $<ttype>2); }
3190 $<ttype>$ = begin_if_stmt ();
3191 cond_stmt_keyword = "if";
3194 { finish_if_stmt_cond ($3, $<ttype>2); }
3195 implicitly_scoped_stmt
3196 { $<ttype>$ = finish_then_clause ($<ttype>2); }
3199 implicitly_scoped_stmt:
3201 | { $<ttype>$ = begin_compound_stmt (0); }
3203 { $$ = finish_compound_stmt (0, $<ttype>1); }
3216 { finish_expr_stmt ($1); }
3218 { begin_else_clause (); }
3219 implicitly_scoped_stmt
3221 finish_else_clause ($<ttype>1);
3224 | simple_if %prec IF
3225 { finish_if_stmt (); }
3228 $<ttype>$ = begin_while_stmt ();
3229 cond_stmt_keyword = "while";
3232 { finish_while_stmt_cond ($3, $<ttype>2); }
3234 { finish_while_stmt ($<ttype>2); }
3236 { $<ttype>$ = begin_do_stmt (); }
3237 implicitly_scoped_stmt WHILE
3239 finish_do_body ($<ttype>2);
3240 cond_stmt_keyword = "do";
3242 paren_expr_or_null ';'
3243 { finish_do_stmt ($6, $<ttype>2); }
3245 { $<ttype>$ = begin_for_stmt (); }
3246 '(' for.init.statement
3247 { finish_for_init_stmt ($<ttype>2); }
3249 { finish_for_cond ($6, $<ttype>2); }
3251 { finish_for_expr ($9, $<ttype>2); }
3253 { finish_for_stmt ($9, $<ttype>2); }
3255 { begin_switch_stmt (); }
3257 { $<ttype>$ = finish_switch_cond ($4); }
3258 implicitly_scoped_stmt
3259 { finish_switch_stmt ($4, $<ttype>6); }
3260 | CASE expr_no_commas ':'
3261 { finish_case_label ($2, NULL_TREE); }
3263 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
3264 { finish_case_label ($2, $4); }
3267 { finish_case_label (NULL_TREE, NULL_TREE); }
3270 { finish_break_stmt (); }
3272 { finish_continue_stmt (); }
3274 { finish_return_stmt (NULL_TREE); }
3276 { finish_return_stmt ($2); }
3277 | asm_keyword maybe_cv_qualifier '(' string ')' ';'
3279 finish_asm_stmt ($2, $4, NULL_TREE, NULL_TREE,
3282 /* This is the case with just output operands. */
3283 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ')' ';'
3285 finish_asm_stmt ($2, $4, $6, NULL_TREE,
3288 /* This is the case with input operands as well. */
3289 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':' asm_operands ')' ';'
3290 { finish_asm_stmt ($2, $4, $6, $8, NULL_TREE); }
3291 /* This is the case with clobbered registers as well. */
3292 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':'
3293 asm_operands ':' asm_clobbers ')' ';'
3294 { finish_asm_stmt ($2, $4, $6, $8, $10); }
3298 pedwarn ("ANSI C++ forbids computed gotos");
3299 finish_goto_stmt ($3);
3301 | GOTO identifier ';'
3302 { finish_goto_stmt ($2); }
3306 { error ("label must be followed by statement");
3313 | namespace_using_decl
3314 { do_local_using_decl ($1); }
3321 if (! current_function_parms_stored)
3322 store_parm_decls ();
3323 expand_start_early_try_stmts ();
3325 ctor_initializer_opt compstmt
3327 expand_start_all_catch ();
3331 int nested = (hack_decl_function_context
3332 (current_function_decl) != NULL_TREE);
3333 expand_end_all_catch ();
3334 finish_function (lineno, (int)$3, nested);
3340 { $<ttype>$ = begin_try_block (); }
3342 { finish_try_block ($<ttype>2); }
3344 { finish_handler_sequence ($<ttype>2); }
3349 | handler_seq handler
3354 { $<ttype>$ = begin_handler(); }
3356 { finish_handler_parms ($<ttype>2); }
3358 { finish_handler ($<ttype>2); }
3362 typed_typespecs %prec EMPTY
3363 | nonempty_cv_qualifiers %prec EMPTY
3368 { expand_start_catch_block (NULL_TREE, NULL_TREE); }
3369 /* This doesn't allow reference parameters, the below does.
3370 | '(' type_specifier_seq absdcl ')'
3371 { check_for_new_type ("inside exception declarations", $2);
3372 expand_start_catch_block ($2.t, $3); }
3373 | '(' type_specifier_seq ')'
3374 { check_for_new_type ("inside exception declarations", $2);
3375 expand_start_catch_block ($2.t, NULL_TREE); }
3376 | '(' type_specifier_seq notype_declarator ')'
3377 { check_for_new_type ("inside exception declarations", $2);
3378 expand_start_catch_block ($2.t, $3); }
3379 | '(' typed_typespecs after_type_declarator ')'
3380 { check_for_new_type ("inside exception declarations", $2);
3381 expand_start_catch_block ($2.t, $3); }
3382 This allows reference parameters... */
3384 { check_for_new_type ("inside exception declarations", $2);
3385 expand_start_catch_block (TREE_PURPOSE ($2.t),
3386 TREE_VALUE ($2.t)); }
3393 label = define_label (input_filename, lineno, $1);
3394 if (label && ! minimal_parse_mode)
3395 expand_label (label);
3407 { if ($1) cplus_expand_expr_stmt ($1); }
3411 pedwarn ("ANSI C++ forbids compound statements inside for initializations");
3415 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
3419 { emit_line_note (input_filename, lineno);
3422 { emit_line_note (input_filename, lineno); }
3433 /* These are the operands other than the first string and colon
3434 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
3438 | nonnull_asm_operands
3441 nonnull_asm_operands:
3443 | nonnull_asm_operands ',' asm_operand
3444 { $$ = chainon ($$, $3); }
3449 { $$ = build_tree_list ($$, $3); }
3454 { $$ = tree_cons (NULL_TREE, $$, NULL_TREE); }
3455 | asm_clobbers ',' STRING
3456 { $$ = tree_cons (NULL_TREE, $3, $$); }
3459 /* This is what appears inside the parens in a function declarator.
3460 Its value is represented in the format that grokdeclarator expects.
3462 In C++, declaring a function with no parameters
3463 means that that function takes *no* parameters. */
3472 { $$ = finish_parmlist (build_tree_list (NULL_TREE, $1.t), 0);
3473 check_for_new_type ("inside parameter list", $1); }
3476 /* This nonterminal does not include the common sequence '(' type_id ')',
3477 as it is ambiguous and must be disambiguated elsewhere. */
3480 { $$ = finish_parmlist ($$, 0); }
3481 | parms_comma ELLIPSIS
3482 { $$ = finish_parmlist ($1, 1); }
3483 /* C++ allows an ellipsis without a separating ',' */
3485 { $$ = finish_parmlist ($1, 1); }
3487 { $$ = finish_parmlist (build_tree_list (NULL_TREE,
3490 { $$ = finish_parmlist (NULL_TREE, 1); }
3493 /* This helps us recover from really nasty
3494 parse errors, for example, a missing right
3496 yyerror ("possibly missing ')'");
3497 $$ = finish_parmlist ($1, 0);
3503 /* This helps us recover from really nasty
3504 parse errors, for example, a missing right
3506 yyerror ("possibly missing ')'");
3507 $$ = finish_parmlist (build_tree_list (NULL_TREE,
3514 /* A default argument to a */
3517 { maybe_snarf_defarg (); }
3527 /* A nonempty list of parameter declarations or type names. */
3530 { check_for_new_type ("in a parameter list", $1);
3531 $$ = build_tree_list (NULL_TREE, $1.t); }
3533 { check_for_new_type ("in a parameter list", $1);
3534 $$ = build_tree_list ($2, $1.t); }
3535 | parms_comma full_parm
3536 { check_for_new_type ("in a parameter list", $2);
3537 $$ = chainon ($$, $2.t); }
3538 | parms_comma bad_parm
3539 { $$ = chainon ($$, build_tree_list (NULL_TREE, $2)); }
3540 | parms_comma bad_parm '=' init
3541 { $$ = chainon ($$, build_tree_list ($4, $2)); }
3547 { check_for_new_type ("in a parameter list", $1);
3548 $$ = build_tree_list (NULL_TREE, $1.t); }
3551 /* A single parameter declaration or parameter type name,
3552 as found in a parmlist. */
3554 /* Here we expand typed_declspecs inline to avoid mis-parsing of
3555 TYPESPEC IDENTIFIER. */
3556 typed_declspecs1 declarator
3557 { tree specs = strip_attrs ($1.t);
3558 $$.new_type_flag = $1.new_type_flag;
3559 $$.t = build_tree_list (specs, $2); }
3560 | typed_typespecs declarator
3561 { $$.t = build_tree_list ($1.t, $2);
3562 $$.new_type_flag = $1.new_type_flag; }
3563 | typespec declarator
3564 { $$.t = build_tree_list (get_decl_list ($1.t), $2);
3565 $$.new_type_flag = $1.new_type_flag; }
3566 | typed_declspecs1 absdcl
3567 { tree specs = strip_attrs ($1.t);
3568 $$.t = build_tree_list (specs, $2);
3569 $$.new_type_flag = $1.new_type_flag; }
3570 | typed_declspecs1 %prec EMPTY
3571 { tree specs = strip_attrs ($1.t);
3572 $$.t = build_tree_list (specs, NULL_TREE);
3573 $$.new_type_flag = $1.new_type_flag; }
3574 | declmods notype_declarator
3575 { tree specs = strip_attrs ($1);
3576 $$.t = build_tree_list (specs, $2);
3577 $$.new_type_flag = 0; }
3582 { $$.t = build_tree_list (NULL_TREE, $1.t);
3583 $$.new_type_flag = $1.new_type_flag; }
3585 { $$.t = build_tree_list ($2, $1.t);
3586 $$.new_type_flag = $1.new_type_flag; }
3595 /* empty */ %prec EMPTY
3596 { see_typename (); }
3600 /* empty */ %prec EMPTY
3602 error ("type specifier omitted for parameter");
3603 $$ = build_tree_list (integer_type_node, NULL_TREE);
3607 error ("type specifier omitted for parameter");
3608 if (TREE_CODE ($$) == SCOPE_REF
3609 && (TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TYPE_PARM
3610 || TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TEMPLATE_PARM))
3611 cp_error (" perhaps you want `typename %E' to make it a type", $$);
3612 $$ = build_tree_list (integer_type_node, $$);
3616 exception_specification_opt:
3617 /* empty */ %prec EMPTY
3619 | THROW '(' ansi_raise_identifiers ')' %prec EMPTY
3621 | THROW LEFT_RIGHT %prec EMPTY
3622 { $$ = build_decl_list (NULL_TREE, NULL_TREE); }
3625 ansi_raise_identifier:
3627 { $$ = build_decl_list (NULL_TREE, groktypename($1.t)); }
3630 ansi_raise_identifiers:
3631 ansi_raise_identifier
3632 | ansi_raise_identifiers ',' ansi_raise_identifier
3634 TREE_CHAIN ($3) = $$;
3639 conversion_declarator:
3640 /* empty */ %prec EMPTY
3642 | '*' cv_qualifiers conversion_declarator
3643 { $$ = make_pointer_declarator ($2, $3); }
3644 | '&' cv_qualifiers conversion_declarator
3645 { $$ = make_reference_declarator ($2, $3); }
3646 | ptr_to_mem cv_qualifiers conversion_declarator
3647 { tree arg = make_pointer_declarator ($2, $3);
3648 $$ = build_parse_node (SCOPE_REF, $1, arg);
3654 { got_scope = NULL_TREE; }
3659 { $$ = ansi_opname[MULT_EXPR]; }
3661 { $$ = ansi_opname[TRUNC_DIV_EXPR]; }
3663 { $$ = ansi_opname[TRUNC_MOD_EXPR]; }
3665 { $$ = ansi_opname[PLUS_EXPR]; }
3667 { $$ = ansi_opname[MINUS_EXPR]; }
3669 { $$ = ansi_opname[BIT_AND_EXPR]; }
3671 { $$ = ansi_opname[BIT_IOR_EXPR]; }
3673 { $$ = ansi_opname[BIT_XOR_EXPR]; }
3675 { $$ = ansi_opname[BIT_NOT_EXPR]; }
3677 { $$ = ansi_opname[COMPOUND_EXPR]; }
3678 | operator ARITHCOMPARE
3679 { $$ = ansi_opname[$2]; }
3681 { $$ = ansi_opname[LT_EXPR]; }
3683 { $$ = ansi_opname[GT_EXPR]; }
3684 | operator EQCOMPARE
3685 { $$ = ansi_opname[$2]; }
3687 { $$ = ansi_assopname[$2]; }
3689 { $$ = ansi_opname [MODIFY_EXPR]; }
3691 { $$ = ansi_opname[$2]; }
3693 { $$ = ansi_opname[$2]; }
3695 { $$ = ansi_opname[POSTINCREMENT_EXPR]; }
3696 | operator MINUSMINUS
3697 { $$ = ansi_opname[PREDECREMENT_EXPR]; }
3699 { $$ = ansi_opname[TRUTH_ANDIF_EXPR]; }
3701 { $$ = ansi_opname[TRUTH_ORIF_EXPR]; }
3703 { $$ = ansi_opname[TRUTH_NOT_EXPR]; }
3705 { $$ = ansi_opname[COND_EXPR]; }
3707 { $$ = ansi_opname[$2]; }
3708 | operator POINTSAT %prec EMPTY
3709 { $$ = ansi_opname[COMPONENT_REF]; }
3710 | operator POINTSAT_STAR %prec EMPTY
3711 { $$ = ansi_opname[MEMBER_REF]; }
3712 | operator LEFT_RIGHT
3713 { $$ = ansi_opname[CALL_EXPR]; }
3715 { $$ = ansi_opname[ARRAY_REF]; }
3716 | operator NEW %prec EMPTY
3717 { $$ = ansi_opname[NEW_EXPR]; }
3718 | operator DELETE %prec EMPTY
3719 { $$ = ansi_opname[DELETE_EXPR]; }
3720 | operator NEW '[' ']'
3721 { $$ = ansi_opname[VEC_NEW_EXPR]; }
3722 | operator DELETE '[' ']'
3723 { $$ = ansi_opname[VEC_DELETE_EXPR]; }
3724 /* Names here should be looked up in class scope ALSO. */
3725 | operator type_specifier_seq conversion_declarator
3726 { $$ = grokoptypename ($2.t, $3); }
3728 { $$ = ansi_opname[ERROR_MARK]; }
3735 debug_yytranslate (value)
3738 return yytname[YYTRANSLATE (value)];