1 /* YACC parser for C++ syntax.
2 Copyright (C) 1988, 89, 93-98, 1999 Free Software Foundation, Inc.
3 Hacked by Michael Tiemann (tiemann@cygnus.com)
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
23 /* This grammar is based on the GNU CC grammar. */
25 /* Note: Bison automatically applies a default action of "$$ = $1" for
26 all derivations; this is applied before the explicit action, if one
27 is given. Keep this in mind when reading the actions. */
30 /* Cause the `yydebug' variable to be defined. */
46 /* Since parsers are distinct for each language, put the language string
47 definition here. (fnf) */
48 char *language_string = "GNU C++";
50 extern tree void_list_node;
51 extern struct obstack permanent_obstack;
53 extern int end_of_file;
55 /* Like YYERROR but do call yyerror. */
56 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
58 #define OP0(NODE) (TREE_OPERAND (NODE, 0))
59 #define OP1(NODE) (TREE_OPERAND (NODE, 1))
61 /* Contains the statement keyword (if/while/do) to include in an
62 error message if the user supplies an empty conditional expression. */
63 static const char *cond_stmt_keyword;
65 static tree empty_parms PROTO((void));
66 static int parse_decl PROTO((tree, tree, tree, int, tree *));
68 /* Nonzero if we have an `extern "C"' acting as an extern specifier. */
72 /* Cons up an empty parameter list. */
82 || current_class_type != NULL)
83 parms = void_list_node;
93 %union {long itype; tree ttype; char *strtype; enum tree_code code; flagged_type_tree ftype; }
95 /* All identifiers that are not reserved words
96 and are not declared typedefs in the current block */
99 /* All identifiers that are declared typedefs in the current block.
100 In some contexts, they are treated just like IDENTIFIER,
101 but they can also serve as typespecs in declarations. */
105 /* A template function. */
108 /* Reserved words that specify storage class.
109 yylval contains an IDENTIFIER_NODE which indicates which one. */
112 /* Reserved words that specify type.
113 yylval contains an IDENTIFIER_NODE which indicates which one. */
116 /* Reserved words that qualify type: "const" or "volatile".
117 yylval contains an IDENTIFIER_NODE which indicates which one. */
120 /* Character or numeric constants.
121 yylval is the node for the constant. */
124 /* String constants in raw form.
125 yylval is a STRING_CST node. */
128 /* "...", used for functions with variable arglists. */
131 /* the reserved words */
132 /* SCO include files test "ASM", so use something else. */
133 %token SIZEOF ENUM /* STRUCT UNION */ IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
134 %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD TYPEOF ALIGNOF
136 %token ATTRIBUTE EXTENSION LABEL
137 %token REALPART IMAGPART
139 /* the reserved words... C++ extensions */
141 %token <ttype> VISSPEC
142 %token DELETE NEW THIS OPERATOR CXX_TRUE CXX_FALSE
143 %token NAMESPACE TYPENAME_KEYWORD USING
144 %token LEFT_RIGHT TEMPLATE
145 %token TYPEID DYNAMIC_CAST STATIC_CAST REINTERPRET_CAST CONST_CAST
148 /* Define the operator tokens and their precedences.
149 The value is an integer because, if used, it is the tree code
150 to use in the expression made from the operator. */
152 %left EMPTY /* used to resolve s/r with epsilon */
156 /* Add precedence rules to solve dangling else s/r conflict */
160 %left IDENTIFIER PFUNCNAME TYPENAME SELFNAME PTYPENAME SCSPEC TYPESPEC CV_QUALIFIER ENUM AGGR ELLIPSIS TYPEOF SIGOF OPERATOR NSNAME TYPENAME_KEYWORD
166 %right <code> ASSIGN '='
174 %left <code> EQCOMPARE
175 %left <code> ARITHCOMPARE '<' '>'
176 %left <code> LSHIFT RSHIFT
178 %left <code> '*' '/' '%'
179 %left <code> POINTSAT_STAR DOT_STAR
180 %right <code> UNARY PLUSPLUS MINUSMINUS '~'
182 %left <ttype> PAREN_STAR_PAREN LEFT_RIGHT
183 %left <code> POINTSAT '.' '(' '['
185 %right SCOPE /* C++ extension */
186 %nonassoc NEW DELETE TRY CATCH
190 %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist
191 %type <ttype> PFUNCNAME maybe_identifier
192 %type <ttype> paren_expr_or_null nontrivial_exprlist SELFNAME
193 %type <ttype> expr_no_commas cast_expr unary_expr primary string STRING
194 %type <ttype> reserved_declspecs boolean.literal
195 %type <ttype> reserved_typespecquals
196 %type <ttype> declmods
197 %type <ttype> SCSPEC TYPESPEC CV_QUALIFIER maybe_cv_qualifier
198 %type <itype> initdecls notype_initdecls initdcl /* C++ modification */
199 %type <ttype> init initlist maybeasm maybe_init defarg defarg1
200 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
201 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
202 %type <ttype> any_word
204 %type <ttype> compstmt implicitly_scoped_stmt
206 %type <ttype> declarator notype_declarator after_type_declarator
207 %type <ttype> notype_declarator_intern
208 %type <ttype> direct_notype_declarator direct_after_type_declarator
209 %type <itype> components notype_components
210 %type <ttype> component_decl component_decl_1
211 %type <ttype> component_declarator component_declarator0
212 %type <ttype> notype_component_declarator notype_component_declarator0
213 %type <ttype> after_type_component_declarator after_type_component_declarator0
214 %type <ttype> enumlist enumerator
215 %type <ttype> absdcl cv_qualifiers
216 %type <ttype> direct_abstract_declarator conversion_declarator
217 %type <ttype> new_declarator direct_new_declarator
218 %type <ttype> xexpr parmlist parms bad_parm
219 %type <ttype> identifiers_or_typenames
220 %type <ttype> fcast_or_absdcl regcast_or_absdcl
221 %type <ttype> expr_or_declarator expr_or_declarator_intern
222 %type <ttype> complex_notype_declarator
223 %type <ttype> notype_unqualified_id unqualified_id qualified_id
224 %type <ttype> template_id do_id object_template_id notype_template_declarator
225 %type <ttype> overqualified_id notype_qualified_id any_id
226 %type <ttype> complex_direct_notype_declarator functional_cast
227 %type <ttype> complex_parmlist parms_comma
228 %type <ttype> namespace_qualifier namespace_using_decl
230 %type <ftype> type_id new_type_id typed_typespecs typespec typed_declspecs
231 %type <ftype> typed_declspecs1 type_specifier_seq nonempty_cv_qualifiers
232 %type <ftype> structsp typespecqual_reserved parm named_parm full_parm
235 %token <ttype> PTYPENAME
236 %token <ttype> PRE_PARSED_FUNCTION_DECL EXTERN_LANG_STRING ALL
237 %token <ttype> PRE_PARSED_CLASS_DECL DEFARG DEFARG_MARKER
238 %type <ttype> component_constructor_declarator
239 %type <ttype> fn.def2 return_id fn.defpen constructor_declarator
240 %type <itype> ctor_initializer_opt function_try_block
241 %type <ttype> named_class_head named_class_head_sans_basetype
242 %type <ttype> named_complex_class_head_sans_basetype
243 %type <ttype> unnamed_class_head
244 %type <ttype> class_head base_class_list
245 %type <ttype> base_class_access_list
246 %type <ttype> base_class maybe_base_class_list base_class.1
247 %type <ttype> exception_specification_opt ansi_raise_identifier ansi_raise_identifiers
248 %type <ttype> operator_name
249 %type <ttype> object aggr
250 %type <itype> new delete .begin_new_placement
251 /* %type <ttype> primary_no_id */
252 %type <ttype> nonmomentary_expr maybe_parmlist
253 %type <itype> initdcl0 notype_initdcl0 member_init_list initdcl0_innards
254 %type <ttype> template_header template_parm_list template_parm
255 %type <ttype> template_type_parm template_template_parm
256 %type <code> template_close_bracket
257 %type <ttype> apparent_template_type
258 %type <ttype> template_type template_arg_list template_arg_list_opt
259 %type <ttype> template_arg
260 %type <ttype> condition xcond paren_cond_or_null
261 %type <ttype> type_name nested_name_specifier nested_type ptr_to_mem
262 %type <ttype> complete_type_name notype_identifier nonnested_type
263 %type <ttype> complex_type_name nested_name_specifier_1
264 %type <ttype> new_initializer new_placement
265 %type <ttype> using_decl
266 %type <ttype> typename_sub typename_sub0 typename_sub1 typename_sub2
267 %type <ttype> explicit_template_type
268 /* in order to recognize aggr tags as defining and thus shadowing. */
269 %token TYPENAME_DEFN IDENTIFIER_DEFN PTYPENAME_DEFN
270 %type <ttype> named_class_head_sans_basetype_defn
271 %type <ttype> identifier_defn IDENTIFIER_DEFN TYPENAME_DEFN PTYPENAME_DEFN
273 %type <ttype> self_template_type .finish_template_type
278 /* Used in lex.c for parsing pragmas. */
281 /* lex.c and pt.c depend on this being the last token. Define
282 any new tokens before this one! */
283 %token END_OF_SAVED_INPUT
286 /* List of types and structure classes of the current declaration. */
287 static tree current_declspecs;
289 /* List of prefix attributes in effect.
290 Prefix attributes are parsed by the reserved_declspecs and declmods
291 rules. They create a list that contains *both* declspecs and attrs. */
292 /* ??? It is not clear yet that all cases where an attribute can now appear in
293 a declspec list have been updated. */
294 static tree prefix_attributes;
296 /* When defining an aggregate, this is the kind of the most recent one
297 being defined. (For example, this might be class_type_node.) */
298 static tree current_aggr;
300 /* When defining an enumeration, this is the type of the enumeration. */
301 static tree current_enum_type;
303 /* Tell yyparse how to print a token's value, if yydebug is set. */
305 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
306 extern void yyprint PROTO((FILE *, int, YYSTYPE));
307 extern tree combine_strings PROTO((tree));
310 parse_decl(declarator, specs_attrs, attributes, initialized, decl)
319 split_specs_attrs (specs_attrs, ¤t_declspecs, &prefix_attributes);
320 if (current_declspecs
321 && TREE_CODE (current_declspecs) != TREE_LIST)
322 current_declspecs = build_decl_list (NULL_TREE, current_declspecs);
323 if (have_extern_spec && !used_extern_spec)
325 current_declspecs = decl_tree_cons (NULL_TREE,
326 get_identifier ("extern"),
328 used_extern_spec = 1;
330 sm = suspend_momentary ();
331 *decl = start_decl (declarator, current_declspecs, initialized,
332 attributes, prefix_attributes);
341 { finish_translation_unit (); }
344 /* the reason for the strange actions in this rule
345 is so that notype_initdecls when reached via datadef
346 can find a valid list of type and sc specs in $0. */
349 { $<ttype>$ = NULL_TREE; }
351 { $<ttype>$ = NULL_TREE; }
352 | extdefs lang_extdef
353 { $<ttype>$ = NULL_TREE; }
362 { have_extern_spec = 1;
363 used_extern_spec = 0;
364 $<ttype>$ = NULL_TREE; }
367 { have_extern_spec = 0; }
372 { $<itype>$ = pedantic;
381 { if (pending_lang_change) do_pending_lang_change(); }
383 { if (! toplevel_bindings_p () && ! pseudo_global_level_p())
388 fndef eat_saved_input
389 { if (pending_inlines) do_pending_inlines (); }
391 { if (pending_inlines) do_pending_inlines (); }
393 { if (pending_inlines) do_pending_inlines (); }
394 | asm_keyword '(' string ')' ';'
395 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
397 | extern_lang_string '{' extdefs_opt '}'
398 { pop_lang_context (); }
399 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
400 { if (pending_inlines) do_pending_inlines ();
401 pop_lang_context (); }
402 | extern_lang_string .hush_warning datadef .warning_ok
403 { if (pending_inlines) do_pending_inlines ();
404 pop_lang_context (); }
405 | NAMESPACE identifier '{'
406 { push_namespace ($2); }
408 { pop_namespace (); }
410 { push_namespace (NULL_TREE); }
412 { pop_namespace (); }
415 { do_toplevel_using_decl ($1); }
418 { pedantic = $<itype>1; }
422 NAMESPACE identifier '='
423 { begin_only_namespace_names (); }
426 end_only_namespace_names ();
429 do_namespace_alias ($2, $5);
436 | USING global_scope qualified_id
438 | USING global_scope unqualified_id
442 namespace_using_decl:
443 USING namespace_qualifier identifier
444 { $$ = build_parse_node (SCOPE_REF, $2, $3); }
445 | USING global_scope identifier
446 { $$ = build_parse_node (SCOPE_REF, global_namespace, $3); }
447 | USING global_scope namespace_qualifier identifier
448 { $$ = build_parse_node (SCOPE_REF, $3, $4); }
453 { begin_only_namespace_names (); }
456 end_only_namespace_names ();
457 /* If no declaration was found, the using-directive is
458 invalid. Since that was not reported, we need the
459 identifier for the error message. */
460 if (TREE_CODE ($4) == IDENTIFIER_NODE && lastiddecl)
462 do_using_directive ($4);
469 if (TREE_CODE ($$) == IDENTIFIER_NODE)
473 | namespace_qualifier NSNAME SCOPE
476 if (TREE_CODE ($$) == IDENTIFIER_NODE)
484 | global_scope qualified_id
486 | global_scope unqualified_id
492 { push_lang_context ($1); }
493 | extern_lang_string EXTERN_LANG_STRING
494 { if (current_lang_name != $2)
495 cp_error ("use of linkage spec `%D' is different from previous spec `%D'", $2, current_lang_name);
496 pop_lang_context (); push_lang_context ($2); }
501 { begin_template_parm_list (); }
502 template_parm_list '>'
503 { $$ = end_template_parm_list ($4); }
505 { begin_specialization();
511 { $$ = process_template_parm (NULL_TREE, $1); }
512 | template_parm_list ',' template_parm
513 { $$ = process_template_parm ($1, $3); }
523 aggr maybe_identifier
524 { $$ = finish_template_type_parm ($1, $2); }
525 | TYPENAME_KEYWORD maybe_identifier
526 { $$ = finish_template_type_parm (class_type_node, $2); }
529 template_template_parm:
530 template_header aggr maybe_identifier
531 { $$ = finish_template_template_parm ($2, $3); }
535 /* The following rules introduce a new reduce/reduce
536 conflict on the ',' and '>' input tokens: they are valid
537 prefixes for a `structsp', which means they could match a
538 nameless parameter. See 14.6, paragraph 3.
539 By putting them before the `parm' rule, we get
540 their match before considering them nameless parameter
543 { $$ = build_tree_list (NULL_TREE, $1); }
544 | template_type_parm '=' type_id
545 { $$ = build_tree_list (groktypename ($3.t), $1); }
547 { $$ = build_tree_list (NULL_TREE, $1.t); }
548 | parm '=' expr_no_commas %prec ARITHCOMPARE
549 { $$ = build_tree_list ($3, $1.t); }
550 | template_template_parm
551 { $$ = build_tree_list (NULL_TREE, $1); }
552 | template_template_parm '=' template_arg
554 if (TREE_CODE ($3) != TEMPLATE_DECL
555 && TREE_CODE ($3) != TEMPLATE_TEMPLATE_PARM
556 && TREE_CODE ($3) != TYPE_DECL)
558 error ("invalid default template argument");
559 $3 = error_mark_node;
561 $$ = build_tree_list ($3, $1);
566 template_header template_extdef
567 { finish_template_decl ($1); }
568 | template_header error %prec EMPTY
569 { finish_template_decl ($1); }
573 fndef eat_saved_input
574 { if (pending_inlines) do_pending_inlines (); }
576 { if (pending_inlines) do_pending_inlines (); }
578 { if (pending_inlines) do_pending_inlines (); }
579 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
580 { if (pending_inlines) do_pending_inlines ();
581 pop_lang_context (); }
582 | extern_lang_string .hush_warning template_datadef .warning_ok
583 { if (pending_inlines) do_pending_inlines ();
584 pop_lang_context (); }
585 | extension template_extdef
586 { pedantic = $<itype>1; }
591 | declmods notype_initdecls ';'
593 | typed_declspecs initdecls ';'
594 { note_list_got_semicolon ($1.t); }
596 { maybe_process_partial_specialization ($1.t);
597 note_got_semicolon ($1.t); }
602 | declmods notype_initdecls ';'
604 | typed_declspecs initdecls ';'
605 { note_list_got_semicolon ($1.t); }
607 { pedwarn ("empty declaration"); }
608 | explicit_instantiation ';'
609 | typed_declspecs ';'
612 split_specs_attrs ($1.t, &t, &attrs);
614 note_list_got_semicolon ($1.t);
621 ctor_initializer_opt:
640 fn.def1 maybe_return_init ctor_initializer_opt compstmt_or_error
641 { finish_function (lineno, (int)$3, 0); }
642 | fn.def1 maybe_return_init function_try_block
644 int nested = (hack_decl_function_context
645 (current_function_decl) != NULL_TREE);
646 finish_function (lineno, (int)$3, nested);
648 | fn.def1 maybe_return_init error
652 constructor_declarator:
653 nested_name_specifier SELFNAME '('
654 { $$ = begin_constructor_declarator ($1, $2); }
655 parmlist ')' cv_qualifiers exception_specification_opt
656 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
657 | nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
658 { $$ = begin_constructor_declarator ($1, $2);
659 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
661 | global_scope nested_name_specifier SELFNAME '('
662 { $$ = begin_constructor_declarator ($2, $3); }
663 parmlist ')' cv_qualifiers exception_specification_opt
664 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
665 | global_scope nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
666 { $$ = begin_constructor_declarator ($2, $3);
667 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
669 | nested_name_specifier self_template_type '('
670 { $$ = begin_constructor_declarator ($1, $2); }
671 parmlist ')' cv_qualifiers exception_specification_opt
672 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
673 | nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
674 { $$ = begin_constructor_declarator ($1, $2);
675 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
677 | global_scope nested_name_specifier self_template_type '('
678 { $$ = begin_constructor_declarator ($2, $3); }
679 parmlist ')' cv_qualifiers exception_specification_opt
680 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
681 | global_scope nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
682 { $$ = begin_constructor_declarator ($2, $3);
683 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
688 typed_declspecs declarator
689 { if (!begin_function_definition ($1.t, $2))
691 | declmods notype_declarator
692 { if (!begin_function_definition ($1, $2))
695 { if (!begin_function_definition (NULL_TREE, $1))
697 | declmods constructor_declarator
698 { if (!begin_function_definition ($1, $2))
700 | constructor_declarator
701 { if (!begin_function_definition (NULL_TREE, $1))
705 component_constructor_declarator:
706 SELFNAME '(' parmlist ')' cv_qualifiers exception_specification_opt
707 { $$ = make_call_declarator ($1, $3, $5, $6); }
708 | SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
709 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
710 | self_template_type '(' parmlist ')' cv_qualifiers exception_specification_opt
711 { $$ = make_call_declarator ($1, $3, $5, $6); }
712 | self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
713 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
716 /* more C++ complexity. See component_decl for a comment on the
717 reduce/reduce conflict introduced by these rules. */
719 declmods component_constructor_declarator
721 split_specs_attrs ($1, &specs, &attrs);
722 attrs = build_tree_list (attrs, NULL_TREE);
723 $$ = start_method (specs, $2, attrs);
727 if (yychar == YYEMPTY)
729 reinit_parse_for_method (yychar, $$); }
730 | component_constructor_declarator
731 { $$ = start_method (NULL_TREE, $1, NULL_TREE);
733 | typed_declspecs declarator
735 split_specs_attrs ($1.t, &specs, &attrs);
736 attrs = build_tree_list (attrs, NULL_TREE);
737 $$ = start_method (specs, $2, attrs); goto rest_of_mdef; }
738 | declmods notype_declarator
740 split_specs_attrs ($1, &specs, &attrs);
741 attrs = build_tree_list (attrs, NULL_TREE);
742 $$ = start_method (specs, $2, attrs); goto rest_of_mdef; }
744 { $$ = start_method (NULL_TREE, $$, NULL_TREE);
746 | declmods constructor_declarator
748 split_specs_attrs ($1, &specs, &attrs);
749 attrs = build_tree_list (attrs, NULL_TREE);
750 $$ = start_method (specs, $2, attrs); goto rest_of_mdef; }
751 | constructor_declarator
752 { $$ = start_method (NULL_TREE, $$, NULL_TREE);
759 if (! current_function_parms_stored)
767 { store_return_init ($<ttype>$, $2); }
768 | return_id '(' nonnull_exprlist ')'
769 { store_return_init ($<ttype>$, $3); }
770 | return_id LEFT_RIGHT
771 { store_return_init ($<ttype>$, NULL_TREE); }
775 ':' .set_base_init member_init_list
778 error ("no base initializers given following ':'");
780 /* Always keep the BLOCK node associated with the outermost
781 pair of curley braces of a function. These are needed
782 for correct operation of dwarfout.c. */
790 if (! current_function_parms_stored)
793 if (DECL_CONSTRUCTOR_P (current_function_decl))
795 /* Make a contour for the initializer list. */
798 expand_start_bindings (0);
800 else if (current_class_type == NULL_TREE)
801 error ("base initializers not allowed for non-member functions");
802 else if (! DECL_CONSTRUCTOR_P (current_function_decl))
803 error ("only constructors take base initializers");
812 | member_init_list ',' member_init
813 | member_init_list error
817 '(' nonnull_exprlist ')'
819 if (current_class_name)
820 pedwarn ("anachronistic old style base class initializer");
821 expand_member_init (current_class_ref, NULL_TREE, $2);
825 if (current_class_name)
826 pedwarn ("anachronistic old style base class initializer");
827 expand_member_init (current_class_ref, NULL_TREE, void_type_node);
829 | notype_identifier '(' nonnull_exprlist ')'
830 { expand_member_init (current_class_ref, $1, $3); }
831 | notype_identifier LEFT_RIGHT
832 { expand_member_init (current_class_ref, $1, void_type_node); }
833 | nonnested_type '(' nonnull_exprlist ')'
834 { expand_member_init (current_class_ref, $1, $3); }
835 | nonnested_type LEFT_RIGHT
836 { expand_member_init (current_class_ref, $1, void_type_node); }
837 | typename_sub '(' nonnull_exprlist ')'
838 { expand_member_init (current_class_ref, TYPE_MAIN_DECL ($1),
840 | typename_sub LEFT_RIGHT
841 { expand_member_init (current_class_ref, TYPE_MAIN_DECL ($1),
865 explicit_instantiation:
866 TEMPLATE begin_explicit_instantiation typespec ';'
867 { do_type_instantiation ($3.t, NULL_TREE);
869 end_explicit_instantiation
870 | TEMPLATE begin_explicit_instantiation typed_declspecs declarator
871 { tree specs = strip_attrs ($3.t);
872 do_decl_instantiation (specs, $4, NULL_TREE); }
873 end_explicit_instantiation
874 | TEMPLATE begin_explicit_instantiation notype_declarator
875 { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
876 end_explicit_instantiation
877 | TEMPLATE begin_explicit_instantiation constructor_declarator
878 { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
879 end_explicit_instantiation
880 | SCSPEC TEMPLATE begin_explicit_instantiation typespec ';'
881 { do_type_instantiation ($4.t, $1);
883 end_explicit_instantiation
884 | SCSPEC TEMPLATE begin_explicit_instantiation typed_declspecs
886 { tree specs = strip_attrs ($4.t);
887 do_decl_instantiation (specs, $5, $1); }
888 end_explicit_instantiation
889 | SCSPEC TEMPLATE begin_explicit_instantiation notype_declarator
890 { do_decl_instantiation (NULL_TREE, $4, $1); }
891 end_explicit_instantiation
892 | SCSPEC TEMPLATE begin_explicit_instantiation constructor_declarator
893 { do_decl_instantiation (NULL_TREE, $4, $1); }
894 end_explicit_instantiation
897 begin_explicit_instantiation:
898 { begin_explicit_instantiation(); }
900 end_explicit_instantiation:
901 { end_explicit_instantiation(); }
903 /* The TYPENAME expansions are to deal with use of a template class name as
904 a template within the class itself, where the template decl is hidden by
905 a type decl. Got all that? */
908 PTYPENAME '<' template_arg_list_opt template_close_bracket
909 .finish_template_type
911 | TYPENAME '<' template_arg_list_opt template_close_bracket
912 .finish_template_type
917 apparent_template_type:
919 | identifier '<' template_arg_list_opt '>'
920 .finish_template_type
924 SELFNAME '<' template_arg_list_opt template_close_bracket
925 .finish_template_type
929 .finish_template_type:
931 if (yychar == YYEMPTY)
934 $$ = finish_template_type ($<ttype>-3, $<ttype>-1,
938 template_close_bracket:
942 /* Handle `Class<Class<Type>>' without space in the `>>' */
943 pedwarn ("`>>' should be `> >' in template class name");
948 template_arg_list_opt:
956 { $$ = build_tree_list (NULL_TREE, $$); }
957 | template_arg_list ',' template_arg
958 { $$ = chainon ($$, build_tree_list (NULL_TREE, $3)); }
963 { $$ = groktypename ($1.t); }
966 | expr_no_commas %prec ARITHCOMPARE
971 { $$ = NEGATE_EXPR; }
973 { $$ = CONVERT_EXPR; }
975 { $$ = PREINCREMENT_EXPR; }
977 { $$ = PREDECREMENT_EXPR; }
979 { $$ = TRUTH_NOT_EXPR; }
984 { $$ = build_x_compound_expr ($$); }
990 { error ("ANSI C++ forbids an empty condition for `%s'",
992 $$ = integer_zero_node; }
999 { error ("ANSI C++ forbids an empty condition for `%s'",
1001 $$ = integer_zero_node; }
1015 type_specifier_seq declarator maybeasm maybe_attribute '='
1018 for (d = getdecls (); d; d = TREE_CHAIN (d))
1019 if (TREE_CODE (d) == TYPE_DECL) {
1020 tree s = TREE_TYPE (d);
1021 if (TREE_CODE (s) == RECORD_TYPE)
1022 cp_error ("definition of class `%T' in condition", s);
1023 else if (TREE_CODE (s) == ENUMERAL_TYPE)
1024 cp_error ("definition of enum `%T' in condition", s);
1027 current_declspecs = $1.t;
1028 $<itype>5 = suspend_momentary ();
1029 $<ttype>$ = start_decl ($<ttype>2, current_declspecs, 1,
1030 $4, /*prefix_attributes*/ NULL_TREE);
1034 cp_finish_decl ($<ttype>6, $7, $4, 1, LOOKUP_ONLYCONVERTING);
1035 resume_momentary ($<itype>5);
1036 $$ = convert_from_reference ($<ttype>6);
1037 if (TREE_CODE (TREE_TYPE ($$)) == ARRAY_TYPE)
1038 cp_error ("definition of array `%#D' in condition", $$);
1045 | maybe_label_decls stmts '}'
1046 | maybe_label_decls stmts error '}'
1047 | maybe_label_decls error '}'
1050 already_scoped_stmt:
1052 { $<ttype>$ = begin_compound_stmt (1); }
1054 { finish_compound_stmt (1, $<ttype>2); }
1059 nontrivial_exprlist:
1060 expr_no_commas ',' expr_no_commas
1061 { $$ = expr_tree_cons (NULL_TREE, $$,
1062 build_expr_list (NULL_TREE, $3)); }
1063 | expr_no_commas ',' error
1064 { $$ = expr_tree_cons (NULL_TREE, $$,
1065 build_expr_list (NULL_TREE, error_mark_node)); }
1066 | nontrivial_exprlist ',' expr_no_commas
1067 { chainon ($$, build_expr_list (NULL_TREE, $3)); }
1068 | nontrivial_exprlist ',' error
1069 { chainon ($$, build_expr_list (NULL_TREE, error_mark_node)); }
1074 { $$ = build_expr_list (NULL_TREE, $$); }
1075 | nontrivial_exprlist
1081 /* __extension__ turns off -pedantic for following primary. */
1082 | extension cast_expr %prec UNARY
1084 pedantic = $<itype>1; }
1085 | '*' cast_expr %prec UNARY
1086 { $$ = build_x_indirect_ref ($2, "unary *"); }
1087 | '&' cast_expr %prec UNARY
1088 { $$ = build_x_unary_op (ADDR_EXPR, $2); }
1090 { $$ = build_x_unary_op (BIT_NOT_EXPR, $2); }
1091 | unop cast_expr %prec UNARY
1092 { $$ = finish_unary_op_expr ($1, $2); }
1093 /* Refer to the address of a label as a pointer. */
1096 pedwarn ("ANSI C++ forbids `&&'");
1097 $$ = finish_label_address_expr ($2); }
1098 | SIZEOF unary_expr %prec UNARY
1099 { $$ = expr_sizeof ($2); }
1100 | SIZEOF '(' type_id ')' %prec HYPERUNARY
1101 { $$ = c_sizeof (groktypename ($3.t));
1102 check_for_new_type ("sizeof", $3); }
1103 | ALIGNOF unary_expr %prec UNARY
1104 { $$ = grok_alignof ($2); }
1105 | ALIGNOF '(' type_id ')' %prec HYPERUNARY
1106 { $$ = c_alignof (groktypename ($3.t));
1107 check_for_new_type ("alignof", $3); }
1109 /* The %prec EMPTY's here are required by the = init initializer
1110 syntax extension; see below. */
1111 | new new_type_id %prec EMPTY
1112 { $$ = build_new (NULL_TREE, $2.t, NULL_TREE, $1);
1113 check_for_new_type ("new", $2); }
1114 | new new_type_id new_initializer
1115 { $$ = build_new (NULL_TREE, $2.t, $3, $1);
1116 check_for_new_type ("new", $2); }
1117 | new new_placement new_type_id %prec EMPTY
1118 { $$ = build_new ($2, $3.t, NULL_TREE, $1);
1119 check_for_new_type ("new", $3); }
1120 | new new_placement new_type_id new_initializer
1121 { $$ = build_new ($2, $3.t, $4, $1);
1122 check_for_new_type ("new", $3); }
1123 /* The .begin_new_placement in the following rules is
1124 necessary to avoid shift/reduce conflicts that lead to
1125 mis-parsing some expressions. Of course, these constructs
1126 are not really new-placement and it is bogus to call
1127 begin_new_placement. But, the parser cannot always tell at this
1128 point whether the next thing is an expression or a type-id,
1129 so there is nothing we can do. Fortunately,
1130 begin_new_placement does nothing harmful. When we rewrite
1131 the parser, this lossage should be removed, of course. */
1132 | new '(' .begin_new_placement type_id .finish_new_placement
1134 { $$ = build_new (NULL_TREE, groktypename($4.t),
1136 check_for_new_type ("new", $4); }
1137 | new '(' .begin_new_placement type_id .finish_new_placement
1139 { $$ = build_new (NULL_TREE, groktypename($4.t), $6, $1);
1140 check_for_new_type ("new", $4); }
1141 | new new_placement '(' .begin_new_placement type_id
1142 .finish_new_placement %prec EMPTY
1143 { $$ = build_new ($2, groktypename($5.t), NULL_TREE, $1);
1144 check_for_new_type ("new", $5); }
1145 | new new_placement '(' .begin_new_placement type_id
1146 .finish_new_placement new_initializer
1147 { $$ = build_new ($2, groktypename($5.t), $7, $1);
1148 check_for_new_type ("new", $5); }
1150 | delete cast_expr %prec UNARY
1151 { $$ = delete_sanity ($2, NULL_TREE, 0, $1); }
1152 | delete '[' ']' cast_expr %prec UNARY
1153 { $$ = delete_sanity ($4, NULL_TREE, 1, $1);
1154 if (yychar == YYEMPTY)
1156 | delete '[' expr ']' cast_expr %prec UNARY
1157 { $$ = delete_sanity ($5, $3, 2, $1);
1158 if (yychar == YYEMPTY)
1160 | REALPART cast_expr %prec UNARY
1161 { $$ = build_x_unary_op (REALPART_EXPR, $2); }
1162 | IMAGPART cast_expr %prec UNARY
1163 { $$ = build_x_unary_op (IMAGPART_EXPR, $2); }
1166 /* Note this rule is not suitable for use in new_placement
1167 since it uses NULL_TREE as the argument to
1168 finish_new_placement. This rule serves only to avoid
1169 reduce/reduce conflicts in unary_expr. See the comments
1170 there on the use of begin/finish_new_placement. */
1171 .finish_new_placement:
1173 { finish_new_placement (NULL_TREE, $<itype>-1); }
1175 .begin_new_placement:
1176 { $$ = begin_new_placement (); }
1179 '(' .begin_new_placement nonnull_exprlist ')'
1180 { $$ = finish_new_placement ($3, $2); }
1181 | '{' .begin_new_placement nonnull_exprlist '}'
1182 { cp_pedwarn ("old style placement syntax, use () instead");
1183 $$ = finish_new_placement ($3, $2); }
1187 '(' nonnull_exprlist ')'
1193 cp_error ("`%T' is not a valid expression", $2.t);
1194 $$ = error_mark_node;
1196 /* GNU extension so people can use initializer lists. Note that
1197 this alters the meaning of `new int = 1', which was previously
1198 syntactically valid but semantically invalid. */
1202 pedwarn ("ANSI C++ forbids initialization of new expression with `='");
1203 if (TREE_CODE ($2) != TREE_LIST
1204 && TREE_CODE ($2) != CONSTRUCTOR)
1205 $$ = build_expr_list (NULL_TREE, $2);
1211 /* This is necessary to postpone reduction of `int ((int)(int)(int))'. */
1213 '(' type_id ')' %prec EMPTY
1214 { $2.t = finish_parmlist (build_tree_list (NULL_TREE, $2.t), 0);
1215 $$ = make_call_declarator (NULL_TREE, $2.t, NULL_TREE, NULL_TREE);
1216 check_for_new_type ("cast", $2); }
1217 | regcast_or_absdcl '(' type_id ')' %prec EMPTY
1218 { $3.t = finish_parmlist (build_tree_list (NULL_TREE, $3.t), 0);
1219 $$ = make_call_declarator ($$, $3.t, NULL_TREE, NULL_TREE);
1220 check_for_new_type ("cast", $3); }
1225 | regcast_or_absdcl unary_expr %prec UNARY
1226 { $$ = reparse_absdcl_as_casts ($$, $2); }
1227 | regcast_or_absdcl '{' initlist maybecomma '}' %prec UNARY
1229 tree init = build_nt (CONSTRUCTOR, NULL_TREE,
1232 pedwarn ("ANSI C++ forbids constructor-expressions");
1233 /* Indicate that this was a GNU C constructor expression. */
1234 TREE_HAS_CONSTRUCTOR (init) = 1;
1236 $$ = reparse_absdcl_as_casts ($$, init);
1242 /* Handle general members. */
1243 | expr_no_commas POINTSAT_STAR expr_no_commas
1244 { $$ = build_x_binary_op (MEMBER_REF, $$, $3); }
1245 | expr_no_commas DOT_STAR expr_no_commas
1246 { $$ = build_m_component_ref ($$, $3); }
1247 | expr_no_commas '+' expr_no_commas
1248 { $$ = build_x_binary_op ($2, $$, $3); }
1249 | expr_no_commas '-' expr_no_commas
1250 { $$ = build_x_binary_op ($2, $$, $3); }
1251 | expr_no_commas '*' expr_no_commas
1252 { $$ = build_x_binary_op ($2, $$, $3); }
1253 | expr_no_commas '/' expr_no_commas
1254 { $$ = build_x_binary_op ($2, $$, $3); }
1255 | expr_no_commas '%' expr_no_commas
1256 { $$ = build_x_binary_op ($2, $$, $3); }
1257 | expr_no_commas LSHIFT expr_no_commas
1258 { $$ = build_x_binary_op ($2, $$, $3); }
1259 | expr_no_commas RSHIFT expr_no_commas
1260 { $$ = build_x_binary_op ($2, $$, $3); }
1261 | expr_no_commas ARITHCOMPARE expr_no_commas
1262 { $$ = build_x_binary_op ($2, $$, $3); }
1263 | expr_no_commas '<' expr_no_commas
1264 { $$ = build_x_binary_op (LT_EXPR, $$, $3); }
1265 | expr_no_commas '>' expr_no_commas
1266 { $$ = build_x_binary_op (GT_EXPR, $$, $3); }
1267 | expr_no_commas EQCOMPARE expr_no_commas
1268 { $$ = build_x_binary_op ($2, $$, $3); }
1269 | expr_no_commas MIN_MAX expr_no_commas
1270 { $$ = build_x_binary_op ($2, $$, $3); }
1271 | expr_no_commas '&' expr_no_commas
1272 { $$ = build_x_binary_op ($2, $$, $3); }
1273 | expr_no_commas '|' expr_no_commas
1274 { $$ = build_x_binary_op ($2, $$, $3); }
1275 | expr_no_commas '^' expr_no_commas
1276 { $$ = build_x_binary_op ($2, $$, $3); }
1277 | expr_no_commas ANDAND expr_no_commas
1278 { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $$, $3); }
1279 | expr_no_commas OROR expr_no_commas
1280 { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $$, $3); }
1281 | expr_no_commas '?' xexpr ':' expr_no_commas
1282 { $$ = build_x_conditional_expr ($$, $3, $5); }
1283 | expr_no_commas '=' expr_no_commas
1284 { $$ = build_x_modify_expr ($$, NOP_EXPR, $3);
1285 if ($$ != error_mark_node)
1286 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
1287 | expr_no_commas ASSIGN expr_no_commas
1288 { $$ = build_x_modify_expr ($$, $2, $3); }
1290 { $$ = build_throw (NULL_TREE); }
1291 | THROW expr_no_commas
1292 { $$ = build_throw ($2); }
1293 /* These extensions are not defined. The second arg to build_m_component_ref
1294 is old, build_m_component_ref now does an implicit
1295 build_indirect_ref (x, NULL_PTR) on the second argument.
1296 | object '&' expr_no_commas %prec UNARY
1297 { $$ = build_m_component_ref ($$, build_x_unary_op (ADDR_EXPR, $3)); }
1298 | object unop expr_no_commas %prec UNARY
1299 { $$ = build_m_component_ref ($$, build_x_unary_op ($2, $3)); }
1300 | object '(' type_id ')' expr_no_commas %prec UNARY
1301 { tree type = groktypename ($3.t);
1302 $$ = build_m_component_ref ($$, build_c_cast (type, $5)); }
1303 | object primary_no_id %prec UNARY
1304 { $$ = build_m_component_ref ($$, $2); }
1308 notype_unqualified_id:
1309 '~' see_typename identifier
1310 { $$ = build_parse_node (BIT_NOT_EXPR, $3); }
1311 | '~' see_typename template_type
1312 { $$ = build_parse_node (BIT_NOT_EXPR, $3); }
1317 | NSNAME %prec EMPTY
1322 /* If lastiddecl is a TREE_LIST, it's a baselink, which
1323 means that we're in an expression like S::f<int>, so
1324 don't do_identifier; we only do that for unqualified
1326 if (lastiddecl && TREE_CODE (lastiddecl) != TREE_LIST)
1327 $$ = do_identifier ($<ttype>-1, 1, NULL_TREE);
1333 PFUNCNAME '<' do_id template_arg_list_opt template_close_bracket
1334 { $$ = lookup_template_function ($3, $4); }
1335 | operator_name '<' do_id template_arg_list_opt template_close_bracket
1336 { $$ = lookup_template_function ($3, $4); }
1340 TEMPLATE identifier '<' template_arg_list_opt template_close_bracket
1341 { $$ = lookup_template_function ($2, $4); }
1342 | TEMPLATE PFUNCNAME '<' template_arg_list_opt template_close_bracket
1343 { $$ = lookup_template_function ($2, $4); }
1344 | TEMPLATE operator_name '<' template_arg_list_opt
1345 template_close_bracket
1346 { $$ = lookup_template_function ($2, $4); }
1350 notype_unqualified_id
1355 expr_or_declarator_intern:
1357 | attributes expr_or_declarator
1359 /* Provide support for '(' attributes '*' declarator ')'
1361 $$ = decl_tree_cons ($1, $2, NULL_TREE);
1366 notype_unqualified_id
1367 | '*' expr_or_declarator_intern %prec UNARY
1368 { $$ = build_parse_node (INDIRECT_REF, $2); }
1369 | '&' expr_or_declarator_intern %prec UNARY
1370 { $$ = build_parse_node (ADDR_EXPR, $2); }
1371 | '(' expr_or_declarator_intern ')'
1375 notype_template_declarator:
1376 IDENTIFIER '<' template_arg_list_opt template_close_bracket
1377 { $$ = lookup_template_function ($1, $3); }
1378 | NSNAME '<' template_arg_list template_close_bracket
1379 { $$ = lookup_template_function ($1, $3); }
1382 direct_notype_declarator:
1383 complex_direct_notype_declarator
1384 /* This precedence declaration is to prefer this reduce
1385 to the Koenig lookup shift in primary, below. I hate yacc. */
1386 | notype_unqualified_id %prec '('
1387 | notype_template_declarator
1388 | '(' expr_or_declarator_intern ')'
1389 { $$ = finish_decl_parsing ($2); }
1393 notype_unqualified_id
1395 if (TREE_CODE ($1) == BIT_NOT_EXPR)
1396 $$ = build_x_unary_op (BIT_NOT_EXPR, TREE_OPERAND ($1, 0));
1398 $$ = finish_id_expr ($1);
1404 if (processing_template_decl)
1405 push_obstacks (&permanent_obstack, &permanent_obstack);
1406 $$ = combine_strings ($$);
1407 /* combine_strings doesn't set up TYPE_MAIN_VARIANT of
1408 a const array the way we want, so fix it. */
1409 if (flag_const_strings)
1410 TREE_TYPE ($$) = build_cplus_array_type
1411 (TREE_TYPE (TREE_TYPE ($$)),
1412 TYPE_DOMAIN (TREE_TYPE ($$)));
1413 if (processing_template_decl)
1417 { $$ = finish_parenthesized_expr ($2); }
1418 | '(' expr_or_declarator_intern ')'
1419 { $2 = reparse_decl_as_expr (NULL_TREE, $2);
1420 $$ = finish_parenthesized_expr ($2); }
1422 { $$ = error_mark_node; }
1424 { tree scope = current_scope ();
1425 if (!scope || TREE_CODE (scope) != FUNCTION_DECL)
1427 error ("braced-group within expression allowed only inside a function");
1431 pedwarn ("ANSI C++ forbids braced-groups within expressions");
1432 $<ttype>$ = begin_stmt_expr ();
1435 { $$ = finish_stmt_expr ($<ttype>2, $3); }
1436 /* Koenig lookup support
1437 We could store lastiddecl in $1 to avoid another lookup,
1438 but that would result in many additional reduce/reduce conflicts. */
1439 | notype_unqualified_id '(' nonnull_exprlist ')'
1440 { $$ = finish_call_expr ($1, $3, 1); }
1441 | notype_unqualified_id LEFT_RIGHT
1442 { $$ = finish_call_expr ($1, NULL_TREE, 1); }
1443 | primary '(' nonnull_exprlist ')'
1444 { $$ = finish_call_expr ($1, $3, 0); }
1445 | primary LEFT_RIGHT
1446 { $$ = finish_call_expr ($1, NULL_TREE, 0); }
1447 | primary '[' expr ']'
1448 { $$ = grok_array_decl ($$, $3); }
1450 { $$ = finish_increment_expr ($1, POSTINCREMENT_EXPR); }
1451 | primary MINUSMINUS
1452 { $$ = finish_increment_expr ($1, POSTDECREMENT_EXPR); }
1453 /* C++ extensions */
1455 { $$ = finish_this_expr (); }
1456 | CV_QUALIFIER '(' nonnull_exprlist ')'
1458 /* This is a C cast in C++'s `functional' notation
1459 using the "implicit int" extension so that:
1460 `const (3)' is equivalent to `const int (3)'. */
1463 if ($3 == error_mark_node)
1465 $$ = error_mark_node;
1469 type = cp_build_qualified_type (integer_type_node,
1470 cp_type_qual_from_rid ($1));
1471 $$ = build_c_cast (type, build_compound_expr ($3));
1474 | DYNAMIC_CAST '<' type_id '>' '(' expr ')'
1475 { tree type = groktypename ($3.t);
1476 check_for_new_type ("dynamic_cast", $3);
1477 $$ = build_dynamic_cast (type, $6); }
1478 | STATIC_CAST '<' type_id '>' '(' expr ')'
1479 { tree type = groktypename ($3.t);
1480 check_for_new_type ("static_cast", $3);
1481 $$ = build_static_cast (type, $6); }
1482 | REINTERPRET_CAST '<' type_id '>' '(' expr ')'
1483 { tree type = groktypename ($3.t);
1484 check_for_new_type ("reinterpret_cast", $3);
1485 $$ = build_reinterpret_cast (type, $6); }
1486 | CONST_CAST '<' type_id '>' '(' expr ')'
1487 { tree type = groktypename ($3.t);
1488 check_for_new_type ("const_cast", $3);
1489 $$ = build_const_cast (type, $6); }
1490 | TYPEID '(' expr ')'
1491 { $$ = build_x_typeid ($3); }
1492 | TYPEID '(' type_id ')'
1493 { tree type = groktypename ($3.t);
1494 check_for_new_type ("typeid", $3);
1495 $$ = get_typeid (TYPE_MAIN_VARIANT (type)); }
1496 | global_scope IDENTIFIER
1497 { $$ = do_scoped_id ($2, 1); }
1498 | global_scope template_id
1500 | global_scope operator_name
1502 got_scope = NULL_TREE;
1503 if (TREE_CODE ($2) == IDENTIFIER_NODE)
1504 $$ = do_scoped_id ($2, 1);
1508 | overqualified_id %prec HYPERUNARY
1509 { $$ = build_offset_ref (OP0 ($$), OP1 ($$)); }
1510 | overqualified_id '(' nonnull_exprlist ')'
1511 { $$ = finish_qualified_call_expr ($1, $3); }
1512 | overqualified_id LEFT_RIGHT
1513 { $$ = finish_qualified_call_expr ($1, NULL_TREE); }
1514 | object object_template_id %prec UNARY
1516 $$ = build_x_component_ref ($$, $2, NULL_TREE, 1);
1518 | object object_template_id '(' nonnull_exprlist ')'
1519 { $$ = finish_object_call_expr ($2, $1, $4); }
1520 | object object_template_id LEFT_RIGHT
1521 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1522 | object unqualified_id %prec UNARY
1523 { $$ = build_x_component_ref ($$, $2, NULL_TREE, 1); }
1524 | object overqualified_id %prec UNARY
1525 { if (processing_template_decl)
1526 $$ = build_min_nt (COMPONENT_REF, $1, copy_to_permanent ($2));
1528 $$ = build_object_ref ($$, OP0 ($2), OP1 ($2)); }
1529 | object unqualified_id '(' nonnull_exprlist ')'
1530 { $$ = finish_object_call_expr ($2, $1, $4); }
1531 | object unqualified_id LEFT_RIGHT
1532 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1533 | object overqualified_id '(' nonnull_exprlist ')'
1534 { $$ = finish_qualified_object_call_expr ($2, $1, $4); }
1535 | object overqualified_id LEFT_RIGHT
1536 { $$ = finish_qualified_object_call_expr ($2, $1, NULL_TREE); }
1537 /* p->int::~int() is valid -- 12.4 */
1538 | object '~' TYPESPEC LEFT_RIGHT
1539 { $$ = finish_pseudo_destructor_call_expr ($1, NULL_TREE, $3); }
1540 | object TYPESPEC SCOPE '~' TYPESPEC LEFT_RIGHT
1541 { $$ = finish_pseudo_destructor_call_expr ($1, $2, $5); }
1544 $$ = error_mark_node;
1548 /* Not needed for now.
1554 { $$ = error_mark_node; }
1556 { if (current_function_decl == 0)
1558 error ("braced-group within expression allowed only inside a function");
1561 $<ttype>$ = expand_start_stmt_expr (); }
1564 pedwarn ("ANSI C++ forbids braced-groups within expressions");
1565 $$ = expand_end_stmt_expr ($<ttype>2); }
1566 | primary_no_id '(' nonnull_exprlist ')'
1567 { $$ = build_x_function_call ($$, $3, current_class_ref); }
1568 | primary_no_id LEFT_RIGHT
1569 { $$ = build_x_function_call ($$, NULL_TREE, current_class_ref); }
1570 | primary_no_id '[' expr ']'
1572 | primary_no_id PLUSPLUS
1573 { $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); }
1574 | primary_no_id MINUSMINUS
1575 { $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); }
1577 { goto do_scoped_id; }
1578 | SCOPE operator_name
1579 { if (TREE_CODE ($2) == IDENTIFIER_NODE)
1581 goto do_scoped_operator;
1590 { got_scope = NULL_TREE; $$ = 1; }
1596 | global_scope delete
1597 { got_scope = NULL_TREE; $$ = 1; }
1602 { $$ = boolean_true_node; }
1604 { $$ = boolean_false_node; }
1607 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
1611 { $$ = chainon ($$, $2); }
1617 if (! current_function_parms_stored)
1618 store_parm_decls ();
1620 /* Always keep the BLOCK node associated with the outermost
1621 pair of curley braces of a function. These are needed
1622 for correct operation of dwarfout.c. */
1629 { got_object = TREE_TYPE ($$); }
1632 $$ = build_x_arrow ($$);
1633 got_object = TREE_TYPE ($$);
1638 typespec initdecls ';'
1640 resume_momentary ($2);
1641 if ($1.t && IS_AGGR_TYPE_CODE (TREE_CODE ($1.t)))
1642 note_got_semicolon ($1.t);
1644 | typed_declspecs initdecls ';'
1646 resume_momentary ($2);
1647 note_list_got_semicolon ($1.t);
1649 | declmods notype_initdecls ';'
1650 { resume_momentary ($2); }
1651 | typed_declspecs ';'
1654 note_list_got_semicolon ($1.t);
1657 { warning ("empty declaration"); }
1659 { pedantic = $<itype>1; }
1662 /* Any kind of declarator (thus, all declarators allowed
1663 after an explicit typespec). */
1666 after_type_declarator %prec EMPTY
1667 | notype_declarator %prec EMPTY
1670 /* This is necessary to postpone reduction of `int()()()()'. */
1672 LEFT_RIGHT %prec EMPTY
1673 { $$ = make_call_declarator (NULL_TREE, empty_parms (),
1674 NULL_TREE, NULL_TREE); }
1675 | fcast_or_absdcl LEFT_RIGHT %prec EMPTY
1676 { $$ = make_call_declarator ($$, empty_parms (), NULL_TREE,
1680 /* ANSI type-id (8.1) */
1682 typed_typespecs absdcl
1683 { $$.t = build_decl_list ($1.t, $2);
1684 $$.new_type_flag = $1.new_type_flag; }
1685 | nonempty_cv_qualifiers absdcl
1686 { $$.t = build_decl_list ($1.t, $2);
1687 $$.new_type_flag = $1.new_type_flag; }
1689 { $$.t = build_decl_list (build_decl_list (NULL_TREE, $1.t),
1691 $$.new_type_flag = $1.new_type_flag; }
1692 | typed_typespecs %prec EMPTY
1693 { $$.t = build_decl_list ($1.t, NULL_TREE);
1694 $$.new_type_flag = $1.new_type_flag; }
1695 | nonempty_cv_qualifiers %prec EMPTY
1696 { $$.t = build_decl_list ($1.t, NULL_TREE);
1697 $$.new_type_flag = $1.new_type_flag; }
1700 /* Declspecs which contain at least one type specifier or typedef name.
1701 (Just `const' or `volatile' is not enough.)
1702 A typedef'd name following these is taken as a name to be declared.
1703 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1706 typed_typespecs %prec EMPTY
1712 { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1);
1713 $$.new_type_flag = $2.new_type_flag; }
1714 | typespec reserved_declspecs %prec HYPERUNARY
1715 { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2);
1716 $$.new_type_flag = $1.new_type_flag; }
1717 | typespec reserved_typespecquals reserved_declspecs
1718 { $$.t = decl_tree_cons (NULL_TREE, $1.t, chainon ($2, $3));
1719 $$.new_type_flag = $1.new_type_flag; }
1720 | declmods typespec reserved_declspecs
1721 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1));
1722 $$.new_type_flag = $2.new_type_flag; }
1723 | declmods typespec reserved_typespecquals
1724 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1));
1725 $$.new_type_flag = $2.new_type_flag; }
1726 | declmods typespec reserved_typespecquals reserved_declspecs
1727 { $$.t = decl_tree_cons (NULL_TREE, $2.t,
1728 chainon ($3, chainon ($4, $1)));
1729 $$.new_type_flag = $2.new_type_flag; }
1734 { if (extra_warnings)
1735 warning ("`%s' is not at beginning of declaration",
1736 IDENTIFIER_POINTER ($$));
1737 $$ = build_decl_list (NULL_TREE, $$); }
1738 | reserved_declspecs typespecqual_reserved
1739 { $$ = decl_tree_cons (NULL_TREE, $2.t, $$); }
1740 | reserved_declspecs SCSPEC
1741 { if (extra_warnings)
1742 warning ("`%s' is not at beginning of declaration",
1743 IDENTIFIER_POINTER ($2));
1744 $$ = decl_tree_cons (NULL_TREE, $2, $$); }
1745 | reserved_declspecs attributes
1746 { $$ = decl_tree_cons ($2, NULL_TREE, $1); }
1748 { $$ = decl_tree_cons ($1, NULL_TREE, NULL_TREE); }
1751 /* List of just storage classes and type modifiers.
1752 A declaration can start with just this, but then it cannot be used
1753 to redeclare a typedef-name.
1754 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1756 /* We use hash_tree_cons for lists of typeless declspecs so that they end
1757 up on a persistent obstack. Otherwise, they could appear at the
1758 beginning of something like
1760 static const struct { int foo () { } } b;
1762 and would be discarded after we finish compiling foo. We don't need to
1763 worry once we see a type. */
1766 nonempty_cv_qualifiers %prec EMPTY
1767 { $$ = $1.t; TREE_STATIC ($$) = 1; }
1769 { $$ = hash_tree_cons (NULL_TREE, $$, NULL_TREE); }
1770 | declmods CV_QUALIFIER
1771 { $$ = hash_tree_cons (NULL_TREE, $2, $$);
1772 TREE_STATIC ($$) = 1; }
1774 { if (extra_warnings && TREE_STATIC ($$))
1775 warning ("`%s' is not at beginning of declaration",
1776 IDENTIFIER_POINTER ($2));
1777 $$ = hash_tree_cons (NULL_TREE, $2, $$);
1778 TREE_STATIC ($$) = TREE_STATIC ($1); }
1779 | declmods attributes
1780 { $$ = hash_tree_cons ($2, NULL_TREE, $1); }
1782 { $$ = hash_tree_cons ($1, NULL_TREE, NULL_TREE); }
1785 /* Used instead of declspecs where storage classes are not allowed
1786 (that is, for typenames and structure components).
1788 C++ can takes storage classes for structure components.
1789 Don't accept a typedef-name if anything but a modifier precedes it. */
1792 typespec %prec EMPTY
1793 { $$.t = build_decl_list (NULL_TREE, $1.t);
1794 $$.new_type_flag = $1.new_type_flag; }
1795 | nonempty_cv_qualifiers typespec
1796 { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1.t);
1797 $$.new_type_flag = $2.new_type_flag; }
1798 | typespec reserved_typespecquals
1799 { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2);
1800 $$.new_type_flag = $1.new_type_flag; }
1801 | nonempty_cv_qualifiers typespec reserved_typespecquals
1802 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1803 $$.new_type_flag = $1.new_type_flag; }
1806 reserved_typespecquals:
1807 typespecqual_reserved
1808 { $$ = build_decl_list (NULL_TREE, $1.t); }
1809 | reserved_typespecquals typespecqual_reserved
1810 { $$ = decl_tree_cons (NULL_TREE, $2.t, $1); }
1813 /* A typespec (but not a type qualifier).
1814 Once we have seen one of these in a declaration,
1815 if a typedef name appears then it is being redeclared. */
1819 | TYPESPEC %prec EMPTY
1820 { $$.t = $1; $$.new_type_flag = 0; }
1821 | complete_type_name
1822 { $$.t = $1; $$.new_type_flag = 0; }
1823 | TYPEOF '(' expr ')'
1824 { $$.t = finish_typeof ($3);
1825 $$.new_type_flag = 0; }
1826 | TYPEOF '(' type_id ')'
1827 { $$.t = groktypename ($3.t);
1828 $$.new_type_flag = 0; }
1829 | SIGOF '(' expr ')'
1830 { tree type = TREE_TYPE ($3);
1832 $$.new_type_flag = 0;
1833 if (IS_AGGR_TYPE (type))
1835 sorry ("sigof type specifier");
1840 error ("`sigof' applied to non-aggregate expression");
1841 $$.t = error_mark_node;
1844 | SIGOF '(' type_id ')'
1845 { tree type = groktypename ($3.t);
1847 $$.new_type_flag = 0;
1848 if (IS_AGGR_TYPE (type))
1850 sorry ("sigof type specifier");
1855 error("`sigof' applied to non-aggregate type");
1856 $$.t = error_mark_node;
1861 /* A typespec that is a reserved word, or a type qualifier. */
1863 typespecqual_reserved:
1865 { $$.t = $1; $$.new_type_flag = 0; }
1867 { $$.t = $1; $$.new_type_flag = 0; }
1873 | initdecls ',' initdcl
1874 { check_multiple_declarators (); }
1879 | notype_initdecls ',' initdcl
1880 { check_multiple_declarators (); }
1885 | nomods_initdecls ',' initdcl
1886 { check_multiple_declarators (); }
1892 | asm_keyword '(' string ')'
1893 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3); $$ = $3; }
1897 declarator maybeasm maybe_attribute '='
1898 { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1,
1899 $3, prefix_attributes); }
1901 /* Note how the declaration of the variable is in effect while its init is parsed! */
1902 { cp_finish_decl ($<ttype>5, $6, $2, 1, LOOKUP_ONLYCONVERTING); }
1903 | declarator maybeasm maybe_attribute
1904 { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 0,
1905 $3, prefix_attributes);
1906 cp_finish_decl ($<ttype>$, NULL_TREE, $2, 1, 0); }
1909 /* This rule assumes a certain configuration of the parser stack.
1910 In particular, $0, the element directly before the beginning of
1911 this rule on the stack, must be a maybeasm. $-1 must be a
1912 declarator or notype_declarator. And $-2 must be some declmods
1913 or declspecs. We can't move the maybeasm into this rule because
1914 we need that reduce so we prefer fn.def1 when appropriate. */
1917 { $<itype>2 = parse_decl ($<ttype>-1, $<ttype>-2,
1918 $1, 1, &$<ttype>$); }
1919 /* Note how the declaration of the variable is in effect
1920 while its init is parsed! */
1922 { cp_finish_decl ($<ttype>3, $4, $<ttype>0, 1,
1923 LOOKUP_ONLYCONVERTING);
1927 $$ = parse_decl ($<ttype>-1, $<ttype>-2, $1, 0, &d);
1928 cp_finish_decl (d, NULL_TREE, $<ttype>0, 1, 0); }
1932 declarator maybeasm initdcl0_innards
1936 notype_declarator maybeasm initdcl0_innards
1941 notype_declarator maybeasm
1942 { /* Set things up as initdcl0_innards expects. */
1947 | constructor_declarator maybeasm maybe_attribute
1949 parse_decl($1, NULL_TREE, $3, 0, &d);
1950 cp_finish_decl (d, NULL_TREE, $2, 1, 0); }
1953 /* the * rules are dummies to accept the Apollo extended syntax
1954 so that the header files compile. */
1965 | attributes attribute
1966 { $$ = chainon ($1, $2); }
1970 ATTRIBUTE '(' '(' attribute_list ')' ')'
1977 | attribute_list ',' attrib
1978 { $$ = chainon ($1, $3); }
1985 { $$ = build_tree_list ($1, NULL_TREE); }
1986 | any_word '(' IDENTIFIER ')'
1987 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1988 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1989 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1990 | any_word '(' nonnull_exprlist ')'
1991 { $$ = build_tree_list ($1, $3); }
1994 /* This still leaves out most reserved keywords,
1995 shouldn't we include them? */
2004 /* A nonempty list of identifiers, including typenames. */
2005 identifiers_or_typenames:
2007 { $$ = build_tree_list (NULL_TREE, $1); }
2008 | identifiers_or_typenames ',' identifier
2009 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2013 /* empty */ %prec EMPTY
2018 /* If we are processing a template, we don't want to expand this
2022 expr_no_commas %prec '='
2024 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, NULL_TREE);
2025 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2027 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2028 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2029 | '{' initlist ',' '}'
2030 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2031 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2036 /* This chain is built in reverse order,
2037 and put in forward order where initlist is used. */
2040 { $$ = build_tree_list (NULL_TREE, $$); }
2042 { $$ = expr_tree_cons (NULL_TREE, $3, $$); }
2043 /* These are for labeled elements. */
2044 | '[' expr_no_commas ']' init
2045 { $$ = build_expr_list ($2, $4); }
2046 | identifier ':' init
2047 { $$ = build_expr_list ($$, $3); }
2048 | initlist ',' identifier ':' init
2049 { $$ = expr_tree_cons ($3, $5, $$); }
2053 PRE_PARSED_FUNCTION_DECL
2054 { start_function (NULL_TREE, TREE_VALUE ($1),
2056 reinit_parse_for_function (); }
2059 fn.defpen maybe_return_init ctor_initializer_opt compstmt_or_error
2061 int nested = (hack_decl_function_context
2062 (current_function_decl) != NULL_TREE);
2063 finish_function (lineno, (int)$3 | 2, nested);
2064 process_next_inline ($1);
2066 | fn.defpen maybe_return_init function_try_block
2068 int nested = (hack_decl_function_context
2069 (current_function_decl) != NULL_TREE);
2070 finish_function (lineno, (int)$3 | 2, nested);
2071 process_next_inline ($1);
2073 | fn.defpen maybe_return_init error
2074 { process_next_inline ($1); }
2079 | pending_inlines pending_inline eat_saved_input
2082 /* A regurgitated default argument. The value of DEFARG_MARKER will be
2083 the TREE_LIST node for the parameter in question. */
2085 DEFARG_MARKER expr_no_commas END_OF_SAVED_INPUT
2086 { replace_defarg ($1, $2); }
2087 | DEFARG_MARKER error END_OF_SAVED_INPUT
2088 { replace_defarg ($1, error_mark_node); }
2091 /* empty */ %prec EMPTY
2092 | pending_defargs defarg_again
2093 { do_pending_defargs (); }
2094 | pending_defargs error
2095 { do_pending_defargs (); }
2100 { $<itype>3 = suspend_momentary ();
2101 $<ttype>$ = current_enum_type;
2102 current_enum_type = start_enum ($2); }
2103 enumlist maybecomma_warn '}'
2104 { TYPE_VALUES (current_enum_type) = $5;
2105 $$.t = finish_enum (current_enum_type);
2106 $$.new_type_flag = 1;
2107 current_enum_type = $<ttype>4;
2108 resume_momentary ((int) $<itype>3);
2109 check_for_missing_semicolon ($$.t); }
2110 | ENUM identifier '{' '}'
2111 { $$.t = finish_enum (start_enum ($2));
2112 $$.new_type_flag = 1;
2113 check_for_missing_semicolon ($$.t); }
2115 { $<itype>2 = suspend_momentary ();
2116 $<ttype>$ = current_enum_type;
2117 current_enum_type = start_enum (make_anon_name ()); }
2118 enumlist maybecomma_warn '}'
2119 { TYPE_VALUES (current_enum_type) = $4;
2120 $$.t = finish_enum (current_enum_type);
2121 $$.new_type_flag = 1;
2122 current_enum_type = $<ttype>3;
2123 resume_momentary ((int) $<itype>1);
2124 check_for_missing_semicolon ($$.t); }
2126 { $$.t = finish_enum (start_enum (make_anon_name()));
2127 $$.new_type_flag = 1;
2128 check_for_missing_semicolon ($$.t); }
2130 { $$.t = xref_tag (enum_type_node, $2, 1);
2131 $$.new_type_flag = 0; }
2132 | ENUM complex_type_name
2133 { $$.t = xref_tag (enum_type_node, $2, 1);
2134 $$.new_type_flag = 0; }
2135 | TYPENAME_KEYWORD typename_sub
2137 $$.new_type_flag = 0;
2138 if (!processing_template_decl)
2139 cp_pedwarn ("using `typename' outside of template"); }
2140 /* C++ extensions, merged with C to avoid shift/reduce conflicts */
2141 | class_head left_curly
2142 opt.component_decl_list '}' maybe_attribute
2146 if (yychar == YYEMPTY)
2148 semi = yychar == ';';
2150 $<ttype>$ = finish_class_definition ($1, $5, semi);
2154 begin_inline_definitions ();
2158 finish_inline_definitions ();
2160 $$.new_type_flag = 1;
2162 | class_head %prec EMPTY
2164 $$.new_type_flag = 0;
2165 if (TYPE_BINFO ($1) == NULL_TREE)
2167 cp_error ("%T is not a class type", $1);
2168 $$.t = error_mark_node;
2173 /* struct B: public A; is not accepted by the WP grammar. */
2174 if (TYPE_BINFO_BASETYPES ($$.t) && !TYPE_SIZE ($$.t)
2175 && ! TYPE_BEING_DEFINED ($$.t))
2176 cp_error ("base clause without member specification for `%#T'",
2190 { if (pedantic && !in_system_header)
2191 pedwarn ("comma at end of enumerator list"); }
2197 { error ("storage class specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2199 { error ("type specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2201 { error ("type qualifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2203 { error ("no body nor ';' separates two class, struct or union declarations"); }
2205 { $$ = build_decl_list ($2, $1); }
2208 named_class_head_sans_basetype:
2216 named_class_head_sans_basetype_defn:
2217 aggr identifier_defn %prec EMPTY
2218 { current_aggr = $$; $$ = $2; }
2219 | named_class_head_sans_basetype '{'
2220 { yyungetc ('{', 1); }
2221 | named_class_head_sans_basetype ':'
2222 { yyungetc (':', 1); }
2225 named_complex_class_head_sans_basetype:
2226 aggr nested_name_specifier identifier
2229 $$ = handle_class_head ($1, $2, $3);
2231 | aggr global_scope nested_name_specifier identifier
2234 $$ = handle_class_head ($1, $3, $4);
2236 | aggr global_scope identifier
2239 $$ = handle_class_head ($1, NULL_TREE, $3);
2241 | aggr apparent_template_type
2242 { current_aggr = $$; $$ = $2; }
2243 | aggr nested_name_specifier apparent_template_type
2244 { current_aggr = $$; $$ = $3; }
2248 named_class_head_sans_basetype %prec EMPTY
2249 { $$ = xref_tag (current_aggr, $1, 1); }
2250 | named_class_head_sans_basetype_defn
2251 { $<ttype>$ = xref_tag (current_aggr, $1, 0); }
2252 /* Class name is unqualified, so we look for base classes
2253 in the current scope. */
2254 maybe_base_class_list %prec EMPTY
2258 xref_basetypes (current_aggr, $1, $<ttype>2, $3);
2260 | named_complex_class_head_sans_basetype
2262 if ($1 != error_mark_node)
2263 push_scope (CP_DECL_CONTEXT ($1));
2265 maybe_base_class_list
2267 if ($1 != error_mark_node)
2269 pop_scope (CP_DECL_CONTEXT ($1));
2270 $$ = TREE_TYPE ($1);
2271 if (current_aggr == union_type_node
2272 && TREE_CODE ($$) != UNION_TYPE)
2273 cp_pedwarn ("`union' tag used in declaring `%#T'", $$);
2274 else if (TREE_CODE ($$) == UNION_TYPE
2275 && current_aggr != union_type_node)
2276 cp_pedwarn ("non-`union' tag used in declaring `%#T'", $$);
2277 else if (TREE_CODE ($$) == RECORD_TYPE)
2278 /* We might be specializing a template with a different
2280 CLASSTYPE_DECLARED_CLASS ($$) = (current_aggr
2281 == class_type_node);
2284 maybe_process_partial_specialization ($$);
2285 xref_basetypes (current_aggr, $1, $$, $3);
2293 { $$ = xref_tag ($$, make_anon_name (), 0);
2294 yyungetc ('{', 1); }
2302 maybe_base_class_list:
2303 /* empty */ %prec EMPTY
2305 | ':' see_typename %prec EMPTY
2306 { yyungetc(':', 1); $$ = NULL_TREE; }
2307 | ':' see_typename base_class_list %prec EMPTY
2313 | base_class_list ',' see_typename base_class
2314 { $$ = chainon ($$, $4); }
2319 { $$ = finish_base_specifier (access_default_node, $1,
2321 == signature_type_node); }
2322 | base_class_access_list see_typename base_class.1
2323 { $$ = finish_base_specifier ($1, $3,
2325 == signature_type_node); }
2330 { if ($$ != error_mark_node) $$ = TYPE_MAIN_DECL ($1); }
2332 | SIGOF '(' expr ')'
2334 if (current_aggr == signature_type_node)
2336 if (IS_AGGR_TYPE (TREE_TYPE ($3)))
2338 sorry ("`sigof' as base signature specifier");
2339 $$ = TREE_TYPE ($3);
2343 error ("`sigof' applied to non-aggregate expression");
2344 $$ = error_mark_node;
2349 error ("`sigof' in struct or class declaration");
2350 $$ = error_mark_node;
2353 | SIGOF '(' type_id ')'
2355 if (current_aggr == signature_type_node)
2357 if (IS_AGGR_TYPE (groktypename ($3.t)))
2359 sorry ("`sigof' as base signature specifier");
2360 $$ = groktypename ($3.t);
2364 error ("`sigof' applied to non-aggregate expression");
2365 $$ = error_mark_node;
2370 error ("`sigof' in struct or class declaration");
2371 $$ = error_mark_node;
2376 base_class_access_list:
2377 VISSPEC see_typename
2378 | SCSPEC see_typename
2379 { if ($1 != ridpointers[(int)RID_VIRTUAL])
2380 cp_error ("`%D' access", $1);
2381 $$ = access_default_virtual_node; }
2382 | base_class_access_list VISSPEC see_typename
2384 if ($1 != access_default_virtual_node)
2385 error ("multiple access specifiers");
2386 else if ($2 == access_public_node)
2387 $$ = access_public_virtual_node;
2388 else if ($2 == access_protected_node)
2389 $$ = access_protected_virtual_node;
2390 else /* $2 == access_private_node */
2391 $$ = access_private_virtual_node;
2393 | base_class_access_list SCSPEC see_typename
2394 { if ($2 != ridpointers[(int)RID_VIRTUAL])
2395 cp_error ("`%D' access", $2);
2396 else if ($$ == access_public_node)
2397 $$ = access_public_virtual_node;
2398 else if ($$ == access_protected_node)
2399 $$ = access_protected_virtual_node;
2400 else if ($$ == access_private_node)
2401 $$ = access_private_virtual_node;
2403 error ("multiple `virtual' specifiers");
2409 { $<ttype>0 = begin_class_definition ($<ttype>0); }
2412 opt.component_decl_list:
2413 | component_decl_list
2414 | opt.component_decl_list access_specifier component_decl_list
2415 | opt.component_decl_list access_specifier
2421 if (current_aggr == signature_type_node)
2423 error ("access specifier not allowed in signature");
2424 $1 = access_public_node;
2427 current_access_specifier = $1;
2431 /* Note: we no longer warn about the semicolon after a component_decl_list.
2432 ARM $9.2 says that the semicolon is optional, and therefore allowed. */
2433 component_decl_list:
2436 finish_member_declaration ($1);
2438 | component_decl_list component_decl
2440 finish_member_declaration ($2);
2445 component_decl_1 ';'
2446 | component_decl_1 '}'
2447 { error ("missing ';' before right brace");
2448 yyungetc ('}', 0); }
2449 /* C++: handle constructors, destructors and inline functions */
2450 /* note that INLINE is like a TYPESPEC */
2451 | fn.def2 ':' /* base_init compstmt */
2452 { $$ = finish_method ($$); }
2453 | fn.def2 TRY /* base_init compstmt */
2454 { $$ = finish_method ($$); }
2455 | fn.def2 RETURN /* base_init compstmt */
2456 { $$ = finish_method ($$); }
2457 | fn.def2 '{' /* nodecls compstmt */
2458 { $$ = finish_method ($$); }
2461 | extension component_decl
2463 pedantic = $<itype>1; }
2464 | template_header component_decl
2467 $$ = finish_member_template_decl ($2);
2469 /* The component was already processed. */
2472 finish_template_decl ($1);
2474 | template_header typed_declspecs ';'
2476 $$ = finish_member_class_template ($2.t);
2477 finish_template_decl ($1);
2482 /* Do not add a "typed_declspecs declarator" rule here for
2483 speed; we need to call grok_x_components for enums, so the
2484 speedup would be insignificant. */
2485 typed_declspecs components
2487 /* Most of the productions for component_decl only
2488 allow the creation of one new member, so we call
2489 finish_member_declaration in component_decl_list.
2490 For this rule and the next, however, there can be
2491 more than one member, e.g.:
2495 and we need the first member to be fully
2496 registered before the second is processed.
2497 Therefore, the rules for components take care of
2498 this processing. To avoid registering the
2499 components more than once, we send NULL_TREE up
2500 here; that lets finish_member_declaration know
2501 that there is nothing to do. */
2503 grok_x_components ($1.t);
2506 | declmods notype_components
2509 grok_x_components ($1);
2512 | notype_declarator maybeasm maybe_attribute maybe_init
2513 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2514 build_tree_list ($3, NULL_TREE)); }
2515 | constructor_declarator maybeasm maybe_attribute maybe_init
2516 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2517 build_tree_list ($3, NULL_TREE)); }
2518 | ':' expr_no_commas
2519 { $$ = grokbitfield (NULL_TREE, NULL_TREE, $2); }
2523 /* These rules introduce a reduce/reduce conflict; in
2524 typedef int foo, bar;
2528 should "A::foo" be declared as a function or "A::bar" as a data
2529 member? In other words, is "bar" an after_type_declarator or a
2531 | declmods component_constructor_declarator maybeasm maybe_attribute maybe_init
2532 { tree specs, attrs;
2533 split_specs_attrs ($1, &specs, &attrs);
2534 $$ = grokfield ($2, specs, $5, $3,
2535 build_tree_list ($4, attrs)); }
2536 | component_constructor_declarator maybeasm maybe_attribute maybe_init
2537 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2538 build_tree_list ($3, NULL_TREE)); }
2540 { $$ = do_class_using_decl ($1); }
2542 /* The case of exactly one component is handled directly by component_decl. */
2545 /* empty: possibly anonymous */
2547 | component_declarator0
2549 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2550 $1 = finish_member_template_decl ($1);
2551 finish_member_declaration ($1);
2554 | components ',' component_declarator
2556 check_multiple_declarators ();
2557 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2558 $3 = finish_member_template_decl ($3);
2559 finish_member_declaration ($3);
2565 /* empty: possibly anonymous */
2567 | notype_component_declarator0
2569 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2570 $1 = finish_member_template_decl ($1);
2571 finish_member_declaration ($1);
2574 | notype_components ',' notype_component_declarator
2576 check_multiple_declarators ();
2577 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2578 $3 = finish_member_template_decl ($3);
2579 finish_member_declaration ($3);
2584 component_declarator0:
2585 after_type_component_declarator0
2586 | notype_component_declarator0
2589 component_declarator:
2590 after_type_component_declarator
2591 | notype_component_declarator
2594 after_type_component_declarator0:
2595 after_type_declarator maybeasm maybe_attribute maybe_init
2596 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2597 &prefix_attributes);
2598 $<ttype>0 = current_declspecs;
2599 $$ = grokfield ($$, current_declspecs, $4, $2,
2600 build_tree_list ($3, prefix_attributes)); }
2601 | TYPENAME ':' expr_no_commas maybe_attribute
2602 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2603 &prefix_attributes);
2604 $<ttype>0 = current_declspecs;
2605 $$ = grokbitfield ($$, current_declspecs, $3);
2606 cplus_decl_attributes ($$, $4, prefix_attributes); }
2609 notype_component_declarator0:
2610 notype_declarator maybeasm maybe_attribute maybe_init
2611 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2612 &prefix_attributes);
2613 $<ttype>0 = current_declspecs;
2614 $$ = grokfield ($$, current_declspecs, $4, $2,
2615 build_tree_list ($3, prefix_attributes)); }
2616 | constructor_declarator maybeasm maybe_attribute maybe_init
2617 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2618 &prefix_attributes);
2619 $<ttype>0 = current_declspecs;
2620 $$ = grokfield ($$, current_declspecs, $4, $2,
2621 build_tree_list ($3, prefix_attributes)); }
2622 | IDENTIFIER ':' expr_no_commas maybe_attribute
2623 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2624 &prefix_attributes);
2625 $<ttype>0 = current_declspecs;
2626 $$ = grokbitfield ($$, current_declspecs, $3);
2627 cplus_decl_attributes ($$, $4, prefix_attributes); }
2628 | ':' expr_no_commas maybe_attribute
2629 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2630 &prefix_attributes);
2631 $<ttype>0 = current_declspecs;
2632 $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
2633 cplus_decl_attributes ($$, $3, prefix_attributes); }
2636 after_type_component_declarator:
2637 after_type_declarator maybeasm maybe_attribute maybe_init
2638 { $$ = grokfield ($$, current_declspecs, $4, $2,
2639 build_tree_list ($3, prefix_attributes)); }
2640 | TYPENAME ':' expr_no_commas maybe_attribute
2641 { $$ = grokbitfield ($$, current_declspecs, $3);
2642 cplus_decl_attributes ($$, $4, prefix_attributes); }
2645 notype_component_declarator:
2646 notype_declarator maybeasm maybe_attribute maybe_init
2647 { $$ = grokfield ($$, current_declspecs, $4, $2,
2648 build_tree_list ($3, prefix_attributes)); }
2649 | IDENTIFIER ':' expr_no_commas maybe_attribute
2650 { $$ = grokbitfield ($$, current_declspecs, $3);
2651 cplus_decl_attributes ($$, $4, prefix_attributes); }
2652 | ':' expr_no_commas maybe_attribute
2653 { $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
2654 cplus_decl_attributes ($$, $3, prefix_attributes); }
2657 /* We chain the enumerators in reverse order.
2658 Because of the way enums are built, the order is
2659 insignificant. Take advantage of this fact. */
2663 | enumlist ',' enumerator
2664 { TREE_CHAIN ($3) = $$; $$ = $3; }
2669 { $$ = build_enumerator ($$, NULL_TREE, current_enum_type); }
2670 | identifier '=' expr_no_commas
2671 { $$ = build_enumerator ($$, $3, current_enum_type); }
2674 /* ANSI new-type-id (5.3.4) */
2676 type_specifier_seq new_declarator
2677 { $$.t = build_decl_list ($1.t, $2);
2678 $$.new_type_flag = $1.new_type_flag; }
2679 | type_specifier_seq %prec EMPTY
2680 { $$.t = build_decl_list ($1.t, NULL_TREE);
2681 $$.new_type_flag = $1.new_type_flag; }
2682 /* GNU extension to allow arrays of arbitrary types with
2683 non-constant dimension. For the use of begin_new_placement
2684 here, see the comments in unary_expr above. */
2685 | '(' .begin_new_placement type_id .finish_new_placement
2689 pedwarn ("ANSI C++ forbids array dimensions with parenthesized type in new");
2690 $$.t = build_parse_node (ARRAY_REF, TREE_VALUE ($3.t), $6);
2691 $$.t = build_decl_list (TREE_PURPOSE ($3.t), $$.t);
2692 $$.new_type_flag = $3.new_type_flag;
2697 /* empty */ %prec EMPTY
2699 | cv_qualifiers CV_QUALIFIER
2700 { $$ = decl_tree_cons (NULL_TREE, $2, $$); }
2703 nonempty_cv_qualifiers:
2705 { $$.t = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
2706 $$.new_type_flag = 0; }
2707 | nonempty_cv_qualifiers CV_QUALIFIER
2708 { $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
2709 $$.new_type_flag = $1.new_type_flag; }
2712 /* These rules must follow the rules for function declarations
2713 and component declarations. That way, longer rules are preferred. */
2717 { $<itype>$ = suspend_momentary (); }
2719 /* An expression which will not live on the momentary obstack. */
2722 { resume_momentary ((int) $<itype>1); $$ = $2; }
2725 /* An expression which will not live on the momentary obstack. */
2727 suspend_mom '(' nonnull_exprlist ')'
2728 { resume_momentary ((int) $<itype>1); $$ = $3; }
2729 | suspend_mom '(' parmlist ')'
2730 { resume_momentary ((int) $<itype>1); $$ = $3; }
2731 | suspend_mom LEFT_RIGHT
2732 { resume_momentary ((int) $<itype>1); $$ = empty_parms (); }
2733 | suspend_mom '(' error ')'
2734 { resume_momentary ((int) $<itype>1); $$ = NULL_TREE; }
2737 /* A declarator that is allowed only after an explicit typespec. */
2738 /* may all be followed by prec '.' */
2739 after_type_declarator:
2740 '*' nonempty_cv_qualifiers after_type_declarator %prec UNARY
2741 { $$ = make_pointer_declarator ($2.t, $3); }
2742 | '&' nonempty_cv_qualifiers after_type_declarator %prec UNARY
2743 { $$ = make_reference_declarator ($2.t, $3); }
2744 | '*' after_type_declarator %prec UNARY
2745 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2746 | '&' after_type_declarator %prec UNARY
2747 { $$ = make_reference_declarator (NULL_TREE, $2); }
2748 | ptr_to_mem cv_qualifiers after_type_declarator
2749 { tree arg = make_pointer_declarator ($2, $3);
2750 $$ = build_parse_node (SCOPE_REF, $1, arg);
2752 | direct_after_type_declarator
2756 type_name %prec EMPTY
2758 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2760 $$ = lookup_name ($1, 1);
2761 if (current_class_type
2762 && TYPE_BEING_DEFINED (current_class_type)
2763 && ! IDENTIFIER_CLASS_VALUE ($1))
2765 /* Remember that this name has been used in the class
2766 definition, as per [class.scope0] */
2767 pushdecl_class_level ($$);
2773 | global_scope type_name
2775 if (TREE_CODE ($2) == IDENTIFIER_NODE)
2776 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
2779 got_scope = NULL_TREE;
2786 | global_scope nested_type
2791 nested_name_specifier type_name %prec EMPTY
2792 { $$ = get_type_decl ($2); }
2795 direct_after_type_declarator:
2796 direct_after_type_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2797 { $$ = make_call_declarator ($$, $2, $3, $4); }
2798 | direct_after_type_declarator '[' nonmomentary_expr ']'
2799 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
2800 | direct_after_type_declarator '[' ']'
2801 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
2802 | '(' after_type_declarator ')'
2804 | nested_name_specifier type_name %prec EMPTY
2805 { push_nested_class ($1, 3);
2806 $$ = build_parse_node (SCOPE_REF, $$, $2);
2807 TREE_COMPLEXITY ($$) = current_class_depth; }
2808 | type_name %prec EMPTY
2811 /* A declarator allowed whether or not there has been
2812 an explicit typespec. These cannot redeclare a typedef-name. */
2814 notype_declarator_intern:
2816 | attributes notype_declarator
2818 /* Provide support for '(' attributes '*' declarator ')'
2820 $$ = decl_tree_cons ($1, $2, NULL_TREE);
2825 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2826 { $$ = make_pointer_declarator ($2.t, $3); }
2827 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2828 { $$ = make_reference_declarator ($2.t, $3); }
2829 | '*' notype_declarator_intern %prec UNARY
2830 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2831 | '&' notype_declarator_intern %prec UNARY
2832 { $$ = make_reference_declarator (NULL_TREE, $2); }
2833 | ptr_to_mem cv_qualifiers notype_declarator_intern
2834 { tree arg = make_pointer_declarator ($2, $3);
2835 $$ = build_parse_node (SCOPE_REF, $1, arg);
2837 | direct_notype_declarator
2840 complex_notype_declarator:
2841 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2842 { $$ = make_pointer_declarator ($2.t, $3); }
2843 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2844 { $$ = make_reference_declarator ($2.t, $3); }
2845 | '*' complex_notype_declarator %prec UNARY
2846 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2847 | '&' complex_notype_declarator %prec UNARY
2848 { $$ = make_reference_declarator (NULL_TREE, $2); }
2849 | ptr_to_mem cv_qualifiers notype_declarator_intern
2850 { tree arg = make_pointer_declarator ($2, $3);
2851 $$ = build_parse_node (SCOPE_REF, $1, arg);
2853 | complex_direct_notype_declarator
2856 complex_direct_notype_declarator:
2857 direct_notype_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2858 { $$ = make_call_declarator ($$, $2, $3, $4); }
2859 | '(' complex_notype_declarator ')'
2861 | direct_notype_declarator '[' nonmomentary_expr ']'
2862 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
2863 | direct_notype_declarator '[' ']'
2864 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
2865 | notype_qualified_id
2866 { enter_scope_of ($1); }
2867 | nested_name_specifier notype_template_declarator
2868 { got_scope = NULL_TREE;
2869 $$ = build_parse_node (SCOPE_REF, $1, $2);
2870 enter_scope_of ($$);
2875 nested_name_specifier unqualified_id
2876 { got_scope = NULL_TREE;
2877 $$ = build_parse_node (SCOPE_REF, $$, $2); }
2878 | nested_name_specifier object_template_id
2879 { got_scope = NULL_TREE;
2880 $$ = build_parse_node (SCOPE_REF, $1, $2); }
2883 notype_qualified_id:
2884 nested_name_specifier notype_unqualified_id
2885 { got_scope = NULL_TREE;
2886 $$ = build_parse_node (SCOPE_REF, $$, $2); }
2887 | nested_name_specifier object_template_id
2888 { got_scope = NULL_TREE;
2889 $$ = build_parse_node (SCOPE_REF, $1, $2); }
2894 | global_scope notype_qualified_id
2899 typespec '(' nonnull_exprlist ')'
2900 { $$ = build_functional_cast ($1.t, $3); }
2901 | typespec '(' expr_or_declarator_intern ')'
2902 { $$ = reparse_decl_as_expr ($1.t, $3); }
2903 | typespec fcast_or_absdcl %prec EMPTY
2904 { $$ = reparse_absdcl_as_expr ($1.t, $2); }
2909 | template_type %prec EMPTY
2912 nested_name_specifier:
2913 nested_name_specifier_1
2914 | nested_name_specifier nested_name_specifier_1
2916 | nested_name_specifier TEMPLATE explicit_template_type SCOPE
2917 { got_scope = $$ = make_typename_type ($1, $3); }
2920 /* Why the @#$%^& do type_name and notype_identifier need to be expanded
2921 inline here?!? (jason) */
2922 nested_name_specifier_1:
2925 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2928 /* Remember that this name has been used in the class
2929 definition, as per [class.scope0] */
2930 if (current_class_type
2931 && TYPE_BEING_DEFINED (current_class_type)
2932 && ! IDENTIFIER_CLASS_VALUE ($1))
2933 pushdecl_class_level ($$);
2935 got_scope = $$ = TYPE_MAIN_VARIANT (TREE_TYPE ($$));
2939 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2941 got_scope = $$ = TREE_TYPE ($$);
2945 if (TREE_CODE ($$) == IDENTIFIER_NODE)
2949 | template_type SCOPE
2950 { got_scope = $$ = complete_type (TREE_TYPE ($1)); }
2951 /* These break 'const i;'
2955 cp_error ("`%D' is not an aggregate typedef",
2956 lastiddecl ? lastiddecl : $$);
2957 $$ = error_mark_node;
2960 { goto failed_scope; } */
2965 | global_scope typename_sub0
2970 typename_sub1 identifier %prec EMPTY
2972 if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't')
2973 $$ = make_typename_type ($1, $2);
2974 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
2975 cp_error ("`%T' is not a class or namespace", $2);
2979 if (TREE_CODE ($$) == TYPE_DECL)
2980 $$ = TREE_TYPE ($$);
2983 | typename_sub1 template_type %prec EMPTY
2984 { $$ = TREE_TYPE ($2); }
2985 | typename_sub1 explicit_template_type %prec EMPTY
2986 { $$ = make_typename_type ($1, $2); }
2987 | typename_sub1 TEMPLATE explicit_template_type %prec EMPTY
2988 { $$ = make_typename_type ($1, $3); }
2994 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2995 cp_error ("`%T' is not a class or namespace", $1);
2997 | typename_sub1 typename_sub2
2999 if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't')
3000 $$ = make_typename_type ($1, $2);
3001 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
3002 cp_error ("`%T' is not a class or namespace", $2);
3006 if (TREE_CODE ($$) == TYPE_DECL)
3007 $$ = TREE_TYPE ($$);
3010 | typename_sub1 explicit_template_type SCOPE
3011 { got_scope = $$ = make_typename_type ($1, $2); }
3012 | typename_sub1 TEMPLATE explicit_template_type SCOPE
3013 { got_scope = $$ = make_typename_type ($1, $3); }
3019 if (TREE_CODE ($1) != IDENTIFIER_NODE)
3022 /* Retrieve the type for the identifier, which might involve
3023 some computation. */
3024 got_scope = $$ = complete_type (IDENTIFIER_TYPE_VALUE ($1));
3026 if ($$ == error_mark_node)
3027 cp_error ("`%T' is not a class or namespace", $1);
3031 if (TREE_CODE ($1) != IDENTIFIER_NODE)
3033 got_scope = $$ = complete_type (TREE_TYPE ($$));
3035 | template_type SCOPE
3036 { got_scope = $$ = complete_type (TREE_TYPE ($$)); }
3041 if (TREE_CODE ($$) == IDENTIFIER_NODE)
3047 explicit_template_type:
3048 identifier '<' template_arg_list_opt template_close_bracket
3049 { $$ = build_min_nt (TEMPLATE_ID_EXPR, $1, $3); }
3053 global_scope type_name
3055 if (TREE_CODE ($2) == IDENTIFIER_NODE)
3056 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
3059 got_scope = NULL_TREE;
3062 | global_scope nested_type
3067 nested_name_specifier '*'
3068 { got_scope = NULL_TREE; }
3069 | global_scope nested_name_specifier '*'
3070 { $$ = $2; got_scope = NULL_TREE; }
3073 /* All uses of explicit global scope must go through this nonterminal so
3074 that got_scope will be set before yylex is called to get the next token. */
3077 { got_scope = void_type_node; }
3080 /* ANSI new-declarator (5.3.4) */
3082 '*' cv_qualifiers new_declarator
3083 { $$ = make_pointer_declarator ($2, $3); }
3084 | '*' cv_qualifiers %prec EMPTY
3085 { $$ = make_pointer_declarator ($2, NULL_TREE); }
3086 | '&' cv_qualifiers new_declarator %prec EMPTY
3087 { $$ = make_reference_declarator ($2, $3); }
3088 | '&' cv_qualifiers %prec EMPTY
3089 { $$ = make_reference_declarator ($2, NULL_TREE); }
3090 | ptr_to_mem cv_qualifiers %prec EMPTY
3091 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3092 $$ = build_parse_node (SCOPE_REF, $1, arg);
3094 | ptr_to_mem cv_qualifiers new_declarator
3095 { tree arg = make_pointer_declarator ($2, $3);
3096 $$ = build_parse_node (SCOPE_REF, $1, arg);
3098 | direct_new_declarator %prec EMPTY
3101 /* ANSI direct-new-declarator (5.3.4) */
3102 direct_new_declarator:
3104 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3105 | direct_new_declarator '[' nonmomentary_expr ']'
3106 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3109 /* ANSI abstract-declarator (8.1) */
3111 '*' nonempty_cv_qualifiers absdcl
3112 { $$ = make_pointer_declarator ($2.t, $3); }
3114 { $$ = make_pointer_declarator (NULL_TREE, $2); }
3115 | '*' nonempty_cv_qualifiers %prec EMPTY
3116 { $$ = make_pointer_declarator ($2.t, NULL_TREE); }
3118 { $$ = make_pointer_declarator (NULL_TREE, NULL_TREE); }
3119 | '&' nonempty_cv_qualifiers absdcl
3120 { $$ = make_reference_declarator ($2.t, $3); }
3122 { $$ = make_reference_declarator (NULL_TREE, $2); }
3123 | '&' nonempty_cv_qualifiers %prec EMPTY
3124 { $$ = make_reference_declarator ($2.t, NULL_TREE); }
3126 { $$ = make_reference_declarator (NULL_TREE, NULL_TREE); }
3127 | ptr_to_mem cv_qualifiers %prec EMPTY
3128 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3129 $$ = build_parse_node (SCOPE_REF, $1, arg);
3131 | ptr_to_mem cv_qualifiers absdcl
3132 { tree arg = make_pointer_declarator ($2, $3);
3133 $$ = build_parse_node (SCOPE_REF, $1, arg);
3135 | direct_abstract_declarator %prec EMPTY
3138 /* ANSI direct-abstract-declarator (8.1) */
3139 direct_abstract_declarator:
3142 /* `(typedef)1' is `int'. */
3144 | direct_abstract_declarator '(' parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3145 { $$ = make_call_declarator ($$, $3, $5, $6); }
3146 | direct_abstract_declarator LEFT_RIGHT cv_qualifiers exception_specification_opt %prec '.'
3147 { $$ = make_call_declarator ($$, empty_parms (), $3, $4); }
3148 | direct_abstract_declarator '[' nonmomentary_expr ']' %prec '.'
3149 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3150 | direct_abstract_declarator '[' ']' %prec '.'
3151 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
3152 | '(' complex_parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3153 { $$ = make_call_declarator (NULL_TREE, $2, $4, $5); }
3154 | regcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3155 { set_quals_and_spec ($$, $2, $3); }
3156 | fcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3157 { set_quals_and_spec ($$, $2, $3); }
3158 | '[' nonmomentary_expr ']' %prec '.'
3159 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3161 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, NULL_TREE); }
3164 /* For C++, decls and stmts can be intermixed, so we don't need to
3165 have a special rule that won't start parsing the stmt section
3166 until we have a stmt that parses without errors. */
3179 /* Read zero or more forward-declarations for labels
3180 that nested functions can jump to. */
3185 pedwarn ("ANSI C++ forbids label declarations"); }
3190 | label_decls label_decl
3194 LABEL identifiers_or_typenames ';'
3196 for (link = $2; link; link = TREE_CHAIN (link))
3198 tree label = shadow_label (TREE_VALUE (link));
3199 C_DECLARED_LABEL_FLAG (label) = 1;
3200 declare_nonlocal_label (label);
3205 /* This is the body of a function definition.
3206 It causes syntax errors to ignore to the next openbrace. */
3215 { $<ttype>$ = begin_compound_stmt (0); }
3217 { $$ = finish_compound_stmt (0, $<ttype>2); }
3223 $<ttype>$ = begin_if_stmt ();
3224 cond_stmt_keyword = "if";
3227 { finish_if_stmt_cond ($3, $<ttype>2); }
3228 implicitly_scoped_stmt
3229 { $<ttype>$ = finish_then_clause ($<ttype>2); }
3232 implicitly_scoped_stmt:
3234 | { $<ttype>$ = begin_compound_stmt (0); }
3236 { $$ = finish_compound_stmt (0, $<ttype>1); }
3249 { finish_expr_stmt ($1); }
3251 { begin_else_clause (); }
3252 implicitly_scoped_stmt
3254 finish_else_clause ($<ttype>1);
3257 | simple_if %prec IF
3258 { finish_if_stmt (); }
3261 $<ttype>$ = begin_while_stmt ();
3262 cond_stmt_keyword = "while";
3265 { finish_while_stmt_cond ($3, $<ttype>2); }
3267 { finish_while_stmt ($<ttype>2); }
3269 { $<ttype>$ = begin_do_stmt (); }
3270 implicitly_scoped_stmt WHILE
3272 finish_do_body ($<ttype>2);
3273 cond_stmt_keyword = "do";
3275 paren_expr_or_null ';'
3276 { finish_do_stmt ($6, $<ttype>2); }
3278 { $<ttype>$ = begin_for_stmt (); }
3279 '(' for.init.statement
3280 { finish_for_init_stmt ($<ttype>2); }
3282 { finish_for_cond ($6, $<ttype>2); }
3284 { finish_for_expr ($9, $<ttype>2); }
3286 { finish_for_stmt ($9, $<ttype>2); }
3288 { begin_switch_stmt (); }
3290 { $<ttype>$ = finish_switch_cond ($4); }
3291 implicitly_scoped_stmt
3292 { finish_switch_stmt ($4, $<ttype>6); }
3293 | CASE expr_no_commas ':'
3294 { finish_case_label ($2, NULL_TREE); }
3296 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
3297 { finish_case_label ($2, $4); }
3300 { finish_case_label (NULL_TREE, NULL_TREE); }
3303 { finish_break_stmt (); }
3305 { finish_continue_stmt (); }
3307 { finish_return_stmt (NULL_TREE); }
3309 { finish_return_stmt ($2); }
3310 | asm_keyword maybe_cv_qualifier '(' string ')' ';'
3312 finish_asm_stmt ($2, $4, NULL_TREE, NULL_TREE,
3315 /* This is the case with just output operands. */
3316 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ')' ';'
3318 finish_asm_stmt ($2, $4, $6, NULL_TREE,
3321 /* This is the case with input operands as well. */
3322 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':' asm_operands ')' ';'
3323 { finish_asm_stmt ($2, $4, $6, $8, NULL_TREE); }
3324 /* This is the case with clobbered registers as well. */
3325 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':'
3326 asm_operands ':' asm_clobbers ')' ';'
3327 { finish_asm_stmt ($2, $4, $6, $8, $10); }
3331 pedwarn ("ANSI C++ forbids computed gotos");
3332 finish_goto_stmt ($3);
3334 | GOTO identifier ';'
3335 { finish_goto_stmt ($2); }
3339 { error ("label must be followed by statement");
3346 | namespace_using_decl
3347 { do_local_using_decl ($1); }
3354 if (! current_function_parms_stored)
3355 store_parm_decls ();
3356 expand_start_early_try_stmts ();
3358 ctor_initializer_opt compstmt
3360 expand_start_all_catch ();
3364 expand_end_all_catch ();
3371 { $<ttype>$ = begin_try_block (); }
3373 { finish_try_block ($<ttype>2); }
3375 { finish_handler_sequence ($<ttype>2); }
3380 | handler_seq handler
3385 { $<ttype>$ = begin_handler(); }
3387 { finish_handler_parms ($<ttype>2); }
3389 { finish_handler ($<ttype>2); }
3393 typed_typespecs %prec EMPTY
3394 | nonempty_cv_qualifiers %prec EMPTY
3399 { expand_start_catch_block (NULL_TREE, NULL_TREE); }
3400 /* This doesn't allow reference parameters, the below does.
3401 | '(' type_specifier_seq absdcl ')'
3402 { check_for_new_type ("inside exception declarations", $2);
3403 expand_start_catch_block ($2.t, $3); }
3404 | '(' type_specifier_seq ')'
3405 { check_for_new_type ("inside exception declarations", $2);
3406 expand_start_catch_block ($2.t, NULL_TREE); }
3407 | '(' type_specifier_seq notype_declarator ')'
3408 { check_for_new_type ("inside exception declarations", $2);
3409 expand_start_catch_block ($2.t, $3); }
3410 | '(' typed_typespecs after_type_declarator ')'
3411 { check_for_new_type ("inside exception declarations", $2);
3412 expand_start_catch_block ($2.t, $3); }
3413 This allows reference parameters... */
3415 { check_for_new_type ("inside exception declarations", $2);
3416 expand_start_catch_block (TREE_PURPOSE ($2.t),
3417 TREE_VALUE ($2.t)); }
3424 label = define_label (input_filename, lineno, $1);
3425 if (label && ! minimal_parse_mode)
3426 expand_label (label);
3438 { if ($1) cplus_expand_expr_stmt ($1); }
3442 pedwarn ("ANSI C++ forbids compound statements inside for initializations");
3446 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
3450 { emit_line_note (input_filename, lineno);
3453 { emit_line_note (input_filename, lineno); }
3464 /* These are the operands other than the first string and colon
3465 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
3469 | nonnull_asm_operands
3472 nonnull_asm_operands:
3474 | nonnull_asm_operands ',' asm_operand
3475 { $$ = chainon ($$, $3); }
3480 { $$ = build_tree_list ($$, $3); }
3485 { $$ = tree_cons (NULL_TREE, $$, NULL_TREE); }
3486 | asm_clobbers ',' STRING
3487 { $$ = tree_cons (NULL_TREE, $3, $$); }
3490 /* This is what appears inside the parens in a function declarator.
3491 Its value is represented in the format that grokdeclarator expects.
3493 In C++, declaring a function with no parameters
3494 means that that function takes *no* parameters. */
3503 { $$ = finish_parmlist (build_tree_list (NULL_TREE, $1.t), 0);
3504 check_for_new_type ("inside parameter list", $1); }
3507 /* This nonterminal does not include the common sequence '(' type_id ')',
3508 as it is ambiguous and must be disambiguated elsewhere. */
3511 { $$ = finish_parmlist ($$, 0); }
3512 | parms_comma ELLIPSIS
3513 { $$ = finish_parmlist ($1, 1); }
3514 /* C++ allows an ellipsis without a separating ',' */
3516 { $$ = finish_parmlist ($1, 1); }
3518 { $$ = finish_parmlist (build_tree_list (NULL_TREE,
3521 { $$ = finish_parmlist (NULL_TREE, 1); }
3524 /* This helps us recover from really nasty
3525 parse errors, for example, a missing right
3527 yyerror ("possibly missing ')'");
3528 $$ = finish_parmlist ($1, 0);
3534 /* This helps us recover from really nasty
3535 parse errors, for example, a missing right
3537 yyerror ("possibly missing ')'");
3538 $$ = finish_parmlist (build_tree_list (NULL_TREE,
3545 /* A default argument to a */
3548 { maybe_snarf_defarg (); }
3558 /* A nonempty list of parameter declarations or type names. */
3561 { check_for_new_type ("in a parameter list", $1);
3562 $$ = build_tree_list (NULL_TREE, $1.t); }
3564 { check_for_new_type ("in a parameter list", $1);
3565 $$ = build_tree_list ($2, $1.t); }
3566 | parms_comma full_parm
3567 { check_for_new_type ("in a parameter list", $2);
3568 $$ = chainon ($$, $2.t); }
3569 | parms_comma bad_parm
3570 { $$ = chainon ($$, build_tree_list (NULL_TREE, $2)); }
3571 | parms_comma bad_parm '=' init
3572 { $$ = chainon ($$, build_tree_list ($4, $2)); }
3578 { check_for_new_type ("in a parameter list", $1);
3579 $$ = build_tree_list (NULL_TREE, $1.t); }
3582 /* A single parameter declaration or parameter type name,
3583 as found in a parmlist. */
3585 /* Here we expand typed_declspecs inline to avoid mis-parsing of
3586 TYPESPEC IDENTIFIER. */
3587 typed_declspecs1 declarator
3588 { tree specs = strip_attrs ($1.t);
3589 $$.new_type_flag = $1.new_type_flag;
3590 $$.t = build_tree_list (specs, $2); }
3591 | typed_typespecs declarator
3592 { $$.t = build_tree_list ($1.t, $2);
3593 $$.new_type_flag = $1.new_type_flag; }
3594 | typespec declarator
3595 { $$.t = build_tree_list (build_decl_list (NULL_TREE, $1.t),
3597 $$.new_type_flag = $1.new_type_flag; }
3598 | typed_declspecs1 absdcl
3599 { tree specs = strip_attrs ($1.t);
3600 $$.t = build_tree_list (specs, $2);
3601 $$.new_type_flag = $1.new_type_flag; }
3602 | typed_declspecs1 %prec EMPTY
3603 { tree specs = strip_attrs ($1.t);
3604 $$.t = build_tree_list (specs, NULL_TREE);
3605 $$.new_type_flag = $1.new_type_flag; }
3606 | declmods notype_declarator
3607 { tree specs = strip_attrs ($1);
3608 $$.t = build_tree_list (specs, $2);
3609 $$.new_type_flag = 0; }
3614 { $$.t = build_tree_list (NULL_TREE, $1.t);
3615 $$.new_type_flag = $1.new_type_flag; }
3617 { $$.t = build_tree_list ($2, $1.t);
3618 $$.new_type_flag = $1.new_type_flag; }
3627 /* empty */ %prec EMPTY
3628 { see_typename (); }
3632 /* empty */ %prec EMPTY
3634 error ("type specifier omitted for parameter");
3635 $$ = build_tree_list (integer_type_node, NULL_TREE);
3639 error ("type specifier omitted for parameter");
3640 if (TREE_CODE ($$) == SCOPE_REF
3641 && (TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TYPE_PARM
3642 || TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TEMPLATE_PARM))
3643 cp_error (" perhaps you want `typename %E' to make it a type", $$);
3644 $$ = build_tree_list (integer_type_node, $$);
3648 exception_specification_opt:
3649 /* empty */ %prec EMPTY
3651 | THROW '(' ansi_raise_identifiers ')' %prec EMPTY
3653 | THROW LEFT_RIGHT %prec EMPTY
3654 { $$ = build_decl_list (NULL_TREE, NULL_TREE); }
3657 ansi_raise_identifier:
3659 { $$ = build_decl_list (NULL_TREE, groktypename($1.t)); }
3662 ansi_raise_identifiers:
3663 ansi_raise_identifier
3664 | ansi_raise_identifiers ',' ansi_raise_identifier
3666 TREE_CHAIN ($3) = $$;
3671 conversion_declarator:
3672 /* empty */ %prec EMPTY
3674 | '*' cv_qualifiers conversion_declarator
3675 { $$ = make_pointer_declarator ($2, $3); }
3676 | '&' cv_qualifiers conversion_declarator
3677 { $$ = make_reference_declarator ($2, $3); }
3678 | ptr_to_mem cv_qualifiers conversion_declarator
3679 { tree arg = make_pointer_declarator ($2, $3);
3680 $$ = build_parse_node (SCOPE_REF, $1, arg);
3686 { got_scope = NULL_TREE; }
3691 { $$ = ansi_opname[MULT_EXPR]; }
3693 { $$ = ansi_opname[TRUNC_DIV_EXPR]; }
3695 { $$ = ansi_opname[TRUNC_MOD_EXPR]; }
3697 { $$ = ansi_opname[PLUS_EXPR]; }
3699 { $$ = ansi_opname[MINUS_EXPR]; }
3701 { $$ = ansi_opname[BIT_AND_EXPR]; }
3703 { $$ = ansi_opname[BIT_IOR_EXPR]; }
3705 { $$ = ansi_opname[BIT_XOR_EXPR]; }
3707 { $$ = ansi_opname[BIT_NOT_EXPR]; }
3709 { $$ = ansi_opname[COMPOUND_EXPR]; }
3710 | operator ARITHCOMPARE
3711 { $$ = ansi_opname[$2]; }
3713 { $$ = ansi_opname[LT_EXPR]; }
3715 { $$ = ansi_opname[GT_EXPR]; }
3716 | operator EQCOMPARE
3717 { $$ = ansi_opname[$2]; }
3719 { $$ = ansi_assopname[$2]; }
3721 { $$ = ansi_opname [MODIFY_EXPR]; }
3723 { $$ = ansi_opname[$2]; }
3725 { $$ = ansi_opname[$2]; }
3727 { $$ = ansi_opname[POSTINCREMENT_EXPR]; }
3728 | operator MINUSMINUS
3729 { $$ = ansi_opname[PREDECREMENT_EXPR]; }
3731 { $$ = ansi_opname[TRUTH_ANDIF_EXPR]; }
3733 { $$ = ansi_opname[TRUTH_ORIF_EXPR]; }
3735 { $$ = ansi_opname[TRUTH_NOT_EXPR]; }
3737 { $$ = ansi_opname[COND_EXPR]; }
3739 { $$ = ansi_opname[$2]; }
3740 | operator POINTSAT %prec EMPTY
3741 { $$ = ansi_opname[COMPONENT_REF]; }
3742 | operator POINTSAT_STAR %prec EMPTY
3743 { $$ = ansi_opname[MEMBER_REF]; }
3744 | operator LEFT_RIGHT
3745 { $$ = ansi_opname[CALL_EXPR]; }
3747 { $$ = ansi_opname[ARRAY_REF]; }
3748 | operator NEW %prec EMPTY
3749 { $$ = ansi_opname[NEW_EXPR]; }
3750 | operator DELETE %prec EMPTY
3751 { $$ = ansi_opname[DELETE_EXPR]; }
3752 | operator NEW '[' ']'
3753 { $$ = ansi_opname[VEC_NEW_EXPR]; }
3754 | operator DELETE '[' ']'
3755 { $$ = ansi_opname[VEC_DELETE_EXPR]; }
3756 /* Names here should be looked up in class scope ALSO. */
3757 | operator type_specifier_seq conversion_declarator
3758 { $$ = grokoptypename ($2.t, $3); }
3760 { $$ = ansi_opname[ERROR_MARK]; }
3767 debug_yytranslate (value)
3770 return yytname[YYTRANSLATE (value)];