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 const char * const language_string = "GNU C++";
50 extern struct obstack permanent_obstack;
52 extern int end_of_file;
54 /* Like YYERROR but do call yyerror. */
55 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
57 #define OP0(NODE) (TREE_OPERAND (NODE, 0))
58 #define OP1(NODE) (TREE_OPERAND (NODE, 1))
60 /* Contains the statement keyword (if/while/do) to include in an
61 error message if the user supplies an empty conditional expression. */
62 static const char *cond_stmt_keyword;
64 static tree empty_parms PROTO((void));
65 static int parse_decl PROTO((tree, tree, tree, int, tree *));
67 /* Nonzero if we have an `extern "C"' acting as an extern specifier. */
71 /* Cons up an empty parameter list. */
81 || current_class_type != NULL)
82 parms = void_list_node;
92 %union {long itype; tree ttype; char *strtype; enum tree_code code; flagged_type_tree ftype; }
94 /* All identifiers that are not reserved words
95 and are not declared typedefs in the current block */
98 /* All identifiers that are declared typedefs in the current block.
99 In some contexts, they are treated just like IDENTIFIER,
100 but they can also serve as typespecs in declarations. */
104 /* A template function. */
107 /* Reserved words that specify storage class.
108 yylval contains an IDENTIFIER_NODE which indicates which one. */
111 /* Reserved words that specify type.
112 yylval contains an IDENTIFIER_NODE which indicates which one. */
115 /* Reserved words that qualify type: "const" or "volatile".
116 yylval contains an IDENTIFIER_NODE which indicates which one. */
119 /* Character or numeric constants.
120 yylval is the node for the constant. */
123 /* String constants in raw form.
124 yylval is a STRING_CST node. */
127 /* "...", used for functions with variable arglists. */
130 /* the reserved words */
131 /* SCO include files test "ASM", so use something else. */
132 %token SIZEOF ENUM /* STRUCT UNION */ IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
133 %token BREAK CONTINUE RETURN_KEYWORD GOTO ASM_KEYWORD TYPEOF ALIGNOF
135 %token ATTRIBUTE EXTENSION LABEL
136 %token REALPART IMAGPART VA_ARG
138 /* the reserved words... C++ extensions */
140 %token <ttype> VISSPEC
141 %token DELETE NEW THIS OPERATOR CXX_TRUE CXX_FALSE
142 %token NAMESPACE TYPENAME_KEYWORD USING
143 %token LEFT_RIGHT TEMPLATE
144 %token TYPEID DYNAMIC_CAST STATIC_CAST REINTERPRET_CAST CONST_CAST
147 /* Define the operator tokens and their precedences.
148 The value is an integer because, if used, it is the tree code
149 to use in the expression made from the operator. */
151 %left EMPTY /* used to resolve s/r with epsilon */
155 /* Add precedence rules to solve dangling else s/r conflict */
159 %left IDENTIFIER PFUNCNAME TYPENAME SELFNAME PTYPENAME SCSPEC TYPESPEC CV_QUALIFIER ENUM AGGR ELLIPSIS TYPEOF SIGOF OPERATOR NSNAME TYPENAME_KEYWORD
165 %right <code> ASSIGN '='
173 %left <code> EQCOMPARE
174 %left <code> ARITHCOMPARE '<' '>'
175 %left <code> LSHIFT RSHIFT
177 %left <code> '*' '/' '%'
178 %left <code> POINTSAT_STAR DOT_STAR
179 %right <code> UNARY PLUSPLUS MINUSMINUS '~'
181 %left <ttype> LEFT_RIGHT
182 %left <code> POINTSAT '.' '(' '['
184 %right SCOPE /* C++ extension */
185 %nonassoc NEW DELETE TRY CATCH
189 %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist
190 %type <ttype> PFUNCNAME maybe_identifier
191 %type <ttype> paren_expr_or_null nontrivial_exprlist SELFNAME
192 %type <ttype> expr_no_commas cast_expr unary_expr primary string STRING
193 %type <ttype> reserved_declspecs boolean.literal
194 %type <ttype> reserved_typespecquals
195 %type <ttype> declmods
196 %type <ttype> SCSPEC TYPESPEC CV_QUALIFIER maybe_cv_qualifier
197 %type <itype> initdecls notype_initdecls initdcl /* C++ modification */
198 %type <ttype> init initlist maybeasm maybe_init defarg defarg1
199 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
200 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
201 %type <ttype> any_word
203 %type <ttype> compstmt implicitly_scoped_stmt
205 %type <ttype> declarator notype_declarator after_type_declarator
206 %type <ttype> notype_declarator_intern absdcl_intern
207 %type <ttype> after_type_declarator_intern
208 %type <ttype> direct_notype_declarator direct_after_type_declarator
209 %type <itype> components notype_components
210 %type <ttype> component_decl component_decl_1
211 %type <ttype> component_declarator component_declarator0
212 %type <ttype> notype_component_declarator notype_component_declarator0
213 %type <ttype> after_type_component_declarator after_type_component_declarator0
214 %type <ttype> enumlist_opt 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
234 %type <itype> extension
237 %token <ttype> PTYPENAME
238 %token <ttype> PRE_PARSED_FUNCTION_DECL EXTERN_LANG_STRING ALL
239 %token <ttype> PRE_PARSED_CLASS_DECL DEFARG DEFARG_MARKER
240 %type <ttype> component_constructor_declarator
241 %type <ttype> fn.def2 return_id fn.defpen constructor_declarator
242 %type <itype> ctor_initializer_opt function_try_block
243 %type <ttype> named_class_head_sans_basetype
244 %type <ftype> class_head named_class_head
245 %type <ftype> named_complex_class_head_sans_basetype
246 %type <ttype> unnamed_class_head
247 %type <ttype> base_class_list
248 %type <ttype> base_class_access_list
249 %type <ttype> base_class maybe_base_class_list base_class.1
250 %type <ttype> exception_specification_opt ansi_raise_identifier ansi_raise_identifiers
251 %type <ttype> operator_name
252 %type <ttype> object aggr
253 %type <itype> new delete .begin_new_placement
254 /* %type <ttype> primary_no_id */
255 %type <ttype> nonmomentary_expr maybe_parmlist
256 %type <itype> initdcl0 notype_initdcl0 member_init_list initdcl0_innards
257 %type <ttype> template_header template_parm_list template_parm
258 %type <ttype> template_type_parm template_template_parm
259 %type <code> template_close_bracket
260 %type <ttype> apparent_template_type
261 %type <ttype> template_type template_arg_list template_arg_list_opt
262 %type <ttype> template_arg
263 %type <ttype> condition xcond paren_cond_or_null
264 %type <ttype> type_name nested_name_specifier nested_type ptr_to_mem
265 %type <ttype> complete_type_name notype_identifier nonnested_type
266 %type <ttype> complex_type_name nested_name_specifier_1
267 %type <ttype> new_initializer new_placement
268 %type <ttype> using_decl
269 %type <ttype> typename_sub typename_sub0 typename_sub1 typename_sub2
270 %type <ttype> explicit_template_type
271 /* in order to recognize aggr tags as defining and thus shadowing. */
272 %token TYPENAME_DEFN IDENTIFIER_DEFN PTYPENAME_DEFN
273 %type <ttype> named_class_head_sans_basetype_defn
274 %type <ttype> identifier_defn IDENTIFIER_DEFN TYPENAME_DEFN PTYPENAME_DEFN
276 %type <ttype> self_template_type .finish_template_type
281 /* Used in lex.c for parsing pragmas. */
284 /* lex.c and pt.c depend on this being the last token. Define
285 any new tokens before this one! */
286 %token END_OF_SAVED_INPUT
289 /* List of types and structure classes of the current declaration. */
290 static tree current_declspecs;
292 /* List of prefix attributes in effect.
293 Prefix attributes are parsed by the reserved_declspecs and declmods
294 rules. They create a list that contains *both* declspecs and attrs. */
295 /* ??? It is not clear yet that all cases where an attribute can now appear in
296 a declspec list have been updated. */
297 static tree prefix_attributes;
299 /* When defining an aggregate, this is the kind of the most recent one
300 being defined. (For example, this might be class_type_node.) */
301 static tree current_aggr;
303 /* When defining an enumeration, this is the type of the enumeration. */
304 static tree current_enum_type;
306 /* Tell yyparse how to print a token's value, if yydebug is set. */
308 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
309 extern void yyprint PROTO((FILE *, int, YYSTYPE));
310 extern tree combine_strings PROTO((tree));
313 parse_decl(declarator, specs_attrs, attributes, initialized, decl)
322 split_specs_attrs (specs_attrs, ¤t_declspecs, &prefix_attributes);
323 if (current_declspecs
324 && TREE_CODE (current_declspecs) != TREE_LIST)
325 current_declspecs = build_decl_list (NULL_TREE, current_declspecs);
326 if (have_extern_spec && !used_extern_spec)
328 current_declspecs = decl_tree_cons (NULL_TREE,
329 get_identifier ("extern"),
331 used_extern_spec = 1;
333 sm = suspend_momentary ();
334 *decl = start_decl (declarator, current_declspecs, initialized,
335 attributes, prefix_attributes);
344 { finish_translation_unit (); }
347 /* the reason for the strange actions in this rule
348 is so that notype_initdecls when reached via datadef
349 can find a valid list of type and sc specs in $0. */
352 { $<ttype>$ = NULL_TREE; }
354 { $<ttype>$ = NULL_TREE; }
355 | extdefs lang_extdef
356 { $<ttype>$ = NULL_TREE; }
365 { have_extern_spec = 1;
366 used_extern_spec = 0;
367 $<ttype>$ = NULL_TREE; }
370 { have_extern_spec = 0; }
384 { if (pending_lang_change) do_pending_lang_change(); }
386 { if (! toplevel_bindings_p ())
391 fndef eat_saved_input
392 { if (pending_inlines) do_pending_inlines (); }
394 { if (pending_inlines) do_pending_inlines (); }
396 { if (pending_inlines) do_pending_inlines (); }
397 | asm_keyword '(' string ')' ';'
398 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
400 | extern_lang_string '{' extdefs_opt '}'
401 { pop_lang_context (); }
402 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
403 { if (pending_inlines) do_pending_inlines ();
404 pop_lang_context (); }
405 | extern_lang_string .hush_warning datadef .warning_ok
406 { if (pending_inlines) do_pending_inlines ();
407 pop_lang_context (); }
408 | NAMESPACE identifier '{'
409 { push_namespace ($2); }
411 { pop_namespace (); }
413 { push_namespace (NULL_TREE); }
415 { pop_namespace (); }
418 { do_toplevel_using_decl ($1); }
425 NAMESPACE identifier '='
426 { begin_only_namespace_names (); }
429 end_only_namespace_names ();
432 do_namespace_alias ($2, $5);
439 | USING global_scope qualified_id
441 | USING global_scope unqualified_id
445 namespace_using_decl:
446 USING namespace_qualifier identifier
447 { $$ = build_parse_node (SCOPE_REF, $2, $3); }
448 | USING global_scope identifier
449 { $$ = build_parse_node (SCOPE_REF, global_namespace, $3); }
450 | USING global_scope namespace_qualifier identifier
451 { $$ = build_parse_node (SCOPE_REF, $3, $4); }
456 { begin_only_namespace_names (); }
459 end_only_namespace_names ();
460 /* If no declaration was found, the using-directive is
461 invalid. Since that was not reported, we need the
462 identifier for the error message. */
463 if (TREE_CODE ($4) == IDENTIFIER_NODE && lastiddecl)
465 do_using_directive ($4);
472 if (TREE_CODE ($$) == IDENTIFIER_NODE)
476 | namespace_qualifier NSNAME SCOPE
479 if (TREE_CODE ($$) == IDENTIFIER_NODE)
487 | global_scope qualified_id
489 | global_scope unqualified_id
495 { push_lang_context ($1); }
496 | extern_lang_string EXTERN_LANG_STRING
497 { if (current_lang_name != $2)
498 cp_error ("use of linkage spec `%D' is different from previous spec `%D'", $2, current_lang_name);
499 pop_lang_context (); push_lang_context ($2); }
504 { begin_template_parm_list (); }
505 template_parm_list '>'
506 { $$ = end_template_parm_list ($4); }
508 { begin_specialization();
514 { $$ = process_template_parm (NULL_TREE, $1); }
515 | template_parm_list ',' template_parm
516 { $$ = process_template_parm ($1, $3); }
526 aggr maybe_identifier
527 { $$ = finish_template_type_parm ($1, $2); }
528 | TYPENAME_KEYWORD maybe_identifier
529 { $$ = finish_template_type_parm (class_type_node, $2); }
532 template_template_parm:
533 template_header aggr maybe_identifier
534 { $$ = finish_template_template_parm ($2, $3); }
538 /* The following rules introduce a new reduce/reduce
539 conflict on the ',' and '>' input tokens: they are valid
540 prefixes for a `structsp', which means they could match a
541 nameless parameter. See 14.6, paragraph 3.
542 By putting them before the `parm' rule, we get
543 their match before considering them nameless parameter
546 { $$ = build_tree_list (NULL_TREE, $1); }
547 | template_type_parm '=' type_id
548 { $$ = build_tree_list (groktypename ($3.t), $1); }
550 { $$ = build_tree_list (NULL_TREE, $1.t); }
551 | parm '=' expr_no_commas %prec ARITHCOMPARE
552 { $$ = build_tree_list ($3, $1.t); }
553 | template_template_parm
554 { $$ = build_tree_list (NULL_TREE, $1); }
555 | template_template_parm '=' template_arg
557 if (TREE_CODE ($3) != TEMPLATE_DECL
558 && TREE_CODE ($3) != TEMPLATE_TEMPLATE_PARM
559 && TREE_CODE ($3) != TYPE_DECL)
561 error ("invalid default template argument");
562 $3 = error_mark_node;
564 $$ = build_tree_list ($3, $1);
569 template_header template_extdef
570 { finish_template_decl ($1); }
571 | template_header error %prec EMPTY
572 { finish_template_decl ($1); }
576 fndef eat_saved_input
577 { if (pending_inlines) do_pending_inlines (); }
579 { if (pending_inlines) do_pending_inlines (); }
581 { if (pending_inlines) do_pending_inlines (); }
582 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
583 { if (pending_inlines) do_pending_inlines ();
584 pop_lang_context (); }
585 | extern_lang_string .hush_warning template_datadef .warning_ok
586 { if (pending_inlines) do_pending_inlines ();
587 pop_lang_context (); }
588 | extension template_extdef
594 | declmods notype_initdecls ';'
596 | typed_declspecs initdecls ';'
597 { note_list_got_semicolon ($1.t); }
599 { maybe_process_partial_specialization ($1.t);
600 note_got_semicolon ($1.t); }
605 | declmods notype_initdecls ';'
607 | typed_declspecs initdecls ';'
608 { note_list_got_semicolon ($1.t); }
610 { pedwarn ("empty declaration"); }
611 | explicit_instantiation ';'
612 | typed_declspecs ';'
615 split_specs_attrs ($1.t, &t, &attrs);
617 note_list_got_semicolon ($1.t);
624 ctor_initializer_opt:
643 fn.def1 maybe_return_init ctor_initializer_opt compstmt_or_error
644 { finish_function (lineno, (int)$3, 0); }
645 | fn.def1 maybe_return_init function_try_block
647 int nested = (hack_decl_function_context
648 (current_function_decl) != NULL_TREE);
649 finish_function (lineno, (int)$3, nested);
651 | fn.def1 maybe_return_init error
655 constructor_declarator:
656 nested_name_specifier SELFNAME '('
657 { $$ = begin_constructor_declarator ($1, $2); }
658 parmlist ')' cv_qualifiers exception_specification_opt
659 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
660 | nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
661 { $$ = begin_constructor_declarator ($1, $2);
662 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
664 | global_scope nested_name_specifier SELFNAME '('
665 { $$ = begin_constructor_declarator ($2, $3); }
666 parmlist ')' cv_qualifiers exception_specification_opt
667 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
668 | global_scope nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
669 { $$ = begin_constructor_declarator ($2, $3);
670 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
672 | nested_name_specifier self_template_type '('
673 { $$ = begin_constructor_declarator ($1, $2); }
674 parmlist ')' cv_qualifiers exception_specification_opt
675 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
676 | nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
677 { $$ = begin_constructor_declarator ($1, $2);
678 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
680 | global_scope nested_name_specifier self_template_type '('
681 { $$ = begin_constructor_declarator ($2, $3); }
682 parmlist ')' cv_qualifiers exception_specification_opt
683 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
684 | global_scope nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
685 { $$ = begin_constructor_declarator ($2, $3);
686 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
691 typed_declspecs declarator
692 { if (!begin_function_definition ($1.t, $2))
694 | declmods notype_declarator
695 { if (!begin_function_definition ($1, $2))
698 { if (!begin_function_definition (NULL_TREE, $1))
700 | declmods constructor_declarator
701 { if (!begin_function_definition ($1, $2))
703 | constructor_declarator
704 { if (!begin_function_definition (NULL_TREE, $1))
708 component_constructor_declarator:
709 SELFNAME '(' parmlist ')' cv_qualifiers exception_specification_opt
710 { $$ = make_call_declarator ($1, $3, $5, $6); }
711 | SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
712 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
713 | self_template_type '(' parmlist ')' cv_qualifiers exception_specification_opt
714 { $$ = make_call_declarator ($1, $3, $5, $6); }
715 | self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
716 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
719 /* more C++ complexity. See component_decl for a comment on the
720 reduce/reduce conflict introduced by these rules. */
722 declmods component_constructor_declarator
724 split_specs_attrs ($1, &specs, &attrs);
725 attrs = build_tree_list (attrs, NULL_TREE);
726 $$ = start_method (specs, $2, attrs);
730 if (yychar == YYEMPTY)
732 reinit_parse_for_method (yychar, $$); }
733 | component_constructor_declarator
734 { $$ = start_method (NULL_TREE, $1, NULL_TREE);
736 | typed_declspecs declarator
738 split_specs_attrs ($1.t, &specs, &attrs);
739 attrs = build_tree_list (attrs, NULL_TREE);
740 $$ = start_method (specs, $2, attrs); goto rest_of_mdef; }
741 | declmods notype_declarator
743 split_specs_attrs ($1, &specs, &attrs);
744 attrs = build_tree_list (attrs, NULL_TREE);
745 $$ = start_method (specs, $2, attrs); goto rest_of_mdef; }
747 { $$ = start_method (NULL_TREE, $$, NULL_TREE);
749 | declmods constructor_declarator
751 split_specs_attrs ($1, &specs, &attrs);
752 attrs = build_tree_list (attrs, NULL_TREE);
753 $$ = start_method (specs, $2, attrs); goto rest_of_mdef; }
754 | constructor_declarator
755 { $$ = start_method (NULL_TREE, $$, NULL_TREE);
760 RETURN_KEYWORD IDENTIFIER
762 if (! current_function_parms_stored)
770 { finish_named_return_value ($<ttype>$, $2); }
771 | return_id '(' nonnull_exprlist ')'
772 { finish_named_return_value ($<ttype>$, $3); }
773 | return_id LEFT_RIGHT
774 { finish_named_return_value ($<ttype>$, NULL_TREE); }
778 ':' .set_base_init member_init_list
781 error ("no base initializers given following ':'");
789 if (! current_function_parms_stored)
792 if (DECL_CONSTRUCTOR_P (current_function_decl))
794 /* Make a contour for the initializer list. */
797 expand_start_bindings (0);
799 else if (current_class_type == NULL_TREE)
800 error ("base initializers not allowed for non-member functions");
801 else if (! DECL_CONSTRUCTOR_P (current_function_decl))
802 error ("only constructors take base initializers");
811 | member_init_list ',' member_init
812 | member_init_list error
816 '(' nonnull_exprlist ')'
818 if (current_class_name)
819 pedwarn ("anachronistic old style base class initializer");
820 expand_member_init (current_class_ref, NULL_TREE, $2);
824 if (current_class_name)
825 pedwarn ("anachronistic old style base class initializer");
826 expand_member_init (current_class_ref, NULL_TREE, void_type_node);
828 | notype_identifier '(' nonnull_exprlist ')'
829 { expand_member_init (current_class_ref, $1, $3); }
830 | notype_identifier LEFT_RIGHT
831 { expand_member_init (current_class_ref, $1, void_type_node); }
832 | nonnested_type '(' nonnull_exprlist ')'
833 { expand_member_init (current_class_ref, $1, $3); }
834 | nonnested_type LEFT_RIGHT
835 { expand_member_init (current_class_ref, $1, void_type_node); }
836 | typename_sub '(' nonnull_exprlist ')'
837 { expand_member_init (current_class_ref, TYPE_MAIN_DECL ($1),
839 | typename_sub LEFT_RIGHT
840 { expand_member_init (current_class_ref, TYPE_MAIN_DECL ($1),
864 explicit_instantiation:
865 TEMPLATE begin_explicit_instantiation typespec ';'
866 { do_type_instantiation ($3.t, NULL_TREE);
868 end_explicit_instantiation
869 | TEMPLATE begin_explicit_instantiation typed_declspecs declarator
870 { tree specs = strip_attrs ($3.t);
871 do_decl_instantiation (specs, $4, NULL_TREE); }
872 end_explicit_instantiation
873 | TEMPLATE begin_explicit_instantiation notype_declarator
874 { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
875 end_explicit_instantiation
876 | TEMPLATE begin_explicit_instantiation constructor_declarator
877 { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
878 end_explicit_instantiation
879 | SCSPEC TEMPLATE begin_explicit_instantiation typespec ';'
880 { do_type_instantiation ($4.t, $1);
882 end_explicit_instantiation
883 | SCSPEC TEMPLATE begin_explicit_instantiation typed_declspecs
885 { tree specs = strip_attrs ($4.t);
886 do_decl_instantiation (specs, $5, $1); }
887 end_explicit_instantiation
888 | SCSPEC TEMPLATE begin_explicit_instantiation notype_declarator
889 { do_decl_instantiation (NULL_TREE, $4, $1); }
890 end_explicit_instantiation
891 | SCSPEC TEMPLATE begin_explicit_instantiation constructor_declarator
892 { do_decl_instantiation (NULL_TREE, $4, $1); }
893 end_explicit_instantiation
896 begin_explicit_instantiation:
897 { begin_explicit_instantiation(); }
899 end_explicit_instantiation:
900 { end_explicit_instantiation(); }
902 /* The TYPENAME expansions are to deal with use of a template class name as
903 a template within the class itself, where the template decl is hidden by
904 a type decl. Got all that? */
907 PTYPENAME '<' template_arg_list_opt template_close_bracket
908 .finish_template_type
910 | TYPENAME '<' template_arg_list_opt template_close_bracket
911 .finish_template_type
916 apparent_template_type:
918 | identifier '<' template_arg_list_opt '>'
919 .finish_template_type
923 SELFNAME '<' template_arg_list_opt template_close_bracket
924 .finish_template_type
928 .finish_template_type:
930 if (yychar == YYEMPTY)
933 $$ = finish_template_type ($<ttype>-3, $<ttype>-1,
937 template_close_bracket:
941 /* Handle `Class<Class<Type>>' without space in the `>>' */
942 pedwarn ("`>>' should be `> >' in template class name");
947 template_arg_list_opt:
955 { $$ = build_tree_list (NULL_TREE, $$); }
956 | template_arg_list ',' template_arg
957 { $$ = chainon ($$, build_tree_list (NULL_TREE, $3)); }
962 { $$ = groktypename ($1.t); }
965 | expr_no_commas %prec ARITHCOMPARE
970 { $$ = NEGATE_EXPR; }
972 { $$ = CONVERT_EXPR; }
974 { $$ = PREINCREMENT_EXPR; }
976 { $$ = PREDECREMENT_EXPR; }
978 { $$ = TRUTH_NOT_EXPR; }
983 { $$ = build_x_compound_expr ($$); }
989 { error ("ANSI C++ forbids an empty condition for `%s'",
991 $$ = integer_zero_node; }
998 { error ("ANSI C++ forbids an empty condition for `%s'",
1000 $$ = integer_zero_node; }
1014 type_specifier_seq declarator maybeasm maybe_attribute '='
1017 for (d = getdecls (); d; d = TREE_CHAIN (d))
1018 if (TREE_CODE (d) == TYPE_DECL) {
1019 tree s = TREE_TYPE (d);
1020 if (TREE_CODE (s) == RECORD_TYPE)
1021 cp_error ("definition of class `%T' in condition", s);
1022 else if (TREE_CODE (s) == ENUMERAL_TYPE)
1023 cp_error ("definition of enum `%T' in condition", s);
1026 current_declspecs = $1.t;
1027 $<itype>5 = suspend_momentary ();
1028 $<ttype>$ = start_decl ($<ttype>2, current_declspecs, 1,
1029 $4, /*prefix_attributes*/ NULL_TREE);
1033 cp_finish_decl ($<ttype>6, $7, $4, 1, LOOKUP_ONLYCONVERTING);
1034 resume_momentary ($<itype>5);
1035 $$ = convert_from_reference ($<ttype>6);
1036 if (TREE_CODE (TREE_TYPE ($$)) == ARRAY_TYPE)
1037 cp_error ("definition of array `%#D' in condition", $$);
1044 | maybe_label_decls stmts '}'
1045 | maybe_label_decls stmts error '}'
1046 | maybe_label_decls error '}'
1049 already_scoped_stmt:
1051 { $<ttype>$ = begin_compound_stmt (1); }
1053 { finish_compound_stmt (1, $<ttype>2); }
1058 nontrivial_exprlist:
1059 expr_no_commas ',' expr_no_commas
1060 { $$ = expr_tree_cons (NULL_TREE, $$,
1061 build_expr_list (NULL_TREE, $3)); }
1062 | expr_no_commas ',' error
1063 { $$ = expr_tree_cons (NULL_TREE, $$,
1064 build_expr_list (NULL_TREE, error_mark_node)); }
1065 | nontrivial_exprlist ',' expr_no_commas
1066 { chainon ($$, build_expr_list (NULL_TREE, $3)); }
1067 | nontrivial_exprlist ',' error
1068 { chainon ($$, build_expr_list (NULL_TREE, error_mark_node)); }
1073 { $$ = build_expr_list (NULL_TREE, $$); }
1074 | nontrivial_exprlist
1080 /* __extension__ turns off -pedantic for following primary. */
1081 | extension cast_expr %prec UNARY
1084 | '*' cast_expr %prec UNARY
1085 { $$ = build_x_indirect_ref ($2, "unary *"); }
1086 | '&' cast_expr %prec UNARY
1087 { $$ = build_x_unary_op (ADDR_EXPR, $2); }
1089 { $$ = build_x_unary_op (BIT_NOT_EXPR, $2); }
1090 | unop cast_expr %prec UNARY
1091 { $$ = finish_unary_op_expr ($1, $2); }
1092 /* Refer to the address of a label as a pointer. */
1095 pedwarn ("ANSI C++ forbids `&&'");
1096 $$ = finish_label_address_expr ($2); }
1097 | SIZEOF unary_expr %prec UNARY
1098 { $$ = expr_sizeof ($2); }
1099 | SIZEOF '(' type_id ')' %prec HYPERUNARY
1100 { $$ = c_sizeof (groktypename ($3.t));
1101 check_for_new_type ("sizeof", $3); }
1102 | ALIGNOF unary_expr %prec UNARY
1103 { $$ = grok_alignof ($2); }
1104 | ALIGNOF '(' type_id ')' %prec HYPERUNARY
1105 { $$ = c_alignof (groktypename ($3.t));
1106 check_for_new_type ("alignof", $3); }
1108 /* The %prec EMPTY's here are required by the = init initializer
1109 syntax extension; see below. */
1110 | new new_type_id %prec EMPTY
1111 { $$ = build_new (NULL_TREE, $2.t, NULL_TREE, $1);
1112 check_for_new_type ("new", $2); }
1113 | new new_type_id new_initializer
1114 { $$ = build_new (NULL_TREE, $2.t, $3, $1);
1115 check_for_new_type ("new", $2); }
1116 | new new_placement new_type_id %prec EMPTY
1117 { $$ = build_new ($2, $3.t, NULL_TREE, $1);
1118 check_for_new_type ("new", $3); }
1119 | new new_placement new_type_id new_initializer
1120 { $$ = build_new ($2, $3.t, $4, $1);
1121 check_for_new_type ("new", $3); }
1122 /* The .begin_new_placement in the following rules is
1123 necessary to avoid shift/reduce conflicts that lead to
1124 mis-parsing some expressions. Of course, these constructs
1125 are not really new-placement and it is bogus to call
1126 begin_new_placement. But, the parser cannot always tell at this
1127 point whether the next thing is an expression or a type-id,
1128 so there is nothing we can do. Fortunately,
1129 begin_new_placement does nothing harmful. When we rewrite
1130 the parser, this lossage should be removed, of course. */
1131 | new '(' .begin_new_placement type_id .finish_new_placement
1133 { $$ = build_new (NULL_TREE, groktypename($4.t),
1135 check_for_new_type ("new", $4); }
1136 | new '(' .begin_new_placement type_id .finish_new_placement
1138 { $$ = build_new (NULL_TREE, groktypename($4.t), $6, $1);
1139 check_for_new_type ("new", $4); }
1140 | new new_placement '(' .begin_new_placement type_id
1141 .finish_new_placement %prec EMPTY
1142 { $$ = build_new ($2, groktypename($5.t), NULL_TREE, $1);
1143 check_for_new_type ("new", $5); }
1144 | new new_placement '(' .begin_new_placement type_id
1145 .finish_new_placement new_initializer
1146 { $$ = build_new ($2, groktypename($5.t), $7, $1);
1147 check_for_new_type ("new", $5); }
1149 | delete cast_expr %prec UNARY
1150 { $$ = delete_sanity ($2, NULL_TREE, 0, $1); }
1151 | delete '[' ']' cast_expr %prec UNARY
1152 { $$ = delete_sanity ($4, NULL_TREE, 1, $1);
1153 if (yychar == YYEMPTY)
1155 | delete '[' expr ']' cast_expr %prec UNARY
1156 { $$ = delete_sanity ($5, $3, 2, $1);
1157 if (yychar == YYEMPTY)
1159 | REALPART cast_expr %prec UNARY
1160 { $$ = build_x_unary_op (REALPART_EXPR, $2); }
1161 | IMAGPART cast_expr %prec UNARY
1162 { $$ = build_x_unary_op (IMAGPART_EXPR, $2); }
1163 | VA_ARG '(' expr_no_commas ',' type_id ')'
1164 { $$ = build_va_arg ($3, groktypename ($5.t));
1165 check_for_new_type ("__builtin_va_arg", $5); }
1168 /* Note this rule is not suitable for use in new_placement
1169 since it uses NULL_TREE as the argument to
1170 finish_new_placement. This rule serves only to avoid
1171 reduce/reduce conflicts in unary_expr. See the comments
1172 there on the use of begin/finish_new_placement. */
1173 .finish_new_placement:
1175 { finish_new_placement (NULL_TREE, $<itype>-1); }
1177 .begin_new_placement:
1178 { $$ = begin_new_placement (); }
1181 '(' .begin_new_placement nonnull_exprlist ')'
1182 { $$ = finish_new_placement ($3, $2); }
1183 | '{' .begin_new_placement nonnull_exprlist '}'
1184 { cp_pedwarn ("old style placement syntax, use () instead");
1185 $$ = finish_new_placement ($3, $2); }
1189 '(' nonnull_exprlist ')'
1195 cp_error ("`%T' is not a valid expression", $2.t);
1196 $$ = error_mark_node;
1198 /* GNU extension so people can use initializer lists. Note that
1199 this alters the meaning of `new int = 1', which was previously
1200 syntactically valid but semantically invalid. */
1204 pedwarn ("ANSI C++ forbids initialization of new expression with `='");
1205 if (TREE_CODE ($2) != TREE_LIST
1206 && TREE_CODE ($2) != CONSTRUCTOR)
1207 $$ = build_expr_list (NULL_TREE, $2);
1213 /* This is necessary to postpone reduction of `int ((int)(int)(int))'. */
1215 '(' type_id ')' %prec EMPTY
1216 { $2.t = finish_parmlist (build_tree_list (NULL_TREE, $2.t), 0);
1217 $$ = make_call_declarator (NULL_TREE, $2.t, NULL_TREE, NULL_TREE);
1218 check_for_new_type ("cast", $2); }
1219 | regcast_or_absdcl '(' type_id ')' %prec EMPTY
1220 { $3.t = finish_parmlist (build_tree_list (NULL_TREE, $3.t), 0);
1221 $$ = make_call_declarator ($$, $3.t, NULL_TREE, NULL_TREE);
1222 check_for_new_type ("cast", $3); }
1227 | regcast_or_absdcl unary_expr %prec UNARY
1228 { $$ = reparse_absdcl_as_casts ($$, $2); }
1229 | regcast_or_absdcl '{' initlist maybecomma '}' %prec UNARY
1231 tree init = build_nt (CONSTRUCTOR, NULL_TREE,
1234 pedwarn ("ANSI C++ forbids constructor-expressions");
1235 /* Indicate that this was a GNU C constructor expression. */
1236 TREE_HAS_CONSTRUCTOR (init) = 1;
1238 $$ = reparse_absdcl_as_casts ($$, init);
1244 /* Handle general members. */
1245 | expr_no_commas POINTSAT_STAR expr_no_commas
1246 { $$ = build_x_binary_op (MEMBER_REF, $$, $3); }
1247 | expr_no_commas DOT_STAR expr_no_commas
1248 { $$ = build_m_component_ref ($$, $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 '%' expr_no_commas
1258 { $$ = build_x_binary_op ($2, $$, $3); }
1259 | expr_no_commas LSHIFT expr_no_commas
1260 { $$ = build_x_binary_op ($2, $$, $3); }
1261 | expr_no_commas RSHIFT expr_no_commas
1262 { $$ = build_x_binary_op ($2, $$, $3); }
1263 | expr_no_commas ARITHCOMPARE expr_no_commas
1264 { $$ = build_x_binary_op ($2, $$, $3); }
1265 | expr_no_commas '<' expr_no_commas
1266 { $$ = build_x_binary_op (LT_EXPR, $$, $3); }
1267 | expr_no_commas '>' expr_no_commas
1268 { $$ = build_x_binary_op (GT_EXPR, $$, $3); }
1269 | expr_no_commas EQCOMPARE expr_no_commas
1270 { $$ = build_x_binary_op ($2, $$, $3); }
1271 | expr_no_commas MIN_MAX 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 '^' expr_no_commas
1278 { $$ = build_x_binary_op ($2, $$, $3); }
1279 | expr_no_commas ANDAND expr_no_commas
1280 { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $$, $3); }
1281 | expr_no_commas OROR expr_no_commas
1282 { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $$, $3); }
1283 | expr_no_commas '?' xexpr ':' expr_no_commas
1284 { $$ = build_x_conditional_expr ($$, $3, $5); }
1285 | expr_no_commas '=' expr_no_commas
1286 { $$ = build_x_modify_expr ($$, NOP_EXPR, $3);
1287 if ($$ != error_mark_node)
1288 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
1289 | expr_no_commas ASSIGN expr_no_commas
1290 { $$ = build_x_modify_expr ($$, $2, $3); }
1292 { $$ = build_throw (NULL_TREE); }
1293 | THROW expr_no_commas
1294 { $$ = build_throw ($2); }
1295 /* These extensions are not defined. The second arg to build_m_component_ref
1296 is old, build_m_component_ref now does an implicit
1297 build_indirect_ref (x, NULL_PTR) on the second argument.
1298 | object '&' expr_no_commas %prec UNARY
1299 { $$ = build_m_component_ref ($$, build_x_unary_op (ADDR_EXPR, $3)); }
1300 | object unop expr_no_commas %prec UNARY
1301 { $$ = build_m_component_ref ($$, build_x_unary_op ($2, $3)); }
1302 | object '(' type_id ')' expr_no_commas %prec UNARY
1303 { tree type = groktypename ($3.t);
1304 $$ = build_m_component_ref ($$, build_c_cast (type, $5)); }
1305 | object primary_no_id %prec UNARY
1306 { $$ = build_m_component_ref ($$, $2); }
1310 notype_unqualified_id:
1311 '~' see_typename identifier
1312 { $$ = build_parse_node (BIT_NOT_EXPR, $3); }
1313 | '~' see_typename template_type
1314 { $$ = build_parse_node (BIT_NOT_EXPR, $3); }
1319 | NSNAME %prec EMPTY
1324 /* If lastiddecl is a TREE_LIST, it's a baselink, which
1325 means that we're in an expression like S::f<int>, so
1326 don't do_identifier; we only do that for unqualified
1328 if (lastiddecl && TREE_CODE (lastiddecl) != TREE_LIST)
1329 $$ = do_identifier ($<ttype>-1, 1, NULL_TREE);
1335 PFUNCNAME '<' do_id template_arg_list_opt template_close_bracket
1336 { $$ = lookup_template_function ($3, $4); }
1337 | operator_name '<' do_id template_arg_list_opt template_close_bracket
1338 { $$ = lookup_template_function ($3, $4); }
1342 TEMPLATE identifier '<' template_arg_list_opt template_close_bracket
1343 { $$ = lookup_template_function ($2, $4); }
1344 | TEMPLATE PFUNCNAME '<' template_arg_list_opt template_close_bracket
1345 { $$ = lookup_template_function ($2, $4); }
1346 | TEMPLATE operator_name '<' template_arg_list_opt
1347 template_close_bracket
1348 { $$ = lookup_template_function ($2, $4); }
1352 notype_unqualified_id
1357 expr_or_declarator_intern:
1359 | attributes expr_or_declarator
1361 /* Provide support for '(' attributes '*' declarator ')'
1363 $$ = decl_tree_cons ($1, $2, NULL_TREE);
1368 notype_unqualified_id
1369 | '*' expr_or_declarator_intern %prec UNARY
1370 { $$ = build_parse_node (INDIRECT_REF, $2); }
1371 | '&' expr_or_declarator_intern %prec UNARY
1372 { $$ = build_parse_node (ADDR_EXPR, $2); }
1373 | '(' expr_or_declarator_intern ')'
1377 notype_template_declarator:
1378 IDENTIFIER '<' template_arg_list_opt template_close_bracket
1379 { $$ = lookup_template_function ($1, $3); }
1380 | NSNAME '<' template_arg_list template_close_bracket
1381 { $$ = lookup_template_function ($1, $3); }
1384 direct_notype_declarator:
1385 complex_direct_notype_declarator
1386 /* This precedence declaration is to prefer this reduce
1387 to the Koenig lookup shift in primary, below. I hate yacc. */
1388 | notype_unqualified_id %prec '('
1389 | notype_template_declarator
1390 | '(' expr_or_declarator_intern ')'
1391 { $$ = finish_decl_parsing ($2); }
1395 notype_unqualified_id
1397 if (TREE_CODE ($1) == BIT_NOT_EXPR)
1398 $$ = build_x_unary_op (BIT_NOT_EXPR, TREE_OPERAND ($1, 0));
1400 $$ = finish_id_expr ($1);
1406 if (processing_template_decl)
1407 push_obstacks (&permanent_obstack, &permanent_obstack);
1408 $$ = combine_strings ($$);
1409 /* combine_strings doesn't set up TYPE_MAIN_VARIANT of
1410 a const array the way we want, so fix it. */
1411 if (flag_const_strings)
1412 TREE_TYPE ($$) = build_cplus_array_type
1413 (TREE_TYPE (TREE_TYPE ($$)),
1414 TYPE_DOMAIN (TREE_TYPE ($$)));
1415 if (processing_template_decl)
1419 { $$ = finish_parenthesized_expr ($2); }
1420 | '(' expr_or_declarator_intern ')'
1421 { $2 = reparse_decl_as_expr (NULL_TREE, $2);
1422 $$ = finish_parenthesized_expr ($2); }
1424 { $$ = error_mark_node; }
1426 { tree scope = current_scope ();
1427 if (!scope || TREE_CODE (scope) != FUNCTION_DECL)
1429 error ("braced-group within expression allowed only inside a function");
1433 pedwarn ("ANSI C++ forbids braced-groups within expressions");
1434 $<ttype>$ = begin_stmt_expr ();
1437 { $$ = finish_stmt_expr ($<ttype>2, $3); }
1438 /* Koenig lookup support
1439 We could store lastiddecl in $1 to avoid another lookup,
1440 but that would result in many additional reduce/reduce conflicts. */
1441 | notype_unqualified_id '(' nonnull_exprlist ')'
1442 { $$ = finish_call_expr ($1, $3, 1); }
1443 | notype_unqualified_id LEFT_RIGHT
1444 { $$ = finish_call_expr ($1, NULL_TREE, 1); }
1445 | primary '(' nonnull_exprlist ')'
1446 { $$ = finish_call_expr ($1, $3, 0); }
1447 | primary LEFT_RIGHT
1448 { $$ = finish_call_expr ($1, NULL_TREE, 0); }
1449 | primary '[' expr ']'
1450 { $$ = grok_array_decl ($$, $3); }
1452 { $$ = finish_increment_expr ($1, POSTINCREMENT_EXPR); }
1453 | primary MINUSMINUS
1454 { $$ = finish_increment_expr ($1, POSTDECREMENT_EXPR); }
1455 /* C++ extensions */
1457 { $$ = finish_this_expr (); }
1458 | CV_QUALIFIER '(' nonnull_exprlist ')'
1460 /* This is a C cast in C++'s `functional' notation
1461 using the "implicit int" extension so that:
1462 `const (3)' is equivalent to `const int (3)'. */
1465 if ($3 == error_mark_node)
1467 $$ = error_mark_node;
1471 type = cp_build_qualified_type (integer_type_node,
1472 cp_type_qual_from_rid ($1));
1473 $$ = build_c_cast (type, build_compound_expr ($3));
1476 | DYNAMIC_CAST '<' type_id '>' '(' expr ')'
1477 { tree type = groktypename ($3.t);
1478 check_for_new_type ("dynamic_cast", $3);
1479 $$ = build_dynamic_cast (type, $6); }
1480 | STATIC_CAST '<' type_id '>' '(' expr ')'
1481 { tree type = groktypename ($3.t);
1482 check_for_new_type ("static_cast", $3);
1483 $$ = build_static_cast (type, $6); }
1484 | REINTERPRET_CAST '<' type_id '>' '(' expr ')'
1485 { tree type = groktypename ($3.t);
1486 check_for_new_type ("reinterpret_cast", $3);
1487 $$ = build_reinterpret_cast (type, $6); }
1488 | CONST_CAST '<' type_id '>' '(' expr ')'
1489 { tree type = groktypename ($3.t);
1490 check_for_new_type ("const_cast", $3);
1491 $$ = build_const_cast (type, $6); }
1492 | TYPEID '(' expr ')'
1493 { $$ = build_x_typeid ($3); }
1494 | TYPEID '(' type_id ')'
1495 { tree type = groktypename ($3.t);
1496 check_for_new_type ("typeid", $3);
1497 $$ = get_typeid (TYPE_MAIN_VARIANT (type)); }
1498 | global_scope IDENTIFIER
1499 { $$ = do_scoped_id ($2, 1); }
1500 | global_scope template_id
1502 | global_scope operator_name
1504 got_scope = NULL_TREE;
1505 if (TREE_CODE ($2) == IDENTIFIER_NODE)
1506 $$ = do_scoped_id ($2, 1);
1510 | overqualified_id %prec HYPERUNARY
1511 { $$ = build_offset_ref (OP0 ($$), OP1 ($$)); }
1512 | overqualified_id '(' nonnull_exprlist ')'
1513 { $$ = finish_qualified_call_expr ($1, $3); }
1514 | overqualified_id LEFT_RIGHT
1515 { $$ = finish_qualified_call_expr ($1, NULL_TREE); }
1516 | object object_template_id %prec UNARY
1518 $$ = build_x_component_ref ($$, $2, NULL_TREE, 1);
1520 | object object_template_id '(' nonnull_exprlist ')'
1521 { $$ = finish_object_call_expr ($2, $1, $4); }
1522 | object object_template_id LEFT_RIGHT
1523 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1524 | object unqualified_id %prec UNARY
1525 { $$ = build_x_component_ref ($$, $2, NULL_TREE, 1); }
1526 | object overqualified_id %prec UNARY
1527 { if (processing_template_decl)
1528 $$ = build_min_nt (COMPONENT_REF, $1, copy_to_permanent ($2));
1530 $$ = build_object_ref ($$, OP0 ($2), OP1 ($2)); }
1531 | object unqualified_id '(' nonnull_exprlist ')'
1532 { $$ = finish_object_call_expr ($2, $1, $4); }
1533 | object unqualified_id LEFT_RIGHT
1534 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1535 | object overqualified_id '(' nonnull_exprlist ')'
1536 { $$ = finish_qualified_object_call_expr ($2, $1, $4); }
1537 | object overqualified_id LEFT_RIGHT
1538 { $$ = finish_qualified_object_call_expr ($2, $1, NULL_TREE); }
1539 /* p->int::~int() is valid -- 12.4 */
1540 | object '~' TYPESPEC LEFT_RIGHT
1541 { $$ = finish_pseudo_destructor_call_expr ($1, NULL_TREE, $3); }
1542 | object TYPESPEC SCOPE '~' TYPESPEC LEFT_RIGHT
1543 { $$ = finish_pseudo_destructor_call_expr ($1, $2, $5); }
1546 $$ = error_mark_node;
1550 /* Not needed for now.
1556 { $$ = error_mark_node; }
1558 { if (current_function_decl == 0)
1560 error ("braced-group within expression allowed only inside a function");
1563 $<ttype>$ = expand_start_stmt_expr (); }
1566 pedwarn ("ANSI C++ forbids braced-groups within expressions");
1567 $$ = expand_end_stmt_expr ($<ttype>2); }
1568 | primary_no_id '(' nonnull_exprlist ')'
1569 { $$ = build_x_function_call ($$, $3, current_class_ref); }
1570 | primary_no_id LEFT_RIGHT
1571 { $$ = build_x_function_call ($$, NULL_TREE, current_class_ref); }
1572 | primary_no_id '[' expr ']'
1574 | primary_no_id PLUSPLUS
1575 { $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); }
1576 | primary_no_id MINUSMINUS
1577 { $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); }
1579 { goto do_scoped_id; }
1580 | SCOPE operator_name
1581 { if (TREE_CODE ($2) == IDENTIFIER_NODE)
1583 goto do_scoped_operator;
1592 { got_scope = NULL_TREE; $$ = 1; }
1598 | global_scope delete
1599 { got_scope = NULL_TREE; $$ = 1; }
1604 { $$ = boolean_true_node; }
1606 { $$ = boolean_false_node; }
1609 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
1613 { $$ = chainon ($$, $2); }
1619 if (! current_function_parms_stored)
1620 store_parm_decls ();
1627 { got_object = TREE_TYPE ($$); }
1630 $$ = build_x_arrow ($$);
1631 got_object = TREE_TYPE ($$);
1636 typespec initdecls ';'
1638 resume_momentary ($2);
1639 if ($1.t && IS_AGGR_TYPE_CODE (TREE_CODE ($1.t)))
1640 note_got_semicolon ($1.t);
1642 | typed_declspecs initdecls ';'
1644 resume_momentary ($2);
1645 note_list_got_semicolon ($1.t);
1647 | declmods notype_initdecls ';'
1648 { resume_momentary ($2); }
1649 | typed_declspecs ';'
1652 note_list_got_semicolon ($1.t);
1655 { warning ("empty declaration"); }
1660 /* Any kind of declarator (thus, all declarators allowed
1661 after an explicit typespec). */
1664 after_type_declarator %prec EMPTY
1665 | notype_declarator %prec EMPTY
1668 /* This is necessary to postpone reduction of `int()()()()'. */
1670 LEFT_RIGHT %prec EMPTY
1671 { $$ = make_call_declarator (NULL_TREE, empty_parms (),
1672 NULL_TREE, NULL_TREE); }
1673 | fcast_or_absdcl LEFT_RIGHT %prec EMPTY
1674 { $$ = make_call_declarator ($$, empty_parms (), NULL_TREE,
1678 /* ANSI type-id (8.1) */
1680 typed_typespecs absdcl
1681 { $$.t = build_decl_list ($1.t, $2);
1682 $$.new_type_flag = $1.new_type_flag; }
1683 | nonempty_cv_qualifiers absdcl
1684 { $$.t = build_decl_list ($1.t, $2);
1685 $$.new_type_flag = $1.new_type_flag; }
1687 { $$.t = build_decl_list (build_decl_list (NULL_TREE, $1.t),
1689 $$.new_type_flag = $1.new_type_flag; }
1690 | typed_typespecs %prec EMPTY
1691 { $$.t = build_decl_list ($1.t, NULL_TREE);
1692 $$.new_type_flag = $1.new_type_flag; }
1693 | nonempty_cv_qualifiers %prec EMPTY
1694 { $$.t = build_decl_list ($1.t, NULL_TREE);
1695 $$.new_type_flag = $1.new_type_flag; }
1698 /* Declspecs which contain at least one type specifier or typedef name.
1699 (Just `const' or `volatile' is not enough.)
1700 A typedef'd name following these is taken as a name to be declared.
1701 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1704 typed_typespecs %prec EMPTY
1710 { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1);
1711 $$.new_type_flag = $2.new_type_flag; }
1712 | typespec reserved_declspecs %prec HYPERUNARY
1713 { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2);
1714 $$.new_type_flag = $1.new_type_flag; }
1715 | typespec reserved_typespecquals reserved_declspecs
1716 { $$.t = decl_tree_cons (NULL_TREE, $1.t, chainon ($2, $3));
1717 $$.new_type_flag = $1.new_type_flag; }
1718 | declmods typespec reserved_declspecs
1719 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1));
1720 $$.new_type_flag = $2.new_type_flag; }
1721 | declmods typespec reserved_typespecquals
1722 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1));
1723 $$.new_type_flag = $2.new_type_flag; }
1724 | declmods typespec reserved_typespecquals reserved_declspecs
1725 { $$.t = decl_tree_cons (NULL_TREE, $2.t,
1726 chainon ($3, chainon ($4, $1)));
1727 $$.new_type_flag = $2.new_type_flag; }
1732 { if (extra_warnings)
1733 warning ("`%s' is not at beginning of declaration",
1734 IDENTIFIER_POINTER ($$));
1735 $$ = build_decl_list (NULL_TREE, $$); }
1736 | reserved_declspecs typespecqual_reserved
1737 { $$ = decl_tree_cons (NULL_TREE, $2.t, $$); }
1738 | reserved_declspecs SCSPEC
1739 { if (extra_warnings)
1740 warning ("`%s' is not at beginning of declaration",
1741 IDENTIFIER_POINTER ($2));
1742 $$ = decl_tree_cons (NULL_TREE, $2, $$); }
1743 | reserved_declspecs attributes
1744 { $$ = decl_tree_cons ($2, NULL_TREE, $1); }
1746 { $$ = decl_tree_cons ($1, NULL_TREE, NULL_TREE); }
1749 /* List of just storage classes and type modifiers.
1750 A declaration can start with just this, but then it cannot be used
1751 to redeclare a typedef-name.
1752 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1754 /* We use hash_tree_cons for lists of typeless declspecs so that they end
1755 up on a persistent obstack. Otherwise, they could appear at the
1756 beginning of something like
1758 static const struct { int foo () { } } b;
1760 and would be discarded after we finish compiling foo. We don't need to
1761 worry once we see a type. */
1764 nonempty_cv_qualifiers %prec EMPTY
1765 { $$ = $1.t; TREE_STATIC ($$) = 1; }
1767 { $$ = hash_tree_cons (NULL_TREE, $$, NULL_TREE); }
1768 | declmods CV_QUALIFIER
1769 { $$ = hash_tree_cons (NULL_TREE, $2, $$);
1770 TREE_STATIC ($$) = 1; }
1772 { if (extra_warnings && TREE_STATIC ($$))
1773 warning ("`%s' is not at beginning of declaration",
1774 IDENTIFIER_POINTER ($2));
1775 $$ = hash_tree_cons (NULL_TREE, $2, $$);
1776 TREE_STATIC ($$) = TREE_STATIC ($1); }
1777 | declmods attributes
1778 { $$ = hash_tree_cons ($2, NULL_TREE, $1); }
1779 | attributes %prec EMPTY
1780 { $$ = hash_tree_cons ($1, NULL_TREE, NULL_TREE); }
1783 /* Used instead of declspecs where storage classes are not allowed
1784 (that is, for typenames and structure components).
1786 C++ can takes storage classes for structure components.
1787 Don't accept a typedef-name if anything but a modifier precedes it. */
1790 typespec %prec EMPTY
1791 { $$.t = build_decl_list (NULL_TREE, $1.t);
1792 $$.new_type_flag = $1.new_type_flag; }
1793 | nonempty_cv_qualifiers typespec
1794 { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1.t);
1795 $$.new_type_flag = $2.new_type_flag; }
1796 | typespec reserved_typespecquals
1797 { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2);
1798 $$.new_type_flag = $1.new_type_flag; }
1799 | nonempty_cv_qualifiers typespec reserved_typespecquals
1800 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1801 $$.new_type_flag = $1.new_type_flag; }
1804 reserved_typespecquals:
1805 typespecqual_reserved
1806 { $$ = build_decl_list (NULL_TREE, $1.t); }
1807 | reserved_typespecquals typespecqual_reserved
1808 { $$ = decl_tree_cons (NULL_TREE, $2.t, $1); }
1811 /* A typespec (but not a type qualifier).
1812 Once we have seen one of these in a declaration,
1813 if a typedef name appears then it is being redeclared. */
1817 | TYPESPEC %prec EMPTY
1818 { $$.t = $1; $$.new_type_flag = 0; }
1819 | complete_type_name
1820 { $$.t = $1; $$.new_type_flag = 0; }
1821 | TYPEOF '(' expr ')'
1822 { $$.t = finish_typeof ($3);
1823 $$.new_type_flag = 0; }
1824 | TYPEOF '(' type_id ')'
1825 { $$.t = groktypename ($3.t);
1826 $$.new_type_flag = 0; }
1827 | SIGOF '(' expr ')'
1828 { tree type = TREE_TYPE ($3);
1830 $$.new_type_flag = 0;
1831 if (IS_AGGR_TYPE (type))
1833 sorry ("sigof type specifier");
1838 error ("`sigof' applied to non-aggregate expression");
1839 $$.t = error_mark_node;
1842 | SIGOF '(' type_id ')'
1843 { tree type = groktypename ($3.t);
1845 $$.new_type_flag = 0;
1846 if (IS_AGGR_TYPE (type))
1848 sorry ("sigof type specifier");
1853 error("`sigof' applied to non-aggregate type");
1854 $$.t = error_mark_node;
1859 /* A typespec that is a reserved word, or a type qualifier. */
1861 typespecqual_reserved:
1863 { $$.t = $1; $$.new_type_flag = 0; }
1865 { $$.t = $1; $$.new_type_flag = 0; }
1871 | initdecls ',' initdcl
1872 { check_multiple_declarators (); }
1877 | notype_initdecls ',' initdcl
1878 { check_multiple_declarators (); }
1883 | nomods_initdecls ',' initdcl
1884 { check_multiple_declarators (); }
1890 | asm_keyword '(' string ')'
1891 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3); $$ = $3; }
1895 declarator maybeasm maybe_attribute '='
1896 { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1,
1897 $3, prefix_attributes); }
1899 /* Note how the declaration of the variable is in effect while its init is parsed! */
1900 { cp_finish_decl ($<ttype>5, $6, $2, 1, LOOKUP_ONLYCONVERTING); }
1901 | declarator maybeasm maybe_attribute
1902 { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 0,
1903 $3, prefix_attributes);
1904 cp_finish_decl ($<ttype>$, NULL_TREE, $2, 1, 0); }
1907 /* This rule assumes a certain configuration of the parser stack.
1908 In particular, $0, the element directly before the beginning of
1909 this rule on the stack, must be a maybeasm. $-1 must be a
1910 declarator or notype_declarator. And $-2 must be some declmods
1911 or declspecs. We can't move the maybeasm into this rule because
1912 we need that reduce so we prefer fn.def1 when appropriate. */
1915 { $<itype>2 = parse_decl ($<ttype>-1, $<ttype>-2,
1916 $1, 1, &$<ttype>$); }
1917 /* Note how the declaration of the variable is in effect
1918 while its init is parsed! */
1920 { cp_finish_decl ($<ttype>3, $4, $<ttype>0, 1,
1921 LOOKUP_ONLYCONVERTING);
1925 $$ = parse_decl ($<ttype>-1, $<ttype>-2, $1, 0, &d);
1926 cp_finish_decl (d, NULL_TREE, $<ttype>0, 1, 0); }
1930 declarator maybeasm initdcl0_innards
1934 notype_declarator maybeasm initdcl0_innards
1939 notype_declarator maybeasm
1940 { /* Set things up as initdcl0_innards expects. */
1945 | constructor_declarator maybeasm maybe_attribute
1947 parse_decl($1, NULL_TREE, $3, 0, &d);
1948 cp_finish_decl (d, NULL_TREE, $2, 1, 0); }
1951 /* the * rules are dummies to accept the Apollo extended syntax
1952 so that the header files compile. */
1963 | attributes attribute
1964 { $$ = chainon ($1, $2); }
1968 ATTRIBUTE '(' '(' attribute_list ')' ')'
1975 | attribute_list ',' attrib
1976 { $$ = chainon ($1, $3); }
1983 { $$ = build_tree_list ($1, NULL_TREE); }
1984 | any_word '(' IDENTIFIER ')'
1985 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1986 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1987 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1988 | any_word '(' nonnull_exprlist ')'
1989 { $$ = build_tree_list ($1, $3); }
1992 /* This still leaves out most reserved keywords,
1993 shouldn't we include them? */
2002 /* A nonempty list of identifiers, including typenames. */
2003 identifiers_or_typenames:
2005 { $$ = build_tree_list (NULL_TREE, $1); }
2006 | identifiers_or_typenames ',' identifier
2007 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2011 /* empty */ %prec EMPTY
2016 /* If we are processing a template, we don't want to expand this
2020 expr_no_commas %prec '='
2022 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, NULL_TREE);
2023 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2025 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2026 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2027 | '{' initlist ',' '}'
2028 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2029 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2034 /* This chain is built in reverse order,
2035 and put in forward order where initlist is used. */
2038 { $$ = build_tree_list (NULL_TREE, $$); }
2040 { $$ = expr_tree_cons (NULL_TREE, $3, $$); }
2041 /* These are for labeled elements. */
2042 | '[' expr_no_commas ']' init
2043 { $$ = build_expr_list ($2, $4); }
2044 | identifier ':' init
2045 { $$ = build_expr_list ($$, $3); }
2046 | initlist ',' identifier ':' init
2047 { $$ = expr_tree_cons ($3, $5, $$); }
2051 PRE_PARSED_FUNCTION_DECL
2052 { start_function (NULL_TREE, TREE_VALUE ($1),
2054 reinit_parse_for_function (); }
2057 fn.defpen maybe_return_init ctor_initializer_opt compstmt_or_error
2059 int nested = (hack_decl_function_context
2060 (current_function_decl) != NULL_TREE);
2061 finish_function (lineno, (int)$3 | 2, nested);
2062 process_next_inline ($1);
2064 | fn.defpen maybe_return_init function_try_block
2066 int nested = (hack_decl_function_context
2067 (current_function_decl) != NULL_TREE);
2068 finish_function (lineno, (int)$3 | 2, nested);
2069 process_next_inline ($1);
2071 | fn.defpen maybe_return_init error
2072 { process_next_inline ($1); }
2077 | pending_inlines pending_inline eat_saved_input
2080 /* A regurgitated default argument. The value of DEFARG_MARKER will be
2081 the TREE_LIST node for the parameter in question. */
2083 DEFARG_MARKER expr_no_commas END_OF_SAVED_INPUT
2084 { replace_defarg ($1, $2); }
2085 | DEFARG_MARKER error END_OF_SAVED_INPUT
2086 { replace_defarg ($1, error_mark_node); }
2089 /* empty */ %prec EMPTY
2090 | pending_defargs defarg_again
2091 { do_pending_defargs (); }
2092 | pending_defargs error
2093 { do_pending_defargs (); }
2098 { $<itype>3 = suspend_momentary ();
2099 $<ttype>$ = current_enum_type;
2100 current_enum_type = start_enum ($2); }
2102 { TYPE_VALUES (current_enum_type) = $5;
2103 $$.t = finish_enum (current_enum_type);
2104 $$.new_type_flag = 1;
2105 current_enum_type = $<ttype>4;
2106 resume_momentary ((int) $<itype>3);
2107 check_for_missing_semicolon ($$.t); }
2109 { $<itype>2 = suspend_momentary ();
2110 $<ttype>$ = current_enum_type;
2111 current_enum_type = start_enum (make_anon_name ()); }
2113 { TYPE_VALUES (current_enum_type) = $4;
2114 $$.t = finish_enum (current_enum_type);
2115 $$.new_type_flag = 1;
2116 current_enum_type = $<ttype>3;
2117 resume_momentary ((int) $<itype>1);
2118 check_for_missing_semicolon ($$.t); }
2120 { $$.t = xref_tag (enum_type_node, $2, 1);
2121 $$.new_type_flag = 0; }
2122 | ENUM complex_type_name
2123 { $$.t = xref_tag (enum_type_node, $2, 1);
2124 $$.new_type_flag = 0; }
2125 | TYPENAME_KEYWORD typename_sub
2127 $$.new_type_flag = 0;
2128 if (!processing_template_decl)
2129 cp_pedwarn ("using `typename' outside of template"); }
2130 /* C++ extensions, merged with C to avoid shift/reduce conflicts */
2132 { $1.t = begin_class_definition ($1.t); }
2133 opt.component_decl_list '}' maybe_attribute
2137 if (yychar == YYEMPTY)
2139 semi = yychar == ';';
2141 $<ttype>$ = finish_class_definition ($1.t, $6, semi,
2146 begin_inline_definitions ();
2150 finish_inline_definitions ();
2152 $$.new_type_flag = 1;
2154 | class_head %prec EMPTY
2156 if ($1.new_type_flag && $1.t != error_mark_node)
2157 pop_scope (CP_DECL_CONTEXT (TYPE_MAIN_DECL ($1.t)));
2158 $$.new_type_flag = 0;
2159 if ($1.t == error_mark_node)
2161 else if (TYPE_BINFO ($1.t) == NULL_TREE)
2163 cp_error ("%T is not a class type", $1.t);
2164 $$.t = error_mark_node;
2169 /* struct B: public A; is not accepted by the WP grammar. */
2170 if (TYPE_BINFO_BASETYPES ($$.t) && !TYPE_SIZE ($$.t)
2171 && ! TYPE_BEING_DEFINED ($$.t))
2172 cp_error ("base clause without member specification for `%#T'",
2186 { if (pedantic && !in_system_header)
2187 pedwarn ("comma at end of enumerator list"); }
2193 { error ("storage class specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2195 { error ("type specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2197 { error ("type qualifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2199 { error ("no body nor ';' separates two class, struct or union declarations"); }
2201 { $$ = build_decl_list ($2, $1); }
2204 named_class_head_sans_basetype:
2212 named_class_head_sans_basetype_defn:
2213 aggr identifier_defn %prec EMPTY
2214 { current_aggr = $$; $$ = $2; }
2215 | named_class_head_sans_basetype '{'
2216 { yyungetc ('{', 1); }
2217 | named_class_head_sans_basetype ':'
2218 { yyungetc (':', 1); }
2221 named_complex_class_head_sans_basetype:
2222 aggr nested_name_specifier identifier
2225 $$.t = handle_class_head ($1, $2, $3);
2226 $$.new_type_flag = 1;
2228 | aggr global_scope nested_name_specifier identifier
2231 $$.t = handle_class_head ($1, $3, $4);
2232 $$.new_type_flag = 1;
2234 | aggr global_scope identifier
2237 $$.t = handle_class_head ($1, NULL_TREE, $3);
2238 $$.new_type_flag = 1;
2240 | aggr apparent_template_type
2244 $$.new_type_flag = 0;
2246 | aggr nested_name_specifier apparent_template_type
2250 if (CP_DECL_CONTEXT ($$.t))
2251 push_scope (CP_DECL_CONTEXT ($$.t));
2252 $$.new_type_flag = 1;
2257 named_class_head_sans_basetype %prec EMPTY
2259 $$.t = xref_tag (current_aggr, $1, 1);
2260 $$.new_type_flag = 0;
2262 | named_class_head_sans_basetype_defn
2263 { $<ttype>$ = xref_tag (current_aggr, $1, 0); }
2264 /* Class name is unqualified, so we look for base classes
2265 in the current scope. */
2266 maybe_base_class_list %prec EMPTY
2269 $$.new_type_flag = 0;
2271 xref_basetypes (current_aggr, $1, $<ttype>2, $3);
2273 | named_complex_class_head_sans_basetype
2274 maybe_base_class_list
2276 if ($1.t != error_mark_node)
2278 $$.t = TREE_TYPE ($1.t);
2279 $$.new_type_flag = $1.new_type_flag;
2280 if (current_aggr == union_type_node
2281 && TREE_CODE ($$.t) != UNION_TYPE)
2282 cp_pedwarn ("`union' tag used in declaring `%#T'",
2284 else if (TREE_CODE ($$.t) == UNION_TYPE
2285 && current_aggr != union_type_node)
2286 cp_pedwarn ("non-`union' tag used in declaring `%#T'", $$);
2287 else if (TREE_CODE ($$.t) == RECORD_TYPE)
2288 /* We might be specializing a template with a different
2290 CLASSTYPE_DECLARED_CLASS ($$.t)
2291 = (current_aggr == class_type_node);
2294 maybe_process_partial_specialization ($$.t);
2295 xref_basetypes (current_aggr, $1.t, $$.t, $2);
2303 { $$ = xref_tag ($$, make_anon_name (), 0);
2304 yyungetc ('{', 1); }
2307 /* The tree output of this nonterminal a declarationf or the type
2308 named. If NEW_TYPE_FLAG is set, then the name used in this
2309 class-head was explicitly qualified, e.g.: `struct X::Y'. We have
2310 already called push_scope for X. */
2315 $$.new_type_flag = 0;
2320 maybe_base_class_list:
2321 /* empty */ %prec EMPTY
2323 | ':' see_typename %prec EMPTY
2324 { yyungetc(':', 1); $$ = NULL_TREE; }
2325 | ':' see_typename base_class_list %prec EMPTY
2331 | base_class_list ',' see_typename base_class
2332 { $$ = chainon ($$, $4); }
2337 { $$ = finish_base_specifier (access_default_node, $1); }
2338 | base_class_access_list see_typename base_class.1
2339 { $$ = finish_base_specifier ($1, $3); }
2344 { if ($$ != error_mark_node) $$ = TYPE_MAIN_DECL ($1); }
2348 base_class_access_list:
2349 VISSPEC see_typename
2350 | SCSPEC see_typename
2351 { if ($1 != ridpointers[(int)RID_VIRTUAL])
2352 cp_error ("`%D' access", $1);
2353 $$ = access_default_virtual_node; }
2354 | base_class_access_list VISSPEC see_typename
2356 if ($1 != access_default_virtual_node)
2357 error ("multiple access specifiers");
2358 else if ($2 == access_public_node)
2359 $$ = access_public_virtual_node;
2360 else if ($2 == access_protected_node)
2361 $$ = access_protected_virtual_node;
2362 else /* $2 == access_private_node */
2363 $$ = access_private_virtual_node;
2365 | base_class_access_list SCSPEC see_typename
2366 { if ($2 != ridpointers[(int)RID_VIRTUAL])
2367 cp_error ("`%D' access", $2);
2368 else if ($$ == access_public_node)
2369 $$ = access_public_virtual_node;
2370 else if ($$ == access_protected_node)
2371 $$ = access_protected_virtual_node;
2372 else if ($$ == access_private_node)
2373 $$ = access_private_virtual_node;
2375 error ("multiple `virtual' specifiers");
2379 opt.component_decl_list:
2380 | component_decl_list
2381 | opt.component_decl_list access_specifier component_decl_list
2382 | opt.component_decl_list access_specifier
2388 current_access_specifier = $1;
2392 /* Note: we no longer warn about the semicolon after a component_decl_list.
2393 ARM $9.2 says that the semicolon is optional, and therefore allowed. */
2394 component_decl_list:
2397 finish_member_declaration ($1);
2399 | component_decl_list component_decl
2401 finish_member_declaration ($2);
2406 component_decl_1 ';'
2407 | component_decl_1 '}'
2408 { error ("missing ';' before right brace");
2409 yyungetc ('}', 0); }
2410 /* C++: handle constructors, destructors and inline functions */
2411 /* note that INLINE is like a TYPESPEC */
2412 | fn.def2 ':' /* base_init compstmt */
2413 { $$ = finish_method ($$); }
2414 | fn.def2 TRY /* base_init compstmt */
2415 { $$ = finish_method ($$); }
2416 | fn.def2 RETURN_KEYWORD /* base_init compstmt */
2417 { $$ = finish_method ($$); }
2418 | fn.def2 '{' /* nodecls compstmt */
2419 { $$ = finish_method ($$); }
2422 | extension component_decl
2425 | template_header component_decl
2428 $$ = finish_member_template_decl ($2);
2430 /* The component was already processed. */
2433 finish_template_decl ($1);
2435 | template_header typed_declspecs ';'
2437 $$ = finish_member_class_template ($2.t);
2438 finish_template_decl ($1);
2443 /* Do not add a "typed_declspecs declarator" rule here for
2444 speed; we need to call grok_x_components for enums, so the
2445 speedup would be insignificant. */
2446 typed_declspecs components
2448 /* Most of the productions for component_decl only
2449 allow the creation of one new member, so we call
2450 finish_member_declaration in component_decl_list.
2451 For this rule and the next, however, there can be
2452 more than one member, e.g.:
2456 and we need the first member to be fully
2457 registered before the second is processed.
2458 Therefore, the rules for components take care of
2459 this processing. To avoid registering the
2460 components more than once, we send NULL_TREE up
2461 here; that lets finish_member_declaration know
2462 that there is nothing to do. */
2464 grok_x_components ($1.t);
2467 | declmods notype_components
2470 grok_x_components ($1);
2473 | notype_declarator maybeasm maybe_attribute maybe_init
2474 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2475 build_tree_list ($3, NULL_TREE)); }
2476 | constructor_declarator maybeasm maybe_attribute maybe_init
2477 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2478 build_tree_list ($3, NULL_TREE)); }
2479 | ':' expr_no_commas
2480 { $$ = grokbitfield (NULL_TREE, NULL_TREE, $2); }
2484 /* These rules introduce a reduce/reduce conflict; in
2485 typedef int foo, bar;
2489 should "A::foo" be declared as a function or "A::bar" as a data
2490 member? In other words, is "bar" an after_type_declarator or a
2492 | declmods component_constructor_declarator maybeasm maybe_attribute maybe_init
2493 { tree specs, attrs;
2494 split_specs_attrs ($1, &specs, &attrs);
2495 $$ = grokfield ($2, specs, $5, $3,
2496 build_tree_list ($4, attrs)); }
2497 | component_constructor_declarator maybeasm maybe_attribute maybe_init
2498 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2499 build_tree_list ($3, NULL_TREE)); }
2501 { $$ = do_class_using_decl ($1); }
2503 /* The case of exactly one component is handled directly by component_decl. */
2506 /* empty: possibly anonymous */
2508 | component_declarator0
2510 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2511 $1 = finish_member_template_decl ($1);
2512 finish_member_declaration ($1);
2515 | components ',' component_declarator
2517 check_multiple_declarators ();
2518 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2519 $3 = finish_member_template_decl ($3);
2520 finish_member_declaration ($3);
2526 /* empty: possibly anonymous */
2528 | notype_component_declarator0
2530 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2531 $1 = finish_member_template_decl ($1);
2532 finish_member_declaration ($1);
2535 | notype_components ',' notype_component_declarator
2537 check_multiple_declarators ();
2538 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2539 $3 = finish_member_template_decl ($3);
2540 finish_member_declaration ($3);
2545 component_declarator0:
2546 after_type_component_declarator0
2547 | notype_component_declarator0
2550 component_declarator:
2551 after_type_component_declarator
2552 | notype_component_declarator
2555 after_type_component_declarator0:
2556 after_type_declarator maybeasm maybe_attribute maybe_init
2557 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2558 &prefix_attributes);
2559 $<ttype>0 = current_declspecs;
2560 $$ = grokfield ($$, current_declspecs, $4, $2,
2561 build_tree_list ($3, prefix_attributes)); }
2562 | TYPENAME ':' expr_no_commas maybe_attribute
2563 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2564 &prefix_attributes);
2565 $<ttype>0 = current_declspecs;
2566 $$ = grokbitfield ($$, current_declspecs, $3);
2567 cplus_decl_attributes ($$, $4, prefix_attributes); }
2570 notype_component_declarator0:
2571 notype_declarator maybeasm maybe_attribute maybe_init
2572 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2573 &prefix_attributes);
2574 $<ttype>0 = current_declspecs;
2575 $$ = grokfield ($$, current_declspecs, $4, $2,
2576 build_tree_list ($3, prefix_attributes)); }
2577 | constructor_declarator maybeasm maybe_attribute maybe_init
2578 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2579 &prefix_attributes);
2580 $<ttype>0 = current_declspecs;
2581 $$ = grokfield ($$, current_declspecs, $4, $2,
2582 build_tree_list ($3, prefix_attributes)); }
2583 | IDENTIFIER ':' expr_no_commas maybe_attribute
2584 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2585 &prefix_attributes);
2586 $<ttype>0 = current_declspecs;
2587 $$ = grokbitfield ($$, current_declspecs, $3);
2588 cplus_decl_attributes ($$, $4, prefix_attributes); }
2589 | ':' expr_no_commas maybe_attribute
2590 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2591 &prefix_attributes);
2592 $<ttype>0 = current_declspecs;
2593 $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
2594 cplus_decl_attributes ($$, $3, prefix_attributes); }
2597 after_type_component_declarator:
2598 after_type_declarator maybeasm maybe_attribute maybe_init
2599 { $$ = grokfield ($$, current_declspecs, $4, $2,
2600 build_tree_list ($3, prefix_attributes)); }
2601 | TYPENAME ':' expr_no_commas maybe_attribute
2602 { $$ = grokbitfield ($$, current_declspecs, $3);
2603 cplus_decl_attributes ($$, $4, prefix_attributes); }
2606 notype_component_declarator:
2607 notype_declarator maybeasm maybe_attribute maybe_init
2608 { $$ = grokfield ($$, current_declspecs, $4, $2,
2609 build_tree_list ($3, prefix_attributes)); }
2610 | IDENTIFIER ':' expr_no_commas maybe_attribute
2611 { $$ = grokbitfield ($$, current_declspecs, $3);
2612 cplus_decl_attributes ($$, $4, prefix_attributes); }
2613 | ':' expr_no_commas maybe_attribute
2614 { $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
2615 cplus_decl_attributes ($$, $3, prefix_attributes); }
2619 enumlist maybecomma_warn
2624 /* We chain the enumerators in reverse order.
2625 Because of the way enums are built, the order is
2626 insignificant. Take advantage of this fact. */
2630 | enumlist ',' enumerator
2631 { TREE_CHAIN ($3) = $$; $$ = $3; }
2636 { $$ = build_enumerator ($$, NULL_TREE, current_enum_type); }
2637 | identifier '=' expr_no_commas
2638 { $$ = build_enumerator ($$, $3, current_enum_type); }
2641 /* ANSI new-type-id (5.3.4) */
2643 type_specifier_seq new_declarator
2644 { $$.t = build_decl_list ($1.t, $2);
2645 $$.new_type_flag = $1.new_type_flag; }
2646 | type_specifier_seq %prec EMPTY
2647 { $$.t = build_decl_list ($1.t, NULL_TREE);
2648 $$.new_type_flag = $1.new_type_flag; }
2649 /* GNU extension to allow arrays of arbitrary types with
2650 non-constant dimension. For the use of begin_new_placement
2651 here, see the comments in unary_expr above. */
2652 | '(' .begin_new_placement type_id .finish_new_placement
2656 pedwarn ("ANSI C++ forbids array dimensions with parenthesized type in new");
2657 $$.t = build_parse_node (ARRAY_REF, TREE_VALUE ($3.t), $6);
2658 $$.t = build_decl_list (TREE_PURPOSE ($3.t), $$.t);
2659 $$.new_type_flag = $3.new_type_flag;
2664 /* empty */ %prec EMPTY
2666 | cv_qualifiers CV_QUALIFIER
2667 { $$ = decl_tree_cons (NULL_TREE, $2, $$); }
2670 nonempty_cv_qualifiers:
2672 { $$.t = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
2673 $$.new_type_flag = 0; }
2674 | nonempty_cv_qualifiers CV_QUALIFIER
2675 { $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
2676 $$.new_type_flag = $1.new_type_flag; }
2679 /* These rules must follow the rules for function declarations
2680 and component declarations. That way, longer rules are preferred. */
2684 { $<itype>$ = suspend_momentary (); }
2686 /* An expression which will not live on the momentary obstack. */
2689 { resume_momentary ((int) $<itype>1); $$ = $2; }
2692 /* An expression which will not live on the momentary obstack. */
2694 suspend_mom '(' nonnull_exprlist ')'
2695 { resume_momentary ((int) $<itype>1); $$ = $3; }
2696 | suspend_mom '(' parmlist ')'
2697 { resume_momentary ((int) $<itype>1); $$ = $3; }
2698 | suspend_mom LEFT_RIGHT
2699 { resume_momentary ((int) $<itype>1); $$ = empty_parms (); }
2700 | suspend_mom '(' error ')'
2701 { resume_momentary ((int) $<itype>1); $$ = NULL_TREE; }
2704 /* A declarator that is allowed only after an explicit typespec. */
2706 after_type_declarator_intern:
2707 after_type_declarator
2708 | attributes after_type_declarator
2710 /* Provide support for '(' attributes '*' declarator ')'
2712 $$ = decl_tree_cons ($1, $2, NULL_TREE);
2716 /* may all be followed by prec '.' */
2717 after_type_declarator:
2718 '*' nonempty_cv_qualifiers after_type_declarator_intern %prec UNARY
2719 { $$ = make_pointer_declarator ($2.t, $3); }
2720 | '&' nonempty_cv_qualifiers after_type_declarator_intern %prec UNARY
2721 { $$ = make_reference_declarator ($2.t, $3); }
2722 | '*' after_type_declarator_intern %prec UNARY
2723 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2724 | '&' after_type_declarator_intern %prec UNARY
2725 { $$ = make_reference_declarator (NULL_TREE, $2); }
2726 | ptr_to_mem cv_qualifiers after_type_declarator_intern
2727 { tree arg = make_pointer_declarator ($2, $3);
2728 $$ = build_parse_node (SCOPE_REF, $1, arg);
2730 | direct_after_type_declarator
2733 direct_after_type_declarator:
2734 direct_after_type_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2735 { $$ = make_call_declarator ($$, $2, $3, $4); }
2736 | direct_after_type_declarator '[' nonmomentary_expr ']'
2737 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
2738 | direct_after_type_declarator '[' ']'
2739 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
2740 | '(' after_type_declarator_intern ')'
2742 | nested_name_specifier type_name %prec EMPTY
2743 { push_nested_class ($1, 3);
2744 $$ = build_parse_node (SCOPE_REF, $$, $2);
2745 TREE_COMPLEXITY ($$) = current_class_depth; }
2746 | type_name %prec EMPTY
2750 type_name %prec EMPTY
2752 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2754 $$ = lookup_name ($1, 1);
2755 maybe_note_name_used_in_class ($1, $$);
2760 | global_scope type_name
2762 if (TREE_CODE ($2) == IDENTIFIER_NODE)
2763 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
2766 got_scope = NULL_TREE;
2773 | global_scope nested_type
2778 nested_name_specifier type_name %prec EMPTY
2779 { $$ = get_type_decl ($2); }
2782 /* A declarator allowed whether or not there has been
2783 an explicit typespec. These cannot redeclare a typedef-name. */
2785 notype_declarator_intern:
2787 | attributes notype_declarator
2789 /* Provide support for '(' attributes '*' declarator ')'
2791 $$ = decl_tree_cons ($1, $2, NULL_TREE);
2796 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2797 { $$ = make_pointer_declarator ($2.t, $3); }
2798 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2799 { $$ = make_reference_declarator ($2.t, $3); }
2800 | '*' notype_declarator_intern %prec UNARY
2801 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2802 | '&' notype_declarator_intern %prec UNARY
2803 { $$ = make_reference_declarator (NULL_TREE, $2); }
2804 | ptr_to_mem cv_qualifiers notype_declarator_intern
2805 { tree arg = make_pointer_declarator ($2, $3);
2806 $$ = build_parse_node (SCOPE_REF, $1, arg);
2808 | direct_notype_declarator
2811 complex_notype_declarator:
2812 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2813 { $$ = make_pointer_declarator ($2.t, $3); }
2814 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2815 { $$ = make_reference_declarator ($2.t, $3); }
2816 | '*' complex_notype_declarator %prec UNARY
2817 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2818 | '&' complex_notype_declarator %prec UNARY
2819 { $$ = make_reference_declarator (NULL_TREE, $2); }
2820 | ptr_to_mem cv_qualifiers notype_declarator_intern
2821 { tree arg = make_pointer_declarator ($2, $3);
2822 $$ = build_parse_node (SCOPE_REF, $1, arg);
2824 | complex_direct_notype_declarator
2827 complex_direct_notype_declarator:
2828 direct_notype_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2829 { $$ = make_call_declarator ($$, $2, $3, $4); }
2830 | '(' complex_notype_declarator ')'
2832 | direct_notype_declarator '[' nonmomentary_expr ']'
2833 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
2834 | direct_notype_declarator '[' ']'
2835 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
2836 | notype_qualified_id
2837 { enter_scope_of ($1); }
2838 | nested_name_specifier notype_template_declarator
2839 { got_scope = NULL_TREE;
2840 $$ = build_parse_node (SCOPE_REF, $1, $2);
2841 enter_scope_of ($$);
2846 nested_name_specifier unqualified_id
2847 { got_scope = NULL_TREE;
2848 $$ = build_parse_node (SCOPE_REF, $$, $2); }
2849 | nested_name_specifier object_template_id
2850 { got_scope = NULL_TREE;
2851 $$ = build_parse_node (SCOPE_REF, $1, $2); }
2854 notype_qualified_id:
2855 nested_name_specifier notype_unqualified_id
2856 { got_scope = NULL_TREE;
2857 $$ = build_parse_node (SCOPE_REF, $$, $2); }
2858 | nested_name_specifier object_template_id
2859 { got_scope = NULL_TREE;
2860 $$ = build_parse_node (SCOPE_REF, $1, $2); }
2865 | global_scope notype_qualified_id
2870 typespec '(' nonnull_exprlist ')'
2871 { $$ = build_functional_cast ($1.t, $3); }
2872 | typespec '(' expr_or_declarator_intern ')'
2873 { $$ = reparse_decl_as_expr ($1.t, $3); }
2874 | typespec fcast_or_absdcl %prec EMPTY
2875 { $$ = reparse_absdcl_as_expr ($1.t, $2); }
2880 | template_type %prec EMPTY
2883 nested_name_specifier:
2884 nested_name_specifier_1
2885 | nested_name_specifier nested_name_specifier_1
2887 | nested_name_specifier TEMPLATE explicit_template_type SCOPE
2888 { got_scope = $$ = make_typename_type ($1, $3); }
2891 /* Why the @#$%^& do type_name and notype_identifier need to be expanded
2892 inline here?!? (jason) */
2893 nested_name_specifier_1:
2896 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2899 maybe_note_name_used_in_class ($1, $$);
2902 complete_type (TYPE_MAIN_VARIANT (TREE_TYPE ($$)));
2906 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2908 got_scope = $$ = TREE_TYPE ($$);
2912 if (TREE_CODE ($$) == IDENTIFIER_NODE)
2916 | template_type SCOPE
2917 { got_scope = $$ = complete_type (TREE_TYPE ($1)); }
2918 /* These break 'const i;'
2922 cp_error ("`%D' is not an aggregate typedef",
2923 lastiddecl ? lastiddecl : $$);
2924 $$ = error_mark_node;
2927 { goto failed_scope; } */
2932 | global_scope typename_sub0
2937 typename_sub1 identifier %prec EMPTY
2939 if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't')
2940 $$ = make_typename_type ($1, $2);
2941 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
2942 cp_error ("`%T' is not a class or namespace", $2);
2946 if (TREE_CODE ($$) == TYPE_DECL)
2947 $$ = TREE_TYPE ($$);
2950 | typename_sub1 template_type %prec EMPTY
2951 { $$ = TREE_TYPE ($2); }
2952 | typename_sub1 explicit_template_type %prec EMPTY
2953 { $$ = make_typename_type ($1, $2); }
2954 | typename_sub1 TEMPLATE explicit_template_type %prec EMPTY
2955 { $$ = make_typename_type ($1, $3); }
2961 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2962 cp_error ("`%T' is not a class or namespace", $1);
2964 | typename_sub1 typename_sub2
2966 if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't')
2967 $$ = make_typename_type ($1, $2);
2968 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
2969 cp_error ("`%T' is not a class or namespace", $2);
2973 if (TREE_CODE ($$) == TYPE_DECL)
2974 $$ = TREE_TYPE ($$);
2977 | typename_sub1 explicit_template_type SCOPE
2978 { got_scope = $$ = make_typename_type ($1, $2); }
2979 | typename_sub1 TEMPLATE explicit_template_type SCOPE
2980 { got_scope = $$ = make_typename_type ($1, $3); }
2986 if (TREE_CODE ($1) != IDENTIFIER_NODE)
2989 /* Retrieve the type for the identifier, which might involve
2990 some computation. */
2991 got_scope = $$ = complete_type (IDENTIFIER_TYPE_VALUE ($1));
2993 if ($$ == error_mark_node)
2994 cp_error ("`%T' is not a class or namespace", $1);
2998 if (TREE_CODE ($1) != IDENTIFIER_NODE)
3000 got_scope = $$ = complete_type (TREE_TYPE ($$));
3002 | template_type SCOPE
3003 { got_scope = $$ = complete_type (TREE_TYPE ($$)); }
3008 if (TREE_CODE ($$) == IDENTIFIER_NODE)
3014 explicit_template_type:
3015 identifier '<' template_arg_list_opt template_close_bracket
3016 { $$ = build_min_nt (TEMPLATE_ID_EXPR, $1, $3); }
3020 global_scope type_name
3022 if (TREE_CODE ($2) == IDENTIFIER_NODE)
3023 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
3026 got_scope = NULL_TREE;
3029 | global_scope nested_type
3034 nested_name_specifier '*'
3035 { got_scope = NULL_TREE; }
3036 | global_scope nested_name_specifier '*'
3037 { $$ = $2; got_scope = NULL_TREE; }
3040 /* All uses of explicit global scope must go through this nonterminal so
3041 that got_scope will be set before yylex is called to get the next token. */
3044 { got_scope = void_type_node; }
3047 /* ANSI new-declarator (5.3.4) */
3049 '*' cv_qualifiers new_declarator
3050 { $$ = make_pointer_declarator ($2, $3); }
3051 | '*' cv_qualifiers %prec EMPTY
3052 { $$ = make_pointer_declarator ($2, NULL_TREE); }
3053 | '&' cv_qualifiers new_declarator %prec EMPTY
3054 { $$ = make_reference_declarator ($2, $3); }
3055 | '&' cv_qualifiers %prec EMPTY
3056 { $$ = make_reference_declarator ($2, NULL_TREE); }
3057 | ptr_to_mem cv_qualifiers %prec EMPTY
3058 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3059 $$ = build_parse_node (SCOPE_REF, $1, arg);
3061 | ptr_to_mem cv_qualifiers new_declarator
3062 { tree arg = make_pointer_declarator ($2, $3);
3063 $$ = build_parse_node (SCOPE_REF, $1, arg);
3065 | direct_new_declarator %prec EMPTY
3068 /* ANSI direct-new-declarator (5.3.4) */
3069 direct_new_declarator:
3071 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3072 | direct_new_declarator '[' nonmomentary_expr ']'
3073 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3080 /* Provide support for '(' attributes '*' declarator ')'
3082 $$ = decl_tree_cons ($1, $2, NULL_TREE);
3086 /* ANSI abstract-declarator (8.1) */
3088 '*' nonempty_cv_qualifiers absdcl_intern
3089 { $$ = make_pointer_declarator ($2.t, $3); }
3091 { $$ = make_pointer_declarator (NULL_TREE, $2); }
3092 | '*' nonempty_cv_qualifiers %prec EMPTY
3093 { $$ = make_pointer_declarator ($2.t, NULL_TREE); }
3095 { $$ = make_pointer_declarator (NULL_TREE, NULL_TREE); }
3096 | '&' nonempty_cv_qualifiers absdcl_intern
3097 { $$ = make_reference_declarator ($2.t, $3); }
3099 { $$ = make_reference_declarator (NULL_TREE, $2); }
3100 | '&' nonempty_cv_qualifiers %prec EMPTY
3101 { $$ = make_reference_declarator ($2.t, NULL_TREE); }
3103 { $$ = make_reference_declarator (NULL_TREE, NULL_TREE); }
3104 | ptr_to_mem cv_qualifiers %prec EMPTY
3105 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3106 $$ = build_parse_node (SCOPE_REF, $1, arg);
3108 | ptr_to_mem cv_qualifiers absdcl_intern
3109 { tree arg = make_pointer_declarator ($2, $3);
3110 $$ = build_parse_node (SCOPE_REF, $1, arg);
3112 | direct_abstract_declarator %prec EMPTY
3115 /* ANSI direct-abstract-declarator (8.1) */
3116 direct_abstract_declarator:
3117 '(' absdcl_intern ')'
3119 /* `(typedef)1' is `int'. */
3120 | direct_abstract_declarator '(' parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3121 { $$ = make_call_declarator ($$, $3, $5, $6); }
3122 | direct_abstract_declarator LEFT_RIGHT cv_qualifiers exception_specification_opt %prec '.'
3123 { $$ = make_call_declarator ($$, empty_parms (), $3, $4); }
3124 | direct_abstract_declarator '[' nonmomentary_expr ']' %prec '.'
3125 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3126 | direct_abstract_declarator '[' ']' %prec '.'
3127 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
3128 | '(' complex_parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3129 { $$ = make_call_declarator (NULL_TREE, $2, $4, $5); }
3130 | regcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3131 { set_quals_and_spec ($$, $2, $3); }
3132 | fcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3133 { set_quals_and_spec ($$, $2, $3); }
3134 | '[' nonmomentary_expr ']' %prec '.'
3135 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3137 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, NULL_TREE); }
3140 /* For C++, decls and stmts can be intermixed, so we don't need to
3141 have a special rule that won't start parsing the stmt section
3142 until we have a stmt that parses without errors. */
3155 /* Read zero or more forward-declarations for labels
3156 that nested functions can jump to. */
3161 pedwarn ("ANSI C++ forbids label declarations"); }
3166 | label_decls label_decl
3170 LABEL identifiers_or_typenames ';'
3174 finish_label_decl (TREE_VALUE ($2));
3175 $2 = TREE_CHAIN ($2);
3180 /* This is the body of a function definition.
3181 It causes syntax errors to ignore to the next openbrace. */
3190 { $<ttype>$ = begin_compound_stmt (0); }
3192 { $$ = finish_compound_stmt (0, $<ttype>2); }
3198 $<ttype>$ = begin_if_stmt ();
3199 cond_stmt_keyword = "if";
3202 { finish_if_stmt_cond ($3, $<ttype>2); }
3203 implicitly_scoped_stmt
3204 { $<ttype>$ = finish_then_clause ($<ttype>2); }
3207 implicitly_scoped_stmt:
3209 | { $<ttype>$ = begin_compound_stmt (0); }
3211 { $$ = finish_compound_stmt (0, $<ttype>1); }
3224 { finish_expr_stmt ($1); }
3226 { begin_else_clause (); }
3227 implicitly_scoped_stmt
3229 finish_else_clause ($<ttype>1);
3232 | simple_if %prec IF
3233 { finish_if_stmt (); }
3236 $<ttype>$ = begin_while_stmt ();
3237 cond_stmt_keyword = "while";
3240 { finish_while_stmt_cond ($3, $<ttype>2); }
3242 { finish_while_stmt ($<ttype>2); }
3244 { $<ttype>$ = begin_do_stmt (); }
3245 implicitly_scoped_stmt WHILE
3247 finish_do_body ($<ttype>2);
3248 cond_stmt_keyword = "do";
3250 paren_expr_or_null ';'
3251 { finish_do_stmt ($6, $<ttype>2); }
3253 { $<ttype>$ = begin_for_stmt (); }
3254 '(' for.init.statement
3255 { finish_for_init_stmt ($<ttype>2); }
3257 { finish_for_cond ($6, $<ttype>2); }
3259 { finish_for_expr ($9, $<ttype>2); }
3261 { finish_for_stmt ($9, $<ttype>2); }
3263 { begin_switch_stmt (); }
3265 { $<ttype>$ = finish_switch_cond ($4); }
3266 implicitly_scoped_stmt
3267 { finish_switch_stmt ($4, $<ttype>6); }
3268 | CASE expr_no_commas ':'
3269 { finish_case_label ($2, NULL_TREE); }
3271 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
3272 { finish_case_label ($2, $4); }
3275 { finish_case_label (NULL_TREE, NULL_TREE); }
3278 { finish_break_stmt (); }
3280 { finish_continue_stmt (); }
3281 | RETURN_KEYWORD ';'
3282 { finish_return_stmt (NULL_TREE); }
3283 | RETURN_KEYWORD expr ';'
3284 { finish_return_stmt ($2); }
3285 | asm_keyword maybe_cv_qualifier '(' string ')' ';'
3287 finish_asm_stmt ($2, $4, NULL_TREE, NULL_TREE,
3290 /* This is the case with just output operands. */
3291 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ')' ';'
3293 finish_asm_stmt ($2, $4, $6, NULL_TREE,
3296 /* This is the case with input operands as well. */
3297 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':' asm_operands ')' ';'
3298 { finish_asm_stmt ($2, $4, $6, $8, NULL_TREE); }
3299 /* This is the case with clobbered registers as well. */
3300 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':'
3301 asm_operands ':' asm_clobbers ')' ';'
3302 { finish_asm_stmt ($2, $4, $6, $8, $10); }
3306 pedwarn ("ANSI C++ forbids computed gotos");
3307 finish_goto_stmt ($3);
3309 | GOTO identifier ';'
3310 { finish_goto_stmt ($2); }
3314 { error ("label must be followed by statement");
3321 | namespace_using_decl
3322 { do_local_using_decl ($1); }
3328 { $<ttype>$ = begin_function_try_block (); }
3329 ctor_initializer_opt compstmt
3330 { finish_function_try_block ($<ttype>2); }
3333 finish_function_handler_sequence ($<ttype>2);
3340 { $<ttype>$ = begin_try_block (); }
3342 { finish_try_block ($<ttype>2); }
3344 { finish_handler_sequence ($<ttype>2); }
3349 | handler_seq handler
3354 { $<ttype>$ = begin_handler(); }
3356 { finish_handler_parms ($<ttype>2); }
3358 { finish_handler ($<ttype>2); }
3362 typed_typespecs %prec EMPTY
3363 | nonempty_cv_qualifiers %prec EMPTY
3368 { expand_start_catch_block (NULL_TREE); }
3369 /* This doesn't allow reference parameters, the below does.
3370 | '(' type_specifier_seq absdcl ')'
3371 { check_for_new_type ("inside exception declarations", $2);
3372 expand_start_catch_block ($2.t, $3); }
3373 | '(' type_specifier_seq ')'
3374 { check_for_new_type ("inside exception declarations", $2);
3375 expand_start_catch_block ($2.t, NULL_TREE); }
3376 | '(' type_specifier_seq notype_declarator ')'
3377 { check_for_new_type ("inside exception declarations", $2);
3378 expand_start_catch_block ($2.t, $3); }
3379 | '(' typed_typespecs after_type_declarator ')'
3380 { check_for_new_type ("inside exception declarations", $2);
3381 expand_start_catch_block ($2.t, $3); }
3382 This allows reference parameters... */
3385 check_for_new_type ("inside exception declarations", $2);
3386 start_handler_parms (TREE_PURPOSE ($2.t),
3393 { finish_label_stmt ($1); }
3395 { finish_label_stmt ($1); }
3397 { finish_label_stmt ($1); }
3399 { finish_label_stmt ($1); }
3404 { finish_expr_stmt ($1); }
3408 pedwarn ("ANSI C++ forbids compound statements inside for initializations");
3412 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
3416 { emit_line_note (input_filename, lineno);
3419 { emit_line_note (input_filename, lineno); }
3430 /* These are the operands other than the first string and colon
3431 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
3435 | nonnull_asm_operands
3438 nonnull_asm_operands:
3440 | nonnull_asm_operands ',' asm_operand
3441 { $$ = chainon ($$, $3); }
3446 { $$ = build_tree_list ($$, $3); }
3451 { $$ = tree_cons (NULL_TREE, $$, NULL_TREE); }
3452 | asm_clobbers ',' STRING
3453 { $$ = tree_cons (NULL_TREE, $3, $$); }
3456 /* This is what appears inside the parens in a function declarator.
3457 Its value is represented in the format that grokdeclarator expects.
3459 In C++, declaring a function with no parameters
3460 means that that function takes *no* parameters. */
3469 { $$ = finish_parmlist (build_tree_list (NULL_TREE, $1.t), 0);
3470 check_for_new_type ("inside parameter list", $1); }
3473 /* This nonterminal does not include the common sequence '(' type_id ')',
3474 as it is ambiguous and must be disambiguated elsewhere. */
3477 { $$ = finish_parmlist ($$, 0); }
3478 | parms_comma ELLIPSIS
3479 { $$ = finish_parmlist ($1, 1); }
3480 /* C++ allows an ellipsis without a separating ',' */
3482 { $$ = finish_parmlist ($1, 1); }
3484 { $$ = finish_parmlist (build_tree_list (NULL_TREE,
3487 { $$ = finish_parmlist (NULL_TREE, 1); }
3490 /* This helps us recover from really nasty
3491 parse errors, for example, a missing right
3493 yyerror ("possibly missing ')'");
3494 $$ = finish_parmlist ($1, 0);
3500 /* This helps us recover from really nasty
3501 parse errors, for example, a missing right
3503 yyerror ("possibly missing ')'");
3504 $$ = finish_parmlist (build_tree_list (NULL_TREE,
3511 /* A default argument to a */
3514 { maybe_snarf_defarg (); }
3524 /* A nonempty list of parameter declarations or type names. */
3527 { check_for_new_type ("in a parameter list", $1);
3528 $$ = build_tree_list (NULL_TREE, $1.t); }
3530 { check_for_new_type ("in a parameter list", $1);
3531 $$ = build_tree_list ($2, $1.t); }
3532 | parms_comma full_parm
3533 { check_for_new_type ("in a parameter list", $2);
3534 $$ = chainon ($$, $2.t); }
3535 | parms_comma bad_parm
3536 { $$ = chainon ($$, build_tree_list (NULL_TREE, $2)); }
3537 | parms_comma bad_parm '=' init
3538 { $$ = chainon ($$, build_tree_list ($4, $2)); }
3544 { check_for_new_type ("in a parameter list", $1);
3545 $$ = build_tree_list (NULL_TREE, $1.t); }
3548 /* A single parameter declaration or parameter type name,
3549 as found in a parmlist. */
3551 /* Here we expand typed_declspecs inline to avoid mis-parsing of
3552 TYPESPEC IDENTIFIER. */
3553 typed_declspecs1 declarator
3554 { tree specs = strip_attrs ($1.t);
3555 $$.new_type_flag = $1.new_type_flag;
3556 $$.t = build_tree_list (specs, $2); }
3557 | typed_typespecs declarator
3558 { $$.t = build_tree_list ($1.t, $2);
3559 $$.new_type_flag = $1.new_type_flag; }
3560 | typespec declarator
3561 { $$.t = build_tree_list (build_decl_list (NULL_TREE, $1.t),
3563 $$.new_type_flag = $1.new_type_flag; }
3564 | typed_declspecs1 absdcl
3565 { tree specs = strip_attrs ($1.t);
3566 $$.t = build_tree_list (specs, $2);
3567 $$.new_type_flag = $1.new_type_flag; }
3568 | typed_declspecs1 %prec EMPTY
3569 { tree specs = strip_attrs ($1.t);
3570 $$.t = build_tree_list (specs, NULL_TREE);
3571 $$.new_type_flag = $1.new_type_flag; }
3572 | declmods notype_declarator
3573 { tree specs = strip_attrs ($1);
3574 $$.t = build_tree_list (specs, $2);
3575 $$.new_type_flag = 0; }
3580 { $$.t = build_tree_list (NULL_TREE, $1.t);
3581 $$.new_type_flag = $1.new_type_flag; }
3583 { $$.t = build_tree_list ($2, $1.t);
3584 $$.new_type_flag = $1.new_type_flag; }
3593 /* empty */ %prec EMPTY
3594 { see_typename (); }
3598 /* empty */ %prec EMPTY
3600 error ("type specifier omitted for parameter");
3601 $$ = build_tree_list (integer_type_node, NULL_TREE);
3605 error ("type specifier omitted for parameter");
3606 if (TREE_CODE ($$) == SCOPE_REF
3607 && (TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TYPE_PARM
3608 || TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TEMPLATE_PARM))
3609 cp_error (" perhaps you want `typename %E' to make it a type", $$);
3610 $$ = build_tree_list (integer_type_node, $$);
3614 exception_specification_opt:
3615 /* empty */ %prec EMPTY
3617 | THROW '(' ansi_raise_identifiers ')' %prec EMPTY
3619 | THROW LEFT_RIGHT %prec EMPTY
3620 { $$ = empty_except_spec; }
3623 ansi_raise_identifier:
3626 check_for_new_type ("exception specifier", $1);
3627 $$ = groktypename ($1.t);
3631 ansi_raise_identifiers:
3632 ansi_raise_identifier
3633 { $$ = add_exception_specifier (NULL_TREE, $1, 1); }
3634 | ansi_raise_identifiers ',' ansi_raise_identifier
3635 { $$ = add_exception_specifier ($1, $3, 1); }
3638 conversion_declarator:
3639 /* empty */ %prec EMPTY
3641 | '*' cv_qualifiers conversion_declarator
3642 { $$ = make_pointer_declarator ($2, $3); }
3643 | '&' cv_qualifiers conversion_declarator
3644 { $$ = make_reference_declarator ($2, $3); }
3645 | ptr_to_mem cv_qualifiers conversion_declarator
3646 { tree arg = make_pointer_declarator ($2, $3);
3647 $$ = build_parse_node (SCOPE_REF, $1, arg);
3653 { got_scope = NULL_TREE; }
3658 { $$ = ansi_opname[MULT_EXPR]; }
3660 { $$ = ansi_opname[TRUNC_DIV_EXPR]; }
3662 { $$ = ansi_opname[TRUNC_MOD_EXPR]; }
3664 { $$ = ansi_opname[PLUS_EXPR]; }
3666 { $$ = ansi_opname[MINUS_EXPR]; }
3668 { $$ = ansi_opname[BIT_AND_EXPR]; }
3670 { $$ = ansi_opname[BIT_IOR_EXPR]; }
3672 { $$ = ansi_opname[BIT_XOR_EXPR]; }
3674 { $$ = ansi_opname[BIT_NOT_EXPR]; }
3676 { $$ = ansi_opname[COMPOUND_EXPR]; }
3677 | operator ARITHCOMPARE
3678 { $$ = ansi_opname[$2]; }
3680 { $$ = ansi_opname[LT_EXPR]; }
3682 { $$ = ansi_opname[GT_EXPR]; }
3683 | operator EQCOMPARE
3684 { $$ = ansi_opname[$2]; }
3686 { $$ = ansi_assopname[$2]; }
3688 { $$ = ansi_opname [MODIFY_EXPR]; }
3690 { $$ = ansi_opname[$2]; }
3692 { $$ = ansi_opname[$2]; }
3694 { $$ = ansi_opname[POSTINCREMENT_EXPR]; }
3695 | operator MINUSMINUS
3696 { $$ = ansi_opname[PREDECREMENT_EXPR]; }
3698 { $$ = ansi_opname[TRUTH_ANDIF_EXPR]; }
3700 { $$ = ansi_opname[TRUTH_ORIF_EXPR]; }
3702 { $$ = ansi_opname[TRUTH_NOT_EXPR]; }
3704 { $$ = ansi_opname[COND_EXPR]; }
3706 { $$ = ansi_opname[$2]; }
3707 | operator POINTSAT %prec EMPTY
3708 { $$ = ansi_opname[COMPONENT_REF]; }
3709 | operator POINTSAT_STAR %prec EMPTY
3710 { $$ = ansi_opname[MEMBER_REF]; }
3711 | operator LEFT_RIGHT
3712 { $$ = ansi_opname[CALL_EXPR]; }
3714 { $$ = ansi_opname[ARRAY_REF]; }
3715 | operator NEW %prec EMPTY
3716 { $$ = ansi_opname[NEW_EXPR]; }
3717 | operator DELETE %prec EMPTY
3718 { $$ = ansi_opname[DELETE_EXPR]; }
3719 | operator NEW '[' ']'
3720 { $$ = ansi_opname[VEC_NEW_EXPR]; }
3721 | operator DELETE '[' ']'
3722 { $$ = ansi_opname[VEC_DELETE_EXPR]; }
3723 /* Names here should be looked up in class scope ALSO. */
3724 | operator type_specifier_seq conversion_declarator
3725 { $$ = grokoptypename ($2.t, $3); }
3727 { $$ = ansi_opname[ERROR_MARK]; }
3734 debug_yytranslate (value)
3737 return yytname[YYTRANSLATE (value)];