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); }
2394 finish_member_declaration (build_self_reference ());
2398 opt.component_decl_list:
2400 | self_reference component_decl_list
2401 | opt.component_decl_list access_specifier component_decl_list
2402 | opt.component_decl_list access_specifier
2408 if (current_aggr == signature_type_node)
2410 error ("access specifier not allowed in signature");
2411 $1 = access_public_node;
2414 current_access_specifier = $1;
2418 /* Note: we no longer warn about the semicolon after a component_decl_list.
2419 ARM $9.2 says that the semicolon is optional, and therefore allowed. */
2420 component_decl_list:
2423 finish_member_declaration ($1);
2425 | component_decl_list component_decl
2427 finish_member_declaration ($2);
2432 component_decl_1 ';'
2433 | component_decl_1 '}'
2434 { error ("missing ';' before right brace");
2435 yyungetc ('}', 0); }
2436 /* C++: handle constructors, destructors and inline functions */
2437 /* note that INLINE is like a TYPESPEC */
2438 | fn.def2 ':' /* base_init compstmt */
2439 { $$ = finish_method ($$); }
2440 | fn.def2 TRY /* base_init compstmt */
2441 { $$ = finish_method ($$); }
2442 | fn.def2 RETURN /* base_init compstmt */
2443 { $$ = finish_method ($$); }
2444 | fn.def2 '{' /* nodecls compstmt */
2445 { $$ = finish_method ($$); }
2448 | extension component_decl
2450 pedantic = $<itype>1; }
2451 | template_header component_decl
2454 $$ = finish_member_template_decl ($2);
2456 /* The component was already processed. */
2459 finish_template_decl ($1);
2461 | template_header typed_declspecs ';'
2463 $$ = finish_member_class_template ($2.t);
2464 finish_template_decl ($1);
2469 /* Do not add a "typed_declspecs declarator" rule here for
2470 speed; we need to call grok_x_components for enums, so the
2471 speedup would be insignificant. */
2472 typed_declspecs components
2474 /* Most of the productions for component_decl only
2475 allow the creation of one new member, so we call
2476 finish_member_declaration in component_decl_list.
2477 For this rule and the next, however, there can be
2478 more than one member, e.g.:
2482 and we need the first member to be fully
2483 registered before the second is processed.
2484 Therefore, the rules for components take care of
2485 this processing. To avoid registering the
2486 components more than once, we send NULL_TREE up
2487 here; that lets finish_member_declaration now
2488 that there is nothing to do. */
2490 grok_x_components ($1.t);
2493 | declmods notype_components
2496 grok_x_components ($1);
2499 | notype_declarator maybeasm maybe_attribute maybe_init
2500 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2501 build_tree_list ($3, NULL_TREE)); }
2502 | constructor_declarator maybeasm maybe_attribute maybe_init
2503 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2504 build_tree_list ($3, NULL_TREE)); }
2505 | ':' expr_no_commas
2506 { $$ = grokbitfield (NULL_TREE, NULL_TREE, $2); }
2510 /* These rules introduce a reduce/reduce conflict; in
2511 typedef int foo, bar;
2515 should "A::foo" be declared as a function or "A::bar" as a data
2516 member? In other words, is "bar" an after_type_declarator or a
2518 | declmods component_constructor_declarator maybeasm maybe_attribute maybe_init
2519 { tree specs, attrs;
2520 split_specs_attrs ($1, &specs, &attrs);
2521 $$ = grokfield ($2, specs, $5, $3,
2522 build_tree_list ($4, attrs)); }
2523 | component_constructor_declarator maybeasm maybe_attribute maybe_init
2524 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2525 build_tree_list ($3, NULL_TREE)); }
2527 { $$ = do_class_using_decl ($1); }
2529 /* The case of exactly one component is handled directly by component_decl. */
2532 /* empty: possibly anonymous */
2534 | component_declarator0
2536 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2537 $1 = finish_member_template_decl ($1);
2538 finish_member_declaration ($1);
2541 | components ',' component_declarator
2543 check_multiple_declarators ();
2544 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2545 $3 = finish_member_template_decl ($3);
2546 finish_member_declaration ($3);
2552 /* empty: possibly anonymous */
2554 | notype_component_declarator0
2556 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2557 $1 = finish_member_template_decl ($1);
2558 finish_member_declaration ($1);
2561 | notype_components ',' notype_component_declarator
2563 check_multiple_declarators ();
2564 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2565 $3 = finish_member_template_decl ($3);
2566 finish_member_declaration ($3);
2571 component_declarator0:
2572 after_type_component_declarator0
2573 | notype_component_declarator0
2576 component_declarator:
2577 after_type_component_declarator
2578 | notype_component_declarator
2581 after_type_component_declarator0:
2582 after_type_declarator maybeasm maybe_attribute maybe_init
2583 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2584 &prefix_attributes);
2585 $<ttype>0 = current_declspecs;
2586 $$ = grokfield ($$, current_declspecs, $4, $2,
2587 build_tree_list ($3, prefix_attributes)); }
2588 | TYPENAME ':' expr_no_commas maybe_attribute
2589 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2590 &prefix_attributes);
2591 $<ttype>0 = current_declspecs;
2592 $$ = grokbitfield ($$, current_declspecs, $3);
2593 cplus_decl_attributes ($$, $4, prefix_attributes); }
2596 notype_component_declarator0:
2597 notype_declarator maybeasm maybe_attribute maybe_init
2598 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2599 &prefix_attributes);
2600 $<ttype>0 = current_declspecs;
2601 $$ = grokfield ($$, current_declspecs, $4, $2,
2602 build_tree_list ($3, prefix_attributes)); }
2603 | constructor_declarator maybeasm maybe_attribute maybe_init
2604 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2605 &prefix_attributes);
2606 $<ttype>0 = current_declspecs;
2607 $$ = grokfield ($$, current_declspecs, $4, $2,
2608 build_tree_list ($3, prefix_attributes)); }
2609 | IDENTIFIER ':' expr_no_commas maybe_attribute
2610 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2611 &prefix_attributes);
2612 $<ttype>0 = current_declspecs;
2613 $$ = grokbitfield ($$, current_declspecs, $3);
2614 cplus_decl_attributes ($$, $4, prefix_attributes); }
2615 | ':' expr_no_commas maybe_attribute
2616 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2617 &prefix_attributes);
2618 $<ttype>0 = current_declspecs;
2619 $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
2620 cplus_decl_attributes ($$, $3, prefix_attributes); }
2623 after_type_component_declarator:
2624 after_type_declarator maybeasm maybe_attribute maybe_init
2625 { $$ = grokfield ($$, current_declspecs, $4, $2,
2626 build_tree_list ($3, prefix_attributes)); }
2627 | TYPENAME ':' expr_no_commas maybe_attribute
2628 { $$ = grokbitfield ($$, current_declspecs, $3);
2629 cplus_decl_attributes ($$, $4, prefix_attributes); }
2632 notype_component_declarator:
2633 notype_declarator maybeasm maybe_attribute maybe_init
2634 { $$ = grokfield ($$, current_declspecs, $4, $2,
2635 build_tree_list ($3, prefix_attributes)); }
2636 | IDENTIFIER ':' expr_no_commas maybe_attribute
2637 { $$ = grokbitfield ($$, current_declspecs, $3);
2638 cplus_decl_attributes ($$, $4, prefix_attributes); }
2639 | ':' expr_no_commas maybe_attribute
2640 { $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
2641 cplus_decl_attributes ($$, $3, prefix_attributes); }
2644 /* We chain the enumerators in reverse order.
2645 Because of the way enums are built, the order is
2646 insignificant. Take advantage of this fact. */
2650 | enumlist ',' enumerator
2651 { TREE_CHAIN ($3) = $$; $$ = $3; }
2656 { $$ = build_enumerator ($$, NULL_TREE, current_enum_type); }
2657 | identifier '=' expr_no_commas
2658 { $$ = build_enumerator ($$, $3, current_enum_type); }
2661 /* ANSI new-type-id (5.3.4) */
2663 type_specifier_seq new_declarator
2664 { $$.t = build_decl_list ($1.t, $2);
2665 $$.new_type_flag = $1.new_type_flag; }
2666 | type_specifier_seq %prec EMPTY
2667 { $$.t = build_decl_list ($1.t, NULL_TREE);
2668 $$.new_type_flag = $1.new_type_flag; }
2669 /* GNU extension to allow arrays of arbitrary types with
2670 non-constant dimension. For the use of begin_new_placement
2671 here, see the comments in unary_expr above. */
2672 | '(' .begin_new_placement type_id .finish_new_placement
2676 pedwarn ("ANSI C++ forbids array dimensions with parenthesized type in new");
2677 $$.t = build_parse_node (ARRAY_REF, TREE_VALUE ($3.t), $6);
2678 $$.t = build_decl_list (TREE_PURPOSE ($3.t), $$.t);
2679 $$.new_type_flag = $3.new_type_flag;
2684 /* empty */ %prec EMPTY
2686 | cv_qualifiers CV_QUALIFIER
2687 { $$ = decl_tree_cons (NULL_TREE, $2, $$); }
2690 nonempty_cv_qualifiers:
2692 { $$.t = IDENTIFIER_AS_LIST ($1);
2693 $$.new_type_flag = 0; }
2694 | nonempty_cv_qualifiers CV_QUALIFIER
2695 { $$.t = decl_tree_cons (NULL_TREE, $2, $1.t);
2696 $$.new_type_flag = $1.new_type_flag; }
2699 /* These rules must follow the rules for function declarations
2700 and component declarations. That way, longer rules are preferred. */
2704 { $<itype>$ = suspend_momentary (); }
2706 /* An expression which will not live on the momentary obstack. */
2709 { resume_momentary ((int) $<itype>1); $$ = $2; }
2712 /* An expression which will not live on the momentary obstack. */
2714 suspend_mom '(' nonnull_exprlist ')'
2715 { resume_momentary ((int) $<itype>1); $$ = $3; }
2716 | suspend_mom '(' parmlist ')'
2717 { resume_momentary ((int) $<itype>1); $$ = $3; }
2718 | suspend_mom LEFT_RIGHT
2719 { resume_momentary ((int) $<itype>1); $$ = empty_parms (); }
2720 | suspend_mom '(' error ')'
2721 { resume_momentary ((int) $<itype>1); $$ = NULL_TREE; }
2724 /* A declarator that is allowed only after an explicit typespec. */
2725 /* may all be followed by prec '.' */
2726 after_type_declarator:
2727 '*' nonempty_cv_qualifiers after_type_declarator %prec UNARY
2728 { $$ = make_pointer_declarator ($2.t, $3); }
2729 | '&' nonempty_cv_qualifiers after_type_declarator %prec UNARY
2730 { $$ = make_reference_declarator ($2.t, $3); }
2731 | '*' after_type_declarator %prec UNARY
2732 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2733 | '&' after_type_declarator %prec UNARY
2734 { $$ = make_reference_declarator (NULL_TREE, $2); }
2735 | ptr_to_mem cv_qualifiers after_type_declarator
2736 { tree arg = make_pointer_declarator ($2, $3);
2737 $$ = build_parse_node (SCOPE_REF, $1, arg);
2739 | direct_after_type_declarator
2743 type_name %prec EMPTY
2745 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2747 $$ = lookup_name ($1, 1);
2748 if (current_class_type
2749 && TYPE_BEING_DEFINED (current_class_type)
2750 && ! IDENTIFIER_CLASS_VALUE ($1))
2752 /* Remember that this name has been used in the class
2753 definition, as per [class.scope0] */
2754 pushdecl_class_level ($$);
2760 | global_scope type_name
2762 if (TREE_CODE ($2) == IDENTIFIER_NODE)
2763 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
2766 got_scope = NULL_TREE;
2773 | global_scope nested_type
2778 nested_name_specifier type_name %prec EMPTY
2779 { $$ = get_type_decl ($2); }
2782 direct_after_type_declarator:
2783 direct_after_type_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2784 { $$ = make_call_declarator ($$, $2, $3, $4); }
2785 | direct_after_type_declarator '[' nonmomentary_expr ']'
2786 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
2787 | direct_after_type_declarator '[' ']'
2788 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
2789 | '(' after_type_declarator ')'
2791 | nested_name_specifier type_name %prec EMPTY
2792 { push_nested_class ($1, 3);
2793 $$ = build_parse_node (SCOPE_REF, $$, $2);
2794 TREE_COMPLEXITY ($$) = current_class_depth; }
2795 | type_name %prec EMPTY
2798 /* A declarator allowed whether or not there has been
2799 an explicit typespec. These cannot redeclare a typedef-name. */
2801 notype_declarator_intern:
2803 | attributes notype_declarator
2805 /* Provide support for '(' attributes '*' declarator ')'
2807 $$ = decl_tree_cons ($1, $2, NULL_TREE);
2812 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2813 { $$ = make_pointer_declarator ($2.t, $3); }
2814 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2815 { $$ = make_reference_declarator ($2.t, $3); }
2816 | '*' notype_declarator_intern %prec UNARY
2817 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2818 | '&' notype_declarator_intern %prec UNARY
2819 { $$ = make_reference_declarator (NULL_TREE, $2); }
2820 | ptr_to_mem cv_qualifiers notype_declarator_intern
2821 { tree arg = make_pointer_declarator ($2, $3);
2822 $$ = build_parse_node (SCOPE_REF, $1, arg);
2824 | direct_notype_declarator
2827 complex_notype_declarator:
2828 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2829 { $$ = make_pointer_declarator ($2.t, $3); }
2830 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2831 { $$ = make_reference_declarator ($2.t, $3); }
2832 | '*' complex_notype_declarator %prec UNARY
2833 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2834 | '&' complex_notype_declarator %prec UNARY
2835 { $$ = make_reference_declarator (NULL_TREE, $2); }
2836 | ptr_to_mem cv_qualifiers notype_declarator_intern
2837 { tree arg = make_pointer_declarator ($2, $3);
2838 $$ = build_parse_node (SCOPE_REF, $1, arg);
2840 | complex_direct_notype_declarator
2843 complex_direct_notype_declarator:
2844 direct_notype_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2845 { $$ = make_call_declarator ($$, $2, $3, $4); }
2846 | '(' complex_notype_declarator ')'
2848 | direct_notype_declarator '[' nonmomentary_expr ']'
2849 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
2850 | direct_notype_declarator '[' ']'
2851 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
2852 | notype_qualified_id
2853 { enter_scope_of ($1); }
2854 | nested_name_specifier notype_template_declarator
2855 { got_scope = NULL_TREE;
2856 $$ = build_parse_node (SCOPE_REF, $1, $2);
2857 enter_scope_of ($$);
2862 nested_name_specifier unqualified_id
2863 { got_scope = NULL_TREE;
2864 $$ = build_parse_node (SCOPE_REF, $$, $2); }
2865 | nested_name_specifier object_template_id
2866 { got_scope = NULL_TREE;
2867 $$ = build_parse_node (SCOPE_REF, $1, $2); }
2870 notype_qualified_id:
2871 nested_name_specifier notype_unqualified_id
2872 { got_scope = NULL_TREE;
2873 $$ = build_parse_node (SCOPE_REF, $$, $2); }
2874 | nested_name_specifier object_template_id
2875 { got_scope = NULL_TREE;
2876 $$ = build_parse_node (SCOPE_REF, $1, $2); }
2881 | global_scope notype_qualified_id
2886 typespec '(' nonnull_exprlist ')'
2887 { $$ = build_functional_cast ($1.t, $3); }
2888 | typespec '(' expr_or_declarator_intern ')'
2889 { $$ = reparse_decl_as_expr ($1.t, $3); }
2890 | typespec fcast_or_absdcl %prec EMPTY
2891 { $$ = reparse_absdcl_as_expr ($1.t, $2); }
2896 | template_type %prec EMPTY
2899 nested_name_specifier:
2900 nested_name_specifier_1
2901 | nested_name_specifier nested_name_specifier_1
2903 | nested_name_specifier TEMPLATE explicit_template_type SCOPE
2904 { got_scope = $$ = make_typename_type ($1, $3); }
2907 /* Why the @#$%^& do type_name and notype_identifier need to be expanded
2908 inline here?!? (jason) */
2909 nested_name_specifier_1:
2912 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2915 /* Remember that this name has been used in the class
2916 definition, as per [class.scope0] */
2917 if (current_class_type
2918 && TYPE_BEING_DEFINED (current_class_type)
2919 && ! IDENTIFIER_CLASS_VALUE ($1))
2920 pushdecl_class_level ($$);
2922 got_scope = $$ = TYPE_MAIN_VARIANT (TREE_TYPE ($$));
2926 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2928 got_scope = $$ = TREE_TYPE ($$);
2932 if (TREE_CODE ($$) == IDENTIFIER_NODE)
2936 | template_type SCOPE
2937 { got_scope = $$ = complete_type (TREE_TYPE ($1)); }
2938 /* These break 'const i;'
2942 cp_error ("`%D' is not an aggregate typedef",
2943 lastiddecl ? lastiddecl : $$);
2944 $$ = error_mark_node;
2947 { goto failed_scope; } */
2952 | global_scope typename_sub0
2957 typename_sub1 identifier %prec EMPTY
2959 if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't')
2960 $$ = make_typename_type ($1, $2);
2961 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
2962 cp_error ("`%T' is not a class or namespace", $2);
2966 if (TREE_CODE ($$) == TYPE_DECL)
2967 $$ = TREE_TYPE ($$);
2970 | typename_sub1 template_type %prec EMPTY
2971 { $$ = TREE_TYPE ($2); }
2972 | typename_sub1 explicit_template_type %prec EMPTY
2973 { $$ = make_typename_type ($1, $2); }
2974 | typename_sub1 TEMPLATE explicit_template_type %prec EMPTY
2975 { $$ = make_typename_type ($1, $3); }
2981 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2982 cp_error ("`%T' is not a class or namespace", $1);
2984 | typename_sub1 typename_sub2
2986 if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't')
2987 $$ = make_typename_type ($1, $2);
2988 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
2989 cp_error ("`%T' is not a class or namespace", $2);
2993 if (TREE_CODE ($$) == TYPE_DECL)
2994 $$ = TREE_TYPE ($$);
2997 | typename_sub1 explicit_template_type SCOPE
2998 { got_scope = $$ = make_typename_type ($1, $2); }
2999 | typename_sub1 TEMPLATE explicit_template_type SCOPE
3000 { got_scope = $$ = make_typename_type ($1, $3); }
3006 if (TREE_CODE ($1) != IDENTIFIER_NODE)
3009 /* Retrieve the type for the identifier, which might involve
3010 some computation. */
3011 got_scope = $$ = complete_type (IDENTIFIER_TYPE_VALUE ($1));
3013 if ($$ == error_mark_node)
3014 cp_error ("`%T' is not a class or namespace", $1);
3018 if (TREE_CODE ($1) != IDENTIFIER_NODE)
3020 got_scope = $$ = complete_type (TREE_TYPE ($$));
3022 | template_type SCOPE
3023 { got_scope = $$ = complete_type (TREE_TYPE ($$)); }
3028 if (TREE_CODE ($$) == IDENTIFIER_NODE)
3034 explicit_template_type:
3035 identifier '<' template_arg_list_opt template_close_bracket
3036 { $$ = build_min_nt (TEMPLATE_ID_EXPR, $1, $3); }
3040 global_scope type_name
3042 if (TREE_CODE ($2) == IDENTIFIER_NODE)
3043 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
3046 got_scope = NULL_TREE;
3049 | global_scope nested_type
3054 nested_name_specifier '*'
3055 { got_scope = NULL_TREE; }
3056 | global_scope nested_name_specifier '*'
3057 { $$ = $2; got_scope = NULL_TREE; }
3060 /* All uses of explicit global scope must go through this nonterminal so
3061 that got_scope will be set before yylex is called to get the next token. */
3064 { got_scope = void_type_node; }
3067 /* ANSI new-declarator (5.3.4) */
3069 '*' cv_qualifiers new_declarator
3070 { $$ = make_pointer_declarator ($2, $3); }
3071 | '*' cv_qualifiers %prec EMPTY
3072 { $$ = make_pointer_declarator ($2, NULL_TREE); }
3073 | '&' cv_qualifiers new_declarator %prec EMPTY
3074 { $$ = make_reference_declarator ($2, $3); }
3075 | '&' cv_qualifiers %prec EMPTY
3076 { $$ = make_reference_declarator ($2, NULL_TREE); }
3077 | ptr_to_mem cv_qualifiers %prec EMPTY
3078 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3079 $$ = build_parse_node (SCOPE_REF, $1, arg);
3081 | ptr_to_mem cv_qualifiers new_declarator
3082 { tree arg = make_pointer_declarator ($2, $3);
3083 $$ = build_parse_node (SCOPE_REF, $1, arg);
3085 | direct_new_declarator %prec EMPTY
3088 /* ANSI direct-new-declarator (5.3.4) */
3089 direct_new_declarator:
3091 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3092 | direct_new_declarator '[' nonmomentary_expr ']'
3093 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3096 /* ANSI abstract-declarator (8.1) */
3098 '*' nonempty_cv_qualifiers absdcl
3099 { $$ = make_pointer_declarator ($2.t, $3); }
3101 { $$ = make_pointer_declarator (NULL_TREE, $2); }
3102 | '*' nonempty_cv_qualifiers %prec EMPTY
3103 { $$ = make_pointer_declarator ($2.t, NULL_TREE); }
3105 { $$ = make_pointer_declarator (NULL_TREE, NULL_TREE); }
3106 | '&' nonempty_cv_qualifiers absdcl
3107 { $$ = make_reference_declarator ($2.t, $3); }
3109 { $$ = make_reference_declarator (NULL_TREE, $2); }
3110 | '&' nonempty_cv_qualifiers %prec EMPTY
3111 { $$ = make_reference_declarator ($2.t, NULL_TREE); }
3113 { $$ = make_reference_declarator (NULL_TREE, NULL_TREE); }
3114 | ptr_to_mem cv_qualifiers %prec EMPTY
3115 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3116 $$ = build_parse_node (SCOPE_REF, $1, arg);
3118 | ptr_to_mem cv_qualifiers absdcl
3119 { tree arg = make_pointer_declarator ($2, $3);
3120 $$ = build_parse_node (SCOPE_REF, $1, arg);
3122 | direct_abstract_declarator %prec EMPTY
3125 /* ANSI direct-abstract-declarator (8.1) */
3126 direct_abstract_declarator:
3129 /* `(typedef)1' is `int'. */
3131 | direct_abstract_declarator '(' parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3132 { $$ = make_call_declarator ($$, $3, $5, $6); }
3133 | direct_abstract_declarator LEFT_RIGHT cv_qualifiers exception_specification_opt %prec '.'
3134 { $$ = make_call_declarator ($$, empty_parms (), $3, $4); }
3135 | direct_abstract_declarator '[' nonmomentary_expr ']' %prec '.'
3136 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3137 | direct_abstract_declarator '[' ']' %prec '.'
3138 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
3139 | '(' complex_parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3140 { $$ = make_call_declarator (NULL_TREE, $2, $4, $5); }
3141 | regcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3142 { set_quals_and_spec ($$, $2, $3); }
3143 | fcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3144 { set_quals_and_spec ($$, $2, $3); }
3145 | '[' nonmomentary_expr ']' %prec '.'
3146 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3148 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, NULL_TREE); }
3151 /* For C++, decls and stmts can be intermixed, so we don't need to
3152 have a special rule that won't start parsing the stmt section
3153 until we have a stmt that parses without errors. */
3166 /* Read zero or more forward-declarations for labels
3167 that nested functions can jump to. */
3172 pedwarn ("ANSI C++ forbids label declarations"); }
3177 | label_decls label_decl
3181 LABEL identifiers_or_typenames ';'
3183 for (link = $2; link; link = TREE_CHAIN (link))
3185 tree label = shadow_label (TREE_VALUE (link));
3186 C_DECLARED_LABEL_FLAG (label) = 1;
3187 declare_nonlocal_label (label);
3192 /* This is the body of a function definition.
3193 It causes syntax errors to ignore to the next openbrace. */
3202 { $<ttype>$ = begin_compound_stmt (0); }
3204 { $$ = finish_compound_stmt (0, $<ttype>2); }
3210 $<ttype>$ = begin_if_stmt ();
3211 cond_stmt_keyword = "if";
3214 { finish_if_stmt_cond ($3, $<ttype>2); }
3215 implicitly_scoped_stmt
3216 { $<ttype>$ = finish_then_clause ($<ttype>2); }
3219 implicitly_scoped_stmt:
3221 | { $<ttype>$ = begin_compound_stmt (0); }
3223 { $$ = finish_compound_stmt (0, $<ttype>1); }
3236 { finish_expr_stmt ($1); }
3238 { begin_else_clause (); }
3239 implicitly_scoped_stmt
3241 finish_else_clause ($<ttype>1);
3244 | simple_if %prec IF
3245 { finish_if_stmt (); }
3248 $<ttype>$ = begin_while_stmt ();
3249 cond_stmt_keyword = "while";
3252 { finish_while_stmt_cond ($3, $<ttype>2); }
3254 { finish_while_stmt ($<ttype>2); }
3256 { $<ttype>$ = begin_do_stmt (); }
3257 implicitly_scoped_stmt WHILE
3259 finish_do_body ($<ttype>2);
3260 cond_stmt_keyword = "do";
3262 paren_expr_or_null ';'
3263 { finish_do_stmt ($6, $<ttype>2); }
3265 { $<ttype>$ = begin_for_stmt (); }
3266 '(' for.init.statement
3267 { finish_for_init_stmt ($<ttype>2); }
3269 { finish_for_cond ($6, $<ttype>2); }
3271 { finish_for_expr ($9, $<ttype>2); }
3273 { finish_for_stmt ($9, $<ttype>2); }
3275 { begin_switch_stmt (); }
3277 { $<ttype>$ = finish_switch_cond ($4); }
3278 implicitly_scoped_stmt
3279 { finish_switch_stmt ($4, $<ttype>6); }
3280 | CASE expr_no_commas ':'
3281 { finish_case_label ($2, NULL_TREE); }
3283 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
3284 { finish_case_label ($2, $4); }
3287 { finish_case_label (NULL_TREE, NULL_TREE); }
3290 { finish_break_stmt (); }
3292 { finish_continue_stmt (); }
3294 { finish_return_stmt (NULL_TREE); }
3296 { finish_return_stmt ($2); }
3297 | asm_keyword maybe_cv_qualifier '(' string ')' ';'
3299 finish_asm_stmt ($2, $4, NULL_TREE, NULL_TREE,
3302 /* This is the case with just output operands. */
3303 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ')' ';'
3305 finish_asm_stmt ($2, $4, $6, NULL_TREE,
3308 /* This is the case with input operands as well. */
3309 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':' asm_operands ')' ';'
3310 { finish_asm_stmt ($2, $4, $6, $8, NULL_TREE); }
3311 /* This is the case with clobbered registers as well. */
3312 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':'
3313 asm_operands ':' asm_clobbers ')' ';'
3314 { finish_asm_stmt ($2, $4, $6, $8, $10); }
3318 pedwarn ("ANSI C++ forbids computed gotos");
3319 finish_goto_stmt ($3);
3321 | GOTO identifier ';'
3322 { finish_goto_stmt ($2); }
3326 { error ("label must be followed by statement");
3333 | namespace_using_decl
3334 { do_local_using_decl ($1); }
3341 if (! current_function_parms_stored)
3342 store_parm_decls ();
3343 expand_start_early_try_stmts ();
3345 ctor_initializer_opt compstmt
3347 expand_start_all_catch ();
3351 expand_end_all_catch ();
3358 { $<ttype>$ = begin_try_block (); }
3360 { finish_try_block ($<ttype>2); }
3362 { finish_handler_sequence ($<ttype>2); }
3367 | handler_seq handler
3372 { $<ttype>$ = begin_handler(); }
3374 { finish_handler_parms ($<ttype>2); }
3376 { finish_handler ($<ttype>2); }
3380 typed_typespecs %prec EMPTY
3381 | nonempty_cv_qualifiers %prec EMPTY
3386 { expand_start_catch_block (NULL_TREE, NULL_TREE); }
3387 /* This doesn't allow reference parameters, the below does.
3388 | '(' type_specifier_seq absdcl ')'
3389 { check_for_new_type ("inside exception declarations", $2);
3390 expand_start_catch_block ($2.t, $3); }
3391 | '(' type_specifier_seq ')'
3392 { check_for_new_type ("inside exception declarations", $2);
3393 expand_start_catch_block ($2.t, NULL_TREE); }
3394 | '(' type_specifier_seq notype_declarator ')'
3395 { check_for_new_type ("inside exception declarations", $2);
3396 expand_start_catch_block ($2.t, $3); }
3397 | '(' typed_typespecs after_type_declarator ')'
3398 { check_for_new_type ("inside exception declarations", $2);
3399 expand_start_catch_block ($2.t, $3); }
3400 This allows reference parameters... */
3402 { check_for_new_type ("inside exception declarations", $2);
3403 expand_start_catch_block (TREE_PURPOSE ($2.t),
3404 TREE_VALUE ($2.t)); }
3411 label = define_label (input_filename, lineno, $1);
3412 if (label && ! minimal_parse_mode)
3413 expand_label (label);
3425 { if ($1) cplus_expand_expr_stmt ($1); }
3429 pedwarn ("ANSI C++ forbids compound statements inside for initializations");
3433 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
3437 { emit_line_note (input_filename, lineno);
3440 { emit_line_note (input_filename, lineno); }
3451 /* These are the operands other than the first string and colon
3452 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
3456 | nonnull_asm_operands
3459 nonnull_asm_operands:
3461 | nonnull_asm_operands ',' asm_operand
3462 { $$ = chainon ($$, $3); }
3467 { $$ = build_tree_list ($$, $3); }
3472 { $$ = tree_cons (NULL_TREE, $$, NULL_TREE); }
3473 | asm_clobbers ',' STRING
3474 { $$ = tree_cons (NULL_TREE, $3, $$); }
3477 /* This is what appears inside the parens in a function declarator.
3478 Its value is represented in the format that grokdeclarator expects.
3480 In C++, declaring a function with no parameters
3481 means that that function takes *no* parameters. */
3490 { $$ = finish_parmlist (build_tree_list (NULL_TREE, $1.t), 0);
3491 check_for_new_type ("inside parameter list", $1); }
3494 /* This nonterminal does not include the common sequence '(' type_id ')',
3495 as it is ambiguous and must be disambiguated elsewhere. */
3498 { $$ = finish_parmlist ($$, 0); }
3499 | parms_comma ELLIPSIS
3500 { $$ = finish_parmlist ($1, 1); }
3501 /* C++ allows an ellipsis without a separating ',' */
3503 { $$ = finish_parmlist ($1, 1); }
3505 { $$ = finish_parmlist (build_tree_list (NULL_TREE,
3508 { $$ = finish_parmlist (NULL_TREE, 1); }
3511 /* This helps us recover from really nasty
3512 parse errors, for example, a missing right
3514 yyerror ("possibly missing ')'");
3515 $$ = finish_parmlist ($1, 0);
3521 /* This helps us recover from really nasty
3522 parse errors, for example, a missing right
3524 yyerror ("possibly missing ')'");
3525 $$ = finish_parmlist (build_tree_list (NULL_TREE,
3532 /* A default argument to a */
3535 { maybe_snarf_defarg (); }
3545 /* A nonempty list of parameter declarations or type names. */
3548 { check_for_new_type ("in a parameter list", $1);
3549 $$ = build_tree_list (NULL_TREE, $1.t); }
3551 { check_for_new_type ("in a parameter list", $1);
3552 $$ = build_tree_list ($2, $1.t); }
3553 | parms_comma full_parm
3554 { check_for_new_type ("in a parameter list", $2);
3555 $$ = chainon ($$, $2.t); }
3556 | parms_comma bad_parm
3557 { $$ = chainon ($$, build_tree_list (NULL_TREE, $2)); }
3558 | parms_comma bad_parm '=' init
3559 { $$ = chainon ($$, build_tree_list ($4, $2)); }
3565 { check_for_new_type ("in a parameter list", $1);
3566 $$ = build_tree_list (NULL_TREE, $1.t); }
3569 /* A single parameter declaration or parameter type name,
3570 as found in a parmlist. */
3572 /* Here we expand typed_declspecs inline to avoid mis-parsing of
3573 TYPESPEC IDENTIFIER. */
3574 typed_declspecs1 declarator
3575 { tree specs = strip_attrs ($1.t);
3576 $$.new_type_flag = $1.new_type_flag;
3577 $$.t = build_tree_list (specs, $2); }
3578 | typed_typespecs declarator
3579 { $$.t = build_tree_list ($1.t, $2);
3580 $$.new_type_flag = $1.new_type_flag; }
3581 | typespec declarator
3582 { $$.t = build_tree_list (get_decl_list ($1.t), $2);
3583 $$.new_type_flag = $1.new_type_flag; }
3584 | typed_declspecs1 absdcl
3585 { tree specs = strip_attrs ($1.t);
3586 $$.t = build_tree_list (specs, $2);
3587 $$.new_type_flag = $1.new_type_flag; }
3588 | typed_declspecs1 %prec EMPTY
3589 { tree specs = strip_attrs ($1.t);
3590 $$.t = build_tree_list (specs, NULL_TREE);
3591 $$.new_type_flag = $1.new_type_flag; }
3592 | declmods notype_declarator
3593 { tree specs = strip_attrs ($1);
3594 $$.t = build_tree_list (specs, $2);
3595 $$.new_type_flag = 0; }
3600 { $$.t = build_tree_list (NULL_TREE, $1.t);
3601 $$.new_type_flag = $1.new_type_flag; }
3603 { $$.t = build_tree_list ($2, $1.t);
3604 $$.new_type_flag = $1.new_type_flag; }
3613 /* empty */ %prec EMPTY
3614 { see_typename (); }
3618 /* empty */ %prec EMPTY
3620 error ("type specifier omitted for parameter");
3621 $$ = build_tree_list (integer_type_node, NULL_TREE);
3625 error ("type specifier omitted for parameter");
3626 if (TREE_CODE ($$) == SCOPE_REF
3627 && (TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TYPE_PARM
3628 || TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TEMPLATE_PARM))
3629 cp_error (" perhaps you want `typename %E' to make it a type", $$);
3630 $$ = build_tree_list (integer_type_node, $$);
3634 exception_specification_opt:
3635 /* empty */ %prec EMPTY
3637 | THROW '(' ansi_raise_identifiers ')' %prec EMPTY
3639 | THROW LEFT_RIGHT %prec EMPTY
3640 { $$ = build_decl_list (NULL_TREE, NULL_TREE); }
3643 ansi_raise_identifier:
3645 { $$ = build_decl_list (NULL_TREE, groktypename($1.t)); }
3648 ansi_raise_identifiers:
3649 ansi_raise_identifier
3650 | ansi_raise_identifiers ',' ansi_raise_identifier
3652 TREE_CHAIN ($3) = $$;
3657 conversion_declarator:
3658 /* empty */ %prec EMPTY
3660 | '*' cv_qualifiers conversion_declarator
3661 { $$ = make_pointer_declarator ($2, $3); }
3662 | '&' cv_qualifiers conversion_declarator
3663 { $$ = make_reference_declarator ($2, $3); }
3664 | ptr_to_mem cv_qualifiers conversion_declarator
3665 { tree arg = make_pointer_declarator ($2, $3);
3666 $$ = build_parse_node (SCOPE_REF, $1, arg);
3672 { got_scope = NULL_TREE; }
3677 { $$ = ansi_opname[MULT_EXPR]; }
3679 { $$ = ansi_opname[TRUNC_DIV_EXPR]; }
3681 { $$ = ansi_opname[TRUNC_MOD_EXPR]; }
3683 { $$ = ansi_opname[PLUS_EXPR]; }
3685 { $$ = ansi_opname[MINUS_EXPR]; }
3687 { $$ = ansi_opname[BIT_AND_EXPR]; }
3689 { $$ = ansi_opname[BIT_IOR_EXPR]; }
3691 { $$ = ansi_opname[BIT_XOR_EXPR]; }
3693 { $$ = ansi_opname[BIT_NOT_EXPR]; }
3695 { $$ = ansi_opname[COMPOUND_EXPR]; }
3696 | operator ARITHCOMPARE
3697 { $$ = ansi_opname[$2]; }
3699 { $$ = ansi_opname[LT_EXPR]; }
3701 { $$ = ansi_opname[GT_EXPR]; }
3702 | operator EQCOMPARE
3703 { $$ = ansi_opname[$2]; }
3705 { $$ = ansi_assopname[$2]; }
3707 { $$ = ansi_opname [MODIFY_EXPR]; }
3709 { $$ = ansi_opname[$2]; }
3711 { $$ = ansi_opname[$2]; }
3713 { $$ = ansi_opname[POSTINCREMENT_EXPR]; }
3714 | operator MINUSMINUS
3715 { $$ = ansi_opname[PREDECREMENT_EXPR]; }
3717 { $$ = ansi_opname[TRUTH_ANDIF_EXPR]; }
3719 { $$ = ansi_opname[TRUTH_ORIF_EXPR]; }
3721 { $$ = ansi_opname[TRUTH_NOT_EXPR]; }
3723 { $$ = ansi_opname[COND_EXPR]; }
3725 { $$ = ansi_opname[$2]; }
3726 | operator POINTSAT %prec EMPTY
3727 { $$ = ansi_opname[COMPONENT_REF]; }
3728 | operator POINTSAT_STAR %prec EMPTY
3729 { $$ = ansi_opname[MEMBER_REF]; }
3730 | operator LEFT_RIGHT
3731 { $$ = ansi_opname[CALL_EXPR]; }
3733 { $$ = ansi_opname[ARRAY_REF]; }
3734 | operator NEW %prec EMPTY
3735 { $$ = ansi_opname[NEW_EXPR]; }
3736 | operator DELETE %prec EMPTY
3737 { $$ = ansi_opname[DELETE_EXPR]; }
3738 | operator NEW '[' ']'
3739 { $$ = ansi_opname[VEC_NEW_EXPR]; }
3740 | operator DELETE '[' ']'
3741 { $$ = ansi_opname[VEC_DELETE_EXPR]; }
3742 /* Names here should be looked up in class scope ALSO. */
3743 | operator type_specifier_seq conversion_declarator
3744 { $$ = grokoptypename ($2.t, $3); }
3746 { $$ = ansi_opname[ERROR_MARK]; }
3753 debug_yytranslate (value)
3756 return yytname[YYTRANSLATE (value)];