1 /* YACC parser for C++ syntax.
2 Copyright (C) 1988, 89, 93-98, 1999 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 const char *cond_stmt_keyword;
65 static tree empty_parms PROTO((void));
66 static int parse_decl PROTO((tree, tree, tree, int, tree *));
68 /* Nonzero if we have an `extern "C"' acting as an extern specifier. */
72 /* Cons up an empty parameter list. */
82 || current_class_type != NULL)
83 parms = void_list_node;
93 %union {long itype; tree ttype; char *strtype; enum tree_code code; flagged_type_tree ftype; }
95 /* All identifiers that are not reserved words
96 and are not declared typedefs in the current block */
99 /* All identifiers that are declared typedefs in the current block.
100 In some contexts, they are treated just like IDENTIFIER,
101 but they can also serve as typespecs in declarations. */
105 /* A template function. */
108 /* Reserved words that specify storage class.
109 yylval contains an IDENTIFIER_NODE which indicates which one. */
112 /* Reserved words that specify type.
113 yylval contains an IDENTIFIER_NODE which indicates which one. */
116 /* Reserved words that qualify type: "const" or "volatile".
117 yylval contains an IDENTIFIER_NODE which indicates which one. */
120 /* Character or numeric constants.
121 yylval is the node for the constant. */
124 /* String constants in raw form.
125 yylval is a STRING_CST node. */
128 /* "...", used for functions with variable arglists. */
131 /* the reserved words */
132 /* SCO include files test "ASM", so use something else. */
133 %token SIZEOF ENUM /* STRUCT UNION */ IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
134 %token BREAK CONTINUE RETURN_KEYWORD GOTO ASM_KEYWORD TYPEOF ALIGNOF
136 %token ATTRIBUTE EXTENSION LABEL
137 %token REALPART IMAGPART
139 /* the reserved words... C++ extensions */
141 %token <ttype> VISSPEC
142 %token DELETE NEW THIS OPERATOR CXX_TRUE CXX_FALSE
143 %token NAMESPACE TYPENAME_KEYWORD USING
144 %token LEFT_RIGHT TEMPLATE
145 %token TYPEID DYNAMIC_CAST STATIC_CAST REINTERPRET_CAST CONST_CAST
148 /* Define the operator tokens and their precedences.
149 The value is an integer because, if used, it is the tree code
150 to use in the expression made from the operator. */
152 %left EMPTY /* used to resolve s/r with epsilon */
156 /* Add precedence rules to solve dangling else s/r conflict */
160 %left IDENTIFIER PFUNCNAME TYPENAME SELFNAME PTYPENAME SCSPEC TYPESPEC CV_QUALIFIER ENUM AGGR ELLIPSIS TYPEOF SIGOF OPERATOR NSNAME TYPENAME_KEYWORD
166 %right <code> ASSIGN '='
174 %left <code> EQCOMPARE
175 %left <code> ARITHCOMPARE '<' '>'
176 %left <code> LSHIFT RSHIFT
178 %left <code> '*' '/' '%'
179 %left <code> POINTSAT_STAR DOT_STAR
180 %right <code> UNARY PLUSPLUS MINUSMINUS '~'
182 %left <ttype> PAREN_STAR_PAREN LEFT_RIGHT
183 %left <code> POINTSAT '.' '(' '['
185 %right SCOPE /* C++ extension */
186 %nonassoc NEW DELETE TRY CATCH
190 %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist
191 %type <ttype> PFUNCNAME maybe_identifier
192 %type <ttype> paren_expr_or_null nontrivial_exprlist SELFNAME
193 %type <ttype> expr_no_commas cast_expr unary_expr primary string STRING
194 %type <ttype> reserved_declspecs boolean.literal
195 %type <ttype> reserved_typespecquals
196 %type <ttype> declmods
197 %type <ttype> SCSPEC TYPESPEC CV_QUALIFIER maybe_cv_qualifier
198 %type <itype> initdecls notype_initdecls initdcl /* C++ modification */
199 %type <ttype> init initlist maybeasm maybe_init defarg defarg1
200 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
201 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
202 %type <ttype> any_word
204 %type <ttype> compstmt implicitly_scoped_stmt
206 %type <ttype> declarator notype_declarator after_type_declarator
207 %type <ttype> notype_declarator_intern absdcl_intern
208 %type <ttype> after_type_declarator_intern
209 %type <ttype> direct_notype_declarator direct_after_type_declarator
210 %type <itype> components notype_components
211 %type <ttype> component_decl component_decl_1
212 %type <ttype> component_declarator component_declarator0
213 %type <ttype> notype_component_declarator notype_component_declarator0
214 %type <ttype> after_type_component_declarator after_type_component_declarator0
215 %type <ttype> enumlist enumerator
216 %type <ttype> absdcl cv_qualifiers
217 %type <ttype> direct_abstract_declarator conversion_declarator
218 %type <ttype> new_declarator direct_new_declarator
219 %type <ttype> xexpr parmlist parms bad_parm
220 %type <ttype> identifiers_or_typenames
221 %type <ttype> fcast_or_absdcl regcast_or_absdcl
222 %type <ttype> expr_or_declarator expr_or_declarator_intern
223 %type <ttype> complex_notype_declarator
224 %type <ttype> notype_unqualified_id unqualified_id qualified_id
225 %type <ttype> template_id do_id object_template_id notype_template_declarator
226 %type <ttype> overqualified_id notype_qualified_id any_id
227 %type <ttype> complex_direct_notype_declarator functional_cast
228 %type <ttype> complex_parmlist parms_comma
229 %type <ttype> namespace_qualifier namespace_using_decl
231 %type <ftype> type_id new_type_id typed_typespecs typespec typed_declspecs
232 %type <ftype> typed_declspecs1 type_specifier_seq nonempty_cv_qualifiers
233 %type <ftype> structsp typespecqual_reserved parm named_parm full_parm
236 %token <ttype> PTYPENAME
237 %token <ttype> PRE_PARSED_FUNCTION_DECL EXTERN_LANG_STRING ALL
238 %token <ttype> PRE_PARSED_CLASS_DECL DEFARG DEFARG_MARKER
239 %type <ttype> component_constructor_declarator
240 %type <ttype> fn.def2 return_id fn.defpen constructor_declarator
241 %type <itype> ctor_initializer_opt function_try_block
242 %type <ttype> named_class_head_sans_basetype
243 %type <ftype> class_head named_class_head
244 %type <ftype> named_complex_class_head_sans_basetype
245 %type <ttype> unnamed_class_head
246 %type <ttype> base_class_list
247 %type <ttype> base_class_access_list
248 %type <ttype> base_class maybe_base_class_list base_class.1
249 %type <ttype> exception_specification_opt ansi_raise_identifier ansi_raise_identifiers
250 %type <ttype> operator_name
251 %type <ttype> object aggr
252 %type <itype> new delete .begin_new_placement
253 /* %type <ttype> primary_no_id */
254 %type <ttype> nonmomentary_expr maybe_parmlist
255 %type <itype> initdcl0 notype_initdcl0 member_init_list initdcl0_innards
256 %type <ttype> template_header template_parm_list template_parm
257 %type <ttype> template_type_parm template_template_parm
258 %type <code> template_close_bracket
259 %type <ttype> apparent_template_type
260 %type <ttype> template_type template_arg_list template_arg_list_opt
261 %type <ttype> template_arg
262 %type <ttype> condition xcond paren_cond_or_null
263 %type <ttype> type_name nested_name_specifier nested_type ptr_to_mem
264 %type <ttype> complete_type_name notype_identifier nonnested_type
265 %type <ttype> complex_type_name nested_name_specifier_1
266 %type <ttype> new_initializer new_placement
267 %type <ttype> using_decl
268 %type <ttype> typename_sub typename_sub0 typename_sub1 typename_sub2
269 %type <ttype> explicit_template_type
270 /* in order to recognize aggr tags as defining and thus shadowing. */
271 %token TYPENAME_DEFN IDENTIFIER_DEFN PTYPENAME_DEFN
272 %type <ttype> named_class_head_sans_basetype_defn
273 %type <ttype> identifier_defn IDENTIFIER_DEFN TYPENAME_DEFN PTYPENAME_DEFN
275 %type <ttype> self_template_type .finish_template_type
280 /* Used in lex.c for parsing pragmas. */
283 /* lex.c and pt.c depend on this being the last token. Define
284 any new tokens before this one! */
285 %token END_OF_SAVED_INPUT
288 /* List of types and structure classes of the current declaration. */
289 static tree current_declspecs;
291 /* List of prefix attributes in effect.
292 Prefix attributes are parsed by the reserved_declspecs and declmods
293 rules. They create a list that contains *both* declspecs and attrs. */
294 /* ??? It is not clear yet that all cases where an attribute can now appear in
295 a declspec list have been updated. */
296 static tree prefix_attributes;
298 /* When defining an aggregate, this is the kind of the most recent one
299 being defined. (For example, this might be class_type_node.) */
300 static tree current_aggr;
302 /* When defining an enumeration, this is the type of the enumeration. */
303 static tree current_enum_type;
305 /* Tell yyparse how to print a token's value, if yydebug is set. */
307 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
308 extern void yyprint PROTO((FILE *, int, YYSTYPE));
309 extern tree combine_strings PROTO((tree));
312 parse_decl(declarator, specs_attrs, attributes, initialized, decl)
321 split_specs_attrs (specs_attrs, ¤t_declspecs, &prefix_attributes);
322 if (current_declspecs
323 && TREE_CODE (current_declspecs) != TREE_LIST)
324 current_declspecs = build_decl_list (NULL_TREE, current_declspecs);
325 if (have_extern_spec && !used_extern_spec)
327 current_declspecs = decl_tree_cons (NULL_TREE,
328 get_identifier ("extern"),
330 used_extern_spec = 1;
332 sm = suspend_momentary ();
333 *decl = start_decl (declarator, current_declspecs, initialized,
334 attributes, prefix_attributes);
343 { finish_translation_unit (); }
346 /* the reason for the strange actions in this rule
347 is so that notype_initdecls when reached via datadef
348 can find a valid list of type and sc specs in $0. */
351 { $<ttype>$ = NULL_TREE; }
353 { $<ttype>$ = NULL_TREE; }
354 | extdefs lang_extdef
355 { $<ttype>$ = NULL_TREE; }
364 { have_extern_spec = 1;
365 used_extern_spec = 0;
366 $<ttype>$ = NULL_TREE; }
369 { have_extern_spec = 0; }
374 { $<itype>$ = pedantic;
383 { if (pending_lang_change) do_pending_lang_change(); }
385 { if (! toplevel_bindings_p () && ! pseudo_global_level_p())
390 fndef eat_saved_input
391 { if (pending_inlines) do_pending_inlines (); }
393 { if (pending_inlines) do_pending_inlines (); }
395 { if (pending_inlines) do_pending_inlines (); }
396 | asm_keyword '(' string ')' ';'
397 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
399 | extern_lang_string '{' extdefs_opt '}'
400 { pop_lang_context (); }
401 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
402 { if (pending_inlines) do_pending_inlines ();
403 pop_lang_context (); }
404 | extern_lang_string .hush_warning datadef .warning_ok
405 { if (pending_inlines) do_pending_inlines ();
406 pop_lang_context (); }
407 | NAMESPACE identifier '{'
408 { push_namespace ($2); }
410 { pop_namespace (); }
412 { push_namespace (NULL_TREE); }
414 { pop_namespace (); }
417 { do_toplevel_using_decl ($1); }
420 { pedantic = $<itype>1; }
424 NAMESPACE identifier '='
425 { begin_only_namespace_names (); }
428 end_only_namespace_names ();
431 do_namespace_alias ($2, $5);
438 | USING global_scope qualified_id
440 | USING global_scope unqualified_id
444 namespace_using_decl:
445 USING namespace_qualifier identifier
446 { $$ = build_parse_node (SCOPE_REF, $2, $3); }
447 | USING global_scope identifier
448 { $$ = build_parse_node (SCOPE_REF, global_namespace, $3); }
449 | USING global_scope namespace_qualifier identifier
450 { $$ = build_parse_node (SCOPE_REF, $3, $4); }
455 { begin_only_namespace_names (); }
458 end_only_namespace_names ();
459 /* If no declaration was found, the using-directive is
460 invalid. Since that was not reported, we need the
461 identifier for the error message. */
462 if (TREE_CODE ($4) == IDENTIFIER_NODE && lastiddecl)
464 do_using_directive ($4);
471 if (TREE_CODE ($$) == IDENTIFIER_NODE)
475 | namespace_qualifier NSNAME SCOPE
478 if (TREE_CODE ($$) == IDENTIFIER_NODE)
486 | global_scope qualified_id
488 | global_scope unqualified_id
494 { push_lang_context ($1); }
495 | extern_lang_string EXTERN_LANG_STRING
496 { if (current_lang_name != $2)
497 cp_error ("use of linkage spec `%D' is different from previous spec `%D'", $2, current_lang_name);
498 pop_lang_context (); push_lang_context ($2); }
503 { begin_template_parm_list (); }
504 template_parm_list '>'
505 { $$ = end_template_parm_list ($4); }
507 { begin_specialization();
513 { $$ = process_template_parm (NULL_TREE, $1); }
514 | template_parm_list ',' template_parm
515 { $$ = process_template_parm ($1, $3); }
525 aggr maybe_identifier
526 { $$ = finish_template_type_parm ($1, $2); }
527 | TYPENAME_KEYWORD maybe_identifier
528 { $$ = finish_template_type_parm (class_type_node, $2); }
531 template_template_parm:
532 template_header aggr maybe_identifier
533 { $$ = finish_template_template_parm ($2, $3); }
537 /* The following rules introduce a new reduce/reduce
538 conflict on the ',' and '>' input tokens: they are valid
539 prefixes for a `structsp', which means they could match a
540 nameless parameter. See 14.6, paragraph 3.
541 By putting them before the `parm' rule, we get
542 their match before considering them nameless parameter
545 { $$ = build_tree_list (NULL_TREE, $1); }
546 | template_type_parm '=' type_id
547 { $$ = build_tree_list (groktypename ($3.t), $1); }
549 { $$ = build_tree_list (NULL_TREE, $1.t); }
550 | parm '=' expr_no_commas %prec ARITHCOMPARE
551 { $$ = build_tree_list ($3, $1.t); }
552 | template_template_parm
553 { $$ = build_tree_list (NULL_TREE, $1); }
554 | template_template_parm '=' template_arg
556 if (TREE_CODE ($3) != TEMPLATE_DECL
557 && TREE_CODE ($3) != TEMPLATE_TEMPLATE_PARM
558 && TREE_CODE ($3) != TYPE_DECL)
560 error ("invalid default template argument");
561 $3 = error_mark_node;
563 $$ = build_tree_list ($3, $1);
568 template_header template_extdef
569 { finish_template_decl ($1); }
570 | template_header error %prec EMPTY
571 { finish_template_decl ($1); }
575 fndef eat_saved_input
576 { if (pending_inlines) do_pending_inlines (); }
578 { if (pending_inlines) do_pending_inlines (); }
580 { if (pending_inlines) do_pending_inlines (); }
581 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
582 { if (pending_inlines) do_pending_inlines ();
583 pop_lang_context (); }
584 | extern_lang_string .hush_warning template_datadef .warning_ok
585 { if (pending_inlines) do_pending_inlines ();
586 pop_lang_context (); }
587 | extension template_extdef
588 { pedantic = $<itype>1; }
593 | declmods notype_initdecls ';'
595 | typed_declspecs initdecls ';'
596 { note_list_got_semicolon ($1.t); }
598 { maybe_process_partial_specialization ($1.t);
599 note_got_semicolon ($1.t); }
604 | declmods notype_initdecls ';'
606 | typed_declspecs initdecls ';'
607 { note_list_got_semicolon ($1.t); }
609 { pedwarn ("empty declaration"); }
610 | explicit_instantiation ';'
611 | typed_declspecs ';'
614 split_specs_attrs ($1.t, &t, &attrs);
616 note_list_got_semicolon ($1.t);
623 ctor_initializer_opt:
642 fn.def1 maybe_return_init ctor_initializer_opt compstmt_or_error
643 { finish_function (lineno, (int)$3, 0); }
644 | fn.def1 maybe_return_init function_try_block
646 int nested = (hack_decl_function_context
647 (current_function_decl) != NULL_TREE);
648 finish_function (lineno, (int)$3, nested);
650 | fn.def1 maybe_return_init error
654 constructor_declarator:
655 nested_name_specifier SELFNAME '('
656 { $$ = begin_constructor_declarator ($1, $2); }
657 parmlist ')' cv_qualifiers exception_specification_opt
658 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
659 | nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
660 { $$ = begin_constructor_declarator ($1, $2);
661 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
663 | global_scope nested_name_specifier SELFNAME '('
664 { $$ = begin_constructor_declarator ($2, $3); }
665 parmlist ')' cv_qualifiers exception_specification_opt
666 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
667 | global_scope nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
668 { $$ = begin_constructor_declarator ($2, $3);
669 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
671 | nested_name_specifier self_template_type '('
672 { $$ = begin_constructor_declarator ($1, $2); }
673 parmlist ')' cv_qualifiers exception_specification_opt
674 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
675 | nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
676 { $$ = begin_constructor_declarator ($1, $2);
677 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
679 | global_scope nested_name_specifier self_template_type '('
680 { $$ = begin_constructor_declarator ($2, $3); }
681 parmlist ')' cv_qualifiers exception_specification_opt
682 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
683 | global_scope nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
684 { $$ = begin_constructor_declarator ($2, $3);
685 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
690 typed_declspecs declarator
691 { if (!begin_function_definition ($1.t, $2))
693 | declmods notype_declarator
694 { if (!begin_function_definition ($1, $2))
697 { if (!begin_function_definition (NULL_TREE, $1))
699 | declmods constructor_declarator
700 { if (!begin_function_definition ($1, $2))
702 | constructor_declarator
703 { if (!begin_function_definition (NULL_TREE, $1))
707 component_constructor_declarator:
708 SELFNAME '(' parmlist ')' cv_qualifiers exception_specification_opt
709 { $$ = make_call_declarator ($1, $3, $5, $6); }
710 | SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
711 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
712 | self_template_type '(' parmlist ')' cv_qualifiers exception_specification_opt
713 { $$ = make_call_declarator ($1, $3, $5, $6); }
714 | self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
715 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
718 /* more C++ complexity. See component_decl for a comment on the
719 reduce/reduce conflict introduced by these rules. */
721 declmods component_constructor_declarator
723 split_specs_attrs ($1, &specs, &attrs);
724 attrs = build_tree_list (attrs, NULL_TREE);
725 $$ = start_method (specs, $2, attrs);
729 if (yychar == YYEMPTY)
731 reinit_parse_for_method (yychar, $$); }
732 | component_constructor_declarator
733 { $$ = start_method (NULL_TREE, $1, NULL_TREE);
735 | typed_declspecs declarator
737 split_specs_attrs ($1.t, &specs, &attrs);
738 attrs = build_tree_list (attrs, NULL_TREE);
739 $$ = start_method (specs, $2, attrs); goto rest_of_mdef; }
740 | declmods notype_declarator
742 split_specs_attrs ($1, &specs, &attrs);
743 attrs = build_tree_list (attrs, NULL_TREE);
744 $$ = start_method (specs, $2, attrs); goto rest_of_mdef; }
746 { $$ = start_method (NULL_TREE, $$, NULL_TREE);
748 | declmods constructor_declarator
750 split_specs_attrs ($1, &specs, &attrs);
751 attrs = build_tree_list (attrs, NULL_TREE);
752 $$ = start_method (specs, $2, attrs); goto rest_of_mdef; }
753 | constructor_declarator
754 { $$ = start_method (NULL_TREE, $$, NULL_TREE);
759 RETURN_KEYWORD IDENTIFIER
761 if (! current_function_parms_stored)
769 { store_return_init ($<ttype>$, $2); }
770 | return_id '(' nonnull_exprlist ')'
771 { store_return_init ($<ttype>$, $3); }
772 | return_id LEFT_RIGHT
773 { store_return_init ($<ttype>$, NULL_TREE); }
777 ':' .set_base_init member_init_list
780 error ("no base initializers given following ':'");
782 /* Always keep the BLOCK node associated with the outermost
783 pair of curley braces of a function. These are needed
784 for correct operation of dwarfout.c. */
792 if (! current_function_parms_stored)
795 if (DECL_CONSTRUCTOR_P (current_function_decl))
797 /* Make a contour for the initializer list. */
800 expand_start_bindings (0);
802 else if (current_class_type == NULL_TREE)
803 error ("base initializers not allowed for non-member functions");
804 else if (! DECL_CONSTRUCTOR_P (current_function_decl))
805 error ("only constructors take base initializers");
814 | member_init_list ',' member_init
815 | member_init_list error
819 '(' nonnull_exprlist ')'
821 if (current_class_name)
822 pedwarn ("anachronistic old style base class initializer");
823 expand_member_init (current_class_ref, NULL_TREE, $2);
827 if (current_class_name)
828 pedwarn ("anachronistic old style base class initializer");
829 expand_member_init (current_class_ref, NULL_TREE, void_type_node);
831 | notype_identifier '(' nonnull_exprlist ')'
832 { expand_member_init (current_class_ref, $1, $3); }
833 | notype_identifier LEFT_RIGHT
834 { expand_member_init (current_class_ref, $1, void_type_node); }
835 | nonnested_type '(' nonnull_exprlist ')'
836 { expand_member_init (current_class_ref, $1, $3); }
837 | nonnested_type LEFT_RIGHT
838 { expand_member_init (current_class_ref, $1, void_type_node); }
839 | typename_sub '(' nonnull_exprlist ')'
840 { expand_member_init (current_class_ref, TYPE_MAIN_DECL ($1),
842 | typename_sub LEFT_RIGHT
843 { expand_member_init (current_class_ref, TYPE_MAIN_DECL ($1),
867 explicit_instantiation:
868 TEMPLATE begin_explicit_instantiation typespec ';'
869 { do_type_instantiation ($3.t, NULL_TREE);
871 end_explicit_instantiation
872 | TEMPLATE begin_explicit_instantiation typed_declspecs declarator
873 { tree specs = strip_attrs ($3.t);
874 do_decl_instantiation (specs, $4, NULL_TREE); }
875 end_explicit_instantiation
876 | TEMPLATE begin_explicit_instantiation notype_declarator
877 { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
878 end_explicit_instantiation
879 | TEMPLATE begin_explicit_instantiation constructor_declarator
880 { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
881 end_explicit_instantiation
882 | SCSPEC TEMPLATE begin_explicit_instantiation typespec ';'
883 { do_type_instantiation ($4.t, $1);
885 end_explicit_instantiation
886 | SCSPEC TEMPLATE begin_explicit_instantiation typed_declspecs
888 { tree specs = strip_attrs ($4.t);
889 do_decl_instantiation (specs, $5, $1); }
890 end_explicit_instantiation
891 | SCSPEC TEMPLATE begin_explicit_instantiation notype_declarator
892 { do_decl_instantiation (NULL_TREE, $4, $1); }
893 end_explicit_instantiation
894 | SCSPEC TEMPLATE begin_explicit_instantiation constructor_declarator
895 { do_decl_instantiation (NULL_TREE, $4, $1); }
896 end_explicit_instantiation
899 begin_explicit_instantiation:
900 { begin_explicit_instantiation(); }
902 end_explicit_instantiation:
903 { end_explicit_instantiation(); }
905 /* The TYPENAME expansions are to deal with use of a template class name as
906 a template within the class itself, where the template decl is hidden by
907 a type decl. Got all that? */
910 PTYPENAME '<' template_arg_list_opt template_close_bracket
911 .finish_template_type
913 | TYPENAME '<' template_arg_list_opt template_close_bracket
914 .finish_template_type
919 apparent_template_type:
921 | identifier '<' template_arg_list_opt '>'
922 .finish_template_type
926 SELFNAME '<' template_arg_list_opt template_close_bracket
927 .finish_template_type
931 .finish_template_type:
933 if (yychar == YYEMPTY)
936 $$ = finish_template_type ($<ttype>-3, $<ttype>-1,
940 template_close_bracket:
944 /* Handle `Class<Class<Type>>' without space in the `>>' */
945 pedwarn ("`>>' should be `> >' in template class name");
950 template_arg_list_opt:
958 { $$ = build_tree_list (NULL_TREE, $$); }
959 | template_arg_list ',' template_arg
960 { $$ = chainon ($$, build_tree_list (NULL_TREE, $3)); }
965 { $$ = groktypename ($1.t); }
968 | expr_no_commas %prec ARITHCOMPARE
973 { $$ = NEGATE_EXPR; }
975 { $$ = CONVERT_EXPR; }
977 { $$ = PREINCREMENT_EXPR; }
979 { $$ = PREDECREMENT_EXPR; }
981 { $$ = TRUTH_NOT_EXPR; }
986 { $$ = build_x_compound_expr ($$); }
992 { error ("ANSI C++ forbids an empty condition for `%s'",
994 $$ = integer_zero_node; }
1001 { error ("ANSI C++ forbids an empty condition for `%s'",
1003 $$ = integer_zero_node; }
1017 type_specifier_seq declarator maybeasm maybe_attribute '='
1020 for (d = getdecls (); d; d = TREE_CHAIN (d))
1021 if (TREE_CODE (d) == TYPE_DECL) {
1022 tree s = TREE_TYPE (d);
1023 if (TREE_CODE (s) == RECORD_TYPE)
1024 cp_error ("definition of class `%T' in condition", s);
1025 else if (TREE_CODE (s) == ENUMERAL_TYPE)
1026 cp_error ("definition of enum `%T' in condition", s);
1029 current_declspecs = $1.t;
1030 $<itype>5 = suspend_momentary ();
1031 $<ttype>$ = start_decl ($<ttype>2, current_declspecs, 1,
1032 $4, /*prefix_attributes*/ NULL_TREE);
1036 cp_finish_decl ($<ttype>6, $7, $4, 1, LOOKUP_ONLYCONVERTING);
1037 resume_momentary ($<itype>5);
1038 $$ = convert_from_reference ($<ttype>6);
1039 if (TREE_CODE (TREE_TYPE ($$)) == ARRAY_TYPE)
1040 cp_error ("definition of array `%#D' in condition", $$);
1047 | maybe_label_decls stmts '}'
1048 | maybe_label_decls stmts error '}'
1049 | maybe_label_decls error '}'
1052 already_scoped_stmt:
1054 { $<ttype>$ = begin_compound_stmt (1); }
1056 { finish_compound_stmt (1, $<ttype>2); }
1061 nontrivial_exprlist:
1062 expr_no_commas ',' expr_no_commas
1063 { $$ = expr_tree_cons (NULL_TREE, $$,
1064 build_expr_list (NULL_TREE, $3)); }
1065 | expr_no_commas ',' error
1066 { $$ = expr_tree_cons (NULL_TREE, $$,
1067 build_expr_list (NULL_TREE, error_mark_node)); }
1068 | nontrivial_exprlist ',' expr_no_commas
1069 { chainon ($$, build_expr_list (NULL_TREE, $3)); }
1070 | nontrivial_exprlist ',' error
1071 { chainon ($$, build_expr_list (NULL_TREE, error_mark_node)); }
1076 { $$ = build_expr_list (NULL_TREE, $$); }
1077 | nontrivial_exprlist
1083 /* __extension__ turns off -pedantic for following primary. */
1084 | extension cast_expr %prec UNARY
1086 pedantic = $<itype>1; }
1087 | '*' cast_expr %prec UNARY
1088 { $$ = build_x_indirect_ref ($2, "unary *"); }
1089 | '&' cast_expr %prec UNARY
1090 { $$ = build_x_unary_op (ADDR_EXPR, $2); }
1092 { $$ = build_x_unary_op (BIT_NOT_EXPR, $2); }
1093 | unop cast_expr %prec UNARY
1094 { $$ = finish_unary_op_expr ($1, $2); }
1095 /* Refer to the address of a label as a pointer. */
1098 pedwarn ("ANSI C++ forbids `&&'");
1099 $$ = finish_label_address_expr ($2); }
1100 | SIZEOF unary_expr %prec UNARY
1101 { $$ = expr_sizeof ($2); }
1102 | SIZEOF '(' type_id ')' %prec HYPERUNARY
1103 { $$ = c_sizeof (groktypename ($3.t));
1104 check_for_new_type ("sizeof", $3); }
1105 | ALIGNOF unary_expr %prec UNARY
1106 { $$ = grok_alignof ($2); }
1107 | ALIGNOF '(' type_id ')' %prec HYPERUNARY
1108 { $$ = c_alignof (groktypename ($3.t));
1109 check_for_new_type ("alignof", $3); }
1111 /* The %prec EMPTY's here are required by the = init initializer
1112 syntax extension; see below. */
1113 | new new_type_id %prec EMPTY
1114 { $$ = build_new (NULL_TREE, $2.t, NULL_TREE, $1);
1115 check_for_new_type ("new", $2); }
1116 | new new_type_id new_initializer
1117 { $$ = build_new (NULL_TREE, $2.t, $3, $1);
1118 check_for_new_type ("new", $2); }
1119 | new new_placement new_type_id %prec EMPTY
1120 { $$ = build_new ($2, $3.t, NULL_TREE, $1);
1121 check_for_new_type ("new", $3); }
1122 | new new_placement new_type_id new_initializer
1123 { $$ = build_new ($2, $3.t, $4, $1);
1124 check_for_new_type ("new", $3); }
1125 /* The .begin_new_placement in the following rules is
1126 necessary to avoid shift/reduce conflicts that lead to
1127 mis-parsing some expressions. Of course, these constructs
1128 are not really new-placement and it is bogus to call
1129 begin_new_placement. But, the parser cannot always tell at this
1130 point whether the next thing is an expression or a type-id,
1131 so there is nothing we can do. Fortunately,
1132 begin_new_placement does nothing harmful. When we rewrite
1133 the parser, this lossage should be removed, of course. */
1134 | new '(' .begin_new_placement type_id .finish_new_placement
1136 { $$ = build_new (NULL_TREE, groktypename($4.t),
1138 check_for_new_type ("new", $4); }
1139 | new '(' .begin_new_placement type_id .finish_new_placement
1141 { $$ = build_new (NULL_TREE, groktypename($4.t), $6, $1);
1142 check_for_new_type ("new", $4); }
1143 | new new_placement '(' .begin_new_placement type_id
1144 .finish_new_placement %prec EMPTY
1145 { $$ = build_new ($2, groktypename($5.t), NULL_TREE, $1);
1146 check_for_new_type ("new", $5); }
1147 | new new_placement '(' .begin_new_placement type_id
1148 .finish_new_placement new_initializer
1149 { $$ = build_new ($2, groktypename($5.t), $7, $1);
1150 check_for_new_type ("new", $5); }
1152 | delete cast_expr %prec UNARY
1153 { $$ = delete_sanity ($2, NULL_TREE, 0, $1); }
1154 | delete '[' ']' cast_expr %prec UNARY
1155 { $$ = delete_sanity ($4, NULL_TREE, 1, $1);
1156 if (yychar == YYEMPTY)
1158 | delete '[' expr ']' cast_expr %prec UNARY
1159 { $$ = delete_sanity ($5, $3, 2, $1);
1160 if (yychar == YYEMPTY)
1162 | REALPART cast_expr %prec UNARY
1163 { $$ = build_x_unary_op (REALPART_EXPR, $2); }
1164 | IMAGPART cast_expr %prec UNARY
1165 { $$ = build_x_unary_op (IMAGPART_EXPR, $2); }
1168 /* Note this rule is not suitable for use in new_placement
1169 since it uses NULL_TREE as the argument to
1170 finish_new_placement. This rule serves only to avoid
1171 reduce/reduce conflicts in unary_expr. See the comments
1172 there on the use of begin/finish_new_placement. */
1173 .finish_new_placement:
1175 { finish_new_placement (NULL_TREE, $<itype>-1); }
1177 .begin_new_placement:
1178 { $$ = begin_new_placement (); }
1181 '(' .begin_new_placement nonnull_exprlist ')'
1182 { $$ = finish_new_placement ($3, $2); }
1183 | '{' .begin_new_placement nonnull_exprlist '}'
1184 { cp_pedwarn ("old style placement syntax, use () instead");
1185 $$ = finish_new_placement ($3, $2); }
1189 '(' nonnull_exprlist ')'
1195 cp_error ("`%T' is not a valid expression", $2.t);
1196 $$ = error_mark_node;
1198 /* GNU extension so people can use initializer lists. Note that
1199 this alters the meaning of `new int = 1', which was previously
1200 syntactically valid but semantically invalid. */
1204 pedwarn ("ANSI C++ forbids initialization of new expression with `='");
1205 if (TREE_CODE ($2) != TREE_LIST
1206 && TREE_CODE ($2) != CONSTRUCTOR)
1207 $$ = build_expr_list (NULL_TREE, $2);
1213 /* This is necessary to postpone reduction of `int ((int)(int)(int))'. */
1215 '(' type_id ')' %prec EMPTY
1216 { $2.t = finish_parmlist (build_tree_list (NULL_TREE, $2.t), 0);
1217 $$ = make_call_declarator (NULL_TREE, $2.t, NULL_TREE, NULL_TREE);
1218 check_for_new_type ("cast", $2); }
1219 | regcast_or_absdcl '(' type_id ')' %prec EMPTY
1220 { $3.t = finish_parmlist (build_tree_list (NULL_TREE, $3.t), 0);
1221 $$ = make_call_declarator ($$, $3.t, NULL_TREE, NULL_TREE);
1222 check_for_new_type ("cast", $3); }
1227 | regcast_or_absdcl unary_expr %prec UNARY
1228 { $$ = reparse_absdcl_as_casts ($$, $2); }
1229 | regcast_or_absdcl '{' initlist maybecomma '}' %prec UNARY
1231 tree init = build_nt (CONSTRUCTOR, NULL_TREE,
1234 pedwarn ("ANSI C++ forbids constructor-expressions");
1235 /* Indicate that this was a GNU C constructor expression. */
1236 TREE_HAS_CONSTRUCTOR (init) = 1;
1238 $$ = reparse_absdcl_as_casts ($$, init);
1244 /* Handle general members. */
1245 | expr_no_commas POINTSAT_STAR expr_no_commas
1246 { $$ = build_x_binary_op (MEMBER_REF, $$, $3); }
1247 | expr_no_commas DOT_STAR expr_no_commas
1248 { $$ = build_m_component_ref ($$, $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 '/' expr_no_commas
1256 { $$ = build_x_binary_op ($2, $$, $3); }
1257 | expr_no_commas '%' expr_no_commas
1258 { $$ = build_x_binary_op ($2, $$, $3); }
1259 | expr_no_commas LSHIFT expr_no_commas
1260 { $$ = build_x_binary_op ($2, $$, $3); }
1261 | expr_no_commas RSHIFT expr_no_commas
1262 { $$ = build_x_binary_op ($2, $$, $3); }
1263 | expr_no_commas ARITHCOMPARE expr_no_commas
1264 { $$ = build_x_binary_op ($2, $$, $3); }
1265 | expr_no_commas '<' expr_no_commas
1266 { $$ = build_x_binary_op (LT_EXPR, $$, $3); }
1267 | expr_no_commas '>' expr_no_commas
1268 { $$ = build_x_binary_op (GT_EXPR, $$, $3); }
1269 | expr_no_commas EQCOMPARE expr_no_commas
1270 { $$ = build_x_binary_op ($2, $$, $3); }
1271 | expr_no_commas MIN_MAX 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 '|' expr_no_commas
1276 { $$ = build_x_binary_op ($2, $$, $3); }
1277 | expr_no_commas '^' expr_no_commas
1278 { $$ = build_x_binary_op ($2, $$, $3); }
1279 | expr_no_commas ANDAND expr_no_commas
1280 { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $$, $3); }
1281 | expr_no_commas OROR expr_no_commas
1282 { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $$, $3); }
1283 | expr_no_commas '?' xexpr ':' expr_no_commas
1284 { $$ = build_x_conditional_expr ($$, $3, $5); }
1285 | expr_no_commas '=' expr_no_commas
1286 { $$ = build_x_modify_expr ($$, NOP_EXPR, $3);
1287 if ($$ != error_mark_node)
1288 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
1289 | expr_no_commas ASSIGN expr_no_commas
1290 { $$ = build_x_modify_expr ($$, $2, $3); }
1292 { $$ = build_throw (NULL_TREE); }
1293 | THROW expr_no_commas
1294 { $$ = build_throw ($2); }
1295 /* These extensions are not defined. The second arg to build_m_component_ref
1296 is old, build_m_component_ref now does an implicit
1297 build_indirect_ref (x, NULL_PTR) on the second argument.
1298 | object '&' expr_no_commas %prec UNARY
1299 { $$ = build_m_component_ref ($$, build_x_unary_op (ADDR_EXPR, $3)); }
1300 | object unop expr_no_commas %prec UNARY
1301 { $$ = build_m_component_ref ($$, build_x_unary_op ($2, $3)); }
1302 | object '(' type_id ')' expr_no_commas %prec UNARY
1303 { tree type = groktypename ($3.t);
1304 $$ = build_m_component_ref ($$, build_c_cast (type, $5)); }
1305 | object primary_no_id %prec UNARY
1306 { $$ = build_m_component_ref ($$, $2); }
1310 notype_unqualified_id:
1311 '~' see_typename identifier
1312 { $$ = build_parse_node (BIT_NOT_EXPR, $3); }
1313 | '~' see_typename template_type
1314 { $$ = build_parse_node (BIT_NOT_EXPR, $3); }
1319 | NSNAME %prec EMPTY
1324 /* If lastiddecl is a TREE_LIST, it's a baselink, which
1325 means that we're in an expression like S::f<int>, so
1326 don't do_identifier; we only do that for unqualified
1328 if (lastiddecl && TREE_CODE (lastiddecl) != TREE_LIST)
1329 $$ = do_identifier ($<ttype>-1, 1, NULL_TREE);
1335 PFUNCNAME '<' do_id template_arg_list_opt template_close_bracket
1336 { $$ = lookup_template_function ($3, $4); }
1337 | operator_name '<' do_id template_arg_list_opt template_close_bracket
1338 { $$ = lookup_template_function ($3, $4); }
1342 TEMPLATE identifier '<' template_arg_list_opt template_close_bracket
1343 { $$ = lookup_template_function ($2, $4); }
1344 | TEMPLATE PFUNCNAME '<' template_arg_list_opt template_close_bracket
1345 { $$ = lookup_template_function ($2, $4); }
1346 | TEMPLATE operator_name '<' template_arg_list_opt
1347 template_close_bracket
1348 { $$ = lookup_template_function ($2, $4); }
1352 notype_unqualified_id
1357 expr_or_declarator_intern:
1359 | attributes expr_or_declarator
1361 /* Provide support for '(' attributes '*' declarator ')'
1363 $$ = decl_tree_cons ($1, $2, NULL_TREE);
1368 notype_unqualified_id
1369 | '*' expr_or_declarator_intern %prec UNARY
1370 { $$ = build_parse_node (INDIRECT_REF, $2); }
1371 | '&' expr_or_declarator_intern %prec UNARY
1372 { $$ = build_parse_node (ADDR_EXPR, $2); }
1373 | '(' expr_or_declarator_intern ')'
1377 notype_template_declarator:
1378 IDENTIFIER '<' template_arg_list_opt template_close_bracket
1379 { $$ = lookup_template_function ($1, $3); }
1380 | NSNAME '<' template_arg_list template_close_bracket
1381 { $$ = lookup_template_function ($1, $3); }
1384 direct_notype_declarator:
1385 complex_direct_notype_declarator
1386 /* This precedence declaration is to prefer this reduce
1387 to the Koenig lookup shift in primary, below. I hate yacc. */
1388 | notype_unqualified_id %prec '('
1389 | notype_template_declarator
1390 | '(' expr_or_declarator_intern ')'
1391 { $$ = finish_decl_parsing ($2); }
1395 notype_unqualified_id
1397 if (TREE_CODE ($1) == BIT_NOT_EXPR)
1398 $$ = build_x_unary_op (BIT_NOT_EXPR, TREE_OPERAND ($1, 0));
1400 $$ = finish_id_expr ($1);
1406 if (processing_template_decl)
1407 push_obstacks (&permanent_obstack, &permanent_obstack);
1408 $$ = combine_strings ($$);
1409 /* combine_strings doesn't set up TYPE_MAIN_VARIANT of
1410 a const array the way we want, so fix it. */
1411 if (flag_const_strings)
1412 TREE_TYPE ($$) = build_cplus_array_type
1413 (TREE_TYPE (TREE_TYPE ($$)),
1414 TYPE_DOMAIN (TREE_TYPE ($$)));
1415 if (processing_template_decl)
1419 { $$ = finish_parenthesized_expr ($2); }
1420 | '(' expr_or_declarator_intern ')'
1421 { $2 = reparse_decl_as_expr (NULL_TREE, $2);
1422 $$ = finish_parenthesized_expr ($2); }
1424 { $$ = error_mark_node; }
1426 { tree scope = current_scope ();
1427 if (!scope || TREE_CODE (scope) != FUNCTION_DECL)
1429 error ("braced-group within expression allowed only inside a function");
1433 pedwarn ("ANSI C++ forbids braced-groups within expressions");
1434 $<ttype>$ = begin_stmt_expr ();
1437 { $$ = finish_stmt_expr ($<ttype>2, $3); }
1438 /* Koenig lookup support
1439 We could store lastiddecl in $1 to avoid another lookup,
1440 but that would result in many additional reduce/reduce conflicts. */
1441 | notype_unqualified_id '(' nonnull_exprlist ')'
1442 { $$ = finish_call_expr ($1, $3, 1); }
1443 | notype_unqualified_id LEFT_RIGHT
1444 { $$ = finish_call_expr ($1, NULL_TREE, 1); }
1445 | primary '(' nonnull_exprlist ')'
1446 { $$ = finish_call_expr ($1, $3, 0); }
1447 | primary LEFT_RIGHT
1448 { $$ = finish_call_expr ($1, NULL_TREE, 0); }
1449 | primary '[' expr ']'
1450 { $$ = grok_array_decl ($$, $3); }
1452 { $$ = finish_increment_expr ($1, POSTINCREMENT_EXPR); }
1453 | primary MINUSMINUS
1454 { $$ = finish_increment_expr ($1, POSTDECREMENT_EXPR); }
1455 /* C++ extensions */
1457 { $$ = finish_this_expr (); }
1458 | CV_QUALIFIER '(' nonnull_exprlist ')'
1460 /* This is a C cast in C++'s `functional' notation
1461 using the "implicit int" extension so that:
1462 `const (3)' is equivalent to `const int (3)'. */
1465 if ($3 == error_mark_node)
1467 $$ = error_mark_node;
1471 type = cp_build_qualified_type (integer_type_node,
1472 cp_type_qual_from_rid ($1));
1473 $$ = build_c_cast (type, build_compound_expr ($3));
1476 | DYNAMIC_CAST '<' type_id '>' '(' expr ')'
1477 { tree type = groktypename ($3.t);
1478 check_for_new_type ("dynamic_cast", $3);
1479 $$ = build_dynamic_cast (type, $6); }
1480 | STATIC_CAST '<' type_id '>' '(' expr ')'
1481 { tree type = groktypename ($3.t);
1482 check_for_new_type ("static_cast", $3);
1483 $$ = build_static_cast (type, $6); }
1484 | REINTERPRET_CAST '<' type_id '>' '(' expr ')'
1485 { tree type = groktypename ($3.t);
1486 check_for_new_type ("reinterpret_cast", $3);
1487 $$ = build_reinterpret_cast (type, $6); }
1488 | CONST_CAST '<' type_id '>' '(' expr ')'
1489 { tree type = groktypename ($3.t);
1490 check_for_new_type ("const_cast", $3);
1491 $$ = build_const_cast (type, $6); }
1492 | TYPEID '(' expr ')'
1493 { $$ = build_x_typeid ($3); }
1494 | TYPEID '(' type_id ')'
1495 { tree type = groktypename ($3.t);
1496 check_for_new_type ("typeid", $3);
1497 $$ = get_typeid (TYPE_MAIN_VARIANT (type)); }
1498 | global_scope IDENTIFIER
1499 { $$ = do_scoped_id ($2, 1); }
1500 | global_scope template_id
1502 | global_scope operator_name
1504 got_scope = NULL_TREE;
1505 if (TREE_CODE ($2) == IDENTIFIER_NODE)
1506 $$ = do_scoped_id ($2, 1);
1510 | overqualified_id %prec HYPERUNARY
1511 { $$ = build_offset_ref (OP0 ($$), OP1 ($$)); }
1512 | overqualified_id '(' nonnull_exprlist ')'
1513 { $$ = finish_qualified_call_expr ($1, $3); }
1514 | overqualified_id LEFT_RIGHT
1515 { $$ = finish_qualified_call_expr ($1, NULL_TREE); }
1516 | object object_template_id %prec UNARY
1518 $$ = build_x_component_ref ($$, $2, NULL_TREE, 1);
1520 | object object_template_id '(' nonnull_exprlist ')'
1521 { $$ = finish_object_call_expr ($2, $1, $4); }
1522 | object object_template_id LEFT_RIGHT
1523 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1524 | object unqualified_id %prec UNARY
1525 { $$ = build_x_component_ref ($$, $2, NULL_TREE, 1); }
1526 | object overqualified_id %prec UNARY
1527 { if (processing_template_decl)
1528 $$ = build_min_nt (COMPONENT_REF, $1, copy_to_permanent ($2));
1530 $$ = build_object_ref ($$, OP0 ($2), OP1 ($2)); }
1531 | object unqualified_id '(' nonnull_exprlist ')'
1532 { $$ = finish_object_call_expr ($2, $1, $4); }
1533 | object unqualified_id LEFT_RIGHT
1534 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1535 | object overqualified_id '(' nonnull_exprlist ')'
1536 { $$ = finish_qualified_object_call_expr ($2, $1, $4); }
1537 | object overqualified_id LEFT_RIGHT
1538 { $$ = finish_qualified_object_call_expr ($2, $1, NULL_TREE); }
1539 /* p->int::~int() is valid -- 12.4 */
1540 | object '~' TYPESPEC LEFT_RIGHT
1541 { $$ = finish_pseudo_destructor_call_expr ($1, NULL_TREE, $3); }
1542 | object TYPESPEC SCOPE '~' TYPESPEC LEFT_RIGHT
1543 { $$ = finish_pseudo_destructor_call_expr ($1, $2, $5); }
1546 $$ = error_mark_node;
1550 /* Not needed for now.
1556 { $$ = error_mark_node; }
1558 { if (current_function_decl == 0)
1560 error ("braced-group within expression allowed only inside a function");
1563 $<ttype>$ = expand_start_stmt_expr (); }
1566 pedwarn ("ANSI C++ forbids braced-groups within expressions");
1567 $$ = expand_end_stmt_expr ($<ttype>2); }
1568 | primary_no_id '(' nonnull_exprlist ')'
1569 { $$ = build_x_function_call ($$, $3, current_class_ref); }
1570 | primary_no_id LEFT_RIGHT
1571 { $$ = build_x_function_call ($$, NULL_TREE, current_class_ref); }
1572 | primary_no_id '[' expr ']'
1574 | primary_no_id PLUSPLUS
1575 { $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); }
1576 | primary_no_id MINUSMINUS
1577 { $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); }
1579 { goto do_scoped_id; }
1580 | SCOPE operator_name
1581 { if (TREE_CODE ($2) == IDENTIFIER_NODE)
1583 goto do_scoped_operator;
1592 { got_scope = NULL_TREE; $$ = 1; }
1598 | global_scope delete
1599 { got_scope = NULL_TREE; $$ = 1; }
1604 { $$ = boolean_true_node; }
1606 { $$ = boolean_false_node; }
1609 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
1613 { $$ = chainon ($$, $2); }
1619 if (! current_function_parms_stored)
1620 store_parm_decls ();
1622 /* Always keep the BLOCK node associated with the outermost
1623 pair of curley braces of a function. These are needed
1624 for correct operation of dwarfout.c. */
1631 { got_object = TREE_TYPE ($$); }
1634 $$ = build_x_arrow ($$);
1635 got_object = TREE_TYPE ($$);
1640 typespec initdecls ';'
1642 resume_momentary ($2);
1643 if ($1.t && IS_AGGR_TYPE_CODE (TREE_CODE ($1.t)))
1644 note_got_semicolon ($1.t);
1646 | typed_declspecs initdecls ';'
1648 resume_momentary ($2);
1649 note_list_got_semicolon ($1.t);
1651 | declmods notype_initdecls ';'
1652 { resume_momentary ($2); }
1653 | typed_declspecs ';'
1656 note_list_got_semicolon ($1.t);
1659 { warning ("empty declaration"); }
1661 { pedantic = $<itype>1; }
1664 /* Any kind of declarator (thus, all declarators allowed
1665 after an explicit typespec). */
1668 after_type_declarator %prec EMPTY
1669 | notype_declarator %prec EMPTY
1672 /* This is necessary to postpone reduction of `int()()()()'. */
1674 LEFT_RIGHT %prec EMPTY
1675 { $$ = make_call_declarator (NULL_TREE, empty_parms (),
1676 NULL_TREE, NULL_TREE); }
1677 | fcast_or_absdcl LEFT_RIGHT %prec EMPTY
1678 { $$ = make_call_declarator ($$, empty_parms (), NULL_TREE,
1682 /* ANSI type-id (8.1) */
1684 typed_typespecs absdcl
1685 { $$.t = build_decl_list ($1.t, $2);
1686 $$.new_type_flag = $1.new_type_flag; }
1687 | nonempty_cv_qualifiers absdcl
1688 { $$.t = build_decl_list ($1.t, $2);
1689 $$.new_type_flag = $1.new_type_flag; }
1691 { $$.t = build_decl_list (build_decl_list (NULL_TREE, $1.t),
1693 $$.new_type_flag = $1.new_type_flag; }
1694 | typed_typespecs %prec EMPTY
1695 { $$.t = build_decl_list ($1.t, NULL_TREE);
1696 $$.new_type_flag = $1.new_type_flag; }
1697 | nonempty_cv_qualifiers %prec EMPTY
1698 { $$.t = build_decl_list ($1.t, NULL_TREE);
1699 $$.new_type_flag = $1.new_type_flag; }
1702 /* Declspecs which contain at least one type specifier or typedef name.
1703 (Just `const' or `volatile' is not enough.)
1704 A typedef'd name following these is taken as a name to be declared.
1705 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1708 typed_typespecs %prec EMPTY
1714 { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1);
1715 $$.new_type_flag = $2.new_type_flag; }
1716 | typespec reserved_declspecs %prec HYPERUNARY
1717 { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2);
1718 $$.new_type_flag = $1.new_type_flag; }
1719 | typespec reserved_typespecquals reserved_declspecs
1720 { $$.t = decl_tree_cons (NULL_TREE, $1.t, chainon ($2, $3));
1721 $$.new_type_flag = $1.new_type_flag; }
1722 | declmods typespec reserved_declspecs
1723 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1));
1724 $$.new_type_flag = $2.new_type_flag; }
1725 | declmods typespec reserved_typespecquals
1726 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1));
1727 $$.new_type_flag = $2.new_type_flag; }
1728 | declmods typespec reserved_typespecquals reserved_declspecs
1729 { $$.t = decl_tree_cons (NULL_TREE, $2.t,
1730 chainon ($3, chainon ($4, $1)));
1731 $$.new_type_flag = $2.new_type_flag; }
1736 { if (extra_warnings)
1737 warning ("`%s' is not at beginning of declaration",
1738 IDENTIFIER_POINTER ($$));
1739 $$ = build_decl_list (NULL_TREE, $$); }
1740 | reserved_declspecs typespecqual_reserved
1741 { $$ = decl_tree_cons (NULL_TREE, $2.t, $$); }
1742 | reserved_declspecs SCSPEC
1743 { if (extra_warnings)
1744 warning ("`%s' is not at beginning of declaration",
1745 IDENTIFIER_POINTER ($2));
1746 $$ = decl_tree_cons (NULL_TREE, $2, $$); }
1747 | reserved_declspecs attributes
1748 { $$ = decl_tree_cons ($2, NULL_TREE, $1); }
1750 { $$ = decl_tree_cons ($1, NULL_TREE, NULL_TREE); }
1753 /* List of just storage classes and type modifiers.
1754 A declaration can start with just this, but then it cannot be used
1755 to redeclare a typedef-name.
1756 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1758 /* We use hash_tree_cons for lists of typeless declspecs so that they end
1759 up on a persistent obstack. Otherwise, they could appear at the
1760 beginning of something like
1762 static const struct { int foo () { } } b;
1764 and would be discarded after we finish compiling foo. We don't need to
1765 worry once we see a type. */
1768 nonempty_cv_qualifiers %prec EMPTY
1769 { $$ = $1.t; TREE_STATIC ($$) = 1; }
1771 { $$ = hash_tree_cons (NULL_TREE, $$, NULL_TREE); }
1772 | declmods CV_QUALIFIER
1773 { $$ = hash_tree_cons (NULL_TREE, $2, $$);
1774 TREE_STATIC ($$) = 1; }
1776 { if (extra_warnings && TREE_STATIC ($$))
1777 warning ("`%s' is not at beginning of declaration",
1778 IDENTIFIER_POINTER ($2));
1779 $$ = hash_tree_cons (NULL_TREE, $2, $$);
1780 TREE_STATIC ($$) = TREE_STATIC ($1); }
1781 | declmods attributes
1782 { $$ = hash_tree_cons ($2, NULL_TREE, $1); }
1783 | attributes %prec EMPTY
1784 { $$ = hash_tree_cons ($1, NULL_TREE, NULL_TREE); }
1787 /* Used instead of declspecs where storage classes are not allowed
1788 (that is, for typenames and structure components).
1790 C++ can takes storage classes for structure components.
1791 Don't accept a typedef-name if anything but a modifier precedes it. */
1794 typespec %prec EMPTY
1795 { $$.t = build_decl_list (NULL_TREE, $1.t);
1796 $$.new_type_flag = $1.new_type_flag; }
1797 | nonempty_cv_qualifiers typespec
1798 { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1.t);
1799 $$.new_type_flag = $2.new_type_flag; }
1800 | typespec reserved_typespecquals
1801 { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2);
1802 $$.new_type_flag = $1.new_type_flag; }
1803 | nonempty_cv_qualifiers typespec reserved_typespecquals
1804 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1805 $$.new_type_flag = $1.new_type_flag; }
1808 reserved_typespecquals:
1809 typespecqual_reserved
1810 { $$ = build_decl_list (NULL_TREE, $1.t); }
1811 | reserved_typespecquals typespecqual_reserved
1812 { $$ = decl_tree_cons (NULL_TREE, $2.t, $1); }
1815 /* A typespec (but not a type qualifier).
1816 Once we have seen one of these in a declaration,
1817 if a typedef name appears then it is being redeclared. */
1821 | TYPESPEC %prec EMPTY
1822 { $$.t = $1; $$.new_type_flag = 0; }
1823 | complete_type_name
1824 { $$.t = $1; $$.new_type_flag = 0; }
1825 | TYPEOF '(' expr ')'
1826 { $$.t = finish_typeof ($3);
1827 $$.new_type_flag = 0; }
1828 | TYPEOF '(' type_id ')'
1829 { $$.t = groktypename ($3.t);
1830 $$.new_type_flag = 0; }
1831 | SIGOF '(' expr ')'
1832 { tree type = TREE_TYPE ($3);
1834 $$.new_type_flag = 0;
1835 if (IS_AGGR_TYPE (type))
1837 sorry ("sigof type specifier");
1842 error ("`sigof' applied to non-aggregate expression");
1843 $$.t = error_mark_node;
1846 | SIGOF '(' type_id ')'
1847 { tree type = groktypename ($3.t);
1849 $$.new_type_flag = 0;
1850 if (IS_AGGR_TYPE (type))
1852 sorry ("sigof type specifier");
1857 error("`sigof' applied to non-aggregate type");
1858 $$.t = error_mark_node;
1863 /* A typespec that is a reserved word, or a type qualifier. */
1865 typespecqual_reserved:
1867 { $$.t = $1; $$.new_type_flag = 0; }
1869 { $$.t = $1; $$.new_type_flag = 0; }
1875 | initdecls ',' initdcl
1876 { check_multiple_declarators (); }
1881 | notype_initdecls ',' initdcl
1882 { check_multiple_declarators (); }
1887 | nomods_initdecls ',' initdcl
1888 { check_multiple_declarators (); }
1894 | asm_keyword '(' string ')'
1895 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3); $$ = $3; }
1899 declarator maybeasm maybe_attribute '='
1900 { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1,
1901 $3, prefix_attributes); }
1903 /* Note how the declaration of the variable is in effect while its init is parsed! */
1904 { cp_finish_decl ($<ttype>5, $6, $2, 1, LOOKUP_ONLYCONVERTING); }
1905 | declarator maybeasm maybe_attribute
1906 { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 0,
1907 $3, prefix_attributes);
1908 cp_finish_decl ($<ttype>$, NULL_TREE, $2, 1, 0); }
1911 /* This rule assumes a certain configuration of the parser stack.
1912 In particular, $0, the element directly before the beginning of
1913 this rule on the stack, must be a maybeasm. $-1 must be a
1914 declarator or notype_declarator. And $-2 must be some declmods
1915 or declspecs. We can't move the maybeasm into this rule because
1916 we need that reduce so we prefer fn.def1 when appropriate. */
1919 { $<itype>2 = parse_decl ($<ttype>-1, $<ttype>-2,
1920 $1, 1, &$<ttype>$); }
1921 /* Note how the declaration of the variable is in effect
1922 while its init is parsed! */
1924 { cp_finish_decl ($<ttype>3, $4, $<ttype>0, 1,
1925 LOOKUP_ONLYCONVERTING);
1929 $$ = parse_decl ($<ttype>-1, $<ttype>-2, $1, 0, &d);
1930 cp_finish_decl (d, NULL_TREE, $<ttype>0, 1, 0); }
1934 declarator maybeasm initdcl0_innards
1938 notype_declarator maybeasm initdcl0_innards
1943 notype_declarator maybeasm
1944 { /* Set things up as initdcl0_innards expects. */
1949 | constructor_declarator maybeasm maybe_attribute
1951 parse_decl($1, NULL_TREE, $3, 0, &d);
1952 cp_finish_decl (d, NULL_TREE, $2, 1, 0); }
1955 /* the * rules are dummies to accept the Apollo extended syntax
1956 so that the header files compile. */
1967 | attributes attribute
1968 { $$ = chainon ($1, $2); }
1972 ATTRIBUTE '(' '(' attribute_list ')' ')'
1979 | attribute_list ',' attrib
1980 { $$ = chainon ($1, $3); }
1987 { $$ = build_tree_list ($1, NULL_TREE); }
1988 | any_word '(' IDENTIFIER ')'
1989 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1990 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1991 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1992 | any_word '(' nonnull_exprlist ')'
1993 { $$ = build_tree_list ($1, $3); }
1996 /* This still leaves out most reserved keywords,
1997 shouldn't we include them? */
2006 /* A nonempty list of identifiers, including typenames. */
2007 identifiers_or_typenames:
2009 { $$ = build_tree_list (NULL_TREE, $1); }
2010 | identifiers_or_typenames ',' identifier
2011 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2015 /* empty */ %prec EMPTY
2020 /* If we are processing a template, we don't want to expand this
2024 expr_no_commas %prec '='
2026 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, NULL_TREE);
2027 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2029 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2030 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2031 | '{' initlist ',' '}'
2032 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2033 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2038 /* This chain is built in reverse order,
2039 and put in forward order where initlist is used. */
2042 { $$ = build_tree_list (NULL_TREE, $$); }
2044 { $$ = expr_tree_cons (NULL_TREE, $3, $$); }
2045 /* These are for labeled elements. */
2046 | '[' expr_no_commas ']' init
2047 { $$ = build_expr_list ($2, $4); }
2048 | identifier ':' init
2049 { $$ = build_expr_list ($$, $3); }
2050 | initlist ',' identifier ':' init
2051 { $$ = expr_tree_cons ($3, $5, $$); }
2055 PRE_PARSED_FUNCTION_DECL
2056 { start_function (NULL_TREE, TREE_VALUE ($1),
2058 reinit_parse_for_function (); }
2061 fn.defpen maybe_return_init ctor_initializer_opt compstmt_or_error
2063 int nested = (hack_decl_function_context
2064 (current_function_decl) != NULL_TREE);
2065 finish_function (lineno, (int)$3 | 2, nested);
2066 process_next_inline ($1);
2068 | fn.defpen maybe_return_init function_try_block
2070 int nested = (hack_decl_function_context
2071 (current_function_decl) != NULL_TREE);
2072 finish_function (lineno, (int)$3 | 2, nested);
2073 process_next_inline ($1);
2075 | fn.defpen maybe_return_init error
2076 { process_next_inline ($1); }
2081 | pending_inlines pending_inline eat_saved_input
2084 /* A regurgitated default argument. The value of DEFARG_MARKER will be
2085 the TREE_LIST node for the parameter in question. */
2087 DEFARG_MARKER expr_no_commas END_OF_SAVED_INPUT
2088 { replace_defarg ($1, $2); }
2089 | DEFARG_MARKER error END_OF_SAVED_INPUT
2090 { replace_defarg ($1, error_mark_node); }
2093 /* empty */ %prec EMPTY
2094 | pending_defargs defarg_again
2095 { do_pending_defargs (); }
2096 | pending_defargs error
2097 { do_pending_defargs (); }
2102 { $<itype>3 = suspend_momentary ();
2103 $<ttype>$ = current_enum_type;
2104 current_enum_type = start_enum ($2); }
2105 enumlist maybecomma_warn '}'
2106 { TYPE_VALUES (current_enum_type) = $5;
2107 $$.t = finish_enum (current_enum_type);
2108 $$.new_type_flag = 1;
2109 current_enum_type = $<ttype>4;
2110 resume_momentary ((int) $<itype>3);
2111 check_for_missing_semicolon ($$.t); }
2112 | ENUM identifier '{' '}'
2113 { $$.t = finish_enum (start_enum ($2));
2114 $$.new_type_flag = 1;
2115 check_for_missing_semicolon ($$.t); }
2117 { $<itype>2 = suspend_momentary ();
2118 $<ttype>$ = current_enum_type;
2119 current_enum_type = start_enum (make_anon_name ()); }
2120 enumlist maybecomma_warn '}'
2121 { TYPE_VALUES (current_enum_type) = $4;
2122 $$.t = finish_enum (current_enum_type);
2123 $$.new_type_flag = 1;
2124 current_enum_type = $<ttype>3;
2125 resume_momentary ((int) $<itype>1);
2126 check_for_missing_semicolon ($$.t); }
2128 { $$.t = finish_enum (start_enum (make_anon_name()));
2129 $$.new_type_flag = 1;
2130 check_for_missing_semicolon ($$.t); }
2132 { $$.t = xref_tag (enum_type_node, $2, 1);
2133 $$.new_type_flag = 0; }
2134 | ENUM complex_type_name
2135 { $$.t = xref_tag (enum_type_node, $2, 1);
2136 $$.new_type_flag = 0; }
2137 | TYPENAME_KEYWORD typename_sub
2139 $$.new_type_flag = 0;
2140 if (!processing_template_decl)
2141 cp_pedwarn ("using `typename' outside of template"); }
2142 /* C++ extensions, merged with C to avoid shift/reduce conflicts */
2144 { $1.t = begin_class_definition ($1.t); }
2145 opt.component_decl_list '}' maybe_attribute
2149 if (yychar == YYEMPTY)
2151 semi = yychar == ';';
2153 $<ttype>$ = finish_class_definition ($1.t, $6, semi,
2158 begin_inline_definitions ();
2162 finish_inline_definitions ();
2164 $$.new_type_flag = 1;
2166 | class_head %prec EMPTY
2168 if ($1.new_type_flag)
2169 pop_scope (CP_DECL_CONTEXT (TYPE_MAIN_DECL ($1.t)));
2170 $$.new_type_flag = 0;
2171 if (TYPE_BINFO ($1.t) == NULL_TREE)
2173 cp_error ("%T is not a class type", $1.t);
2174 $$.t = error_mark_node;
2179 /* struct B: public A; is not accepted by the WP grammar. */
2180 if (TYPE_BINFO_BASETYPES ($$.t) && !TYPE_SIZE ($$.t)
2181 && ! TYPE_BEING_DEFINED ($$.t))
2182 cp_error ("base clause without member specification for `%#T'",
2196 { if (pedantic && !in_system_header)
2197 pedwarn ("comma at end of enumerator list"); }
2203 { error ("storage class specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2205 { error ("type specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2207 { error ("type qualifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2209 { error ("no body nor ';' separates two class, struct or union declarations"); }
2211 { $$ = build_decl_list ($2, $1); }
2214 named_class_head_sans_basetype:
2222 named_class_head_sans_basetype_defn:
2223 aggr identifier_defn %prec EMPTY
2224 { current_aggr = $$; $$ = $2; }
2225 | named_class_head_sans_basetype '{'
2226 { yyungetc ('{', 1); }
2227 | named_class_head_sans_basetype ':'
2228 { yyungetc (':', 1); }
2231 named_complex_class_head_sans_basetype:
2232 aggr nested_name_specifier identifier
2235 $$.t = handle_class_head ($1, $2, $3);
2236 $$.new_type_flag = 1;
2238 | aggr global_scope nested_name_specifier identifier
2241 $$.t = handle_class_head ($1, $3, $4);
2242 $$.new_type_flag = 1;
2244 | aggr global_scope identifier
2247 $$.t = handle_class_head ($1, NULL_TREE, $3);
2248 $$.new_type_flag = 1;
2250 | aggr apparent_template_type
2254 $$.new_type_flag = 0;
2256 | aggr nested_name_specifier apparent_template_type
2260 if (CP_DECL_CONTEXT ($$.t))
2261 push_scope (CP_DECL_CONTEXT ($$.t));
2262 $$.new_type_flag = 1;
2267 named_class_head_sans_basetype %prec EMPTY
2269 $$.t = xref_tag (current_aggr, $1, 1);
2270 $$.new_type_flag = 0;
2272 | named_class_head_sans_basetype_defn
2273 { $<ttype>$ = xref_tag (current_aggr, $1, 0); }
2274 /* Class name is unqualified, so we look for base classes
2275 in the current scope. */
2276 maybe_base_class_list %prec EMPTY
2279 $$.new_type_flag = 0;
2281 xref_basetypes (current_aggr, $1, $<ttype>2, $3);
2283 | named_complex_class_head_sans_basetype
2284 maybe_base_class_list
2286 if ($1.t != error_mark_node)
2288 $$.t = TREE_TYPE ($1.t);
2289 $$.new_type_flag = $1.new_type_flag;
2290 if (current_aggr == union_type_node
2291 && TREE_CODE ($$.t) != UNION_TYPE)
2292 cp_pedwarn ("`union' tag used in declaring `%#T'",
2294 else if (TREE_CODE ($$.t) == UNION_TYPE
2295 && current_aggr != union_type_node)
2296 cp_pedwarn ("non-`union' tag used in declaring `%#T'", $$);
2297 else if (TREE_CODE ($$.t) == RECORD_TYPE)
2298 /* We might be specializing a template with a different
2300 CLASSTYPE_DECLARED_CLASS ($$.t)
2301 = (current_aggr == class_type_node);
2304 maybe_process_partial_specialization ($$.t);
2305 xref_basetypes (current_aggr, $1.t, $$.t, $2);
2313 { $$ = xref_tag ($$, make_anon_name (), 0);
2314 yyungetc ('{', 1); }
2317 /* The tree output of this nonterminal a declarationf or the type
2318 named. If NEW_TYPE_FLAG is set, then the name used in this
2319 class-head was explicitly qualified, e.g.: `struct X::Y'. We have
2320 already called push_scope for X. */
2325 $$.new_type_flag = 0;
2330 maybe_base_class_list:
2331 /* empty */ %prec EMPTY
2333 | ':' see_typename %prec EMPTY
2334 { yyungetc(':', 1); $$ = NULL_TREE; }
2335 | ':' see_typename base_class_list %prec EMPTY
2341 | base_class_list ',' see_typename base_class
2342 { $$ = chainon ($$, $4); }
2347 { $$ = finish_base_specifier (access_default_node, $1,
2349 == signature_type_node); }
2350 | base_class_access_list see_typename base_class.1
2351 { $$ = finish_base_specifier ($1, $3,
2353 == signature_type_node); }
2358 { if ($$ != error_mark_node) $$ = TYPE_MAIN_DECL ($1); }
2360 | SIGOF '(' expr ')'
2362 if (current_aggr == signature_type_node)
2364 if (IS_AGGR_TYPE (TREE_TYPE ($3)))
2366 sorry ("`sigof' as base signature specifier");
2367 $$ = TREE_TYPE ($3);
2371 error ("`sigof' applied to non-aggregate expression");
2372 $$ = error_mark_node;
2377 error ("`sigof' in struct or class declaration");
2378 $$ = error_mark_node;
2381 | SIGOF '(' type_id ')'
2383 if (current_aggr == signature_type_node)
2385 if (IS_AGGR_TYPE (groktypename ($3.t)))
2387 sorry ("`sigof' as base signature specifier");
2388 $$ = groktypename ($3.t);
2392 error ("`sigof' applied to non-aggregate expression");
2393 $$ = error_mark_node;
2398 error ("`sigof' in struct or class declaration");
2399 $$ = error_mark_node;
2404 base_class_access_list:
2405 VISSPEC see_typename
2406 | SCSPEC see_typename
2407 { if ($1 != ridpointers[(int)RID_VIRTUAL])
2408 cp_error ("`%D' access", $1);
2409 $$ = access_default_virtual_node; }
2410 | base_class_access_list VISSPEC see_typename
2412 if ($1 != access_default_virtual_node)
2413 error ("multiple access specifiers");
2414 else if ($2 == access_public_node)
2415 $$ = access_public_virtual_node;
2416 else if ($2 == access_protected_node)
2417 $$ = access_protected_virtual_node;
2418 else /* $2 == access_private_node */
2419 $$ = access_private_virtual_node;
2421 | base_class_access_list SCSPEC see_typename
2422 { if ($2 != ridpointers[(int)RID_VIRTUAL])
2423 cp_error ("`%D' access", $2);
2424 else if ($$ == access_public_node)
2425 $$ = access_public_virtual_node;
2426 else if ($$ == access_protected_node)
2427 $$ = access_protected_virtual_node;
2428 else if ($$ == access_private_node)
2429 $$ = access_private_virtual_node;
2431 error ("multiple `virtual' specifiers");
2435 opt.component_decl_list:
2436 | component_decl_list
2437 | opt.component_decl_list access_specifier component_decl_list
2438 | opt.component_decl_list access_specifier
2444 if (current_aggr == signature_type_node)
2446 error ("access specifier not allowed in signature");
2447 $1 = access_public_node;
2450 current_access_specifier = $1;
2454 /* Note: we no longer warn about the semicolon after a component_decl_list.
2455 ARM $9.2 says that the semicolon is optional, and therefore allowed. */
2456 component_decl_list:
2459 finish_member_declaration ($1);
2461 | component_decl_list component_decl
2463 finish_member_declaration ($2);
2468 component_decl_1 ';'
2469 | component_decl_1 '}'
2470 { error ("missing ';' before right brace");
2471 yyungetc ('}', 0); }
2472 /* C++: handle constructors, destructors and inline functions */
2473 /* note that INLINE is like a TYPESPEC */
2474 | fn.def2 ':' /* base_init compstmt */
2475 { $$ = finish_method ($$); }
2476 | fn.def2 TRY /* base_init compstmt */
2477 { $$ = finish_method ($$); }
2478 | fn.def2 RETURN_KEYWORD /* base_init compstmt */
2479 { $$ = finish_method ($$); }
2480 | fn.def2 '{' /* nodecls compstmt */
2481 { $$ = finish_method ($$); }
2484 | extension component_decl
2486 pedantic = $<itype>1; }
2487 | template_header component_decl
2490 $$ = finish_member_template_decl ($2);
2492 /* The component was already processed. */
2495 finish_template_decl ($1);
2497 | template_header typed_declspecs ';'
2499 $$ = finish_member_class_template ($2.t);
2500 finish_template_decl ($1);
2505 /* Do not add a "typed_declspecs declarator" rule here for
2506 speed; we need to call grok_x_components for enums, so the
2507 speedup would be insignificant. */
2508 typed_declspecs components
2510 /* Most of the productions for component_decl only
2511 allow the creation of one new member, so we call
2512 finish_member_declaration in component_decl_list.
2513 For this rule and the next, however, there can be
2514 more than one member, e.g.:
2518 and we need the first member to be fully
2519 registered before the second is processed.
2520 Therefore, the rules for components take care of
2521 this processing. To avoid registering the
2522 components more than once, we send NULL_TREE up
2523 here; that lets finish_member_declaration know
2524 that there is nothing to do. */
2526 grok_x_components ($1.t);
2529 | declmods notype_components
2532 grok_x_components ($1);
2535 | notype_declarator maybeasm maybe_attribute maybe_init
2536 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2537 build_tree_list ($3, NULL_TREE)); }
2538 | constructor_declarator maybeasm maybe_attribute maybe_init
2539 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2540 build_tree_list ($3, NULL_TREE)); }
2541 | ':' expr_no_commas
2542 { $$ = grokbitfield (NULL_TREE, NULL_TREE, $2); }
2546 /* These rules introduce a reduce/reduce conflict; in
2547 typedef int foo, bar;
2551 should "A::foo" be declared as a function or "A::bar" as a data
2552 member? In other words, is "bar" an after_type_declarator or a
2554 | declmods component_constructor_declarator maybeasm maybe_attribute maybe_init
2555 { tree specs, attrs;
2556 split_specs_attrs ($1, &specs, &attrs);
2557 $$ = grokfield ($2, specs, $5, $3,
2558 build_tree_list ($4, attrs)); }
2559 | component_constructor_declarator maybeasm maybe_attribute maybe_init
2560 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2561 build_tree_list ($3, NULL_TREE)); }
2563 { $$ = do_class_using_decl ($1); }
2565 /* The case of exactly one component is handled directly by component_decl. */
2568 /* empty: possibly anonymous */
2570 | component_declarator0
2572 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2573 $1 = finish_member_template_decl ($1);
2574 finish_member_declaration ($1);
2577 | components ',' component_declarator
2579 check_multiple_declarators ();
2580 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2581 $3 = finish_member_template_decl ($3);
2582 finish_member_declaration ($3);
2588 /* empty: possibly anonymous */
2590 | notype_component_declarator0
2592 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2593 $1 = finish_member_template_decl ($1);
2594 finish_member_declaration ($1);
2597 | notype_components ',' notype_component_declarator
2599 check_multiple_declarators ();
2600 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2601 $3 = finish_member_template_decl ($3);
2602 finish_member_declaration ($3);
2607 component_declarator0:
2608 after_type_component_declarator0
2609 | notype_component_declarator0
2612 component_declarator:
2613 after_type_component_declarator
2614 | notype_component_declarator
2617 after_type_component_declarator0:
2618 after_type_declarator maybeasm maybe_attribute maybe_init
2619 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2620 &prefix_attributes);
2621 $<ttype>0 = current_declspecs;
2622 $$ = grokfield ($$, current_declspecs, $4, $2,
2623 build_tree_list ($3, prefix_attributes)); }
2624 | TYPENAME ':' expr_no_commas maybe_attribute
2625 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2626 &prefix_attributes);
2627 $<ttype>0 = current_declspecs;
2628 $$ = grokbitfield ($$, current_declspecs, $3);
2629 cplus_decl_attributes ($$, $4, prefix_attributes); }
2632 notype_component_declarator0:
2633 notype_declarator maybeasm maybe_attribute maybe_init
2634 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2635 &prefix_attributes);
2636 $<ttype>0 = current_declspecs;
2637 $$ = grokfield ($$, current_declspecs, $4, $2,
2638 build_tree_list ($3, prefix_attributes)); }
2639 | constructor_declarator maybeasm maybe_attribute maybe_init
2640 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2641 &prefix_attributes);
2642 $<ttype>0 = current_declspecs;
2643 $$ = grokfield ($$, current_declspecs, $4, $2,
2644 build_tree_list ($3, prefix_attributes)); }
2645 | IDENTIFIER ':' expr_no_commas maybe_attribute
2646 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2647 &prefix_attributes);
2648 $<ttype>0 = current_declspecs;
2649 $$ = grokbitfield ($$, current_declspecs, $3);
2650 cplus_decl_attributes ($$, $4, prefix_attributes); }
2651 | ':' expr_no_commas maybe_attribute
2652 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2653 &prefix_attributes);
2654 $<ttype>0 = current_declspecs;
2655 $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
2656 cplus_decl_attributes ($$, $3, prefix_attributes); }
2659 after_type_component_declarator:
2660 after_type_declarator maybeasm maybe_attribute maybe_init
2661 { $$ = grokfield ($$, current_declspecs, $4, $2,
2662 build_tree_list ($3, prefix_attributes)); }
2663 | TYPENAME ':' expr_no_commas maybe_attribute
2664 { $$ = grokbitfield ($$, current_declspecs, $3);
2665 cplus_decl_attributes ($$, $4, prefix_attributes); }
2668 notype_component_declarator:
2669 notype_declarator maybeasm maybe_attribute maybe_init
2670 { $$ = grokfield ($$, current_declspecs, $4, $2,
2671 build_tree_list ($3, prefix_attributes)); }
2672 | IDENTIFIER ':' expr_no_commas maybe_attribute
2673 { $$ = grokbitfield ($$, current_declspecs, $3);
2674 cplus_decl_attributes ($$, $4, prefix_attributes); }
2675 | ':' expr_no_commas maybe_attribute
2676 { $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
2677 cplus_decl_attributes ($$, $3, prefix_attributes); }
2680 /* We chain the enumerators in reverse order.
2681 Because of the way enums are built, the order is
2682 insignificant. Take advantage of this fact. */
2686 | enumlist ',' enumerator
2687 { TREE_CHAIN ($3) = $$; $$ = $3; }
2692 { $$ = build_enumerator ($$, NULL_TREE, current_enum_type); }
2693 | identifier '=' expr_no_commas
2694 { $$ = build_enumerator ($$, $3, current_enum_type); }
2697 /* ANSI new-type-id (5.3.4) */
2699 type_specifier_seq new_declarator
2700 { $$.t = build_decl_list ($1.t, $2);
2701 $$.new_type_flag = $1.new_type_flag; }
2702 | type_specifier_seq %prec EMPTY
2703 { $$.t = build_decl_list ($1.t, NULL_TREE);
2704 $$.new_type_flag = $1.new_type_flag; }
2705 /* GNU extension to allow arrays of arbitrary types with
2706 non-constant dimension. For the use of begin_new_placement
2707 here, see the comments in unary_expr above. */
2708 | '(' .begin_new_placement type_id .finish_new_placement
2712 pedwarn ("ANSI C++ forbids array dimensions with parenthesized type in new");
2713 $$.t = build_parse_node (ARRAY_REF, TREE_VALUE ($3.t), $6);
2714 $$.t = build_decl_list (TREE_PURPOSE ($3.t), $$.t);
2715 $$.new_type_flag = $3.new_type_flag;
2720 /* empty */ %prec EMPTY
2722 | cv_qualifiers CV_QUALIFIER
2723 { $$ = decl_tree_cons (NULL_TREE, $2, $$); }
2726 nonempty_cv_qualifiers:
2728 { $$.t = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
2729 $$.new_type_flag = 0; }
2730 | nonempty_cv_qualifiers CV_QUALIFIER
2731 { $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
2732 $$.new_type_flag = $1.new_type_flag; }
2735 /* These rules must follow the rules for function declarations
2736 and component declarations. That way, longer rules are preferred. */
2740 { $<itype>$ = suspend_momentary (); }
2742 /* An expression which will not live on the momentary obstack. */
2745 { resume_momentary ((int) $<itype>1); $$ = $2; }
2748 /* An expression which will not live on the momentary obstack. */
2750 suspend_mom '(' nonnull_exprlist ')'
2751 { resume_momentary ((int) $<itype>1); $$ = $3; }
2752 | suspend_mom '(' parmlist ')'
2753 { resume_momentary ((int) $<itype>1); $$ = $3; }
2754 | suspend_mom LEFT_RIGHT
2755 { resume_momentary ((int) $<itype>1); $$ = empty_parms (); }
2756 | suspend_mom '(' error ')'
2757 { resume_momentary ((int) $<itype>1); $$ = NULL_TREE; }
2760 /* A declarator that is allowed only after an explicit typespec. */
2762 after_type_declarator_intern:
2763 after_type_declarator
2764 | attributes after_type_declarator
2766 /* Provide support for '(' attributes '*' declarator ')'
2768 $$ = decl_tree_cons ($1, $2, NULL_TREE);
2772 /* may all be followed by prec '.' */
2773 after_type_declarator:
2774 '*' nonempty_cv_qualifiers after_type_declarator_intern %prec UNARY
2775 { $$ = make_pointer_declarator ($2.t, $3); }
2776 | '&' nonempty_cv_qualifiers after_type_declarator_intern %prec UNARY
2777 { $$ = make_reference_declarator ($2.t, $3); }
2778 | '*' after_type_declarator_intern %prec UNARY
2779 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2780 | '&' after_type_declarator_intern %prec UNARY
2781 { $$ = make_reference_declarator (NULL_TREE, $2); }
2782 | ptr_to_mem cv_qualifiers after_type_declarator_intern
2783 { tree arg = make_pointer_declarator ($2, $3);
2784 $$ = build_parse_node (SCOPE_REF, $1, arg);
2786 | direct_after_type_declarator
2789 direct_after_type_declarator:
2790 direct_after_type_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2791 { $$ = make_call_declarator ($$, $2, $3, $4); }
2792 | direct_after_type_declarator '[' nonmomentary_expr ']'
2793 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
2794 | direct_after_type_declarator '[' ']'
2795 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
2796 | '(' after_type_declarator_intern ')'
2798 | nested_name_specifier type_name %prec EMPTY
2799 { push_nested_class ($1, 3);
2800 $$ = build_parse_node (SCOPE_REF, $$, $2);
2801 TREE_COMPLEXITY ($$) = current_class_depth; }
2802 | type_name %prec EMPTY
2806 type_name %prec EMPTY
2808 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2810 $$ = lookup_name ($1, 1);
2811 maybe_note_name_used_in_class ($1, $$);
2816 | global_scope type_name
2818 if (TREE_CODE ($2) == IDENTIFIER_NODE)
2819 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
2822 got_scope = NULL_TREE;
2829 | global_scope nested_type
2834 nested_name_specifier type_name %prec EMPTY
2835 { $$ = get_type_decl ($2); }
2838 /* A declarator allowed whether or not there has been
2839 an explicit typespec. These cannot redeclare a typedef-name. */
2841 notype_declarator_intern:
2843 | attributes notype_declarator
2845 /* Provide support for '(' attributes '*' declarator ')'
2847 $$ = decl_tree_cons ($1, $2, NULL_TREE);
2852 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2853 { $$ = make_pointer_declarator ($2.t, $3); }
2854 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2855 { $$ = make_reference_declarator ($2.t, $3); }
2856 | '*' notype_declarator_intern %prec UNARY
2857 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2858 | '&' notype_declarator_intern %prec UNARY
2859 { $$ = make_reference_declarator (NULL_TREE, $2); }
2860 | ptr_to_mem cv_qualifiers notype_declarator_intern
2861 { tree arg = make_pointer_declarator ($2, $3);
2862 $$ = build_parse_node (SCOPE_REF, $1, arg);
2864 | direct_notype_declarator
2867 complex_notype_declarator:
2868 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2869 { $$ = make_pointer_declarator ($2.t, $3); }
2870 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2871 { $$ = make_reference_declarator ($2.t, $3); }
2872 | '*' complex_notype_declarator %prec UNARY
2873 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2874 | '&' complex_notype_declarator %prec UNARY
2875 { $$ = make_reference_declarator (NULL_TREE, $2); }
2876 | ptr_to_mem cv_qualifiers notype_declarator_intern
2877 { tree arg = make_pointer_declarator ($2, $3);
2878 $$ = build_parse_node (SCOPE_REF, $1, arg);
2880 | complex_direct_notype_declarator
2883 complex_direct_notype_declarator:
2884 direct_notype_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2885 { $$ = make_call_declarator ($$, $2, $3, $4); }
2886 | '(' complex_notype_declarator ')'
2888 | direct_notype_declarator '[' nonmomentary_expr ']'
2889 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
2890 | direct_notype_declarator '[' ']'
2891 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
2892 | notype_qualified_id
2893 { enter_scope_of ($1); }
2894 | nested_name_specifier notype_template_declarator
2895 { got_scope = NULL_TREE;
2896 $$ = build_parse_node (SCOPE_REF, $1, $2);
2897 enter_scope_of ($$);
2902 nested_name_specifier unqualified_id
2903 { got_scope = NULL_TREE;
2904 $$ = build_parse_node (SCOPE_REF, $$, $2); }
2905 | nested_name_specifier object_template_id
2906 { got_scope = NULL_TREE;
2907 $$ = build_parse_node (SCOPE_REF, $1, $2); }
2910 notype_qualified_id:
2911 nested_name_specifier notype_unqualified_id
2912 { got_scope = NULL_TREE;
2913 $$ = build_parse_node (SCOPE_REF, $$, $2); }
2914 | nested_name_specifier object_template_id
2915 { got_scope = NULL_TREE;
2916 $$ = build_parse_node (SCOPE_REF, $1, $2); }
2921 | global_scope notype_qualified_id
2926 typespec '(' nonnull_exprlist ')'
2927 { $$ = build_functional_cast ($1.t, $3); }
2928 | typespec '(' expr_or_declarator_intern ')'
2929 { $$ = reparse_decl_as_expr ($1.t, $3); }
2930 | typespec fcast_or_absdcl %prec EMPTY
2931 { $$ = reparse_absdcl_as_expr ($1.t, $2); }
2936 | template_type %prec EMPTY
2939 nested_name_specifier:
2940 nested_name_specifier_1
2941 | nested_name_specifier nested_name_specifier_1
2943 | nested_name_specifier TEMPLATE explicit_template_type SCOPE
2944 { got_scope = $$ = make_typename_type ($1, $3); }
2947 /* Why the @#$%^& do type_name and notype_identifier need to be expanded
2948 inline here?!? (jason) */
2949 nested_name_specifier_1:
2952 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2955 maybe_note_name_used_in_class ($1, $$);
2958 complete_type (TYPE_MAIN_VARIANT (TREE_TYPE ($$)));
2962 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2964 got_scope = $$ = TREE_TYPE ($$);
2968 if (TREE_CODE ($$) == IDENTIFIER_NODE)
2972 | template_type SCOPE
2973 { got_scope = $$ = complete_type (TREE_TYPE ($1)); }
2974 /* These break 'const i;'
2978 cp_error ("`%D' is not an aggregate typedef",
2979 lastiddecl ? lastiddecl : $$);
2980 $$ = error_mark_node;
2983 { goto failed_scope; } */
2988 | global_scope typename_sub0
2993 typename_sub1 identifier %prec EMPTY
2995 if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't')
2996 $$ = make_typename_type ($1, $2);
2997 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
2998 cp_error ("`%T' is not a class or namespace", $2);
3002 if (TREE_CODE ($$) == TYPE_DECL)
3003 $$ = TREE_TYPE ($$);
3006 | typename_sub1 template_type %prec EMPTY
3007 { $$ = TREE_TYPE ($2); }
3008 | typename_sub1 explicit_template_type %prec EMPTY
3009 { $$ = make_typename_type ($1, $2); }
3010 | typename_sub1 TEMPLATE explicit_template_type %prec EMPTY
3011 { $$ = make_typename_type ($1, $3); }
3017 if (TREE_CODE ($1) == IDENTIFIER_NODE)
3018 cp_error ("`%T' is not a class or namespace", $1);
3020 | typename_sub1 typename_sub2
3022 if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't')
3023 $$ = make_typename_type ($1, $2);
3024 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
3025 cp_error ("`%T' is not a class or namespace", $2);
3029 if (TREE_CODE ($$) == TYPE_DECL)
3030 $$ = TREE_TYPE ($$);
3033 | typename_sub1 explicit_template_type SCOPE
3034 { got_scope = $$ = make_typename_type ($1, $2); }
3035 | typename_sub1 TEMPLATE explicit_template_type SCOPE
3036 { got_scope = $$ = make_typename_type ($1, $3); }
3042 if (TREE_CODE ($1) != IDENTIFIER_NODE)
3045 /* Retrieve the type for the identifier, which might involve
3046 some computation. */
3047 got_scope = $$ = complete_type (IDENTIFIER_TYPE_VALUE ($1));
3049 if ($$ == error_mark_node)
3050 cp_error ("`%T' is not a class or namespace", $1);
3054 if (TREE_CODE ($1) != IDENTIFIER_NODE)
3056 got_scope = $$ = complete_type (TREE_TYPE ($$));
3058 | template_type SCOPE
3059 { got_scope = $$ = complete_type (TREE_TYPE ($$)); }
3064 if (TREE_CODE ($$) == IDENTIFIER_NODE)
3070 explicit_template_type:
3071 identifier '<' template_arg_list_opt template_close_bracket
3072 { $$ = build_min_nt (TEMPLATE_ID_EXPR, $1, $3); }
3076 global_scope type_name
3078 if (TREE_CODE ($2) == IDENTIFIER_NODE)
3079 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
3082 got_scope = NULL_TREE;
3085 | global_scope nested_type
3090 nested_name_specifier '*'
3091 { got_scope = NULL_TREE; }
3092 | global_scope nested_name_specifier '*'
3093 { $$ = $2; got_scope = NULL_TREE; }
3096 /* All uses of explicit global scope must go through this nonterminal so
3097 that got_scope will be set before yylex is called to get the next token. */
3100 { got_scope = void_type_node; }
3103 /* ANSI new-declarator (5.3.4) */
3105 '*' cv_qualifiers new_declarator
3106 { $$ = make_pointer_declarator ($2, $3); }
3107 | '*' cv_qualifiers %prec EMPTY
3108 { $$ = make_pointer_declarator ($2, NULL_TREE); }
3109 | '&' cv_qualifiers new_declarator %prec EMPTY
3110 { $$ = make_reference_declarator ($2, $3); }
3111 | '&' cv_qualifiers %prec EMPTY
3112 { $$ = make_reference_declarator ($2, NULL_TREE); }
3113 | ptr_to_mem cv_qualifiers %prec EMPTY
3114 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3115 $$ = build_parse_node (SCOPE_REF, $1, arg);
3117 | ptr_to_mem cv_qualifiers new_declarator
3118 { tree arg = make_pointer_declarator ($2, $3);
3119 $$ = build_parse_node (SCOPE_REF, $1, arg);
3121 | direct_new_declarator %prec EMPTY
3124 /* ANSI direct-new-declarator (5.3.4) */
3125 direct_new_declarator:
3127 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3128 | direct_new_declarator '[' nonmomentary_expr ']'
3129 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3136 /* Provide support for '(' attributes '*' declarator ')'
3138 $$ = decl_tree_cons ($1, $2, NULL_TREE);
3142 /* ANSI abstract-declarator (8.1) */
3144 '*' nonempty_cv_qualifiers absdcl_intern
3145 { $$ = make_pointer_declarator ($2.t, $3); }
3147 { $$ = make_pointer_declarator (NULL_TREE, $2); }
3148 | '*' nonempty_cv_qualifiers %prec EMPTY
3149 { $$ = make_pointer_declarator ($2.t, NULL_TREE); }
3151 { $$ = make_pointer_declarator (NULL_TREE, NULL_TREE); }
3152 | '&' nonempty_cv_qualifiers absdcl_intern
3153 { $$ = make_reference_declarator ($2.t, $3); }
3155 { $$ = make_reference_declarator (NULL_TREE, $2); }
3156 | '&' nonempty_cv_qualifiers %prec EMPTY
3157 { $$ = make_reference_declarator ($2.t, NULL_TREE); }
3159 { $$ = make_reference_declarator (NULL_TREE, NULL_TREE); }
3160 | ptr_to_mem cv_qualifiers %prec EMPTY
3161 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3162 $$ = build_parse_node (SCOPE_REF, $1, arg);
3164 | ptr_to_mem cv_qualifiers absdcl_intern
3165 { tree arg = make_pointer_declarator ($2, $3);
3166 $$ = build_parse_node (SCOPE_REF, $1, arg);
3168 | direct_abstract_declarator %prec EMPTY
3171 /* ANSI direct-abstract-declarator (8.1) */
3172 direct_abstract_declarator:
3173 '(' absdcl_intern ')'
3175 /* `(typedef)1' is `int'. */
3177 | direct_abstract_declarator '(' parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3178 { $$ = make_call_declarator ($$, $3, $5, $6); }
3179 | direct_abstract_declarator LEFT_RIGHT cv_qualifiers exception_specification_opt %prec '.'
3180 { $$ = make_call_declarator ($$, empty_parms (), $3, $4); }
3181 | direct_abstract_declarator '[' nonmomentary_expr ']' %prec '.'
3182 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3183 | direct_abstract_declarator '[' ']' %prec '.'
3184 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
3185 | '(' complex_parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3186 { $$ = make_call_declarator (NULL_TREE, $2, $4, $5); }
3187 | regcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3188 { set_quals_and_spec ($$, $2, $3); }
3189 | fcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3190 { set_quals_and_spec ($$, $2, $3); }
3191 | '[' nonmomentary_expr ']' %prec '.'
3192 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3194 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, NULL_TREE); }
3197 /* For C++, decls and stmts can be intermixed, so we don't need to
3198 have a special rule that won't start parsing the stmt section
3199 until we have a stmt that parses without errors. */
3212 /* Read zero or more forward-declarations for labels
3213 that nested functions can jump to. */
3218 pedwarn ("ANSI C++ forbids label declarations"); }
3223 | label_decls label_decl
3227 LABEL identifiers_or_typenames ';'
3229 for (link = $2; link; link = TREE_CHAIN (link))
3231 tree label = shadow_label (TREE_VALUE (link));
3232 C_DECLARED_LABEL_FLAG (label) = 1;
3233 declare_nonlocal_label (label);
3238 /* This is the body of a function definition.
3239 It causes syntax errors to ignore to the next openbrace. */
3248 { $<ttype>$ = begin_compound_stmt (0); }
3250 { $$ = finish_compound_stmt (0, $<ttype>2); }
3256 $<ttype>$ = begin_if_stmt ();
3257 cond_stmt_keyword = "if";
3260 { finish_if_stmt_cond ($3, $<ttype>2); }
3261 implicitly_scoped_stmt
3262 { $<ttype>$ = finish_then_clause ($<ttype>2); }
3265 implicitly_scoped_stmt:
3267 | { $<ttype>$ = begin_compound_stmt (0); }
3269 { $$ = finish_compound_stmt (0, $<ttype>1); }
3282 { finish_expr_stmt ($1); }
3284 { begin_else_clause (); }
3285 implicitly_scoped_stmt
3287 finish_else_clause ($<ttype>1);
3290 | simple_if %prec IF
3291 { finish_if_stmt (); }
3294 $<ttype>$ = begin_while_stmt ();
3295 cond_stmt_keyword = "while";
3298 { finish_while_stmt_cond ($3, $<ttype>2); }
3300 { finish_while_stmt ($<ttype>2); }
3302 { $<ttype>$ = begin_do_stmt (); }
3303 implicitly_scoped_stmt WHILE
3305 finish_do_body ($<ttype>2);
3306 cond_stmt_keyword = "do";
3308 paren_expr_or_null ';'
3309 { finish_do_stmt ($6, $<ttype>2); }
3311 { $<ttype>$ = begin_for_stmt (); }
3312 '(' for.init.statement
3313 { finish_for_init_stmt ($<ttype>2); }
3315 { finish_for_cond ($6, $<ttype>2); }
3317 { finish_for_expr ($9, $<ttype>2); }
3319 { finish_for_stmt ($9, $<ttype>2); }
3321 { begin_switch_stmt (); }
3323 { $<ttype>$ = finish_switch_cond ($4); }
3324 implicitly_scoped_stmt
3325 { finish_switch_stmt ($4, $<ttype>6); }
3326 | CASE expr_no_commas ':'
3327 { finish_case_label ($2, NULL_TREE); }
3329 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
3330 { finish_case_label ($2, $4); }
3333 { finish_case_label (NULL_TREE, NULL_TREE); }
3336 { finish_break_stmt (); }
3338 { finish_continue_stmt (); }
3339 | RETURN_KEYWORD ';'
3340 { finish_return_stmt (NULL_TREE); }
3341 | RETURN_KEYWORD expr ';'
3342 { finish_return_stmt ($2); }
3343 | asm_keyword maybe_cv_qualifier '(' string ')' ';'
3345 finish_asm_stmt ($2, $4, NULL_TREE, NULL_TREE,
3348 /* This is the case with just output operands. */
3349 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ')' ';'
3351 finish_asm_stmt ($2, $4, $6, NULL_TREE,
3354 /* This is the case with input operands as well. */
3355 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':' asm_operands ')' ';'
3356 { finish_asm_stmt ($2, $4, $6, $8, NULL_TREE); }
3357 /* This is the case with clobbered registers as well. */
3358 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':'
3359 asm_operands ':' asm_clobbers ')' ';'
3360 { finish_asm_stmt ($2, $4, $6, $8, $10); }
3364 pedwarn ("ANSI C++ forbids computed gotos");
3365 finish_goto_stmt ($3);
3367 | GOTO identifier ';'
3368 { finish_goto_stmt ($2); }
3372 { error ("label must be followed by statement");
3379 | namespace_using_decl
3380 { do_local_using_decl ($1); }
3387 if (! current_function_parms_stored)
3388 store_parm_decls ();
3389 expand_start_early_try_stmts ();
3391 ctor_initializer_opt compstmt
3393 end_protect_partials ();
3394 expand_start_all_catch ();
3398 expand_end_all_catch ();
3405 { $<ttype>$ = begin_try_block (); }
3407 { finish_try_block ($<ttype>2); }
3409 { finish_handler_sequence ($<ttype>2); }
3414 | handler_seq handler
3419 { $<ttype>$ = begin_handler(); }
3421 { finish_handler_parms ($<ttype>2); }
3423 { finish_handler ($<ttype>2); }
3427 typed_typespecs %prec EMPTY
3428 | nonempty_cv_qualifiers %prec EMPTY
3433 { expand_start_catch_block (NULL_TREE, NULL_TREE); }
3434 /* This doesn't allow reference parameters, the below does.
3435 | '(' type_specifier_seq absdcl ')'
3436 { check_for_new_type ("inside exception declarations", $2);
3437 expand_start_catch_block ($2.t, $3); }
3438 | '(' type_specifier_seq ')'
3439 { check_for_new_type ("inside exception declarations", $2);
3440 expand_start_catch_block ($2.t, NULL_TREE); }
3441 | '(' type_specifier_seq notype_declarator ')'
3442 { check_for_new_type ("inside exception declarations", $2);
3443 expand_start_catch_block ($2.t, $3); }
3444 | '(' typed_typespecs after_type_declarator ')'
3445 { check_for_new_type ("inside exception declarations", $2);
3446 expand_start_catch_block ($2.t, $3); }
3447 This allows reference parameters... */
3449 { check_for_new_type ("inside exception declarations", $2);
3450 expand_start_catch_block (TREE_PURPOSE ($2.t),
3451 TREE_VALUE ($2.t)); }
3458 label = define_label (input_filename, lineno, $1);
3459 if (label && ! minimal_parse_mode)
3460 expand_label (label);
3472 { if ($1) cplus_expand_expr_stmt ($1); }
3476 pedwarn ("ANSI C++ forbids compound statements inside for initializations");
3480 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
3484 { emit_line_note (input_filename, lineno);
3487 { emit_line_note (input_filename, lineno); }
3498 /* These are the operands other than the first string and colon
3499 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
3503 | nonnull_asm_operands
3506 nonnull_asm_operands:
3508 | nonnull_asm_operands ',' asm_operand
3509 { $$ = chainon ($$, $3); }
3514 { $$ = build_tree_list ($$, $3); }
3519 { $$ = tree_cons (NULL_TREE, $$, NULL_TREE); }
3520 | asm_clobbers ',' STRING
3521 { $$ = tree_cons (NULL_TREE, $3, $$); }
3524 /* This is what appears inside the parens in a function declarator.
3525 Its value is represented in the format that grokdeclarator expects.
3527 In C++, declaring a function with no parameters
3528 means that that function takes *no* parameters. */
3537 { $$ = finish_parmlist (build_tree_list (NULL_TREE, $1.t), 0);
3538 check_for_new_type ("inside parameter list", $1); }
3541 /* This nonterminal does not include the common sequence '(' type_id ')',
3542 as it is ambiguous and must be disambiguated elsewhere. */
3545 { $$ = finish_parmlist ($$, 0); }
3546 | parms_comma ELLIPSIS
3547 { $$ = finish_parmlist ($1, 1); }
3548 /* C++ allows an ellipsis without a separating ',' */
3550 { $$ = finish_parmlist ($1, 1); }
3552 { $$ = finish_parmlist (build_tree_list (NULL_TREE,
3555 { $$ = finish_parmlist (NULL_TREE, 1); }
3558 /* This helps us recover from really nasty
3559 parse errors, for example, a missing right
3561 yyerror ("possibly missing ')'");
3562 $$ = finish_parmlist ($1, 0);
3568 /* This helps us recover from really nasty
3569 parse errors, for example, a missing right
3571 yyerror ("possibly missing ')'");
3572 $$ = finish_parmlist (build_tree_list (NULL_TREE,
3579 /* A default argument to a */
3582 { maybe_snarf_defarg (); }
3592 /* A nonempty list of parameter declarations or type names. */
3595 { check_for_new_type ("in a parameter list", $1);
3596 $$ = build_tree_list (NULL_TREE, $1.t); }
3598 { check_for_new_type ("in a parameter list", $1);
3599 $$ = build_tree_list ($2, $1.t); }
3600 | parms_comma full_parm
3601 { check_for_new_type ("in a parameter list", $2);
3602 $$ = chainon ($$, $2.t); }
3603 | parms_comma bad_parm
3604 { $$ = chainon ($$, build_tree_list (NULL_TREE, $2)); }
3605 | parms_comma bad_parm '=' init
3606 { $$ = chainon ($$, build_tree_list ($4, $2)); }
3612 { check_for_new_type ("in a parameter list", $1);
3613 $$ = build_tree_list (NULL_TREE, $1.t); }
3616 /* A single parameter declaration or parameter type name,
3617 as found in a parmlist. */
3619 /* Here we expand typed_declspecs inline to avoid mis-parsing of
3620 TYPESPEC IDENTIFIER. */
3621 typed_declspecs1 declarator
3622 { tree specs = strip_attrs ($1.t);
3623 $$.new_type_flag = $1.new_type_flag;
3624 $$.t = build_tree_list (specs, $2); }
3625 | typed_typespecs declarator
3626 { $$.t = build_tree_list ($1.t, $2);
3627 $$.new_type_flag = $1.new_type_flag; }
3628 | typespec declarator
3629 { $$.t = build_tree_list (build_decl_list (NULL_TREE, $1.t),
3631 $$.new_type_flag = $1.new_type_flag; }
3632 | typed_declspecs1 absdcl
3633 { tree specs = strip_attrs ($1.t);
3634 $$.t = build_tree_list (specs, $2);
3635 $$.new_type_flag = $1.new_type_flag; }
3636 | typed_declspecs1 %prec EMPTY
3637 { tree specs = strip_attrs ($1.t);
3638 $$.t = build_tree_list (specs, NULL_TREE);
3639 $$.new_type_flag = $1.new_type_flag; }
3640 | declmods notype_declarator
3641 { tree specs = strip_attrs ($1);
3642 $$.t = build_tree_list (specs, $2);
3643 $$.new_type_flag = 0; }
3648 { $$.t = build_tree_list (NULL_TREE, $1.t);
3649 $$.new_type_flag = $1.new_type_flag; }
3651 { $$.t = build_tree_list ($2, $1.t);
3652 $$.new_type_flag = $1.new_type_flag; }
3661 /* empty */ %prec EMPTY
3662 { see_typename (); }
3666 /* empty */ %prec EMPTY
3668 error ("type specifier omitted for parameter");
3669 $$ = build_tree_list (integer_type_node, NULL_TREE);
3673 error ("type specifier omitted for parameter");
3674 if (TREE_CODE ($$) == SCOPE_REF
3675 && (TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TYPE_PARM
3676 || TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TEMPLATE_PARM))
3677 cp_error (" perhaps you want `typename %E' to make it a type", $$);
3678 $$ = build_tree_list (integer_type_node, $$);
3682 exception_specification_opt:
3683 /* empty */ %prec EMPTY
3685 | THROW '(' ansi_raise_identifiers ')' %prec EMPTY
3687 | THROW LEFT_RIGHT %prec EMPTY
3688 { $$ = build_decl_list (NULL_TREE, NULL_TREE); }
3691 ansi_raise_identifier:
3693 { $$ = build_decl_list (NULL_TREE, groktypename($1.t)); }
3696 ansi_raise_identifiers:
3697 ansi_raise_identifier
3698 | ansi_raise_identifiers ',' ansi_raise_identifier
3700 TREE_CHAIN ($3) = $$;
3705 conversion_declarator:
3706 /* empty */ %prec EMPTY
3708 | '*' cv_qualifiers conversion_declarator
3709 { $$ = make_pointer_declarator ($2, $3); }
3710 | '&' cv_qualifiers conversion_declarator
3711 { $$ = make_reference_declarator ($2, $3); }
3712 | ptr_to_mem cv_qualifiers conversion_declarator
3713 { tree arg = make_pointer_declarator ($2, $3);
3714 $$ = build_parse_node (SCOPE_REF, $1, arg);
3720 { got_scope = NULL_TREE; }
3725 { $$ = ansi_opname[MULT_EXPR]; }
3727 { $$ = ansi_opname[TRUNC_DIV_EXPR]; }
3729 { $$ = ansi_opname[TRUNC_MOD_EXPR]; }
3731 { $$ = ansi_opname[PLUS_EXPR]; }
3733 { $$ = ansi_opname[MINUS_EXPR]; }
3735 { $$ = ansi_opname[BIT_AND_EXPR]; }
3737 { $$ = ansi_opname[BIT_IOR_EXPR]; }
3739 { $$ = ansi_opname[BIT_XOR_EXPR]; }
3741 { $$ = ansi_opname[BIT_NOT_EXPR]; }
3743 { $$ = ansi_opname[COMPOUND_EXPR]; }
3744 | operator ARITHCOMPARE
3745 { $$ = ansi_opname[$2]; }
3747 { $$ = ansi_opname[LT_EXPR]; }
3749 { $$ = ansi_opname[GT_EXPR]; }
3750 | operator EQCOMPARE
3751 { $$ = ansi_opname[$2]; }
3753 { $$ = ansi_assopname[$2]; }
3755 { $$ = ansi_opname [MODIFY_EXPR]; }
3757 { $$ = ansi_opname[$2]; }
3759 { $$ = ansi_opname[$2]; }
3761 { $$ = ansi_opname[POSTINCREMENT_EXPR]; }
3762 | operator MINUSMINUS
3763 { $$ = ansi_opname[PREDECREMENT_EXPR]; }
3765 { $$ = ansi_opname[TRUTH_ANDIF_EXPR]; }
3767 { $$ = ansi_opname[TRUTH_ORIF_EXPR]; }
3769 { $$ = ansi_opname[TRUTH_NOT_EXPR]; }
3771 { $$ = ansi_opname[COND_EXPR]; }
3773 { $$ = ansi_opname[$2]; }
3774 | operator POINTSAT %prec EMPTY
3775 { $$ = ansi_opname[COMPONENT_REF]; }
3776 | operator POINTSAT_STAR %prec EMPTY
3777 { $$ = ansi_opname[MEMBER_REF]; }
3778 | operator LEFT_RIGHT
3779 { $$ = ansi_opname[CALL_EXPR]; }
3781 { $$ = ansi_opname[ARRAY_REF]; }
3782 | operator NEW %prec EMPTY
3783 { $$ = ansi_opname[NEW_EXPR]; }
3784 | operator DELETE %prec EMPTY
3785 { $$ = ansi_opname[DELETE_EXPR]; }
3786 | operator NEW '[' ']'
3787 { $$ = ansi_opname[VEC_NEW_EXPR]; }
3788 | operator DELETE '[' ']'
3789 { $$ = ansi_opname[VEC_DELETE_EXPR]; }
3790 /* Names here should be looked up in class scope ALSO. */
3791 | operator type_specifier_seq conversion_declarator
3792 { $$ = grokoptypename ($2.t, $3); }
3794 { $$ = ansi_opname[ERROR_MARK]; }
3801 debug_yytranslate (value)
3804 return yytname[YYTRANSLATE (value)];