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 struct obstack permanent_obstack;
52 extern int end_of_file;
54 /* Like YYERROR but do call yyerror. */
55 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
57 #define OP0(NODE) (TREE_OPERAND (NODE, 0))
58 #define OP1(NODE) (TREE_OPERAND (NODE, 1))
60 /* Contains the statement keyword (if/while/do) to include in an
61 error message if the user supplies an empty conditional expression. */
62 static const char *cond_stmt_keyword;
64 static tree empty_parms PROTO((void));
65 static int parse_decl PROTO((tree, tree, tree, int, tree *));
67 /* Nonzero if we have an `extern "C"' acting as an extern specifier. */
71 /* Cons up an empty parameter list. */
81 || current_class_type != NULL)
82 parms = void_list_node;
92 %union {long itype; tree ttype; char *strtype; enum tree_code code; flagged_type_tree ftype; }
94 /* All identifiers that are not reserved words
95 and are not declared typedefs in the current block */
98 /* All identifiers that are declared typedefs in the current block.
99 In some contexts, they are treated just like IDENTIFIER,
100 but they can also serve as typespecs in declarations. */
104 /* A template function. */
107 /* Reserved words that specify storage class.
108 yylval contains an IDENTIFIER_NODE which indicates which one. */
111 /* Reserved words that specify type.
112 yylval contains an IDENTIFIER_NODE which indicates which one. */
115 /* Reserved words that qualify type: "const" or "volatile".
116 yylval contains an IDENTIFIER_NODE which indicates which one. */
119 /* Character or numeric constants.
120 yylval is the node for the constant. */
123 /* String constants in raw form.
124 yylval is a STRING_CST node. */
127 /* "...", used for functions with variable arglists. */
130 /* the reserved words */
131 /* SCO include files test "ASM", so use something else. */
132 %token SIZEOF ENUM /* STRUCT UNION */ IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
133 %token BREAK CONTINUE RETURN_KEYWORD GOTO ASM_KEYWORD TYPEOF ALIGNOF
135 %token ATTRIBUTE EXTENSION LABEL
136 %token REALPART IMAGPART VA_ARG
138 /* the reserved words... C++ extensions */
140 %token <ttype> VISSPEC
141 %token DELETE NEW THIS OPERATOR CXX_TRUE CXX_FALSE
142 %token NAMESPACE TYPENAME_KEYWORD USING
143 %token LEFT_RIGHT TEMPLATE
144 %token TYPEID DYNAMIC_CAST STATIC_CAST REINTERPRET_CAST CONST_CAST
147 /* Define the operator tokens and their precedences.
148 The value is an integer because, if used, it is the tree code
149 to use in the expression made from the operator. */
151 %left EMPTY /* used to resolve s/r with epsilon */
155 /* Add precedence rules to solve dangling else s/r conflict */
159 %left IDENTIFIER PFUNCNAME TYPENAME SELFNAME PTYPENAME SCSPEC TYPESPEC CV_QUALIFIER ENUM AGGR ELLIPSIS TYPEOF SIGOF OPERATOR NSNAME TYPENAME_KEYWORD
165 %right <code> ASSIGN '='
173 %left <code> EQCOMPARE
174 %left <code> ARITHCOMPARE '<' '>'
175 %left <code> LSHIFT RSHIFT
177 %left <code> '*' '/' '%'
178 %left <code> POINTSAT_STAR DOT_STAR
179 %right <code> UNARY PLUSPLUS MINUSMINUS '~'
181 %left <ttype> LEFT_RIGHT
182 %left <code> POINTSAT '.' '(' '['
184 %right SCOPE /* C++ extension */
185 %nonassoc NEW DELETE TRY CATCH
189 %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist
190 %type <ttype> PFUNCNAME maybe_identifier
191 %type <ttype> paren_expr_or_null nontrivial_exprlist SELFNAME
192 %type <ttype> expr_no_commas cast_expr unary_expr primary string STRING
193 %type <ttype> reserved_declspecs boolean.literal
194 %type <ttype> reserved_typespecquals
195 %type <ttype> declmods
196 %type <ttype> SCSPEC TYPESPEC CV_QUALIFIER maybe_cv_qualifier
197 %type <itype> initdecls notype_initdecls initdcl /* C++ modification */
198 %type <ttype> init initlist maybeasm maybe_init defarg defarg1
199 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
200 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
201 %type <ttype> any_word
203 %type <ttype> compstmt implicitly_scoped_stmt
205 %type <ttype> declarator notype_declarator after_type_declarator
206 %type <ttype> notype_declarator_intern absdcl_intern
207 %type <ttype> after_type_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_sans_basetype
242 %type <ftype> class_head named_class_head
243 %type <ftype> named_complex_class_head_sans_basetype
244 %type <ttype> unnamed_class_head
245 %type <ttype> base_class_list
246 %type <ttype> base_class_access_list
247 %type <ttype> base_class maybe_base_class_list base_class.1
248 %type <ttype> exception_specification_opt ansi_raise_identifier ansi_raise_identifiers
249 %type <ttype> operator_name
250 %type <ttype> object aggr
251 %type <itype> new delete .begin_new_placement
252 /* %type <ttype> primary_no_id */
253 %type <ttype> nonmomentary_expr maybe_parmlist
254 %type <itype> initdcl0 notype_initdcl0 member_init_list initdcl0_innards
255 %type <ttype> template_header template_parm_list template_parm
256 %type <ttype> template_type_parm template_template_parm
257 %type <code> template_close_bracket
258 %type <ttype> apparent_template_type
259 %type <ttype> template_type template_arg_list template_arg_list_opt
260 %type <ttype> template_arg
261 %type <ttype> condition xcond paren_cond_or_null
262 %type <ttype> type_name nested_name_specifier nested_type ptr_to_mem
263 %type <ttype> complete_type_name notype_identifier nonnested_type
264 %type <ttype> complex_type_name nested_name_specifier_1
265 %type <ttype> new_initializer new_placement
266 %type <ttype> using_decl
267 %type <ttype> typename_sub typename_sub0 typename_sub1 typename_sub2
268 %type <ttype> explicit_template_type
269 /* in order to recognize aggr tags as defining and thus shadowing. */
270 %token TYPENAME_DEFN IDENTIFIER_DEFN PTYPENAME_DEFN
271 %type <ttype> named_class_head_sans_basetype_defn
272 %type <ttype> identifier_defn IDENTIFIER_DEFN TYPENAME_DEFN PTYPENAME_DEFN
274 %type <ttype> self_template_type .finish_template_type
279 /* Used in lex.c for parsing pragmas. */
282 /* lex.c and pt.c depend on this being the last token. Define
283 any new tokens before this one! */
284 %token END_OF_SAVED_INPUT
287 /* List of types and structure classes of the current declaration. */
288 static tree current_declspecs;
290 /* List of prefix attributes in effect.
291 Prefix attributes are parsed by the reserved_declspecs and declmods
292 rules. They create a list that contains *both* declspecs and attrs. */
293 /* ??? It is not clear yet that all cases where an attribute can now appear in
294 a declspec list have been updated. */
295 static tree prefix_attributes;
297 /* When defining an aggregate, this is the kind of the most recent one
298 being defined. (For example, this might be class_type_node.) */
299 static tree current_aggr;
301 /* When defining an enumeration, this is the type of the enumeration. */
302 static tree current_enum_type;
304 /* Tell yyparse how to print a token's value, if yydebug is set. */
306 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
307 extern void yyprint PROTO((FILE *, int, YYSTYPE));
308 extern tree combine_strings PROTO((tree));
311 parse_decl(declarator, specs_attrs, attributes, initialized, decl)
320 split_specs_attrs (specs_attrs, ¤t_declspecs, &prefix_attributes);
321 if (current_declspecs
322 && TREE_CODE (current_declspecs) != TREE_LIST)
323 current_declspecs = build_decl_list (NULL_TREE, current_declspecs);
324 if (have_extern_spec && !used_extern_spec)
326 current_declspecs = decl_tree_cons (NULL_TREE,
327 get_identifier ("extern"),
329 used_extern_spec = 1;
331 sm = suspend_momentary ();
332 *decl = start_decl (declarator, current_declspecs, initialized,
333 attributes, prefix_attributes);
342 { finish_translation_unit (); }
345 /* the reason for the strange actions in this rule
346 is so that notype_initdecls when reached via datadef
347 can find a valid list of type and sc specs in $0. */
350 { $<ttype>$ = NULL_TREE; }
352 { $<ttype>$ = NULL_TREE; }
353 | extdefs lang_extdef
354 { $<ttype>$ = NULL_TREE; }
363 { have_extern_spec = 1;
364 used_extern_spec = 0;
365 $<ttype>$ = NULL_TREE; }
368 { have_extern_spec = 0; }
373 { $<itype>$ = pedantic;
382 { if (pending_lang_change) do_pending_lang_change(); }
384 { if (! toplevel_bindings_p () && ! pseudo_global_level_p())
389 fndef eat_saved_input
390 { if (pending_inlines) do_pending_inlines (); }
392 { if (pending_inlines) do_pending_inlines (); }
394 { if (pending_inlines) do_pending_inlines (); }
395 | asm_keyword '(' string ')' ';'
396 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
398 | extern_lang_string '{' extdefs_opt '}'
399 { pop_lang_context (); }
400 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
401 { if (pending_inlines) do_pending_inlines ();
402 pop_lang_context (); }
403 | extern_lang_string .hush_warning datadef .warning_ok
404 { if (pending_inlines) do_pending_inlines ();
405 pop_lang_context (); }
406 | NAMESPACE identifier '{'
407 { push_namespace ($2); }
409 { pop_namespace (); }
411 { push_namespace (NULL_TREE); }
413 { pop_namespace (); }
416 { do_toplevel_using_decl ($1); }
419 { pedantic = $<itype>1; }
423 NAMESPACE identifier '='
424 { begin_only_namespace_names (); }
427 end_only_namespace_names ();
430 do_namespace_alias ($2, $5);
437 | USING global_scope qualified_id
439 | USING global_scope unqualified_id
443 namespace_using_decl:
444 USING namespace_qualifier identifier
445 { $$ = build_parse_node (SCOPE_REF, $2, $3); }
446 | USING global_scope identifier
447 { $$ = build_parse_node (SCOPE_REF, global_namespace, $3); }
448 | USING global_scope namespace_qualifier identifier
449 { $$ = build_parse_node (SCOPE_REF, $3, $4); }
454 { begin_only_namespace_names (); }
457 end_only_namespace_names ();
458 /* If no declaration was found, the using-directive is
459 invalid. Since that was not reported, we need the
460 identifier for the error message. */
461 if (TREE_CODE ($4) == IDENTIFIER_NODE && lastiddecl)
463 do_using_directive ($4);
470 if (TREE_CODE ($$) == IDENTIFIER_NODE)
474 | namespace_qualifier NSNAME SCOPE
477 if (TREE_CODE ($$) == IDENTIFIER_NODE)
485 | global_scope qualified_id
487 | global_scope unqualified_id
493 { push_lang_context ($1); }
494 | extern_lang_string EXTERN_LANG_STRING
495 { if (current_lang_name != $2)
496 cp_error ("use of linkage spec `%D' is different from previous spec `%D'", $2, current_lang_name);
497 pop_lang_context (); push_lang_context ($2); }
502 { begin_template_parm_list (); }
503 template_parm_list '>'
504 { $$ = end_template_parm_list ($4); }
506 { begin_specialization();
512 { $$ = process_template_parm (NULL_TREE, $1); }
513 | template_parm_list ',' template_parm
514 { $$ = process_template_parm ($1, $3); }
524 aggr maybe_identifier
525 { $$ = finish_template_type_parm ($1, $2); }
526 | TYPENAME_KEYWORD maybe_identifier
527 { $$ = finish_template_type_parm (class_type_node, $2); }
530 template_template_parm:
531 template_header aggr maybe_identifier
532 { $$ = finish_template_template_parm ($2, $3); }
536 /* The following rules introduce a new reduce/reduce
537 conflict on the ',' and '>' input tokens: they are valid
538 prefixes for a `structsp', which means they could match a
539 nameless parameter. See 14.6, paragraph 3.
540 By putting them before the `parm' rule, we get
541 their match before considering them nameless parameter
544 { $$ = build_tree_list (NULL_TREE, $1); }
545 | template_type_parm '=' type_id
546 { $$ = build_tree_list (groktypename ($3.t), $1); }
548 { $$ = build_tree_list (NULL_TREE, $1.t); }
549 | parm '=' expr_no_commas %prec ARITHCOMPARE
550 { $$ = build_tree_list ($3, $1.t); }
551 | template_template_parm
552 { $$ = build_tree_list (NULL_TREE, $1); }
553 | template_template_parm '=' template_arg
555 if (TREE_CODE ($3) != TEMPLATE_DECL
556 && TREE_CODE ($3) != TEMPLATE_TEMPLATE_PARM
557 && TREE_CODE ($3) != TYPE_DECL)
559 error ("invalid default template argument");
560 $3 = error_mark_node;
562 $$ = build_tree_list ($3, $1);
567 template_header template_extdef
568 { finish_template_decl ($1); }
569 | template_header error %prec EMPTY
570 { finish_template_decl ($1); }
574 fndef eat_saved_input
575 { if (pending_inlines) do_pending_inlines (); }
577 { if (pending_inlines) do_pending_inlines (); }
579 { if (pending_inlines) do_pending_inlines (); }
580 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
581 { if (pending_inlines) do_pending_inlines ();
582 pop_lang_context (); }
583 | extern_lang_string .hush_warning template_datadef .warning_ok
584 { if (pending_inlines) do_pending_inlines ();
585 pop_lang_context (); }
586 | extension template_extdef
587 { pedantic = $<itype>1; }
592 | declmods notype_initdecls ';'
594 | typed_declspecs initdecls ';'
595 { note_list_got_semicolon ($1.t); }
597 { maybe_process_partial_specialization ($1.t);
598 note_got_semicolon ($1.t); }
603 | declmods notype_initdecls ';'
605 | typed_declspecs initdecls ';'
606 { note_list_got_semicolon ($1.t); }
608 { pedwarn ("empty declaration"); }
609 | explicit_instantiation ';'
610 | typed_declspecs ';'
613 split_specs_attrs ($1.t, &t, &attrs);
615 note_list_got_semicolon ($1.t);
622 ctor_initializer_opt:
641 fn.def1 maybe_return_init ctor_initializer_opt compstmt_or_error
642 { finish_function (lineno, (int)$3, 0); }
643 | fn.def1 maybe_return_init function_try_block
645 int nested = (hack_decl_function_context
646 (current_function_decl) != NULL_TREE);
647 finish_function (lineno, (int)$3, nested);
649 | fn.def1 maybe_return_init error
653 constructor_declarator:
654 nested_name_specifier SELFNAME '('
655 { $$ = begin_constructor_declarator ($1, $2); }
656 parmlist ')' cv_qualifiers exception_specification_opt
657 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
658 | nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
659 { $$ = begin_constructor_declarator ($1, $2);
660 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
662 | global_scope nested_name_specifier SELFNAME '('
663 { $$ = begin_constructor_declarator ($2, $3); }
664 parmlist ')' cv_qualifiers exception_specification_opt
665 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
666 | global_scope nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
667 { $$ = begin_constructor_declarator ($2, $3);
668 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
670 | nested_name_specifier self_template_type '('
671 { $$ = begin_constructor_declarator ($1, $2); }
672 parmlist ')' cv_qualifiers exception_specification_opt
673 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
674 | nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
675 { $$ = begin_constructor_declarator ($1, $2);
676 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
678 | global_scope nested_name_specifier self_template_type '('
679 { $$ = begin_constructor_declarator ($2, $3); }
680 parmlist ')' cv_qualifiers exception_specification_opt
681 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
682 | global_scope nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
683 { $$ = begin_constructor_declarator ($2, $3);
684 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
689 typed_declspecs declarator
690 { if (!begin_function_definition ($1.t, $2))
692 | declmods notype_declarator
693 { if (!begin_function_definition ($1, $2))
696 { if (!begin_function_definition (NULL_TREE, $1))
698 | declmods constructor_declarator
699 { if (!begin_function_definition ($1, $2))
701 | constructor_declarator
702 { if (!begin_function_definition (NULL_TREE, $1))
706 component_constructor_declarator:
707 SELFNAME '(' parmlist ')' cv_qualifiers exception_specification_opt
708 { $$ = make_call_declarator ($1, $3, $5, $6); }
709 | SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
710 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
711 | self_template_type '(' parmlist ')' cv_qualifiers exception_specification_opt
712 { $$ = make_call_declarator ($1, $3, $5, $6); }
713 | self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
714 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
717 /* more C++ complexity. See component_decl for a comment on the
718 reduce/reduce conflict introduced by these rules. */
720 declmods component_constructor_declarator
722 split_specs_attrs ($1, &specs, &attrs);
723 attrs = build_tree_list (attrs, NULL_TREE);
724 $$ = start_method (specs, $2, attrs);
728 if (yychar == YYEMPTY)
730 reinit_parse_for_method (yychar, $$); }
731 | component_constructor_declarator
732 { $$ = start_method (NULL_TREE, $1, NULL_TREE);
734 | typed_declspecs declarator
736 split_specs_attrs ($1.t, &specs, &attrs);
737 attrs = build_tree_list (attrs, NULL_TREE);
738 $$ = start_method (specs, $2, attrs); goto rest_of_mdef; }
739 | declmods notype_declarator
741 split_specs_attrs ($1, &specs, &attrs);
742 attrs = build_tree_list (attrs, NULL_TREE);
743 $$ = start_method (specs, $2, attrs); goto rest_of_mdef; }
745 { $$ = start_method (NULL_TREE, $$, NULL_TREE);
747 | declmods constructor_declarator
749 split_specs_attrs ($1, &specs, &attrs);
750 attrs = build_tree_list (attrs, NULL_TREE);
751 $$ = start_method (specs, $2, attrs); goto rest_of_mdef; }
752 | constructor_declarator
753 { $$ = start_method (NULL_TREE, $$, NULL_TREE);
758 RETURN_KEYWORD IDENTIFIER
760 if (! current_function_parms_stored)
768 { store_return_init ($<ttype>$, $2); }
769 | return_id '(' nonnull_exprlist ')'
770 { store_return_init ($<ttype>$, $3); }
771 | return_id LEFT_RIGHT
772 { store_return_init ($<ttype>$, NULL_TREE); }
776 ':' .set_base_init member_init_list
779 error ("no base initializers given following ':'");
781 /* Always keep the BLOCK node associated with the outermost
782 pair of curley braces of a function. These are needed
783 for correct operation of dwarfout.c. */
791 if (! current_function_parms_stored)
794 if (DECL_CONSTRUCTOR_P (current_function_decl))
796 /* Make a contour for the initializer list. */
799 expand_start_bindings (0);
801 else if (current_class_type == NULL_TREE)
802 error ("base initializers not allowed for non-member functions");
803 else if (! DECL_CONSTRUCTOR_P (current_function_decl))
804 error ("only constructors take base initializers");
813 | member_init_list ',' member_init
814 | member_init_list error
818 '(' nonnull_exprlist ')'
820 if (current_class_name)
821 pedwarn ("anachronistic old style base class initializer");
822 expand_member_init (current_class_ref, NULL_TREE, $2);
826 if (current_class_name)
827 pedwarn ("anachronistic old style base class initializer");
828 expand_member_init (current_class_ref, NULL_TREE, void_type_node);
830 | notype_identifier '(' nonnull_exprlist ')'
831 { expand_member_init (current_class_ref, $1, $3); }
832 | notype_identifier LEFT_RIGHT
833 { expand_member_init (current_class_ref, $1, void_type_node); }
834 | nonnested_type '(' nonnull_exprlist ')'
835 { expand_member_init (current_class_ref, $1, $3); }
836 | nonnested_type LEFT_RIGHT
837 { expand_member_init (current_class_ref, $1, void_type_node); }
838 | typename_sub '(' nonnull_exprlist ')'
839 { expand_member_init (current_class_ref, TYPE_MAIN_DECL ($1),
841 | typename_sub LEFT_RIGHT
842 { expand_member_init (current_class_ref, TYPE_MAIN_DECL ($1),
866 explicit_instantiation:
867 TEMPLATE begin_explicit_instantiation typespec ';'
868 { do_type_instantiation ($3.t, NULL_TREE);
870 end_explicit_instantiation
871 | TEMPLATE begin_explicit_instantiation typed_declspecs declarator
872 { tree specs = strip_attrs ($3.t);
873 do_decl_instantiation (specs, $4, NULL_TREE); }
874 end_explicit_instantiation
875 | TEMPLATE begin_explicit_instantiation notype_declarator
876 { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
877 end_explicit_instantiation
878 | TEMPLATE begin_explicit_instantiation constructor_declarator
879 { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
880 end_explicit_instantiation
881 | SCSPEC TEMPLATE begin_explicit_instantiation typespec ';'
882 { do_type_instantiation ($4.t, $1);
884 end_explicit_instantiation
885 | SCSPEC TEMPLATE begin_explicit_instantiation typed_declspecs
887 { tree specs = strip_attrs ($4.t);
888 do_decl_instantiation (specs, $5, $1); }
889 end_explicit_instantiation
890 | SCSPEC TEMPLATE begin_explicit_instantiation notype_declarator
891 { do_decl_instantiation (NULL_TREE, $4, $1); }
892 end_explicit_instantiation
893 | SCSPEC TEMPLATE begin_explicit_instantiation constructor_declarator
894 { do_decl_instantiation (NULL_TREE, $4, $1); }
895 end_explicit_instantiation
898 begin_explicit_instantiation:
899 { begin_explicit_instantiation(); }
901 end_explicit_instantiation:
902 { end_explicit_instantiation(); }
904 /* The TYPENAME expansions are to deal with use of a template class name as
905 a template within the class itself, where the template decl is hidden by
906 a type decl. Got all that? */
909 PTYPENAME '<' template_arg_list_opt template_close_bracket
910 .finish_template_type
912 | TYPENAME '<' template_arg_list_opt template_close_bracket
913 .finish_template_type
918 apparent_template_type:
920 | identifier '<' template_arg_list_opt '>'
921 .finish_template_type
925 SELFNAME '<' template_arg_list_opt template_close_bracket
926 .finish_template_type
930 .finish_template_type:
932 if (yychar == YYEMPTY)
935 $$ = finish_template_type ($<ttype>-3, $<ttype>-1,
939 template_close_bracket:
943 /* Handle `Class<Class<Type>>' without space in the `>>' */
944 pedwarn ("`>>' should be `> >' in template class name");
949 template_arg_list_opt:
957 { $$ = build_tree_list (NULL_TREE, $$); }
958 | template_arg_list ',' template_arg
959 { $$ = chainon ($$, build_tree_list (NULL_TREE, $3)); }
964 { $$ = groktypename ($1.t); }
967 | expr_no_commas %prec ARITHCOMPARE
972 { $$ = NEGATE_EXPR; }
974 { $$ = CONVERT_EXPR; }
976 { $$ = PREINCREMENT_EXPR; }
978 { $$ = PREDECREMENT_EXPR; }
980 { $$ = TRUTH_NOT_EXPR; }
985 { $$ = build_x_compound_expr ($$); }
991 { error ("ANSI C++ forbids an empty condition for `%s'",
993 $$ = integer_zero_node; }
1000 { error ("ANSI C++ forbids an empty condition for `%s'",
1002 $$ = integer_zero_node; }
1016 type_specifier_seq declarator maybeasm maybe_attribute '='
1019 for (d = getdecls (); d; d = TREE_CHAIN (d))
1020 if (TREE_CODE (d) == TYPE_DECL) {
1021 tree s = TREE_TYPE (d);
1022 if (TREE_CODE (s) == RECORD_TYPE)
1023 cp_error ("definition of class `%T' in condition", s);
1024 else if (TREE_CODE (s) == ENUMERAL_TYPE)
1025 cp_error ("definition of enum `%T' in condition", s);
1028 current_declspecs = $1.t;
1029 $<itype>5 = suspend_momentary ();
1030 $<ttype>$ = start_decl ($<ttype>2, current_declspecs, 1,
1031 $4, /*prefix_attributes*/ NULL_TREE);
1035 cp_finish_decl ($<ttype>6, $7, $4, 1, LOOKUP_ONLYCONVERTING);
1036 resume_momentary ($<itype>5);
1037 $$ = convert_from_reference ($<ttype>6);
1038 if (TREE_CODE (TREE_TYPE ($$)) == ARRAY_TYPE)
1039 cp_error ("definition of array `%#D' in condition", $$);
1046 | maybe_label_decls stmts '}'
1047 | maybe_label_decls stmts error '}'
1048 | maybe_label_decls error '}'
1051 already_scoped_stmt:
1053 { $<ttype>$ = begin_compound_stmt (1); }
1055 { finish_compound_stmt (1, $<ttype>2); }
1060 nontrivial_exprlist:
1061 expr_no_commas ',' expr_no_commas
1062 { $$ = expr_tree_cons (NULL_TREE, $$,
1063 build_expr_list (NULL_TREE, $3)); }
1064 | expr_no_commas ',' error
1065 { $$ = expr_tree_cons (NULL_TREE, $$,
1066 build_expr_list (NULL_TREE, error_mark_node)); }
1067 | nontrivial_exprlist ',' expr_no_commas
1068 { chainon ($$, build_expr_list (NULL_TREE, $3)); }
1069 | nontrivial_exprlist ',' error
1070 { chainon ($$, build_expr_list (NULL_TREE, error_mark_node)); }
1075 { $$ = build_expr_list (NULL_TREE, $$); }
1076 | nontrivial_exprlist
1082 /* __extension__ turns off -pedantic for following primary. */
1083 | extension cast_expr %prec UNARY
1085 pedantic = $<itype>1; }
1086 | '*' cast_expr %prec UNARY
1087 { $$ = build_x_indirect_ref ($2, "unary *"); }
1088 | '&' cast_expr %prec UNARY
1089 { $$ = build_x_unary_op (ADDR_EXPR, $2); }
1091 { $$ = build_x_unary_op (BIT_NOT_EXPR, $2); }
1092 | unop cast_expr %prec UNARY
1093 { $$ = finish_unary_op_expr ($1, $2); }
1094 /* Refer to the address of a label as a pointer. */
1097 pedwarn ("ANSI C++ forbids `&&'");
1098 $$ = finish_label_address_expr ($2); }
1099 | SIZEOF unary_expr %prec UNARY
1100 { $$ = expr_sizeof ($2); }
1101 | SIZEOF '(' type_id ')' %prec HYPERUNARY
1102 { $$ = c_sizeof (groktypename ($3.t));
1103 check_for_new_type ("sizeof", $3); }
1104 | ALIGNOF unary_expr %prec UNARY
1105 { $$ = grok_alignof ($2); }
1106 | ALIGNOF '(' type_id ')' %prec HYPERUNARY
1107 { $$ = c_alignof (groktypename ($3.t));
1108 check_for_new_type ("alignof", $3); }
1110 /* The %prec EMPTY's here are required by the = init initializer
1111 syntax extension; see below. */
1112 | new new_type_id %prec EMPTY
1113 { $$ = build_new (NULL_TREE, $2.t, NULL_TREE, $1);
1114 check_for_new_type ("new", $2); }
1115 | new new_type_id new_initializer
1116 { $$ = build_new (NULL_TREE, $2.t, $3, $1);
1117 check_for_new_type ("new", $2); }
1118 | new new_placement new_type_id %prec EMPTY
1119 { $$ = build_new ($2, $3.t, NULL_TREE, $1);
1120 check_for_new_type ("new", $3); }
1121 | new new_placement new_type_id new_initializer
1122 { $$ = build_new ($2, $3.t, $4, $1);
1123 check_for_new_type ("new", $3); }
1124 /* The .begin_new_placement in the following rules is
1125 necessary to avoid shift/reduce conflicts that lead to
1126 mis-parsing some expressions. Of course, these constructs
1127 are not really new-placement and it is bogus to call
1128 begin_new_placement. But, the parser cannot always tell at this
1129 point whether the next thing is an expression or a type-id,
1130 so there is nothing we can do. Fortunately,
1131 begin_new_placement does nothing harmful. When we rewrite
1132 the parser, this lossage should be removed, of course. */
1133 | new '(' .begin_new_placement type_id .finish_new_placement
1135 { $$ = build_new (NULL_TREE, groktypename($4.t),
1137 check_for_new_type ("new", $4); }
1138 | new '(' .begin_new_placement type_id .finish_new_placement
1140 { $$ = build_new (NULL_TREE, groktypename($4.t), $6, $1);
1141 check_for_new_type ("new", $4); }
1142 | new new_placement '(' .begin_new_placement type_id
1143 .finish_new_placement %prec EMPTY
1144 { $$ = build_new ($2, groktypename($5.t), NULL_TREE, $1);
1145 check_for_new_type ("new", $5); }
1146 | new new_placement '(' .begin_new_placement type_id
1147 .finish_new_placement new_initializer
1148 { $$ = build_new ($2, groktypename($5.t), $7, $1);
1149 check_for_new_type ("new", $5); }
1151 | delete cast_expr %prec UNARY
1152 { $$ = delete_sanity ($2, NULL_TREE, 0, $1); }
1153 | delete '[' ']' cast_expr %prec UNARY
1154 { $$ = delete_sanity ($4, NULL_TREE, 1, $1);
1155 if (yychar == YYEMPTY)
1157 | delete '[' expr ']' cast_expr %prec UNARY
1158 { $$ = delete_sanity ($5, $3, 2, $1);
1159 if (yychar == YYEMPTY)
1161 | REALPART cast_expr %prec UNARY
1162 { $$ = build_x_unary_op (REALPART_EXPR, $2); }
1163 | IMAGPART cast_expr %prec UNARY
1164 { $$ = build_x_unary_op (IMAGPART_EXPR, $2); }
1165 | VA_ARG '(' expr_no_commas ',' type_id ')'
1166 { $$ = build_va_arg ($3, groktypename ($5.t));
1167 check_for_new_type ("__builtin_va_arg", $5); }
1170 /* Note this rule is not suitable for use in new_placement
1171 since it uses NULL_TREE as the argument to
1172 finish_new_placement. This rule serves only to avoid
1173 reduce/reduce conflicts in unary_expr. See the comments
1174 there on the use of begin/finish_new_placement. */
1175 .finish_new_placement:
1177 { finish_new_placement (NULL_TREE, $<itype>-1); }
1179 .begin_new_placement:
1180 { $$ = begin_new_placement (); }
1183 '(' .begin_new_placement nonnull_exprlist ')'
1184 { $$ = finish_new_placement ($3, $2); }
1185 | '{' .begin_new_placement nonnull_exprlist '}'
1186 { cp_pedwarn ("old style placement syntax, use () instead");
1187 $$ = finish_new_placement ($3, $2); }
1191 '(' nonnull_exprlist ')'
1197 cp_error ("`%T' is not a valid expression", $2.t);
1198 $$ = error_mark_node;
1200 /* GNU extension so people can use initializer lists. Note that
1201 this alters the meaning of `new int = 1', which was previously
1202 syntactically valid but semantically invalid. */
1206 pedwarn ("ANSI C++ forbids initialization of new expression with `='");
1207 if (TREE_CODE ($2) != TREE_LIST
1208 && TREE_CODE ($2) != CONSTRUCTOR)
1209 $$ = build_expr_list (NULL_TREE, $2);
1215 /* This is necessary to postpone reduction of `int ((int)(int)(int))'. */
1217 '(' type_id ')' %prec EMPTY
1218 { $2.t = finish_parmlist (build_tree_list (NULL_TREE, $2.t), 0);
1219 $$ = make_call_declarator (NULL_TREE, $2.t, NULL_TREE, NULL_TREE);
1220 check_for_new_type ("cast", $2); }
1221 | regcast_or_absdcl '(' type_id ')' %prec EMPTY
1222 { $3.t = finish_parmlist (build_tree_list (NULL_TREE, $3.t), 0);
1223 $$ = make_call_declarator ($$, $3.t, NULL_TREE, NULL_TREE);
1224 check_for_new_type ("cast", $3); }
1229 | regcast_or_absdcl unary_expr %prec UNARY
1230 { $$ = reparse_absdcl_as_casts ($$, $2); }
1231 | regcast_or_absdcl '{' initlist maybecomma '}' %prec UNARY
1233 tree init = build_nt (CONSTRUCTOR, NULL_TREE,
1236 pedwarn ("ANSI C++ forbids constructor-expressions");
1237 /* Indicate that this was a GNU C constructor expression. */
1238 TREE_HAS_CONSTRUCTOR (init) = 1;
1240 $$ = reparse_absdcl_as_casts ($$, init);
1246 /* Handle general members. */
1247 | expr_no_commas POINTSAT_STAR expr_no_commas
1248 { $$ = build_x_binary_op (MEMBER_REF, $$, $3); }
1249 | expr_no_commas DOT_STAR expr_no_commas
1250 { $$ = build_m_component_ref ($$, $3); }
1251 | expr_no_commas '+' expr_no_commas
1252 { $$ = build_x_binary_op ($2, $$, $3); }
1253 | expr_no_commas '-' expr_no_commas
1254 { $$ = build_x_binary_op ($2, $$, $3); }
1255 | expr_no_commas '*' expr_no_commas
1256 { $$ = build_x_binary_op ($2, $$, $3); }
1257 | expr_no_commas '/' expr_no_commas
1258 { $$ = build_x_binary_op ($2, $$, $3); }
1259 | expr_no_commas '%' expr_no_commas
1260 { $$ = build_x_binary_op ($2, $$, $3); }
1261 | expr_no_commas LSHIFT expr_no_commas
1262 { $$ = build_x_binary_op ($2, $$, $3); }
1263 | expr_no_commas RSHIFT expr_no_commas
1264 { $$ = build_x_binary_op ($2, $$, $3); }
1265 | expr_no_commas ARITHCOMPARE expr_no_commas
1266 { $$ = build_x_binary_op ($2, $$, $3); }
1267 | expr_no_commas '<' expr_no_commas
1268 { $$ = build_x_binary_op (LT_EXPR, $$, $3); }
1269 | expr_no_commas '>' expr_no_commas
1270 { $$ = build_x_binary_op (GT_EXPR, $$, $3); }
1271 | expr_no_commas EQCOMPARE expr_no_commas
1272 { $$ = build_x_binary_op ($2, $$, $3); }
1273 | expr_no_commas MIN_MAX expr_no_commas
1274 { $$ = build_x_binary_op ($2, $$, $3); }
1275 | expr_no_commas '&' expr_no_commas
1276 { $$ = build_x_binary_op ($2, $$, $3); }
1277 | expr_no_commas '|' expr_no_commas
1278 { $$ = build_x_binary_op ($2, $$, $3); }
1279 | expr_no_commas '^' expr_no_commas
1280 { $$ = build_x_binary_op ($2, $$, $3); }
1281 | expr_no_commas ANDAND expr_no_commas
1282 { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $$, $3); }
1283 | expr_no_commas OROR expr_no_commas
1284 { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $$, $3); }
1285 | expr_no_commas '?' xexpr ':' expr_no_commas
1286 { $$ = build_x_conditional_expr ($$, $3, $5); }
1287 | expr_no_commas '=' expr_no_commas
1288 { $$ = build_x_modify_expr ($$, NOP_EXPR, $3);
1289 if ($$ != error_mark_node)
1290 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
1291 | expr_no_commas ASSIGN expr_no_commas
1292 { $$ = build_x_modify_expr ($$, $2, $3); }
1294 { $$ = build_throw (NULL_TREE); }
1295 | THROW expr_no_commas
1296 { $$ = build_throw ($2); }
1297 /* These extensions are not defined. The second arg to build_m_component_ref
1298 is old, build_m_component_ref now does an implicit
1299 build_indirect_ref (x, NULL_PTR) on the second argument.
1300 | object '&' expr_no_commas %prec UNARY
1301 { $$ = build_m_component_ref ($$, build_x_unary_op (ADDR_EXPR, $3)); }
1302 | object unop expr_no_commas %prec UNARY
1303 { $$ = build_m_component_ref ($$, build_x_unary_op ($2, $3)); }
1304 | object '(' type_id ')' expr_no_commas %prec UNARY
1305 { tree type = groktypename ($3.t);
1306 $$ = build_m_component_ref ($$, build_c_cast (type, $5)); }
1307 | object primary_no_id %prec UNARY
1308 { $$ = build_m_component_ref ($$, $2); }
1312 notype_unqualified_id:
1313 '~' see_typename identifier
1314 { $$ = build_parse_node (BIT_NOT_EXPR, $3); }
1315 | '~' see_typename template_type
1316 { $$ = build_parse_node (BIT_NOT_EXPR, $3); }
1321 | NSNAME %prec EMPTY
1326 /* If lastiddecl is a TREE_LIST, it's a baselink, which
1327 means that we're in an expression like S::f<int>, so
1328 don't do_identifier; we only do that for unqualified
1330 if (lastiddecl && TREE_CODE (lastiddecl) != TREE_LIST)
1331 $$ = do_identifier ($<ttype>-1, 1, NULL_TREE);
1337 PFUNCNAME '<' do_id template_arg_list_opt template_close_bracket
1338 { $$ = lookup_template_function ($3, $4); }
1339 | operator_name '<' do_id template_arg_list_opt template_close_bracket
1340 { $$ = lookup_template_function ($3, $4); }
1344 TEMPLATE identifier '<' template_arg_list_opt template_close_bracket
1345 { $$ = lookup_template_function ($2, $4); }
1346 | TEMPLATE PFUNCNAME '<' template_arg_list_opt template_close_bracket
1347 { $$ = lookup_template_function ($2, $4); }
1348 | TEMPLATE operator_name '<' template_arg_list_opt
1349 template_close_bracket
1350 { $$ = lookup_template_function ($2, $4); }
1354 notype_unqualified_id
1359 expr_or_declarator_intern:
1361 | attributes expr_or_declarator
1363 /* Provide support for '(' attributes '*' declarator ')'
1365 $$ = decl_tree_cons ($1, $2, NULL_TREE);
1370 notype_unqualified_id
1371 | '*' expr_or_declarator_intern %prec UNARY
1372 { $$ = build_parse_node (INDIRECT_REF, $2); }
1373 | '&' expr_or_declarator_intern %prec UNARY
1374 { $$ = build_parse_node (ADDR_EXPR, $2); }
1375 | '(' expr_or_declarator_intern ')'
1379 notype_template_declarator:
1380 IDENTIFIER '<' template_arg_list_opt template_close_bracket
1381 { $$ = lookup_template_function ($1, $3); }
1382 | NSNAME '<' template_arg_list template_close_bracket
1383 { $$ = lookup_template_function ($1, $3); }
1386 direct_notype_declarator:
1387 complex_direct_notype_declarator
1388 /* This precedence declaration is to prefer this reduce
1389 to the Koenig lookup shift in primary, below. I hate yacc. */
1390 | notype_unqualified_id %prec '('
1391 | notype_template_declarator
1392 | '(' expr_or_declarator_intern ')'
1393 { $$ = finish_decl_parsing ($2); }
1397 notype_unqualified_id
1399 if (TREE_CODE ($1) == BIT_NOT_EXPR)
1400 $$ = build_x_unary_op (BIT_NOT_EXPR, TREE_OPERAND ($1, 0));
1402 $$ = finish_id_expr ($1);
1408 if (processing_template_decl)
1409 push_obstacks (&permanent_obstack, &permanent_obstack);
1410 $$ = combine_strings ($$);
1411 /* combine_strings doesn't set up TYPE_MAIN_VARIANT of
1412 a const array the way we want, so fix it. */
1413 if (flag_const_strings)
1414 TREE_TYPE ($$) = build_cplus_array_type
1415 (TREE_TYPE (TREE_TYPE ($$)),
1416 TYPE_DOMAIN (TREE_TYPE ($$)));
1417 if (processing_template_decl)
1421 { $$ = finish_parenthesized_expr ($2); }
1422 | '(' expr_or_declarator_intern ')'
1423 { $2 = reparse_decl_as_expr (NULL_TREE, $2);
1424 $$ = finish_parenthesized_expr ($2); }
1426 { $$ = error_mark_node; }
1428 { tree scope = current_scope ();
1429 if (!scope || TREE_CODE (scope) != FUNCTION_DECL)
1431 error ("braced-group within expression allowed only inside a function");
1435 pedwarn ("ANSI C++ forbids braced-groups within expressions");
1436 $<ttype>$ = begin_stmt_expr ();
1439 { $$ = finish_stmt_expr ($<ttype>2, $3); }
1440 /* Koenig lookup support
1441 We could store lastiddecl in $1 to avoid another lookup,
1442 but that would result in many additional reduce/reduce conflicts. */
1443 | notype_unqualified_id '(' nonnull_exprlist ')'
1444 { $$ = finish_call_expr ($1, $3, 1); }
1445 | notype_unqualified_id LEFT_RIGHT
1446 { $$ = finish_call_expr ($1, NULL_TREE, 1); }
1447 | primary '(' nonnull_exprlist ')'
1448 { $$ = finish_call_expr ($1, $3, 0); }
1449 | primary LEFT_RIGHT
1450 { $$ = finish_call_expr ($1, NULL_TREE, 0); }
1451 | primary '[' expr ']'
1452 { $$ = grok_array_decl ($$, $3); }
1454 { $$ = finish_increment_expr ($1, POSTINCREMENT_EXPR); }
1455 | primary MINUSMINUS
1456 { $$ = finish_increment_expr ($1, POSTDECREMENT_EXPR); }
1457 /* C++ extensions */
1459 { $$ = finish_this_expr (); }
1460 | CV_QUALIFIER '(' nonnull_exprlist ')'
1462 /* This is a C cast in C++'s `functional' notation
1463 using the "implicit int" extension so that:
1464 `const (3)' is equivalent to `const int (3)'. */
1467 if ($3 == error_mark_node)
1469 $$ = error_mark_node;
1473 type = cp_build_qualified_type (integer_type_node,
1474 cp_type_qual_from_rid ($1));
1475 $$ = build_c_cast (type, build_compound_expr ($3));
1478 | DYNAMIC_CAST '<' type_id '>' '(' expr ')'
1479 { tree type = groktypename ($3.t);
1480 check_for_new_type ("dynamic_cast", $3);
1481 $$ = build_dynamic_cast (type, $6); }
1482 | STATIC_CAST '<' type_id '>' '(' expr ')'
1483 { tree type = groktypename ($3.t);
1484 check_for_new_type ("static_cast", $3);
1485 $$ = build_static_cast (type, $6); }
1486 | REINTERPRET_CAST '<' type_id '>' '(' expr ')'
1487 { tree type = groktypename ($3.t);
1488 check_for_new_type ("reinterpret_cast", $3);
1489 $$ = build_reinterpret_cast (type, $6); }
1490 | CONST_CAST '<' type_id '>' '(' expr ')'
1491 { tree type = groktypename ($3.t);
1492 check_for_new_type ("const_cast", $3);
1493 $$ = build_const_cast (type, $6); }
1494 | TYPEID '(' expr ')'
1495 { $$ = build_x_typeid ($3); }
1496 | TYPEID '(' type_id ')'
1497 { tree type = groktypename ($3.t);
1498 check_for_new_type ("typeid", $3);
1499 $$ = get_typeid (TYPE_MAIN_VARIANT (type)); }
1500 | global_scope IDENTIFIER
1501 { $$ = do_scoped_id ($2, 1); }
1502 | global_scope template_id
1504 | global_scope operator_name
1506 got_scope = NULL_TREE;
1507 if (TREE_CODE ($2) == IDENTIFIER_NODE)
1508 $$ = do_scoped_id ($2, 1);
1512 | overqualified_id %prec HYPERUNARY
1513 { $$ = build_offset_ref (OP0 ($$), OP1 ($$)); }
1514 | overqualified_id '(' nonnull_exprlist ')'
1515 { $$ = finish_qualified_call_expr ($1, $3); }
1516 | overqualified_id LEFT_RIGHT
1517 { $$ = finish_qualified_call_expr ($1, NULL_TREE); }
1518 | object object_template_id %prec UNARY
1520 $$ = build_x_component_ref ($$, $2, NULL_TREE, 1);
1522 | object object_template_id '(' nonnull_exprlist ')'
1523 { $$ = finish_object_call_expr ($2, $1, $4); }
1524 | object object_template_id LEFT_RIGHT
1525 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1526 | object unqualified_id %prec UNARY
1527 { $$ = build_x_component_ref ($$, $2, NULL_TREE, 1); }
1528 | object overqualified_id %prec UNARY
1529 { if (processing_template_decl)
1530 $$ = build_min_nt (COMPONENT_REF, $1, copy_to_permanent ($2));
1532 $$ = build_object_ref ($$, OP0 ($2), OP1 ($2)); }
1533 | object unqualified_id '(' nonnull_exprlist ')'
1534 { $$ = finish_object_call_expr ($2, $1, $4); }
1535 | object unqualified_id LEFT_RIGHT
1536 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1537 | object overqualified_id '(' nonnull_exprlist ')'
1538 { $$ = finish_qualified_object_call_expr ($2, $1, $4); }
1539 | object overqualified_id LEFT_RIGHT
1540 { $$ = finish_qualified_object_call_expr ($2, $1, NULL_TREE); }
1541 /* p->int::~int() is valid -- 12.4 */
1542 | object '~' TYPESPEC LEFT_RIGHT
1543 { $$ = finish_pseudo_destructor_call_expr ($1, NULL_TREE, $3); }
1544 | object TYPESPEC SCOPE '~' TYPESPEC LEFT_RIGHT
1545 { $$ = finish_pseudo_destructor_call_expr ($1, $2, $5); }
1548 $$ = error_mark_node;
1552 /* Not needed for now.
1558 { $$ = error_mark_node; }
1560 { if (current_function_decl == 0)
1562 error ("braced-group within expression allowed only inside a function");
1565 $<ttype>$ = expand_start_stmt_expr (); }
1568 pedwarn ("ANSI C++ forbids braced-groups within expressions");
1569 $$ = expand_end_stmt_expr ($<ttype>2); }
1570 | primary_no_id '(' nonnull_exprlist ')'
1571 { $$ = build_x_function_call ($$, $3, current_class_ref); }
1572 | primary_no_id LEFT_RIGHT
1573 { $$ = build_x_function_call ($$, NULL_TREE, current_class_ref); }
1574 | primary_no_id '[' expr ']'
1576 | primary_no_id PLUSPLUS
1577 { $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); }
1578 | primary_no_id MINUSMINUS
1579 { $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); }
1581 { goto do_scoped_id; }
1582 | SCOPE operator_name
1583 { if (TREE_CODE ($2) == IDENTIFIER_NODE)
1585 goto do_scoped_operator;
1594 { got_scope = NULL_TREE; $$ = 1; }
1600 | global_scope delete
1601 { got_scope = NULL_TREE; $$ = 1; }
1606 { $$ = boolean_true_node; }
1608 { $$ = boolean_false_node; }
1611 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
1615 { $$ = chainon ($$, $2); }
1621 if (! current_function_parms_stored)
1622 store_parm_decls ();
1624 /* Always keep the BLOCK node associated with the outermost
1625 pair of curley braces of a function. These are needed
1626 for correct operation of dwarfout.c. */
1633 { got_object = TREE_TYPE ($$); }
1636 $$ = build_x_arrow ($$);
1637 got_object = TREE_TYPE ($$);
1642 typespec initdecls ';'
1644 resume_momentary ($2);
1645 if ($1.t && IS_AGGR_TYPE_CODE (TREE_CODE ($1.t)))
1646 note_got_semicolon ($1.t);
1648 | typed_declspecs initdecls ';'
1650 resume_momentary ($2);
1651 note_list_got_semicolon ($1.t);
1653 | declmods notype_initdecls ';'
1654 { resume_momentary ($2); }
1655 | typed_declspecs ';'
1658 note_list_got_semicolon ($1.t);
1661 { warning ("empty declaration"); }
1663 { pedantic = $<itype>1; }
1666 /* Any kind of declarator (thus, all declarators allowed
1667 after an explicit typespec). */
1670 after_type_declarator %prec EMPTY
1671 | notype_declarator %prec EMPTY
1674 /* This is necessary to postpone reduction of `int()()()()'. */
1676 LEFT_RIGHT %prec EMPTY
1677 { $$ = make_call_declarator (NULL_TREE, empty_parms (),
1678 NULL_TREE, NULL_TREE); }
1679 | fcast_or_absdcl LEFT_RIGHT %prec EMPTY
1680 { $$ = make_call_declarator ($$, empty_parms (), NULL_TREE,
1684 /* ANSI type-id (8.1) */
1686 typed_typespecs absdcl
1687 { $$.t = build_decl_list ($1.t, $2);
1688 $$.new_type_flag = $1.new_type_flag; }
1689 | nonempty_cv_qualifiers absdcl
1690 { $$.t = build_decl_list ($1.t, $2);
1691 $$.new_type_flag = $1.new_type_flag; }
1693 { $$.t = build_decl_list (build_decl_list (NULL_TREE, $1.t),
1695 $$.new_type_flag = $1.new_type_flag; }
1696 | typed_typespecs %prec EMPTY
1697 { $$.t = build_decl_list ($1.t, NULL_TREE);
1698 $$.new_type_flag = $1.new_type_flag; }
1699 | nonempty_cv_qualifiers %prec EMPTY
1700 { $$.t = build_decl_list ($1.t, NULL_TREE);
1701 $$.new_type_flag = $1.new_type_flag; }
1704 /* Declspecs which contain at least one type specifier or typedef name.
1705 (Just `const' or `volatile' is not enough.)
1706 A typedef'd name following these is taken as a name to be declared.
1707 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1710 typed_typespecs %prec EMPTY
1716 { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1);
1717 $$.new_type_flag = $2.new_type_flag; }
1718 | typespec reserved_declspecs %prec HYPERUNARY
1719 { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2);
1720 $$.new_type_flag = $1.new_type_flag; }
1721 | typespec reserved_typespecquals reserved_declspecs
1722 { $$.t = decl_tree_cons (NULL_TREE, $1.t, chainon ($2, $3));
1723 $$.new_type_flag = $1.new_type_flag; }
1724 | declmods typespec reserved_declspecs
1725 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1));
1726 $$.new_type_flag = $2.new_type_flag; }
1727 | declmods typespec reserved_typespecquals
1728 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1));
1729 $$.new_type_flag = $2.new_type_flag; }
1730 | declmods typespec reserved_typespecquals reserved_declspecs
1731 { $$.t = decl_tree_cons (NULL_TREE, $2.t,
1732 chainon ($3, chainon ($4, $1)));
1733 $$.new_type_flag = $2.new_type_flag; }
1738 { if (extra_warnings)
1739 warning ("`%s' is not at beginning of declaration",
1740 IDENTIFIER_POINTER ($$));
1741 $$ = build_decl_list (NULL_TREE, $$); }
1742 | reserved_declspecs typespecqual_reserved
1743 { $$ = decl_tree_cons (NULL_TREE, $2.t, $$); }
1744 | reserved_declspecs SCSPEC
1745 { if (extra_warnings)
1746 warning ("`%s' is not at beginning of declaration",
1747 IDENTIFIER_POINTER ($2));
1748 $$ = decl_tree_cons (NULL_TREE, $2, $$); }
1749 | reserved_declspecs attributes
1750 { $$ = decl_tree_cons ($2, NULL_TREE, $1); }
1752 { $$ = decl_tree_cons ($1, NULL_TREE, NULL_TREE); }
1755 /* List of just storage classes and type modifiers.
1756 A declaration can start with just this, but then it cannot be used
1757 to redeclare a typedef-name.
1758 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1760 /* We use hash_tree_cons for lists of typeless declspecs so that they end
1761 up on a persistent obstack. Otherwise, they could appear at the
1762 beginning of something like
1764 static const struct { int foo () { } } b;
1766 and would be discarded after we finish compiling foo. We don't need to
1767 worry once we see a type. */
1770 nonempty_cv_qualifiers %prec EMPTY
1771 { $$ = $1.t; TREE_STATIC ($$) = 1; }
1773 { $$ = hash_tree_cons (NULL_TREE, $$, NULL_TREE); }
1774 | declmods CV_QUALIFIER
1775 { $$ = hash_tree_cons (NULL_TREE, $2, $$);
1776 TREE_STATIC ($$) = 1; }
1778 { if (extra_warnings && TREE_STATIC ($$))
1779 warning ("`%s' is not at beginning of declaration",
1780 IDENTIFIER_POINTER ($2));
1781 $$ = hash_tree_cons (NULL_TREE, $2, $$);
1782 TREE_STATIC ($$) = TREE_STATIC ($1); }
1783 | declmods attributes
1784 { $$ = hash_tree_cons ($2, NULL_TREE, $1); }
1785 | attributes %prec EMPTY
1786 { $$ = hash_tree_cons ($1, NULL_TREE, NULL_TREE); }
1789 /* Used instead of declspecs where storage classes are not allowed
1790 (that is, for typenames and structure components).
1792 C++ can takes storage classes for structure components.
1793 Don't accept a typedef-name if anything but a modifier precedes it. */
1796 typespec %prec EMPTY
1797 { $$.t = build_decl_list (NULL_TREE, $1.t);
1798 $$.new_type_flag = $1.new_type_flag; }
1799 | nonempty_cv_qualifiers typespec
1800 { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1.t);
1801 $$.new_type_flag = $2.new_type_flag; }
1802 | typespec reserved_typespecquals
1803 { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2);
1804 $$.new_type_flag = $1.new_type_flag; }
1805 | nonempty_cv_qualifiers typespec reserved_typespecquals
1806 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1807 $$.new_type_flag = $1.new_type_flag; }
1810 reserved_typespecquals:
1811 typespecqual_reserved
1812 { $$ = build_decl_list (NULL_TREE, $1.t); }
1813 | reserved_typespecquals typespecqual_reserved
1814 { $$ = decl_tree_cons (NULL_TREE, $2.t, $1); }
1817 /* A typespec (but not a type qualifier).
1818 Once we have seen one of these in a declaration,
1819 if a typedef name appears then it is being redeclared. */
1823 | TYPESPEC %prec EMPTY
1824 { $$.t = $1; $$.new_type_flag = 0; }
1825 | complete_type_name
1826 { $$.t = $1; $$.new_type_flag = 0; }
1827 | TYPEOF '(' expr ')'
1828 { $$.t = finish_typeof ($3);
1829 $$.new_type_flag = 0; }
1830 | TYPEOF '(' type_id ')'
1831 { $$.t = groktypename ($3.t);
1832 $$.new_type_flag = 0; }
1833 | SIGOF '(' expr ')'
1834 { tree type = TREE_TYPE ($3);
1836 $$.new_type_flag = 0;
1837 if (IS_AGGR_TYPE (type))
1839 sorry ("sigof type specifier");
1844 error ("`sigof' applied to non-aggregate expression");
1845 $$.t = error_mark_node;
1848 | SIGOF '(' type_id ')'
1849 { tree type = groktypename ($3.t);
1851 $$.new_type_flag = 0;
1852 if (IS_AGGR_TYPE (type))
1854 sorry ("sigof type specifier");
1859 error("`sigof' applied to non-aggregate type");
1860 $$.t = error_mark_node;
1865 /* A typespec that is a reserved word, or a type qualifier. */
1867 typespecqual_reserved:
1869 { $$.t = $1; $$.new_type_flag = 0; }
1871 { $$.t = $1; $$.new_type_flag = 0; }
1877 | initdecls ',' initdcl
1878 { check_multiple_declarators (); }
1883 | notype_initdecls ',' initdcl
1884 { check_multiple_declarators (); }
1889 | nomods_initdecls ',' initdcl
1890 { check_multiple_declarators (); }
1896 | asm_keyword '(' string ')'
1897 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3); $$ = $3; }
1901 declarator maybeasm maybe_attribute '='
1902 { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1,
1903 $3, prefix_attributes); }
1905 /* Note how the declaration of the variable is in effect while its init is parsed! */
1906 { cp_finish_decl ($<ttype>5, $6, $2, 1, LOOKUP_ONLYCONVERTING); }
1907 | declarator maybeasm maybe_attribute
1908 { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 0,
1909 $3, prefix_attributes);
1910 cp_finish_decl ($<ttype>$, NULL_TREE, $2, 1, 0); }
1913 /* This rule assumes a certain configuration of the parser stack.
1914 In particular, $0, the element directly before the beginning of
1915 this rule on the stack, must be a maybeasm. $-1 must be a
1916 declarator or notype_declarator. And $-2 must be some declmods
1917 or declspecs. We can't move the maybeasm into this rule because
1918 we need that reduce so we prefer fn.def1 when appropriate. */
1921 { $<itype>2 = parse_decl ($<ttype>-1, $<ttype>-2,
1922 $1, 1, &$<ttype>$); }
1923 /* Note how the declaration of the variable is in effect
1924 while its init is parsed! */
1926 { cp_finish_decl ($<ttype>3, $4, $<ttype>0, 1,
1927 LOOKUP_ONLYCONVERTING);
1931 $$ = parse_decl ($<ttype>-1, $<ttype>-2, $1, 0, &d);
1932 cp_finish_decl (d, NULL_TREE, $<ttype>0, 1, 0); }
1936 declarator maybeasm initdcl0_innards
1940 notype_declarator maybeasm initdcl0_innards
1945 notype_declarator maybeasm
1946 { /* Set things up as initdcl0_innards expects. */
1951 | constructor_declarator maybeasm maybe_attribute
1953 parse_decl($1, NULL_TREE, $3, 0, &d);
1954 cp_finish_decl (d, NULL_TREE, $2, 1, 0); }
1957 /* the * rules are dummies to accept the Apollo extended syntax
1958 so that the header files compile. */
1969 | attributes attribute
1970 { $$ = chainon ($1, $2); }
1974 ATTRIBUTE '(' '(' attribute_list ')' ')'
1981 | attribute_list ',' attrib
1982 { $$ = chainon ($1, $3); }
1989 { $$ = build_tree_list ($1, NULL_TREE); }
1990 | any_word '(' IDENTIFIER ')'
1991 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1992 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1993 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1994 | any_word '(' nonnull_exprlist ')'
1995 { $$ = build_tree_list ($1, $3); }
1998 /* This still leaves out most reserved keywords,
1999 shouldn't we include them? */
2008 /* A nonempty list of identifiers, including typenames. */
2009 identifiers_or_typenames:
2011 { $$ = build_tree_list (NULL_TREE, $1); }
2012 | identifiers_or_typenames ',' identifier
2013 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2017 /* empty */ %prec EMPTY
2022 /* If we are processing a template, we don't want to expand this
2026 expr_no_commas %prec '='
2028 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, NULL_TREE);
2029 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2031 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2032 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2033 | '{' initlist ',' '}'
2034 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2035 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2040 /* This chain is built in reverse order,
2041 and put in forward order where initlist is used. */
2044 { $$ = build_tree_list (NULL_TREE, $$); }
2046 { $$ = expr_tree_cons (NULL_TREE, $3, $$); }
2047 /* These are for labeled elements. */
2048 | '[' expr_no_commas ']' init
2049 { $$ = build_expr_list ($2, $4); }
2050 | identifier ':' init
2051 { $$ = build_expr_list ($$, $3); }
2052 | initlist ',' identifier ':' init
2053 { $$ = expr_tree_cons ($3, $5, $$); }
2057 PRE_PARSED_FUNCTION_DECL
2058 { start_function (NULL_TREE, TREE_VALUE ($1),
2060 reinit_parse_for_function (); }
2063 fn.defpen maybe_return_init ctor_initializer_opt compstmt_or_error
2065 int nested = (hack_decl_function_context
2066 (current_function_decl) != NULL_TREE);
2067 finish_function (lineno, (int)$3 | 2, nested);
2068 process_next_inline ($1);
2070 | fn.defpen maybe_return_init function_try_block
2072 int nested = (hack_decl_function_context
2073 (current_function_decl) != NULL_TREE);
2074 finish_function (lineno, (int)$3 | 2, nested);
2075 process_next_inline ($1);
2077 | fn.defpen maybe_return_init error
2078 { process_next_inline ($1); }
2083 | pending_inlines pending_inline eat_saved_input
2086 /* A regurgitated default argument. The value of DEFARG_MARKER will be
2087 the TREE_LIST node for the parameter in question. */
2089 DEFARG_MARKER expr_no_commas END_OF_SAVED_INPUT
2090 { replace_defarg ($1, $2); }
2091 | DEFARG_MARKER error END_OF_SAVED_INPUT
2092 { replace_defarg ($1, error_mark_node); }
2095 /* empty */ %prec EMPTY
2096 | pending_defargs defarg_again
2097 { do_pending_defargs (); }
2098 | pending_defargs error
2099 { do_pending_defargs (); }
2104 { $<itype>3 = suspend_momentary ();
2105 $<ttype>$ = current_enum_type;
2106 current_enum_type = start_enum ($2); }
2107 enumlist maybecomma_warn '}'
2108 { TYPE_VALUES (current_enum_type) = $5;
2109 $$.t = finish_enum (current_enum_type);
2110 $$.new_type_flag = 1;
2111 current_enum_type = $<ttype>4;
2112 resume_momentary ((int) $<itype>3);
2113 check_for_missing_semicolon ($$.t); }
2114 | ENUM identifier '{' '}'
2115 { $$.t = finish_enum (start_enum ($2));
2116 $$.new_type_flag = 1;
2117 check_for_missing_semicolon ($$.t); }
2119 { $<itype>2 = suspend_momentary ();
2120 $<ttype>$ = current_enum_type;
2121 current_enum_type = start_enum (make_anon_name ()); }
2122 enumlist maybecomma_warn '}'
2123 { TYPE_VALUES (current_enum_type) = $4;
2124 $$.t = finish_enum (current_enum_type);
2125 $$.new_type_flag = 1;
2126 current_enum_type = $<ttype>3;
2127 resume_momentary ((int) $<itype>1);
2128 check_for_missing_semicolon ($$.t); }
2130 { $$.t = finish_enum (start_enum (make_anon_name()));
2131 $$.new_type_flag = 1;
2132 check_for_missing_semicolon ($$.t); }
2134 { $$.t = xref_tag (enum_type_node, $2, 1);
2135 $$.new_type_flag = 0; }
2136 | ENUM complex_type_name
2137 { $$.t = xref_tag (enum_type_node, $2, 1);
2138 $$.new_type_flag = 0; }
2139 | TYPENAME_KEYWORD typename_sub
2141 $$.new_type_flag = 0;
2142 if (!processing_template_decl)
2143 cp_pedwarn ("using `typename' outside of template"); }
2144 /* C++ extensions, merged with C to avoid shift/reduce conflicts */
2146 { $1.t = begin_class_definition ($1.t); }
2147 opt.component_decl_list '}' maybe_attribute
2151 if (yychar == YYEMPTY)
2153 semi = yychar == ';';
2155 $<ttype>$ = finish_class_definition ($1.t, $6, semi,
2160 begin_inline_definitions ();
2164 finish_inline_definitions ();
2166 $$.new_type_flag = 1;
2168 | class_head %prec EMPTY
2170 if ($1.new_type_flag && $1.t != error_mark_node)
2171 pop_scope (CP_DECL_CONTEXT (TYPE_MAIN_DECL ($1.t)));
2172 $$.new_type_flag = 0;
2173 if ($1.t == error_mark_node)
2175 else if (TYPE_BINFO ($1.t) == NULL_TREE)
2177 cp_error ("%T is not a class type", $1.t);
2178 $$.t = error_mark_node;
2183 /* struct B: public A; is not accepted by the WP grammar. */
2184 if (TYPE_BINFO_BASETYPES ($$.t) && !TYPE_SIZE ($$.t)
2185 && ! TYPE_BEING_DEFINED ($$.t))
2186 cp_error ("base clause without member specification for `%#T'",
2200 { if (pedantic && !in_system_header)
2201 pedwarn ("comma at end of enumerator list"); }
2207 { error ("storage class specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2209 { error ("type specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2211 { error ("type qualifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2213 { error ("no body nor ';' separates two class, struct or union declarations"); }
2215 { $$ = build_decl_list ($2, $1); }
2218 named_class_head_sans_basetype:
2226 named_class_head_sans_basetype_defn:
2227 aggr identifier_defn %prec EMPTY
2228 { current_aggr = $$; $$ = $2; }
2229 | named_class_head_sans_basetype '{'
2230 { yyungetc ('{', 1); }
2231 | named_class_head_sans_basetype ':'
2232 { yyungetc (':', 1); }
2235 named_complex_class_head_sans_basetype:
2236 aggr nested_name_specifier identifier
2239 $$.t = handle_class_head ($1, $2, $3);
2240 $$.new_type_flag = 1;
2242 | aggr global_scope nested_name_specifier identifier
2245 $$.t = handle_class_head ($1, $3, $4);
2246 $$.new_type_flag = 1;
2248 | aggr global_scope identifier
2251 $$.t = handle_class_head ($1, NULL_TREE, $3);
2252 $$.new_type_flag = 1;
2254 | aggr apparent_template_type
2258 $$.new_type_flag = 0;
2260 | aggr nested_name_specifier apparent_template_type
2264 if (CP_DECL_CONTEXT ($$.t))
2265 push_scope (CP_DECL_CONTEXT ($$.t));
2266 $$.new_type_flag = 1;
2271 named_class_head_sans_basetype %prec EMPTY
2273 $$.t = xref_tag (current_aggr, $1, 1);
2274 $$.new_type_flag = 0;
2276 | named_class_head_sans_basetype_defn
2277 { $<ttype>$ = xref_tag (current_aggr, $1, 0); }
2278 /* Class name is unqualified, so we look for base classes
2279 in the current scope. */
2280 maybe_base_class_list %prec EMPTY
2283 $$.new_type_flag = 0;
2285 xref_basetypes (current_aggr, $1, $<ttype>2, $3);
2287 | named_complex_class_head_sans_basetype
2288 maybe_base_class_list
2290 if ($1.t != error_mark_node)
2292 $$.t = TREE_TYPE ($1.t);
2293 $$.new_type_flag = $1.new_type_flag;
2294 if (current_aggr == union_type_node
2295 && TREE_CODE ($$.t) != UNION_TYPE)
2296 cp_pedwarn ("`union' tag used in declaring `%#T'",
2298 else if (TREE_CODE ($$.t) == UNION_TYPE
2299 && current_aggr != union_type_node)
2300 cp_pedwarn ("non-`union' tag used in declaring `%#T'", $$);
2301 else if (TREE_CODE ($$.t) == RECORD_TYPE)
2302 /* We might be specializing a template with a different
2304 CLASSTYPE_DECLARED_CLASS ($$.t)
2305 = (current_aggr == class_type_node);
2308 maybe_process_partial_specialization ($$.t);
2309 xref_basetypes (current_aggr, $1.t, $$.t, $2);
2317 { $$ = xref_tag ($$, make_anon_name (), 0);
2318 yyungetc ('{', 1); }
2321 /* The tree output of this nonterminal a declarationf or the type
2322 named. If NEW_TYPE_FLAG is set, then the name used in this
2323 class-head was explicitly qualified, e.g.: `struct X::Y'. We have
2324 already called push_scope for X. */
2329 $$.new_type_flag = 0;
2334 maybe_base_class_list:
2335 /* empty */ %prec EMPTY
2337 | ':' see_typename %prec EMPTY
2338 { yyungetc(':', 1); $$ = NULL_TREE; }
2339 | ':' see_typename base_class_list %prec EMPTY
2345 | base_class_list ',' see_typename base_class
2346 { $$ = chainon ($$, $4); }
2351 { $$ = finish_base_specifier (access_default_node, $1,
2353 == signature_type_node); }
2354 | base_class_access_list see_typename base_class.1
2355 { $$ = finish_base_specifier ($1, $3,
2357 == signature_type_node); }
2362 { if ($$ != error_mark_node) $$ = TYPE_MAIN_DECL ($1); }
2364 | SIGOF '(' expr ')'
2366 if (current_aggr == signature_type_node)
2368 if (IS_AGGR_TYPE (TREE_TYPE ($3)))
2370 sorry ("`sigof' as base signature specifier");
2371 $$ = TREE_TYPE ($3);
2375 error ("`sigof' applied to non-aggregate expression");
2376 $$ = error_mark_node;
2381 error ("`sigof' in struct or class declaration");
2382 $$ = error_mark_node;
2385 | SIGOF '(' type_id ')'
2387 if (current_aggr == signature_type_node)
2389 if (IS_AGGR_TYPE (groktypename ($3.t)))
2391 sorry ("`sigof' as base signature specifier");
2392 $$ = groktypename ($3.t);
2396 error ("`sigof' applied to non-aggregate expression");
2397 $$ = error_mark_node;
2402 error ("`sigof' in struct or class declaration");
2403 $$ = error_mark_node;
2408 base_class_access_list:
2409 VISSPEC see_typename
2410 | SCSPEC see_typename
2411 { if ($1 != ridpointers[(int)RID_VIRTUAL])
2412 cp_error ("`%D' access", $1);
2413 $$ = access_default_virtual_node; }
2414 | base_class_access_list VISSPEC see_typename
2416 if ($1 != access_default_virtual_node)
2417 error ("multiple access specifiers");
2418 else if ($2 == access_public_node)
2419 $$ = access_public_virtual_node;
2420 else if ($2 == access_protected_node)
2421 $$ = access_protected_virtual_node;
2422 else /* $2 == access_private_node */
2423 $$ = access_private_virtual_node;
2425 | base_class_access_list SCSPEC see_typename
2426 { if ($2 != ridpointers[(int)RID_VIRTUAL])
2427 cp_error ("`%D' access", $2);
2428 else if ($$ == access_public_node)
2429 $$ = access_public_virtual_node;
2430 else if ($$ == access_protected_node)
2431 $$ = access_protected_virtual_node;
2432 else if ($$ == access_private_node)
2433 $$ = access_private_virtual_node;
2435 error ("multiple `virtual' specifiers");
2439 opt.component_decl_list:
2440 | component_decl_list
2441 | opt.component_decl_list access_specifier component_decl_list
2442 | opt.component_decl_list access_specifier
2448 if (current_aggr == signature_type_node)
2450 error ("access specifier not allowed in signature");
2451 $1 = access_public_node;
2454 current_access_specifier = $1;
2458 /* Note: we no longer warn about the semicolon after a component_decl_list.
2459 ARM $9.2 says that the semicolon is optional, and therefore allowed. */
2460 component_decl_list:
2463 finish_member_declaration ($1);
2465 | component_decl_list component_decl
2467 finish_member_declaration ($2);
2472 component_decl_1 ';'
2473 | component_decl_1 '}'
2474 { error ("missing ';' before right brace");
2475 yyungetc ('}', 0); }
2476 /* C++: handle constructors, destructors and inline functions */
2477 /* note that INLINE is like a TYPESPEC */
2478 | fn.def2 ':' /* base_init compstmt */
2479 { $$ = finish_method ($$); }
2480 | fn.def2 TRY /* base_init compstmt */
2481 { $$ = finish_method ($$); }
2482 | fn.def2 RETURN_KEYWORD /* base_init compstmt */
2483 { $$ = finish_method ($$); }
2484 | fn.def2 '{' /* nodecls compstmt */
2485 { $$ = finish_method ($$); }
2488 | extension component_decl
2490 pedantic = $<itype>1; }
2491 | template_header component_decl
2494 $$ = finish_member_template_decl ($2);
2496 /* The component was already processed. */
2499 finish_template_decl ($1);
2501 | template_header typed_declspecs ';'
2503 $$ = finish_member_class_template ($2.t);
2504 finish_template_decl ($1);
2509 /* Do not add a "typed_declspecs declarator" rule here for
2510 speed; we need to call grok_x_components for enums, so the
2511 speedup would be insignificant. */
2512 typed_declspecs components
2514 /* Most of the productions for component_decl only
2515 allow the creation of one new member, so we call
2516 finish_member_declaration in component_decl_list.
2517 For this rule and the next, however, there can be
2518 more than one member, e.g.:
2522 and we need the first member to be fully
2523 registered before the second is processed.
2524 Therefore, the rules for components take care of
2525 this processing. To avoid registering the
2526 components more than once, we send NULL_TREE up
2527 here; that lets finish_member_declaration know
2528 that there is nothing to do. */
2530 grok_x_components ($1.t);
2533 | declmods notype_components
2536 grok_x_components ($1);
2539 | notype_declarator maybeasm maybe_attribute maybe_init
2540 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2541 build_tree_list ($3, NULL_TREE)); }
2542 | constructor_declarator maybeasm maybe_attribute maybe_init
2543 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2544 build_tree_list ($3, NULL_TREE)); }
2545 | ':' expr_no_commas
2546 { $$ = grokbitfield (NULL_TREE, NULL_TREE, $2); }
2550 /* These rules introduce a reduce/reduce conflict; in
2551 typedef int foo, bar;
2555 should "A::foo" be declared as a function or "A::bar" as a data
2556 member? In other words, is "bar" an after_type_declarator or a
2558 | declmods component_constructor_declarator maybeasm maybe_attribute maybe_init
2559 { tree specs, attrs;
2560 split_specs_attrs ($1, &specs, &attrs);
2561 $$ = grokfield ($2, specs, $5, $3,
2562 build_tree_list ($4, attrs)); }
2563 | component_constructor_declarator maybeasm maybe_attribute maybe_init
2564 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2565 build_tree_list ($3, NULL_TREE)); }
2567 { $$ = do_class_using_decl ($1); }
2569 /* The case of exactly one component is handled directly by component_decl. */
2572 /* empty: possibly anonymous */
2574 | component_declarator0
2576 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2577 $1 = finish_member_template_decl ($1);
2578 finish_member_declaration ($1);
2581 | components ',' component_declarator
2583 check_multiple_declarators ();
2584 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2585 $3 = finish_member_template_decl ($3);
2586 finish_member_declaration ($3);
2592 /* empty: possibly anonymous */
2594 | notype_component_declarator0
2596 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2597 $1 = finish_member_template_decl ($1);
2598 finish_member_declaration ($1);
2601 | notype_components ',' notype_component_declarator
2603 check_multiple_declarators ();
2604 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2605 $3 = finish_member_template_decl ($3);
2606 finish_member_declaration ($3);
2611 component_declarator0:
2612 after_type_component_declarator0
2613 | notype_component_declarator0
2616 component_declarator:
2617 after_type_component_declarator
2618 | notype_component_declarator
2621 after_type_component_declarator0:
2622 after_type_declarator maybeasm maybe_attribute maybe_init
2623 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2624 &prefix_attributes);
2625 $<ttype>0 = current_declspecs;
2626 $$ = grokfield ($$, current_declspecs, $4, $2,
2627 build_tree_list ($3, prefix_attributes)); }
2628 | TYPENAME ':' expr_no_commas maybe_attribute
2629 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2630 &prefix_attributes);
2631 $<ttype>0 = current_declspecs;
2632 $$ = grokbitfield ($$, current_declspecs, $3);
2633 cplus_decl_attributes ($$, $4, prefix_attributes); }
2636 notype_component_declarator0:
2637 notype_declarator maybeasm maybe_attribute maybe_init
2638 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2639 &prefix_attributes);
2640 $<ttype>0 = current_declspecs;
2641 $$ = grokfield ($$, current_declspecs, $4, $2,
2642 build_tree_list ($3, prefix_attributes)); }
2643 | constructor_declarator maybeasm maybe_attribute maybe_init
2644 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2645 &prefix_attributes);
2646 $<ttype>0 = current_declspecs;
2647 $$ = grokfield ($$, current_declspecs, $4, $2,
2648 build_tree_list ($3, prefix_attributes)); }
2649 | IDENTIFIER ':' expr_no_commas maybe_attribute
2650 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2651 &prefix_attributes);
2652 $<ttype>0 = current_declspecs;
2653 $$ = grokbitfield ($$, current_declspecs, $3);
2654 cplus_decl_attributes ($$, $4, prefix_attributes); }
2655 | ':' expr_no_commas maybe_attribute
2656 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2657 &prefix_attributes);
2658 $<ttype>0 = current_declspecs;
2659 $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
2660 cplus_decl_attributes ($$, $3, prefix_attributes); }
2663 after_type_component_declarator:
2664 after_type_declarator maybeasm maybe_attribute maybe_init
2665 { $$ = grokfield ($$, current_declspecs, $4, $2,
2666 build_tree_list ($3, prefix_attributes)); }
2667 | TYPENAME ':' expr_no_commas maybe_attribute
2668 { $$ = grokbitfield ($$, current_declspecs, $3);
2669 cplus_decl_attributes ($$, $4, prefix_attributes); }
2672 notype_component_declarator:
2673 notype_declarator maybeasm maybe_attribute maybe_init
2674 { $$ = grokfield ($$, current_declspecs, $4, $2,
2675 build_tree_list ($3, prefix_attributes)); }
2676 | IDENTIFIER ':' expr_no_commas maybe_attribute
2677 { $$ = grokbitfield ($$, current_declspecs, $3);
2678 cplus_decl_attributes ($$, $4, prefix_attributes); }
2679 | ':' expr_no_commas maybe_attribute
2680 { $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
2681 cplus_decl_attributes ($$, $3, prefix_attributes); }
2684 /* We chain the enumerators in reverse order.
2685 Because of the way enums are built, the order is
2686 insignificant. Take advantage of this fact. */
2690 | enumlist ',' enumerator
2691 { TREE_CHAIN ($3) = $$; $$ = $3; }
2696 { $$ = build_enumerator ($$, NULL_TREE, current_enum_type); }
2697 | identifier '=' expr_no_commas
2698 { $$ = build_enumerator ($$, $3, current_enum_type); }
2701 /* ANSI new-type-id (5.3.4) */
2703 type_specifier_seq new_declarator
2704 { $$.t = build_decl_list ($1.t, $2);
2705 $$.new_type_flag = $1.new_type_flag; }
2706 | type_specifier_seq %prec EMPTY
2707 { $$.t = build_decl_list ($1.t, NULL_TREE);
2708 $$.new_type_flag = $1.new_type_flag; }
2709 /* GNU extension to allow arrays of arbitrary types with
2710 non-constant dimension. For the use of begin_new_placement
2711 here, see the comments in unary_expr above. */
2712 | '(' .begin_new_placement type_id .finish_new_placement
2716 pedwarn ("ANSI C++ forbids array dimensions with parenthesized type in new");
2717 $$.t = build_parse_node (ARRAY_REF, TREE_VALUE ($3.t), $6);
2718 $$.t = build_decl_list (TREE_PURPOSE ($3.t), $$.t);
2719 $$.new_type_flag = $3.new_type_flag;
2724 /* empty */ %prec EMPTY
2726 | cv_qualifiers CV_QUALIFIER
2727 { $$ = decl_tree_cons (NULL_TREE, $2, $$); }
2730 nonempty_cv_qualifiers:
2732 { $$.t = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
2733 $$.new_type_flag = 0; }
2734 | nonempty_cv_qualifiers CV_QUALIFIER
2735 { $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
2736 $$.new_type_flag = $1.new_type_flag; }
2739 /* These rules must follow the rules for function declarations
2740 and component declarations. That way, longer rules are preferred. */
2744 { $<itype>$ = suspend_momentary (); }
2746 /* An expression which will not live on the momentary obstack. */
2749 { resume_momentary ((int) $<itype>1); $$ = $2; }
2752 /* An expression which will not live on the momentary obstack. */
2754 suspend_mom '(' nonnull_exprlist ')'
2755 { resume_momentary ((int) $<itype>1); $$ = $3; }
2756 | suspend_mom '(' parmlist ')'
2757 { resume_momentary ((int) $<itype>1); $$ = $3; }
2758 | suspend_mom LEFT_RIGHT
2759 { resume_momentary ((int) $<itype>1); $$ = empty_parms (); }
2760 | suspend_mom '(' error ')'
2761 { resume_momentary ((int) $<itype>1); $$ = NULL_TREE; }
2764 /* A declarator that is allowed only after an explicit typespec. */
2766 after_type_declarator_intern:
2767 after_type_declarator
2768 | attributes after_type_declarator
2770 /* Provide support for '(' attributes '*' declarator ')'
2772 $$ = decl_tree_cons ($1, $2, NULL_TREE);
2776 /* may all be followed by prec '.' */
2777 after_type_declarator:
2778 '*' nonempty_cv_qualifiers after_type_declarator_intern %prec UNARY
2779 { $$ = make_pointer_declarator ($2.t, $3); }
2780 | '&' nonempty_cv_qualifiers after_type_declarator_intern %prec UNARY
2781 { $$ = make_reference_declarator ($2.t, $3); }
2782 | '*' after_type_declarator_intern %prec UNARY
2783 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2784 | '&' after_type_declarator_intern %prec UNARY
2785 { $$ = make_reference_declarator (NULL_TREE, $2); }
2786 | ptr_to_mem cv_qualifiers after_type_declarator_intern
2787 { tree arg = make_pointer_declarator ($2, $3);
2788 $$ = build_parse_node (SCOPE_REF, $1, arg);
2790 | direct_after_type_declarator
2793 direct_after_type_declarator:
2794 direct_after_type_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2795 { $$ = make_call_declarator ($$, $2, $3, $4); }
2796 | direct_after_type_declarator '[' nonmomentary_expr ']'
2797 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
2798 | direct_after_type_declarator '[' ']'
2799 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
2800 | '(' after_type_declarator_intern ')'
2802 | nested_name_specifier type_name %prec EMPTY
2803 { push_nested_class ($1, 3);
2804 $$ = build_parse_node (SCOPE_REF, $$, $2);
2805 TREE_COMPLEXITY ($$) = current_class_depth; }
2806 | type_name %prec EMPTY
2810 type_name %prec EMPTY
2812 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2814 $$ = lookup_name ($1, 1);
2815 maybe_note_name_used_in_class ($1, $$);
2820 | global_scope type_name
2822 if (TREE_CODE ($2) == IDENTIFIER_NODE)
2823 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
2826 got_scope = NULL_TREE;
2833 | global_scope nested_type
2838 nested_name_specifier type_name %prec EMPTY
2839 { $$ = get_type_decl ($2); }
2842 /* A declarator allowed whether or not there has been
2843 an explicit typespec. These cannot redeclare a typedef-name. */
2845 notype_declarator_intern:
2847 | attributes notype_declarator
2849 /* Provide support for '(' attributes '*' declarator ')'
2851 $$ = decl_tree_cons ($1, $2, NULL_TREE);
2856 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2857 { $$ = make_pointer_declarator ($2.t, $3); }
2858 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2859 { $$ = make_reference_declarator ($2.t, $3); }
2860 | '*' notype_declarator_intern %prec UNARY
2861 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2862 | '&' notype_declarator_intern %prec UNARY
2863 { $$ = make_reference_declarator (NULL_TREE, $2); }
2864 | ptr_to_mem cv_qualifiers notype_declarator_intern
2865 { tree arg = make_pointer_declarator ($2, $3);
2866 $$ = build_parse_node (SCOPE_REF, $1, arg);
2868 | direct_notype_declarator
2871 complex_notype_declarator:
2872 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2873 { $$ = make_pointer_declarator ($2.t, $3); }
2874 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2875 { $$ = make_reference_declarator ($2.t, $3); }
2876 | '*' complex_notype_declarator %prec UNARY
2877 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2878 | '&' complex_notype_declarator %prec UNARY
2879 { $$ = make_reference_declarator (NULL_TREE, $2); }
2880 | ptr_to_mem cv_qualifiers notype_declarator_intern
2881 { tree arg = make_pointer_declarator ($2, $3);
2882 $$ = build_parse_node (SCOPE_REF, $1, arg);
2884 | complex_direct_notype_declarator
2887 complex_direct_notype_declarator:
2888 direct_notype_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2889 { $$ = make_call_declarator ($$, $2, $3, $4); }
2890 | '(' complex_notype_declarator ')'
2892 | direct_notype_declarator '[' nonmomentary_expr ']'
2893 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
2894 | direct_notype_declarator '[' ']'
2895 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
2896 | notype_qualified_id
2897 { enter_scope_of ($1); }
2898 | nested_name_specifier notype_template_declarator
2899 { got_scope = NULL_TREE;
2900 $$ = build_parse_node (SCOPE_REF, $1, $2);
2901 enter_scope_of ($$);
2906 nested_name_specifier unqualified_id
2907 { got_scope = NULL_TREE;
2908 $$ = build_parse_node (SCOPE_REF, $$, $2); }
2909 | nested_name_specifier object_template_id
2910 { got_scope = NULL_TREE;
2911 $$ = build_parse_node (SCOPE_REF, $1, $2); }
2914 notype_qualified_id:
2915 nested_name_specifier notype_unqualified_id
2916 { got_scope = NULL_TREE;
2917 $$ = build_parse_node (SCOPE_REF, $$, $2); }
2918 | nested_name_specifier object_template_id
2919 { got_scope = NULL_TREE;
2920 $$ = build_parse_node (SCOPE_REF, $1, $2); }
2925 | global_scope notype_qualified_id
2930 typespec '(' nonnull_exprlist ')'
2931 { $$ = build_functional_cast ($1.t, $3); }
2932 | typespec '(' expr_or_declarator_intern ')'
2933 { $$ = reparse_decl_as_expr ($1.t, $3); }
2934 | typespec fcast_or_absdcl %prec EMPTY
2935 { $$ = reparse_absdcl_as_expr ($1.t, $2); }
2940 | template_type %prec EMPTY
2943 nested_name_specifier:
2944 nested_name_specifier_1
2945 | nested_name_specifier nested_name_specifier_1
2947 | nested_name_specifier TEMPLATE explicit_template_type SCOPE
2948 { got_scope = $$ = make_typename_type ($1, $3); }
2951 /* Why the @#$%^& do type_name and notype_identifier need to be expanded
2952 inline here?!? (jason) */
2953 nested_name_specifier_1:
2956 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2959 maybe_note_name_used_in_class ($1, $$);
2962 complete_type (TYPE_MAIN_VARIANT (TREE_TYPE ($$)));
2966 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2968 got_scope = $$ = TREE_TYPE ($$);
2972 if (TREE_CODE ($$) == IDENTIFIER_NODE)
2976 | template_type SCOPE
2977 { got_scope = $$ = complete_type (TREE_TYPE ($1)); }
2978 /* These break 'const i;'
2982 cp_error ("`%D' is not an aggregate typedef",
2983 lastiddecl ? lastiddecl : $$);
2984 $$ = error_mark_node;
2987 { goto failed_scope; } */
2992 | global_scope typename_sub0
2997 typename_sub1 identifier %prec EMPTY
2999 if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't')
3000 $$ = make_typename_type ($1, $2);
3001 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
3002 cp_error ("`%T' is not a class or namespace", $2);
3006 if (TREE_CODE ($$) == TYPE_DECL)
3007 $$ = TREE_TYPE ($$);
3010 | typename_sub1 template_type %prec EMPTY
3011 { $$ = TREE_TYPE ($2); }
3012 | typename_sub1 explicit_template_type %prec EMPTY
3013 { $$ = make_typename_type ($1, $2); }
3014 | typename_sub1 TEMPLATE explicit_template_type %prec EMPTY
3015 { $$ = make_typename_type ($1, $3); }
3021 if (TREE_CODE ($1) == IDENTIFIER_NODE)
3022 cp_error ("`%T' is not a class or namespace", $1);
3024 | typename_sub1 typename_sub2
3026 if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't')
3027 $$ = make_typename_type ($1, $2);
3028 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
3029 cp_error ("`%T' is not a class or namespace", $2);
3033 if (TREE_CODE ($$) == TYPE_DECL)
3034 $$ = TREE_TYPE ($$);
3037 | typename_sub1 explicit_template_type SCOPE
3038 { got_scope = $$ = make_typename_type ($1, $2); }
3039 | typename_sub1 TEMPLATE explicit_template_type SCOPE
3040 { got_scope = $$ = make_typename_type ($1, $3); }
3046 if (TREE_CODE ($1) != IDENTIFIER_NODE)
3049 /* Retrieve the type for the identifier, which might involve
3050 some computation. */
3051 got_scope = $$ = complete_type (IDENTIFIER_TYPE_VALUE ($1));
3053 if ($$ == error_mark_node)
3054 cp_error ("`%T' is not a class or namespace", $1);
3058 if (TREE_CODE ($1) != IDENTIFIER_NODE)
3060 got_scope = $$ = complete_type (TREE_TYPE ($$));
3062 | template_type SCOPE
3063 { got_scope = $$ = complete_type (TREE_TYPE ($$)); }
3068 if (TREE_CODE ($$) == IDENTIFIER_NODE)
3074 explicit_template_type:
3075 identifier '<' template_arg_list_opt template_close_bracket
3076 { $$ = build_min_nt (TEMPLATE_ID_EXPR, $1, $3); }
3080 global_scope type_name
3082 if (TREE_CODE ($2) == IDENTIFIER_NODE)
3083 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
3086 got_scope = NULL_TREE;
3089 | global_scope nested_type
3094 nested_name_specifier '*'
3095 { got_scope = NULL_TREE; }
3096 | global_scope nested_name_specifier '*'
3097 { $$ = $2; got_scope = NULL_TREE; }
3100 /* All uses of explicit global scope must go through this nonterminal so
3101 that got_scope will be set before yylex is called to get the next token. */
3104 { got_scope = void_type_node; }
3107 /* ANSI new-declarator (5.3.4) */
3109 '*' cv_qualifiers new_declarator
3110 { $$ = make_pointer_declarator ($2, $3); }
3111 | '*' cv_qualifiers %prec EMPTY
3112 { $$ = make_pointer_declarator ($2, NULL_TREE); }
3113 | '&' cv_qualifiers new_declarator %prec EMPTY
3114 { $$ = make_reference_declarator ($2, $3); }
3115 | '&' cv_qualifiers %prec EMPTY
3116 { $$ = make_reference_declarator ($2, NULL_TREE); }
3117 | ptr_to_mem cv_qualifiers %prec EMPTY
3118 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3119 $$ = build_parse_node (SCOPE_REF, $1, arg);
3121 | ptr_to_mem cv_qualifiers new_declarator
3122 { tree arg = make_pointer_declarator ($2, $3);
3123 $$ = build_parse_node (SCOPE_REF, $1, arg);
3125 | direct_new_declarator %prec EMPTY
3128 /* ANSI direct-new-declarator (5.3.4) */
3129 direct_new_declarator:
3131 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3132 | direct_new_declarator '[' nonmomentary_expr ']'
3133 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3140 /* Provide support for '(' attributes '*' declarator ')'
3142 $$ = decl_tree_cons ($1, $2, NULL_TREE);
3146 /* ANSI abstract-declarator (8.1) */
3148 '*' nonempty_cv_qualifiers absdcl_intern
3149 { $$ = make_pointer_declarator ($2.t, $3); }
3151 { $$ = make_pointer_declarator (NULL_TREE, $2); }
3152 | '*' nonempty_cv_qualifiers %prec EMPTY
3153 { $$ = make_pointer_declarator ($2.t, NULL_TREE); }
3155 { $$ = make_pointer_declarator (NULL_TREE, NULL_TREE); }
3156 | '&' nonempty_cv_qualifiers absdcl_intern
3157 { $$ = make_reference_declarator ($2.t, $3); }
3159 { $$ = make_reference_declarator (NULL_TREE, $2); }
3160 | '&' nonempty_cv_qualifiers %prec EMPTY
3161 { $$ = make_reference_declarator ($2.t, NULL_TREE); }
3163 { $$ = make_reference_declarator (NULL_TREE, NULL_TREE); }
3164 | ptr_to_mem cv_qualifiers %prec EMPTY
3165 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3166 $$ = build_parse_node (SCOPE_REF, $1, arg);
3168 | ptr_to_mem cv_qualifiers absdcl_intern
3169 { tree arg = make_pointer_declarator ($2, $3);
3170 $$ = build_parse_node (SCOPE_REF, $1, arg);
3172 | direct_abstract_declarator %prec EMPTY
3175 /* ANSI direct-abstract-declarator (8.1) */
3176 direct_abstract_declarator:
3177 '(' absdcl_intern ')'
3179 /* `(typedef)1' is `int'. */
3180 | direct_abstract_declarator '(' parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3181 { $$ = make_call_declarator ($$, $3, $5, $6); }
3182 | direct_abstract_declarator LEFT_RIGHT cv_qualifiers exception_specification_opt %prec '.'
3183 { $$ = make_call_declarator ($$, empty_parms (), $3, $4); }
3184 | direct_abstract_declarator '[' nonmomentary_expr ']' %prec '.'
3185 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3186 | direct_abstract_declarator '[' ']' %prec '.'
3187 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
3188 | '(' complex_parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3189 { $$ = make_call_declarator (NULL_TREE, $2, $4, $5); }
3190 | regcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3191 { set_quals_and_spec ($$, $2, $3); }
3192 | fcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3193 { set_quals_and_spec ($$, $2, $3); }
3194 | '[' nonmomentary_expr ']' %prec '.'
3195 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3197 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, NULL_TREE); }
3200 /* For C++, decls and stmts can be intermixed, so we don't need to
3201 have a special rule that won't start parsing the stmt section
3202 until we have a stmt that parses without errors. */
3215 /* Read zero or more forward-declarations for labels
3216 that nested functions can jump to. */
3221 pedwarn ("ANSI C++ forbids label declarations"); }
3226 | label_decls label_decl
3230 LABEL identifiers_or_typenames ';'
3232 for (link = $2; link; link = TREE_CHAIN (link))
3234 tree label = shadow_label (TREE_VALUE (link));
3235 C_DECLARED_LABEL_FLAG (label) = 1;
3236 declare_nonlocal_label (label);
3241 /* This is the body of a function definition.
3242 It causes syntax errors to ignore to the next openbrace. */
3251 { $<ttype>$ = begin_compound_stmt (0); }
3253 { $$ = finish_compound_stmt (0, $<ttype>2); }
3259 $<ttype>$ = begin_if_stmt ();
3260 cond_stmt_keyword = "if";
3263 { finish_if_stmt_cond ($3, $<ttype>2); }
3264 implicitly_scoped_stmt
3265 { $<ttype>$ = finish_then_clause ($<ttype>2); }
3268 implicitly_scoped_stmt:
3270 | { $<ttype>$ = begin_compound_stmt (0); }
3272 { $$ = finish_compound_stmt (0, $<ttype>1); }
3285 { finish_expr_stmt ($1); }
3287 { begin_else_clause (); }
3288 implicitly_scoped_stmt
3290 finish_else_clause ($<ttype>1);
3293 | simple_if %prec IF
3294 { finish_if_stmt (); }
3297 $<ttype>$ = begin_while_stmt ();
3298 cond_stmt_keyword = "while";
3301 { finish_while_stmt_cond ($3, $<ttype>2); }
3303 { finish_while_stmt ($<ttype>2); }
3305 { $<ttype>$ = begin_do_stmt (); }
3306 implicitly_scoped_stmt WHILE
3308 finish_do_body ($<ttype>2);
3309 cond_stmt_keyword = "do";
3311 paren_expr_or_null ';'
3312 { finish_do_stmt ($6, $<ttype>2); }
3314 { $<ttype>$ = begin_for_stmt (); }
3315 '(' for.init.statement
3316 { finish_for_init_stmt ($<ttype>2); }
3318 { finish_for_cond ($6, $<ttype>2); }
3320 { finish_for_expr ($9, $<ttype>2); }
3322 { finish_for_stmt ($9, $<ttype>2); }
3324 { begin_switch_stmt (); }
3326 { $<ttype>$ = finish_switch_cond ($4); }
3327 implicitly_scoped_stmt
3328 { finish_switch_stmt ($4, $<ttype>6); }
3329 | CASE expr_no_commas ':'
3330 { finish_case_label ($2, NULL_TREE); }
3332 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
3333 { finish_case_label ($2, $4); }
3336 { finish_case_label (NULL_TREE, NULL_TREE); }
3339 { finish_break_stmt (); }
3341 { finish_continue_stmt (); }
3342 | RETURN_KEYWORD ';'
3343 { finish_return_stmt (NULL_TREE); }
3344 | RETURN_KEYWORD expr ';'
3345 { finish_return_stmt ($2); }
3346 | asm_keyword maybe_cv_qualifier '(' string ')' ';'
3348 finish_asm_stmt ($2, $4, NULL_TREE, NULL_TREE,
3351 /* This is the case with just output operands. */
3352 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ')' ';'
3354 finish_asm_stmt ($2, $4, $6, NULL_TREE,
3357 /* This is the case with input operands as well. */
3358 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':' asm_operands ')' ';'
3359 { finish_asm_stmt ($2, $4, $6, $8, NULL_TREE); }
3360 /* This is the case with clobbered registers as well. */
3361 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':'
3362 asm_operands ':' asm_clobbers ')' ';'
3363 { finish_asm_stmt ($2, $4, $6, $8, $10); }
3367 pedwarn ("ANSI C++ forbids computed gotos");
3368 finish_goto_stmt ($3);
3370 | GOTO identifier ';'
3371 { finish_goto_stmt ($2); }
3375 { error ("label must be followed by statement");
3382 | namespace_using_decl
3383 { do_local_using_decl ($1); }
3390 if (! current_function_parms_stored)
3391 store_parm_decls ();
3392 expand_start_early_try_stmts ();
3394 ctor_initializer_opt compstmt
3396 expand_start_all_catch ();
3400 expand_end_all_catch ();
3407 { $<ttype>$ = begin_try_block (); }
3409 { finish_try_block ($<ttype>2); }
3411 { finish_handler_sequence ($<ttype>2); }
3416 | handler_seq handler
3421 { $<ttype>$ = begin_handler(); }
3423 { finish_handler_parms ($<ttype>2); }
3425 { finish_handler ($<ttype>2); }
3429 typed_typespecs %prec EMPTY
3430 | nonempty_cv_qualifiers %prec EMPTY
3435 { expand_start_catch_block (NULL_TREE, NULL_TREE); }
3436 /* This doesn't allow reference parameters, the below does.
3437 | '(' type_specifier_seq absdcl ')'
3438 { check_for_new_type ("inside exception declarations", $2);
3439 expand_start_catch_block ($2.t, $3); }
3440 | '(' type_specifier_seq ')'
3441 { check_for_new_type ("inside exception declarations", $2);
3442 expand_start_catch_block ($2.t, NULL_TREE); }
3443 | '(' type_specifier_seq notype_declarator ')'
3444 { check_for_new_type ("inside exception declarations", $2);
3445 expand_start_catch_block ($2.t, $3); }
3446 | '(' typed_typespecs after_type_declarator ')'
3447 { check_for_new_type ("inside exception declarations", $2);
3448 expand_start_catch_block ($2.t, $3); }
3449 This allows reference parameters... */
3451 { check_for_new_type ("inside exception declarations", $2);
3452 expand_start_catch_block (TREE_PURPOSE ($2.t),
3453 TREE_VALUE ($2.t)); }
3460 label = define_label (input_filename, lineno, $1);
3461 if (label && ! minimal_parse_mode)
3462 expand_label (label);
3474 { if ($1) cplus_expand_expr_stmt ($1); }
3478 pedwarn ("ANSI C++ forbids compound statements inside for initializations");
3482 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
3486 { emit_line_note (input_filename, lineno);
3489 { emit_line_note (input_filename, lineno); }
3500 /* These are the operands other than the first string and colon
3501 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
3505 | nonnull_asm_operands
3508 nonnull_asm_operands:
3510 | nonnull_asm_operands ',' asm_operand
3511 { $$ = chainon ($$, $3); }
3516 { $$ = build_tree_list ($$, $3); }
3521 { $$ = tree_cons (NULL_TREE, $$, NULL_TREE); }
3522 | asm_clobbers ',' STRING
3523 { $$ = tree_cons (NULL_TREE, $3, $$); }
3526 /* This is what appears inside the parens in a function declarator.
3527 Its value is represented in the format that grokdeclarator expects.
3529 In C++, declaring a function with no parameters
3530 means that that function takes *no* parameters. */
3539 { $$ = finish_parmlist (build_tree_list (NULL_TREE, $1.t), 0);
3540 check_for_new_type ("inside parameter list", $1); }
3543 /* This nonterminal does not include the common sequence '(' type_id ')',
3544 as it is ambiguous and must be disambiguated elsewhere. */
3547 { $$ = finish_parmlist ($$, 0); }
3548 | parms_comma ELLIPSIS
3549 { $$ = finish_parmlist ($1, 1); }
3550 /* C++ allows an ellipsis without a separating ',' */
3552 { $$ = finish_parmlist ($1, 1); }
3554 { $$ = finish_parmlist (build_tree_list (NULL_TREE,
3557 { $$ = finish_parmlist (NULL_TREE, 1); }
3560 /* This helps us recover from really nasty
3561 parse errors, for example, a missing right
3563 yyerror ("possibly missing ')'");
3564 $$ = finish_parmlist ($1, 0);
3570 /* This helps us recover from really nasty
3571 parse errors, for example, a missing right
3573 yyerror ("possibly missing ')'");
3574 $$ = finish_parmlist (build_tree_list (NULL_TREE,
3581 /* A default argument to a */
3584 { maybe_snarf_defarg (); }
3594 /* A nonempty list of parameter declarations or type names. */
3597 { check_for_new_type ("in a parameter list", $1);
3598 $$ = build_tree_list (NULL_TREE, $1.t); }
3600 { check_for_new_type ("in a parameter list", $1);
3601 $$ = build_tree_list ($2, $1.t); }
3602 | parms_comma full_parm
3603 { check_for_new_type ("in a parameter list", $2);
3604 $$ = chainon ($$, $2.t); }
3605 | parms_comma bad_parm
3606 { $$ = chainon ($$, build_tree_list (NULL_TREE, $2)); }
3607 | parms_comma bad_parm '=' init
3608 { $$ = chainon ($$, build_tree_list ($4, $2)); }
3614 { check_for_new_type ("in a parameter list", $1);
3615 $$ = build_tree_list (NULL_TREE, $1.t); }
3618 /* A single parameter declaration or parameter type name,
3619 as found in a parmlist. */
3621 /* Here we expand typed_declspecs inline to avoid mis-parsing of
3622 TYPESPEC IDENTIFIER. */
3623 typed_declspecs1 declarator
3624 { tree specs = strip_attrs ($1.t);
3625 $$.new_type_flag = $1.new_type_flag;
3626 $$.t = build_tree_list (specs, $2); }
3627 | typed_typespecs declarator
3628 { $$.t = build_tree_list ($1.t, $2);
3629 $$.new_type_flag = $1.new_type_flag; }
3630 | typespec declarator
3631 { $$.t = build_tree_list (build_decl_list (NULL_TREE, $1.t),
3633 $$.new_type_flag = $1.new_type_flag; }
3634 | typed_declspecs1 absdcl
3635 { tree specs = strip_attrs ($1.t);
3636 $$.t = build_tree_list (specs, $2);
3637 $$.new_type_flag = $1.new_type_flag; }
3638 | typed_declspecs1 %prec EMPTY
3639 { tree specs = strip_attrs ($1.t);
3640 $$.t = build_tree_list (specs, NULL_TREE);
3641 $$.new_type_flag = $1.new_type_flag; }
3642 | declmods notype_declarator
3643 { tree specs = strip_attrs ($1);
3644 $$.t = build_tree_list (specs, $2);
3645 $$.new_type_flag = 0; }
3650 { $$.t = build_tree_list (NULL_TREE, $1.t);
3651 $$.new_type_flag = $1.new_type_flag; }
3653 { $$.t = build_tree_list ($2, $1.t);
3654 $$.new_type_flag = $1.new_type_flag; }
3663 /* empty */ %prec EMPTY
3664 { see_typename (); }
3668 /* empty */ %prec EMPTY
3670 error ("type specifier omitted for parameter");
3671 $$ = build_tree_list (integer_type_node, NULL_TREE);
3675 error ("type specifier omitted for parameter");
3676 if (TREE_CODE ($$) == SCOPE_REF
3677 && (TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TYPE_PARM
3678 || TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TEMPLATE_PARM))
3679 cp_error (" perhaps you want `typename %E' to make it a type", $$);
3680 $$ = build_tree_list (integer_type_node, $$);
3684 exception_specification_opt:
3685 /* empty */ %prec EMPTY
3687 | THROW '(' ansi_raise_identifiers ')' %prec EMPTY
3689 | THROW LEFT_RIGHT %prec EMPTY
3690 { $$ = build_decl_list (NULL_TREE, NULL_TREE); }
3693 ansi_raise_identifier:
3695 { $$ = build_decl_list (NULL_TREE, groktypename($1.t)); }
3698 ansi_raise_identifiers:
3699 ansi_raise_identifier
3700 | ansi_raise_identifiers ',' ansi_raise_identifier
3702 TREE_CHAIN ($3) = $$;
3707 conversion_declarator:
3708 /* empty */ %prec EMPTY
3710 | '*' cv_qualifiers conversion_declarator
3711 { $$ = make_pointer_declarator ($2, $3); }
3712 | '&' cv_qualifiers conversion_declarator
3713 { $$ = make_reference_declarator ($2, $3); }
3714 | ptr_to_mem cv_qualifiers conversion_declarator
3715 { tree arg = make_pointer_declarator ($2, $3);
3716 $$ = build_parse_node (SCOPE_REF, $1, arg);
3722 { got_scope = NULL_TREE; }
3727 { $$ = ansi_opname[MULT_EXPR]; }
3729 { $$ = ansi_opname[TRUNC_DIV_EXPR]; }
3731 { $$ = ansi_opname[TRUNC_MOD_EXPR]; }
3733 { $$ = ansi_opname[PLUS_EXPR]; }
3735 { $$ = ansi_opname[MINUS_EXPR]; }
3737 { $$ = ansi_opname[BIT_AND_EXPR]; }
3739 { $$ = ansi_opname[BIT_IOR_EXPR]; }
3741 { $$ = ansi_opname[BIT_XOR_EXPR]; }
3743 { $$ = ansi_opname[BIT_NOT_EXPR]; }
3745 { $$ = ansi_opname[COMPOUND_EXPR]; }
3746 | operator ARITHCOMPARE
3747 { $$ = ansi_opname[$2]; }
3749 { $$ = ansi_opname[LT_EXPR]; }
3751 { $$ = ansi_opname[GT_EXPR]; }
3752 | operator EQCOMPARE
3753 { $$ = ansi_opname[$2]; }
3755 { $$ = ansi_assopname[$2]; }
3757 { $$ = ansi_opname [MODIFY_EXPR]; }
3759 { $$ = ansi_opname[$2]; }
3761 { $$ = ansi_opname[$2]; }
3763 { $$ = ansi_opname[POSTINCREMENT_EXPR]; }
3764 | operator MINUSMINUS
3765 { $$ = ansi_opname[PREDECREMENT_EXPR]; }
3767 { $$ = ansi_opname[TRUTH_ANDIF_EXPR]; }
3769 { $$ = ansi_opname[TRUTH_ORIF_EXPR]; }
3771 { $$ = ansi_opname[TRUTH_NOT_EXPR]; }
3773 { $$ = ansi_opname[COND_EXPR]; }
3775 { $$ = ansi_opname[$2]; }
3776 | operator POINTSAT %prec EMPTY
3777 { $$ = ansi_opname[COMPONENT_REF]; }
3778 | operator POINTSAT_STAR %prec EMPTY
3779 { $$ = ansi_opname[MEMBER_REF]; }
3780 | operator LEFT_RIGHT
3781 { $$ = ansi_opname[CALL_EXPR]; }
3783 { $$ = ansi_opname[ARRAY_REF]; }
3784 | operator NEW %prec EMPTY
3785 { $$ = ansi_opname[NEW_EXPR]; }
3786 | operator DELETE %prec EMPTY
3787 { $$ = ansi_opname[DELETE_EXPR]; }
3788 | operator NEW '[' ']'
3789 { $$ = ansi_opname[VEC_NEW_EXPR]; }
3790 | operator DELETE '[' ']'
3791 { $$ = ansi_opname[VEC_DELETE_EXPR]; }
3792 /* Names here should be looked up in class scope ALSO. */
3793 | operator type_specifier_seq conversion_declarator
3794 { $$ = grokoptypename ($2.t, $3); }
3796 { $$ = ansi_opname[ERROR_MARK]; }
3803 debug_yytranslate (value)
3806 return yytname[YYTRANSLATE (value)];