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 (current_class_ref, NULL_TREE, $2);
988 if (current_class_name)
989 pedwarn ("anachronistic old style base class initializer");
990 $$ = expand_member_init (current_class_ref,
994 | notype_identifier '(' nonnull_exprlist ')'
995 { $$ = expand_member_init (current_class_ref, $1, $3); }
996 | notype_identifier LEFT_RIGHT
997 { $$ = expand_member_init (current_class_ref, $1,
999 | nonnested_type '(' nonnull_exprlist ')'
1000 { $$ = expand_member_init (current_class_ref, $1, $3); }
1001 | nonnested_type LEFT_RIGHT
1002 { $$ = expand_member_init (current_class_ref, $1,
1004 | typename_sub '(' nonnull_exprlist ')'
1005 { $$ = expand_member_init (current_class_ref, $1, $3); }
1006 | typename_sub LEFT_RIGHT
1007 { $$ = expand_member_init (current_class_ref, $1,
1024 | NSNAME %prec EMPTY
1033 explicit_instantiation:
1034 TEMPLATE begin_explicit_instantiation typespec ';'
1035 { do_type_instantiation ($3.t, NULL_TREE, 1);
1036 yyungetc (';', 1); }
1037 end_explicit_instantiation
1038 | TEMPLATE begin_explicit_instantiation typed_declspecs declarator
1039 { tree specs = strip_attrs ($3.t);
1040 parse_decl_instantiation (specs, $4, NULL_TREE); }
1041 end_explicit_instantiation
1042 | TEMPLATE begin_explicit_instantiation notype_declarator
1043 { parse_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
1044 end_explicit_instantiation
1045 | TEMPLATE begin_explicit_instantiation constructor_declarator
1046 { parse_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
1047 end_explicit_instantiation
1048 | SCSPEC TEMPLATE begin_explicit_instantiation typespec ';'
1049 { do_type_instantiation ($4.t, $1, 1);
1050 yyungetc (';', 1); }
1051 end_explicit_instantiation
1053 | SCSPEC TEMPLATE begin_explicit_instantiation typed_declspecs
1055 { tree specs = strip_attrs ($4.t);
1056 parse_decl_instantiation (specs, $5, $1); }
1057 end_explicit_instantiation
1059 | SCSPEC TEMPLATE begin_explicit_instantiation notype_declarator
1060 { parse_decl_instantiation (NULL_TREE, $4, $1); }
1061 end_explicit_instantiation
1063 | SCSPEC TEMPLATE begin_explicit_instantiation constructor_declarator
1064 { parse_decl_instantiation (NULL_TREE, $4, $1); }
1065 end_explicit_instantiation
1069 begin_explicit_instantiation:
1070 { begin_explicit_instantiation(); }
1073 end_explicit_instantiation:
1074 { end_explicit_instantiation(); }
1077 /* The TYPENAME expansions are to deal with use of a template class name as
1078 a template within the class itself, where the template decl is hidden by
1079 a type decl. Got all that? */
1082 PTYPENAME '<' template_arg_list_opt template_close_bracket
1083 finish_template_type_
1085 | tTYPENAME '<' template_arg_list_opt template_close_bracket
1086 finish_template_type_
1088 | self_template_type
1091 apparent_template_type:
1093 | identifier '<' template_arg_list_opt '>'
1094 finish_template_type_
1099 SELFNAME '<' template_arg_list_opt template_close_bracket
1100 finish_template_type_
1104 finish_template_type_:
1106 if (yychar == YYEMPTY)
1109 $$ = finish_template_type ($<ttype>-3, $<ttype>-1,
1114 template_close_bracket:
1118 /* Handle `Class<Class<Type>>' without space in the `>>' */
1119 pedwarn ("`>>' should be `> >' in template class name");
1124 template_arg_list_opt:
1132 { $$ = build_tree_list (NULL_TREE, $$); }
1133 | template_arg_list ',' template_arg
1134 { $$ = chainon ($$, build_tree_list (NULL_TREE, $3)); }
1139 { $$ = groktypename ($1.t); }
1143 if (DECL_TEMPLATE_TEMPLATE_PARM_P ($$))
1144 $$ = TREE_TYPE ($$);
1146 | global_scope PTYPENAME
1149 if (DECL_TEMPLATE_TEMPLATE_PARM_P ($$))
1150 $$ = TREE_TYPE ($$);
1152 | expr_no_comma_rangle
1153 | nested_name_specifier TEMPLATE identifier
1155 if (!processing_template_decl)
1157 error ("use of template qualifier outside template");
1158 $$ = error_mark_node;
1161 $$ = make_unbound_class_template ($1, $3, tf_error | tf_parsing);
1167 { $$ = NEGATE_EXPR; }
1169 { $$ = CONVERT_EXPR; }
1171 { $$ = PREINCREMENT_EXPR; }
1173 { $$ = PREDECREMENT_EXPR; }
1175 { $$ = TRUTH_NOT_EXPR; }
1180 { $$ = build_x_compound_expr ($$); }
1186 { error ("ISO C++ forbids an empty condition for `%s'",
1188 $$ = integer_zero_node; }
1195 { error ("ISO C++ forbids an empty condition for `%s'",
1197 $$ = integer_zero_node; }
1211 type_specifier_seq declarator maybeasm maybe_attribute '='
1214 for (d = getdecls (); d; d = TREE_CHAIN (d))
1215 if (TREE_CODE (d) == TYPE_DECL) {
1216 tree s = TREE_TYPE (d);
1217 if (TREE_CODE (s) == RECORD_TYPE)
1218 error ("definition of class `%T' in condition", s);
1219 else if (TREE_CODE (s) == ENUMERAL_TYPE)
1220 error ("definition of enum `%T' in condition", s);
1223 current_declspecs = $1.t;
1224 $<ttype>$ = parse_decl ($<ttype>2, $4, 1);
1228 parse_end_decl ($<ttype>6, $7, $4);
1229 $$ = convert_from_reference ($<ttype>6);
1230 if (TREE_CODE (TREE_TYPE ($$)) == ARRAY_TYPE)
1231 error ("definition of array `%#D' in condition", $$);
1238 | maybe_label_decls stmts '}'
1239 | maybe_label_decls stmts error '}'
1240 | maybe_label_decls error '}'
1243 nontrivial_exprlist:
1244 expr_no_commas ',' expr_no_commas
1245 { $$ = tree_cons (NULL_TREE, $$,
1246 build_tree_list (NULL_TREE, $3)); }
1247 | expr_no_commas ',' error
1248 { $$ = tree_cons (NULL_TREE, $$,
1249 build_tree_list (NULL_TREE, error_mark_node)); }
1250 | nontrivial_exprlist ',' expr_no_commas
1251 { chainon ($$, build_tree_list (NULL_TREE, $3)); }
1252 | nontrivial_exprlist ',' error
1253 { chainon ($$, build_tree_list (NULL_TREE, error_mark_node)); }
1258 { $$ = build_tree_list (NULL_TREE, $$); }
1259 | nontrivial_exprlist
1265 /* __extension__ turns off -pedantic for following primary. */
1266 | extension cast_expr %prec UNARY
1269 | '*' cast_expr %prec UNARY
1270 { $$ = build_x_indirect_ref ($2, "unary *"); }
1271 | '&' cast_expr %prec UNARY
1272 { $$ = build_x_unary_op (ADDR_EXPR, $2); }
1274 { $$ = build_x_unary_op (BIT_NOT_EXPR, $2); }
1275 | unop cast_expr %prec UNARY
1276 { $$ = finish_unary_op_expr ($1, $2); }
1277 /* Refer to the address of a label as a pointer. */
1279 { $$ = finish_label_address_expr ($2); }
1280 | sizeof unary_expr %prec UNARY
1281 { $$ = finish_sizeof ($2);
1282 skip_evaluation--; }
1283 | sizeof '(' type_id ')' %prec HYPERUNARY
1284 { $$ = finish_sizeof (groktypename ($3.t));
1285 check_for_new_type ("sizeof", $3);
1286 skip_evaluation--; }
1287 | alignof unary_expr %prec UNARY
1288 { $$ = finish_alignof ($2);
1289 skip_evaluation--; }
1290 | alignof '(' type_id ')' %prec HYPERUNARY
1291 { $$ = finish_alignof (groktypename ($3.t));
1292 check_for_new_type ("alignof", $3);
1293 skip_evaluation--; }
1295 /* The %prec EMPTY's here are required by the = init initializer
1296 syntax extension; see below. */
1297 | new new_type_id %prec EMPTY
1298 { $$ = build_new (NULL_TREE, $2.t, NULL_TREE, $1);
1299 check_for_new_type ("new", $2); }
1300 | new new_type_id new_initializer
1301 { $$ = build_new (NULL_TREE, $2.t, $3, $1);
1302 check_for_new_type ("new", $2); }
1303 | new new_placement new_type_id %prec EMPTY
1304 { $$ = build_new ($2, $3.t, NULL_TREE, $1);
1305 check_for_new_type ("new", $3); }
1306 | new new_placement new_type_id new_initializer
1307 { $$ = build_new ($2, $3.t, $4, $1);
1308 check_for_new_type ("new", $3); }
1309 | new '(' type_id ')'
1311 { $$ = build_new (NULL_TREE, groktypename($3.t),
1313 check_for_new_type ("new", $3); }
1314 | new '(' type_id ')' new_initializer
1315 { $$ = build_new (NULL_TREE, groktypename($3.t), $5, $1);
1316 check_for_new_type ("new", $3); }
1317 | new new_placement '(' type_id ')' %prec EMPTY
1318 { $$ = build_new ($2, groktypename($4.t), NULL_TREE, $1);
1319 check_for_new_type ("new", $4); }
1320 | new new_placement '(' type_id ')' new_initializer
1321 { $$ = build_new ($2, groktypename($4.t), $6, $1);
1322 check_for_new_type ("new", $4); }
1324 | delete cast_expr %prec UNARY
1325 { $$ = delete_sanity ($2, NULL_TREE, 0, $1); }
1326 | delete '[' ']' cast_expr %prec UNARY
1327 { $$ = delete_sanity ($4, NULL_TREE, 1, $1);
1328 if (yychar == YYEMPTY)
1330 | delete '[' expr ']' cast_expr %prec UNARY
1331 { $$ = delete_sanity ($5, $3, 2, $1);
1332 if (yychar == YYEMPTY)
1334 | REALPART cast_expr %prec UNARY
1335 { $$ = build_x_unary_op (REALPART_EXPR, $2); }
1336 | IMAGPART cast_expr %prec UNARY
1337 { $$ = build_x_unary_op (IMAGPART_EXPR, $2); }
1341 '(' nonnull_exprlist ')'
1343 | '{' nonnull_exprlist '}'
1344 { pedwarn ("old style placement syntax, use () instead");
1349 '(' nonnull_exprlist ')'
1352 { $$ = void_zero_node; }
1355 error ("`%T' is not a valid expression", $2.t);
1356 $$ = error_mark_node;
1358 /* GNU extension so people can use initializer lists. Note that
1359 this alters the meaning of `new int = 1', which was previously
1360 syntactically valid but semantically invalid.
1361 This feature is now deprecated and will be removed in a future
1366 pedwarn ("ISO C++ forbids initialization of new expression with `='");
1367 cp_deprecated ("new initializer lists extension");
1368 if (TREE_CODE ($2) != TREE_LIST
1369 && TREE_CODE ($2) != CONSTRUCTOR)
1370 $$ = build_tree_list (NULL_TREE, $2);
1376 /* This is necessary to postpone reduction of `int ((int)(int)(int))'. */
1378 '(' type_id ')' %prec EMPTY
1379 { $2.t = finish_parmlist (build_tree_list (NULL_TREE, $2.t), 0);
1380 $$ = make_call_declarator (NULL_TREE, $2.t, NULL_TREE, NULL_TREE);
1381 check_for_new_type ("cast", $2); }
1382 | regcast_or_absdcl '(' type_id ')' %prec EMPTY
1383 { $3.t = finish_parmlist (build_tree_list (NULL_TREE, $3.t), 0);
1384 $$ = make_call_declarator ($$, $3.t, NULL_TREE, NULL_TREE);
1385 check_for_new_type ("cast", $3); }
1390 | regcast_or_absdcl unary_expr %prec UNARY
1391 { $$ = reparse_absdcl_as_casts ($$, $2); }
1392 | regcast_or_absdcl '{' initlist maybecomma '}' %prec UNARY
1394 tree init = build_nt (CONSTRUCTOR, NULL_TREE,
1397 pedwarn ("ISO C++ forbids compound literals");
1398 /* Indicate that this was a C99 compound literal. */
1399 TREE_HAS_CONSTRUCTOR (init) = 1;
1401 $$ = reparse_absdcl_as_casts ($$, init);
1407 /* Handle general members. */
1408 | expr_no_commas POINTSAT_STAR expr_no_commas
1409 { $$ = build_x_binary_op (MEMBER_REF, $$, $3); }
1410 | expr_no_commas DOT_STAR expr_no_commas
1411 { $$ = build_m_component_ref ($$, $3); }
1412 | expr_no_commas '+' expr_no_commas
1413 { $$ = build_x_binary_op ($2, $$, $3); }
1414 | expr_no_commas '-' expr_no_commas
1415 { $$ = build_x_binary_op ($2, $$, $3); }
1416 | expr_no_commas '*' expr_no_commas
1417 { $$ = build_x_binary_op ($2, $$, $3); }
1418 | expr_no_commas '/' expr_no_commas
1419 { $$ = build_x_binary_op ($2, $$, $3); }
1420 | expr_no_commas '%' expr_no_commas
1421 { $$ = build_x_binary_op ($2, $$, $3); }
1422 | expr_no_commas LSHIFT expr_no_commas
1423 { $$ = build_x_binary_op ($2, $$, $3); }
1424 | expr_no_commas RSHIFT expr_no_commas
1425 { $$ = build_x_binary_op ($2, $$, $3); }
1426 | expr_no_commas ARITHCOMPARE expr_no_commas
1427 { $$ = build_x_binary_op ($2, $$, $3); }
1428 | expr_no_commas '<' expr_no_commas
1429 { $$ = build_x_binary_op (LT_EXPR, $$, $3); }
1430 | expr_no_commas '>' expr_no_commas
1431 { $$ = build_x_binary_op (GT_EXPR, $$, $3); }
1432 | expr_no_commas EQCOMPARE expr_no_commas
1433 { $$ = build_x_binary_op ($2, $$, $3); }
1434 | expr_no_commas MIN_MAX expr_no_commas
1435 { $$ = build_x_binary_op ($2, $$, $3); }
1436 | expr_no_commas '&' expr_no_commas
1437 { $$ = build_x_binary_op ($2, $$, $3); }
1438 | expr_no_commas '|' expr_no_commas
1439 { $$ = build_x_binary_op ($2, $$, $3); }
1440 | expr_no_commas '^' expr_no_commas
1441 { $$ = build_x_binary_op ($2, $$, $3); }
1442 | expr_no_commas ANDAND expr_no_commas
1443 { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $$, $3); }
1444 | expr_no_commas OROR expr_no_commas
1445 { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $$, $3); }
1446 | expr_no_commas '?' xexpr ':' expr_no_commas
1447 { $$ = build_x_conditional_expr ($$, $3, $5); }
1448 | expr_no_commas '=' expr_no_commas
1449 { $$ = build_x_modify_expr ($$, NOP_EXPR, $3);
1450 if ($$ != error_mark_node)
1451 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
1452 | expr_no_commas ASSIGN expr_no_commas
1453 { $$ = build_x_modify_expr ($$, $2, $3); }
1455 { $$ = build_throw (NULL_TREE); }
1456 | THROW expr_no_commas
1457 { $$ = build_throw ($2); }
1460 expr_no_comma_rangle:
1462 /* Handle general members. */
1463 | expr_no_comma_rangle POINTSAT_STAR expr_no_comma_rangle
1464 { $$ = build_x_binary_op (MEMBER_REF, $$, $3); }
1465 | expr_no_comma_rangle DOT_STAR expr_no_comma_rangle
1466 { $$ = build_m_component_ref ($$, $3); }
1467 | expr_no_comma_rangle '+' expr_no_comma_rangle
1468 { $$ = build_x_binary_op ($2, $$, $3); }
1469 | expr_no_comma_rangle '-' expr_no_comma_rangle
1470 { $$ = build_x_binary_op ($2, $$, $3); }
1471 | expr_no_comma_rangle '*' expr_no_comma_rangle
1472 { $$ = build_x_binary_op ($2, $$, $3); }
1473 | expr_no_comma_rangle '/' expr_no_comma_rangle
1474 { $$ = build_x_binary_op ($2, $$, $3); }
1475 | expr_no_comma_rangle '%' expr_no_comma_rangle
1476 { $$ = build_x_binary_op ($2, $$, $3); }
1477 | expr_no_comma_rangle LSHIFT expr_no_comma_rangle
1478 { $$ = build_x_binary_op ($2, $$, $3); }
1479 | expr_no_comma_rangle RSHIFT expr_no_comma_rangle
1480 { $$ = build_x_binary_op ($2, $$, $3); }
1481 | expr_no_comma_rangle ARITHCOMPARE expr_no_comma_rangle
1482 { $$ = build_x_binary_op ($2, $$, $3); }
1483 | expr_no_comma_rangle '<' expr_no_comma_rangle
1484 { $$ = build_x_binary_op (LT_EXPR, $$, $3); }
1485 | expr_no_comma_rangle EQCOMPARE expr_no_comma_rangle
1486 { $$ = build_x_binary_op ($2, $$, $3); }
1487 | expr_no_comma_rangle MIN_MAX expr_no_comma_rangle
1488 { $$ = build_x_binary_op ($2, $$, $3); }
1489 | expr_no_comma_rangle '&' expr_no_comma_rangle
1490 { $$ = build_x_binary_op ($2, $$, $3); }
1491 | expr_no_comma_rangle '|' expr_no_comma_rangle
1492 { $$ = build_x_binary_op ($2, $$, $3); }
1493 | expr_no_comma_rangle '^' expr_no_comma_rangle
1494 { $$ = build_x_binary_op ($2, $$, $3); }
1495 | expr_no_comma_rangle ANDAND expr_no_comma_rangle
1496 { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $$, $3); }
1497 | expr_no_comma_rangle OROR expr_no_comma_rangle
1498 { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $$, $3); }
1499 | expr_no_comma_rangle '?' xexpr ':' expr_no_comma_rangle
1500 { $$ = build_x_conditional_expr ($$, $3, $5); }
1501 | expr_no_comma_rangle '=' expr_no_comma_rangle
1502 { $$ = build_x_modify_expr ($$, NOP_EXPR, $3);
1503 if ($$ != error_mark_node)
1504 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
1505 | expr_no_comma_rangle ASSIGN expr_no_comma_rangle
1506 { $$ = build_x_modify_expr ($$, $2, $3); }
1508 { $$ = build_throw (NULL_TREE); }
1509 | THROW expr_no_comma_rangle
1510 { $$ = build_throw ($2); }
1513 notype_unqualified_id:
1514 '~' see_typename identifier
1515 { $$ = build_nt (BIT_NOT_EXPR, $3); }
1516 | '~' see_typename template_type
1517 { $$ = build_nt (BIT_NOT_EXPR, $3); }
1522 | NSNAME %prec EMPTY
1527 /* If lastiddecl is a BASELINK we're in an
1528 expression like S::f<int>, so don't
1529 do_identifier; we only do that for unqualified
1531 if (!lastiddecl || !BASELINK_P (lastiddecl))
1532 $$ = do_identifier ($<ttype>-1, 1, NULL_TREE);
1539 PFUNCNAME '<' do_id template_arg_list_opt template_close_bracket
1541 tree template_name = $3;
1542 if (TREE_CODE (template_name) == COMPONENT_REF)
1543 template_name = TREE_OPERAND (template_name, 1);
1544 $$ = lookup_template_function (template_name, $4);
1546 | operator_name '<' do_id template_arg_list_opt template_close_bracket
1548 tree template_name = $3;
1549 if (TREE_CODE (template_name) == COMPONENT_REF)
1550 template_name = TREE_OPERAND (template_name, 1);
1551 $$ = lookup_template_function (template_name, $4);
1556 TEMPLATE identifier '<' template_arg_list_opt template_close_bracket
1557 { $$ = lookup_template_function ($2, $4); }
1558 | TEMPLATE PFUNCNAME '<' template_arg_list_opt template_close_bracket
1559 { $$ = lookup_template_function ($2, $4); }
1560 | TEMPLATE operator_name '<' template_arg_list_opt
1561 template_close_bracket
1562 { $$ = lookup_template_function ($2, $4); }
1566 notype_unqualified_id
1571 expr_or_declarator_intern:
1573 | attributes expr_or_declarator
1575 /* Provide support for '(' attributes '*' declarator ')'
1577 $$ = tree_cons ($1, $2, NULL_TREE);
1582 notype_unqualified_id
1583 | '*' expr_or_declarator_intern %prec UNARY
1584 { $$ = build_nt (INDIRECT_REF, $2); }
1585 | '&' expr_or_declarator_intern %prec UNARY
1586 { $$ = build_nt (ADDR_EXPR, $2); }
1587 | '(' expr_or_declarator_intern ')'
1591 notype_template_declarator:
1592 IDENTIFIER '<' template_arg_list_opt template_close_bracket
1593 { $$ = lookup_template_function ($1, $3); }
1594 | NSNAME '<' template_arg_list template_close_bracket
1595 { $$ = lookup_template_function ($1, $3); }
1598 direct_notype_declarator:
1599 complex_direct_notype_declarator
1600 /* This precedence declaration is to prefer this reduce
1601 to the Koenig lookup shift in primary, below. I hate yacc. */
1602 | notype_unqualified_id %prec '('
1603 | notype_template_declarator
1604 | '(' expr_or_declarator_intern ')'
1605 { $$ = finish_decl_parsing ($2); }
1609 notype_unqualified_id
1611 if (TREE_CODE ($1) == BIT_NOT_EXPR)
1612 $$ = build_x_unary_op (BIT_NOT_EXPR, TREE_OPERAND ($1, 0));
1614 $$ = finish_id_expr ($1);
1620 $$ = fix_string_type ($$);
1621 /* fix_string_type doesn't set up TYPE_MAIN_VARIANT of
1622 a const array the way we want, so fix it. */
1623 if (flag_const_strings)
1624 TREE_TYPE ($$) = build_cplus_array_type
1625 (TREE_TYPE (TREE_TYPE ($$)),
1626 TYPE_DOMAIN (TREE_TYPE ($$)));
1629 { $$ = finish_fname ($1); }
1631 { $$ = finish_parenthesized_expr ($2); }
1632 | '(' expr_or_declarator_intern ')'
1633 { $2 = reparse_decl_as_expr (NULL_TREE, $2);
1634 $$ = finish_parenthesized_expr ($2); }
1636 { $$ = error_mark_node; }
1638 { if (!at_function_scope_p ())
1640 error ("braced-group within expression allowed only inside a function");
1644 pedwarn ("ISO C++ forbids braced-groups within expressions");
1645 $<ttype>$ = begin_stmt_expr ();
1647 compstmt_or_stmtexpr ')'
1648 { $$ = finish_stmt_expr ($<ttype>2); }
1649 /* Koenig lookup support
1650 We could store lastiddecl in $1 to avoid another lookup,
1651 but that would result in many additional reduce/reduce conflicts. */
1652 | notype_unqualified_id '(' nonnull_exprlist ')'
1653 { $$ = parse_finish_call_expr ($1, $3, 1); }
1654 | notype_unqualified_id LEFT_RIGHT
1655 { $$ = parse_finish_call_expr ($1, NULL_TREE, 1); }
1656 | primary '(' nonnull_exprlist ')'
1657 { $$ = parse_finish_call_expr ($1, $3, 0); }
1658 | primary LEFT_RIGHT
1659 { $$ = parse_finish_call_expr ($1, NULL_TREE, 0); }
1660 | VA_ARG '(' expr_no_commas ',' type_id ')'
1661 { $$ = build_x_va_arg ($3, groktypename ($5.t));
1662 check_for_new_type ("__builtin_va_arg", $5); }
1663 | primary '[' expr ']'
1664 { $$ = grok_array_decl ($$, $3); }
1666 { $$ = finish_increment_expr ($1, POSTINCREMENT_EXPR); }
1667 | primary MINUSMINUS
1668 { $$ = finish_increment_expr ($1, POSTDECREMENT_EXPR); }
1669 /* C++ extensions */
1671 { $$ = finish_this_expr (); }
1672 | CV_QUALIFIER '(' nonnull_exprlist ')'
1674 /* This is a C cast in C++'s `functional' notation
1675 using the "implicit int" extension so that:
1676 `const (3)' is equivalent to `const int (3)'. */
1679 type = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
1680 type = groktypename (build_tree_list (type, NULL_TREE));
1681 $$ = build_functional_cast (type, $3);
1684 | DYNAMIC_CAST '<' type_id '>' '(' expr ')'
1685 { tree type = groktypename ($3.t);
1686 check_for_new_type ("dynamic_cast", $3);
1687 $$ = build_dynamic_cast (type, $6); }
1688 | STATIC_CAST '<' type_id '>' '(' expr ')'
1689 { tree type = groktypename ($3.t);
1690 check_for_new_type ("static_cast", $3);
1691 $$ = build_static_cast (type, $6); }
1692 | REINTERPRET_CAST '<' type_id '>' '(' expr ')'
1693 { tree type = groktypename ($3.t);
1694 check_for_new_type ("reinterpret_cast", $3);
1695 $$ = build_reinterpret_cast (type, $6); }
1696 | CONST_CAST '<' type_id '>' '(' expr ')'
1697 { tree type = groktypename ($3.t);
1698 check_for_new_type ("const_cast", $3);
1699 $$ = build_const_cast (type, $6); }
1700 | TYPEID '(' expr ')'
1701 { $$ = build_typeid ($3); }
1702 | TYPEID '(' type_id ')'
1703 { tree type = groktypename ($3.t);
1704 check_for_new_type ("typeid", $3);
1705 $$ = get_typeid (type); }
1706 | global_scope IDENTIFIER
1707 { $$ = parse_scoped_id ($2); }
1708 | global_scope template_id
1710 | global_scope operator_name
1712 got_scope = NULL_TREE;
1713 if (TREE_CODE ($2) == IDENTIFIER_NODE)
1714 $$ = parse_scoped_id ($2);
1718 | overqualified_id %prec HYPERUNARY
1719 { $$ = build_offset_ref (OP0 ($$), OP1 ($$)); }
1720 | overqualified_id '(' nonnull_exprlist ')'
1721 { $$ = parse_finish_call_expr ($1, $3, 0); }
1722 | overqualified_id LEFT_RIGHT
1723 { $$ = parse_finish_call_expr ($1, NULL_TREE, 0); }
1724 | object object_template_id %prec UNARY
1725 { $$ = finish_class_member_access_expr ($$, $2); }
1726 | object object_template_id '(' nonnull_exprlist ')'
1727 { $$ = finish_object_call_expr ($2, $1, $4); }
1728 | object object_template_id LEFT_RIGHT
1729 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1730 | object unqualified_id %prec UNARY
1731 { $$ = finish_class_member_access_expr ($$, $2); }
1732 | object overqualified_id %prec UNARY
1733 { $$ = finish_class_member_access_expr ($1, $2); }
1734 | object unqualified_id '(' nonnull_exprlist ')'
1735 { $$ = finish_object_call_expr ($2, $1, $4); }
1736 | object unqualified_id LEFT_RIGHT
1737 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1738 | object overqualified_id '(' nonnull_exprlist ')'
1739 { $$ = finish_qualified_object_call_expr ($2, $1, $4); }
1740 | object overqualified_id LEFT_RIGHT
1741 { $$ = finish_qualified_object_call_expr ($2, $1, NULL_TREE); }
1742 /* p->int::~int() is valid -- 12.4 */
1743 | object '~' TYPESPEC LEFT_RIGHT
1744 { $$ = finish_pseudo_destructor_call_expr ($1, NULL_TREE, $3); }
1745 | object TYPESPEC SCOPE '~' TYPESPEC LEFT_RIGHT
1746 { $$ = finish_pseudo_destructor_call_expr ($1, $2, $5); }
1749 $$ = error_mark_node;
1753 /* Not needed for now.
1759 { $$ = error_mark_node; }
1761 { if (current_function_decl == 0)
1763 error ("braced-group within expression allowed only inside a function");
1766 $<ttype>$ = expand_start_stmt_expr (); }
1767 compstmt_or_stmtexpr ')'
1769 pedwarn ("ISO C++ forbids braced-groups within expressions");
1770 $$ = expand_end_stmt_expr ($<ttype>2); }
1771 | primary_no_id '(' nonnull_exprlist ')'
1772 { $$ = build_x_function_call ($$, $3, current_class_ref); }
1773 | primary_no_id LEFT_RIGHT
1774 { $$ = build_x_function_call ($$, NULL_TREE, current_class_ref); }
1775 | primary_no_id '[' expr ']'
1777 | primary_no_id PLUSPLUS
1778 { $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); }
1779 | primary_no_id MINUSMINUS
1780 { $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); }
1782 { goto do_scoped_id; }
1783 | SCOPE operator_name
1784 { if (TREE_CODE ($2) == IDENTIFIER_NODE)
1786 goto do_scoped_operator;
1795 { got_scope = NULL_TREE; $$ = 1; }
1801 | global_scope delete
1802 { got_scope = NULL_TREE; $$ = 1; }
1807 { $$ = boolean_true_node; }
1809 { $$ = boolean_false_node; }
1815 if (DECL_CONSTRUCTOR_P (current_function_decl))
1816 finish_mem_initializers (NULL_TREE);
1822 { got_object = TREE_TYPE ($$); }
1825 $$ = build_x_arrow ($$);
1826 got_object = TREE_TYPE ($$);
1831 typespec initdecls ';'
1833 if ($1.t && IS_AGGR_TYPE_CODE (TREE_CODE ($1.t)))
1834 note_got_semicolon ($1.t);
1836 | typed_declspecs initdecls ';'
1838 note_list_got_semicolon ($1.t);
1840 | declmods notype_initdecls ';'
1842 | typed_declspecs ';'
1845 note_list_got_semicolon ($1.t);
1848 { warning ("empty declaration"); }
1853 /* Any kind of declarator (thus, all declarators allowed
1854 after an explicit typespec). */
1857 after_type_declarator %prec EMPTY
1858 | notype_declarator %prec EMPTY
1861 /* This is necessary to postpone reduction of `int()()()()'. */
1863 LEFT_RIGHT %prec EMPTY
1864 { $$ = make_call_declarator (NULL_TREE, empty_parms (),
1865 NULL_TREE, NULL_TREE); }
1866 | fcast_or_absdcl LEFT_RIGHT %prec EMPTY
1867 { $$ = make_call_declarator ($$, empty_parms (), NULL_TREE,
1871 /* ISO type-id (8.1) */
1873 typed_typespecs absdcl
1874 { $$.t = build_tree_list ($1.t, $2);
1875 $$.new_type_flag = $1.new_type_flag; }
1876 | nonempty_cv_qualifiers absdcl
1877 { $$.t = build_tree_list ($1.t, $2);
1878 $$.new_type_flag = $1.new_type_flag; }
1880 { $$.t = build_tree_list (build_tree_list (NULL_TREE, $1.t),
1882 $$.new_type_flag = $1.new_type_flag; }
1883 | typed_typespecs %prec EMPTY
1884 { $$.t = build_tree_list ($1.t, NULL_TREE);
1885 $$.new_type_flag = $1.new_type_flag; }
1886 | nonempty_cv_qualifiers %prec EMPTY
1887 { $$.t = build_tree_list ($1.t, NULL_TREE);
1888 $$.new_type_flag = $1.new_type_flag; }
1891 /* Declspecs which contain at least one type specifier or typedef name.
1892 (Just `const' or `volatile' is not enough.)
1893 A typedef'd name following these is taken as a name to be declared.
1894 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1897 typed_typespecs %prec EMPTY
1898 { $$.lookups = type_lookups; }
1900 { $$.lookups = type_lookups; }
1905 { $$.t = tree_cons (NULL_TREE, $2.t, $1.t);
1906 $$.new_type_flag = $2.new_type_flag; }
1907 | typespec reserved_declspecs %prec HYPERUNARY
1908 { $$.t = tree_cons (NULL_TREE, $1.t, $2);
1909 $$.new_type_flag = $1.new_type_flag; }
1910 | typespec reserved_typespecquals reserved_declspecs
1911 { $$.t = tree_cons (NULL_TREE, $1.t, chainon ($2, $3));
1912 $$.new_type_flag = $1.new_type_flag; }
1913 | declmods typespec reserved_declspecs
1914 { $$.t = tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1915 $$.new_type_flag = $2.new_type_flag; }
1916 | declmods typespec reserved_typespecquals
1917 { $$.t = tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1918 $$.new_type_flag = $2.new_type_flag; }
1919 | declmods typespec reserved_typespecquals reserved_declspecs
1920 { $$.t = tree_cons (NULL_TREE, $2.t,
1921 chainon ($3, chainon ($4, $1.t)));
1922 $$.new_type_flag = $2.new_type_flag; }
1927 { if (extra_warnings)
1928 warning ("`%s' is not at beginning of declaration",
1929 IDENTIFIER_POINTER ($$));
1930 $$ = build_tree_list (NULL_TREE, $$); }
1931 | reserved_declspecs typespecqual_reserved
1932 { $$ = tree_cons (NULL_TREE, $2.t, $$); }
1933 | reserved_declspecs SCSPEC
1934 { if (extra_warnings)
1935 warning ("`%s' is not at beginning of declaration",
1936 IDENTIFIER_POINTER ($2));
1937 $$ = tree_cons (NULL_TREE, $2, $$); }
1940 /* List of just storage classes and type modifiers.
1941 A declaration can start with just this, but then it cannot be used
1942 to redeclare a typedef-name.
1943 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1945 /* We use hash_tree_cons for lists of typeless declspecs so that they end
1946 up on a persistent obstack. Otherwise, they could appear at the
1947 beginning of something like
1949 static const struct { int foo () { } } b;
1951 and would be discarded after we finish compiling foo. We don't need to
1952 worry once we see a type. */
1955 nonempty_cv_qualifiers %prec EMPTY
1956 { $$.lookups = NULL_TREE; TREE_STATIC ($$.t) = 1; }
1959 $$.t = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
1960 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
1962 | declmods CV_QUALIFIER
1964 $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
1965 TREE_STATIC ($$.t) = 1;
1969 if (extra_warnings && TREE_STATIC ($$.t))
1970 warning ("`%s' is not at beginning of declaration",
1971 IDENTIFIER_POINTER ($2));
1972 $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
1973 TREE_STATIC ($$.t) = TREE_STATIC ($1.t);
1975 | declmods attributes
1976 { $$.t = hash_tree_cons ($2, NULL_TREE, $1.t); }
1979 /* Used instead of declspecs where storage classes are not allowed
1980 (that is, for typenames and structure components).
1982 C++ can takes storage classes for structure components.
1983 Don't accept a typedef-name if anything but a modifier precedes it. */
1986 typespec %prec EMPTY
1987 { $$.t = build_tree_list (NULL_TREE, $1.t);
1988 $$.new_type_flag = $1.new_type_flag; }
1989 | nonempty_cv_qualifiers typespec
1990 { $$.t = tree_cons (NULL_TREE, $2.t, $1.t);
1991 $$.new_type_flag = $2.new_type_flag; }
1992 | typespec reserved_typespecquals
1993 { $$.t = tree_cons (NULL_TREE, $1.t, $2);
1994 $$.new_type_flag = $1.new_type_flag; }
1995 | nonempty_cv_qualifiers typespec reserved_typespecquals
1996 { $$.t = tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1997 $$.new_type_flag = $2.new_type_flag; }
2000 reserved_typespecquals:
2001 typespecqual_reserved
2002 { $$ = build_tree_list (NULL_TREE, $1.t); }
2003 | reserved_typespecquals typespecqual_reserved
2004 { $$ = tree_cons (NULL_TREE, $2.t, $1); }
2005 | reserved_typespecquals attributes
2006 { $$ = tree_cons ($2, NULL_TREE, $1); }
2007 | attributes %prec EMPTY
2008 { $$ = tree_cons ($1, NULL_TREE, NULL_TREE); }
2012 SIZEOF { skip_evaluation++; }
2016 ALIGNOF { skip_evaluation++; }
2020 TYPEOF { skip_evaluation++; }
2023 /* A typespec (but not a type qualifier).
2024 Once we have seen one of these in a declaration,
2025 if a typedef name appears then it is being redeclared. */
2029 { $$.lookups = NULL_TREE; }
2030 | TYPESPEC %prec EMPTY
2031 { $$.t = $1; $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
2032 | complete_type_name
2033 { $$.t = $1; $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
2034 | typeof '(' expr ')'
2035 { $$.t = finish_typeof ($3);
2036 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
2037 skip_evaluation--; }
2038 | typeof '(' type_id ')'
2039 { $$.t = groktypename ($3.t);
2040 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
2041 skip_evaluation--; }
2042 | SIGOF '(' expr ')'
2043 { tree type = TREE_TYPE ($3);
2045 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
2046 if (IS_AGGR_TYPE (type))
2048 sorry ("sigof type specifier");
2053 error ("`sigof' applied to non-aggregate expression");
2054 $$.t = error_mark_node;
2057 | SIGOF '(' type_id ')'
2058 { tree type = groktypename ($3.t);
2060 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
2061 if (IS_AGGR_TYPE (type))
2063 sorry ("sigof type specifier");
2068 error("`sigof' applied to non-aggregate type");
2069 $$.t = error_mark_node;
2074 /* A typespec that is a reserved word, or a type qualifier. */
2076 typespecqual_reserved:
2078 { $$.t = $1; $$.new_type_flag = 0; }
2080 { $$.t = $1; $$.new_type_flag = 0; }
2086 | initdecls ',' initdcl
2087 { check_multiple_declarators (); }
2092 | notype_initdecls ',' initdcl
2093 { check_multiple_declarators (); }
2098 | nomods_initdecls ',' initdcl
2099 { check_multiple_declarators (); }
2105 | asm_keyword '(' STRING ')'
2110 declarator maybeasm maybe_attribute '='
2111 { $<ttype>$ = parse_decl ($<ttype>1, $3, 1); }
2113 /* Note how the declaration of the variable is in effect while its init is parsed! */
2114 { parse_end_decl ($<ttype>5, $6, $2); }
2115 | declarator maybeasm maybe_attribute
2117 $<ttype>$ = parse_decl ($<ttype>1, $3, 0);
2118 parse_end_decl ($<ttype>$, NULL_TREE, $2);
2122 /* This rule assumes a certain configuration of the parser stack.
2123 In particular, $0, the element directly before the beginning of
2124 this rule on the stack, must be a maybeasm. $-1 must be a
2125 declarator or notype_declarator. And $-2 must be some declmods
2126 or declspecs. We can't move the maybeasm into this rule because
2127 we need that reduce so we prefer fn.def1 when appropriate. */
2130 { $<ttype>$ = parse_decl0 ($<ttype>-1, $<ftype>-2.t,
2131 $<ftype>-2.lookups, $1, 1); }
2132 /* Note how the declaration of the variable is in effect
2133 while its init is parsed! */
2135 { parse_end_decl ($<ttype>3, $4, $<ttype>0); }
2137 { tree d = parse_decl0 ($<ttype>-1, $<ftype>-2.t,
2138 $<ftype>-2.lookups, $1, 0);
2139 parse_end_decl (d, NULL_TREE, $<ttype>0); }
2143 declarator maybeasm initdcl0_innards
2148 notype_declarator maybeasm initdcl0_innards
2153 notype_declarator maybeasm
2154 { /* Set things up as initdcl0_innards expects. */
2157 $<ftype>1.t = NULL_TREE;
2158 $<ftype>1.lookups = NULL_TREE; }
2161 | constructor_declarator maybeasm maybe_attribute
2162 { tree d = parse_decl0 ($1, NULL_TREE, NULL_TREE, $3, 0);
2163 parse_end_decl (d, NULL_TREE, $2); }
2166 /* the * rules are dummies to accept the Apollo extended syntax
2167 so that the header files compile. */
2178 | attributes attribute
2179 { $$ = chainon ($1, $2); }
2183 ATTRIBUTE '(' '(' attribute_list ')' ')'
2190 | attribute_list ',' attrib
2191 { $$ = chainon ($1, $3); }
2198 { $$ = build_tree_list ($1, NULL_TREE); }
2199 | any_word '(' IDENTIFIER ')'
2200 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
2201 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
2202 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
2203 | any_word '(' nonnull_exprlist ')'
2204 { $$ = build_tree_list ($1, $3); }
2207 /* This still leaves out most reserved keywords,
2208 shouldn't we include them? */
2217 /* A nonempty list of identifiers, including typenames. */
2218 identifiers_or_typenames:
2220 { $$ = build_tree_list (NULL_TREE, $1); }
2221 | identifiers_or_typenames ',' identifier
2222 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2226 /* empty */ %prec EMPTY
2232 /* If we are processing a template, we don't want to expand this
2236 expr_no_commas %prec '='
2238 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, NULL_TREE);
2239 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2241 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2242 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2243 | '{' initlist ',' '}'
2244 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2245 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2250 /* This chain is built in reverse order,
2251 and put in forward order where initlist is used. */
2254 { $$ = build_tree_list (NULL_TREE, $$); }
2256 { $$ = tree_cons (NULL_TREE, $3, $$); }
2257 /* These are for labeled elements. */
2258 | '[' expr_no_commas ']' init
2259 { $$ = build_tree_list ($2, $4); }
2260 | identifier ':' init
2261 { $$ = build_tree_list ($$, $3); }
2262 | initlist ',' identifier ':' init
2263 { $$ = tree_cons ($3, $5, $$); }
2267 PRE_PARSED_FUNCTION_DECL maybe_return_init function_body
2269 expand_body (finish_function (2));
2270 process_next_inline ($1);
2272 | PRE_PARSED_FUNCTION_DECL maybe_return_init function_try_block
2274 expand_body (finish_function (2));
2275 process_next_inline ($1);
2277 | PRE_PARSED_FUNCTION_DECL maybe_return_init error
2279 finish_function (2);
2280 process_next_inline ($1); }
2285 | pending_inlines pending_inline eat_saved_input
2288 /* A regurgitated default argument. The value of DEFARG_MARKER will be
2289 the TREE_LIST node for the parameter in question. */
2291 DEFARG_MARKER expr_no_commas END_OF_SAVED_INPUT
2292 { replace_defarg ($1, $2); }
2293 | DEFARG_MARKER error END_OF_SAVED_INPUT
2294 { replace_defarg ($1, error_mark_node); }
2298 /* empty */ %prec EMPTY
2299 | pending_defargs defarg_again
2300 { do_pending_defargs (); }
2301 | pending_defargs error
2302 { do_pending_defargs (); }
2307 { $<ttype>$ = current_enum_type;
2308 current_enum_type = start_enum ($2); }
2310 { $$.t = current_enum_type;
2311 finish_enum (current_enum_type);
2312 $$.new_type_flag = 1;
2313 current_enum_type = $<ttype>4;
2314 check_for_missing_semicolon ($$.t); }
2316 { $<ttype>$ = current_enum_type;
2317 current_enum_type = start_enum (make_anon_name ()); }
2319 { $$.t = current_enum_type;
2320 finish_enum (current_enum_type);
2321 $$.new_type_flag = 1;
2322 current_enum_type = $<ttype>3;
2323 check_for_missing_semicolon ($$.t); }
2325 { $$.t = parse_xref_tag (enum_type_node, $2, 1);
2326 $$.new_type_flag = 0; }
2327 | ENUM complex_type_name
2328 { $$.t = parse_xref_tag (enum_type_node, $2, 1);
2329 $$.new_type_flag = 0; }
2330 | TYPENAME_KEYWORD typename_sub
2332 $$.new_type_flag = 0;
2333 if (!processing_template_decl)
2334 pedwarn ("using `typename' outside of template"); }
2335 /* C++ extensions, merged with C to avoid shift/reduce conflicts */
2336 | class_head_defn maybe_base_class_list '{'
2338 if ($2 && $1.t != error_mark_node)
2340 tree type = TREE_TYPE ($1.t);
2342 if (TREE_CODE (type) == TYPENAME_TYPE)
2343 /* In a definition of a member class template,
2344 we will get here with an implicit typename,
2345 a TYPENAME_TYPE with a type. */
2346 type = TREE_TYPE (type);
2347 maybe_process_partial_specialization (type);
2348 xref_basetypes (type, $2);
2350 $1.t = begin_class_definition (TREE_TYPE ($1.t));
2351 check_class_key (current_aggr, $1.t);
2352 current_aggr = NULL_TREE; }
2353 opt.component_decl_list '}' maybe_attribute
2358 if (yychar == YYEMPTY)
2360 semi = yychar == ';';
2362 t = finish_class_definition ($1.t, $7, semi, $1.new_type_flag);
2365 /* restore current_aggr */
2366 current_aggr = TREE_CODE (t) != RECORD_TYPE
2368 : CLASSTYPE_DECLARED_CLASS (t)
2369 ? class_type_node : record_type_node;
2373 done_pending_defargs ();
2374 begin_inline_definitions ();
2379 $$.new_type_flag = 1;
2383 $$.t = TREE_TYPE ($1.t);
2384 $$.new_type_flag = $1.new_type_flag;
2385 check_class_key (current_aggr, $$.t);
2397 { if (pedantic && !in_system_header)
2398 pedwarn ("comma at end of enumerator list"); }
2404 { error ("storage class specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2406 { error ("type specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2408 { error ("type qualifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2410 { error ("no body nor ';' separates two class, struct or union declarations"); }
2412 { $$ = build_tree_list ($2, $1); }
2419 $$ = build_tree_list (NULL_TREE, $2);
2421 | aggr nested_name_specifier identifier
2424 $$ = build_tree_list ($2, $3);
2426 | aggr global_scope nested_name_specifier identifier
2429 $$ = build_tree_list ($3, $4);
2431 | aggr global_scope identifier
2434 $$ = build_tree_list (global_namespace, $3);
2438 class_head_apparent_template:
2439 aggr apparent_template_type
2444 | aggr nested_name_specifier apparent_template_type
2449 | aggr global_scope nested_name_specifier apparent_template_type
2457 class_head %prec EMPTY
2459 $$.t = parse_handle_class_head (current_aggr,
2462 0, &$$.new_type_flag);
2464 | aggr identifier_defn %prec EMPTY
2467 $$.t = TYPE_MAIN_DECL (parse_xref_tag (current_aggr, $2, 0));
2468 $$.new_type_flag = 1;
2470 | class_head_apparent_template %prec EMPTY
2473 $$.new_type_flag = 0;
2481 $$.t = parse_handle_class_head (current_aggr,
2490 $$.t = parse_handle_class_head (current_aggr,
2493 1, &$$.new_type_flag);
2495 | class_head_apparent_template '{'
2499 $$.new_type_flag = 0;
2500 if (TREE_CODE (TREE_TYPE ($1)) == RECORD_TYPE)
2501 /* We might be specializing a template with a different
2503 CLASSTYPE_DECLARED_CLASS (TREE_TYPE ($1))
2504 = (current_aggr == class_type_node);
2506 | class_head_apparent_template ':'
2510 $$.new_type_flag = 0;
2511 if (TREE_CODE (TREE_TYPE ($1)) == RECORD_TYPE)
2512 /* We might be specializing a template with a different
2514 CLASSTYPE_DECLARED_CLASS (TREE_TYPE ($1))
2515 = (current_aggr == class_type_node);
2517 | aggr identifier_defn '{'
2521 $$.t = parse_handle_class_head (current_aggr,
2523 1, &$$.new_type_flag);
2525 | aggr identifier_defn ':'
2529 $$.t = parse_handle_class_head (current_aggr,
2531 1, &$$.new_type_flag);
2536 $$.t = TYPE_MAIN_DECL (parse_xref_tag ($1,
2539 $$.new_type_flag = 0;
2544 maybe_base_class_list:
2548 { error ("no bases given following `:'");
2550 | ':' see_typename base_class_list
2556 | base_class_list ',' see_typename base_class
2557 { $$ = chainon ($$, $4); }
2562 { $$ = finish_base_specifier (access_default_node, $1); }
2563 | base_class_access_list see_typename base_class_1
2564 { $$ = finish_base_specifier ($1, $3); }
2570 $$ = error_mark_node; }
2572 { $$ = TREE_TYPE ($$); }
2575 base_class_access_list:
2576 VISSPEC see_typename
2577 | SCSPEC see_typename
2578 { if ($1 != ridpointers[(int)RID_VIRTUAL])
2579 error ("`%D' access", $1);
2580 $$ = access_default_virtual_node; }
2581 | base_class_access_list VISSPEC see_typename
2583 if ($1 != access_default_virtual_node)
2584 error ("multiple access specifiers");
2585 else if ($2 == access_public_node)
2586 $$ = access_public_virtual_node;
2587 else if ($2 == access_protected_node)
2588 $$ = access_protected_virtual_node;
2589 else /* $2 == access_private_node */
2590 $$ = access_private_virtual_node;
2592 | base_class_access_list SCSPEC see_typename
2593 { if ($2 != ridpointers[(int)RID_VIRTUAL])
2594 error ("`%D' access", $2);
2595 else if ($$ == access_public_node)
2596 $$ = access_public_virtual_node;
2597 else if ($$ == access_protected_node)
2598 $$ = access_protected_virtual_node;
2599 else if ($$ == access_private_node)
2600 $$ = access_private_virtual_node;
2602 error ("multiple `virtual' specifiers");
2606 opt.component_decl_list:
2607 | component_decl_list
2608 | opt.component_decl_list access_specifier component_decl_list
2609 | opt.component_decl_list access_specifier
2615 current_access_specifier = $1;
2619 /* Note: we no longer warn about the semicolon after a component_decl_list.
2620 ARM $9.2 says that the semicolon is optional, and therefore allowed. */
2621 component_decl_list:
2624 finish_member_declaration ($1);
2625 current_aggr = NULL_TREE;
2626 reset_type_access_control ();
2628 | component_decl_list component_decl
2630 finish_member_declaration ($2);
2631 current_aggr = NULL_TREE;
2632 reset_type_access_control ();
2637 component_decl_1 ';'
2638 | component_decl_1 '}'
2639 { error ("missing ';' before right brace");
2640 yyungetc ('}', 0); }
2641 /* C++: handle constructors, destructors and inline functions */
2642 /* note that INLINE is like a TYPESPEC */
2643 | fn_def2 ':' /* base_init compstmt */
2644 { $$ = finish_method ($$); }
2645 | fn_def2 TRY /* base_init compstmt */
2646 { $$ = finish_method ($$); }
2647 | fn_def2 RETURN_KEYWORD /* base_init compstmt */
2648 { $$ = finish_method ($$); }
2649 | fn_def2 '{' /* nodecls compstmt */
2650 { $$ = finish_method ($$); }
2653 | extension component_decl
2656 | template_header component_decl
2659 $$ = finish_member_template_decl ($2);
2661 /* The component was already processed. */
2664 finish_template_decl ($1);
2666 | template_header typed_declspecs ';'
2668 $$ = finish_member_class_template ($2.t);
2669 finish_template_decl ($1);
2676 /* Do not add a "typed_declspecs declarator" rule here for
2677 speed; we need to call grok_x_components for enums, so the
2678 speedup would be insignificant. */
2679 typed_declspecs components
2681 /* Most of the productions for component_decl only
2682 allow the creation of one new member, so we call
2683 finish_member_declaration in component_decl_list.
2684 For this rule and the next, however, there can be
2685 more than one member, e.g.:
2689 and we need the first member to be fully
2690 registered before the second is processed.
2691 Therefore, the rules for components take care of
2692 this processing. To avoid registering the
2693 components more than once, we send NULL_TREE up
2694 here; that lets finish_member_declaration know
2695 that there is nothing to do. */
2697 grok_x_components ($1.t);
2700 | declmods notype_components
2703 grok_x_components ($1.t);
2706 | notype_declarator maybeasm maybe_attribute maybe_init
2707 { $$ = grokfield ($$, NULL_TREE, $4, $2, $3); }
2708 | constructor_declarator maybeasm maybe_attribute maybe_init
2709 { $$ = grokfield ($$, NULL_TREE, $4, $2, $3); }
2710 | ':' expr_no_commas
2711 { $$ = grokbitfield (NULL_TREE, NULL_TREE, $2); }
2715 /* These rules introduce a reduce/reduce conflict; in
2716 typedef int foo, bar;
2720 should "A::foo" be declared as a function or "A::bar" as a data
2721 member? In other words, is "bar" an after_type_declarator or a
2723 | declmods component_constructor_declarator maybeasm maybe_attribute maybe_init
2724 { tree specs, attrs;
2725 split_specs_attrs ($1.t, &specs, &attrs);
2726 $$ = grokfield ($2, specs, $5, $3,
2727 chainon ($4, attrs)); }
2728 | component_constructor_declarator maybeasm maybe_attribute maybe_init
2729 { $$ = grokfield ($$, NULL_TREE, $4, $2, $3); }
2731 { $$ = do_class_using_decl ($1); }
2734 /* The case of exactly one component is handled directly by component_decl. */
2737 /* empty: possibly anonymous */
2739 | component_declarator0
2741 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2742 $1 = finish_member_template_decl ($1);
2743 finish_member_declaration ($1);
2746 | components ',' component_declarator
2748 check_multiple_declarators ();
2749 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2750 $3 = finish_member_template_decl ($3);
2751 finish_member_declaration ($3);
2757 /* empty: possibly anonymous */
2759 | notype_component_declarator0
2761 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2762 $1 = finish_member_template_decl ($1);
2763 finish_member_declaration ($1);
2766 | notype_components ',' notype_component_declarator
2768 check_multiple_declarators ();
2769 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2770 $3 = finish_member_template_decl ($3);
2771 finish_member_declaration ($3);
2776 component_declarator0:
2777 after_type_component_declarator0
2778 | notype_component_declarator0
2781 component_declarator:
2782 after_type_component_declarator
2783 | notype_component_declarator
2786 after_type_component_declarator0:
2787 after_type_declarator maybeasm maybe_attribute maybe_init
2788 { $$ = parse_field0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2790 | tTYPENAME ':' expr_no_commas maybe_attribute
2791 { $$ = parse_bitfield0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2795 notype_component_declarator0:
2796 notype_declarator maybeasm maybe_attribute maybe_init
2797 { $$ = parse_field0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2799 | constructor_declarator maybeasm maybe_attribute maybe_init
2800 { $$ = parse_field0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2802 | IDENTIFIER ':' expr_no_commas maybe_attribute
2803 { $$ = parse_bitfield0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2805 | ':' expr_no_commas maybe_attribute
2806 { $$ = parse_bitfield0 (NULL_TREE, $<ftype>0.t,
2807 $<ftype>0.lookups, $3, $2); }
2810 after_type_component_declarator:
2811 after_type_declarator maybeasm maybe_attribute maybe_init
2812 { $$ = parse_field ($1, $3, $2, $4); }
2813 | tTYPENAME ':' expr_no_commas maybe_attribute
2814 { $$ = parse_bitfield ($1, $4, $3); }
2817 notype_component_declarator:
2818 notype_declarator maybeasm maybe_attribute maybe_init
2819 { $$ = parse_field ($1, $3, $2, $4); }
2820 | IDENTIFIER ':' expr_no_commas maybe_attribute
2821 { $$ = parse_bitfield ($1, $4, $3); }
2822 | ':' expr_no_commas maybe_attribute
2823 { $$ = parse_bitfield (NULL_TREE, $3, $2); }
2827 enumlist maybecomma_warn
2831 /* We chain the enumerators in reverse order.
2832 Because of the way enums are built, the order is
2833 insignificant. Take advantage of this fact. */
2837 | enumlist ',' enumerator
2842 { build_enumerator ($1, NULL_TREE, current_enum_type); }
2843 | identifier '=' expr_no_commas
2844 { build_enumerator ($1, $3, current_enum_type); }
2847 /* ISO new-type-id (5.3.4) */
2849 type_specifier_seq new_declarator
2850 { $$.t = build_tree_list ($1.t, $2);
2851 $$.new_type_flag = $1.new_type_flag; }
2852 | type_specifier_seq %prec EMPTY
2853 { $$.t = build_tree_list ($1.t, NULL_TREE);
2854 $$.new_type_flag = $1.new_type_flag; }
2855 /* GNU extension to allow arrays of arbitrary types with
2856 non-constant dimension. */
2857 | '(' type_id ')' '[' expr ']'
2860 pedwarn ("ISO C++ forbids array dimensions with parenthesized type in new");
2861 $$.t = build_nt (ARRAY_REF, TREE_VALUE ($2.t), $5);
2862 $$.t = build_tree_list (TREE_PURPOSE ($2.t), $$.t);
2863 $$.new_type_flag = $2.new_type_flag;
2868 /* empty */ %prec EMPTY
2870 | cv_qualifiers CV_QUALIFIER
2871 { $$ = tree_cons (NULL_TREE, $2, $$); }
2874 nonempty_cv_qualifiers:
2876 { $$.t = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
2877 $$.new_type_flag = 0; }
2878 | nonempty_cv_qualifiers CV_QUALIFIER
2879 { $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
2880 $$.new_type_flag = $1.new_type_flag; }
2881 | attributes %prec EMPTY
2882 { $$.t = hash_tree_cons ($1, NULL_TREE, NULL_TREE);
2883 $$.new_type_flag = 0; }
2884 | nonempty_cv_qualifiers attributes %prec EMPTY
2885 { $$.t = hash_tree_cons ($2, NULL_TREE, $1.t);
2886 $$.new_type_flag = $1.new_type_flag; }
2889 /* These rules must follow the rules for function declarations
2890 and component declarations. That way, longer rules are preferred. */
2892 /* An expression which will not live on the momentary obstack. */
2894 '(' nonnull_exprlist ')'
2899 { $$ = empty_parms (); }
2904 /* A declarator that is allowed only after an explicit typespec. */
2906 after_type_declarator_intern:
2907 after_type_declarator
2908 | attributes after_type_declarator
2910 /* Provide support for '(' attributes '*' declarator ')'
2912 $$ = tree_cons ($1, $2, NULL_TREE);
2916 /* may all be followed by prec '.' */
2917 after_type_declarator:
2918 '*' nonempty_cv_qualifiers after_type_declarator_intern %prec UNARY
2919 { $$ = make_pointer_declarator ($2.t, $3); }
2920 | '&' nonempty_cv_qualifiers after_type_declarator_intern %prec UNARY
2921 { $$ = make_reference_declarator ($2.t, $3); }
2922 | '*' after_type_declarator_intern %prec UNARY
2923 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2924 | '&' after_type_declarator_intern %prec UNARY
2925 { $$ = make_reference_declarator (NULL_TREE, $2); }
2926 | ptr_to_mem cv_qualifiers after_type_declarator_intern
2927 { tree arg = make_pointer_declarator ($2, $3);
2928 $$ = build_nt (SCOPE_REF, $1, arg);
2930 | direct_after_type_declarator
2933 direct_after_type_declarator:
2934 direct_after_type_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2935 { $$ = make_call_declarator ($$, $2, $3, $4); }
2936 | direct_after_type_declarator '[' expr ']'
2937 { $$ = build_nt (ARRAY_REF, $$, $3); }
2938 | direct_after_type_declarator '[' ']'
2939 { $$ = build_nt (ARRAY_REF, $$, NULL_TREE); }
2940 | '(' after_type_declarator_intern ')'
2942 | nested_name_specifier type_name %prec EMPTY
2943 { push_nested_class ($1, 3);
2944 $$ = build_nt (SCOPE_REF, $$, $2);
2945 TREE_COMPLEXITY ($$) = current_class_depth; }
2946 | type_name %prec EMPTY
2950 type_name %prec EMPTY
2952 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2954 $$ = lookup_name ($1, 1);
2955 maybe_note_name_used_in_class ($1, $$);
2960 | global_scope type_name
2962 if (TREE_CODE ($2) == IDENTIFIER_NODE)
2963 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
2966 got_scope = NULL_TREE;
2973 | global_scope nested_type
2978 nested_name_specifier type_name %prec EMPTY
2979 { $$ = get_type_decl ($2); }
2982 /* A declarator allowed whether or not there has been
2983 an explicit typespec. These cannot redeclare a typedef-name. */
2985 notype_declarator_intern:
2987 | attributes notype_declarator
2989 /* Provide support for '(' attributes '*' declarator ')'
2991 $$ = tree_cons ($1, $2, NULL_TREE);
2996 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2997 { $$ = make_pointer_declarator ($2.t, $3); }
2998 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2999 { $$ = make_reference_declarator ($2.t, $3); }
3000 | '*' notype_declarator_intern %prec UNARY
3001 { $$ = make_pointer_declarator (NULL_TREE, $2); }
3002 | '&' notype_declarator_intern %prec UNARY
3003 { $$ = make_reference_declarator (NULL_TREE, $2); }
3004 | ptr_to_mem cv_qualifiers notype_declarator_intern
3005 { tree arg = make_pointer_declarator ($2, $3);
3006 $$ = build_nt (SCOPE_REF, $1, arg);
3008 | direct_notype_declarator
3011 complex_notype_declarator:
3012 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
3013 { $$ = make_pointer_declarator ($2.t, $3); }
3014 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
3015 { $$ = make_reference_declarator ($2.t, $3); }
3016 | '*' complex_notype_declarator %prec UNARY
3017 { $$ = make_pointer_declarator (NULL_TREE, $2); }
3018 | '&' complex_notype_declarator %prec UNARY
3019 { $$ = make_reference_declarator (NULL_TREE, $2); }
3020 | ptr_to_mem cv_qualifiers notype_declarator_intern
3021 { tree arg = make_pointer_declarator ($2, $3);
3022 $$ = build_nt (SCOPE_REF, $1, arg);
3024 | complex_direct_notype_declarator
3027 complex_direct_notype_declarator:
3028 direct_notype_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
3029 { $$ = make_call_declarator ($$, $2, $3, $4); }
3030 | '(' complex_notype_declarator ')'
3032 | direct_notype_declarator '[' expr ']'
3033 { $$ = build_nt (ARRAY_REF, $$, $3); }
3034 | direct_notype_declarator '[' ']'
3035 { $$ = build_nt (ARRAY_REF, $$, NULL_TREE); }
3036 | notype_qualified_id
3037 { enter_scope_of ($1); }
3038 | global_scope notype_qualified_id
3039 { enter_scope_of ($2); $$ = $2;}
3040 | global_scope notype_unqualified_id
3041 { $$ = build_nt (SCOPE_REF, global_namespace, $2);
3042 enter_scope_of ($$);
3044 | nested_name_specifier notype_template_declarator
3045 { got_scope = NULL_TREE;
3046 $$ = build_nt (SCOPE_REF, $1, $2);
3047 enter_scope_of ($$);
3052 nested_name_specifier unqualified_id
3053 { got_scope = NULL_TREE;
3054 $$ = build_nt (SCOPE_REF, $$, $2); }
3055 | nested_name_specifier object_template_id
3056 { got_scope = NULL_TREE;
3057 $$ = build_nt (SCOPE_REF, $1, $2); }
3060 notype_qualified_id:
3061 nested_name_specifier notype_unqualified_id
3062 { got_scope = NULL_TREE;
3063 $$ = build_nt (SCOPE_REF, $$, $2); }
3064 | nested_name_specifier object_template_id
3065 { got_scope = NULL_TREE;
3066 $$ = build_nt (SCOPE_REF, $1, $2); }
3071 | global_scope notype_qualified_id
3076 typespec '(' nonnull_exprlist ')'
3077 { $$ = build_functional_cast ($1.t, $3); }
3078 | typespec '(' expr_or_declarator_intern ')'
3079 { $$ = reparse_decl_as_expr ($1.t, $3); }
3080 | typespec fcast_or_absdcl %prec EMPTY
3081 { $$ = reparse_absdcl_as_expr ($1.t, $2); }
3087 | template_type %prec EMPTY
3090 nested_name_specifier:
3091 nested_name_specifier_1
3092 | nested_name_specifier nested_name_specifier_1
3094 | nested_name_specifier TEMPLATE explicit_template_type SCOPE
3096 = make_typename_type ($1, $3, tf_error | tf_parsing); }
3097 /* Error handling per Core 125. */
3098 | nested_name_specifier IDENTIFIER SCOPE
3100 = make_typename_type ($1, $2, tf_error | tf_parsing); }
3101 | nested_name_specifier PTYPENAME SCOPE
3103 = make_typename_type ($1, $2, tf_error | tf_parsing); }
3106 /* Why the @#$%^& do type_name and notype_identifier need to be expanded
3107 inline here?!? (jason) */
3108 nested_name_specifier_1:
3111 if (TREE_CODE ($1) == IDENTIFIER_NODE)
3114 maybe_note_name_used_in_class ($1, $$);
3117 complete_type (TYPE_MAIN_VARIANT (TREE_TYPE ($$)));
3121 if (TREE_CODE ($1) == IDENTIFIER_NODE)
3123 got_scope = $$ = TREE_TYPE ($$);
3127 if (TREE_CODE ($$) == IDENTIFIER_NODE)
3131 | template_type SCOPE
3132 { got_scope = $$ = complete_type (TREE_TYPE ($1)); }
3137 | global_scope typename_sub0
3142 typename_sub1 identifier %prec EMPTY
3145 $$ = make_typename_type ($1, $2, tf_error | tf_parsing);
3146 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
3147 error ("`%T' is not a class or namespace", $2);
3151 if (TREE_CODE ($$) == TYPE_DECL)
3152 $$ = TREE_TYPE ($$);
3155 | typename_sub1 template_type %prec EMPTY
3156 { $$ = TREE_TYPE ($2); }
3157 | typename_sub1 explicit_template_type %prec EMPTY
3158 { $$ = make_typename_type ($1, $2, tf_error | tf_parsing); }
3159 | typename_sub1 TEMPLATE explicit_template_type %prec EMPTY
3160 { $$ = make_typename_type ($1, $3, tf_error | tf_parsing); }
3166 if (TREE_CODE ($1) == IDENTIFIER_NODE)
3167 error ("`%T' is not a class or namespace", $1);
3168 else if (TREE_CODE ($1) == TYPE_DECL)
3169 $$ = TREE_TYPE ($1);
3171 | typename_sub1 typename_sub2
3174 $$ = make_typename_type ($1, $2, tf_error | tf_parsing);
3175 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
3176 error ("`%T' is not a class or namespace", $2);
3180 if (TREE_CODE ($$) == TYPE_DECL)
3181 $$ = TREE_TYPE ($$);
3184 | typename_sub1 explicit_template_type SCOPE
3186 = make_typename_type ($1, $2, tf_error | tf_parsing); }
3187 | typename_sub1 TEMPLATE explicit_template_type SCOPE
3189 = make_typename_type ($1, $3, tf_error | tf_parsing); }
3192 /* This needs to return a TYPE_DECL for simple names so that we don't
3193 forget what name was used. */
3197 if (TREE_CODE ($1) != TYPE_DECL)
3200 /* Retrieve the type for the identifier, which might involve
3201 some computation. */
3202 got_scope = complete_type (TREE_TYPE ($$));
3204 if ($$ == error_mark_node)
3205 error ("`%T' is not a class or namespace", $1);
3209 if (TREE_CODE ($1) != TYPE_DECL)
3211 got_scope = complete_type (TREE_TYPE ($$));
3213 | template_type SCOPE
3214 { got_scope = $$ = complete_type (TREE_TYPE ($$)); }
3219 if (TREE_CODE ($$) == IDENTIFIER_NODE)
3225 explicit_template_type:
3226 identifier '<' template_arg_list_opt template_close_bracket
3227 { $$ = build_min_nt (TEMPLATE_ID_EXPR, $1, $3); }
3231 global_scope type_name
3233 if (TREE_CODE ($2) == IDENTIFIER_NODE)
3234 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
3237 got_scope = NULL_TREE;
3240 | global_scope nested_type
3245 nested_name_specifier '*'
3246 { got_scope = NULL_TREE; }
3247 | global_scope nested_name_specifier '*'
3248 { $$ = $2; got_scope = NULL_TREE; }
3251 /* All uses of explicit global scope must go through this nonterminal so
3252 that got_scope will be set before yylex is called to get the next token. */
3255 { got_scope = void_type_node; }
3258 /* ISO new-declarator (5.3.4) */
3260 '*' cv_qualifiers new_declarator
3261 { $$ = make_pointer_declarator ($2, $3); }
3262 | '*' cv_qualifiers %prec EMPTY
3263 { $$ = make_pointer_declarator ($2, NULL_TREE); }
3264 | '&' cv_qualifiers new_declarator %prec EMPTY
3265 { $$ = make_reference_declarator ($2, $3); }
3266 | '&' cv_qualifiers %prec EMPTY
3267 { $$ = make_reference_declarator ($2, NULL_TREE); }
3268 | ptr_to_mem cv_qualifiers %prec EMPTY
3269 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3270 $$ = build_nt (SCOPE_REF, $1, arg);
3272 | ptr_to_mem cv_qualifiers new_declarator
3273 { tree arg = make_pointer_declarator ($2, $3);
3274 $$ = build_nt (SCOPE_REF, $1, arg);
3276 | direct_new_declarator %prec EMPTY
3279 /* ISO direct-new-declarator (5.3.4) */
3280 direct_new_declarator:
3282 { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
3283 | direct_new_declarator '[' expr ']'
3284 { $$ = build_nt (ARRAY_REF, $$, $3); }
3291 /* Provide support for '(' attributes '*' declarator ')'
3293 $$ = tree_cons ($1, $2, NULL_TREE);
3297 /* ISO abstract-declarator (8.1) */
3299 '*' nonempty_cv_qualifiers absdcl_intern
3300 { $$ = make_pointer_declarator ($2.t, $3); }
3302 { $$ = make_pointer_declarator (NULL_TREE, $2); }
3303 | '*' nonempty_cv_qualifiers %prec EMPTY
3304 { $$ = make_pointer_declarator ($2.t, NULL_TREE); }
3306 { $$ = make_pointer_declarator (NULL_TREE, NULL_TREE); }
3307 | '&' nonempty_cv_qualifiers absdcl_intern
3308 { $$ = make_reference_declarator ($2.t, $3); }
3310 { $$ = make_reference_declarator (NULL_TREE, $2); }
3311 | '&' nonempty_cv_qualifiers %prec EMPTY
3312 { $$ = make_reference_declarator ($2.t, NULL_TREE); }
3314 { $$ = make_reference_declarator (NULL_TREE, NULL_TREE); }
3315 | ptr_to_mem cv_qualifiers %prec EMPTY
3316 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3317 $$ = build_nt (SCOPE_REF, $1, arg);
3319 | ptr_to_mem cv_qualifiers absdcl_intern
3320 { tree arg = make_pointer_declarator ($2, $3);
3321 $$ = build_nt (SCOPE_REF, $1, arg);
3323 | direct_abstract_declarator %prec EMPTY
3326 /* ISO direct-abstract-declarator (8.1) */
3327 direct_abstract_declarator:
3328 '(' absdcl_intern ')'
3330 /* `(typedef)1' is `int'. */
3331 | direct_abstract_declarator '(' parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3332 { $$ = make_call_declarator ($$, $3, $5, $6); }
3333 | direct_abstract_declarator LEFT_RIGHT cv_qualifiers exception_specification_opt %prec '.'
3334 { $$ = make_call_declarator ($$, empty_parms (), $3, $4); }
3335 | direct_abstract_declarator '[' expr ']' %prec '.'
3336 { $$ = build_nt (ARRAY_REF, $$, $3); }
3337 | direct_abstract_declarator '[' ']' %prec '.'
3338 { $$ = build_nt (ARRAY_REF, $$, NULL_TREE); }
3339 | '(' complex_parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3340 { $$ = make_call_declarator (NULL_TREE, $2, $4, $5); }
3341 | regcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3342 { set_quals_and_spec ($$, $2, $3); }
3343 | fcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3344 { set_quals_and_spec ($$, $2, $3); }
3345 | '[' expr ']' %prec '.'
3346 { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
3348 { $$ = build_nt (ARRAY_REF, NULL_TREE, NULL_TREE); }
3351 /* For C++, decls and stmts can be intermixed, so we don't need to
3352 have a special rule that won't start parsing the stmt section
3353 until we have a stmt that parses without errors. */
3366 /* Read zero or more forward-declarations for labels
3367 that nested functions can jump to. */
3372 pedwarn ("ISO C++ forbids label declarations"); }
3377 | label_decls label_decl
3381 LABEL identifiers_or_typenames ';'
3385 finish_label_decl (TREE_VALUE ($2));
3386 $2 = TREE_CHAIN ($2);
3391 compstmt_or_stmtexpr:
3393 { $<ttype>$ = begin_compound_stmt (0); }
3395 { STMT_LINENO ($<ttype>3) = $1;
3396 finish_compound_stmt (0, $<ttype>3); }
3400 compstmt_or_stmtexpr
3401 { last_expr_type = NULL_TREE; }
3406 { $<ttype>$ = begin_if_stmt ();
3407 cond_stmt_keyword = "if"; }
3409 { finish_if_stmt_cond ($3, $<ttype>2); }
3410 implicitly_scoped_stmt
3412 finish_then_clause ($<ttype>2); }
3415 implicitly_scoped_stmt:
3418 { $<ttype>$ = begin_compound_stmt (0); }
3419 save_lineno simple_stmt
3420 { STMT_LINENO ($<ttype>1) = $2;
3421 if ($3) STMT_LINENO ($3) = $2;
3422 finish_compound_stmt (0, $<ttype>1); }
3427 | save_lineno simple_stmt
3428 { if ($2) STMT_LINENO ($2) = $1; }
3436 { $$ = finish_expr_stmt ($1); }
3438 { begin_else_clause (); }
3439 implicitly_scoped_stmt
3442 finish_else_clause ($1);
3445 | simple_if %prec IF
3447 finish_if_stmt (); }
3450 $<ttype>$ = begin_while_stmt ();
3451 cond_stmt_keyword = "while";
3454 { finish_while_stmt_cond ($3, $<ttype>2); }
3455 implicitly_scoped_stmt
3457 finish_while_stmt ($<ttype>2); }
3459 { $<ttype>$ = begin_do_stmt (); }
3460 implicitly_scoped_stmt WHILE
3462 finish_do_body ($<ttype>2);
3463 cond_stmt_keyword = "do";
3465 paren_expr_or_null ';'
3467 finish_do_stmt ($6, $<ttype>2); }
3469 { $<ttype>$ = begin_for_stmt (); }
3470 '(' for.init.statement
3471 { finish_for_init_stmt ($<ttype>2); }
3473 { finish_for_cond ($6, $<ttype>2); }
3475 { finish_for_expr ($9, $<ttype>2); }
3476 implicitly_scoped_stmt
3478 finish_for_stmt ($<ttype>2); }
3480 { $<ttype>$ = begin_switch_stmt (); }
3482 { finish_switch_cond ($4, $<ttype>2); }
3483 implicitly_scoped_stmt
3485 finish_switch_stmt ($<ttype>2); }
3486 | CASE expr_no_commas ':'
3487 { $<ttype>$ = finish_case_label ($2, NULL_TREE); }
3490 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
3491 { $<ttype>$ = finish_case_label ($2, $4); }
3495 { $<ttype>$ = finish_case_label (NULL_TREE, NULL_TREE); }
3499 { $$ = finish_break_stmt (); }
3501 { $$ = finish_continue_stmt (); }
3502 | RETURN_KEYWORD ';'
3503 { $$ = finish_return_stmt (NULL_TREE); }
3504 | RETURN_KEYWORD expr ';'
3505 { $$ = finish_return_stmt ($2); }
3506 | asm_keyword maybe_cv_qualifier '(' STRING ')' ';'
3507 { $$ = finish_asm_stmt ($2, $4, NULL_TREE, NULL_TREE,
3509 ASM_INPUT_P ($$) = 1; }
3510 /* This is the case with just output operands. */
3511 | asm_keyword maybe_cv_qualifier '(' STRING ':' asm_operands ')' ';'
3512 { $$ = finish_asm_stmt ($2, $4, $6, NULL_TREE, NULL_TREE); }
3513 /* This is the case with input operands as well. */
3514 | asm_keyword maybe_cv_qualifier '(' STRING ':' asm_operands ':'
3515 asm_operands ')' ';'
3516 { $$ = finish_asm_stmt ($2, $4, $6, $8, NULL_TREE); }
3517 | asm_keyword maybe_cv_qualifier '(' STRING SCOPE asm_operands ')' ';'
3518 { $$ = finish_asm_stmt ($2, $4, NULL_TREE, $6, NULL_TREE); }
3519 /* This is the case with clobbered registers as well. */
3520 | asm_keyword maybe_cv_qualifier '(' STRING ':' asm_operands ':'
3521 asm_operands ':' asm_clobbers ')' ';'
3522 { $$ = finish_asm_stmt ($2, $4, $6, $8, $10); }
3523 | asm_keyword maybe_cv_qualifier '(' STRING SCOPE asm_operands ':'
3524 asm_clobbers ')' ';'
3525 { $$ = finish_asm_stmt ($2, $4, NULL_TREE, $6, $8); }
3526 | asm_keyword maybe_cv_qualifier '(' STRING ':' asm_operands SCOPE
3527 asm_clobbers ')' ';'
3528 { $$ = finish_asm_stmt ($2, $4, $6, NULL_TREE, $8); }
3532 pedwarn ("ISO C++ forbids computed gotos");
3533 $$ = finish_goto_stmt ($3);
3535 | GOTO identifier ';'
3536 { $$ = finish_goto_stmt ($2); }
3540 { error ("label must be followed by statement");
3550 | namespace_using_decl
3551 { do_local_using_decl ($1);
3559 { $<ttype>$ = begin_function_try_block (); }
3561 { finish_function_try_block ($<ttype>2); }
3563 { finish_function_handler_sequence ($<ttype>2); }
3568 { $<ttype>$ = begin_try_block (); }
3570 { finish_try_block ($<ttype>2); }
3572 { finish_handler_sequence ($<ttype>2); }
3577 | handler_seq handler
3579 { /* Generate a fake handler block to avoid later aborts. */
3580 tree fake_handler = begin_handler ();
3581 finish_handler_parms (NULL_TREE, fake_handler);
3582 finish_handler (fake_handler);
3583 $<ttype>$ = fake_handler;
3585 error ("must have at least one catch per try block");
3591 { $<ttype>$ = begin_handler (); }
3593 { finish_handler_parms ($3, $<ttype>2); }
3595 { finish_handler ($<ttype>2); }
3599 typed_typespecs %prec EMPTY
3600 | nonempty_cv_qualifiers %prec EMPTY
3606 /* This doesn't allow reference parameters, the below does.
3607 | '(' type_specifier_seq absdcl ')'
3608 { check_for_new_type ("inside exception declarations", $2);
3609 expand_start_catch_block ($2.t, $3); }
3610 | '(' type_specifier_seq ')'
3611 { check_for_new_type ("inside exception declarations", $2);
3612 expand_start_catch_block ($2.t, NULL_TREE); }
3613 | '(' type_specifier_seq notype_declarator ')'
3614 { check_for_new_type ("inside exception declarations", $2);
3615 expand_start_catch_block ($2.t, $3); }
3616 | '(' typed_typespecs after_type_declarator ')'
3617 { check_for_new_type ("inside exception declarations", $2);
3618 expand_start_catch_block ($2.t, $3); }
3619 This allows reference parameters... */
3622 check_for_new_type ("inside exception declarations", $2);
3623 $$ = start_handler_parms (TREE_PURPOSE ($2.t),
3630 { finish_label_stmt ($1); }
3632 { finish_label_stmt ($1); }
3634 { finish_label_stmt ($1); }
3636 { finish_label_stmt ($1); }
3641 { finish_expr_stmt ($1); }
3645 pedwarn ("ISO C++ forbids compound statements inside for initializations");
3649 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
3665 /* These are the operands other than the first string and colon
3666 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
3670 | nonnull_asm_operands
3673 nonnull_asm_operands:
3675 | nonnull_asm_operands ',' asm_operand
3676 { $$ = chainon ($$, $3); }
3681 { $$ = build_tree_list (build_tree_list (NULL_TREE, $1), $3); }
3682 | '[' identifier ']' STRING '(' expr ')'
3683 { $2 = build_string (IDENTIFIER_LENGTH ($2),
3684 IDENTIFIER_POINTER ($2));
3685 $$ = build_tree_list (build_tree_list ($2, $4), $6); }
3690 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);}
3691 | asm_clobbers ',' STRING
3692 { $$ = tree_cons (NULL_TREE, $3, $1); }
3695 /* This is what appears inside the parens in a function declarator.
3696 Its value is represented in the format that grokdeclarator expects.
3698 In C++, declaring a function with no parameters
3699 means that that function takes *no* parameters. */
3708 { $$ = finish_parmlist (build_tree_list (NULL_TREE, $1.t), 0);
3709 check_for_new_type ("inside parameter list", $1); }
3712 /* This nonterminal does not include the common sequence '(' type_id ')',
3713 as it is ambiguous and must be disambiguated elsewhere. */
3716 { $$ = finish_parmlist ($$, 0); }
3717 | parms_comma ELLIPSIS
3718 { $$ = finish_parmlist ($1, 1); }
3719 /* C++ allows an ellipsis without a separating ',' */
3721 { $$ = finish_parmlist ($1, 1); }
3723 { $$ = finish_parmlist (build_tree_list (NULL_TREE,
3726 { $$ = finish_parmlist (NULL_TREE, 1); }
3729 /* This helps us recover from really nasty
3730 parse errors, for example, a missing right
3732 yyerror ("possibly missing ')'");
3733 $$ = finish_parmlist ($1, 0);
3739 /* This helps us recover from really nasty
3740 parse errors, for example, a missing right
3742 yyerror ("possibly missing ')'");
3743 $$ = finish_parmlist (build_tree_list (NULL_TREE,
3750 /* A default argument to a */
3753 { maybe_snarf_defarg (); }
3763 /* A nonempty list of parameter declarations or type names. */
3766 { check_for_new_type ("in a parameter list", $1);
3767 $$ = build_tree_list (NULL_TREE, $1.t); }
3769 { check_for_new_type ("in a parameter list", $1);
3770 $$ = build_tree_list ($2, $1.t); }
3771 | parms_comma full_parm
3772 { check_for_new_type ("in a parameter list", $2);
3773 $$ = chainon ($$, $2.t); }
3774 | parms_comma bad_parm
3775 { $$ = chainon ($$, build_tree_list (NULL_TREE, $2)); }
3776 | parms_comma bad_parm '=' init
3777 { $$ = chainon ($$, build_tree_list ($4, $2)); }
3783 { check_for_new_type ("in a parameter list", $1);
3784 $$ = build_tree_list (NULL_TREE, $1.t); }
3787 /* A single parameter declaration or parameter type name,
3788 as found in a parmlist. */
3790 /* Here we expand typed_declspecs inline to avoid mis-parsing of
3791 TYPESPEC IDENTIFIER. */
3792 typed_declspecs1 declarator
3793 { $$.new_type_flag = $1.new_type_flag;
3794 $$.t = build_tree_list ($1.t, $2); }
3795 | typed_typespecs declarator
3796 { $$.t = build_tree_list ($1.t, $2);
3797 $$.new_type_flag = $1.new_type_flag; }
3798 | typespec declarator
3799 { $$.t = build_tree_list (build_tree_list (NULL_TREE, $1.t),
3801 $$.new_type_flag = $1.new_type_flag; }
3802 | typed_declspecs1 absdcl
3803 { $$.t = build_tree_list ($1.t, $2);
3804 $$.new_type_flag = $1.new_type_flag; }
3805 | typed_declspecs1 %prec EMPTY
3806 { $$.t = build_tree_list ($1.t, NULL_TREE);
3807 $$.new_type_flag = $1.new_type_flag; }
3808 | declmods notype_declarator
3809 { $$.t = build_tree_list ($1.t, $2);
3810 $$.new_type_flag = 0; }
3815 { $$.t = build_tree_list (NULL_TREE, $1.t);
3816 $$.new_type_flag = $1.new_type_flag; }
3818 { $$.t = build_tree_list ($2, $1.t);
3819 $$.new_type_flag = $1.new_type_flag; }
3828 /* empty */ %prec EMPTY
3829 { see_typename (); }
3833 /* empty */ %prec EMPTY
3835 error ("type specifier omitted for parameter");
3836 $$ = build_tree_list (integer_type_node, NULL_TREE);
3840 if (TREE_CODE ($$) == SCOPE_REF)
3842 if (TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TYPE_PARM
3843 || TREE_CODE (TREE_OPERAND ($$, 0)) == BOUND_TEMPLATE_TEMPLATE_PARM)
3844 error ("`%E' is not a type, use `typename %E' to make it one", $$);
3846 error ("no type `%D' in `%T'", TREE_OPERAND ($$, 1), TREE_OPERAND ($$, 0));
3849 error ("type specifier omitted for parameter `%E'", $$);
3850 $$ = build_tree_list (integer_type_node, $$);
3855 IDENTIFIER template_arg_list_ignore IDENTIFIER arg_list_ignore ';'
3857 error("'%D' is used as a type, but is not defined as a type.", $1);
3858 $3 = error_mark_node;
3862 template_arg_list_ignore:
3863 '<' template_arg_list_opt template_close_bracket
3869 '(' nonnull_exprlist ')'
3874 exception_specification_opt:
3875 /* empty */ %prec EMPTY
3877 | THROW '(' ansi_raise_identifiers ')' %prec EMPTY
3879 | THROW LEFT_RIGHT %prec EMPTY
3880 { $$ = empty_except_spec; }
3883 ansi_raise_identifier:
3886 check_for_new_type ("exception specifier", $1);
3887 $$ = groktypename ($1.t);
3890 { $$ = error_mark_node; }
3893 ansi_raise_identifiers:
3894 ansi_raise_identifier
3895 { $$ = add_exception_specifier (NULL_TREE, $1, 1); }
3896 | ansi_raise_identifiers ',' ansi_raise_identifier
3897 { $$ = add_exception_specifier ($1, $3, 1); }
3900 conversion_declarator:
3901 /* empty */ %prec EMPTY
3903 | '*' cv_qualifiers conversion_declarator
3904 { $$ = make_pointer_declarator ($2, $3); }
3905 | '&' cv_qualifiers conversion_declarator
3906 { $$ = make_reference_declarator ($2, $3); }
3907 | ptr_to_mem cv_qualifiers conversion_declarator
3908 { tree arg = make_pointer_declarator ($2, $3);
3909 $$ = build_nt (SCOPE_REF, $1, arg);
3916 saved_scopes = tree_cons (got_scope, got_object, saved_scopes);
3917 TREE_LANG_FLAG_0 (saved_scopes) = looking_for_typename;
3918 /* We look for conversion-type-id's in both the class and current
3919 scopes, just as for ID in 'ptr->ID::'. */
3920 looking_for_typename = 1;
3921 got_object = got_scope;
3922 got_scope = NULL_TREE;
3927 { got_scope = TREE_PURPOSE (saved_scopes);
3928 got_object = TREE_VALUE (saved_scopes);
3929 looking_for_typename = TREE_LANG_FLAG_0 (saved_scopes);
3930 saved_scopes = TREE_CHAIN (saved_scopes);
3935 operator '*' unoperator
3936 { $$ = frob_opname (ansi_opname (MULT_EXPR)); }
3937 | operator '/' unoperator
3938 { $$ = frob_opname (ansi_opname (TRUNC_DIV_EXPR)); }
3939 | operator '%' unoperator
3940 { $$ = frob_opname (ansi_opname (TRUNC_MOD_EXPR)); }
3941 | operator '+' unoperator
3942 { $$ = frob_opname (ansi_opname (PLUS_EXPR)); }
3943 | operator '-' unoperator
3944 { $$ = frob_opname (ansi_opname (MINUS_EXPR)); }
3945 | operator '&' unoperator
3946 { $$ = frob_opname (ansi_opname (BIT_AND_EXPR)); }
3947 | operator '|' unoperator
3948 { $$ = frob_opname (ansi_opname (BIT_IOR_EXPR)); }
3949 | operator '^' unoperator
3950 { $$ = frob_opname (ansi_opname (BIT_XOR_EXPR)); }
3951 | operator '~' unoperator
3952 { $$ = frob_opname (ansi_opname (BIT_NOT_EXPR)); }
3953 | operator ',' unoperator
3954 { $$ = frob_opname (ansi_opname (COMPOUND_EXPR)); }
3955 | operator ARITHCOMPARE unoperator
3956 { $$ = frob_opname (ansi_opname ($2)); }
3957 | operator '<' unoperator
3958 { $$ = frob_opname (ansi_opname (LT_EXPR)); }
3959 | operator '>' unoperator
3960 { $$ = frob_opname (ansi_opname (GT_EXPR)); }
3961 | operator EQCOMPARE unoperator
3962 { $$ = frob_opname (ansi_opname ($2)); }
3963 | operator ASSIGN unoperator
3964 { $$ = frob_opname (ansi_assopname ($2)); }
3965 | operator '=' unoperator
3966 { $$ = frob_opname (ansi_assopname (NOP_EXPR)); }
3967 | operator LSHIFT unoperator
3968 { $$ = frob_opname (ansi_opname ($2)); }
3969 | operator RSHIFT unoperator
3970 { $$ = frob_opname (ansi_opname ($2)); }
3971 | operator PLUSPLUS unoperator
3972 { $$ = frob_opname (ansi_opname (POSTINCREMENT_EXPR)); }
3973 | operator MINUSMINUS unoperator
3974 { $$ = frob_opname (ansi_opname (PREDECREMENT_EXPR)); }
3975 | operator ANDAND unoperator
3976 { $$ = frob_opname (ansi_opname (TRUTH_ANDIF_EXPR)); }
3977 | operator OROR unoperator
3978 { $$ = frob_opname (ansi_opname (TRUTH_ORIF_EXPR)); }
3979 | operator '!' unoperator
3980 { $$ = frob_opname (ansi_opname (TRUTH_NOT_EXPR)); }
3981 | operator '?' ':' unoperator
3982 { $$ = frob_opname (ansi_opname (COND_EXPR)); }
3983 | operator MIN_MAX unoperator
3984 { $$ = frob_opname (ansi_opname ($2)); }
3985 | operator POINTSAT unoperator %prec EMPTY
3986 { $$ = frob_opname (ansi_opname (COMPONENT_REF)); }
3987 | operator POINTSAT_STAR unoperator %prec EMPTY
3988 { $$ = frob_opname (ansi_opname (MEMBER_REF)); }
3989 | operator LEFT_RIGHT unoperator
3990 { $$ = frob_opname (ansi_opname (CALL_EXPR)); }
3991 | operator '[' ']' unoperator
3992 { $$ = frob_opname (ansi_opname (ARRAY_REF)); }
3993 | operator NEW unoperator %prec EMPTY
3994 { $$ = frob_opname (ansi_opname (NEW_EXPR)); }
3995 | operator DELETE unoperator %prec EMPTY
3996 { $$ = frob_opname (ansi_opname (DELETE_EXPR)); }
3997 | operator NEW '[' ']' unoperator
3998 { $$ = frob_opname (ansi_opname (VEC_NEW_EXPR)); }
3999 | operator DELETE '[' ']' unoperator
4000 { $$ = frob_opname (ansi_opname (VEC_DELETE_EXPR)); }
4001 | operator type_specifier_seq conversion_declarator unoperator
4002 { $$ = frob_opname (grokoptypename ($2.t, $3)); }
4003 | operator error unoperator
4004 { $$ = frob_opname (ansi_opname (ERROR_MARK)); }
4007 /* The forced readahead in here is because we might be at the end of a
4008 line, and lineno won't be bumped until yylex absorbs the first token
4009 on the next line. */
4011 { if (yychar == YYEMPTY)
4019 debug_yytranslate (value)
4022 return yytname[YYTRANSLATE (value)];
4026 /* Free malloced parser stacks if necessary. */
4029 free_parser_stacks ()
4033 free (malloced_yyss);
4034 free (malloced_yyvs);
4038 /* Return the value corresponding to TOKEN in the global scope. */
4041 parse_scoped_id (token)
4046 id = make_node (CPLUS_BINDING);
4047 if (!qualified_lookup_using_namespace (token, global_namespace, id, 0))
4050 id = BINDING_VALUE (id);
4051 if (yychar == YYEMPTY)
4054 return do_scoped_id (token, id);
4057 /* AGGR may be either a type node (like class_type_node) or a
4058 TREE_LIST whose TREE_PURPOSE is a list of attributes and whose
4059 TREE_VALUE is a type node. Set *TAG_KIND and *ATTRIBUTES to
4060 represent the information encoded. */
4063 parse_split_aggr (tree aggr, enum tag_types *tag_kind, tree *attributes)
4065 if (TREE_CODE (aggr) == TREE_LIST)
4067 *attributes = TREE_PURPOSE (aggr);
4068 aggr = TREE_VALUE (aggr);
4071 *attributes = NULL_TREE;
4072 *tag_kind = (enum tag_types) tree_low_cst (aggr, 1);
4075 /* Like xref_tag, except that the AGGR may be either a type node (like
4076 class_type_node) or a TREE_LIST whose TREE_PURPOSE is a list of
4077 attributes and whose TREE_VALUE is a type node. */
4080 parse_xref_tag (tree aggr, tree name, int globalize)
4083 enum tag_types tag_kind;
4084 parse_split_aggr (aggr, &tag_kind, &attributes);
4085 return xref_tag (tag_kind, name, attributes, globalize);
4088 /* Like handle_class_head, but AGGR may be as for parse_xref_tag. */
4091 parse_handle_class_head (tree aggr, tree scope, tree id,
4092 int defn_p, int *new_type_p)
4095 enum tag_types tag_kind;
4096 parse_split_aggr (aggr, &tag_kind, &attributes);
4097 return handle_class_head (tag_kind, scope, id, attributes,
4098 defn_p, new_type_p);
4101 /* Like do_decl_instantiation, but the declarator has not yet been
4105 parse_decl_instantiation (tree declspecs, tree declarator, tree storage)
4107 tree decl = grokdeclarator (declarator, declspecs, NORMAL, 0, NULL);
4108 do_decl_instantiation (decl, storage);
4111 /* Like begin_function_definition, but SPECS_ATTRS is a combined list
4112 containing both a decl-specifier-seq and attributes. */
4115 parse_begin_function_definition (tree specs_attrs, tree declarator)
4120 split_specs_attrs (specs_attrs, &specs, &attrs);
4121 return begin_function_definition (specs, attrs, declarator);
4124 /* Like finish_call_expr, but the name for FN has not yet been
4128 parse_finish_call_expr (tree fn, tree args, int koenig)
4130 bool disallow_virtual;
4135 if (TREE_CODE (fn) == OFFSET_REF)
4136 return build_offset_ref_call_from_tree (fn, args);
4138 if (TREE_CODE (fn) == SCOPE_REF)
4143 scope = TREE_OPERAND (fn, 0);
4144 name = TREE_OPERAND (fn, 1);
4146 if (scope == error_mark_node || name == error_mark_node)
4147 return error_mark_node;
4148 if (!processing_template_decl)
4150 if (TREE_CODE (scope) == NAMESPACE_DECL)
4151 fn = lookup_namespace_name (scope, name);
4154 if (!COMPLETE_TYPE_P (scope) && !TYPE_BEING_DEFINED (scope))
4156 error ("incomplete type '%T' cannot be used to name a scope",
4158 return error_mark_node;
4160 else if (TREE_CODE (name) == TEMPLATE_ID_EXPR)
4163 template_args = TREE_OPERAND (name, 1);
4164 name = TREE_OPERAND (name, 0);
4168 template_id = NULL_TREE;
4169 template_args = NULL_TREE;
4172 if (BASELINK_P (name))
4176 if (TREE_CODE (name) == OVERLOAD)
4177 name = DECL_NAME (get_first_fn (name));
4178 fn = lookup_member (scope, name, /*protect=*/1,
4180 if (BASELINK_P (fn) && template_id)
4181 BASELINK_FUNCTIONS (fn)
4182 = build_nt (TEMPLATE_ID_EXPR,
4183 BASELINK_FUNCTIONS (fn),
4186 if (current_class_type)
4187 fn = (adjust_result_of_qualified_name_lookup
4188 (fn, scope, current_class_type));
4191 disallow_virtual = true;
4194 disallow_virtual = false;
4196 if (koenig && TREE_CODE (fn) == IDENTIFIER_NODE)
4198 /* Do the Koenig lookup. */
4199 fn = do_identifier (fn, 2, args);
4200 /* If name lookup didn't find any matching declarations, we've
4201 got an unbound identifier. */
4202 if (TREE_CODE (fn) == IDENTIFIER_NODE)
4204 /* For some reason, do_identifier does not resolve
4205 conversion operator names if the only matches would be
4206 template conversion operators. So, we do it here. */
4207 if (IDENTIFIER_TYPENAME_P (fn) && current_class_type)
4209 f = lookup_member (current_class_type, fn,
4210 /*protect=*/1, /*want_type=*/0);
4212 return finish_call_expr (f, args,
4213 /*disallow_virtual=*/false);
4215 /* If the name still could not be resolved, then the program
4217 if (TREE_CODE (fn) == IDENTIFIER_NODE)
4219 unqualified_name_lookup_error (fn);
4220 return error_mark_node;
4223 else if (TREE_CODE (fn) == FUNCTION_DECL
4224 || DECL_FUNCTION_TEMPLATE_P (fn)
4225 || TREE_CODE (fn) == OVERLOAD)
4227 tree scope = DECL_CONTEXT (get_first_fn (fn));
4228 if (scope && TYPE_P (scope))
4232 if (DERIVED_FROM_P (scope, current_class_type)
4233 && current_class_ref)
4235 fn = build_baselink (lookup_base (current_class_type,
4239 TYPE_BINFO (current_class_type),
4241 /*optype=*/NULL_TREE);
4242 return finish_object_call_expr (fn,
4248 access_scope = current_class_type;
4249 while (!DERIVED_FROM_P (scope, access_scope))
4251 access_scope = TYPE_CONTEXT (access_scope);
4252 while (DECL_P (access_scope))
4253 access_scope = DECL_CONTEXT (access_scope);
4256 fn = build_baselink (NULL_TREE,
4257 TYPE_BINFO (access_scope),
4259 /*optype=*/NULL_TREE);
4264 if (TREE_CODE (fn) == COMPONENT_REF)
4265 /* If the parser sees `(x->y)(bar)' we get here because the
4266 parentheses confuse the parser. Treat this like
4268 return finish_object_call_expr (TREE_OPERAND (fn, 1),
4269 TREE_OPERAND (fn, 0),
4272 if (processing_template_decl)
4273 return build_nt (CALL_EXPR, fn, args, NULL_TREE);
4275 return build_call_from_tree (fn, args, disallow_virtual);
4278 #include "gt-cp-parse.h"