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 (lineno, (int)$3)); }
736 | fn.def1 maybe_return_init function_try_block
737 { expand_body (finish_function (lineno, (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 { if (!begin_function_definition ($1.t, $2))
781 | declmods notype_declarator
782 { if (!begin_function_definition ($1.t, $2))
785 { if (!begin_function_definition (NULL_TREE, $1))
787 | declmods constructor_declarator
788 { if (!begin_function_definition ($1.t, $2))
790 | constructor_declarator
791 { if (!begin_function_definition (NULL_TREE, $1))
795 component_constructor_declarator:
796 SELFNAME '(' parmlist ')' cv_qualifiers exception_specification_opt
797 { $$ = make_call_declarator ($1, $3, $5, $6); }
798 | SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
799 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
800 | self_template_type '(' parmlist ')' cv_qualifiers exception_specification_opt
801 { $$ = make_call_declarator ($1, $3, $5, $6); }
802 | self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
803 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
806 /* more C++ complexity. See component_decl for a comment on the
807 reduce/reduce conflict introduced by these rules. */
809 declmods component_constructor_declarator
810 { $$ = parse_method ($2, $1.t, $1.lookups);
814 if (yychar == YYEMPTY)
816 reinit_parse_for_method (yychar, $$); }
817 | component_constructor_declarator
818 { $$ = parse_method ($1, NULL_TREE, NULL_TREE);
820 | typed_declspecs declarator
821 { $$ = parse_method ($2, $1.t, $1.lookups); goto rest_of_mdef;}
822 | declmods notype_declarator
823 { $$ = parse_method ($2, $1.t, $1.lookups); goto rest_of_mdef;}
825 { $$ = parse_method ($1, NULL_TREE, NULL_TREE);
827 | declmods constructor_declarator
828 { $$ = parse_method ($2, $1.t, $1.lookups); goto rest_of_mdef;}
829 | constructor_declarator
830 { $$ = parse_method ($1, NULL_TREE, NULL_TREE);
835 RETURN_KEYWORD IDENTIFIER
837 if (! current_function_parms_stored)
845 { finish_named_return_value ($<ttype>$, $2); }
846 | return_id '(' nonnull_exprlist ')'
847 { finish_named_return_value ($<ttype>$, $3); }
848 | return_id LEFT_RIGHT
849 { finish_named_return_value ($<ttype>$, NULL_TREE); }
853 ':' .set_base_init member_init_list
856 error ("no base initializers given following ':'");
864 if (! current_function_parms_stored)
867 if (DECL_CONSTRUCTOR_P (current_function_decl))
868 /* Make a contour for the initializer list. */
870 else if (current_class_type == NULL_TREE)
871 error ("base initializers not allowed for non-member functions");
872 else if (! DECL_CONSTRUCTOR_P (current_function_decl))
873 error ("only constructors take base initializers");
882 | member_init_list ',' member_init
883 | member_init_list error
887 '(' nonnull_exprlist ')'
889 if (current_class_name)
890 pedwarn ("anachronistic old style base class initializer");
891 expand_member_init (current_class_ref, NULL_TREE, $2);
895 if (current_class_name)
896 pedwarn ("anachronistic old style base class initializer");
897 expand_member_init (current_class_ref, NULL_TREE, void_type_node);
899 | notype_identifier '(' nonnull_exprlist ')'
900 { expand_member_init (current_class_ref, $1, $3); }
901 | notype_identifier LEFT_RIGHT
902 { expand_member_init (current_class_ref, $1, void_type_node); }
903 | nonnested_type '(' nonnull_exprlist ')'
904 { expand_member_init (current_class_ref, $1, $3); }
905 | nonnested_type LEFT_RIGHT
906 { expand_member_init (current_class_ref, $1, void_type_node); }
907 | typename_sub '(' nonnull_exprlist ')'
908 { expand_member_init (current_class_ref, TYPE_MAIN_DECL ($1),
910 | typename_sub LEFT_RIGHT
911 { expand_member_init (current_class_ref, TYPE_MAIN_DECL ($1),
936 explicit_instantiation:
937 TEMPLATE begin_explicit_instantiation typespec ';'
938 { do_type_instantiation ($3.t, NULL_TREE);
940 end_explicit_instantiation
941 | TEMPLATE begin_explicit_instantiation typed_declspecs declarator
942 { tree specs = strip_attrs ($3.t);
943 do_decl_instantiation (specs, $4, NULL_TREE); }
944 end_explicit_instantiation
945 | TEMPLATE begin_explicit_instantiation notype_declarator
946 { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
947 end_explicit_instantiation
948 | TEMPLATE begin_explicit_instantiation constructor_declarator
949 { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
950 end_explicit_instantiation
951 | SCSPEC TEMPLATE begin_explicit_instantiation typespec ';'
952 { do_type_instantiation ($4.t, $1);
954 end_explicit_instantiation
955 | SCSPEC TEMPLATE begin_explicit_instantiation typed_declspecs
957 { tree specs = strip_attrs ($4.t);
958 do_decl_instantiation (specs, $5, $1); }
959 end_explicit_instantiation
960 | SCSPEC TEMPLATE begin_explicit_instantiation notype_declarator
961 { do_decl_instantiation (NULL_TREE, $4, $1); }
962 end_explicit_instantiation
963 | SCSPEC TEMPLATE begin_explicit_instantiation constructor_declarator
964 { do_decl_instantiation (NULL_TREE, $4, $1); }
965 end_explicit_instantiation
968 begin_explicit_instantiation:
969 { begin_explicit_instantiation(); }
971 end_explicit_instantiation:
972 { end_explicit_instantiation(); }
974 /* The TYPENAME expansions are to deal with use of a template class name as
975 a template within the class itself, where the template decl is hidden by
976 a type decl. Got all that? */
979 PTYPENAME '<' template_arg_list_opt template_close_bracket
980 .finish_template_type
982 | TYPENAME '<' template_arg_list_opt template_close_bracket
983 .finish_template_type
988 apparent_template_type:
990 | identifier '<' template_arg_list_opt '>'
991 .finish_template_type
995 SELFNAME '<' template_arg_list_opt template_close_bracket
996 .finish_template_type
1000 .finish_template_type:
1002 if (yychar == YYEMPTY)
1005 $$ = finish_template_type ($<ttype>-3, $<ttype>-1,
1009 template_close_bracket:
1013 /* Handle `Class<Class<Type>>' without space in the `>>' */
1014 pedwarn ("`>>' should be `> >' in template class name");
1019 template_arg_list_opt:
1027 { $$ = build_tree_list (NULL_TREE, $$); }
1028 | template_arg_list ',' template_arg
1029 { $$ = chainon ($$, build_tree_list (NULL_TREE, $3)); }
1034 { $$ = groktypename ($1.t); }
1036 { $$ = lastiddecl; }
1037 | expr_no_commas %prec ARITHCOMPARE
1042 { $$ = NEGATE_EXPR; }
1044 { $$ = CONVERT_EXPR; }
1046 { $$ = PREINCREMENT_EXPR; }
1048 { $$ = PREDECREMENT_EXPR; }
1050 { $$ = TRUTH_NOT_EXPR; }
1055 { $$ = build_x_compound_expr ($$); }
1061 { error ("ISO C++ forbids an empty condition for `%s'",
1063 $$ = integer_zero_node; }
1070 { error ("ISO C++ forbids an empty condition for `%s'",
1072 $$ = integer_zero_node; }
1086 type_specifier_seq declarator maybeasm maybe_attribute '='
1089 for (d = getdecls (); d; d = TREE_CHAIN (d))
1090 if (TREE_CODE (d) == TYPE_DECL) {
1091 tree s = TREE_TYPE (d);
1092 if (TREE_CODE (s) == RECORD_TYPE)
1093 cp_error ("definition of class `%T' in condition", s);
1094 else if (TREE_CODE (s) == ENUMERAL_TYPE)
1095 cp_error ("definition of enum `%T' in condition", s);
1098 current_declspecs = $1.t;
1099 $<ttype>$ = parse_decl ($<ttype>2, $4, 1);
1103 parse_end_decl ($<ttype>6, $7, $4);
1104 $$ = convert_from_reference ($<ttype>6);
1105 if (TREE_CODE (TREE_TYPE ($$)) == ARRAY_TYPE)
1106 cp_error ("definition of array `%#D' in condition", $$);
1113 | maybe_label_decls stmts '}'
1114 | maybe_label_decls stmts error '}'
1115 | maybe_label_decls error '}'
1118 already_scoped_stmt:
1120 { $<ttype>$ = begin_compound_stmt (1); }
1122 { finish_compound_stmt (1, $<ttype>2); }
1127 nontrivial_exprlist:
1128 expr_no_commas ',' expr_no_commas
1129 { $$ = tree_cons (NULL_TREE, $$,
1130 build_tree_list (NULL_TREE, $3)); }
1131 | expr_no_commas ',' error
1132 { $$ = tree_cons (NULL_TREE, $$,
1133 build_tree_list (NULL_TREE, error_mark_node)); }
1134 | nontrivial_exprlist ',' expr_no_commas
1135 { chainon ($$, build_tree_list (NULL_TREE, $3)); }
1136 | nontrivial_exprlist ',' error
1137 { chainon ($$, build_tree_list (NULL_TREE, error_mark_node)); }
1142 { $$ = build_tree_list (NULL_TREE, $$); }
1143 | nontrivial_exprlist
1149 /* __extension__ turns off -pedantic for following primary. */
1150 | extension cast_expr %prec UNARY
1153 | '*' cast_expr %prec UNARY
1154 { $$ = build_x_indirect_ref ($2, "unary *"); }
1155 | '&' cast_expr %prec UNARY
1156 { $$ = build_x_unary_op (ADDR_EXPR, $2); }
1158 { $$ = build_x_unary_op (BIT_NOT_EXPR, $2); }
1159 | unop cast_expr %prec UNARY
1160 { $$ = finish_unary_op_expr ($1, $2); }
1161 /* Refer to the address of a label as a pointer. */
1164 pedwarn ("ISO C++ forbids `&&'");
1165 $$ = finish_label_address_expr ($2); }
1166 | SIZEOF unary_expr %prec UNARY
1167 { $$ = expr_sizeof ($2); }
1168 | SIZEOF '(' type_id ')' %prec HYPERUNARY
1169 { $$ = c_sizeof (groktypename ($3.t));
1170 check_for_new_type ("sizeof", $3); }
1171 | ALIGNOF unary_expr %prec UNARY
1172 { $$ = grok_alignof ($2); }
1173 | ALIGNOF '(' type_id ')' %prec HYPERUNARY
1174 { $$ = c_alignof (groktypename ($3.t));
1175 check_for_new_type ("alignof", $3); }
1177 /* The %prec EMPTY's here are required by the = init initializer
1178 syntax extension; see below. */
1179 | new new_type_id %prec EMPTY
1180 { $$ = build_new (NULL_TREE, $2.t, NULL_TREE, $1);
1181 check_for_new_type ("new", $2); }
1182 | new new_type_id new_initializer
1183 { $$ = build_new (NULL_TREE, $2.t, $3, $1);
1184 check_for_new_type ("new", $2); }
1185 | new new_placement new_type_id %prec EMPTY
1186 { $$ = build_new ($2, $3.t, NULL_TREE, $1);
1187 check_for_new_type ("new", $3); }
1188 | new new_placement new_type_id new_initializer
1189 { $$ = build_new ($2, $3.t, $4, $1);
1190 check_for_new_type ("new", $3); }
1191 | new '(' type_id ')'
1193 { $$ = build_new (NULL_TREE, groktypename($3.t),
1195 check_for_new_type ("new", $3); }
1196 | new '(' type_id ')' new_initializer
1197 { $$ = build_new (NULL_TREE, groktypename($3.t), $5, $1);
1198 check_for_new_type ("new", $3); }
1199 | new new_placement '(' type_id ')' %prec EMPTY
1200 { $$ = build_new ($2, groktypename($4.t), NULL_TREE, $1);
1201 check_for_new_type ("new", $4); }
1202 | new new_placement '(' type_id ')' new_initializer
1203 { $$ = build_new ($2, groktypename($4.t), $6, $1);
1204 check_for_new_type ("new", $4); }
1206 | delete cast_expr %prec UNARY
1207 { $$ = delete_sanity ($2, NULL_TREE, 0, $1); }
1208 | delete '[' ']' cast_expr %prec UNARY
1209 { $$ = delete_sanity ($4, NULL_TREE, 1, $1);
1210 if (yychar == YYEMPTY)
1212 | delete '[' expr ']' cast_expr %prec UNARY
1213 { $$ = delete_sanity ($5, $3, 2, $1);
1214 if (yychar == YYEMPTY)
1216 | REALPART cast_expr %prec UNARY
1217 { $$ = build_x_unary_op (REALPART_EXPR, $2); }
1218 | IMAGPART cast_expr %prec UNARY
1219 { $$ = build_x_unary_op (IMAGPART_EXPR, $2); }
1220 | VA_ARG '(' expr_no_commas ',' type_id ')'
1221 { $$ = build_x_va_arg ($3, groktypename ($5.t));
1222 check_for_new_type ("__builtin_va_arg", $5); }
1226 '(' nonnull_exprlist ')'
1228 | '{' nonnull_exprlist '}'
1229 { cp_pedwarn ("old style placement syntax, use () instead");
1234 '(' nonnull_exprlist ')'
1240 cp_error ("`%T' is not a valid expression", $2.t);
1241 $$ = error_mark_node;
1243 /* GNU extension so people can use initializer lists. Note that
1244 this alters the meaning of `new int = 1', which was previously
1245 syntactically valid but semantically invalid. */
1249 pedwarn ("ISO C++ forbids initialization of new expression with `='");
1250 if (TREE_CODE ($2) != TREE_LIST
1251 && TREE_CODE ($2) != CONSTRUCTOR)
1252 $$ = build_tree_list (NULL_TREE, $2);
1258 /* This is necessary to postpone reduction of `int ((int)(int)(int))'. */
1260 '(' type_id ')' %prec EMPTY
1261 { $2.t = finish_parmlist (build_tree_list (NULL_TREE, $2.t), 0);
1262 $$ = make_call_declarator (NULL_TREE, $2.t, NULL_TREE, NULL_TREE);
1263 check_for_new_type ("cast", $2); }
1264 | regcast_or_absdcl '(' type_id ')' %prec EMPTY
1265 { $3.t = finish_parmlist (build_tree_list (NULL_TREE, $3.t), 0);
1266 $$ = make_call_declarator ($$, $3.t, NULL_TREE, NULL_TREE);
1267 check_for_new_type ("cast", $3); }
1272 | regcast_or_absdcl unary_expr %prec UNARY
1273 { $$ = reparse_absdcl_as_casts ($$, $2); }
1274 | regcast_or_absdcl '{' initlist maybecomma '}' %prec UNARY
1276 tree init = build_nt (CONSTRUCTOR, NULL_TREE,
1279 pedwarn ("ISO C++ forbids constructor-expressions");
1280 /* Indicate that this was a GNU C constructor expression. */
1281 TREE_HAS_CONSTRUCTOR (init) = 1;
1283 $$ = reparse_absdcl_as_casts ($$, init);
1289 /* Handle general members. */
1290 | expr_no_commas POINTSAT_STAR expr_no_commas
1291 { $$ = build_x_binary_op (MEMBER_REF, $$, $3); }
1292 | expr_no_commas DOT_STAR expr_no_commas
1293 { $$ = build_m_component_ref ($$, $3); }
1294 | expr_no_commas '+' expr_no_commas
1295 { $$ = build_x_binary_op ($2, $$, $3); }
1296 | expr_no_commas '-' expr_no_commas
1297 { $$ = build_x_binary_op ($2, $$, $3); }
1298 | expr_no_commas '*' expr_no_commas
1299 { $$ = build_x_binary_op ($2, $$, $3); }
1300 | expr_no_commas '/' expr_no_commas
1301 { $$ = build_x_binary_op ($2, $$, $3); }
1302 | expr_no_commas '%' expr_no_commas
1303 { $$ = build_x_binary_op ($2, $$, $3); }
1304 | expr_no_commas LSHIFT expr_no_commas
1305 { $$ = build_x_binary_op ($2, $$, $3); }
1306 | expr_no_commas RSHIFT expr_no_commas
1307 { $$ = build_x_binary_op ($2, $$, $3); }
1308 | expr_no_commas ARITHCOMPARE expr_no_commas
1309 { $$ = build_x_binary_op ($2, $$, $3); }
1310 | expr_no_commas '<' expr_no_commas
1311 { $$ = build_x_binary_op (LT_EXPR, $$, $3); }
1312 | expr_no_commas '>' expr_no_commas
1313 { $$ = build_x_binary_op (GT_EXPR, $$, $3); }
1314 | expr_no_commas EQCOMPARE expr_no_commas
1315 { $$ = build_x_binary_op ($2, $$, $3); }
1316 | expr_no_commas MIN_MAX expr_no_commas
1317 { $$ = build_x_binary_op ($2, $$, $3); }
1318 | expr_no_commas '&' expr_no_commas
1319 { $$ = build_x_binary_op ($2, $$, $3); }
1320 | expr_no_commas '|' expr_no_commas
1321 { $$ = build_x_binary_op ($2, $$, $3); }
1322 | expr_no_commas '^' expr_no_commas
1323 { $$ = build_x_binary_op ($2, $$, $3); }
1324 | expr_no_commas ANDAND expr_no_commas
1325 { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $$, $3); }
1326 | expr_no_commas OROR expr_no_commas
1327 { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $$, $3); }
1328 | expr_no_commas '?' xexpr ':' expr_no_commas
1329 { $$ = build_x_conditional_expr ($$, $3, $5); }
1330 | expr_no_commas '=' expr_no_commas
1331 { $$ = build_x_modify_expr ($$, NOP_EXPR, $3);
1332 if ($$ != error_mark_node)
1333 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
1334 | expr_no_commas ASSIGN expr_no_commas
1335 { $$ = build_x_modify_expr ($$, $2, $3); }
1337 { $$ = build_throw (NULL_TREE); }
1338 | THROW expr_no_commas
1339 { $$ = build_throw ($2); }
1340 /* These extensions are not defined. The second arg to build_m_component_ref
1341 is old, build_m_component_ref now does an implicit
1342 build_indirect_ref (x, NULL_PTR) on the second argument.
1343 | object '&' expr_no_commas %prec UNARY
1344 { $$ = build_m_component_ref ($$, build_x_unary_op (ADDR_EXPR, $3)); }
1345 | object unop expr_no_commas %prec UNARY
1346 { $$ = build_m_component_ref ($$, build_x_unary_op ($2, $3)); }
1347 | object '(' type_id ')' expr_no_commas %prec UNARY
1348 { tree type = groktypename ($3.t);
1349 $$ = build_m_component_ref ($$, build_c_cast (type, $5)); }
1350 | object primary_no_id %prec UNARY
1351 { $$ = build_m_component_ref ($$, $2); }
1355 notype_unqualified_id:
1356 '~' see_typename identifier
1357 { $$ = build_parse_node (BIT_NOT_EXPR, $3); }
1358 | '~' see_typename template_type
1359 { $$ = build_parse_node (BIT_NOT_EXPR, $3); }
1364 | NSNAME %prec EMPTY
1369 /* If lastiddecl is a TREE_LIST, it's a baselink, which
1370 means that we're in an expression like S::f<int>, so
1371 don't do_identifier; we only do that for unqualified
1373 if (lastiddecl && TREE_CODE (lastiddecl) != TREE_LIST)
1374 $$ = do_identifier ($<ttype>-1, 1, NULL_TREE);
1380 PFUNCNAME '<' do_id template_arg_list_opt template_close_bracket
1381 { $$ = lookup_template_function ($3, $4); }
1382 | operator_name '<' do_id template_arg_list_opt template_close_bracket
1383 { $$ = lookup_template_function ($3, $4); }
1387 TEMPLATE identifier '<' template_arg_list_opt template_close_bracket
1388 { $$ = lookup_template_function ($2, $4); }
1389 | TEMPLATE PFUNCNAME '<' template_arg_list_opt template_close_bracket
1390 { $$ = lookup_template_function ($2, $4); }
1391 | TEMPLATE operator_name '<' template_arg_list_opt
1392 template_close_bracket
1393 { $$ = lookup_template_function ($2, $4); }
1397 notype_unqualified_id
1402 expr_or_declarator_intern:
1404 | attributes expr_or_declarator
1406 /* Provide support for '(' attributes '*' declarator ')'
1408 $$ = decl_tree_cons ($1, $2, NULL_TREE);
1413 notype_unqualified_id
1414 | '*' expr_or_declarator_intern %prec UNARY
1415 { $$ = build_parse_node (INDIRECT_REF, $2); }
1416 | '&' expr_or_declarator_intern %prec UNARY
1417 { $$ = build_parse_node (ADDR_EXPR, $2); }
1418 | '(' expr_or_declarator_intern ')'
1422 notype_template_declarator:
1423 IDENTIFIER '<' template_arg_list_opt template_close_bracket
1424 { $$ = lookup_template_function ($1, $3); }
1425 | NSNAME '<' template_arg_list template_close_bracket
1426 { $$ = lookup_template_function ($1, $3); }
1429 direct_notype_declarator:
1430 complex_direct_notype_declarator
1431 /* This precedence declaration is to prefer this reduce
1432 to the Koenig lookup shift in primary, below. I hate yacc. */
1433 | notype_unqualified_id %prec '('
1434 | notype_template_declarator
1435 | '(' expr_or_declarator_intern ')'
1436 { $$ = finish_decl_parsing ($2); }
1440 notype_unqualified_id
1442 if (TREE_CODE ($1) == BIT_NOT_EXPR)
1443 $$ = build_x_unary_op (BIT_NOT_EXPR, TREE_OPERAND ($1, 0));
1445 $$ = finish_id_expr ($1);
1451 $$ = combine_strings ($$);
1452 /* combine_strings doesn't set up TYPE_MAIN_VARIANT of
1453 a const array the way we want, so fix it. */
1454 if (flag_const_strings)
1455 TREE_TYPE ($$) = build_cplus_array_type
1456 (TREE_TYPE (TREE_TYPE ($$)),
1457 TYPE_DOMAIN (TREE_TYPE ($$)));
1460 { $$ = finish_parenthesized_expr ($2); }
1461 | '(' expr_or_declarator_intern ')'
1462 { $2 = reparse_decl_as_expr (NULL_TREE, $2);
1463 $$ = finish_parenthesized_expr ($2); }
1465 { $$ = error_mark_node; }
1467 { tree scope = current_scope ();
1468 if (!scope || TREE_CODE (scope) != FUNCTION_DECL)
1470 error ("braced-group within expression allowed only inside a function");
1474 pedwarn ("ISO C++ forbids braced-groups within expressions");
1475 $<ttype>$ = begin_stmt_expr ();
1478 { $$ = finish_stmt_expr ($<ttype>2); }
1479 /* Koenig lookup support
1480 We could store lastiddecl in $1 to avoid another lookup,
1481 but that would result in many additional reduce/reduce conflicts. */
1482 | notype_unqualified_id '(' nonnull_exprlist ')'
1483 { $$ = finish_call_expr ($1, $3, 1); }
1484 | notype_unqualified_id LEFT_RIGHT
1485 { $$ = finish_call_expr ($1, NULL_TREE, 1); }
1486 | primary '(' nonnull_exprlist ')'
1487 { $$ = finish_call_expr ($1, $3, 0); }
1488 | primary LEFT_RIGHT
1489 { $$ = finish_call_expr ($1, NULL_TREE, 0); }
1490 | primary '[' expr ']'
1491 { $$ = grok_array_decl ($$, $3); }
1493 { $$ = finish_increment_expr ($1, POSTINCREMENT_EXPR); }
1494 | primary MINUSMINUS
1495 { $$ = finish_increment_expr ($1, POSTDECREMENT_EXPR); }
1496 /* C++ extensions */
1498 { $$ = finish_this_expr (); }
1499 | CV_QUALIFIER '(' nonnull_exprlist ')'
1501 /* This is a C cast in C++'s `functional' notation
1502 using the "implicit int" extension so that:
1503 `const (3)' is equivalent to `const int (3)'. */
1506 type = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
1507 type = groktypename (build_decl_list (type, NULL_TREE));
1508 $$ = build_functional_cast (type, $3);
1511 | DYNAMIC_CAST '<' type_id '>' '(' expr ')'
1512 { tree type = groktypename ($3.t);
1513 check_for_new_type ("dynamic_cast", $3);
1514 $$ = build_dynamic_cast (type, $6); }
1515 | STATIC_CAST '<' type_id '>' '(' expr ')'
1516 { tree type = groktypename ($3.t);
1517 check_for_new_type ("static_cast", $3);
1518 $$ = build_static_cast (type, $6); }
1519 | REINTERPRET_CAST '<' type_id '>' '(' expr ')'
1520 { tree type = groktypename ($3.t);
1521 check_for_new_type ("reinterpret_cast", $3);
1522 $$ = build_reinterpret_cast (type, $6); }
1523 | CONST_CAST '<' type_id '>' '(' expr ')'
1524 { tree type = groktypename ($3.t);
1525 check_for_new_type ("const_cast", $3);
1526 $$ = build_const_cast (type, $6); }
1527 | TYPEID '(' expr ')'
1528 { $$ = build_typeid ($3); }
1529 | TYPEID '(' type_id ')'
1530 { tree type = groktypename ($3.t);
1531 check_for_new_type ("typeid", $3);
1532 $$ = get_typeid (TYPE_MAIN_VARIANT (type)); }
1533 | global_scope IDENTIFIER
1534 { $$ = do_scoped_id ($2, 1); }
1535 | global_scope template_id
1537 | global_scope operator_name
1539 got_scope = NULL_TREE;
1540 if (TREE_CODE ($2) == IDENTIFIER_NODE)
1541 $$ = do_scoped_id ($2, 1);
1545 | overqualified_id %prec HYPERUNARY
1546 { $$ = build_offset_ref (OP0 ($$), OP1 ($$)); }
1547 | overqualified_id '(' nonnull_exprlist ')'
1548 { $$ = finish_qualified_call_expr ($1, $3); }
1549 | overqualified_id LEFT_RIGHT
1550 { $$ = finish_qualified_call_expr ($1, NULL_TREE); }
1551 | object object_template_id %prec UNARY
1553 $$ = build_x_component_ref ($$, $2, NULL_TREE, 1);
1555 | object object_template_id '(' nonnull_exprlist ')'
1556 { $$ = finish_object_call_expr ($2, $1, $4); }
1557 | object object_template_id LEFT_RIGHT
1558 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1559 | object unqualified_id %prec UNARY
1560 { $$ = build_x_component_ref ($$, $2, NULL_TREE, 1); }
1561 | object overqualified_id %prec UNARY
1562 { if (processing_template_decl)
1563 $$ = build_min_nt (COMPONENT_REF, $1, $2);
1565 $$ = build_object_ref ($$, OP0 ($2), OP1 ($2)); }
1566 | object unqualified_id '(' nonnull_exprlist ')'
1567 { $$ = finish_object_call_expr ($2, $1, $4); }
1568 | object unqualified_id LEFT_RIGHT
1569 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1570 | object overqualified_id '(' nonnull_exprlist ')'
1571 { $$ = finish_qualified_object_call_expr ($2, $1, $4); }
1572 | object overqualified_id LEFT_RIGHT
1573 { $$ = finish_qualified_object_call_expr ($2, $1, NULL_TREE); }
1574 /* p->int::~int() is valid -- 12.4 */
1575 | object '~' TYPESPEC LEFT_RIGHT
1576 { $$ = finish_pseudo_destructor_call_expr ($1, NULL_TREE, $3); }
1577 | object TYPESPEC SCOPE '~' TYPESPEC LEFT_RIGHT
1578 { $$ = finish_pseudo_destructor_call_expr ($1, $2, $5); }
1581 $$ = error_mark_node;
1585 /* Not needed for now.
1591 { $$ = error_mark_node; }
1593 { if (current_function_decl == 0)
1595 error ("braced-group within expression allowed only inside a function");
1598 $<ttype>$ = expand_start_stmt_expr (); }
1601 pedwarn ("ISO C++ forbids braced-groups within expressions");
1602 $$ = expand_end_stmt_expr ($<ttype>2); }
1603 | primary_no_id '(' nonnull_exprlist ')'
1604 { $$ = build_x_function_call ($$, $3, current_class_ref); }
1605 | primary_no_id LEFT_RIGHT
1606 { $$ = build_x_function_call ($$, NULL_TREE, current_class_ref); }
1607 | primary_no_id '[' expr ']'
1609 | primary_no_id PLUSPLUS
1610 { $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); }
1611 | primary_no_id MINUSMINUS
1612 { $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); }
1614 { goto do_scoped_id; }
1615 | SCOPE operator_name
1616 { if (TREE_CODE ($2) == IDENTIFIER_NODE)
1618 goto do_scoped_operator;
1627 { got_scope = NULL_TREE; $$ = 1; }
1633 | global_scope delete
1634 { got_scope = NULL_TREE; $$ = 1; }
1639 { $$ = boolean_true_node; }
1641 { $$ = boolean_false_node; }
1644 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
1648 { $$ = chainon ($$, $2); }
1654 if (! current_function_parms_stored)
1655 store_parm_decls ();
1662 { got_object = TREE_TYPE ($$); }
1665 $$ = build_x_arrow ($$);
1666 got_object = TREE_TYPE ($$);
1671 typespec initdecls ';'
1673 if ($1.t && IS_AGGR_TYPE_CODE (TREE_CODE ($1.t)))
1674 note_got_semicolon ($1.t);
1676 | typed_declspecs initdecls ';'
1678 note_list_got_semicolon ($1.t);
1680 | declmods notype_initdecls ';'
1682 | typed_declspecs ';'
1685 note_list_got_semicolon ($1.t);
1688 { warning ("empty declaration"); }
1693 /* Any kind of declarator (thus, all declarators allowed
1694 after an explicit typespec). */
1697 after_type_declarator %prec EMPTY
1698 | notype_declarator %prec EMPTY
1701 /* This is necessary to postpone reduction of `int()()()()'. */
1703 LEFT_RIGHT %prec EMPTY
1704 { $$ = make_call_declarator (NULL_TREE, empty_parms (),
1705 NULL_TREE, NULL_TREE); }
1706 | fcast_or_absdcl LEFT_RIGHT %prec EMPTY
1707 { $$ = make_call_declarator ($$, empty_parms (), NULL_TREE,
1711 /* ISO type-id (8.1) */
1713 typed_typespecs absdcl
1714 { $$.t = build_decl_list ($1.t, $2);
1715 $$.new_type_flag = $1.new_type_flag; }
1716 | nonempty_cv_qualifiers absdcl
1717 { $$.t = build_decl_list ($1.t, $2);
1718 $$.new_type_flag = $1.new_type_flag; }
1720 { $$.t = build_decl_list (build_decl_list (NULL_TREE, $1.t),
1722 $$.new_type_flag = $1.new_type_flag; }
1723 | typed_typespecs %prec EMPTY
1724 { $$.t = build_decl_list ($1.t, NULL_TREE);
1725 $$.new_type_flag = $1.new_type_flag; }
1726 | nonempty_cv_qualifiers %prec EMPTY
1727 { $$.t = build_decl_list ($1.t, NULL_TREE);
1728 $$.new_type_flag = $1.new_type_flag; }
1731 /* Declspecs which contain at least one type specifier or typedef name.
1732 (Just `const' or `volatile' is not enough.)
1733 A typedef'd name following these is taken as a name to be declared.
1734 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1737 typed_typespecs %prec EMPTY
1738 { $$.lookups = type_lookups; }
1740 { $$.lookups = type_lookups; }
1745 { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1.t);
1746 $$.new_type_flag = $2.new_type_flag; }
1747 | typespec reserved_declspecs %prec HYPERUNARY
1748 { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2);
1749 $$.new_type_flag = $1.new_type_flag; }
1750 | typespec reserved_typespecquals reserved_declspecs
1751 { $$.t = decl_tree_cons (NULL_TREE, $1.t, chainon ($2, $3));
1752 $$.new_type_flag = $1.new_type_flag; }
1753 | declmods typespec reserved_declspecs
1754 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1755 $$.new_type_flag = $2.new_type_flag; }
1756 | declmods typespec reserved_typespecquals
1757 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1758 $$.new_type_flag = $2.new_type_flag; }
1759 | declmods typespec reserved_typespecquals reserved_declspecs
1760 { $$.t = decl_tree_cons (NULL_TREE, $2.t,
1761 chainon ($3, chainon ($4, $1.t)));
1762 $$.new_type_flag = $2.new_type_flag; }
1767 { if (extra_warnings)
1768 warning ("`%s' is not at beginning of declaration",
1769 IDENTIFIER_POINTER ($$));
1770 $$ = build_decl_list (NULL_TREE, $$); }
1771 | reserved_declspecs typespecqual_reserved
1772 { $$ = decl_tree_cons (NULL_TREE, $2.t, $$); }
1773 | reserved_declspecs SCSPEC
1774 { if (extra_warnings)
1775 warning ("`%s' is not at beginning of declaration",
1776 IDENTIFIER_POINTER ($2));
1777 $$ = decl_tree_cons (NULL_TREE, $2, $$); }
1778 | reserved_declspecs attributes
1779 { $$ = decl_tree_cons ($2, NULL_TREE, $1); }
1781 { $$ = decl_tree_cons ($1, NULL_TREE, NULL_TREE); }
1784 /* List of just storage classes and type modifiers.
1785 A declaration can start with just this, but then it cannot be used
1786 to redeclare a typedef-name.
1787 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1789 /* We use hash_tree_cons for lists of typeless declspecs so that they end
1790 up on a persistent obstack. Otherwise, they could appear at the
1791 beginning of something like
1793 static const struct { int foo () { } } b;
1795 and would be discarded after we finish compiling foo. We don't need to
1796 worry once we see a type. */
1799 nonempty_cv_qualifiers %prec EMPTY
1800 { $$.lookups = NULL_TREE; TREE_STATIC ($$.t) = 1; }
1803 $$.t = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
1804 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
1806 | declmods CV_QUALIFIER
1808 $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
1809 TREE_STATIC ($$.t) = 1;
1813 if (extra_warnings && TREE_STATIC ($$.t))
1814 warning ("`%s' is not at beginning of declaration",
1815 IDENTIFIER_POINTER ($2));
1816 $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
1817 TREE_STATIC ($$.t) = TREE_STATIC ($1.t);
1819 | declmods attributes
1820 { $$.t = hash_tree_cons ($2, NULL_TREE, $1.t); }
1821 | attributes %prec EMPTY
1823 $$.t = hash_tree_cons ($1, NULL_TREE, NULL_TREE);
1824 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
1828 /* Used instead of declspecs where storage classes are not allowed
1829 (that is, for typenames and structure components).
1831 C++ can takes storage classes for structure components.
1832 Don't accept a typedef-name if anything but a modifier precedes it. */
1835 typespec %prec EMPTY
1836 { $$.t = build_decl_list (NULL_TREE, $1.t);
1837 $$.new_type_flag = $1.new_type_flag; }
1838 | nonempty_cv_qualifiers typespec
1839 { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1.t);
1840 $$.new_type_flag = $2.new_type_flag; }
1841 | typespec reserved_typespecquals
1842 { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2);
1843 $$.new_type_flag = $1.new_type_flag; }
1844 | nonempty_cv_qualifiers typespec reserved_typespecquals
1845 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1846 $$.new_type_flag = $2.new_type_flag; }
1849 reserved_typespecquals:
1850 typespecqual_reserved
1851 { $$ = build_decl_list (NULL_TREE, $1.t); }
1852 | reserved_typespecquals typespecqual_reserved
1853 { $$ = decl_tree_cons (NULL_TREE, $2.t, $1); }
1856 /* A typespec (but not a type qualifier).
1857 Once we have seen one of these in a declaration,
1858 if a typedef name appears then it is being redeclared. */
1862 { $$.lookups = NULL_TREE; }
1863 | TYPESPEC %prec EMPTY
1864 { $$.t = $1; $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
1865 | complete_type_name
1866 { $$.t = $1; $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
1867 | TYPEOF '(' expr ')'
1868 { $$.t = finish_typeof ($3);
1869 $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
1870 | TYPEOF '(' type_id ')'
1871 { $$.t = groktypename ($3.t);
1872 $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
1873 | SIGOF '(' expr ')'
1874 { tree type = TREE_TYPE ($3);
1876 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
1877 if (IS_AGGR_TYPE (type))
1879 sorry ("sigof type specifier");
1884 error ("`sigof' applied to non-aggregate expression");
1885 $$.t = error_mark_node;
1888 | SIGOF '(' type_id ')'
1889 { tree type = groktypename ($3.t);
1891 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
1892 if (IS_AGGR_TYPE (type))
1894 sorry ("sigof type specifier");
1899 error("`sigof' applied to non-aggregate type");
1900 $$.t = error_mark_node;
1905 /* A typespec that is a reserved word, or a type qualifier. */
1907 typespecqual_reserved:
1909 { $$.t = $1; $$.new_type_flag = 0; }
1911 { $$.t = $1; $$.new_type_flag = 0; }
1917 | initdecls ',' initdcl
1918 { check_multiple_declarators (); }
1923 | notype_initdecls ',' initdcl
1924 { check_multiple_declarators (); }
1929 | nomods_initdecls ',' initdcl
1930 { check_multiple_declarators (); }
1936 | asm_keyword '(' string ')'
1937 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3); $$ = $3; }
1941 declarator maybeasm maybe_attribute '='
1942 { $<ttype>$ = parse_decl ($<ttype>1, $3, 1); }
1944 /* Note how the declaration of the variable is in effect while its init is parsed! */
1945 { parse_end_decl ($<ttype>5, $6, $2); }
1946 | declarator maybeasm maybe_attribute
1948 $<ttype>$ = parse_decl ($<ttype>1, $3, 0);
1949 parse_end_decl ($<ttype>$, NULL_TREE, $2);
1953 /* This rule assumes a certain configuration of the parser stack.
1954 In particular, $0, the element directly before the beginning of
1955 this rule on the stack, must be a maybeasm. $-1 must be a
1956 declarator or notype_declarator. And $-2 must be some declmods
1957 or declspecs. We can't move the maybeasm into this rule because
1958 we need that reduce so we prefer fn.def1 when appropriate. */
1961 { $<ttype>$ = parse_decl0 ($<ttype>-1, $<ftype>-2.t,
1962 $<ftype>-2.lookups, $1, 1); }
1963 /* Note how the declaration of the variable is in effect
1964 while its init is parsed! */
1966 { parse_end_decl ($<ttype>3, $4, $<ttype>0); }
1968 { tree d = parse_decl0 ($<ttype>-1, $<ftype>-2.t,
1969 $<ftype>-2.lookups, $1, 0);
1970 parse_end_decl (d, NULL_TREE, $<ttype>0); }
1974 declarator maybeasm initdcl0_innards
1979 notype_declarator maybeasm initdcl0_innards
1984 notype_declarator maybeasm
1985 { /* Set things up as initdcl0_innards expects. */
1990 | constructor_declarator maybeasm maybe_attribute
1991 { tree d = parse_decl0 ($1, NULL_TREE, NULL_TREE, $3, 0);
1992 parse_end_decl (d, NULL_TREE, $2); }
1995 /* the * rules are dummies to accept the Apollo extended syntax
1996 so that the header files compile. */
2007 | attributes attribute
2008 { $$ = chainon ($1, $2); }
2012 ATTRIBUTE '(' '(' attribute_list ')' ')'
2019 | attribute_list ',' attrib
2020 { $$ = chainon ($1, $3); }
2027 { $$ = build_tree_list ($1, NULL_TREE); }
2028 | any_word '(' IDENTIFIER ')'
2029 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
2030 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
2031 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
2032 | any_word '(' nonnull_exprlist ')'
2033 { $$ = build_tree_list ($1, $3); }
2036 /* This still leaves out most reserved keywords,
2037 shouldn't we include them? */
2046 /* A nonempty list of identifiers, including typenames. */
2047 identifiers_or_typenames:
2049 { $$ = build_tree_list (NULL_TREE, $1); }
2050 | identifiers_or_typenames ',' identifier
2051 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2055 /* empty */ %prec EMPTY
2060 /* If we are processing a template, we don't want to expand this
2064 expr_no_commas %prec '='
2066 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, NULL_TREE);
2067 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2069 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2070 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2071 | '{' initlist ',' '}'
2072 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2073 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2078 /* This chain is built in reverse order,
2079 and put in forward order where initlist is used. */
2082 { $$ = build_tree_list (NULL_TREE, $$); }
2084 { $$ = tree_cons (NULL_TREE, $3, $$); }
2085 /* These are for labeled elements. */
2086 | '[' expr_no_commas ']' init
2087 { $$ = build_tree_list ($2, $4); }
2088 | identifier ':' init
2089 { $$ = build_tree_list ($$, $3); }
2090 | initlist ',' identifier ':' init
2091 { $$ = tree_cons ($3, $5, $$); }
2095 PRE_PARSED_FUNCTION_DECL
2096 { start_function (NULL_TREE, $1->fndecl, NULL_TREE,
2097 (SF_DEFAULT | SF_PRE_PARSED
2098 | SF_INCLASS_INLINE));
2099 reinit_parse_for_function (); }
2102 fn.defpen maybe_return_init ctor_initializer_opt compstmt_or_error
2104 expand_body (finish_function (lineno, (int)$3 | 2));
2105 process_next_inline ($1);
2107 | fn.defpen maybe_return_init function_try_block
2109 expand_body (finish_function (lineno, (int)$3 | 2));
2110 process_next_inline ($1);
2112 | fn.defpen maybe_return_init error
2114 finish_function (lineno, 2);
2115 process_next_inline ($1); }
2120 | pending_inlines pending_inline eat_saved_input
2123 /* A regurgitated default argument. The value of DEFARG_MARKER will be
2124 the TREE_LIST node for the parameter in question. */
2126 DEFARG_MARKER expr_no_commas END_OF_SAVED_INPUT
2127 { replace_defarg ($1, $2); }
2128 | DEFARG_MARKER error END_OF_SAVED_INPUT
2129 { replace_defarg ($1, error_mark_node); }
2132 /* empty */ %prec EMPTY
2133 | pending_defargs defarg_again
2134 { do_pending_defargs (); }
2135 | pending_defargs error
2136 { do_pending_defargs (); }
2141 { $<ttype>$ = current_enum_type;
2142 current_enum_type = start_enum ($2); }
2144 { $$.t = finish_enum (current_enum_type);
2145 $$.new_type_flag = 1;
2146 current_enum_type = $<ttype>4;
2147 check_for_missing_semicolon ($$.t); }
2149 { $<ttype>$ = current_enum_type;
2150 current_enum_type = start_enum (make_anon_name ()); }
2152 { $$.t = finish_enum (current_enum_type);
2153 $$.new_type_flag = 1;
2154 current_enum_type = $<ttype>3;
2155 check_for_missing_semicolon ($$.t); }
2157 { $$.t = xref_tag (enum_type_node, $2, 1);
2158 $$.new_type_flag = 0; }
2159 | ENUM complex_type_name
2160 { $$.t = xref_tag (enum_type_node, $2, 1);
2161 $$.new_type_flag = 0; }
2162 | TYPENAME_KEYWORD typename_sub
2164 $$.new_type_flag = 0;
2165 if (!processing_template_decl)
2166 cp_pedwarn ("using `typename' outside of template"); }
2167 /* C++ extensions, merged with C to avoid shift/reduce conflicts */
2169 { $1.t = begin_class_definition ($1.t); }
2170 opt.component_decl_list '}' maybe_attribute
2174 if (yychar == YYEMPTY)
2176 semi = yychar == ';';
2178 $<ttype>$ = finish_class_definition ($1.t, $6, semi,
2183 begin_inline_definitions ();
2187 finish_inline_definitions ();
2189 $$.new_type_flag = 1;
2191 | class_head %prec EMPTY
2193 if ($1.new_type_flag && $1.t != error_mark_node)
2194 pop_scope (CP_DECL_CONTEXT (TYPE_MAIN_DECL ($1.t)));
2195 $$.new_type_flag = 0;
2196 if ($1.t == error_mark_node)
2198 else if (TYPE_BINFO ($1.t) == NULL_TREE)
2200 cp_error ("%T is not a class type", $1.t);
2201 $$.t = error_mark_node;
2206 /* struct B: public A; is not accepted by the standard grammar. */
2207 if (CLASS_TYPE_P ($$.t)
2208 && TYPE_BINFO_BASETYPES ($$.t)
2209 && !TYPE_SIZE ($$.t)
2210 && ! TYPE_BEING_DEFINED ($$.t))
2211 cp_error ("base clause without member specification for `%#T'",
2225 { if (pedantic && !in_system_header)
2226 pedwarn ("comma at end of enumerator list"); }
2232 { error ("storage class specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2234 { error ("type specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2236 { error ("type qualifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2238 { error ("no body nor ';' separates two class, struct or union declarations"); }
2240 { $$ = build_decl_list ($2, $1); }
2243 named_class_head_sans_basetype:
2251 named_class_head_sans_basetype_defn:
2252 aggr identifier_defn %prec EMPTY
2253 { current_aggr = $$; $$ = $2; }
2254 | named_class_head_sans_basetype '{'
2255 { yyungetc ('{', 1); }
2256 | named_class_head_sans_basetype ':'
2257 { yyungetc (':', 1); }
2260 named_complex_class_head_sans_basetype:
2261 aggr nested_name_specifier identifier
2264 $$.t = handle_class_head ($1, $2, $3);
2265 $$.new_type_flag = 1;
2267 | aggr global_scope nested_name_specifier identifier
2270 $$.t = handle_class_head ($1, $3, $4);
2271 $$.new_type_flag = 1;
2273 | aggr global_scope identifier
2276 $$.t = handle_class_head ($1, NULL_TREE, $3);
2277 $$.new_type_flag = 1;
2279 | aggr apparent_template_type
2283 $$.new_type_flag = 0;
2285 | aggr nested_name_specifier apparent_template_type
2289 if (CP_DECL_CONTEXT ($$.t))
2290 push_scope (CP_DECL_CONTEXT ($$.t));
2291 $$.new_type_flag = 1;
2296 named_class_head_sans_basetype %prec EMPTY
2298 $$.t = xref_tag (current_aggr, $1, 1);
2299 $$.new_type_flag = 0;
2301 | named_class_head_sans_basetype_defn
2302 { $<ttype>$ = xref_tag (current_aggr, $1, 0); }
2303 /* Class name is unqualified, so we look for base classes
2304 in the current scope. */
2305 maybe_base_class_list %prec EMPTY
2308 $$.new_type_flag = 0;
2310 xref_basetypes (current_aggr, $1, $<ttype>2, $3);
2312 | named_complex_class_head_sans_basetype
2313 maybe_base_class_list
2315 if ($1.t != error_mark_node)
2317 $$.t = TREE_TYPE ($1.t);
2318 $$.new_type_flag = $1.new_type_flag;
2319 if (current_aggr == union_type_node
2320 && TREE_CODE ($$.t) != UNION_TYPE)
2321 cp_pedwarn ("`union' tag used in declaring `%#T'",
2323 else if (TREE_CODE ($$.t) == UNION_TYPE
2324 && current_aggr != union_type_node)
2325 cp_pedwarn ("non-`union' tag used in declaring `%#T'", $$);
2326 else if (TREE_CODE ($$.t) == RECORD_TYPE)
2327 /* We might be specializing a template with a different
2329 CLASSTYPE_DECLARED_CLASS ($$.t)
2330 = (current_aggr == class_type_node);
2333 maybe_process_partial_specialization ($$.t);
2334 xref_basetypes (current_aggr, $1.t, $$.t, $2);
2342 { $$ = xref_tag ($$, make_anon_name (), 0);
2343 yyungetc ('{', 1); }
2346 /* The tree output of this nonterminal a declarationf or the type
2347 named. If NEW_TYPE_FLAG is set, then the name used in this
2348 class-head was explicitly qualified, e.g.: `struct X::Y'. We have
2349 already called push_scope for X. */
2354 $$.new_type_flag = 0;
2359 maybe_base_class_list:
2360 /* empty */ %prec EMPTY
2362 | ':' see_typename %prec EMPTY
2363 { yyungetc(':', 1); $$ = NULL_TREE; }
2364 | ':' see_typename base_class_list %prec EMPTY
2370 | base_class_list ',' see_typename base_class
2371 { $$ = chainon ($$, $4); }
2376 { $$ = finish_base_specifier (access_default_node, $1); }
2377 | base_class_access_list see_typename base_class.1
2378 { $$ = finish_base_specifier ($1, $3); }
2383 { if ($$ == error_mark_node)
2385 else if (!TYPE_P ($$))
2386 $$ = error_mark_node;
2388 $$ = TYPE_MAIN_DECL ($1); }
2392 base_class_access_list:
2393 VISSPEC see_typename
2394 | SCSPEC see_typename
2395 { if ($1 != ridpointers[(int)RID_VIRTUAL])
2396 cp_error ("`%D' access", $1);
2397 $$ = access_default_virtual_node; }
2398 | base_class_access_list VISSPEC see_typename
2400 if ($1 != access_default_virtual_node)
2401 error ("multiple access specifiers");
2402 else if ($2 == access_public_node)
2403 $$ = access_public_virtual_node;
2404 else if ($2 == access_protected_node)
2405 $$ = access_protected_virtual_node;
2406 else /* $2 == access_private_node */
2407 $$ = access_private_virtual_node;
2409 | base_class_access_list SCSPEC see_typename
2410 { if ($2 != ridpointers[(int)RID_VIRTUAL])
2411 cp_error ("`%D' access", $2);
2412 else if ($$ == access_public_node)
2413 $$ = access_public_virtual_node;
2414 else if ($$ == access_protected_node)
2415 $$ = access_protected_virtual_node;
2416 else if ($$ == access_private_node)
2417 $$ = access_private_virtual_node;
2419 error ("multiple `virtual' specifiers");
2423 opt.component_decl_list:
2424 | component_decl_list
2425 | opt.component_decl_list access_specifier component_decl_list
2426 | opt.component_decl_list access_specifier
2432 current_access_specifier = $1;
2436 /* Note: we no longer warn about the semicolon after a component_decl_list.
2437 ARM $9.2 says that the semicolon is optional, and therefore allowed. */
2438 component_decl_list:
2441 finish_member_declaration ($1);
2443 | component_decl_list component_decl
2445 finish_member_declaration ($2);
2450 component_decl_1 ';'
2451 | component_decl_1 '}'
2452 { error ("missing ';' before right brace");
2453 yyungetc ('}', 0); }
2454 /* C++: handle constructors, destructors and inline functions */
2455 /* note that INLINE is like a TYPESPEC */
2456 | fn.def2 ':' /* base_init compstmt */
2457 { $$ = finish_method ($$); }
2458 | fn.def2 TRY /* base_init compstmt */
2459 { $$ = finish_method ($$); }
2460 | fn.def2 RETURN_KEYWORD /* base_init compstmt */
2461 { $$ = finish_method ($$); }
2462 | fn.def2 '{' /* nodecls compstmt */
2463 { $$ = finish_method ($$); }
2466 | extension component_decl
2469 | template_header component_decl
2472 $$ = finish_member_template_decl ($2);
2474 /* The component was already processed. */
2477 finish_template_decl ($1);
2479 | template_header typed_declspecs ';'
2481 $$ = finish_member_class_template ($2.t);
2482 finish_template_decl ($1);
2487 /* Do not add a "typed_declspecs declarator" rule here for
2488 speed; we need to call grok_x_components for enums, so the
2489 speedup would be insignificant. */
2490 typed_declspecs components
2492 /* Most of the productions for component_decl only
2493 allow the creation of one new member, so we call
2494 finish_member_declaration in component_decl_list.
2495 For this rule and the next, however, there can be
2496 more than one member, e.g.:
2500 and we need the first member to be fully
2501 registered before the second is processed.
2502 Therefore, the rules for components take care of
2503 this processing. To avoid registering the
2504 components more than once, we send NULL_TREE up
2505 here; that lets finish_member_declaration know
2506 that there is nothing to do. */
2508 grok_x_components ($1.t);
2511 | declmods notype_components
2514 grok_x_components ($1.t);
2517 | notype_declarator maybeasm maybe_attribute maybe_init
2518 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2519 build_tree_list ($3, NULL_TREE)); }
2520 | constructor_declarator maybeasm maybe_attribute maybe_init
2521 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2522 build_tree_list ($3, NULL_TREE)); }
2523 | ':' expr_no_commas
2524 { $$ = grokbitfield (NULL_TREE, NULL_TREE, $2); }
2528 /* These rules introduce a reduce/reduce conflict; in
2529 typedef int foo, bar;
2533 should "A::foo" be declared as a function or "A::bar" as a data
2534 member? In other words, is "bar" an after_type_declarator or a
2536 | declmods component_constructor_declarator maybeasm maybe_attribute maybe_init
2537 { tree specs, attrs;
2538 split_specs_attrs ($1.t, &specs, &attrs);
2539 $$ = grokfield ($2, specs, $5, $3,
2540 build_tree_list ($4, attrs)); }
2541 | component_constructor_declarator maybeasm maybe_attribute maybe_init
2542 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2543 build_tree_list ($3, NULL_TREE)); }
2545 { $$ = do_class_using_decl ($1); }
2547 /* The case of exactly one component is handled directly by component_decl. */
2550 /* empty: possibly anonymous */
2552 | component_declarator0
2554 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2555 $1 = finish_member_template_decl ($1);
2556 finish_member_declaration ($1);
2559 | components ',' component_declarator
2561 check_multiple_declarators ();
2562 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2563 $3 = finish_member_template_decl ($3);
2564 finish_member_declaration ($3);
2570 /* empty: possibly anonymous */
2572 | notype_component_declarator0
2574 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2575 $1 = finish_member_template_decl ($1);
2576 finish_member_declaration ($1);
2579 | notype_components ',' notype_component_declarator
2581 check_multiple_declarators ();
2582 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2583 $3 = finish_member_template_decl ($3);
2584 finish_member_declaration ($3);
2589 component_declarator0:
2590 after_type_component_declarator0
2591 | notype_component_declarator0
2594 component_declarator:
2595 after_type_component_declarator
2596 | notype_component_declarator
2599 after_type_component_declarator0:
2600 after_type_declarator maybeasm maybe_attribute maybe_init
2601 { $$ = parse_field0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2603 | TYPENAME ':' expr_no_commas maybe_attribute
2604 { $$ = parse_bitfield0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2608 notype_component_declarator0:
2609 notype_declarator maybeasm maybe_attribute maybe_init
2610 { $$ = parse_field0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2612 | constructor_declarator maybeasm maybe_attribute maybe_init
2613 { $$ = parse_field0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2615 | IDENTIFIER ':' expr_no_commas maybe_attribute
2616 { $$ = parse_bitfield0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2618 | ':' expr_no_commas maybe_attribute
2619 { $$ = parse_bitfield0 (NULL_TREE, $<ftype>0.t,
2620 $<ftype>0.lookups, $3, $2); }
2623 after_type_component_declarator:
2624 after_type_declarator maybeasm maybe_attribute maybe_init
2625 { $$ = parse_field ($1, $3, $2, $4); }
2626 | TYPENAME ':' expr_no_commas maybe_attribute
2627 { $$ = parse_bitfield ($1, $4, $3); }
2630 notype_component_declarator:
2631 notype_declarator maybeasm maybe_attribute maybe_init
2632 { $$ = parse_field ($1, $3, $2, $4); }
2633 | IDENTIFIER ':' expr_no_commas maybe_attribute
2634 { $$ = parse_bitfield ($1, $4, $3); }
2635 | ':' expr_no_commas maybe_attribute
2636 { $$ = parse_bitfield (NULL_TREE, $3, $2); }
2640 enumlist maybecomma_warn
2644 /* We chain the enumerators in reverse order.
2645 Because of the way enums are built, the order is
2646 insignificant. Take advantage of this fact. */
2650 | enumlist ',' enumerator
2655 { build_enumerator ($1, NULL_TREE, current_enum_type); }
2656 | identifier '=' expr_no_commas
2657 { build_enumerator ($1, $3, current_enum_type); }
2660 /* ISO new-type-id (5.3.4) */
2662 type_specifier_seq new_declarator
2663 { $$.t = build_decl_list ($1.t, $2);
2664 $$.new_type_flag = $1.new_type_flag; }
2665 | type_specifier_seq %prec EMPTY
2666 { $$.t = build_decl_list ($1.t, NULL_TREE);
2667 $$.new_type_flag = $1.new_type_flag; }
2668 /* GNU extension to allow arrays of arbitrary types with
2669 non-constant dimension. */
2670 | '(' type_id ')' '[' expr ']'
2673 pedwarn ("ISO C++ forbids array dimensions with parenthesized type in new");
2674 $$.t = build_parse_node (ARRAY_REF, TREE_VALUE ($2.t), $5);
2675 $$.t = build_decl_list (TREE_PURPOSE ($2.t), $$.t);
2676 $$.new_type_flag = $2.new_type_flag;
2681 /* empty */ %prec EMPTY
2683 | cv_qualifiers CV_QUALIFIER
2684 { $$ = decl_tree_cons (NULL_TREE, $2, $$); }
2687 nonempty_cv_qualifiers:
2689 { $$.t = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
2690 $$.new_type_flag = 0; }
2691 | nonempty_cv_qualifiers CV_QUALIFIER
2692 { $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
2693 $$.new_type_flag = $1.new_type_flag; }
2696 /* These rules must follow the rules for function declarations
2697 and component declarations. That way, longer rules are preferred. */
2699 /* An expression which will not live on the momentary obstack. */
2701 '(' nonnull_exprlist ')'
2706 { $$ = empty_parms (); }
2711 /* A declarator that is allowed only after an explicit typespec. */
2713 after_type_declarator_intern:
2714 after_type_declarator
2715 | attributes after_type_declarator
2717 /* Provide support for '(' attributes '*' declarator ')'
2719 $$ = decl_tree_cons ($1, $2, NULL_TREE);
2723 /* may all be followed by prec '.' */
2724 after_type_declarator:
2725 '*' nonempty_cv_qualifiers after_type_declarator_intern %prec UNARY
2726 { $$ = make_pointer_declarator ($2.t, $3); }
2727 | '&' nonempty_cv_qualifiers after_type_declarator_intern %prec UNARY
2728 { $$ = make_reference_declarator ($2.t, $3); }
2729 | '*' after_type_declarator_intern %prec UNARY
2730 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2731 | '&' after_type_declarator_intern %prec UNARY
2732 { $$ = make_reference_declarator (NULL_TREE, $2); }
2733 | ptr_to_mem cv_qualifiers after_type_declarator_intern
2734 { tree arg = make_pointer_declarator ($2, $3);
2735 $$ = build_parse_node (SCOPE_REF, $1, arg);
2737 | direct_after_type_declarator
2740 direct_after_type_declarator:
2741 direct_after_type_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2742 { $$ = make_call_declarator ($$, $2, $3, $4); }
2743 | direct_after_type_declarator '[' expr ']'
2744 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
2745 | direct_after_type_declarator '[' ']'
2746 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
2747 | '(' after_type_declarator_intern ')'
2749 | nested_name_specifier type_name %prec EMPTY
2750 { push_nested_class ($1, 3);
2751 $$ = build_parse_node (SCOPE_REF, $$, $2);
2752 TREE_COMPLEXITY ($$) = current_class_depth; }
2753 | type_name %prec EMPTY
2757 type_name %prec EMPTY
2759 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2761 $$ = lookup_name ($1, 1);
2762 maybe_note_name_used_in_class ($1, $$);
2767 | global_scope type_name
2769 if (TREE_CODE ($2) == IDENTIFIER_NODE)
2770 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
2773 got_scope = NULL_TREE;
2780 | global_scope nested_type
2785 nested_name_specifier type_name %prec EMPTY
2786 { $$ = get_type_decl ($2); }
2789 /* A declarator allowed whether or not there has been
2790 an explicit typespec. These cannot redeclare a typedef-name. */
2792 notype_declarator_intern:
2794 | attributes notype_declarator
2796 /* Provide support for '(' attributes '*' declarator ')'
2798 $$ = decl_tree_cons ($1, $2, NULL_TREE);
2803 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2804 { $$ = make_pointer_declarator ($2.t, $3); }
2805 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2806 { $$ = make_reference_declarator ($2.t, $3); }
2807 | '*' notype_declarator_intern %prec UNARY
2808 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2809 | '&' notype_declarator_intern %prec UNARY
2810 { $$ = make_reference_declarator (NULL_TREE, $2); }
2811 | ptr_to_mem cv_qualifiers notype_declarator_intern
2812 { tree arg = make_pointer_declarator ($2, $3);
2813 $$ = build_parse_node (SCOPE_REF, $1, arg);
2815 | direct_notype_declarator
2818 complex_notype_declarator:
2819 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2820 { $$ = make_pointer_declarator ($2.t, $3); }
2821 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2822 { $$ = make_reference_declarator ($2.t, $3); }
2823 | '*' complex_notype_declarator %prec UNARY
2824 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2825 | '&' complex_notype_declarator %prec UNARY
2826 { $$ = make_reference_declarator (NULL_TREE, $2); }
2827 | ptr_to_mem cv_qualifiers notype_declarator_intern
2828 { tree arg = make_pointer_declarator ($2, $3);
2829 $$ = build_parse_node (SCOPE_REF, $1, arg);
2831 | complex_direct_notype_declarator
2834 complex_direct_notype_declarator:
2835 direct_notype_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2836 { $$ = make_call_declarator ($$, $2, $3, $4); }
2837 | '(' complex_notype_declarator ')'
2839 | direct_notype_declarator '[' expr ']'
2840 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
2841 | direct_notype_declarator '[' ']'
2842 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
2843 | notype_qualified_id
2844 { enter_scope_of ($1); }
2845 | nested_name_specifier notype_template_declarator
2846 { got_scope = NULL_TREE;
2847 $$ = build_parse_node (SCOPE_REF, $1, $2);
2848 enter_scope_of ($$);
2853 nested_name_specifier unqualified_id
2854 { got_scope = NULL_TREE;
2855 $$ = build_parse_node (SCOPE_REF, $$, $2); }
2856 | nested_name_specifier object_template_id
2857 { got_scope = NULL_TREE;
2858 $$ = build_parse_node (SCOPE_REF, $1, $2); }
2861 notype_qualified_id:
2862 nested_name_specifier notype_unqualified_id
2863 { got_scope = NULL_TREE;
2864 $$ = build_parse_node (SCOPE_REF, $$, $2); }
2865 | nested_name_specifier object_template_id
2866 { got_scope = NULL_TREE;
2867 $$ = build_parse_node (SCOPE_REF, $1, $2); }
2872 | global_scope notype_qualified_id
2877 typespec '(' nonnull_exprlist ')'
2878 { $$ = build_functional_cast ($1.t, $3); }
2879 | typespec '(' expr_or_declarator_intern ')'
2880 { $$ = reparse_decl_as_expr ($1.t, $3); }
2881 | typespec fcast_or_absdcl %prec EMPTY
2882 { $$ = reparse_absdcl_as_expr ($1.t, $2); }
2888 | template_type %prec EMPTY
2891 nested_name_specifier:
2892 nested_name_specifier_1
2893 | nested_name_specifier nested_name_specifier_1
2895 | nested_name_specifier TEMPLATE explicit_template_type SCOPE
2897 = make_typename_type ($1, $3, /*complain=*/1); }
2900 /* Why the @#$%^& do type_name and notype_identifier need to be expanded
2901 inline here?!? (jason) */
2902 nested_name_specifier_1:
2905 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2908 maybe_note_name_used_in_class ($1, $$);
2911 complete_type (TYPE_MAIN_VARIANT (TREE_TYPE ($$)));
2915 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2917 got_scope = $$ = TREE_TYPE ($$);
2921 if (TREE_CODE ($$) == IDENTIFIER_NODE)
2925 | template_type SCOPE
2926 { got_scope = $$ = complete_type (TREE_TYPE ($1)); }
2927 /* These break 'const i;'
2931 cp_error ("`%D' is not an aggregate typedef",
2932 lastiddecl ? lastiddecl : $$);
2933 $$ = error_mark_node;
2936 { goto failed_scope; } */
2941 | global_scope typename_sub0
2946 typename_sub1 identifier %prec EMPTY
2948 if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't')
2949 $$ = make_typename_type ($1, $2, /*complain=*/1);
2950 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
2951 cp_error ("`%T' is not a class or namespace", $2);
2955 if (TREE_CODE ($$) == TYPE_DECL)
2956 $$ = TREE_TYPE ($$);
2959 | typename_sub1 template_type %prec EMPTY
2960 { $$ = TREE_TYPE ($2); }
2961 | typename_sub1 explicit_template_type %prec EMPTY
2962 { $$ = make_typename_type ($1, $2, /*complain=*/1); }
2963 | typename_sub1 TEMPLATE explicit_template_type %prec EMPTY
2964 { $$ = make_typename_type ($1, $3, /*complain=*/1); }
2970 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2971 cp_error ("`%T' is not a class or namespace", $1);
2973 | typename_sub1 typename_sub2
2975 if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't')
2976 $$ = make_typename_type ($1, $2, /*complain=*/1);
2977 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
2978 cp_error ("`%T' is not a class or namespace", $2);
2982 if (TREE_CODE ($$) == TYPE_DECL)
2983 $$ = TREE_TYPE ($$);
2986 | typename_sub1 explicit_template_type SCOPE
2988 = make_typename_type ($1, $2, /*complain=*/1); }
2989 | typename_sub1 TEMPLATE explicit_template_type SCOPE
2991 = make_typename_type ($1, $3, /*complain=*/1); }
2997 if (TREE_CODE ($1) != IDENTIFIER_NODE)
3000 /* Retrieve the type for the identifier, which might involve
3001 some computation. */
3002 got_scope = $$ = complete_type (IDENTIFIER_TYPE_VALUE ($1));
3004 if ($$ == error_mark_node)
3005 cp_error ("`%T' is not a class or namespace", $1);
3009 if (TREE_CODE ($1) != IDENTIFIER_NODE)
3011 got_scope = $$ = complete_type (TREE_TYPE ($$));
3013 | template_type SCOPE
3014 { got_scope = $$ = complete_type (TREE_TYPE ($$)); }
3019 if (TREE_CODE ($$) == IDENTIFIER_NODE)
3025 explicit_template_type:
3026 identifier '<' template_arg_list_opt template_close_bracket
3027 { $$ = build_min_nt (TEMPLATE_ID_EXPR, $1, $3); }
3031 global_scope type_name
3033 if (TREE_CODE ($2) == IDENTIFIER_NODE)
3034 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
3037 got_scope = NULL_TREE;
3040 | global_scope nested_type
3045 nested_name_specifier '*'
3046 { got_scope = NULL_TREE; }
3047 | global_scope nested_name_specifier '*'
3048 { $$ = $2; got_scope = NULL_TREE; }
3051 /* All uses of explicit global scope must go through this nonterminal so
3052 that got_scope will be set before yylex is called to get the next token. */
3055 { got_scope = void_type_node; }
3058 /* ISO new-declarator (5.3.4) */
3060 '*' cv_qualifiers new_declarator
3061 { $$ = make_pointer_declarator ($2, $3); }
3062 | '*' cv_qualifiers %prec EMPTY
3063 { $$ = make_pointer_declarator ($2, NULL_TREE); }
3064 | '&' cv_qualifiers new_declarator %prec EMPTY
3065 { $$ = make_reference_declarator ($2, $3); }
3066 | '&' cv_qualifiers %prec EMPTY
3067 { $$ = make_reference_declarator ($2, NULL_TREE); }
3068 | ptr_to_mem cv_qualifiers %prec EMPTY
3069 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3070 $$ = build_parse_node (SCOPE_REF, $1, arg);
3072 | ptr_to_mem cv_qualifiers new_declarator
3073 { tree arg = make_pointer_declarator ($2, $3);
3074 $$ = build_parse_node (SCOPE_REF, $1, arg);
3076 | direct_new_declarator %prec EMPTY
3079 /* ISO direct-new-declarator (5.3.4) */
3080 direct_new_declarator:
3082 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3083 | direct_new_declarator '[' expr ']'
3084 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3091 /* Provide support for '(' attributes '*' declarator ')'
3093 $$ = decl_tree_cons ($1, $2, NULL_TREE);
3097 /* ISO abstract-declarator (8.1) */
3099 '*' nonempty_cv_qualifiers absdcl_intern
3100 { $$ = make_pointer_declarator ($2.t, $3); }
3102 { $$ = make_pointer_declarator (NULL_TREE, $2); }
3103 | '*' nonempty_cv_qualifiers %prec EMPTY
3104 { $$ = make_pointer_declarator ($2.t, NULL_TREE); }
3106 { $$ = make_pointer_declarator (NULL_TREE, NULL_TREE); }
3107 | '&' nonempty_cv_qualifiers absdcl_intern
3108 { $$ = make_reference_declarator ($2.t, $3); }
3110 { $$ = make_reference_declarator (NULL_TREE, $2); }
3111 | '&' nonempty_cv_qualifiers %prec EMPTY
3112 { $$ = make_reference_declarator ($2.t, NULL_TREE); }
3114 { $$ = make_reference_declarator (NULL_TREE, NULL_TREE); }
3115 | ptr_to_mem cv_qualifiers %prec EMPTY
3116 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3117 $$ = build_parse_node (SCOPE_REF, $1, arg);
3119 | ptr_to_mem cv_qualifiers absdcl_intern
3120 { tree arg = make_pointer_declarator ($2, $3);
3121 $$ = build_parse_node (SCOPE_REF, $1, arg);
3123 | direct_abstract_declarator %prec EMPTY
3126 /* ISO direct-abstract-declarator (8.1) */
3127 direct_abstract_declarator:
3128 '(' absdcl_intern ')'
3130 /* `(typedef)1' is `int'. */
3131 | direct_abstract_declarator '(' parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3132 { $$ = make_call_declarator ($$, $3, $5, $6); }
3133 | direct_abstract_declarator LEFT_RIGHT cv_qualifiers exception_specification_opt %prec '.'
3134 { $$ = make_call_declarator ($$, empty_parms (), $3, $4); }
3135 | direct_abstract_declarator '[' expr ']' %prec '.'
3136 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3137 | direct_abstract_declarator '[' ']' %prec '.'
3138 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
3139 | '(' complex_parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3140 { $$ = make_call_declarator (NULL_TREE, $2, $4, $5); }
3141 | regcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3142 { set_quals_and_spec ($$, $2, $3); }
3143 | fcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3144 { set_quals_and_spec ($$, $2, $3); }
3145 | '[' expr ']' %prec '.'
3146 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3148 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, NULL_TREE); }
3151 /* For C++, decls and stmts can be intermixed, so we don't need to
3152 have a special rule that won't start parsing the stmt section
3153 until we have a stmt that parses without errors. */
3166 /* Read zero or more forward-declarations for labels
3167 that nested functions can jump to. */
3172 pedwarn ("ISO C++ forbids label declarations"); }
3177 | label_decls label_decl
3181 LABEL identifiers_or_typenames ';'
3185 finish_label_decl (TREE_VALUE ($2));
3186 $2 = TREE_CHAIN ($2);
3191 /* This is the body of a function definition.
3192 It causes syntax errors to ignore to the next openbrace. */
3201 { $<ttype>$ = begin_compound_stmt (0); }
3203 { $$ = finish_compound_stmt (0, $<ttype>2); }
3209 $<ttype>$ = begin_if_stmt ();
3210 cond_stmt_keyword = "if";
3213 { finish_if_stmt_cond ($3, $<ttype>2); }
3214 implicitly_scoped_stmt
3215 { $<ttype>$ = finish_then_clause ($<ttype>2); }
3218 implicitly_scoped_stmt:
3220 | { $<ttype>$ = begin_compound_stmt (0); }
3222 { $$ = finish_compound_stmt (0, $<ttype>1); }
3235 { finish_expr_stmt ($1); }
3237 { begin_else_clause (); }
3238 implicitly_scoped_stmt
3240 finish_else_clause ($<ttype>1);
3243 | simple_if %prec IF
3244 { finish_if_stmt (); }
3247 $<ttype>$ = begin_while_stmt ();
3248 cond_stmt_keyword = "while";
3251 { finish_while_stmt_cond ($3, $<ttype>2); }
3253 { finish_while_stmt ($<ttype>2); }
3255 { $<ttype>$ = begin_do_stmt (); }
3256 implicitly_scoped_stmt WHILE
3258 finish_do_body ($<ttype>2);
3259 cond_stmt_keyword = "do";
3261 paren_expr_or_null ';'
3262 { finish_do_stmt ($6, $<ttype>2); }
3264 { $<ttype>$ = begin_for_stmt (); }
3265 '(' for.init.statement
3266 { finish_for_init_stmt ($<ttype>2); }
3268 { finish_for_cond ($6, $<ttype>2); }
3270 { finish_for_expr ($9, $<ttype>2); }
3272 { finish_for_stmt ($9, $<ttype>2); }
3274 { $<ttype>$ = begin_switch_stmt (); }
3276 { finish_switch_cond ($4, $<ttype>2); }
3277 implicitly_scoped_stmt
3278 { finish_switch_stmt ($4, $<ttype>2); }
3279 | CASE expr_no_commas ':'
3280 { finish_case_label ($2, NULL_TREE); }
3282 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
3283 { finish_case_label ($2, $4); }
3286 { finish_case_label (NULL_TREE, NULL_TREE); }
3289 { finish_break_stmt (); }
3291 { finish_continue_stmt (); }
3292 | RETURN_KEYWORD ';'
3293 { finish_return_stmt (NULL_TREE); }
3294 | RETURN_KEYWORD expr ';'
3295 { finish_return_stmt ($2); }
3296 | asm_keyword maybe_cv_qualifier '(' string ')' ';'
3298 finish_asm_stmt ($2, $4, NULL_TREE, NULL_TREE,
3301 /* This is the case with just output operands. */
3302 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ')' ';'
3304 finish_asm_stmt ($2, $4, $6, NULL_TREE,
3307 /* This is the case with input operands as well. */
3308 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':' asm_operands ')' ';'
3309 { finish_asm_stmt ($2, $4, $6, $8, NULL_TREE); }
3310 | asm_keyword maybe_cv_qualifier '(' string SCOPE asm_operands ')' ';'
3311 { finish_asm_stmt ($2, $4, NULL_TREE, $6, NULL_TREE); }
3312 /* This is the case with clobbered registers as well. */
3313 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':'
3314 asm_operands ':' asm_clobbers ')' ';'
3315 { finish_asm_stmt ($2, $4, $6, $8, $10); }
3316 | asm_keyword maybe_cv_qualifier '(' string SCOPE asm_operands ':'
3317 asm_clobbers ')' ';'
3318 { finish_asm_stmt ($2, $4, NULL_TREE, $6, $8); }
3319 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands SCOPE
3320 asm_clobbers ')' ';'
3321 { finish_asm_stmt ($2, $4, $6, NULL_TREE, $8); }
3325 pedwarn ("ISO C++ forbids computed gotos");
3326 finish_goto_stmt ($3);
3328 | GOTO identifier ';'
3329 { finish_goto_stmt ($2); }
3332 { error ("label must be followed by statement");
3333 yyungetc ('}', 0); }
3338 | namespace_using_decl
3339 { do_local_using_decl ($1); }
3345 { $<ttype>$ = begin_function_try_block (); }
3346 ctor_initializer_opt compstmt
3347 { finish_function_try_block ($<ttype>2); }
3350 finish_function_handler_sequence ($<ttype>2);
3357 { $<ttype>$ = begin_try_block (); }
3359 { finish_try_block ($<ttype>2); }
3361 { finish_handler_sequence ($<ttype>2); }
3366 | handler_seq handler
3371 { $<ttype>$ = begin_handler(); }
3373 { $<ttype>$ = finish_handler_parms ($3, $<ttype>2); }
3375 { finish_handler ($<ttype>4, $<ttype>2); }
3379 typed_typespecs %prec EMPTY
3380 | nonempty_cv_qualifiers %prec EMPTY
3386 /* This doesn't allow reference parameters, the below does.
3387 | '(' type_specifier_seq absdcl ')'
3388 { check_for_new_type ("inside exception declarations", $2);
3389 expand_start_catch_block ($2.t, $3); }
3390 | '(' type_specifier_seq ')'
3391 { check_for_new_type ("inside exception declarations", $2);
3392 expand_start_catch_block ($2.t, NULL_TREE); }
3393 | '(' type_specifier_seq notype_declarator ')'
3394 { check_for_new_type ("inside exception declarations", $2);
3395 expand_start_catch_block ($2.t, $3); }
3396 | '(' typed_typespecs after_type_declarator ')'
3397 { check_for_new_type ("inside exception declarations", $2);
3398 expand_start_catch_block ($2.t, $3); }
3399 This allows reference parameters... */
3402 check_for_new_type ("inside exception declarations", $2);
3403 $$ = start_handler_parms (TREE_PURPOSE ($2.t),
3410 { finish_label_stmt ($1); }
3412 { finish_label_stmt ($1); }
3414 { finish_label_stmt ($1); }
3416 { finish_label_stmt ($1); }
3421 { finish_expr_stmt ($1); }
3425 pedwarn ("ISO C++ forbids compound statements inside for initializations");
3429 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
3445 /* These are the operands other than the first string and colon
3446 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
3450 | nonnull_asm_operands
3453 nonnull_asm_operands:
3455 | nonnull_asm_operands ',' asm_operand
3456 { $$ = chainon ($$, $3); }
3461 { $$ = build_tree_list ($$, $3); }
3466 { $$ = tree_cons (NULL_TREE, $$, NULL_TREE); }
3467 | asm_clobbers ',' STRING
3468 { $$ = tree_cons (NULL_TREE, $3, $$); }
3471 /* This is what appears inside the parens in a function declarator.
3472 Its value is represented in the format that grokdeclarator expects.
3474 In C++, declaring a function with no parameters
3475 means that that function takes *no* parameters. */
3484 { $$ = finish_parmlist (build_tree_list (NULL_TREE, $1.t), 0);
3485 check_for_new_type ("inside parameter list", $1); }
3488 /* This nonterminal does not include the common sequence '(' type_id ')',
3489 as it is ambiguous and must be disambiguated elsewhere. */
3492 { $$ = finish_parmlist ($$, 0); }
3493 | parms_comma ELLIPSIS
3494 { $$ = finish_parmlist ($1, 1); }
3495 /* C++ allows an ellipsis without a separating ',' */
3497 { $$ = finish_parmlist ($1, 1); }
3499 { $$ = finish_parmlist (build_tree_list (NULL_TREE,
3502 { $$ = finish_parmlist (NULL_TREE, 1); }
3505 /* This helps us recover from really nasty
3506 parse errors, for example, a missing right
3508 yyerror ("possibly missing ')'");
3509 $$ = finish_parmlist ($1, 0);
3515 /* This helps us recover from really nasty
3516 parse errors, for example, a missing right
3518 yyerror ("possibly missing ')'");
3519 $$ = finish_parmlist (build_tree_list (NULL_TREE,
3526 /* A default argument to a */
3529 { maybe_snarf_defarg (); }
3539 /* A nonempty list of parameter declarations or type names. */
3542 { check_for_new_type ("in a parameter list", $1);
3543 $$ = build_tree_list (NULL_TREE, $1.t); }
3545 { check_for_new_type ("in a parameter list", $1);
3546 $$ = build_tree_list ($2, $1.t); }
3547 | parms_comma full_parm
3548 { check_for_new_type ("in a parameter list", $2);
3549 $$ = chainon ($$, $2.t); }
3550 | parms_comma bad_parm
3551 { $$ = chainon ($$, build_tree_list (NULL_TREE, $2)); }
3552 | parms_comma bad_parm '=' init
3553 { $$ = chainon ($$, build_tree_list ($4, $2)); }
3559 { check_for_new_type ("in a parameter list", $1);
3560 $$ = build_tree_list (NULL_TREE, $1.t); }
3563 /* A single parameter declaration or parameter type name,
3564 as found in a parmlist. */
3566 /* Here we expand typed_declspecs inline to avoid mis-parsing of
3567 TYPESPEC IDENTIFIER. */
3568 typed_declspecs1 declarator
3569 { tree specs = strip_attrs ($1.t);
3570 $$.new_type_flag = $1.new_type_flag;
3571 $$.t = build_tree_list (specs, $2); }
3572 | typed_typespecs declarator
3573 { $$.t = build_tree_list ($1.t, $2);
3574 $$.new_type_flag = $1.new_type_flag; }
3575 | typespec declarator
3576 { $$.t = build_tree_list (build_decl_list (NULL_TREE, $1.t),
3578 $$.new_type_flag = $1.new_type_flag; }
3579 | typed_declspecs1 absdcl
3580 { tree specs = strip_attrs ($1.t);
3581 $$.t = build_tree_list (specs, $2);
3582 $$.new_type_flag = $1.new_type_flag; }
3583 | typed_declspecs1 %prec EMPTY
3584 { tree specs = strip_attrs ($1.t);
3585 $$.t = build_tree_list (specs, NULL_TREE);
3586 $$.new_type_flag = $1.new_type_flag; }
3587 | declmods notype_declarator
3588 { tree specs = strip_attrs ($1.t);
3589 $$.t = build_tree_list (specs, $2);
3590 $$.new_type_flag = 0; }
3595 { $$.t = build_tree_list (NULL_TREE, $1.t);
3596 $$.new_type_flag = $1.new_type_flag; }
3598 { $$.t = build_tree_list ($2, $1.t);
3599 $$.new_type_flag = $1.new_type_flag; }
3608 /* empty */ %prec EMPTY
3609 { see_typename (); }
3613 /* empty */ %prec EMPTY
3615 error ("type specifier omitted for parameter");
3616 $$ = build_tree_list (integer_type_node, NULL_TREE);
3620 error ("type specifier omitted for parameter");
3621 if (TREE_CODE ($$) == SCOPE_REF
3622 && (TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TYPE_PARM
3623 || TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TEMPLATE_PARM))
3624 cp_error (" perhaps you want `typename %E' to make it a type", $$);
3625 $$ = build_tree_list (integer_type_node, $$);
3629 exception_specification_opt:
3630 /* empty */ %prec EMPTY
3632 | THROW '(' ansi_raise_identifiers ')' %prec EMPTY
3634 | THROW LEFT_RIGHT %prec EMPTY
3635 { $$ = empty_except_spec; }
3638 ansi_raise_identifier:
3641 check_for_new_type ("exception specifier", $1);
3642 $$ = groktypename ($1.t);
3646 ansi_raise_identifiers:
3647 ansi_raise_identifier
3648 { $$ = add_exception_specifier (NULL_TREE, $1, 1); }
3649 | ansi_raise_identifiers ',' ansi_raise_identifier
3650 { $$ = add_exception_specifier ($1, $3, 1); }
3653 conversion_declarator:
3654 /* empty */ %prec EMPTY
3656 | '*' cv_qualifiers conversion_declarator
3657 { $$ = make_pointer_declarator ($2, $3); }
3658 | '&' cv_qualifiers conversion_declarator
3659 { $$ = make_reference_declarator ($2, $3); }
3660 | ptr_to_mem cv_qualifiers conversion_declarator
3661 { tree arg = make_pointer_declarator ($2, $3);
3662 $$ = build_parse_node (SCOPE_REF, $1, arg);
3668 { got_scope = NULL_TREE; }
3673 { $$ = ansi_opname[MULT_EXPR]; }
3675 { $$ = ansi_opname[TRUNC_DIV_EXPR]; }
3677 { $$ = ansi_opname[TRUNC_MOD_EXPR]; }
3679 { $$ = ansi_opname[PLUS_EXPR]; }
3681 { $$ = ansi_opname[MINUS_EXPR]; }
3683 { $$ = ansi_opname[BIT_AND_EXPR]; }
3685 { $$ = ansi_opname[BIT_IOR_EXPR]; }
3687 { $$ = ansi_opname[BIT_XOR_EXPR]; }
3689 { $$ = ansi_opname[BIT_NOT_EXPR]; }
3691 { $$ = ansi_opname[COMPOUND_EXPR]; }
3692 | operator ARITHCOMPARE
3693 { $$ = ansi_opname[$2]; }
3695 { $$ = ansi_opname[LT_EXPR]; }
3697 { $$ = ansi_opname[GT_EXPR]; }
3698 | operator EQCOMPARE
3699 { $$ = ansi_opname[$2]; }
3701 { $$ = ansi_assopname[$2]; }
3703 { $$ = ansi_opname [MODIFY_EXPR]; }
3705 { $$ = ansi_opname[$2]; }
3707 { $$ = ansi_opname[$2]; }
3709 { $$ = ansi_opname[POSTINCREMENT_EXPR]; }
3710 | operator MINUSMINUS
3711 { $$ = ansi_opname[PREDECREMENT_EXPR]; }
3713 { $$ = ansi_opname[TRUTH_ANDIF_EXPR]; }
3715 { $$ = ansi_opname[TRUTH_ORIF_EXPR]; }
3717 { $$ = ansi_opname[TRUTH_NOT_EXPR]; }
3719 { $$ = ansi_opname[COND_EXPR]; }
3721 { $$ = ansi_opname[$2]; }
3722 | operator POINTSAT %prec EMPTY
3723 { $$ = ansi_opname[COMPONENT_REF]; }
3724 | operator POINTSAT_STAR %prec EMPTY
3725 { $$ = ansi_opname[MEMBER_REF]; }
3726 | operator LEFT_RIGHT
3727 { $$ = ansi_opname[CALL_EXPR]; }
3729 { $$ = ansi_opname[ARRAY_REF]; }
3730 | operator NEW %prec EMPTY
3731 { $$ = ansi_opname[NEW_EXPR]; }
3732 | operator DELETE %prec EMPTY
3733 { $$ = ansi_opname[DELETE_EXPR]; }
3734 | operator NEW '[' ']'
3735 { $$ = ansi_opname[VEC_NEW_EXPR]; }
3736 | operator DELETE '[' ']'
3737 { $$ = ansi_opname[VEC_DELETE_EXPR]; }
3738 /* Names here should be looked up in class scope ALSO. */
3739 | operator type_specifier_seq conversion_declarator
3740 { $$ = grokoptypename ($2.t, $3); }
3742 { $$ = ansi_opname[ERROR_MARK]; }
3749 debug_yytranslate (value)
3752 return yytname[YYTRANSLATE (value)];