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 /* Like YYERROR but do call yyerror. */
48 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
50 /* Like the default stack expander, except (1) use realloc when possible,
51 (2) impose no hard maxiumum on stack size, (3) REALLY do not use alloca.
53 Irritatingly, YYSTYPE is defined after this %{ %} block, so we cannot
54 give malloced_yyvs its proper type. This is ok since all we need from
55 it is to be able to free it. */
57 static short *malloced_yyss;
58 static void *malloced_yyvs;
60 #define yyoverflow(MSG, SS, SSSIZE, VS, VSSIZE, YYSSZ) \
65 newsize = *(YYSSZ) *= 2; \
69 really_call_realloc (*(SS), newsize * sizeof (short)); \
71 really_call_realloc (*(VS), newsize * sizeof (YYSTYPE)); \
75 newss = (short *) really_call_malloc (newsize * sizeof (short)); \
76 newvs = (YYSTYPE *) really_call_malloc (newsize * sizeof (YYSTYPE)); \
78 memcpy (newss, *(SS), (SSSIZE)); \
80 memcpy (newvs, *(VS), (VSSIZE)); \
82 if (!newss || !newvs) \
89 malloced_yyss = newss; \
90 malloced_yyvs = (void *) newvs; \
92 #define OP0(NODE) (TREE_OPERAND (NODE, 0))
93 #define OP1(NODE) (TREE_OPERAND (NODE, 1))
95 /* Contains the statement keyword (if/while/do) to include in an
96 error message if the user supplies an empty conditional expression. */
97 static const char *cond_stmt_keyword;
99 /* List of types and structure classes of the current declaration. */
100 static GTY(()) tree current_declspecs;
102 /* List of prefix attributes in effect.
103 Prefix attributes are parsed by the reserved_declspecs and declmods
104 rules. They create a list that contains *both* declspecs and attrs. */
105 /* ??? It is not clear yet that all cases where an attribute can now appear in
106 a declspec list have been updated. */
107 static GTY(()) tree prefix_attributes;
109 /* When defining an enumeration, this is the type of the enumeration. */
110 static GTY(()) tree current_enum_type;
112 /* When parsing a conversion operator name, this is the scope of the
114 static GTY(()) tree saved_scopes;
116 static tree empty_parms PARAMS ((void));
117 static tree parse_decl0 PARAMS ((tree, tree, tree, tree, int));
118 static tree parse_decl PARAMS ((tree, tree, int));
119 static void parse_end_decl PARAMS ((tree, tree, tree));
120 static tree parse_field0 PARAMS ((tree, tree, tree, tree, tree, tree));
121 static tree parse_field PARAMS ((tree, tree, tree, tree));
122 static tree parse_bitfield0 PARAMS ((tree, tree, tree, tree, tree));
123 static tree parse_bitfield PARAMS ((tree, tree, tree));
124 static tree parse_method PARAMS ((tree, tree, tree));
125 static void frob_specs PARAMS ((tree, tree));
126 static void check_class_key PARAMS ((tree, tree));
127 static tree parse_scoped_id PARAMS ((tree));
128 static tree parse_xref_tag (tree, tree, int);
129 static tree parse_handle_class_head (tree, tree, tree, int, int *);
130 static void parse_decl_instantiation (tree, tree, tree);
131 static int parse_begin_function_definition (tree, tree);
132 static tree parse_finish_call_expr (tree, tree, int);
134 /* Cons up an empty parameter list. */
140 #ifndef NO_IMPLICIT_EXTERN_C
141 if (in_system_header && current_class_type == NULL
142 && current_lang_name == lang_name_c)
146 parms = void_list_node;
150 /* Record the decl-specifiers, attributes and type lookups from the
151 decl-specifier-seq in a declaration. */
154 frob_specs (specs_attrs, lookups)
155 tree specs_attrs, lookups;
157 save_type_access_control (lookups);
158 split_specs_attrs (specs_attrs, ¤t_declspecs, &prefix_attributes);
159 if (current_declspecs
160 && TREE_CODE (current_declspecs) != TREE_LIST)
161 current_declspecs = build_tree_list (NULL_TREE, current_declspecs);
162 if (have_extern_spec)
164 /* We have to indicate that there is an "extern", but that it
165 was part of a language specifier. For instance,
167 extern "C" typedef int (*Ptr) ();
170 current_declspecs = tree_cons (error_mark_node,
171 get_identifier ("extern"),
173 have_extern_spec = false;
178 parse_decl (declarator, attributes, initialized)
179 tree declarator, attributes;
182 return start_decl (declarator, current_declspecs, initialized,
183 attributes, prefix_attributes);
187 parse_decl0 (declarator, specs_attrs, lookups, attributes, initialized)
188 tree declarator, specs_attrs, lookups, attributes;
191 frob_specs (specs_attrs, lookups);
192 return parse_decl (declarator, attributes, initialized);
196 parse_end_decl (decl, init, asmspec)
197 tree decl, init, asmspec;
199 /* If decl is NULL_TREE, then this was a variable declaration using
200 () syntax for the initializer, so we handled it in grokdeclarator. */
202 decl_type_access_control (decl);
203 cp_finish_decl (decl, init, asmspec, init ? LOOKUP_ONLYCONVERTING : 0);
207 parse_field (declarator, attributes, asmspec, init)
208 tree declarator, attributes, asmspec, init;
210 tree d = grokfield (declarator, current_declspecs, init, asmspec,
211 chainon (attributes, prefix_attributes));
212 decl_type_access_control (d);
217 parse_field0 (declarator, specs_attrs, lookups, attributes, asmspec, init)
218 tree declarator, specs_attrs, lookups, attributes, asmspec, init;
220 frob_specs (specs_attrs, lookups);
221 return parse_field (declarator, attributes, asmspec, init);
225 parse_bitfield (declarator, attributes, width)
226 tree declarator, attributes, width;
228 tree d = grokbitfield (declarator, current_declspecs, width);
229 cplus_decl_attributes (&d, chainon (attributes, prefix_attributes), 0);
230 decl_type_access_control (d);
235 parse_bitfield0 (declarator, specs_attrs, lookups, attributes, width)
236 tree declarator, specs_attrs, lookups, attributes, width;
238 frob_specs (specs_attrs, lookups);
239 return parse_bitfield (declarator, attributes, width);
243 parse_method (declarator, specs_attrs, lookups)
244 tree declarator, specs_attrs, lookups;
247 frob_specs (specs_attrs, lookups);
248 d = start_method (current_declspecs, declarator, prefix_attributes);
249 decl_type_access_control (d);
254 check_class_key (key, aggr)
258 if (TREE_CODE (key) == TREE_LIST)
259 key = TREE_VALUE (key);
260 if ((key == union_type_node) != (TREE_CODE (aggr) == UNION_TYPE))
261 pedwarn ("`%s' tag used in naming `%#T'",
262 key == union_type_node ? "union"
263 : key == record_type_node ? "struct" : "class", aggr);
275 flagged_type_tree ftype;
276 struct unparsed_text *pi;
279 /* All identifiers that are not reserved words
280 and are not declared typedefs in the current block */
283 /* All identifiers that are declared typedefs in the current block.
284 In some contexts, they are treated just like IDENTIFIER,
285 but they can also serve as typespecs in declarations. */
289 /* A template function. */
292 /* Reserved words that specify storage class.
293 yylval contains an IDENTIFIER_NODE which indicates which one. */
296 /* Reserved words that specify type.
297 yylval contains an IDENTIFIER_NODE which indicates which one. */
300 /* Reserved words that qualify type: "const" or "volatile".
301 yylval contains an IDENTIFIER_NODE which indicates which one. */
304 /* Character or numeric constants.
305 yylval is the node for the constant. */
308 /* __func__, __FUNCTION__ or __PRETTY_FUNCTION__.
309 yylval contains an IDENTIFIER_NODE which indicates which one. */
310 %token <ttype> VAR_FUNC_NAME
312 /* String constants in raw form.
313 yylval is a STRING_CST node. */
316 /* "...", used for functions with variable arglists. */
319 /* the reserved words */
320 /* SCO include files test "ASM", so use something else. */
321 %token SIZEOF ENUM /* STRUCT UNION */ IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
322 %token BREAK CONTINUE RETURN_KEYWORD GOTO ASM_KEYWORD TYPEOF ALIGNOF
324 %token ATTRIBUTE EXTENSION LABEL
325 %token REALPART IMAGPART VA_ARG
327 /* the reserved words... C++ extensions */
329 %token <ttype> VISSPEC
330 %token DELETE NEW THIS OPERATOR CXX_TRUE CXX_FALSE
331 %token NAMESPACE TYPENAME_KEYWORD USING
332 %token LEFT_RIGHT TEMPLATE
333 %token TYPEID DYNAMIC_CAST STATIC_CAST REINTERPRET_CAST CONST_CAST
336 /* Define the operator tokens and their precedences.
337 The value is an integer because, if used, it is the tree code
338 to use in the expression made from the operator. */
340 %left EMPTY /* used to resolve s/r with epsilon */
344 /* Add precedence rules to solve dangling else s/r conflict */
348 %left IDENTIFIER PFUNCNAME tTYPENAME SELFNAME PTYPENAME SCSPEC TYPESPEC CV_QUALIFIER ENUM AGGR ELLIPSIS TYPEOF SIGOF OPERATOR NSNAME TYPENAME_KEYWORD ATTRIBUTE
354 %right <code> ASSIGN '='
362 %left <code> EQCOMPARE
363 %left <code> ARITHCOMPARE '<' '>'
364 %left <code> LSHIFT RSHIFT
366 %left <code> '*' '/' '%'
367 %left <code> POINTSAT_STAR DOT_STAR
368 %right <code> UNARY PLUSPLUS MINUSMINUS '~'
370 %left <ttype> LEFT_RIGHT
371 %left <code> POINTSAT '.' '(' '['
373 %right SCOPE /* C++ extension */
374 %nonassoc NEW DELETE TRY CATCH
378 %type <ttype> identifier IDENTIFIER tTYPENAME CONSTANT expr nonnull_exprlist
379 %type <ttype> PFUNCNAME maybe_identifier
380 %type <ttype> paren_expr_or_null nontrivial_exprlist SELFNAME
381 %type <ttype> expr_no_commas expr_no_comma_rangle
382 %type <ttype> cast_expr unary_expr primary STRING
383 %type <ttype> reserved_declspecs boolean_literal
384 %type <ttype> reserved_typespecquals
385 %type <ttype> SCSPEC TYPESPEC CV_QUALIFIER maybe_cv_qualifier
386 %type <ttype> init initlist maybeasm maybe_init defarg defarg1
387 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
388 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
389 %type <ttype> any_word
391 %type <itype> save_lineno
392 %type <ttype> simple_stmt simple_if
394 %type <ttype> declarator notype_declarator after_type_declarator
395 %type <ttype> notype_declarator_intern absdcl_intern
396 %type <ttype> after_type_declarator_intern
397 %type <ttype> direct_notype_declarator direct_after_type_declarator
398 %type <itype> components notype_components
399 %type <ttype> component_decl component_decl_1
400 %type <ttype> component_declarator component_declarator0
401 %type <ttype> notype_component_declarator notype_component_declarator0
402 %type <ttype> after_type_component_declarator after_type_component_declarator0
403 %type <ttype> absdcl cv_qualifiers
404 %type <ttype> direct_abstract_declarator conversion_declarator
405 %type <ttype> new_declarator direct_new_declarator
406 %type <ttype> xexpr parmlist parms bad_parm
407 %type <ttype> identifiers_or_typenames
408 %type <ttype> fcast_or_absdcl regcast_or_absdcl
409 %type <ttype> expr_or_declarator expr_or_declarator_intern
410 %type <ttype> complex_notype_declarator
411 %type <ttype> notype_unqualified_id unqualified_id qualified_id
412 %type <ttype> template_id do_id object_template_id notype_template_declarator
413 %type <ttype> overqualified_id notype_qualified_id any_id
414 %type <ttype> complex_direct_notype_declarator functional_cast
415 %type <ttype> complex_parmlist parms_comma
416 %type <ttype> namespace_qualifier namespace_using_decl
418 %type <ftype> type_id new_type_id typed_typespecs typespec typed_declspecs
419 %type <ftype> typed_declspecs1 type_specifier_seq nonempty_cv_qualifiers
420 %type <ftype> structsp typespecqual_reserved parm named_parm full_parm
421 %type <ftype> declmods
423 %type <itype> extension
426 %token <ttype> PTYPENAME
427 %token <ttype> EXTERN_LANG_STRING ALL
428 %token <ttype> PRE_PARSED_CLASS_DECL DEFARG DEFARG_MARKER
429 %token <pi> PRE_PARSED_FUNCTION_DECL
430 %type <ttype> component_constructor_declarator
431 %type <ttype> fn_def2 return_id constructor_declarator
432 %type <ttype> begin_function_body_
433 %type <ttype> class_head class_head_apparent_template
434 %type <ftype> class_head_decl class_head_defn
435 %type <ttype> base_class_list
436 %type <ttype> base_class_access_list
437 %type <ttype> base_class maybe_base_class_list base_class_1
438 %type <ttype> exception_specification_opt ansi_raise_identifier ansi_raise_identifiers
439 %type <ttype> operator_name
440 %type <ttype> object aggr
441 %type <itype> new delete
442 /* %type <ttype> primary_no_id */
443 %type <ttype> maybe_parmlist
444 %type <ttype> member_init
445 %type <ftype> member_init_list
446 %type <ttype> template_parm_header template_spec_header template_header
447 %type <ttype> template_parm_list template_parm
448 %type <ttype> template_type_parm template_template_parm
449 %type <code> template_close_bracket
450 %type <ttype> apparent_template_type
451 %type <ttype> template_type template_arg_list template_arg_list_opt
452 %type <ttype> template_arg
453 %type <ttype> condition xcond paren_cond_or_null
454 %type <ttype> type_name nested_name_specifier nested_type ptr_to_mem
455 %type <ttype> complete_type_name notype_identifier nonnested_type
456 %type <ttype> complex_type_name nested_name_specifier_1
457 %type <ttype> new_initializer new_placement
458 %type <ttype> using_decl
459 %type <ttype> typename_sub typename_sub0 typename_sub1 typename_sub2
460 %type <ttype> explicit_template_type
461 /* in order to recognize aggr tags as defining and thus shadowing. */
462 %token TYPENAME_DEFN IDENTIFIER_DEFN PTYPENAME_DEFN
463 %type <ttype> identifier_defn IDENTIFIER_DEFN TYPENAME_DEFN PTYPENAME_DEFN
464 %type <ttype> handler_args
465 %type <ttype> self_template_type finish_template_type_
470 /* Used in lex.c for parsing pragmas. */
473 /* lex.c and pt.c depend on this being the last token. Define
474 any new tokens before this one! */
475 %token END_OF_SAVED_INPUT
478 /* Tell yyparse how to print a token's value, if yydebug is set. */
479 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
480 extern void yyprint PARAMS ((FILE *, int, YYSTYPE));
486 { finish_translation_unit (); }
488 { finish_translation_unit (); }
491 /* the reason for the strange actions in this rule
492 is so that notype_initdecls when reached via datadef
493 can find a valid list of type and sc specs in $0. */
496 { $<ttype>$ = NULL_TREE; }
498 { $<ttype>$ = NULL_TREE; ggc_collect (); }
499 | extdefs lang_extdef
500 { $<ttype>$ = NULL_TREE; ggc_collect (); }
509 { have_extern_spec = true;
510 $<ttype>$ = NULL_TREE; }
513 { have_extern_spec = false; }
527 { if (pending_lang_change) do_pending_lang_change();
528 type_lookups = NULL_TREE; }
530 { if (! toplevel_bindings_p ())
535 fndef eat_saved_input
536 { do_pending_inlines (); }
538 { do_pending_inlines (); }
541 { warning ("keyword `export' not implemented, and will be ignored"); }
543 { do_pending_inlines (); }
545 { do_pending_inlines (); }
546 | asm_keyword '(' STRING ')' ';'
547 { assemble_asm ($3); }
548 | extern_lang_string '{' extdefs_opt '}'
549 { pop_lang_context (); }
550 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
551 { do_pending_inlines (); pop_lang_context (); }
552 | extern_lang_string .hush_warning datadef .warning_ok
553 { do_pending_inlines (); pop_lang_context (); }
554 | NAMESPACE identifier '{'
555 { push_namespace ($2); }
557 { pop_namespace (); }
559 { push_namespace (NULL_TREE); }
561 { pop_namespace (); }
564 { do_toplevel_using_decl ($1); }
571 NAMESPACE identifier '='
572 { begin_only_namespace_names (); }
575 end_only_namespace_names ();
578 do_namespace_alias ($2, $5);
585 | USING global_scope qualified_id
587 | USING global_scope unqualified_id
591 namespace_using_decl:
592 USING namespace_qualifier identifier
593 { $$ = build_nt (SCOPE_REF, $2, $3); }
594 | USING global_scope identifier
595 { $$ = build_nt (SCOPE_REF, global_namespace, $3); }
596 | USING global_scope namespace_qualifier identifier
597 { $$ = build_nt (SCOPE_REF, $3, $4); }
602 { begin_only_namespace_names (); }
605 end_only_namespace_names ();
606 /* If no declaration was found, the using-directive is
607 invalid. Since that was not reported, we need the
608 identifier for the error message. */
609 if (TREE_CODE ($4) == IDENTIFIER_NODE && lastiddecl)
611 do_using_directive ($4);
618 if (TREE_CODE ($$) == IDENTIFIER_NODE)
622 | namespace_qualifier NSNAME SCOPE
625 if (TREE_CODE ($$) == IDENTIFIER_NODE)
634 | global_scope qualified_id
636 | global_scope unqualified_id
642 { push_lang_context ($1); }
643 | extern_lang_string EXTERN_LANG_STRING
644 { if (current_lang_name != $2)
645 error ("use of linkage spec `%D' is different from previous spec `%D'", $2, current_lang_name);
646 pop_lang_context (); push_lang_context ($2); }
649 template_parm_header:
651 { begin_template_parm_list (); }
652 template_parm_list '>'
653 { $$ = end_template_parm_list ($4); }
656 template_spec_header:
658 { begin_specialization();
664 | template_spec_header
669 { $$ = process_template_parm (NULL_TREE, $1); }
670 | template_parm_list ',' template_parm
671 { $$ = process_template_parm ($1, $3); }
682 aggr maybe_identifier
683 { $$ = finish_template_type_parm ($1, $2); }
684 | TYPENAME_KEYWORD maybe_identifier
685 { $$ = finish_template_type_parm (class_type_node, $2); }
688 template_template_parm:
689 template_parm_header aggr maybe_identifier
690 { $$ = finish_template_template_parm ($2, $3); }
694 /* The following rules introduce a new reduce/reduce
695 conflict on the ',' and '>' input tokens: they are valid
696 prefixes for a `structsp', which means they could match a
697 nameless parameter. See 14.6, paragraph 3.
698 By putting them before the `parm' rule, we get
699 their match before considering them nameless parameter
702 { $$ = build_tree_list (NULL_TREE, $1); }
703 | template_type_parm '=' type_id
704 { $$ = build_tree_list (groktypename ($3.t), $1); }
706 { $$ = build_tree_list (NULL_TREE, $1.t); }
707 | parm '=' expr_no_comma_rangle
708 { $$ = build_tree_list ($3, $1.t); }
709 | template_template_parm
710 { $$ = build_tree_list (NULL_TREE, $1); }
711 | template_template_parm '=' template_arg
713 $3 = check_template_template_default_arg ($3);
714 $$ = build_tree_list ($3, $1);
719 template_header template_extdef
720 { finish_template_decl ($1); }
721 | template_header error %prec EMPTY
722 { finish_template_decl ($1); }
726 fndef eat_saved_input
727 { do_pending_inlines (); }
729 { do_pending_inlines (); }
731 { do_pending_inlines (); }
732 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
733 { do_pending_inlines ();
734 pop_lang_context (); }
735 | extern_lang_string .hush_warning template_datadef .warning_ok
736 { do_pending_inlines ();
737 pop_lang_context (); }
738 | extension template_extdef
744 | declmods notype_initdecls ';'
746 | typed_declspecs initdecls ';'
747 { note_list_got_semicolon ($1.t); }
750 if ($1.t != error_mark_node)
752 maybe_process_partial_specialization ($1.t);
753 note_got_semicolon ($1.t);
760 | declmods notype_initdecls ';'
762 | typed_declspecs initdecls ';'
763 { note_list_got_semicolon ($1.t); }
765 { pedwarn ("empty declaration"); }
766 | explicit_instantiation ';'
767 | typed_declspecs ';'
770 split_specs_attrs ($1.t, &t, &attrs);
772 note_list_got_semicolon ($1.t);
776 | error END_OF_SAVED_INPUT
782 ctor_initializer_opt:
798 /* The outermost block of a function really begins before the
799 mem-initializer-list, so we open one there and suppress the one that
800 actually corresponds to the curly braces. */
802 begin_function_body_ ctor_initializer_opt save_lineno '{'
803 { $<ttype>$ = begin_compound_stmt (/*has_no_scope=*/1); }
806 STMT_LINENO ($<ttype>5) = $3;
807 finish_compound_stmt (/*has_no_scope=*/1, $<ttype>5);
808 finish_function_body ($1);
813 fn.def1 maybe_return_init function_body
814 { expand_body (finish_function (0)); }
815 | fn.def1 maybe_return_init function_try_block
816 { expand_body (finish_function (0)); }
817 | fn.def1 maybe_return_init error
821 constructor_declarator:
822 nested_name_specifier SELFNAME '('
823 { $$ = begin_constructor_declarator ($1, $2); }
824 parmlist ')' cv_qualifiers exception_specification_opt
825 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
826 | nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
827 { $$ = begin_constructor_declarator ($1, $2);
828 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
830 | global_scope nested_name_specifier SELFNAME '('
831 { $$ = begin_constructor_declarator ($2, $3); }
832 parmlist ')' cv_qualifiers exception_specification_opt
833 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
834 | global_scope nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
835 { $$ = begin_constructor_declarator ($2, $3);
836 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
838 | nested_name_specifier self_template_type '('
839 { $$ = begin_constructor_declarator ($1, $2); }
840 parmlist ')' cv_qualifiers exception_specification_opt
841 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
842 | nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
843 { $$ = begin_constructor_declarator ($1, $2);
844 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
846 | global_scope nested_name_specifier self_template_type '('
847 { $$ = begin_constructor_declarator ($2, $3); }
848 parmlist ')' cv_qualifiers exception_specification_opt
849 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
850 | global_scope nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
851 { $$ = begin_constructor_declarator ($2, $3);
852 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
857 typed_declspecs declarator
858 { check_for_new_type ("return type", $1);
859 if (!parse_begin_function_definition ($1.t, $2))
861 | declmods notype_declarator
862 { if (!parse_begin_function_definition ($1.t, $2))
865 { if (!parse_begin_function_definition (NULL_TREE, $1))
867 | declmods constructor_declarator
868 { if (!parse_begin_function_definition ($1.t, $2))
870 | constructor_declarator
871 { if (!parse_begin_function_definition (NULL_TREE, $1))
875 /* ANSI allows optional parentheses around constructor class names.
876 See ISO/IEC 14882:1998(E) 12.1. */
878 component_constructor_declarator:
879 SELFNAME '(' parmlist ')' cv_qualifiers exception_specification_opt
880 { $$ = make_call_declarator ($1, $3, $5, $6); }
881 | '(' SELFNAME ')' '(' parmlist ')' cv_qualifiers
882 exception_specification_opt
883 { $$ = make_call_declarator ($2, $5, $7, $8); }
884 | SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
885 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
886 | '(' SELFNAME ')' LEFT_RIGHT cv_qualifiers exception_specification_opt
887 { $$ = make_call_declarator ($2, empty_parms (), $5, $6); }
888 | self_template_type '(' parmlist ')' cv_qualifiers exception_specification_opt
889 { $$ = make_call_declarator ($1, $3, $5, $6); }
890 | self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
891 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
894 /* more C++ complexity. See component_decl for a comment on the
895 reduce/reduce conflict introduced by these rules. */
897 declmods component_constructor_declarator
898 { $$ = parse_method ($2, $1.t, $1.lookups);
902 if (yychar == YYEMPTY)
905 | component_constructor_declarator
906 { $$ = parse_method ($1, NULL_TREE, NULL_TREE);
908 | typed_declspecs declarator
909 { $$ = parse_method ($2, $1.t, $1.lookups); goto rest_of_mdef;}
910 | declmods notype_declarator
911 { $$ = parse_method ($2, $1.t, $1.lookups); goto rest_of_mdef;}
913 { $$ = parse_method ($1, NULL_TREE, NULL_TREE);
915 | declmods constructor_declarator
916 { $$ = parse_method ($2, $1.t, $1.lookups); goto rest_of_mdef;}
917 | constructor_declarator
918 { $$ = parse_method ($1, NULL_TREE, NULL_TREE);
923 RETURN_KEYWORD IDENTIFIER
931 { finish_named_return_value ($<ttype>$, $2); }
932 | return_id '(' nonnull_exprlist ')'
933 { finish_named_return_value ($<ttype>$, $3); }
934 | return_id LEFT_RIGHT
935 { finish_named_return_value ($<ttype>$, NULL_TREE); }
939 ':' { begin_mem_initializers (); } member_init_list
941 if ($3.new_type_flag == 0)
942 error ("no base or member initializers given following ':'");
943 finish_mem_initializers ($3.t);
947 begin_function_body_:
950 $$ = begin_function_body ();
957 $$.new_type_flag = 0;
962 $$.new_type_flag = 1;
965 | member_init_list ',' member_init
969 $$.new_type_flag = 1;
970 TREE_CHAIN ($3) = $1.t;
976 | member_init_list error
980 '(' nonnull_exprlist ')'
982 if (current_class_name)
983 pedwarn ("anachronistic old style base class initializer");
984 $$ = expand_member_init (NULL_TREE, $2);
988 if (current_class_name)
989 pedwarn ("anachronistic old style base class initializer");
990 $$ = expand_member_init (NULL_TREE,
993 | notype_identifier '(' nonnull_exprlist ')'
994 { $$ = expand_member_init ($1, $3); }
995 | notype_identifier LEFT_RIGHT
996 { $$ = expand_member_init ($1, void_type_node); }
997 | nonnested_type '(' nonnull_exprlist ')'
998 { $$ = expand_member_init ($1, $3); }
999 | nonnested_type LEFT_RIGHT
1000 { $$ = expand_member_init ($1, void_type_node); }
1001 | typename_sub '(' nonnull_exprlist ')'
1002 { $$ = expand_member_init ($1, $3); }
1003 | typename_sub LEFT_RIGHT
1004 { $$ = expand_member_init ($1, void_type_node); }
1020 | NSNAME %prec EMPTY
1029 explicit_instantiation:
1030 TEMPLATE begin_explicit_instantiation typespec ';'
1031 { do_type_instantiation ($3.t, NULL_TREE, 1);
1032 yyungetc (';', 1); }
1033 end_explicit_instantiation
1034 | TEMPLATE begin_explicit_instantiation typed_declspecs declarator
1035 { tree specs = strip_attrs ($3.t);
1036 parse_decl_instantiation (specs, $4, NULL_TREE); }
1037 end_explicit_instantiation
1038 | TEMPLATE begin_explicit_instantiation notype_declarator
1039 { parse_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
1040 end_explicit_instantiation
1041 | TEMPLATE begin_explicit_instantiation constructor_declarator
1042 { parse_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
1043 end_explicit_instantiation
1044 | SCSPEC TEMPLATE begin_explicit_instantiation typespec ';'
1045 { do_type_instantiation ($4.t, $1, 1);
1046 yyungetc (';', 1); }
1047 end_explicit_instantiation
1049 | SCSPEC TEMPLATE begin_explicit_instantiation typed_declspecs
1051 { tree specs = strip_attrs ($4.t);
1052 parse_decl_instantiation (specs, $5, $1); }
1053 end_explicit_instantiation
1055 | SCSPEC TEMPLATE begin_explicit_instantiation notype_declarator
1056 { parse_decl_instantiation (NULL_TREE, $4, $1); }
1057 end_explicit_instantiation
1059 | SCSPEC TEMPLATE begin_explicit_instantiation constructor_declarator
1060 { parse_decl_instantiation (NULL_TREE, $4, $1); }
1061 end_explicit_instantiation
1065 begin_explicit_instantiation:
1066 { begin_explicit_instantiation(); }
1069 end_explicit_instantiation:
1070 { end_explicit_instantiation(); }
1073 /* The TYPENAME expansions are to deal with use of a template class name as
1074 a template within the class itself, where the template decl is hidden by
1075 a type decl. Got all that? */
1078 PTYPENAME '<' template_arg_list_opt template_close_bracket
1079 finish_template_type_
1081 | tTYPENAME '<' template_arg_list_opt template_close_bracket
1082 finish_template_type_
1084 | self_template_type
1087 apparent_template_type:
1089 | identifier '<' template_arg_list_opt '>'
1090 finish_template_type_
1095 SELFNAME '<' template_arg_list_opt template_close_bracket
1096 finish_template_type_
1100 finish_template_type_:
1102 if (yychar == YYEMPTY)
1105 $$ = finish_template_type ($<ttype>-3, $<ttype>-1,
1110 template_close_bracket:
1114 /* Handle `Class<Class<Type>>' without space in the `>>' */
1115 pedwarn ("`>>' should be `> >' in template class name");
1120 template_arg_list_opt:
1128 { $$ = build_tree_list (NULL_TREE, $$); }
1129 | template_arg_list ',' template_arg
1130 { $$ = chainon ($$, build_tree_list (NULL_TREE, $3)); }
1135 { $$ = groktypename ($1.t); }
1139 if (DECL_TEMPLATE_TEMPLATE_PARM_P ($$))
1140 $$ = TREE_TYPE ($$);
1142 | global_scope PTYPENAME
1145 if (DECL_TEMPLATE_TEMPLATE_PARM_P ($$))
1146 $$ = TREE_TYPE ($$);
1148 | expr_no_comma_rangle
1149 | nested_name_specifier TEMPLATE identifier
1151 if (!processing_template_decl)
1153 error ("use of template qualifier outside template");
1154 $$ = error_mark_node;
1157 $$ = make_unbound_class_template ($1, $3, tf_error | tf_parsing);
1163 { $$ = NEGATE_EXPR; }
1165 { $$ = CONVERT_EXPR; }
1167 { $$ = PREINCREMENT_EXPR; }
1169 { $$ = PREDECREMENT_EXPR; }
1171 { $$ = TRUTH_NOT_EXPR; }
1176 { $$ = build_x_compound_expr ($$); }
1182 { error ("ISO C++ forbids an empty condition for `%s'",
1184 $$ = integer_zero_node; }
1191 { error ("ISO C++ forbids an empty condition for `%s'",
1193 $$ = integer_zero_node; }
1207 type_specifier_seq declarator maybeasm maybe_attribute '='
1210 for (d = getdecls (); d; d = TREE_CHAIN (d))
1211 if (TREE_CODE (d) == TYPE_DECL) {
1212 tree s = TREE_TYPE (d);
1213 if (TREE_CODE (s) == RECORD_TYPE)
1214 error ("definition of class `%T' in condition", s);
1215 else if (TREE_CODE (s) == ENUMERAL_TYPE)
1216 error ("definition of enum `%T' in condition", s);
1219 current_declspecs = $1.t;
1220 $<ttype>$ = parse_decl ($<ttype>2, $4, 1);
1224 parse_end_decl ($<ttype>6, $7, $4);
1225 $$ = convert_from_reference ($<ttype>6);
1226 if (TREE_CODE (TREE_TYPE ($$)) == ARRAY_TYPE)
1227 error ("definition of array `%#D' in condition", $$);
1234 | maybe_label_decls stmts '}'
1235 | maybe_label_decls stmts error '}'
1236 | maybe_label_decls error '}'
1239 nontrivial_exprlist:
1240 expr_no_commas ',' expr_no_commas
1241 { $$ = tree_cons (NULL_TREE, $$,
1242 build_tree_list (NULL_TREE, $3)); }
1243 | expr_no_commas ',' error
1244 { $$ = tree_cons (NULL_TREE, $$,
1245 build_tree_list (NULL_TREE, error_mark_node)); }
1246 | nontrivial_exprlist ',' expr_no_commas
1247 { chainon ($$, build_tree_list (NULL_TREE, $3)); }
1248 | nontrivial_exprlist ',' error
1249 { chainon ($$, build_tree_list (NULL_TREE, error_mark_node)); }
1254 { $$ = build_tree_list (NULL_TREE, $$); }
1255 | nontrivial_exprlist
1261 /* __extension__ turns off -pedantic for following primary. */
1262 | extension cast_expr %prec UNARY
1265 | '*' cast_expr %prec UNARY
1266 { $$ = build_x_indirect_ref ($2, "unary *"); }
1267 | '&' cast_expr %prec UNARY
1268 { $$ = build_x_unary_op (ADDR_EXPR, $2); }
1270 { $$ = build_x_unary_op (BIT_NOT_EXPR, $2); }
1271 | unop cast_expr %prec UNARY
1272 { $$ = finish_unary_op_expr ($1, $2); }
1273 /* Refer to the address of a label as a pointer. */
1275 { $$ = finish_label_address_expr ($2); }
1276 | sizeof unary_expr %prec UNARY
1277 { $$ = finish_sizeof ($2);
1278 skip_evaluation--; }
1279 | sizeof '(' type_id ')' %prec HYPERUNARY
1280 { $$ = finish_sizeof (groktypename ($3.t));
1281 check_for_new_type ("sizeof", $3);
1282 skip_evaluation--; }
1283 | alignof unary_expr %prec UNARY
1284 { $$ = finish_alignof ($2);
1285 skip_evaluation--; }
1286 | alignof '(' type_id ')' %prec HYPERUNARY
1287 { $$ = finish_alignof (groktypename ($3.t));
1288 check_for_new_type ("alignof", $3);
1289 skip_evaluation--; }
1291 /* The %prec EMPTY's here are required by the = init initializer
1292 syntax extension; see below. */
1293 | new new_type_id %prec EMPTY
1294 { $$ = build_new (NULL_TREE, $2.t, NULL_TREE, $1);
1295 check_for_new_type ("new", $2); }
1296 | new new_type_id new_initializer
1297 { $$ = build_new (NULL_TREE, $2.t, $3, $1);
1298 check_for_new_type ("new", $2); }
1299 | new new_placement new_type_id %prec EMPTY
1300 { $$ = build_new ($2, $3.t, NULL_TREE, $1);
1301 check_for_new_type ("new", $3); }
1302 | new new_placement new_type_id new_initializer
1303 { $$ = build_new ($2, $3.t, $4, $1);
1304 check_for_new_type ("new", $3); }
1305 | new '(' type_id ')'
1307 { $$ = build_new (NULL_TREE, groktypename($3.t),
1309 check_for_new_type ("new", $3); }
1310 | new '(' type_id ')' new_initializer
1311 { $$ = build_new (NULL_TREE, groktypename($3.t), $5, $1);
1312 check_for_new_type ("new", $3); }
1313 | new new_placement '(' type_id ')' %prec EMPTY
1314 { $$ = build_new ($2, groktypename($4.t), NULL_TREE, $1);
1315 check_for_new_type ("new", $4); }
1316 | new new_placement '(' type_id ')' new_initializer
1317 { $$ = build_new ($2, groktypename($4.t), $6, $1);
1318 check_for_new_type ("new", $4); }
1320 | delete cast_expr %prec UNARY
1321 { $$ = delete_sanity ($2, NULL_TREE, 0, $1); }
1322 | delete '[' ']' cast_expr %prec UNARY
1323 { $$ = delete_sanity ($4, NULL_TREE, 1, $1);
1324 if (yychar == YYEMPTY)
1326 | delete '[' expr ']' cast_expr %prec UNARY
1327 { $$ = delete_sanity ($5, $3, 2, $1);
1328 if (yychar == YYEMPTY)
1330 | REALPART cast_expr %prec UNARY
1331 { $$ = build_x_unary_op (REALPART_EXPR, $2); }
1332 | IMAGPART cast_expr %prec UNARY
1333 { $$ = build_x_unary_op (IMAGPART_EXPR, $2); }
1337 '(' nonnull_exprlist ')'
1339 | '{' nonnull_exprlist '}'
1340 { pedwarn ("old style placement syntax, use () instead");
1345 '(' nonnull_exprlist ')'
1348 { $$ = void_zero_node; }
1351 error ("`%T' is not a valid expression", $2.t);
1352 $$ = error_mark_node;
1356 /* This was previously allowed as an extension, but
1357 was removed in G++ 3.3. */
1358 error ("initialization of new expression with `='");
1359 $$ = error_mark_node;
1363 /* This is necessary to postpone reduction of `int ((int)(int)(int))'. */
1365 '(' type_id ')' %prec EMPTY
1366 { $2.t = finish_parmlist (build_tree_list (NULL_TREE, $2.t), 0);
1367 $$ = make_call_declarator (NULL_TREE, $2.t, NULL_TREE, NULL_TREE);
1368 check_for_new_type ("cast", $2); }
1369 | regcast_or_absdcl '(' type_id ')' %prec EMPTY
1370 { $3.t = finish_parmlist (build_tree_list (NULL_TREE, $3.t), 0);
1371 $$ = make_call_declarator ($$, $3.t, NULL_TREE, NULL_TREE);
1372 check_for_new_type ("cast", $3); }
1377 | regcast_or_absdcl unary_expr %prec UNARY
1378 { $$ = reparse_absdcl_as_casts ($$, $2); }
1379 | regcast_or_absdcl '{' initlist maybecomma '}' %prec UNARY
1381 tree init = build_nt (CONSTRUCTOR, NULL_TREE,
1384 pedwarn ("ISO C++ forbids compound literals");
1385 /* Indicate that this was a C99 compound literal. */
1386 TREE_HAS_CONSTRUCTOR (init) = 1;
1388 $$ = reparse_absdcl_as_casts ($$, init);
1394 /* Handle general members. */
1395 | expr_no_commas POINTSAT_STAR expr_no_commas
1396 { $$ = build_x_binary_op (MEMBER_REF, $$, $3); }
1397 | expr_no_commas DOT_STAR expr_no_commas
1398 { $$ = build_m_component_ref ($$, $3); }
1399 | expr_no_commas '+' expr_no_commas
1400 { $$ = build_x_binary_op ($2, $$, $3); }
1401 | expr_no_commas '-' expr_no_commas
1402 { $$ = build_x_binary_op ($2, $$, $3); }
1403 | expr_no_commas '*' expr_no_commas
1404 { $$ = build_x_binary_op ($2, $$, $3); }
1405 | expr_no_commas '/' expr_no_commas
1406 { $$ = build_x_binary_op ($2, $$, $3); }
1407 | expr_no_commas '%' expr_no_commas
1408 { $$ = build_x_binary_op ($2, $$, $3); }
1409 | expr_no_commas LSHIFT expr_no_commas
1410 { $$ = build_x_binary_op ($2, $$, $3); }
1411 | expr_no_commas RSHIFT expr_no_commas
1412 { $$ = build_x_binary_op ($2, $$, $3); }
1413 | expr_no_commas ARITHCOMPARE expr_no_commas
1414 { $$ = build_x_binary_op ($2, $$, $3); }
1415 | expr_no_commas '<' expr_no_commas
1416 { $$ = build_x_binary_op (LT_EXPR, $$, $3); }
1417 | expr_no_commas '>' expr_no_commas
1418 { $$ = build_x_binary_op (GT_EXPR, $$, $3); }
1419 | expr_no_commas EQCOMPARE expr_no_commas
1420 { $$ = build_x_binary_op ($2, $$, $3); }
1421 | expr_no_commas MIN_MAX expr_no_commas
1422 { $$ = build_x_binary_op ($2, $$, $3); }
1423 | expr_no_commas '&' expr_no_commas
1424 { $$ = build_x_binary_op ($2, $$, $3); }
1425 | expr_no_commas '|' expr_no_commas
1426 { $$ = build_x_binary_op ($2, $$, $3); }
1427 | expr_no_commas '^' expr_no_commas
1428 { $$ = build_x_binary_op ($2, $$, $3); }
1429 | expr_no_commas ANDAND expr_no_commas
1430 { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $$, $3); }
1431 | expr_no_commas OROR expr_no_commas
1432 { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $$, $3); }
1433 | expr_no_commas '?' xexpr ':' expr_no_commas
1434 { $$ = build_x_conditional_expr ($$, $3, $5); }
1435 | expr_no_commas '=' expr_no_commas
1436 { $$ = build_x_modify_expr ($$, NOP_EXPR, $3);
1437 if ($$ != error_mark_node)
1438 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
1439 | expr_no_commas ASSIGN expr_no_commas
1440 { $$ = build_x_modify_expr ($$, $2, $3); }
1442 { $$ = build_throw (NULL_TREE); }
1443 | THROW expr_no_commas
1444 { $$ = build_throw ($2); }
1447 expr_no_comma_rangle:
1449 /* Handle general members. */
1450 | expr_no_comma_rangle POINTSAT_STAR expr_no_comma_rangle
1451 { $$ = build_x_binary_op (MEMBER_REF, $$, $3); }
1452 | expr_no_comma_rangle DOT_STAR expr_no_comma_rangle
1453 { $$ = build_m_component_ref ($$, $3); }
1454 | expr_no_comma_rangle '+' expr_no_comma_rangle
1455 { $$ = build_x_binary_op ($2, $$, $3); }
1456 | expr_no_comma_rangle '-' expr_no_comma_rangle
1457 { $$ = build_x_binary_op ($2, $$, $3); }
1458 | expr_no_comma_rangle '*' expr_no_comma_rangle
1459 { $$ = build_x_binary_op ($2, $$, $3); }
1460 | expr_no_comma_rangle '/' expr_no_comma_rangle
1461 { $$ = build_x_binary_op ($2, $$, $3); }
1462 | expr_no_comma_rangle '%' expr_no_comma_rangle
1463 { $$ = build_x_binary_op ($2, $$, $3); }
1464 | expr_no_comma_rangle LSHIFT expr_no_comma_rangle
1465 { $$ = build_x_binary_op ($2, $$, $3); }
1466 | expr_no_comma_rangle RSHIFT expr_no_comma_rangle
1467 { $$ = build_x_binary_op ($2, $$, $3); }
1468 | expr_no_comma_rangle ARITHCOMPARE 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 (LT_EXPR, $$, $3); }
1472 | expr_no_comma_rangle EQCOMPARE expr_no_comma_rangle
1473 { $$ = build_x_binary_op ($2, $$, $3); }
1474 | expr_no_comma_rangle MIN_MAX expr_no_comma_rangle
1475 { $$ = build_x_binary_op ($2, $$, $3); }
1476 | expr_no_comma_rangle '&' expr_no_comma_rangle
1477 { $$ = build_x_binary_op ($2, $$, $3); }
1478 | expr_no_comma_rangle '|' 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 ($2, $$, $3); }
1482 | expr_no_comma_rangle ANDAND expr_no_comma_rangle
1483 { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $$, $3); }
1484 | expr_no_comma_rangle OROR expr_no_comma_rangle
1485 { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $$, $3); }
1486 | expr_no_comma_rangle '?' xexpr ':' expr_no_comma_rangle
1487 { $$ = build_x_conditional_expr ($$, $3, $5); }
1488 | expr_no_comma_rangle '=' expr_no_comma_rangle
1489 { $$ = build_x_modify_expr ($$, NOP_EXPR, $3);
1490 if ($$ != error_mark_node)
1491 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
1492 | expr_no_comma_rangle ASSIGN expr_no_comma_rangle
1493 { $$ = build_x_modify_expr ($$, $2, $3); }
1495 { $$ = build_throw (NULL_TREE); }
1496 | THROW expr_no_comma_rangle
1497 { $$ = build_throw ($2); }
1500 notype_unqualified_id:
1501 '~' see_typename identifier
1502 { $$ = build_nt (BIT_NOT_EXPR, $3); }
1503 | '~' see_typename template_type
1504 { $$ = build_nt (BIT_NOT_EXPR, $3); }
1509 | NSNAME %prec EMPTY
1514 /* If lastiddecl is a BASELINK we're in an
1515 expression like S::f<int>, so don't
1516 do_identifier; we only do that for unqualified
1518 if (!lastiddecl || !BASELINK_P (lastiddecl))
1519 $$ = do_identifier ($<ttype>-1, 3, NULL_TREE);
1526 PFUNCNAME '<' do_id template_arg_list_opt template_close_bracket
1528 tree template_name = $3;
1529 if (TREE_CODE (template_name) == COMPONENT_REF)
1530 template_name = TREE_OPERAND (template_name, 1);
1531 $$ = lookup_template_function (template_name, $4);
1533 | operator_name '<' do_id template_arg_list_opt template_close_bracket
1535 tree template_name = $3;
1536 if (TREE_CODE (template_name) == COMPONENT_REF)
1537 template_name = TREE_OPERAND (template_name, 1);
1538 $$ = lookup_template_function (template_name, $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 { $$ = parse_finish_call_expr ($1, $3, 1); }
1641 | notype_unqualified_id LEFT_RIGHT
1642 { $$ = parse_finish_call_expr ($1, NULL_TREE, 1); }
1643 | primary '(' nonnull_exprlist ')'
1644 { $$ = parse_finish_call_expr ($1, $3, 0); }
1645 | primary LEFT_RIGHT
1646 { $$ = parse_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 { $$ = parse_finish_call_expr ($1, $3, 0); }
1709 | overqualified_id LEFT_RIGHT
1710 { $$ = parse_finish_call_expr ($1, NULL_TREE, 0); }
1711 | object object_template_id %prec UNARY
1712 { $$ = finish_class_member_access_expr ($$, $2); }
1713 | object object_template_id '(' nonnull_exprlist ')'
1714 { $$ = finish_object_call_expr ($2, $1, $4); }
1715 | object object_template_id LEFT_RIGHT
1716 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1717 | object unqualified_id %prec UNARY
1718 { $$ = finish_class_member_access_expr ($$, $2); }
1719 | object overqualified_id %prec UNARY
1720 { $$ = finish_class_member_access_expr ($1, $2); }
1721 | object unqualified_id '(' nonnull_exprlist ')'
1722 { $$ = finish_object_call_expr ($2, $1, $4); }
1723 | object unqualified_id LEFT_RIGHT
1724 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1725 | object overqualified_id '(' nonnull_exprlist ')'
1726 { $$ = finish_qualified_object_call_expr ($2, $1, $4); }
1727 | object overqualified_id LEFT_RIGHT
1728 { $$ = finish_qualified_object_call_expr ($2, $1, NULL_TREE); }
1729 /* p->int::~int() is valid -- 12.4 */
1730 | object '~' TYPESPEC LEFT_RIGHT
1731 { $$ = finish_pseudo_destructor_call_expr ($1, NULL_TREE, $3); }
1732 | object TYPESPEC SCOPE '~' TYPESPEC LEFT_RIGHT
1733 { $$ = finish_pseudo_destructor_call_expr ($1, $2, $5); }
1736 $$ = error_mark_node;
1740 /* Not needed for now.
1746 { $$ = error_mark_node; }
1748 { if (current_function_decl == 0)
1750 error ("braced-group within expression allowed only inside a function");
1753 $<ttype>$ = expand_start_stmt_expr (); }
1754 compstmt_or_stmtexpr ')'
1756 pedwarn ("ISO C++ forbids braced-groups within expressions");
1757 $$ = expand_end_stmt_expr ($<ttype>2); }
1758 | primary_no_id '(' nonnull_exprlist ')'
1759 { $$ = build_x_function_call ($$, $3, current_class_ref); }
1760 | primary_no_id LEFT_RIGHT
1761 { $$ = build_x_function_call ($$, NULL_TREE, current_class_ref); }
1762 | primary_no_id '[' expr ']'
1764 | primary_no_id PLUSPLUS
1765 { $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); }
1766 | primary_no_id MINUSMINUS
1767 { $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); }
1769 { goto do_scoped_id; }
1770 | SCOPE operator_name
1771 { if (TREE_CODE ($2) == IDENTIFIER_NODE)
1773 goto do_scoped_operator;
1782 { got_scope = NULL_TREE; $$ = 1; }
1788 | global_scope delete
1789 { got_scope = NULL_TREE; $$ = 1; }
1794 { $$ = boolean_true_node; }
1796 { $$ = boolean_false_node; }
1802 if (DECL_CONSTRUCTOR_P (current_function_decl))
1803 finish_mem_initializers (NULL_TREE);
1809 { got_object = TREE_TYPE ($$); }
1812 $$ = build_x_arrow ($$);
1813 got_object = TREE_TYPE ($$);
1818 typespec initdecls ';'
1820 if ($1.t && IS_AGGR_TYPE_CODE (TREE_CODE ($1.t)))
1821 note_got_semicolon ($1.t);
1823 | typed_declspecs initdecls ';'
1825 note_list_got_semicolon ($1.t);
1827 | declmods notype_initdecls ';'
1829 | typed_declspecs ';'
1832 note_list_got_semicolon ($1.t);
1835 { warning ("empty declaration"); }
1840 /* Any kind of declarator (thus, all declarators allowed
1841 after an explicit typespec). */
1844 after_type_declarator %prec EMPTY
1845 | notype_declarator %prec EMPTY
1848 /* This is necessary to postpone reduction of `int()()()()'. */
1850 LEFT_RIGHT %prec EMPTY
1851 { $$ = make_call_declarator (NULL_TREE, empty_parms (),
1852 NULL_TREE, NULL_TREE); }
1853 | fcast_or_absdcl LEFT_RIGHT %prec EMPTY
1854 { $$ = make_call_declarator ($$, empty_parms (), NULL_TREE,
1858 /* ISO type-id (8.1) */
1860 typed_typespecs absdcl
1861 { $$.t = build_tree_list ($1.t, $2);
1862 $$.new_type_flag = $1.new_type_flag; }
1863 | nonempty_cv_qualifiers absdcl
1864 { $$.t = build_tree_list ($1.t, $2);
1865 $$.new_type_flag = $1.new_type_flag; }
1867 { $$.t = build_tree_list (build_tree_list (NULL_TREE, $1.t),
1869 $$.new_type_flag = $1.new_type_flag; }
1870 | typed_typespecs %prec EMPTY
1871 { $$.t = build_tree_list ($1.t, NULL_TREE);
1872 $$.new_type_flag = $1.new_type_flag; }
1873 | nonempty_cv_qualifiers %prec EMPTY
1874 { $$.t = build_tree_list ($1.t, NULL_TREE);
1875 $$.new_type_flag = $1.new_type_flag; }
1878 /* Declspecs which contain at least one type specifier or typedef name.
1879 (Just `const' or `volatile' is not enough.)
1880 A typedef'd name following these is taken as a name to be declared.
1881 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1884 typed_typespecs %prec EMPTY
1885 { $$.lookups = type_lookups; }
1887 { $$.lookups = type_lookups; }
1892 { $$.t = tree_cons (NULL_TREE, $2.t, $1.t);
1893 $$.new_type_flag = $2.new_type_flag; }
1894 | typespec reserved_declspecs %prec HYPERUNARY
1895 { $$.t = tree_cons (NULL_TREE, $1.t, $2);
1896 $$.new_type_flag = $1.new_type_flag; }
1897 | typespec reserved_typespecquals reserved_declspecs
1898 { $$.t = tree_cons (NULL_TREE, $1.t, chainon ($2, $3));
1899 $$.new_type_flag = $1.new_type_flag; }
1900 | declmods typespec reserved_declspecs
1901 { $$.t = tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1902 $$.new_type_flag = $2.new_type_flag; }
1903 | declmods typespec reserved_typespecquals
1904 { $$.t = tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1905 $$.new_type_flag = $2.new_type_flag; }
1906 | declmods typespec reserved_typespecquals reserved_declspecs
1907 { $$.t = tree_cons (NULL_TREE, $2.t,
1908 chainon ($3, chainon ($4, $1.t)));
1909 $$.new_type_flag = $2.new_type_flag; }
1914 { if (extra_warnings)
1915 warning ("`%s' is not at beginning of declaration",
1916 IDENTIFIER_POINTER ($$));
1917 $$ = build_tree_list (NULL_TREE, $$); }
1918 | reserved_declspecs typespecqual_reserved
1919 { $$ = tree_cons (NULL_TREE, $2.t, $$); }
1920 | reserved_declspecs SCSPEC
1921 { if (extra_warnings)
1922 warning ("`%s' is not at beginning of declaration",
1923 IDENTIFIER_POINTER ($2));
1924 $$ = tree_cons (NULL_TREE, $2, $$); }
1927 /* List of just storage classes and type modifiers.
1928 A declaration can start with just this, but then it cannot be used
1929 to redeclare a typedef-name.
1930 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1932 /* We use hash_tree_cons for lists of typeless declspecs so that they end
1933 up on a persistent obstack. Otherwise, they could appear at the
1934 beginning of something like
1936 static const struct { int foo () { } } b;
1938 and would be discarded after we finish compiling foo. We don't need to
1939 worry once we see a type. */
1942 nonempty_cv_qualifiers %prec EMPTY
1943 { $$.lookups = NULL_TREE; TREE_STATIC ($$.t) = 1; }
1946 $$.t = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
1947 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
1949 | declmods CV_QUALIFIER
1951 $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
1952 TREE_STATIC ($$.t) = 1;
1956 if (extra_warnings && TREE_STATIC ($$.t))
1957 warning ("`%s' is not at beginning of declaration",
1958 IDENTIFIER_POINTER ($2));
1959 $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
1960 TREE_STATIC ($$.t) = TREE_STATIC ($1.t);
1962 | declmods attributes
1963 { $$.t = hash_tree_cons ($2, NULL_TREE, $1.t); }
1966 /* Used instead of declspecs where storage classes are not allowed
1967 (that is, for typenames and structure components).
1969 C++ can takes storage classes for structure components.
1970 Don't accept a typedef-name if anything but a modifier precedes it. */
1973 typespec %prec EMPTY
1974 { $$.t = build_tree_list (NULL_TREE, $1.t);
1975 $$.new_type_flag = $1.new_type_flag; }
1976 | nonempty_cv_qualifiers typespec
1977 { $$.t = tree_cons (NULL_TREE, $2.t, $1.t);
1978 $$.new_type_flag = $2.new_type_flag; }
1979 | typespec reserved_typespecquals
1980 { $$.t = tree_cons (NULL_TREE, $1.t, $2);
1981 $$.new_type_flag = $1.new_type_flag; }
1982 | nonempty_cv_qualifiers typespec reserved_typespecquals
1983 { $$.t = tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1984 $$.new_type_flag = $2.new_type_flag; }
1987 reserved_typespecquals:
1988 typespecqual_reserved
1989 { $$ = build_tree_list (NULL_TREE, $1.t); }
1990 | reserved_typespecquals typespecqual_reserved
1991 { $$ = tree_cons (NULL_TREE, $2.t, $1); }
1992 | reserved_typespecquals attributes
1993 { $$ = tree_cons ($2, NULL_TREE, $1); }
1994 | attributes %prec EMPTY
1995 { $$ = tree_cons ($1, NULL_TREE, NULL_TREE); }
1999 SIZEOF { skip_evaluation++; }
2003 ALIGNOF { skip_evaluation++; }
2007 TYPEOF { skip_evaluation++; }
2010 /* A typespec (but not a type qualifier).
2011 Once we have seen one of these in a declaration,
2012 if a typedef name appears then it is being redeclared. */
2016 { $$.lookups = NULL_TREE; }
2017 | TYPESPEC %prec EMPTY
2018 { $$.t = $1; $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
2019 | complete_type_name
2020 { $$.t = $1; $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
2021 | typeof '(' expr ')'
2022 { $$.t = finish_typeof ($3);
2023 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
2024 skip_evaluation--; }
2025 | typeof '(' type_id ')'
2026 { $$.t = groktypename ($3.t);
2027 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
2028 skip_evaluation--; }
2029 | SIGOF '(' expr ')'
2030 { tree type = TREE_TYPE ($3);
2032 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
2033 if (IS_AGGR_TYPE (type))
2035 sorry ("sigof type specifier");
2040 error ("`sigof' applied to non-aggregate expression");
2041 $$.t = error_mark_node;
2044 | SIGOF '(' type_id ')'
2045 { tree type = groktypename ($3.t);
2047 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
2048 if (IS_AGGR_TYPE (type))
2050 sorry ("sigof type specifier");
2055 error("`sigof' applied to non-aggregate type");
2056 $$.t = error_mark_node;
2061 /* A typespec that is a reserved word, or a type qualifier. */
2063 typespecqual_reserved:
2065 { $$.t = $1; $$.new_type_flag = 0; }
2067 { $$.t = $1; $$.new_type_flag = 0; }
2073 | initdecls ',' initdcl
2074 { check_multiple_declarators (); }
2079 | notype_initdecls ',' initdcl
2080 { check_multiple_declarators (); }
2085 | nomods_initdecls ',' initdcl
2086 { check_multiple_declarators (); }
2092 | asm_keyword '(' STRING ')'
2097 declarator maybeasm maybe_attribute '='
2098 { $<ttype>$ = parse_decl ($<ttype>1, $3, 1); }
2100 /* Note how the declaration of the variable is in effect while its init is parsed! */
2101 { parse_end_decl ($<ttype>5, $6, $2); }
2102 | declarator maybeasm maybe_attribute
2104 $<ttype>$ = parse_decl ($<ttype>1, $3, 0);
2105 parse_end_decl ($<ttype>$, NULL_TREE, $2);
2109 /* This rule assumes a certain configuration of the parser stack.
2110 In particular, $0, the element directly before the beginning of
2111 this rule on the stack, must be a maybeasm. $-1 must be a
2112 declarator or notype_declarator. And $-2 must be some declmods
2113 or declspecs. We can't move the maybeasm into this rule because
2114 we need that reduce so we prefer fn.def1 when appropriate. */
2117 { $<ttype>$ = parse_decl0 ($<ttype>-1, $<ftype>-2.t,
2118 $<ftype>-2.lookups, $1, 1); }
2119 /* Note how the declaration of the variable is in effect
2120 while its init is parsed! */
2122 { parse_end_decl ($<ttype>3, $4, $<ttype>0); }
2124 { tree d = parse_decl0 ($<ttype>-1, $<ftype>-2.t,
2125 $<ftype>-2.lookups, $1, 0);
2126 parse_end_decl (d, NULL_TREE, $<ttype>0); }
2130 declarator maybeasm initdcl0_innards
2135 notype_declarator maybeasm initdcl0_innards
2140 notype_declarator maybeasm
2141 { /* Set things up as initdcl0_innards expects. */
2144 $<ftype>1.t = NULL_TREE;
2145 $<ftype>1.lookups = NULL_TREE; }
2148 | constructor_declarator maybeasm maybe_attribute
2149 { tree d = parse_decl0 ($1, NULL_TREE, NULL_TREE, $3, 0);
2150 parse_end_decl (d, NULL_TREE, $2); }
2153 /* the * rules are dummies to accept the Apollo extended syntax
2154 so that the header files compile. */
2165 | attributes attribute
2166 { $$ = chainon ($1, $2); }
2170 ATTRIBUTE '(' '(' attribute_list ')' ')'
2177 | attribute_list ',' attrib
2178 { $$ = chainon ($1, $3); }
2185 { $$ = build_tree_list ($1, NULL_TREE); }
2186 | any_word '(' IDENTIFIER ')'
2187 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
2188 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
2189 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
2190 | any_word '(' nonnull_exprlist ')'
2191 { $$ = build_tree_list ($1, $3); }
2194 /* This still leaves out most reserved keywords,
2195 shouldn't we include them? */
2204 /* A nonempty list of identifiers, including typenames. */
2205 identifiers_or_typenames:
2207 { $$ = build_tree_list (NULL_TREE, $1); }
2208 | identifiers_or_typenames ',' identifier
2209 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2213 /* empty */ %prec EMPTY
2219 /* If we are processing a template, we don't want to expand this
2223 expr_no_commas %prec '='
2225 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, NULL_TREE);
2226 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2228 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2229 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2230 | '{' initlist ',' '}'
2231 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2232 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2237 /* This chain is built in reverse order,
2238 and put in forward order where initlist is used. */
2241 { $$ = build_tree_list (NULL_TREE, $$); }
2243 { $$ = tree_cons (NULL_TREE, $3, $$); }
2244 /* These are for labeled elements. */
2245 | '[' expr_no_commas ']' init
2246 { $$ = build_tree_list ($2, $4); }
2247 | identifier ':' init
2248 { $$ = build_tree_list ($$, $3); }
2249 | initlist ',' identifier ':' init
2250 { $$ = tree_cons ($3, $5, $$); }
2254 PRE_PARSED_FUNCTION_DECL maybe_return_init function_body
2256 expand_body (finish_function (2));
2257 process_next_inline ($1);
2259 | PRE_PARSED_FUNCTION_DECL maybe_return_init function_try_block
2261 expand_body (finish_function (2));
2262 process_next_inline ($1);
2264 | PRE_PARSED_FUNCTION_DECL maybe_return_init error
2266 finish_function (2);
2267 process_next_inline ($1); }
2272 | pending_inlines pending_inline eat_saved_input
2275 /* A regurgitated default argument. The value of DEFARG_MARKER will be
2276 the TREE_LIST node for the parameter in question. */
2278 DEFARG_MARKER expr_no_commas END_OF_SAVED_INPUT
2279 { replace_defarg ($1, $2); }
2280 | DEFARG_MARKER error END_OF_SAVED_INPUT
2281 { replace_defarg ($1, error_mark_node); }
2285 /* empty */ %prec EMPTY
2286 | pending_defargs defarg_again
2287 { do_pending_defargs (); }
2288 | pending_defargs error
2289 { do_pending_defargs (); }
2294 { $<ttype>$ = current_enum_type;
2295 current_enum_type = start_enum ($2); }
2297 { $$.t = current_enum_type;
2298 finish_enum (current_enum_type);
2299 $$.new_type_flag = 1;
2300 current_enum_type = $<ttype>4;
2301 check_for_missing_semicolon ($$.t); }
2303 { $<ttype>$ = current_enum_type;
2304 current_enum_type = start_enum (make_anon_name ()); }
2306 { $$.t = current_enum_type;
2307 finish_enum (current_enum_type);
2308 $$.new_type_flag = 1;
2309 current_enum_type = $<ttype>3;
2310 check_for_missing_semicolon ($$.t); }
2312 { $$.t = parse_xref_tag (enum_type_node, $2, 1);
2313 $$.new_type_flag = 0; }
2314 | ENUM complex_type_name
2315 { $$.t = parse_xref_tag (enum_type_node, $2, 1);
2316 $$.new_type_flag = 0; }
2317 | TYPENAME_KEYWORD typename_sub
2319 $$.new_type_flag = 0;
2320 if (!processing_template_decl)
2321 pedwarn ("using `typename' outside of template"); }
2322 /* C++ extensions, merged with C to avoid shift/reduce conflicts */
2323 | class_head_defn maybe_base_class_list '{'
2325 if ($2 && $1.t != error_mark_node)
2327 tree type = TREE_TYPE ($1.t);
2329 if (TREE_CODE (type) == TYPENAME_TYPE)
2330 /* In a definition of a member class template,
2331 we will get here with an implicit typename,
2332 a TYPENAME_TYPE with a type. */
2333 type = TREE_TYPE (type);
2334 maybe_process_partial_specialization (type);
2335 xref_basetypes (type, $2);
2337 $1.t = begin_class_definition (TREE_TYPE ($1.t));
2338 check_class_key (current_aggr, $1.t);
2339 current_aggr = NULL_TREE; }
2340 opt.component_decl_list '}' maybe_attribute
2345 if (yychar == YYEMPTY)
2347 semi = yychar == ';';
2349 t = finish_class_definition ($1.t, $7, semi, $1.new_type_flag);
2352 /* restore current_aggr */
2353 current_aggr = TREE_CODE (t) != RECORD_TYPE
2355 : CLASSTYPE_DECLARED_CLASS (t)
2356 ? class_type_node : record_type_node;
2360 done_pending_defargs ();
2361 begin_inline_definitions ();
2366 $$.new_type_flag = 1;
2370 $$.t = TREE_TYPE ($1.t);
2371 $$.new_type_flag = $1.new_type_flag;
2372 check_class_key (current_aggr, $$.t);
2384 { if (pedantic && !in_system_header)
2385 pedwarn ("comma at end of enumerator list"); }
2391 { error ("storage class specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2393 { error ("type specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2395 { error ("type qualifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2397 { error ("no body nor ';' separates two class, struct or union declarations"); }
2399 { $$ = build_tree_list ($2, $1); }
2406 $$ = build_tree_list (NULL_TREE, $2);
2408 | aggr nested_name_specifier identifier
2411 $$ = build_tree_list ($2, $3);
2413 | aggr global_scope nested_name_specifier identifier
2416 $$ = build_tree_list ($3, $4);
2418 | aggr global_scope identifier
2421 $$ = build_tree_list (global_namespace, $3);
2425 class_head_apparent_template:
2426 aggr apparent_template_type
2431 | aggr nested_name_specifier apparent_template_type
2436 | aggr global_scope nested_name_specifier apparent_template_type
2444 class_head %prec EMPTY
2446 $$.t = parse_handle_class_head (current_aggr,
2449 0, &$$.new_type_flag);
2451 | aggr identifier_defn %prec EMPTY
2454 $$.t = TYPE_MAIN_DECL (parse_xref_tag (current_aggr, $2, 0));
2455 $$.new_type_flag = 1;
2457 | class_head_apparent_template %prec EMPTY
2460 $$.new_type_flag = 0;
2468 $$.t = parse_handle_class_head (current_aggr,
2477 $$.t = parse_handle_class_head (current_aggr,
2480 1, &$$.new_type_flag);
2482 | class_head_apparent_template '{'
2486 $$.new_type_flag = 0;
2487 if (TREE_CODE (TREE_TYPE ($1)) == RECORD_TYPE)
2488 /* We might be specializing a template with a different
2490 CLASSTYPE_DECLARED_CLASS (TREE_TYPE ($1))
2491 = (current_aggr == class_type_node);
2493 | class_head_apparent_template ':'
2497 $$.new_type_flag = 0;
2498 if (TREE_CODE (TREE_TYPE ($1)) == RECORD_TYPE)
2499 /* We might be specializing a template with a different
2501 CLASSTYPE_DECLARED_CLASS (TREE_TYPE ($1))
2502 = (current_aggr == class_type_node);
2504 | aggr identifier_defn '{'
2508 $$.t = parse_handle_class_head (current_aggr,
2510 1, &$$.new_type_flag);
2512 | aggr identifier_defn ':'
2516 $$.t = parse_handle_class_head (current_aggr,
2518 1, &$$.new_type_flag);
2523 $$.t = TYPE_MAIN_DECL (parse_xref_tag ($1,
2526 $$.new_type_flag = 0;
2527 CLASSTYPE_DECLARED_CLASS (TREE_TYPE ($$.t))
2528 = $1 == class_type_node;
2533 maybe_base_class_list:
2537 { error ("no bases given following `:'");
2539 | ':' see_typename base_class_list
2545 | base_class_list ',' see_typename base_class
2546 { $$ = chainon ($$, $4); }
2551 { $$ = finish_base_specifier (access_default_node, $1); }
2552 | base_class_access_list see_typename base_class_1
2553 { $$ = finish_base_specifier ($1, $3); }
2559 $$ = error_mark_node; }
2561 { $$ = TREE_TYPE ($$); }
2564 base_class_access_list:
2565 VISSPEC see_typename
2566 | SCSPEC see_typename
2567 { if ($1 != ridpointers[(int)RID_VIRTUAL])
2568 error ("`%D' access", $1);
2569 $$ = access_default_virtual_node; }
2570 | base_class_access_list VISSPEC see_typename
2572 if ($1 != access_default_virtual_node)
2573 error ("multiple access specifiers");
2574 else if ($2 == access_public_node)
2575 $$ = access_public_virtual_node;
2576 else if ($2 == access_protected_node)
2577 $$ = access_protected_virtual_node;
2578 else /* $2 == access_private_node */
2579 $$ = access_private_virtual_node;
2581 | base_class_access_list SCSPEC see_typename
2582 { if ($2 != ridpointers[(int)RID_VIRTUAL])
2583 error ("`%D' access", $2);
2584 else if ($$ == access_public_node)
2585 $$ = access_public_virtual_node;
2586 else if ($$ == access_protected_node)
2587 $$ = access_protected_virtual_node;
2588 else if ($$ == access_private_node)
2589 $$ = access_private_virtual_node;
2591 error ("multiple `virtual' specifiers");
2595 opt.component_decl_list:
2596 | component_decl_list
2597 | opt.component_decl_list access_specifier component_decl_list
2598 | opt.component_decl_list access_specifier
2604 current_access_specifier = $1;
2608 /* Note: we no longer warn about the semicolon after a component_decl_list.
2609 ARM $9.2 says that the semicolon is optional, and therefore allowed. */
2610 component_decl_list:
2613 finish_member_declaration ($1);
2614 current_aggr = NULL_TREE;
2615 reset_type_access_control ();
2617 | component_decl_list component_decl
2619 finish_member_declaration ($2);
2620 current_aggr = NULL_TREE;
2621 reset_type_access_control ();
2626 component_decl_1 ';'
2627 | component_decl_1 '}'
2628 { error ("missing ';' before right brace");
2629 yyungetc ('}', 0); }
2630 /* C++: handle constructors, destructors and inline functions */
2631 /* note that INLINE is like a TYPESPEC */
2632 | fn_def2 ':' /* base_init compstmt */
2633 { $$ = finish_method ($$); }
2634 | fn_def2 TRY /* base_init compstmt */
2635 { $$ = finish_method ($$); }
2636 | fn_def2 RETURN_KEYWORD /* base_init compstmt */
2637 { $$ = finish_method ($$); }
2638 | fn_def2 '{' /* nodecls compstmt */
2639 { $$ = finish_method ($$); }
2642 | extension component_decl
2645 | template_header component_decl
2648 $$ = finish_member_template_decl ($2);
2650 /* The component was already processed. */
2653 finish_template_decl ($1);
2655 | template_header typed_declspecs ';'
2657 $$ = finish_member_class_template ($2.t);
2658 finish_template_decl ($1);
2665 /* Do not add a "typed_declspecs declarator" rule here for
2666 speed; we need to call grok_x_components for enums, so the
2667 speedup would be insignificant. */
2668 typed_declspecs components
2670 /* Most of the productions for component_decl only
2671 allow the creation of one new member, so we call
2672 finish_member_declaration in component_decl_list.
2673 For this rule and the next, however, there can be
2674 more than one member, e.g.:
2678 and we need the first member to be fully
2679 registered before the second is processed.
2680 Therefore, the rules for components take care of
2681 this processing. To avoid registering the
2682 components more than once, we send NULL_TREE up
2683 here; that lets finish_member_declaration know
2684 that there is nothing to do. */
2686 grok_x_components ($1.t);
2689 | declmods notype_components
2692 grok_x_components ($1.t);
2695 | notype_declarator maybeasm maybe_attribute maybe_init
2696 { $$ = grokfield ($$, NULL_TREE, $4, $2, $3); }
2697 | constructor_declarator maybeasm maybe_attribute maybe_init
2698 { $$ = grokfield ($$, NULL_TREE, $4, $2, $3); }
2699 | ':' expr_no_commas
2700 { $$ = grokbitfield (NULL_TREE, NULL_TREE, $2); }
2704 /* These rules introduce a reduce/reduce conflict; in
2705 typedef int foo, bar;
2709 should "A::foo" be declared as a function or "A::bar" as a data
2710 member? In other words, is "bar" an after_type_declarator or a
2712 | declmods component_constructor_declarator maybeasm maybe_attribute maybe_init
2713 { tree specs, attrs;
2714 split_specs_attrs ($1.t, &specs, &attrs);
2715 $$ = grokfield ($2, specs, $5, $3,
2716 chainon ($4, attrs)); }
2717 | component_constructor_declarator maybeasm maybe_attribute maybe_init
2718 { $$ = grokfield ($$, NULL_TREE, $4, $2, $3); }
2720 { $$ = do_class_using_decl ($1); }
2723 /* The case of exactly one component is handled directly by component_decl. */
2726 /* empty: possibly anonymous */
2728 | component_declarator0
2730 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2731 $1 = finish_member_template_decl ($1);
2732 finish_member_declaration ($1);
2735 | components ',' component_declarator
2737 check_multiple_declarators ();
2738 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2739 $3 = finish_member_template_decl ($3);
2740 finish_member_declaration ($3);
2746 /* empty: possibly anonymous */
2748 | notype_component_declarator0
2750 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2751 $1 = finish_member_template_decl ($1);
2752 finish_member_declaration ($1);
2755 | notype_components ',' notype_component_declarator
2757 check_multiple_declarators ();
2758 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2759 $3 = finish_member_template_decl ($3);
2760 finish_member_declaration ($3);
2765 component_declarator0:
2766 after_type_component_declarator0
2767 | notype_component_declarator0
2770 component_declarator:
2771 after_type_component_declarator
2772 | notype_component_declarator
2775 after_type_component_declarator0:
2776 after_type_declarator maybeasm maybe_attribute maybe_init
2777 { $$ = parse_field0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2779 | tTYPENAME ':' expr_no_commas maybe_attribute
2780 { $$ = parse_bitfield0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2784 notype_component_declarator0:
2785 notype_declarator maybeasm maybe_attribute maybe_init
2786 { $$ = parse_field0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2788 | constructor_declarator maybeasm maybe_attribute maybe_init
2789 { $$ = parse_field0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2791 | IDENTIFIER ':' expr_no_commas maybe_attribute
2792 { $$ = parse_bitfield0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2794 | ':' expr_no_commas maybe_attribute
2795 { $$ = parse_bitfield0 (NULL_TREE, $<ftype>0.t,
2796 $<ftype>0.lookups, $3, $2); }
2799 after_type_component_declarator:
2800 after_type_declarator maybeasm maybe_attribute maybe_init
2801 { $$ = parse_field ($1, $3, $2, $4); }
2802 | tTYPENAME ':' expr_no_commas maybe_attribute
2803 { $$ = parse_bitfield ($1, $4, $3); }
2806 notype_component_declarator:
2807 notype_declarator maybeasm maybe_attribute maybe_init
2808 { $$ = parse_field ($1, $3, $2, $4); }
2809 | IDENTIFIER ':' expr_no_commas maybe_attribute
2810 { $$ = parse_bitfield ($1, $4, $3); }
2811 | ':' expr_no_commas maybe_attribute
2812 { $$ = parse_bitfield (NULL_TREE, $3, $2); }
2816 enumlist maybecomma_warn
2820 /* We chain the enumerators in reverse order.
2821 Because of the way enums are built, the order is
2822 insignificant. Take advantage of this fact. */
2826 | enumlist ',' enumerator
2831 { build_enumerator ($1, NULL_TREE, current_enum_type); }
2832 | identifier '=' expr_no_commas
2833 { build_enumerator ($1, $3, current_enum_type); }
2836 /* ISO new-type-id (5.3.4) */
2838 type_specifier_seq new_declarator
2839 { $$.t = build_tree_list ($1.t, $2);
2840 $$.new_type_flag = $1.new_type_flag; }
2841 | type_specifier_seq %prec EMPTY
2842 { $$.t = build_tree_list ($1.t, NULL_TREE);
2843 $$.new_type_flag = $1.new_type_flag; }
2844 /* GNU extension to allow arrays of arbitrary types with
2845 non-constant dimension. */
2846 | '(' type_id ')' '[' expr ']'
2849 pedwarn ("ISO C++ forbids array dimensions with parenthesized type in new");
2850 $$.t = build_nt (ARRAY_REF, TREE_VALUE ($2.t), $5);
2851 $$.t = build_tree_list (TREE_PURPOSE ($2.t), $$.t);
2852 $$.new_type_flag = $2.new_type_flag;
2857 /* empty */ %prec EMPTY
2859 | cv_qualifiers CV_QUALIFIER
2860 { $$ = tree_cons (NULL_TREE, $2, $$); }
2863 nonempty_cv_qualifiers:
2865 { $$.t = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
2866 $$.new_type_flag = 0; }
2867 | nonempty_cv_qualifiers CV_QUALIFIER
2868 { $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
2869 $$.new_type_flag = $1.new_type_flag; }
2870 | attributes %prec EMPTY
2871 { $$.t = hash_tree_cons ($1, NULL_TREE, NULL_TREE);
2872 $$.new_type_flag = 0; }
2873 | nonempty_cv_qualifiers attributes %prec EMPTY
2874 { $$.t = hash_tree_cons ($2, NULL_TREE, $1.t);
2875 $$.new_type_flag = $1.new_type_flag; }
2878 /* These rules must follow the rules for function declarations
2879 and component declarations. That way, longer rules are preferred. */
2881 /* An expression which will not live on the momentary obstack. */
2883 '(' nonnull_exprlist ')'
2888 { $$ = empty_parms (); }
2893 /* A declarator that is allowed only after an explicit typespec. */
2895 after_type_declarator_intern:
2896 after_type_declarator
2897 | attributes after_type_declarator
2899 /* Provide support for '(' attributes '*' declarator ')'
2901 $$ = tree_cons ($1, $2, NULL_TREE);
2905 /* may all be followed by prec '.' */
2906 after_type_declarator:
2907 '*' nonempty_cv_qualifiers after_type_declarator_intern %prec UNARY
2908 { $$ = make_pointer_declarator ($2.t, $3); }
2909 | '&' nonempty_cv_qualifiers after_type_declarator_intern %prec UNARY
2910 { $$ = make_reference_declarator ($2.t, $3); }
2911 | '*' after_type_declarator_intern %prec UNARY
2912 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2913 | '&' after_type_declarator_intern %prec UNARY
2914 { $$ = make_reference_declarator (NULL_TREE, $2); }
2915 | ptr_to_mem cv_qualifiers after_type_declarator_intern
2916 { tree arg = make_pointer_declarator ($2, $3);
2917 $$ = build_nt (SCOPE_REF, $1, arg);
2919 | direct_after_type_declarator
2922 direct_after_type_declarator:
2923 direct_after_type_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2924 { $$ = make_call_declarator ($$, $2, $3, $4); }
2925 | direct_after_type_declarator '[' expr ']'
2926 { $$ = build_nt (ARRAY_REF, $$, $3); }
2927 | direct_after_type_declarator '[' ']'
2928 { $$ = build_nt (ARRAY_REF, $$, NULL_TREE); }
2929 | '(' after_type_declarator_intern ')'
2931 | nested_name_specifier type_name %prec EMPTY
2932 { push_nested_class ($1, 3);
2933 $$ = build_nt (SCOPE_REF, $$, $2);
2934 TREE_COMPLEXITY ($$) = current_class_depth; }
2935 | type_name %prec EMPTY
2939 type_name %prec EMPTY
2941 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2943 $$ = lookup_name ($1, 1);
2944 maybe_note_name_used_in_class ($1, $$);
2949 | global_scope type_name
2951 if (TREE_CODE ($2) == IDENTIFIER_NODE)
2952 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
2955 got_scope = NULL_TREE;
2962 | global_scope nested_type
2967 nested_name_specifier type_name %prec EMPTY
2968 { $$ = get_type_decl ($2); }
2971 /* A declarator allowed whether or not there has been
2972 an explicit typespec. These cannot redeclare a typedef-name. */
2974 notype_declarator_intern:
2976 | attributes notype_declarator
2978 /* Provide support for '(' attributes '*' declarator ')'
2980 $$ = tree_cons ($1, $2, NULL_TREE);
2985 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2986 { $$ = make_pointer_declarator ($2.t, $3); }
2987 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2988 { $$ = make_reference_declarator ($2.t, $3); }
2989 | '*' notype_declarator_intern %prec UNARY
2990 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2991 | '&' notype_declarator_intern %prec UNARY
2992 { $$ = make_reference_declarator (NULL_TREE, $2); }
2993 | ptr_to_mem cv_qualifiers notype_declarator_intern
2994 { tree arg = make_pointer_declarator ($2, $3);
2995 $$ = build_nt (SCOPE_REF, $1, arg);
2997 | direct_notype_declarator
3000 complex_notype_declarator:
3001 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
3002 { $$ = make_pointer_declarator ($2.t, $3); }
3003 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
3004 { $$ = make_reference_declarator ($2.t, $3); }
3005 | '*' complex_notype_declarator %prec UNARY
3006 { $$ = make_pointer_declarator (NULL_TREE, $2); }
3007 | '&' complex_notype_declarator %prec UNARY
3008 { $$ = make_reference_declarator (NULL_TREE, $2); }
3009 | ptr_to_mem cv_qualifiers notype_declarator_intern
3010 { tree arg = make_pointer_declarator ($2, $3);
3011 $$ = build_nt (SCOPE_REF, $1, arg);
3013 | complex_direct_notype_declarator
3016 complex_direct_notype_declarator:
3017 direct_notype_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
3018 { $$ = make_call_declarator ($$, $2, $3, $4); }
3019 | '(' complex_notype_declarator ')'
3021 | direct_notype_declarator '[' expr ']'
3022 { $$ = build_nt (ARRAY_REF, $$, $3); }
3023 | direct_notype_declarator '[' ']'
3024 { $$ = build_nt (ARRAY_REF, $$, NULL_TREE); }
3025 | notype_qualified_id
3026 { enter_scope_of ($1); }
3027 | global_scope notype_qualified_id
3028 { enter_scope_of ($2); $$ = $2;}
3029 | global_scope notype_unqualified_id
3030 { $$ = build_nt (SCOPE_REF, global_namespace, $2);
3031 enter_scope_of ($$);
3033 | nested_name_specifier notype_template_declarator
3034 { got_scope = NULL_TREE;
3035 $$ = build_nt (SCOPE_REF, $1, $2);
3036 enter_scope_of ($$);
3041 nested_name_specifier unqualified_id
3042 { got_scope = NULL_TREE;
3043 $$ = build_nt (SCOPE_REF, $$, $2); }
3044 | nested_name_specifier object_template_id
3045 { got_scope = NULL_TREE;
3046 $$ = build_nt (SCOPE_REF, $1, $2); }
3049 notype_qualified_id:
3050 nested_name_specifier notype_unqualified_id
3051 { got_scope = NULL_TREE;
3052 $$ = build_nt (SCOPE_REF, $$, $2); }
3053 | nested_name_specifier object_template_id
3054 { got_scope = NULL_TREE;
3055 $$ = build_nt (SCOPE_REF, $1, $2); }
3060 | global_scope notype_qualified_id
3065 typespec '(' nonnull_exprlist ')'
3066 { $$ = build_functional_cast ($1.t, $3); }
3067 | typespec '(' expr_or_declarator_intern ')'
3068 { $$ = reparse_decl_as_expr ($1.t, $3); }
3069 | typespec fcast_or_absdcl %prec EMPTY
3070 { $$ = reparse_absdcl_as_expr ($1.t, $2); }
3076 | template_type %prec EMPTY
3079 nested_name_specifier:
3080 nested_name_specifier_1
3081 | nested_name_specifier nested_name_specifier_1
3083 | nested_name_specifier TEMPLATE explicit_template_type SCOPE
3085 = make_typename_type ($1, $3, tf_error | tf_parsing); }
3086 /* Error handling per Core 125. */
3087 | nested_name_specifier IDENTIFIER SCOPE
3089 = make_typename_type ($1, $2, tf_error | tf_parsing); }
3090 | nested_name_specifier PTYPENAME SCOPE
3092 = make_typename_type ($1, $2, tf_error | tf_parsing); }
3095 /* Why the @#$%^& do type_name and notype_identifier need to be expanded
3096 inline here?!? (jason) */
3097 nested_name_specifier_1:
3100 if (TREE_CODE ($1) == IDENTIFIER_NODE)
3103 maybe_note_name_used_in_class ($1, $$);
3106 complete_type (TYPE_MAIN_VARIANT (TREE_TYPE ($$)));
3110 if (TREE_CODE ($1) == IDENTIFIER_NODE)
3112 got_scope = $$ = TREE_TYPE ($$);
3116 if (TREE_CODE ($$) == IDENTIFIER_NODE)
3120 | template_type SCOPE
3121 { got_scope = $$ = complete_type (TREE_TYPE ($1)); }
3126 | global_scope typename_sub0
3131 typename_sub1 identifier %prec EMPTY
3134 $$ = make_typename_type ($1, $2, tf_error | tf_parsing);
3135 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
3136 error ("`%T' is not a class or namespace", $2);
3140 if (TREE_CODE ($$) == TYPE_DECL)
3141 $$ = TREE_TYPE ($$);
3144 | typename_sub1 template_type %prec EMPTY
3145 { $$ = TREE_TYPE ($2); }
3146 | typename_sub1 explicit_template_type %prec EMPTY
3147 { $$ = make_typename_type ($1, $2, tf_error | tf_parsing); }
3148 | typename_sub1 TEMPLATE explicit_template_type %prec EMPTY
3149 { $$ = make_typename_type ($1, $3, tf_error | tf_parsing); }
3155 if (TREE_CODE ($1) == IDENTIFIER_NODE)
3156 error ("`%T' is not a class or namespace", $1);
3157 else if (TREE_CODE ($1) == TYPE_DECL)
3158 $$ = TREE_TYPE ($1);
3160 | typename_sub1 typename_sub2
3163 $$ = make_typename_type ($1, $2, tf_error | tf_parsing);
3164 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
3165 error ("`%T' is not a class or namespace", $2);
3169 if (TREE_CODE ($$) == TYPE_DECL)
3170 $$ = TREE_TYPE ($$);
3173 | typename_sub1 explicit_template_type SCOPE
3175 = make_typename_type ($1, $2, tf_error | tf_parsing); }
3176 | typename_sub1 TEMPLATE explicit_template_type SCOPE
3178 = make_typename_type ($1, $3, tf_error | tf_parsing); }
3181 /* This needs to return a TYPE_DECL for simple names so that we don't
3182 forget what name was used. */
3186 if (TREE_CODE ($1) != TYPE_DECL)
3189 /* Retrieve the type for the identifier, which might involve
3190 some computation. */
3191 got_scope = complete_type (TREE_TYPE ($$));
3193 if ($$ == error_mark_node)
3194 error ("`%T' is not a class or namespace", $1);
3198 if (TREE_CODE ($1) != TYPE_DECL)
3200 got_scope = complete_type (TREE_TYPE ($$));
3202 | template_type SCOPE
3203 { got_scope = $$ = complete_type (TREE_TYPE ($$)); }
3208 if (TREE_CODE ($$) == IDENTIFIER_NODE)
3214 explicit_template_type:
3215 identifier '<' template_arg_list_opt template_close_bracket
3216 { $$ = build_min_nt (TEMPLATE_ID_EXPR, $1, $3); }
3220 global_scope type_name
3222 if (TREE_CODE ($2) == IDENTIFIER_NODE)
3223 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
3226 got_scope = NULL_TREE;
3229 | global_scope nested_type
3234 nested_name_specifier '*'
3235 { got_scope = NULL_TREE; }
3236 | global_scope nested_name_specifier '*'
3237 { $$ = $2; got_scope = NULL_TREE; }
3240 /* All uses of explicit global scope must go through this nonterminal so
3241 that got_scope will be set before yylex is called to get the next token. */
3244 { got_scope = void_type_node; }
3247 /* ISO new-declarator (5.3.4) */
3249 '*' cv_qualifiers new_declarator
3250 { $$ = make_pointer_declarator ($2, $3); }
3251 | '*' cv_qualifiers %prec EMPTY
3252 { $$ = make_pointer_declarator ($2, NULL_TREE); }
3253 | '&' cv_qualifiers new_declarator %prec EMPTY
3254 { $$ = make_reference_declarator ($2, $3); }
3255 | '&' cv_qualifiers %prec EMPTY
3256 { $$ = make_reference_declarator ($2, NULL_TREE); }
3257 | ptr_to_mem cv_qualifiers %prec EMPTY
3258 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3259 $$ = build_nt (SCOPE_REF, $1, arg);
3261 | ptr_to_mem cv_qualifiers new_declarator
3262 { tree arg = make_pointer_declarator ($2, $3);
3263 $$ = build_nt (SCOPE_REF, $1, arg);
3265 | direct_new_declarator %prec EMPTY
3268 /* ISO direct-new-declarator (5.3.4) */
3269 direct_new_declarator:
3271 { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
3272 | direct_new_declarator '[' expr ']'
3273 { $$ = build_nt (ARRAY_REF, $$, $3); }
3280 /* Provide support for '(' attributes '*' declarator ')'
3282 $$ = tree_cons ($1, $2, NULL_TREE);
3286 /* ISO abstract-declarator (8.1) */
3288 '*' nonempty_cv_qualifiers absdcl_intern
3289 { $$ = make_pointer_declarator ($2.t, $3); }
3291 { $$ = make_pointer_declarator (NULL_TREE, $2); }
3292 | '*' nonempty_cv_qualifiers %prec EMPTY
3293 { $$ = make_pointer_declarator ($2.t, NULL_TREE); }
3295 { $$ = make_pointer_declarator (NULL_TREE, NULL_TREE); }
3296 | '&' nonempty_cv_qualifiers absdcl_intern
3297 { $$ = make_reference_declarator ($2.t, $3); }
3299 { $$ = make_reference_declarator (NULL_TREE, $2); }
3300 | '&' nonempty_cv_qualifiers %prec EMPTY
3301 { $$ = make_reference_declarator ($2.t, NULL_TREE); }
3303 { $$ = make_reference_declarator (NULL_TREE, NULL_TREE); }
3304 | ptr_to_mem cv_qualifiers %prec EMPTY
3305 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3306 $$ = build_nt (SCOPE_REF, $1, arg);
3308 | ptr_to_mem cv_qualifiers absdcl_intern
3309 { tree arg = make_pointer_declarator ($2, $3);
3310 $$ = build_nt (SCOPE_REF, $1, arg);
3312 | direct_abstract_declarator %prec EMPTY
3315 /* ISO direct-abstract-declarator (8.1) */
3316 direct_abstract_declarator:
3317 '(' absdcl_intern ')'
3319 /* `(typedef)1' is `int'. */
3320 | direct_abstract_declarator '(' parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3321 { $$ = make_call_declarator ($$, $3, $5, $6); }
3322 | direct_abstract_declarator LEFT_RIGHT cv_qualifiers exception_specification_opt %prec '.'
3323 { $$ = make_call_declarator ($$, empty_parms (), $3, $4); }
3324 | direct_abstract_declarator '[' expr ']' %prec '.'
3325 { $$ = build_nt (ARRAY_REF, $$, $3); }
3326 | direct_abstract_declarator '[' ']' %prec '.'
3327 { $$ = build_nt (ARRAY_REF, $$, NULL_TREE); }
3328 | '(' complex_parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3329 { $$ = make_call_declarator (NULL_TREE, $2, $4, $5); }
3330 | regcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3331 { set_quals_and_spec ($$, $2, $3); }
3332 | fcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3333 { set_quals_and_spec ($$, $2, $3); }
3334 | '[' expr ']' %prec '.'
3335 { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
3337 { $$ = build_nt (ARRAY_REF, NULL_TREE, NULL_TREE); }
3340 /* For C++, decls and stmts can be intermixed, so we don't need to
3341 have a special rule that won't start parsing the stmt section
3342 until we have a stmt that parses without errors. */
3355 /* Read zero or more forward-declarations for labels
3356 that nested functions can jump to. */
3361 pedwarn ("ISO C++ forbids label declarations"); }
3366 | label_decls label_decl
3370 LABEL identifiers_or_typenames ';'
3374 finish_label_decl (TREE_VALUE ($2));
3375 $2 = TREE_CHAIN ($2);
3380 compstmt_or_stmtexpr:
3382 { $<ttype>$ = begin_compound_stmt (0); }
3384 { STMT_LINENO ($<ttype>3) = $1;
3385 finish_compound_stmt (0, $<ttype>3); }
3389 compstmt_or_stmtexpr
3390 { last_expr_type = NULL_TREE; }
3395 { $<ttype>$ = begin_if_stmt ();
3396 cond_stmt_keyword = "if"; }
3398 { finish_if_stmt_cond ($3, $<ttype>2); }
3399 implicitly_scoped_stmt
3401 finish_then_clause ($<ttype>2); }
3404 implicitly_scoped_stmt:
3407 { $<ttype>$ = begin_compound_stmt (0); }
3408 save_lineno simple_stmt
3409 { STMT_LINENO ($<ttype>1) = $2;
3410 if ($3) STMT_LINENO ($3) = $2;
3411 finish_compound_stmt (0, $<ttype>1); }
3416 | save_lineno simple_stmt
3417 { if ($2) STMT_LINENO ($2) = $1; }
3425 { $$ = finish_expr_stmt ($1); }
3427 { begin_else_clause (); }
3428 implicitly_scoped_stmt
3431 finish_else_clause ($1);
3434 | simple_if %prec IF
3436 finish_if_stmt (); }
3439 $<ttype>$ = begin_while_stmt ();
3440 cond_stmt_keyword = "while";
3443 { finish_while_stmt_cond ($3, $<ttype>2); }
3444 implicitly_scoped_stmt
3446 finish_while_stmt ($<ttype>2); }
3448 { $<ttype>$ = begin_do_stmt (); }
3449 implicitly_scoped_stmt WHILE
3451 finish_do_body ($<ttype>2);
3452 cond_stmt_keyword = "do";
3454 paren_expr_or_null ';'
3456 finish_do_stmt ($6, $<ttype>2); }
3458 { $<ttype>$ = begin_for_stmt (); }
3459 '(' for.init.statement
3460 { finish_for_init_stmt ($<ttype>2); }
3462 { finish_for_cond ($6, $<ttype>2); }
3464 { finish_for_expr ($9, $<ttype>2); }
3465 implicitly_scoped_stmt
3467 finish_for_stmt ($<ttype>2); }
3469 { $<ttype>$ = begin_switch_stmt (); }
3471 { finish_switch_cond ($4, $<ttype>2); }
3472 implicitly_scoped_stmt
3474 finish_switch_stmt ($<ttype>2); }
3475 | CASE expr_no_commas ':'
3476 { $<ttype>$ = finish_case_label ($2, NULL_TREE); }
3479 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
3480 { $<ttype>$ = finish_case_label ($2, $4); }
3484 { $<ttype>$ = finish_case_label (NULL_TREE, NULL_TREE); }
3488 { $$ = finish_break_stmt (); }
3490 { $$ = finish_continue_stmt (); }
3491 | RETURN_KEYWORD ';'
3492 { $$ = finish_return_stmt (NULL_TREE); }
3493 | RETURN_KEYWORD expr ';'
3494 { $$ = finish_return_stmt ($2); }
3495 | asm_keyword maybe_cv_qualifier '(' STRING ')' ';'
3496 { $$ = finish_asm_stmt ($2, $4, NULL_TREE, NULL_TREE,
3498 ASM_INPUT_P ($$) = 1; }
3499 /* This is the case with just output operands. */
3500 | asm_keyword maybe_cv_qualifier '(' STRING ':' asm_operands ')' ';'
3501 { $$ = finish_asm_stmt ($2, $4, $6, NULL_TREE, NULL_TREE); }
3502 /* This is the case with input operands as well. */
3503 | asm_keyword maybe_cv_qualifier '(' STRING ':' asm_operands ':'
3504 asm_operands ')' ';'
3505 { $$ = finish_asm_stmt ($2, $4, $6, $8, NULL_TREE); }
3506 | asm_keyword maybe_cv_qualifier '(' STRING SCOPE asm_operands ')' ';'
3507 { $$ = finish_asm_stmt ($2, $4, NULL_TREE, $6, NULL_TREE); }
3508 /* This is the case with clobbered registers as well. */
3509 | asm_keyword maybe_cv_qualifier '(' STRING ':' asm_operands ':'
3510 asm_operands ':' asm_clobbers ')' ';'
3511 { $$ = finish_asm_stmt ($2, $4, $6, $8, $10); }
3512 | asm_keyword maybe_cv_qualifier '(' STRING SCOPE asm_operands ':'
3513 asm_clobbers ')' ';'
3514 { $$ = finish_asm_stmt ($2, $4, NULL_TREE, $6, $8); }
3515 | asm_keyword maybe_cv_qualifier '(' STRING ':' asm_operands SCOPE
3516 asm_clobbers ')' ';'
3517 { $$ = finish_asm_stmt ($2, $4, $6, NULL_TREE, $8); }
3521 pedwarn ("ISO C++ forbids computed gotos");
3522 $$ = finish_goto_stmt ($3);
3524 | GOTO identifier ';'
3525 { $$ = finish_goto_stmt ($2); }
3529 { error ("label must be followed by statement");
3539 | namespace_using_decl
3540 { do_local_using_decl ($1);
3548 { $<ttype>$ = begin_function_try_block (); }
3550 { finish_function_try_block ($<ttype>2); }
3552 { finish_function_handler_sequence ($<ttype>2); }
3557 { $<ttype>$ = begin_try_block (); }
3559 { finish_try_block ($<ttype>2); }
3561 { finish_handler_sequence ($<ttype>2); }
3566 | handler_seq handler
3568 { /* Generate a fake handler block to avoid later aborts. */
3569 tree fake_handler = begin_handler ();
3570 finish_handler_parms (NULL_TREE, fake_handler);
3571 finish_handler (fake_handler);
3572 $<ttype>$ = fake_handler;
3574 error ("must have at least one catch per try block");
3580 { $<ttype>$ = begin_handler (); }
3582 { finish_handler_parms ($3, $<ttype>2); }
3584 { finish_handler ($<ttype>2); }
3588 typed_typespecs %prec EMPTY
3589 | nonempty_cv_qualifiers %prec EMPTY
3595 /* This doesn't allow reference parameters, the below does.
3596 | '(' type_specifier_seq absdcl ')'
3597 { check_for_new_type ("inside exception declarations", $2);
3598 expand_start_catch_block ($2.t, $3); }
3599 | '(' type_specifier_seq ')'
3600 { check_for_new_type ("inside exception declarations", $2);
3601 expand_start_catch_block ($2.t, NULL_TREE); }
3602 | '(' type_specifier_seq notype_declarator ')'
3603 { check_for_new_type ("inside exception declarations", $2);
3604 expand_start_catch_block ($2.t, $3); }
3605 | '(' typed_typespecs after_type_declarator ')'
3606 { check_for_new_type ("inside exception declarations", $2);
3607 expand_start_catch_block ($2.t, $3); }
3608 This allows reference parameters... */
3611 check_for_new_type ("inside exception declarations", $2);
3612 $$ = start_handler_parms (TREE_PURPOSE ($2.t),
3619 { finish_label_stmt ($1); }
3621 { finish_label_stmt ($1); }
3623 { finish_label_stmt ($1); }
3625 { finish_label_stmt ($1); }
3630 { finish_expr_stmt ($1); }
3634 pedwarn ("ISO C++ forbids compound statements inside for initializations");
3638 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
3654 /* These are the operands other than the first string and colon
3655 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
3659 | nonnull_asm_operands
3662 nonnull_asm_operands:
3664 | nonnull_asm_operands ',' asm_operand
3665 { $$ = chainon ($$, $3); }
3670 { $$ = build_tree_list (build_tree_list (NULL_TREE, $1), $3); }
3671 | '[' identifier ']' STRING '(' expr ')'
3672 { $2 = build_string (IDENTIFIER_LENGTH ($2),
3673 IDENTIFIER_POINTER ($2));
3674 $$ = build_tree_list (build_tree_list ($2, $4), $6); }
3679 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);}
3680 | asm_clobbers ',' STRING
3681 { $$ = tree_cons (NULL_TREE, $3, $1); }
3684 /* This is what appears inside the parens in a function declarator.
3685 Its value is represented in the format that grokdeclarator expects.
3687 In C++, declaring a function with no parameters
3688 means that that function takes *no* parameters. */
3697 { $$ = finish_parmlist (build_tree_list (NULL_TREE, $1.t), 0);
3698 check_for_new_type ("inside parameter list", $1); }
3701 /* This nonterminal does not include the common sequence '(' type_id ')',
3702 as it is ambiguous and must be disambiguated elsewhere. */
3705 { $$ = finish_parmlist ($$, 0); }
3706 | parms_comma ELLIPSIS
3707 { $$ = finish_parmlist ($1, 1); }
3708 /* C++ allows an ellipsis without a separating ',' */
3710 { $$ = finish_parmlist ($1, 1); }
3712 { $$ = finish_parmlist (build_tree_list (NULL_TREE,
3715 { $$ = finish_parmlist (NULL_TREE, 1); }
3718 /* This helps us recover from really nasty
3719 parse errors, for example, a missing right
3721 yyerror ("possibly missing ')'");
3722 $$ = finish_parmlist ($1, 0);
3728 /* This helps us recover from really nasty
3729 parse errors, for example, a missing right
3731 yyerror ("possibly missing ')'");
3732 $$ = finish_parmlist (build_tree_list (NULL_TREE,
3739 /* A default argument to a */
3742 { maybe_snarf_defarg (); }
3752 /* A nonempty list of parameter declarations or type names. */
3755 { check_for_new_type ("in a parameter list", $1);
3756 $$ = build_tree_list (NULL_TREE, $1.t); }
3758 { check_for_new_type ("in a parameter list", $1);
3759 $$ = build_tree_list ($2, $1.t); }
3760 | parms_comma full_parm
3761 { check_for_new_type ("in a parameter list", $2);
3762 $$ = chainon ($$, $2.t); }
3763 | parms_comma bad_parm
3764 { $$ = chainon ($$, build_tree_list (NULL_TREE, $2)); }
3765 | parms_comma bad_parm '=' init
3766 { $$ = chainon ($$, build_tree_list ($4, $2)); }
3772 { check_for_new_type ("in a parameter list", $1);
3773 $$ = build_tree_list (NULL_TREE, $1.t); }
3776 /* A single parameter declaration or parameter type name,
3777 as found in a parmlist. */
3779 /* Here we expand typed_declspecs inline to avoid mis-parsing of
3780 TYPESPEC IDENTIFIER. */
3781 typed_declspecs1 declarator
3782 { $$.new_type_flag = $1.new_type_flag;
3783 $$.t = build_tree_list ($1.t, $2); }
3784 | typed_typespecs declarator
3785 { $$.t = build_tree_list ($1.t, $2);
3786 $$.new_type_flag = $1.new_type_flag; }
3787 | typespec declarator
3788 { $$.t = build_tree_list (build_tree_list (NULL_TREE, $1.t),
3790 $$.new_type_flag = $1.new_type_flag; }
3791 | typed_declspecs1 absdcl
3792 { $$.t = build_tree_list ($1.t, $2);
3793 $$.new_type_flag = $1.new_type_flag; }
3794 | typed_declspecs1 %prec EMPTY
3795 { $$.t = build_tree_list ($1.t, NULL_TREE);
3796 $$.new_type_flag = $1.new_type_flag; }
3797 | declmods notype_declarator
3798 { $$.t = build_tree_list ($1.t, $2);
3799 $$.new_type_flag = 0; }
3804 { $$.t = build_tree_list (NULL_TREE, $1.t);
3805 $$.new_type_flag = $1.new_type_flag; }
3807 { $$.t = build_tree_list ($2, $1.t);
3808 $$.new_type_flag = $1.new_type_flag; }
3817 /* empty */ %prec EMPTY
3818 { see_typename (); }
3822 /* empty */ %prec EMPTY
3824 error ("type specifier omitted for parameter");
3825 $$ = build_tree_list (integer_type_node, NULL_TREE);
3829 if (TREE_CODE ($$) == SCOPE_REF)
3831 if (TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TYPE_PARM
3832 || TREE_CODE (TREE_OPERAND ($$, 0)) == BOUND_TEMPLATE_TEMPLATE_PARM)
3833 error ("`%E' is not a type, use `typename %E' to make it one", $$);
3835 error ("no type `%D' in `%T'", TREE_OPERAND ($$, 1), TREE_OPERAND ($$, 0));
3838 error ("type specifier omitted for parameter `%E'", $$);
3839 $$ = build_tree_list (integer_type_node, $$);
3844 IDENTIFIER template_arg_list_ignore IDENTIFIER arg_list_ignore ';'
3846 error("'%D' is used as a type, but is not defined as a type.", $1);
3847 $3 = error_mark_node;
3851 template_arg_list_ignore:
3852 '<' template_arg_list_opt template_close_bracket
3858 '(' nonnull_exprlist ')'
3863 exception_specification_opt:
3864 /* empty */ %prec EMPTY
3866 | THROW '(' ansi_raise_identifiers ')' %prec EMPTY
3868 | THROW LEFT_RIGHT %prec EMPTY
3869 { $$ = empty_except_spec; }
3872 ansi_raise_identifier:
3875 check_for_new_type ("exception specifier", $1);
3876 $$ = groktypename ($1.t);
3879 { $$ = error_mark_node; }
3882 ansi_raise_identifiers:
3883 ansi_raise_identifier
3884 { $$ = add_exception_specifier (NULL_TREE, $1, 1); }
3885 | ansi_raise_identifiers ',' ansi_raise_identifier
3886 { $$ = add_exception_specifier ($1, $3, 1); }
3889 conversion_declarator:
3890 /* empty */ %prec EMPTY
3892 | '*' cv_qualifiers conversion_declarator
3893 { $$ = make_pointer_declarator ($2, $3); }
3894 | '&' cv_qualifiers conversion_declarator
3895 { $$ = make_reference_declarator ($2, $3); }
3896 | ptr_to_mem cv_qualifiers conversion_declarator
3897 { tree arg = make_pointer_declarator ($2, $3);
3898 $$ = build_nt (SCOPE_REF, $1, arg);
3905 saved_scopes = tree_cons (got_scope, got_object, saved_scopes);
3906 TREE_LANG_FLAG_0 (saved_scopes) = looking_for_typename;
3907 /* We look for conversion-type-id's in both the class and current
3908 scopes, just as for ID in 'ptr->ID::'. */
3909 looking_for_typename = 1;
3910 got_object = got_scope;
3911 got_scope = NULL_TREE;
3916 { got_scope = TREE_PURPOSE (saved_scopes);
3917 got_object = TREE_VALUE (saved_scopes);
3918 looking_for_typename = TREE_LANG_FLAG_0 (saved_scopes);
3919 saved_scopes = TREE_CHAIN (saved_scopes);
3924 operator '*' unoperator
3925 { $$ = frob_opname (ansi_opname (MULT_EXPR)); }
3926 | operator '/' unoperator
3927 { $$ = frob_opname (ansi_opname (TRUNC_DIV_EXPR)); }
3928 | operator '%' unoperator
3929 { $$ = frob_opname (ansi_opname (TRUNC_MOD_EXPR)); }
3930 | operator '+' unoperator
3931 { $$ = frob_opname (ansi_opname (PLUS_EXPR)); }
3932 | operator '-' unoperator
3933 { $$ = frob_opname (ansi_opname (MINUS_EXPR)); }
3934 | operator '&' unoperator
3935 { $$ = frob_opname (ansi_opname (BIT_AND_EXPR)); }
3936 | operator '|' unoperator
3937 { $$ = frob_opname (ansi_opname (BIT_IOR_EXPR)); }
3938 | operator '^' unoperator
3939 { $$ = frob_opname (ansi_opname (BIT_XOR_EXPR)); }
3940 | operator '~' unoperator
3941 { $$ = frob_opname (ansi_opname (BIT_NOT_EXPR)); }
3942 | operator ',' unoperator
3943 { $$ = frob_opname (ansi_opname (COMPOUND_EXPR)); }
3944 | operator ARITHCOMPARE unoperator
3945 { $$ = frob_opname (ansi_opname ($2)); }
3946 | operator '<' unoperator
3947 { $$ = frob_opname (ansi_opname (LT_EXPR)); }
3948 | operator '>' unoperator
3949 { $$ = frob_opname (ansi_opname (GT_EXPR)); }
3950 | operator EQCOMPARE unoperator
3951 { $$ = frob_opname (ansi_opname ($2)); }
3952 | operator ASSIGN unoperator
3953 { $$ = frob_opname (ansi_assopname ($2)); }
3954 | operator '=' unoperator
3955 { $$ = frob_opname (ansi_assopname (NOP_EXPR)); }
3956 | operator LSHIFT unoperator
3957 { $$ = frob_opname (ansi_opname ($2)); }
3958 | operator RSHIFT unoperator
3959 { $$ = frob_opname (ansi_opname ($2)); }
3960 | operator PLUSPLUS unoperator
3961 { $$ = frob_opname (ansi_opname (POSTINCREMENT_EXPR)); }
3962 | operator MINUSMINUS unoperator
3963 { $$ = frob_opname (ansi_opname (PREDECREMENT_EXPR)); }
3964 | operator ANDAND unoperator
3965 { $$ = frob_opname (ansi_opname (TRUTH_ANDIF_EXPR)); }
3966 | operator OROR unoperator
3967 { $$ = frob_opname (ansi_opname (TRUTH_ORIF_EXPR)); }
3968 | operator '!' unoperator
3969 { $$ = frob_opname (ansi_opname (TRUTH_NOT_EXPR)); }
3970 | operator '?' ':' unoperator
3971 { $$ = frob_opname (ansi_opname (COND_EXPR)); }
3972 | operator MIN_MAX unoperator
3973 { $$ = frob_opname (ansi_opname ($2)); }
3974 | operator POINTSAT unoperator %prec EMPTY
3975 { $$ = frob_opname (ansi_opname (COMPONENT_REF)); }
3976 | operator POINTSAT_STAR unoperator %prec EMPTY
3977 { $$ = frob_opname (ansi_opname (MEMBER_REF)); }
3978 | operator LEFT_RIGHT unoperator
3979 { $$ = frob_opname (ansi_opname (CALL_EXPR)); }
3980 | operator '[' ']' unoperator
3981 { $$ = frob_opname (ansi_opname (ARRAY_REF)); }
3982 | operator NEW unoperator %prec EMPTY
3983 { $$ = frob_opname (ansi_opname (NEW_EXPR)); }
3984 | operator DELETE unoperator %prec EMPTY
3985 { $$ = frob_opname (ansi_opname (DELETE_EXPR)); }
3986 | operator NEW '[' ']' unoperator
3987 { $$ = frob_opname (ansi_opname (VEC_NEW_EXPR)); }
3988 | operator DELETE '[' ']' unoperator
3989 { $$ = frob_opname (ansi_opname (VEC_DELETE_EXPR)); }
3990 | operator type_specifier_seq conversion_declarator unoperator
3991 { $$ = frob_opname (grokoptypename ($2.t, $3)); }
3992 | operator error unoperator
3993 { $$ = frob_opname (ansi_opname (ERROR_MARK)); }
3996 /* The forced readahead in here is because we might be at the end of a
3997 line, and lineno won't be bumped until yylex absorbs the first token
3998 on the next line. */
4000 { if (yychar == YYEMPTY)
4008 debug_yytranslate (value)
4011 return yytname[YYTRANSLATE (value)];
4015 /* Free malloced parser stacks if necessary. */
4018 free_parser_stacks ()
4022 free (malloced_yyss);
4023 free (malloced_yyvs);
4027 /* Return the value corresponding to TOKEN in the global scope. */
4030 parse_scoped_id (token)
4035 id = make_node (CPLUS_BINDING);
4036 if (!qualified_lookup_using_namespace (token, global_namespace, id, 0))
4039 id = BINDING_VALUE (id);
4040 if (yychar == YYEMPTY)
4043 return do_scoped_id (token, id);
4046 /* AGGR may be either a type node (like class_type_node) or a
4047 TREE_LIST whose TREE_PURPOSE is a list of attributes and whose
4048 TREE_VALUE is a type node. Set *TAG_KIND and *ATTRIBUTES to
4049 represent the information encoded. */
4052 parse_split_aggr (tree aggr, enum tag_types *tag_kind, tree *attributes)
4054 if (TREE_CODE (aggr) == TREE_LIST)
4056 *attributes = TREE_PURPOSE (aggr);
4057 aggr = TREE_VALUE (aggr);
4060 *attributes = NULL_TREE;
4061 *tag_kind = (enum tag_types) tree_low_cst (aggr, 1);
4064 /* Like xref_tag, except that the AGGR may be either a type node (like
4065 class_type_node) or a TREE_LIST whose TREE_PURPOSE is a list of
4066 attributes and whose TREE_VALUE is a type node. */
4069 parse_xref_tag (tree aggr, tree name, int globalize)
4072 enum tag_types tag_kind;
4073 parse_split_aggr (aggr, &tag_kind, &attributes);
4074 return xref_tag (tag_kind, name, attributes, globalize);
4077 /* Like handle_class_head, but AGGR may be as for parse_xref_tag. */
4080 parse_handle_class_head (tree aggr, tree scope, tree id,
4081 int defn_p, int *new_type_p)
4084 enum tag_types tag_kind;
4085 parse_split_aggr (aggr, &tag_kind, &attributes);
4086 return handle_class_head (tag_kind, scope, id, attributes,
4087 defn_p, new_type_p);
4090 /* Like do_decl_instantiation, but the declarator has not yet been
4094 parse_decl_instantiation (tree declspecs, tree declarator, tree storage)
4096 tree decl = grokdeclarator (declarator, declspecs, NORMAL, 0, NULL);
4097 do_decl_instantiation (decl, storage);
4100 /* Like begin_function_definition, but SPECS_ATTRS is a combined list
4101 containing both a decl-specifier-seq and attributes. */
4104 parse_begin_function_definition (tree specs_attrs, tree declarator)
4109 split_specs_attrs (specs_attrs, &specs, &attrs);
4110 return begin_function_definition (specs, attrs, declarator);
4113 /* Like finish_call_expr, but the name for FN has not yet been
4117 parse_finish_call_expr (tree fn, tree args, int koenig)
4119 bool disallow_virtual;
4124 if (TREE_CODE (fn) == OFFSET_REF)
4125 return build_offset_ref_call_from_tree (fn, args);
4127 if (TREE_CODE (fn) == SCOPE_REF)
4132 scope = TREE_OPERAND (fn, 0);
4133 name = TREE_OPERAND (fn, 1);
4135 if (scope == error_mark_node || name == error_mark_node)
4136 return error_mark_node;
4137 if (!processing_template_decl)
4139 if (TREE_CODE (scope) == NAMESPACE_DECL)
4140 fn = lookup_namespace_name (scope, name);
4143 if (!COMPLETE_TYPE_P (scope) && !TYPE_BEING_DEFINED (scope))
4145 error ("incomplete type '%T' cannot be used to name a scope",
4147 return error_mark_node;
4149 else if (TREE_CODE (name) == TEMPLATE_ID_EXPR)
4152 template_args = TREE_OPERAND (name, 1);
4153 name = TREE_OPERAND (name, 0);
4157 template_id = NULL_TREE;
4158 template_args = NULL_TREE;
4161 if (BASELINK_P (name))
4165 if (TREE_CODE (name) == OVERLOAD)
4166 name = DECL_NAME (get_first_fn (name));
4167 fn = lookup_member (scope, name, /*protect=*/1,
4171 error ("'%D' has no member named '%E'", scope, name);
4172 return error_mark_node;
4175 if (BASELINK_P (fn) && template_id)
4176 BASELINK_FUNCTIONS (fn)
4177 = build_nt (TEMPLATE_ID_EXPR,
4178 BASELINK_FUNCTIONS (fn),
4181 if (current_class_type)
4182 fn = (adjust_result_of_qualified_name_lookup
4183 (fn, scope, current_class_type));
4186 disallow_virtual = true;
4189 disallow_virtual = false;
4191 if (koenig && TREE_CODE (fn) == IDENTIFIER_NODE)
4193 /* Do the Koenig lookup. */
4194 fn = do_identifier (fn, 2, args);
4195 /* If name lookup didn't find any matching declarations, we've
4196 got an unbound identifier. */
4197 if (TREE_CODE (fn) == IDENTIFIER_NODE)
4199 /* For some reason, do_identifier does not resolve
4200 conversion operator names if the only matches would be
4201 template conversion operators. So, we do it here. */
4202 if (IDENTIFIER_TYPENAME_P (fn) && current_class_type)
4204 f = lookup_member (current_class_type, fn,
4205 /*protect=*/1, /*want_type=*/0);
4207 return finish_call_expr (f, args,
4208 /*disallow_virtual=*/false);
4210 /* If the name still could not be resolved, then the program
4212 if (TREE_CODE (fn) == IDENTIFIER_NODE)
4214 unqualified_name_lookup_error (fn);
4215 return error_mark_node;
4218 else if (TREE_CODE (fn) == FUNCTION_DECL
4219 || DECL_FUNCTION_TEMPLATE_P (fn)
4220 || TREE_CODE (fn) == OVERLOAD)
4222 tree scope = DECL_CONTEXT (get_first_fn (fn));
4223 if (scope && TYPE_P (scope))
4227 if (DERIVED_FROM_P (scope, current_class_type)
4228 && current_class_ref)
4230 fn = build_baselink (lookup_base (current_class_type,
4234 TYPE_BINFO (current_class_type),
4236 /*optype=*/NULL_TREE);
4237 return finish_object_call_expr (fn,
4243 access_scope = current_class_type;
4244 while (!DERIVED_FROM_P (scope, access_scope))
4246 access_scope = TYPE_CONTEXT (access_scope);
4247 while (DECL_P (access_scope))
4248 access_scope = DECL_CONTEXT (access_scope);
4251 fn = build_baselink (NULL_TREE,
4252 TYPE_BINFO (access_scope),
4254 /*optype=*/NULL_TREE);
4259 if (TREE_CODE (fn) == COMPONENT_REF)
4260 /* If the parser sees `(x->y)(bar)' we get here because the
4261 parentheses confuse the parser. Treat this like
4263 return finish_object_call_expr (TREE_OPERAND (fn, 1),
4264 TREE_OPERAND (fn, 0),
4267 if (processing_template_decl)
4268 return build_nt (CALL_EXPR, fn, args, NULL_TREE);
4270 return build_call_from_tree (fn, args, disallow_virtual);
4273 #include "gt-cp-parse.h"