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 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
208 %type <ttype> direct_notype_declarator direct_after_type_declarator
209 %type <itype> components notype_components
210 %type <ttype> component_decl component_decl_1
211 %type <ttype> component_declarator component_declarator0
212 %type <ttype> notype_component_declarator notype_component_declarator0
213 %type <ttype> after_type_component_declarator after_type_component_declarator0
214 %type <ttype> enumlist enumerator
215 %type <ttype> absdcl cv_qualifiers
216 %type <ttype> direct_abstract_declarator conversion_declarator
217 %type <ttype> new_declarator direct_new_declarator
218 %type <ttype> xexpr parmlist parms bad_parm
219 %type <ttype> identifiers_or_typenames
220 %type <ttype> fcast_or_absdcl regcast_or_absdcl
221 %type <ttype> expr_or_declarator expr_or_declarator_intern
222 %type <ttype> complex_notype_declarator
223 %type <ttype> notype_unqualified_id unqualified_id qualified_id
224 %type <ttype> template_id do_id object_template_id notype_template_declarator
225 %type <ttype> overqualified_id notype_qualified_id any_id
226 %type <ttype> complex_direct_notype_declarator functional_cast
227 %type <ttype> complex_parmlist parms_comma
228 %type <ttype> namespace_qualifier namespace_using_decl
230 %type <ftype> type_id new_type_id typed_typespecs typespec typed_declspecs
231 %type <ftype> typed_declspecs1 type_specifier_seq nonempty_cv_qualifiers
232 %type <ftype> structsp typespecqual_reserved parm named_parm full_parm
235 %token <ttype> PTYPENAME
236 %token <ttype> PRE_PARSED_FUNCTION_DECL EXTERN_LANG_STRING ALL
237 %token <ttype> PRE_PARSED_CLASS_DECL DEFARG DEFARG_MARKER
238 %type <ttype> component_constructor_declarator
239 %type <ttype> fn.def2 return_id fn.defpen constructor_declarator
240 %type <itype> ctor_initializer_opt function_try_block
241 %type <ttype> named_class_head named_class_head_sans_basetype
242 %type <ttype> named_complex_class_head_sans_basetype
243 %type <ttype> unnamed_class_head
244 %type <ttype> class_head base_class_list
245 %type <ttype> base_class_access_list
246 %type <ttype> base_class maybe_base_class_list base_class.1
247 %type <ttype> exception_specification_opt ansi_raise_identifier ansi_raise_identifiers
248 %type <ttype> operator_name
249 %type <ttype> object aggr
250 %type <itype> new delete .begin_new_placement
251 /* %type <ttype> primary_no_id */
252 %type <ttype> nonmomentary_expr maybe_parmlist
253 %type <itype> initdcl0 notype_initdcl0 member_init_list initdcl0_innards
254 %type <ttype> template_header template_parm_list template_parm
255 %type <ttype> template_type_parm template_template_parm
256 %type <code> template_close_bracket
257 %type <ttype> apparent_template_type
258 %type <ttype> template_type template_arg_list template_arg_list_opt
259 %type <ttype> template_arg
260 %type <ttype> condition xcond paren_cond_or_null
261 %type <ttype> type_name nested_name_specifier nested_type ptr_to_mem
262 %type <ttype> complete_type_name notype_identifier nonnested_type
263 %type <ttype> complex_type_name nested_name_specifier_1
264 %type <ttype> new_initializer new_placement
265 %type <ttype> using_decl
266 %type <ttype> typename_sub typename_sub0 typename_sub1 typename_sub2
267 %type <ttype> explicit_template_type
268 /* in order to recognize aggr tags as defining and thus shadowing. */
269 %token TYPENAME_DEFN IDENTIFIER_DEFN PTYPENAME_DEFN
270 %type <ttype> named_class_head_sans_basetype_defn
271 %type <ttype> identifier_defn IDENTIFIER_DEFN TYPENAME_DEFN PTYPENAME_DEFN
273 %type <ttype> self_template_type .finish_template_type
278 /* Used in lex.c for parsing pragmas. */
281 /* lex.c and pt.c depend on this being the last token. Define
282 any new tokens before this one! */
283 %token END_OF_SAVED_INPUT
286 /* List of types and structure classes of the current declaration. */
287 static tree current_declspecs;
289 /* List of prefix attributes in effect.
290 Prefix attributes are parsed by the reserved_declspecs and declmods
291 rules. They create a list that contains *both* declspecs and attrs. */
292 /* ??? It is not clear yet that all cases where an attribute can now appear in
293 a declspec list have been updated. */
294 static tree prefix_attributes;
296 /* When defining an aggregate, this is the kind of the most recent one
297 being defined. (For example, this might be class_type_node.) */
298 static tree current_aggr;
300 /* When defining an enumeration, this is the type of the enumeration. */
301 static tree current_enum_type;
303 /* Tell yyparse how to print a token's value, if yydebug is set. */
305 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
306 extern void yyprint PROTO((FILE *, int, YYSTYPE));
307 extern tree combine_strings PROTO((tree));
310 parse_decl(declarator, specs_attrs, attributes, initialized, decl)
319 split_specs_attrs (specs_attrs, ¤t_declspecs, &prefix_attributes);
320 if (current_declspecs
321 && TREE_CODE (current_declspecs) != TREE_LIST)
322 current_declspecs = get_decl_list (current_declspecs);
323 if (have_extern_spec && !used_extern_spec)
325 current_declspecs = decl_tree_cons (NULL_TREE,
326 get_identifier ("extern"),
328 used_extern_spec = 1;
330 sm = suspend_momentary ();
331 *decl = start_decl (declarator, current_declspecs, initialized,
332 attributes, prefix_attributes);
341 { finish_translation_unit (); }
344 /* the reason for the strange actions in this rule
345 is so that notype_initdecls when reached via datadef
346 can find a valid list of type and sc specs in $0. */
349 { $<ttype>$ = NULL_TREE; }
351 { $<ttype>$ = NULL_TREE; }
352 | extdefs lang_extdef
353 { $<ttype>$ = NULL_TREE; }
362 { have_extern_spec = 1;
363 used_extern_spec = 0;
364 $<ttype>$ = NULL_TREE; }
367 { have_extern_spec = 0; }
372 { $<itype>$ = pedantic;
381 { if (pending_lang_change) do_pending_lang_change(); }
383 { if (! toplevel_bindings_p () && ! pseudo_global_level_p())
388 fndef eat_saved_input
389 { if (pending_inlines) do_pending_inlines (); }
391 { if (pending_inlines) do_pending_inlines (); }
393 { if (pending_inlines) do_pending_inlines (); }
394 | asm_keyword '(' string ')' ';'
395 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
397 | extern_lang_string '{' extdefs_opt '}'
398 { pop_lang_context (); }
399 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
400 { if (pending_inlines) do_pending_inlines ();
401 pop_lang_context (); }
402 | extern_lang_string .hush_warning datadef .warning_ok
403 { if (pending_inlines) do_pending_inlines ();
404 pop_lang_context (); }
405 | NAMESPACE identifier '{'
406 { push_namespace ($2); }
408 { pop_namespace (); }
410 { push_namespace (NULL_TREE); }
412 { pop_namespace (); }
415 { do_toplevel_using_decl ($1); }
418 { pedantic = $<itype>1; }
422 NAMESPACE identifier '='
423 { begin_only_namespace_names (); }
426 end_only_namespace_names ();
429 do_namespace_alias ($2, $5);
436 | USING global_scope qualified_id
438 | USING global_scope unqualified_id
442 namespace_using_decl:
443 USING namespace_qualifier identifier
444 { $$ = build_parse_node (SCOPE_REF, $2, $3); }
445 | USING global_scope identifier
446 { $$ = build_parse_node (SCOPE_REF, global_namespace, $3); }
447 | USING global_scope namespace_qualifier identifier
448 { $$ = build_parse_node (SCOPE_REF, $3, $4); }
453 { begin_only_namespace_names (); }
456 end_only_namespace_names ();
457 /* If no declaration was found, the using-directive is
458 invalid. Since that was not reported, we need the
459 identifier for the error message. */
460 if (TREE_CODE ($4) == IDENTIFIER_NODE && lastiddecl)
462 do_using_directive ($4);
469 if (TREE_CODE ($$) == IDENTIFIER_NODE)
473 | namespace_qualifier NSNAME SCOPE
476 if (TREE_CODE ($$) == IDENTIFIER_NODE)
484 | global_scope qualified_id
486 | global_scope unqualified_id
492 { push_lang_context ($1); }
493 | extern_lang_string EXTERN_LANG_STRING
494 { if (current_lang_name != $2)
495 cp_error ("use of linkage spec `%D' is different from previous spec `%D'", $2, current_lang_name);
496 pop_lang_context (); push_lang_context ($2); }
501 { begin_template_parm_list (); }
502 template_parm_list '>'
503 { $$ = end_template_parm_list ($4); }
505 { begin_specialization();
511 { $$ = process_template_parm (NULL_TREE, $1); }
512 | template_parm_list ',' template_parm
513 { $$ = process_template_parm ($1, $3); }
523 aggr maybe_identifier
524 { $$ = finish_template_type_parm ($1, $2); }
525 | TYPENAME_KEYWORD maybe_identifier
526 { $$ = finish_template_type_parm (class_type_node, $2); }
529 template_template_parm:
530 template_header aggr maybe_identifier
531 { $$ = finish_template_template_parm ($2, $3); }
535 /* The following rules introduce a new reduce/reduce
536 conflict on the ',' and '>' input tokens: they are valid
537 prefixes for a `structsp', which means they could match a
538 nameless parameter. See 14.6, paragraph 3.
539 By putting them before the `parm' rule, we get
540 their match before considering them nameless parameter
543 { $$ = build_tree_list (NULL_TREE, $1); }
544 | template_type_parm '=' type_id
545 { $$ = build_tree_list (groktypename ($3.t), $1); }
547 { $$ = build_tree_list (NULL_TREE, $1.t); }
548 | parm '=' expr_no_commas %prec ARITHCOMPARE
549 { $$ = build_tree_list ($3, $1.t); }
550 | template_template_parm
551 { $$ = build_tree_list (NULL_TREE, $1); }
552 | template_template_parm '=' template_arg
554 if (TREE_CODE ($3) != TEMPLATE_DECL
555 && TREE_CODE ($3) != TEMPLATE_TEMPLATE_PARM
556 && TREE_CODE ($3) != TYPE_DECL)
558 error ("invalid default template argument");
559 $3 = error_mark_node;
561 $$ = build_tree_list ($3, $1);
566 template_header template_extdef
567 { finish_template_decl ($1); }
568 | template_header error %prec EMPTY
569 { finish_template_decl ($1); }
573 fndef eat_saved_input
574 { if (pending_inlines) do_pending_inlines (); }
576 { if (pending_inlines) do_pending_inlines (); }
578 { if (pending_inlines) do_pending_inlines (); }
579 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
580 { if (pending_inlines) do_pending_inlines ();
581 pop_lang_context (); }
582 | extern_lang_string .hush_warning template_datadef .warning_ok
583 { if (pending_inlines) do_pending_inlines ();
584 pop_lang_context (); }
585 | extension template_extdef
586 { pedantic = $<itype>1; }
591 | declmods notype_initdecls ';'
593 | typed_declspecs initdecls ';'
594 { note_list_got_semicolon ($1.t); }
596 { maybe_process_partial_specialization ($1.t);
597 note_got_semicolon ($1.t); }
602 | declmods notype_initdecls ';'
604 | typed_declspecs initdecls ';'
605 { note_list_got_semicolon ($1.t); }
607 { pedwarn ("empty declaration"); }
608 | explicit_instantiation ';'
609 | typed_declspecs ';'
612 split_specs_attrs ($1.t, &t, &attrs);
614 note_list_got_semicolon ($1.t);
621 ctor_initializer_opt:
640 fn.def1 maybe_return_init ctor_initializer_opt compstmt_or_error
641 { finish_function (lineno, (int)$3, 0); }
642 | fn.def1 maybe_return_init function_try_block
644 int nested = (hack_decl_function_context
645 (current_function_decl) != NULL_TREE);
646 finish_function (lineno, (int)$3, nested);
648 | fn.def1 maybe_return_init error
652 constructor_declarator:
653 nested_name_specifier SELFNAME '('
654 { $$ = begin_constructor_declarator ($1, $2); }
655 parmlist ')' cv_qualifiers exception_specification_opt
656 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
657 | nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
658 { $$ = begin_constructor_declarator ($1, $2);
659 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
661 | global_scope nested_name_specifier SELFNAME '('
662 { $$ = begin_constructor_declarator ($2, $3); }
663 parmlist ')' cv_qualifiers exception_specification_opt
664 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
665 | global_scope nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
666 { $$ = begin_constructor_declarator ($2, $3);
667 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
669 | nested_name_specifier self_template_type '('
670 { $$ = begin_constructor_declarator ($1, $2); }
671 parmlist ')' cv_qualifiers exception_specification_opt
672 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
673 | nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
674 { $$ = begin_constructor_declarator ($1, $2);
675 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
677 | global_scope nested_name_specifier self_template_type '('
678 { $$ = begin_constructor_declarator ($2, $3); }
679 parmlist ')' cv_qualifiers exception_specification_opt
680 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
681 | global_scope nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
682 { $$ = begin_constructor_declarator ($2, $3);
683 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
688 typed_declspecs declarator
689 { if (!begin_function_definition ($1.t, $2))
691 | declmods notype_declarator
692 { if (!begin_function_definition ($1, $2))
695 { if (!begin_function_definition (NULL_TREE, $1))
697 | declmods constructor_declarator
698 { if (!begin_function_definition ($1, $2))
700 | constructor_declarator
701 { if (!begin_function_definition (NULL_TREE, $1))
705 component_constructor_declarator:
706 SELFNAME '(' parmlist ')' cv_qualifiers exception_specification_opt
707 { $$ = make_call_declarator ($1, $3, $5, $6); }
708 | SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
709 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
710 | self_template_type '(' parmlist ')' cv_qualifiers exception_specification_opt
711 { $$ = make_call_declarator ($1, $3, $5, $6); }
712 | self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
713 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
716 /* more C++ complexity. See component_decl for a comment on the
717 reduce/reduce conflict introduced by these rules. */
719 declmods component_constructor_declarator
721 split_specs_attrs ($1, &specs, &attrs);
722 attrs = build_tree_list (attrs, NULL_TREE);
723 $$ = start_method (specs, $2, attrs);
727 if (yychar == YYEMPTY)
729 reinit_parse_for_method (yychar, $$); }
730 | component_constructor_declarator
731 { $$ = start_method (NULL_TREE, $1, NULL_TREE);
733 | typed_declspecs declarator
735 split_specs_attrs ($1.t, &specs, &attrs);
736 attrs = build_tree_list (attrs, NULL_TREE);
737 $$ = start_method (specs, $2, attrs); goto rest_of_mdef; }
738 | declmods notype_declarator
740 split_specs_attrs ($1, &specs, &attrs);
741 attrs = build_tree_list (attrs, NULL_TREE);
742 $$ = start_method (specs, $2, attrs); goto rest_of_mdef; }
744 { $$ = start_method (NULL_TREE, $$, NULL_TREE);
746 | declmods constructor_declarator
748 split_specs_attrs ($1, &specs, &attrs);
749 attrs = build_tree_list (attrs, NULL_TREE);
750 $$ = start_method (specs, $2, attrs); goto rest_of_mdef; }
751 | constructor_declarator
752 { $$ = start_method (NULL_TREE, $$, NULL_TREE);
759 if (! current_function_parms_stored)
767 { store_return_init ($<ttype>$, $2); }
768 | return_id '(' nonnull_exprlist ')'
769 { store_return_init ($<ttype>$, $3); }
770 | return_id LEFT_RIGHT
771 { store_return_init ($<ttype>$, NULL_TREE); }
775 ':' .set_base_init member_init_list
778 error ("no base initializers given following ':'");
780 /* Always keep the BLOCK node associated with the outermost
781 pair of curley braces of a function. These are needed
782 for correct operation of dwarfout.c. */
790 if (! current_function_parms_stored)
793 if (DECL_CONSTRUCTOR_P (current_function_decl))
795 /* Make a contour for the initializer list. */
798 expand_start_bindings (0);
800 else if (current_class_type == NULL_TREE)
801 error ("base initializers not allowed for non-member functions");
802 else if (! DECL_CONSTRUCTOR_P (current_function_decl))
803 error ("only constructors take base initializers");
812 | member_init_list ',' member_init
813 | member_init_list error
817 '(' nonnull_exprlist ')'
819 if (current_class_name)
820 pedwarn ("anachronistic old style base class initializer");
821 expand_member_init (current_class_ref, NULL_TREE, $2);
825 if (current_class_name)
826 pedwarn ("anachronistic old style base class initializer");
827 expand_member_init (current_class_ref, NULL_TREE, void_type_node);
829 | notype_identifier '(' nonnull_exprlist ')'
830 { expand_member_init (current_class_ref, $1, $3); }
831 | notype_identifier LEFT_RIGHT
832 { expand_member_init (current_class_ref, $1, void_type_node); }
833 | nonnested_type '(' nonnull_exprlist ')'
834 { expand_member_init (current_class_ref, $1, $3); }
835 | nonnested_type LEFT_RIGHT
836 { expand_member_init (current_class_ref, $1, void_type_node); }
837 | typename_sub '(' nonnull_exprlist ')'
838 { expand_member_init (current_class_ref, TYPE_MAIN_DECL ($1),
840 | typename_sub LEFT_RIGHT
841 { expand_member_init (current_class_ref, TYPE_MAIN_DECL ($1),
865 explicit_instantiation:
866 TEMPLATE begin_explicit_instantiation typespec ';'
867 { do_type_instantiation ($3.t, NULL_TREE);
869 end_explicit_instantiation
870 | TEMPLATE begin_explicit_instantiation typed_declspecs declarator
871 { tree specs = strip_attrs ($3.t);
872 do_decl_instantiation (specs, $4, NULL_TREE); }
873 end_explicit_instantiation
874 | TEMPLATE begin_explicit_instantiation notype_declarator
875 { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
876 end_explicit_instantiation
877 | TEMPLATE begin_explicit_instantiation constructor_declarator
878 { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
879 end_explicit_instantiation
880 | SCSPEC TEMPLATE begin_explicit_instantiation typespec ';'
881 { do_type_instantiation ($4.t, $1);
883 end_explicit_instantiation
884 | SCSPEC TEMPLATE begin_explicit_instantiation typed_declspecs
886 { tree specs = strip_attrs ($4.t);
887 do_decl_instantiation (specs, $5, $1); }
888 end_explicit_instantiation
889 | SCSPEC TEMPLATE begin_explicit_instantiation notype_declarator
890 { do_decl_instantiation (NULL_TREE, $4, $1); }
891 end_explicit_instantiation
892 | SCSPEC TEMPLATE begin_explicit_instantiation constructor_declarator
893 { do_decl_instantiation (NULL_TREE, $4, $1); }
894 end_explicit_instantiation
897 begin_explicit_instantiation:
898 { begin_explicit_instantiation(); }
900 end_explicit_instantiation:
901 { end_explicit_instantiation(); }
903 /* The TYPENAME expansions are to deal with use of a template class name as
904 a template within the class itself, where the template decl is hidden by
905 a type decl. Got all that? */
908 PTYPENAME '<' template_arg_list_opt template_close_bracket
909 .finish_template_type
911 | TYPENAME '<' template_arg_list_opt template_close_bracket
912 .finish_template_type
917 apparent_template_type:
919 | identifier '<' template_arg_list_opt '>'
920 .finish_template_type
924 SELFNAME '<' template_arg_list_opt template_close_bracket
925 .finish_template_type
929 .finish_template_type:
931 if (yychar == YYEMPTY)
934 $$ = finish_template_type ($<ttype>-3, $<ttype>-1,
938 template_close_bracket:
942 /* Handle `Class<Class<Type>>' without space in the `>>' */
943 pedwarn ("`>>' should be `> >' in template class name");
948 template_arg_list_opt:
956 { $$ = build_tree_list (NULL_TREE, $$); }
957 | template_arg_list ',' template_arg
958 { $$ = chainon ($$, build_tree_list (NULL_TREE, $3)); }
963 { $$ = groktypename ($1.t); }
966 | expr_no_commas %prec ARITHCOMPARE
971 { $$ = NEGATE_EXPR; }
973 { $$ = CONVERT_EXPR; }
975 { $$ = PREINCREMENT_EXPR; }
977 { $$ = PREDECREMENT_EXPR; }
979 { $$ = TRUTH_NOT_EXPR; }
984 { $$ = build_x_compound_expr ($$); }
990 { error ("ANSI C++ forbids an empty condition for `%s'",
992 $$ = integer_zero_node; }
999 { error ("ANSI C++ forbids an empty condition for `%s'",
1001 $$ = integer_zero_node; }
1015 type_specifier_seq declarator maybeasm maybe_attribute '='
1018 for (d = getdecls (); d; d = TREE_CHAIN (d))
1019 if (TREE_CODE (d) == TYPE_DECL) {
1020 tree s = TREE_TYPE (d);
1021 if (TREE_CODE (s) == RECORD_TYPE)
1022 cp_error ("definition of class `%T' in condition", s);
1023 else if (TREE_CODE (s) == ENUMERAL_TYPE)
1024 cp_error ("definition of enum `%T' in condition", s);
1027 current_declspecs = $1.t;
1028 $<itype>5 = suspend_momentary ();
1029 $<ttype>$ = start_decl ($<ttype>2, current_declspecs, 1,
1030 $4, /*prefix_attributes*/ NULL_TREE);
1034 cp_finish_decl ($<ttype>6, $7, $4, 1, LOOKUP_ONLYCONVERTING);
1035 resume_momentary ($<itype>5);
1036 $$ = convert_from_reference ($<ttype>6);
1037 if (TREE_CODE (TREE_TYPE ($$)) == ARRAY_TYPE)
1038 cp_error ("definition of array `%#D' in condition", $$);
1045 | maybe_label_decls stmts '}'
1046 | maybe_label_decls stmts error '}'
1047 | maybe_label_decls error '}'
1050 already_scoped_stmt:
1052 { $<ttype>$ = begin_compound_stmt (1); }
1054 { finish_compound_stmt (1, $<ttype>2); }
1059 nontrivial_exprlist:
1060 expr_no_commas ',' expr_no_commas
1061 { $$ = expr_tree_cons (NULL_TREE, $$,
1062 build_expr_list (NULL_TREE, $3)); }
1063 | expr_no_commas ',' error
1064 { $$ = expr_tree_cons (NULL_TREE, $$,
1065 build_expr_list (NULL_TREE, error_mark_node)); }
1066 | nontrivial_exprlist ',' expr_no_commas
1067 { chainon ($$, build_expr_list (NULL_TREE, $3)); }
1068 | nontrivial_exprlist ',' error
1069 { chainon ($$, build_expr_list (NULL_TREE, error_mark_node)); }
1074 { $$ = build_expr_list (NULL_TREE, $$); }
1075 | nontrivial_exprlist
1081 /* __extension__ turns off -pedantic for following primary. */
1082 | extension cast_expr %prec UNARY
1084 pedantic = $<itype>1; }
1085 | '*' cast_expr %prec UNARY
1086 { $$ = build_x_indirect_ref ($2, "unary *"); }
1087 | '&' cast_expr %prec UNARY
1088 { $$ = build_x_unary_op (ADDR_EXPR, $2); }
1090 { $$ = build_x_unary_op (BIT_NOT_EXPR, $2); }
1091 | unop cast_expr %prec UNARY
1092 { $$ = finish_unary_op_expr ($1, $2); }
1093 /* Refer to the address of a label as a pointer. */
1096 pedwarn ("ANSI C++ forbids `&&'");
1097 $$ = finish_label_address_expr ($2); }
1098 | SIZEOF unary_expr %prec UNARY
1099 { $$ = expr_sizeof ($2); }
1100 | SIZEOF '(' type_id ')' %prec HYPERUNARY
1101 { $$ = c_sizeof (groktypename ($3.t));
1102 check_for_new_type ("sizeof", $3); }
1103 | ALIGNOF unary_expr %prec UNARY
1104 { $$ = grok_alignof ($2); }
1105 | ALIGNOF '(' type_id ')' %prec HYPERUNARY
1106 { $$ = c_alignof (groktypename ($3.t));
1107 check_for_new_type ("alignof", $3); }
1109 /* The %prec EMPTY's here are required by the = init initializer
1110 syntax extension; see below. */
1111 | new new_type_id %prec EMPTY
1112 { $$ = build_new (NULL_TREE, $2.t, NULL_TREE, $1);
1113 check_for_new_type ("new", $2); }
1114 | new new_type_id new_initializer
1115 { $$ = build_new (NULL_TREE, $2.t, $3, $1);
1116 check_for_new_type ("new", $2); }
1117 | new new_placement new_type_id %prec EMPTY
1118 { $$ = build_new ($2, $3.t, NULL_TREE, $1);
1119 check_for_new_type ("new", $3); }
1120 | new new_placement new_type_id new_initializer
1121 { $$ = build_new ($2, $3.t, $4, $1);
1122 check_for_new_type ("new", $3); }
1123 /* The .begin_new_placement in the following rules is
1124 necessary to avoid shift/reduce conflicts that lead to
1125 mis-parsing some expressions. Of course, these constructs
1126 are not really new-placement and it is bogus to call
1127 begin_new_placement. But, the parser cannot always tell at this
1128 point whether the next thing is an expression or a type-id,
1129 so there is nothing we can do. Fortunately,
1130 begin_new_placement does nothing harmful. When we rewrite
1131 the parser, this lossage should be removed, of course. */
1132 | new '(' .begin_new_placement type_id .finish_new_placement
1134 { $$ = build_new (NULL_TREE, groktypename($4.t),
1136 check_for_new_type ("new", $4); }
1137 | new '(' .begin_new_placement type_id .finish_new_placement
1139 { $$ = build_new (NULL_TREE, groktypename($4.t), $6, $1);
1140 check_for_new_type ("new", $4); }
1141 | new new_placement '(' .begin_new_placement type_id
1142 .finish_new_placement %prec EMPTY
1143 { $$ = build_new ($2, groktypename($5.t), NULL_TREE, $1);
1144 check_for_new_type ("new", $5); }
1145 | new new_placement '(' .begin_new_placement type_id
1146 .finish_new_placement new_initializer
1147 { $$ = build_new ($2, groktypename($5.t), $7, $1);
1148 check_for_new_type ("new", $5); }
1150 | delete cast_expr %prec UNARY
1151 { $$ = delete_sanity ($2, NULL_TREE, 0, $1); }
1152 | delete '[' ']' cast_expr %prec UNARY
1153 { $$ = delete_sanity ($4, NULL_TREE, 1, $1);
1154 if (yychar == YYEMPTY)
1156 | delete '[' expr ']' cast_expr %prec UNARY
1157 { $$ = delete_sanity ($5, $3, 2, $1);
1158 if (yychar == YYEMPTY)
1160 | REALPART cast_expr %prec UNARY
1161 { $$ = build_x_unary_op (REALPART_EXPR, $2); }
1162 | IMAGPART cast_expr %prec UNARY
1163 { $$ = build_x_unary_op (IMAGPART_EXPR, $2); }
1166 /* Note this rule is not suitable for use in new_placement
1167 since it uses NULL_TREE as the argument to
1168 finish_new_placement. This rule serves only to avoid
1169 reduce/reduce conflicts in unary_expr. See the comments
1170 there on the use of begin/finish_new_placement. */
1171 .finish_new_placement:
1173 { finish_new_placement (NULL_TREE, $<itype>-1); }
1175 .begin_new_placement:
1176 { $$ = begin_new_placement (); }
1179 '(' .begin_new_placement nonnull_exprlist ')'
1180 { $$ = finish_new_placement ($3, $2); }
1181 | '{' .begin_new_placement nonnull_exprlist '}'
1182 { cp_pedwarn ("old style placement syntax, use () instead");
1183 $$ = finish_new_placement ($3, $2); }
1187 '(' nonnull_exprlist ')'
1193 cp_error ("`%T' is not a valid expression", $2.t);
1194 $$ = error_mark_node;
1196 /* GNU extension so people can use initializer lists. Note that
1197 this alters the meaning of `new int = 1', which was previously
1198 syntactically valid but semantically invalid. */
1202 pedwarn ("ANSI C++ forbids initialization of new expression with `='");
1203 if (TREE_CODE ($2) != TREE_LIST
1204 && TREE_CODE ($2) != CONSTRUCTOR)
1205 $$ = build_expr_list (NULL_TREE, $2);
1211 /* This is necessary to postpone reduction of `int ((int)(int)(int))'. */
1213 '(' type_id ')' %prec EMPTY
1214 { $2.t = finish_parmlist (build_tree_list (NULL_TREE, $2.t), 0);
1215 $$ = make_call_declarator (NULL_TREE, $2.t, NULL_TREE, NULL_TREE);
1216 check_for_new_type ("cast", $2); }
1217 | regcast_or_absdcl '(' type_id ')' %prec EMPTY
1218 { $3.t = finish_parmlist (build_tree_list (NULL_TREE, $3.t), 0);
1219 $$ = make_call_declarator ($$, $3.t, NULL_TREE, NULL_TREE);
1220 check_for_new_type ("cast", $3); }
1225 | regcast_or_absdcl unary_expr %prec UNARY
1226 { $$ = reparse_absdcl_as_casts ($$, $2); }
1227 | regcast_or_absdcl '{' initlist maybecomma '}' %prec UNARY
1229 tree init = build_nt (CONSTRUCTOR, NULL_TREE,
1232 pedwarn ("ANSI C++ forbids constructor-expressions");
1233 /* Indicate that this was a GNU C constructor expression. */
1234 TREE_HAS_CONSTRUCTOR (init) = 1;
1236 $$ = reparse_absdcl_as_casts ($$, init);
1242 /* Handle general members. */
1243 | expr_no_commas POINTSAT_STAR expr_no_commas
1244 { $$ = build_x_binary_op (MEMBER_REF, $$, $3); }
1245 | expr_no_commas DOT_STAR expr_no_commas
1246 { $$ = build_m_component_ref ($$, $3); }
1247 | expr_no_commas '+' expr_no_commas
1248 { $$ = build_x_binary_op ($2, $$, $3); }
1249 | expr_no_commas '-' expr_no_commas
1250 { $$ = build_x_binary_op ($2, $$, $3); }
1251 | expr_no_commas '*' expr_no_commas
1252 { $$ = build_x_binary_op ($2, $$, $3); }
1253 | expr_no_commas '/' expr_no_commas
1254 { $$ = build_x_binary_op ($2, $$, $3); }
1255 | expr_no_commas '%' expr_no_commas
1256 { $$ = build_x_binary_op ($2, $$, $3); }
1257 | expr_no_commas LSHIFT expr_no_commas
1258 { $$ = build_x_binary_op ($2, $$, $3); }
1259 | expr_no_commas RSHIFT expr_no_commas
1260 { $$ = build_x_binary_op ($2, $$, $3); }
1261 | expr_no_commas ARITHCOMPARE expr_no_commas
1262 { $$ = build_x_binary_op ($2, $$, $3); }
1263 | expr_no_commas '<' expr_no_commas
1264 { $$ = build_x_binary_op (LT_EXPR, $$, $3); }
1265 | expr_no_commas '>' expr_no_commas
1266 { $$ = build_x_binary_op (GT_EXPR, $$, $3); }
1267 | expr_no_commas EQCOMPARE expr_no_commas
1268 { $$ = build_x_binary_op ($2, $$, $3); }
1269 | expr_no_commas MIN_MAX expr_no_commas
1270 { $$ = build_x_binary_op ($2, $$, $3); }
1271 | expr_no_commas '&' expr_no_commas
1272 { $$ = build_x_binary_op ($2, $$, $3); }
1273 | expr_no_commas '|' expr_no_commas
1274 { $$ = build_x_binary_op ($2, $$, $3); }
1275 | expr_no_commas '^' expr_no_commas
1276 { $$ = build_x_binary_op ($2, $$, $3); }
1277 | expr_no_commas ANDAND expr_no_commas
1278 { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $$, $3); }
1279 | expr_no_commas OROR expr_no_commas
1280 { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $$, $3); }
1281 | expr_no_commas '?' xexpr ':' expr_no_commas
1282 { $$ = build_x_conditional_expr ($$, $3, $5); }
1283 | expr_no_commas '=' expr_no_commas
1284 { $$ = build_x_modify_expr ($$, NOP_EXPR, $3);
1285 if ($$ != error_mark_node)
1286 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
1287 | expr_no_commas ASSIGN expr_no_commas
1288 { $$ = build_x_modify_expr ($$, $2, $3); }
1290 { $$ = build_throw (NULL_TREE); }
1291 | THROW expr_no_commas
1292 { $$ = build_throw ($2); }
1293 /* These extensions are not defined. The second arg to build_m_component_ref
1294 is old, build_m_component_ref now does an implicit
1295 build_indirect_ref (x, NULL_PTR) on the second argument.
1296 | object '&' expr_no_commas %prec UNARY
1297 { $$ = build_m_component_ref ($$, build_x_unary_op (ADDR_EXPR, $3)); }
1298 | object unop expr_no_commas %prec UNARY
1299 { $$ = build_m_component_ref ($$, build_x_unary_op ($2, $3)); }
1300 | object '(' type_id ')' expr_no_commas %prec UNARY
1301 { tree type = groktypename ($3.t);
1302 $$ = build_m_component_ref ($$, build_c_cast (type, $5)); }
1303 | object primary_no_id %prec UNARY
1304 { $$ = build_m_component_ref ($$, $2); }
1308 notype_unqualified_id:
1309 '~' see_typename identifier
1310 { $$ = build_parse_node (BIT_NOT_EXPR, $3); }
1311 | '~' see_typename template_type
1312 { $$ = build_parse_node (BIT_NOT_EXPR, $3); }
1317 | NSNAME %prec EMPTY
1322 /* If lastiddecl is a TREE_LIST, it's a baselink, which
1323 means that we're in an expression like S::f<int>, so
1324 don't do_identifier; we only do that for unqualified
1326 if (lastiddecl && TREE_CODE (lastiddecl) != TREE_LIST)
1327 $$ = do_identifier ($<ttype>-1, 1, NULL_TREE);
1333 PFUNCNAME '<' do_id template_arg_list_opt template_close_bracket
1334 { $$ = lookup_template_function ($3, $4); }
1335 | operator_name '<' do_id template_arg_list_opt template_close_bracket
1336 { $$ = lookup_template_function ($3, $4); }
1340 TEMPLATE identifier '<' template_arg_list_opt template_close_bracket
1341 { $$ = lookup_template_function ($2, $4); }
1342 | TEMPLATE PFUNCNAME '<' template_arg_list_opt template_close_bracket
1343 { $$ = lookup_template_function ($2, $4); }
1344 | TEMPLATE operator_name '<' template_arg_list_opt
1345 template_close_bracket
1346 { $$ = lookup_template_function ($2, $4); }
1350 notype_unqualified_id
1355 expr_or_declarator_intern:
1357 | attributes expr_or_declarator
1359 /* Provide support for '(' attributes '*' declarator ')'
1361 $$ = decl_tree_cons ($1, $2, NULL_TREE);
1366 notype_unqualified_id
1367 | '*' expr_or_declarator_intern %prec UNARY
1368 { $$ = build_parse_node (INDIRECT_REF, $2); }
1369 | '&' expr_or_declarator_intern %prec UNARY
1370 { $$ = build_parse_node (ADDR_EXPR, $2); }
1371 | '(' expr_or_declarator_intern ')'
1375 notype_template_declarator:
1376 IDENTIFIER '<' template_arg_list_opt template_close_bracket
1377 { $$ = lookup_template_function ($1, $3); }
1378 | NSNAME '<' template_arg_list template_close_bracket
1379 { $$ = lookup_template_function ($1, $3); }
1382 direct_notype_declarator:
1383 complex_direct_notype_declarator
1384 /* This precedence declaration is to prefer this reduce
1385 to the Koenig lookup shift in primary, below. I hate yacc. */
1386 | notype_unqualified_id %prec '('
1387 | notype_template_declarator
1388 | '(' expr_or_declarator_intern ')'
1389 { $$ = finish_decl_parsing ($2); }
1393 notype_unqualified_id
1395 if (TREE_CODE ($1) == BIT_NOT_EXPR)
1396 $$ = build_x_unary_op (BIT_NOT_EXPR, TREE_OPERAND ($1, 0));
1398 $$ = finish_id_expr ($1);
1404 if (processing_template_decl)
1405 push_obstacks (&permanent_obstack, &permanent_obstack);
1406 $$ = combine_strings ($$);
1407 /* combine_strings doesn't set up TYPE_MAIN_VARIANT of
1408 a const array the way we want, so fix it. */
1409 if (flag_const_strings)
1410 TREE_TYPE ($$) = build_cplus_array_type
1411 (TREE_TYPE (TREE_TYPE ($$)),
1412 TYPE_DOMAIN (TREE_TYPE ($$)));
1413 if (processing_template_decl)
1417 { $$ = finish_parenthesized_expr ($2); }
1418 | '(' expr_or_declarator_intern ')'
1419 { $2 = reparse_decl_as_expr (NULL_TREE, $2);
1420 $$ = finish_parenthesized_expr ($2); }
1422 { $$ = error_mark_node; }
1424 { tree scope = current_scope ();
1425 if (!scope || TREE_CODE (scope) != FUNCTION_DECL)
1427 error ("braced-group within expression allowed only inside a function");
1431 pedwarn ("ANSI C++ forbids braced-groups within expressions");
1432 $<ttype>$ = begin_stmt_expr ();
1435 { $$ = finish_stmt_expr ($<ttype>2, $3); }
1436 /* Koenig lookup support
1437 We could store lastiddecl in $1 to avoid another lookup,
1438 but that would result in many additional reduce/reduce conflicts. */
1439 | notype_unqualified_id '(' nonnull_exprlist ')'
1440 { $$ = finish_call_expr ($1, $3, 1); }
1441 | notype_unqualified_id LEFT_RIGHT
1442 { $$ = finish_call_expr ($1, NULL_TREE, 1); }
1443 | primary '(' nonnull_exprlist ')'
1444 { $$ = finish_call_expr ($1, $3, 0); }
1445 | primary LEFT_RIGHT
1446 { $$ = finish_call_expr ($1, NULL_TREE, 0); }
1447 | primary '[' expr ']'
1448 { $$ = grok_array_decl ($$, $3); }
1450 { $$ = finish_increment_expr ($1, POSTINCREMENT_EXPR); }
1451 | primary MINUSMINUS
1452 { $$ = finish_increment_expr ($1, POSTDECREMENT_EXPR); }
1453 /* C++ extensions */
1455 { $$ = finish_this_expr (); }
1456 | CV_QUALIFIER '(' nonnull_exprlist ')'
1458 /* This is a C cast in C++'s `functional' notation
1459 using the "implicit int" extension so that:
1460 `const (3)' is equivalent to `const int (3)'. */
1463 if ($3 == error_mark_node)
1465 $$ = error_mark_node;
1469 type = cp_build_qualified_type (integer_type_node,
1470 cp_type_qual_from_rid ($1));
1471 $$ = build_c_cast (type, build_compound_expr ($3));
1474 | DYNAMIC_CAST '<' type_id '>' '(' expr ')'
1475 { tree type = groktypename ($3.t);
1476 check_for_new_type ("dynamic_cast", $3);
1477 $$ = build_dynamic_cast (type, $6); }
1478 | STATIC_CAST '<' type_id '>' '(' expr ')'
1479 { tree type = groktypename ($3.t);
1480 check_for_new_type ("static_cast", $3);
1481 $$ = build_static_cast (type, $6); }
1482 | REINTERPRET_CAST '<' type_id '>' '(' expr ')'
1483 { tree type = groktypename ($3.t);
1484 check_for_new_type ("reinterpret_cast", $3);
1485 $$ = build_reinterpret_cast (type, $6); }
1486 | CONST_CAST '<' type_id '>' '(' expr ')'
1487 { tree type = groktypename ($3.t);
1488 check_for_new_type ("const_cast", $3);
1489 $$ = build_const_cast (type, $6); }
1490 | TYPEID '(' expr ')'
1491 { $$ = build_x_typeid ($3); }
1492 | TYPEID '(' type_id ')'
1493 { tree type = groktypename ($3.t);
1494 check_for_new_type ("typeid", $3);
1495 $$ = get_typeid (TYPE_MAIN_VARIANT (type)); }
1496 | global_scope IDENTIFIER
1497 { $$ = do_scoped_id ($2, 1); }
1498 | global_scope template_id
1500 | global_scope operator_name
1502 got_scope = NULL_TREE;
1503 if (TREE_CODE ($2) == IDENTIFIER_NODE)
1504 $$ = do_scoped_id ($2, 1);
1508 | overqualified_id %prec HYPERUNARY
1509 { $$ = build_offset_ref (OP0 ($$), OP1 ($$)); }
1510 | overqualified_id '(' nonnull_exprlist ')'
1511 { $$ = finish_qualified_call_expr ($1, $3); }
1512 | overqualified_id LEFT_RIGHT
1513 { $$ = finish_qualified_call_expr ($1, NULL_TREE); }
1514 | object object_template_id %prec UNARY
1516 $$ = build_x_component_ref ($$, $2, NULL_TREE, 1);
1518 | object object_template_id '(' nonnull_exprlist ')'
1519 { $$ = finish_object_call_expr ($2, $1, $4); }
1520 | object object_template_id LEFT_RIGHT
1521 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1522 | object unqualified_id %prec UNARY
1523 { $$ = build_x_component_ref ($$, $2, NULL_TREE, 1); }
1524 | object overqualified_id %prec UNARY
1525 { if (processing_template_decl)
1526 $$ = build_min_nt (COMPONENT_REF, $1, copy_to_permanent ($2));
1528 $$ = build_object_ref ($$, OP0 ($2), OP1 ($2)); }
1529 | object unqualified_id '(' nonnull_exprlist ')'
1530 { $$ = finish_object_call_expr ($2, $1, $4); }
1531 | object unqualified_id LEFT_RIGHT
1532 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1533 | object overqualified_id '(' nonnull_exprlist ')'
1534 { $$ = finish_qualified_object_call_expr ($2, $1, $4); }
1535 | object overqualified_id LEFT_RIGHT
1536 { $$ = finish_qualified_object_call_expr ($2, $1, NULL_TREE); }
1537 /* p->int::~int() is valid -- 12.4 */
1538 | object '~' TYPESPEC LEFT_RIGHT
1539 { $$ = finish_pseudo_destructor_call_expr ($1, NULL_TREE, $3); }
1540 | object TYPESPEC SCOPE '~' TYPESPEC LEFT_RIGHT
1541 { $$ = finish_pseudo_destructor_call_expr ($1, $2, $5); }
1544 $$ = error_mark_node;
1548 /* Not needed for now.
1554 { $$ = error_mark_node; }
1556 { if (current_function_decl == 0)
1558 error ("braced-group within expression allowed only inside a function");
1561 $<ttype>$ = expand_start_stmt_expr (); }
1564 pedwarn ("ANSI C++ forbids braced-groups within expressions");
1565 $$ = expand_end_stmt_expr ($<ttype>2); }
1566 | primary_no_id '(' nonnull_exprlist ')'
1567 { $$ = build_x_function_call ($$, $3, current_class_ref); }
1568 | primary_no_id LEFT_RIGHT
1569 { $$ = build_x_function_call ($$, NULL_TREE, current_class_ref); }
1570 | primary_no_id '[' expr ']'
1572 | primary_no_id PLUSPLUS
1573 { $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); }
1574 | primary_no_id MINUSMINUS
1575 { $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); }
1577 { goto do_scoped_id; }
1578 | SCOPE operator_name
1579 { if (TREE_CODE ($2) == IDENTIFIER_NODE)
1581 goto do_scoped_operator;
1590 { got_scope = NULL_TREE; $$ = 1; }
1596 | global_scope delete
1597 { got_scope = NULL_TREE; $$ = 1; }
1602 { $$ = boolean_true_node; }
1604 { $$ = boolean_false_node; }
1607 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
1611 { $$ = chainon ($$, $2); }
1617 if (! current_function_parms_stored)
1618 store_parm_decls ();
1620 /* Always keep the BLOCK node associated with the outermost
1621 pair of curley braces of a function. These are needed
1622 for correct operation of dwarfout.c. */
1629 { got_object = TREE_TYPE ($$); }
1632 $$ = build_x_arrow ($$);
1633 got_object = TREE_TYPE ($$);
1638 typespec initdecls ';'
1640 resume_momentary ($2);
1641 if ($1.t && IS_AGGR_TYPE_CODE (TREE_CODE ($1.t)))
1642 note_got_semicolon ($1.t);
1644 | typed_declspecs initdecls ';'
1646 resume_momentary ($2);
1647 note_list_got_semicolon ($1.t);
1649 | declmods notype_initdecls ';'
1650 { resume_momentary ($2); }
1651 | typed_declspecs ';'
1654 note_list_got_semicolon ($1.t);
1657 { warning ("empty declaration"); }
1659 { pedantic = $<itype>1; }
1662 /* Any kind of declarator (thus, all declarators allowed
1663 after an explicit typespec). */
1666 after_type_declarator %prec EMPTY
1667 | notype_declarator %prec EMPTY
1670 /* This is necessary to postpone reduction of `int()()()()'. */
1672 LEFT_RIGHT %prec EMPTY
1673 { $$ = make_call_declarator (NULL_TREE, empty_parms (),
1674 NULL_TREE, NULL_TREE); }
1675 | fcast_or_absdcl LEFT_RIGHT %prec EMPTY
1676 { $$ = make_call_declarator ($$, empty_parms (), NULL_TREE,
1680 /* ANSI type-id (8.1) */
1682 typed_typespecs absdcl
1683 { $$.t = build_decl_list ($1.t, $2);
1684 $$.new_type_flag = $1.new_type_flag; }
1685 | nonempty_cv_qualifiers absdcl
1686 { $$.t = build_decl_list ($1.t, $2);
1687 $$.new_type_flag = $1.new_type_flag; }
1689 { $$.t = build_decl_list (get_decl_list ($1.t), $2);
1690 $$.new_type_flag = $1.new_type_flag; }
1691 | typed_typespecs %prec EMPTY
1692 { $$.t = build_decl_list ($1.t, NULL_TREE);
1693 $$.new_type_flag = $1.new_type_flag; }
1694 | nonempty_cv_qualifiers %prec EMPTY
1695 { $$.t = build_decl_list ($1.t, NULL_TREE);
1696 $$.new_type_flag = $1.new_type_flag; }
1699 /* Declspecs which contain at least one type specifier or typedef name.
1700 (Just `const' or `volatile' is not enough.)
1701 A typedef'd name following these is taken as a name to be declared.
1702 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1705 typed_typespecs %prec EMPTY
1711 { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1);
1712 $$.new_type_flag = $2.new_type_flag; }
1713 | typespec reserved_declspecs %prec HYPERUNARY
1714 { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2);
1715 $$.new_type_flag = $1.new_type_flag; }
1716 | typespec reserved_typespecquals reserved_declspecs
1717 { $$.t = decl_tree_cons (NULL_TREE, $1.t, chainon ($2, $3));
1718 $$.new_type_flag = $1.new_type_flag; }
1719 | declmods typespec reserved_declspecs
1720 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1));
1721 $$.new_type_flag = $2.new_type_flag; }
1722 | declmods typespec reserved_typespecquals
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 reserved_declspecs
1726 { $$.t = decl_tree_cons (NULL_TREE, $2.t,
1727 chainon ($3, chainon ($4, $1)));
1728 $$.new_type_flag = $2.new_type_flag; }
1733 { if (extra_warnings)
1734 warning ("`%s' is not at beginning of declaration",
1735 IDENTIFIER_POINTER ($$));
1736 $$ = build_decl_list (NULL_TREE, $$); }
1737 | reserved_declspecs typespecqual_reserved
1738 { $$ = decl_tree_cons (NULL_TREE, $2.t, $$); }
1739 | reserved_declspecs SCSPEC
1740 { if (extra_warnings)
1741 warning ("`%s' is not at beginning of declaration",
1742 IDENTIFIER_POINTER ($2));
1743 $$ = decl_tree_cons (NULL_TREE, $2, $$); }
1744 | reserved_declspecs attributes
1745 { $$ = decl_tree_cons ($2, NULL_TREE, $1); }
1747 { $$ = decl_tree_cons ($1, NULL_TREE, NULL_TREE); }
1750 /* List of just storage classes and type modifiers.
1751 A declaration can start with just this, but then it cannot be used
1752 to redeclare a typedef-name.
1753 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1756 nonempty_cv_qualifiers %prec EMPTY
1757 { $$ = $1.t; TREE_STATIC ($$) = 1; }
1759 { $$ = IDENTIFIER_AS_LIST ($$); }
1760 | declmods CV_QUALIFIER
1761 { $$ = decl_tree_cons (NULL_TREE, $2, $$);
1762 TREE_STATIC ($$) = 1; }
1764 { if (extra_warnings && TREE_STATIC ($$))
1765 warning ("`%s' is not at beginning of declaration",
1766 IDENTIFIER_POINTER ($2));
1767 $$ = decl_tree_cons (NULL_TREE, $2, $$);
1768 TREE_STATIC ($$) = TREE_STATIC ($1); }
1769 | declmods attributes
1770 { $$ = decl_tree_cons ($2, NULL_TREE, $1); }
1772 { $$ = decl_tree_cons ($1, NULL_TREE, NULL_TREE); }
1775 /* Used instead of declspecs where storage classes are not allowed
1776 (that is, for typenames and structure components).
1778 C++ can takes storage classes for structure components.
1779 Don't accept a typedef-name if anything but a modifier precedes it. */
1782 typespec %prec EMPTY
1783 { $$.t = get_decl_list ($1.t);
1784 $$.new_type_flag = $1.new_type_flag; }
1785 | nonempty_cv_qualifiers typespec
1786 { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1.t);
1787 $$.new_type_flag = $2.new_type_flag; }
1788 | typespec reserved_typespecquals
1789 { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2);
1790 $$.new_type_flag = $1.new_type_flag; }
1791 | nonempty_cv_qualifiers typespec reserved_typespecquals
1792 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1793 $$.new_type_flag = $1.new_type_flag; }
1796 reserved_typespecquals:
1797 typespecqual_reserved
1798 { $$ = build_decl_list (NULL_TREE, $1.t); }
1799 | reserved_typespecquals typespecqual_reserved
1800 { $$ = decl_tree_cons (NULL_TREE, $2.t, $1); }
1803 /* A typespec (but not a type qualifier).
1804 Once we have seen one of these in a declaration,
1805 if a typedef name appears then it is being redeclared. */
1809 | TYPESPEC %prec EMPTY
1810 { $$.t = $1; $$.new_type_flag = 0; }
1811 | complete_type_name
1812 { $$.t = $1; $$.new_type_flag = 0; }
1813 | TYPEOF '(' expr ')'
1814 { $$.t = finish_typeof ($3);
1815 $$.new_type_flag = 0; }
1816 | TYPEOF '(' type_id ')'
1817 { $$.t = groktypename ($3.t);
1818 $$.new_type_flag = 0; }
1819 | SIGOF '(' expr ')'
1820 { tree type = TREE_TYPE ($3);
1822 $$.new_type_flag = 0;
1823 if (IS_AGGR_TYPE (type))
1825 sorry ("sigof type specifier");
1830 error ("`sigof' applied to non-aggregate expression");
1831 $$.t = error_mark_node;
1834 | SIGOF '(' type_id ')'
1835 { tree type = groktypename ($3.t);
1837 $$.new_type_flag = 0;
1838 if (IS_AGGR_TYPE (type))
1840 sorry ("sigof type specifier");
1845 error("`sigof' applied to non-aggregate type");
1846 $$.t = error_mark_node;
1851 /* A typespec that is a reserved word, or a type qualifier. */
1853 typespecqual_reserved:
1855 { $$.t = $1; $$.new_type_flag = 0; }
1857 { $$.t = $1; $$.new_type_flag = 0; }
1863 | initdecls ',' initdcl
1864 { check_multiple_declarators (); }
1869 | notype_initdecls ',' initdcl
1870 { check_multiple_declarators (); }
1875 | nomods_initdecls ',' initdcl
1876 { check_multiple_declarators (); }
1882 | asm_keyword '(' string ')'
1883 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3); $$ = $3; }
1887 declarator maybeasm maybe_attribute '='
1888 { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1,
1889 $3, prefix_attributes); }
1891 /* Note how the declaration of the variable is in effect while its init is parsed! */
1892 { cp_finish_decl ($<ttype>5, $6, $2, 1, LOOKUP_ONLYCONVERTING); }
1893 | declarator maybeasm maybe_attribute
1894 { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 0,
1895 $3, prefix_attributes);
1896 cp_finish_decl ($<ttype>$, NULL_TREE, $2, 1, 0); }
1899 /* This rule assumes a certain configuration of the parser stack.
1900 In particular, $0, the element directly before the beginning of
1901 this rule on the stack, must be a maybeasm. $-1 must be a
1902 declarator or notype_declarator. And $-2 must be some declmods
1903 or declspecs. We can't move the maybeasm into this rule because
1904 we need that reduce so we prefer fn.def1 when appropriate. */
1907 { $<itype>2 = parse_decl ($<ttype>-1, $<ttype>-2,
1908 $1, 1, &$<ttype>$); }
1909 /* Note how the declaration of the variable is in effect
1910 while its init is parsed! */
1912 { cp_finish_decl ($<ttype>3, $4, $<ttype>0, 1,
1913 LOOKUP_ONLYCONVERTING);
1917 $$ = parse_decl ($<ttype>-1, $<ttype>-2, $1, 0, &d);
1918 cp_finish_decl (d, NULL_TREE, $<ttype>0, 1, 0); }
1922 declarator maybeasm initdcl0_innards
1926 notype_declarator maybeasm initdcl0_innards
1931 notype_declarator maybeasm
1932 { /* Set things up as initdcl0_innards expects. */
1937 | constructor_declarator maybeasm maybe_attribute
1939 parse_decl($1, NULL_TREE, $3, 0, &d);
1940 cp_finish_decl (d, NULL_TREE, $2, 1, 0); }
1943 /* the * rules are dummies to accept the Apollo extended syntax
1944 so that the header files compile. */
1955 | attributes attribute
1956 { $$ = chainon ($1, $2); }
1960 ATTRIBUTE '(' '(' attribute_list ')' ')'
1967 | attribute_list ',' attrib
1968 { $$ = chainon ($1, $3); }
1975 { $$ = build_tree_list ($1, NULL_TREE); }
1976 | any_word '(' IDENTIFIER ')'
1977 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1978 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1979 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1980 | any_word '(' nonnull_exprlist ')'
1981 { $$ = build_tree_list ($1, $3); }
1984 /* This still leaves out most reserved keywords,
1985 shouldn't we include them? */
1994 /* A nonempty list of identifiers, including typenames. */
1995 identifiers_or_typenames:
1997 { $$ = build_tree_list (NULL_TREE, $1); }
1998 | identifiers_or_typenames ',' identifier
1999 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2003 /* empty */ %prec EMPTY
2008 /* If we are processing a template, we don't want to expand this
2012 expr_no_commas %prec '='
2014 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, NULL_TREE);
2015 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2017 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2018 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2019 | '{' initlist ',' '}'
2020 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2021 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2026 /* This chain is built in reverse order,
2027 and put in forward order where initlist is used. */
2030 { $$ = build_tree_list (NULL_TREE, $$); }
2032 { $$ = expr_tree_cons (NULL_TREE, $3, $$); }
2033 /* These are for labeled elements. */
2034 | '[' expr_no_commas ']' init
2035 { $$ = build_expr_list ($2, $4); }
2036 | identifier ':' init
2037 { $$ = build_expr_list ($$, $3); }
2038 | initlist ',' identifier ':' init
2039 { $$ = expr_tree_cons ($3, $5, $$); }
2043 PRE_PARSED_FUNCTION_DECL
2044 { start_function (NULL_TREE, TREE_VALUE ($1),
2046 reinit_parse_for_function (); }
2049 fn.defpen maybe_return_init ctor_initializer_opt compstmt_or_error
2051 int nested = (hack_decl_function_context
2052 (current_function_decl) != NULL_TREE);
2053 finish_function (lineno, (int)$3 | 2, nested);
2054 process_next_inline ($1);
2056 | fn.defpen maybe_return_init function_try_block
2058 int nested = (hack_decl_function_context
2059 (current_function_decl) != NULL_TREE);
2060 finish_function (lineno, (int)$3 | 2, nested);
2061 process_next_inline ($1);
2063 | fn.defpen maybe_return_init error
2064 { process_next_inline ($1); }
2069 | pending_inlines pending_inline eat_saved_input
2072 /* A regurgitated default argument. The value of DEFARG_MARKER will be
2073 the TREE_LIST node for the parameter in question. */
2075 DEFARG_MARKER expr_no_commas END_OF_SAVED_INPUT
2076 { replace_defarg ($1, $2); }
2077 | DEFARG_MARKER error END_OF_SAVED_INPUT
2078 { replace_defarg ($1, error_mark_node); }
2081 /* empty */ %prec EMPTY
2082 | pending_defargs defarg_again
2083 { do_pending_defargs (); }
2084 | pending_defargs error
2085 { do_pending_defargs (); }
2090 { $<itype>3 = suspend_momentary ();
2091 $<ttype>$ = current_enum_type;
2092 current_enum_type = start_enum ($2); }
2093 enumlist maybecomma_warn '}'
2094 { TYPE_VALUES (current_enum_type) = $5;
2095 $$.t = finish_enum (current_enum_type);
2096 $$.new_type_flag = 1;
2097 current_enum_type = $<ttype>4;
2098 resume_momentary ((int) $<itype>3);
2099 check_for_missing_semicolon ($$.t); }
2100 | ENUM identifier '{' '}'
2101 { $$.t = finish_enum (start_enum ($2));
2102 $$.new_type_flag = 1;
2103 check_for_missing_semicolon ($$.t); }
2105 { $<itype>2 = suspend_momentary ();
2106 $<ttype>$ = current_enum_type;
2107 current_enum_type = start_enum (make_anon_name ()); }
2108 enumlist maybecomma_warn '}'
2109 { TYPE_VALUES (current_enum_type) = $4;
2110 $$.t = finish_enum (current_enum_type);
2111 $$.new_type_flag = 1;
2112 current_enum_type = $<ttype>3;
2113 resume_momentary ((int) $<itype>1);
2114 check_for_missing_semicolon ($$.t); }
2116 { $$.t = finish_enum (start_enum (make_anon_name()));
2117 $$.new_type_flag = 1;
2118 check_for_missing_semicolon ($$.t); }
2120 { $$.t = xref_tag (enum_type_node, $2, 1);
2121 $$.new_type_flag = 0; }
2122 | ENUM complex_type_name
2123 { $$.t = xref_tag (enum_type_node, $2, 1);
2124 $$.new_type_flag = 0; }
2125 | TYPENAME_KEYWORD typename_sub
2127 $$.new_type_flag = 0;
2128 if (!processing_template_decl)
2129 cp_pedwarn ("using `typename' outside of template"); }
2130 /* C++ extensions, merged with C to avoid shift/reduce conflicts */
2131 | class_head left_curly
2132 opt.component_decl_list '}' maybe_attribute
2136 if (yychar == YYEMPTY)
2138 semi = yychar == ';';
2140 $<ttype>$ = finish_class_definition ($1, $5, semi);
2143 { finish_default_args (); }
2146 $$.new_type_flag = 1;
2147 begin_inline_definitions (); }
2148 | class_head %prec EMPTY
2150 $$.new_type_flag = 0;
2151 if (TYPE_BINFO ($1) == NULL_TREE)
2153 cp_error ("%T is not a class type", $1);
2154 $$.t = error_mark_node;
2159 /* struct B: public A; is not accepted by the WP grammar. */
2160 if (TYPE_BINFO_BASETYPES ($$.t) && !TYPE_SIZE ($$.t)
2161 && ! TYPE_BEING_DEFINED ($$.t))
2162 cp_error ("base clause without member specification for `%#T'",
2176 { if (pedantic && !in_system_header)
2177 pedwarn ("comma at end of enumerator list"); }
2183 { error ("storage class specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2185 { error ("type specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2187 { error ("type qualifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2189 { error ("no body nor ';' separates two class, struct or union declarations"); }
2191 { $$ = build_decl_list ($2, $1); }
2194 named_class_head_sans_basetype:
2202 named_class_head_sans_basetype_defn:
2203 aggr identifier_defn %prec EMPTY
2204 { current_aggr = $$; $$ = $2; }
2205 | named_class_head_sans_basetype '{'
2206 { yyungetc ('{', 1); }
2207 | named_class_head_sans_basetype ':'
2208 { yyungetc (':', 1); }
2211 named_complex_class_head_sans_basetype:
2212 aggr nested_name_specifier identifier
2215 $$ = handle_class_head ($1, $2, $3);
2217 | aggr global_scope nested_name_specifier identifier
2220 $$ = handle_class_head ($1, $3, $4);
2222 | aggr global_scope identifier
2225 $$ = handle_class_head ($1, NULL_TREE, $3);
2227 | aggr apparent_template_type
2228 { current_aggr = $$; $$ = $2; }
2229 | aggr nested_name_specifier apparent_template_type
2230 { current_aggr = $$; $$ = $3; }
2234 named_class_head_sans_basetype %prec EMPTY
2235 { $$ = xref_tag (current_aggr, $1, 1); }
2236 | named_class_head_sans_basetype_defn
2237 { $<ttype>$ = xref_tag (current_aggr, $1, 0); }
2238 /* Class name is unqualified, so we look for base classes
2239 in the current scope. */
2240 maybe_base_class_list %prec EMPTY
2244 xref_basetypes (current_aggr, $1, $<ttype>2, $3);
2246 | named_complex_class_head_sans_basetype
2248 if ($1 != error_mark_node)
2249 push_scope (CP_DECL_CONTEXT ($1));
2251 maybe_base_class_list
2253 if ($1 != error_mark_node)
2255 pop_scope (CP_DECL_CONTEXT ($1));
2256 $$ = TREE_TYPE ($1);
2257 if (current_aggr == union_type_node
2258 && TREE_CODE ($$) != UNION_TYPE)
2259 cp_pedwarn ("`union' tag used in declaring `%#T'", $$);
2260 else if (TREE_CODE ($$) == UNION_TYPE
2261 && current_aggr != union_type_node)
2262 cp_pedwarn ("non-`union' tag used in declaring `%#T'", $$);
2263 else if (TREE_CODE ($$) == RECORD_TYPE)
2264 /* We might be specializing a template with a different
2266 CLASSTYPE_DECLARED_CLASS ($$) = (current_aggr
2267 == class_type_node);
2270 maybe_process_partial_specialization ($$);
2271 xref_basetypes (current_aggr, $1, $$, $3);
2279 { $$ = xref_tag ($$, make_anon_name (), 0);
2280 yyungetc ('{', 1); }
2288 maybe_base_class_list:
2289 /* empty */ %prec EMPTY
2291 | ':' see_typename %prec EMPTY
2292 { yyungetc(':', 1); $$ = NULL_TREE; }
2293 | ':' see_typename base_class_list %prec EMPTY
2299 | base_class_list ',' see_typename base_class
2300 { $$ = chainon ($$, $4); }
2305 { $$ = finish_base_specifier (access_default_node, $1,
2307 == signature_type_node); }
2308 | base_class_access_list see_typename base_class.1
2309 { $$ = finish_base_specifier ($1, $3,
2311 == signature_type_node); }
2316 { if ($$ != error_mark_node) $$ = TYPE_MAIN_DECL ($1); }
2318 | SIGOF '(' expr ')'
2320 if (current_aggr == signature_type_node)
2322 if (IS_AGGR_TYPE (TREE_TYPE ($3)))
2324 sorry ("`sigof' as base signature specifier");
2325 $$ = TREE_TYPE ($3);
2329 error ("`sigof' applied to non-aggregate expression");
2330 $$ = error_mark_node;
2335 error ("`sigof' in struct or class declaration");
2336 $$ = error_mark_node;
2339 | SIGOF '(' type_id ')'
2341 if (current_aggr == signature_type_node)
2343 if (IS_AGGR_TYPE (groktypename ($3.t)))
2345 sorry ("`sigof' as base signature specifier");
2346 $$ = groktypename ($3.t);
2350 error ("`sigof' applied to non-aggregate expression");
2351 $$ = error_mark_node;
2356 error ("`sigof' in struct or class declaration");
2357 $$ = error_mark_node;
2362 base_class_access_list:
2363 VISSPEC see_typename
2364 | SCSPEC see_typename
2365 { if ($1 != ridpointers[(int)RID_VIRTUAL])
2366 cp_error ("`%D' access", $1);
2367 $$ = access_default_virtual_node; }
2368 | base_class_access_list VISSPEC see_typename
2370 if ($1 != access_default_virtual_node)
2371 error ("multiple access specifiers");
2372 else if ($2 == access_public_node)
2373 $$ = access_public_virtual_node;
2374 else if ($2 == access_protected_node)
2375 $$ = access_protected_virtual_node;
2376 else /* $2 == access_private_node */
2377 $$ = access_private_virtual_node;
2379 | base_class_access_list SCSPEC see_typename
2380 { if ($2 != ridpointers[(int)RID_VIRTUAL])
2381 cp_error ("`%D' access", $2);
2382 else if ($$ == access_public_node)
2383 $$ = access_public_virtual_node;
2384 else if ($$ == access_protected_node)
2385 $$ = access_protected_virtual_node;
2386 else if ($$ == access_private_node)
2387 $$ = access_private_virtual_node;
2389 error ("multiple `virtual' specifiers");
2395 { $<ttype>0 = begin_class_definition ($<ttype>0); }
2398 opt.component_decl_list:
2399 | component_decl_list
2400 | opt.component_decl_list access_specifier component_decl_list
2401 | opt.component_decl_list access_specifier
2407 if (current_aggr == signature_type_node)
2409 error ("access specifier not allowed in signature");
2410 $1 = access_public_node;
2413 current_access_specifier = $1;
2417 /* Note: we no longer warn about the semicolon after a component_decl_list.
2418 ARM $9.2 says that the semicolon is optional, and therefore allowed. */
2419 component_decl_list:
2422 finish_member_declaration ($1);
2424 | component_decl_list component_decl
2426 finish_member_declaration ($2);
2431 component_decl_1 ';'
2432 | component_decl_1 '}'
2433 { error ("missing ';' before right brace");
2434 yyungetc ('}', 0); }
2435 /* C++: handle constructors, destructors and inline functions */
2436 /* note that INLINE is like a TYPESPEC */
2437 | fn.def2 ':' /* base_init compstmt */
2438 { $$ = finish_method ($$); }
2439 | fn.def2 TRY /* base_init compstmt */
2440 { $$ = finish_method ($$); }
2441 | fn.def2 RETURN /* base_init compstmt */
2442 { $$ = finish_method ($$); }
2443 | fn.def2 '{' /* nodecls compstmt */
2444 { $$ = finish_method ($$); }
2447 | extension component_decl
2449 pedantic = $<itype>1; }
2450 | template_header component_decl
2453 $$ = finish_member_template_decl ($2);
2455 /* The component was already processed. */
2458 finish_template_decl ($1);
2460 | template_header typed_declspecs ';'
2462 $$ = finish_member_class_template ($2.t);
2463 finish_template_decl ($1);
2468 /* Do not add a "typed_declspecs declarator" rule here for
2469 speed; we need to call grok_x_components for enums, so the
2470 speedup would be insignificant. */
2471 typed_declspecs components
2473 /* Most of the productions for component_decl only
2474 allow the creation of one new member, so we call
2475 finish_member_declaration in component_decl_list.
2476 For this rule and the next, however, there can be
2477 more than one member, e.g.:
2481 and we need the first member to be fully
2482 registered before the second is processed.
2483 Therefore, the rules for components take care of
2484 this processing. To avoid registering the
2485 components more than once, we send NULL_TREE up
2486 here; that lets finish_member_declaration now
2487 that there is nothing to do. */
2489 grok_x_components ($1.t);
2492 | declmods notype_components
2495 grok_x_components ($1);
2498 | notype_declarator maybeasm maybe_attribute maybe_init
2499 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2500 build_tree_list ($3, NULL_TREE)); }
2501 | constructor_declarator maybeasm maybe_attribute maybe_init
2502 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2503 build_tree_list ($3, NULL_TREE)); }
2504 | ':' expr_no_commas
2505 { $$ = grokbitfield (NULL_TREE, NULL_TREE, $2); }
2509 /* These rules introduce a reduce/reduce conflict; in
2510 typedef int foo, bar;
2514 should "A::foo" be declared as a function or "A::bar" as a data
2515 member? In other words, is "bar" an after_type_declarator or a
2517 | declmods component_constructor_declarator maybeasm maybe_attribute maybe_init
2518 { tree specs, attrs;
2519 split_specs_attrs ($1, &specs, &attrs);
2520 $$ = grokfield ($2, specs, $5, $3,
2521 build_tree_list ($4, attrs)); }
2522 | component_constructor_declarator maybeasm maybe_attribute maybe_init
2523 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2524 build_tree_list ($3, NULL_TREE)); }
2526 { $$ = do_class_using_decl ($1); }
2528 /* The case of exactly one component is handled directly by component_decl. */
2531 /* empty: possibly anonymous */
2533 | component_declarator0
2535 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2536 $1 = finish_member_template_decl ($1);
2537 finish_member_declaration ($1);
2540 | components ',' component_declarator
2542 check_multiple_declarators ();
2543 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2544 $3 = finish_member_template_decl ($3);
2545 finish_member_declaration ($3);
2551 /* empty: possibly anonymous */
2553 | notype_component_declarator0
2555 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2556 $1 = finish_member_template_decl ($1);
2557 finish_member_declaration ($1);
2560 | notype_components ',' notype_component_declarator
2562 check_multiple_declarators ();
2563 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2564 $3 = finish_member_template_decl ($3);
2565 finish_member_declaration ($3);
2570 component_declarator0:
2571 after_type_component_declarator0
2572 | notype_component_declarator0
2575 component_declarator:
2576 after_type_component_declarator
2577 | notype_component_declarator
2580 after_type_component_declarator0:
2581 after_type_declarator maybeasm maybe_attribute maybe_init
2582 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2583 &prefix_attributes);
2584 $<ttype>0 = current_declspecs;
2585 $$ = grokfield ($$, current_declspecs, $4, $2,
2586 build_tree_list ($3, prefix_attributes)); }
2587 | TYPENAME ':' expr_no_commas maybe_attribute
2588 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2589 &prefix_attributes);
2590 $<ttype>0 = current_declspecs;
2591 $$ = grokbitfield ($$, current_declspecs, $3);
2592 cplus_decl_attributes ($$, $4, prefix_attributes); }
2595 notype_component_declarator0:
2596 notype_declarator maybeasm maybe_attribute maybe_init
2597 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2598 &prefix_attributes);
2599 $<ttype>0 = current_declspecs;
2600 $$ = grokfield ($$, current_declspecs, $4, $2,
2601 build_tree_list ($3, prefix_attributes)); }
2602 | constructor_declarator maybeasm maybe_attribute maybe_init
2603 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2604 &prefix_attributes);
2605 $<ttype>0 = current_declspecs;
2606 $$ = grokfield ($$, current_declspecs, $4, $2,
2607 build_tree_list ($3, prefix_attributes)); }
2608 | IDENTIFIER ':' expr_no_commas maybe_attribute
2609 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2610 &prefix_attributes);
2611 $<ttype>0 = current_declspecs;
2612 $$ = grokbitfield ($$, current_declspecs, $3);
2613 cplus_decl_attributes ($$, $4, prefix_attributes); }
2614 | ':' expr_no_commas maybe_attribute
2615 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2616 &prefix_attributes);
2617 $<ttype>0 = current_declspecs;
2618 $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
2619 cplus_decl_attributes ($$, $3, prefix_attributes); }
2622 after_type_component_declarator:
2623 after_type_declarator maybeasm maybe_attribute maybe_init
2624 { $$ = grokfield ($$, current_declspecs, $4, $2,
2625 build_tree_list ($3, prefix_attributes)); }
2626 | TYPENAME ':' expr_no_commas maybe_attribute
2627 { $$ = grokbitfield ($$, current_declspecs, $3);
2628 cplus_decl_attributes ($$, $4, prefix_attributes); }
2631 notype_component_declarator:
2632 notype_declarator maybeasm maybe_attribute maybe_init
2633 { $$ = grokfield ($$, current_declspecs, $4, $2,
2634 build_tree_list ($3, prefix_attributes)); }
2635 | IDENTIFIER ':' expr_no_commas maybe_attribute
2636 { $$ = grokbitfield ($$, current_declspecs, $3);
2637 cplus_decl_attributes ($$, $4, prefix_attributes); }
2638 | ':' expr_no_commas maybe_attribute
2639 { $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
2640 cplus_decl_attributes ($$, $3, prefix_attributes); }
2643 /* We chain the enumerators in reverse order.
2644 Because of the way enums are built, the order is
2645 insignificant. Take advantage of this fact. */
2649 | enumlist ',' enumerator
2650 { TREE_CHAIN ($3) = $$; $$ = $3; }
2655 { $$ = build_enumerator ($$, NULL_TREE, current_enum_type); }
2656 | identifier '=' expr_no_commas
2657 { $$ = build_enumerator ($$, $3, current_enum_type); }
2660 /* ANSI new-type-id (5.3.4) */
2662 type_specifier_seq new_declarator
2663 { $$.t = build_decl_list ($1.t, $2);
2664 $$.new_type_flag = $1.new_type_flag; }
2665 | type_specifier_seq %prec EMPTY
2666 { $$.t = build_decl_list ($1.t, NULL_TREE);
2667 $$.new_type_flag = $1.new_type_flag; }
2668 /* GNU extension to allow arrays of arbitrary types with
2669 non-constant dimension. For the use of begin_new_placement
2670 here, see the comments in unary_expr above. */
2671 | '(' .begin_new_placement type_id .finish_new_placement
2675 pedwarn ("ANSI C++ forbids array dimensions with parenthesized type in new");
2676 $$.t = build_parse_node (ARRAY_REF, TREE_VALUE ($3.t), $6);
2677 $$.t = build_decl_list (TREE_PURPOSE ($3.t), $$.t);
2678 $$.new_type_flag = $3.new_type_flag;
2683 /* empty */ %prec EMPTY
2685 | cv_qualifiers CV_QUALIFIER
2686 { $$ = decl_tree_cons (NULL_TREE, $2, $$); }
2689 nonempty_cv_qualifiers:
2691 { $$.t = IDENTIFIER_AS_LIST ($1);
2692 $$.new_type_flag = 0; }
2693 | nonempty_cv_qualifiers CV_QUALIFIER
2694 { $$.t = decl_tree_cons (NULL_TREE, $2, $1.t);
2695 $$.new_type_flag = $1.new_type_flag; }
2698 /* These rules must follow the rules for function declarations
2699 and component declarations. That way, longer rules are preferred. */
2703 { $<itype>$ = suspend_momentary (); }
2705 /* An expression which will not live on the momentary obstack. */
2708 { resume_momentary ((int) $<itype>1); $$ = $2; }
2711 /* An expression which will not live on the momentary obstack. */
2713 suspend_mom '(' nonnull_exprlist ')'
2714 { resume_momentary ((int) $<itype>1); $$ = $3; }
2715 | suspend_mom '(' parmlist ')'
2716 { resume_momentary ((int) $<itype>1); $$ = $3; }
2717 | suspend_mom LEFT_RIGHT
2718 { resume_momentary ((int) $<itype>1); $$ = empty_parms (); }
2719 | suspend_mom '(' error ')'
2720 { resume_momentary ((int) $<itype>1); $$ = NULL_TREE; }
2723 /* A declarator that is allowed only after an explicit typespec. */
2724 /* may all be followed by prec '.' */
2725 after_type_declarator:
2726 '*' nonempty_cv_qualifiers after_type_declarator %prec UNARY
2727 { $$ = make_pointer_declarator ($2.t, $3); }
2728 | '&' nonempty_cv_qualifiers after_type_declarator %prec UNARY
2729 { $$ = make_reference_declarator ($2.t, $3); }
2730 | '*' after_type_declarator %prec UNARY
2731 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2732 | '&' after_type_declarator %prec UNARY
2733 { $$ = make_reference_declarator (NULL_TREE, $2); }
2734 | ptr_to_mem cv_qualifiers after_type_declarator
2735 { tree arg = make_pointer_declarator ($2, $3);
2736 $$ = build_parse_node (SCOPE_REF, $1, arg);
2738 | direct_after_type_declarator
2742 type_name %prec EMPTY
2744 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2746 $$ = lookup_name ($1, 1);
2747 if (current_class_type
2748 && TYPE_BEING_DEFINED (current_class_type)
2749 && ! IDENTIFIER_CLASS_VALUE ($1))
2751 /* Remember that this name has been used in the class
2752 definition, as per [class.scope0] */
2753 pushdecl_class_level ($$);
2759 | global_scope type_name
2761 if (TREE_CODE ($2) == IDENTIFIER_NODE)
2762 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
2765 got_scope = NULL_TREE;
2772 | global_scope nested_type
2777 nested_name_specifier type_name %prec EMPTY
2778 { $$ = get_type_decl ($2); }
2781 direct_after_type_declarator:
2782 direct_after_type_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2783 { $$ = make_call_declarator ($$, $2, $3, $4); }
2784 | direct_after_type_declarator '[' nonmomentary_expr ']'
2785 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
2786 | direct_after_type_declarator '[' ']'
2787 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
2788 | '(' after_type_declarator ')'
2790 | nested_name_specifier type_name %prec EMPTY
2791 { push_nested_class ($1, 3);
2792 $$ = build_parse_node (SCOPE_REF, $$, $2);
2793 TREE_COMPLEXITY ($$) = current_class_depth; }
2794 | type_name %prec EMPTY
2797 /* A declarator allowed whether or not there has been
2798 an explicit typespec. These cannot redeclare a typedef-name. */
2800 notype_declarator_intern:
2802 | attributes notype_declarator
2804 /* Provide support for '(' attributes '*' declarator ')'
2806 $$ = decl_tree_cons ($1, $2, NULL_TREE);
2811 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2812 { $$ = make_pointer_declarator ($2.t, $3); }
2813 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2814 { $$ = make_reference_declarator ($2.t, $3); }
2815 | '*' notype_declarator_intern %prec UNARY
2816 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2817 | '&' notype_declarator_intern %prec UNARY
2818 { $$ = make_reference_declarator (NULL_TREE, $2); }
2819 | ptr_to_mem cv_qualifiers notype_declarator_intern
2820 { tree arg = make_pointer_declarator ($2, $3);
2821 $$ = build_parse_node (SCOPE_REF, $1, arg);
2823 | direct_notype_declarator
2826 complex_notype_declarator:
2827 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2828 { $$ = make_pointer_declarator ($2.t, $3); }
2829 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2830 { $$ = make_reference_declarator ($2.t, $3); }
2831 | '*' complex_notype_declarator %prec UNARY
2832 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2833 | '&' complex_notype_declarator %prec UNARY
2834 { $$ = make_reference_declarator (NULL_TREE, $2); }
2835 | ptr_to_mem cv_qualifiers notype_declarator_intern
2836 { tree arg = make_pointer_declarator ($2, $3);
2837 $$ = build_parse_node (SCOPE_REF, $1, arg);
2839 | complex_direct_notype_declarator
2842 complex_direct_notype_declarator:
2843 direct_notype_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2844 { $$ = make_call_declarator ($$, $2, $3, $4); }
2845 | '(' complex_notype_declarator ')'
2847 | direct_notype_declarator '[' nonmomentary_expr ']'
2848 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
2849 | direct_notype_declarator '[' ']'
2850 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
2851 | notype_qualified_id
2852 { enter_scope_of ($1); }
2853 | nested_name_specifier notype_template_declarator
2854 { got_scope = NULL_TREE;
2855 $$ = build_parse_node (SCOPE_REF, $1, $2);
2856 enter_scope_of ($$);
2861 nested_name_specifier unqualified_id
2862 { got_scope = NULL_TREE;
2863 $$ = build_parse_node (SCOPE_REF, $$, $2); }
2864 | nested_name_specifier object_template_id
2865 { got_scope = NULL_TREE;
2866 $$ = build_parse_node (SCOPE_REF, $1, $2); }
2869 notype_qualified_id:
2870 nested_name_specifier notype_unqualified_id
2871 { got_scope = NULL_TREE;
2872 $$ = build_parse_node (SCOPE_REF, $$, $2); }
2873 | nested_name_specifier object_template_id
2874 { got_scope = NULL_TREE;
2875 $$ = build_parse_node (SCOPE_REF, $1, $2); }
2880 | global_scope notype_qualified_id
2885 typespec '(' nonnull_exprlist ')'
2886 { $$ = build_functional_cast ($1.t, $3); }
2887 | typespec '(' expr_or_declarator_intern ')'
2888 { $$ = reparse_decl_as_expr ($1.t, $3); }
2889 | typespec fcast_or_absdcl %prec EMPTY
2890 { $$ = reparse_absdcl_as_expr ($1.t, $2); }
2895 | template_type %prec EMPTY
2898 nested_name_specifier:
2899 nested_name_specifier_1
2900 | nested_name_specifier nested_name_specifier_1
2902 | nested_name_specifier TEMPLATE explicit_template_type SCOPE
2903 { got_scope = $$ = make_typename_type ($1, $3); }
2906 /* Why the @#$%^& do type_name and notype_identifier need to be expanded
2907 inline here?!? (jason) */
2908 nested_name_specifier_1:
2911 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2914 /* Remember that this name has been used in the class
2915 definition, as per [class.scope0] */
2916 if (current_class_type
2917 && TYPE_BEING_DEFINED (current_class_type)
2918 && ! IDENTIFIER_CLASS_VALUE ($1))
2919 pushdecl_class_level ($$);
2921 got_scope = $$ = TYPE_MAIN_VARIANT (TREE_TYPE ($$));
2925 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2927 got_scope = $$ = TREE_TYPE ($$);
2931 if (TREE_CODE ($$) == IDENTIFIER_NODE)
2935 | template_type SCOPE
2936 { got_scope = $$ = complete_type (TREE_TYPE ($1)); }
2937 /* These break 'const i;'
2941 cp_error ("`%D' is not an aggregate typedef",
2942 lastiddecl ? lastiddecl : $$);
2943 $$ = error_mark_node;
2946 { goto failed_scope; } */
2951 | global_scope typename_sub0
2956 typename_sub1 identifier %prec EMPTY
2958 if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't')
2959 $$ = make_typename_type ($1, $2);
2960 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
2961 cp_error ("`%T' is not a class or namespace", $2);
2965 if (TREE_CODE ($$) == TYPE_DECL)
2966 $$ = TREE_TYPE ($$);
2969 | typename_sub1 template_type %prec EMPTY
2970 { $$ = TREE_TYPE ($2); }
2971 | typename_sub1 explicit_template_type %prec EMPTY
2972 { $$ = make_typename_type ($1, $2); }
2973 | typename_sub1 TEMPLATE explicit_template_type %prec EMPTY
2974 { $$ = make_typename_type ($1, $3); }
2980 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2981 cp_error ("`%T' is not a class or namespace", $1);
2983 | typename_sub1 typename_sub2
2985 if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't')
2986 $$ = make_typename_type ($1, $2);
2987 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
2988 cp_error ("`%T' is not a class or namespace", $2);
2992 if (TREE_CODE ($$) == TYPE_DECL)
2993 $$ = TREE_TYPE ($$);
2996 | typename_sub1 explicit_template_type SCOPE
2997 { got_scope = $$ = make_typename_type ($1, $2); }
2998 | typename_sub1 TEMPLATE explicit_template_type SCOPE
2999 { got_scope = $$ = make_typename_type ($1, $3); }
3005 if (TREE_CODE ($1) != IDENTIFIER_NODE)
3008 /* Retrieve the type for the identifier, which might involve
3009 some computation. */
3010 got_scope = $$ = complete_type (IDENTIFIER_TYPE_VALUE ($1));
3012 if ($$ == error_mark_node)
3013 cp_error ("`%T' is not a class or namespace", $1);
3017 if (TREE_CODE ($1) != IDENTIFIER_NODE)
3019 got_scope = $$ = complete_type (TREE_TYPE ($$));
3021 | template_type SCOPE
3022 { got_scope = $$ = complete_type (TREE_TYPE ($$)); }
3027 if (TREE_CODE ($$) == IDENTIFIER_NODE)
3033 explicit_template_type:
3034 identifier '<' template_arg_list_opt template_close_bracket
3035 { $$ = build_min_nt (TEMPLATE_ID_EXPR, $1, $3); }
3039 global_scope type_name
3041 if (TREE_CODE ($2) == IDENTIFIER_NODE)
3042 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
3045 got_scope = NULL_TREE;
3048 | global_scope nested_type
3053 nested_name_specifier '*'
3054 { got_scope = NULL_TREE; }
3055 | global_scope nested_name_specifier '*'
3056 { $$ = $2; got_scope = NULL_TREE; }
3059 /* All uses of explicit global scope must go through this nonterminal so
3060 that got_scope will be set before yylex is called to get the next token. */
3063 { got_scope = void_type_node; }
3066 /* ANSI new-declarator (5.3.4) */
3068 '*' cv_qualifiers new_declarator
3069 { $$ = make_pointer_declarator ($2, $3); }
3070 | '*' cv_qualifiers %prec EMPTY
3071 { $$ = make_pointer_declarator ($2, NULL_TREE); }
3072 | '&' cv_qualifiers new_declarator %prec EMPTY
3073 { $$ = make_reference_declarator ($2, $3); }
3074 | '&' cv_qualifiers %prec EMPTY
3075 { $$ = make_reference_declarator ($2, NULL_TREE); }
3076 | ptr_to_mem cv_qualifiers %prec EMPTY
3077 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3078 $$ = build_parse_node (SCOPE_REF, $1, arg);
3080 | ptr_to_mem cv_qualifiers new_declarator
3081 { tree arg = make_pointer_declarator ($2, $3);
3082 $$ = build_parse_node (SCOPE_REF, $1, arg);
3084 | direct_new_declarator %prec EMPTY
3087 /* ANSI direct-new-declarator (5.3.4) */
3088 direct_new_declarator:
3090 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3091 | direct_new_declarator '[' nonmomentary_expr ']'
3092 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3095 /* ANSI abstract-declarator (8.1) */
3097 '*' nonempty_cv_qualifiers absdcl
3098 { $$ = make_pointer_declarator ($2.t, $3); }
3100 { $$ = make_pointer_declarator (NULL_TREE, $2); }
3101 | '*' nonempty_cv_qualifiers %prec EMPTY
3102 { $$ = make_pointer_declarator ($2.t, NULL_TREE); }
3104 { $$ = make_pointer_declarator (NULL_TREE, NULL_TREE); }
3105 | '&' nonempty_cv_qualifiers absdcl
3106 { $$ = make_reference_declarator ($2.t, $3); }
3108 { $$ = make_reference_declarator (NULL_TREE, $2); }
3109 | '&' nonempty_cv_qualifiers %prec EMPTY
3110 { $$ = make_reference_declarator ($2.t, NULL_TREE); }
3112 { $$ = make_reference_declarator (NULL_TREE, 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 absdcl
3118 { tree arg = make_pointer_declarator ($2, $3);
3119 $$ = build_parse_node (SCOPE_REF, $1, arg);
3121 | direct_abstract_declarator %prec EMPTY
3124 /* ANSI direct-abstract-declarator (8.1) */
3125 direct_abstract_declarator:
3128 /* `(typedef)1' is `int'. */
3130 | direct_abstract_declarator '(' parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3131 { $$ = make_call_declarator ($$, $3, $5, $6); }
3132 | direct_abstract_declarator LEFT_RIGHT cv_qualifiers exception_specification_opt %prec '.'
3133 { $$ = make_call_declarator ($$, empty_parms (), $3, $4); }
3134 | direct_abstract_declarator '[' nonmomentary_expr ']' %prec '.'
3135 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3136 | direct_abstract_declarator '[' ']' %prec '.'
3137 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
3138 | '(' complex_parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3139 { $$ = make_call_declarator (NULL_TREE, $2, $4, $5); }
3140 | regcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3141 { set_quals_and_spec ($$, $2, $3); }
3142 | fcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3143 { set_quals_and_spec ($$, $2, $3); }
3144 | '[' nonmomentary_expr ']' %prec '.'
3145 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3147 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, NULL_TREE); }
3150 /* For C++, decls and stmts can be intermixed, so we don't need to
3151 have a special rule that won't start parsing the stmt section
3152 until we have a stmt that parses without errors. */
3165 /* Read zero or more forward-declarations for labels
3166 that nested functions can jump to. */
3171 pedwarn ("ANSI C++ forbids label declarations"); }
3176 | label_decls label_decl
3180 LABEL identifiers_or_typenames ';'
3182 for (link = $2; link; link = TREE_CHAIN (link))
3184 tree label = shadow_label (TREE_VALUE (link));
3185 C_DECLARED_LABEL_FLAG (label) = 1;
3186 declare_nonlocal_label (label);
3191 /* This is the body of a function definition.
3192 It causes syntax errors to ignore to the next openbrace. */
3201 { $<ttype>$ = begin_compound_stmt (0); }
3203 { $$ = finish_compound_stmt (0, $<ttype>2); }
3209 $<ttype>$ = begin_if_stmt ();
3210 cond_stmt_keyword = "if";
3213 { finish_if_stmt_cond ($3, $<ttype>2); }
3214 implicitly_scoped_stmt
3215 { $<ttype>$ = finish_then_clause ($<ttype>2); }
3218 implicitly_scoped_stmt:
3220 | { $<ttype>$ = begin_compound_stmt (0); }
3222 { $$ = finish_compound_stmt (0, $<ttype>1); }
3235 { finish_expr_stmt ($1); }
3237 { begin_else_clause (); }
3238 implicitly_scoped_stmt
3240 finish_else_clause ($<ttype>1);
3243 | simple_if %prec IF
3244 { finish_if_stmt (); }
3247 $<ttype>$ = begin_while_stmt ();
3248 cond_stmt_keyword = "while";
3251 { finish_while_stmt_cond ($3, $<ttype>2); }
3253 { finish_while_stmt ($<ttype>2); }
3255 { $<ttype>$ = begin_do_stmt (); }
3256 implicitly_scoped_stmt WHILE
3258 finish_do_body ($<ttype>2);
3259 cond_stmt_keyword = "do";
3261 paren_expr_or_null ';'
3262 { finish_do_stmt ($6, $<ttype>2); }
3264 { $<ttype>$ = begin_for_stmt (); }
3265 '(' for.init.statement
3266 { finish_for_init_stmt ($<ttype>2); }
3268 { finish_for_cond ($6, $<ttype>2); }
3270 { finish_for_expr ($9, $<ttype>2); }
3272 { finish_for_stmt ($9, $<ttype>2); }
3274 { begin_switch_stmt (); }
3276 { $<ttype>$ = finish_switch_cond ($4); }
3277 implicitly_scoped_stmt
3278 { finish_switch_stmt ($4, $<ttype>6); }
3279 | CASE expr_no_commas ':'
3280 { finish_case_label ($2, NULL_TREE); }
3282 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
3283 { finish_case_label ($2, $4); }
3286 { finish_case_label (NULL_TREE, NULL_TREE); }
3289 { finish_break_stmt (); }
3291 { finish_continue_stmt (); }
3293 { finish_return_stmt (NULL_TREE); }
3295 { finish_return_stmt ($2); }
3296 | asm_keyword maybe_cv_qualifier '(' string ')' ';'
3298 finish_asm_stmt ($2, $4, NULL_TREE, NULL_TREE,
3301 /* This is the case with just output operands. */
3302 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ')' ';'
3304 finish_asm_stmt ($2, $4, $6, NULL_TREE,
3307 /* This is the case with input operands as well. */
3308 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':' asm_operands ')' ';'
3309 { finish_asm_stmt ($2, $4, $6, $8, NULL_TREE); }
3310 /* This is the case with clobbered registers as well. */
3311 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':'
3312 asm_operands ':' asm_clobbers ')' ';'
3313 { finish_asm_stmt ($2, $4, $6, $8, $10); }
3317 pedwarn ("ANSI C++ forbids computed gotos");
3318 finish_goto_stmt ($3);
3320 | GOTO identifier ';'
3321 { finish_goto_stmt ($2); }
3325 { error ("label must be followed by statement");
3332 | namespace_using_decl
3333 { do_local_using_decl ($1); }
3340 if (! current_function_parms_stored)
3341 store_parm_decls ();
3342 expand_start_early_try_stmts ();
3344 ctor_initializer_opt compstmt
3346 expand_start_all_catch ();
3350 expand_end_all_catch ();
3357 { $<ttype>$ = begin_try_block (); }
3359 { finish_try_block ($<ttype>2); }
3361 { finish_handler_sequence ($<ttype>2); }
3366 | handler_seq handler
3371 { $<ttype>$ = begin_handler(); }
3373 { finish_handler_parms ($<ttype>2); }
3375 { finish_handler ($<ttype>2); }
3379 typed_typespecs %prec EMPTY
3380 | nonempty_cv_qualifiers %prec EMPTY
3385 { expand_start_catch_block (NULL_TREE, NULL_TREE); }
3386 /* This doesn't allow reference parameters, the below does.
3387 | '(' type_specifier_seq absdcl ')'
3388 { check_for_new_type ("inside exception declarations", $2);
3389 expand_start_catch_block ($2.t, $3); }
3390 | '(' type_specifier_seq ')'
3391 { check_for_new_type ("inside exception declarations", $2);
3392 expand_start_catch_block ($2.t, NULL_TREE); }
3393 | '(' type_specifier_seq notype_declarator ')'
3394 { check_for_new_type ("inside exception declarations", $2);
3395 expand_start_catch_block ($2.t, $3); }
3396 | '(' typed_typespecs after_type_declarator ')'
3397 { check_for_new_type ("inside exception declarations", $2);
3398 expand_start_catch_block ($2.t, $3); }
3399 This allows reference parameters... */
3401 { check_for_new_type ("inside exception declarations", $2);
3402 expand_start_catch_block (TREE_PURPOSE ($2.t),
3403 TREE_VALUE ($2.t)); }
3410 label = define_label (input_filename, lineno, $1);
3411 if (label && ! minimal_parse_mode)
3412 expand_label (label);
3424 { if ($1) cplus_expand_expr_stmt ($1); }
3428 pedwarn ("ANSI C++ forbids compound statements inside for initializations");
3432 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
3436 { emit_line_note (input_filename, lineno);
3439 { emit_line_note (input_filename, lineno); }
3450 /* These are the operands other than the first string and colon
3451 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
3455 | nonnull_asm_operands
3458 nonnull_asm_operands:
3460 | nonnull_asm_operands ',' asm_operand
3461 { $$ = chainon ($$, $3); }
3466 { $$ = build_tree_list ($$, $3); }
3471 { $$ = tree_cons (NULL_TREE, $$, NULL_TREE); }
3472 | asm_clobbers ',' STRING
3473 { $$ = tree_cons (NULL_TREE, $3, $$); }
3476 /* This is what appears inside the parens in a function declarator.
3477 Its value is represented in the format that grokdeclarator expects.
3479 In C++, declaring a function with no parameters
3480 means that that function takes *no* parameters. */
3489 { $$ = finish_parmlist (build_tree_list (NULL_TREE, $1.t), 0);
3490 check_for_new_type ("inside parameter list", $1); }
3493 /* This nonterminal does not include the common sequence '(' type_id ')',
3494 as it is ambiguous and must be disambiguated elsewhere. */
3497 { $$ = finish_parmlist ($$, 0); }
3498 | parms_comma ELLIPSIS
3499 { $$ = finish_parmlist ($1, 1); }
3500 /* C++ allows an ellipsis without a separating ',' */
3502 { $$ = finish_parmlist ($1, 1); }
3504 { $$ = finish_parmlist (build_tree_list (NULL_TREE,
3507 { $$ = finish_parmlist (NULL_TREE, 1); }
3510 /* This helps us recover from really nasty
3511 parse errors, for example, a missing right
3513 yyerror ("possibly missing ')'");
3514 $$ = finish_parmlist ($1, 0);
3520 /* This helps us recover from really nasty
3521 parse errors, for example, a missing right
3523 yyerror ("possibly missing ')'");
3524 $$ = finish_parmlist (build_tree_list (NULL_TREE,
3531 /* A default argument to a */
3534 { maybe_snarf_defarg (); }
3544 /* A nonempty list of parameter declarations or type names. */
3547 { check_for_new_type ("in a parameter list", $1);
3548 $$ = build_tree_list (NULL_TREE, $1.t); }
3550 { check_for_new_type ("in a parameter list", $1);
3551 $$ = build_tree_list ($2, $1.t); }
3552 | parms_comma full_parm
3553 { check_for_new_type ("in a parameter list", $2);
3554 $$ = chainon ($$, $2.t); }
3555 | parms_comma bad_parm
3556 { $$ = chainon ($$, build_tree_list (NULL_TREE, $2)); }
3557 | parms_comma bad_parm '=' init
3558 { $$ = chainon ($$, build_tree_list ($4, $2)); }
3564 { check_for_new_type ("in a parameter list", $1);
3565 $$ = build_tree_list (NULL_TREE, $1.t); }
3568 /* A single parameter declaration or parameter type name,
3569 as found in a parmlist. */
3571 /* Here we expand typed_declspecs inline to avoid mis-parsing of
3572 TYPESPEC IDENTIFIER. */
3573 typed_declspecs1 declarator
3574 { tree specs = strip_attrs ($1.t);
3575 $$.new_type_flag = $1.new_type_flag;
3576 $$.t = build_tree_list (specs, $2); }
3577 | typed_typespecs declarator
3578 { $$.t = build_tree_list ($1.t, $2);
3579 $$.new_type_flag = $1.new_type_flag; }
3580 | typespec declarator
3581 { $$.t = build_tree_list (get_decl_list ($1.t), $2);
3582 $$.new_type_flag = $1.new_type_flag; }
3583 | typed_declspecs1 absdcl
3584 { tree specs = strip_attrs ($1.t);
3585 $$.t = build_tree_list (specs, $2);
3586 $$.new_type_flag = $1.new_type_flag; }
3587 | typed_declspecs1 %prec EMPTY
3588 { tree specs = strip_attrs ($1.t);
3589 $$.t = build_tree_list (specs, NULL_TREE);
3590 $$.new_type_flag = $1.new_type_flag; }
3591 | declmods notype_declarator
3592 { tree specs = strip_attrs ($1);
3593 $$.t = build_tree_list (specs, $2);
3594 $$.new_type_flag = 0; }
3599 { $$.t = build_tree_list (NULL_TREE, $1.t);
3600 $$.new_type_flag = $1.new_type_flag; }
3602 { $$.t = build_tree_list ($2, $1.t);
3603 $$.new_type_flag = $1.new_type_flag; }
3612 /* empty */ %prec EMPTY
3613 { see_typename (); }
3617 /* empty */ %prec EMPTY
3619 error ("type specifier omitted for parameter");
3620 $$ = build_tree_list (integer_type_node, NULL_TREE);
3624 error ("type specifier omitted for parameter");
3625 if (TREE_CODE ($$) == SCOPE_REF
3626 && (TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TYPE_PARM
3627 || TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TEMPLATE_PARM))
3628 cp_error (" perhaps you want `typename %E' to make it a type", $$);
3629 $$ = build_tree_list (integer_type_node, $$);
3633 exception_specification_opt:
3634 /* empty */ %prec EMPTY
3636 | THROW '(' ansi_raise_identifiers ')' %prec EMPTY
3638 | THROW LEFT_RIGHT %prec EMPTY
3639 { $$ = build_decl_list (NULL_TREE, NULL_TREE); }
3642 ansi_raise_identifier:
3644 { $$ = build_decl_list (NULL_TREE, groktypename($1.t)); }
3647 ansi_raise_identifiers:
3648 ansi_raise_identifier
3649 | ansi_raise_identifiers ',' ansi_raise_identifier
3651 TREE_CHAIN ($3) = $$;
3656 conversion_declarator:
3657 /* empty */ %prec EMPTY
3659 | '*' cv_qualifiers conversion_declarator
3660 { $$ = make_pointer_declarator ($2, $3); }
3661 | '&' cv_qualifiers conversion_declarator
3662 { $$ = make_reference_declarator ($2, $3); }
3663 | ptr_to_mem cv_qualifiers conversion_declarator
3664 { tree arg = make_pointer_declarator ($2, $3);
3665 $$ = build_parse_node (SCOPE_REF, $1, arg);
3671 { got_scope = NULL_TREE; }
3676 { $$ = ansi_opname[MULT_EXPR]; }
3678 { $$ = ansi_opname[TRUNC_DIV_EXPR]; }
3680 { $$ = ansi_opname[TRUNC_MOD_EXPR]; }
3682 { $$ = ansi_opname[PLUS_EXPR]; }
3684 { $$ = ansi_opname[MINUS_EXPR]; }
3686 { $$ = ansi_opname[BIT_AND_EXPR]; }
3688 { $$ = ansi_opname[BIT_IOR_EXPR]; }
3690 { $$ = ansi_opname[BIT_XOR_EXPR]; }
3692 { $$ = ansi_opname[BIT_NOT_EXPR]; }
3694 { $$ = ansi_opname[COMPOUND_EXPR]; }
3695 | operator ARITHCOMPARE
3696 { $$ = ansi_opname[$2]; }
3698 { $$ = ansi_opname[LT_EXPR]; }
3700 { $$ = ansi_opname[GT_EXPR]; }
3701 | operator EQCOMPARE
3702 { $$ = ansi_opname[$2]; }
3704 { $$ = ansi_assopname[$2]; }
3706 { $$ = ansi_opname [MODIFY_EXPR]; }
3708 { $$ = ansi_opname[$2]; }
3710 { $$ = ansi_opname[$2]; }
3712 { $$ = ansi_opname[POSTINCREMENT_EXPR]; }
3713 | operator MINUSMINUS
3714 { $$ = ansi_opname[PREDECREMENT_EXPR]; }
3716 { $$ = ansi_opname[TRUTH_ANDIF_EXPR]; }
3718 { $$ = ansi_opname[TRUTH_ORIF_EXPR]; }
3720 { $$ = ansi_opname[TRUTH_NOT_EXPR]; }
3722 { $$ = ansi_opname[COND_EXPR]; }
3724 { $$ = ansi_opname[$2]; }
3725 | operator POINTSAT %prec EMPTY
3726 { $$ = ansi_opname[COMPONENT_REF]; }
3727 | operator POINTSAT_STAR %prec EMPTY
3728 { $$ = ansi_opname[MEMBER_REF]; }
3729 | operator LEFT_RIGHT
3730 { $$ = ansi_opname[CALL_EXPR]; }
3732 { $$ = ansi_opname[ARRAY_REF]; }
3733 | operator NEW %prec EMPTY
3734 { $$ = ansi_opname[NEW_EXPR]; }
3735 | operator DELETE %prec EMPTY
3736 { $$ = ansi_opname[DELETE_EXPR]; }
3737 | operator NEW '[' ']'
3738 { $$ = ansi_opname[VEC_NEW_EXPR]; }
3739 | operator DELETE '[' ']'
3740 { $$ = ansi_opname[VEC_DELETE_EXPR]; }
3741 /* Names here should be looked up in class scope ALSO. */
3742 | operator type_specifier_seq conversion_declarator
3743 { $$ = grokoptypename ($2.t, $3); }
3745 { $$ = ansi_opname[ERROR_MARK]; }
3752 debug_yytranslate (value)
3755 return yytname[YYTRANSLATE (value)];