1 /* YACC parser for C++ syntax.
2 Copyright (C) 1988, 1989, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000, 2001, 2002 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. */
41 #include "c-pragma.h" /* For YYDEBUG definition. */
47 extern struct obstack permanent_obstack;
49 /* Like YYERROR but do call yyerror. */
50 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
52 /* Like the default stack expander, except (1) use realloc when possible,
53 (2) impose no hard maxiumum on stack size, (3) REALLY do not use alloca.
55 Irritatingly, YYSTYPE is defined after this %{ %} block, so we cannot
56 give malloced_yyvs its proper type. This is ok since all we need from
57 it is to be able to free it. */
59 static short *malloced_yyss;
60 static void *malloced_yyvs;
62 #define yyoverflow(MSG, SS, SSSIZE, VS, VSSIZE, YYSSZ) \
67 newsize = *(YYSSZ) *= 2; \
71 really_call_realloc (*(SS), newsize * sizeof (short)); \
73 really_call_realloc (*(VS), newsize * sizeof (YYSTYPE)); \
77 newss = (short *) really_call_malloc (newsize * sizeof (short)); \
78 newvs = (YYSTYPE *) really_call_malloc (newsize * sizeof (YYSTYPE)); \
80 memcpy (newss, *(SS), (SSSIZE)); \
82 memcpy (newvs, *(VS), (VSSIZE)); \
84 if (!newss || !newvs) \
91 malloced_yyss = newss; \
92 malloced_yyvs = (void *) newvs; \
94 #define OP0(NODE) (TREE_OPERAND (NODE, 0))
95 #define OP1(NODE) (TREE_OPERAND (NODE, 1))
97 /* Contains the statement keyword (if/while/do) to include in an
98 error message if the user supplies an empty conditional expression. */
99 static const char *cond_stmt_keyword;
101 /* List of types and structure classes of the current declaration. */
102 static GTY(()) tree current_declspecs;
104 /* List of prefix attributes in effect.
105 Prefix attributes are parsed by the reserved_declspecs and declmods
106 rules. They create a list that contains *both* declspecs and attrs. */
107 /* ??? It is not clear yet that all cases where an attribute can now appear in
108 a declspec list have been updated. */
109 static GTY(()) tree prefix_attributes;
111 /* When defining an enumeration, this is the type of the enumeration. */
112 static GTY(()) tree current_enum_type;
114 /* When parsing a conversion operator name, this is the scope of the
116 static GTY(()) tree saved_scopes;
118 static tree empty_parms PARAMS ((void));
119 static tree parse_decl0 PARAMS ((tree, tree, tree, tree, int));
120 static tree parse_decl PARAMS ((tree, tree, int));
121 static void parse_end_decl PARAMS ((tree, tree, tree));
122 static tree parse_field0 PARAMS ((tree, tree, tree, tree, tree, tree));
123 static tree parse_field PARAMS ((tree, tree, tree, tree));
124 static tree parse_bitfield0 PARAMS ((tree, tree, tree, tree, tree));
125 static tree parse_bitfield PARAMS ((tree, tree, tree));
126 static tree parse_method PARAMS ((tree, tree, tree));
127 static void frob_specs PARAMS ((tree, tree));
128 static void check_class_key PARAMS ((tree, tree));
129 static tree parse_scoped_id PARAMS ((tree));
130 static tree parse_xref_tag (tree, tree, int);
131 static tree parse_handle_class_head (tree, tree, tree, int, int *);
132 static void parse_decl_instantiation (tree, tree, tree);
133 static int parse_begin_function_definition (tree, tree);
135 /* Cons up an empty parameter list. */
141 #ifndef NO_IMPLICIT_EXTERN_C
142 if (in_system_header && current_class_type == NULL
143 && current_lang_name == lang_name_c)
147 parms = void_list_node;
151 /* Record the decl-specifiers, attributes and type lookups from the
152 decl-specifier-seq in a declaration. */
155 frob_specs (specs_attrs, lookups)
156 tree specs_attrs, lookups;
158 save_type_access_control (lookups);
159 split_specs_attrs (specs_attrs, ¤t_declspecs, &prefix_attributes);
160 if (current_declspecs
161 && TREE_CODE (current_declspecs) != TREE_LIST)
162 current_declspecs = build_tree_list (NULL_TREE, current_declspecs);
163 if (have_extern_spec)
165 /* We have to indicate that there is an "extern", but that it
166 was part of a language specifier. For instance,
168 extern "C" typedef int (*Ptr) ();
171 current_declspecs = tree_cons (error_mark_node,
172 get_identifier ("extern"),
174 have_extern_spec = false;
179 parse_decl (declarator, attributes, initialized)
180 tree declarator, attributes;
183 return start_decl (declarator, current_declspecs, initialized,
184 attributes, prefix_attributes);
188 parse_decl0 (declarator, specs_attrs, lookups, attributes, initialized)
189 tree declarator, specs_attrs, lookups, attributes;
192 frob_specs (specs_attrs, lookups);
193 return parse_decl (declarator, attributes, initialized);
197 parse_end_decl (decl, init, asmspec)
198 tree decl, init, asmspec;
200 /* If decl is NULL_TREE, then this was a variable declaration using
201 () syntax for the initializer, so we handled it in grokdeclarator. */
203 decl_type_access_control (decl);
204 cp_finish_decl (decl, init, asmspec, init ? LOOKUP_ONLYCONVERTING : 0);
208 parse_field (declarator, attributes, asmspec, init)
209 tree declarator, attributes, asmspec, init;
211 tree d = grokfield (declarator, current_declspecs, init, asmspec,
212 chainon (attributes, prefix_attributes));
213 decl_type_access_control (d);
218 parse_field0 (declarator, specs_attrs, lookups, attributes, asmspec, init)
219 tree declarator, specs_attrs, lookups, attributes, asmspec, init;
221 frob_specs (specs_attrs, lookups);
222 return parse_field (declarator, attributes, asmspec, init);
226 parse_bitfield (declarator, attributes, width)
227 tree declarator, attributes, width;
229 tree d = grokbitfield (declarator, current_declspecs, width);
230 cplus_decl_attributes (&d, chainon (attributes, prefix_attributes), 0);
231 decl_type_access_control (d);
236 parse_bitfield0 (declarator, specs_attrs, lookups, attributes, width)
237 tree declarator, specs_attrs, lookups, attributes, width;
239 frob_specs (specs_attrs, lookups);
240 return parse_bitfield (declarator, attributes, width);
244 parse_method (declarator, specs_attrs, lookups)
245 tree declarator, specs_attrs, lookups;
248 frob_specs (specs_attrs, lookups);
249 d = start_method (current_declspecs, declarator, prefix_attributes);
250 decl_type_access_control (d);
255 check_class_key (key, aggr)
259 if (TREE_CODE (key) == TREE_LIST)
260 key = TREE_VALUE (key);
261 if ((key == union_type_node) != (TREE_CODE (aggr) == UNION_TYPE))
262 pedwarn ("`%s' tag used in naming `%#T'",
263 key == union_type_node ? "union"
264 : key == record_type_node ? "struct" : "class", aggr);
276 flagged_type_tree ftype;
277 struct unparsed_text *pi;
280 /* All identifiers that are not reserved words
281 and are not declared typedefs in the current block */
284 /* All identifiers that are declared typedefs in the current block.
285 In some contexts, they are treated just like IDENTIFIER,
286 but they can also serve as typespecs in declarations. */
290 /* A template function. */
293 /* Reserved words that specify storage class.
294 yylval contains an IDENTIFIER_NODE which indicates which one. */
297 /* Reserved words that specify type.
298 yylval contains an IDENTIFIER_NODE which indicates which one. */
301 /* Reserved words that qualify type: "const" or "volatile".
302 yylval contains an IDENTIFIER_NODE which indicates which one. */
305 /* Character or numeric constants.
306 yylval is the node for the constant. */
309 /* __func__, __FUNCTION__ or __PRETTY_FUNCTION__.
310 yylval contains an IDENTIFIER_NODE which indicates which one. */
311 %token <ttype> VAR_FUNC_NAME
313 /* String constants in raw form.
314 yylval is a STRING_CST node. */
317 /* "...", used for functions with variable arglists. */
320 /* the reserved words */
321 /* SCO include files test "ASM", so use something else. */
322 %token SIZEOF ENUM /* STRUCT UNION */ IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
323 %token BREAK CONTINUE RETURN_KEYWORD GOTO ASM_KEYWORD TYPEOF ALIGNOF
325 %token ATTRIBUTE EXTENSION LABEL
326 %token REALPART IMAGPART VA_ARG
328 /* the reserved words... C++ extensions */
330 %token <ttype> VISSPEC
331 %token DELETE NEW THIS OPERATOR CXX_TRUE CXX_FALSE
332 %token NAMESPACE TYPENAME_KEYWORD USING
333 %token LEFT_RIGHT TEMPLATE
334 %token TYPEID DYNAMIC_CAST STATIC_CAST REINTERPRET_CAST CONST_CAST
337 /* Define the operator tokens and their precedences.
338 The value is an integer because, if used, it is the tree code
339 to use in the expression made from the operator. */
341 %left EMPTY /* used to resolve s/r with epsilon */
345 /* Add precedence rules to solve dangling else s/r conflict */
349 %left IDENTIFIER PFUNCNAME tTYPENAME SELFNAME PTYPENAME SCSPEC TYPESPEC CV_QUALIFIER ENUM AGGR ELLIPSIS TYPEOF SIGOF OPERATOR NSNAME TYPENAME_KEYWORD ATTRIBUTE
355 %right <code> ASSIGN '='
363 %left <code> EQCOMPARE
364 %left <code> ARITHCOMPARE '<' '>'
365 %left <code> LSHIFT RSHIFT
367 %left <code> '*' '/' '%'
368 %left <code> POINTSAT_STAR DOT_STAR
369 %right <code> UNARY PLUSPLUS MINUSMINUS '~'
371 %left <ttype> LEFT_RIGHT
372 %left <code> POINTSAT '.' '(' '['
374 %right SCOPE /* C++ extension */
375 %nonassoc NEW DELETE TRY CATCH
379 %type <ttype> identifier IDENTIFIER tTYPENAME CONSTANT expr nonnull_exprlist
380 %type <ttype> PFUNCNAME maybe_identifier
381 %type <ttype> paren_expr_or_null nontrivial_exprlist SELFNAME
382 %type <ttype> expr_no_commas expr_no_comma_rangle
383 %type <ttype> cast_expr unary_expr primary STRING
384 %type <ttype> reserved_declspecs boolean_literal
385 %type <ttype> reserved_typespecquals
386 %type <ttype> SCSPEC TYPESPEC CV_QUALIFIER maybe_cv_qualifier
387 %type <ttype> init initlist maybeasm maybe_init defarg defarg1
388 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
389 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
390 %type <ttype> any_word
392 %type <itype> save_lineno
393 %type <ttype> simple_stmt simple_if
395 %type <ttype> declarator notype_declarator after_type_declarator
396 %type <ttype> notype_declarator_intern absdcl_intern
397 %type <ttype> after_type_declarator_intern
398 %type <ttype> direct_notype_declarator direct_after_type_declarator
399 %type <itype> components notype_components
400 %type <ttype> component_decl component_decl_1
401 %type <ttype> component_declarator component_declarator0
402 %type <ttype> notype_component_declarator notype_component_declarator0
403 %type <ttype> after_type_component_declarator after_type_component_declarator0
404 %type <ttype> absdcl cv_qualifiers
405 %type <ttype> direct_abstract_declarator conversion_declarator
406 %type <ttype> new_declarator direct_new_declarator
407 %type <ttype> xexpr parmlist parms bad_parm
408 %type <ttype> identifiers_or_typenames
409 %type <ttype> fcast_or_absdcl regcast_or_absdcl
410 %type <ttype> expr_or_declarator expr_or_declarator_intern
411 %type <ttype> complex_notype_declarator
412 %type <ttype> notype_unqualified_id unqualified_id qualified_id
413 %type <ttype> template_id do_id object_template_id notype_template_declarator
414 %type <ttype> overqualified_id notype_qualified_id any_id
415 %type <ttype> complex_direct_notype_declarator functional_cast
416 %type <ttype> complex_parmlist parms_comma
417 %type <ttype> namespace_qualifier namespace_using_decl
419 %type <ftype> type_id new_type_id typed_typespecs typespec typed_declspecs
420 %type <ftype> typed_declspecs1 type_specifier_seq nonempty_cv_qualifiers
421 %type <ftype> structsp typespecqual_reserved parm named_parm full_parm
422 %type <ftype> declmods
424 %type <itype> extension
427 %token <ttype> PTYPENAME
428 %token <ttype> EXTERN_LANG_STRING ALL
429 %token <ttype> PRE_PARSED_CLASS_DECL DEFARG DEFARG_MARKER
430 %token <pi> PRE_PARSED_FUNCTION_DECL
431 %type <ttype> component_constructor_declarator
432 %type <ttype> fn_def2 return_id constructor_declarator
433 %type <ttype> begin_function_body_
434 %type <ttype> class_head class_head_apparent_template
435 %type <ftype> class_head_decl class_head_defn
436 %type <ttype> base_class_list
437 %type <ttype> base_class_access_list
438 %type <ttype> base_class maybe_base_class_list base_class_1
439 %type <ttype> exception_specification_opt ansi_raise_identifier ansi_raise_identifiers
440 %type <ttype> operator_name
441 %type <ttype> object aggr
442 %type <itype> new delete
443 /* %type <ttype> primary_no_id */
444 %type <ttype> maybe_parmlist
445 %type <ttype> member_init
446 %type <ftype> member_init_list
447 %type <ttype> template_parm_header template_spec_header template_header
448 %type <ttype> template_parm_list template_parm
449 %type <ttype> template_type_parm template_template_parm
450 %type <code> template_close_bracket
451 %type <ttype> apparent_template_type
452 %type <ttype> template_type template_arg_list template_arg_list_opt
453 %type <ttype> template_arg
454 %type <ttype> condition xcond paren_cond_or_null
455 %type <ttype> type_name nested_name_specifier nested_type ptr_to_mem
456 %type <ttype> complete_type_name notype_identifier nonnested_type
457 %type <ttype> complex_type_name nested_name_specifier_1
458 %type <ttype> new_initializer new_placement
459 %type <ttype> using_decl
460 %type <ttype> typename_sub typename_sub0 typename_sub1 typename_sub2
461 %type <ttype> explicit_template_type
462 /* in order to recognize aggr tags as defining and thus shadowing. */
463 %token TYPENAME_DEFN IDENTIFIER_DEFN PTYPENAME_DEFN
464 %type <ttype> identifier_defn IDENTIFIER_DEFN TYPENAME_DEFN PTYPENAME_DEFN
465 %type <ttype> handler_args
466 %type <ttype> self_template_type finish_template_type_
471 /* Used in lex.c for parsing pragmas. */
474 /* lex.c and pt.c depend on this being the last token. Define
475 any new tokens before this one! */
476 %token END_OF_SAVED_INPUT
479 /* Tell yyparse how to print a token's value, if yydebug is set. */
480 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
481 extern void yyprint PARAMS ((FILE *, int, YYSTYPE));
487 { finish_translation_unit (); }
489 { finish_translation_unit (); }
492 /* the reason for the strange actions in this rule
493 is so that notype_initdecls when reached via datadef
494 can find a valid list of type and sc specs in $0. */
497 { $<ttype>$ = NULL_TREE; }
499 { $<ttype>$ = NULL_TREE; ggc_collect (); }
500 | extdefs lang_extdef
501 { $<ttype>$ = NULL_TREE; ggc_collect (); }
510 { have_extern_spec = true;
511 $<ttype>$ = NULL_TREE; }
514 { have_extern_spec = false; }
528 { if (pending_lang_change) do_pending_lang_change();
529 type_lookups = NULL_TREE; }
531 { if (! toplevel_bindings_p ())
536 fndef eat_saved_input
537 { do_pending_inlines (); }
539 { do_pending_inlines (); }
542 { warning ("keyword `export' not implemented, and will be ignored"); }
544 { do_pending_inlines (); }
546 { do_pending_inlines (); }
547 | asm_keyword '(' STRING ')' ';'
548 { assemble_asm ($3); }
549 | extern_lang_string '{' extdefs_opt '}'
550 { pop_lang_context (); }
551 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
552 { do_pending_inlines (); pop_lang_context (); }
553 | extern_lang_string .hush_warning datadef .warning_ok
554 { do_pending_inlines (); pop_lang_context (); }
555 | NAMESPACE identifier '{'
556 { push_namespace ($2); }
558 { pop_namespace (); }
560 { push_namespace (NULL_TREE); }
562 { pop_namespace (); }
565 { do_toplevel_using_decl ($1); }
572 NAMESPACE identifier '='
573 { begin_only_namespace_names (); }
576 end_only_namespace_names ();
579 do_namespace_alias ($2, $5);
586 | USING global_scope qualified_id
588 | USING global_scope unqualified_id
592 namespace_using_decl:
593 USING namespace_qualifier identifier
594 { $$ = build_nt (SCOPE_REF, $2, $3); }
595 | USING global_scope identifier
596 { $$ = build_nt (SCOPE_REF, global_namespace, $3); }
597 | USING global_scope namespace_qualifier identifier
598 { $$ = build_nt (SCOPE_REF, $3, $4); }
603 { begin_only_namespace_names (); }
606 end_only_namespace_names ();
607 /* If no declaration was found, the using-directive is
608 invalid. Since that was not reported, we need the
609 identifier for the error message. */
610 if (TREE_CODE ($4) == IDENTIFIER_NODE && lastiddecl)
612 do_using_directive ($4);
619 if (TREE_CODE ($$) == IDENTIFIER_NODE)
623 | namespace_qualifier NSNAME SCOPE
626 if (TREE_CODE ($$) == IDENTIFIER_NODE)
635 | global_scope qualified_id
637 | global_scope unqualified_id
643 { push_lang_context ($1); }
644 | extern_lang_string EXTERN_LANG_STRING
645 { if (current_lang_name != $2)
646 error ("use of linkage spec `%D' is different from previous spec `%D'", $2, current_lang_name);
647 pop_lang_context (); push_lang_context ($2); }
650 template_parm_header:
652 { begin_template_parm_list (); }
653 template_parm_list '>'
654 { $$ = end_template_parm_list ($4); }
657 template_spec_header:
659 { begin_specialization();
665 | template_spec_header
670 { $$ = process_template_parm (NULL_TREE, $1); }
671 | template_parm_list ',' template_parm
672 { $$ = process_template_parm ($1, $3); }
683 aggr maybe_identifier
684 { $$ = finish_template_type_parm ($1, $2); }
685 | TYPENAME_KEYWORD maybe_identifier
686 { $$ = finish_template_type_parm (class_type_node, $2); }
689 template_template_parm:
690 template_parm_header aggr maybe_identifier
691 { $$ = finish_template_template_parm ($2, $3); }
695 /* The following rules introduce a new reduce/reduce
696 conflict on the ',' and '>' input tokens: they are valid
697 prefixes for a `structsp', which means they could match a
698 nameless parameter. See 14.6, paragraph 3.
699 By putting them before the `parm' rule, we get
700 their match before considering them nameless parameter
703 { $$ = build_tree_list (NULL_TREE, $1); }
704 | template_type_parm '=' type_id
705 { $$ = build_tree_list (groktypename ($3.t), $1); }
707 { $$ = build_tree_list (NULL_TREE, $1.t); }
708 | parm '=' expr_no_comma_rangle
709 { $$ = build_tree_list ($3, $1.t); }
710 | template_template_parm
711 { $$ = build_tree_list (NULL_TREE, $1); }
712 | template_template_parm '=' template_arg
714 $3 = check_template_template_default_arg ($3);
715 $$ = build_tree_list ($3, $1);
720 template_header template_extdef
721 { finish_template_decl ($1); }
722 | template_header error %prec EMPTY
723 { finish_template_decl ($1); }
727 fndef eat_saved_input
728 { do_pending_inlines (); }
730 { do_pending_inlines (); }
732 { do_pending_inlines (); }
733 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
734 { do_pending_inlines ();
735 pop_lang_context (); }
736 | extern_lang_string .hush_warning template_datadef .warning_ok
737 { do_pending_inlines ();
738 pop_lang_context (); }
739 | extension template_extdef
745 | declmods notype_initdecls ';'
747 | typed_declspecs initdecls ';'
748 { note_list_got_semicolon ($1.t); }
751 if ($1.t != error_mark_node)
753 maybe_process_partial_specialization ($1.t);
754 note_got_semicolon ($1.t);
761 | declmods notype_initdecls ';'
763 | typed_declspecs initdecls ';'
764 { note_list_got_semicolon ($1.t); }
766 { pedwarn ("empty declaration"); }
767 | explicit_instantiation ';'
768 | typed_declspecs ';'
771 split_specs_attrs ($1.t, &t, &attrs);
773 note_list_got_semicolon ($1.t);
777 | error END_OF_SAVED_INPUT
783 ctor_initializer_opt:
799 /* The outermost block of a function really begins before the
800 mem-initializer-list, so we open one there and suppress the one that
801 actually corresponds to the curly braces. */
803 begin_function_body_ ctor_initializer_opt save_lineno '{'
804 { $<ttype>$ = begin_compound_stmt (/*has_no_scope=*/1); }
807 STMT_LINENO ($<ttype>5) = $3;
808 finish_compound_stmt (/*has_no_scope=*/1, $<ttype>5);
809 finish_function_body ($1);
814 fn.def1 maybe_return_init function_body
815 { expand_body (finish_function (0)); }
816 | fn.def1 maybe_return_init function_try_block
817 { expand_body (finish_function (0)); }
818 | fn.def1 maybe_return_init error
822 constructor_declarator:
823 nested_name_specifier SELFNAME '('
824 { $$ = begin_constructor_declarator ($1, $2); }
825 parmlist ')' cv_qualifiers exception_specification_opt
826 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
827 | nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
828 { $$ = begin_constructor_declarator ($1, $2);
829 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
831 | global_scope nested_name_specifier SELFNAME '('
832 { $$ = begin_constructor_declarator ($2, $3); }
833 parmlist ')' cv_qualifiers exception_specification_opt
834 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
835 | global_scope nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
836 { $$ = begin_constructor_declarator ($2, $3);
837 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
839 | nested_name_specifier self_template_type '('
840 { $$ = begin_constructor_declarator ($1, $2); }
841 parmlist ')' cv_qualifiers exception_specification_opt
842 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
843 | nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
844 { $$ = begin_constructor_declarator ($1, $2);
845 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
847 | global_scope nested_name_specifier self_template_type '('
848 { $$ = begin_constructor_declarator ($2, $3); }
849 parmlist ')' cv_qualifiers exception_specification_opt
850 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
851 | global_scope nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
852 { $$ = begin_constructor_declarator ($2, $3);
853 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
858 typed_declspecs declarator
859 { check_for_new_type ("return type", $1);
860 if (!parse_begin_function_definition ($1.t, $2))
862 | declmods notype_declarator
863 { if (!parse_begin_function_definition ($1.t, $2))
866 { if (!parse_begin_function_definition (NULL_TREE, $1))
868 | declmods constructor_declarator
869 { if (!parse_begin_function_definition ($1.t, $2))
871 | constructor_declarator
872 { if (!parse_begin_function_definition (NULL_TREE, $1))
876 /* ANSI allows optional parentheses around constructor class names.
877 See ISO/IEC 14882:1998(E) 12.1. */
879 component_constructor_declarator:
880 SELFNAME '(' parmlist ')' cv_qualifiers exception_specification_opt
881 { $$ = make_call_declarator ($1, $3, $5, $6); }
882 | '(' SELFNAME ')' '(' parmlist ')' cv_qualifiers
883 exception_specification_opt
884 { $$ = make_call_declarator ($2, $5, $7, $8); }
885 | SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
886 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
887 | '(' SELFNAME ')' LEFT_RIGHT cv_qualifiers exception_specification_opt
888 { $$ = make_call_declarator ($2, empty_parms (), $5, $6); }
889 | self_template_type '(' parmlist ')' cv_qualifiers exception_specification_opt
890 { $$ = make_call_declarator ($1, $3, $5, $6); }
891 | self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
892 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
895 /* more C++ complexity. See component_decl for a comment on the
896 reduce/reduce conflict introduced by these rules. */
898 declmods component_constructor_declarator
899 { $$ = parse_method ($2, $1.t, $1.lookups);
903 if (yychar == YYEMPTY)
906 | component_constructor_declarator
907 { $$ = parse_method ($1, NULL_TREE, NULL_TREE);
909 | typed_declspecs declarator
910 { $$ = parse_method ($2, $1.t, $1.lookups); goto rest_of_mdef;}
911 | declmods notype_declarator
912 { $$ = parse_method ($2, $1.t, $1.lookups); goto rest_of_mdef;}
914 { $$ = parse_method ($1, NULL_TREE, NULL_TREE);
916 | declmods constructor_declarator
917 { $$ = parse_method ($2, $1.t, $1.lookups); goto rest_of_mdef;}
918 | constructor_declarator
919 { $$ = parse_method ($1, NULL_TREE, NULL_TREE);
924 RETURN_KEYWORD IDENTIFIER
932 { finish_named_return_value ($<ttype>$, $2); }
933 | return_id '(' nonnull_exprlist ')'
934 { finish_named_return_value ($<ttype>$, $3); }
935 | return_id LEFT_RIGHT
936 { finish_named_return_value ($<ttype>$, NULL_TREE); }
940 ':' { begin_mem_initializers (); } member_init_list
942 if ($3.new_type_flag == 0)
943 error ("no base or member initializers given following ':'");
944 finish_mem_initializers ($3.t);
948 begin_function_body_:
951 $$ = begin_function_body ();
958 $$.new_type_flag = 0;
963 $$.new_type_flag = 1;
966 | member_init_list ',' member_init
970 $$.new_type_flag = 1;
971 TREE_CHAIN ($3) = $1.t;
977 | member_init_list error
981 '(' nonnull_exprlist ')'
983 if (current_class_name)
984 pedwarn ("anachronistic old style base class initializer");
985 $$ = expand_member_init (current_class_ref, NULL_TREE, $2);
989 if (current_class_name)
990 pedwarn ("anachronistic old style base class initializer");
991 $$ = expand_member_init (current_class_ref,
995 | notype_identifier '(' nonnull_exprlist ')'
996 { $$ = expand_member_init (current_class_ref, $1, $3); }
997 | notype_identifier LEFT_RIGHT
998 { $$ = expand_member_init (current_class_ref, $1,
1000 | nonnested_type '(' nonnull_exprlist ')'
1001 { $$ = expand_member_init (current_class_ref, $1, $3); }
1002 | nonnested_type LEFT_RIGHT
1003 { $$ = expand_member_init (current_class_ref, $1,
1005 | typename_sub '(' nonnull_exprlist ')'
1006 { $$ = expand_member_init (current_class_ref, $1, $3); }
1007 | typename_sub LEFT_RIGHT
1008 { $$ = expand_member_init (current_class_ref, $1,
1025 | NSNAME %prec EMPTY
1034 explicit_instantiation:
1035 TEMPLATE begin_explicit_instantiation typespec ';'
1036 { do_type_instantiation ($3.t, NULL_TREE, 1);
1037 yyungetc (';', 1); }
1038 end_explicit_instantiation
1039 | TEMPLATE begin_explicit_instantiation typed_declspecs declarator
1040 { tree specs = strip_attrs ($3.t);
1041 parse_decl_instantiation (specs, $4, NULL_TREE); }
1042 end_explicit_instantiation
1043 | TEMPLATE begin_explicit_instantiation notype_declarator
1044 { parse_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
1045 end_explicit_instantiation
1046 | TEMPLATE begin_explicit_instantiation constructor_declarator
1047 { parse_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
1048 end_explicit_instantiation
1049 | SCSPEC TEMPLATE begin_explicit_instantiation typespec ';'
1050 { do_type_instantiation ($4.t, $1, 1);
1051 yyungetc (';', 1); }
1052 end_explicit_instantiation
1054 | SCSPEC TEMPLATE begin_explicit_instantiation typed_declspecs
1056 { tree specs = strip_attrs ($4.t);
1057 parse_decl_instantiation (specs, $5, $1); }
1058 end_explicit_instantiation
1060 | SCSPEC TEMPLATE begin_explicit_instantiation notype_declarator
1061 { parse_decl_instantiation (NULL_TREE, $4, $1); }
1062 end_explicit_instantiation
1064 | SCSPEC TEMPLATE begin_explicit_instantiation constructor_declarator
1065 { parse_decl_instantiation (NULL_TREE, $4, $1); }
1066 end_explicit_instantiation
1070 begin_explicit_instantiation:
1071 { begin_explicit_instantiation(); }
1074 end_explicit_instantiation:
1075 { end_explicit_instantiation(); }
1078 /* The TYPENAME expansions are to deal with use of a template class name as
1079 a template within the class itself, where the template decl is hidden by
1080 a type decl. Got all that? */
1083 PTYPENAME '<' template_arg_list_opt template_close_bracket
1084 finish_template_type_
1086 | tTYPENAME '<' template_arg_list_opt template_close_bracket
1087 finish_template_type_
1089 | self_template_type
1092 apparent_template_type:
1094 | identifier '<' template_arg_list_opt '>'
1095 finish_template_type_
1100 SELFNAME '<' template_arg_list_opt template_close_bracket
1101 finish_template_type_
1105 finish_template_type_:
1107 if (yychar == YYEMPTY)
1110 $$ = finish_template_type ($<ttype>-3, $<ttype>-1,
1115 template_close_bracket:
1119 /* Handle `Class<Class<Type>>' without space in the `>>' */
1120 pedwarn ("`>>' should be `> >' in template class name");
1125 template_arg_list_opt:
1133 { $$ = build_tree_list (NULL_TREE, $$); }
1134 | template_arg_list ',' template_arg
1135 { $$ = chainon ($$, build_tree_list (NULL_TREE, $3)); }
1140 { $$ = groktypename ($1.t); }
1144 if (DECL_TEMPLATE_TEMPLATE_PARM_P ($$))
1145 $$ = TREE_TYPE ($$);
1147 | global_scope PTYPENAME
1150 if (DECL_TEMPLATE_TEMPLATE_PARM_P ($$))
1151 $$ = TREE_TYPE ($$);
1153 | expr_no_comma_rangle
1154 | nested_name_specifier TEMPLATE identifier
1156 if (!processing_template_decl)
1158 error ("use of template qualifier outside template");
1159 $$ = error_mark_node;
1162 $$ = make_unbound_class_template ($1, $3, tf_error | tf_parsing);
1168 { $$ = NEGATE_EXPR; }
1170 { $$ = CONVERT_EXPR; }
1172 { $$ = PREINCREMENT_EXPR; }
1174 { $$ = PREDECREMENT_EXPR; }
1176 { $$ = TRUTH_NOT_EXPR; }
1181 { $$ = build_x_compound_expr ($$); }
1187 { error ("ISO C++ forbids an empty condition for `%s'",
1189 $$ = integer_zero_node; }
1196 { error ("ISO C++ forbids an empty condition for `%s'",
1198 $$ = integer_zero_node; }
1212 type_specifier_seq declarator maybeasm maybe_attribute '='
1215 for (d = getdecls (); d; d = TREE_CHAIN (d))
1216 if (TREE_CODE (d) == TYPE_DECL) {
1217 tree s = TREE_TYPE (d);
1218 if (TREE_CODE (s) == RECORD_TYPE)
1219 error ("definition of class `%T' in condition", s);
1220 else if (TREE_CODE (s) == ENUMERAL_TYPE)
1221 error ("definition of enum `%T' in condition", s);
1224 current_declspecs = $1.t;
1225 $<ttype>$ = parse_decl ($<ttype>2, $4, 1);
1229 parse_end_decl ($<ttype>6, $7, $4);
1230 $$ = convert_from_reference ($<ttype>6);
1231 if (TREE_CODE (TREE_TYPE ($$)) == ARRAY_TYPE)
1232 error ("definition of array `%#D' in condition", $$);
1239 | maybe_label_decls stmts '}'
1240 | maybe_label_decls stmts error '}'
1241 | maybe_label_decls error '}'
1244 nontrivial_exprlist:
1245 expr_no_commas ',' expr_no_commas
1246 { $$ = tree_cons (NULL_TREE, $$,
1247 build_tree_list (NULL_TREE, $3)); }
1248 | expr_no_commas ',' error
1249 { $$ = tree_cons (NULL_TREE, $$,
1250 build_tree_list (NULL_TREE, error_mark_node)); }
1251 | nontrivial_exprlist ',' expr_no_commas
1252 { chainon ($$, build_tree_list (NULL_TREE, $3)); }
1253 | nontrivial_exprlist ',' error
1254 { chainon ($$, build_tree_list (NULL_TREE, error_mark_node)); }
1259 { $$ = build_tree_list (NULL_TREE, $$); }
1260 | nontrivial_exprlist
1266 /* __extension__ turns off -pedantic for following primary. */
1267 | extension cast_expr %prec UNARY
1270 | '*' cast_expr %prec UNARY
1271 { $$ = build_x_indirect_ref ($2, "unary *"); }
1272 | '&' cast_expr %prec UNARY
1273 { $$ = build_x_unary_op (ADDR_EXPR, $2); }
1275 { $$ = build_x_unary_op (BIT_NOT_EXPR, $2); }
1276 | unop cast_expr %prec UNARY
1277 { $$ = finish_unary_op_expr ($1, $2); }
1278 /* Refer to the address of a label as a pointer. */
1280 { $$ = finish_label_address_expr ($2); }
1281 | SIZEOF unary_expr %prec UNARY
1282 { $$ = finish_sizeof ($2); }
1283 | SIZEOF '(' type_id ')' %prec HYPERUNARY
1284 { $$ = finish_sizeof (groktypename ($3.t));
1285 check_for_new_type ("sizeof", $3); }
1286 | ALIGNOF unary_expr %prec UNARY
1287 { $$ = finish_alignof ($2); }
1288 | ALIGNOF '(' type_id ')' %prec HYPERUNARY
1289 { $$ = finish_alignof (groktypename ($3.t));
1290 check_for_new_type ("alignof", $3); }
1292 /* The %prec EMPTY's here are required by the = init initializer
1293 syntax extension; see below. */
1294 | new new_type_id %prec EMPTY
1295 { $$ = build_new (NULL_TREE, $2.t, NULL_TREE, $1);
1296 check_for_new_type ("new", $2); }
1297 | new new_type_id new_initializer
1298 { $$ = build_new (NULL_TREE, $2.t, $3, $1);
1299 check_for_new_type ("new", $2); }
1300 | new new_placement new_type_id %prec EMPTY
1301 { $$ = build_new ($2, $3.t, NULL_TREE, $1);
1302 check_for_new_type ("new", $3); }
1303 | new new_placement new_type_id new_initializer
1304 { $$ = build_new ($2, $3.t, $4, $1);
1305 check_for_new_type ("new", $3); }
1306 | new '(' type_id ')'
1308 { $$ = build_new (NULL_TREE, groktypename($3.t),
1310 check_for_new_type ("new", $3); }
1311 | new '(' type_id ')' new_initializer
1312 { $$ = build_new (NULL_TREE, groktypename($3.t), $5, $1);
1313 check_for_new_type ("new", $3); }
1314 | new new_placement '(' type_id ')' %prec EMPTY
1315 { $$ = build_new ($2, groktypename($4.t), NULL_TREE, $1);
1316 check_for_new_type ("new", $4); }
1317 | new new_placement '(' type_id ')' new_initializer
1318 { $$ = build_new ($2, groktypename($4.t), $6, $1);
1319 check_for_new_type ("new", $4); }
1321 | delete cast_expr %prec UNARY
1322 { $$ = delete_sanity ($2, NULL_TREE, 0, $1); }
1323 | delete '[' ']' cast_expr %prec UNARY
1324 { $$ = delete_sanity ($4, NULL_TREE, 1, $1);
1325 if (yychar == YYEMPTY)
1327 | delete '[' expr ']' cast_expr %prec UNARY
1328 { $$ = delete_sanity ($5, $3, 2, $1);
1329 if (yychar == YYEMPTY)
1331 | REALPART cast_expr %prec UNARY
1332 { $$ = build_x_unary_op (REALPART_EXPR, $2); }
1333 | IMAGPART cast_expr %prec UNARY
1334 { $$ = build_x_unary_op (IMAGPART_EXPR, $2); }
1338 '(' nonnull_exprlist ')'
1340 | '{' nonnull_exprlist '}'
1341 { pedwarn ("old style placement syntax, use () instead");
1346 '(' nonnull_exprlist ')'
1349 { $$ = void_zero_node; }
1352 error ("`%T' is not a valid expression", $2.t);
1353 $$ = error_mark_node;
1355 /* GNU extension so people can use initializer lists. Note that
1356 this alters the meaning of `new int = 1', which was previously
1357 syntactically valid but semantically invalid.
1358 This feature is now deprecated and will be removed in a future
1363 pedwarn ("ISO C++ forbids initialization of new expression with `='");
1364 cp_deprecated ("new initializer lists extension");
1365 if (TREE_CODE ($2) != TREE_LIST
1366 && TREE_CODE ($2) != CONSTRUCTOR)
1367 $$ = build_tree_list (NULL_TREE, $2);
1373 /* This is necessary to postpone reduction of `int ((int)(int)(int))'. */
1375 '(' type_id ')' %prec EMPTY
1376 { $2.t = finish_parmlist (build_tree_list (NULL_TREE, $2.t), 0);
1377 $$ = make_call_declarator (NULL_TREE, $2.t, NULL_TREE, NULL_TREE);
1378 check_for_new_type ("cast", $2); }
1379 | regcast_or_absdcl '(' type_id ')' %prec EMPTY
1380 { $3.t = finish_parmlist (build_tree_list (NULL_TREE, $3.t), 0);
1381 $$ = make_call_declarator ($$, $3.t, NULL_TREE, NULL_TREE);
1382 check_for_new_type ("cast", $3); }
1387 | regcast_or_absdcl unary_expr %prec UNARY
1388 { $$ = reparse_absdcl_as_casts ($$, $2); }
1389 | regcast_or_absdcl '{' initlist maybecomma '}' %prec UNARY
1391 tree init = build_nt (CONSTRUCTOR, NULL_TREE,
1394 pedwarn ("ISO C++ forbids compound literals");
1395 /* Indicate that this was a C99 compound literal. */
1396 TREE_HAS_CONSTRUCTOR (init) = 1;
1398 $$ = reparse_absdcl_as_casts ($$, init);
1404 /* Handle general members. */
1405 | expr_no_commas POINTSAT_STAR expr_no_commas
1406 { $$ = build_x_binary_op (MEMBER_REF, $$, $3); }
1407 | expr_no_commas DOT_STAR expr_no_commas
1408 { $$ = build_m_component_ref ($$, $3); }
1409 | expr_no_commas '+' expr_no_commas
1410 { $$ = build_x_binary_op ($2, $$, $3); }
1411 | expr_no_commas '-' expr_no_commas
1412 { $$ = build_x_binary_op ($2, $$, $3); }
1413 | expr_no_commas '*' expr_no_commas
1414 { $$ = build_x_binary_op ($2, $$, $3); }
1415 | expr_no_commas '/' expr_no_commas
1416 { $$ = build_x_binary_op ($2, $$, $3); }
1417 | expr_no_commas '%' expr_no_commas
1418 { $$ = build_x_binary_op ($2, $$, $3); }
1419 | expr_no_commas LSHIFT expr_no_commas
1420 { $$ = build_x_binary_op ($2, $$, $3); }
1421 | expr_no_commas RSHIFT expr_no_commas
1422 { $$ = build_x_binary_op ($2, $$, $3); }
1423 | expr_no_commas ARITHCOMPARE expr_no_commas
1424 { $$ = build_x_binary_op ($2, $$, $3); }
1425 | expr_no_commas '<' expr_no_commas
1426 { $$ = build_x_binary_op (LT_EXPR, $$, $3); }
1427 | expr_no_commas '>' expr_no_commas
1428 { $$ = build_x_binary_op (GT_EXPR, $$, $3); }
1429 | expr_no_commas EQCOMPARE expr_no_commas
1430 { $$ = build_x_binary_op ($2, $$, $3); }
1431 | expr_no_commas MIN_MAX expr_no_commas
1432 { $$ = build_x_binary_op ($2, $$, $3); }
1433 | expr_no_commas '&' expr_no_commas
1434 { $$ = build_x_binary_op ($2, $$, $3); }
1435 | expr_no_commas '|' expr_no_commas
1436 { $$ = build_x_binary_op ($2, $$, $3); }
1437 | expr_no_commas '^' expr_no_commas
1438 { $$ = build_x_binary_op ($2, $$, $3); }
1439 | expr_no_commas ANDAND expr_no_commas
1440 { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $$, $3); }
1441 | expr_no_commas OROR expr_no_commas
1442 { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $$, $3); }
1443 | expr_no_commas '?' xexpr ':' expr_no_commas
1444 { $$ = build_x_conditional_expr ($$, $3, $5); }
1445 | expr_no_commas '=' expr_no_commas
1446 { $$ = build_x_modify_expr ($$, NOP_EXPR, $3);
1447 if ($$ != error_mark_node)
1448 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
1449 | expr_no_commas ASSIGN expr_no_commas
1450 { $$ = build_x_modify_expr ($$, $2, $3); }
1452 { $$ = build_throw (NULL_TREE); }
1453 | THROW expr_no_commas
1454 { $$ = build_throw ($2); }
1457 expr_no_comma_rangle:
1459 /* Handle general members. */
1460 | expr_no_comma_rangle POINTSAT_STAR expr_no_comma_rangle
1461 { $$ = build_x_binary_op (MEMBER_REF, $$, $3); }
1462 | expr_no_comma_rangle DOT_STAR expr_no_comma_rangle
1463 { $$ = build_m_component_ref ($$, $3); }
1464 | expr_no_comma_rangle '+' expr_no_comma_rangle
1465 { $$ = build_x_binary_op ($2, $$, $3); }
1466 | expr_no_comma_rangle '-' expr_no_comma_rangle
1467 { $$ = build_x_binary_op ($2, $$, $3); }
1468 | expr_no_comma_rangle '*' expr_no_comma_rangle
1469 { $$ = build_x_binary_op ($2, $$, $3); }
1470 | expr_no_comma_rangle '/' expr_no_comma_rangle
1471 { $$ = build_x_binary_op ($2, $$, $3); }
1472 | expr_no_comma_rangle '%' expr_no_comma_rangle
1473 { $$ = build_x_binary_op ($2, $$, $3); }
1474 | expr_no_comma_rangle LSHIFT expr_no_comma_rangle
1475 { $$ = build_x_binary_op ($2, $$, $3); }
1476 | expr_no_comma_rangle RSHIFT expr_no_comma_rangle
1477 { $$ = build_x_binary_op ($2, $$, $3); }
1478 | expr_no_comma_rangle ARITHCOMPARE expr_no_comma_rangle
1479 { $$ = build_x_binary_op ($2, $$, $3); }
1480 | expr_no_comma_rangle '<' expr_no_comma_rangle
1481 { $$ = build_x_binary_op (LT_EXPR, $$, $3); }
1482 | expr_no_comma_rangle EQCOMPARE expr_no_comma_rangle
1483 { $$ = build_x_binary_op ($2, $$, $3); }
1484 | expr_no_comma_rangle MIN_MAX expr_no_comma_rangle
1485 { $$ = build_x_binary_op ($2, $$, $3); }
1486 | expr_no_comma_rangle '&' expr_no_comma_rangle
1487 { $$ = build_x_binary_op ($2, $$, $3); }
1488 | expr_no_comma_rangle '|' expr_no_comma_rangle
1489 { $$ = build_x_binary_op ($2, $$, $3); }
1490 | expr_no_comma_rangle '^' expr_no_comma_rangle
1491 { $$ = build_x_binary_op ($2, $$, $3); }
1492 | expr_no_comma_rangle ANDAND expr_no_comma_rangle
1493 { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $$, $3); }
1494 | expr_no_comma_rangle OROR expr_no_comma_rangle
1495 { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $$, $3); }
1496 | expr_no_comma_rangle '?' xexpr ':' expr_no_comma_rangle
1497 { $$ = build_x_conditional_expr ($$, $3, $5); }
1498 | expr_no_comma_rangle '=' expr_no_comma_rangle
1499 { $$ = build_x_modify_expr ($$, NOP_EXPR, $3);
1500 if ($$ != error_mark_node)
1501 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
1502 | expr_no_comma_rangle ASSIGN expr_no_comma_rangle
1503 { $$ = build_x_modify_expr ($$, $2, $3); }
1505 { $$ = build_throw (NULL_TREE); }
1506 | THROW expr_no_comma_rangle
1507 { $$ = build_throw ($2); }
1510 notype_unqualified_id:
1511 '~' see_typename identifier
1512 { $$ = build_nt (BIT_NOT_EXPR, $3); }
1513 | '~' see_typename template_type
1514 { $$ = build_nt (BIT_NOT_EXPR, $3); }
1519 | NSNAME %prec EMPTY
1524 /* If lastiddecl is a TREE_LIST, it's a baselink, which
1525 means that we're in an expression like S::f<int>, so
1526 don't do_identifier; we only do that for unqualified
1528 if (!lastiddecl || TREE_CODE (lastiddecl) != TREE_LIST)
1529 $$ = do_identifier ($<ttype>-1, 1, NULL_TREE);
1536 PFUNCNAME '<' do_id template_arg_list_opt template_close_bracket
1537 { $$ = lookup_template_function ($3, $4); }
1538 | operator_name '<' do_id template_arg_list_opt template_close_bracket
1539 { $$ = lookup_template_function ($3, $4); }
1543 TEMPLATE identifier '<' template_arg_list_opt template_close_bracket
1544 { $$ = lookup_template_function ($2, $4); }
1545 | TEMPLATE PFUNCNAME '<' template_arg_list_opt template_close_bracket
1546 { $$ = lookup_template_function ($2, $4); }
1547 | TEMPLATE operator_name '<' template_arg_list_opt
1548 template_close_bracket
1549 { $$ = lookup_template_function ($2, $4); }
1553 notype_unqualified_id
1558 expr_or_declarator_intern:
1560 | attributes expr_or_declarator
1562 /* Provide support for '(' attributes '*' declarator ')'
1564 $$ = tree_cons ($1, $2, NULL_TREE);
1569 notype_unqualified_id
1570 | '*' expr_or_declarator_intern %prec UNARY
1571 { $$ = build_nt (INDIRECT_REF, $2); }
1572 | '&' expr_or_declarator_intern %prec UNARY
1573 { $$ = build_nt (ADDR_EXPR, $2); }
1574 | '(' expr_or_declarator_intern ')'
1578 notype_template_declarator:
1579 IDENTIFIER '<' template_arg_list_opt template_close_bracket
1580 { $$ = lookup_template_function ($1, $3); }
1581 | NSNAME '<' template_arg_list template_close_bracket
1582 { $$ = lookup_template_function ($1, $3); }
1585 direct_notype_declarator:
1586 complex_direct_notype_declarator
1587 /* This precedence declaration is to prefer this reduce
1588 to the Koenig lookup shift in primary, below. I hate yacc. */
1589 | notype_unqualified_id %prec '('
1590 | notype_template_declarator
1591 | '(' expr_or_declarator_intern ')'
1592 { $$ = finish_decl_parsing ($2); }
1596 notype_unqualified_id
1598 if (TREE_CODE ($1) == BIT_NOT_EXPR)
1599 $$ = build_x_unary_op (BIT_NOT_EXPR, TREE_OPERAND ($1, 0));
1601 $$ = finish_id_expr ($1);
1607 $$ = fix_string_type ($$);
1608 /* fix_string_type doesn't set up TYPE_MAIN_VARIANT of
1609 a const array the way we want, so fix it. */
1610 if (flag_const_strings)
1611 TREE_TYPE ($$) = build_cplus_array_type
1612 (TREE_TYPE (TREE_TYPE ($$)),
1613 TYPE_DOMAIN (TREE_TYPE ($$)));
1616 { $$ = finish_fname ($1); }
1618 { $$ = finish_parenthesized_expr ($2); }
1619 | '(' expr_or_declarator_intern ')'
1620 { $2 = reparse_decl_as_expr (NULL_TREE, $2);
1621 $$ = finish_parenthesized_expr ($2); }
1623 { $$ = error_mark_node; }
1625 { if (!at_function_scope_p ())
1627 error ("braced-group within expression allowed only inside a function");
1631 pedwarn ("ISO C++ forbids braced-groups within expressions");
1632 $<ttype>$ = begin_stmt_expr ();
1634 compstmt_or_stmtexpr ')'
1635 { $$ = finish_stmt_expr ($<ttype>2); }
1636 /* Koenig lookup support
1637 We could store lastiddecl in $1 to avoid another lookup,
1638 but that would result in many additional reduce/reduce conflicts. */
1639 | notype_unqualified_id '(' nonnull_exprlist ')'
1640 { $$ = finish_call_expr ($1, $3, 1); }
1641 | notype_unqualified_id LEFT_RIGHT
1642 { $$ = finish_call_expr ($1, NULL_TREE, 1); }
1643 | primary '(' nonnull_exprlist ')'
1644 { $$ = finish_call_expr ($1, $3, 0); }
1645 | primary LEFT_RIGHT
1646 { $$ = finish_call_expr ($1, NULL_TREE, 0); }
1647 | VA_ARG '(' expr_no_commas ',' type_id ')'
1648 { $$ = build_x_va_arg ($3, groktypename ($5.t));
1649 check_for_new_type ("__builtin_va_arg", $5); }
1650 | primary '[' expr ']'
1651 { $$ = grok_array_decl ($$, $3); }
1653 { $$ = finish_increment_expr ($1, POSTINCREMENT_EXPR); }
1654 | primary MINUSMINUS
1655 { $$ = finish_increment_expr ($1, POSTDECREMENT_EXPR); }
1656 /* C++ extensions */
1658 { $$ = finish_this_expr (); }
1659 | CV_QUALIFIER '(' nonnull_exprlist ')'
1661 /* This is a C cast in C++'s `functional' notation
1662 using the "implicit int" extension so that:
1663 `const (3)' is equivalent to `const int (3)'. */
1666 type = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
1667 type = groktypename (build_tree_list (type, NULL_TREE));
1668 $$ = build_functional_cast (type, $3);
1671 | DYNAMIC_CAST '<' type_id '>' '(' expr ')'
1672 { tree type = groktypename ($3.t);
1673 check_for_new_type ("dynamic_cast", $3);
1674 $$ = build_dynamic_cast (type, $6); }
1675 | STATIC_CAST '<' type_id '>' '(' expr ')'
1676 { tree type = groktypename ($3.t);
1677 check_for_new_type ("static_cast", $3);
1678 $$ = build_static_cast (type, $6); }
1679 | REINTERPRET_CAST '<' type_id '>' '(' expr ')'
1680 { tree type = groktypename ($3.t);
1681 check_for_new_type ("reinterpret_cast", $3);
1682 $$ = build_reinterpret_cast (type, $6); }
1683 | CONST_CAST '<' type_id '>' '(' expr ')'
1684 { tree type = groktypename ($3.t);
1685 check_for_new_type ("const_cast", $3);
1686 $$ = build_const_cast (type, $6); }
1687 | TYPEID '(' expr ')'
1688 { $$ = build_typeid ($3); }
1689 | TYPEID '(' type_id ')'
1690 { tree type = groktypename ($3.t);
1691 check_for_new_type ("typeid", $3);
1692 $$ = get_typeid (type); }
1693 | global_scope IDENTIFIER
1694 { $$ = parse_scoped_id ($2); }
1695 | global_scope template_id
1697 | global_scope operator_name
1699 got_scope = NULL_TREE;
1700 if (TREE_CODE ($2) == IDENTIFIER_NODE)
1701 $$ = parse_scoped_id ($2);
1705 | overqualified_id %prec HYPERUNARY
1706 { $$ = build_offset_ref (OP0 ($$), OP1 ($$)); }
1707 | overqualified_id '(' nonnull_exprlist ')'
1708 { $$ = finish_qualified_call_expr ($1, $3); }
1709 | overqualified_id LEFT_RIGHT
1710 { $$ = finish_qualified_call_expr ($1, NULL_TREE); }
1711 | object object_template_id %prec UNARY
1713 $$ = build_x_component_ref ($$, $2, NULL_TREE);
1715 | object object_template_id '(' nonnull_exprlist ')'
1716 { $$ = finish_object_call_expr ($2, $1, $4); }
1717 | object object_template_id LEFT_RIGHT
1718 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1719 | object unqualified_id %prec UNARY
1720 { $$ = build_x_component_ref ($$, $2, NULL_TREE); }
1721 | object overqualified_id %prec UNARY
1722 { if (processing_template_decl)
1723 $$ = build_min_nt (COMPONENT_REF, $1, $2);
1725 $$ = build_object_ref ($$, OP0 ($2), OP1 ($2)); }
1726 | object unqualified_id '(' nonnull_exprlist ')'
1727 { $$ = finish_object_call_expr ($2, $1, $4); }
1728 | object unqualified_id LEFT_RIGHT
1729 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1730 | object overqualified_id '(' nonnull_exprlist ')'
1731 { $$ = finish_qualified_object_call_expr ($2, $1, $4); }
1732 | object overqualified_id LEFT_RIGHT
1733 { $$ = finish_qualified_object_call_expr ($2, $1, NULL_TREE); }
1734 /* p->int::~int() is valid -- 12.4 */
1735 | object '~' TYPESPEC LEFT_RIGHT
1736 { $$ = finish_pseudo_destructor_call_expr ($1, NULL_TREE, $3); }
1737 | object TYPESPEC SCOPE '~' TYPESPEC LEFT_RIGHT
1738 { $$ = finish_pseudo_destructor_call_expr ($1, $2, $5); }
1741 $$ = error_mark_node;
1745 /* Not needed for now.
1751 { $$ = error_mark_node; }
1753 { if (current_function_decl == 0)
1755 error ("braced-group within expression allowed only inside a function");
1758 $<ttype>$ = expand_start_stmt_expr (); }
1759 compstmt_or_stmtexpr ')'
1761 pedwarn ("ISO C++ forbids braced-groups within expressions");
1762 $$ = expand_end_stmt_expr ($<ttype>2); }
1763 | primary_no_id '(' nonnull_exprlist ')'
1764 { $$ = build_x_function_call ($$, $3, current_class_ref); }
1765 | primary_no_id LEFT_RIGHT
1766 { $$ = build_x_function_call ($$, NULL_TREE, current_class_ref); }
1767 | primary_no_id '[' expr ']'
1769 | primary_no_id PLUSPLUS
1770 { $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); }
1771 | primary_no_id MINUSMINUS
1772 { $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); }
1774 { goto do_scoped_id; }
1775 | SCOPE operator_name
1776 { if (TREE_CODE ($2) == IDENTIFIER_NODE)
1778 goto do_scoped_operator;
1787 { got_scope = NULL_TREE; $$ = 1; }
1793 | global_scope delete
1794 { got_scope = NULL_TREE; $$ = 1; }
1799 { $$ = boolean_true_node; }
1801 { $$ = boolean_false_node; }
1807 if (DECL_CONSTRUCTOR_P (current_function_decl))
1808 finish_mem_initializers (NULL_TREE);
1814 { got_object = TREE_TYPE ($$); }
1817 $$ = build_x_arrow ($$);
1818 got_object = TREE_TYPE ($$);
1823 typespec initdecls ';'
1825 if ($1.t && IS_AGGR_TYPE_CODE (TREE_CODE ($1.t)))
1826 note_got_semicolon ($1.t);
1828 | typed_declspecs initdecls ';'
1830 note_list_got_semicolon ($1.t);
1832 | declmods notype_initdecls ';'
1834 | typed_declspecs ';'
1837 note_list_got_semicolon ($1.t);
1840 { warning ("empty declaration"); }
1845 /* Any kind of declarator (thus, all declarators allowed
1846 after an explicit typespec). */
1849 after_type_declarator %prec EMPTY
1850 | notype_declarator %prec EMPTY
1853 /* This is necessary to postpone reduction of `int()()()()'. */
1855 LEFT_RIGHT %prec EMPTY
1856 { $$ = make_call_declarator (NULL_TREE, empty_parms (),
1857 NULL_TREE, NULL_TREE); }
1858 | fcast_or_absdcl LEFT_RIGHT %prec EMPTY
1859 { $$ = make_call_declarator ($$, empty_parms (), NULL_TREE,
1863 /* ISO type-id (8.1) */
1865 typed_typespecs absdcl
1866 { $$.t = build_tree_list ($1.t, $2);
1867 $$.new_type_flag = $1.new_type_flag; }
1868 | nonempty_cv_qualifiers absdcl
1869 { $$.t = build_tree_list ($1.t, $2);
1870 $$.new_type_flag = $1.new_type_flag; }
1872 { $$.t = build_tree_list (build_tree_list (NULL_TREE, $1.t),
1874 $$.new_type_flag = $1.new_type_flag; }
1875 | typed_typespecs %prec EMPTY
1876 { $$.t = build_tree_list ($1.t, NULL_TREE);
1877 $$.new_type_flag = $1.new_type_flag; }
1878 | nonempty_cv_qualifiers %prec EMPTY
1879 { $$.t = build_tree_list ($1.t, NULL_TREE);
1880 $$.new_type_flag = $1.new_type_flag; }
1883 /* Declspecs which contain at least one type specifier or typedef name.
1884 (Just `const' or `volatile' is not enough.)
1885 A typedef'd name following these is taken as a name to be declared.
1886 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1889 typed_typespecs %prec EMPTY
1890 { $$.lookups = type_lookups; }
1892 { $$.lookups = type_lookups; }
1897 { $$.t = tree_cons (NULL_TREE, $2.t, $1.t);
1898 $$.new_type_flag = $2.new_type_flag; }
1899 | typespec reserved_declspecs %prec HYPERUNARY
1900 { $$.t = tree_cons (NULL_TREE, $1.t, $2);
1901 $$.new_type_flag = $1.new_type_flag; }
1902 | typespec reserved_typespecquals reserved_declspecs
1903 { $$.t = tree_cons (NULL_TREE, $1.t, chainon ($2, $3));
1904 $$.new_type_flag = $1.new_type_flag; }
1905 | declmods typespec reserved_declspecs
1906 { $$.t = tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1907 $$.new_type_flag = $2.new_type_flag; }
1908 | declmods typespec reserved_typespecquals
1909 { $$.t = tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1910 $$.new_type_flag = $2.new_type_flag; }
1911 | declmods typespec reserved_typespecquals reserved_declspecs
1912 { $$.t = tree_cons (NULL_TREE, $2.t,
1913 chainon ($3, chainon ($4, $1.t)));
1914 $$.new_type_flag = $2.new_type_flag; }
1919 { if (extra_warnings)
1920 warning ("`%s' is not at beginning of declaration",
1921 IDENTIFIER_POINTER ($$));
1922 $$ = build_tree_list (NULL_TREE, $$); }
1923 | reserved_declspecs typespecqual_reserved
1924 { $$ = tree_cons (NULL_TREE, $2.t, $$); }
1925 | reserved_declspecs SCSPEC
1926 { if (extra_warnings)
1927 warning ("`%s' is not at beginning of declaration",
1928 IDENTIFIER_POINTER ($2));
1929 $$ = tree_cons (NULL_TREE, $2, $$); }
1932 /* List of just storage classes and type modifiers.
1933 A declaration can start with just this, but then it cannot be used
1934 to redeclare a typedef-name.
1935 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1937 /* We use hash_tree_cons for lists of typeless declspecs so that they end
1938 up on a persistent obstack. Otherwise, they could appear at the
1939 beginning of something like
1941 static const struct { int foo () { } } b;
1943 and would be discarded after we finish compiling foo. We don't need to
1944 worry once we see a type. */
1947 nonempty_cv_qualifiers %prec EMPTY
1948 { $$.lookups = NULL_TREE; TREE_STATIC ($$.t) = 1; }
1951 $$.t = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
1952 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
1954 | declmods CV_QUALIFIER
1956 $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
1957 TREE_STATIC ($$.t) = 1;
1961 if (extra_warnings && TREE_STATIC ($$.t))
1962 warning ("`%s' is not at beginning of declaration",
1963 IDENTIFIER_POINTER ($2));
1964 $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
1965 TREE_STATIC ($$.t) = TREE_STATIC ($1.t);
1967 | declmods attributes
1968 { $$.t = hash_tree_cons ($2, NULL_TREE, $1.t); }
1971 /* Used instead of declspecs where storage classes are not allowed
1972 (that is, for typenames and structure components).
1974 C++ can takes storage classes for structure components.
1975 Don't accept a typedef-name if anything but a modifier precedes it. */
1978 typespec %prec EMPTY
1979 { $$.t = build_tree_list (NULL_TREE, $1.t);
1980 $$.new_type_flag = $1.new_type_flag; }
1981 | nonempty_cv_qualifiers typespec
1982 { $$.t = tree_cons (NULL_TREE, $2.t, $1.t);
1983 $$.new_type_flag = $2.new_type_flag; }
1984 | typespec reserved_typespecquals
1985 { $$.t = tree_cons (NULL_TREE, $1.t, $2);
1986 $$.new_type_flag = $1.new_type_flag; }
1987 | nonempty_cv_qualifiers typespec reserved_typespecquals
1988 { $$.t = tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1989 $$.new_type_flag = $2.new_type_flag; }
1992 reserved_typespecquals:
1993 typespecqual_reserved
1994 { $$ = build_tree_list (NULL_TREE, $1.t); }
1995 | reserved_typespecquals typespecqual_reserved
1996 { $$ = tree_cons (NULL_TREE, $2.t, $1); }
1997 | reserved_typespecquals attributes
1998 { $$ = tree_cons ($2, NULL_TREE, $1); }
1999 | attributes %prec EMPTY
2000 { $$ = tree_cons ($1, NULL_TREE, NULL_TREE); }
2003 /* A typespec (but not a type qualifier).
2004 Once we have seen one of these in a declaration,
2005 if a typedef name appears then it is being redeclared. */
2009 { $$.lookups = NULL_TREE; }
2010 | TYPESPEC %prec EMPTY
2011 { $$.t = $1; $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
2012 | complete_type_name
2013 { $$.t = $1; $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
2014 | TYPEOF '(' expr ')'
2015 { $$.t = finish_typeof ($3);
2016 $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
2017 | TYPEOF '(' type_id ')'
2018 { $$.t = groktypename ($3.t);
2019 $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
2020 | SIGOF '(' expr ')'
2021 { tree type = TREE_TYPE ($3);
2023 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
2024 if (IS_AGGR_TYPE (type))
2026 sorry ("sigof type specifier");
2031 error ("`sigof' applied to non-aggregate expression");
2032 $$.t = error_mark_node;
2035 | SIGOF '(' type_id ')'
2036 { tree type = groktypename ($3.t);
2038 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
2039 if (IS_AGGR_TYPE (type))
2041 sorry ("sigof type specifier");
2046 error("`sigof' applied to non-aggregate type");
2047 $$.t = error_mark_node;
2052 /* A typespec that is a reserved word, or a type qualifier. */
2054 typespecqual_reserved:
2056 { $$.t = $1; $$.new_type_flag = 0; }
2058 { $$.t = $1; $$.new_type_flag = 0; }
2064 | initdecls ',' initdcl
2065 { check_multiple_declarators (); }
2070 | notype_initdecls ',' initdcl
2071 { check_multiple_declarators (); }
2076 | nomods_initdecls ',' initdcl
2077 { check_multiple_declarators (); }
2083 | asm_keyword '(' STRING ')'
2088 declarator maybeasm maybe_attribute '='
2089 { $<ttype>$ = parse_decl ($<ttype>1, $3, 1); }
2091 /* Note how the declaration of the variable is in effect while its init is parsed! */
2092 { parse_end_decl ($<ttype>5, $6, $2); }
2093 | declarator maybeasm maybe_attribute
2095 $<ttype>$ = parse_decl ($<ttype>1, $3, 0);
2096 parse_end_decl ($<ttype>$, NULL_TREE, $2);
2100 /* This rule assumes a certain configuration of the parser stack.
2101 In particular, $0, the element directly before the beginning of
2102 this rule on the stack, must be a maybeasm. $-1 must be a
2103 declarator or notype_declarator. And $-2 must be some declmods
2104 or declspecs. We can't move the maybeasm into this rule because
2105 we need that reduce so we prefer fn.def1 when appropriate. */
2108 { $<ttype>$ = parse_decl0 ($<ttype>-1, $<ftype>-2.t,
2109 $<ftype>-2.lookups, $1, 1); }
2110 /* Note how the declaration of the variable is in effect
2111 while its init is parsed! */
2113 { parse_end_decl ($<ttype>3, $4, $<ttype>0); }
2115 { tree d = parse_decl0 ($<ttype>-1, $<ftype>-2.t,
2116 $<ftype>-2.lookups, $1, 0);
2117 parse_end_decl (d, NULL_TREE, $<ttype>0); }
2121 declarator maybeasm initdcl0_innards
2126 notype_declarator maybeasm initdcl0_innards
2131 notype_declarator maybeasm
2132 { /* Set things up as initdcl0_innards expects. */
2135 $<ftype>1.t = NULL_TREE;
2136 $<ftype>1.lookups = NULL_TREE; }
2139 | constructor_declarator maybeasm maybe_attribute
2140 { tree d = parse_decl0 ($1, NULL_TREE, NULL_TREE, $3, 0);
2141 parse_end_decl (d, NULL_TREE, $2); }
2144 /* the * rules are dummies to accept the Apollo extended syntax
2145 so that the header files compile. */
2156 | attributes attribute
2157 { $$ = chainon ($1, $2); }
2161 ATTRIBUTE '(' '(' attribute_list ')' ')'
2168 | attribute_list ',' attrib
2169 { $$ = chainon ($1, $3); }
2176 { $$ = build_tree_list ($1, NULL_TREE); }
2177 | any_word '(' IDENTIFIER ')'
2178 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
2179 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
2180 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
2181 | any_word '(' nonnull_exprlist ')'
2182 { $$ = build_tree_list ($1, $3); }
2185 /* This still leaves out most reserved keywords,
2186 shouldn't we include them? */
2195 /* A nonempty list of identifiers, including typenames. */
2196 identifiers_or_typenames:
2198 { $$ = build_tree_list (NULL_TREE, $1); }
2199 | identifiers_or_typenames ',' identifier
2200 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2204 /* empty */ %prec EMPTY
2210 /* If we are processing a template, we don't want to expand this
2214 expr_no_commas %prec '='
2216 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, NULL_TREE);
2217 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2219 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2220 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2221 | '{' initlist ',' '}'
2222 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2223 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2228 /* This chain is built in reverse order,
2229 and put in forward order where initlist is used. */
2232 { $$ = build_tree_list (NULL_TREE, $$); }
2234 { $$ = tree_cons (NULL_TREE, $3, $$); }
2235 /* These are for labeled elements. */
2236 | '[' expr_no_commas ']' init
2237 { $$ = build_tree_list ($2, $4); }
2238 | identifier ':' init
2239 { $$ = build_tree_list ($$, $3); }
2240 | initlist ',' identifier ':' init
2241 { $$ = tree_cons ($3, $5, $$); }
2245 PRE_PARSED_FUNCTION_DECL maybe_return_init function_body
2247 expand_body (finish_function (2));
2248 process_next_inline ($1);
2250 | PRE_PARSED_FUNCTION_DECL maybe_return_init function_try_block
2252 expand_body (finish_function (2));
2253 process_next_inline ($1);
2255 | PRE_PARSED_FUNCTION_DECL maybe_return_init error
2257 finish_function (2);
2258 process_next_inline ($1); }
2263 | pending_inlines pending_inline eat_saved_input
2266 /* A regurgitated default argument. The value of DEFARG_MARKER will be
2267 the TREE_LIST node for the parameter in question. */
2269 DEFARG_MARKER expr_no_commas END_OF_SAVED_INPUT
2270 { replace_defarg ($1, $2); }
2271 | DEFARG_MARKER error END_OF_SAVED_INPUT
2272 { replace_defarg ($1, error_mark_node); }
2276 /* empty */ %prec EMPTY
2277 | pending_defargs defarg_again
2278 { do_pending_defargs (); }
2279 | pending_defargs error
2280 { do_pending_defargs (); }
2285 { $<ttype>$ = current_enum_type;
2286 current_enum_type = start_enum ($2); }
2288 { $$.t = current_enum_type;
2289 finish_enum (current_enum_type);
2290 $$.new_type_flag = 1;
2291 current_enum_type = $<ttype>4;
2292 check_for_missing_semicolon ($$.t); }
2294 { $<ttype>$ = current_enum_type;
2295 current_enum_type = start_enum (make_anon_name ()); }
2297 { $$.t = current_enum_type;
2298 finish_enum (current_enum_type);
2299 $$.new_type_flag = 1;
2300 current_enum_type = $<ttype>3;
2301 check_for_missing_semicolon ($$.t); }
2303 { $$.t = parse_xref_tag (enum_type_node, $2, 1);
2304 $$.new_type_flag = 0; }
2305 | ENUM complex_type_name
2306 { $$.t = parse_xref_tag (enum_type_node, $2, 1);
2307 $$.new_type_flag = 0; }
2308 | TYPENAME_KEYWORD typename_sub
2310 $$.new_type_flag = 0;
2311 if (!processing_template_decl)
2312 pedwarn ("using `typename' outside of template"); }
2313 /* C++ extensions, merged with C to avoid shift/reduce conflicts */
2314 | class_head_defn maybe_base_class_list '{'
2316 if ($2 && $1.t != error_mark_node)
2318 tree type = TREE_TYPE ($1.t);
2320 if (TREE_CODE (type) == TYPENAME_TYPE)
2321 /* In a definition of a member class template,
2322 we will get here with an implicit typename,
2323 a TYPENAME_TYPE with a type. */
2324 type = TREE_TYPE (type);
2325 maybe_process_partial_specialization (type);
2326 xref_basetypes (type, $2);
2328 $1.t = begin_class_definition (TREE_TYPE ($1.t));
2329 check_class_key (current_aggr, $1.t);
2330 current_aggr = NULL_TREE; }
2331 opt.component_decl_list '}' maybe_attribute
2336 if (yychar == YYEMPTY)
2338 semi = yychar == ';';
2340 t = finish_class_definition ($1.t, $7, semi, $1.new_type_flag);
2343 /* restore current_aggr */
2344 current_aggr = TREE_CODE (t) != RECORD_TYPE
2346 : CLASSTYPE_DECLARED_CLASS (t)
2347 ? class_type_node : record_type_node;
2351 done_pending_defargs ();
2352 begin_inline_definitions ();
2357 $$.new_type_flag = 1;
2361 $$.t = TREE_TYPE ($1.t);
2362 $$.new_type_flag = $1.new_type_flag;
2363 check_class_key (current_aggr, $$.t);
2375 { if (pedantic && !in_system_header)
2376 pedwarn ("comma at end of enumerator list"); }
2382 { error ("storage class specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2384 { error ("type specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2386 { error ("type qualifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2388 { error ("no body nor ';' separates two class, struct or union declarations"); }
2390 { $$ = build_tree_list ($2, $1); }
2397 $$ = build_tree_list (NULL_TREE, $2);
2399 | aggr nested_name_specifier identifier
2402 $$ = build_tree_list ($2, $3);
2404 | aggr global_scope nested_name_specifier identifier
2407 $$ = build_tree_list ($3, $4);
2409 | aggr global_scope identifier
2412 $$ = build_tree_list (global_namespace, $3);
2416 class_head_apparent_template:
2417 aggr apparent_template_type
2422 | aggr nested_name_specifier apparent_template_type
2427 | aggr global_scope nested_name_specifier apparent_template_type
2435 class_head %prec EMPTY
2437 $$.t = parse_handle_class_head (current_aggr,
2440 0, &$$.new_type_flag);
2442 | aggr identifier_defn %prec EMPTY
2445 $$.t = TYPE_MAIN_DECL (parse_xref_tag (current_aggr, $2, 0));
2446 $$.new_type_flag = 1;
2448 | class_head_apparent_template %prec EMPTY
2451 $$.new_type_flag = 0;
2459 $$.t = parse_handle_class_head (current_aggr,
2468 $$.t = parse_handle_class_head (current_aggr,
2471 1, &$$.new_type_flag);
2473 | class_head_apparent_template '{'
2477 $$.new_type_flag = 0;
2478 if (TREE_CODE (TREE_TYPE ($1)) == RECORD_TYPE)
2479 /* We might be specializing a template with a different
2481 CLASSTYPE_DECLARED_CLASS (TREE_TYPE ($1))
2482 = (current_aggr == class_type_node);
2484 | class_head_apparent_template ':'
2488 $$.new_type_flag = 0;
2489 if (TREE_CODE (TREE_TYPE ($1)) == RECORD_TYPE)
2490 /* We might be specializing a template with a different
2492 CLASSTYPE_DECLARED_CLASS (TREE_TYPE ($1))
2493 = (current_aggr == class_type_node);
2495 | aggr identifier_defn '{'
2499 $$.t = parse_handle_class_head (current_aggr,
2501 1, &$$.new_type_flag);
2503 | aggr identifier_defn ':'
2507 $$.t = parse_handle_class_head (current_aggr,
2509 1, &$$.new_type_flag);
2514 $$.t = TYPE_MAIN_DECL (parse_xref_tag ($1,
2517 $$.new_type_flag = 0;
2522 maybe_base_class_list:
2526 { error ("no bases given following `:'");
2528 | ':' see_typename base_class_list
2534 | base_class_list ',' see_typename base_class
2535 { $$ = chainon ($$, $4); }
2540 { $$ = finish_base_specifier (access_default_node, $1); }
2541 | base_class_access_list see_typename base_class_1
2542 { $$ = finish_base_specifier ($1, $3); }
2548 $$ = error_mark_node; }
2550 { $$ = TREE_TYPE ($$); }
2553 base_class_access_list:
2554 VISSPEC see_typename
2555 | SCSPEC see_typename
2556 { if ($1 != ridpointers[(int)RID_VIRTUAL])
2557 error ("`%D' access", $1);
2558 $$ = access_default_virtual_node; }
2559 | base_class_access_list VISSPEC see_typename
2561 if ($1 != access_default_virtual_node)
2562 error ("multiple access specifiers");
2563 else if ($2 == access_public_node)
2564 $$ = access_public_virtual_node;
2565 else if ($2 == access_protected_node)
2566 $$ = access_protected_virtual_node;
2567 else /* $2 == access_private_node */
2568 $$ = access_private_virtual_node;
2570 | base_class_access_list SCSPEC see_typename
2571 { if ($2 != ridpointers[(int)RID_VIRTUAL])
2572 error ("`%D' access", $2);
2573 else if ($$ == access_public_node)
2574 $$ = access_public_virtual_node;
2575 else if ($$ == access_protected_node)
2576 $$ = access_protected_virtual_node;
2577 else if ($$ == access_private_node)
2578 $$ = access_private_virtual_node;
2580 error ("multiple `virtual' specifiers");
2584 opt.component_decl_list:
2585 | component_decl_list
2586 | opt.component_decl_list access_specifier component_decl_list
2587 | opt.component_decl_list access_specifier
2593 current_access_specifier = $1;
2597 /* Note: we no longer warn about the semicolon after a component_decl_list.
2598 ARM $9.2 says that the semicolon is optional, and therefore allowed. */
2599 component_decl_list:
2602 finish_member_declaration ($1);
2603 current_aggr = NULL_TREE;
2604 reset_type_access_control ();
2606 | component_decl_list component_decl
2608 finish_member_declaration ($2);
2609 current_aggr = NULL_TREE;
2610 reset_type_access_control ();
2615 component_decl_1 ';'
2616 | component_decl_1 '}'
2617 { error ("missing ';' before right brace");
2618 yyungetc ('}', 0); }
2619 /* C++: handle constructors, destructors and inline functions */
2620 /* note that INLINE is like a TYPESPEC */
2621 | fn_def2 ':' /* base_init compstmt */
2622 { $$ = finish_method ($$); }
2623 | fn_def2 TRY /* base_init compstmt */
2624 { $$ = finish_method ($$); }
2625 | fn_def2 RETURN_KEYWORD /* base_init compstmt */
2626 { $$ = finish_method ($$); }
2627 | fn_def2 '{' /* nodecls compstmt */
2628 { $$ = finish_method ($$); }
2631 | extension component_decl
2634 | template_header component_decl
2637 $$ = finish_member_template_decl ($2);
2639 /* The component was already processed. */
2642 finish_template_decl ($1);
2644 | template_header typed_declspecs ';'
2646 $$ = finish_member_class_template ($2.t);
2647 finish_template_decl ($1);
2654 /* Do not add a "typed_declspecs declarator" rule here for
2655 speed; we need to call grok_x_components for enums, so the
2656 speedup would be insignificant. */
2657 typed_declspecs components
2659 /* Most of the productions for component_decl only
2660 allow the creation of one new member, so we call
2661 finish_member_declaration in component_decl_list.
2662 For this rule and the next, however, there can be
2663 more than one member, e.g.:
2667 and we need the first member to be fully
2668 registered before the second is processed.
2669 Therefore, the rules for components take care of
2670 this processing. To avoid registering the
2671 components more than once, we send NULL_TREE up
2672 here; that lets finish_member_declaration know
2673 that there is nothing to do. */
2675 grok_x_components ($1.t);
2678 | declmods notype_components
2681 grok_x_components ($1.t);
2684 | notype_declarator maybeasm maybe_attribute maybe_init
2685 { $$ = grokfield ($$, NULL_TREE, $4, $2, $3); }
2686 | constructor_declarator maybeasm maybe_attribute maybe_init
2687 { $$ = grokfield ($$, NULL_TREE, $4, $2, $3); }
2688 | ':' expr_no_commas
2689 { $$ = grokbitfield (NULL_TREE, NULL_TREE, $2); }
2693 /* These rules introduce a reduce/reduce conflict; in
2694 typedef int foo, bar;
2698 should "A::foo" be declared as a function or "A::bar" as a data
2699 member? In other words, is "bar" an after_type_declarator or a
2701 | declmods component_constructor_declarator maybeasm maybe_attribute maybe_init
2702 { tree specs, attrs;
2703 split_specs_attrs ($1.t, &specs, &attrs);
2704 $$ = grokfield ($2, specs, $5, $3,
2705 chainon ($4, attrs)); }
2706 | component_constructor_declarator maybeasm maybe_attribute maybe_init
2707 { $$ = grokfield ($$, NULL_TREE, $4, $2, $3); }
2709 { $$ = do_class_using_decl ($1); }
2712 /* The case of exactly one component is handled directly by component_decl. */
2715 /* empty: possibly anonymous */
2717 | component_declarator0
2719 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2720 $1 = finish_member_template_decl ($1);
2721 finish_member_declaration ($1);
2724 | components ',' component_declarator
2726 check_multiple_declarators ();
2727 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2728 $3 = finish_member_template_decl ($3);
2729 finish_member_declaration ($3);
2735 /* empty: possibly anonymous */
2737 | notype_component_declarator0
2739 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2740 $1 = finish_member_template_decl ($1);
2741 finish_member_declaration ($1);
2744 | notype_components ',' notype_component_declarator
2746 check_multiple_declarators ();
2747 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2748 $3 = finish_member_template_decl ($3);
2749 finish_member_declaration ($3);
2754 component_declarator0:
2755 after_type_component_declarator0
2756 | notype_component_declarator0
2759 component_declarator:
2760 after_type_component_declarator
2761 | notype_component_declarator
2764 after_type_component_declarator0:
2765 after_type_declarator maybeasm maybe_attribute maybe_init
2766 { $$ = parse_field0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2768 | tTYPENAME ':' expr_no_commas maybe_attribute
2769 { $$ = parse_bitfield0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2773 notype_component_declarator0:
2774 notype_declarator maybeasm maybe_attribute maybe_init
2775 { $$ = parse_field0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2777 | constructor_declarator maybeasm maybe_attribute maybe_init
2778 { $$ = parse_field0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2780 | IDENTIFIER ':' expr_no_commas maybe_attribute
2781 { $$ = parse_bitfield0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2783 | ':' expr_no_commas maybe_attribute
2784 { $$ = parse_bitfield0 (NULL_TREE, $<ftype>0.t,
2785 $<ftype>0.lookups, $3, $2); }
2788 after_type_component_declarator:
2789 after_type_declarator maybeasm maybe_attribute maybe_init
2790 { $$ = parse_field ($1, $3, $2, $4); }
2791 | tTYPENAME ':' expr_no_commas maybe_attribute
2792 { $$ = parse_bitfield ($1, $4, $3); }
2795 notype_component_declarator:
2796 notype_declarator maybeasm maybe_attribute maybe_init
2797 { $$ = parse_field ($1, $3, $2, $4); }
2798 | IDENTIFIER ':' expr_no_commas maybe_attribute
2799 { $$ = parse_bitfield ($1, $4, $3); }
2800 | ':' expr_no_commas maybe_attribute
2801 { $$ = parse_bitfield (NULL_TREE, $3, $2); }
2805 enumlist maybecomma_warn
2809 /* We chain the enumerators in reverse order.
2810 Because of the way enums are built, the order is
2811 insignificant. Take advantage of this fact. */
2815 | enumlist ',' enumerator
2820 { build_enumerator ($1, NULL_TREE, current_enum_type); }
2821 | identifier '=' expr_no_commas
2822 { build_enumerator ($1, $3, current_enum_type); }
2825 /* ISO new-type-id (5.3.4) */
2827 type_specifier_seq new_declarator
2828 { $$.t = build_tree_list ($1.t, $2);
2829 $$.new_type_flag = $1.new_type_flag; }
2830 | type_specifier_seq %prec EMPTY
2831 { $$.t = build_tree_list ($1.t, NULL_TREE);
2832 $$.new_type_flag = $1.new_type_flag; }
2833 /* GNU extension to allow arrays of arbitrary types with
2834 non-constant dimension. */
2835 | '(' type_id ')' '[' expr ']'
2838 pedwarn ("ISO C++ forbids array dimensions with parenthesized type in new");
2839 $$.t = build_nt (ARRAY_REF, TREE_VALUE ($2.t), $5);
2840 $$.t = build_tree_list (TREE_PURPOSE ($2.t), $$.t);
2841 $$.new_type_flag = $2.new_type_flag;
2846 /* empty */ %prec EMPTY
2848 | cv_qualifiers CV_QUALIFIER
2849 { $$ = tree_cons (NULL_TREE, $2, $$); }
2852 nonempty_cv_qualifiers:
2854 { $$.t = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
2855 $$.new_type_flag = 0; }
2856 | nonempty_cv_qualifiers CV_QUALIFIER
2857 { $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
2858 $$.new_type_flag = $1.new_type_flag; }
2859 | attributes %prec EMPTY
2860 { $$.t = hash_tree_cons ($1, NULL_TREE, NULL_TREE);
2861 $$.new_type_flag = 0; }
2862 | nonempty_cv_qualifiers attributes %prec EMPTY
2863 { $$.t = hash_tree_cons ($2, NULL_TREE, $1.t);
2864 $$.new_type_flag = $1.new_type_flag; }
2867 /* These rules must follow the rules for function declarations
2868 and component declarations. That way, longer rules are preferred. */
2870 /* An expression which will not live on the momentary obstack. */
2872 '(' nonnull_exprlist ')'
2877 { $$ = empty_parms (); }
2882 /* A declarator that is allowed only after an explicit typespec. */
2884 after_type_declarator_intern:
2885 after_type_declarator
2886 | attributes after_type_declarator
2888 /* Provide support for '(' attributes '*' declarator ')'
2890 $$ = tree_cons ($1, $2, NULL_TREE);
2894 /* may all be followed by prec '.' */
2895 after_type_declarator:
2896 '*' nonempty_cv_qualifiers after_type_declarator_intern %prec UNARY
2897 { $$ = make_pointer_declarator ($2.t, $3); }
2898 | '&' nonempty_cv_qualifiers after_type_declarator_intern %prec UNARY
2899 { $$ = make_reference_declarator ($2.t, $3); }
2900 | '*' after_type_declarator_intern %prec UNARY
2901 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2902 | '&' after_type_declarator_intern %prec UNARY
2903 { $$ = make_reference_declarator (NULL_TREE, $2); }
2904 | ptr_to_mem cv_qualifiers after_type_declarator_intern
2905 { tree arg = make_pointer_declarator ($2, $3);
2906 $$ = build_nt (SCOPE_REF, $1, arg);
2908 | direct_after_type_declarator
2911 direct_after_type_declarator:
2912 direct_after_type_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2913 { $$ = make_call_declarator ($$, $2, $3, $4); }
2914 | direct_after_type_declarator '[' expr ']'
2915 { $$ = build_nt (ARRAY_REF, $$, $3); }
2916 | direct_after_type_declarator '[' ']'
2917 { $$ = build_nt (ARRAY_REF, $$, NULL_TREE); }
2918 | '(' after_type_declarator_intern ')'
2920 | nested_name_specifier type_name %prec EMPTY
2921 { push_nested_class ($1, 3);
2922 $$ = build_nt (SCOPE_REF, $$, $2);
2923 TREE_COMPLEXITY ($$) = current_class_depth; }
2924 | type_name %prec EMPTY
2928 type_name %prec EMPTY
2930 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2932 $$ = lookup_name ($1, 1);
2933 maybe_note_name_used_in_class ($1, $$);
2938 | global_scope type_name
2940 if (TREE_CODE ($2) == IDENTIFIER_NODE)
2941 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
2944 got_scope = NULL_TREE;
2951 | global_scope nested_type
2956 nested_name_specifier type_name %prec EMPTY
2957 { $$ = get_type_decl ($2); }
2960 /* A declarator allowed whether or not there has been
2961 an explicit typespec. These cannot redeclare a typedef-name. */
2963 notype_declarator_intern:
2965 | attributes notype_declarator
2967 /* Provide support for '(' attributes '*' declarator ')'
2969 $$ = tree_cons ($1, $2, NULL_TREE);
2974 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2975 { $$ = make_pointer_declarator ($2.t, $3); }
2976 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2977 { $$ = make_reference_declarator ($2.t, $3); }
2978 | '*' notype_declarator_intern %prec UNARY
2979 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2980 | '&' notype_declarator_intern %prec UNARY
2981 { $$ = make_reference_declarator (NULL_TREE, $2); }
2982 | ptr_to_mem cv_qualifiers notype_declarator_intern
2983 { tree arg = make_pointer_declarator ($2, $3);
2984 $$ = build_nt (SCOPE_REF, $1, arg);
2986 | direct_notype_declarator
2989 complex_notype_declarator:
2990 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2991 { $$ = make_pointer_declarator ($2.t, $3); }
2992 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2993 { $$ = make_reference_declarator ($2.t, $3); }
2994 | '*' complex_notype_declarator %prec UNARY
2995 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2996 | '&' complex_notype_declarator %prec UNARY
2997 { $$ = make_reference_declarator (NULL_TREE, $2); }
2998 | ptr_to_mem cv_qualifiers notype_declarator_intern
2999 { tree arg = make_pointer_declarator ($2, $3);
3000 $$ = build_nt (SCOPE_REF, $1, arg);
3002 | complex_direct_notype_declarator
3005 complex_direct_notype_declarator:
3006 direct_notype_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
3007 { $$ = make_call_declarator ($$, $2, $3, $4); }
3008 | '(' complex_notype_declarator ')'
3010 | direct_notype_declarator '[' expr ']'
3011 { $$ = build_nt (ARRAY_REF, $$, $3); }
3012 | direct_notype_declarator '[' ']'
3013 { $$ = build_nt (ARRAY_REF, $$, NULL_TREE); }
3014 | notype_qualified_id
3015 { enter_scope_of ($1); }
3016 | global_scope notype_qualified_id
3017 { enter_scope_of ($2); $$ = $2;}
3018 | global_scope notype_unqualified_id
3019 { $$ = build_nt (SCOPE_REF, global_namespace, $2);
3020 enter_scope_of ($$);
3022 | nested_name_specifier notype_template_declarator
3023 { got_scope = NULL_TREE;
3024 $$ = build_nt (SCOPE_REF, $1, $2);
3025 enter_scope_of ($$);
3030 nested_name_specifier unqualified_id
3031 { got_scope = NULL_TREE;
3032 $$ = build_nt (SCOPE_REF, $$, $2); }
3033 | nested_name_specifier object_template_id
3034 { got_scope = NULL_TREE;
3035 $$ = build_nt (SCOPE_REF, $1, $2); }
3038 notype_qualified_id:
3039 nested_name_specifier notype_unqualified_id
3040 { got_scope = NULL_TREE;
3041 $$ = build_nt (SCOPE_REF, $$, $2); }
3042 | nested_name_specifier object_template_id
3043 { got_scope = NULL_TREE;
3044 $$ = build_nt (SCOPE_REF, $1, $2); }
3049 | global_scope notype_qualified_id
3054 typespec '(' nonnull_exprlist ')'
3055 { $$ = build_functional_cast ($1.t, $3); }
3056 | typespec '(' expr_or_declarator_intern ')'
3057 { $$ = reparse_decl_as_expr ($1.t, $3); }
3058 | typespec fcast_or_absdcl %prec EMPTY
3059 { $$ = reparse_absdcl_as_expr ($1.t, $2); }
3065 | template_type %prec EMPTY
3068 nested_name_specifier:
3069 nested_name_specifier_1
3070 | nested_name_specifier nested_name_specifier_1
3072 | nested_name_specifier TEMPLATE explicit_template_type SCOPE
3074 = make_typename_type ($1, $3, tf_error | tf_parsing); }
3075 /* Error handling per Core 125. */
3076 | nested_name_specifier IDENTIFIER SCOPE
3078 = make_typename_type ($1, $2, tf_error | tf_parsing); }
3079 | nested_name_specifier PTYPENAME SCOPE
3081 = make_typename_type ($1, $2, tf_error | tf_parsing); }
3084 /* Why the @#$%^& do type_name and notype_identifier need to be expanded
3085 inline here?!? (jason) */
3086 nested_name_specifier_1:
3089 if (TREE_CODE ($1) == IDENTIFIER_NODE)
3092 maybe_note_name_used_in_class ($1, $$);
3095 complete_type (TYPE_MAIN_VARIANT (TREE_TYPE ($$)));
3099 if (TREE_CODE ($1) == IDENTIFIER_NODE)
3101 got_scope = $$ = TREE_TYPE ($$);
3105 if (TREE_CODE ($$) == IDENTIFIER_NODE)
3109 | template_type SCOPE
3110 { got_scope = $$ = complete_type (TREE_TYPE ($1)); }
3115 | global_scope typename_sub0
3120 typename_sub1 identifier %prec EMPTY
3123 $$ = make_typename_type ($1, $2, tf_error | tf_parsing);
3124 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
3125 error ("`%T' is not a class or namespace", $2);
3129 if (TREE_CODE ($$) == TYPE_DECL)
3130 $$ = TREE_TYPE ($$);
3133 | typename_sub1 template_type %prec EMPTY
3134 { $$ = TREE_TYPE ($2); }
3135 | typename_sub1 explicit_template_type %prec EMPTY
3136 { $$ = make_typename_type ($1, $2, tf_error | tf_parsing); }
3137 | typename_sub1 TEMPLATE explicit_template_type %prec EMPTY
3138 { $$ = make_typename_type ($1, $3, tf_error | tf_parsing); }
3144 if (TREE_CODE ($1) == IDENTIFIER_NODE)
3145 error ("`%T' is not a class or namespace", $1);
3146 else if (TREE_CODE ($1) == TYPE_DECL)
3147 $$ = TREE_TYPE ($1);
3149 | typename_sub1 typename_sub2
3152 $$ = make_typename_type ($1, $2, tf_error | tf_parsing);
3153 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
3154 error ("`%T' is not a class or namespace", $2);
3158 if (TREE_CODE ($$) == TYPE_DECL)
3159 $$ = TREE_TYPE ($$);
3162 | typename_sub1 explicit_template_type SCOPE
3164 = make_typename_type ($1, $2, tf_error | tf_parsing); }
3165 | typename_sub1 TEMPLATE explicit_template_type SCOPE
3167 = make_typename_type ($1, $3, tf_error | tf_parsing); }
3170 /* This needs to return a TYPE_DECL for simple names so that we don't
3171 forget what name was used. */
3175 if (TREE_CODE ($1) != TYPE_DECL)
3178 /* Retrieve the type for the identifier, which might involve
3179 some computation. */
3180 got_scope = complete_type (TREE_TYPE ($$));
3182 if ($$ == error_mark_node)
3183 error ("`%T' is not a class or namespace", $1);
3187 if (TREE_CODE ($1) != TYPE_DECL)
3189 got_scope = complete_type (TREE_TYPE ($$));
3191 | template_type SCOPE
3192 { got_scope = $$ = complete_type (TREE_TYPE ($$)); }
3197 if (TREE_CODE ($$) == IDENTIFIER_NODE)
3203 explicit_template_type:
3204 identifier '<' template_arg_list_opt template_close_bracket
3205 { $$ = build_min_nt (TEMPLATE_ID_EXPR, $1, $3); }
3209 global_scope type_name
3211 if (TREE_CODE ($2) == IDENTIFIER_NODE)
3212 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
3215 got_scope = NULL_TREE;
3218 | global_scope nested_type
3223 nested_name_specifier '*'
3224 { got_scope = NULL_TREE; }
3225 | global_scope nested_name_specifier '*'
3226 { $$ = $2; got_scope = NULL_TREE; }
3229 /* All uses of explicit global scope must go through this nonterminal so
3230 that got_scope will be set before yylex is called to get the next token. */
3233 { got_scope = void_type_node; }
3236 /* ISO new-declarator (5.3.4) */
3238 '*' cv_qualifiers new_declarator
3239 { $$ = make_pointer_declarator ($2, $3); }
3240 | '*' cv_qualifiers %prec EMPTY
3241 { $$ = make_pointer_declarator ($2, NULL_TREE); }
3242 | '&' cv_qualifiers new_declarator %prec EMPTY
3243 { $$ = make_reference_declarator ($2, $3); }
3244 | '&' cv_qualifiers %prec EMPTY
3245 { $$ = make_reference_declarator ($2, NULL_TREE); }
3246 | ptr_to_mem cv_qualifiers %prec EMPTY
3247 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3248 $$ = build_nt (SCOPE_REF, $1, arg);
3250 | ptr_to_mem cv_qualifiers new_declarator
3251 { tree arg = make_pointer_declarator ($2, $3);
3252 $$ = build_nt (SCOPE_REF, $1, arg);
3254 | direct_new_declarator %prec EMPTY
3257 /* ISO direct-new-declarator (5.3.4) */
3258 direct_new_declarator:
3260 { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
3261 | direct_new_declarator '[' expr ']'
3262 { $$ = build_nt (ARRAY_REF, $$, $3); }
3269 /* Provide support for '(' attributes '*' declarator ')'
3271 $$ = tree_cons ($1, $2, NULL_TREE);
3275 /* ISO abstract-declarator (8.1) */
3277 '*' nonempty_cv_qualifiers absdcl_intern
3278 { $$ = make_pointer_declarator ($2.t, $3); }
3280 { $$ = make_pointer_declarator (NULL_TREE, $2); }
3281 | '*' nonempty_cv_qualifiers %prec EMPTY
3282 { $$ = make_pointer_declarator ($2.t, NULL_TREE); }
3284 { $$ = make_pointer_declarator (NULL_TREE, NULL_TREE); }
3285 | '&' nonempty_cv_qualifiers absdcl_intern
3286 { $$ = make_reference_declarator ($2.t, $3); }
3288 { $$ = make_reference_declarator (NULL_TREE, $2); }
3289 | '&' nonempty_cv_qualifiers %prec EMPTY
3290 { $$ = make_reference_declarator ($2.t, NULL_TREE); }
3292 { $$ = make_reference_declarator (NULL_TREE, NULL_TREE); }
3293 | ptr_to_mem cv_qualifiers %prec EMPTY
3294 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3295 $$ = build_nt (SCOPE_REF, $1, arg);
3297 | ptr_to_mem cv_qualifiers absdcl_intern
3298 { tree arg = make_pointer_declarator ($2, $3);
3299 $$ = build_nt (SCOPE_REF, $1, arg);
3301 | direct_abstract_declarator %prec EMPTY
3304 /* ISO direct-abstract-declarator (8.1) */
3305 direct_abstract_declarator:
3306 '(' absdcl_intern ')'
3308 /* `(typedef)1' is `int'. */
3309 | direct_abstract_declarator '(' parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3310 { $$ = make_call_declarator ($$, $3, $5, $6); }
3311 | direct_abstract_declarator LEFT_RIGHT cv_qualifiers exception_specification_opt %prec '.'
3312 { $$ = make_call_declarator ($$, empty_parms (), $3, $4); }
3313 | direct_abstract_declarator '[' expr ']' %prec '.'
3314 { $$ = build_nt (ARRAY_REF, $$, $3); }
3315 | direct_abstract_declarator '[' ']' %prec '.'
3316 { $$ = build_nt (ARRAY_REF, $$, NULL_TREE); }
3317 | '(' complex_parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3318 { $$ = make_call_declarator (NULL_TREE, $2, $4, $5); }
3319 | regcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3320 { set_quals_and_spec ($$, $2, $3); }
3321 | fcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3322 { set_quals_and_spec ($$, $2, $3); }
3323 | '[' expr ']' %prec '.'
3324 { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
3326 { $$ = build_nt (ARRAY_REF, NULL_TREE, NULL_TREE); }
3329 /* For C++, decls and stmts can be intermixed, so we don't need to
3330 have a special rule that won't start parsing the stmt section
3331 until we have a stmt that parses without errors. */
3344 /* Read zero or more forward-declarations for labels
3345 that nested functions can jump to. */
3350 pedwarn ("ISO C++ forbids label declarations"); }
3355 | label_decls label_decl
3359 LABEL identifiers_or_typenames ';'
3363 finish_label_decl (TREE_VALUE ($2));
3364 $2 = TREE_CHAIN ($2);
3369 compstmt_or_stmtexpr:
3371 { $<ttype>$ = begin_compound_stmt (0); }
3373 { STMT_LINENO ($<ttype>3) = $1;
3374 finish_compound_stmt (0, $<ttype>3); }
3378 compstmt_or_stmtexpr
3379 { last_expr_type = NULL_TREE; }
3384 { $<ttype>$ = begin_if_stmt ();
3385 cond_stmt_keyword = "if"; }
3387 { finish_if_stmt_cond ($3, $<ttype>2); }
3388 implicitly_scoped_stmt
3390 finish_then_clause ($<ttype>2); }
3393 implicitly_scoped_stmt:
3396 { $<ttype>$ = begin_compound_stmt (0); }
3397 save_lineno simple_stmt
3398 { STMT_LINENO ($<ttype>1) = $2;
3399 if ($3) STMT_LINENO ($3) = $2;
3400 finish_compound_stmt (0, $<ttype>1); }
3405 | save_lineno simple_stmt
3406 { if ($2) STMT_LINENO ($2) = $1; }
3414 { $$ = finish_expr_stmt ($1); }
3416 { begin_else_clause (); }
3417 implicitly_scoped_stmt
3420 finish_else_clause ($1);
3423 | simple_if %prec IF
3425 finish_if_stmt (); }
3428 $<ttype>$ = begin_while_stmt ();
3429 cond_stmt_keyword = "while";
3432 { finish_while_stmt_cond ($3, $<ttype>2); }
3433 implicitly_scoped_stmt
3435 finish_while_stmt ($<ttype>2); }
3437 { $<ttype>$ = begin_do_stmt (); }
3438 implicitly_scoped_stmt WHILE
3440 finish_do_body ($<ttype>2);
3441 cond_stmt_keyword = "do";
3443 paren_expr_or_null ';'
3445 finish_do_stmt ($6, $<ttype>2); }
3447 { $<ttype>$ = begin_for_stmt (); }
3448 '(' for.init.statement
3449 { finish_for_init_stmt ($<ttype>2); }
3451 { finish_for_cond ($6, $<ttype>2); }
3453 { finish_for_expr ($9, $<ttype>2); }
3454 implicitly_scoped_stmt
3456 finish_for_stmt ($<ttype>2); }
3458 { $<ttype>$ = begin_switch_stmt (); }
3460 { finish_switch_cond ($4, $<ttype>2); }
3461 implicitly_scoped_stmt
3463 finish_switch_stmt ($<ttype>2); }
3464 | CASE expr_no_commas ':'
3465 { $<ttype>$ = finish_case_label ($2, NULL_TREE); }
3468 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
3469 { $<ttype>$ = finish_case_label ($2, $4); }
3473 { $<ttype>$ = finish_case_label (NULL_TREE, NULL_TREE); }
3477 { $$ = finish_break_stmt (); }
3479 { $$ = finish_continue_stmt (); }
3480 | RETURN_KEYWORD ';'
3481 { $$ = finish_return_stmt (NULL_TREE); }
3482 | RETURN_KEYWORD expr ';'
3483 { $$ = finish_return_stmt ($2); }
3484 | asm_keyword maybe_cv_qualifier '(' STRING ')' ';'
3485 { $$ = finish_asm_stmt ($2, $4, NULL_TREE, NULL_TREE,
3487 ASM_INPUT_P ($$) = 1; }
3488 /* This is the case with just output operands. */
3489 | asm_keyword maybe_cv_qualifier '(' STRING ':' asm_operands ')' ';'
3490 { $$ = finish_asm_stmt ($2, $4, $6, NULL_TREE, NULL_TREE); }
3491 /* This is the case with input operands as well. */
3492 | asm_keyword maybe_cv_qualifier '(' STRING ':' asm_operands ':'
3493 asm_operands ')' ';'
3494 { $$ = finish_asm_stmt ($2, $4, $6, $8, NULL_TREE); }
3495 | asm_keyword maybe_cv_qualifier '(' STRING SCOPE asm_operands ')' ';'
3496 { $$ = finish_asm_stmt ($2, $4, NULL_TREE, $6, NULL_TREE); }
3497 /* This is the case with clobbered registers as well. */
3498 | asm_keyword maybe_cv_qualifier '(' STRING ':' asm_operands ':'
3499 asm_operands ':' asm_clobbers ')' ';'
3500 { $$ = finish_asm_stmt ($2, $4, $6, $8, $10); }
3501 | asm_keyword maybe_cv_qualifier '(' STRING SCOPE asm_operands ':'
3502 asm_clobbers ')' ';'
3503 { $$ = finish_asm_stmt ($2, $4, NULL_TREE, $6, $8); }
3504 | asm_keyword maybe_cv_qualifier '(' STRING ':' asm_operands SCOPE
3505 asm_clobbers ')' ';'
3506 { $$ = finish_asm_stmt ($2, $4, $6, NULL_TREE, $8); }
3510 pedwarn ("ISO C++ forbids computed gotos");
3511 $$ = finish_goto_stmt ($3);
3513 | GOTO identifier ';'
3514 { $$ = finish_goto_stmt ($2); }
3518 { error ("label must be followed by statement");
3528 | namespace_using_decl
3529 { do_local_using_decl ($1);
3537 { $<ttype>$ = begin_function_try_block (); }
3539 { finish_function_try_block ($<ttype>2); }
3541 { finish_function_handler_sequence ($<ttype>2); }
3546 { $<ttype>$ = begin_try_block (); }
3548 { finish_try_block ($<ttype>2); }
3550 { finish_handler_sequence ($<ttype>2); }
3555 | handler_seq handler
3557 { /* Generate a fake handler block to avoid later aborts. */
3558 tree fake_handler = begin_handler ();
3559 finish_handler_parms (NULL_TREE, fake_handler);
3560 finish_handler (fake_handler);
3561 $<ttype>$ = fake_handler;
3563 error ("must have at least one catch per try block");
3569 { $<ttype>$ = begin_handler (); }
3571 { finish_handler_parms ($3, $<ttype>2); }
3573 { finish_handler ($<ttype>2); }
3577 typed_typespecs %prec EMPTY
3578 | nonempty_cv_qualifiers %prec EMPTY
3584 /* This doesn't allow reference parameters, the below does.
3585 | '(' type_specifier_seq absdcl ')'
3586 { check_for_new_type ("inside exception declarations", $2);
3587 expand_start_catch_block ($2.t, $3); }
3588 | '(' type_specifier_seq ')'
3589 { check_for_new_type ("inside exception declarations", $2);
3590 expand_start_catch_block ($2.t, NULL_TREE); }
3591 | '(' type_specifier_seq notype_declarator ')'
3592 { check_for_new_type ("inside exception declarations", $2);
3593 expand_start_catch_block ($2.t, $3); }
3594 | '(' typed_typespecs after_type_declarator ')'
3595 { check_for_new_type ("inside exception declarations", $2);
3596 expand_start_catch_block ($2.t, $3); }
3597 This allows reference parameters... */
3600 check_for_new_type ("inside exception declarations", $2);
3601 $$ = start_handler_parms (TREE_PURPOSE ($2.t),
3608 { finish_label_stmt ($1); }
3610 { finish_label_stmt ($1); }
3612 { finish_label_stmt ($1); }
3614 { finish_label_stmt ($1); }
3619 { finish_expr_stmt ($1); }
3623 pedwarn ("ISO C++ forbids compound statements inside for initializations");
3627 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
3643 /* These are the operands other than the first string and colon
3644 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
3648 | nonnull_asm_operands
3651 nonnull_asm_operands:
3653 | nonnull_asm_operands ',' asm_operand
3654 { $$ = chainon ($$, $3); }
3659 { $$ = build_tree_list (build_tree_list (NULL_TREE, $1), $3); }
3660 | '[' identifier ']' STRING '(' expr ')'
3661 { $2 = build_string (IDENTIFIER_LENGTH ($2),
3662 IDENTIFIER_POINTER ($2));
3663 $$ = build_tree_list (build_tree_list ($2, $4), $6); }
3668 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);}
3669 | asm_clobbers ',' STRING
3670 { $$ = tree_cons (NULL_TREE, $3, $1); }
3673 /* This is what appears inside the parens in a function declarator.
3674 Its value is represented in the format that grokdeclarator expects.
3676 In C++, declaring a function with no parameters
3677 means that that function takes *no* parameters. */
3686 { $$ = finish_parmlist (build_tree_list (NULL_TREE, $1.t), 0);
3687 check_for_new_type ("inside parameter list", $1); }
3690 /* This nonterminal does not include the common sequence '(' type_id ')',
3691 as it is ambiguous and must be disambiguated elsewhere. */
3694 { $$ = finish_parmlist ($$, 0); }
3695 | parms_comma ELLIPSIS
3696 { $$ = finish_parmlist ($1, 1); }
3697 /* C++ allows an ellipsis without a separating ',' */
3699 { $$ = finish_parmlist ($1, 1); }
3701 { $$ = finish_parmlist (build_tree_list (NULL_TREE,
3704 { $$ = finish_parmlist (NULL_TREE, 1); }
3707 /* This helps us recover from really nasty
3708 parse errors, for example, a missing right
3710 yyerror ("possibly missing ')'");
3711 $$ = finish_parmlist ($1, 0);
3717 /* This helps us recover from really nasty
3718 parse errors, for example, a missing right
3720 yyerror ("possibly missing ')'");
3721 $$ = finish_parmlist (build_tree_list (NULL_TREE,
3728 /* A default argument to a */
3731 { maybe_snarf_defarg (); }
3741 /* A nonempty list of parameter declarations or type names. */
3744 { check_for_new_type ("in a parameter list", $1);
3745 $$ = build_tree_list (NULL_TREE, $1.t); }
3747 { check_for_new_type ("in a parameter list", $1);
3748 $$ = build_tree_list ($2, $1.t); }
3749 | parms_comma full_parm
3750 { check_for_new_type ("in a parameter list", $2);
3751 $$ = chainon ($$, $2.t); }
3752 | parms_comma bad_parm
3753 { $$ = chainon ($$, build_tree_list (NULL_TREE, $2)); }
3754 | parms_comma bad_parm '=' init
3755 { $$ = chainon ($$, build_tree_list ($4, $2)); }
3761 { check_for_new_type ("in a parameter list", $1);
3762 $$ = build_tree_list (NULL_TREE, $1.t); }
3765 /* A single parameter declaration or parameter type name,
3766 as found in a parmlist. */
3768 /* Here we expand typed_declspecs inline to avoid mis-parsing of
3769 TYPESPEC IDENTIFIER. */
3770 typed_declspecs1 declarator
3771 { $$.new_type_flag = $1.new_type_flag;
3772 $$.t = build_tree_list ($1.t, $2); }
3773 | typed_typespecs declarator
3774 { $$.t = build_tree_list ($1.t, $2);
3775 $$.new_type_flag = $1.new_type_flag; }
3776 | typespec declarator
3777 { $$.t = build_tree_list (build_tree_list (NULL_TREE, $1.t),
3779 $$.new_type_flag = $1.new_type_flag; }
3780 | typed_declspecs1 absdcl
3781 { $$.t = build_tree_list ($1.t, $2);
3782 $$.new_type_flag = $1.new_type_flag; }
3783 | typed_declspecs1 %prec EMPTY
3784 { $$.t = build_tree_list ($1.t, NULL_TREE);
3785 $$.new_type_flag = $1.new_type_flag; }
3786 | declmods notype_declarator
3787 { $$.t = build_tree_list ($1.t, $2);
3788 $$.new_type_flag = 0; }
3793 { $$.t = build_tree_list (NULL_TREE, $1.t);
3794 $$.new_type_flag = $1.new_type_flag; }
3796 { $$.t = build_tree_list ($2, $1.t);
3797 $$.new_type_flag = $1.new_type_flag; }
3806 /* empty */ %prec EMPTY
3807 { see_typename (); }
3811 /* empty */ %prec EMPTY
3813 error ("type specifier omitted for parameter");
3814 $$ = build_tree_list (integer_type_node, NULL_TREE);
3818 if (TREE_CODE ($$) == SCOPE_REF)
3820 if (TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TYPE_PARM
3821 || TREE_CODE (TREE_OPERAND ($$, 0)) == BOUND_TEMPLATE_TEMPLATE_PARM)
3822 error ("`%E' is not a type, use `typename %E' to make it one", $$);
3824 error ("no type `%D' in `%T'", TREE_OPERAND ($$, 1), TREE_OPERAND ($$, 0));
3827 error ("type specifier omitted for parameter `%E'", $$);
3828 $$ = build_tree_list (integer_type_node, $$);
3833 IDENTIFIER template_arg_list_ignore IDENTIFIER arg_list_ignore ';'
3835 error("'%D' is used as a type, but is not defined as a type.", $1);
3836 $3 = error_mark_node;
3840 template_arg_list_ignore:
3841 '<' template_arg_list_opt template_close_bracket
3847 '(' nonnull_exprlist ')'
3852 exception_specification_opt:
3853 /* empty */ %prec EMPTY
3855 | THROW '(' ansi_raise_identifiers ')' %prec EMPTY
3857 | THROW LEFT_RIGHT %prec EMPTY
3858 { $$ = empty_except_spec; }
3861 ansi_raise_identifier:
3864 check_for_new_type ("exception specifier", $1);
3865 $$ = groktypename ($1.t);
3868 { $$ = error_mark_node; }
3871 ansi_raise_identifiers:
3872 ansi_raise_identifier
3873 { $$ = add_exception_specifier (NULL_TREE, $1, 1); }
3874 | ansi_raise_identifiers ',' ansi_raise_identifier
3875 { $$ = add_exception_specifier ($1, $3, 1); }
3878 conversion_declarator:
3879 /* empty */ %prec EMPTY
3881 | '*' cv_qualifiers conversion_declarator
3882 { $$ = make_pointer_declarator ($2, $3); }
3883 | '&' cv_qualifiers conversion_declarator
3884 { $$ = make_reference_declarator ($2, $3); }
3885 | ptr_to_mem cv_qualifiers conversion_declarator
3886 { tree arg = make_pointer_declarator ($2, $3);
3887 $$ = build_nt (SCOPE_REF, $1, arg);
3894 saved_scopes = tree_cons (got_scope, got_object, saved_scopes);
3895 TREE_LANG_FLAG_0 (saved_scopes) = looking_for_typename;
3896 /* We look for conversion-type-id's in both the class and current
3897 scopes, just as for ID in 'ptr->ID::'. */
3898 looking_for_typename = 1;
3899 got_object = got_scope;
3900 got_scope = NULL_TREE;
3905 { got_scope = TREE_PURPOSE (saved_scopes);
3906 got_object = TREE_VALUE (saved_scopes);
3907 looking_for_typename = TREE_LANG_FLAG_0 (saved_scopes);
3908 saved_scopes = TREE_CHAIN (saved_scopes);
3913 operator '*' unoperator
3914 { $$ = frob_opname (ansi_opname (MULT_EXPR)); }
3915 | operator '/' unoperator
3916 { $$ = frob_opname (ansi_opname (TRUNC_DIV_EXPR)); }
3917 | operator '%' unoperator
3918 { $$ = frob_opname (ansi_opname (TRUNC_MOD_EXPR)); }
3919 | operator '+' unoperator
3920 { $$ = frob_opname (ansi_opname (PLUS_EXPR)); }
3921 | operator '-' unoperator
3922 { $$ = frob_opname (ansi_opname (MINUS_EXPR)); }
3923 | operator '&' unoperator
3924 { $$ = frob_opname (ansi_opname (BIT_AND_EXPR)); }
3925 | operator '|' unoperator
3926 { $$ = frob_opname (ansi_opname (BIT_IOR_EXPR)); }
3927 | operator '^' unoperator
3928 { $$ = frob_opname (ansi_opname (BIT_XOR_EXPR)); }
3929 | operator '~' unoperator
3930 { $$ = frob_opname (ansi_opname (BIT_NOT_EXPR)); }
3931 | operator ',' unoperator
3932 { $$ = frob_opname (ansi_opname (COMPOUND_EXPR)); }
3933 | operator ARITHCOMPARE unoperator
3934 { $$ = frob_opname (ansi_opname ($2)); }
3935 | operator '<' unoperator
3936 { $$ = frob_opname (ansi_opname (LT_EXPR)); }
3937 | operator '>' unoperator
3938 { $$ = frob_opname (ansi_opname (GT_EXPR)); }
3939 | operator EQCOMPARE unoperator
3940 { $$ = frob_opname (ansi_opname ($2)); }
3941 | operator ASSIGN unoperator
3942 { $$ = frob_opname (ansi_assopname ($2)); }
3943 | operator '=' unoperator
3944 { $$ = frob_opname (ansi_assopname (NOP_EXPR)); }
3945 | operator LSHIFT unoperator
3946 { $$ = frob_opname (ansi_opname ($2)); }
3947 | operator RSHIFT unoperator
3948 { $$ = frob_opname (ansi_opname ($2)); }
3949 | operator PLUSPLUS unoperator
3950 { $$ = frob_opname (ansi_opname (POSTINCREMENT_EXPR)); }
3951 | operator MINUSMINUS unoperator
3952 { $$ = frob_opname (ansi_opname (PREDECREMENT_EXPR)); }
3953 | operator ANDAND unoperator
3954 { $$ = frob_opname (ansi_opname (TRUTH_ANDIF_EXPR)); }
3955 | operator OROR unoperator
3956 { $$ = frob_opname (ansi_opname (TRUTH_ORIF_EXPR)); }
3957 | operator '!' unoperator
3958 { $$ = frob_opname (ansi_opname (TRUTH_NOT_EXPR)); }
3959 | operator '?' ':' unoperator
3960 { $$ = frob_opname (ansi_opname (COND_EXPR)); }
3961 | operator MIN_MAX unoperator
3962 { $$ = frob_opname (ansi_opname ($2)); }
3963 | operator POINTSAT unoperator %prec EMPTY
3964 { $$ = frob_opname (ansi_opname (COMPONENT_REF)); }
3965 | operator POINTSAT_STAR unoperator %prec EMPTY
3966 { $$ = frob_opname (ansi_opname (MEMBER_REF)); }
3967 | operator LEFT_RIGHT unoperator
3968 { $$ = frob_opname (ansi_opname (CALL_EXPR)); }
3969 | operator '[' ']' unoperator
3970 { $$ = frob_opname (ansi_opname (ARRAY_REF)); }
3971 | operator NEW unoperator %prec EMPTY
3972 { $$ = frob_opname (ansi_opname (NEW_EXPR)); }
3973 | operator DELETE unoperator %prec EMPTY
3974 { $$ = frob_opname (ansi_opname (DELETE_EXPR)); }
3975 | operator NEW '[' ']' unoperator
3976 { $$ = frob_opname (ansi_opname (VEC_NEW_EXPR)); }
3977 | operator DELETE '[' ']' unoperator
3978 { $$ = frob_opname (ansi_opname (VEC_DELETE_EXPR)); }
3979 | operator type_specifier_seq conversion_declarator unoperator
3980 { $$ = frob_opname (grokoptypename ($2.t, $3)); }
3981 | operator error unoperator
3982 { $$ = frob_opname (ansi_opname (ERROR_MARK)); }
3985 /* The forced readahead in here is because we might be at the end of a
3986 line, and lineno won't be bumped until yylex absorbs the first token
3987 on the next line. */
3989 { if (yychar == YYEMPTY)
3997 debug_yytranslate (value)
4000 return yytname[YYTRANSLATE (value)];
4004 /* Free malloced parser stacks if necessary. */
4007 free_parser_stacks ()
4011 free (malloced_yyss);
4012 free (malloced_yyvs);
4016 /* Return the value corresponding to TOKEN in the global scope. */
4019 parse_scoped_id (token)
4024 id = make_node (CPLUS_BINDING);
4025 if (!qualified_lookup_using_namespace (token, global_namespace, id, 0))
4028 id = BINDING_VALUE (id);
4029 if (yychar == YYEMPTY)
4032 return do_scoped_id (token, id);
4035 /* AGGR may be either a type node (like class_type_node) or a
4036 TREE_LIST whose TREE_PURPOSE is a list of attributes and whose
4037 TREE_VALUE is a type node. Set *TAG_KIND and *ATTRIBUTES to
4038 represent the information encoded. */
4041 parse_split_aggr (tree aggr, enum tag_types *tag_kind, tree *attributes)
4043 if (TREE_CODE (aggr) == TREE_LIST)
4045 *attributes = TREE_PURPOSE (aggr);
4046 aggr = TREE_VALUE (aggr);
4049 *attributes = NULL_TREE;
4050 *tag_kind = (enum tag_types) tree_low_cst (aggr, 1);
4053 /* Like xref_tag, except that the AGGR may be either a type node (like
4054 class_type_node) or a TREE_LIST whose TREE_PURPOSE is a list of
4055 attributes and whose TREE_VALUE is a type node. */
4058 parse_xref_tag (tree aggr, tree name, int globalize)
4061 enum tag_types tag_kind;
4062 parse_split_aggr (aggr, &tag_kind, &attributes);
4063 return xref_tag (tag_kind, name, attributes, globalize);
4066 /* Like handle_class_head, but AGGR may be as for parse_xref_tag. */
4069 parse_handle_class_head (tree aggr, tree scope, tree id,
4070 int defn_p, int *new_type_p)
4073 enum tag_types tag_kind;
4074 parse_split_aggr (aggr, &tag_kind, &attributes);
4075 return handle_class_head (tag_kind, scope, id, attributes,
4076 defn_p, new_type_p);
4079 /* Like do_decl_instantiation, but the declarator has not yet been
4083 parse_decl_instantiation (tree declspecs, tree declarator, tree storage)
4085 tree decl = grokdeclarator (declarator, declspecs, NORMAL, 0, NULL);
4086 do_decl_instantiation (decl, storage);
4089 /* Like begin_function_definition, but SPECS_ATTRS is a combined list
4090 containing both a decl-specifier-seq and attributes. */
4093 parse_begin_function_definition (tree specs_attrs, tree declarator)
4098 split_specs_attrs (specs_attrs, &specs, &attrs);
4099 return begin_function_definition (specs, attrs, declarator);
4102 #include "gt-cp-parse.h"