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. */
31 /* Cause the `yydebug' variable to be defined. */
48 extern struct obstack permanent_obstack;
50 /* Like YYERROR but do call yyerror. */
51 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
53 #define OP0(NODE) (TREE_OPERAND (NODE, 0))
54 #define OP1(NODE) (TREE_OPERAND (NODE, 1))
56 /* Contains the statement keyword (if/while/do) to include in an
57 error message if the user supplies an empty conditional expression. */
58 static const char *cond_stmt_keyword;
60 /* Nonzero if we have an `extern "C"' acting as an extern specifier. */
64 /* List of types and structure classes of the current declaration. */
65 static tree current_declspecs;
67 /* List of prefix attributes in effect.
68 Prefix attributes are parsed by the reserved_declspecs and declmods
69 rules. They create a list that contains *both* declspecs and attrs. */
70 /* ??? It is not clear yet that all cases where an attribute can now appear in
71 a declspec list have been updated. */
72 static tree prefix_attributes;
74 /* When defining an enumeration, this is the type of the enumeration. */
75 static tree current_enum_type;
77 /* When parsing a conversion operator name, this is the scope of the
79 static tree saved_scopes;
81 static tree empty_parms PARAMS ((void));
82 static tree parse_decl0 PARAMS ((tree, tree, tree, tree, int));
83 static tree parse_decl PARAMS ((tree, tree, int));
84 static void parse_end_decl PARAMS ((tree, tree, tree));
85 static tree parse_field0 PARAMS ((tree, tree, tree, tree, tree, tree));
86 static tree parse_field PARAMS ((tree, tree, tree, tree));
87 static tree parse_bitfield0 PARAMS ((tree, tree, tree, tree, tree));
88 static tree parse_bitfield PARAMS ((tree, tree, tree));
89 static tree parse_method PARAMS ((tree, tree, tree));
90 static void frob_specs PARAMS ((tree, tree));
92 /* Cons up an empty parameter list. */
98 #ifndef NO_IMPLICIT_EXTERN_C
99 if (in_system_header && current_class_type == NULL
100 && current_lang_name == lang_name_c)
104 parms = void_list_node;
108 /* Record the decl-specifiers, attributes and type lookups from the
109 decl-specifier-seq in a declaration. */
112 frob_specs (specs_attrs, lookups)
113 tree specs_attrs, lookups;
115 save_type_access_control (lookups);
116 split_specs_attrs (specs_attrs, ¤t_declspecs, &prefix_attributes);
117 if (current_declspecs
118 && TREE_CODE (current_declspecs) != TREE_LIST)
119 current_declspecs = build_tree_list (NULL_TREE, current_declspecs);
120 if (have_extern_spec && !used_extern_spec)
122 /* We have to indicate that there is an "extern", but that it
123 was part of a language specifier. For instance,
125 extern "C" typedef int (*Ptr) ();
128 current_declspecs = tree_cons (error_mark_node,
129 get_identifier ("extern"),
131 used_extern_spec = 1;
136 parse_decl (declarator, attributes, initialized)
137 tree declarator, attributes;
140 return start_decl (declarator, current_declspecs, initialized,
141 attributes, prefix_attributes);
145 parse_decl0 (declarator, specs_attrs, lookups, attributes, initialized)
146 tree declarator, specs_attrs, lookups, attributes;
149 frob_specs (specs_attrs, lookups);
150 return parse_decl (declarator, attributes, initialized);
154 parse_end_decl (decl, init, asmspec)
155 tree decl, init, asmspec;
157 /* If decl is NULL_TREE, then this was a variable declaration using
158 () syntax for the initializer, so we handled it in grokdeclarator. */
160 decl_type_access_control (decl);
161 cp_finish_decl (decl, init, asmspec, init ? LOOKUP_ONLYCONVERTING : 0);
165 parse_field (declarator, attributes, asmspec, init)
166 tree declarator, attributes, asmspec, init;
168 tree d = grokfield (declarator, current_declspecs, init, asmspec,
169 chainon (attributes, prefix_attributes));
170 decl_type_access_control (d);
175 parse_field0 (declarator, specs_attrs, lookups, attributes, asmspec, init)
176 tree declarator, specs_attrs, lookups, attributes, asmspec, init;
178 frob_specs (specs_attrs, lookups);
179 return parse_field (declarator, attributes, asmspec, init);
183 parse_bitfield (declarator, attributes, width)
184 tree declarator, attributes, width;
186 tree d = grokbitfield (declarator, current_declspecs, width);
187 cplus_decl_attributes (&d, chainon (attributes, prefix_attributes), 0);
188 decl_type_access_control (d);
193 parse_bitfield0 (declarator, specs_attrs, lookups, attributes, width)
194 tree declarator, specs_attrs, lookups, attributes, width;
196 frob_specs (specs_attrs, lookups);
197 return parse_bitfield (declarator, attributes, width);
201 parse_method (declarator, specs_attrs, lookups)
202 tree declarator, specs_attrs, lookups;
205 frob_specs (specs_attrs, lookups);
206 d = start_method (current_declspecs, declarator, prefix_attributes);
207 decl_type_access_control (d);
214 ggc_add_tree_root (¤t_declspecs, 1);
215 ggc_add_tree_root (&prefix_attributes, 1);
216 ggc_add_tree_root (¤t_enum_type, 1);
217 ggc_add_tree_root (&saved_scopes, 1);
220 /* Rename the "yyparse" function so that we can override it elsewhere. */
221 #define yyparse yyparse_1
231 flagged_type_tree ftype;
232 struct unparsed_text *pi;
235 /* All identifiers that are not reserved words
236 and are not declared typedefs in the current block */
239 /* All identifiers that are declared typedefs in the current block.
240 In some contexts, they are treated just like IDENTIFIER,
241 but they can also serve as typespecs in declarations. */
245 /* A template function. */
248 /* Reserved words that specify storage class.
249 yylval contains an IDENTIFIER_NODE which indicates which one. */
252 /* Reserved words that specify type.
253 yylval contains an IDENTIFIER_NODE which indicates which one. */
256 /* Reserved words that qualify type: "const" or "volatile".
257 yylval contains an IDENTIFIER_NODE which indicates which one. */
260 /* Character or numeric constants.
261 yylval is the node for the constant. */
264 /* __func__, __FUNCTION__ or __PRETTY_FUNCTION__.
265 yylval contains an IDENTIFIER_NODE which indicates which one. */
268 /* String constants in raw form.
269 yylval is a STRING_CST node. */
272 /* "...", used for functions with variable arglists. */
275 /* the reserved words */
276 /* SCO include files test "ASM", so use something else. */
277 %token SIZEOF ENUM /* STRUCT UNION */ IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
278 %token BREAK CONTINUE RETURN_KEYWORD GOTO ASM_KEYWORD TYPEOF ALIGNOF
280 %token ATTRIBUTE EXTENSION LABEL
281 %token REALPART IMAGPART VA_ARG
283 /* the reserved words... C++ extensions */
285 %token <ttype> VISSPEC
286 %token DELETE NEW THIS OPERATOR CXX_TRUE CXX_FALSE
287 %token NAMESPACE TYPENAME_KEYWORD USING
288 %token LEFT_RIGHT TEMPLATE
289 %token TYPEID DYNAMIC_CAST STATIC_CAST REINTERPRET_CAST CONST_CAST
292 /* Define the operator tokens and their precedences.
293 The value is an integer because, if used, it is the tree code
294 to use in the expression made from the operator. */
296 %left EMPTY /* used to resolve s/r with epsilon */
300 /* Add precedence rules to solve dangling else s/r conflict */
304 %left IDENTIFIER PFUNCNAME TYPENAME SELFNAME PTYPENAME SCSPEC TYPESPEC CV_QUALIFIER ENUM AGGR ELLIPSIS TYPEOF SIGOF OPERATOR NSNAME TYPENAME_KEYWORD
310 %right <code> ASSIGN '='
318 %left <code> EQCOMPARE
319 %left <code> ARITHCOMPARE '<' '>'
320 %left <code> LSHIFT RSHIFT
322 %left <code> '*' '/' '%'
323 %left <code> POINTSAT_STAR DOT_STAR
324 %right <code> UNARY PLUSPLUS MINUSMINUS '~'
326 %left <ttype> LEFT_RIGHT
327 %left <code> POINTSAT '.' '(' '['
329 %right SCOPE /* C++ extension */
330 %nonassoc NEW DELETE TRY CATCH
334 %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist
335 %type <ttype> PFUNCNAME maybe_identifier
336 %type <ttype> paren_expr_or_null nontrivial_exprlist SELFNAME
337 %type <ttype> expr_no_commas expr_no_comma_rangle
338 %type <ttype> cast_expr unary_expr primary string STRING
339 %type <ttype> reserved_declspecs boolean.literal
340 %type <ttype> reserved_typespecquals
341 %type <ttype> SCSPEC TYPESPEC CV_QUALIFIER maybe_cv_qualifier
342 %type <ttype> init initlist maybeasm maybe_init defarg defarg1
343 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
344 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
345 %type <ttype> any_word
347 %type <itype> save_lineno
348 %type <ttype> simple_stmt simple_if
350 %type <ttype> declarator notype_declarator after_type_declarator
351 %type <ttype> notype_declarator_intern absdcl_intern
352 %type <ttype> after_type_declarator_intern
353 %type <ttype> direct_notype_declarator direct_after_type_declarator
354 %type <itype> components notype_components
355 %type <ttype> component_decl component_decl_1
356 %type <ttype> component_declarator component_declarator0
357 %type <ttype> notype_component_declarator notype_component_declarator0
358 %type <ttype> after_type_component_declarator after_type_component_declarator0
359 %type <ttype> absdcl cv_qualifiers
360 %type <ttype> direct_abstract_declarator conversion_declarator
361 %type <ttype> new_declarator direct_new_declarator
362 %type <ttype> xexpr parmlist parms bad_parm
363 %type <ttype> identifiers_or_typenames
364 %type <ttype> fcast_or_absdcl regcast_or_absdcl
365 %type <ttype> expr_or_declarator expr_or_declarator_intern
366 %type <ttype> complex_notype_declarator
367 %type <ttype> notype_unqualified_id unqualified_id qualified_id
368 %type <ttype> template_id do_id object_template_id notype_template_declarator
369 %type <ttype> overqualified_id notype_qualified_id any_id
370 %type <ttype> complex_direct_notype_declarator functional_cast
371 %type <ttype> complex_parmlist parms_comma
372 %type <ttype> namespace_qualifier namespace_using_decl
374 %type <ftype> type_id new_type_id typed_typespecs typespec typed_declspecs
375 %type <ftype> typed_declspecs1 type_specifier_seq nonempty_cv_qualifiers
376 %type <ftype> structsp typespecqual_reserved parm named_parm full_parm
377 %type <ftype> declmods
379 %type <itype> extension
382 %token <ttype> PTYPENAME
383 %token <ttype> EXTERN_LANG_STRING ALL
384 %token <ttype> PRE_PARSED_CLASS_DECL DEFARG DEFARG_MARKER
385 %token <pi> PRE_PARSED_FUNCTION_DECL
386 %type <ttype> component_constructor_declarator
387 %type <ttype> fn.def2 return_id constructor_declarator
388 %type <ttype> .begin_function_body
389 %type <ttype> class_head class_head_apparent_template
390 %type <ftype> class_head_decl class_head_defn
391 %type <ttype> base_class_list
392 %type <ttype> base_class_access_list
393 %type <ttype> base_class maybe_base_class_list base_class.1
394 %type <ttype> exception_specification_opt ansi_raise_identifier ansi_raise_identifiers
395 %type <ttype> operator_name
396 %type <ttype> object aggr
397 %type <itype> new delete
398 /* %type <ttype> primary_no_id */
399 %type <ttype> maybe_parmlist
400 %type <ttype> member_init
401 %type <ftype> member_init_list
402 %type <ttype> template_parm_header template_spec_header template_header
403 %type <ttype> template_parm_list template_parm
404 %type <ttype> template_type_parm template_template_parm
405 %type <code> template_close_bracket
406 %type <ttype> apparent_template_type
407 %type <ttype> template_type template_arg_list template_arg_list_opt
408 %type <ttype> template_arg
409 %type <ttype> condition xcond paren_cond_or_null
410 %type <ttype> type_name nested_name_specifier nested_type ptr_to_mem
411 %type <ttype> complete_type_name notype_identifier nonnested_type
412 %type <ttype> complex_type_name nested_name_specifier_1
413 %type <ttype> new_initializer new_placement
414 %type <ttype> using_decl
415 %type <ttype> typename_sub typename_sub0 typename_sub1 typename_sub2
416 %type <ttype> explicit_template_type
417 /* in order to recognize aggr tags as defining and thus shadowing. */
418 %token TYPENAME_DEFN IDENTIFIER_DEFN PTYPENAME_DEFN
419 %type <ttype> identifier_defn IDENTIFIER_DEFN TYPENAME_DEFN PTYPENAME_DEFN
420 %type <ttype> handler_args
421 %type <ttype> self_template_type .finish_template_type
426 /* Used in lex.c for parsing pragmas. */
429 /* lex.c and pt.c depend on this being the last token. Define
430 any new tokens before this one! */
431 %token END_OF_SAVED_INPUT
434 /* Tell yyparse how to print a token's value, if yydebug is set. */
435 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
436 extern void yyprint PARAMS ((FILE *, int, YYSTYPE));
442 { finish_translation_unit (); }
444 { finish_translation_unit (); }
447 /* the reason for the strange actions in this rule
448 is so that notype_initdecls when reached via datadef
449 can find a valid list of type and sc specs in $0. */
452 { $<ttype>$ = NULL_TREE; }
454 { $<ttype>$ = NULL_TREE; ggc_collect (); }
455 | extdefs lang_extdef
456 { $<ttype>$ = NULL_TREE; ggc_collect (); }
465 { have_extern_spec = 1;
466 used_extern_spec = 0;
467 $<ttype>$ = NULL_TREE; }
470 { have_extern_spec = 0; }
484 { if (pending_lang_change) do_pending_lang_change();
485 type_lookups = NULL_TREE; }
487 { if (! toplevel_bindings_p ())
492 fndef eat_saved_input
493 { do_pending_inlines (); }
495 { do_pending_inlines (); }
498 { warning ("keyword `export' not implemented, and will be ignored"); }
500 { do_pending_inlines (); }
502 { do_pending_inlines (); }
503 | asm_keyword '(' string ')' ';'
504 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
506 | extern_lang_string '{' extdefs_opt '}'
507 { pop_lang_context (); }
508 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
509 { do_pending_inlines (); pop_lang_context (); }
510 | extern_lang_string .hush_warning datadef .warning_ok
511 { do_pending_inlines (); pop_lang_context (); }
512 | NAMESPACE identifier '{'
513 { push_namespace ($2); }
515 { pop_namespace (); }
517 { push_namespace (NULL_TREE); }
519 { pop_namespace (); }
522 { do_toplevel_using_decl ($1); }
529 NAMESPACE identifier '='
530 { begin_only_namespace_names (); }
533 end_only_namespace_names ();
536 do_namespace_alias ($2, $5);
543 | USING global_scope qualified_id
545 | USING global_scope unqualified_id
549 namespace_using_decl:
550 USING namespace_qualifier identifier
551 { $$ = build_nt (SCOPE_REF, $2, $3); }
552 | USING global_scope identifier
553 { $$ = build_nt (SCOPE_REF, global_namespace, $3); }
554 | USING global_scope namespace_qualifier identifier
555 { $$ = build_nt (SCOPE_REF, $3, $4); }
560 { begin_only_namespace_names (); }
563 end_only_namespace_names ();
564 /* If no declaration was found, the using-directive is
565 invalid. Since that was not reported, we need the
566 identifier for the error message. */
567 if (TREE_CODE ($4) == IDENTIFIER_NODE && lastiddecl)
569 do_using_directive ($4);
576 if (TREE_CODE ($$) == IDENTIFIER_NODE)
580 | namespace_qualifier NSNAME SCOPE
583 if (TREE_CODE ($$) == IDENTIFIER_NODE)
591 | global_scope qualified_id
593 | global_scope unqualified_id
599 { push_lang_context ($1); }
600 | extern_lang_string EXTERN_LANG_STRING
601 { if (current_lang_name != $2)
602 error ("use of linkage spec `%D' is different from previous spec `%D'", $2, current_lang_name);
603 pop_lang_context (); push_lang_context ($2); }
606 template_parm_header:
608 { begin_template_parm_list (); }
609 template_parm_list '>'
610 { $$ = end_template_parm_list ($4); }
613 template_spec_header:
615 { begin_specialization();
621 | template_spec_header
626 { $$ = process_template_parm (NULL_TREE, $1); }
627 | template_parm_list ',' template_parm
628 { $$ = process_template_parm ($1, $3); }
638 aggr maybe_identifier
639 { $$ = finish_template_type_parm ($1, $2); }
640 | TYPENAME_KEYWORD maybe_identifier
641 { $$ = finish_template_type_parm (class_type_node, $2); }
644 template_template_parm:
645 template_parm_header aggr maybe_identifier
646 { $$ = finish_template_template_parm ($2, $3); }
650 /* The following rules introduce a new reduce/reduce
651 conflict on the ',' and '>' input tokens: they are valid
652 prefixes for a `structsp', which means they could match a
653 nameless parameter. See 14.6, paragraph 3.
654 By putting them before the `parm' rule, we get
655 their match before considering them nameless parameter
658 { $$ = build_tree_list (NULL_TREE, $1); }
659 | template_type_parm '=' type_id
660 { $$ = build_tree_list (groktypename ($3.t), $1); }
662 { $$ = build_tree_list (NULL_TREE, $1.t); }
663 | parm '=' expr_no_comma_rangle
664 { $$ = build_tree_list ($3, $1.t); }
665 | template_template_parm
666 { $$ = build_tree_list (NULL_TREE, $1); }
667 | template_template_parm '=' template_arg
669 if (TREE_CODE ($3) != TEMPLATE_DECL
670 && TREE_CODE ($3) != TEMPLATE_TEMPLATE_PARM
671 && TREE_CODE ($3) != TYPE_DECL
672 && TREE_CODE ($3) != UNBOUND_CLASS_TEMPLATE)
674 error ("invalid default template argument");
675 $3 = error_mark_node;
677 $$ = build_tree_list ($3, $1);
682 template_header template_extdef
683 { finish_template_decl ($1); }
684 | template_header error %prec EMPTY
685 { finish_template_decl ($1); }
689 fndef eat_saved_input
690 { do_pending_inlines (); }
692 { do_pending_inlines (); }
694 { do_pending_inlines (); }
695 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
696 { do_pending_inlines ();
697 pop_lang_context (); }
698 | extern_lang_string .hush_warning template_datadef .warning_ok
699 { do_pending_inlines ();
700 pop_lang_context (); }
701 | extension template_extdef
707 | declmods notype_initdecls ';'
709 | typed_declspecs initdecls ';'
710 { note_list_got_semicolon ($1.t); }
713 if ($1.t != error_mark_node)
715 maybe_process_partial_specialization ($1.t);
716 note_got_semicolon ($1.t);
723 | declmods notype_initdecls ';'
725 | typed_declspecs initdecls ';'
726 { note_list_got_semicolon ($1.t); }
728 { pedwarn ("empty declaration"); }
729 | explicit_instantiation ';'
730 | typed_declspecs ';'
733 split_specs_attrs ($1.t, &t, &attrs);
735 note_list_got_semicolon ($1.t);
739 | error END_OF_SAVED_INPUT
745 ctor_initializer_opt:
762 .begin_function_body ctor_initializer_opt compstmt
764 finish_function_body ($1);
769 fn.def1 maybe_return_init function_body
770 { expand_body (finish_function (0)); }
771 | fn.def1 maybe_return_init function_try_block
772 { expand_body (finish_function (0)); }
773 | fn.def1 maybe_return_init error
777 constructor_declarator:
778 nested_name_specifier SELFNAME '('
779 { $$ = begin_constructor_declarator ($1, $2); }
780 parmlist ')' cv_qualifiers exception_specification_opt
781 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
782 | nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
783 { $$ = begin_constructor_declarator ($1, $2);
784 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
786 | global_scope nested_name_specifier SELFNAME '('
787 { $$ = begin_constructor_declarator ($2, $3); }
788 parmlist ')' cv_qualifiers exception_specification_opt
789 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
790 | global_scope nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
791 { $$ = begin_constructor_declarator ($2, $3);
792 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
794 | nested_name_specifier self_template_type '('
795 { $$ = begin_constructor_declarator ($1, $2); }
796 parmlist ')' cv_qualifiers exception_specification_opt
797 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
798 | nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
799 { $$ = begin_constructor_declarator ($1, $2);
800 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
802 | global_scope nested_name_specifier self_template_type '('
803 { $$ = begin_constructor_declarator ($2, $3); }
804 parmlist ')' cv_qualifiers exception_specification_opt
805 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
806 | global_scope nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
807 { $$ = begin_constructor_declarator ($2, $3);
808 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
813 typed_declspecs declarator
814 { check_for_new_type ("return type", $1);
815 if (!begin_function_definition ($1.t, $2))
817 | declmods notype_declarator
818 { if (!begin_function_definition ($1.t, $2))
821 { if (!begin_function_definition (NULL_TREE, $1))
823 | declmods constructor_declarator
824 { if (!begin_function_definition ($1.t, $2))
826 | constructor_declarator
827 { if (!begin_function_definition (NULL_TREE, $1))
831 /* ANSI allows optional parentheses around constructor class names.
832 See ISO/IEC 14882:1998(E) 12.1. */
834 component_constructor_declarator:
835 SELFNAME '(' parmlist ')' cv_qualifiers exception_specification_opt
836 { $$ = make_call_declarator ($1, $3, $5, $6); }
837 | '(' SELFNAME ')' '(' parmlist ')' cv_qualifiers
838 exception_specification_opt
839 { $$ = make_call_declarator ($2, $5, $7, $8); }
840 | SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
841 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
842 | '(' SELFNAME ')' LEFT_RIGHT cv_qualifiers exception_specification_opt
843 { $$ = make_call_declarator ($2, empty_parms (), $5, $6); }
844 | self_template_type '(' parmlist ')' cv_qualifiers exception_specification_opt
845 { $$ = make_call_declarator ($1, $3, $5, $6); }
846 | self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
847 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
850 /* more C++ complexity. See component_decl for a comment on the
851 reduce/reduce conflict introduced by these rules. */
853 declmods component_constructor_declarator
854 { $$ = parse_method ($2, $1.t, $1.lookups);
858 if (yychar == YYEMPTY)
861 | component_constructor_declarator
862 { $$ = parse_method ($1, NULL_TREE, NULL_TREE);
864 | typed_declspecs declarator
865 { $$ = parse_method ($2, $1.t, $1.lookups); goto rest_of_mdef;}
866 | declmods notype_declarator
867 { $$ = parse_method ($2, $1.t, $1.lookups); goto rest_of_mdef;}
869 { $$ = parse_method ($1, NULL_TREE, NULL_TREE);
871 | declmods constructor_declarator
872 { $$ = parse_method ($2, $1.t, $1.lookups); goto rest_of_mdef;}
873 | constructor_declarator
874 { $$ = parse_method ($1, NULL_TREE, NULL_TREE);
879 RETURN_KEYWORD IDENTIFIER
887 { finish_named_return_value ($<ttype>$, $2); }
888 | return_id '(' nonnull_exprlist ')'
889 { finish_named_return_value ($<ttype>$, $3); }
890 | return_id LEFT_RIGHT
891 { finish_named_return_value ($<ttype>$, NULL_TREE); }
897 if (! DECL_CONSTRUCTOR_P (current_function_decl))
898 error ("only constructors take base initializers");
899 else if ($2.new_type_flag == 0)
900 error ("no base or member initializers given following ':'");
902 finish_mem_initializers ($2.t);
906 .begin_function_body:
909 $$ = begin_function_body ();
916 $$.new_type_flag = 0;
921 $$.new_type_flag = 1;
924 | member_init_list ',' member_init
928 $$.new_type_flag = 1;
929 TREE_CHAIN ($3) = $1.t;
935 | member_init_list error
939 '(' nonnull_exprlist ')'
941 if (current_class_name)
942 pedwarn ("anachronistic old style base class initializer");
943 $$ = expand_member_init (current_class_ref, NULL_TREE, $2);
947 if (current_class_name)
948 pedwarn ("anachronistic old style base class initializer");
949 $$ = expand_member_init (current_class_ref,
953 | notype_identifier '(' nonnull_exprlist ')'
954 { $$ = expand_member_init (current_class_ref, $1, $3); }
955 | notype_identifier LEFT_RIGHT
956 { $$ = expand_member_init (current_class_ref, $1,
958 | nonnested_type '(' nonnull_exprlist ')'
959 { $$ = expand_member_init (current_class_ref, $1, $3); }
960 | nonnested_type LEFT_RIGHT
961 { $$ = expand_member_init (current_class_ref, $1,
963 | typename_sub '(' nonnull_exprlist ')'
964 { $$ = expand_member_init (current_class_ref, $1, $3); }
965 | typename_sub LEFT_RIGHT
966 { $$ = expand_member_init (current_class_ref, $1,
992 explicit_instantiation:
993 TEMPLATE begin_explicit_instantiation typespec ';'
994 { do_type_instantiation ($3.t, NULL_TREE, 1);
996 end_explicit_instantiation
997 | TEMPLATE begin_explicit_instantiation typed_declspecs declarator
998 { tree specs = strip_attrs ($3.t);
999 do_decl_instantiation (specs, $4, NULL_TREE); }
1000 end_explicit_instantiation
1001 | TEMPLATE begin_explicit_instantiation notype_declarator
1002 { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
1003 end_explicit_instantiation
1004 | TEMPLATE begin_explicit_instantiation constructor_declarator
1005 { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
1006 end_explicit_instantiation
1007 | SCSPEC TEMPLATE begin_explicit_instantiation typespec ';'
1008 { do_type_instantiation ($4.t, $1, 1);
1009 yyungetc (';', 1); }
1010 end_explicit_instantiation
1011 | SCSPEC TEMPLATE begin_explicit_instantiation typed_declspecs
1013 { tree specs = strip_attrs ($4.t);
1014 do_decl_instantiation (specs, $5, $1); }
1015 end_explicit_instantiation
1016 | SCSPEC TEMPLATE begin_explicit_instantiation notype_declarator
1017 { do_decl_instantiation (NULL_TREE, $4, $1); }
1018 end_explicit_instantiation
1019 | SCSPEC TEMPLATE begin_explicit_instantiation constructor_declarator
1020 { do_decl_instantiation (NULL_TREE, $4, $1); }
1021 end_explicit_instantiation
1024 begin_explicit_instantiation:
1025 { begin_explicit_instantiation(); }
1027 end_explicit_instantiation:
1028 { end_explicit_instantiation(); }
1030 /* The TYPENAME expansions are to deal with use of a template class name as
1031 a template within the class itself, where the template decl is hidden by
1032 a type decl. Got all that? */
1035 PTYPENAME '<' template_arg_list_opt template_close_bracket
1036 .finish_template_type
1038 | TYPENAME '<' template_arg_list_opt template_close_bracket
1039 .finish_template_type
1041 | self_template_type
1044 apparent_template_type:
1046 | identifier '<' template_arg_list_opt '>'
1047 .finish_template_type
1051 SELFNAME '<' template_arg_list_opt template_close_bracket
1052 .finish_template_type
1056 .finish_template_type:
1058 if (yychar == YYEMPTY)
1061 $$ = finish_template_type ($<ttype>-3, $<ttype>-1,
1065 template_close_bracket:
1069 /* Handle `Class<Class<Type>>' without space in the `>>' */
1070 pedwarn ("`>>' should be `> >' in template class name");
1075 template_arg_list_opt:
1083 { $$ = build_tree_list (NULL_TREE, $$); }
1084 | template_arg_list ',' template_arg
1085 { $$ = chainon ($$, build_tree_list (NULL_TREE, $3)); }
1090 { $$ = groktypename ($1.t); }
1094 if (DECL_TEMPLATE_TEMPLATE_PARM_P ($$))
1095 $$ = TREE_TYPE ($$);
1097 | global_scope PTYPENAME
1100 if (DECL_TEMPLATE_TEMPLATE_PARM_P ($$))
1101 $$ = TREE_TYPE ($$);
1103 | expr_no_comma_rangle
1104 | nested_name_specifier TEMPLATE identifier
1106 if (!processing_template_decl)
1108 error ("use of template qualifier outside template");
1109 $$ = error_mark_node;
1112 $$ = make_unbound_class_template ($1, $3, 1);
1118 { $$ = NEGATE_EXPR; }
1120 { $$ = CONVERT_EXPR; }
1122 { $$ = PREINCREMENT_EXPR; }
1124 { $$ = PREDECREMENT_EXPR; }
1126 { $$ = TRUTH_NOT_EXPR; }
1131 { $$ = build_x_compound_expr ($$); }
1137 { error ("ISO C++ forbids an empty condition for `%s'",
1139 $$ = integer_zero_node; }
1146 { error ("ISO C++ forbids an empty condition for `%s'",
1148 $$ = integer_zero_node; }
1162 type_specifier_seq declarator maybeasm maybe_attribute '='
1165 for (d = getdecls (); d; d = TREE_CHAIN (d))
1166 if (TREE_CODE (d) == TYPE_DECL) {
1167 tree s = TREE_TYPE (d);
1168 if (TREE_CODE (s) == RECORD_TYPE)
1169 error ("definition of class `%T' in condition", s);
1170 else if (TREE_CODE (s) == ENUMERAL_TYPE)
1171 error ("definition of enum `%T' in condition", s);
1174 current_declspecs = $1.t;
1175 $<ttype>$ = parse_decl ($<ttype>2, $4, 1);
1179 parse_end_decl ($<ttype>6, $7, $4);
1180 $$ = convert_from_reference ($<ttype>6);
1181 if (TREE_CODE (TREE_TYPE ($$)) == ARRAY_TYPE)
1182 error ("definition of array `%#D' in condition", $$);
1189 | maybe_label_decls stmts '}'
1190 | maybe_label_decls stmts error '}'
1191 | maybe_label_decls error '}'
1194 nontrivial_exprlist:
1195 expr_no_commas ',' expr_no_commas
1196 { $$ = tree_cons (NULL_TREE, $$,
1197 build_tree_list (NULL_TREE, $3)); }
1198 | expr_no_commas ',' error
1199 { $$ = tree_cons (NULL_TREE, $$,
1200 build_tree_list (NULL_TREE, error_mark_node)); }
1201 | nontrivial_exprlist ',' expr_no_commas
1202 { chainon ($$, build_tree_list (NULL_TREE, $3)); }
1203 | nontrivial_exprlist ',' error
1204 { chainon ($$, build_tree_list (NULL_TREE, error_mark_node)); }
1209 { $$ = build_tree_list (NULL_TREE, $$); }
1210 | nontrivial_exprlist
1216 /* __extension__ turns off -pedantic for following primary. */
1217 | extension cast_expr %prec UNARY
1220 | '*' cast_expr %prec UNARY
1221 { $$ = build_x_indirect_ref ($2, "unary *"); }
1222 | '&' cast_expr %prec UNARY
1223 { $$ = build_x_unary_op (ADDR_EXPR, $2); }
1225 { $$ = build_x_unary_op (BIT_NOT_EXPR, $2); }
1226 | unop cast_expr %prec UNARY
1227 { $$ = finish_unary_op_expr ($1, $2); }
1228 /* Refer to the address of a label as a pointer. */
1230 { $$ = finish_label_address_expr ($2); }
1231 | SIZEOF unary_expr %prec UNARY
1232 { $$ = finish_sizeof ($2); }
1233 | SIZEOF '(' type_id ')' %prec HYPERUNARY
1234 { $$ = finish_sizeof (groktypename ($3.t));
1235 check_for_new_type ("sizeof", $3); }
1236 | ALIGNOF unary_expr %prec UNARY
1237 { $$ = finish_alignof ($2); }
1238 | ALIGNOF '(' type_id ')' %prec HYPERUNARY
1239 { $$ = finish_alignof (groktypename ($3.t));
1240 check_for_new_type ("alignof", $3); }
1242 /* The %prec EMPTY's here are required by the = init initializer
1243 syntax extension; see below. */
1244 | new new_type_id %prec EMPTY
1245 { $$ = build_new (NULL_TREE, $2.t, NULL_TREE, $1);
1246 check_for_new_type ("new", $2); }
1247 | new new_type_id new_initializer
1248 { $$ = build_new (NULL_TREE, $2.t, $3, $1);
1249 check_for_new_type ("new", $2); }
1250 | new new_placement new_type_id %prec EMPTY
1251 { $$ = build_new ($2, $3.t, NULL_TREE, $1);
1252 check_for_new_type ("new", $3); }
1253 | new new_placement new_type_id new_initializer
1254 { $$ = build_new ($2, $3.t, $4, $1);
1255 check_for_new_type ("new", $3); }
1256 | new '(' type_id ')'
1258 { $$ = build_new (NULL_TREE, groktypename($3.t),
1260 check_for_new_type ("new", $3); }
1261 | new '(' type_id ')' new_initializer
1262 { $$ = build_new (NULL_TREE, groktypename($3.t), $5, $1);
1263 check_for_new_type ("new", $3); }
1264 | new new_placement '(' type_id ')' %prec EMPTY
1265 { $$ = build_new ($2, groktypename($4.t), NULL_TREE, $1);
1266 check_for_new_type ("new", $4); }
1267 | new new_placement '(' type_id ')' new_initializer
1268 { $$ = build_new ($2, groktypename($4.t), $6, $1);
1269 check_for_new_type ("new", $4); }
1271 | delete cast_expr %prec UNARY
1272 { $$ = delete_sanity ($2, NULL_TREE, 0, $1); }
1273 | delete '[' ']' cast_expr %prec UNARY
1274 { $$ = delete_sanity ($4, NULL_TREE, 1, $1);
1275 if (yychar == YYEMPTY)
1277 | delete '[' expr ']' cast_expr %prec UNARY
1278 { $$ = delete_sanity ($5, $3, 2, $1);
1279 if (yychar == YYEMPTY)
1281 | REALPART cast_expr %prec UNARY
1282 { $$ = build_x_unary_op (REALPART_EXPR, $2); }
1283 | IMAGPART cast_expr %prec UNARY
1284 { $$ = build_x_unary_op (IMAGPART_EXPR, $2); }
1288 '(' nonnull_exprlist ')'
1290 | '{' nonnull_exprlist '}'
1291 { pedwarn ("old style placement syntax, use () instead");
1296 '(' nonnull_exprlist ')'
1299 { $$ = void_zero_node; }
1302 error ("`%T' is not a valid expression", $2.t);
1303 $$ = error_mark_node;
1305 /* GNU extension so people can use initializer lists. Note that
1306 this alters the meaning of `new int = 1', which was previously
1307 syntactically valid but semantically invalid.
1308 This feature is now deprecated and will be removed in a future
1313 pedwarn ("ISO C++ forbids initialization of new expression with `='");
1314 cp_deprecated ("new initializer lists extension");
1315 if (TREE_CODE ($2) != TREE_LIST
1316 && TREE_CODE ($2) != CONSTRUCTOR)
1317 $$ = build_tree_list (NULL_TREE, $2);
1323 /* This is necessary to postpone reduction of `int ((int)(int)(int))'. */
1325 '(' type_id ')' %prec EMPTY
1326 { $2.t = finish_parmlist (build_tree_list (NULL_TREE, $2.t), 0);
1327 $$ = make_call_declarator (NULL_TREE, $2.t, NULL_TREE, NULL_TREE);
1328 check_for_new_type ("cast", $2); }
1329 | regcast_or_absdcl '(' type_id ')' %prec EMPTY
1330 { $3.t = finish_parmlist (build_tree_list (NULL_TREE, $3.t), 0);
1331 $$ = make_call_declarator ($$, $3.t, NULL_TREE, NULL_TREE);
1332 check_for_new_type ("cast", $3); }
1337 | regcast_or_absdcl unary_expr %prec UNARY
1338 { $$ = reparse_absdcl_as_casts ($$, $2); }
1339 | regcast_or_absdcl '{' initlist maybecomma '}' %prec UNARY
1341 tree init = build_nt (CONSTRUCTOR, NULL_TREE,
1344 pedwarn ("ISO C++ forbids compound literals");
1345 /* Indicate that this was a C99 compound literal. */
1346 TREE_HAS_CONSTRUCTOR (init) = 1;
1348 $$ = reparse_absdcl_as_casts ($$, init);
1354 /* Handle general members. */
1355 | expr_no_commas POINTSAT_STAR expr_no_commas
1356 { $$ = build_x_binary_op (MEMBER_REF, $$, $3); }
1357 | expr_no_commas DOT_STAR expr_no_commas
1358 { $$ = build_m_component_ref ($$, $3); }
1359 | expr_no_commas '+' expr_no_commas
1360 { $$ = build_x_binary_op ($2, $$, $3); }
1361 | expr_no_commas '-' expr_no_commas
1362 { $$ = build_x_binary_op ($2, $$, $3); }
1363 | expr_no_commas '*' expr_no_commas
1364 { $$ = build_x_binary_op ($2, $$, $3); }
1365 | expr_no_commas '/' expr_no_commas
1366 { $$ = build_x_binary_op ($2, $$, $3); }
1367 | expr_no_commas '%' expr_no_commas
1368 { $$ = build_x_binary_op ($2, $$, $3); }
1369 | expr_no_commas LSHIFT expr_no_commas
1370 { $$ = build_x_binary_op ($2, $$, $3); }
1371 | expr_no_commas RSHIFT expr_no_commas
1372 { $$ = build_x_binary_op ($2, $$, $3); }
1373 | expr_no_commas ARITHCOMPARE expr_no_commas
1374 { $$ = build_x_binary_op ($2, $$, $3); }
1375 | expr_no_commas '<' expr_no_commas
1376 { $$ = build_x_binary_op (LT_EXPR, $$, $3); }
1377 | expr_no_commas '>' expr_no_commas
1378 { $$ = build_x_binary_op (GT_EXPR, $$, $3); }
1379 | expr_no_commas EQCOMPARE expr_no_commas
1380 { $$ = build_x_binary_op ($2, $$, $3); }
1381 | expr_no_commas MIN_MAX expr_no_commas
1382 { $$ = build_x_binary_op ($2, $$, $3); }
1383 | expr_no_commas '&' expr_no_commas
1384 { $$ = build_x_binary_op ($2, $$, $3); }
1385 | expr_no_commas '|' expr_no_commas
1386 { $$ = build_x_binary_op ($2, $$, $3); }
1387 | expr_no_commas '^' expr_no_commas
1388 { $$ = build_x_binary_op ($2, $$, $3); }
1389 | expr_no_commas ANDAND expr_no_commas
1390 { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $$, $3); }
1391 | expr_no_commas OROR expr_no_commas
1392 { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $$, $3); }
1393 | expr_no_commas '?' xexpr ':' expr_no_commas
1394 { $$ = build_x_conditional_expr ($$, $3, $5); }
1395 | expr_no_commas '=' expr_no_commas
1396 { $$ = build_x_modify_expr ($$, NOP_EXPR, $3);
1397 if ($$ != error_mark_node)
1398 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
1399 | expr_no_commas ASSIGN expr_no_commas
1400 { $$ = build_x_modify_expr ($$, $2, $3); }
1402 { $$ = build_throw (NULL_TREE); }
1403 | THROW expr_no_commas
1404 { $$ = build_throw ($2); }
1407 expr_no_comma_rangle:
1409 /* Handle general members. */
1410 | expr_no_comma_rangle POINTSAT_STAR expr_no_comma_rangle
1411 { $$ = build_x_binary_op (MEMBER_REF, $$, $3); }
1412 | expr_no_comma_rangle DOT_STAR expr_no_comma_rangle
1413 { $$ = build_m_component_ref ($$, $3); }
1414 | expr_no_comma_rangle '+' expr_no_comma_rangle
1415 { $$ = build_x_binary_op ($2, $$, $3); }
1416 | expr_no_comma_rangle '-' expr_no_comma_rangle
1417 { $$ = build_x_binary_op ($2, $$, $3); }
1418 | expr_no_comma_rangle '*' expr_no_comma_rangle
1419 { $$ = build_x_binary_op ($2, $$, $3); }
1420 | expr_no_comma_rangle '/' expr_no_comma_rangle
1421 { $$ = build_x_binary_op ($2, $$, $3); }
1422 | expr_no_comma_rangle '%' expr_no_comma_rangle
1423 { $$ = build_x_binary_op ($2, $$, $3); }
1424 | expr_no_comma_rangle LSHIFT expr_no_comma_rangle
1425 { $$ = build_x_binary_op ($2, $$, $3); }
1426 | expr_no_comma_rangle RSHIFT expr_no_comma_rangle
1427 { $$ = build_x_binary_op ($2, $$, $3); }
1428 | expr_no_comma_rangle ARITHCOMPARE expr_no_comma_rangle
1429 { $$ = build_x_binary_op ($2, $$, $3); }
1430 | expr_no_comma_rangle '<' expr_no_comma_rangle
1431 { $$ = build_x_binary_op (LT_EXPR, $$, $3); }
1432 | expr_no_comma_rangle EQCOMPARE expr_no_comma_rangle
1433 { $$ = build_x_binary_op ($2, $$, $3); }
1434 | expr_no_comma_rangle MIN_MAX expr_no_comma_rangle
1435 { $$ = build_x_binary_op ($2, $$, $3); }
1436 | expr_no_comma_rangle '&' expr_no_comma_rangle
1437 { $$ = build_x_binary_op ($2, $$, $3); }
1438 | expr_no_comma_rangle '|' expr_no_comma_rangle
1439 { $$ = build_x_binary_op ($2, $$, $3); }
1440 | expr_no_comma_rangle '^' expr_no_comma_rangle
1441 { $$ = build_x_binary_op ($2, $$, $3); }
1442 | expr_no_comma_rangle ANDAND expr_no_comma_rangle
1443 { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $$, $3); }
1444 | expr_no_comma_rangle OROR expr_no_comma_rangle
1445 { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $$, $3); }
1446 | expr_no_comma_rangle '?' xexpr ':' expr_no_comma_rangle
1447 { $$ = build_x_conditional_expr ($$, $3, $5); }
1448 | expr_no_comma_rangle '=' expr_no_comma_rangle
1449 { $$ = build_x_modify_expr ($$, NOP_EXPR, $3);
1450 if ($$ != error_mark_node)
1451 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
1452 | expr_no_comma_rangle ASSIGN expr_no_comma_rangle
1453 { $$ = build_x_modify_expr ($$, $2, $3); }
1455 { $$ = build_throw (NULL_TREE); }
1456 | THROW expr_no_comma_rangle
1457 { $$ = build_throw ($2); }
1460 notype_unqualified_id:
1461 '~' see_typename identifier
1462 { $$ = build_nt (BIT_NOT_EXPR, $3); }
1463 | '~' see_typename template_type
1464 { $$ = build_nt (BIT_NOT_EXPR, $3); }
1469 | NSNAME %prec EMPTY
1474 /* If lastiddecl is a TREE_LIST, it's a baselink, which
1475 means that we're in an expression like S::f<int>, so
1476 don't do_identifier; we only do that for unqualified
1478 if (!lastiddecl || TREE_CODE (lastiddecl) != TREE_LIST)
1479 $$ = do_identifier ($<ttype>-1, 1, NULL_TREE);
1485 PFUNCNAME '<' do_id template_arg_list_opt template_close_bracket
1486 { $$ = lookup_template_function ($3, $4); }
1487 | operator_name '<' do_id template_arg_list_opt template_close_bracket
1488 { $$ = lookup_template_function ($3, $4); }
1492 TEMPLATE identifier '<' template_arg_list_opt template_close_bracket
1493 { $$ = lookup_template_function ($2, $4); }
1494 | TEMPLATE PFUNCNAME '<' template_arg_list_opt template_close_bracket
1495 { $$ = lookup_template_function ($2, $4); }
1496 | TEMPLATE operator_name '<' template_arg_list_opt
1497 template_close_bracket
1498 { $$ = lookup_template_function ($2, $4); }
1502 notype_unqualified_id
1507 expr_or_declarator_intern:
1509 | attributes expr_or_declarator
1511 /* Provide support for '(' attributes '*' declarator ')'
1513 $$ = tree_cons ($1, $2, NULL_TREE);
1518 notype_unqualified_id
1519 | '*' expr_or_declarator_intern %prec UNARY
1520 { $$ = build_nt (INDIRECT_REF, $2); }
1521 | '&' expr_or_declarator_intern %prec UNARY
1522 { $$ = build_nt (ADDR_EXPR, $2); }
1523 | '(' expr_or_declarator_intern ')'
1527 notype_template_declarator:
1528 IDENTIFIER '<' template_arg_list_opt template_close_bracket
1529 { $$ = lookup_template_function ($1, $3); }
1530 | NSNAME '<' template_arg_list template_close_bracket
1531 { $$ = lookup_template_function ($1, $3); }
1534 direct_notype_declarator:
1535 complex_direct_notype_declarator
1536 /* This precedence declaration is to prefer this reduce
1537 to the Koenig lookup shift in primary, below. I hate yacc. */
1538 | notype_unqualified_id %prec '('
1539 | notype_template_declarator
1540 | '(' expr_or_declarator_intern ')'
1541 { $$ = finish_decl_parsing ($2); }
1545 notype_unqualified_id
1547 if (TREE_CODE ($1) == BIT_NOT_EXPR)
1548 $$ = build_x_unary_op (BIT_NOT_EXPR, TREE_OPERAND ($1, 0));
1550 $$ = finish_id_expr ($1);
1556 $$ = combine_strings ($$);
1557 /* combine_strings doesn't set up TYPE_MAIN_VARIANT of
1558 a const array the way we want, so fix it. */
1559 if (flag_const_strings)
1560 TREE_TYPE ($$) = build_cplus_array_type
1561 (TREE_TYPE (TREE_TYPE ($$)),
1562 TYPE_DOMAIN (TREE_TYPE ($$)));
1566 $$ = fname_decl (C_RID_CODE ($$), $$);
1567 if (processing_template_decl)
1568 $$ = build_min_nt (LOOKUP_EXPR, DECL_NAME ($$));
1571 { $$ = finish_parenthesized_expr ($2); }
1572 | '(' expr_or_declarator_intern ')'
1573 { $2 = reparse_decl_as_expr (NULL_TREE, $2);
1574 $$ = finish_parenthesized_expr ($2); }
1576 { $$ = error_mark_node; }
1578 { tree scope = current_scope ();
1579 if (!scope || TREE_CODE (scope) != FUNCTION_DECL)
1581 error ("braced-group within expression allowed only inside a function");
1585 pedwarn ("ISO C++ forbids braced-groups within expressions");
1586 $<ttype>$ = begin_stmt_expr ();
1589 { $$ = finish_stmt_expr ($<ttype>2); }
1590 /* Koenig lookup support
1591 We could store lastiddecl in $1 to avoid another lookup,
1592 but that would result in many additional reduce/reduce conflicts. */
1593 | notype_unqualified_id '(' nonnull_exprlist ')'
1594 { $$ = finish_call_expr ($1, $3, 1); }
1595 | notype_unqualified_id LEFT_RIGHT
1596 { $$ = finish_call_expr ($1, NULL_TREE, 1); }
1597 | primary '(' nonnull_exprlist ')'
1598 { $$ = finish_call_expr ($1, $3, 0); }
1599 | primary LEFT_RIGHT
1600 { $$ = finish_call_expr ($1, NULL_TREE, 0); }
1601 | VA_ARG '(' expr_no_commas ',' type_id ')'
1602 { $$ = build_x_va_arg ($3, groktypename ($5.t));
1603 check_for_new_type ("__builtin_va_arg", $5); }
1604 | primary '[' expr ']'
1605 { $$ = grok_array_decl ($$, $3); }
1607 { $$ = finish_increment_expr ($1, POSTINCREMENT_EXPR); }
1608 | primary MINUSMINUS
1609 { $$ = finish_increment_expr ($1, POSTDECREMENT_EXPR); }
1610 /* C++ extensions */
1612 { $$ = finish_this_expr (); }
1613 | CV_QUALIFIER '(' nonnull_exprlist ')'
1615 /* This is a C cast in C++'s `functional' notation
1616 using the "implicit int" extension so that:
1617 `const (3)' is equivalent to `const int (3)'. */
1620 type = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
1621 type = groktypename (build_tree_list (type, NULL_TREE));
1622 $$ = build_functional_cast (type, $3);
1625 | DYNAMIC_CAST '<' type_id '>' '(' expr ')'
1626 { tree type = groktypename ($3.t);
1627 check_for_new_type ("dynamic_cast", $3);
1628 $$ = build_dynamic_cast (type, $6); }
1629 | STATIC_CAST '<' type_id '>' '(' expr ')'
1630 { tree type = groktypename ($3.t);
1631 check_for_new_type ("static_cast", $3);
1632 $$ = build_static_cast (type, $6); }
1633 | REINTERPRET_CAST '<' type_id '>' '(' expr ')'
1634 { tree type = groktypename ($3.t);
1635 check_for_new_type ("reinterpret_cast", $3);
1636 $$ = build_reinterpret_cast (type, $6); }
1637 | CONST_CAST '<' type_id '>' '(' expr ')'
1638 { tree type = groktypename ($3.t);
1639 check_for_new_type ("const_cast", $3);
1640 $$ = build_const_cast (type, $6); }
1641 | TYPEID '(' expr ')'
1642 { $$ = build_typeid ($3); }
1643 | TYPEID '(' type_id ')'
1644 { tree type = groktypename ($3.t);
1645 check_for_new_type ("typeid", $3);
1646 $$ = get_typeid (TYPE_MAIN_VARIANT (type)); }
1647 | global_scope IDENTIFIER
1648 { $$ = do_scoped_id ($2, 1); }
1649 | global_scope template_id
1651 | global_scope operator_name
1653 got_scope = NULL_TREE;
1654 if (TREE_CODE ($2) == IDENTIFIER_NODE)
1655 $$ = do_scoped_id ($2, 1);
1659 | overqualified_id %prec HYPERUNARY
1660 { $$ = build_offset_ref (OP0 ($$), OP1 ($$)); }
1661 | overqualified_id '(' nonnull_exprlist ')'
1662 { $$ = finish_qualified_call_expr ($1, $3); }
1663 | overqualified_id LEFT_RIGHT
1664 { $$ = finish_qualified_call_expr ($1, NULL_TREE); }
1665 | object object_template_id %prec UNARY
1667 $$ = build_x_component_ref ($$, $2, NULL_TREE, 1);
1669 | object object_template_id '(' nonnull_exprlist ')'
1670 { $$ = finish_object_call_expr ($2, $1, $4); }
1671 | object object_template_id LEFT_RIGHT
1672 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1673 | object unqualified_id %prec UNARY
1674 { $$ = build_x_component_ref ($$, $2, NULL_TREE, 1); }
1675 | object overqualified_id %prec UNARY
1676 { if (processing_template_decl)
1677 $$ = build_min_nt (COMPONENT_REF, $1, $2);
1679 $$ = build_object_ref ($$, OP0 ($2), OP1 ($2)); }
1680 | object unqualified_id '(' nonnull_exprlist ')'
1681 { $$ = finish_object_call_expr ($2, $1, $4); }
1682 | object unqualified_id LEFT_RIGHT
1683 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1684 | object overqualified_id '(' nonnull_exprlist ')'
1685 { $$ = finish_qualified_object_call_expr ($2, $1, $4); }
1686 | object overqualified_id LEFT_RIGHT
1687 { $$ = finish_qualified_object_call_expr ($2, $1, NULL_TREE); }
1688 /* p->int::~int() is valid -- 12.4 */
1689 | object '~' TYPESPEC LEFT_RIGHT
1690 { $$ = finish_pseudo_destructor_call_expr ($1, NULL_TREE, $3); }
1691 | object TYPESPEC SCOPE '~' TYPESPEC LEFT_RIGHT
1692 { $$ = finish_pseudo_destructor_call_expr ($1, $2, $5); }
1695 $$ = error_mark_node;
1699 /* Not needed for now.
1705 { $$ = error_mark_node; }
1707 { if (current_function_decl == 0)
1709 error ("braced-group within expression allowed only inside a function");
1712 $<ttype>$ = expand_start_stmt_expr (); }
1715 pedwarn ("ISO C++ forbids braced-groups within expressions");
1716 $$ = expand_end_stmt_expr ($<ttype>2); }
1717 | primary_no_id '(' nonnull_exprlist ')'
1718 { $$ = build_x_function_call ($$, $3, current_class_ref); }
1719 | primary_no_id LEFT_RIGHT
1720 { $$ = build_x_function_call ($$, NULL_TREE, current_class_ref); }
1721 | primary_no_id '[' expr ']'
1723 | primary_no_id PLUSPLUS
1724 { $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); }
1725 | primary_no_id MINUSMINUS
1726 { $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); }
1728 { goto do_scoped_id; }
1729 | SCOPE operator_name
1730 { if (TREE_CODE ($2) == IDENTIFIER_NODE)
1732 goto do_scoped_operator;
1741 { got_scope = NULL_TREE; $$ = 1; }
1747 | global_scope delete
1748 { got_scope = NULL_TREE; $$ = 1; }
1753 { $$ = boolean_true_node; }
1755 { $$ = boolean_false_node; }
1758 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
1762 { $$ = chainon ($$, $2); }
1768 if (DECL_CONSTRUCTOR_P (current_function_decl))
1769 finish_mem_initializers (NULL_TREE);
1775 { got_object = TREE_TYPE ($$); }
1778 $$ = build_x_arrow ($$);
1779 got_object = TREE_TYPE ($$);
1784 typespec initdecls ';'
1786 if ($1.t && IS_AGGR_TYPE_CODE (TREE_CODE ($1.t)))
1787 note_got_semicolon ($1.t);
1789 | typed_declspecs initdecls ';'
1791 note_list_got_semicolon ($1.t);
1793 | declmods notype_initdecls ';'
1795 | typed_declspecs ';'
1798 note_list_got_semicolon ($1.t);
1801 { warning ("empty declaration"); }
1806 /* Any kind of declarator (thus, all declarators allowed
1807 after an explicit typespec). */
1810 after_type_declarator %prec EMPTY
1811 | notype_declarator %prec EMPTY
1814 /* This is necessary to postpone reduction of `int()()()()'. */
1816 LEFT_RIGHT %prec EMPTY
1817 { $$ = make_call_declarator (NULL_TREE, empty_parms (),
1818 NULL_TREE, NULL_TREE); }
1819 | fcast_or_absdcl LEFT_RIGHT %prec EMPTY
1820 { $$ = make_call_declarator ($$, empty_parms (), NULL_TREE,
1824 /* ISO type-id (8.1) */
1826 typed_typespecs absdcl
1827 { $$.t = build_tree_list ($1.t, $2);
1828 $$.new_type_flag = $1.new_type_flag; }
1829 | nonempty_cv_qualifiers absdcl
1830 { $$.t = build_tree_list ($1.t, $2);
1831 $$.new_type_flag = $1.new_type_flag; }
1833 { $$.t = build_tree_list (build_tree_list (NULL_TREE, $1.t),
1835 $$.new_type_flag = $1.new_type_flag; }
1836 | typed_typespecs %prec EMPTY
1837 { $$.t = build_tree_list ($1.t, NULL_TREE);
1838 $$.new_type_flag = $1.new_type_flag; }
1839 | nonempty_cv_qualifiers %prec EMPTY
1840 { $$.t = build_tree_list ($1.t, NULL_TREE);
1841 $$.new_type_flag = $1.new_type_flag; }
1844 /* Declspecs which contain at least one type specifier or typedef name.
1845 (Just `const' or `volatile' is not enough.)
1846 A typedef'd name following these is taken as a name to be declared.
1847 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1850 typed_typespecs %prec EMPTY
1851 { $$.lookups = type_lookups; }
1853 { $$.lookups = type_lookups; }
1858 { $$.t = tree_cons (NULL_TREE, $2.t, $1.t);
1859 $$.new_type_flag = $2.new_type_flag; }
1860 | typespec reserved_declspecs %prec HYPERUNARY
1861 { $$.t = tree_cons (NULL_TREE, $1.t, $2);
1862 $$.new_type_flag = $1.new_type_flag; }
1863 | typespec reserved_typespecquals reserved_declspecs
1864 { $$.t = tree_cons (NULL_TREE, $1.t, chainon ($2, $3));
1865 $$.new_type_flag = $1.new_type_flag; }
1866 | declmods typespec reserved_declspecs
1867 { $$.t = tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1868 $$.new_type_flag = $2.new_type_flag; }
1869 | declmods typespec reserved_typespecquals
1870 { $$.t = tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1871 $$.new_type_flag = $2.new_type_flag; }
1872 | declmods typespec reserved_typespecquals reserved_declspecs
1873 { $$.t = tree_cons (NULL_TREE, $2.t,
1874 chainon ($3, chainon ($4, $1.t)));
1875 $$.new_type_flag = $2.new_type_flag; }
1880 { if (extra_warnings)
1881 warning ("`%s' is not at beginning of declaration",
1882 IDENTIFIER_POINTER ($$));
1883 $$ = build_tree_list (NULL_TREE, $$); }
1884 | reserved_declspecs typespecqual_reserved
1885 { $$ = tree_cons (NULL_TREE, $2.t, $$); }
1886 | reserved_declspecs SCSPEC
1887 { if (extra_warnings)
1888 warning ("`%s' is not at beginning of declaration",
1889 IDENTIFIER_POINTER ($2));
1890 $$ = tree_cons (NULL_TREE, $2, $$); }
1891 | reserved_declspecs attributes
1892 { $$ = tree_cons ($2, NULL_TREE, $1); }
1894 { $$ = tree_cons ($1, NULL_TREE, NULL_TREE); }
1897 /* List of just storage classes and type modifiers.
1898 A declaration can start with just this, but then it cannot be used
1899 to redeclare a typedef-name.
1900 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1902 /* We use hash_tree_cons for lists of typeless declspecs so that they end
1903 up on a persistent obstack. Otherwise, they could appear at the
1904 beginning of something like
1906 static const struct { int foo () { } } b;
1908 and would be discarded after we finish compiling foo. We don't need to
1909 worry once we see a type. */
1912 nonempty_cv_qualifiers %prec EMPTY
1913 { $$.lookups = NULL_TREE; TREE_STATIC ($$.t) = 1; }
1916 $$.t = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
1917 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
1919 | declmods CV_QUALIFIER
1921 $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
1922 TREE_STATIC ($$.t) = 1;
1926 if (extra_warnings && TREE_STATIC ($$.t))
1927 warning ("`%s' is not at beginning of declaration",
1928 IDENTIFIER_POINTER ($2));
1929 $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
1930 TREE_STATIC ($$.t) = TREE_STATIC ($1.t);
1932 | declmods attributes
1933 { $$.t = hash_tree_cons ($2, NULL_TREE, $1.t); }
1934 | attributes %prec EMPTY
1936 $$.t = hash_tree_cons ($1, NULL_TREE, NULL_TREE);
1937 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
1941 /* Used instead of declspecs where storage classes are not allowed
1942 (that is, for typenames and structure components).
1944 C++ can takes storage classes for structure components.
1945 Don't accept a typedef-name if anything but a modifier precedes it. */
1948 typespec %prec EMPTY
1949 { $$.t = build_tree_list (NULL_TREE, $1.t);
1950 $$.new_type_flag = $1.new_type_flag; }
1951 | nonempty_cv_qualifiers typespec
1952 { $$.t = tree_cons (NULL_TREE, $2.t, $1.t);
1953 $$.new_type_flag = $2.new_type_flag; }
1954 | typespec reserved_typespecquals
1955 { $$.t = tree_cons (NULL_TREE, $1.t, $2);
1956 $$.new_type_flag = $1.new_type_flag; }
1957 | nonempty_cv_qualifiers typespec reserved_typespecquals
1958 { $$.t = tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1959 $$.new_type_flag = $2.new_type_flag; }
1962 reserved_typespecquals:
1963 typespecqual_reserved
1964 { $$ = build_tree_list (NULL_TREE, $1.t); }
1965 | reserved_typespecquals typespecqual_reserved
1966 { $$ = tree_cons (NULL_TREE, $2.t, $1); }
1969 /* A typespec (but not a type qualifier).
1970 Once we have seen one of these in a declaration,
1971 if a typedef name appears then it is being redeclared. */
1975 { $$.lookups = NULL_TREE; }
1976 | TYPESPEC %prec EMPTY
1977 { $$.t = $1; $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
1978 | complete_type_name
1979 { $$.t = $1; $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
1980 | TYPEOF '(' expr ')'
1981 { $$.t = finish_typeof ($3);
1982 $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
1983 | TYPEOF '(' type_id ')'
1984 { $$.t = groktypename ($3.t);
1985 $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
1986 | SIGOF '(' expr ')'
1987 { tree type = TREE_TYPE ($3);
1989 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
1990 if (IS_AGGR_TYPE (type))
1992 sorry ("sigof type specifier");
1997 error ("`sigof' applied to non-aggregate expression");
1998 $$.t = error_mark_node;
2001 | SIGOF '(' type_id ')'
2002 { tree type = groktypename ($3.t);
2004 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
2005 if (IS_AGGR_TYPE (type))
2007 sorry ("sigof type specifier");
2012 error("`sigof' applied to non-aggregate type");
2013 $$.t = error_mark_node;
2018 /* A typespec that is a reserved word, or a type qualifier. */
2020 typespecqual_reserved:
2022 { $$.t = $1; $$.new_type_flag = 0; }
2024 { $$.t = $1; $$.new_type_flag = 0; }
2030 | initdecls ',' initdcl
2031 { check_multiple_declarators (); }
2036 | notype_initdecls ',' initdcl
2037 { check_multiple_declarators (); }
2042 | nomods_initdecls ',' initdcl
2043 { check_multiple_declarators (); }
2049 | asm_keyword '(' string ')'
2050 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3); $$ = $3; }
2054 declarator maybeasm maybe_attribute '='
2055 { $<ttype>$ = parse_decl ($<ttype>1, $3, 1); }
2057 /* Note how the declaration of the variable is in effect while its init is parsed! */
2058 { parse_end_decl ($<ttype>5, $6, $2); }
2059 | declarator maybeasm maybe_attribute
2061 $<ttype>$ = parse_decl ($<ttype>1, $3, 0);
2062 parse_end_decl ($<ttype>$, NULL_TREE, $2);
2066 /* This rule assumes a certain configuration of the parser stack.
2067 In particular, $0, the element directly before the beginning of
2068 this rule on the stack, must be a maybeasm. $-1 must be a
2069 declarator or notype_declarator. And $-2 must be some declmods
2070 or declspecs. We can't move the maybeasm into this rule because
2071 we need that reduce so we prefer fn.def1 when appropriate. */
2074 { $<ttype>$ = parse_decl0 ($<ttype>-1, $<ftype>-2.t,
2075 $<ftype>-2.lookups, $1, 1); }
2076 /* Note how the declaration of the variable is in effect
2077 while its init is parsed! */
2079 { parse_end_decl ($<ttype>3, $4, $<ttype>0); }
2081 { tree d = parse_decl0 ($<ttype>-1, $<ftype>-2.t,
2082 $<ftype>-2.lookups, $1, 0);
2083 parse_end_decl (d, NULL_TREE, $<ttype>0); }
2087 declarator maybeasm initdcl0_innards
2092 notype_declarator maybeasm initdcl0_innards
2097 notype_declarator maybeasm
2098 { /* Set things up as initdcl0_innards expects. */
2101 $<ftype>1.t = NULL_TREE;
2102 $<ftype>1.lookups = NULL_TREE; }
2105 | constructor_declarator maybeasm maybe_attribute
2106 { tree d = parse_decl0 ($1, NULL_TREE, NULL_TREE, $3, 0);
2107 parse_end_decl (d, NULL_TREE, $2); }
2110 /* the * rules are dummies to accept the Apollo extended syntax
2111 so that the header files compile. */
2122 | attributes attribute
2123 { $$ = chainon ($1, $2); }
2127 ATTRIBUTE '(' '(' attribute_list ')' ')'
2134 | attribute_list ',' attrib
2135 { $$ = chainon ($1, $3); }
2142 { $$ = build_tree_list ($1, NULL_TREE); }
2143 | any_word '(' IDENTIFIER ')'
2144 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
2145 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
2146 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
2147 | any_word '(' nonnull_exprlist ')'
2148 { $$ = build_tree_list ($1, $3); }
2151 /* This still leaves out most reserved keywords,
2152 shouldn't we include them? */
2161 /* A nonempty list of identifiers, including typenames. */
2162 identifiers_or_typenames:
2164 { $$ = build_tree_list (NULL_TREE, $1); }
2165 | identifiers_or_typenames ',' identifier
2166 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2170 /* empty */ %prec EMPTY
2175 /* If we are processing a template, we don't want to expand this
2179 expr_no_commas %prec '='
2181 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, NULL_TREE);
2182 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2184 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2185 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2186 | '{' initlist ',' '}'
2187 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2188 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2193 /* This chain is built in reverse order,
2194 and put in forward order where initlist is used. */
2197 { $$ = build_tree_list (NULL_TREE, $$); }
2199 { $$ = tree_cons (NULL_TREE, $3, $$); }
2200 /* These are for labeled elements. */
2201 | '[' expr_no_commas ']' init
2202 { $$ = build_tree_list ($2, $4); }
2203 | identifier ':' init
2204 { $$ = build_tree_list ($$, $3); }
2205 | initlist ',' identifier ':' init
2206 { $$ = tree_cons ($3, $5, $$); }
2210 PRE_PARSED_FUNCTION_DECL maybe_return_init function_body
2212 expand_body (finish_function (2));
2213 process_next_inline ($1);
2215 | PRE_PARSED_FUNCTION_DECL maybe_return_init function_try_block
2217 expand_body (finish_function (2));
2218 process_next_inline ($1);
2220 | PRE_PARSED_FUNCTION_DECL maybe_return_init error
2222 finish_function (2);
2223 process_next_inline ($1); }
2228 | pending_inlines pending_inline eat_saved_input
2231 /* A regurgitated default argument. The value of DEFARG_MARKER will be
2232 the TREE_LIST node for the parameter in question. */
2234 DEFARG_MARKER expr_no_commas END_OF_SAVED_INPUT
2235 { replace_defarg ($1, $2); }
2236 | DEFARG_MARKER error END_OF_SAVED_INPUT
2237 { replace_defarg ($1, error_mark_node); }
2240 /* empty */ %prec EMPTY
2241 | pending_defargs defarg_again
2242 { do_pending_defargs (); }
2243 | pending_defargs error
2244 { do_pending_defargs (); }
2249 { $<ttype>$ = current_enum_type;
2250 current_enum_type = start_enum ($2); }
2252 { $$.t = current_enum_type;
2253 finish_enum (current_enum_type);
2254 $$.new_type_flag = 1;
2255 current_enum_type = $<ttype>4;
2256 check_for_missing_semicolon ($$.t); }
2258 { $<ttype>$ = current_enum_type;
2259 current_enum_type = start_enum (make_anon_name ()); }
2261 { $$.t = current_enum_type;
2262 finish_enum (current_enum_type);
2263 $$.new_type_flag = 1;
2264 current_enum_type = $<ttype>3;
2265 check_for_missing_semicolon ($$.t); }
2267 { $$.t = xref_tag (enum_type_node, $2, 1);
2268 $$.new_type_flag = 0; }
2269 | ENUM complex_type_name
2270 { $$.t = xref_tag (enum_type_node, $2, 1);
2271 $$.new_type_flag = 0; }
2272 | TYPENAME_KEYWORD typename_sub
2274 $$.new_type_flag = 0;
2275 if (!processing_template_decl)
2276 pedwarn ("using `typename' outside of template"); }
2277 /* C++ extensions, merged with C to avoid shift/reduce conflicts */
2278 | class_head_defn maybe_base_class_list '{'
2280 if ($2 && $1.t != error_mark_node)
2282 tree type = TREE_TYPE ($1.t);
2284 if (TREE_CODE (type) == TYPENAME_TYPE)
2285 /* In a definition of a member class template,
2286 we will get here with an implicit typename,
2287 a TYPENAME_TYPE with a type. */
2288 type = TREE_TYPE (type);
2289 maybe_process_partial_specialization (type);
2290 xref_basetypes (current_aggr, $1.t, type, $2);
2292 $1.t = begin_class_definition (TREE_TYPE ($1.t));
2293 current_aggr = NULL_TREE; }
2294 opt.component_decl_list '}' maybe_attribute
2299 if (yychar == YYEMPTY)
2301 semi = yychar == ';';
2303 t = finish_class_definition ($1.t, $7, semi, $1.new_type_flag);
2306 /* restore current_aggr */
2307 current_aggr = TREE_CODE (t) != RECORD_TYPE
2309 : CLASSTYPE_DECLARED_CLASS (t)
2310 ? class_type_node : record_type_node;
2314 done_pending_defargs ();
2315 begin_inline_definitions ();
2319 finish_inline_definitions ();
2321 $$.new_type_flag = 1;
2325 $$.t = TREE_TYPE ($1.t);
2326 $$.new_type_flag = $1.new_type_flag;
2338 { if (pedantic && !in_system_header)
2339 pedwarn ("comma at end of enumerator list"); }
2345 { error ("storage class specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2347 { error ("type specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2349 { error ("type qualifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2351 { error ("no body nor ';' separates two class, struct or union declarations"); }
2353 { $$ = build_tree_list ($2, $1); }
2360 $$ = build_tree_list (NULL_TREE, $2);
2362 | aggr nested_name_specifier identifier
2365 $$ = build_tree_list ($2, $3);
2367 | aggr global_scope nested_name_specifier identifier
2370 $$ = build_tree_list ($3, $4);
2372 | aggr global_scope identifier
2375 $$ = build_tree_list (global_namespace, $3);
2379 class_head_apparent_template:
2380 aggr apparent_template_type
2385 | aggr nested_name_specifier apparent_template_type
2390 | aggr global_scope nested_name_specifier apparent_template_type
2398 class_head %prec EMPTY
2400 $$.t = handle_class_head (current_aggr,
2401 TREE_PURPOSE ($1), TREE_VALUE ($1),
2402 0, &$$.new_type_flag);
2404 | aggr identifier_defn %prec EMPTY
2407 $$.t = TYPE_MAIN_DECL (xref_tag (current_aggr, $2, 0));
2408 $$.new_type_flag = 1;
2410 | class_head_apparent_template %prec EMPTY
2413 $$.new_type_flag = 0;
2421 $$.t = handle_class_head (current_aggr,
2422 TREE_PURPOSE ($1), TREE_VALUE ($1),
2423 1, &$$.new_type_flag);
2428 $$.t = handle_class_head (current_aggr,
2429 TREE_PURPOSE ($1), TREE_VALUE ($1),
2430 1, &$$.new_type_flag);
2432 | class_head_apparent_template '{'
2436 $$.new_type_flag = 0;
2438 | class_head_apparent_template ':'
2442 $$.new_type_flag = 0;
2444 | aggr identifier_defn '{'
2448 $$.t = handle_class_head (current_aggr,
2450 1, &$$.new_type_flag);
2452 | aggr identifier_defn ':'
2456 $$.t = handle_class_head (current_aggr,
2458 1, &$$.new_type_flag);
2463 $$.t = TYPE_MAIN_DECL (xref_tag ($1, make_anon_name (), 0));
2464 $$.new_type_flag = 0;
2469 maybe_base_class_list:
2473 { error ("no bases given following `:'");
2475 | ':' see_typename base_class_list
2481 | base_class_list ',' see_typename base_class
2482 { $$ = chainon ($$, $4); }
2487 { $$ = finish_base_specifier (access_default_node, $1); }
2488 | base_class_access_list see_typename base_class.1
2489 { $$ = finish_base_specifier ($1, $3); }
2495 $$ = error_mark_node; }
2497 { $$ = TREE_TYPE ($$); }
2500 base_class_access_list:
2501 VISSPEC see_typename
2502 | SCSPEC see_typename
2503 { if ($1 != ridpointers[(int)RID_VIRTUAL])
2504 error ("`%D' access", $1);
2505 $$ = access_default_virtual_node; }
2506 | base_class_access_list VISSPEC see_typename
2508 if ($1 != access_default_virtual_node)
2509 error ("multiple access specifiers");
2510 else if ($2 == access_public_node)
2511 $$ = access_public_virtual_node;
2512 else if ($2 == access_protected_node)
2513 $$ = access_protected_virtual_node;
2514 else /* $2 == access_private_node */
2515 $$ = access_private_virtual_node;
2517 | base_class_access_list SCSPEC see_typename
2518 { if ($2 != ridpointers[(int)RID_VIRTUAL])
2519 error ("`%D' access", $2);
2520 else if ($$ == access_public_node)
2521 $$ = access_public_virtual_node;
2522 else if ($$ == access_protected_node)
2523 $$ = access_protected_virtual_node;
2524 else if ($$ == access_private_node)
2525 $$ = access_private_virtual_node;
2527 error ("multiple `virtual' specifiers");
2531 opt.component_decl_list:
2532 | component_decl_list
2533 | opt.component_decl_list access_specifier component_decl_list
2534 | opt.component_decl_list access_specifier
2540 current_access_specifier = $1;
2544 /* Note: we no longer warn about the semicolon after a component_decl_list.
2545 ARM $9.2 says that the semicolon is optional, and therefore allowed. */
2546 component_decl_list:
2549 finish_member_declaration ($1);
2550 current_aggr = NULL_TREE;
2551 reset_type_access_control ();
2553 | component_decl_list component_decl
2555 finish_member_declaration ($2);
2556 current_aggr = NULL_TREE;
2557 reset_type_access_control ();
2562 component_decl_1 ';'
2563 | component_decl_1 '}'
2564 { error ("missing ';' before right brace");
2565 yyungetc ('}', 0); }
2566 /* C++: handle constructors, destructors and inline functions */
2567 /* note that INLINE is like a TYPESPEC */
2568 | fn.def2 ':' /* base_init compstmt */
2569 { $$ = finish_method ($$); }
2570 | fn.def2 TRY /* base_init compstmt */
2571 { $$ = finish_method ($$); }
2572 | fn.def2 RETURN_KEYWORD /* base_init compstmt */
2573 { $$ = finish_method ($$); }
2574 | fn.def2 '{' /* nodecls compstmt */
2575 { $$ = finish_method ($$); }
2578 | extension component_decl
2581 | template_header component_decl
2584 $$ = finish_member_template_decl ($2);
2586 /* The component was already processed. */
2589 finish_template_decl ($1);
2591 | template_header typed_declspecs ';'
2593 $$ = finish_member_class_template ($2.t);
2594 finish_template_decl ($1);
2601 /* Do not add a "typed_declspecs declarator" rule here for
2602 speed; we need to call grok_x_components for enums, so the
2603 speedup would be insignificant. */
2604 typed_declspecs components
2606 /* Most of the productions for component_decl only
2607 allow the creation of one new member, so we call
2608 finish_member_declaration in component_decl_list.
2609 For this rule and the next, however, there can be
2610 more than one member, e.g.:
2614 and we need the first member to be fully
2615 registered before the second is processed.
2616 Therefore, the rules for components take care of
2617 this processing. To avoid registering the
2618 components more than once, we send NULL_TREE up
2619 here; that lets finish_member_declaration know
2620 that there is nothing to do. */
2622 grok_x_components ($1.t);
2625 | declmods notype_components
2628 grok_x_components ($1.t);
2631 | notype_declarator maybeasm maybe_attribute maybe_init
2632 { $$ = grokfield ($$, NULL_TREE, $4, $2, $3); }
2633 | constructor_declarator maybeasm maybe_attribute maybe_init
2634 { $$ = grokfield ($$, NULL_TREE, $4, $2, $3); }
2635 | ':' expr_no_commas
2636 { $$ = grokbitfield (NULL_TREE, NULL_TREE, $2); }
2640 /* These rules introduce a reduce/reduce conflict; in
2641 typedef int foo, bar;
2645 should "A::foo" be declared as a function or "A::bar" as a data
2646 member? In other words, is "bar" an after_type_declarator or a
2648 | declmods component_constructor_declarator maybeasm maybe_attribute maybe_init
2649 { tree specs, attrs;
2650 split_specs_attrs ($1.t, &specs, &attrs);
2651 $$ = grokfield ($2, specs, $5, $3,
2652 chainon ($4, attrs)); }
2653 | component_constructor_declarator maybeasm maybe_attribute maybe_init
2654 { $$ = grokfield ($$, NULL_TREE, $4, $2, $3); }
2656 { $$ = do_class_using_decl ($1); }
2658 /* The case of exactly one component is handled directly by component_decl. */
2661 /* empty: possibly anonymous */
2663 | component_declarator0
2665 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2666 $1 = finish_member_template_decl ($1);
2667 finish_member_declaration ($1);
2670 | components ',' component_declarator
2672 check_multiple_declarators ();
2673 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2674 $3 = finish_member_template_decl ($3);
2675 finish_member_declaration ($3);
2681 /* empty: possibly anonymous */
2683 | notype_component_declarator0
2685 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2686 $1 = finish_member_template_decl ($1);
2687 finish_member_declaration ($1);
2690 | notype_components ',' notype_component_declarator
2692 check_multiple_declarators ();
2693 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2694 $3 = finish_member_template_decl ($3);
2695 finish_member_declaration ($3);
2700 component_declarator0:
2701 after_type_component_declarator0
2702 | notype_component_declarator0
2705 component_declarator:
2706 after_type_component_declarator
2707 | notype_component_declarator
2710 after_type_component_declarator0:
2711 after_type_declarator maybeasm maybe_attribute maybe_init
2712 { $$ = parse_field0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2714 | TYPENAME ':' expr_no_commas maybe_attribute
2715 { $$ = parse_bitfield0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2719 notype_component_declarator0:
2720 notype_declarator maybeasm maybe_attribute maybe_init
2721 { $$ = parse_field0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2723 | constructor_declarator maybeasm maybe_attribute maybe_init
2724 { $$ = parse_field0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2726 | IDENTIFIER ':' expr_no_commas maybe_attribute
2727 { $$ = parse_bitfield0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2729 | ':' expr_no_commas maybe_attribute
2730 { $$ = parse_bitfield0 (NULL_TREE, $<ftype>0.t,
2731 $<ftype>0.lookups, $3, $2); }
2734 after_type_component_declarator:
2735 after_type_declarator maybeasm maybe_attribute maybe_init
2736 { $$ = parse_field ($1, $3, $2, $4); }
2737 | TYPENAME ':' expr_no_commas maybe_attribute
2738 { $$ = parse_bitfield ($1, $4, $3); }
2741 notype_component_declarator:
2742 notype_declarator maybeasm maybe_attribute maybe_init
2743 { $$ = parse_field ($1, $3, $2, $4); }
2744 | IDENTIFIER ':' expr_no_commas maybe_attribute
2745 { $$ = parse_bitfield ($1, $4, $3); }
2746 | ':' expr_no_commas maybe_attribute
2747 { $$ = parse_bitfield (NULL_TREE, $3, $2); }
2751 enumlist maybecomma_warn
2755 /* We chain the enumerators in reverse order.
2756 Because of the way enums are built, the order is
2757 insignificant. Take advantage of this fact. */
2761 | enumlist ',' enumerator
2766 { build_enumerator ($1, NULL_TREE, current_enum_type); }
2767 | identifier '=' expr_no_commas
2768 { build_enumerator ($1, $3, current_enum_type); }
2771 /* ISO new-type-id (5.3.4) */
2773 type_specifier_seq new_declarator
2774 { $$.t = build_tree_list ($1.t, $2);
2775 $$.new_type_flag = $1.new_type_flag; }
2776 | type_specifier_seq %prec EMPTY
2777 { $$.t = build_tree_list ($1.t, NULL_TREE);
2778 $$.new_type_flag = $1.new_type_flag; }
2779 /* GNU extension to allow arrays of arbitrary types with
2780 non-constant dimension. */
2781 | '(' type_id ')' '[' expr ']'
2784 pedwarn ("ISO C++ forbids array dimensions with parenthesized type in new");
2785 $$.t = build_nt (ARRAY_REF, TREE_VALUE ($2.t), $5);
2786 $$.t = build_tree_list (TREE_PURPOSE ($2.t), $$.t);
2787 $$.new_type_flag = $2.new_type_flag;
2792 /* empty */ %prec EMPTY
2794 | cv_qualifiers CV_QUALIFIER
2795 { $$ = tree_cons (NULL_TREE, $2, $$); }
2798 nonempty_cv_qualifiers:
2800 { $$.t = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
2801 $$.new_type_flag = 0; }
2802 | nonempty_cv_qualifiers CV_QUALIFIER
2803 { $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
2804 $$.new_type_flag = $1.new_type_flag; }
2807 /* These rules must follow the rules for function declarations
2808 and component declarations. That way, longer rules are preferred. */
2810 /* An expression which will not live on the momentary obstack. */
2812 '(' nonnull_exprlist ')'
2817 { $$ = empty_parms (); }
2822 /* A declarator that is allowed only after an explicit typespec. */
2824 after_type_declarator_intern:
2825 after_type_declarator
2826 | attributes after_type_declarator
2828 /* Provide support for '(' attributes '*' declarator ')'
2830 $$ = tree_cons ($1, $2, NULL_TREE);
2834 /* may all be followed by prec '.' */
2835 after_type_declarator:
2836 '*' nonempty_cv_qualifiers after_type_declarator_intern %prec UNARY
2837 { $$ = make_pointer_declarator ($2.t, $3); }
2838 | '&' nonempty_cv_qualifiers after_type_declarator_intern %prec UNARY
2839 { $$ = make_reference_declarator ($2.t, $3); }
2840 | '*' after_type_declarator_intern %prec UNARY
2841 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2842 | '&' after_type_declarator_intern %prec UNARY
2843 { $$ = make_reference_declarator (NULL_TREE, $2); }
2844 | ptr_to_mem cv_qualifiers after_type_declarator_intern
2845 { tree arg = make_pointer_declarator ($2, $3);
2846 $$ = build_nt (SCOPE_REF, $1, arg);
2848 | direct_after_type_declarator
2851 direct_after_type_declarator:
2852 direct_after_type_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2853 { $$ = make_call_declarator ($$, $2, $3, $4); }
2854 | direct_after_type_declarator '[' expr ']'
2855 { $$ = build_nt (ARRAY_REF, $$, $3); }
2856 | direct_after_type_declarator '[' ']'
2857 { $$ = build_nt (ARRAY_REF, $$, NULL_TREE); }
2858 | '(' after_type_declarator_intern ')'
2860 | nested_name_specifier type_name %prec EMPTY
2861 { push_nested_class ($1, 3);
2862 $$ = build_nt (SCOPE_REF, $$, $2);
2863 TREE_COMPLEXITY ($$) = current_class_depth; }
2864 | type_name %prec EMPTY
2868 type_name %prec EMPTY
2870 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2872 $$ = lookup_name ($1, 1);
2873 maybe_note_name_used_in_class ($1, $$);
2878 | global_scope type_name
2880 if (TREE_CODE ($2) == IDENTIFIER_NODE)
2881 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
2884 got_scope = NULL_TREE;
2891 | global_scope nested_type
2896 nested_name_specifier type_name %prec EMPTY
2897 { $$ = get_type_decl ($2); }
2900 /* A declarator allowed whether or not there has been
2901 an explicit typespec. These cannot redeclare a typedef-name. */
2903 notype_declarator_intern:
2905 | attributes notype_declarator
2907 /* Provide support for '(' attributes '*' declarator ')'
2909 $$ = tree_cons ($1, $2, NULL_TREE);
2914 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2915 { $$ = make_pointer_declarator ($2.t, $3); }
2916 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2917 { $$ = make_reference_declarator ($2.t, $3); }
2918 | '*' notype_declarator_intern %prec UNARY
2919 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2920 | '&' notype_declarator_intern %prec UNARY
2921 { $$ = make_reference_declarator (NULL_TREE, $2); }
2922 | ptr_to_mem cv_qualifiers notype_declarator_intern
2923 { tree arg = make_pointer_declarator ($2, $3);
2924 $$ = build_nt (SCOPE_REF, $1, arg);
2926 | direct_notype_declarator
2929 complex_notype_declarator:
2930 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2931 { $$ = make_pointer_declarator ($2.t, $3); }
2932 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2933 { $$ = make_reference_declarator ($2.t, $3); }
2934 | '*' complex_notype_declarator %prec UNARY
2935 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2936 | '&' complex_notype_declarator %prec UNARY
2937 { $$ = make_reference_declarator (NULL_TREE, $2); }
2938 | ptr_to_mem cv_qualifiers notype_declarator_intern
2939 { tree arg = make_pointer_declarator ($2, $3);
2940 $$ = build_nt (SCOPE_REF, $1, arg);
2942 | complex_direct_notype_declarator
2945 complex_direct_notype_declarator:
2946 direct_notype_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2947 { $$ = make_call_declarator ($$, $2, $3, $4); }
2948 | '(' complex_notype_declarator ')'
2950 | direct_notype_declarator '[' expr ']'
2951 { $$ = build_nt (ARRAY_REF, $$, $3); }
2952 | direct_notype_declarator '[' ']'
2953 { $$ = build_nt (ARRAY_REF, $$, NULL_TREE); }
2954 | notype_qualified_id
2955 { enter_scope_of ($1); }
2956 | global_scope notype_qualified_id
2957 { enter_scope_of ($2); $$ = $2;}
2958 | global_scope notype_unqualified_id
2959 { $$ = build_nt (SCOPE_REF, global_namespace, $2);
2960 enter_scope_of ($$);
2962 | nested_name_specifier notype_template_declarator
2963 { got_scope = NULL_TREE;
2964 $$ = build_nt (SCOPE_REF, $1, $2);
2965 enter_scope_of ($$);
2970 nested_name_specifier unqualified_id
2971 { got_scope = NULL_TREE;
2972 $$ = build_nt (SCOPE_REF, $$, $2); }
2973 | nested_name_specifier object_template_id
2974 { got_scope = NULL_TREE;
2975 $$ = build_nt (SCOPE_REF, $1, $2); }
2978 notype_qualified_id:
2979 nested_name_specifier notype_unqualified_id
2980 { got_scope = NULL_TREE;
2981 $$ = build_nt (SCOPE_REF, $$, $2); }
2982 | nested_name_specifier object_template_id
2983 { got_scope = NULL_TREE;
2984 $$ = build_nt (SCOPE_REF, $1, $2); }
2989 | global_scope notype_qualified_id
2994 typespec '(' nonnull_exprlist ')'
2995 { $$ = build_functional_cast ($1.t, $3); }
2996 | typespec '(' expr_or_declarator_intern ')'
2997 { $$ = reparse_decl_as_expr ($1.t, $3); }
2998 | typespec fcast_or_absdcl %prec EMPTY
2999 { $$ = reparse_absdcl_as_expr ($1.t, $2); }
3005 | template_type %prec EMPTY
3008 nested_name_specifier:
3009 nested_name_specifier_1
3010 | nested_name_specifier nested_name_specifier_1
3012 | nested_name_specifier TEMPLATE explicit_template_type SCOPE
3014 = make_typename_type ($1, $3, /*complain=*/1); }
3015 /* Error handling per Core 125. */
3016 | nested_name_specifier IDENTIFIER SCOPE
3018 = make_typename_type ($1, $2, /*complain=*/1); }
3019 | nested_name_specifier PTYPENAME SCOPE
3021 = make_typename_type ($1, $2, /*complain=*/1); }
3024 /* Why the @#$%^& do type_name and notype_identifier need to be expanded
3025 inline here?!? (jason) */
3026 nested_name_specifier_1:
3029 if (TREE_CODE ($1) == IDENTIFIER_NODE)
3032 maybe_note_name_used_in_class ($1, $$);
3035 complete_type (TYPE_MAIN_VARIANT (TREE_TYPE ($$)));
3039 if (TREE_CODE ($1) == IDENTIFIER_NODE)
3041 got_scope = $$ = TREE_TYPE ($$);
3045 if (TREE_CODE ($$) == IDENTIFIER_NODE)
3049 | template_type SCOPE
3050 { got_scope = $$ = complete_type (TREE_TYPE ($1)); }
3055 | global_scope typename_sub0
3060 typename_sub1 identifier %prec EMPTY
3063 $$ = make_typename_type ($1, $2, /*complain=*/1);
3064 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
3065 error ("`%T' is not a class or namespace", $2);
3069 if (TREE_CODE ($$) == TYPE_DECL)
3070 $$ = TREE_TYPE ($$);
3073 | typename_sub1 template_type %prec EMPTY
3074 { $$ = TREE_TYPE ($2); }
3075 | typename_sub1 explicit_template_type %prec EMPTY
3076 { $$ = make_typename_type ($1, $2, /*complain=*/1); }
3077 | typename_sub1 TEMPLATE explicit_template_type %prec EMPTY
3078 { $$ = make_typename_type ($1, $3, /*complain=*/1); }
3084 if (TREE_CODE ($1) == IDENTIFIER_NODE)
3085 error ("`%T' is not a class or namespace", $1);
3086 else if (TREE_CODE ($1) == TYPE_DECL)
3087 $$ = TREE_TYPE ($1);
3089 | typename_sub1 typename_sub2
3092 $$ = make_typename_type ($1, $2, /*complain=*/1);
3093 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
3094 error ("`%T' is not a class or namespace", $2);
3098 if (TREE_CODE ($$) == TYPE_DECL)
3099 $$ = TREE_TYPE ($$);
3102 | typename_sub1 explicit_template_type SCOPE
3104 = make_typename_type ($1, $2, /*complain=*/1); }
3105 | typename_sub1 TEMPLATE explicit_template_type SCOPE
3107 = make_typename_type ($1, $3, /*complain=*/1); }
3110 /* This needs to return a TYPE_DECL for simple names so that we don't
3111 forget what name was used. */
3115 if (TREE_CODE ($1) != TYPE_DECL)
3118 /* Retrieve the type for the identifier, which might involve
3119 some computation. */
3120 got_scope = complete_type (TREE_TYPE ($$));
3122 if ($$ == error_mark_node)
3123 error ("`%T' is not a class or namespace", $1);
3127 if (TREE_CODE ($1) != TYPE_DECL)
3129 got_scope = complete_type (TREE_TYPE ($$));
3131 | template_type SCOPE
3132 { got_scope = $$ = complete_type (TREE_TYPE ($$)); }
3137 if (TREE_CODE ($$) == IDENTIFIER_NODE)
3143 explicit_template_type:
3144 identifier '<' template_arg_list_opt template_close_bracket
3145 { $$ = build_min_nt (TEMPLATE_ID_EXPR, $1, $3); }
3149 global_scope type_name
3151 if (TREE_CODE ($2) == IDENTIFIER_NODE)
3152 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
3155 got_scope = NULL_TREE;
3158 | global_scope nested_type
3163 nested_name_specifier '*'
3164 { got_scope = NULL_TREE; }
3165 | global_scope nested_name_specifier '*'
3166 { $$ = $2; got_scope = NULL_TREE; }
3169 /* All uses of explicit global scope must go through this nonterminal so
3170 that got_scope will be set before yylex is called to get the next token. */
3173 { got_scope = void_type_node; }
3176 /* ISO new-declarator (5.3.4) */
3178 '*' cv_qualifiers new_declarator
3179 { $$ = make_pointer_declarator ($2, $3); }
3180 | '*' cv_qualifiers %prec EMPTY
3181 { $$ = make_pointer_declarator ($2, NULL_TREE); }
3182 | '&' cv_qualifiers new_declarator %prec EMPTY
3183 { $$ = make_reference_declarator ($2, $3); }
3184 | '&' cv_qualifiers %prec EMPTY
3185 { $$ = make_reference_declarator ($2, NULL_TREE); }
3186 | ptr_to_mem cv_qualifiers %prec EMPTY
3187 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3188 $$ = build_nt (SCOPE_REF, $1, arg);
3190 | ptr_to_mem cv_qualifiers new_declarator
3191 { tree arg = make_pointer_declarator ($2, $3);
3192 $$ = build_nt (SCOPE_REF, $1, arg);
3194 | direct_new_declarator %prec EMPTY
3197 /* ISO direct-new-declarator (5.3.4) */
3198 direct_new_declarator:
3200 { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
3201 | direct_new_declarator '[' expr ']'
3202 { $$ = build_nt (ARRAY_REF, $$, $3); }
3209 /* Provide support for '(' attributes '*' declarator ')'
3211 $$ = tree_cons ($1, $2, NULL_TREE);
3215 /* ISO abstract-declarator (8.1) */
3217 '*' nonempty_cv_qualifiers absdcl_intern
3218 { $$ = make_pointer_declarator ($2.t, $3); }
3220 { $$ = make_pointer_declarator (NULL_TREE, $2); }
3221 | '*' nonempty_cv_qualifiers %prec EMPTY
3222 { $$ = make_pointer_declarator ($2.t, NULL_TREE); }
3224 { $$ = make_pointer_declarator (NULL_TREE, NULL_TREE); }
3225 | '&' nonempty_cv_qualifiers absdcl_intern
3226 { $$ = make_reference_declarator ($2.t, $3); }
3228 { $$ = make_reference_declarator (NULL_TREE, $2); }
3229 | '&' nonempty_cv_qualifiers %prec EMPTY
3230 { $$ = make_reference_declarator ($2.t, NULL_TREE); }
3232 { $$ = make_reference_declarator (NULL_TREE, NULL_TREE); }
3233 | ptr_to_mem cv_qualifiers %prec EMPTY
3234 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3235 $$ = build_nt (SCOPE_REF, $1, arg);
3237 | ptr_to_mem cv_qualifiers absdcl_intern
3238 { tree arg = make_pointer_declarator ($2, $3);
3239 $$ = build_nt (SCOPE_REF, $1, arg);
3241 | direct_abstract_declarator %prec EMPTY
3244 /* ISO direct-abstract-declarator (8.1) */
3245 direct_abstract_declarator:
3246 '(' absdcl_intern ')'
3248 /* `(typedef)1' is `int'. */
3249 | direct_abstract_declarator '(' parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3250 { $$ = make_call_declarator ($$, $3, $5, $6); }
3251 | direct_abstract_declarator LEFT_RIGHT cv_qualifiers exception_specification_opt %prec '.'
3252 { $$ = make_call_declarator ($$, empty_parms (), $3, $4); }
3253 | direct_abstract_declarator '[' expr ']' %prec '.'
3254 { $$ = build_nt (ARRAY_REF, $$, $3); }
3255 | direct_abstract_declarator '[' ']' %prec '.'
3256 { $$ = build_nt (ARRAY_REF, $$, NULL_TREE); }
3257 | '(' complex_parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3258 { $$ = make_call_declarator (NULL_TREE, $2, $4, $5); }
3259 | regcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3260 { set_quals_and_spec ($$, $2, $3); }
3261 | fcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3262 { set_quals_and_spec ($$, $2, $3); }
3263 | '[' expr ']' %prec '.'
3264 { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
3266 { $$ = build_nt (ARRAY_REF, NULL_TREE, NULL_TREE); }
3269 /* For C++, decls and stmts can be intermixed, so we don't need to
3270 have a special rule that won't start parsing the stmt section
3271 until we have a stmt that parses without errors. */
3284 /* Read zero or more forward-declarations for labels
3285 that nested functions can jump to. */
3290 pedwarn ("ISO C++ forbids label declarations"); }
3295 | label_decls label_decl
3299 LABEL identifiers_or_typenames ';'
3303 finish_label_decl (TREE_VALUE ($2));
3304 $2 = TREE_CHAIN ($2);
3311 { $<ttype>$ = begin_compound_stmt (0); }
3313 { STMT_LINENO ($<ttype>3) = $1;
3314 finish_compound_stmt (0, $<ttype>3); }
3319 { $<ttype>$ = begin_if_stmt ();
3320 cond_stmt_keyword = "if"; }
3322 { finish_if_stmt_cond ($3, $<ttype>2); }
3323 implicitly_scoped_stmt
3325 finish_then_clause ($<ttype>2); }
3328 implicitly_scoped_stmt:
3331 { $<ttype>$ = begin_compound_stmt (0); }
3332 save_lineno simple_stmt
3333 { STMT_LINENO ($<ttype>1) = $2;
3334 if ($3) STMT_LINENO ($3) = $2;
3335 finish_compound_stmt (0, $<ttype>1); }
3340 | save_lineno simple_stmt
3341 { if ($2) STMT_LINENO ($2) = $1; }
3349 { $$ = finish_expr_stmt ($1); }
3351 { begin_else_clause (); }
3352 implicitly_scoped_stmt
3355 finish_else_clause ($1);
3358 | simple_if %prec IF
3360 finish_if_stmt (); }
3363 $<ttype>$ = begin_while_stmt ();
3364 cond_stmt_keyword = "while";
3367 { finish_while_stmt_cond ($3, $<ttype>2); }
3368 implicitly_scoped_stmt
3370 finish_while_stmt ($<ttype>2); }
3372 { $<ttype>$ = begin_do_stmt (); }
3373 implicitly_scoped_stmt WHILE
3375 finish_do_body ($<ttype>2);
3376 cond_stmt_keyword = "do";
3378 paren_expr_or_null ';'
3380 finish_do_stmt ($6, $<ttype>2); }
3382 { $<ttype>$ = begin_for_stmt (); }
3383 '(' for.init.statement
3384 { finish_for_init_stmt ($<ttype>2); }
3386 { finish_for_cond ($6, $<ttype>2); }
3388 { finish_for_expr ($9, $<ttype>2); }
3389 implicitly_scoped_stmt
3391 finish_for_stmt ($<ttype>2); }
3393 { $<ttype>$ = begin_switch_stmt (); }
3395 { finish_switch_cond ($4, $<ttype>2); }
3396 implicitly_scoped_stmt
3398 finish_switch_stmt ($<ttype>2); }
3399 | CASE expr_no_commas ':'
3400 { $<ttype>$ = finish_case_label ($2, NULL_TREE); }
3403 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
3404 { $<ttype>$ = finish_case_label ($2, $4); }
3408 { $<ttype>$ = finish_case_label (NULL_TREE, NULL_TREE); }
3412 { $$ = finish_break_stmt (); }
3414 { $$ = finish_continue_stmt (); }
3415 | RETURN_KEYWORD ';'
3416 { $$ = finish_return_stmt (NULL_TREE); }
3417 | RETURN_KEYWORD expr ';'
3418 { $$ = finish_return_stmt ($2); }
3419 | asm_keyword maybe_cv_qualifier '(' string ')' ';'
3420 { $$ = finish_asm_stmt ($2, $4, NULL_TREE, NULL_TREE,
3422 ASM_INPUT_P ($$) = 1; }
3423 /* This is the case with just output operands. */
3424 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ')' ';'
3425 { $$ = finish_asm_stmt ($2, $4, $6, NULL_TREE, NULL_TREE); }
3426 /* This is the case with input operands as well. */
3427 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':'
3428 asm_operands ')' ';'
3429 { $$ = finish_asm_stmt ($2, $4, $6, $8, NULL_TREE); }
3430 | asm_keyword maybe_cv_qualifier '(' string SCOPE asm_operands ')' ';'
3431 { $$ = finish_asm_stmt ($2, $4, NULL_TREE, $6, NULL_TREE); }
3432 /* This is the case with clobbered registers as well. */
3433 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':'
3434 asm_operands ':' asm_clobbers ')' ';'
3435 { $$ = finish_asm_stmt ($2, $4, $6, $8, $10); }
3436 | asm_keyword maybe_cv_qualifier '(' string SCOPE asm_operands ':'
3437 asm_clobbers ')' ';'
3438 { $$ = finish_asm_stmt ($2, $4, NULL_TREE, $6, $8); }
3439 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands SCOPE
3440 asm_clobbers ')' ';'
3441 { $$ = finish_asm_stmt ($2, $4, $6, NULL_TREE, $8); }
3445 pedwarn ("ISO C++ forbids computed gotos");
3446 $$ = finish_goto_stmt ($3);
3448 | GOTO identifier ';'
3449 { $$ = finish_goto_stmt ($2); }
3453 { error ("label must be followed by statement");
3463 | namespace_using_decl
3464 { do_local_using_decl ($1);
3472 { $<ttype>$ = begin_function_try_block (); }
3474 { finish_function_try_block ($<ttype>2); }
3476 { finish_function_handler_sequence ($<ttype>2); }
3481 { $<ttype>$ = begin_try_block (); }
3483 { finish_try_block ($<ttype>2); }
3485 { finish_handler_sequence ($<ttype>2); }
3490 | handler_seq handler
3495 { $<ttype>$ = begin_handler (); }
3497 { finish_handler_parms ($3, $<ttype>2); }
3499 { finish_handler ($<ttype>2); }
3503 typed_typespecs %prec EMPTY
3504 | nonempty_cv_qualifiers %prec EMPTY
3510 /* This doesn't allow reference parameters, the below does.
3511 | '(' type_specifier_seq absdcl ')'
3512 { check_for_new_type ("inside exception declarations", $2);
3513 expand_start_catch_block ($2.t, $3); }
3514 | '(' type_specifier_seq ')'
3515 { check_for_new_type ("inside exception declarations", $2);
3516 expand_start_catch_block ($2.t, NULL_TREE); }
3517 | '(' type_specifier_seq notype_declarator ')'
3518 { check_for_new_type ("inside exception declarations", $2);
3519 expand_start_catch_block ($2.t, $3); }
3520 | '(' typed_typespecs after_type_declarator ')'
3521 { check_for_new_type ("inside exception declarations", $2);
3522 expand_start_catch_block ($2.t, $3); }
3523 This allows reference parameters... */
3526 check_for_new_type ("inside exception declarations", $2);
3527 $$ = start_handler_parms (TREE_PURPOSE ($2.t),
3534 { finish_label_stmt ($1); }
3536 { finish_label_stmt ($1); }
3538 { finish_label_stmt ($1); }
3540 { finish_label_stmt ($1); }
3545 { finish_expr_stmt ($1); }
3549 pedwarn ("ISO C++ forbids compound statements inside for initializations");
3553 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
3569 /* These are the operands other than the first string and colon
3570 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
3574 | nonnull_asm_operands
3577 nonnull_asm_operands:
3579 | nonnull_asm_operands ',' asm_operand
3580 { $$ = chainon ($$, $3); }
3585 { $$ = build_tree_list (build_tree_list (NULL_TREE, $1), $3); }
3586 | '[' identifier ']' STRING '(' expr ')'
3587 { $$ = build_tree_list (build_tree_list ($2, $4), $6); }
3592 { $$ = tree_cons (NULL_TREE, combine_strings ($1), NULL_TREE);}
3593 | asm_clobbers ',' string
3594 { $$ = tree_cons (NULL_TREE, combine_strings ($3), $1); }
3597 /* This is what appears inside the parens in a function declarator.
3598 Its value is represented in the format that grokdeclarator expects.
3600 In C++, declaring a function with no parameters
3601 means that that function takes *no* parameters. */
3610 { $$ = finish_parmlist (build_tree_list (NULL_TREE, $1.t), 0);
3611 check_for_new_type ("inside parameter list", $1); }
3614 /* This nonterminal does not include the common sequence '(' type_id ')',
3615 as it is ambiguous and must be disambiguated elsewhere. */
3618 { $$ = finish_parmlist ($$, 0); }
3619 | parms_comma ELLIPSIS
3620 { $$ = finish_parmlist ($1, 1); }
3621 /* C++ allows an ellipsis without a separating ',' */
3623 { $$ = finish_parmlist ($1, 1); }
3625 { $$ = finish_parmlist (build_tree_list (NULL_TREE,
3628 { $$ = finish_parmlist (NULL_TREE, 1); }
3631 /* This helps us recover from really nasty
3632 parse errors, for example, a missing right
3634 yyerror ("possibly missing ')'");
3635 $$ = finish_parmlist ($1, 0);
3641 /* This helps us recover from really nasty
3642 parse errors, for example, a missing right
3644 yyerror ("possibly missing ')'");
3645 $$ = finish_parmlist (build_tree_list (NULL_TREE,
3652 /* A default argument to a */
3655 { maybe_snarf_defarg (); }
3665 /* A nonempty list of parameter declarations or type names. */
3668 { check_for_new_type ("in a parameter list", $1);
3669 $$ = build_tree_list (NULL_TREE, $1.t); }
3671 { check_for_new_type ("in a parameter list", $1);
3672 $$ = build_tree_list ($2, $1.t); }
3673 | parms_comma full_parm
3674 { check_for_new_type ("in a parameter list", $2);
3675 $$ = chainon ($$, $2.t); }
3676 | parms_comma bad_parm
3677 { $$ = chainon ($$, build_tree_list (NULL_TREE, $2)); }
3678 | parms_comma bad_parm '=' init
3679 { $$ = chainon ($$, build_tree_list ($4, $2)); }
3685 { check_for_new_type ("in a parameter list", $1);
3686 $$ = build_tree_list (NULL_TREE, $1.t); }
3689 /* A single parameter declaration or parameter type name,
3690 as found in a parmlist. */
3692 /* Here we expand typed_declspecs inline to avoid mis-parsing of
3693 TYPESPEC IDENTIFIER. */
3694 typed_declspecs1 declarator
3695 { tree specs = strip_attrs ($1.t);
3696 $$.new_type_flag = $1.new_type_flag;
3697 $$.t = build_tree_list (specs, $2); }
3698 | typed_typespecs declarator
3699 { $$.t = build_tree_list ($1.t, $2);
3700 $$.new_type_flag = $1.new_type_flag; }
3701 | typespec declarator
3702 { $$.t = build_tree_list (build_tree_list (NULL_TREE, $1.t),
3704 $$.new_type_flag = $1.new_type_flag; }
3705 | typed_declspecs1 absdcl
3706 { tree specs = strip_attrs ($1.t);
3707 $$.t = build_tree_list (specs, $2);
3708 $$.new_type_flag = $1.new_type_flag; }
3709 | typed_declspecs1 %prec EMPTY
3710 { tree specs = strip_attrs ($1.t);
3711 $$.t = build_tree_list (specs, NULL_TREE);
3712 $$.new_type_flag = $1.new_type_flag; }
3713 | declmods notype_declarator
3714 { tree specs = strip_attrs ($1.t);
3715 $$.t = build_tree_list (specs, $2);
3716 $$.new_type_flag = 0; }
3721 { $$.t = build_tree_list (NULL_TREE, $1.t);
3722 $$.new_type_flag = $1.new_type_flag; }
3724 { $$.t = build_tree_list ($2, $1.t);
3725 $$.new_type_flag = $1.new_type_flag; }
3734 /* empty */ %prec EMPTY
3735 { see_typename (); }
3739 /* empty */ %prec EMPTY
3741 error ("type specifier omitted for parameter");
3742 $$ = build_tree_list (integer_type_node, NULL_TREE);
3746 if (TREE_CODE ($$) == SCOPE_REF)
3748 if (TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TYPE_PARM
3749 || TREE_CODE (TREE_OPERAND ($$, 0)) == BOUND_TEMPLATE_TEMPLATE_PARM)
3750 error ("`%E' is not a type, use `typename %E' to make it one", $$);
3752 error ("no type `%D' in `%T'", TREE_OPERAND ($$, 1), TREE_OPERAND ($$, 0));
3755 error ("type specifier omitted for parameter `%E'", $$);
3756 $$ = build_tree_list (integer_type_node, $$);
3761 IDENTIFIER template_arg_list_ignore IDENTIFIER arg_list_ignore ';'
3763 error("'%D' is used as a type, but is not defined as a type.", $1);
3764 $3 = error_mark_node;
3768 template_arg_list_ignore:
3769 '<' template_arg_list_opt template_close_bracket
3775 '(' nonnull_exprlist ')'
3780 exception_specification_opt:
3781 /* empty */ %prec EMPTY
3783 | THROW '(' ansi_raise_identifiers ')' %prec EMPTY
3785 | THROW LEFT_RIGHT %prec EMPTY
3786 { $$ = empty_except_spec; }
3789 ansi_raise_identifier:
3792 check_for_new_type ("exception specifier", $1);
3793 $$ = groktypename ($1.t);
3797 ansi_raise_identifiers:
3798 ansi_raise_identifier
3799 { $$ = add_exception_specifier (NULL_TREE, $1, 1); }
3800 | ansi_raise_identifiers ',' ansi_raise_identifier
3801 { $$ = add_exception_specifier ($1, $3, 1); }
3804 conversion_declarator:
3805 /* empty */ %prec EMPTY
3807 | '*' cv_qualifiers conversion_declarator
3808 { $$ = make_pointer_declarator ($2, $3); }
3809 | '&' cv_qualifiers conversion_declarator
3810 { $$ = make_reference_declarator ($2, $3); }
3811 | ptr_to_mem cv_qualifiers conversion_declarator
3812 { tree arg = make_pointer_declarator ($2, $3);
3813 $$ = build_nt (SCOPE_REF, $1, arg);
3820 saved_scopes = tree_cons (got_scope, got_object, saved_scopes);
3821 TREE_LANG_FLAG_0 (saved_scopes) = looking_for_typename;
3822 /* We look for conversion-type-id's in both the class and current
3823 scopes, just as for ID in 'ptr->ID::'. */
3824 looking_for_typename = 1;
3825 got_object = got_scope;
3826 got_scope = NULL_TREE;
3831 { got_scope = TREE_PURPOSE (saved_scopes);
3832 got_object = TREE_VALUE (saved_scopes);
3833 looking_for_typename = TREE_LANG_FLAG_0 (saved_scopes);
3834 saved_scopes = TREE_CHAIN (saved_scopes);
3839 operator '*' unoperator
3840 { $$ = frob_opname (ansi_opname (MULT_EXPR)); }
3841 | operator '/' unoperator
3842 { $$ = frob_opname (ansi_opname (TRUNC_DIV_EXPR)); }
3843 | operator '%' unoperator
3844 { $$ = frob_opname (ansi_opname (TRUNC_MOD_EXPR)); }
3845 | operator '+' unoperator
3846 { $$ = frob_opname (ansi_opname (PLUS_EXPR)); }
3847 | operator '-' unoperator
3848 { $$ = frob_opname (ansi_opname (MINUS_EXPR)); }
3849 | operator '&' unoperator
3850 { $$ = frob_opname (ansi_opname (BIT_AND_EXPR)); }
3851 | operator '|' unoperator
3852 { $$ = frob_opname (ansi_opname (BIT_IOR_EXPR)); }
3853 | operator '^' unoperator
3854 { $$ = frob_opname (ansi_opname (BIT_XOR_EXPR)); }
3855 | operator '~' unoperator
3856 { $$ = frob_opname (ansi_opname (BIT_NOT_EXPR)); }
3857 | operator ',' unoperator
3858 { $$ = frob_opname (ansi_opname (COMPOUND_EXPR)); }
3859 | operator ARITHCOMPARE unoperator
3860 { $$ = frob_opname (ansi_opname ($2)); }
3861 | operator '<' unoperator
3862 { $$ = frob_opname (ansi_opname (LT_EXPR)); }
3863 | operator '>' unoperator
3864 { $$ = frob_opname (ansi_opname (GT_EXPR)); }
3865 | operator EQCOMPARE unoperator
3866 { $$ = frob_opname (ansi_opname ($2)); }
3867 | operator ASSIGN unoperator
3868 { $$ = frob_opname (ansi_assopname ($2)); }
3869 | operator '=' unoperator
3870 { $$ = frob_opname (ansi_assopname (NOP_EXPR)); }
3871 | operator LSHIFT unoperator
3872 { $$ = frob_opname (ansi_opname ($2)); }
3873 | operator RSHIFT unoperator
3874 { $$ = frob_opname (ansi_opname ($2)); }
3875 | operator PLUSPLUS unoperator
3876 { $$ = frob_opname (ansi_opname (POSTINCREMENT_EXPR)); }
3877 | operator MINUSMINUS unoperator
3878 { $$ = frob_opname (ansi_opname (PREDECREMENT_EXPR)); }
3879 | operator ANDAND unoperator
3880 { $$ = frob_opname (ansi_opname (TRUTH_ANDIF_EXPR)); }
3881 | operator OROR unoperator
3882 { $$ = frob_opname (ansi_opname (TRUTH_ORIF_EXPR)); }
3883 | operator '!' unoperator
3884 { $$ = frob_opname (ansi_opname (TRUTH_NOT_EXPR)); }
3885 | operator '?' ':' unoperator
3886 { $$ = frob_opname (ansi_opname (COND_EXPR)); }
3887 | operator MIN_MAX unoperator
3888 { $$ = frob_opname (ansi_opname ($2)); }
3889 | operator POINTSAT unoperator %prec EMPTY
3890 { $$ = frob_opname (ansi_opname (COMPONENT_REF)); }
3891 | operator POINTSAT_STAR unoperator %prec EMPTY
3892 { $$ = frob_opname (ansi_opname (MEMBER_REF)); }
3893 | operator LEFT_RIGHT unoperator
3894 { $$ = frob_opname (ansi_opname (CALL_EXPR)); }
3895 | operator '[' ']' unoperator
3896 { $$ = frob_opname (ansi_opname (ARRAY_REF)); }
3897 | operator NEW unoperator %prec EMPTY
3898 { $$ = frob_opname (ansi_opname (NEW_EXPR)); }
3899 | operator DELETE unoperator %prec EMPTY
3900 { $$ = frob_opname (ansi_opname (DELETE_EXPR)); }
3901 | operator NEW '[' ']' unoperator
3902 { $$ = frob_opname (ansi_opname (VEC_NEW_EXPR)); }
3903 | operator DELETE '[' ']' unoperator
3904 { $$ = frob_opname (ansi_opname (VEC_DELETE_EXPR)); }
3905 | operator type_specifier_seq conversion_declarator unoperator
3906 { $$ = frob_opname (grokoptypename ($2.t, $3)); }
3907 | operator error unoperator
3908 { $$ = frob_opname (ansi_opname (ERROR_MARK)); }
3911 /* The forced readahead in here is because we might be at the end of a
3912 line, and lineno won't be bumped until yylex absorbs the first token
3913 on the next line. */
3915 { if (yychar == YYEMPTY)
3923 debug_yytranslate (value)
3926 return yytname[YYTRANSLATE (value)];