1 /* YACC parser for C++ syntax.
2 Copyright (C) 1988, 89, 93-97, 1998 Free Software Foundation, Inc.
3 Hacked by Michael Tiemann (tiemann@cygnus.com)
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
23 /* This grammar is based on the GNU CC grammar. */
25 /* Note: Bison automatically applies a default action of "$$ = $1" for
26 all derivations; this is applied before the explicit action, if one
27 is given. Keep this in mind when reading the actions. */
30 /* Cause the `yydebug' variable to be defined. */
46 /* Since parsers are distinct for each language, put the language string
47 definition here. (fnf) */
48 char *language_string = "GNU C++";
50 extern tree void_list_node;
51 extern struct obstack permanent_obstack;
53 extern int end_of_file;
55 /* Like YYERROR but do call yyerror. */
56 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
58 #define OP0(NODE) (TREE_OPERAND (NODE, 0))
59 #define OP1(NODE) (TREE_OPERAND (NODE, 1))
61 /* Contains the statement keyword (if/while/do) to include in an
62 error message if the user supplies an empty conditional expression. */
63 static char *cond_stmt_keyword;
65 static tree empty_parms PROTO((void));
67 /* Nonzero if we have an `extern "C"' acting as an extern specifier. */
71 /* Cons up an empty parameter list. */
81 || current_class_type != NULL)
82 parms = void_list_node;
92 %union {long itype; tree ttype; char *strtype; enum tree_code code; flagged_type_tree ftype; }
94 /* All identifiers that are not reserved words
95 and are not declared typedefs in the current block */
98 /* All identifiers that are declared typedefs in the current block.
99 In some contexts, they are treated just like IDENTIFIER,
100 but they can also serve as typespecs in declarations. */
104 /* A template function. */
107 /* Reserved words that specify storage class.
108 yylval contains an IDENTIFIER_NODE which indicates which one. */
111 /* Reserved words that specify type.
112 yylval contains an IDENTIFIER_NODE which indicates which one. */
115 /* Reserved words that qualify type: "const" or "volatile".
116 yylval contains an IDENTIFIER_NODE which indicates which one. */
119 /* Character or numeric constants.
120 yylval is the node for the constant. */
123 /* String constants in raw form.
124 yylval is a STRING_CST node. */
127 /* "...", used for functions with variable arglists. */
130 /* the reserved words */
131 /* SCO include files test "ASM", so use something else. */
132 %token SIZEOF ENUM /* STRUCT UNION */ IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
133 %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD TYPEOF ALIGNOF
135 %token ATTRIBUTE EXTENSION LABEL
136 %token REALPART IMAGPART
138 /* the reserved words... C++ extensions */
140 %token <ttype> VISSPEC
141 %token DELETE NEW THIS OPERATOR CXX_TRUE CXX_FALSE
142 %token NAMESPACE TYPENAME_KEYWORD USING
143 %token LEFT_RIGHT TEMPLATE
144 %token TYPEID DYNAMIC_CAST STATIC_CAST REINTERPRET_CAST CONST_CAST
147 /* Define the operator tokens and their precedences.
148 The value is an integer because, if used, it is the tree code
149 to use in the expression made from the operator. */
151 %left EMPTY /* used to resolve s/r with epsilon */
155 /* Add precedence rules to solve dangling else s/r conflict */
159 %left IDENTIFIER PFUNCNAME TYPENAME SELFNAME PTYPENAME SCSPEC TYPESPEC CV_QUALIFIER ENUM AGGR ELLIPSIS TYPEOF SIGOF OPERATOR NSNAME TYPENAME_KEYWORD
165 %right <code> ASSIGN '='
173 %left <code> EQCOMPARE
174 %left <code> ARITHCOMPARE '<' '>'
175 %left <code> LSHIFT RSHIFT
177 %left <code> '*' '/' '%'
178 %left <code> POINTSAT_STAR DOT_STAR
179 %right <code> UNARY PLUSPLUS MINUSMINUS '~'
181 %left <ttype> PAREN_STAR_PAREN LEFT_RIGHT
182 %left <code> POINTSAT '.' '(' '['
184 %right SCOPE /* C++ extension */
185 %nonassoc NEW DELETE TRY CATCH
189 %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist
190 %type <ttype> PFUNCNAME maybe_identifier
191 %type <ttype> paren_expr_or_null nontrivial_exprlist SELFNAME
192 %type <ttype> expr_no_commas cast_expr unary_expr primary string STRING
193 %type <ttype> reserved_declspecs boolean.literal
194 %type <ttype> reserved_typespecquals
195 %type <ttype> declmods
196 %type <ttype> SCSPEC TYPESPEC CV_QUALIFIER maybe_cv_qualifier
197 %type <itype> initdecls notype_initdecls initdcl /* C++ modification */
198 %type <ttype> init initlist maybeasm maybe_init defarg defarg1
199 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
200 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
201 %type <ttype> any_word
203 %type <ttype> compstmt implicitly_scoped_stmt
205 %type <ttype> declarator notype_declarator after_type_declarator
206 %type <ttype> notype_declarator_intern
207 %type <ttype> direct_notype_declarator direct_after_type_declarator
208 %type <itype> components notype_components
209 %type <ttype> component_decl component_decl_1
210 %type <ttype> component_declarator component_declarator0
211 %type <ttype> notype_component_declarator notype_component_declarator0
212 %type <ttype> after_type_component_declarator after_type_component_declarator0
213 %type <ttype> enumlist enumerator
214 %type <ttype> absdcl cv_qualifiers
215 %type <ttype> direct_abstract_declarator conversion_declarator
216 %type <ttype> new_declarator direct_new_declarator
217 %type <ttype> xexpr parmlist parms bad_parm
218 %type <ttype> identifiers_or_typenames
219 %type <ttype> fcast_or_absdcl regcast_or_absdcl
220 %type <ttype> expr_or_declarator expr_or_declarator_intern
221 %type <ttype> complex_notype_declarator
222 %type <ttype> notype_unqualified_id unqualified_id qualified_id
223 %type <ttype> template_id do_id object_template_id notype_template_declarator
224 %type <ttype> overqualified_id notype_qualified_id any_id
225 %type <ttype> complex_direct_notype_declarator functional_cast
226 %type <ttype> complex_parmlist parms_comma
227 %type <ttype> namespace_qualifier namespace_using_decl
229 %type <ftype> type_id new_type_id typed_typespecs typespec typed_declspecs
230 %type <ftype> typed_declspecs1 type_specifier_seq nonempty_cv_qualifiers
231 %type <ftype> structsp typespecqual_reserved parm named_parm full_parm
234 %token <ttype> PTYPENAME
235 %token <ttype> PRE_PARSED_FUNCTION_DECL EXTERN_LANG_STRING ALL
236 %token <ttype> PRE_PARSED_CLASS_DECL DEFARG DEFARG_MARKER
237 %type <ttype> component_constructor_declarator
238 %type <ttype> fn.def2 return_id fn.defpen constructor_declarator
239 %type <itype> ctor_initializer_opt function_try_block
240 %type <ttype> named_class_head named_class_head_sans_basetype
241 %type <ttype> named_complex_class_head_sans_basetype
242 %type <ttype> unnamed_class_head
243 %type <ttype> class_head base_class_list
244 %type <ttype> base_class_access_list
245 %type <ttype> base_class maybe_base_class_list base_class.1
246 %type <ttype> exception_specification_opt ansi_raise_identifier ansi_raise_identifiers
247 %type <ttype> operator_name
248 %type <ttype> object aggr
249 %type <itype> new delete .begin_new_placement
250 /* %type <ttype> primary_no_id */
251 %type <ttype> nonmomentary_expr maybe_parmlist
252 %type <itype> initdcl0 notype_initdcl0 member_init_list initdcl0_innards
253 %type <ttype> template_header template_parm_list template_parm
254 %type <ttype> template_type_parm template_template_parm
255 %type <code> template_close_bracket
256 %type <ttype> apparent_template_type
257 %type <ttype> template_type template_arg_list template_arg_list_opt
258 %type <ttype> template_arg
259 %type <ttype> condition xcond paren_cond_or_null
260 %type <ttype> type_name nested_name_specifier nested_type ptr_to_mem
261 %type <ttype> complete_type_name notype_identifier nonnested_type
262 %type <ttype> complex_type_name nested_name_specifier_1
263 %type <ttype> new_initializer new_placement
264 %type <ttype> using_decl
265 %type <ttype> typename_sub typename_sub0 typename_sub1 typename_sub2
266 %type <ttype> explicit_template_type
267 /* in order to recognize aggr tags as defining and thus shadowing. */
268 %token TYPENAME_DEFN IDENTIFIER_DEFN PTYPENAME_DEFN
269 %type <ttype> named_class_head_sans_basetype_defn
270 %type <ttype> identifier_defn IDENTIFIER_DEFN TYPENAME_DEFN PTYPENAME_DEFN
272 %type <ttype> self_template_type .finish_template_type
277 /* Used in lex.c for parsing pragmas. */
280 /* lex.c and pt.c depend on this being the last token. Define
281 any new tokens before this one! */
282 %token END_OF_SAVED_INPUT
285 /* List of types and structure classes of the current declaration. */
286 static tree current_declspecs;
288 /* List of prefix attributes in effect.
289 Prefix attributes are parsed by the reserved_declspecs and declmods
290 rules. They create a list that contains *both* declspecs and attrs. */
291 /* ??? It is not clear yet that all cases where an attribute can now appear in
292 a declspec list have been updated. */
293 static tree prefix_attributes;
295 /* When defining an aggregate, this is the kind of the most recent one
296 being defined. (For example, this might be class_type_node.) */
297 static tree current_aggr;
299 /* When defining an enumeration, this is the type of the enumeration. */
300 static tree current_enum_type;
302 /* Tell yyparse how to print a token's value, if yydebug is set. */
304 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
305 extern void yyprint PROTO((FILE *, int, YYSTYPE));
306 extern tree combine_strings PROTO((tree));
309 parse_decl(declarator, specs_attrs, attributes, initialized, decl)
318 split_specs_attrs (specs_attrs, ¤t_declspecs, &prefix_attributes);
319 if (current_declspecs
320 && TREE_CODE (current_declspecs) != TREE_LIST)
321 current_declspecs = get_decl_list (current_declspecs);
322 if (have_extern_spec && !used_extern_spec)
324 current_declspecs = decl_tree_cons (NULL_TREE,
325 get_identifier ("extern"),
327 used_extern_spec = 1;
329 sm = suspend_momentary ();
330 *decl = start_decl (declarator, current_declspecs, initialized,
331 attributes, prefix_attributes);
340 { finish_translation_unit (); }
343 /* the reason for the strange actions in this rule
344 is so that notype_initdecls when reached via datadef
345 can find a valid list of type and sc specs in $0. */
348 { $<ttype>$ = NULL_TREE; }
350 { $<ttype>$ = NULL_TREE; }
351 | extdefs lang_extdef
352 { $<ttype>$ = NULL_TREE; }
361 { have_extern_spec = 1;
362 used_extern_spec = 0;
363 $<ttype>$ = NULL_TREE; }
366 { have_extern_spec = 0; }
371 { $<itype>$ = pedantic;
380 { if (pending_lang_change) do_pending_lang_change(); }
382 { if (! toplevel_bindings_p () && ! pseudo_global_level_p())
387 fndef eat_saved_input
388 { if (pending_inlines) do_pending_inlines (); }
390 { if (pending_inlines) do_pending_inlines (); }
392 { if (pending_inlines) do_pending_inlines (); }
393 | asm_keyword '(' string ')' ';'
394 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
396 | extern_lang_string '{' extdefs_opt '}'
397 { pop_lang_context (); }
398 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
399 { if (pending_inlines) do_pending_inlines ();
400 pop_lang_context (); }
401 | extern_lang_string .hush_warning datadef .warning_ok
402 { if (pending_inlines) do_pending_inlines ();
403 pop_lang_context (); }
404 | NAMESPACE identifier '{'
405 { push_namespace ($2); }
407 { pop_namespace (); }
409 { push_namespace (NULL_TREE); }
411 { pop_namespace (); }
414 { do_toplevel_using_decl ($1); }
417 { pedantic = $<itype>1; }
421 NAMESPACE identifier '='
422 { begin_only_namespace_names (); }
425 end_only_namespace_names ();
428 do_namespace_alias ($2, $5);
435 | USING global_scope qualified_id
437 | USING global_scope unqualified_id
441 namespace_using_decl:
442 USING namespace_qualifier identifier
443 { $$ = build_parse_node (SCOPE_REF, $2, $3); }
444 | USING global_scope identifier
445 { $$ = build_parse_node (SCOPE_REF, global_namespace, $3); }
446 | USING global_scope namespace_qualifier identifier
447 { $$ = build_parse_node (SCOPE_REF, $3, $4); }
452 { begin_only_namespace_names (); }
455 end_only_namespace_names ();
456 /* If no declaration was found, the using-directive is
457 invalid. Since that was not reported, we need the
458 identifier for the error message. */
459 if (TREE_CODE ($4) == IDENTIFIER_NODE && lastiddecl)
461 do_using_directive ($4);
468 if (TREE_CODE ($$) == IDENTIFIER_NODE)
472 | namespace_qualifier NSNAME SCOPE
475 if (TREE_CODE ($$) == IDENTIFIER_NODE)
483 | global_scope qualified_id
485 | global_scope unqualified_id
491 { push_lang_context ($1); }
492 | extern_lang_string EXTERN_LANG_STRING
493 { if (current_lang_name != $2)
494 cp_error ("use of linkage spec `%D' is different from previous spec `%D'", $2, current_lang_name);
495 pop_lang_context (); push_lang_context ($2); }
500 { begin_template_parm_list (); }
501 template_parm_list '>'
502 { $$ = end_template_parm_list ($4); }
504 { begin_specialization();
510 { $$ = process_template_parm (NULL_TREE, $1); }
511 | template_parm_list ',' template_parm
512 { $$ = process_template_parm ($1, $3); }
522 aggr maybe_identifier
523 { $$ = finish_template_type_parm ($1, $2); }
524 | TYPENAME_KEYWORD maybe_identifier
525 { $$ = finish_template_type_parm (class_type_node, $2); }
528 template_template_parm:
529 template_header aggr maybe_identifier
530 { $$ = finish_template_template_parm ($2, $3); }
534 /* The following rules introduce a new reduce/reduce
535 conflict on the ',' and '>' input tokens: they are valid
536 prefixes for a `structsp', which means they could match a
537 nameless parameter. See 14.6, paragraph 3.
538 By putting them before the `parm' rule, we get
539 their match before considering them nameless parameter
542 { $$ = build_tree_list (NULL_TREE, $1); }
543 | template_type_parm '=' type_id
544 { $$ = build_tree_list (groktypename ($3.t), $1); }
546 { $$ = build_tree_list (NULL_TREE, $1.t); }
547 | parm '=' expr_no_commas %prec ARITHCOMPARE
548 { $$ = build_tree_list ($3, $1.t); }
549 | template_template_parm
550 { $$ = build_tree_list (NULL_TREE, $1); }
551 | template_template_parm '=' template_arg
553 if (TREE_CODE ($3) != TEMPLATE_DECL
554 && TREE_CODE ($3) != TEMPLATE_TEMPLATE_PARM
555 && TREE_CODE ($3) != TYPE_DECL)
557 error ("invalid default template argument");
558 $3 = error_mark_node;
560 $$ = build_tree_list ($3, $1);
565 template_header template_extdef
566 { finish_template_decl ($1); }
567 | template_header error %prec EMPTY
568 { finish_template_decl ($1); }
572 fndef eat_saved_input
573 { if (pending_inlines) do_pending_inlines (); }
575 { if (pending_inlines) do_pending_inlines (); }
577 { if (pending_inlines) do_pending_inlines (); }
578 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
579 { if (pending_inlines) do_pending_inlines ();
580 pop_lang_context (); }
581 | extern_lang_string .hush_warning template_datadef .warning_ok
582 { if (pending_inlines) do_pending_inlines ();
583 pop_lang_context (); }
584 | extension template_extdef
585 { pedantic = $<itype>1; }
590 | declmods notype_initdecls ';'
592 | typed_declspecs initdecls ';'
593 { note_list_got_semicolon ($1.t); }
595 { maybe_process_partial_specialization ($1.t);
596 note_got_semicolon ($1.t); }
601 | declmods notype_initdecls ';'
603 | typed_declspecs initdecls ';'
604 { note_list_got_semicolon ($1.t); }
606 { pedwarn ("empty declaration"); }
607 | explicit_instantiation ';'
608 | typed_declspecs ';'
611 split_specs_attrs ($1.t, &t, &attrs);
613 note_list_got_semicolon ($1.t);
620 ctor_initializer_opt:
639 fn.def1 maybe_return_init ctor_initializer_opt compstmt_or_error
640 { finish_function (lineno, (int)$3, 0); }
641 | fn.def1 maybe_return_init function_try_block
643 int nested = (hack_decl_function_context
644 (current_function_decl) != NULL_TREE);
645 finish_function (lineno, (int)$3, nested);
647 | fn.def1 maybe_return_init error
651 constructor_declarator:
652 nested_name_specifier SELFNAME '('
653 { $$ = begin_constructor_declarator ($1, $2); }
654 parmlist ')' cv_qualifiers exception_specification_opt
655 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
656 | nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
657 { $$ = begin_constructor_declarator ($1, $2);
658 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
660 | global_scope nested_name_specifier SELFNAME '('
661 { $$ = begin_constructor_declarator ($2, $3); }
662 parmlist ')' cv_qualifiers exception_specification_opt
663 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
664 | global_scope nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
665 { $$ = begin_constructor_declarator ($2, $3);
666 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
668 | nested_name_specifier self_template_type '('
669 { $$ = begin_constructor_declarator ($1, $2); }
670 parmlist ')' cv_qualifiers exception_specification_opt
671 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
672 | nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
673 { $$ = begin_constructor_declarator ($1, $2);
674 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
676 | global_scope nested_name_specifier self_template_type '('
677 { $$ = begin_constructor_declarator ($2, $3); }
678 parmlist ')' cv_qualifiers exception_specification_opt
679 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
680 | global_scope nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
681 { $$ = begin_constructor_declarator ($2, $3);
682 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
687 typed_declspecs declarator
688 { if (!begin_function_definition ($1.t, $2))
690 | declmods notype_declarator
691 { if (!begin_function_definition ($1, $2))
694 { if (!begin_function_definition (NULL_TREE, $1))
696 | declmods constructor_declarator
697 { if (!begin_function_definition ($1, $2))
699 | constructor_declarator
700 { if (!begin_function_definition (NULL_TREE, $1))
704 component_constructor_declarator:
705 SELFNAME '(' parmlist ')' cv_qualifiers exception_specification_opt
706 { $$ = make_call_declarator ($1, $3, $5, $6); }
707 | SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
708 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
709 | self_template_type '(' parmlist ')' cv_qualifiers exception_specification_opt
710 { $$ = make_call_declarator ($1, $3, $5, $6); }
711 | self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
712 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
715 /* more C++ complexity. See component_decl for a comment on the
716 reduce/reduce conflict introduced by these rules. */
718 declmods component_constructor_declarator
720 split_specs_attrs ($1, &specs, &attrs);
721 attrs = build_tree_list (attrs, NULL_TREE);
722 $$ = start_method (specs, $2, attrs);
726 if (yychar == YYEMPTY)
728 reinit_parse_for_method (yychar, $$); }
729 | component_constructor_declarator
730 { $$ = start_method (NULL_TREE, $1, NULL_TREE);
732 | typed_declspecs declarator
734 split_specs_attrs ($1.t, &specs, &attrs);
735 attrs = build_tree_list (attrs, NULL_TREE);
736 $$ = start_method (specs, $2, attrs); goto rest_of_mdef; }
737 | declmods notype_declarator
739 split_specs_attrs ($1, &specs, &attrs);
740 attrs = build_tree_list (attrs, NULL_TREE);
741 $$ = start_method (specs, $2, attrs); goto rest_of_mdef; }
743 { $$ = start_method (NULL_TREE, $$, NULL_TREE);
745 | declmods constructor_declarator
747 split_specs_attrs ($1, &specs, &attrs);
748 attrs = build_tree_list (attrs, NULL_TREE);
749 $$ = start_method (specs, $2, attrs); goto rest_of_mdef; }
750 | constructor_declarator
751 { $$ = start_method (NULL_TREE, $$, NULL_TREE);
758 if (! current_function_parms_stored)
766 { store_return_init ($<ttype>$, $2); }
767 | return_id '(' nonnull_exprlist ')'
768 { store_return_init ($<ttype>$, $3); }
769 | return_id LEFT_RIGHT
770 { store_return_init ($<ttype>$, NULL_TREE); }
774 ':' .set_base_init member_init_list
777 error ("no base initializers given following ':'");
779 /* Always keep the BLOCK node associated with the outermost
780 pair of curley braces of a function. These are needed
781 for correct operation of dwarfout.c. */
789 if (! current_function_parms_stored)
792 if (DECL_CONSTRUCTOR_P (current_function_decl))
794 /* Make a contour for the initializer list. */
797 expand_start_bindings (0);
799 else if (current_class_type == NULL_TREE)
800 error ("base initializers not allowed for non-member functions");
801 else if (! DECL_CONSTRUCTOR_P (current_function_decl))
802 error ("only constructors take base initializers");
811 | member_init_list ',' member_init
812 | member_init_list error
816 '(' nonnull_exprlist ')'
818 if (current_class_name)
819 pedwarn ("anachronistic old style base class initializer");
820 expand_member_init (current_class_ref, NULL_TREE, $2);
824 if (current_class_name)
825 pedwarn ("anachronistic old style base class initializer");
826 expand_member_init (current_class_ref, NULL_TREE, void_type_node);
828 | notype_identifier '(' nonnull_exprlist ')'
829 { expand_member_init (current_class_ref, $1, $3); }
830 | notype_identifier LEFT_RIGHT
831 { expand_member_init (current_class_ref, $1, void_type_node); }
832 | nonnested_type '(' nonnull_exprlist ')'
833 { expand_member_init (current_class_ref, $1, $3); }
834 | nonnested_type LEFT_RIGHT
835 { expand_member_init (current_class_ref, $1, void_type_node); }
836 | typename_sub '(' nonnull_exprlist ')'
837 { expand_member_init (current_class_ref, TYPE_MAIN_DECL ($1),
839 | typename_sub LEFT_RIGHT
840 { expand_member_init (current_class_ref, TYPE_MAIN_DECL ($1),
864 explicit_instantiation:
865 TEMPLATE begin_explicit_instantiation typespec ';'
866 { do_type_instantiation ($3.t, NULL_TREE);
868 end_explicit_instantiation
869 | TEMPLATE begin_explicit_instantiation typed_declspecs declarator
870 { tree specs = strip_attrs ($3.t);
871 do_decl_instantiation (specs, $4, NULL_TREE); }
872 end_explicit_instantiation
873 | TEMPLATE begin_explicit_instantiation notype_declarator
874 { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
875 end_explicit_instantiation
876 | TEMPLATE begin_explicit_instantiation constructor_declarator
877 { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
878 end_explicit_instantiation
879 | SCSPEC TEMPLATE begin_explicit_instantiation typespec ';'
880 { do_type_instantiation ($4.t, $1);
882 end_explicit_instantiation
883 | SCSPEC TEMPLATE begin_explicit_instantiation typed_declspecs
885 { tree specs = strip_attrs ($4.t);
886 do_decl_instantiation (specs, $5, $1); }
887 end_explicit_instantiation
888 | SCSPEC TEMPLATE begin_explicit_instantiation notype_declarator
889 { do_decl_instantiation (NULL_TREE, $4, $1); }
890 end_explicit_instantiation
891 | SCSPEC TEMPLATE begin_explicit_instantiation constructor_declarator
892 { do_decl_instantiation (NULL_TREE, $4, $1); }
893 end_explicit_instantiation
896 begin_explicit_instantiation:
897 { begin_explicit_instantiation(); }
899 end_explicit_instantiation:
900 { end_explicit_instantiation(); }
902 /* The TYPENAME expansions are to deal with use of a template class name as
903 a template within the class itself, where the template decl is hidden by
904 a type decl. Got all that? */
907 PTYPENAME '<' template_arg_list_opt template_close_bracket
908 .finish_template_type
910 | TYPENAME '<' template_arg_list_opt template_close_bracket
911 .finish_template_type
916 apparent_template_type:
918 | identifier '<' template_arg_list_opt '>'
919 .finish_template_type
923 SELFNAME '<' template_arg_list_opt template_close_bracket
924 .finish_template_type
928 .finish_template_type:
930 if (yychar == YYEMPTY)
933 $$ = finish_template_type ($<ttype>-3, $<ttype>-1,
937 template_close_bracket:
941 /* Handle `Class<Class<Type>>' without space in the `>>' */
942 pedwarn ("`>>' should be `> >' in template class name");
947 template_arg_list_opt:
955 { $$ = build_tree_list (NULL_TREE, $$); }
956 | template_arg_list ',' template_arg
957 { $$ = chainon ($$, build_tree_list (NULL_TREE, $3)); }
962 { $$ = groktypename ($1.t); }
965 | expr_no_commas %prec ARITHCOMPARE
970 { $$ = NEGATE_EXPR; }
972 { $$ = CONVERT_EXPR; }
974 { $$ = PREINCREMENT_EXPR; }
976 { $$ = PREDECREMENT_EXPR; }
978 { $$ = TRUTH_NOT_EXPR; }
983 { $$ = build_x_compound_expr ($$); }
989 { error ("ANSI C++ forbids an empty condition for `%s'",
991 $$ = integer_zero_node; }
998 { error ("ANSI C++ forbids an empty condition for `%s'",
1000 $$ = integer_zero_node; }
1014 type_specifier_seq declarator maybeasm maybe_attribute '='
1017 for (d = getdecls (); d; d = TREE_CHAIN (d))
1018 if (TREE_CODE (d) == TYPE_DECL) {
1019 tree s = TREE_TYPE (d);
1020 if (TREE_CODE (s) == RECORD_TYPE)
1021 cp_error ("definition of class `%T' in condition", s);
1022 else if (TREE_CODE (s) == ENUMERAL_TYPE)
1023 cp_error ("definition of enum `%T' in condition", s);
1026 current_declspecs = $1.t;
1027 $<itype>5 = suspend_momentary ();
1028 $<ttype>$ = start_decl ($<ttype>2, current_declspecs, 1,
1029 $4, /*prefix_attributes*/ NULL_TREE);
1033 cp_finish_decl ($<ttype>6, $7, $4, 1, LOOKUP_ONLYCONVERTING);
1034 resume_momentary ($<itype>5);
1035 $$ = convert_from_reference ($<ttype>6);
1036 if (TREE_CODE (TREE_TYPE ($$)) == ARRAY_TYPE)
1037 cp_error ("definition of array `%#D' in condition", $$);
1044 | maybe_label_decls stmts '}'
1045 | maybe_label_decls stmts error '}'
1046 | maybe_label_decls error '}'
1049 already_scoped_stmt:
1051 { $<ttype>$ = begin_compound_stmt (1); }
1053 { finish_compound_stmt (1, $<ttype>2); }
1058 nontrivial_exprlist:
1059 expr_no_commas ',' expr_no_commas
1060 { $$ = expr_tree_cons (NULL_TREE, $$,
1061 build_expr_list (NULL_TREE, $3)); }
1062 | expr_no_commas ',' error
1063 { $$ = expr_tree_cons (NULL_TREE, $$,
1064 build_expr_list (NULL_TREE, error_mark_node)); }
1065 | nontrivial_exprlist ',' expr_no_commas
1066 { chainon ($$, build_expr_list (NULL_TREE, $3)); }
1067 | nontrivial_exprlist ',' error
1068 { chainon ($$, build_expr_list (NULL_TREE, error_mark_node)); }
1073 { $$ = build_expr_list (NULL_TREE, $$); }
1074 | nontrivial_exprlist
1080 /* __extension__ turns off -pedantic for following primary. */
1081 | extension cast_expr %prec UNARY
1083 pedantic = $<itype>1; }
1084 | '*' cast_expr %prec UNARY
1085 { $$ = build_x_indirect_ref ($2, "unary *"); }
1086 | '&' cast_expr %prec UNARY
1087 { $$ = build_x_unary_op (ADDR_EXPR, $2); }
1089 { $$ = build_x_unary_op (BIT_NOT_EXPR, $2); }
1090 | unop cast_expr %prec UNARY
1091 { $$ = finish_unary_op_expr ($1, $2); }
1092 /* Refer to the address of a label as a pointer. */
1095 pedwarn ("ANSI C++ forbids `&&'");
1096 $$ = finish_label_address_expr ($2); }
1097 | SIZEOF unary_expr %prec UNARY
1098 { $$ = expr_sizeof ($2); }
1099 | SIZEOF '(' type_id ')' %prec HYPERUNARY
1100 { $$ = c_sizeof (groktypename ($3.t));
1101 check_for_new_type ("sizeof", $3); }
1102 | ALIGNOF unary_expr %prec UNARY
1103 { $$ = grok_alignof ($2); }
1104 | ALIGNOF '(' type_id ')' %prec HYPERUNARY
1105 { $$ = c_alignof (groktypename ($3.t));
1106 check_for_new_type ("alignof", $3); }
1108 /* The %prec EMPTY's here are required by the = init initializer
1109 syntax extension; see below. */
1110 | new new_type_id %prec EMPTY
1111 { $$ = build_new (NULL_TREE, $2.t, NULL_TREE, $1);
1112 check_for_new_type ("new", $2); }
1113 | new new_type_id new_initializer
1114 { $$ = build_new (NULL_TREE, $2.t, $3, $1);
1115 check_for_new_type ("new", $2); }
1116 | new new_placement new_type_id %prec EMPTY
1117 { $$ = build_new ($2, $3.t, NULL_TREE, $1);
1118 check_for_new_type ("new", $3); }
1119 | new new_placement new_type_id new_initializer
1120 { $$ = build_new ($2, $3.t, $4, $1);
1121 check_for_new_type ("new", $3); }
1122 /* The .begin_new_placement in the following rules is
1123 necessary to avoid shift/reduce conflicts that lead to
1124 mis-parsing some expressions. Of course, these constructs
1125 are not really new-placement and it is bogus to call
1126 begin_new_placement. But, the parser cannot always tell at this
1127 point whether the next thing is an expression or a type-id,
1128 so there is nothing we can do. Fortunately,
1129 begin_new_placement does nothing harmful. When we rewrite
1130 the parser, this lossage should be removed, of course. */
1131 | new '(' .begin_new_placement type_id .finish_new_placement
1133 { $$ = build_new (NULL_TREE, groktypename($4.t),
1135 check_for_new_type ("new", $4); }
1136 | new '(' .begin_new_placement type_id .finish_new_placement
1138 { $$ = build_new (NULL_TREE, groktypename($4.t), $6, $1);
1139 check_for_new_type ("new", $4); }
1140 | new new_placement '(' .begin_new_placement type_id
1141 .finish_new_placement %prec EMPTY
1142 { $$ = build_new ($2, groktypename($5.t), NULL_TREE, $1);
1143 check_for_new_type ("new", $5); }
1144 | new new_placement '(' .begin_new_placement type_id
1145 .finish_new_placement new_initializer
1146 { $$ = build_new ($2, groktypename($5.t), $7, $1);
1147 check_for_new_type ("new", $5); }
1149 | delete cast_expr %prec UNARY
1150 { $$ = delete_sanity ($2, NULL_TREE, 0, $1); }
1151 | delete '[' ']' cast_expr %prec UNARY
1152 { $$ = delete_sanity ($4, NULL_TREE, 1, $1);
1153 if (yychar == YYEMPTY)
1155 | delete '[' expr ']' cast_expr %prec UNARY
1156 { $$ = delete_sanity ($5, $3, 2, $1);
1157 if (yychar == YYEMPTY)
1159 | REALPART cast_expr %prec UNARY
1160 { $$ = build_x_unary_op (REALPART_EXPR, $2); }
1161 | IMAGPART cast_expr %prec UNARY
1162 { $$ = build_x_unary_op (IMAGPART_EXPR, $2); }
1165 /* Note this rule is not suitable for use in new_placement
1166 since it uses NULL_TREE as the argument to
1167 finish_new_placement. This rule serves only to avoid
1168 reduce/reduce conflicts in unary_expr. See the comments
1169 there on the use of begin/finish_new_placement. */
1170 .finish_new_placement:
1172 { finish_new_placement (NULL_TREE, $<itype>-1); }
1174 .begin_new_placement:
1175 { $$ = begin_new_placement (); }
1178 '(' .begin_new_placement nonnull_exprlist ')'
1179 { $$ = finish_new_placement ($3, $2); }
1180 | '{' .begin_new_placement nonnull_exprlist '}'
1181 { cp_pedwarn ("old style placement syntax, use () instead");
1182 $$ = finish_new_placement ($3, $2); }
1186 '(' nonnull_exprlist ')'
1192 cp_error ("`%T' is not a valid expression", $2.t);
1193 $$ = error_mark_node;
1195 /* GNU extension so people can use initializer lists. Note that
1196 this alters the meaning of `new int = 1', which was previously
1197 syntactically valid but semantically invalid. */
1201 pedwarn ("ANSI C++ forbids initialization of new expression with `='");
1202 if (TREE_CODE ($2) != TREE_LIST
1203 && TREE_CODE ($2) != CONSTRUCTOR)
1204 $$ = build_expr_list (NULL_TREE, $2);
1210 /* This is necessary to postpone reduction of `int ((int)(int)(int))'. */
1212 '(' type_id ')' %prec EMPTY
1213 { $2.t = finish_parmlist (build_tree_list (NULL_TREE, $2.t), 0);
1214 $$ = make_call_declarator (NULL_TREE, $2.t, NULL_TREE, NULL_TREE);
1215 check_for_new_type ("cast", $2); }
1216 | regcast_or_absdcl '(' type_id ')' %prec EMPTY
1217 { $3.t = finish_parmlist (build_tree_list (NULL_TREE, $3.t), 0);
1218 $$ = make_call_declarator ($$, $3.t, NULL_TREE, NULL_TREE);
1219 check_for_new_type ("cast", $3); }
1224 | regcast_or_absdcl unary_expr %prec UNARY
1225 { $$ = reparse_absdcl_as_casts ($$, $2); }
1226 | regcast_or_absdcl '{' initlist maybecomma '}' %prec UNARY
1228 tree init = build_nt (CONSTRUCTOR, NULL_TREE,
1231 pedwarn ("ANSI C++ forbids constructor-expressions");
1232 /* Indicate that this was a GNU C constructor expression. */
1233 TREE_HAS_CONSTRUCTOR (init) = 1;
1235 $$ = reparse_absdcl_as_casts ($$, init);
1241 /* Handle general members. */
1242 | expr_no_commas POINTSAT_STAR expr_no_commas
1243 { $$ = build_x_binary_op (MEMBER_REF, $$, $3); }
1244 | expr_no_commas DOT_STAR expr_no_commas
1245 { $$ = build_m_component_ref ($$, $3); }
1246 | expr_no_commas '+' expr_no_commas
1247 { $$ = build_x_binary_op ($2, $$, $3); }
1248 | expr_no_commas '-' expr_no_commas
1249 { $$ = build_x_binary_op ($2, $$, $3); }
1250 | expr_no_commas '*' expr_no_commas
1251 { $$ = build_x_binary_op ($2, $$, $3); }
1252 | expr_no_commas '/' expr_no_commas
1253 { $$ = build_x_binary_op ($2, $$, $3); }
1254 | expr_no_commas '%' expr_no_commas
1255 { $$ = build_x_binary_op ($2, $$, $3); }
1256 | expr_no_commas LSHIFT expr_no_commas
1257 { $$ = build_x_binary_op ($2, $$, $3); }
1258 | expr_no_commas RSHIFT expr_no_commas
1259 { $$ = build_x_binary_op ($2, $$, $3); }
1260 | expr_no_commas ARITHCOMPARE expr_no_commas
1261 { $$ = build_x_binary_op ($2, $$, $3); }
1262 | expr_no_commas '<' expr_no_commas
1263 { $$ = build_x_binary_op (LT_EXPR, $$, $3); }
1264 | expr_no_commas '>' expr_no_commas
1265 { $$ = build_x_binary_op (GT_EXPR, $$, $3); }
1266 | expr_no_commas EQCOMPARE expr_no_commas
1267 { $$ = build_x_binary_op ($2, $$, $3); }
1268 | expr_no_commas MIN_MAX expr_no_commas
1269 { $$ = build_x_binary_op ($2, $$, $3); }
1270 | expr_no_commas '&' expr_no_commas
1271 { $$ = build_x_binary_op ($2, $$, $3); }
1272 | expr_no_commas '|' expr_no_commas
1273 { $$ = build_x_binary_op ($2, $$, $3); }
1274 | expr_no_commas '^' expr_no_commas
1275 { $$ = build_x_binary_op ($2, $$, $3); }
1276 | expr_no_commas ANDAND expr_no_commas
1277 { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $$, $3); }
1278 | expr_no_commas OROR expr_no_commas
1279 { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $$, $3); }
1280 | expr_no_commas '?' xexpr ':' expr_no_commas
1281 { $$ = build_x_conditional_expr ($$, $3, $5); }
1282 | expr_no_commas '=' expr_no_commas
1283 { $$ = build_x_modify_expr ($$, NOP_EXPR, $3);
1284 if ($$ != error_mark_node)
1285 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
1286 | expr_no_commas ASSIGN expr_no_commas
1287 { $$ = build_x_modify_expr ($$, $2, $3); }
1289 { $$ = build_throw (NULL_TREE); }
1290 | THROW expr_no_commas
1291 { $$ = build_throw ($2); }
1292 /* These extensions are not defined. The second arg to build_m_component_ref
1293 is old, build_m_component_ref now does an implicit
1294 build_indirect_ref (x, NULL_PTR) on the second argument.
1295 | object '&' expr_no_commas %prec UNARY
1296 { $$ = build_m_component_ref ($$, build_x_unary_op (ADDR_EXPR, $3)); }
1297 | object unop expr_no_commas %prec UNARY
1298 { $$ = build_m_component_ref ($$, build_x_unary_op ($2, $3)); }
1299 | object '(' type_id ')' expr_no_commas %prec UNARY
1300 { tree type = groktypename ($3.t);
1301 $$ = build_m_component_ref ($$, build_c_cast (type, $5)); }
1302 | object primary_no_id %prec UNARY
1303 { $$ = build_m_component_ref ($$, $2); }
1307 notype_unqualified_id:
1308 '~' see_typename identifier
1309 { $$ = build_parse_node (BIT_NOT_EXPR, $3); }
1310 | '~' see_typename template_type
1311 { $$ = build_parse_node (BIT_NOT_EXPR, $3); }
1316 | NSNAME %prec EMPTY
1321 /* If lastiddecl is a TREE_LIST, it's a baselink, which
1322 means that we're in an expression like S::f<int>, so
1323 don't do_identifier; we only do that for unqualified
1325 if (lastiddecl && TREE_CODE (lastiddecl) != TREE_LIST)
1326 $$ = do_identifier ($<ttype>-1, 1, NULL_TREE);
1332 PFUNCNAME '<' do_id template_arg_list_opt template_close_bracket
1333 { $$ = lookup_template_function ($3, $4); }
1334 | operator_name '<' do_id template_arg_list_opt template_close_bracket
1335 { $$ = lookup_template_function ($3, $4); }
1339 TEMPLATE identifier '<' template_arg_list_opt template_close_bracket
1340 { $$ = lookup_template_function ($2, $4); }
1341 | TEMPLATE PFUNCNAME '<' template_arg_list_opt template_close_bracket
1342 { $$ = lookup_template_function ($2, $4); }
1343 | TEMPLATE operator_name '<' template_arg_list_opt
1344 template_close_bracket
1345 { $$ = lookup_template_function ($2, $4); }
1349 notype_unqualified_id
1354 expr_or_declarator_intern:
1356 | attributes expr_or_declarator
1358 /* Provide support for '(' attributes '*' declarator ')'
1360 $$ = decl_tree_cons ($1, $2, NULL_TREE);
1365 notype_unqualified_id
1366 | '*' expr_or_declarator_intern %prec UNARY
1367 { $$ = build_parse_node (INDIRECT_REF, $2); }
1368 | '&' expr_or_declarator_intern %prec UNARY
1369 { $$ = build_parse_node (ADDR_EXPR, $2); }
1370 | '(' expr_or_declarator_intern ')'
1374 notype_template_declarator:
1375 IDENTIFIER '<' template_arg_list_opt template_close_bracket
1376 { $$ = lookup_template_function ($1, $3); }
1377 | NSNAME '<' template_arg_list template_close_bracket
1378 { $$ = lookup_template_function ($1, $3); }
1381 direct_notype_declarator:
1382 complex_direct_notype_declarator
1383 /* This precedence declaration is to prefer this reduce
1384 to the Koenig lookup shift in primary, below. I hate yacc. */
1385 | notype_unqualified_id %prec '('
1386 | notype_template_declarator
1387 | '(' expr_or_declarator_intern ')'
1388 { $$ = finish_decl_parsing ($2); }
1392 notype_unqualified_id
1394 if (TREE_CODE ($1) == BIT_NOT_EXPR)
1395 $$ = build_x_unary_op (BIT_NOT_EXPR, TREE_OPERAND ($1, 0));
1397 $$ = finish_id_expr ($1);
1403 if (processing_template_decl)
1404 push_obstacks (&permanent_obstack, &permanent_obstack);
1405 $$ = combine_strings ($$);
1406 /* combine_strings doesn't set up TYPE_MAIN_VARIANT of
1407 a const array the way we want, so fix it. */
1408 if (flag_const_strings)
1409 TREE_TYPE ($$) = build_cplus_array_type
1410 (TREE_TYPE (TREE_TYPE ($$)),
1411 TYPE_DOMAIN (TREE_TYPE ($$)));
1412 if (processing_template_decl)
1416 { $$ = finish_parenthesized_expr ($2); }
1417 | '(' expr_or_declarator_intern ')'
1418 { $2 = reparse_decl_as_expr (NULL_TREE, $2);
1419 $$ = finish_parenthesized_expr ($2); }
1421 { $$ = error_mark_node; }
1423 { tree scope = current_scope ();
1424 if (!scope || TREE_CODE (scope) != FUNCTION_DECL)
1426 error ("braced-group within expression allowed only inside a function");
1430 pedwarn ("ANSI C++ forbids braced-groups within expressions");
1431 $<ttype>$ = begin_stmt_expr ();
1434 { $$ = finish_stmt_expr ($<ttype>2, $3); }
1435 /* Koenig lookup support
1436 We could store lastiddecl in $1 to avoid another lookup,
1437 but that would result in many additional reduce/reduce conflicts. */
1438 | notype_unqualified_id '(' nonnull_exprlist ')'
1439 { $$ = finish_call_expr ($1, $3, 1); }
1440 | notype_unqualified_id LEFT_RIGHT
1441 { $$ = finish_call_expr ($1, NULL_TREE, 1); }
1442 | primary '(' nonnull_exprlist ')'
1443 { $$ = finish_call_expr ($1, $3, 0); }
1444 | primary LEFT_RIGHT
1445 { $$ = finish_call_expr ($1, NULL_TREE, 0); }
1446 | primary '[' expr ']'
1447 { $$ = grok_array_decl ($$, $3); }
1449 { $$ = finish_increment_expr ($1, POSTINCREMENT_EXPR); }
1450 | primary MINUSMINUS
1451 { $$ = finish_increment_expr ($1, POSTDECREMENT_EXPR); }
1452 /* C++ extensions */
1454 { $$ = finish_this_expr (); }
1455 | CV_QUALIFIER '(' nonnull_exprlist ')'
1457 /* This is a C cast in C++'s `functional' notation
1458 using the "implicit int" extension so that:
1459 `const (3)' is equivalent to `const int (3)'. */
1462 if ($3 == error_mark_node)
1464 $$ = error_mark_node;
1468 type = cp_build_qualified_type (integer_type_node,
1469 cp_type_qual_from_rid ($1));
1470 $$ = build_c_cast (type, build_compound_expr ($3));
1473 | DYNAMIC_CAST '<' type_id '>' '(' expr ')'
1474 { tree type = groktypename ($3.t);
1475 check_for_new_type ("dynamic_cast", $3);
1476 $$ = build_dynamic_cast (type, $6); }
1477 | STATIC_CAST '<' type_id '>' '(' expr ')'
1478 { tree type = groktypename ($3.t);
1479 check_for_new_type ("static_cast", $3);
1480 $$ = build_static_cast (type, $6); }
1481 | REINTERPRET_CAST '<' type_id '>' '(' expr ')'
1482 { tree type = groktypename ($3.t);
1483 check_for_new_type ("reinterpret_cast", $3);
1484 $$ = build_reinterpret_cast (type, $6); }
1485 | CONST_CAST '<' type_id '>' '(' expr ')'
1486 { tree type = groktypename ($3.t);
1487 check_for_new_type ("const_cast", $3);
1488 $$ = build_const_cast (type, $6); }
1489 | TYPEID '(' expr ')'
1490 { $$ = build_x_typeid ($3); }
1491 | TYPEID '(' type_id ')'
1492 { tree type = groktypename ($3.t);
1493 check_for_new_type ("typeid", $3);
1494 $$ = get_typeid (TYPE_MAIN_VARIANT (type)); }
1495 | global_scope IDENTIFIER
1496 { $$ = do_scoped_id ($2, 1); }
1497 | global_scope template_id
1499 | global_scope operator_name
1501 got_scope = NULL_TREE;
1502 if (TREE_CODE ($2) == IDENTIFIER_NODE)
1503 $$ = do_scoped_id ($2, 1);
1507 | overqualified_id %prec HYPERUNARY
1508 { $$ = build_offset_ref (OP0 ($$), OP1 ($$)); }
1509 | overqualified_id '(' nonnull_exprlist ')'
1510 { $$ = finish_qualified_call_expr ($1, $3); }
1511 | overqualified_id LEFT_RIGHT
1512 { $$ = finish_qualified_call_expr ($1, NULL_TREE); }
1513 | object object_template_id %prec UNARY
1515 $$ = build_x_component_ref ($$, $2, NULL_TREE, 1);
1517 | object object_template_id '(' nonnull_exprlist ')'
1518 { $$ = finish_object_call_expr ($2, $1, $4); }
1519 | object object_template_id LEFT_RIGHT
1520 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1521 | object unqualified_id %prec UNARY
1522 { $$ = build_x_component_ref ($$, $2, NULL_TREE, 1); }
1523 | object overqualified_id %prec UNARY
1524 { if (processing_template_decl)
1525 $$ = build_min_nt (COMPONENT_REF, $1, copy_to_permanent ($2));
1527 $$ = build_object_ref ($$, OP0 ($2), OP1 ($2)); }
1528 | object unqualified_id '(' nonnull_exprlist ')'
1529 { $$ = finish_object_call_expr ($2, $1, $4); }
1530 | object unqualified_id LEFT_RIGHT
1531 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1532 | object overqualified_id '(' nonnull_exprlist ')'
1533 { $$ = finish_qualified_object_call_expr ($2, $1, $4); }
1534 | object overqualified_id LEFT_RIGHT
1535 { $$ = finish_qualified_object_call_expr ($2, $1, NULL_TREE); }
1536 /* p->int::~int() is valid -- 12.4 */
1537 | object '~' TYPESPEC LEFT_RIGHT
1538 { $$ = finish_pseudo_destructor_call_expr ($1, NULL_TREE, $3); }
1539 | object TYPESPEC SCOPE '~' TYPESPEC LEFT_RIGHT
1540 { $$ = finish_pseudo_destructor_call_expr ($1, $2, $5); }
1543 $$ = error_mark_node;
1547 /* Not needed for now.
1553 { $$ = error_mark_node; }
1555 { if (current_function_decl == 0)
1557 error ("braced-group within expression allowed only inside a function");
1560 $<ttype>$ = expand_start_stmt_expr (); }
1563 pedwarn ("ANSI C++ forbids braced-groups within expressions");
1564 $$ = expand_end_stmt_expr ($<ttype>2); }
1565 | primary_no_id '(' nonnull_exprlist ')'
1566 { $$ = build_x_function_call ($$, $3, current_class_ref); }
1567 | primary_no_id LEFT_RIGHT
1568 { $$ = build_x_function_call ($$, NULL_TREE, current_class_ref); }
1569 | primary_no_id '[' expr ']'
1571 | primary_no_id PLUSPLUS
1572 { $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); }
1573 | primary_no_id MINUSMINUS
1574 { $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); }
1576 { goto do_scoped_id; }
1577 | SCOPE operator_name
1578 { if (TREE_CODE ($2) == IDENTIFIER_NODE)
1580 goto do_scoped_operator;
1589 { got_scope = NULL_TREE; $$ = 1; }
1595 | global_scope delete
1596 { got_scope = NULL_TREE; $$ = 1; }
1601 { $$ = boolean_true_node; }
1603 { $$ = boolean_false_node; }
1606 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
1610 { $$ = chainon ($$, $2); }
1616 if (! current_function_parms_stored)
1617 store_parm_decls ();
1619 /* Always keep the BLOCK node associated with the outermost
1620 pair of curley braces of a function. These are needed
1621 for correct operation of dwarfout.c. */
1628 { got_object = TREE_TYPE ($$); }
1631 $$ = build_x_arrow ($$);
1632 got_object = TREE_TYPE ($$);
1637 typespec initdecls ';'
1639 resume_momentary ($2);
1640 if ($1.t && IS_AGGR_TYPE_CODE (TREE_CODE ($1.t)))
1641 note_got_semicolon ($1.t);
1643 | typed_declspecs initdecls ';'
1645 resume_momentary ($2);
1646 note_list_got_semicolon ($1.t);
1648 | declmods notype_initdecls ';'
1649 { resume_momentary ($2); }
1650 | typed_declspecs ';'
1653 note_list_got_semicolon ($1.t);
1656 { warning ("empty declaration"); }
1658 { pedantic = $<itype>1; }
1661 /* Any kind of declarator (thus, all declarators allowed
1662 after an explicit typespec). */
1665 after_type_declarator %prec EMPTY
1666 | notype_declarator %prec EMPTY
1669 /* This is necessary to postpone reduction of `int()()()()'. */
1671 LEFT_RIGHT %prec EMPTY
1672 { $$ = make_call_declarator (NULL_TREE, empty_parms (),
1673 NULL_TREE, NULL_TREE); }
1674 | fcast_or_absdcl LEFT_RIGHT %prec EMPTY
1675 { $$ = make_call_declarator ($$, empty_parms (), NULL_TREE,
1679 /* ANSI type-id (8.1) */
1681 typed_typespecs absdcl
1682 { $$.t = build_decl_list ($1.t, $2);
1683 $$.new_type_flag = $1.new_type_flag; }
1684 | nonempty_cv_qualifiers absdcl
1685 { $$.t = build_decl_list ($1.t, $2);
1686 $$.new_type_flag = $1.new_type_flag; }
1688 { $$.t = build_decl_list (get_decl_list ($1.t), $2);
1689 $$.new_type_flag = $1.new_type_flag; }
1690 | typed_typespecs %prec EMPTY
1691 { $$.t = build_decl_list ($1.t, NULL_TREE);
1692 $$.new_type_flag = $1.new_type_flag; }
1693 | nonempty_cv_qualifiers %prec EMPTY
1694 { $$.t = build_decl_list ($1.t, NULL_TREE);
1695 $$.new_type_flag = $1.new_type_flag; }
1698 /* Declspecs which contain at least one type specifier or typedef name.
1699 (Just `const' or `volatile' is not enough.)
1700 A typedef'd name following these is taken as a name to be declared.
1701 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1704 typed_typespecs %prec EMPTY
1710 { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1);
1711 $$.new_type_flag = $2.new_type_flag; }
1712 | typespec reserved_declspecs %prec HYPERUNARY
1713 { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2);
1714 $$.new_type_flag = $1.new_type_flag; }
1715 | typespec reserved_typespecquals reserved_declspecs
1716 { $$.t = decl_tree_cons (NULL_TREE, $1.t, chainon ($2, $3));
1717 $$.new_type_flag = $1.new_type_flag; }
1718 | declmods typespec reserved_declspecs
1719 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1));
1720 $$.new_type_flag = $2.new_type_flag; }
1721 | declmods typespec reserved_typespecquals
1722 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1));
1723 $$.new_type_flag = $2.new_type_flag; }
1724 | declmods typespec reserved_typespecquals reserved_declspecs
1725 { $$.t = decl_tree_cons (NULL_TREE, $2.t,
1726 chainon ($3, chainon ($4, $1)));
1727 $$.new_type_flag = $2.new_type_flag; }
1732 { if (extra_warnings)
1733 warning ("`%s' is not at beginning of declaration",
1734 IDENTIFIER_POINTER ($$));
1735 $$ = build_decl_list (NULL_TREE, $$); }
1736 | reserved_declspecs typespecqual_reserved
1737 { $$ = decl_tree_cons (NULL_TREE, $2.t, $$); }
1738 | reserved_declspecs SCSPEC
1739 { if (extra_warnings)
1740 warning ("`%s' is not at beginning of declaration",
1741 IDENTIFIER_POINTER ($2));
1742 $$ = decl_tree_cons (NULL_TREE, $2, $$); }
1743 | reserved_declspecs attributes
1744 { $$ = decl_tree_cons ($2, NULL_TREE, $1); }
1746 { $$ = decl_tree_cons ($1, NULL_TREE, NULL_TREE); }
1749 /* List of just storage classes and type modifiers.
1750 A declaration can start with just this, but then it cannot be used
1751 to redeclare a typedef-name.
1752 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1755 nonempty_cv_qualifiers %prec EMPTY
1756 { $$ = $1.t; TREE_STATIC ($$) = 1; }
1758 { $$ = IDENTIFIER_AS_LIST ($$); }
1759 | declmods CV_QUALIFIER
1760 { $$ = decl_tree_cons (NULL_TREE, $2, $$);
1761 TREE_STATIC ($$) = 1; }
1763 { if (extra_warnings && TREE_STATIC ($$))
1764 warning ("`%s' is not at beginning of declaration",
1765 IDENTIFIER_POINTER ($2));
1766 $$ = decl_tree_cons (NULL_TREE, $2, $$);
1767 TREE_STATIC ($$) = TREE_STATIC ($1); }
1768 | declmods attributes
1769 { $$ = decl_tree_cons ($2, NULL_TREE, $1); }
1771 { $$ = decl_tree_cons ($1, NULL_TREE, NULL_TREE); }
1774 /* Used instead of declspecs where storage classes are not allowed
1775 (that is, for typenames and structure components).
1777 C++ can takes storage classes for structure components.
1778 Don't accept a typedef-name if anything but a modifier precedes it. */
1781 typespec %prec EMPTY
1782 { $$.t = get_decl_list ($1.t);
1783 $$.new_type_flag = $1.new_type_flag; }
1784 | nonempty_cv_qualifiers typespec
1785 { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1.t);
1786 $$.new_type_flag = $2.new_type_flag; }
1787 | typespec reserved_typespecquals
1788 { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2);
1789 $$.new_type_flag = $1.new_type_flag; }
1790 | nonempty_cv_qualifiers typespec reserved_typespecquals
1791 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1792 $$.new_type_flag = $1.new_type_flag; }
1795 reserved_typespecquals:
1796 typespecqual_reserved
1797 { $$ = build_decl_list (NULL_TREE, $1.t); }
1798 | reserved_typespecquals typespecqual_reserved
1799 { $$ = decl_tree_cons (NULL_TREE, $2.t, $1); }
1802 /* A typespec (but not a type qualifier).
1803 Once we have seen one of these in a declaration,
1804 if a typedef name appears then it is being redeclared. */
1808 | TYPESPEC %prec EMPTY
1809 { $$.t = $1; $$.new_type_flag = 0; }
1810 | complete_type_name
1811 { $$.t = $1; $$.new_type_flag = 0; }
1812 | TYPEOF '(' expr ')'
1813 { $$.t = finish_typeof ($3);
1814 $$.new_type_flag = 0; }
1815 | TYPEOF '(' type_id ')'
1816 { $$.t = groktypename ($3.t);
1817 $$.new_type_flag = 0; }
1818 | SIGOF '(' expr ')'
1819 { tree type = TREE_TYPE ($3);
1821 $$.new_type_flag = 0;
1822 if (IS_AGGR_TYPE (type))
1824 sorry ("sigof type specifier");
1829 error ("`sigof' applied to non-aggregate expression");
1830 $$.t = error_mark_node;
1833 | SIGOF '(' type_id ')'
1834 { tree type = groktypename ($3.t);
1836 $$.new_type_flag = 0;
1837 if (IS_AGGR_TYPE (type))
1839 sorry ("sigof type specifier");
1844 error("`sigof' applied to non-aggregate type");
1845 $$.t = error_mark_node;
1850 /* A typespec that is a reserved word, or a type qualifier. */
1852 typespecqual_reserved:
1854 { $$.t = $1; $$.new_type_flag = 0; }
1856 { $$.t = $1; $$.new_type_flag = 0; }
1862 | initdecls ',' initdcl
1863 { check_multiple_declarators (); }
1868 | notype_initdecls ',' initdcl
1869 { check_multiple_declarators (); }
1874 | nomods_initdecls ',' initdcl
1875 { check_multiple_declarators (); }
1881 | asm_keyword '(' string ')'
1882 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3); $$ = $3; }
1886 declarator maybeasm maybe_attribute '='
1887 { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1,
1888 $3, prefix_attributes); }
1890 /* Note how the declaration of the variable is in effect while its init is parsed! */
1891 { cp_finish_decl ($<ttype>5, $6, $2, 1, LOOKUP_ONLYCONVERTING); }
1892 | declarator maybeasm maybe_attribute
1893 { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 0,
1894 $3, prefix_attributes);
1895 cp_finish_decl ($<ttype>$, NULL_TREE, $2, 1, 0); }
1898 /* This rule assumes a certain configuration of the parser stack.
1899 In particular, $0, the element directly before the beginning of
1900 this rule on the stack, must be a maybeasm. $-1 must be a
1901 declarator or notype_declarator. And $-2 must be some declmods
1902 or declspecs. We can't move the maybeasm into this rule because
1903 we need that reduce so we prefer fn.def1 when appropriate. */
1906 { $<itype>2 = parse_decl ($<ttype>-1, $<ttype>-2,
1907 $1, 1, &$<ttype>$); }
1908 /* Note how the declaration of the variable is in effect
1909 while its init is parsed! */
1911 { cp_finish_decl ($<ttype>3, $4, $<ttype>0, 1,
1912 LOOKUP_ONLYCONVERTING);
1916 $$ = parse_decl ($<ttype>-1, $<ttype>-2, $1, 0, &d);
1917 cp_finish_decl (d, NULL_TREE, $<ttype>0, 1, 0); }
1921 declarator maybeasm initdcl0_innards
1925 notype_declarator maybeasm initdcl0_innards
1930 notype_declarator maybeasm
1931 { /* Set things up as initdcl0_innards expects. */
1936 | constructor_declarator maybeasm maybe_attribute
1938 parse_decl($1, NULL_TREE, $3, 0, &d);
1939 cp_finish_decl (d, NULL_TREE, $2, 1, 0); }
1942 /* the * rules are dummies to accept the Apollo extended syntax
1943 so that the header files compile. */
1954 | attributes attribute
1955 { $$ = chainon ($1, $2); }
1959 ATTRIBUTE '(' '(' attribute_list ')' ')'
1966 | attribute_list ',' attrib
1967 { $$ = chainon ($1, $3); }
1974 { $$ = build_tree_list ($1, NULL_TREE); }
1975 | any_word '(' IDENTIFIER ')'
1976 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1977 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1978 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1979 | any_word '(' nonnull_exprlist ')'
1980 { $$ = build_tree_list ($1, $3); }
1983 /* This still leaves out most reserved keywords,
1984 shouldn't we include them? */
1993 /* A nonempty list of identifiers, including typenames. */
1994 identifiers_or_typenames:
1996 { $$ = build_tree_list (NULL_TREE, $1); }
1997 | identifiers_or_typenames ',' identifier
1998 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2002 /* empty */ %prec EMPTY
2007 /* If we are processing a template, we don't want to expand this
2011 expr_no_commas %prec '='
2013 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, NULL_TREE);
2014 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2016 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2017 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2018 | '{' initlist ',' '}'
2019 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2020 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2025 /* This chain is built in reverse order,
2026 and put in forward order where initlist is used. */
2029 { $$ = build_tree_list (NULL_TREE, $$); }
2031 { $$ = expr_tree_cons (NULL_TREE, $3, $$); }
2032 /* These are for labeled elements. */
2033 | '[' expr_no_commas ']' init
2034 { $$ = build_expr_list ($2, $4); }
2035 | identifier ':' init
2036 { $$ = build_expr_list ($$, $3); }
2037 | initlist ',' identifier ':' init
2038 { $$ = expr_tree_cons ($3, $5, $$); }
2042 PRE_PARSED_FUNCTION_DECL
2043 { start_function (NULL_TREE, TREE_VALUE ($1),
2045 reinit_parse_for_function (); }
2048 fn.defpen maybe_return_init ctor_initializer_opt compstmt_or_error
2050 int nested = (hack_decl_function_context
2051 (current_function_decl) != NULL_TREE);
2052 finish_function (lineno, (int)$3 | 2, nested);
2053 process_next_inline ($1);
2055 | fn.defpen maybe_return_init function_try_block
2057 int nested = (hack_decl_function_context
2058 (current_function_decl) != NULL_TREE);
2059 finish_function (lineno, (int)$3 | 2, nested);
2060 process_next_inline ($1);
2062 | fn.defpen maybe_return_init error
2063 { process_next_inline ($1); }
2068 | pending_inlines pending_inline eat_saved_input
2071 /* A regurgitated default argument. The value of DEFARG_MARKER will be
2072 the TREE_LIST node for the parameter in question. */
2074 DEFARG_MARKER expr_no_commas END_OF_SAVED_INPUT
2075 { replace_defarg ($1, $2); }
2076 | DEFARG_MARKER error END_OF_SAVED_INPUT
2077 { replace_defarg ($1, error_mark_node); }
2080 /* empty */ %prec EMPTY
2081 | pending_defargs defarg_again
2082 { do_pending_defargs (); }
2083 | pending_defargs error
2084 { do_pending_defargs (); }
2089 { $<itype>3 = suspend_momentary ();
2090 $<ttype>$ = current_enum_type;
2091 current_enum_type = start_enum ($2); }
2092 enumlist maybecomma_warn '}'
2093 { TYPE_VALUES (current_enum_type) = $5;
2094 $$.t = finish_enum (current_enum_type);
2095 $$.new_type_flag = 1;
2096 current_enum_type = $<ttype>4;
2097 resume_momentary ((int) $<itype>3);
2098 check_for_missing_semicolon ($$.t); }
2099 | ENUM identifier '{' '}'
2100 { $$.t = finish_enum (start_enum ($2));
2101 $$.new_type_flag = 1;
2102 check_for_missing_semicolon ($$.t); }
2104 { $<itype>2 = suspend_momentary ();
2105 $<ttype>$ = current_enum_type;
2106 current_enum_type = start_enum (make_anon_name ()); }
2107 enumlist maybecomma_warn '}'
2108 { TYPE_VALUES (current_enum_type) = $4;
2109 $$.t = finish_enum (current_enum_type);
2110 $$.new_type_flag = 1;
2111 current_enum_type = $<ttype>3;
2112 resume_momentary ((int) $<itype>1);
2113 check_for_missing_semicolon ($$.t); }
2115 { $$.t = finish_enum (start_enum (make_anon_name()));
2116 $$.new_type_flag = 1;
2117 check_for_missing_semicolon ($$.t); }
2119 { $$.t = xref_tag (enum_type_node, $2, 1);
2120 $$.new_type_flag = 0; }
2121 | ENUM complex_type_name
2122 { $$.t = xref_tag (enum_type_node, $2, 1);
2123 $$.new_type_flag = 0; }
2124 | TYPENAME_KEYWORD typename_sub
2126 $$.new_type_flag = 0;
2127 if (!processing_template_decl)
2128 cp_pedwarn ("using `typename' outside of template"); }
2129 /* C++ extensions, merged with C to avoid shift/reduce conflicts */
2130 | class_head left_curly
2131 opt.component_decl_list '}' maybe_attribute
2135 if (yychar == YYEMPTY)
2137 semi = yychar == ';';
2139 $<ttype>$ = finish_class_definition ($1, $5, semi);
2142 { finish_default_args (); }
2145 $$.new_type_flag = 1;
2146 begin_inline_definitions (); }
2147 | class_head %prec EMPTY
2149 $$.new_type_flag = 0;
2150 if (TYPE_BINFO ($1) == NULL_TREE)
2152 cp_error ("%T is not a class type", $1);
2153 $$.t = error_mark_node;
2158 /* struct B: public A; is not accepted by the WP grammar. */
2159 if (TYPE_BINFO_BASETYPES ($$.t) && !TYPE_SIZE ($$.t)
2160 && ! TYPE_BEING_DEFINED ($$.t))
2161 cp_error ("base clause without member specification for `%#T'",
2175 { if (pedantic && !in_system_header)
2176 pedwarn ("comma at end of enumerator list"); }
2182 { error ("storage class specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2184 { error ("type specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2186 { error ("type qualifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2188 { error ("no body nor ';' separates two class, struct or union declarations"); }
2190 { $$ = build_decl_list ($2, $1); }
2193 named_class_head_sans_basetype:
2201 named_class_head_sans_basetype_defn:
2202 aggr identifier_defn %prec EMPTY
2203 { current_aggr = $$; $$ = $2; }
2204 | named_class_head_sans_basetype '{'
2205 { yyungetc ('{', 1); }
2206 | named_class_head_sans_basetype ':'
2207 { yyungetc (':', 1); }
2210 named_complex_class_head_sans_basetype:
2211 aggr nested_name_specifier identifier
2214 $$ = handle_class_head ($1, $2, $3);
2216 | aggr global_scope nested_name_specifier identifier
2219 $$ = handle_class_head ($1, $3, $4);
2221 | aggr global_scope identifier
2224 $$ = handle_class_head ($1, NULL_TREE, $3);
2226 | aggr apparent_template_type
2227 { current_aggr = $$; $$ = $2; }
2228 | aggr nested_name_specifier apparent_template_type
2229 { current_aggr = $$; $$ = $3; }
2233 named_class_head_sans_basetype %prec EMPTY
2234 { $$ = xref_tag (current_aggr, $1, 1); }
2235 | named_class_head_sans_basetype_defn
2236 { $<ttype>$ = xref_tag (current_aggr, $1, 0); }
2237 /* Class name is unqualified, so we look for base classes
2238 in the current scope. */
2239 maybe_base_class_list %prec EMPTY
2243 xref_basetypes (current_aggr, $1, $<ttype>2, $3);
2245 | named_complex_class_head_sans_basetype
2246 { push_scope (CP_DECL_CONTEXT ($1)); }
2247 maybe_base_class_list
2249 pop_scope (CP_DECL_CONTEXT ($1));
2250 $$ = TREE_TYPE ($1);
2251 if (current_aggr == union_type_node
2252 && TREE_CODE ($$) != UNION_TYPE)
2253 cp_pedwarn ("`union' tag used in declaring `%#T'", $$);
2254 else if (TREE_CODE ($$) == UNION_TYPE
2255 && current_aggr != union_type_node)
2256 cp_pedwarn ("non-`union' tag used in declaring `%#T'", $$);
2257 else if (TREE_CODE ($$) == RECORD_TYPE)
2258 /* We might be specializing a template with a different
2260 CLASSTYPE_DECLARED_CLASS ($$) = (current_aggr
2261 == class_type_node);
2264 maybe_process_partial_specialization ($$);
2265 xref_basetypes (current_aggr, $1, $$, $3);
2272 { $$ = xref_tag ($$, make_anon_name (), 0);
2273 yyungetc ('{', 1); }
2281 maybe_base_class_list:
2282 /* empty */ %prec EMPTY
2284 | ':' see_typename %prec EMPTY
2285 { yyungetc(':', 1); $$ = NULL_TREE; }
2286 | ':' see_typename base_class_list %prec EMPTY
2292 | base_class_list ',' see_typename base_class
2293 { $$ = chainon ($$, $4); }
2298 { $$ = finish_base_specifier (access_default_node, $1,
2300 == signature_type_node); }
2301 | base_class_access_list see_typename base_class.1
2302 { $$ = finish_base_specifier ($1, $3,
2304 == signature_type_node); }
2309 { if ($$ != error_mark_node) $$ = TYPE_MAIN_DECL ($1); }
2311 | SIGOF '(' expr ')'
2313 if (current_aggr == signature_type_node)
2315 if (IS_AGGR_TYPE (TREE_TYPE ($3)))
2317 sorry ("`sigof' as base signature specifier");
2318 $$ = TREE_TYPE ($3);
2322 error ("`sigof' applied to non-aggregate expression");
2323 $$ = error_mark_node;
2328 error ("`sigof' in struct or class declaration");
2329 $$ = error_mark_node;
2332 | SIGOF '(' type_id ')'
2334 if (current_aggr == signature_type_node)
2336 if (IS_AGGR_TYPE (groktypename ($3.t)))
2338 sorry ("`sigof' as base signature specifier");
2339 $$ = groktypename ($3.t);
2343 error ("`sigof' applied to non-aggregate expression");
2344 $$ = error_mark_node;
2349 error ("`sigof' in struct or class declaration");
2350 $$ = error_mark_node;
2355 base_class_access_list:
2356 VISSPEC see_typename
2357 | SCSPEC see_typename
2358 { if ($1 != ridpointers[(int)RID_VIRTUAL])
2359 cp_error ("`%D' access", $1);
2360 $$ = access_default_virtual_node; }
2361 | base_class_access_list VISSPEC see_typename
2363 if ($1 != access_default_virtual_node)
2364 error ("multiple access specifiers");
2365 else if ($2 == access_public_node)
2366 $$ = access_public_virtual_node;
2367 else if ($2 == access_protected_node)
2368 $$ = access_protected_virtual_node;
2369 else /* $2 == access_private_node */
2370 $$ = access_private_virtual_node;
2372 | base_class_access_list SCSPEC see_typename
2373 { if ($2 != ridpointers[(int)RID_VIRTUAL])
2374 cp_error ("`%D' access", $2);
2375 else if ($$ == access_public_node)
2376 $$ = access_public_virtual_node;
2377 else if ($$ == access_protected_node)
2378 $$ = access_protected_virtual_node;
2379 else if ($$ == access_private_node)
2380 $$ = access_private_virtual_node;
2382 error ("multiple `virtual' specifiers");
2388 { $<ttype>0 = begin_class_definition ($<ttype>0); }
2391 opt.component_decl_list:
2392 | component_decl_list
2393 | opt.component_decl_list access_specifier component_decl_list
2394 | opt.component_decl_list access_specifier
2400 if (current_aggr == signature_type_node)
2402 error ("access specifier not allowed in signature");
2403 $1 = access_public_node;
2406 current_access_specifier = $1;
2410 /* Note: we no longer warn about the semicolon after a component_decl_list.
2411 ARM $9.2 says that the semicolon is optional, and therefore allowed. */
2412 component_decl_list:
2415 finish_member_declaration ($1);
2417 | component_decl_list component_decl
2419 finish_member_declaration ($2);
2424 component_decl_1 ';'
2425 | component_decl_1 '}'
2426 { error ("missing ';' before right brace");
2427 yyungetc ('}', 0); }
2428 /* C++: handle constructors, destructors and inline functions */
2429 /* note that INLINE is like a TYPESPEC */
2430 | fn.def2 ':' /* base_init compstmt */
2431 { $$ = finish_method ($$); }
2432 | fn.def2 TRY /* base_init compstmt */
2433 { $$ = finish_method ($$); }
2434 | fn.def2 RETURN /* base_init compstmt */
2435 { $$ = finish_method ($$); }
2436 | fn.def2 '{' /* nodecls compstmt */
2437 { $$ = finish_method ($$); }
2440 | extension component_decl
2442 pedantic = $<itype>1; }
2443 | template_header component_decl
2446 $$ = finish_member_template_decl ($2);
2448 /* The component was already processed. */
2451 finish_template_decl ($1);
2453 | template_header typed_declspecs ';'
2455 $$ = finish_member_class_template ($2.t);
2456 finish_template_decl ($1);
2461 /* Do not add a "typed_declspecs declarator" rule here for
2462 speed; we need to call grok_x_components for enums, so the
2463 speedup would be insignificant. */
2464 typed_declspecs components
2466 /* Most of the productions for component_decl only
2467 allow the creation of one new member, so we call
2468 finish_member_declaration in component_decl_list.
2469 For this rule and the next, however, there can be
2470 more than one member, e.g.:
2474 and we need the first member to be fully
2475 registered before the second is processed.
2476 Therefore, the rules for components take care of
2477 this processing. To avoid registering the
2478 components more than once, we send NULL_TREE up
2479 here; that lets finish_member_declaration now
2480 that there is nothing to do. */
2482 grok_x_components ($1.t);
2485 | declmods notype_components
2488 grok_x_components ($1);
2491 | notype_declarator maybeasm maybe_attribute maybe_init
2492 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2493 build_tree_list ($3, NULL_TREE)); }
2494 | constructor_declarator maybeasm maybe_attribute maybe_init
2495 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2496 build_tree_list ($3, NULL_TREE)); }
2497 | ':' expr_no_commas
2498 { $$ = grokbitfield (NULL_TREE, NULL_TREE, $2); }
2502 /* These rules introduce a reduce/reduce conflict; in
2503 typedef int foo, bar;
2507 should "A::foo" be declared as a function or "A::bar" as a data
2508 member? In other words, is "bar" an after_type_declarator or a
2510 | declmods component_constructor_declarator maybeasm maybe_attribute maybe_init
2511 { tree specs, attrs;
2512 split_specs_attrs ($1, &specs, &attrs);
2513 $$ = grokfield ($2, specs, $5, $3,
2514 build_tree_list ($4, attrs)); }
2515 | component_constructor_declarator maybeasm maybe_attribute maybe_init
2516 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2517 build_tree_list ($3, NULL_TREE)); }
2519 { $$ = do_class_using_decl ($1); }
2521 /* The case of exactly one component is handled directly by component_decl. */
2524 /* empty: possibly anonymous */
2526 | component_declarator0
2528 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2529 $1 = finish_member_template_decl ($1);
2530 finish_member_declaration ($1);
2533 | components ',' component_declarator
2535 check_multiple_declarators ();
2536 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2537 $3 = finish_member_template_decl ($3);
2538 finish_member_declaration ($3);
2544 /* empty: possibly anonymous */
2546 | notype_component_declarator0
2548 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2549 $1 = finish_member_template_decl ($1);
2550 finish_member_declaration ($1);
2553 | notype_components ',' notype_component_declarator
2555 check_multiple_declarators ();
2556 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2557 $3 = finish_member_template_decl ($3);
2558 finish_member_declaration ($3);
2563 component_declarator0:
2564 after_type_component_declarator0
2565 | notype_component_declarator0
2568 component_declarator:
2569 after_type_component_declarator
2570 | notype_component_declarator
2573 after_type_component_declarator0:
2574 after_type_declarator maybeasm maybe_attribute maybe_init
2575 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2576 &prefix_attributes);
2577 $<ttype>0 = current_declspecs;
2578 $$ = grokfield ($$, current_declspecs, $4, $2,
2579 build_tree_list ($3, prefix_attributes)); }
2580 | TYPENAME ':' expr_no_commas maybe_attribute
2581 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2582 &prefix_attributes);
2583 $<ttype>0 = current_declspecs;
2584 $$ = grokbitfield ($$, current_declspecs, $3);
2585 cplus_decl_attributes ($$, $4, prefix_attributes); }
2588 notype_component_declarator0:
2589 notype_declarator maybeasm maybe_attribute maybe_init
2590 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2591 &prefix_attributes);
2592 $<ttype>0 = current_declspecs;
2593 $$ = grokfield ($$, current_declspecs, $4, $2,
2594 build_tree_list ($3, prefix_attributes)); }
2595 | constructor_declarator maybeasm maybe_attribute maybe_init
2596 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2597 &prefix_attributes);
2598 $<ttype>0 = current_declspecs;
2599 $$ = grokfield ($$, current_declspecs, $4, $2,
2600 build_tree_list ($3, prefix_attributes)); }
2601 | IDENTIFIER ':' expr_no_commas maybe_attribute
2602 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2603 &prefix_attributes);
2604 $<ttype>0 = current_declspecs;
2605 $$ = grokbitfield ($$, current_declspecs, $3);
2606 cplus_decl_attributes ($$, $4, prefix_attributes); }
2607 | ':' expr_no_commas maybe_attribute
2608 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2609 &prefix_attributes);
2610 $<ttype>0 = current_declspecs;
2611 $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
2612 cplus_decl_attributes ($$, $3, prefix_attributes); }
2615 after_type_component_declarator:
2616 after_type_declarator maybeasm maybe_attribute maybe_init
2617 { $$ = grokfield ($$, current_declspecs, $4, $2,
2618 build_tree_list ($3, prefix_attributes)); }
2619 | TYPENAME ':' expr_no_commas maybe_attribute
2620 { $$ = grokbitfield ($$, current_declspecs, $3);
2621 cplus_decl_attributes ($$, $4, prefix_attributes); }
2624 notype_component_declarator:
2625 notype_declarator maybeasm maybe_attribute maybe_init
2626 { $$ = grokfield ($$, current_declspecs, $4, $2,
2627 build_tree_list ($3, prefix_attributes)); }
2628 | IDENTIFIER ':' expr_no_commas maybe_attribute
2629 { $$ = grokbitfield ($$, current_declspecs, $3);
2630 cplus_decl_attributes ($$, $4, prefix_attributes); }
2631 | ':' expr_no_commas maybe_attribute
2632 { $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
2633 cplus_decl_attributes ($$, $3, prefix_attributes); }
2636 /* We chain the enumerators in reverse order.
2637 Because of the way enums are built, the order is
2638 insignificant. Take advantage of this fact. */
2642 | enumlist ',' enumerator
2643 { TREE_CHAIN ($3) = $$; $$ = $3; }
2648 { $$ = build_enumerator ($$, NULL_TREE, current_enum_type); }
2649 | identifier '=' expr_no_commas
2650 { $$ = build_enumerator ($$, $3, current_enum_type); }
2653 /* ANSI new-type-id (5.3.4) */
2655 type_specifier_seq new_declarator
2656 { $$.t = build_decl_list ($1.t, $2);
2657 $$.new_type_flag = $1.new_type_flag; }
2658 | type_specifier_seq %prec EMPTY
2659 { $$.t = build_decl_list ($1.t, NULL_TREE);
2660 $$.new_type_flag = $1.new_type_flag; }
2661 /* GNU extension to allow arrays of arbitrary types with
2662 non-constant dimension. For the use of begin_new_placement
2663 here, see the comments in unary_expr above. */
2664 | '(' .begin_new_placement type_id .finish_new_placement
2668 pedwarn ("ANSI C++ forbids array dimensions with parenthesized type in new");
2669 $$.t = build_parse_node (ARRAY_REF, TREE_VALUE ($3.t), $6);
2670 $$.t = build_decl_list (TREE_PURPOSE ($3.t), $$.t);
2671 $$.new_type_flag = $3.new_type_flag;
2676 /* empty */ %prec EMPTY
2678 | cv_qualifiers CV_QUALIFIER
2679 { $$ = decl_tree_cons (NULL_TREE, $2, $$); }
2682 nonempty_cv_qualifiers:
2684 { $$.t = IDENTIFIER_AS_LIST ($1);
2685 $$.new_type_flag = 0; }
2686 | nonempty_cv_qualifiers CV_QUALIFIER
2687 { $$.t = decl_tree_cons (NULL_TREE, $2, $1.t);
2688 $$.new_type_flag = $1.new_type_flag; }
2691 /* These rules must follow the rules for function declarations
2692 and component declarations. That way, longer rules are preferred. */
2696 { $<itype>$ = suspend_momentary (); }
2698 /* An expression which will not live on the momentary obstack. */
2701 { resume_momentary ((int) $<itype>1); $$ = $2; }
2704 /* An expression which will not live on the momentary obstack. */
2706 suspend_mom '(' nonnull_exprlist ')'
2707 { resume_momentary ((int) $<itype>1); $$ = $3; }
2708 | suspend_mom '(' parmlist ')'
2709 { resume_momentary ((int) $<itype>1); $$ = $3; }
2710 | suspend_mom LEFT_RIGHT
2711 { resume_momentary ((int) $<itype>1); $$ = empty_parms (); }
2712 | suspend_mom '(' error ')'
2713 { resume_momentary ((int) $<itype>1); $$ = NULL_TREE; }
2716 /* A declarator that is allowed only after an explicit typespec. */
2717 /* may all be followed by prec '.' */
2718 after_type_declarator:
2719 '*' nonempty_cv_qualifiers after_type_declarator %prec UNARY
2720 { $$ = make_pointer_declarator ($2.t, $3); }
2721 | '&' nonempty_cv_qualifiers after_type_declarator %prec UNARY
2722 { $$ = make_reference_declarator ($2.t, $3); }
2723 | '*' after_type_declarator %prec UNARY
2724 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2725 | '&' after_type_declarator %prec UNARY
2726 { $$ = make_reference_declarator (NULL_TREE, $2); }
2727 | ptr_to_mem cv_qualifiers after_type_declarator
2728 { tree arg = make_pointer_declarator ($2, $3);
2729 $$ = build_parse_node (SCOPE_REF, $1, arg);
2731 | direct_after_type_declarator
2735 type_name %prec EMPTY
2737 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2739 $$ = lookup_name ($1, 1);
2740 if (current_class_type
2741 && TYPE_BEING_DEFINED (current_class_type)
2742 && ! IDENTIFIER_CLASS_VALUE ($1))
2744 /* Remember that this name has been used in the class
2745 definition, as per [class.scope0] */
2746 pushdecl_class_level ($$);
2752 | global_scope type_name
2754 if (TREE_CODE ($2) == IDENTIFIER_NODE)
2755 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
2758 got_scope = NULL_TREE;
2765 | global_scope nested_type
2770 nested_name_specifier type_name %prec EMPTY
2771 { $$ = get_type_decl ($2); }
2774 direct_after_type_declarator:
2775 direct_after_type_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2776 { $$ = make_call_declarator ($$, $2, $3, $4); }
2777 | direct_after_type_declarator '[' nonmomentary_expr ']'
2778 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
2779 | direct_after_type_declarator '[' ']'
2780 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
2781 | '(' after_type_declarator ')'
2783 | nested_name_specifier type_name %prec EMPTY
2784 { push_nested_class ($1, 3);
2785 $$ = build_parse_node (SCOPE_REF, $$, $2);
2786 TREE_COMPLEXITY ($$) = current_class_depth; }
2787 | type_name %prec EMPTY
2790 /* A declarator allowed whether or not there has been
2791 an explicit typespec. These cannot redeclare a typedef-name. */
2793 notype_declarator_intern:
2795 | attributes notype_declarator
2797 /* Provide support for '(' attributes '*' declarator ')'
2799 $$ = decl_tree_cons ($1, $2, NULL_TREE);
2804 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2805 { $$ = make_pointer_declarator ($2.t, $3); }
2806 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2807 { $$ = make_reference_declarator ($2.t, $3); }
2808 | '*' notype_declarator_intern %prec UNARY
2809 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2810 | '&' notype_declarator_intern %prec UNARY
2811 { $$ = make_reference_declarator (NULL_TREE, $2); }
2812 | ptr_to_mem cv_qualifiers notype_declarator_intern
2813 { tree arg = make_pointer_declarator ($2, $3);
2814 $$ = build_parse_node (SCOPE_REF, $1, arg);
2816 | direct_notype_declarator
2819 complex_notype_declarator:
2820 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2821 { $$ = make_pointer_declarator ($2.t, $3); }
2822 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2823 { $$ = make_reference_declarator ($2.t, $3); }
2824 | '*' complex_notype_declarator %prec UNARY
2825 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2826 | '&' complex_notype_declarator %prec UNARY
2827 { $$ = make_reference_declarator (NULL_TREE, $2); }
2828 | ptr_to_mem cv_qualifiers notype_declarator_intern
2829 { tree arg = make_pointer_declarator ($2, $3);
2830 $$ = build_parse_node (SCOPE_REF, $1, arg);
2832 | complex_direct_notype_declarator
2835 complex_direct_notype_declarator:
2836 direct_notype_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2837 { $$ = make_call_declarator ($$, $2, $3, $4); }
2838 | '(' complex_notype_declarator ')'
2840 | direct_notype_declarator '[' nonmomentary_expr ']'
2841 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
2842 | direct_notype_declarator '[' ']'
2843 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
2844 | notype_qualified_id
2845 { enter_scope_of ($1); }
2846 | nested_name_specifier notype_template_declarator
2847 { got_scope = NULL_TREE;
2848 $$ = build_parse_node (SCOPE_REF, $1, $2);
2849 enter_scope_of ($$);
2854 nested_name_specifier unqualified_id
2855 { got_scope = NULL_TREE;
2856 $$ = build_parse_node (SCOPE_REF, $$, $2); }
2857 | nested_name_specifier object_template_id
2858 { got_scope = NULL_TREE;
2859 $$ = build_parse_node (SCOPE_REF, $1, $2); }
2862 notype_qualified_id:
2863 nested_name_specifier notype_unqualified_id
2864 { got_scope = NULL_TREE;
2865 $$ = build_parse_node (SCOPE_REF, $$, $2); }
2866 | nested_name_specifier object_template_id
2867 { got_scope = NULL_TREE;
2868 $$ = build_parse_node (SCOPE_REF, $1, $2); }
2873 | global_scope notype_qualified_id
2878 typespec '(' nonnull_exprlist ')'
2879 { $$ = build_functional_cast ($1.t, $3); }
2880 | typespec '(' expr_or_declarator_intern ')'
2881 { $$ = reparse_decl_as_expr ($1.t, $3); }
2882 | typespec fcast_or_absdcl %prec EMPTY
2883 { $$ = reparse_absdcl_as_expr ($1.t, $2); }
2888 | template_type %prec EMPTY
2891 nested_name_specifier:
2892 nested_name_specifier_1
2893 | nested_name_specifier nested_name_specifier_1
2895 | nested_name_specifier TEMPLATE explicit_template_type SCOPE
2896 { got_scope = $$ = make_typename_type ($1, $3); }
2899 /* Why the @#$%^& do type_name and notype_identifier need to be expanded
2900 inline here?!? (jason) */
2901 nested_name_specifier_1:
2904 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2907 /* Remember that this name has been used in the class
2908 definition, as per [class.scope0] */
2909 if (current_class_type
2910 && TYPE_BEING_DEFINED (current_class_type)
2911 && ! IDENTIFIER_CLASS_VALUE ($1))
2912 pushdecl_class_level ($$);
2914 got_scope = $$ = TYPE_MAIN_VARIANT (TREE_TYPE ($$));
2918 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2920 got_scope = $$ = TREE_TYPE ($$);
2924 if (TREE_CODE ($$) == IDENTIFIER_NODE)
2928 | template_type SCOPE
2929 { got_scope = $$ = complete_type (TREE_TYPE ($1)); }
2930 /* These break 'const i;'
2934 cp_error ("`%D' is not an aggregate typedef",
2935 lastiddecl ? lastiddecl : $$);
2936 $$ = error_mark_node;
2939 { goto failed_scope; } */
2944 | global_scope typename_sub0
2949 typename_sub1 identifier %prec EMPTY
2951 if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't')
2952 $$ = make_typename_type ($1, $2);
2953 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
2954 cp_error ("`%T' is not a class or namespace", $2);
2958 if (TREE_CODE ($$) == TYPE_DECL)
2959 $$ = TREE_TYPE ($$);
2962 | typename_sub1 template_type %prec EMPTY
2963 { $$ = TREE_TYPE ($2); }
2964 | typename_sub1 explicit_template_type %prec EMPTY
2965 { $$ = make_typename_type ($1, $2); }
2966 | typename_sub1 TEMPLATE explicit_template_type %prec EMPTY
2967 { $$ = make_typename_type ($1, $3); }
2973 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2974 cp_error ("`%T' is not a class or namespace", $1);
2976 | typename_sub1 typename_sub2
2978 if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't')
2979 $$ = make_typename_type ($1, $2);
2980 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
2981 cp_error ("`%T' is not a class or namespace", $2);
2985 if (TREE_CODE ($$) == TYPE_DECL)
2986 $$ = TREE_TYPE ($$);
2989 | typename_sub1 explicit_template_type SCOPE
2990 { got_scope = $$ = make_typename_type ($1, $2); }
2991 | typename_sub1 TEMPLATE explicit_template_type SCOPE
2992 { got_scope = $$ = make_typename_type ($1, $3); }
2998 if (TREE_CODE ($1) != IDENTIFIER_NODE)
3001 /* Retrieve the type for the identifier, which might involve
3002 some computation. */
3003 got_scope = $$ = complete_type (IDENTIFIER_TYPE_VALUE ($1));
3005 if ($$ == error_mark_node)
3006 cp_error ("`%T' is not a class or namespace", $1);
3010 if (TREE_CODE ($1) != IDENTIFIER_NODE)
3012 got_scope = $$ = complete_type (TREE_TYPE ($$));
3014 | template_type SCOPE
3015 { got_scope = $$ = complete_type (TREE_TYPE ($$)); }
3020 if (TREE_CODE ($$) == IDENTIFIER_NODE)
3026 explicit_template_type:
3027 identifier '<' template_arg_list_opt template_close_bracket
3028 { $$ = build_min_nt (TEMPLATE_ID_EXPR, $1, $3); }
3032 global_scope type_name
3034 if (TREE_CODE ($2) == IDENTIFIER_NODE)
3035 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
3038 got_scope = NULL_TREE;
3041 | global_scope nested_type
3046 nested_name_specifier '*'
3047 { got_scope = NULL_TREE; }
3048 | global_scope nested_name_specifier '*'
3049 { $$ = $2; got_scope = NULL_TREE; }
3052 /* All uses of explicit global scope must go through this nonterminal so
3053 that got_scope will be set before yylex is called to get the next token. */
3056 { got_scope = void_type_node; }
3059 /* ANSI new-declarator (5.3.4) */
3061 '*' cv_qualifiers new_declarator
3062 { $$ = make_pointer_declarator ($2, $3); }
3063 | '*' cv_qualifiers %prec EMPTY
3064 { $$ = make_pointer_declarator ($2, NULL_TREE); }
3065 | '&' cv_qualifiers new_declarator %prec EMPTY
3066 { $$ = make_reference_declarator ($2, $3); }
3067 | '&' cv_qualifiers %prec EMPTY
3068 { $$ = make_reference_declarator ($2, NULL_TREE); }
3069 | ptr_to_mem cv_qualifiers %prec EMPTY
3070 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3071 $$ = build_parse_node (SCOPE_REF, $1, arg);
3073 | ptr_to_mem cv_qualifiers new_declarator
3074 { tree arg = make_pointer_declarator ($2, $3);
3075 $$ = build_parse_node (SCOPE_REF, $1, arg);
3077 | direct_new_declarator %prec EMPTY
3080 /* ANSI direct-new-declarator (5.3.4) */
3081 direct_new_declarator:
3083 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3084 | direct_new_declarator '[' nonmomentary_expr ']'
3085 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3088 /* ANSI abstract-declarator (8.1) */
3090 '*' nonempty_cv_qualifiers absdcl
3091 { $$ = make_pointer_declarator ($2.t, $3); }
3093 { $$ = make_pointer_declarator (NULL_TREE, $2); }
3094 | '*' nonempty_cv_qualifiers %prec EMPTY
3095 { $$ = make_pointer_declarator ($2.t, NULL_TREE); }
3097 { $$ = make_pointer_declarator (NULL_TREE, NULL_TREE); }
3098 | '&' nonempty_cv_qualifiers absdcl
3099 { $$ = make_reference_declarator ($2.t, $3); }
3101 { $$ = make_reference_declarator (NULL_TREE, $2); }
3102 | '&' nonempty_cv_qualifiers %prec EMPTY
3103 { $$ = make_reference_declarator ($2.t, NULL_TREE); }
3105 { $$ = make_reference_declarator (NULL_TREE, NULL_TREE); }
3106 | ptr_to_mem cv_qualifiers %prec EMPTY
3107 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3108 $$ = build_parse_node (SCOPE_REF, $1, arg);
3110 | ptr_to_mem cv_qualifiers absdcl
3111 { tree arg = make_pointer_declarator ($2, $3);
3112 $$ = build_parse_node (SCOPE_REF, $1, arg);
3114 | direct_abstract_declarator %prec EMPTY
3117 /* ANSI direct-abstract-declarator (8.1) */
3118 direct_abstract_declarator:
3121 /* `(typedef)1' is `int'. */
3123 | direct_abstract_declarator '(' parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3124 { $$ = make_call_declarator ($$, $3, $5, $6); }
3125 | direct_abstract_declarator LEFT_RIGHT cv_qualifiers exception_specification_opt %prec '.'
3126 { $$ = make_call_declarator ($$, empty_parms (), $3, $4); }
3127 | direct_abstract_declarator '[' nonmomentary_expr ']' %prec '.'
3128 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3129 | direct_abstract_declarator '[' ']' %prec '.'
3130 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
3131 | '(' complex_parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3132 { $$ = make_call_declarator (NULL_TREE, $2, $4, $5); }
3133 | regcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3134 { set_quals_and_spec ($$, $2, $3); }
3135 | fcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3136 { set_quals_and_spec ($$, $2, $3); }
3137 | '[' nonmomentary_expr ']' %prec '.'
3138 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3140 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, NULL_TREE); }
3143 /* For C++, decls and stmts can be intermixed, so we don't need to
3144 have a special rule that won't start parsing the stmt section
3145 until we have a stmt that parses without errors. */
3158 /* Read zero or more forward-declarations for labels
3159 that nested functions can jump to. */
3164 pedwarn ("ANSI C++ forbids label declarations"); }
3169 | label_decls label_decl
3173 LABEL identifiers_or_typenames ';'
3175 for (link = $2; link; link = TREE_CHAIN (link))
3177 tree label = shadow_label (TREE_VALUE (link));
3178 C_DECLARED_LABEL_FLAG (label) = 1;
3179 declare_nonlocal_label (label);
3184 /* This is the body of a function definition.
3185 It causes syntax errors to ignore to the next openbrace. */
3194 { $<ttype>$ = begin_compound_stmt (0); }
3196 { $$ = finish_compound_stmt (0, $<ttype>2); }
3202 $<ttype>$ = begin_if_stmt ();
3203 cond_stmt_keyword = "if";
3206 { finish_if_stmt_cond ($3, $<ttype>2); }
3207 implicitly_scoped_stmt
3208 { $<ttype>$ = finish_then_clause ($<ttype>2); }
3211 implicitly_scoped_stmt:
3213 | { $<ttype>$ = begin_compound_stmt (0); }
3215 { $$ = finish_compound_stmt (0, $<ttype>1); }
3228 { finish_expr_stmt ($1); }
3230 { begin_else_clause (); }
3231 implicitly_scoped_stmt
3233 finish_else_clause ($<ttype>1);
3236 | simple_if %prec IF
3237 { finish_if_stmt (); }
3240 $<ttype>$ = begin_while_stmt ();
3241 cond_stmt_keyword = "while";
3244 { finish_while_stmt_cond ($3, $<ttype>2); }
3246 { finish_while_stmt ($<ttype>2); }
3248 { $<ttype>$ = begin_do_stmt (); }
3249 implicitly_scoped_stmt WHILE
3251 finish_do_body ($<ttype>2);
3252 cond_stmt_keyword = "do";
3254 paren_expr_or_null ';'
3255 { finish_do_stmt ($6, $<ttype>2); }
3257 { $<ttype>$ = begin_for_stmt (); }
3258 '(' for.init.statement
3259 { finish_for_init_stmt ($<ttype>2); }
3261 { finish_for_cond ($6, $<ttype>2); }
3263 { finish_for_expr ($9, $<ttype>2); }
3265 { finish_for_stmt ($9, $<ttype>2); }
3267 { begin_switch_stmt (); }
3269 { $<ttype>$ = finish_switch_cond ($4); }
3270 implicitly_scoped_stmt
3271 { finish_switch_stmt ($4, $<ttype>6); }
3272 | CASE expr_no_commas ':'
3273 { finish_case_label ($2, NULL_TREE); }
3275 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
3276 { finish_case_label ($2, $4); }
3279 { finish_case_label (NULL_TREE, NULL_TREE); }
3282 { finish_break_stmt (); }
3284 { finish_continue_stmt (); }
3286 { finish_return_stmt (NULL_TREE); }
3288 { finish_return_stmt ($2); }
3289 | asm_keyword maybe_cv_qualifier '(' string ')' ';'
3291 finish_asm_stmt ($2, $4, NULL_TREE, NULL_TREE,
3294 /* This is the case with just output operands. */
3295 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ')' ';'
3297 finish_asm_stmt ($2, $4, $6, NULL_TREE,
3300 /* This is the case with input operands as well. */
3301 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':' asm_operands ')' ';'
3302 { finish_asm_stmt ($2, $4, $6, $8, NULL_TREE); }
3303 /* This is the case with clobbered registers as well. */
3304 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':'
3305 asm_operands ':' asm_clobbers ')' ';'
3306 { finish_asm_stmt ($2, $4, $6, $8, $10); }
3310 pedwarn ("ANSI C++ forbids computed gotos");
3311 finish_goto_stmt ($3);
3313 | GOTO identifier ';'
3314 { finish_goto_stmt ($2); }
3318 { error ("label must be followed by statement");
3325 | namespace_using_decl
3326 { do_local_using_decl ($1); }
3333 if (! current_function_parms_stored)
3334 store_parm_decls ();
3335 expand_start_early_try_stmts ();
3337 ctor_initializer_opt compstmt
3339 expand_start_all_catch ();
3343 expand_end_all_catch ();
3350 { $<ttype>$ = begin_try_block (); }
3352 { finish_try_block ($<ttype>2); }
3354 { finish_handler_sequence ($<ttype>2); }
3359 | handler_seq handler
3364 { $<ttype>$ = begin_handler(); }
3366 { finish_handler_parms ($<ttype>2); }
3368 { finish_handler ($<ttype>2); }
3372 typed_typespecs %prec EMPTY
3373 | nonempty_cv_qualifiers %prec EMPTY
3378 { expand_start_catch_block (NULL_TREE, NULL_TREE); }
3379 /* This doesn't allow reference parameters, the below does.
3380 | '(' type_specifier_seq absdcl ')'
3381 { check_for_new_type ("inside exception declarations", $2);
3382 expand_start_catch_block ($2.t, $3); }
3383 | '(' type_specifier_seq ')'
3384 { check_for_new_type ("inside exception declarations", $2);
3385 expand_start_catch_block ($2.t, NULL_TREE); }
3386 | '(' type_specifier_seq notype_declarator ')'
3387 { check_for_new_type ("inside exception declarations", $2);
3388 expand_start_catch_block ($2.t, $3); }
3389 | '(' typed_typespecs after_type_declarator ')'
3390 { check_for_new_type ("inside exception declarations", $2);
3391 expand_start_catch_block ($2.t, $3); }
3392 This allows reference parameters... */
3394 { check_for_new_type ("inside exception declarations", $2);
3395 expand_start_catch_block (TREE_PURPOSE ($2.t),
3396 TREE_VALUE ($2.t)); }
3403 label = define_label (input_filename, lineno, $1);
3404 if (label && ! minimal_parse_mode)
3405 expand_label (label);
3417 { if ($1) cplus_expand_expr_stmt ($1); }
3421 pedwarn ("ANSI C++ forbids compound statements inside for initializations");
3425 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
3429 { emit_line_note (input_filename, lineno);
3432 { emit_line_note (input_filename, lineno); }
3443 /* These are the operands other than the first string and colon
3444 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
3448 | nonnull_asm_operands
3451 nonnull_asm_operands:
3453 | nonnull_asm_operands ',' asm_operand
3454 { $$ = chainon ($$, $3); }
3459 { $$ = build_tree_list ($$, $3); }
3464 { $$ = tree_cons (NULL_TREE, $$, NULL_TREE); }
3465 | asm_clobbers ',' STRING
3466 { $$ = tree_cons (NULL_TREE, $3, $$); }
3469 /* This is what appears inside the parens in a function declarator.
3470 Its value is represented in the format that grokdeclarator expects.
3472 In C++, declaring a function with no parameters
3473 means that that function takes *no* parameters. */
3482 { $$ = finish_parmlist (build_tree_list (NULL_TREE, $1.t), 0);
3483 check_for_new_type ("inside parameter list", $1); }
3486 /* This nonterminal does not include the common sequence '(' type_id ')',
3487 as it is ambiguous and must be disambiguated elsewhere. */
3490 { $$ = finish_parmlist ($$, 0); }
3491 | parms_comma ELLIPSIS
3492 { $$ = finish_parmlist ($1, 1); }
3493 /* C++ allows an ellipsis without a separating ',' */
3495 { $$ = finish_parmlist ($1, 1); }
3497 { $$ = finish_parmlist (build_tree_list (NULL_TREE,
3500 { $$ = finish_parmlist (NULL_TREE, 1); }
3503 /* This helps us recover from really nasty
3504 parse errors, for example, a missing right
3506 yyerror ("possibly missing ')'");
3507 $$ = finish_parmlist ($1, 0);
3513 /* This helps us recover from really nasty
3514 parse errors, for example, a missing right
3516 yyerror ("possibly missing ')'");
3517 $$ = finish_parmlist (build_tree_list (NULL_TREE,
3524 /* A default argument to a */
3527 { maybe_snarf_defarg (); }
3537 /* A nonempty list of parameter declarations or type names. */
3540 { check_for_new_type ("in a parameter list", $1);
3541 $$ = build_tree_list (NULL_TREE, $1.t); }
3543 { check_for_new_type ("in a parameter list", $1);
3544 $$ = build_tree_list ($2, $1.t); }
3545 | parms_comma full_parm
3546 { check_for_new_type ("in a parameter list", $2);
3547 $$ = chainon ($$, $2.t); }
3548 | parms_comma bad_parm
3549 { $$ = chainon ($$, build_tree_list (NULL_TREE, $2)); }
3550 | parms_comma bad_parm '=' init
3551 { $$ = chainon ($$, build_tree_list ($4, $2)); }
3557 { check_for_new_type ("in a parameter list", $1);
3558 $$ = build_tree_list (NULL_TREE, $1.t); }
3561 /* A single parameter declaration or parameter type name,
3562 as found in a parmlist. */
3564 /* Here we expand typed_declspecs inline to avoid mis-parsing of
3565 TYPESPEC IDENTIFIER. */
3566 typed_declspecs1 declarator
3567 { tree specs = strip_attrs ($1.t);
3568 $$.new_type_flag = $1.new_type_flag;
3569 $$.t = build_tree_list (specs, $2); }
3570 | typed_typespecs declarator
3571 { $$.t = build_tree_list ($1.t, $2);
3572 $$.new_type_flag = $1.new_type_flag; }
3573 | typespec declarator
3574 { $$.t = build_tree_list (get_decl_list ($1.t), $2);
3575 $$.new_type_flag = $1.new_type_flag; }
3576 | typed_declspecs1 absdcl
3577 { tree specs = strip_attrs ($1.t);
3578 $$.t = build_tree_list (specs, $2);
3579 $$.new_type_flag = $1.new_type_flag; }
3580 | typed_declspecs1 %prec EMPTY
3581 { tree specs = strip_attrs ($1.t);
3582 $$.t = build_tree_list (specs, NULL_TREE);
3583 $$.new_type_flag = $1.new_type_flag; }
3584 | declmods notype_declarator
3585 { tree specs = strip_attrs ($1);
3586 $$.t = build_tree_list (specs, $2);
3587 $$.new_type_flag = 0; }
3592 { $$.t = build_tree_list (NULL_TREE, $1.t);
3593 $$.new_type_flag = $1.new_type_flag; }
3595 { $$.t = build_tree_list ($2, $1.t);
3596 $$.new_type_flag = $1.new_type_flag; }
3605 /* empty */ %prec EMPTY
3606 { see_typename (); }
3610 /* empty */ %prec EMPTY
3612 error ("type specifier omitted for parameter");
3613 $$ = build_tree_list (integer_type_node, NULL_TREE);
3617 error ("type specifier omitted for parameter");
3618 if (TREE_CODE ($$) == SCOPE_REF
3619 && (TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TYPE_PARM
3620 || TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TEMPLATE_PARM))
3621 cp_error (" perhaps you want `typename %E' to make it a type", $$);
3622 $$ = build_tree_list (integer_type_node, $$);
3626 exception_specification_opt:
3627 /* empty */ %prec EMPTY
3629 | THROW '(' ansi_raise_identifiers ')' %prec EMPTY
3631 | THROW LEFT_RIGHT %prec EMPTY
3632 { $$ = build_decl_list (NULL_TREE, NULL_TREE); }
3635 ansi_raise_identifier:
3637 { $$ = build_decl_list (NULL_TREE, groktypename($1.t)); }
3640 ansi_raise_identifiers:
3641 ansi_raise_identifier
3642 | ansi_raise_identifiers ',' ansi_raise_identifier
3644 TREE_CHAIN ($3) = $$;
3649 conversion_declarator:
3650 /* empty */ %prec EMPTY
3652 | '*' cv_qualifiers conversion_declarator
3653 { $$ = make_pointer_declarator ($2, $3); }
3654 | '&' cv_qualifiers conversion_declarator
3655 { $$ = make_reference_declarator ($2, $3); }
3656 | ptr_to_mem cv_qualifiers conversion_declarator
3657 { tree arg = make_pointer_declarator ($2, $3);
3658 $$ = build_parse_node (SCOPE_REF, $1, arg);
3664 { got_scope = NULL_TREE; }
3669 { $$ = ansi_opname[MULT_EXPR]; }
3671 { $$ = ansi_opname[TRUNC_DIV_EXPR]; }
3673 { $$ = ansi_opname[TRUNC_MOD_EXPR]; }
3675 { $$ = ansi_opname[PLUS_EXPR]; }
3677 { $$ = ansi_opname[MINUS_EXPR]; }
3679 { $$ = ansi_opname[BIT_AND_EXPR]; }
3681 { $$ = ansi_opname[BIT_IOR_EXPR]; }
3683 { $$ = ansi_opname[BIT_XOR_EXPR]; }
3685 { $$ = ansi_opname[BIT_NOT_EXPR]; }
3687 { $$ = ansi_opname[COMPOUND_EXPR]; }
3688 | operator ARITHCOMPARE
3689 { $$ = ansi_opname[$2]; }
3691 { $$ = ansi_opname[LT_EXPR]; }
3693 { $$ = ansi_opname[GT_EXPR]; }
3694 | operator EQCOMPARE
3695 { $$ = ansi_opname[$2]; }
3697 { $$ = ansi_assopname[$2]; }
3699 { $$ = ansi_opname [MODIFY_EXPR]; }
3701 { $$ = ansi_opname[$2]; }
3703 { $$ = ansi_opname[$2]; }
3705 { $$ = ansi_opname[POSTINCREMENT_EXPR]; }
3706 | operator MINUSMINUS
3707 { $$ = ansi_opname[PREDECREMENT_EXPR]; }
3709 { $$ = ansi_opname[TRUTH_ANDIF_EXPR]; }
3711 { $$ = ansi_opname[TRUTH_ORIF_EXPR]; }
3713 { $$ = ansi_opname[TRUTH_NOT_EXPR]; }
3715 { $$ = ansi_opname[COND_EXPR]; }
3717 { $$ = ansi_opname[$2]; }
3718 | operator POINTSAT %prec EMPTY
3719 { $$ = ansi_opname[COMPONENT_REF]; }
3720 | operator POINTSAT_STAR %prec EMPTY
3721 { $$ = ansi_opname[MEMBER_REF]; }
3722 | operator LEFT_RIGHT
3723 { $$ = ansi_opname[CALL_EXPR]; }
3725 { $$ = ansi_opname[ARRAY_REF]; }
3726 | operator NEW %prec EMPTY
3727 { $$ = ansi_opname[NEW_EXPR]; }
3728 | operator DELETE %prec EMPTY
3729 { $$ = ansi_opname[DELETE_EXPR]; }
3730 | operator NEW '[' ']'
3731 { $$ = ansi_opname[VEC_NEW_EXPR]; }
3732 | operator DELETE '[' ']'
3733 { $$ = ansi_opname[VEC_DELETE_EXPR]; }
3734 /* Names here should be looked up in class scope ALSO. */
3735 | operator type_specifier_seq conversion_declarator
3736 { $$ = grokoptypename ($2.t, $3); }
3738 { $$ = ansi_opname[ERROR_MARK]; }
3745 debug_yytranslate (value)
3748 return yytname[YYTRANSLATE (value)];