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 setup_vtbl_ptr (NULL_TREE, NULL_TREE);
1774 { got_object = TREE_TYPE ($$); }
1777 $$ = build_x_arrow ($$);
1778 got_object = TREE_TYPE ($$);
1783 typespec initdecls ';'
1785 if ($1.t && IS_AGGR_TYPE_CODE (TREE_CODE ($1.t)))
1786 note_got_semicolon ($1.t);
1788 | typed_declspecs initdecls ';'
1790 note_list_got_semicolon ($1.t);
1792 | declmods notype_initdecls ';'
1794 | typed_declspecs ';'
1797 note_list_got_semicolon ($1.t);
1800 { warning ("empty declaration"); }
1805 /* Any kind of declarator (thus, all declarators allowed
1806 after an explicit typespec). */
1809 after_type_declarator %prec EMPTY
1810 | notype_declarator %prec EMPTY
1813 /* This is necessary to postpone reduction of `int()()()()'. */
1815 LEFT_RIGHT %prec EMPTY
1816 { $$ = make_call_declarator (NULL_TREE, empty_parms (),
1817 NULL_TREE, NULL_TREE); }
1818 | fcast_or_absdcl LEFT_RIGHT %prec EMPTY
1819 { $$ = make_call_declarator ($$, empty_parms (), NULL_TREE,
1823 /* ISO type-id (8.1) */
1825 typed_typespecs absdcl
1826 { $$.t = build_tree_list ($1.t, $2);
1827 $$.new_type_flag = $1.new_type_flag; }
1828 | nonempty_cv_qualifiers absdcl
1829 { $$.t = build_tree_list ($1.t, $2);
1830 $$.new_type_flag = $1.new_type_flag; }
1832 { $$.t = build_tree_list (build_tree_list (NULL_TREE, $1.t),
1834 $$.new_type_flag = $1.new_type_flag; }
1835 | typed_typespecs %prec EMPTY
1836 { $$.t = build_tree_list ($1.t, NULL_TREE);
1837 $$.new_type_flag = $1.new_type_flag; }
1838 | nonempty_cv_qualifiers %prec EMPTY
1839 { $$.t = build_tree_list ($1.t, NULL_TREE);
1840 $$.new_type_flag = $1.new_type_flag; }
1843 /* Declspecs which contain at least one type specifier or typedef name.
1844 (Just `const' or `volatile' is not enough.)
1845 A typedef'd name following these is taken as a name to be declared.
1846 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1849 typed_typespecs %prec EMPTY
1850 { $$.lookups = type_lookups; }
1852 { $$.lookups = type_lookups; }
1857 { $$.t = tree_cons (NULL_TREE, $2.t, $1.t);
1858 $$.new_type_flag = $2.new_type_flag; }
1859 | typespec reserved_declspecs %prec HYPERUNARY
1860 { $$.t = tree_cons (NULL_TREE, $1.t, $2);
1861 $$.new_type_flag = $1.new_type_flag; }
1862 | typespec reserved_typespecquals reserved_declspecs
1863 { $$.t = tree_cons (NULL_TREE, $1.t, chainon ($2, $3));
1864 $$.new_type_flag = $1.new_type_flag; }
1865 | declmods typespec reserved_declspecs
1866 { $$.t = tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1867 $$.new_type_flag = $2.new_type_flag; }
1868 | declmods typespec reserved_typespecquals
1869 { $$.t = tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1870 $$.new_type_flag = $2.new_type_flag; }
1871 | declmods typespec reserved_typespecquals reserved_declspecs
1872 { $$.t = tree_cons (NULL_TREE, $2.t,
1873 chainon ($3, chainon ($4, $1.t)));
1874 $$.new_type_flag = $2.new_type_flag; }
1879 { if (extra_warnings)
1880 warning ("`%s' is not at beginning of declaration",
1881 IDENTIFIER_POINTER ($$));
1882 $$ = build_tree_list (NULL_TREE, $$); }
1883 | reserved_declspecs typespecqual_reserved
1884 { $$ = tree_cons (NULL_TREE, $2.t, $$); }
1885 | reserved_declspecs SCSPEC
1886 { if (extra_warnings)
1887 warning ("`%s' is not at beginning of declaration",
1888 IDENTIFIER_POINTER ($2));
1889 $$ = tree_cons (NULL_TREE, $2, $$); }
1890 | reserved_declspecs attributes
1891 { $$ = tree_cons ($2, NULL_TREE, $1); }
1893 { $$ = tree_cons ($1, NULL_TREE, NULL_TREE); }
1896 /* List of just storage classes and type modifiers.
1897 A declaration can start with just this, but then it cannot be used
1898 to redeclare a typedef-name.
1899 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1901 /* We use hash_tree_cons for lists of typeless declspecs so that they end
1902 up on a persistent obstack. Otherwise, they could appear at the
1903 beginning of something like
1905 static const struct { int foo () { } } b;
1907 and would be discarded after we finish compiling foo. We don't need to
1908 worry once we see a type. */
1911 nonempty_cv_qualifiers %prec EMPTY
1912 { $$.lookups = NULL_TREE; TREE_STATIC ($$.t) = 1; }
1915 $$.t = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
1916 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
1918 | declmods CV_QUALIFIER
1920 $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
1921 TREE_STATIC ($$.t) = 1;
1925 if (extra_warnings && TREE_STATIC ($$.t))
1926 warning ("`%s' is not at beginning of declaration",
1927 IDENTIFIER_POINTER ($2));
1928 $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
1929 TREE_STATIC ($$.t) = TREE_STATIC ($1.t);
1931 | declmods attributes
1932 { $$.t = hash_tree_cons ($2, NULL_TREE, $1.t); }
1933 | attributes %prec EMPTY
1935 $$.t = hash_tree_cons ($1, NULL_TREE, NULL_TREE);
1936 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
1940 /* Used instead of declspecs where storage classes are not allowed
1941 (that is, for typenames and structure components).
1943 C++ can takes storage classes for structure components.
1944 Don't accept a typedef-name if anything but a modifier precedes it. */
1947 typespec %prec EMPTY
1948 { $$.t = build_tree_list (NULL_TREE, $1.t);
1949 $$.new_type_flag = $1.new_type_flag; }
1950 | nonempty_cv_qualifiers typespec
1951 { $$.t = tree_cons (NULL_TREE, $2.t, $1.t);
1952 $$.new_type_flag = $2.new_type_flag; }
1953 | typespec reserved_typespecquals
1954 { $$.t = tree_cons (NULL_TREE, $1.t, $2);
1955 $$.new_type_flag = $1.new_type_flag; }
1956 | nonempty_cv_qualifiers typespec reserved_typespecquals
1957 { $$.t = tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1958 $$.new_type_flag = $2.new_type_flag; }
1961 reserved_typespecquals:
1962 typespecqual_reserved
1963 { $$ = build_tree_list (NULL_TREE, $1.t); }
1964 | reserved_typespecquals typespecqual_reserved
1965 { $$ = tree_cons (NULL_TREE, $2.t, $1); }
1968 /* A typespec (but not a type qualifier).
1969 Once we have seen one of these in a declaration,
1970 if a typedef name appears then it is being redeclared. */
1974 { $$.lookups = NULL_TREE; }
1975 | TYPESPEC %prec EMPTY
1976 { $$.t = $1; $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
1977 | complete_type_name
1978 { $$.t = $1; $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
1979 | TYPEOF '(' expr ')'
1980 { $$.t = finish_typeof ($3);
1981 $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
1982 | TYPEOF '(' type_id ')'
1983 { $$.t = groktypename ($3.t);
1984 $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
1985 | SIGOF '(' expr ')'
1986 { tree type = TREE_TYPE ($3);
1988 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
1989 if (IS_AGGR_TYPE (type))
1991 sorry ("sigof type specifier");
1996 error ("`sigof' applied to non-aggregate expression");
1997 $$.t = error_mark_node;
2000 | SIGOF '(' type_id ')'
2001 { tree type = groktypename ($3.t);
2003 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
2004 if (IS_AGGR_TYPE (type))
2006 sorry ("sigof type specifier");
2011 error("`sigof' applied to non-aggregate type");
2012 $$.t = error_mark_node;
2017 /* A typespec that is a reserved word, or a type qualifier. */
2019 typespecqual_reserved:
2021 { $$.t = $1; $$.new_type_flag = 0; }
2023 { $$.t = $1; $$.new_type_flag = 0; }
2029 | initdecls ',' initdcl
2030 { check_multiple_declarators (); }
2035 | notype_initdecls ',' initdcl
2036 { check_multiple_declarators (); }
2041 | nomods_initdecls ',' initdcl
2042 { check_multiple_declarators (); }
2048 | asm_keyword '(' string ')'
2049 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3); $$ = $3; }
2053 declarator maybeasm maybe_attribute '='
2054 { $<ttype>$ = parse_decl ($<ttype>1, $3, 1); }
2056 /* Note how the declaration of the variable is in effect while its init is parsed! */
2057 { parse_end_decl ($<ttype>5, $6, $2); }
2058 | declarator maybeasm maybe_attribute
2060 $<ttype>$ = parse_decl ($<ttype>1, $3, 0);
2061 parse_end_decl ($<ttype>$, NULL_TREE, $2);
2065 /* This rule assumes a certain configuration of the parser stack.
2066 In particular, $0, the element directly before the beginning of
2067 this rule on the stack, must be a maybeasm. $-1 must be a
2068 declarator or notype_declarator. And $-2 must be some declmods
2069 or declspecs. We can't move the maybeasm into this rule because
2070 we need that reduce so we prefer fn.def1 when appropriate. */
2073 { $<ttype>$ = parse_decl0 ($<ttype>-1, $<ftype>-2.t,
2074 $<ftype>-2.lookups, $1, 1); }
2075 /* Note how the declaration of the variable is in effect
2076 while its init is parsed! */
2078 { parse_end_decl ($<ttype>3, $4, $<ttype>0); }
2080 { tree d = parse_decl0 ($<ttype>-1, $<ftype>-2.t,
2081 $<ftype>-2.lookups, $1, 0);
2082 parse_end_decl (d, NULL_TREE, $<ttype>0); }
2086 declarator maybeasm initdcl0_innards
2091 notype_declarator maybeasm initdcl0_innards
2096 notype_declarator maybeasm
2097 { /* Set things up as initdcl0_innards expects. */
2100 $<ftype>1.t = NULL_TREE;
2101 $<ftype>1.lookups = NULL_TREE; }
2104 | constructor_declarator maybeasm maybe_attribute
2105 { tree d = parse_decl0 ($1, NULL_TREE, NULL_TREE, $3, 0);
2106 parse_end_decl (d, NULL_TREE, $2); }
2109 /* the * rules are dummies to accept the Apollo extended syntax
2110 so that the header files compile. */
2121 | attributes attribute
2122 { $$ = chainon ($1, $2); }
2126 ATTRIBUTE '(' '(' attribute_list ')' ')'
2133 | attribute_list ',' attrib
2134 { $$ = chainon ($1, $3); }
2141 { $$ = build_tree_list ($1, NULL_TREE); }
2142 | any_word '(' IDENTIFIER ')'
2143 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
2144 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
2145 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
2146 | any_word '(' nonnull_exprlist ')'
2147 { $$ = build_tree_list ($1, $3); }
2150 /* This still leaves out most reserved keywords,
2151 shouldn't we include them? */
2160 /* A nonempty list of identifiers, including typenames. */
2161 identifiers_or_typenames:
2163 { $$ = build_tree_list (NULL_TREE, $1); }
2164 | identifiers_or_typenames ',' identifier
2165 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2169 /* empty */ %prec EMPTY
2174 /* If we are processing a template, we don't want to expand this
2178 expr_no_commas %prec '='
2180 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, NULL_TREE);
2181 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2183 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2184 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2185 | '{' initlist ',' '}'
2186 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2187 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2192 /* This chain is built in reverse order,
2193 and put in forward order where initlist is used. */
2196 { $$ = build_tree_list (NULL_TREE, $$); }
2198 { $$ = tree_cons (NULL_TREE, $3, $$); }
2199 /* These are for labeled elements. */
2200 | '[' expr_no_commas ']' init
2201 { $$ = build_tree_list ($2, $4); }
2202 | identifier ':' init
2203 { $$ = build_tree_list ($$, $3); }
2204 | initlist ',' identifier ':' init
2205 { $$ = tree_cons ($3, $5, $$); }
2209 PRE_PARSED_FUNCTION_DECL maybe_return_init function_body
2211 expand_body (finish_function (2));
2212 process_next_inline ($1);
2214 | PRE_PARSED_FUNCTION_DECL maybe_return_init function_try_block
2216 expand_body (finish_function (2));
2217 process_next_inline ($1);
2219 | PRE_PARSED_FUNCTION_DECL maybe_return_init error
2221 finish_function (2);
2222 process_next_inline ($1); }
2227 | pending_inlines pending_inline eat_saved_input
2230 /* A regurgitated default argument. The value of DEFARG_MARKER will be
2231 the TREE_LIST node for the parameter in question. */
2233 DEFARG_MARKER expr_no_commas END_OF_SAVED_INPUT
2234 { replace_defarg ($1, $2); }
2235 | DEFARG_MARKER error END_OF_SAVED_INPUT
2236 { replace_defarg ($1, error_mark_node); }
2239 /* empty */ %prec EMPTY
2240 | pending_defargs defarg_again
2241 { do_pending_defargs (); }
2242 | pending_defargs error
2243 { do_pending_defargs (); }
2248 { $<ttype>$ = current_enum_type;
2249 current_enum_type = start_enum ($2); }
2251 { $$.t = current_enum_type;
2252 finish_enum (current_enum_type);
2253 $$.new_type_flag = 1;
2254 current_enum_type = $<ttype>4;
2255 check_for_missing_semicolon ($$.t); }
2257 { $<ttype>$ = current_enum_type;
2258 current_enum_type = start_enum (make_anon_name ()); }
2260 { $$.t = current_enum_type;
2261 finish_enum (current_enum_type);
2262 $$.new_type_flag = 1;
2263 current_enum_type = $<ttype>3;
2264 check_for_missing_semicolon ($$.t); }
2266 { $$.t = xref_tag (enum_type_node, $2, 1);
2267 $$.new_type_flag = 0; }
2268 | ENUM complex_type_name
2269 { $$.t = xref_tag (enum_type_node, $2, 1);
2270 $$.new_type_flag = 0; }
2271 | TYPENAME_KEYWORD typename_sub
2273 $$.new_type_flag = 0;
2274 if (!processing_template_decl)
2275 pedwarn ("using `typename' outside of template"); }
2276 /* C++ extensions, merged with C to avoid shift/reduce conflicts */
2277 | class_head_defn maybe_base_class_list '{'
2279 if ($2 && $1.t != error_mark_node)
2281 tree type = TREE_TYPE ($1.t);
2283 if (TREE_CODE (type) == TYPENAME_TYPE)
2284 /* In a definition of a member class template,
2285 we will get here with an implicit typename,
2286 a TYPENAME_TYPE with a type. */
2287 type = TREE_TYPE (type);
2288 maybe_process_partial_specialization (type);
2289 xref_basetypes (current_aggr, $1.t, type, $2);
2291 $1.t = begin_class_definition (TREE_TYPE ($1.t));
2292 current_aggr = NULL_TREE; }
2293 opt.component_decl_list '}' maybe_attribute
2298 if (yychar == YYEMPTY)
2300 semi = yychar == ';';
2302 t = finish_class_definition ($1.t, $7, semi, $1.new_type_flag);
2305 /* restore current_aggr */
2306 current_aggr = TREE_CODE (t) != RECORD_TYPE
2308 : CLASSTYPE_DECLARED_CLASS (t)
2309 ? class_type_node : record_type_node;
2313 done_pending_defargs ();
2314 begin_inline_definitions ();
2318 finish_inline_definitions ();
2320 $$.new_type_flag = 1;
2324 $$.t = TREE_TYPE ($1.t);
2325 $$.new_type_flag = $1.new_type_flag;
2337 { if (pedantic && !in_system_header)
2338 pedwarn ("comma at end of enumerator list"); }
2344 { error ("storage class specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2346 { error ("type specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2348 { error ("type qualifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2350 { error ("no body nor ';' separates two class, struct or union declarations"); }
2352 { $$ = build_tree_list ($2, $1); }
2359 $$ = build_tree_list (NULL_TREE, $2);
2361 | aggr nested_name_specifier identifier
2364 $$ = build_tree_list ($2, $3);
2366 | aggr global_scope nested_name_specifier identifier
2369 $$ = build_tree_list ($3, $4);
2371 | aggr global_scope identifier
2374 $$ = build_tree_list (global_namespace, $3);
2378 class_head_apparent_template:
2379 aggr apparent_template_type
2384 | aggr nested_name_specifier apparent_template_type
2389 | aggr global_scope nested_name_specifier apparent_template_type
2397 class_head %prec EMPTY
2399 $$.t = handle_class_head (current_aggr,
2400 TREE_PURPOSE ($1), TREE_VALUE ($1),
2401 0, &$$.new_type_flag);
2403 | aggr identifier_defn %prec EMPTY
2406 $$.t = TYPE_MAIN_DECL (xref_tag (current_aggr, $2, 0));
2407 $$.new_type_flag = 1;
2409 | class_head_apparent_template %prec EMPTY
2412 $$.new_type_flag = 0;
2420 $$.t = handle_class_head (current_aggr,
2421 TREE_PURPOSE ($1), TREE_VALUE ($1),
2422 1, &$$.new_type_flag);
2427 $$.t = handle_class_head (current_aggr,
2428 TREE_PURPOSE ($1), TREE_VALUE ($1),
2429 1, &$$.new_type_flag);
2431 | class_head_apparent_template '{'
2435 $$.new_type_flag = 0;
2437 | class_head_apparent_template ':'
2441 $$.new_type_flag = 0;
2443 | aggr identifier_defn '{'
2447 $$.t = handle_class_head (current_aggr,
2449 1, &$$.new_type_flag);
2451 | aggr identifier_defn ':'
2455 $$.t = handle_class_head (current_aggr,
2457 1, &$$.new_type_flag);
2462 $$.t = TYPE_MAIN_DECL (xref_tag ($1, make_anon_name (), 0));
2463 $$.new_type_flag = 0;
2468 maybe_base_class_list:
2472 { error ("no bases given following `:'");
2474 | ':' see_typename base_class_list
2480 | base_class_list ',' see_typename base_class
2481 { $$ = chainon ($$, $4); }
2486 { $$ = finish_base_specifier (access_default_node, $1); }
2487 | base_class_access_list see_typename base_class.1
2488 { $$ = finish_base_specifier ($1, $3); }
2494 $$ = error_mark_node; }
2496 { $$ = TREE_TYPE ($$); }
2499 base_class_access_list:
2500 VISSPEC see_typename
2501 | SCSPEC see_typename
2502 { if ($1 != ridpointers[(int)RID_VIRTUAL])
2503 error ("`%D' access", $1);
2504 $$ = access_default_virtual_node; }
2505 | base_class_access_list VISSPEC see_typename
2507 if ($1 != access_default_virtual_node)
2508 error ("multiple access specifiers");
2509 else if ($2 == access_public_node)
2510 $$ = access_public_virtual_node;
2511 else if ($2 == access_protected_node)
2512 $$ = access_protected_virtual_node;
2513 else /* $2 == access_private_node */
2514 $$ = access_private_virtual_node;
2516 | base_class_access_list SCSPEC see_typename
2517 { if ($2 != ridpointers[(int)RID_VIRTUAL])
2518 error ("`%D' access", $2);
2519 else if ($$ == access_public_node)
2520 $$ = access_public_virtual_node;
2521 else if ($$ == access_protected_node)
2522 $$ = access_protected_virtual_node;
2523 else if ($$ == access_private_node)
2524 $$ = access_private_virtual_node;
2526 error ("multiple `virtual' specifiers");
2530 opt.component_decl_list:
2531 | component_decl_list
2532 | opt.component_decl_list access_specifier component_decl_list
2533 | opt.component_decl_list access_specifier
2539 current_access_specifier = $1;
2543 /* Note: we no longer warn about the semicolon after a component_decl_list.
2544 ARM $9.2 says that the semicolon is optional, and therefore allowed. */
2545 component_decl_list:
2548 finish_member_declaration ($1);
2549 current_aggr = NULL_TREE;
2550 reset_type_access_control ();
2552 | component_decl_list component_decl
2554 finish_member_declaration ($2);
2555 current_aggr = NULL_TREE;
2556 reset_type_access_control ();
2561 component_decl_1 ';'
2562 | component_decl_1 '}'
2563 { error ("missing ';' before right brace");
2564 yyungetc ('}', 0); }
2565 /* C++: handle constructors, destructors and inline functions */
2566 /* note that INLINE is like a TYPESPEC */
2567 | fn.def2 ':' /* base_init compstmt */
2568 { $$ = finish_method ($$); }
2569 | fn.def2 TRY /* base_init compstmt */
2570 { $$ = finish_method ($$); }
2571 | fn.def2 RETURN_KEYWORD /* base_init compstmt */
2572 { $$ = finish_method ($$); }
2573 | fn.def2 '{' /* nodecls compstmt */
2574 { $$ = finish_method ($$); }
2577 | extension component_decl
2580 | template_header component_decl
2583 $$ = finish_member_template_decl ($2);
2585 /* The component was already processed. */
2588 finish_template_decl ($1);
2590 | template_header typed_declspecs ';'
2592 $$ = finish_member_class_template ($2.t);
2593 finish_template_decl ($1);
2600 /* Do not add a "typed_declspecs declarator" rule here for
2601 speed; we need to call grok_x_components for enums, so the
2602 speedup would be insignificant. */
2603 typed_declspecs components
2605 /* Most of the productions for component_decl only
2606 allow the creation of one new member, so we call
2607 finish_member_declaration in component_decl_list.
2608 For this rule and the next, however, there can be
2609 more than one member, e.g.:
2613 and we need the first member to be fully
2614 registered before the second is processed.
2615 Therefore, the rules for components take care of
2616 this processing. To avoid registering the
2617 components more than once, we send NULL_TREE up
2618 here; that lets finish_member_declaration know
2619 that there is nothing to do. */
2621 grok_x_components ($1.t);
2624 | declmods notype_components
2627 grok_x_components ($1.t);
2630 | notype_declarator maybeasm maybe_attribute maybe_init
2631 { $$ = grokfield ($$, NULL_TREE, $4, $2, $3); }
2632 | constructor_declarator maybeasm maybe_attribute maybe_init
2633 { $$ = grokfield ($$, NULL_TREE, $4, $2, $3); }
2634 | ':' expr_no_commas
2635 { $$ = grokbitfield (NULL_TREE, NULL_TREE, $2); }
2639 /* These rules introduce a reduce/reduce conflict; in
2640 typedef int foo, bar;
2644 should "A::foo" be declared as a function or "A::bar" as a data
2645 member? In other words, is "bar" an after_type_declarator or a
2647 | declmods component_constructor_declarator maybeasm maybe_attribute maybe_init
2648 { tree specs, attrs;
2649 split_specs_attrs ($1.t, &specs, &attrs);
2650 $$ = grokfield ($2, specs, $5, $3,
2651 chainon ($4, attrs)); }
2652 | component_constructor_declarator maybeasm maybe_attribute maybe_init
2653 { $$ = grokfield ($$, NULL_TREE, $4, $2, $3); }
2655 { $$ = do_class_using_decl ($1); }
2657 /* The case of exactly one component is handled directly by component_decl. */
2660 /* empty: possibly anonymous */
2662 | component_declarator0
2664 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2665 $1 = finish_member_template_decl ($1);
2666 finish_member_declaration ($1);
2669 | components ',' component_declarator
2671 check_multiple_declarators ();
2672 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2673 $3 = finish_member_template_decl ($3);
2674 finish_member_declaration ($3);
2680 /* empty: possibly anonymous */
2682 | notype_component_declarator0
2684 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2685 $1 = finish_member_template_decl ($1);
2686 finish_member_declaration ($1);
2689 | notype_components ',' notype_component_declarator
2691 check_multiple_declarators ();
2692 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2693 $3 = finish_member_template_decl ($3);
2694 finish_member_declaration ($3);
2699 component_declarator0:
2700 after_type_component_declarator0
2701 | notype_component_declarator0
2704 component_declarator:
2705 after_type_component_declarator
2706 | notype_component_declarator
2709 after_type_component_declarator0:
2710 after_type_declarator maybeasm maybe_attribute maybe_init
2711 { $$ = parse_field0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2713 | TYPENAME ':' expr_no_commas maybe_attribute
2714 { $$ = parse_bitfield0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2718 notype_component_declarator0:
2719 notype_declarator maybeasm maybe_attribute maybe_init
2720 { $$ = parse_field0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2722 | constructor_declarator maybeasm maybe_attribute maybe_init
2723 { $$ = parse_field0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2725 | IDENTIFIER ':' expr_no_commas maybe_attribute
2726 { $$ = parse_bitfield0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2728 | ':' expr_no_commas maybe_attribute
2729 { $$ = parse_bitfield0 (NULL_TREE, $<ftype>0.t,
2730 $<ftype>0.lookups, $3, $2); }
2733 after_type_component_declarator:
2734 after_type_declarator maybeasm maybe_attribute maybe_init
2735 { $$ = parse_field ($1, $3, $2, $4); }
2736 | TYPENAME ':' expr_no_commas maybe_attribute
2737 { $$ = parse_bitfield ($1, $4, $3); }
2740 notype_component_declarator:
2741 notype_declarator maybeasm maybe_attribute maybe_init
2742 { $$ = parse_field ($1, $3, $2, $4); }
2743 | IDENTIFIER ':' expr_no_commas maybe_attribute
2744 { $$ = parse_bitfield ($1, $4, $3); }
2745 | ':' expr_no_commas maybe_attribute
2746 { $$ = parse_bitfield (NULL_TREE, $3, $2); }
2750 enumlist maybecomma_warn
2754 /* We chain the enumerators in reverse order.
2755 Because of the way enums are built, the order is
2756 insignificant. Take advantage of this fact. */
2760 | enumlist ',' enumerator
2765 { build_enumerator ($1, NULL_TREE, current_enum_type); }
2766 | identifier '=' expr_no_commas
2767 { build_enumerator ($1, $3, current_enum_type); }
2770 /* ISO new-type-id (5.3.4) */
2772 type_specifier_seq new_declarator
2773 { $$.t = build_tree_list ($1.t, $2);
2774 $$.new_type_flag = $1.new_type_flag; }
2775 | type_specifier_seq %prec EMPTY
2776 { $$.t = build_tree_list ($1.t, NULL_TREE);
2777 $$.new_type_flag = $1.new_type_flag; }
2778 /* GNU extension to allow arrays of arbitrary types with
2779 non-constant dimension. */
2780 | '(' type_id ')' '[' expr ']'
2783 pedwarn ("ISO C++ forbids array dimensions with parenthesized type in new");
2784 $$.t = build_nt (ARRAY_REF, TREE_VALUE ($2.t), $5);
2785 $$.t = build_tree_list (TREE_PURPOSE ($2.t), $$.t);
2786 $$.new_type_flag = $2.new_type_flag;
2791 /* empty */ %prec EMPTY
2793 | cv_qualifiers CV_QUALIFIER
2794 { $$ = tree_cons (NULL_TREE, $2, $$); }
2797 nonempty_cv_qualifiers:
2799 { $$.t = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
2800 $$.new_type_flag = 0; }
2801 | nonempty_cv_qualifiers CV_QUALIFIER
2802 { $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
2803 $$.new_type_flag = $1.new_type_flag; }
2806 /* These rules must follow the rules for function declarations
2807 and component declarations. That way, longer rules are preferred. */
2809 /* An expression which will not live on the momentary obstack. */
2811 '(' nonnull_exprlist ')'
2816 { $$ = empty_parms (); }
2821 /* A declarator that is allowed only after an explicit typespec. */
2823 after_type_declarator_intern:
2824 after_type_declarator
2825 | attributes after_type_declarator
2827 /* Provide support for '(' attributes '*' declarator ')'
2829 $$ = tree_cons ($1, $2, NULL_TREE);
2833 /* may all be followed by prec '.' */
2834 after_type_declarator:
2835 '*' nonempty_cv_qualifiers after_type_declarator_intern %prec UNARY
2836 { $$ = make_pointer_declarator ($2.t, $3); }
2837 | '&' nonempty_cv_qualifiers after_type_declarator_intern %prec UNARY
2838 { $$ = make_reference_declarator ($2.t, $3); }
2839 | '*' after_type_declarator_intern %prec UNARY
2840 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2841 | '&' after_type_declarator_intern %prec UNARY
2842 { $$ = make_reference_declarator (NULL_TREE, $2); }
2843 | ptr_to_mem cv_qualifiers after_type_declarator_intern
2844 { tree arg = make_pointer_declarator ($2, $3);
2845 $$ = build_nt (SCOPE_REF, $1, arg);
2847 | direct_after_type_declarator
2850 direct_after_type_declarator:
2851 direct_after_type_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2852 { $$ = make_call_declarator ($$, $2, $3, $4); }
2853 | direct_after_type_declarator '[' expr ']'
2854 { $$ = build_nt (ARRAY_REF, $$, $3); }
2855 | direct_after_type_declarator '[' ']'
2856 { $$ = build_nt (ARRAY_REF, $$, NULL_TREE); }
2857 | '(' after_type_declarator_intern ')'
2859 | nested_name_specifier type_name %prec EMPTY
2860 { push_nested_class ($1, 3);
2861 $$ = build_nt (SCOPE_REF, $$, $2);
2862 TREE_COMPLEXITY ($$) = current_class_depth; }
2863 | type_name %prec EMPTY
2867 type_name %prec EMPTY
2869 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2871 $$ = lookup_name ($1, 1);
2872 maybe_note_name_used_in_class ($1, $$);
2877 | global_scope type_name
2879 if (TREE_CODE ($2) == IDENTIFIER_NODE)
2880 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
2883 got_scope = NULL_TREE;
2890 | global_scope nested_type
2895 nested_name_specifier type_name %prec EMPTY
2896 { $$ = get_type_decl ($2); }
2899 /* A declarator allowed whether or not there has been
2900 an explicit typespec. These cannot redeclare a typedef-name. */
2902 notype_declarator_intern:
2904 | attributes notype_declarator
2906 /* Provide support for '(' attributes '*' declarator ')'
2908 $$ = tree_cons ($1, $2, NULL_TREE);
2913 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2914 { $$ = make_pointer_declarator ($2.t, $3); }
2915 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2916 { $$ = make_reference_declarator ($2.t, $3); }
2917 | '*' notype_declarator_intern %prec UNARY
2918 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2919 | '&' notype_declarator_intern %prec UNARY
2920 { $$ = make_reference_declarator (NULL_TREE, $2); }
2921 | ptr_to_mem cv_qualifiers notype_declarator_intern
2922 { tree arg = make_pointer_declarator ($2, $3);
2923 $$ = build_nt (SCOPE_REF, $1, arg);
2925 | direct_notype_declarator
2928 complex_notype_declarator:
2929 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2930 { $$ = make_pointer_declarator ($2.t, $3); }
2931 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2932 { $$ = make_reference_declarator ($2.t, $3); }
2933 | '*' complex_notype_declarator %prec UNARY
2934 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2935 | '&' complex_notype_declarator %prec UNARY
2936 { $$ = make_reference_declarator (NULL_TREE, $2); }
2937 | ptr_to_mem cv_qualifiers notype_declarator_intern
2938 { tree arg = make_pointer_declarator ($2, $3);
2939 $$ = build_nt (SCOPE_REF, $1, arg);
2941 | complex_direct_notype_declarator
2944 complex_direct_notype_declarator:
2945 direct_notype_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2946 { $$ = make_call_declarator ($$, $2, $3, $4); }
2947 | '(' complex_notype_declarator ')'
2949 | direct_notype_declarator '[' expr ']'
2950 { $$ = build_nt (ARRAY_REF, $$, $3); }
2951 | direct_notype_declarator '[' ']'
2952 { $$ = build_nt (ARRAY_REF, $$, NULL_TREE); }
2953 | notype_qualified_id
2954 { enter_scope_of ($1); }
2955 | global_scope notype_qualified_id
2956 { enter_scope_of ($2); $$ = $2;}
2957 | global_scope notype_unqualified_id
2958 { $$ = build_nt (SCOPE_REF, global_namespace, $2);
2959 enter_scope_of ($$);
2961 | nested_name_specifier notype_template_declarator
2962 { got_scope = NULL_TREE;
2963 $$ = build_nt (SCOPE_REF, $1, $2);
2964 enter_scope_of ($$);
2969 nested_name_specifier unqualified_id
2970 { got_scope = NULL_TREE;
2971 $$ = build_nt (SCOPE_REF, $$, $2); }
2972 | nested_name_specifier object_template_id
2973 { got_scope = NULL_TREE;
2974 $$ = build_nt (SCOPE_REF, $1, $2); }
2977 notype_qualified_id:
2978 nested_name_specifier notype_unqualified_id
2979 { got_scope = NULL_TREE;
2980 $$ = build_nt (SCOPE_REF, $$, $2); }
2981 | nested_name_specifier object_template_id
2982 { got_scope = NULL_TREE;
2983 $$ = build_nt (SCOPE_REF, $1, $2); }
2988 | global_scope notype_qualified_id
2993 typespec '(' nonnull_exprlist ')'
2994 { $$ = build_functional_cast ($1.t, $3); }
2995 | typespec '(' expr_or_declarator_intern ')'
2996 { $$ = reparse_decl_as_expr ($1.t, $3); }
2997 | typespec fcast_or_absdcl %prec EMPTY
2998 { $$ = reparse_absdcl_as_expr ($1.t, $2); }
3004 | template_type %prec EMPTY
3007 nested_name_specifier:
3008 nested_name_specifier_1
3009 | nested_name_specifier nested_name_specifier_1
3011 | nested_name_specifier TEMPLATE explicit_template_type SCOPE
3013 = make_typename_type ($1, $3, /*complain=*/1); }
3014 /* Error handling per Core 125. */
3015 | nested_name_specifier IDENTIFIER SCOPE
3017 = make_typename_type ($1, $2, /*complain=*/1); }
3018 | nested_name_specifier PTYPENAME SCOPE
3020 = make_typename_type ($1, $2, /*complain=*/1); }
3023 /* Why the @#$%^& do type_name and notype_identifier need to be expanded
3024 inline here?!? (jason) */
3025 nested_name_specifier_1:
3028 if (TREE_CODE ($1) == IDENTIFIER_NODE)
3031 maybe_note_name_used_in_class ($1, $$);
3034 complete_type (TYPE_MAIN_VARIANT (TREE_TYPE ($$)));
3038 if (TREE_CODE ($1) == IDENTIFIER_NODE)
3040 got_scope = $$ = TREE_TYPE ($$);
3044 if (TREE_CODE ($$) == IDENTIFIER_NODE)
3048 | template_type SCOPE
3049 { got_scope = $$ = complete_type (TREE_TYPE ($1)); }
3054 | global_scope typename_sub0
3059 typename_sub1 identifier %prec EMPTY
3062 $$ = make_typename_type ($1, $2, /*complain=*/1);
3063 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
3064 error ("`%T' is not a class or namespace", $2);
3068 if (TREE_CODE ($$) == TYPE_DECL)
3069 $$ = TREE_TYPE ($$);
3072 | typename_sub1 template_type %prec EMPTY
3073 { $$ = TREE_TYPE ($2); }
3074 | typename_sub1 explicit_template_type %prec EMPTY
3075 { $$ = make_typename_type ($1, $2, /*complain=*/1); }
3076 | typename_sub1 TEMPLATE explicit_template_type %prec EMPTY
3077 { $$ = make_typename_type ($1, $3, /*complain=*/1); }
3083 if (TREE_CODE ($1) == IDENTIFIER_NODE)
3084 error ("`%T' is not a class or namespace", $1);
3085 else if (TREE_CODE ($1) == TYPE_DECL)
3086 $$ = TREE_TYPE ($1);
3088 | typename_sub1 typename_sub2
3091 $$ = make_typename_type ($1, $2, /*complain=*/1);
3092 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
3093 error ("`%T' is not a class or namespace", $2);
3097 if (TREE_CODE ($$) == TYPE_DECL)
3098 $$ = TREE_TYPE ($$);
3101 | typename_sub1 explicit_template_type SCOPE
3103 = make_typename_type ($1, $2, /*complain=*/1); }
3104 | typename_sub1 TEMPLATE explicit_template_type SCOPE
3106 = make_typename_type ($1, $3, /*complain=*/1); }
3109 /* This needs to return a TYPE_DECL for simple names so that we don't
3110 forget what name was used. */
3114 if (TREE_CODE ($1) != TYPE_DECL)
3117 /* Retrieve the type for the identifier, which might involve
3118 some computation. */
3119 got_scope = complete_type (TREE_TYPE ($$));
3121 if ($$ == error_mark_node)
3122 error ("`%T' is not a class or namespace", $1);
3126 if (TREE_CODE ($1) != TYPE_DECL)
3128 got_scope = complete_type (TREE_TYPE ($$));
3130 | template_type SCOPE
3131 { got_scope = $$ = complete_type (TREE_TYPE ($$)); }
3136 if (TREE_CODE ($$) == IDENTIFIER_NODE)
3142 explicit_template_type:
3143 identifier '<' template_arg_list_opt template_close_bracket
3144 { $$ = build_min_nt (TEMPLATE_ID_EXPR, $1, $3); }
3148 global_scope type_name
3150 if (TREE_CODE ($2) == IDENTIFIER_NODE)
3151 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
3154 got_scope = NULL_TREE;
3157 | global_scope nested_type
3162 nested_name_specifier '*'
3163 { got_scope = NULL_TREE; }
3164 | global_scope nested_name_specifier '*'
3165 { $$ = $2; got_scope = NULL_TREE; }
3168 /* All uses of explicit global scope must go through this nonterminal so
3169 that got_scope will be set before yylex is called to get the next token. */
3172 { got_scope = void_type_node; }
3175 /* ISO new-declarator (5.3.4) */
3177 '*' cv_qualifiers new_declarator
3178 { $$ = make_pointer_declarator ($2, $3); }
3179 | '*' cv_qualifiers %prec EMPTY
3180 { $$ = make_pointer_declarator ($2, NULL_TREE); }
3181 | '&' cv_qualifiers new_declarator %prec EMPTY
3182 { $$ = make_reference_declarator ($2, $3); }
3183 | '&' cv_qualifiers %prec EMPTY
3184 { $$ = make_reference_declarator ($2, NULL_TREE); }
3185 | ptr_to_mem cv_qualifiers %prec EMPTY
3186 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3187 $$ = build_nt (SCOPE_REF, $1, arg);
3189 | ptr_to_mem cv_qualifiers new_declarator
3190 { tree arg = make_pointer_declarator ($2, $3);
3191 $$ = build_nt (SCOPE_REF, $1, arg);
3193 | direct_new_declarator %prec EMPTY
3196 /* ISO direct-new-declarator (5.3.4) */
3197 direct_new_declarator:
3199 { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
3200 | direct_new_declarator '[' expr ']'
3201 { $$ = build_nt (ARRAY_REF, $$, $3); }
3208 /* Provide support for '(' attributes '*' declarator ')'
3210 $$ = tree_cons ($1, $2, NULL_TREE);
3214 /* ISO abstract-declarator (8.1) */
3216 '*' nonempty_cv_qualifiers absdcl_intern
3217 { $$ = make_pointer_declarator ($2.t, $3); }
3219 { $$ = make_pointer_declarator (NULL_TREE, $2); }
3220 | '*' nonempty_cv_qualifiers %prec EMPTY
3221 { $$ = make_pointer_declarator ($2.t, NULL_TREE); }
3223 { $$ = make_pointer_declarator (NULL_TREE, NULL_TREE); }
3224 | '&' nonempty_cv_qualifiers absdcl_intern
3225 { $$ = make_reference_declarator ($2.t, $3); }
3227 { $$ = make_reference_declarator (NULL_TREE, $2); }
3228 | '&' nonempty_cv_qualifiers %prec EMPTY
3229 { $$ = make_reference_declarator ($2.t, NULL_TREE); }
3231 { $$ = make_reference_declarator (NULL_TREE, NULL_TREE); }
3232 | ptr_to_mem cv_qualifiers %prec EMPTY
3233 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3234 $$ = build_nt (SCOPE_REF, $1, arg);
3236 | ptr_to_mem cv_qualifiers absdcl_intern
3237 { tree arg = make_pointer_declarator ($2, $3);
3238 $$ = build_nt (SCOPE_REF, $1, arg);
3240 | direct_abstract_declarator %prec EMPTY
3243 /* ISO direct-abstract-declarator (8.1) */
3244 direct_abstract_declarator:
3245 '(' absdcl_intern ')'
3247 /* `(typedef)1' is `int'. */
3248 | direct_abstract_declarator '(' parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3249 { $$ = make_call_declarator ($$, $3, $5, $6); }
3250 | direct_abstract_declarator LEFT_RIGHT cv_qualifiers exception_specification_opt %prec '.'
3251 { $$ = make_call_declarator ($$, empty_parms (), $3, $4); }
3252 | direct_abstract_declarator '[' expr ']' %prec '.'
3253 { $$ = build_nt (ARRAY_REF, $$, $3); }
3254 | direct_abstract_declarator '[' ']' %prec '.'
3255 { $$ = build_nt (ARRAY_REF, $$, NULL_TREE); }
3256 | '(' complex_parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3257 { $$ = make_call_declarator (NULL_TREE, $2, $4, $5); }
3258 | regcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3259 { set_quals_and_spec ($$, $2, $3); }
3260 | fcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3261 { set_quals_and_spec ($$, $2, $3); }
3262 | '[' expr ']' %prec '.'
3263 { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
3265 { $$ = build_nt (ARRAY_REF, NULL_TREE, NULL_TREE); }
3268 /* For C++, decls and stmts can be intermixed, so we don't need to
3269 have a special rule that won't start parsing the stmt section
3270 until we have a stmt that parses without errors. */
3283 /* Read zero or more forward-declarations for labels
3284 that nested functions can jump to. */
3289 pedwarn ("ISO C++ forbids label declarations"); }
3294 | label_decls label_decl
3298 LABEL identifiers_or_typenames ';'
3302 finish_label_decl (TREE_VALUE ($2));
3303 $2 = TREE_CHAIN ($2);
3310 { $<ttype>$ = begin_compound_stmt (0); }
3312 { STMT_LINENO ($<ttype>3) = $1;
3313 finish_compound_stmt (0, $<ttype>3); }
3318 { $<ttype>$ = begin_if_stmt ();
3319 cond_stmt_keyword = "if"; }
3321 { finish_if_stmt_cond ($3, $<ttype>2); }
3322 implicitly_scoped_stmt
3324 finish_then_clause ($<ttype>2); }
3327 implicitly_scoped_stmt:
3330 { $<ttype>$ = begin_compound_stmt (0); }
3331 save_lineno simple_stmt
3332 { STMT_LINENO ($<ttype>1) = $2;
3333 if ($3) STMT_LINENO ($3) = $2;
3334 finish_compound_stmt (0, $<ttype>1); }
3339 | save_lineno simple_stmt
3340 { if ($2) STMT_LINENO ($2) = $1; }
3348 { $$ = finish_expr_stmt ($1); }
3350 { begin_else_clause (); }
3351 implicitly_scoped_stmt
3354 finish_else_clause ($1);
3357 | simple_if %prec IF
3359 finish_if_stmt (); }
3362 $<ttype>$ = begin_while_stmt ();
3363 cond_stmt_keyword = "while";
3366 { finish_while_stmt_cond ($3, $<ttype>2); }
3367 implicitly_scoped_stmt
3369 finish_while_stmt ($<ttype>2); }
3371 { $<ttype>$ = begin_do_stmt (); }
3372 implicitly_scoped_stmt WHILE
3374 finish_do_body ($<ttype>2);
3375 cond_stmt_keyword = "do";
3377 paren_expr_or_null ';'
3379 finish_do_stmt ($6, $<ttype>2); }
3381 { $<ttype>$ = begin_for_stmt (); }
3382 '(' for.init.statement
3383 { finish_for_init_stmt ($<ttype>2); }
3385 { finish_for_cond ($6, $<ttype>2); }
3387 { finish_for_expr ($9, $<ttype>2); }
3388 implicitly_scoped_stmt
3390 finish_for_stmt ($<ttype>2); }
3392 { $<ttype>$ = begin_switch_stmt (); }
3394 { finish_switch_cond ($4, $<ttype>2); }
3395 implicitly_scoped_stmt
3397 finish_switch_stmt ($<ttype>2); }
3398 | CASE expr_no_commas ':'
3399 { $<ttype>$ = finish_case_label ($2, NULL_TREE); }
3402 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
3403 { $<ttype>$ = finish_case_label ($2, $4); }
3407 { $<ttype>$ = finish_case_label (NULL_TREE, NULL_TREE); }
3411 { $$ = finish_break_stmt (); }
3413 { $$ = finish_continue_stmt (); }
3414 | RETURN_KEYWORD ';'
3415 { $$ = finish_return_stmt (NULL_TREE); }
3416 | RETURN_KEYWORD expr ';'
3417 { $$ = finish_return_stmt ($2); }
3418 | asm_keyword maybe_cv_qualifier '(' string ')' ';'
3419 { $$ = finish_asm_stmt ($2, $4, NULL_TREE, NULL_TREE,
3421 ASM_INPUT_P ($$) = 1; }
3422 /* This is the case with just output operands. */
3423 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ')' ';'
3424 { $$ = finish_asm_stmt ($2, $4, $6, NULL_TREE, NULL_TREE); }
3425 /* This is the case with input operands as well. */
3426 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':'
3427 asm_operands ')' ';'
3428 { $$ = finish_asm_stmt ($2, $4, $6, $8, NULL_TREE); }
3429 | asm_keyword maybe_cv_qualifier '(' string SCOPE asm_operands ')' ';'
3430 { $$ = finish_asm_stmt ($2, $4, NULL_TREE, $6, NULL_TREE); }
3431 /* This is the case with clobbered registers as well. */
3432 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':'
3433 asm_operands ':' asm_clobbers ')' ';'
3434 { $$ = finish_asm_stmt ($2, $4, $6, $8, $10); }
3435 | asm_keyword maybe_cv_qualifier '(' string SCOPE asm_operands ':'
3436 asm_clobbers ')' ';'
3437 { $$ = finish_asm_stmt ($2, $4, NULL_TREE, $6, $8); }
3438 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands SCOPE
3439 asm_clobbers ')' ';'
3440 { $$ = finish_asm_stmt ($2, $4, $6, NULL_TREE, $8); }
3444 pedwarn ("ISO C++ forbids computed gotos");
3445 $$ = finish_goto_stmt ($3);
3447 | GOTO identifier ';'
3448 { $$ = finish_goto_stmt ($2); }
3452 { error ("label must be followed by statement");
3462 | namespace_using_decl
3463 { do_local_using_decl ($1);
3471 { $<ttype>$ = begin_function_try_block (); }
3473 { finish_function_try_block ($<ttype>2); }
3475 { finish_function_handler_sequence ($<ttype>2); }
3480 { $<ttype>$ = begin_try_block (); }
3482 { finish_try_block ($<ttype>2); }
3484 { finish_handler_sequence ($<ttype>2); }
3489 | handler_seq handler
3494 { $<ttype>$ = begin_handler (); }
3496 { finish_handler_parms ($3, $<ttype>2); }
3498 { finish_handler ($<ttype>2); }
3502 typed_typespecs %prec EMPTY
3503 | nonempty_cv_qualifiers %prec EMPTY
3509 /* This doesn't allow reference parameters, the below does.
3510 | '(' type_specifier_seq absdcl ')'
3511 { check_for_new_type ("inside exception declarations", $2);
3512 expand_start_catch_block ($2.t, $3); }
3513 | '(' type_specifier_seq ')'
3514 { check_for_new_type ("inside exception declarations", $2);
3515 expand_start_catch_block ($2.t, NULL_TREE); }
3516 | '(' type_specifier_seq notype_declarator ')'
3517 { check_for_new_type ("inside exception declarations", $2);
3518 expand_start_catch_block ($2.t, $3); }
3519 | '(' typed_typespecs after_type_declarator ')'
3520 { check_for_new_type ("inside exception declarations", $2);
3521 expand_start_catch_block ($2.t, $3); }
3522 This allows reference parameters... */
3525 check_for_new_type ("inside exception declarations", $2);
3526 $$ = start_handler_parms (TREE_PURPOSE ($2.t),
3533 { finish_label_stmt ($1); }
3535 { finish_label_stmt ($1); }
3537 { finish_label_stmt ($1); }
3539 { finish_label_stmt ($1); }
3544 { finish_expr_stmt ($1); }
3548 pedwarn ("ISO C++ forbids compound statements inside for initializations");
3552 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
3568 /* These are the operands other than the first string and colon
3569 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
3573 | nonnull_asm_operands
3576 nonnull_asm_operands:
3578 | nonnull_asm_operands ',' asm_operand
3579 { $$ = chainon ($$, $3); }
3584 { $$ = build_tree_list (build_tree_list (NULL_TREE, $1), $3); }
3585 | '[' identifier ']' STRING '(' expr ')'
3586 { $$ = build_tree_list (build_tree_list ($2, $4), $6); }
3591 { $$ = tree_cons (NULL_TREE, combine_strings ($1), NULL_TREE);}
3592 | asm_clobbers ',' string
3593 { $$ = tree_cons (NULL_TREE, combine_strings ($3), $1); }
3596 /* This is what appears inside the parens in a function declarator.
3597 Its value is represented in the format that grokdeclarator expects.
3599 In C++, declaring a function with no parameters
3600 means that that function takes *no* parameters. */
3609 { $$ = finish_parmlist (build_tree_list (NULL_TREE, $1.t), 0);
3610 check_for_new_type ("inside parameter list", $1); }
3613 /* This nonterminal does not include the common sequence '(' type_id ')',
3614 as it is ambiguous and must be disambiguated elsewhere. */
3617 { $$ = finish_parmlist ($$, 0); }
3618 | parms_comma ELLIPSIS
3619 { $$ = finish_parmlist ($1, 1); }
3620 /* C++ allows an ellipsis without a separating ',' */
3622 { $$ = finish_parmlist ($1, 1); }
3624 { $$ = finish_parmlist (build_tree_list (NULL_TREE,
3627 { $$ = finish_parmlist (NULL_TREE, 1); }
3630 /* This helps us recover from really nasty
3631 parse errors, for example, a missing right
3633 yyerror ("possibly missing ')'");
3634 $$ = finish_parmlist ($1, 0);
3640 /* This helps us recover from really nasty
3641 parse errors, for example, a missing right
3643 yyerror ("possibly missing ')'");
3644 $$ = finish_parmlist (build_tree_list (NULL_TREE,
3651 /* A default argument to a */
3654 { maybe_snarf_defarg (); }
3664 /* A nonempty list of parameter declarations or type names. */
3667 { check_for_new_type ("in a parameter list", $1);
3668 $$ = build_tree_list (NULL_TREE, $1.t); }
3670 { check_for_new_type ("in a parameter list", $1);
3671 $$ = build_tree_list ($2, $1.t); }
3672 | parms_comma full_parm
3673 { check_for_new_type ("in a parameter list", $2);
3674 $$ = chainon ($$, $2.t); }
3675 | parms_comma bad_parm
3676 { $$ = chainon ($$, build_tree_list (NULL_TREE, $2)); }
3677 | parms_comma bad_parm '=' init
3678 { $$ = chainon ($$, build_tree_list ($4, $2)); }
3684 { check_for_new_type ("in a parameter list", $1);
3685 $$ = build_tree_list (NULL_TREE, $1.t); }
3688 /* A single parameter declaration or parameter type name,
3689 as found in a parmlist. */
3691 /* Here we expand typed_declspecs inline to avoid mis-parsing of
3692 TYPESPEC IDENTIFIER. */
3693 typed_declspecs1 declarator
3694 { tree specs = strip_attrs ($1.t);
3695 $$.new_type_flag = $1.new_type_flag;
3696 $$.t = build_tree_list (specs, $2); }
3697 | typed_typespecs declarator
3698 { $$.t = build_tree_list ($1.t, $2);
3699 $$.new_type_flag = $1.new_type_flag; }
3700 | typespec declarator
3701 { $$.t = build_tree_list (build_tree_list (NULL_TREE, $1.t),
3703 $$.new_type_flag = $1.new_type_flag; }
3704 | typed_declspecs1 absdcl
3705 { tree specs = strip_attrs ($1.t);
3706 $$.t = build_tree_list (specs, $2);
3707 $$.new_type_flag = $1.new_type_flag; }
3708 | typed_declspecs1 %prec EMPTY
3709 { tree specs = strip_attrs ($1.t);
3710 $$.t = build_tree_list (specs, NULL_TREE);
3711 $$.new_type_flag = $1.new_type_flag; }
3712 | declmods notype_declarator
3713 { tree specs = strip_attrs ($1.t);
3714 $$.t = build_tree_list (specs, $2);
3715 $$.new_type_flag = 0; }
3720 { $$.t = build_tree_list (NULL_TREE, $1.t);
3721 $$.new_type_flag = $1.new_type_flag; }
3723 { $$.t = build_tree_list ($2, $1.t);
3724 $$.new_type_flag = $1.new_type_flag; }
3733 /* empty */ %prec EMPTY
3734 { see_typename (); }
3738 /* empty */ %prec EMPTY
3740 error ("type specifier omitted for parameter");
3741 $$ = build_tree_list (integer_type_node, NULL_TREE);
3745 if (TREE_CODE ($$) == SCOPE_REF)
3747 if (TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TYPE_PARM
3748 || TREE_CODE (TREE_OPERAND ($$, 0)) == BOUND_TEMPLATE_TEMPLATE_PARM)
3749 error ("`%E' is not a type, use `typename %E' to make it one", $$);
3751 error ("no type `%D' in `%T'", TREE_OPERAND ($$, 1), TREE_OPERAND ($$, 0));
3754 error ("type specifier omitted for parameter `%E'", $$);
3755 $$ = build_tree_list (integer_type_node, $$);
3760 IDENTIFIER template_arg_list_ignore IDENTIFIER arg_list_ignore ';'
3762 error("'%D' is used as a type, but is not defined as a type.", $1);
3763 $3 = error_mark_node;
3767 template_arg_list_ignore:
3768 '<' template_arg_list_opt template_close_bracket
3774 '(' nonnull_exprlist ')'
3779 exception_specification_opt:
3780 /* empty */ %prec EMPTY
3782 | THROW '(' ansi_raise_identifiers ')' %prec EMPTY
3784 | THROW LEFT_RIGHT %prec EMPTY
3785 { $$ = empty_except_spec; }
3788 ansi_raise_identifier:
3791 check_for_new_type ("exception specifier", $1);
3792 $$ = groktypename ($1.t);
3796 ansi_raise_identifiers:
3797 ansi_raise_identifier
3798 { $$ = add_exception_specifier (NULL_TREE, $1, 1); }
3799 | ansi_raise_identifiers ',' ansi_raise_identifier
3800 { $$ = add_exception_specifier ($1, $3, 1); }
3803 conversion_declarator:
3804 /* empty */ %prec EMPTY
3806 | '*' cv_qualifiers conversion_declarator
3807 { $$ = make_pointer_declarator ($2, $3); }
3808 | '&' cv_qualifiers conversion_declarator
3809 { $$ = make_reference_declarator ($2, $3); }
3810 | ptr_to_mem cv_qualifiers conversion_declarator
3811 { tree arg = make_pointer_declarator ($2, $3);
3812 $$ = build_nt (SCOPE_REF, $1, arg);
3819 saved_scopes = tree_cons (got_scope, got_object, saved_scopes);
3820 TREE_LANG_FLAG_0 (saved_scopes) = looking_for_typename;
3821 /* We look for conversion-type-id's in both the class and current
3822 scopes, just as for ID in 'ptr->ID::'. */
3823 looking_for_typename = 1;
3824 got_object = got_scope;
3825 got_scope = NULL_TREE;
3830 { got_scope = TREE_PURPOSE (saved_scopes);
3831 got_object = TREE_VALUE (saved_scopes);
3832 looking_for_typename = TREE_LANG_FLAG_0 (saved_scopes);
3833 saved_scopes = TREE_CHAIN (saved_scopes);
3838 operator '*' unoperator
3839 { $$ = frob_opname (ansi_opname (MULT_EXPR)); }
3840 | operator '/' unoperator
3841 { $$ = frob_opname (ansi_opname (TRUNC_DIV_EXPR)); }
3842 | operator '%' unoperator
3843 { $$ = frob_opname (ansi_opname (TRUNC_MOD_EXPR)); }
3844 | operator '+' unoperator
3845 { $$ = frob_opname (ansi_opname (PLUS_EXPR)); }
3846 | operator '-' unoperator
3847 { $$ = frob_opname (ansi_opname (MINUS_EXPR)); }
3848 | operator '&' unoperator
3849 { $$ = frob_opname (ansi_opname (BIT_AND_EXPR)); }
3850 | operator '|' unoperator
3851 { $$ = frob_opname (ansi_opname (BIT_IOR_EXPR)); }
3852 | operator '^' unoperator
3853 { $$ = frob_opname (ansi_opname (BIT_XOR_EXPR)); }
3854 | operator '~' unoperator
3855 { $$ = frob_opname (ansi_opname (BIT_NOT_EXPR)); }
3856 | operator ',' unoperator
3857 { $$ = frob_opname (ansi_opname (COMPOUND_EXPR)); }
3858 | operator ARITHCOMPARE unoperator
3859 { $$ = frob_opname (ansi_opname ($2)); }
3860 | operator '<' unoperator
3861 { $$ = frob_opname (ansi_opname (LT_EXPR)); }
3862 | operator '>' unoperator
3863 { $$ = frob_opname (ansi_opname (GT_EXPR)); }
3864 | operator EQCOMPARE unoperator
3865 { $$ = frob_opname (ansi_opname ($2)); }
3866 | operator ASSIGN unoperator
3867 { $$ = frob_opname (ansi_assopname ($2)); }
3868 | operator '=' unoperator
3869 { $$ = frob_opname (ansi_assopname (NOP_EXPR)); }
3870 | operator LSHIFT unoperator
3871 { $$ = frob_opname (ansi_opname ($2)); }
3872 | operator RSHIFT unoperator
3873 { $$ = frob_opname (ansi_opname ($2)); }
3874 | operator PLUSPLUS unoperator
3875 { $$ = frob_opname (ansi_opname (POSTINCREMENT_EXPR)); }
3876 | operator MINUSMINUS unoperator
3877 { $$ = frob_opname (ansi_opname (PREDECREMENT_EXPR)); }
3878 | operator ANDAND unoperator
3879 { $$ = frob_opname (ansi_opname (TRUTH_ANDIF_EXPR)); }
3880 | operator OROR unoperator
3881 { $$ = frob_opname (ansi_opname (TRUTH_ORIF_EXPR)); }
3882 | operator '!' unoperator
3883 { $$ = frob_opname (ansi_opname (TRUTH_NOT_EXPR)); }
3884 | operator '?' ':' unoperator
3885 { $$ = frob_opname (ansi_opname (COND_EXPR)); }
3886 | operator MIN_MAX unoperator
3887 { $$ = frob_opname (ansi_opname ($2)); }
3888 | operator POINTSAT unoperator %prec EMPTY
3889 { $$ = frob_opname (ansi_opname (COMPONENT_REF)); }
3890 | operator POINTSAT_STAR unoperator %prec EMPTY
3891 { $$ = frob_opname (ansi_opname (MEMBER_REF)); }
3892 | operator LEFT_RIGHT unoperator
3893 { $$ = frob_opname (ansi_opname (CALL_EXPR)); }
3894 | operator '[' ']' unoperator
3895 { $$ = frob_opname (ansi_opname (ARRAY_REF)); }
3896 | operator NEW unoperator %prec EMPTY
3897 { $$ = frob_opname (ansi_opname (NEW_EXPR)); }
3898 | operator DELETE unoperator %prec EMPTY
3899 { $$ = frob_opname (ansi_opname (DELETE_EXPR)); }
3900 | operator NEW '[' ']' unoperator
3901 { $$ = frob_opname (ansi_opname (VEC_NEW_EXPR)); }
3902 | operator DELETE '[' ']' unoperator
3903 { $$ = frob_opname (ansi_opname (VEC_DELETE_EXPR)); }
3904 | operator type_specifier_seq conversion_declarator unoperator
3905 { $$ = frob_opname (grokoptypename ($2.t, $3)); }
3906 | operator error unoperator
3907 { $$ = frob_opname (ansi_opname (ERROR_MARK)); }
3910 /* The forced readahead in here is because we might be at the end of a
3911 line, and lineno won't be bumped until yylex absorbs the first token
3912 on the next line. */
3914 { if (yychar == YYEMPTY)
3922 debug_yytranslate (value)
3925 return yytname[YYTRANSLATE (value)];