1 /* YACC parser for C++ syntax.
2 Copyright (C) 1988, 1989, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000 Free Software Foundation, Inc.
4 Hacked by Michael Tiemann (tiemann@cygnus.com)
6 This file is part of GNU CC.
8 GNU CC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 GNU CC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU CC; see the file COPYING. If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
24 /* This grammar is based on the GNU CC grammar. */
26 /* Note: Bison automatically applies a default action of "$$ = $1" for
27 all derivations; this is applied before the explicit action, if one
28 is given. Keep this in mind when reading the actions. */
31 /* Cause the `yydebug' variable to be defined. */
48 /* Since parsers are distinct for each language, put the language string
49 definition here. (fnf) */
50 const char * const language_string = "GNU C++";
52 extern struct obstack permanent_obstack;
54 extern int end_of_file;
56 /* Like YYERROR but do call yyerror. */
57 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
59 #define OP0(NODE) (TREE_OPERAND (NODE, 0))
60 #define OP1(NODE) (TREE_OPERAND (NODE, 1))
62 /* Contains the statement keyword (if/while/do) to include in an
63 error message if the user supplies an empty conditional expression. */
64 static const char *cond_stmt_keyword;
66 /* Nonzero if we have an `extern "C"' acting as an extern specifier. */
70 /* List of types and structure classes of the current declaration. */
71 static tree current_declspecs;
73 /* List of prefix attributes in effect.
74 Prefix attributes are parsed by the reserved_declspecs and declmods
75 rules. They create a list that contains *both* declspecs and attrs. */
76 /* ??? It is not clear yet that all cases where an attribute can now appear in
77 a declspec list have been updated. */
78 static tree prefix_attributes;
80 /* When defining an aggregate, this is the kind of the most recent one
81 being defined. (For example, this might be class_type_node.) */
82 static tree current_aggr;
84 /* When defining an enumeration, this is the type of the enumeration. */
85 static tree current_enum_type;
87 static tree empty_parms PARAMS ((void));
88 static tree parse_decl0 PARAMS ((tree, tree, tree, tree, int));
89 static tree parse_decl PARAMS ((tree, tree, int));
90 static void parse_end_decl PARAMS ((tree, tree, tree));
91 static tree parse_field0 PARAMS ((tree, tree, tree, tree, tree, tree));
92 static tree parse_field PARAMS ((tree, tree, tree, tree));
93 static tree parse_bitfield0 PARAMS ((tree, tree, tree, tree, tree));
94 static tree parse_bitfield PARAMS ((tree, tree, tree));
95 static tree parse_method PARAMS ((tree, tree, tree));
96 static void frob_specs PARAMS ((tree, tree));
98 /* Cons up an empty parameter list. */
105 || current_class_type != NULL)
106 parms = void_list_node;
112 /* Record the decl-specifiers, attributes and type lookups from the
113 decl-specifier-seq in a declaration. */
116 frob_specs (specs_attrs, lookups)
117 tree specs_attrs, lookups;
119 save_type_access_control (lookups);
120 split_specs_attrs (specs_attrs, ¤t_declspecs, &prefix_attributes);
121 if (current_declspecs
122 && TREE_CODE (current_declspecs) != TREE_LIST)
123 current_declspecs = build_decl_list (NULL_TREE, current_declspecs);
124 if (have_extern_spec && !used_extern_spec)
126 current_declspecs = decl_tree_cons (NULL_TREE,
127 get_identifier ("extern"),
129 used_extern_spec = 1;
134 parse_decl (declarator, attributes, initialized)
135 tree declarator, attributes;
138 return start_decl (declarator, current_declspecs, initialized,
139 attributes, prefix_attributes);
143 parse_decl0 (declarator, specs_attrs, lookups, attributes, initialized)
144 tree declarator, specs_attrs, lookups, attributes;
147 frob_specs (specs_attrs, lookups);
148 return parse_decl (declarator, attributes, initialized);
152 parse_end_decl (decl, init, asmspec)
153 tree decl, init, asmspec;
155 /* If decl is NULL_TREE, then this was a variable declaration using
156 () syntax for the initializer, so we handled it in grokdeclarator. */
158 decl_type_access_control (decl);
159 cp_finish_decl (decl, init, asmspec, init ? LOOKUP_ONLYCONVERTING : 0);
163 parse_field (declarator, attributes, asmspec, init)
164 tree declarator, attributes, asmspec, init;
166 tree d = grokfield (declarator, current_declspecs, init, asmspec,
167 build_tree_list (attributes, prefix_attributes));
168 decl_type_access_control (d);
173 parse_field0 (declarator, specs_attrs, lookups, attributes, asmspec, init)
174 tree declarator, specs_attrs, lookups, attributes, asmspec, init;
176 frob_specs (specs_attrs, lookups);
177 return parse_field (declarator, attributes, asmspec, init);
181 parse_bitfield (declarator, attributes, width)
182 tree declarator, attributes, width;
184 tree d = grokbitfield (declarator, current_declspecs, width);
185 cplus_decl_attributes (d, attributes, prefix_attributes);
186 decl_type_access_control (d);
191 parse_bitfield0 (declarator, specs_attrs, lookups, attributes, width)
192 tree declarator, specs_attrs, lookups, attributes, width;
194 frob_specs (specs_attrs, lookups);
195 return parse_bitfield (declarator, attributes, width);
199 parse_method (declarator, specs_attrs, lookups)
200 tree declarator, specs_attrs, lookups;
203 frob_specs (specs_attrs, lookups);
204 d = start_method (current_declspecs, declarator, prefix_attributes);
205 decl_type_access_control (d);
212 ggc_add_tree_root (¤t_declspecs, 1);
213 ggc_add_tree_root (&prefix_attributes, 1);
214 ggc_add_tree_root (¤t_aggr, 1);
215 ggc_add_tree_root (¤t_enum_type, 1);
226 flagged_type_tree ftype;
227 struct pending_inline *pi;
230 /* All identifiers that are not reserved words
231 and are not declared typedefs in the current block */
234 /* All identifiers that are declared typedefs in the current block.
235 In some contexts, they are treated just like IDENTIFIER,
236 but they can also serve as typespecs in declarations. */
240 /* A template function. */
243 /* Reserved words that specify storage class.
244 yylval contains an IDENTIFIER_NODE which indicates which one. */
247 /* Reserved words that specify type.
248 yylval contains an IDENTIFIER_NODE which indicates which one. */
251 /* Reserved words that qualify type: "const" or "volatile".
252 yylval contains an IDENTIFIER_NODE which indicates which one. */
255 /* Character or numeric constants.
256 yylval is the node for the constant. */
259 /* String constants in raw form.
260 yylval is a STRING_CST node. */
263 /* "...", used for functions with variable arglists. */
266 /* the reserved words */
267 /* SCO include files test "ASM", so use something else. */
268 %token SIZEOF ENUM /* STRUCT UNION */ IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
269 %token BREAK CONTINUE RETURN_KEYWORD GOTO ASM_KEYWORD TYPEOF ALIGNOF
271 %token ATTRIBUTE EXTENSION LABEL
272 %token REALPART IMAGPART VA_ARG
274 /* the reserved words... C++ extensions */
276 %token <ttype> VISSPEC
277 %token DELETE NEW THIS OPERATOR CXX_TRUE CXX_FALSE
278 %token NAMESPACE TYPENAME_KEYWORD USING
279 %token LEFT_RIGHT TEMPLATE
280 %token TYPEID DYNAMIC_CAST STATIC_CAST REINTERPRET_CAST CONST_CAST
283 /* Define the operator tokens and their precedences.
284 The value is an integer because, if used, it is the tree code
285 to use in the expression made from the operator. */
287 %left EMPTY /* used to resolve s/r with epsilon */
291 /* Add precedence rules to solve dangling else s/r conflict */
295 %left IDENTIFIER PFUNCNAME TYPENAME SELFNAME PTYPENAME SCSPEC TYPESPEC CV_QUALIFIER ENUM AGGR ELLIPSIS TYPEOF SIGOF OPERATOR NSNAME TYPENAME_KEYWORD
301 %right <code> ASSIGN '='
309 %left <code> EQCOMPARE
310 %left <code> ARITHCOMPARE '<' '>'
311 %left <code> LSHIFT RSHIFT
313 %left <code> '*' '/' '%'
314 %left <code> POINTSAT_STAR DOT_STAR
315 %right <code> UNARY PLUSPLUS MINUSMINUS '~'
317 %left <ttype> LEFT_RIGHT
318 %left <code> POINTSAT '.' '(' '['
320 %right SCOPE /* C++ extension */
321 %nonassoc NEW DELETE TRY CATCH
325 %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist
326 %type <ttype> PFUNCNAME maybe_identifier
327 %type <ttype> paren_expr_or_null nontrivial_exprlist SELFNAME
328 %type <ttype> expr_no_commas cast_expr unary_expr primary string STRING
329 %type <ttype> reserved_declspecs boolean.literal
330 %type <ttype> reserved_typespecquals
331 %type <ttype> SCSPEC TYPESPEC CV_QUALIFIER maybe_cv_qualifier
332 %type <ttype> init initlist maybeasm maybe_init defarg defarg1
333 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
334 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
335 %type <ttype> any_word
337 %type <ttype> compstmt implicitly_scoped_stmt
339 %type <ttype> declarator notype_declarator after_type_declarator
340 %type <ttype> notype_declarator_intern absdcl_intern
341 %type <ttype> after_type_declarator_intern
342 %type <ttype> direct_notype_declarator direct_after_type_declarator
343 %type <itype> components notype_components
344 %type <ttype> component_decl component_decl_1
345 %type <ttype> component_declarator component_declarator0
346 %type <ttype> notype_component_declarator notype_component_declarator0
347 %type <ttype> after_type_component_declarator after_type_component_declarator0
348 %type <ttype> absdcl cv_qualifiers
349 %type <ttype> direct_abstract_declarator conversion_declarator
350 %type <ttype> new_declarator direct_new_declarator
351 %type <ttype> xexpr parmlist parms bad_parm
352 %type <ttype> identifiers_or_typenames
353 %type <ttype> fcast_or_absdcl regcast_or_absdcl
354 %type <ttype> expr_or_declarator expr_or_declarator_intern
355 %type <ttype> complex_notype_declarator
356 %type <ttype> notype_unqualified_id unqualified_id qualified_id
357 %type <ttype> template_id do_id object_template_id notype_template_declarator
358 %type <ttype> overqualified_id notype_qualified_id any_id
359 %type <ttype> complex_direct_notype_declarator functional_cast
360 %type <ttype> complex_parmlist parms_comma
361 %type <ttype> namespace_qualifier namespace_using_decl
363 %type <ftype> type_id new_type_id typed_typespecs typespec typed_declspecs
364 %type <ftype> typed_declspecs1 type_specifier_seq nonempty_cv_qualifiers
365 %type <ftype> structsp typespecqual_reserved parm named_parm full_parm
366 %type <ftype> declmods
368 %type <itype> extension
371 %token <ttype> PTYPENAME
372 %token <ttype> EXTERN_LANG_STRING ALL
373 %token <ttype> PRE_PARSED_CLASS_DECL DEFARG DEFARG_MARKER
374 %token <pi> PRE_PARSED_FUNCTION_DECL
375 %type <ttype> component_constructor_declarator
376 %type <ttype> fn.def2 return_id constructor_declarator
378 %type <itype> ctor_initializer_opt function_try_block
379 %type <ttype> named_class_head_sans_basetype
380 %type <ftype> class_head named_class_head
381 %type <ftype> named_complex_class_head_sans_basetype
382 %type <ttype> unnamed_class_head
383 %type <ttype> base_class_list
384 %type <ttype> base_class_access_list
385 %type <ttype> base_class maybe_base_class_list base_class.1
386 %type <ttype> exception_specification_opt ansi_raise_identifier ansi_raise_identifiers
387 %type <ttype> operator_name
388 %type <ttype> object aggr
389 %type <itype> new delete
390 /* %type <ttype> primary_no_id */
391 %type <ttype> maybe_parmlist
392 %type <itype> member_init_list
393 %type <ttype> template_header template_parm_list template_parm
394 %type <ttype> template_type_parm template_template_parm
395 %type <code> template_close_bracket
396 %type <ttype> apparent_template_type
397 %type <ttype> template_type template_arg_list template_arg_list_opt
398 %type <ttype> template_arg
399 %type <ttype> condition xcond paren_cond_or_null
400 %type <ttype> type_name nested_name_specifier nested_type ptr_to_mem
401 %type <ttype> complete_type_name notype_identifier nonnested_type
402 %type <ttype> complex_type_name nested_name_specifier_1
403 %type <ttype> new_initializer new_placement
404 %type <ttype> using_decl
405 %type <ttype> typename_sub typename_sub0 typename_sub1 typename_sub2
406 %type <ttype> explicit_template_type
407 /* in order to recognize aggr tags as defining and thus shadowing. */
408 %token TYPENAME_DEFN IDENTIFIER_DEFN PTYPENAME_DEFN
409 %type <ttype> named_class_head_sans_basetype_defn
410 %type <ttype> identifier_defn IDENTIFIER_DEFN TYPENAME_DEFN PTYPENAME_DEFN
411 %type <ttype> handler_args
412 %type <ttype> self_template_type .finish_template_type
417 /* Used in lex.c for parsing pragmas. */
420 /* lex.c and pt.c depend on this being the last token. Define
421 any new tokens before this one! */
422 %token END_OF_SAVED_INPUT
425 /* Tell yyparse how to print a token's value, if yydebug is set. */
426 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
427 extern void yyprint PARAMS ((FILE *, int, YYSTYPE));
434 { finish_translation_unit (); }
437 /* the reason for the strange actions in this rule
438 is so that notype_initdecls when reached via datadef
439 can find a valid list of type and sc specs in $0. */
442 { $<ttype>$ = NULL_TREE; }
444 { $<ttype>$ = NULL_TREE; ggc_collect (); }
445 | extdefs lang_extdef
446 { $<ttype>$ = NULL_TREE; ggc_collect (); }
455 { have_extern_spec = 1;
456 used_extern_spec = 0;
457 $<ttype>$ = NULL_TREE; }
460 { have_extern_spec = 0; }
474 { if (pending_lang_change) do_pending_lang_change();
475 type_lookups = NULL_TREE; }
477 { if (! toplevel_bindings_p ())
482 fndef eat_saved_input
483 { if (pending_inlines) do_pending_inlines (); }
485 { if (pending_inlines) do_pending_inlines (); }
487 { if (pending_inlines) do_pending_inlines (); }
488 | asm_keyword '(' string ')' ';'
489 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
491 | extern_lang_string '{' extdefs_opt '}'
492 { pop_lang_context (); }
493 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
494 { if (pending_inlines) do_pending_inlines ();
495 pop_lang_context (); }
496 | extern_lang_string .hush_warning datadef .warning_ok
497 { if (pending_inlines) do_pending_inlines ();
498 pop_lang_context (); }
499 | NAMESPACE identifier '{'
500 { push_namespace ($2); }
502 { pop_namespace (); }
504 { push_namespace (NULL_TREE); }
506 { pop_namespace (); }
509 { do_toplevel_using_decl ($1); }
516 NAMESPACE identifier '='
517 { begin_only_namespace_names (); }
520 end_only_namespace_names ();
523 do_namespace_alias ($2, $5);
530 | USING global_scope qualified_id
532 | USING global_scope unqualified_id
536 namespace_using_decl:
537 USING namespace_qualifier identifier
538 { $$ = build_parse_node (SCOPE_REF, $2, $3); }
539 | USING global_scope identifier
540 { $$ = build_parse_node (SCOPE_REF, global_namespace, $3); }
541 | USING global_scope namespace_qualifier identifier
542 { $$ = build_parse_node (SCOPE_REF, $3, $4); }
547 { begin_only_namespace_names (); }
550 end_only_namespace_names ();
551 /* If no declaration was found, the using-directive is
552 invalid. Since that was not reported, we need the
553 identifier for the error message. */
554 if (TREE_CODE ($4) == IDENTIFIER_NODE && lastiddecl)
556 do_using_directive ($4);
563 if (TREE_CODE ($$) == IDENTIFIER_NODE)
567 | namespace_qualifier NSNAME SCOPE
570 if (TREE_CODE ($$) == IDENTIFIER_NODE)
578 | global_scope qualified_id
580 | global_scope unqualified_id
586 { push_lang_context ($1); }
587 | extern_lang_string EXTERN_LANG_STRING
588 { if (current_lang_name != $2)
589 cp_error ("use of linkage spec `%D' is different from previous spec `%D'", $2, current_lang_name);
590 pop_lang_context (); push_lang_context ($2); }
595 { begin_template_parm_list (); }
596 template_parm_list '>'
597 { $$ = end_template_parm_list ($4); }
599 { begin_specialization();
605 { $$ = process_template_parm (NULL_TREE, $1); }
606 | template_parm_list ',' template_parm
607 { $$ = process_template_parm ($1, $3); }
617 aggr maybe_identifier
618 { $$ = finish_template_type_parm ($1, $2); }
619 | TYPENAME_KEYWORD maybe_identifier
620 { $$ = finish_template_type_parm (class_type_node, $2); }
623 template_template_parm:
624 template_header aggr maybe_identifier
625 { $$ = finish_template_template_parm ($2, $3); }
629 /* The following rules introduce a new reduce/reduce
630 conflict on the ',' and '>' input tokens: they are valid
631 prefixes for a `structsp', which means they could match a
632 nameless parameter. See 14.6, paragraph 3.
633 By putting them before the `parm' rule, we get
634 their match before considering them nameless parameter
637 { $$ = build_tree_list (NULL_TREE, $1); }
638 | template_type_parm '=' type_id
639 { $$ = build_tree_list (groktypename ($3.t), $1); }
641 { $$ = build_tree_list (NULL_TREE, $1.t); }
642 | parm '=' expr_no_commas %prec ARITHCOMPARE
643 { $$ = build_tree_list ($3, $1.t); }
644 | template_template_parm
645 { $$ = build_tree_list (NULL_TREE, $1); }
646 | template_template_parm '=' template_arg
648 if (TREE_CODE ($3) != TEMPLATE_DECL
649 && TREE_CODE ($3) != TEMPLATE_TEMPLATE_PARM
650 && TREE_CODE ($3) != TYPE_DECL)
652 error ("invalid default template argument");
653 $3 = error_mark_node;
655 $$ = build_tree_list ($3, $1);
660 template_header template_extdef
661 { finish_template_decl ($1); }
662 | template_header error %prec EMPTY
663 { finish_template_decl ($1); }
667 fndef eat_saved_input
668 { if (pending_inlines) do_pending_inlines (); }
670 { if (pending_inlines) do_pending_inlines (); }
672 { if (pending_inlines) do_pending_inlines (); }
673 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
674 { if (pending_inlines) do_pending_inlines ();
675 pop_lang_context (); }
676 | extern_lang_string .hush_warning template_datadef .warning_ok
677 { if (pending_inlines) do_pending_inlines ();
678 pop_lang_context (); }
679 | extension template_extdef
685 | declmods notype_initdecls ';'
687 | typed_declspecs initdecls ';'
688 { note_list_got_semicolon ($1.t); }
690 { maybe_process_partial_specialization ($1.t);
691 note_got_semicolon ($1.t); }
696 | declmods notype_initdecls ';'
698 | typed_declspecs initdecls ';'
699 { note_list_got_semicolon ($1.t); }
701 { pedwarn ("empty declaration"); }
702 | explicit_instantiation ';'
703 | typed_declspecs ';'
706 split_specs_attrs ($1.t, &t, &attrs);
708 note_list_got_semicolon ($1.t);
715 ctor_initializer_opt:
734 fn.def1 maybe_return_init ctor_initializer_opt compstmt_or_error
735 { expand_body (finish_function ((int)$3)); }
736 | fn.def1 maybe_return_init function_try_block
737 { expand_body (finish_function ((int)$3)); }
738 | fn.def1 maybe_return_init error
742 constructor_declarator:
743 nested_name_specifier SELFNAME '('
744 { $$ = begin_constructor_declarator ($1, $2); }
745 parmlist ')' cv_qualifiers exception_specification_opt
746 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
747 | nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
748 { $$ = begin_constructor_declarator ($1, $2);
749 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
751 | global_scope nested_name_specifier SELFNAME '('
752 { $$ = begin_constructor_declarator ($2, $3); }
753 parmlist ')' cv_qualifiers exception_specification_opt
754 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
755 | global_scope nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
756 { $$ = begin_constructor_declarator ($2, $3);
757 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
759 | nested_name_specifier self_template_type '('
760 { $$ = begin_constructor_declarator ($1, $2); }
761 parmlist ')' cv_qualifiers exception_specification_opt
762 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
763 | nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
764 { $$ = begin_constructor_declarator ($1, $2);
765 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
767 | global_scope nested_name_specifier self_template_type '('
768 { $$ = begin_constructor_declarator ($2, $3); }
769 parmlist ')' cv_qualifiers exception_specification_opt
770 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
771 | global_scope nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
772 { $$ = begin_constructor_declarator ($2, $3);
773 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
778 typed_declspecs declarator
779 { check_for_new_type ("return type", $1);
780 if (!begin_function_definition ($1.t, $2))
782 | declmods notype_declarator
783 { if (!begin_function_definition ($1.t, $2))
786 { if (!begin_function_definition (NULL_TREE, $1))
788 | declmods constructor_declarator
789 { if (!begin_function_definition ($1.t, $2))
791 | constructor_declarator
792 { if (!begin_function_definition (NULL_TREE, $1))
796 component_constructor_declarator:
797 SELFNAME '(' parmlist ')' cv_qualifiers exception_specification_opt
798 { $$ = make_call_declarator ($1, $3, $5, $6); }
799 | SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
800 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
801 | self_template_type '(' parmlist ')' cv_qualifiers exception_specification_opt
802 { $$ = make_call_declarator ($1, $3, $5, $6); }
803 | self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
804 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
807 /* more C++ complexity. See component_decl for a comment on the
808 reduce/reduce conflict introduced by these rules. */
810 declmods component_constructor_declarator
811 { $$ = parse_method ($2, $1.t, $1.lookups);
815 if (yychar == YYEMPTY)
817 reinit_parse_for_method (yychar, $$); }
818 | component_constructor_declarator
819 { $$ = parse_method ($1, NULL_TREE, NULL_TREE);
821 | typed_declspecs declarator
822 { $$ = parse_method ($2, $1.t, $1.lookups); goto rest_of_mdef;}
823 | declmods notype_declarator
824 { $$ = parse_method ($2, $1.t, $1.lookups); goto rest_of_mdef;}
826 { $$ = parse_method ($1, NULL_TREE, NULL_TREE);
828 | declmods constructor_declarator
829 { $$ = parse_method ($2, $1.t, $1.lookups); goto rest_of_mdef;}
830 | constructor_declarator
831 { $$ = parse_method ($1, NULL_TREE, NULL_TREE);
836 RETURN_KEYWORD IDENTIFIER
838 if (! current_function_parms_stored)
846 { finish_named_return_value ($<ttype>$, $2); }
847 | return_id '(' nonnull_exprlist ')'
848 { finish_named_return_value ($<ttype>$, $3); }
849 | return_id LEFT_RIGHT
850 { finish_named_return_value ($<ttype>$, NULL_TREE); }
854 ':' .set_base_init member_init_list
857 error ("no base initializers given following ':'");
865 if (! current_function_parms_stored)
868 if (DECL_CONSTRUCTOR_P (current_function_decl))
869 /* Make a contour for the initializer list. */
871 else if (current_class_type == NULL_TREE)
872 error ("base initializers not allowed for non-member functions");
873 else if (! DECL_CONSTRUCTOR_P (current_function_decl))
874 error ("only constructors take base initializers");
883 | member_init_list ',' member_init
884 | member_init_list error
888 '(' nonnull_exprlist ')'
890 if (current_class_name)
891 pedwarn ("anachronistic old style base class initializer");
892 expand_member_init (current_class_ref, NULL_TREE, $2);
896 if (current_class_name)
897 pedwarn ("anachronistic old style base class initializer");
898 expand_member_init (current_class_ref, NULL_TREE, void_type_node);
900 | notype_identifier '(' nonnull_exprlist ')'
901 { expand_member_init (current_class_ref, $1, $3); }
902 | notype_identifier LEFT_RIGHT
903 { expand_member_init (current_class_ref, $1, void_type_node); }
904 | nonnested_type '(' nonnull_exprlist ')'
905 { expand_member_init (current_class_ref, $1, $3); }
906 | nonnested_type LEFT_RIGHT
907 { expand_member_init (current_class_ref, $1, void_type_node); }
908 | typename_sub '(' nonnull_exprlist ')'
909 { expand_member_init (current_class_ref, TYPE_MAIN_DECL ($1),
911 | typename_sub LEFT_RIGHT
912 { expand_member_init (current_class_ref, TYPE_MAIN_DECL ($1),
937 explicit_instantiation:
938 TEMPLATE begin_explicit_instantiation typespec ';'
939 { do_type_instantiation ($3.t, NULL_TREE);
941 end_explicit_instantiation
942 | TEMPLATE begin_explicit_instantiation typed_declspecs declarator
943 { tree specs = strip_attrs ($3.t);
944 do_decl_instantiation (specs, $4, NULL_TREE); }
945 end_explicit_instantiation
946 | TEMPLATE begin_explicit_instantiation notype_declarator
947 { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
948 end_explicit_instantiation
949 | TEMPLATE begin_explicit_instantiation constructor_declarator
950 { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
951 end_explicit_instantiation
952 | SCSPEC TEMPLATE begin_explicit_instantiation typespec ';'
953 { do_type_instantiation ($4.t, $1);
955 end_explicit_instantiation
956 | SCSPEC TEMPLATE begin_explicit_instantiation typed_declspecs
958 { tree specs = strip_attrs ($4.t);
959 do_decl_instantiation (specs, $5, $1); }
960 end_explicit_instantiation
961 | SCSPEC TEMPLATE begin_explicit_instantiation notype_declarator
962 { do_decl_instantiation (NULL_TREE, $4, $1); }
963 end_explicit_instantiation
964 | SCSPEC TEMPLATE begin_explicit_instantiation constructor_declarator
965 { do_decl_instantiation (NULL_TREE, $4, $1); }
966 end_explicit_instantiation
969 begin_explicit_instantiation:
970 { begin_explicit_instantiation(); }
972 end_explicit_instantiation:
973 { end_explicit_instantiation(); }
975 /* The TYPENAME expansions are to deal with use of a template class name as
976 a template within the class itself, where the template decl is hidden by
977 a type decl. Got all that? */
980 PTYPENAME '<' template_arg_list_opt template_close_bracket
981 .finish_template_type
983 | TYPENAME '<' template_arg_list_opt template_close_bracket
984 .finish_template_type
989 apparent_template_type:
991 | identifier '<' template_arg_list_opt '>'
992 .finish_template_type
996 SELFNAME '<' template_arg_list_opt template_close_bracket
997 .finish_template_type
1001 .finish_template_type:
1003 if (yychar == YYEMPTY)
1006 $$ = finish_template_type ($<ttype>-3, $<ttype>-1,
1010 template_close_bracket:
1014 /* Handle `Class<Class<Type>>' without space in the `>>' */
1015 pedwarn ("`>>' should be `> >' in template class name");
1020 template_arg_list_opt:
1028 { $$ = build_tree_list (NULL_TREE, $$); }
1029 | template_arg_list ',' template_arg
1030 { $$ = chainon ($$, build_tree_list (NULL_TREE, $3)); }
1035 { $$ = groktypename ($1.t); }
1037 { $$ = lastiddecl; }
1038 | expr_no_commas %prec ARITHCOMPARE
1043 { $$ = NEGATE_EXPR; }
1045 { $$ = CONVERT_EXPR; }
1047 { $$ = PREINCREMENT_EXPR; }
1049 { $$ = PREDECREMENT_EXPR; }
1051 { $$ = TRUTH_NOT_EXPR; }
1056 { $$ = build_x_compound_expr ($$); }
1062 { error ("ISO C++ forbids an empty condition for `%s'",
1064 $$ = integer_zero_node; }
1071 { error ("ISO C++ forbids an empty condition for `%s'",
1073 $$ = integer_zero_node; }
1087 type_specifier_seq declarator maybeasm maybe_attribute '='
1090 for (d = getdecls (); d; d = TREE_CHAIN (d))
1091 if (TREE_CODE (d) == TYPE_DECL) {
1092 tree s = TREE_TYPE (d);
1093 if (TREE_CODE (s) == RECORD_TYPE)
1094 cp_error ("definition of class `%T' in condition", s);
1095 else if (TREE_CODE (s) == ENUMERAL_TYPE)
1096 cp_error ("definition of enum `%T' in condition", s);
1099 current_declspecs = $1.t;
1100 $<ttype>$ = parse_decl ($<ttype>2, $4, 1);
1104 parse_end_decl ($<ttype>6, $7, $4);
1105 $$ = convert_from_reference ($<ttype>6);
1106 if (TREE_CODE (TREE_TYPE ($$)) == ARRAY_TYPE)
1107 cp_error ("definition of array `%#D' in condition", $$);
1114 | maybe_label_decls stmts '}'
1115 | maybe_label_decls stmts error '}'
1116 | maybe_label_decls error '}'
1119 already_scoped_stmt:
1121 { $<ttype>$ = begin_compound_stmt (1); }
1123 { finish_compound_stmt (1, $<ttype>2); }
1128 nontrivial_exprlist:
1129 expr_no_commas ',' expr_no_commas
1130 { $$ = tree_cons (NULL_TREE, $$,
1131 build_tree_list (NULL_TREE, $3)); }
1132 | expr_no_commas ',' error
1133 { $$ = tree_cons (NULL_TREE, $$,
1134 build_tree_list (NULL_TREE, error_mark_node)); }
1135 | nontrivial_exprlist ',' expr_no_commas
1136 { chainon ($$, build_tree_list (NULL_TREE, $3)); }
1137 | nontrivial_exprlist ',' error
1138 { chainon ($$, build_tree_list (NULL_TREE, error_mark_node)); }
1143 { $$ = build_tree_list (NULL_TREE, $$); }
1144 | nontrivial_exprlist
1150 /* __extension__ turns off -pedantic for following primary. */
1151 | extension cast_expr %prec UNARY
1154 | '*' cast_expr %prec UNARY
1155 { $$ = build_x_indirect_ref ($2, "unary *"); }
1156 | '&' cast_expr %prec UNARY
1157 { $$ = build_x_unary_op (ADDR_EXPR, $2); }
1159 { $$ = build_x_unary_op (BIT_NOT_EXPR, $2); }
1160 | unop cast_expr %prec UNARY
1161 { $$ = finish_unary_op_expr ($1, $2); }
1162 /* Refer to the address of a label as a pointer. */
1165 pedwarn ("ISO C++ forbids `&&'");
1166 $$ = finish_label_address_expr ($2); }
1167 | SIZEOF unary_expr %prec UNARY
1168 { $$ = expr_sizeof ($2); }
1169 | SIZEOF '(' type_id ')' %prec HYPERUNARY
1170 { $$ = c_sizeof (groktypename ($3.t));
1171 check_for_new_type ("sizeof", $3); }
1172 | ALIGNOF unary_expr %prec UNARY
1173 { $$ = grok_alignof ($2); }
1174 | ALIGNOF '(' type_id ')' %prec HYPERUNARY
1175 { $$ = c_alignof (groktypename ($3.t));
1176 check_for_new_type ("alignof", $3); }
1178 /* The %prec EMPTY's here are required by the = init initializer
1179 syntax extension; see below. */
1180 | new new_type_id %prec EMPTY
1181 { $$ = build_new (NULL_TREE, $2.t, NULL_TREE, $1);
1182 check_for_new_type ("new", $2); }
1183 | new new_type_id new_initializer
1184 { $$ = build_new (NULL_TREE, $2.t, $3, $1);
1185 check_for_new_type ("new", $2); }
1186 | new new_placement new_type_id %prec EMPTY
1187 { $$ = build_new ($2, $3.t, NULL_TREE, $1);
1188 check_for_new_type ("new", $3); }
1189 | new new_placement new_type_id new_initializer
1190 { $$ = build_new ($2, $3.t, $4, $1);
1191 check_for_new_type ("new", $3); }
1192 | new '(' type_id ')'
1194 { $$ = build_new (NULL_TREE, groktypename($3.t),
1196 check_for_new_type ("new", $3); }
1197 | new '(' type_id ')' new_initializer
1198 { $$ = build_new (NULL_TREE, groktypename($3.t), $5, $1);
1199 check_for_new_type ("new", $3); }
1200 | new new_placement '(' type_id ')' %prec EMPTY
1201 { $$ = build_new ($2, groktypename($4.t), NULL_TREE, $1);
1202 check_for_new_type ("new", $4); }
1203 | new new_placement '(' type_id ')' new_initializer
1204 { $$ = build_new ($2, groktypename($4.t), $6, $1);
1205 check_for_new_type ("new", $4); }
1207 | delete cast_expr %prec UNARY
1208 { $$ = delete_sanity ($2, NULL_TREE, 0, $1); }
1209 | delete '[' ']' cast_expr %prec UNARY
1210 { $$ = delete_sanity ($4, NULL_TREE, 1, $1);
1211 if (yychar == YYEMPTY)
1213 | delete '[' expr ']' cast_expr %prec UNARY
1214 { $$ = delete_sanity ($5, $3, 2, $1);
1215 if (yychar == YYEMPTY)
1217 | REALPART cast_expr %prec UNARY
1218 { $$ = build_x_unary_op (REALPART_EXPR, $2); }
1219 | IMAGPART cast_expr %prec UNARY
1220 { $$ = build_x_unary_op (IMAGPART_EXPR, $2); }
1221 | VA_ARG '(' expr_no_commas ',' type_id ')'
1222 { $$ = build_x_va_arg ($3, groktypename ($5.t));
1223 check_for_new_type ("__builtin_va_arg", $5); }
1227 '(' nonnull_exprlist ')'
1229 | '{' nonnull_exprlist '}'
1230 { cp_pedwarn ("old style placement syntax, use () instead");
1235 '(' nonnull_exprlist ')'
1241 cp_error ("`%T' is not a valid expression", $2.t);
1242 $$ = error_mark_node;
1244 /* GNU extension so people can use initializer lists. Note that
1245 this alters the meaning of `new int = 1', which was previously
1246 syntactically valid but semantically invalid. */
1250 pedwarn ("ISO C++ forbids initialization of new expression with `='");
1251 if (TREE_CODE ($2) != TREE_LIST
1252 && TREE_CODE ($2) != CONSTRUCTOR)
1253 $$ = build_tree_list (NULL_TREE, $2);
1259 /* This is necessary to postpone reduction of `int ((int)(int)(int))'. */
1261 '(' type_id ')' %prec EMPTY
1262 { $2.t = finish_parmlist (build_tree_list (NULL_TREE, $2.t), 0);
1263 $$ = make_call_declarator (NULL_TREE, $2.t, NULL_TREE, NULL_TREE);
1264 check_for_new_type ("cast", $2); }
1265 | regcast_or_absdcl '(' type_id ')' %prec EMPTY
1266 { $3.t = finish_parmlist (build_tree_list (NULL_TREE, $3.t), 0);
1267 $$ = make_call_declarator ($$, $3.t, NULL_TREE, NULL_TREE);
1268 check_for_new_type ("cast", $3); }
1273 | regcast_or_absdcl unary_expr %prec UNARY
1274 { $$ = reparse_absdcl_as_casts ($$, $2); }
1275 | regcast_or_absdcl '{' initlist maybecomma '}' %prec UNARY
1277 tree init = build_nt (CONSTRUCTOR, NULL_TREE,
1280 pedwarn ("ISO C++ forbids constructor-expressions");
1281 /* Indicate that this was a GNU C constructor expression. */
1282 TREE_HAS_CONSTRUCTOR (init) = 1;
1284 $$ = reparse_absdcl_as_casts ($$, init);
1290 /* Handle general members. */
1291 | expr_no_commas POINTSAT_STAR expr_no_commas
1292 { $$ = build_x_binary_op (MEMBER_REF, $$, $3); }
1293 | expr_no_commas DOT_STAR expr_no_commas
1294 { $$ = build_m_component_ref ($$, $3); }
1295 | expr_no_commas '+' expr_no_commas
1296 { $$ = build_x_binary_op ($2, $$, $3); }
1297 | expr_no_commas '-' expr_no_commas
1298 { $$ = build_x_binary_op ($2, $$, $3); }
1299 | expr_no_commas '*' expr_no_commas
1300 { $$ = build_x_binary_op ($2, $$, $3); }
1301 | expr_no_commas '/' expr_no_commas
1302 { $$ = build_x_binary_op ($2, $$, $3); }
1303 | expr_no_commas '%' expr_no_commas
1304 { $$ = build_x_binary_op ($2, $$, $3); }
1305 | expr_no_commas LSHIFT expr_no_commas
1306 { $$ = build_x_binary_op ($2, $$, $3); }
1307 | expr_no_commas RSHIFT expr_no_commas
1308 { $$ = build_x_binary_op ($2, $$, $3); }
1309 | expr_no_commas ARITHCOMPARE expr_no_commas
1310 { $$ = build_x_binary_op ($2, $$, $3); }
1311 | expr_no_commas '<' expr_no_commas
1312 { $$ = build_x_binary_op (LT_EXPR, $$, $3); }
1313 | expr_no_commas '>' expr_no_commas
1314 { $$ = build_x_binary_op (GT_EXPR, $$, $3); }
1315 | expr_no_commas EQCOMPARE expr_no_commas
1316 { $$ = build_x_binary_op ($2, $$, $3); }
1317 | expr_no_commas MIN_MAX expr_no_commas
1318 { $$ = build_x_binary_op ($2, $$, $3); }
1319 | expr_no_commas '&' expr_no_commas
1320 { $$ = build_x_binary_op ($2, $$, $3); }
1321 | expr_no_commas '|' expr_no_commas
1322 { $$ = build_x_binary_op ($2, $$, $3); }
1323 | expr_no_commas '^' expr_no_commas
1324 { $$ = build_x_binary_op ($2, $$, $3); }
1325 | expr_no_commas ANDAND expr_no_commas
1326 { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $$, $3); }
1327 | expr_no_commas OROR expr_no_commas
1328 { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $$, $3); }
1329 | expr_no_commas '?' xexpr ':' expr_no_commas
1330 { $$ = build_x_conditional_expr ($$, $3, $5); }
1331 | expr_no_commas '=' expr_no_commas
1332 { $$ = build_x_modify_expr ($$, NOP_EXPR, $3);
1333 if ($$ != error_mark_node)
1334 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
1335 | expr_no_commas ASSIGN expr_no_commas
1336 { $$ = build_x_modify_expr ($$, $2, $3); }
1338 { $$ = build_throw (NULL_TREE); }
1339 | THROW expr_no_commas
1340 { $$ = build_throw ($2); }
1341 /* These extensions are not defined. The second arg to build_m_component_ref
1342 is old, build_m_component_ref now does an implicit
1343 build_indirect_ref (x, NULL_PTR) on the second argument.
1344 | object '&' expr_no_commas %prec UNARY
1345 { $$ = build_m_component_ref ($$, build_x_unary_op (ADDR_EXPR, $3)); }
1346 | object unop expr_no_commas %prec UNARY
1347 { $$ = build_m_component_ref ($$, build_x_unary_op ($2, $3)); }
1348 | object '(' type_id ')' expr_no_commas %prec UNARY
1349 { tree type = groktypename ($3.t);
1350 $$ = build_m_component_ref ($$, build_c_cast (type, $5)); }
1351 | object primary_no_id %prec UNARY
1352 { $$ = build_m_component_ref ($$, $2); }
1356 notype_unqualified_id:
1357 '~' see_typename identifier
1358 { $$ = build_parse_node (BIT_NOT_EXPR, $3); }
1359 | '~' see_typename template_type
1360 { $$ = build_parse_node (BIT_NOT_EXPR, $3); }
1365 | NSNAME %prec EMPTY
1370 /* If lastiddecl is a TREE_LIST, it's a baselink, which
1371 means that we're in an expression like S::f<int>, so
1372 don't do_identifier; we only do that for unqualified
1374 if (lastiddecl && TREE_CODE (lastiddecl) != TREE_LIST)
1375 $$ = do_identifier ($<ttype>-1, 1, NULL_TREE);
1381 PFUNCNAME '<' do_id template_arg_list_opt template_close_bracket
1382 { $$ = lookup_template_function ($3, $4); }
1383 | operator_name '<' do_id template_arg_list_opt template_close_bracket
1384 { $$ = lookup_template_function ($3, $4); }
1388 TEMPLATE identifier '<' template_arg_list_opt template_close_bracket
1389 { $$ = lookup_template_function ($2, $4); }
1390 | TEMPLATE PFUNCNAME '<' template_arg_list_opt template_close_bracket
1391 { $$ = lookup_template_function ($2, $4); }
1392 | TEMPLATE operator_name '<' template_arg_list_opt
1393 template_close_bracket
1394 { $$ = lookup_template_function ($2, $4); }
1398 notype_unqualified_id
1403 expr_or_declarator_intern:
1405 | attributes expr_or_declarator
1407 /* Provide support for '(' attributes '*' declarator ')'
1409 $$ = decl_tree_cons ($1, $2, NULL_TREE);
1414 notype_unqualified_id
1415 | '*' expr_or_declarator_intern %prec UNARY
1416 { $$ = build_parse_node (INDIRECT_REF, $2); }
1417 | '&' expr_or_declarator_intern %prec UNARY
1418 { $$ = build_parse_node (ADDR_EXPR, $2); }
1419 | '(' expr_or_declarator_intern ')'
1423 notype_template_declarator:
1424 IDENTIFIER '<' template_arg_list_opt template_close_bracket
1425 { $$ = lookup_template_function ($1, $3); }
1426 | NSNAME '<' template_arg_list template_close_bracket
1427 { $$ = lookup_template_function ($1, $3); }
1430 direct_notype_declarator:
1431 complex_direct_notype_declarator
1432 /* This precedence declaration is to prefer this reduce
1433 to the Koenig lookup shift in primary, below. I hate yacc. */
1434 | notype_unqualified_id %prec '('
1435 | notype_template_declarator
1436 | '(' expr_or_declarator_intern ')'
1437 { $$ = finish_decl_parsing ($2); }
1441 notype_unqualified_id
1443 if (TREE_CODE ($1) == BIT_NOT_EXPR)
1444 $$ = build_x_unary_op (BIT_NOT_EXPR, TREE_OPERAND ($1, 0));
1446 $$ = finish_id_expr ($1);
1452 $$ = combine_strings ($$);
1453 /* combine_strings doesn't set up TYPE_MAIN_VARIANT of
1454 a const array the way we want, so fix it. */
1455 if (flag_const_strings)
1456 TREE_TYPE ($$) = build_cplus_array_type
1457 (TREE_TYPE (TREE_TYPE ($$)),
1458 TYPE_DOMAIN (TREE_TYPE ($$)));
1461 { $$ = finish_parenthesized_expr ($2); }
1462 | '(' expr_or_declarator_intern ')'
1463 { $2 = reparse_decl_as_expr (NULL_TREE, $2);
1464 $$ = finish_parenthesized_expr ($2); }
1466 { $$ = error_mark_node; }
1468 { tree scope = current_scope ();
1469 if (!scope || TREE_CODE (scope) != FUNCTION_DECL)
1471 error ("braced-group within expression allowed only inside a function");
1475 pedwarn ("ISO C++ forbids braced-groups within expressions");
1476 $<ttype>$ = begin_stmt_expr ();
1479 { $$ = finish_stmt_expr ($<ttype>2); }
1480 /* Koenig lookup support
1481 We could store lastiddecl in $1 to avoid another lookup,
1482 but that would result in many additional reduce/reduce conflicts. */
1483 | notype_unqualified_id '(' nonnull_exprlist ')'
1484 { $$ = finish_call_expr ($1, $3, 1); }
1485 | notype_unqualified_id LEFT_RIGHT
1486 { $$ = finish_call_expr ($1, NULL_TREE, 1); }
1487 | primary '(' nonnull_exprlist ')'
1488 { $$ = finish_call_expr ($1, $3, 0); }
1489 | primary LEFT_RIGHT
1490 { $$ = finish_call_expr ($1, NULL_TREE, 0); }
1491 | primary '[' expr ']'
1492 { $$ = grok_array_decl ($$, $3); }
1494 { $$ = finish_increment_expr ($1, POSTINCREMENT_EXPR); }
1495 | primary MINUSMINUS
1496 { $$ = finish_increment_expr ($1, POSTDECREMENT_EXPR); }
1497 /* C++ extensions */
1499 { $$ = finish_this_expr (); }
1500 | CV_QUALIFIER '(' nonnull_exprlist ')'
1502 /* This is a C cast in C++'s `functional' notation
1503 using the "implicit int" extension so that:
1504 `const (3)' is equivalent to `const int (3)'. */
1507 type = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
1508 type = groktypename (build_decl_list (type, NULL_TREE));
1509 $$ = build_functional_cast (type, $3);
1512 | DYNAMIC_CAST '<' type_id '>' '(' expr ')'
1513 { tree type = groktypename ($3.t);
1514 check_for_new_type ("dynamic_cast", $3);
1515 $$ = build_dynamic_cast (type, $6); }
1516 | STATIC_CAST '<' type_id '>' '(' expr ')'
1517 { tree type = groktypename ($3.t);
1518 check_for_new_type ("static_cast", $3);
1519 $$ = build_static_cast (type, $6); }
1520 | REINTERPRET_CAST '<' type_id '>' '(' expr ')'
1521 { tree type = groktypename ($3.t);
1522 check_for_new_type ("reinterpret_cast", $3);
1523 $$ = build_reinterpret_cast (type, $6); }
1524 | CONST_CAST '<' type_id '>' '(' expr ')'
1525 { tree type = groktypename ($3.t);
1526 check_for_new_type ("const_cast", $3);
1527 $$ = build_const_cast (type, $6); }
1528 | TYPEID '(' expr ')'
1529 { $$ = build_typeid ($3); }
1530 | TYPEID '(' type_id ')'
1531 { tree type = groktypename ($3.t);
1532 check_for_new_type ("typeid", $3);
1533 $$ = get_typeid (TYPE_MAIN_VARIANT (type)); }
1534 | global_scope IDENTIFIER
1535 { $$ = do_scoped_id ($2, 1); }
1536 | global_scope template_id
1538 | global_scope operator_name
1540 got_scope = NULL_TREE;
1541 if (TREE_CODE ($2) == IDENTIFIER_NODE)
1542 $$ = do_scoped_id ($2, 1);
1546 | overqualified_id %prec HYPERUNARY
1547 { $$ = build_offset_ref (OP0 ($$), OP1 ($$)); }
1548 | overqualified_id '(' nonnull_exprlist ')'
1549 { $$ = finish_qualified_call_expr ($1, $3); }
1550 | overqualified_id LEFT_RIGHT
1551 { $$ = finish_qualified_call_expr ($1, NULL_TREE); }
1552 | object object_template_id %prec UNARY
1554 $$ = build_x_component_ref ($$, $2, NULL_TREE, 1);
1556 | object object_template_id '(' nonnull_exprlist ')'
1557 { $$ = finish_object_call_expr ($2, $1, $4); }
1558 | object object_template_id LEFT_RIGHT
1559 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1560 | object unqualified_id %prec UNARY
1561 { $$ = build_x_component_ref ($$, $2, NULL_TREE, 1); }
1562 | object overqualified_id %prec UNARY
1563 { if (processing_template_decl)
1564 $$ = build_min_nt (COMPONENT_REF, $1, $2);
1566 $$ = build_object_ref ($$, OP0 ($2), OP1 ($2)); }
1567 | object unqualified_id '(' nonnull_exprlist ')'
1568 { $$ = finish_object_call_expr ($2, $1, $4); }
1569 | object unqualified_id LEFT_RIGHT
1570 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1571 | object overqualified_id '(' nonnull_exprlist ')'
1572 { $$ = finish_qualified_object_call_expr ($2, $1, $4); }
1573 | object overqualified_id LEFT_RIGHT
1574 { $$ = finish_qualified_object_call_expr ($2, $1, NULL_TREE); }
1575 /* p->int::~int() is valid -- 12.4 */
1576 | object '~' TYPESPEC LEFT_RIGHT
1577 { $$ = finish_pseudo_destructor_call_expr ($1, NULL_TREE, $3); }
1578 | object TYPESPEC SCOPE '~' TYPESPEC LEFT_RIGHT
1579 { $$ = finish_pseudo_destructor_call_expr ($1, $2, $5); }
1582 $$ = error_mark_node;
1586 /* Not needed for now.
1592 { $$ = error_mark_node; }
1594 { if (current_function_decl == 0)
1596 error ("braced-group within expression allowed only inside a function");
1599 $<ttype>$ = expand_start_stmt_expr (); }
1602 pedwarn ("ISO C++ forbids braced-groups within expressions");
1603 $$ = expand_end_stmt_expr ($<ttype>2); }
1604 | primary_no_id '(' nonnull_exprlist ')'
1605 { $$ = build_x_function_call ($$, $3, current_class_ref); }
1606 | primary_no_id LEFT_RIGHT
1607 { $$ = build_x_function_call ($$, NULL_TREE, current_class_ref); }
1608 | primary_no_id '[' expr ']'
1610 | primary_no_id PLUSPLUS
1611 { $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); }
1612 | primary_no_id MINUSMINUS
1613 { $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); }
1615 { goto do_scoped_id; }
1616 | SCOPE operator_name
1617 { if (TREE_CODE ($2) == IDENTIFIER_NODE)
1619 goto do_scoped_operator;
1628 { got_scope = NULL_TREE; $$ = 1; }
1634 | global_scope delete
1635 { got_scope = NULL_TREE; $$ = 1; }
1640 { $$ = boolean_true_node; }
1642 { $$ = boolean_false_node; }
1645 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
1649 { $$ = chainon ($$, $2); }
1655 if (! current_function_parms_stored)
1656 store_parm_decls ();
1663 { got_object = TREE_TYPE ($$); }
1666 $$ = build_x_arrow ($$);
1667 got_object = TREE_TYPE ($$);
1672 typespec initdecls ';'
1674 if ($1.t && IS_AGGR_TYPE_CODE (TREE_CODE ($1.t)))
1675 note_got_semicolon ($1.t);
1677 | typed_declspecs initdecls ';'
1679 note_list_got_semicolon ($1.t);
1681 | declmods notype_initdecls ';'
1683 | typed_declspecs ';'
1686 note_list_got_semicolon ($1.t);
1689 { warning ("empty declaration"); }
1694 /* Any kind of declarator (thus, all declarators allowed
1695 after an explicit typespec). */
1698 after_type_declarator %prec EMPTY
1699 | notype_declarator %prec EMPTY
1702 /* This is necessary to postpone reduction of `int()()()()'. */
1704 LEFT_RIGHT %prec EMPTY
1705 { $$ = make_call_declarator (NULL_TREE, empty_parms (),
1706 NULL_TREE, NULL_TREE); }
1707 | fcast_or_absdcl LEFT_RIGHT %prec EMPTY
1708 { $$ = make_call_declarator ($$, empty_parms (), NULL_TREE,
1712 /* ISO type-id (8.1) */
1714 typed_typespecs absdcl
1715 { $$.t = build_decl_list ($1.t, $2);
1716 $$.new_type_flag = $1.new_type_flag; }
1717 | nonempty_cv_qualifiers absdcl
1718 { $$.t = build_decl_list ($1.t, $2);
1719 $$.new_type_flag = $1.new_type_flag; }
1721 { $$.t = build_decl_list (build_decl_list (NULL_TREE, $1.t),
1723 $$.new_type_flag = $1.new_type_flag; }
1724 | typed_typespecs %prec EMPTY
1725 { $$.t = build_decl_list ($1.t, NULL_TREE);
1726 $$.new_type_flag = $1.new_type_flag; }
1727 | nonempty_cv_qualifiers %prec EMPTY
1728 { $$.t = build_decl_list ($1.t, NULL_TREE);
1729 $$.new_type_flag = $1.new_type_flag; }
1732 /* Declspecs which contain at least one type specifier or typedef name.
1733 (Just `const' or `volatile' is not enough.)
1734 A typedef'd name following these is taken as a name to be declared.
1735 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1738 typed_typespecs %prec EMPTY
1739 { $$.lookups = type_lookups; }
1741 { $$.lookups = type_lookups; }
1746 { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1.t);
1747 $$.new_type_flag = $2.new_type_flag; }
1748 | typespec reserved_declspecs %prec HYPERUNARY
1749 { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2);
1750 $$.new_type_flag = $1.new_type_flag; }
1751 | typespec reserved_typespecquals reserved_declspecs
1752 { $$.t = decl_tree_cons (NULL_TREE, $1.t, chainon ($2, $3));
1753 $$.new_type_flag = $1.new_type_flag; }
1754 | declmods typespec reserved_declspecs
1755 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1756 $$.new_type_flag = $2.new_type_flag; }
1757 | declmods typespec reserved_typespecquals
1758 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1759 $$.new_type_flag = $2.new_type_flag; }
1760 | declmods typespec reserved_typespecquals reserved_declspecs
1761 { $$.t = decl_tree_cons (NULL_TREE, $2.t,
1762 chainon ($3, chainon ($4, $1.t)));
1763 $$.new_type_flag = $2.new_type_flag; }
1768 { if (extra_warnings)
1769 warning ("`%s' is not at beginning of declaration",
1770 IDENTIFIER_POINTER ($$));
1771 $$ = build_decl_list (NULL_TREE, $$); }
1772 | reserved_declspecs typespecqual_reserved
1773 { $$ = decl_tree_cons (NULL_TREE, $2.t, $$); }
1774 | reserved_declspecs SCSPEC
1775 { if (extra_warnings)
1776 warning ("`%s' is not at beginning of declaration",
1777 IDENTIFIER_POINTER ($2));
1778 $$ = decl_tree_cons (NULL_TREE, $2, $$); }
1779 | reserved_declspecs attributes
1780 { $$ = decl_tree_cons ($2, NULL_TREE, $1); }
1782 { $$ = decl_tree_cons ($1, NULL_TREE, NULL_TREE); }
1785 /* List of just storage classes and type modifiers.
1786 A declaration can start with just this, but then it cannot be used
1787 to redeclare a typedef-name.
1788 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1790 /* We use hash_tree_cons for lists of typeless declspecs so that they end
1791 up on a persistent obstack. Otherwise, they could appear at the
1792 beginning of something like
1794 static const struct { int foo () { } } b;
1796 and would be discarded after we finish compiling foo. We don't need to
1797 worry once we see a type. */
1800 nonempty_cv_qualifiers %prec EMPTY
1801 { $$.lookups = NULL_TREE; TREE_STATIC ($$.t) = 1; }
1804 $$.t = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
1805 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
1807 | declmods CV_QUALIFIER
1809 $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
1810 TREE_STATIC ($$.t) = 1;
1814 if (extra_warnings && TREE_STATIC ($$.t))
1815 warning ("`%s' is not at beginning of declaration",
1816 IDENTIFIER_POINTER ($2));
1817 $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
1818 TREE_STATIC ($$.t) = TREE_STATIC ($1.t);
1820 | declmods attributes
1821 { $$.t = hash_tree_cons ($2, NULL_TREE, $1.t); }
1822 | attributes %prec EMPTY
1824 $$.t = hash_tree_cons ($1, NULL_TREE, NULL_TREE);
1825 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
1829 /* Used instead of declspecs where storage classes are not allowed
1830 (that is, for typenames and structure components).
1832 C++ can takes storage classes for structure components.
1833 Don't accept a typedef-name if anything but a modifier precedes it. */
1836 typespec %prec EMPTY
1837 { $$.t = build_decl_list (NULL_TREE, $1.t);
1838 $$.new_type_flag = $1.new_type_flag; }
1839 | nonempty_cv_qualifiers typespec
1840 { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1.t);
1841 $$.new_type_flag = $2.new_type_flag; }
1842 | typespec reserved_typespecquals
1843 { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2);
1844 $$.new_type_flag = $1.new_type_flag; }
1845 | nonempty_cv_qualifiers typespec reserved_typespecquals
1846 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1847 $$.new_type_flag = $2.new_type_flag; }
1850 reserved_typespecquals:
1851 typespecqual_reserved
1852 { $$ = build_decl_list (NULL_TREE, $1.t); }
1853 | reserved_typespecquals typespecqual_reserved
1854 { $$ = decl_tree_cons (NULL_TREE, $2.t, $1); }
1857 /* A typespec (but not a type qualifier).
1858 Once we have seen one of these in a declaration,
1859 if a typedef name appears then it is being redeclared. */
1863 { $$.lookups = NULL_TREE; }
1864 | TYPESPEC %prec EMPTY
1865 { $$.t = $1; $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
1866 | complete_type_name
1867 { $$.t = $1; $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
1868 | TYPEOF '(' expr ')'
1869 { $$.t = finish_typeof ($3);
1870 $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
1871 | TYPEOF '(' type_id ')'
1872 { $$.t = groktypename ($3.t);
1873 $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
1874 | SIGOF '(' expr ')'
1875 { tree type = TREE_TYPE ($3);
1877 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
1878 if (IS_AGGR_TYPE (type))
1880 sorry ("sigof type specifier");
1885 error ("`sigof' applied to non-aggregate expression");
1886 $$.t = error_mark_node;
1889 | SIGOF '(' type_id ')'
1890 { tree type = groktypename ($3.t);
1892 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
1893 if (IS_AGGR_TYPE (type))
1895 sorry ("sigof type specifier");
1900 error("`sigof' applied to non-aggregate type");
1901 $$.t = error_mark_node;
1906 /* A typespec that is a reserved word, or a type qualifier. */
1908 typespecqual_reserved:
1910 { $$.t = $1; $$.new_type_flag = 0; }
1912 { $$.t = $1; $$.new_type_flag = 0; }
1918 | initdecls ',' initdcl
1919 { check_multiple_declarators (); }
1924 | notype_initdecls ',' initdcl
1925 { check_multiple_declarators (); }
1930 | nomods_initdecls ',' initdcl
1931 { check_multiple_declarators (); }
1937 | asm_keyword '(' string ')'
1938 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3); $$ = $3; }
1942 declarator maybeasm maybe_attribute '='
1943 { $<ttype>$ = parse_decl ($<ttype>1, $3, 1); }
1945 /* Note how the declaration of the variable is in effect while its init is parsed! */
1946 { parse_end_decl ($<ttype>5, $6, $2); }
1947 | declarator maybeasm maybe_attribute
1949 $<ttype>$ = parse_decl ($<ttype>1, $3, 0);
1950 parse_end_decl ($<ttype>$, NULL_TREE, $2);
1954 /* This rule assumes a certain configuration of the parser stack.
1955 In particular, $0, the element directly before the beginning of
1956 this rule on the stack, must be a maybeasm. $-1 must be a
1957 declarator or notype_declarator. And $-2 must be some declmods
1958 or declspecs. We can't move the maybeasm into this rule because
1959 we need that reduce so we prefer fn.def1 when appropriate. */
1962 { $<ttype>$ = parse_decl0 ($<ttype>-1, $<ftype>-2.t,
1963 $<ftype>-2.lookups, $1, 1); }
1964 /* Note how the declaration of the variable is in effect
1965 while its init is parsed! */
1967 { parse_end_decl ($<ttype>3, $4, $<ttype>0); }
1969 { tree d = parse_decl0 ($<ttype>-1, $<ftype>-2.t,
1970 $<ftype>-2.lookups, $1, 0);
1971 parse_end_decl (d, NULL_TREE, $<ttype>0); }
1975 declarator maybeasm initdcl0_innards
1980 notype_declarator maybeasm initdcl0_innards
1985 notype_declarator maybeasm
1986 { /* Set things up as initdcl0_innards expects. */
1991 | constructor_declarator maybeasm maybe_attribute
1992 { tree d = parse_decl0 ($1, NULL_TREE, NULL_TREE, $3, 0);
1993 parse_end_decl (d, NULL_TREE, $2); }
1996 /* the * rules are dummies to accept the Apollo extended syntax
1997 so that the header files compile. */
2008 | attributes attribute
2009 { $$ = chainon ($1, $2); }
2013 ATTRIBUTE '(' '(' attribute_list ')' ')'
2020 | attribute_list ',' attrib
2021 { $$ = chainon ($1, $3); }
2028 { $$ = build_tree_list ($1, NULL_TREE); }
2029 | any_word '(' IDENTIFIER ')'
2030 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
2031 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
2032 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
2033 | any_word '(' nonnull_exprlist ')'
2034 { $$ = build_tree_list ($1, $3); }
2037 /* This still leaves out most reserved keywords,
2038 shouldn't we include them? */
2047 /* A nonempty list of identifiers, including typenames. */
2048 identifiers_or_typenames:
2050 { $$ = build_tree_list (NULL_TREE, $1); }
2051 | identifiers_or_typenames ',' identifier
2052 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2056 /* empty */ %prec EMPTY
2061 /* If we are processing a template, we don't want to expand this
2065 expr_no_commas %prec '='
2067 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, NULL_TREE);
2068 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2070 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2071 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2072 | '{' initlist ',' '}'
2073 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2074 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2079 /* This chain is built in reverse order,
2080 and put in forward order where initlist is used. */
2083 { $$ = build_tree_list (NULL_TREE, $$); }
2085 { $$ = tree_cons (NULL_TREE, $3, $$); }
2086 /* These are for labeled elements. */
2087 | '[' expr_no_commas ']' init
2088 { $$ = build_tree_list ($2, $4); }
2089 | identifier ':' init
2090 { $$ = build_tree_list ($$, $3); }
2091 | initlist ',' identifier ':' init
2092 { $$ = tree_cons ($3, $5, $$); }
2096 PRE_PARSED_FUNCTION_DECL
2097 { start_function (NULL_TREE, $1->fndecl, NULL_TREE,
2098 (SF_DEFAULT | SF_PRE_PARSED
2099 | SF_INCLASS_INLINE));
2100 reinit_parse_for_function (); }
2103 fn.defpen maybe_return_init ctor_initializer_opt compstmt_or_error
2105 expand_body (finish_function ((int)$3 | 2));
2106 process_next_inline ($1);
2108 | fn.defpen maybe_return_init function_try_block
2110 expand_body (finish_function ((int)$3 | 2));
2111 process_next_inline ($1);
2113 | fn.defpen maybe_return_init error
2115 finish_function (2);
2116 process_next_inline ($1); }
2121 | pending_inlines pending_inline eat_saved_input
2124 /* A regurgitated default argument. The value of DEFARG_MARKER will be
2125 the TREE_LIST node for the parameter in question. */
2127 DEFARG_MARKER expr_no_commas END_OF_SAVED_INPUT
2128 { replace_defarg ($1, $2); }
2129 | DEFARG_MARKER error END_OF_SAVED_INPUT
2130 { replace_defarg ($1, error_mark_node); }
2133 /* empty */ %prec EMPTY
2134 | pending_defargs defarg_again
2135 { do_pending_defargs (); }
2136 | pending_defargs error
2137 { do_pending_defargs (); }
2142 { $<ttype>$ = current_enum_type;
2143 current_enum_type = start_enum ($2); }
2145 { $$.t = finish_enum (current_enum_type);
2146 $$.new_type_flag = 1;
2147 current_enum_type = $<ttype>4;
2148 check_for_missing_semicolon ($$.t); }
2150 { $<ttype>$ = current_enum_type;
2151 current_enum_type = start_enum (make_anon_name ()); }
2153 { $$.t = finish_enum (current_enum_type);
2154 $$.new_type_flag = 1;
2155 current_enum_type = $<ttype>3;
2156 check_for_missing_semicolon ($$.t); }
2158 { $$.t = xref_tag (enum_type_node, $2, 1);
2159 $$.new_type_flag = 0; }
2160 | ENUM complex_type_name
2161 { $$.t = xref_tag (enum_type_node, $2, 1);
2162 $$.new_type_flag = 0; }
2163 | TYPENAME_KEYWORD typename_sub
2165 $$.new_type_flag = 0;
2166 if (!processing_template_decl)
2167 cp_pedwarn ("using `typename' outside of template"); }
2168 /* C++ extensions, merged with C to avoid shift/reduce conflicts */
2170 { $1.t = begin_class_definition ($1.t); }
2171 opt.component_decl_list '}' maybe_attribute
2175 if (yychar == YYEMPTY)
2177 semi = yychar == ';';
2179 $<ttype>$ = finish_class_definition ($1.t, $6, semi,
2184 begin_inline_definitions ();
2188 finish_inline_definitions ();
2190 $$.new_type_flag = 1;
2192 | class_head %prec EMPTY
2194 if ($1.new_type_flag && $1.t != error_mark_node)
2195 pop_scope (CP_DECL_CONTEXT (TYPE_MAIN_DECL ($1.t)));
2196 $$.new_type_flag = 0;
2197 if ($1.t == error_mark_node)
2199 else if (TYPE_BINFO ($1.t) == NULL_TREE)
2201 cp_error ("%T is not a class type", $1.t);
2202 $$.t = error_mark_node;
2207 /* struct B: public A; is not accepted by the standard grammar. */
2208 if (CLASS_TYPE_P ($$.t)
2209 && TYPE_BINFO_BASETYPES ($$.t)
2210 && !COMPLETE_TYPE_P ($$.t)
2211 && ! TYPE_BEING_DEFINED ($$.t))
2212 cp_error ("base clause without member specification for `%#T'",
2226 { if (pedantic && !in_system_header)
2227 pedwarn ("comma at end of enumerator list"); }
2233 { error ("storage class specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2235 { error ("type specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2237 { error ("type qualifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2239 { error ("no body nor ';' separates two class, struct or union declarations"); }
2241 { $$ = build_decl_list ($2, $1); }
2244 named_class_head_sans_basetype:
2252 named_class_head_sans_basetype_defn:
2253 aggr identifier_defn %prec EMPTY
2254 { current_aggr = $$; $$ = $2; }
2255 | named_class_head_sans_basetype '{'
2256 { yyungetc ('{', 1); }
2257 | named_class_head_sans_basetype ':'
2258 { yyungetc (':', 1); }
2261 named_complex_class_head_sans_basetype:
2262 aggr nested_name_specifier identifier
2265 $$.t = handle_class_head ($1, $2, $3);
2266 $$.new_type_flag = 1;
2268 | aggr global_scope nested_name_specifier identifier
2271 $$.t = handle_class_head ($1, $3, $4);
2272 $$.new_type_flag = 1;
2274 | aggr global_scope identifier
2277 $$.t = handle_class_head ($1, NULL_TREE, $3);
2278 $$.new_type_flag = 1;
2280 | aggr apparent_template_type
2284 $$.new_type_flag = 0;
2286 | aggr nested_name_specifier apparent_template_type
2290 if (CP_DECL_CONTEXT ($$.t))
2291 push_scope (CP_DECL_CONTEXT ($$.t));
2292 $$.new_type_flag = 1;
2297 named_class_head_sans_basetype %prec EMPTY
2299 $$.t = xref_tag (current_aggr, $1, 1);
2300 $$.new_type_flag = 0;
2302 | named_class_head_sans_basetype_defn
2303 { $<ttype>$ = xref_tag (current_aggr, $1, 0); }
2304 /* Class name is unqualified, so we look for base classes
2305 in the current scope. */
2306 maybe_base_class_list %prec EMPTY
2309 $$.new_type_flag = 0;
2311 xref_basetypes (current_aggr, $1, $<ttype>2, $3);
2313 | named_complex_class_head_sans_basetype
2314 maybe_base_class_list
2316 if ($1.t != error_mark_node)
2318 $$.t = TREE_TYPE ($1.t);
2319 $$.new_type_flag = $1.new_type_flag;
2320 if (current_aggr == union_type_node
2321 && TREE_CODE ($$.t) != UNION_TYPE)
2322 cp_pedwarn ("`union' tag used in declaring `%#T'",
2324 else if (TREE_CODE ($$.t) == UNION_TYPE
2325 && current_aggr != union_type_node)
2326 cp_pedwarn ("non-`union' tag used in declaring `%#T'", $$);
2327 else if (TREE_CODE ($$.t) == RECORD_TYPE)
2328 /* We might be specializing a template with a different
2330 CLASSTYPE_DECLARED_CLASS ($$.t)
2331 = (current_aggr == class_type_node);
2334 maybe_process_partial_specialization ($$.t);
2335 xref_basetypes (current_aggr, $1.t, $$.t, $2);
2343 { $$ = xref_tag ($$, make_anon_name (), 0);
2344 yyungetc ('{', 1); }
2347 /* The tree output of this nonterminal a declarationf or the type
2348 named. If NEW_TYPE_FLAG is set, then the name used in this
2349 class-head was explicitly qualified, e.g.: `struct X::Y'. We have
2350 already called push_scope for X. */
2355 $$.new_type_flag = 0;
2360 maybe_base_class_list:
2361 /* empty */ %prec EMPTY
2363 | ':' see_typename %prec EMPTY
2364 { yyungetc(':', 1); $$ = NULL_TREE; }
2365 | ':' see_typename base_class_list %prec EMPTY
2371 | base_class_list ',' see_typename base_class
2372 { $$ = chainon ($$, $4); }
2377 { $$ = finish_base_specifier (access_default_node, $1); }
2378 | base_class_access_list see_typename base_class.1
2379 { $$ = finish_base_specifier ($1, $3); }
2384 { if ($$ == error_mark_node)
2386 else if (!TYPE_P ($$))
2387 $$ = error_mark_node;
2389 $$ = TYPE_MAIN_DECL ($1); }
2393 base_class_access_list:
2394 VISSPEC see_typename
2395 | SCSPEC see_typename
2396 { if ($1 != ridpointers[(int)RID_VIRTUAL])
2397 cp_error ("`%D' access", $1);
2398 $$ = access_default_virtual_node; }
2399 | base_class_access_list VISSPEC see_typename
2401 if ($1 != access_default_virtual_node)
2402 error ("multiple access specifiers");
2403 else if ($2 == access_public_node)
2404 $$ = access_public_virtual_node;
2405 else if ($2 == access_protected_node)
2406 $$ = access_protected_virtual_node;
2407 else /* $2 == access_private_node */
2408 $$ = access_private_virtual_node;
2410 | base_class_access_list SCSPEC see_typename
2411 { if ($2 != ridpointers[(int)RID_VIRTUAL])
2412 cp_error ("`%D' access", $2);
2413 else if ($$ == access_public_node)
2414 $$ = access_public_virtual_node;
2415 else if ($$ == access_protected_node)
2416 $$ = access_protected_virtual_node;
2417 else if ($$ == access_private_node)
2418 $$ = access_private_virtual_node;
2420 error ("multiple `virtual' specifiers");
2424 opt.component_decl_list:
2425 | component_decl_list
2426 | opt.component_decl_list access_specifier component_decl_list
2427 | opt.component_decl_list access_specifier
2433 current_access_specifier = $1;
2437 /* Note: we no longer warn about the semicolon after a component_decl_list.
2438 ARM $9.2 says that the semicolon is optional, and therefore allowed. */
2439 component_decl_list:
2442 finish_member_declaration ($1);
2444 | component_decl_list component_decl
2446 finish_member_declaration ($2);
2451 component_decl_1 ';'
2452 | component_decl_1 '}'
2453 { error ("missing ';' before right brace");
2454 yyungetc ('}', 0); }
2455 /* C++: handle constructors, destructors and inline functions */
2456 /* note that INLINE is like a TYPESPEC */
2457 | fn.def2 ':' /* base_init compstmt */
2458 { $$ = finish_method ($$); }
2459 | fn.def2 TRY /* base_init compstmt */
2460 { $$ = finish_method ($$); }
2461 | fn.def2 RETURN_KEYWORD /* base_init compstmt */
2462 { $$ = finish_method ($$); }
2463 | fn.def2 '{' /* nodecls compstmt */
2464 { $$ = finish_method ($$); }
2467 | extension component_decl
2470 | template_header component_decl
2473 $$ = finish_member_template_decl ($2);
2475 /* The component was already processed. */
2478 finish_template_decl ($1);
2480 | template_header typed_declspecs ';'
2482 $$ = finish_member_class_template ($2.t);
2483 finish_template_decl ($1);
2488 /* Do not add a "typed_declspecs declarator" rule here for
2489 speed; we need to call grok_x_components for enums, so the
2490 speedup would be insignificant. */
2491 typed_declspecs components
2493 /* Most of the productions for component_decl only
2494 allow the creation of one new member, so we call
2495 finish_member_declaration in component_decl_list.
2496 For this rule and the next, however, there can be
2497 more than one member, e.g.:
2501 and we need the first member to be fully
2502 registered before the second is processed.
2503 Therefore, the rules for components take care of
2504 this processing. To avoid registering the
2505 components more than once, we send NULL_TREE up
2506 here; that lets finish_member_declaration know
2507 that there is nothing to do. */
2509 grok_x_components ($1.t);
2512 | declmods notype_components
2515 grok_x_components ($1.t);
2518 | notype_declarator maybeasm maybe_attribute maybe_init
2519 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2520 build_tree_list ($3, NULL_TREE)); }
2521 | constructor_declarator maybeasm maybe_attribute maybe_init
2522 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2523 build_tree_list ($3, NULL_TREE)); }
2524 | ':' expr_no_commas
2525 { $$ = grokbitfield (NULL_TREE, NULL_TREE, $2); }
2529 /* These rules introduce a reduce/reduce conflict; in
2530 typedef int foo, bar;
2534 should "A::foo" be declared as a function or "A::bar" as a data
2535 member? In other words, is "bar" an after_type_declarator or a
2537 | declmods component_constructor_declarator maybeasm maybe_attribute maybe_init
2538 { tree specs, attrs;
2539 split_specs_attrs ($1.t, &specs, &attrs);
2540 $$ = grokfield ($2, specs, $5, $3,
2541 build_tree_list ($4, attrs)); }
2542 | component_constructor_declarator maybeasm maybe_attribute maybe_init
2543 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2544 build_tree_list ($3, NULL_TREE)); }
2546 { $$ = do_class_using_decl ($1); }
2548 /* The case of exactly one component is handled directly by component_decl. */
2551 /* empty: possibly anonymous */
2553 | component_declarator0
2555 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2556 $1 = finish_member_template_decl ($1);
2557 finish_member_declaration ($1);
2560 | components ',' component_declarator
2562 check_multiple_declarators ();
2563 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2564 $3 = finish_member_template_decl ($3);
2565 finish_member_declaration ($3);
2571 /* empty: possibly anonymous */
2573 | notype_component_declarator0
2575 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2576 $1 = finish_member_template_decl ($1);
2577 finish_member_declaration ($1);
2580 | notype_components ',' notype_component_declarator
2582 check_multiple_declarators ();
2583 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2584 $3 = finish_member_template_decl ($3);
2585 finish_member_declaration ($3);
2590 component_declarator0:
2591 after_type_component_declarator0
2592 | notype_component_declarator0
2595 component_declarator:
2596 after_type_component_declarator
2597 | notype_component_declarator
2600 after_type_component_declarator0:
2601 after_type_declarator maybeasm maybe_attribute maybe_init
2602 { $$ = parse_field0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2604 | TYPENAME ':' expr_no_commas maybe_attribute
2605 { $$ = parse_bitfield0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2609 notype_component_declarator0:
2610 notype_declarator maybeasm maybe_attribute maybe_init
2611 { $$ = parse_field0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2613 | constructor_declarator maybeasm maybe_attribute maybe_init
2614 { $$ = parse_field0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2616 | IDENTIFIER ':' expr_no_commas maybe_attribute
2617 { $$ = parse_bitfield0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2619 | ':' expr_no_commas maybe_attribute
2620 { $$ = parse_bitfield0 (NULL_TREE, $<ftype>0.t,
2621 $<ftype>0.lookups, $3, $2); }
2624 after_type_component_declarator:
2625 after_type_declarator maybeasm maybe_attribute maybe_init
2626 { $$ = parse_field ($1, $3, $2, $4); }
2627 | TYPENAME ':' expr_no_commas maybe_attribute
2628 { $$ = parse_bitfield ($1, $4, $3); }
2631 notype_component_declarator:
2632 notype_declarator maybeasm maybe_attribute maybe_init
2633 { $$ = parse_field ($1, $3, $2, $4); }
2634 | IDENTIFIER ':' expr_no_commas maybe_attribute
2635 { $$ = parse_bitfield ($1, $4, $3); }
2636 | ':' expr_no_commas maybe_attribute
2637 { $$ = parse_bitfield (NULL_TREE, $3, $2); }
2641 enumlist maybecomma_warn
2645 /* We chain the enumerators in reverse order.
2646 Because of the way enums are built, the order is
2647 insignificant. Take advantage of this fact. */
2651 | enumlist ',' enumerator
2656 { build_enumerator ($1, NULL_TREE, current_enum_type); }
2657 | identifier '=' expr_no_commas
2658 { build_enumerator ($1, $3, current_enum_type); }
2661 /* ISO new-type-id (5.3.4) */
2663 type_specifier_seq new_declarator
2664 { $$.t = build_decl_list ($1.t, $2);
2665 $$.new_type_flag = $1.new_type_flag; }
2666 | type_specifier_seq %prec EMPTY
2667 { $$.t = build_decl_list ($1.t, NULL_TREE);
2668 $$.new_type_flag = $1.new_type_flag; }
2669 /* GNU extension to allow arrays of arbitrary types with
2670 non-constant dimension. */
2671 | '(' type_id ')' '[' expr ']'
2674 pedwarn ("ISO C++ forbids array dimensions with parenthesized type in new");
2675 $$.t = build_parse_node (ARRAY_REF, TREE_VALUE ($2.t), $5);
2676 $$.t = build_decl_list (TREE_PURPOSE ($2.t), $$.t);
2677 $$.new_type_flag = $2.new_type_flag;
2682 /* empty */ %prec EMPTY
2684 | cv_qualifiers CV_QUALIFIER
2685 { $$ = decl_tree_cons (NULL_TREE, $2, $$); }
2688 nonempty_cv_qualifiers:
2690 { $$.t = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
2691 $$.new_type_flag = 0; }
2692 | nonempty_cv_qualifiers CV_QUALIFIER
2693 { $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
2694 $$.new_type_flag = $1.new_type_flag; }
2697 /* These rules must follow the rules for function declarations
2698 and component declarations. That way, longer rules are preferred. */
2700 /* An expression which will not live on the momentary obstack. */
2702 '(' nonnull_exprlist ')'
2707 { $$ = empty_parms (); }
2712 /* A declarator that is allowed only after an explicit typespec. */
2714 after_type_declarator_intern:
2715 after_type_declarator
2716 | attributes after_type_declarator
2718 /* Provide support for '(' attributes '*' declarator ')'
2720 $$ = decl_tree_cons ($1, $2, NULL_TREE);
2724 /* may all be followed by prec '.' */
2725 after_type_declarator:
2726 '*' nonempty_cv_qualifiers after_type_declarator_intern %prec UNARY
2727 { $$ = make_pointer_declarator ($2.t, $3); }
2728 | '&' nonempty_cv_qualifiers after_type_declarator_intern %prec UNARY
2729 { $$ = make_reference_declarator ($2.t, $3); }
2730 | '*' after_type_declarator_intern %prec UNARY
2731 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2732 | '&' after_type_declarator_intern %prec UNARY
2733 { $$ = make_reference_declarator (NULL_TREE, $2); }
2734 | ptr_to_mem cv_qualifiers after_type_declarator_intern
2735 { tree arg = make_pointer_declarator ($2, $3);
2736 $$ = build_parse_node (SCOPE_REF, $1, arg);
2738 | direct_after_type_declarator
2741 direct_after_type_declarator:
2742 direct_after_type_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2743 { $$ = make_call_declarator ($$, $2, $3, $4); }
2744 | direct_after_type_declarator '[' expr ']'
2745 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
2746 | direct_after_type_declarator '[' ']'
2747 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
2748 | '(' after_type_declarator_intern ')'
2750 | nested_name_specifier type_name %prec EMPTY
2751 { push_nested_class ($1, 3);
2752 $$ = build_parse_node (SCOPE_REF, $$, $2);
2753 TREE_COMPLEXITY ($$) = current_class_depth; }
2754 | type_name %prec EMPTY
2758 type_name %prec EMPTY
2760 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2762 $$ = lookup_name ($1, 1);
2763 maybe_note_name_used_in_class ($1, $$);
2768 | global_scope type_name
2770 if (TREE_CODE ($2) == IDENTIFIER_NODE)
2771 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
2774 got_scope = NULL_TREE;
2781 | global_scope nested_type
2786 nested_name_specifier type_name %prec EMPTY
2787 { $$ = get_type_decl ($2); }
2790 /* A declarator allowed whether or not there has been
2791 an explicit typespec. These cannot redeclare a typedef-name. */
2793 notype_declarator_intern:
2795 | attributes notype_declarator
2797 /* Provide support for '(' attributes '*' declarator ')'
2799 $$ = decl_tree_cons ($1, $2, NULL_TREE);
2804 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2805 { $$ = make_pointer_declarator ($2.t, $3); }
2806 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2807 { $$ = make_reference_declarator ($2.t, $3); }
2808 | '*' notype_declarator_intern %prec UNARY
2809 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2810 | '&' notype_declarator_intern %prec UNARY
2811 { $$ = make_reference_declarator (NULL_TREE, $2); }
2812 | ptr_to_mem cv_qualifiers notype_declarator_intern
2813 { tree arg = make_pointer_declarator ($2, $3);
2814 $$ = build_parse_node (SCOPE_REF, $1, arg);
2816 | direct_notype_declarator
2819 complex_notype_declarator:
2820 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2821 { $$ = make_pointer_declarator ($2.t, $3); }
2822 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2823 { $$ = make_reference_declarator ($2.t, $3); }
2824 | '*' complex_notype_declarator %prec UNARY
2825 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2826 | '&' complex_notype_declarator %prec UNARY
2827 { $$ = make_reference_declarator (NULL_TREE, $2); }
2828 | ptr_to_mem cv_qualifiers notype_declarator_intern
2829 { tree arg = make_pointer_declarator ($2, $3);
2830 $$ = build_parse_node (SCOPE_REF, $1, arg);
2832 | complex_direct_notype_declarator
2835 complex_direct_notype_declarator:
2836 direct_notype_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2837 { $$ = make_call_declarator ($$, $2, $3, $4); }
2838 | '(' complex_notype_declarator ')'
2840 | direct_notype_declarator '[' expr ']'
2841 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
2842 | direct_notype_declarator '[' ']'
2843 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
2844 | notype_qualified_id
2845 { enter_scope_of ($1); }
2846 | nested_name_specifier notype_template_declarator
2847 { got_scope = NULL_TREE;
2848 $$ = build_parse_node (SCOPE_REF, $1, $2);
2849 enter_scope_of ($$);
2854 nested_name_specifier unqualified_id
2855 { got_scope = NULL_TREE;
2856 $$ = build_parse_node (SCOPE_REF, $$, $2); }
2857 | nested_name_specifier object_template_id
2858 { got_scope = NULL_TREE;
2859 $$ = build_parse_node (SCOPE_REF, $1, $2); }
2862 notype_qualified_id:
2863 nested_name_specifier notype_unqualified_id
2864 { got_scope = NULL_TREE;
2865 $$ = build_parse_node (SCOPE_REF, $$, $2); }
2866 | nested_name_specifier object_template_id
2867 { got_scope = NULL_TREE;
2868 $$ = build_parse_node (SCOPE_REF, $1, $2); }
2873 | global_scope notype_qualified_id
2878 typespec '(' nonnull_exprlist ')'
2879 { $$ = build_functional_cast ($1.t, $3); }
2880 | typespec '(' expr_or_declarator_intern ')'
2881 { $$ = reparse_decl_as_expr ($1.t, $3); }
2882 | typespec fcast_or_absdcl %prec EMPTY
2883 { $$ = reparse_absdcl_as_expr ($1.t, $2); }
2889 | template_type %prec EMPTY
2892 nested_name_specifier:
2893 nested_name_specifier_1
2894 | nested_name_specifier nested_name_specifier_1
2896 | nested_name_specifier TEMPLATE explicit_template_type SCOPE
2898 = make_typename_type ($1, $3, /*complain=*/1); }
2901 /* Why the @#$%^& do type_name and notype_identifier need to be expanded
2902 inline here?!? (jason) */
2903 nested_name_specifier_1:
2906 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2909 maybe_note_name_used_in_class ($1, $$);
2912 complete_type (TYPE_MAIN_VARIANT (TREE_TYPE ($$)));
2916 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2918 got_scope = $$ = TREE_TYPE ($$);
2922 if (TREE_CODE ($$) == IDENTIFIER_NODE)
2926 | template_type SCOPE
2927 { got_scope = $$ = complete_type (TREE_TYPE ($1)); }
2928 /* These break 'const i;'
2932 cp_error ("`%D' is not an aggregate typedef",
2933 lastiddecl ? lastiddecl : $$);
2934 $$ = error_mark_node;
2937 { goto failed_scope; } */
2942 | global_scope typename_sub0
2947 typename_sub1 identifier %prec EMPTY
2950 $$ = make_typename_type ($1, $2, /*complain=*/1);
2951 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
2952 cp_error ("`%T' is not a class or namespace", $2);
2956 if (TREE_CODE ($$) == TYPE_DECL)
2957 $$ = TREE_TYPE ($$);
2960 | typename_sub1 template_type %prec EMPTY
2961 { $$ = TREE_TYPE ($2); }
2962 | typename_sub1 explicit_template_type %prec EMPTY
2963 { $$ = make_typename_type ($1, $2, /*complain=*/1); }
2964 | typename_sub1 TEMPLATE explicit_template_type %prec EMPTY
2965 { $$ = make_typename_type ($1, $3, /*complain=*/1); }
2971 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2972 cp_error ("`%T' is not a class or namespace", $1);
2974 | typename_sub1 typename_sub2
2977 $$ = make_typename_type ($1, $2, /*complain=*/1);
2978 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
2979 cp_error ("`%T' is not a class or namespace", $2);
2983 if (TREE_CODE ($$) == TYPE_DECL)
2984 $$ = TREE_TYPE ($$);
2987 | typename_sub1 explicit_template_type SCOPE
2989 = make_typename_type ($1, $2, /*complain=*/1); }
2990 | typename_sub1 TEMPLATE explicit_template_type SCOPE
2992 = make_typename_type ($1, $3, /*complain=*/1); }
2998 if (TREE_CODE ($1) != IDENTIFIER_NODE)
3001 /* Retrieve the type for the identifier, which might involve
3002 some computation. */
3003 got_scope = $$ = complete_type (IDENTIFIER_TYPE_VALUE ($1));
3005 if ($$ == error_mark_node)
3006 cp_error ("`%T' is not a class or namespace", $1);
3010 if (TREE_CODE ($1) != IDENTIFIER_NODE)
3012 got_scope = $$ = complete_type (TREE_TYPE ($$));
3014 | template_type SCOPE
3015 { got_scope = $$ = complete_type (TREE_TYPE ($$)); }
3020 if (TREE_CODE ($$) == IDENTIFIER_NODE)
3026 explicit_template_type:
3027 identifier '<' template_arg_list_opt template_close_bracket
3028 { $$ = build_min_nt (TEMPLATE_ID_EXPR, $1, $3); }
3032 global_scope type_name
3034 if (TREE_CODE ($2) == IDENTIFIER_NODE)
3035 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
3038 got_scope = NULL_TREE;
3041 | global_scope nested_type
3046 nested_name_specifier '*'
3047 { got_scope = NULL_TREE; }
3048 | global_scope nested_name_specifier '*'
3049 { $$ = $2; got_scope = NULL_TREE; }
3052 /* All uses of explicit global scope must go through this nonterminal so
3053 that got_scope will be set before yylex is called to get the next token. */
3056 { got_scope = void_type_node; }
3059 /* ISO new-declarator (5.3.4) */
3061 '*' cv_qualifiers new_declarator
3062 { $$ = make_pointer_declarator ($2, $3); }
3063 | '*' cv_qualifiers %prec EMPTY
3064 { $$ = make_pointer_declarator ($2, NULL_TREE); }
3065 | '&' cv_qualifiers new_declarator %prec EMPTY
3066 { $$ = make_reference_declarator ($2, $3); }
3067 | '&' cv_qualifiers %prec EMPTY
3068 { $$ = make_reference_declarator ($2, NULL_TREE); }
3069 | ptr_to_mem cv_qualifiers %prec EMPTY
3070 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3071 $$ = build_parse_node (SCOPE_REF, $1, arg);
3073 | ptr_to_mem cv_qualifiers new_declarator
3074 { tree arg = make_pointer_declarator ($2, $3);
3075 $$ = build_parse_node (SCOPE_REF, $1, arg);
3077 | direct_new_declarator %prec EMPTY
3080 /* ISO direct-new-declarator (5.3.4) */
3081 direct_new_declarator:
3083 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3084 | direct_new_declarator '[' expr ']'
3085 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3092 /* Provide support for '(' attributes '*' declarator ')'
3094 $$ = decl_tree_cons ($1, $2, NULL_TREE);
3098 /* ISO abstract-declarator (8.1) */
3100 '*' nonempty_cv_qualifiers absdcl_intern
3101 { $$ = make_pointer_declarator ($2.t, $3); }
3103 { $$ = make_pointer_declarator (NULL_TREE, $2); }
3104 | '*' nonempty_cv_qualifiers %prec EMPTY
3105 { $$ = make_pointer_declarator ($2.t, NULL_TREE); }
3107 { $$ = make_pointer_declarator (NULL_TREE, NULL_TREE); }
3108 | '&' nonempty_cv_qualifiers absdcl_intern
3109 { $$ = make_reference_declarator ($2.t, $3); }
3111 { $$ = make_reference_declarator (NULL_TREE, $2); }
3112 | '&' nonempty_cv_qualifiers %prec EMPTY
3113 { $$ = make_reference_declarator ($2.t, NULL_TREE); }
3115 { $$ = make_reference_declarator (NULL_TREE, NULL_TREE); }
3116 | ptr_to_mem cv_qualifiers %prec EMPTY
3117 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3118 $$ = build_parse_node (SCOPE_REF, $1, arg);
3120 | ptr_to_mem cv_qualifiers absdcl_intern
3121 { tree arg = make_pointer_declarator ($2, $3);
3122 $$ = build_parse_node (SCOPE_REF, $1, arg);
3124 | direct_abstract_declarator %prec EMPTY
3127 /* ISO direct-abstract-declarator (8.1) */
3128 direct_abstract_declarator:
3129 '(' absdcl_intern ')'
3131 /* `(typedef)1' is `int'. */
3132 | direct_abstract_declarator '(' parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3133 { $$ = make_call_declarator ($$, $3, $5, $6); }
3134 | direct_abstract_declarator LEFT_RIGHT cv_qualifiers exception_specification_opt %prec '.'
3135 { $$ = make_call_declarator ($$, empty_parms (), $3, $4); }
3136 | direct_abstract_declarator '[' expr ']' %prec '.'
3137 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3138 | direct_abstract_declarator '[' ']' %prec '.'
3139 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
3140 | '(' complex_parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3141 { $$ = make_call_declarator (NULL_TREE, $2, $4, $5); }
3142 | regcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3143 { set_quals_and_spec ($$, $2, $3); }
3144 | fcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3145 { set_quals_and_spec ($$, $2, $3); }
3146 | '[' expr ']' %prec '.'
3147 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3149 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, NULL_TREE); }
3152 /* For C++, decls and stmts can be intermixed, so we don't need to
3153 have a special rule that won't start parsing the stmt section
3154 until we have a stmt that parses without errors. */
3167 /* Read zero or more forward-declarations for labels
3168 that nested functions can jump to. */
3173 pedwarn ("ISO C++ forbids label declarations"); }
3178 | label_decls label_decl
3182 LABEL identifiers_or_typenames ';'
3186 finish_label_decl (TREE_VALUE ($2));
3187 $2 = TREE_CHAIN ($2);
3192 /* This is the body of a function definition.
3193 It causes syntax errors to ignore to the next openbrace. */
3202 { $<ttype>$ = begin_compound_stmt (0); }
3204 { $$ = finish_compound_stmt (0, $<ttype>2); }
3210 $<ttype>$ = begin_if_stmt ();
3211 cond_stmt_keyword = "if";
3214 { finish_if_stmt_cond ($3, $<ttype>2); }
3215 implicitly_scoped_stmt
3216 { $<ttype>$ = finish_then_clause ($<ttype>2); }
3219 implicitly_scoped_stmt:
3221 | { $<ttype>$ = begin_compound_stmt (0); }
3223 { $$ = finish_compound_stmt (0, $<ttype>1); }
3236 { finish_expr_stmt ($1); }
3238 { begin_else_clause (); }
3239 implicitly_scoped_stmt
3241 finish_else_clause ($<ttype>1);
3244 | simple_if %prec IF
3245 { finish_if_stmt (); }
3248 $<ttype>$ = begin_while_stmt ();
3249 cond_stmt_keyword = "while";
3252 { finish_while_stmt_cond ($3, $<ttype>2); }
3254 { finish_while_stmt ($<ttype>2); }
3256 { $<ttype>$ = begin_do_stmt (); }
3257 implicitly_scoped_stmt WHILE
3259 finish_do_body ($<ttype>2);
3260 cond_stmt_keyword = "do";
3262 paren_expr_or_null ';'
3263 { finish_do_stmt ($6, $<ttype>2); }
3265 { $<ttype>$ = begin_for_stmt (); }
3266 '(' for.init.statement
3267 { finish_for_init_stmt ($<ttype>2); }
3269 { finish_for_cond ($6, $<ttype>2); }
3271 { finish_for_expr ($9, $<ttype>2); }
3273 { finish_for_stmt ($9, $<ttype>2); }
3275 { $<ttype>$ = begin_switch_stmt (); }
3277 { finish_switch_cond ($4, $<ttype>2); }
3278 implicitly_scoped_stmt
3279 { finish_switch_stmt ($4, $<ttype>2); }
3280 | CASE expr_no_commas ':'
3281 { finish_case_label ($2, NULL_TREE); }
3283 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
3284 { finish_case_label ($2, $4); }
3287 { finish_case_label (NULL_TREE, NULL_TREE); }
3290 { finish_break_stmt (); }
3292 { finish_continue_stmt (); }
3293 | RETURN_KEYWORD ';'
3294 { finish_return_stmt (NULL_TREE); }
3295 | RETURN_KEYWORD expr ';'
3296 { finish_return_stmt ($2); }
3297 | asm_keyword maybe_cv_qualifier '(' string ')' ';'
3299 finish_asm_stmt ($2, $4, NULL_TREE, NULL_TREE,
3302 /* This is the case with just output operands. */
3303 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ')' ';'
3305 finish_asm_stmt ($2, $4, $6, NULL_TREE,
3308 /* This is the case with input operands as well. */
3309 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':' asm_operands ')' ';'
3310 { finish_asm_stmt ($2, $4, $6, $8, NULL_TREE); }
3311 | asm_keyword maybe_cv_qualifier '(' string SCOPE asm_operands ')' ';'
3312 { finish_asm_stmt ($2, $4, NULL_TREE, $6, NULL_TREE); }
3313 /* This is the case with clobbered registers as well. */
3314 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':'
3315 asm_operands ':' asm_clobbers ')' ';'
3316 { finish_asm_stmt ($2, $4, $6, $8, $10); }
3317 | asm_keyword maybe_cv_qualifier '(' string SCOPE asm_operands ':'
3318 asm_clobbers ')' ';'
3319 { finish_asm_stmt ($2, $4, NULL_TREE, $6, $8); }
3320 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands SCOPE
3321 asm_clobbers ')' ';'
3322 { finish_asm_stmt ($2, $4, $6, NULL_TREE, $8); }
3326 pedwarn ("ISO C++ forbids computed gotos");
3327 finish_goto_stmt ($3);
3329 | GOTO identifier ';'
3330 { finish_goto_stmt ($2); }
3333 { error ("label must be followed by statement");
3334 yyungetc ('}', 0); }
3339 | namespace_using_decl
3340 { do_local_using_decl ($1); }
3346 { $<ttype>$ = begin_function_try_block (); }
3347 ctor_initializer_opt compstmt
3348 { finish_function_try_block ($<ttype>2); }
3351 finish_function_handler_sequence ($<ttype>2);
3358 { $<ttype>$ = begin_try_block (); }
3360 { finish_try_block ($<ttype>2); }
3362 { finish_handler_sequence ($<ttype>2); }
3367 | handler_seq handler
3372 { $<ttype>$ = begin_handler(); }
3374 { $<ttype>$ = finish_handler_parms ($3, $<ttype>2); }
3376 { finish_handler ($<ttype>4, $<ttype>2); }
3380 typed_typespecs %prec EMPTY
3381 | nonempty_cv_qualifiers %prec EMPTY
3387 /* This doesn't allow reference parameters, the below does.
3388 | '(' type_specifier_seq absdcl ')'
3389 { check_for_new_type ("inside exception declarations", $2);
3390 expand_start_catch_block ($2.t, $3); }
3391 | '(' type_specifier_seq ')'
3392 { check_for_new_type ("inside exception declarations", $2);
3393 expand_start_catch_block ($2.t, NULL_TREE); }
3394 | '(' type_specifier_seq notype_declarator ')'
3395 { check_for_new_type ("inside exception declarations", $2);
3396 expand_start_catch_block ($2.t, $3); }
3397 | '(' typed_typespecs after_type_declarator ')'
3398 { check_for_new_type ("inside exception declarations", $2);
3399 expand_start_catch_block ($2.t, $3); }
3400 This allows reference parameters... */
3403 check_for_new_type ("inside exception declarations", $2);
3404 $$ = start_handler_parms (TREE_PURPOSE ($2.t),
3411 { finish_label_stmt ($1); }
3413 { finish_label_stmt ($1); }
3415 { finish_label_stmt ($1); }
3417 { finish_label_stmt ($1); }
3422 { finish_expr_stmt ($1); }
3426 pedwarn ("ISO C++ forbids compound statements inside for initializations");
3430 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
3446 /* These are the operands other than the first string and colon
3447 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
3451 | nonnull_asm_operands
3454 nonnull_asm_operands:
3456 | nonnull_asm_operands ',' asm_operand
3457 { $$ = chainon ($$, $3); }
3462 { $$ = build_tree_list ($$, $3); }
3467 { $$ = tree_cons (NULL_TREE, $$, NULL_TREE); }
3468 | asm_clobbers ',' STRING
3469 { $$ = tree_cons (NULL_TREE, $3, $$); }
3472 /* This is what appears inside the parens in a function declarator.
3473 Its value is represented in the format that grokdeclarator expects.
3475 In C++, declaring a function with no parameters
3476 means that that function takes *no* parameters. */
3485 { $$ = finish_parmlist (build_tree_list (NULL_TREE, $1.t), 0);
3486 check_for_new_type ("inside parameter list", $1); }
3489 /* This nonterminal does not include the common sequence '(' type_id ')',
3490 as it is ambiguous and must be disambiguated elsewhere. */
3493 { $$ = finish_parmlist ($$, 0); }
3494 | parms_comma ELLIPSIS
3495 { $$ = finish_parmlist ($1, 1); }
3496 /* C++ allows an ellipsis without a separating ',' */
3498 { $$ = finish_parmlist ($1, 1); }
3500 { $$ = finish_parmlist (build_tree_list (NULL_TREE,
3503 { $$ = finish_parmlist (NULL_TREE, 1); }
3506 /* This helps us recover from really nasty
3507 parse errors, for example, a missing right
3509 yyerror ("possibly missing ')'");
3510 $$ = finish_parmlist ($1, 0);
3516 /* This helps us recover from really nasty
3517 parse errors, for example, a missing right
3519 yyerror ("possibly missing ')'");
3520 $$ = finish_parmlist (build_tree_list (NULL_TREE,
3527 /* A default argument to a */
3530 { maybe_snarf_defarg (); }
3540 /* A nonempty list of parameter declarations or type names. */
3543 { check_for_new_type ("in a parameter list", $1);
3544 $$ = build_tree_list (NULL_TREE, $1.t); }
3546 { check_for_new_type ("in a parameter list", $1);
3547 $$ = build_tree_list ($2, $1.t); }
3548 | parms_comma full_parm
3549 { check_for_new_type ("in a parameter list", $2);
3550 $$ = chainon ($$, $2.t); }
3551 | parms_comma bad_parm
3552 { $$ = chainon ($$, build_tree_list (NULL_TREE, $2)); }
3553 | parms_comma bad_parm '=' init
3554 { $$ = chainon ($$, build_tree_list ($4, $2)); }
3560 { check_for_new_type ("in a parameter list", $1);
3561 $$ = build_tree_list (NULL_TREE, $1.t); }
3564 /* A single parameter declaration or parameter type name,
3565 as found in a parmlist. */
3567 /* Here we expand typed_declspecs inline to avoid mis-parsing of
3568 TYPESPEC IDENTIFIER. */
3569 typed_declspecs1 declarator
3570 { tree specs = strip_attrs ($1.t);
3571 $$.new_type_flag = $1.new_type_flag;
3572 $$.t = build_tree_list (specs, $2); }
3573 | typed_typespecs declarator
3574 { $$.t = build_tree_list ($1.t, $2);
3575 $$.new_type_flag = $1.new_type_flag; }
3576 | typespec declarator
3577 { $$.t = build_tree_list (build_decl_list (NULL_TREE, $1.t),
3579 $$.new_type_flag = $1.new_type_flag; }
3580 | typed_declspecs1 absdcl
3581 { tree specs = strip_attrs ($1.t);
3582 $$.t = build_tree_list (specs, $2);
3583 $$.new_type_flag = $1.new_type_flag; }
3584 | typed_declspecs1 %prec EMPTY
3585 { tree specs = strip_attrs ($1.t);
3586 $$.t = build_tree_list (specs, NULL_TREE);
3587 $$.new_type_flag = $1.new_type_flag; }
3588 | declmods notype_declarator
3589 { tree specs = strip_attrs ($1.t);
3590 $$.t = build_tree_list (specs, $2);
3591 $$.new_type_flag = 0; }
3596 { $$.t = build_tree_list (NULL_TREE, $1.t);
3597 $$.new_type_flag = $1.new_type_flag; }
3599 { $$.t = build_tree_list ($2, $1.t);
3600 $$.new_type_flag = $1.new_type_flag; }
3609 /* empty */ %prec EMPTY
3610 { see_typename (); }
3614 /* empty */ %prec EMPTY
3616 error ("type specifier omitted for parameter");
3617 $$ = build_tree_list (integer_type_node, NULL_TREE);
3621 error ("type specifier omitted for parameter");
3622 if (TREE_CODE ($$) == SCOPE_REF
3623 && (TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TYPE_PARM
3624 || TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TEMPLATE_PARM))
3625 cp_error (" perhaps you want `typename %E' to make it a type", $$);
3626 $$ = build_tree_list (integer_type_node, $$);
3630 exception_specification_opt:
3631 /* empty */ %prec EMPTY
3633 | THROW '(' ansi_raise_identifiers ')' %prec EMPTY
3635 | THROW LEFT_RIGHT %prec EMPTY
3636 { $$ = empty_except_spec; }
3639 ansi_raise_identifier:
3642 check_for_new_type ("exception specifier", $1);
3643 $$ = groktypename ($1.t);
3647 ansi_raise_identifiers:
3648 ansi_raise_identifier
3649 { $$ = add_exception_specifier (NULL_TREE, $1, 1); }
3650 | ansi_raise_identifiers ',' ansi_raise_identifier
3651 { $$ = add_exception_specifier ($1, $3, 1); }
3654 conversion_declarator:
3655 /* empty */ %prec EMPTY
3657 | '*' cv_qualifiers conversion_declarator
3658 { $$ = make_pointer_declarator ($2, $3); }
3659 | '&' cv_qualifiers conversion_declarator
3660 { $$ = make_reference_declarator ($2, $3); }
3661 | ptr_to_mem cv_qualifiers conversion_declarator
3662 { tree arg = make_pointer_declarator ($2, $3);
3663 $$ = build_parse_node (SCOPE_REF, $1, arg);
3669 { got_scope = NULL_TREE; }
3674 { $$ = ansi_opname[MULT_EXPR]; }
3676 { $$ = ansi_opname[TRUNC_DIV_EXPR]; }
3678 { $$ = ansi_opname[TRUNC_MOD_EXPR]; }
3680 { $$ = ansi_opname[PLUS_EXPR]; }
3682 { $$ = ansi_opname[MINUS_EXPR]; }
3684 { $$ = ansi_opname[BIT_AND_EXPR]; }
3686 { $$ = ansi_opname[BIT_IOR_EXPR]; }
3688 { $$ = ansi_opname[BIT_XOR_EXPR]; }
3690 { $$ = ansi_opname[BIT_NOT_EXPR]; }
3692 { $$ = ansi_opname[COMPOUND_EXPR]; }
3693 | operator ARITHCOMPARE
3694 { $$ = ansi_opname[$2]; }
3696 { $$ = ansi_opname[LT_EXPR]; }
3698 { $$ = ansi_opname[GT_EXPR]; }
3699 | operator EQCOMPARE
3700 { $$ = ansi_opname[$2]; }
3702 { $$ = ansi_assopname[$2]; }
3704 { $$ = ansi_opname [MODIFY_EXPR]; }
3706 { $$ = ansi_opname[$2]; }
3708 { $$ = ansi_opname[$2]; }
3710 { $$ = ansi_opname[POSTINCREMENT_EXPR]; }
3711 | operator MINUSMINUS
3712 { $$ = ansi_opname[PREDECREMENT_EXPR]; }
3714 { $$ = ansi_opname[TRUTH_ANDIF_EXPR]; }
3716 { $$ = ansi_opname[TRUTH_ORIF_EXPR]; }
3718 { $$ = ansi_opname[TRUTH_NOT_EXPR]; }
3720 { $$ = ansi_opname[COND_EXPR]; }
3722 { $$ = ansi_opname[$2]; }
3723 | operator POINTSAT %prec EMPTY
3724 { $$ = ansi_opname[COMPONENT_REF]; }
3725 | operator POINTSAT_STAR %prec EMPTY
3726 { $$ = ansi_opname[MEMBER_REF]; }
3727 | operator LEFT_RIGHT
3728 { $$ = ansi_opname[CALL_EXPR]; }
3730 { $$ = ansi_opname[ARRAY_REF]; }
3731 | operator NEW %prec EMPTY
3732 { $$ = ansi_opname[NEW_EXPR]; }
3733 | operator DELETE %prec EMPTY
3734 { $$ = ansi_opname[DELETE_EXPR]; }
3735 | operator NEW '[' ']'
3736 { $$ = ansi_opname[VEC_NEW_EXPR]; }
3737 | operator DELETE '[' ']'
3738 { $$ = ansi_opname[VEC_DELETE_EXPR]; }
3739 /* Names here should be looked up in class scope ALSO. */
3740 | operator type_specifier_seq conversion_declarator
3741 { $$ = grokoptypename ($2.t, $3); }
3743 { $$ = ansi_opname[ERROR_MARK]; }
3750 debug_yytranslate (value)
3753 return yytname[YYTRANSLATE (value)];