1 /* YACC parser for C++ syntax.
2 Copyright (C) 1988, 89, 93, 94, 95, 1996 Free Software Foundation, Inc.
3 Hacked by Michael Tiemann (tiemann@cygnus.com)
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
23 /* This grammar is based on the GNU CC grammar. */
25 /* Note: Bison automatically applies a default action of "$$ = $1" for
26 all derivations; this is applied before the explicit action, if one
27 is given. Keep this in mind when reading the actions. */
30 /* Cause the `yydebug' variable to be defined. */
46 /* Since parsers are distinct for each language, put the language string
47 definition here. (fnf) */
48 char *language_string = "GNU C++";
50 extern tree void_list_node;
51 extern struct obstack permanent_obstack;
57 extern int end_of_file;
58 extern int current_class_depth;
60 /* FSF LOCAL dje prefix attributes */
61 extern tree strip_attrs PROTO((tree));
64 /* Like YYERROR but do call yyerror. */
65 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
67 #define OP0(NODE) (TREE_OPERAND (NODE, 0))
68 #define OP1(NODE) (TREE_OPERAND (NODE, 1))
70 /* Contains the statement keyword (if/while/do) to include in an
71 error message if the user supplies an empty conditional expression. */
72 static char *cond_stmt_keyword;
74 /* If nonzero, we try to treat TEMPLATE_DECL as argument in template
75 template parameter. */
76 static int processing_template_arg;
78 extern int arg_looking_for_template;
80 static tree empty_parms PROTO((void));
82 /* Nonzero if we have an `extern "C"' acting as an extern specifier. */
86 /* Cons up an empty parameter list. */
96 || current_class_type != NULL)
97 parms = void_list_node;
107 %union {long itype; tree ttype; char *strtype; enum tree_code code; flagged_type_tree ftype; }
109 /* All identifiers that are not reserved words
110 and are not declared typedefs in the current block */
113 /* All identifiers that are declared typedefs in the current block.
114 In some contexts, they are treated just like IDENTIFIER,
115 but they can also serve as typespecs in declarations. */
119 /* A template function. */
122 /* Reserved words that specify storage class.
123 yylval contains an IDENTIFIER_NODE which indicates which one. */
126 /* Reserved words that specify type.
127 yylval contains an IDENTIFIER_NODE which indicates which one. */
130 /* Reserved words that qualify type: "const" or "volatile".
131 yylval contains an IDENTIFIER_NODE which indicates which one. */
134 /* Character or numeric constants.
135 yylval is the node for the constant. */
138 /* String constants in raw form.
139 yylval is a STRING_CST node. */
142 /* "...", used for functions with variable arglists. */
145 /* the reserved words */
146 /* SCO include files test "ASM", so use something else. */
147 %token SIZEOF ENUM /* STRUCT UNION */ IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
148 %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD GCC_ASM_KEYWORD TYPEOF ALIGNOF
150 %token ATTRIBUTE EXTENSION LABEL
151 %token REALPART IMAGPART
153 /* the reserved words... C++ extensions */
155 %token <ttype> VISSPEC
156 %token DELETE NEW THIS OPERATOR CXX_TRUE CXX_FALSE
157 %token NAMESPACE TYPENAME_KEYWORD USING
158 %token LEFT_RIGHT TEMPLATE
159 %token TYPEID DYNAMIC_CAST STATIC_CAST REINTERPRET_CAST CONST_CAST
162 /* Define the operator tokens and their precedences.
163 The value is an integer because, if used, it is the tree code
164 to use in the expression made from the operator. */
166 %left EMPTY /* used to resolve s/r with epsilon */
170 /* Add precedence rules to solve dangling else s/r conflict */
174 %left IDENTIFIER PFUNCNAME TYPENAME SELFNAME PTYPENAME SCSPEC TYPESPEC CV_QUALIFIER ENUM AGGR ELLIPSIS TYPEOF SIGOF OPERATOR NSNAME TYPENAME_KEYWORD
180 %right <code> ASSIGN '='
188 %left <code> EQCOMPARE
189 %left <code> ARITHCOMPARE '<' '>'
190 %left <code> LSHIFT RSHIFT
192 %left <code> '*' '/' '%'
193 %left <code> POINTSAT_STAR DOT_STAR
194 %right <code> UNARY PLUSPLUS MINUSMINUS '~'
196 %left <ttype> PAREN_STAR_PAREN LEFT_RIGHT
197 %left <code> POINTSAT '.' '(' '['
199 %right SCOPE /* C++ extension */
200 %nonassoc NEW DELETE TRY CATCH
204 %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist
205 %type <ttype> PFUNCNAME maybe_identifier
206 %type <ttype> paren_expr_or_null nontrivial_exprlist SELFNAME
207 %type <ttype> expr_no_commas cast_expr unary_expr primary string STRING
208 %type <ttype> reserved_declspecs boolean.literal
209 %type <ttype> reserved_typespecquals
210 %type <ttype> declmods
211 %type <ttype> SCSPEC TYPESPEC CV_QUALIFIER maybe_cv_qualifier
212 %type <itype> initdecls notype_initdecls initdcl /* C++ modification */
213 %type <ttype> init initlist maybeasm maybe_init defarg defarg1
214 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
215 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
216 %type <ttype> any_word
218 %type <ttype> compstmt implicitly_scoped_stmt
220 %type <ttype> declarator notype_declarator after_type_declarator
221 %type <ttype> direct_notype_declarator direct_after_type_declarator
223 %type <ttype> opt.component_decl_list component_decl_list
224 %type <ttype> component_decl component_decl_1 components notype_components
225 %type <ttype> component_declarator component_declarator0 self_reference
226 %type <ttype> notype_component_declarator notype_component_declarator0
227 %type <ttype> after_type_component_declarator after_type_component_declarator0
228 %type <ttype> enumlist enumerator
229 %type <ttype> absdcl cv_qualifiers
230 %type <ttype> direct_abstract_declarator conversion_declarator
231 %type <ttype> new_declarator direct_new_declarator
232 %type <ttype> xexpr parmlist parms bad_parm
233 %type <ttype> identifiers_or_typenames
234 %type <ttype> fcast_or_absdcl regcast_or_absdcl
235 %type <ttype> expr_or_declarator complex_notype_declarator
236 %type <ttype> notype_unqualified_id unqualified_id qualified_id
237 %type <ttype> template_id do_id object_template_id notype_template_declarator
238 %type <ttype> overqualified_id notype_qualified_id any_id
239 %type <ttype> complex_direct_notype_declarator functional_cast
240 %type <ttype> complex_parmlist parms_comma
242 %type <ftype> type_id new_type_id typed_typespecs typespec typed_declspecs
243 %type <ftype> typed_declspecs1 type_specifier_seq nonempty_cv_qualifiers
244 %type <ftype> structsp typespecqual_reserved parm named_parm full_parm
247 %token <ttype> TYPENAME_ELLIPSIS PTYPENAME
248 %token <ttype> PRE_PARSED_FUNCTION_DECL EXTERN_LANG_STRING ALL
249 %token <ttype> PRE_PARSED_CLASS_DECL DEFARG DEFARG_MARKER
250 %type <ttype> fn.def1 /* Not really! */ component_constructor_declarator
251 %type <ttype> fn.def2 return_id fn.defpen constructor_declarator
252 %type <itype> ctor_initializer_opt
253 %type <ttype> named_class_head named_class_head_sans_basetype
254 %type <ttype> named_complex_class_head_sans_basetype
255 %type <ttype> unnamed_class_head
256 %type <ttype> class_head base_class_list
257 %type <ttype> base_class_access_list
258 %type <ttype> base_class maybe_base_class_list base_class.1
259 %type <ttype> exception_specification_opt ansi_raise_identifier ansi_raise_identifiers
260 %type <ttype> operator_name
261 %type <ttype> object aggr
262 %type <itype> new delete
263 /* %type <ttype> primary_no_id */
264 %type <ttype> nonmomentary_expr maybe_parmlist
265 %type <itype> initdcl0 notype_initdcl0 member_init_list
266 %type <ttype> template_header template_parm_list template_parm
267 %type <ttype> template_type_parm template_template_parm
268 %type <code> template_close_bracket
269 %type <ttype> template_type template_arg_list template_arg_list_opt
270 %type <ttype> template_arg template_arg1
271 %type <ttype> condition xcond paren_cond_or_null
272 %type <ttype> type_name nested_name_specifier nested_type ptr_to_mem
273 %type <ttype> complete_type_name notype_identifier nonnested_type
274 %type <ttype> complex_type_name nested_name_specifier_1
275 %type <itype> nomods_initdecls nomods_initdcl0
276 %type <ttype> new_initializer new_placement
277 %type <ttype> using_decl .poplevel
278 %type <ttype> typename_sub typename_sub0 typename_sub1 typename_sub2
279 /* in order to recognize aggr tags as defining and thus shadowing. */
280 %token TYPENAME_DEFN IDENTIFIER_DEFN PTYPENAME_DEFN
281 %type <ttype> named_class_head_sans_basetype_defn
282 %type <ttype> identifier_defn IDENTIFIER_DEFN TYPENAME_DEFN PTYPENAME_DEFN
284 %type <ttype> self_template_type
289 /* Used in lex.c for parsing pragmas. */
292 /* lex.c and pt.c depend on this being the last token. Define
293 any new tokens before this one! */
294 %token END_OF_SAVED_INPUT
297 /* List of types and structure classes of the current declaration. */
298 static tree current_declspecs = NULL_TREE;
299 /* List of prefix attributes in effect.
300 Prefix attributes are parsed by the reserved_declspecs and declmods
301 rules. They create a list that contains *both* declspecs and attrs. */
302 /* ??? It is not clear yet that all cases where an attribute can now appear in
303 a declspec list have been updated. */
304 static tree prefix_attributes = NULL_TREE;
306 /* When defining an aggregate, this is the most recent one being defined. */
307 static tree current_aggr;
309 /* Tell yyparse how to print a token's value, if yydebug is set. */
311 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
312 extern void yyprint PROTO((FILE *, int, YYSTYPE));
313 extern tree combine_strings PROTO((tree));
321 /* In case there were missing closebraces,
322 get us back to the global binding level. */
323 while (! global_bindings_p ())
329 /* the reason for the strange actions in this rule
330 is so that notype_initdecls when reached via datadef
331 can find a valid list of type and sc specs in $0. */
334 { $<ttype>$ = NULL_TREE; }
336 { $<ttype>$ = NULL_TREE; }
337 | extdefs lang_extdef
338 { $<ttype>$ = NULL_TREE; }
347 { have_extern_spec = 1;
348 used_extern_spec = 0;
349 $<ttype>$ = NULL_TREE; }
352 { have_extern_spec = 0; }
357 { $<itype>$ = pedantic;
367 { if (pending_lang_change) do_pending_lang_change(); }
369 { if (! toplevel_bindings_p () && ! pseudo_global_level_p())
374 fndef eat_saved_input
375 { if (pending_inlines) do_pending_inlines (); }
377 { if (pending_inlines) do_pending_inlines (); }
379 { if (pending_inlines) do_pending_inlines (); }
380 | asm_keyword '(' string ')' ';'
381 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
383 | extern_lang_string '{' extdefs_opt '}'
384 { pop_lang_context (); }
385 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
386 { if (pending_inlines) do_pending_inlines ();
387 pop_lang_context (); }
388 | extern_lang_string .hush_warning datadef .warning_ok
389 { if (pending_inlines) do_pending_inlines ();
390 pop_lang_context (); }
391 | NAMESPACE identifier '{'
392 { push_namespace ($2); }
394 { pop_namespace (); }
396 { push_namespace (NULL_TREE); }
398 { pop_namespace (); }
399 | NAMESPACE identifier '=' any_id ';'
400 { do_namespace_alias ($2, $4); }
402 { do_toplevel_using_decl ($1); }
403 | USING NAMESPACE any_id ';'
405 if (TREE_CODE ($3) == IDENTIFIER_NODE)
407 do_using_directive ($3);
410 { pedantic = $<itype>1; }
416 | USING global_scope qualified_id
418 | USING global_scope unqualified_id
425 | global_scope qualified_id
427 | global_scope unqualified_id
433 { push_lang_context ($1); }
434 | extern_lang_string EXTERN_LANG_STRING
435 { if (current_lang_name != $2)
436 cp_error ("use of linkage spec `%D' is different from previous spec `%D'", $2, current_lang_name);
437 pop_lang_context (); push_lang_context ($2); }
442 { begin_template_parm_list (); }
443 template_parm_list '>'
444 { $$ = end_template_parm_list ($4); }
446 { begin_specialization();
452 { $$ = process_template_parm (NULL_TREE, $1); }
453 | template_parm_list ',' template_parm
454 { $$ = process_template_parm ($1, $3); }
464 aggr maybe_identifier
466 $$ = build_tree_list ($1, $2);
467 if (TREE_PURPOSE ($$) == signature_type_node)
468 sorry ("signature as template type parameter");
469 else if (TREE_PURPOSE ($$) != class_type_node)
471 pedwarn ("template type parameters must use the keyword `class'");
472 TREE_PURPOSE ($$) = class_type_node;
475 | TYPENAME_KEYWORD maybe_identifier
476 { $$ = build_tree_list (class_type_node, $2); }
479 template_template_parm:
480 template_header aggr maybe_identifier
482 tree decl = build_decl (TYPE_DECL, $3, NULL_TREE);
483 tree tmpl = build_lang_decl (TEMPLATE_DECL, $3, NULL_TREE);
484 DECL_TEMPLATE_PARMS (tmpl) = current_template_parms;
485 DECL_TEMPLATE_RESULT (tmpl) = decl;
486 SET_DECL_ARTIFICIAL (decl);
487 end_template_decl ();
489 if ($2 == signature_type_node)
490 sorry ("signature as template template parameter");
491 else if ($2 != class_type_node)
492 pedwarn ("template template parameters must use the keyword `class'");
493 $$ = build_tree_list (class_type_node, tmpl);
498 /* The following rules introduce a new reduce/reduce
499 conflict on the ',' and '>' input tokens: they are valid
500 prefixes for a `structsp', which means they could match a
501 nameless parameter. See 14.6, paragraph 3.
502 By putting them before the `parm' rule, we get
503 their match before considering them nameless parameter
506 { $$ = build_tree_list (NULL_TREE, $1); }
507 | template_type_parm '=' type_id
508 { $$ = build_tree_list (groktypename ($3.t), $1); }
510 { $$ = build_tree_list (NULL_TREE, $1.t); }
511 | parm '=' expr_no_commas %prec ARITHCOMPARE
512 { $$ = build_tree_list ($3, $1.t); }
513 | template_template_parm
514 { $$ = build_tree_list (NULL_TREE, $1); }
515 | template_template_parm '=' PTYPENAME
518 arg_looking_for_template = 1;
519 defarg = lookup_name ($3, 0);
520 arg_looking_for_template = 0;
522 if (!defarg || defarg == error_mark_node
523 || (TREE_CODE (defarg) != TEMPLATE_DECL
524 && TREE_CODE (defarg) != TEMPLATE_TEMPLATE_PARM))
525 defarg = do_identifier ($3, 1);
526 $$ = build_tree_list (defarg, $1);
535 end_template_decl ();
537 end_specialization ();
543 end_template_decl ();
545 end_specialization ();
552 | declmods notype_initdecls ';'
554 | typed_declspecs initdecls ';'
556 note_list_got_semicolon ($1.t);
559 { pedwarn ("empty declaration"); }
560 | explicit_instantiation ';'
561 | typed_declspecs ';'
564 split_specs_attrs ($1.t, &t, &attrs);
566 note_list_got_semicolon ($1.t);
573 ctor_initializer_opt:
592 fn.def1 maybe_return_init ctor_initializer_opt compstmt_or_error
593 { finish_function (lineno, (int)$3, 0); }
594 | fn.def1 maybe_return_init function_try_block
596 | fn.def1 maybe_return_init error
600 constructor_declarator:
601 nested_name_specifier SELFNAME '('
603 $$ = build_parse_node (SCOPE_REF, $1, $2);
604 if ($1 != current_class_type)
606 push_nested_class ($1, 3);
607 TREE_COMPLEXITY ($$) = current_class_depth;
610 parmlist ')' cv_qualifiers exception_specification_opt
611 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
612 | nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
614 $$ = build_parse_node (SCOPE_REF, $1, $2);
615 if ($1 != current_class_type)
617 push_nested_class ($1, 3);
618 TREE_COMPLEXITY ($$) = current_class_depth;
620 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
622 | global_scope nested_name_specifier SELFNAME '('
624 $$ = build_parse_node (SCOPE_REF, $2, $3);
625 if ($2 != current_class_type)
627 push_nested_class ($2, 3);
628 TREE_COMPLEXITY ($$) = current_class_depth;
631 parmlist ')' cv_qualifiers exception_specification_opt
632 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
633 | global_scope nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
635 $$ = build_parse_node (SCOPE_REF, $2, $3);
636 if ($2 != current_class_type)
638 push_nested_class ($2, 3);
639 TREE_COMPLEXITY ($$) = current_class_depth;
641 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
643 | nested_name_specifier self_template_type '('
645 $$ = build_parse_node (SCOPE_REF, $1, $2);
646 if ($1 != current_class_type)
648 push_nested_class ($1, 3);
649 TREE_COMPLEXITY ($$) = current_class_depth;
652 parmlist ')' cv_qualifiers exception_specification_opt
653 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
654 | nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
656 $$ = build_parse_node (SCOPE_REF, $1, $2);
657 if ($1 != current_class_type)
659 push_nested_class ($1, 3);
660 TREE_COMPLEXITY ($$) = current_class_depth;
662 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
664 | global_scope nested_name_specifier self_template_type '('
666 $$ = build_parse_node (SCOPE_REF, $2, $3);
667 if ($2 != current_class_type)
669 push_nested_class ($2, 3);
670 TREE_COMPLEXITY ($$) = current_class_depth;
673 parmlist ')' cv_qualifiers exception_specification_opt
674 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
675 | global_scope nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
677 $$ = build_parse_node (SCOPE_REF, $2, $3);
678 if ($2 != current_class_type)
680 push_nested_class ($2, 3);
681 TREE_COMPLEXITY ($$) = current_class_depth;
683 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
688 typed_declspecs declarator
690 split_specs_attrs ($1.t, &specs, &attrs);
691 if (! start_function (specs, $2, attrs, 0))
693 reinit_parse_for_function ();
695 | declmods notype_declarator
697 split_specs_attrs ($1, &specs, &attrs);
698 if (! start_function (specs, $2, attrs, 0))
700 reinit_parse_for_function ();
703 { if (! start_function (NULL_TREE, $$, NULL_TREE, 0))
705 reinit_parse_for_function ();
707 | declmods constructor_declarator
709 split_specs_attrs ($1, &specs, &attrs);
710 if (! start_function (specs, $2, attrs, 0))
712 reinit_parse_for_function ();
714 | constructor_declarator
715 { if (! start_function (NULL_TREE, $$, NULL_TREE, 0))
717 reinit_parse_for_function ();
721 component_constructor_declarator:
722 SELFNAME '(' parmlist ')' cv_qualifiers exception_specification_opt
723 { $$ = make_call_declarator ($1, $3, $5, $6); }
724 | SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
725 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
726 | self_template_type '(' parmlist ')' cv_qualifiers exception_specification_opt
727 { $$ = make_call_declarator ($1, $3, $5, $6); }
728 | self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
729 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
732 /* more C++ complexity. See component_decl for a comment on the
733 reduce/reduce conflict introduced by these rules. */
735 declmods component_constructor_declarator
736 { tree specs = strip_attrs ($1);
737 $$ = start_method (specs, $2);
741 if (yychar == YYEMPTY)
743 reinit_parse_for_method (yychar, $$); }
744 | component_constructor_declarator
745 { $$ = start_method (NULL_TREE, $1); goto rest_of_mdef; }
746 | typed_declspecs declarator
747 { tree specs = strip_attrs ($1.t);
748 $$ = start_method (specs, $2); goto rest_of_mdef; }
749 | declmods notype_declarator
750 { tree specs = strip_attrs ($1);
751 $$ = start_method (specs, $2); goto rest_of_mdef; }
753 { $$ = start_method (NULL_TREE, $$); goto rest_of_mdef; }
754 | declmods constructor_declarator
755 { tree specs = strip_attrs ($1);
756 $$ = start_method (specs, $2); goto rest_of_mdef; }
757 | constructor_declarator
758 { $$ = start_method (NULL_TREE, $$); goto rest_of_mdef; }
759 | template_header fn.def2
760 { $$ = finish_member_template_decl ($1, $2); }
766 if (! current_function_parms_stored)
774 { store_return_init ($<ttype>$, $2); }
775 | return_id '(' nonnull_exprlist ')'
776 { store_return_init ($<ttype>$, $3); }
777 | return_id LEFT_RIGHT
778 { store_return_init ($<ttype>$, NULL_TREE); }
782 ':' .set_base_init member_init_list
785 error ("no base initializers given following ':'");
787 /* Always keep the BLOCK node associated with the outermost
788 pair of curley braces of a function. These are needed
789 for correct operation of dwarfout.c. */
797 if (! current_function_parms_stored)
800 if (DECL_CONSTRUCTOR_P (current_function_decl))
802 /* Make a contour for the initializer list. */
805 expand_start_bindings (0);
807 else if (current_class_type == NULL_TREE)
808 error ("base initializers not allowed for non-member functions");
809 else if (! DECL_CONSTRUCTOR_P (current_function_decl))
810 error ("only constructors take base initializers");
819 | member_init_list ',' member_init
820 | member_init_list error
824 '(' nonnull_exprlist ')'
826 if (current_class_name)
827 pedwarn ("anachronistic old style base class initializer");
828 expand_member_init (current_class_ref, NULL_TREE, $2);
832 if (current_class_name)
833 pedwarn ("anachronistic old style base class initializer");
834 expand_member_init (current_class_ref, NULL_TREE, void_type_node);
836 | notype_identifier '(' nonnull_exprlist ')'
837 { expand_member_init (current_class_ref, $1, $3); }
838 | notype_identifier LEFT_RIGHT
839 { expand_member_init (current_class_ref, $1, void_type_node); }
840 | nonnested_type '(' nonnull_exprlist ')'
841 { expand_member_init (current_class_ref, $1, $3); }
842 | nonnested_type LEFT_RIGHT
843 { expand_member_init (current_class_ref, $1, void_type_node); }
844 | typename_sub '(' nonnull_exprlist ')'
845 { expand_member_init (current_class_ref, TYPE_MAIN_DECL ($1),
847 | typename_sub LEFT_RIGHT
848 { expand_member_init (current_class_ref, TYPE_MAIN_DECL ($1),
872 explicit_instantiation:
873 TEMPLATE begin_explicit_instantiation typespec ';'
874 { do_type_instantiation ($3.t, NULL_TREE);
876 end_explicit_instantiation
877 | TEMPLATE begin_explicit_instantiation typed_declspecs declarator
878 { tree specs = strip_attrs ($3.t);
879 do_decl_instantiation (specs, $4, NULL_TREE); }
880 end_explicit_instantiation
881 | TEMPLATE begin_explicit_instantiation notype_declarator
882 { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
883 end_explicit_instantiation
884 | TEMPLATE begin_explicit_instantiation constructor_declarator
885 { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
886 end_explicit_instantiation
887 | SCSPEC TEMPLATE begin_explicit_instantiation typespec ';'
888 { do_type_instantiation ($4.t, $1);
890 end_explicit_instantiation
891 | SCSPEC TEMPLATE begin_explicit_instantiation typed_declspecs
893 { tree specs = strip_attrs ($4.t);
894 do_decl_instantiation (specs, $5, $1); }
895 end_explicit_instantiation
896 | SCSPEC TEMPLATE begin_explicit_instantiation notype_declarator
897 { do_decl_instantiation (NULL_TREE, $4, $1); }
898 end_explicit_instantiation
899 | SCSPEC TEMPLATE begin_explicit_instantiation constructor_declarator
900 { do_decl_instantiation (NULL_TREE, $4, $1); }
901 end_explicit_instantiation
904 begin_explicit_instantiation:
905 { begin_explicit_instantiation(); }
907 end_explicit_instantiation:
908 { end_explicit_instantiation(); }
910 /* The TYPENAME expansions are to deal with use of a template class name as
911 a template within the class itself, where the template decl is hidden by
912 a type decl. Got all that? */
915 PTYPENAME '<' template_arg_list_opt template_close_bracket
917 $$ = lookup_template_class ($1, $3, NULL_TREE, NULL_TREE);
918 if ($$ != error_mark_node)
919 $$ = TYPE_STUB_DECL ($$);
921 | TYPENAME '<' template_arg_list_opt template_close_bracket
923 $$ = lookup_template_class ($1, $3, NULL_TREE, NULL_TREE);
924 if ($$ != error_mark_node)
925 $$ = TYPE_STUB_DECL ($$);
931 SELFNAME '<' template_arg_list_opt template_close_bracket
933 $$ = lookup_template_class ($1, $3, NULL_TREE, NULL_TREE);
934 if ($$ != error_mark_node)
935 $$ = TYPE_STUB_DECL ($$);
939 template_close_bracket:
943 /* Handle `Class<Class<Type>>' without space in the `>>' */
944 pedwarn ("`>>' should be `> >' in template class name");
949 template_arg_list_opt:
957 { $$ = build_tree_list (NULL_TREE, $$); }
958 | template_arg_list ',' template_arg
959 { $$ = chainon ($$, build_tree_list (NULL_TREE, $3)); }
963 { processing_template_arg = 1; }
966 processing_template_arg = 0; }
970 { $$ = groktypename ($1.t); }
971 | expr_no_commas %prec ARITHCOMPARE
976 { $$ = NEGATE_EXPR; }
978 { $$ = CONVERT_EXPR; }
980 { $$ = PREINCREMENT_EXPR; }
982 { $$ = PREDECREMENT_EXPR; }
984 { $$ = TRUTH_NOT_EXPR; }
989 { $$ = build_x_compound_expr ($$); }
995 { error ("ANSI C++ forbids an empty condition for `%s'",
997 $$ = integer_zero_node; }
999 { $$ = condition_conversion ($2); }
1004 { error ("ANSI C++ forbids an empty condition for `%s'",
1006 $$ = integer_zero_node; }
1008 { $$ = condition_conversion ($2); }
1015 { $$ = condition_conversion ($$); }
1021 type_specifier_seq declarator maybeasm maybe_attribute '='
1024 for (d = getdecls (); d; d = TREE_CHAIN (d))
1025 if (TREE_CODE (d) == TYPE_DECL) {
1026 tree s = TREE_TYPE (d);
1027 if (TREE_CODE (s) == RECORD_TYPE)
1028 cp_error ("definition of class `%T' in condition", s);
1029 else if (TREE_CODE (s) == ENUMERAL_TYPE)
1030 cp_error ("definition of enum `%T' in condition", s);
1033 current_declspecs = $1.t;
1034 $<itype>5 = suspend_momentary ();
1035 $<ttype>$ = start_decl ($<ttype>2, current_declspecs, 1);
1036 cplus_decl_attributes ($<ttype>$, $4,
1037 /*prefix_attributes*/ NULL_TREE);
1041 cp_finish_decl ($<ttype>6, $7, $4, 1, LOOKUP_ONLYCONVERTING);
1042 resume_momentary ($<itype>5);
1044 if (TREE_CODE (TREE_TYPE ($$)) == ARRAY_TYPE)
1045 cp_error ("definition of array `%#D' in condition", $$);
1052 | maybe_label_decls stmts '}'
1053 | maybe_label_decls stmts error '}'
1054 | maybe_label_decls error '}'
1057 already_scoped_stmt:
1060 if (processing_template_decl)
1062 $<ttype>$ = build_min_nt (COMPOUND_STMT, NULL_TREE);
1063 COMPOUND_STMT_NO_SCOPE ($<ttype>$) = 1;
1064 add_tree ($<ttype>$);
1069 if (processing_template_decl)
1071 TREE_OPERAND ($<ttype>2, 0) = TREE_CHAIN ($<ttype>2);
1072 TREE_CHAIN ($<ttype>2) = NULL_TREE;
1073 last_tree = $<ttype>2;
1081 nontrivial_exprlist:
1082 expr_no_commas ',' expr_no_commas
1083 { $$ = expr_tree_cons (NULL_TREE, $$,
1084 build_expr_list (NULL_TREE, $3)); }
1085 | expr_no_commas ',' error
1086 { $$ = expr_tree_cons (NULL_TREE, $$,
1087 build_expr_list (NULL_TREE, error_mark_node)); }
1088 | nontrivial_exprlist ',' expr_no_commas
1089 { chainon ($$, build_expr_list (NULL_TREE, $3)); }
1090 | nontrivial_exprlist ',' error
1091 { chainon ($$, build_expr_list (NULL_TREE, error_mark_node)); }
1096 { $$ = build_expr_list (NULL_TREE, $$); }
1097 | nontrivial_exprlist
1103 /* __extension__ turns off -pedantic for following primary. */
1104 | extension cast_expr %prec UNARY
1106 pedantic = $<itype>1; }
1107 | '*' cast_expr %prec UNARY
1108 { $$ = build_x_indirect_ref ($2, "unary *"); }
1109 | '&' cast_expr %prec UNARY
1110 { $$ = build_x_unary_op (ADDR_EXPR, $2); }
1112 { $$ = build_x_unary_op (BIT_NOT_EXPR, $2); }
1113 | unop cast_expr %prec UNARY
1114 { $$ = build_x_unary_op ($1, $2);
1115 if ($1 == NEGATE_EXPR && TREE_CODE ($2) == INTEGER_CST)
1116 TREE_NEGATED_INT ($$) = 1;
1117 overflow_warning ($$);
1119 /* Refer to the address of a label as a pointer. */
1121 { tree label = lookup_label ($2);
1123 pedwarn ("ANSI C++ forbids `&&'");
1124 if (label == NULL_TREE)
1125 $$ = null_pointer_node;
1128 TREE_USED (label) = 1;
1129 $$ = build1 (ADDR_EXPR, ptr_type_node, label);
1130 TREE_CONSTANT ($$) = 1;
1133 | SIZEOF unary_expr %prec UNARY
1134 { $$ = expr_sizeof ($2); }
1135 | SIZEOF '(' type_id ')' %prec HYPERUNARY
1136 { $$ = c_sizeof (groktypename ($3.t)); }
1137 | ALIGNOF unary_expr %prec UNARY
1138 { $$ = grok_alignof ($2); }
1139 | ALIGNOF '(' type_id ')' %prec HYPERUNARY
1140 { $$ = c_alignof (groktypename ($3.t));
1141 check_for_new_type ("alignof", $3); }
1143 /* The %prec EMPTY's here are required by the = init initializer
1144 syntax extension; see below. */
1145 | new new_type_id %prec EMPTY
1146 { $$ = build_new (NULL_TREE, $2.t, NULL_TREE, $1);
1147 check_for_new_type ("new", $2); }
1148 | new new_type_id new_initializer
1149 { $$ = build_new (NULL_TREE, $2.t, $3, $1);
1150 check_for_new_type ("new", $2); }
1151 | new new_placement new_type_id %prec EMPTY
1152 { $$ = build_new ($2, $3.t, NULL_TREE, $1);
1153 check_for_new_type ("new", $3); }
1154 | new new_placement new_type_id new_initializer
1155 { $$ = build_new ($2, $3.t, $4, $1);
1156 check_for_new_type ("new", $3); }
1157 | new '(' type_id ')' %prec EMPTY
1158 { $$ = build_new (NULL_TREE, groktypename($3.t),
1160 check_for_new_type ("new", $3); }
1161 | new '(' type_id ')' new_initializer
1162 { $$ = build_new (NULL_TREE, groktypename($3.t), $5, $1);
1163 check_for_new_type ("new", $3); }
1164 | new new_placement '(' type_id ')' %prec EMPTY
1165 { $$ = build_new ($2, groktypename($4.t), NULL_TREE, $1);
1166 check_for_new_type ("new", $4); }
1167 | new new_placement '(' type_id ')' new_initializer
1168 { $$ = build_new ($2, groktypename($4.t), $6, $1);
1169 check_for_new_type ("new", $4); }
1171 | delete cast_expr %prec UNARY
1172 { $$ = delete_sanity ($2, NULL_TREE, 0, $1); }
1173 | delete '[' ']' cast_expr %prec UNARY
1174 { $$ = delete_sanity ($4, NULL_TREE, 1, $1);
1175 if (yychar == YYEMPTY)
1177 | delete '[' expr ']' cast_expr %prec UNARY
1178 { $$ = delete_sanity ($5, $3, 2, $1);
1179 if (yychar == YYEMPTY)
1181 | REALPART cast_expr %prec UNARY
1182 { $$ = build_x_unary_op (REALPART_EXPR, $2); }
1183 | IMAGPART cast_expr %prec UNARY
1184 { $$ = build_x_unary_op (IMAGPART_EXPR, $2); }
1188 '(' nonnull_exprlist ')'
1190 | '{' nonnull_exprlist '}'
1193 pedwarn ("old style placement syntax, use () instead");
1198 '(' nonnull_exprlist ')'
1204 cp_error ("`%T' is not a valid expression", $2.t);
1205 $$ = error_mark_node;
1207 /* GNU extension so people can use initializer lists. Note that
1208 this alters the meaning of `new int = 1', which was previously
1209 syntactically valid but semantically invalid. */
1213 pedwarn ("ANSI C++ forbids initialization of new expression with `='");
1218 /* This is necessary to postpone reduction of `int ((int)(int)(int))'. */
1220 '(' type_id ')' %prec EMPTY
1221 { $2.t = tree_cons (NULL_TREE, $2.t, void_list_node);
1222 TREE_PARMLIST ($2.t) = 1;
1223 $$ = make_call_declarator (NULL_TREE, $2.t, NULL_TREE, NULL_TREE);
1224 check_for_new_type ("cast", $2); }
1225 | regcast_or_absdcl '(' type_id ')' %prec EMPTY
1226 { $3.t = tree_cons (NULL_TREE, $3.t, void_list_node);
1227 TREE_PARMLIST ($3.t) = 1;
1228 $$ = make_call_declarator ($$, $3.t, NULL_TREE, NULL_TREE);
1229 check_for_new_type ("cast", $3); }
1234 | regcast_or_absdcl unary_expr %prec UNARY
1235 { $$ = reparse_absdcl_as_casts ($$, $2); }
1236 | regcast_or_absdcl '{' initlist maybecomma '}' %prec UNARY
1238 tree init = build_nt (CONSTRUCTOR, NULL_TREE,
1241 pedwarn ("ANSI C++ forbids constructor-expressions");
1242 /* Indicate that this was a GNU C constructor expression. */
1243 TREE_HAS_CONSTRUCTOR (init) = 1;
1245 $$ = reparse_absdcl_as_casts ($$, init);
1251 /* Handle general members. */
1252 | expr_no_commas POINTSAT_STAR expr_no_commas
1253 { $$ = build_x_binary_op (MEMBER_REF, $$, $3); }
1254 | expr_no_commas DOT_STAR expr_no_commas
1255 { $$ = build_m_component_ref ($$, $3); }
1256 | expr_no_commas '+' expr_no_commas
1257 { $$ = build_x_binary_op ($2, $$, $3); }
1258 | expr_no_commas '-' expr_no_commas
1259 { $$ = build_x_binary_op ($2, $$, $3); }
1260 | expr_no_commas '*' expr_no_commas
1261 { $$ = build_x_binary_op ($2, $$, $3); }
1262 | expr_no_commas '/' expr_no_commas
1263 { $$ = build_x_binary_op ($2, $$, $3); }
1264 | expr_no_commas '%' expr_no_commas
1265 { $$ = build_x_binary_op ($2, $$, $3); }
1266 | expr_no_commas LSHIFT expr_no_commas
1267 { $$ = build_x_binary_op ($2, $$, $3); }
1268 | expr_no_commas RSHIFT expr_no_commas
1269 { $$ = build_x_binary_op ($2, $$, $3); }
1270 | expr_no_commas ARITHCOMPARE expr_no_commas
1271 { $$ = build_x_binary_op ($2, $$, $3); }
1272 | expr_no_commas '<' expr_no_commas
1273 { $$ = build_x_binary_op (LT_EXPR, $$, $3); }
1274 | expr_no_commas '>' expr_no_commas
1275 { $$ = build_x_binary_op (GT_EXPR, $$, $3); }
1276 | expr_no_commas EQCOMPARE expr_no_commas
1277 { $$ = build_x_binary_op ($2, $$, $3); }
1278 | expr_no_commas MIN_MAX expr_no_commas
1279 { $$ = build_x_binary_op ($2, $$, $3); }
1280 | expr_no_commas '&' expr_no_commas
1281 { $$ = build_x_binary_op ($2, $$, $3); }
1282 | expr_no_commas '|' expr_no_commas
1283 { $$ = build_x_binary_op ($2, $$, $3); }
1284 | expr_no_commas '^' expr_no_commas
1285 { $$ = build_x_binary_op ($2, $$, $3); }
1286 | expr_no_commas ANDAND expr_no_commas
1287 { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $$, $3); }
1288 | expr_no_commas OROR expr_no_commas
1289 { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $$, $3); }
1290 | expr_no_commas '?' xexpr ':' expr_no_commas
1291 { $$ = build_x_conditional_expr ($$, $3, $5); }
1292 | expr_no_commas '=' expr_no_commas
1293 { $$ = build_x_modify_expr ($$, NOP_EXPR, $3);
1294 if ($$ != error_mark_node)
1295 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
1296 | expr_no_commas ASSIGN expr_no_commas
1297 { $$ = build_x_modify_expr ($$, $2, $3); }
1299 { $$ = build_throw (NULL_TREE); }
1300 | THROW expr_no_commas
1301 { $$ = build_throw ($2); }
1302 /* These extensions are not defined. The second arg to build_m_component_ref
1303 is old, build_m_component_ref now does an implicit
1304 build_indirect_ref (x, NULL_PTR) on the second argument.
1305 | object '&' expr_no_commas %prec UNARY
1306 { $$ = build_m_component_ref ($$, build_x_unary_op (ADDR_EXPR, $3)); }
1307 | object unop expr_no_commas %prec UNARY
1308 { $$ = build_m_component_ref ($$, build_x_unary_op ($2, $3)); }
1309 | object '(' type_id ')' expr_no_commas %prec UNARY
1310 { tree type = groktypename ($3.t);
1311 $$ = build_m_component_ref ($$, build_c_cast (type, $5)); }
1312 | object primary_no_id %prec UNARY
1313 { $$ = build_m_component_ref ($$, $2); }
1317 notype_unqualified_id:
1318 '~' see_typename identifier
1319 { $$ = build_parse_node (BIT_NOT_EXPR, $3); }
1324 | NSNAME %prec EMPTY
1328 { $$ = do_identifier ($<ttype>-1, 1); }
1331 PFUNCNAME '<' do_id template_arg_list_opt template_close_bracket
1332 { $$ = lookup_template_function ($3, $4); }
1333 | operator_name '<' do_id template_arg_list_opt template_close_bracket
1334 { $$ = lookup_template_function ($3, $4); }
1338 TEMPLATE identifier '<' template_arg_list_opt template_close_bracket
1339 { $$ = lookup_template_function ($2, $4); }
1340 | TEMPLATE PFUNCNAME '<' template_arg_list_opt template_close_bracket
1341 { $$ = lookup_template_function ($2, $4); }
1342 | TEMPLATE operator_name '<' template_arg_list_opt
1343 template_close_bracket
1344 { $$ = lookup_template_function ($2, $4); }
1348 notype_unqualified_id
1354 notype_unqualified_id
1355 | '*' expr_or_declarator %prec UNARY
1356 { $$ = build_parse_node (INDIRECT_REF, $2); }
1357 | '&' expr_or_declarator %prec UNARY
1358 { $$ = build_parse_node (ADDR_EXPR, $2); }
1359 | '(' expr_or_declarator ')'
1363 notype_template_declarator:
1364 IDENTIFIER '<' template_arg_list_opt template_close_bracket
1365 { $$ = lookup_template_function ($1, $3); }
1366 | NSNAME '<' template_arg_list template_close_bracket
1367 { $$ = lookup_template_function ($1, $3); }
1370 direct_notype_declarator:
1371 complex_direct_notype_declarator
1372 | notype_unqualified_id
1373 | notype_template_declarator
1374 | '(' expr_or_declarator ')'
1375 { $$ = finish_decl_parsing ($2); }
1379 notype_unqualified_id
1381 if (TREE_CODE ($$) == BIT_NOT_EXPR)
1382 $$ = build_x_unary_op (BIT_NOT_EXPR, TREE_OPERAND ($$, 0));
1383 else if (TREE_CODE ($$) != TEMPLATE_ID_EXPR)
1385 if (processing_template_arg)
1388 arg_looking_for_template = processing_template_arg;
1389 id = lookup_name ($$, 0);
1390 arg_looking_for_template = 0;
1392 if (!id || id == error_mark_node
1393 || (TREE_CODE (id) != TEMPLATE_DECL
1394 && TREE_CODE (id) != TEMPLATE_TEMPLATE_PARM))
1395 id = do_identifier ($$, 1);
1399 $$ = do_identifier ($$, 1);
1406 if (processing_template_decl)
1407 push_obstacks (&permanent_obstack, &permanent_obstack);
1408 $$ = combine_strings ($$);
1409 if (processing_template_decl)
1415 class = TREE_CODE_CLASS (TREE_CODE ($$));
1416 if (class == 'e' || class == '1'
1417 || class == '2' || class == '<')
1418 /* This inhibits warnings in truthvalue_conversion. */
1419 C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK); }
1420 | '(' expr_or_declarator ')'
1422 $$ = reparse_decl_as_expr (NULL_TREE, $2);
1423 class = TREE_CODE_CLASS (TREE_CODE ($$));
1424 if (class == 'e' || class == '1'
1425 || class == '2' || class == '<')
1426 /* This inhibits warnings in truthvalue_conversion. */
1427 C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK); }
1429 { $$ = error_mark_node; }
1431 { if (current_function_decl == 0)
1433 error ("braced-group within expression allowed only inside a function");
1437 $<ttype>$ = expand_start_stmt_expr (); }
1441 pedwarn ("ANSI C++ forbids braced-groups within expressions");
1442 rtl_exp = expand_end_stmt_expr ($<ttype>2);
1443 /* The statements have side effects, so the group does. */
1444 TREE_SIDE_EFFECTS (rtl_exp) = 1;
1446 if (TREE_CODE ($3) == BLOCK)
1448 /* Make a BIND_EXPR for the BLOCK already made. */
1449 $$ = build (BIND_EXPR, TREE_TYPE (rtl_exp),
1450 NULL_TREE, rtl_exp, $3);
1451 /* Remove the block from the tree at this point.
1452 It gets put back at the proper place
1453 when the BIND_EXPR is expanded. */
1459 | primary '(' nonnull_exprlist ')'
1461 $$ = build_x_function_call ($1, $3, current_class_ref);
1462 if (TREE_CODE ($$) == CALL_EXPR
1463 && TREE_TYPE ($$) != void_type_node)
1464 $$ = require_complete_type ($$);
1466 | primary LEFT_RIGHT
1468 $$ = build_x_function_call ($$, NULL_TREE, current_class_ref);
1469 if (TREE_CODE ($$) == CALL_EXPR
1470 && TREE_TYPE ($$) != void_type_node)
1471 $$ = require_complete_type ($$);
1473 | primary '[' expr ']'
1474 { $$ = grok_array_decl ($$, $3); }
1476 { /* If we get an OFFSET_REF, turn it into what it really
1477 means (e.g., a COMPONENT_REF). This way if we've got,
1478 say, a reference to a static member that's being operated
1479 on, we don't end up trying to find a member operator for
1480 the class it's in. */
1481 if (TREE_CODE ($$) == OFFSET_REF)
1482 $$ = resolve_offset_ref ($$);
1483 $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); }
1484 | primary MINUSMINUS
1485 { if (TREE_CODE ($$) == OFFSET_REF)
1486 $$ = resolve_offset_ref ($$);
1487 $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); }
1488 /* C++ extensions */
1490 { if (current_class_ptr)
1492 #ifdef WARNING_ABOUT_CCD
1493 TREE_USED (current_class_ptr) = 1;
1495 $$ = current_class_ptr;
1497 else if (current_function_decl
1498 && DECL_STATIC_FUNCTION_P (current_function_decl))
1500 error ("`this' is unavailable for static member functions");
1501 $$ = error_mark_node;
1505 if (current_function_decl)
1506 error ("invalid use of `this' in non-member function");
1508 error ("invalid use of `this' at top level");
1509 $$ = error_mark_node;
1512 | CV_QUALIFIER '(' nonnull_exprlist ')'
1514 tree type = NULL_TREE;
1517 /* This is a C cast in C++'s `functional' notation. */
1518 if ($3 == error_mark_node)
1520 $$ = error_mark_node;
1524 if ($3 == NULL_TREE)
1526 error ("cannot cast null list to type `%s'",
1527 IDENTIFIER_POINTER (TYPE_NAME (id)));
1528 $$ = error_mark_node;
1533 /* type is not set! (mrs) */
1534 if (type == error_mark_node)
1535 $$ = error_mark_node;
1539 if (id == ridpointers[(int) RID_CONST])
1540 type = build_type_variant (integer_type_node, 1, 0);
1541 else if (id == ridpointers[(int) RID_VOLATILE])
1542 type = build_type_variant (integer_type_node, 0, 1);
1544 /* should not be able to get here (mrs) */
1545 else if (id == ridpointers[(int) RID_FRIEND])
1547 error ("cannot cast expression to `friend' type");
1548 $$ = error_mark_node;
1552 else my_friendly_abort (79);
1553 $$ = build_c_cast (type, build_compound_expr ($3));
1557 | DYNAMIC_CAST '<' type_id '>' '(' expr ')'
1558 { tree type = groktypename ($3.t);
1559 check_for_new_type ("dynamic_cast", $3);
1560 $$ = build_dynamic_cast (type, $6); }
1561 | STATIC_CAST '<' type_id '>' '(' expr ')'
1562 { tree type = groktypename ($3.t);
1563 check_for_new_type ("static_cast", $3);
1564 $$ = build_static_cast (type, $6); }
1565 | REINTERPRET_CAST '<' type_id '>' '(' expr ')'
1566 { tree type = groktypename ($3.t);
1567 check_for_new_type ("reinterpret_cast", $3);
1568 $$ = build_reinterpret_cast (type, $6); }
1569 | CONST_CAST '<' type_id '>' '(' expr ')'
1570 { tree type = groktypename ($3.t);
1571 check_for_new_type ("const_cast", $3);
1572 $$ = build_const_cast (type, $6); }
1573 | TYPEID '(' expr ')'
1574 { $$ = build_x_typeid ($3); }
1575 | TYPEID '(' type_id ')'
1576 { tree type = groktypename ($3.t);
1577 check_for_new_type ("typeid", $3);
1578 $$ = get_typeid (TYPE_MAIN_VARIANT (type)); }
1579 | global_scope IDENTIFIER
1580 { $$ = do_scoped_id ($2, 1); }
1581 | global_scope operator_name
1583 got_scope = NULL_TREE;
1584 if (TREE_CODE ($2) == IDENTIFIER_NODE)
1585 $$ = do_scoped_id ($2, 1);
1589 | overqualified_id %prec HYPERUNARY
1590 { $$ = build_offset_ref (OP0 ($$), OP1 ($$)); }
1591 | overqualified_id '(' nonnull_exprlist ')'
1592 { if (processing_template_decl)
1593 $$ = build_min_nt (CALL_EXPR, copy_to_permanent ($1), $3, NULL_TREE);
1595 $$ = build_member_call (OP0 ($$), OP1 ($$), $3); }
1596 | overqualified_id LEFT_RIGHT
1597 { if (processing_template_decl)
1598 $$ = build_min_nt (CALL_EXPR, copy_to_permanent ($1),
1599 NULL_TREE, NULL_TREE);
1601 $$ = build_member_call (OP0 ($$), OP1 ($$), NULL_TREE); }
1602 | object object_template_id %prec UNARY
1604 $$ = build_x_component_ref ($$, $2, NULL_TREE, 1);
1606 | object object_template_id '(' nonnull_exprlist ')'
1608 $$ = build_method_call ($1, $2, $4,
1609 NULL_TREE, LOOKUP_NORMAL);
1611 | object object_template_id LEFT_RIGHT
1613 $$ = build_method_call ($1, $2, NULL_TREE,
1614 NULL_TREE, LOOKUP_NORMAL);
1616 | object unqualified_id %prec UNARY
1617 { $$ = build_x_component_ref ($$, $2, NULL_TREE, 1); }
1618 | object overqualified_id %prec UNARY
1619 { if (processing_template_decl)
1620 $$ = build_min_nt (COMPONENT_REF, $1, copy_to_permanent ($2));
1622 $$ = build_object_ref ($$, OP0 ($2), OP1 ($2)); }
1623 | object unqualified_id '(' nonnull_exprlist ')'
1626 /* This is a future direction of this code, but because
1627 build_x_function_call cannot always undo what is done
1628 in build_component_ref entirely yet, we cannot do this. */
1629 $$ = build_x_function_call (build_component_ref ($$, $2, NULL_TREE, 1), $4, current_class_ref);
1630 if (TREE_CODE ($$) == CALL_EXPR
1631 && TREE_TYPE ($$) != void_type_node)
1632 $$ = require_complete_type ($$);
1634 $$ = build_method_call ($$, $2, $4, NULL_TREE,
1638 | object unqualified_id LEFT_RIGHT
1641 /* This is a future direction of this code, but because
1642 build_x_function_call cannot always undo what is done
1643 in build_component_ref entirely yet, we cannot do this. */
1644 $$ = build_x_function_call (build_component_ref ($$, $2, NULL_TREE, 1), NULL_TREE, current_class_ref);
1645 if (TREE_CODE ($$) == CALL_EXPR
1646 && TREE_TYPE ($$) != void_type_node)
1647 $$ = require_complete_type ($$);
1649 $$ = build_method_call ($$, $2, NULL_TREE, NULL_TREE,
1653 | object overqualified_id '(' nonnull_exprlist ')'
1655 if (IS_SIGNATURE (OP0 ($2)))
1657 warning ("signature name in scope resolution ignored");
1658 $$ = build_method_call ($$, OP1 ($2), $4, NULL_TREE,
1662 $$ = build_scoped_method_call ($$, OP0 ($2), OP1 ($2), $4);
1664 | object overqualified_id LEFT_RIGHT
1666 if (IS_SIGNATURE (OP0 ($2)))
1668 warning ("signature name in scope resolution ignored");
1669 $$ = build_method_call ($$, OP1 ($2), NULL_TREE, NULL_TREE,
1673 $$ = build_scoped_method_call ($$, OP0 ($2), OP1 ($2), NULL_TREE);
1675 /* p->int::~int() is valid -- 12.4 */
1676 | object '~' TYPESPEC LEFT_RIGHT
1678 if (IDENTIFIER_GLOBAL_VALUE ($3)
1679 && (TREE_CODE (TREE_TYPE ($1))
1680 != TREE_CODE (TREE_TYPE (IDENTIFIER_GLOBAL_VALUE ($3)))))
1681 cp_error ("`%E' is not of type `%T'", $1, $3);
1682 $$ = cp_convert (void_type_node, $1);
1684 | object TYPESPEC SCOPE '~' TYPESPEC LEFT_RIGHT
1687 cp_error ("destructor specifier `%T::~%T()' must have matching names", $2, $5);
1688 if (TREE_CODE (TREE_TYPE ($1))
1689 != TREE_CODE (TREE_TYPE (IDENTIFIER_GLOBAL_VALUE ($2))))
1690 cp_error ("`%E' is not of type `%T'", $1, $2);
1691 $$ = cp_convert (void_type_node, $1);
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 ("ANSI C++ forbids braced-groups within expressions");
1716 $$ = expand_end_stmt_expr ($<ttype>2); }
1717 | primary_no_id '(' nonnull_exprlist ')'
1718 { $$ = build_x_function_call ($$, $3, current_class_ref); }
1719 | primary_no_id LEFT_RIGHT
1720 { $$ = build_x_function_call ($$, NULL_TREE, current_class_ref); }
1721 | primary_no_id '[' expr ']'
1723 | primary_no_id PLUSPLUS
1724 { $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); }
1725 | primary_no_id MINUSMINUS
1726 { $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); }
1728 { goto do_scoped_id; }
1729 | SCOPE operator_name
1730 { if (TREE_CODE ($2) == IDENTIFIER_NODE)
1732 goto do_scoped_operator;
1741 { got_scope = NULL_TREE; $$ = 1; }
1747 | global_scope delete
1748 { got_scope = NULL_TREE; $$ = 1; }
1753 { $$ = boolean_true_node; }
1755 { $$ = boolean_false_node; }
1758 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
1762 { $$ = chainon ($$, $2); }
1768 if (! current_function_parms_stored)
1769 store_parm_decls ();
1771 /* Always keep the BLOCK node associated with the outermost
1772 pair of curley braces of a function. These are needed
1773 for correct operation of dwarfout.c. */
1780 { got_object = TREE_TYPE ($$); }
1783 $$ = build_x_arrow ($$);
1784 got_object = TREE_TYPE ($$);
1789 typespec initdecls ';'
1791 resume_momentary ($2);
1792 if ($1.t && IS_AGGR_TYPE_CODE (TREE_CODE ($1.t)))
1793 note_got_semicolon ($1.t);
1795 | typed_declspecs initdecls ';'
1797 resume_momentary ($2);
1798 note_list_got_semicolon ($1.t);
1800 | declmods notype_initdecls ';'
1801 { resume_momentary ($2); }
1802 | typed_declspecs ';'
1805 note_list_got_semicolon ($1.t);
1808 { warning ("empty declaration"); }
1810 { pedantic = $<itype>1; }
1813 /* Any kind of declarator (thus, all declarators allowed
1814 after an explicit typespec). */
1817 after_type_declarator %prec EMPTY
1818 | notype_declarator %prec EMPTY
1821 /* This is necessary to postpone reduction of `int()()()()'. */
1823 LEFT_RIGHT %prec EMPTY
1824 { $$ = make_call_declarator (NULL_TREE, empty_parms (),
1825 NULL_TREE, NULL_TREE); }
1826 | fcast_or_absdcl LEFT_RIGHT %prec EMPTY
1827 { $$ = make_call_declarator ($$, empty_parms (), NULL_TREE,
1831 /* ANSI type-id (8.1) */
1833 typed_typespecs absdcl
1834 { $$.t = build_decl_list ($1.t, $2);
1835 $$.new_type_flag = $1.new_type_flag; }
1836 | nonempty_cv_qualifiers absdcl
1837 { $$.t = build_decl_list ($1.t, $2);
1838 $$.new_type_flag = $1.new_type_flag; }
1840 { $$.t = build_decl_list (get_decl_list ($1.t), $2);
1841 $$.new_type_flag = $1.new_type_flag; }
1842 | typed_typespecs %prec EMPTY
1843 { $$.t = build_decl_list ($1.t, NULL_TREE);
1844 $$.new_type_flag = $1.new_type_flag; }
1845 | nonempty_cv_qualifiers %prec EMPTY
1846 { $$.t = build_decl_list ($1.t, NULL_TREE);
1847 $$.new_type_flag = $1.new_type_flag; }
1850 /* Declspecs which contain at least one type specifier or typedef name.
1851 (Just `const' or `volatile' is not enough.)
1852 A typedef'd name following these is taken as a name to be declared.
1853 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1856 typed_typespecs %prec EMPTY
1862 { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1);
1863 $$.new_type_flag = $2.new_type_flag; }
1864 | typespec reserved_declspecs %prec HYPERUNARY
1865 { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2);
1866 $$.new_type_flag = $1.new_type_flag; }
1867 | typespec reserved_typespecquals reserved_declspecs
1868 { $$.t = decl_tree_cons (NULL_TREE, $1.t, chainon ($2, $3));
1869 $$.new_type_flag = $1.new_type_flag; }
1870 | declmods typespec reserved_declspecs
1871 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1));
1872 $$.new_type_flag = $2.new_type_flag; }
1873 | declmods typespec reserved_typespecquals
1874 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1));
1875 $$.new_type_flag = $2.new_type_flag; }
1876 | declmods typespec reserved_typespecquals reserved_declspecs
1877 { $$.t = decl_tree_cons (NULL_TREE, $2.t,
1878 chainon ($3, chainon ($4, $1)));
1879 $$.new_type_flag = $2.new_type_flag; }
1884 { if (extra_warnings)
1885 warning ("`%s' is not at beginning of declaration",
1886 IDENTIFIER_POINTER ($$));
1887 $$ = build_decl_list (NULL_TREE, $$); }
1888 | reserved_declspecs typespecqual_reserved
1889 { $$ = decl_tree_cons (NULL_TREE, $2.t, $$); }
1890 | reserved_declspecs SCSPEC
1891 { if (extra_warnings)
1892 warning ("`%s' is not at beginning of declaration",
1893 IDENTIFIER_POINTER ($2));
1894 $$ = decl_tree_cons (NULL_TREE, $2, $$); }
1895 | reserved_declspecs attributes
1896 { $$ = decl_tree_cons ($2, NULL_TREE, $1); }
1898 { $$ = decl_tree_cons ($1, NULL_TREE, NULL_TREE); }
1901 /* List of just storage classes and type modifiers.
1902 A declaration can start with just this, but then it cannot be used
1903 to redeclare a typedef-name.
1904 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1907 nonempty_cv_qualifiers %prec EMPTY
1908 { $$ = $1.t; TREE_STATIC ($$) = 1; }
1910 { $$ = IDENTIFIER_AS_LIST ($$); }
1911 | declmods CV_QUALIFIER
1912 { $$ = decl_tree_cons (NULL_TREE, $2, $$);
1913 TREE_STATIC ($$) = 1; }
1915 { if (extra_warnings && TREE_STATIC ($$))
1916 warning ("`%s' is not at beginning of declaration",
1917 IDENTIFIER_POINTER ($2));
1918 $$ = decl_tree_cons (NULL_TREE, $2, $$);
1919 TREE_STATIC ($$) = TREE_STATIC ($1); }
1920 | declmods attributes
1921 { $$ = decl_tree_cons ($2, NULL_TREE, $1); }
1923 { $$ = decl_tree_cons ($1, NULL_TREE, NULL_TREE); }
1926 /* Used instead of declspecs where storage classes are not allowed
1927 (that is, for typenames and structure components).
1929 C++ can takes storage classes for structure components.
1930 Don't accept a typedef-name if anything but a modifier precedes it. */
1933 typespec %prec EMPTY
1934 { $$.t = get_decl_list ($1.t);
1935 $$.new_type_flag = $1.new_type_flag; }
1936 | nonempty_cv_qualifiers typespec
1937 { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1.t);
1938 $$.new_type_flag = $2.new_type_flag; }
1939 | typespec reserved_typespecquals
1940 { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2);
1941 $$.new_type_flag = $1.new_type_flag; }
1942 | nonempty_cv_qualifiers typespec reserved_typespecquals
1943 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1944 $$.new_type_flag = $1.new_type_flag; }
1947 reserved_typespecquals:
1948 typespecqual_reserved
1949 { $$ = build_decl_list (NULL_TREE, $1.t); }
1950 | reserved_typespecquals typespecqual_reserved
1951 { $$ = decl_tree_cons (NULL_TREE, $2.t, $1); }
1954 /* A typespec (but not a type qualifier).
1955 Once we have seen one of these in a declaration,
1956 if a typedef name appears then it is being redeclared. */
1960 | TYPESPEC %prec EMPTY
1961 { $$.t = $1; $$.new_type_flag = 0; }
1962 | complete_type_name
1963 { $$.t = $1; $$.new_type_flag = 0; }
1964 | TYPEOF '(' expr ')'
1965 { $$.t = TREE_TYPE ($3);
1966 $$.new_type_flag = 0; }
1967 | TYPEOF '(' type_id ')'
1968 { $$.t = groktypename ($3.t);
1969 $$.new_type_flag = 0; }
1970 | SIGOF '(' expr ')'
1971 { tree type = TREE_TYPE ($3);
1973 $$.new_type_flag = 0;
1974 if (IS_AGGR_TYPE (type))
1976 sorry ("sigof type specifier");
1981 error ("`sigof' applied to non-aggregate expression");
1982 $$.t = error_mark_node;
1985 | SIGOF '(' type_id ')'
1986 { tree type = groktypename ($3.t);
1988 $$.new_type_flag = 0;
1989 if (IS_AGGR_TYPE (type))
1991 sorry ("sigof type specifier");
1996 error("`sigof' applied to non-aggregate type");
1997 $$.t = error_mark_node;
2002 /* A typespec that is a reserved word, or a type qualifier. */
2004 typespecqual_reserved:
2006 { $$.t = $1; $$.new_type_flag = 0; }
2008 { $$.t = $1; $$.new_type_flag = 0; }
2014 | initdecls ',' initdcl
2019 | notype_initdecls ',' initdcl
2024 | nomods_initdecls ',' initdcl
2030 | asm_keyword '(' string ')'
2031 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3); $$ = $3; }
2035 declarator maybeasm maybe_attribute '='
2036 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2037 &prefix_attributes);
2038 if (current_declspecs
2039 && TREE_CODE (current_declspecs) != TREE_LIST)
2040 current_declspecs = get_decl_list (current_declspecs);
2041 if (have_extern_spec && !used_extern_spec)
2043 current_declspecs = decl_tree_cons
2044 (NULL_TREE, get_identifier ("extern"),
2046 used_extern_spec = 1;
2048 $<itype>4 = suspend_momentary ();
2049 $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1);
2050 cplus_decl_attributes ($<ttype>$, $3, prefix_attributes); }
2052 /* Note how the declaration of the variable is in effect while its init is parsed! */
2053 { cp_finish_decl ($<ttype>5, $6, $2, 1, LOOKUP_ONLYCONVERTING);
2055 | declarator maybeasm maybe_attribute
2057 split_specs_attrs ($<ttype>0, ¤t_declspecs,
2058 &prefix_attributes);
2059 if (current_declspecs
2060 && TREE_CODE (current_declspecs) != TREE_LIST)
2061 current_declspecs = get_decl_list (current_declspecs);
2062 if (have_extern_spec && !used_extern_spec)
2064 current_declspecs = decl_tree_cons
2065 (NULL_TREE, get_identifier ("extern"),
2067 used_extern_spec = 1;
2069 $$ = suspend_momentary ();
2070 d = start_decl ($<ttype>1, current_declspecs, 0);
2071 cplus_decl_attributes (d, $3, prefix_attributes);
2072 cp_finish_decl (d, NULL_TREE, $2, 1, 0); }
2076 declarator maybeasm maybe_attribute '='
2077 { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1);
2078 cplus_decl_attributes ($<ttype>$, $3, prefix_attributes); }
2080 /* Note how the declaration of the variable is in effect while its init is parsed! */
2081 { cp_finish_decl ($<ttype>5, $6, $2, 1, LOOKUP_ONLYCONVERTING); }
2082 | declarator maybeasm maybe_attribute
2083 { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 0);
2084 cplus_decl_attributes ($<ttype>$, $3, prefix_attributes);
2085 cp_finish_decl ($<ttype>$, NULL_TREE, $2, 1, 0); }
2089 notype_declarator maybeasm maybe_attribute '='
2090 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2091 &prefix_attributes);
2092 $<itype>4 = suspend_momentary ();
2093 $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1);
2094 cplus_decl_attributes ($<ttype>$, $3, prefix_attributes); }
2096 /* Note how the declaration of the variable is in effect while its init is parsed! */
2097 { cp_finish_decl ($<ttype>5, $6, $2, 1, LOOKUP_ONLYCONVERTING);
2099 | notype_declarator maybeasm maybe_attribute
2101 split_specs_attrs ($<ttype>0, ¤t_declspecs,
2102 &prefix_attributes);
2103 $$ = suspend_momentary ();
2104 d = start_decl ($<ttype>1, current_declspecs, 0);
2105 cplus_decl_attributes (d, $3, prefix_attributes);
2106 cp_finish_decl (d, NULL_TREE, $2, 1, 0); }
2110 notype_declarator maybeasm maybe_attribute '='
2111 { current_declspecs = NULL_TREE;
2112 prefix_attributes = NULL_TREE;
2113 $<itype>4 = suspend_momentary ();
2114 $<ttype>$ = start_decl ($1, current_declspecs, 1);
2115 cplus_decl_attributes ($<ttype>$, $3, prefix_attributes); }
2117 /* Note how the declaration of the variable is in effect while its init is parsed! */
2118 { cp_finish_decl ($<ttype>5, $6, $2, 1, LOOKUP_ONLYCONVERTING);
2120 | notype_declarator maybeasm maybe_attribute
2122 current_declspecs = NULL_TREE;
2123 prefix_attributes = NULL_TREE;
2124 $$ = suspend_momentary ();
2125 d = start_decl ($1, current_declspecs, 0);
2126 cplus_decl_attributes (d, $3, prefix_attributes);
2127 cp_finish_decl (d, NULL_TREE, $2, 1, 0); }
2130 /* the * rules are dummies to accept the Apollo extended syntax
2131 so that the header files compile. */
2142 | attributes attribute
2143 { $$ = chainon ($1, $2); }
2147 ATTRIBUTE '(' '(' attribute_list ')' ')'
2154 | attribute_list ',' attrib
2155 { $$ = chainon ($1, $3); }
2162 { $$ = build_tree_list ($1, NULL_TREE); }
2163 | any_word '(' IDENTIFIER ')'
2164 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
2165 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
2166 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
2167 | any_word '(' nonnull_exprlist ')'
2168 { $$ = build_tree_list ($1, $3); }
2171 /* This still leaves out most reserved keywords,
2172 shouldn't we include them? */
2181 /* A nonempty list of identifiers, including typenames. */
2182 identifiers_or_typenames:
2184 { $$ = build_tree_list (NULL_TREE, $1); }
2185 | identifiers_or_typenames ',' identifier
2186 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2190 /* empty */ %prec EMPTY
2195 /* If we are processing a template, we don't want to expand this
2199 expr_no_commas %prec '='
2201 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, NULL_TREE);
2202 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2204 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2205 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2206 | '{' initlist ',' '}'
2207 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2208 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2213 /* This chain is built in reverse order,
2214 and put in forward order where initlist is used. */
2217 { $$ = build_tree_list (NULL_TREE, $$); }
2219 { $$ = expr_tree_cons (NULL_TREE, $3, $$); }
2220 /* These are for labeled elements. */
2221 | '[' expr_no_commas ']' init
2222 { $$ = build_expr_list ($2, $4); }
2223 | initlist ',' CASE expr_no_commas ':' init
2224 { $$ = expr_tree_cons ($4, $6, $$); }
2225 | identifier ':' init
2226 { $$ = build_expr_list ($$, $3); }
2227 | initlist ',' identifier ':' init
2228 { $$ = expr_tree_cons ($3, $5, $$); }
2232 PRE_PARSED_FUNCTION_DECL
2233 { start_function (NULL_TREE, TREE_VALUE ($1),
2235 reinit_parse_for_function (); }
2238 fn.defpen maybe_return_init ctor_initializer_opt compstmt_or_error
2240 int nested = (hack_decl_function_context
2241 (current_function_decl) != NULL_TREE);
2242 finish_function (lineno, (int)$3, nested);
2243 process_next_inline ($1);
2245 | fn.defpen maybe_return_init function_try_block
2246 { process_next_inline ($1); }
2247 | fn.defpen maybe_return_init error
2248 { process_next_inline ($1); }
2253 | pending_inlines pending_inline eat_saved_input
2256 /* A regurgitated default argument. The value of DEFARG_MARKER will be
2257 the TREE_LIST node for the parameter in question. */
2259 DEFARG_MARKER expr_no_commas END_OF_SAVED_INPUT
2260 { replace_defarg ($1, $2); }
2261 | DEFARG_MARKER error END_OF_SAVED_INPUT
2262 { replace_defarg ($1, error_mark_node); }
2265 /* empty */ %prec EMPTY
2266 | pending_defargs defarg_again
2267 { do_pending_defargs (); }
2268 | pending_defargs error
2269 { do_pending_defargs (); }
2274 { $<itype>3 = suspend_momentary ();
2275 $<ttype>$ = start_enum ($2); }
2276 enumlist maybecomma_warn '}'
2277 { $$.t = finish_enum ($<ttype>4, $5);
2278 $$.new_type_flag = 1;
2279 resume_momentary ((int) $<itype>3);
2280 check_for_missing_semicolon ($<ttype>4); }
2281 | ENUM identifier '{' '}'
2282 { $$.t = finish_enum (start_enum ($2), NULL_TREE);
2283 $$.new_type_flag = 1;
2284 check_for_missing_semicolon ($$.t); }
2286 { $<itype>2 = suspend_momentary ();
2287 $<ttype>$ = start_enum (make_anon_name ()); }
2288 enumlist maybecomma_warn '}'
2289 { $$.t = finish_enum ($<ttype>3, $4);
2290 resume_momentary ((int) $<itype>1);
2291 check_for_missing_semicolon ($<ttype>3);
2292 $$.new_type_flag = 1; }
2294 { $$.t = finish_enum (start_enum (make_anon_name()), NULL_TREE);
2295 $$.new_type_flag = 1;
2296 check_for_missing_semicolon ($$.t); }
2298 { $$.t = xref_tag (enum_type_node, $2, NULL_TREE, 1);
2299 $$.new_type_flag = 0; }
2300 | ENUM complex_type_name
2301 { $$.t = xref_tag (enum_type_node, $2, NULL_TREE, 1);
2302 $$.new_type_flag = 0; }
2303 | TYPENAME_KEYWORD typename_sub
2305 $$.new_type_flag = 0; }
2306 /* C++ extensions, merged with C to avoid shift/reduce conflicts */
2307 | class_head left_curly
2308 opt.component_decl_list '}' maybe_attribute
2314 /* Need to rework class nesting in the
2315 presence of nested classes, etc. */
2316 shadow_tag (CLASSTYPE_AS_LIST ($1)); */
2318 if (yychar == YYEMPTY)
2320 semi = yychar == ';';
2321 /* finish_struct nukes this anyway; if
2322 finish_exception does too, then it can go. */
2324 note_got_semicolon ($1);
2326 if (TREE_CODE ($1) == ENUMERAL_TYPE)
2330 $<ttype>$ = finish_struct ($1, $3, $5, semi);
2331 if (semi) note_got_semicolon ($<ttype>$);
2337 check_for_missing_semicolon ($1);
2338 if (current_scope () == current_function_decl)
2339 do_pending_defargs ();
2344 && current_scope () == current_function_decl)
2345 do_pending_inlines ();
2350 $$.new_type_flag = 1;
2351 if (current_class_type == NULL_TREE)
2352 clear_inline_text_obstack ();
2354 /* Undo the begin_tree in left_curly. */
2357 | class_head %prec EMPTY
2359 $$.new_type_flag = 0;
2360 if (TYPE_BINFO ($1) == NULL_TREE)
2362 cp_error ("%T is not a class type", $1);
2363 $$.t = error_mark_node;
2368 /* struct B: public A; is not accepted by the WP grammar. */
2369 if (TYPE_BINFO_BASETYPES ($$.t) && !TYPE_SIZE ($$.t)
2370 && ! TYPE_BEING_DEFINED ($$.t))
2371 cp_error ("base clause without member specification for `%#T'",
2385 { if (pedantic && !in_system_header)
2386 pedwarn ("comma at end of enumerator list"); }
2392 { error ("storage class specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2394 { error ("type specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2396 { error ("type qualifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2398 { error ("no body nor ';' separates two class, struct or union declarations"); }
2401 named_class_head_sans_basetype:
2403 { current_aggr = $$; $$ = $2; }
2406 named_class_head_sans_basetype_defn:
2407 aggr identifier_defn %prec EMPTY
2408 { current_aggr = $$; $$ = $2; }
2411 named_complex_class_head_sans_basetype:
2412 aggr nested_name_specifier identifier
2415 $$ = handle_class_head ($1, $2, $3);
2417 | aggr global_scope nested_name_specifier identifier
2420 $$ = handle_class_head ($1, $3, $4);
2422 | aggr global_scope identifier
2425 $$ = handle_class_head ($1, NULL_TREE, $3);
2427 | aggr template_type
2428 { current_aggr = $$; $$ = $2; }
2429 | aggr nested_name_specifier template_type
2430 { current_aggr = $$; $$ = $3; }
2434 /* empty */ %prec EMPTY
2435 { $<ttype>$ = xref_tag (current_aggr, $<ttype>0, NULL_TREE, 0); }
2439 named_class_head_sans_basetype %prec EMPTY
2440 { $$ = xref_tag (current_aggr, $1, NULL_TREE, 1); }
2441 | named_class_head_sans_basetype_defn do_xref_defn
2442 maybe_base_class_list %prec EMPTY
2446 xref_basetypes (current_aggr, $1, $<ttype>2, $3);
2448 | named_complex_class_head_sans_basetype maybe_base_class_list
2450 $$ = TREE_TYPE ($1);
2451 if (TREE_INT_CST_LOW (current_aggr) == union_type
2452 && TREE_CODE ($$) != UNION_TYPE)
2453 cp_pedwarn ("`union' tag used in declaring `%#T'", $$);
2454 else if (TREE_CODE ($$) == UNION_TYPE
2455 && TREE_INT_CST_LOW (current_aggr) != union_type)
2456 cp_pedwarn ("non-`union' tag used in declaring `%#T'", $$);
2459 if (IS_AGGR_TYPE ($$) && CLASSTYPE_USE_TEMPLATE ($$))
2461 if (CLASSTYPE_IMPLICIT_INSTANTIATION ($$)
2462 && TYPE_SIZE ($$) == NULL_TREE)
2464 SET_CLASSTYPE_TEMPLATE_SPECIALIZATION ($$);
2465 if (processing_template_decl)
2466 push_template_decl (TYPE_MAIN_DECL ($$));
2468 else if (CLASSTYPE_TEMPLATE_INSTANTIATION ($$))
2469 cp_error ("specialization after instantiation of `%T'", $$);
2471 xref_basetypes (current_aggr, $1, $$, $2);
2478 { $$ = xref_tag ($$, make_anon_name (), NULL_TREE, 0);
2479 yyungetc ('{', 1); }
2487 maybe_base_class_list:
2488 /* empty */ %prec EMPTY
2490 | ':' see_typename %prec EMPTY
2491 { yyungetc(':', 1); $$ = NULL_TREE; }
2492 | ':' see_typename base_class_list %prec EMPTY
2498 | base_class_list ',' see_typename base_class
2499 { $$ = chainon ($$, $4); }
2505 tree type = TREE_TYPE ($1);
2506 if (! is_aggr_type (type, 1))
2508 else if (current_aggr == signature_type_node
2509 && (! type) && (! IS_SIGNATURE (type)))
2511 error ("class name not allowed as base signature");
2514 else if (current_aggr == signature_type_node)
2516 sorry ("signature inheritance, base type `%s' ignored",
2517 IDENTIFIER_POINTER ($$));
2518 $$ = build_tree_list (access_public_node, type);
2520 else if (type && IS_SIGNATURE (type))
2522 error ("signature name not allowed as base class");
2526 $$ = build_tree_list (access_default_node, type);
2528 | base_class_access_list see_typename base_class.1
2530 tree type = TREE_TYPE ($3);
2531 if (current_aggr == signature_type_node)
2532 error ("access and source specifiers not allowed in signature");
2533 if (! IS_AGGR_TYPE (type))
2535 else if (current_aggr == signature_type_node
2536 && (! type) && (! IS_SIGNATURE (type)))
2538 error ("class name not allowed as base signature");
2541 else if (current_aggr == signature_type_node)
2543 sorry ("signature inheritance, base type `%s' ignored",
2544 IDENTIFIER_POINTER ($$));
2545 $$ = build_tree_list (access_public_node, type);
2547 else if (type && IS_SIGNATURE (type))
2549 error ("signature name not allowed as base class");
2553 $$ = build_tree_list ($$, type);
2559 { $$ = TYPE_MAIN_DECL ($1); }
2561 | SIGOF '(' expr ')'
2563 if (current_aggr == signature_type_node)
2565 if (IS_AGGR_TYPE (TREE_TYPE ($3)))
2567 sorry ("`sigof' as base signature specifier");
2568 $$ = TREE_TYPE ($3);
2572 error ("`sigof' applied to non-aggregate expression");
2573 $$ = error_mark_node;
2578 error ("`sigof' in struct or class declaration");
2579 $$ = error_mark_node;
2582 | SIGOF '(' type_id ')'
2584 if (current_aggr == signature_type_node)
2586 if (IS_AGGR_TYPE (groktypename ($3.t)))
2588 sorry ("`sigof' as base signature specifier");
2589 $$ = groktypename ($3.t);
2593 error ("`sigof' applied to non-aggregate expression");
2594 $$ = error_mark_node;
2599 error ("`sigof' in struct or class declaration");
2600 $$ = error_mark_node;
2605 base_class_access_list:
2606 VISSPEC see_typename
2607 | SCSPEC see_typename
2608 { if ($<ttype>$ != ridpointers[(int)RID_VIRTUAL])
2609 sorry ("non-virtual access");
2610 $$ = access_default_virtual_node; }
2611 | base_class_access_list VISSPEC see_typename
2613 if ($2 == access_protected_node)
2615 warning ("`protected' access not implemented");
2616 $2 = access_public_node;
2619 else if ($2 == access_public_node)
2621 if ($1 == access_private_node)
2624 error ("base class cannot be public and private");
2626 else if ($1 == access_default_virtual_node)
2627 $$ = access_public_virtual_node;
2629 else /* $2 == access_private_node */
2631 if ($1 == access_public_node)
2633 else if ($1 == access_default_virtual_node)
2634 $$ = access_private_virtual_node;
2637 | base_class_access_list SCSPEC see_typename
2638 { if ($2 != ridpointers[(int)RID_VIRTUAL])
2639 sorry ("non-virtual access");
2640 if ($$ == access_public_node)
2641 $$ = access_public_virtual_node;
2642 else if ($$ == access_private_node)
2643 $$ = access_private_virtual_node; }
2648 { tree t = $<ttype>0;
2649 push_obstacks_nochange ();
2650 end_temporary_allocation ();
2652 if (t == error_mark_node
2653 || ! IS_AGGR_TYPE (t))
2655 t = $<ttype>0 = make_lang_type (RECORD_TYPE);
2656 pushtag (make_anon_name (), t, 0);
2659 duplicate_tag_error (t);
2660 if (TYPE_SIZE (t) || TYPE_BEING_DEFINED (t))
2662 t = make_lang_type (TREE_CODE (t));
2663 pushtag (TYPE_IDENTIFIER ($<ttype>0), t, 0);
2666 if (processing_template_decl && TYPE_CONTEXT (t)
2667 && ! current_class_type)
2668 push_template_decl (TYPE_STUB_DECL (t));
2670 TYPE_BEING_DEFINED (t) = 1;
2671 if (IS_AGGR_TYPE (t) && CLASSTYPE_USE_TEMPLATE (t))
2673 if (CLASSTYPE_IMPLICIT_INSTANTIATION (t)
2674 && TYPE_SIZE (t) == NULL_TREE)
2676 SET_CLASSTYPE_TEMPLATE_SPECIALIZATION (t);
2677 if (processing_template_decl)
2678 push_template_decl (TYPE_MAIN_DECL (t));
2680 else if (CLASSTYPE_TEMPLATE_INSTANTIATION (t))
2681 cp_error ("specialization after instantiation of `%T'", t);
2683 /* Reset the interface data, at the earliest possible
2684 moment, as it might have been set via a class foo;
2686 /* Don't change signatures. */
2687 if (! IS_SIGNATURE (t))
2689 extern tree pending_vtables;
2691 tree name = TYPE_IDENTIFIER (t);
2693 if (! ANON_AGGRNAME_P (name))
2695 CLASSTYPE_INTERFACE_ONLY (t) = interface_only;
2696 SET_CLASSTYPE_INTERFACE_UNKNOWN_X
2697 (t, interface_unknown);
2700 /* Record how to set the access of this class's
2701 virtual functions. If write_virtuals == 2 or 3, then
2702 inline virtuals are ``extern inline''. */
2703 switch (write_virtuals)
2710 needs_writing = !! value_member (name, pending_vtables);
2713 needs_writing = ! CLASSTYPE_INTERFACE_ONLY (t)
2714 && CLASSTYPE_INTERFACE_KNOWN (t);
2719 CLASSTYPE_VTABLE_NEEDS_WRITING (t) = needs_writing;
2722 t = TYPE_IDENTIFIER ($<ttype>0);
2723 if (t && IDENTIFIER_TEMPLATE (t))
2724 overload_template_name (t, 1);
2726 reset_specialization();
2728 /* In case this is a local class within a template
2729 function, we save the current tree structure so
2730 that we can get it back later. */
2738 $$ = build_self_reference ();
2742 opt.component_decl_list:
2744 { if ($$) $$ = build_tree_list (access_public_node, $$); }
2745 | self_reference component_decl_list
2747 if (current_aggr == signature_type_node)
2748 $$ = build_tree_list (access_public_node, $2);
2750 $$ = build_tree_list (access_default_node, $2);
2751 if ($1) $$ = tree_cons (access_public_node, $1, $$);
2753 | opt.component_decl_list VISSPEC ':' component_decl_list
2757 if (current_aggr == signature_type_node)
2759 error ("access specifier not allowed in signature");
2760 visspec = access_public_node;
2762 $$ = chainon ($$, build_tree_list (visspec, $4));
2764 | opt.component_decl_list VISSPEC ':'
2766 if (current_aggr == signature_type_node)
2767 error ("access specifier not allowed in signature");
2771 /* Note: we no longer warn about the semicolon after a component_decl_list.
2772 ARM $9.2 says that the semicolon is optional, and therefore allowed. */
2773 component_decl_list:
2775 { if ($$ == void_type_node) $$ = NULL_TREE;
2777 | component_decl_list component_decl
2778 { /* In pushdecl, we created a reverse list of names
2779 in this binding level. Make sure that the chain
2780 of what we're trying to add isn't the item itself
2781 (which can happen with what pushdecl's doing). */
2782 if ($2 != NULL_TREE && $2 != void_type_node)
2784 if (TREE_CHAIN ($2) != $$)
2785 $$ = chainon ($$, $2);
2793 component_decl_1 ';'
2795 | component_decl_1 '}'
2796 { error ("missing ';' before right brace");
2797 yyungetc ('}', 0); }
2798 /* C++: handle constructors, destructors and inline functions */
2799 /* note that INLINE is like a TYPESPEC */
2800 | fn.def2 ':' /* base_init compstmt */
2801 { $$ = finish_method ($$); }
2802 | fn.def2 TRY /* base_init compstmt */
2803 { $$ = finish_method ($$); }
2804 | fn.def2 RETURN /* base_init compstmt */
2805 { $$ = finish_method ($$); }
2806 | fn.def2 '{' /* nodecls compstmt */
2807 { $$ = finish_method ($$); }
2810 | extension component_decl
2812 pedantic = $<itype>1; }
2816 /* Do not add a "typed_declspecs declarator" rule here for
2817 speed; we need to call grok_x_components for enums, so the
2818 speedup would be insignificant. */
2819 typed_declspecs components
2820 { $$ = grok_x_components ($1.t, $2); }
2821 | declmods notype_components
2822 { $$ = grok_x_components ($1, $2); }
2823 | notype_declarator maybeasm maybe_attribute maybe_init
2824 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2825 build_tree_list ($3, NULL_TREE)); }
2826 | constructor_declarator maybeasm maybe_attribute maybe_init
2827 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2828 build_tree_list ($3, NULL_TREE)); }
2829 | ':' expr_no_commas
2830 { $$ = grokbitfield (NULL_TREE, NULL_TREE, $2); }
2834 /* These rules introduce a reduce/reduce conflict; in
2835 typedef int foo, bar;
2839 should "A::foo" be declared as a function or "A::bar" as a data
2840 member? In other words, is "bar" an after_type_declarator or a
2842 | declmods component_constructor_declarator maybeasm maybe_attribute maybe_init
2843 { tree specs, attrs;
2844 split_specs_attrs ($1, &specs, &attrs);
2845 $$ = grokfield ($2, specs, $5, $3,
2846 build_tree_list ($4, attrs)); }
2847 | component_constructor_declarator maybeasm maybe_attribute maybe_init
2848 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2849 build_tree_list ($3, NULL_TREE)); }
2851 { $$ = do_class_using_decl ($1); }
2852 | template_header component_decl_1
2853 { $$ = finish_member_template_decl ($1, $2); }
2855 /* The case of exactly one component is handled directly by component_decl. */
2858 /* empty: possibly anonymous */
2860 | component_declarator0
2861 | components ',' component_declarator
2863 /* In this context, void_type_node encodes
2864 friends. They have been recorded elsewhere. */
2865 if ($$ == void_type_node)
2868 $$ = chainon ($$, $3);
2873 /* empty: possibly anonymous */
2875 | notype_component_declarator0
2876 | notype_components ',' notype_component_declarator
2878 /* In this context, void_type_node encodes
2879 friends. They have been recorded elsewhere. */
2880 if ($$ == void_type_node)
2883 $$ = chainon ($$, $3);
2887 component_declarator0:
2888 after_type_component_declarator0
2889 | notype_component_declarator0
2892 component_declarator:
2893 after_type_component_declarator
2894 | notype_component_declarator
2897 after_type_component_declarator0:
2898 after_type_declarator maybeasm maybe_attribute maybe_init
2899 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2900 &prefix_attributes);
2901 $<ttype>0 = current_declspecs;
2902 $$ = grokfield ($$, current_declspecs, $4, $2,
2903 build_tree_list ($3, prefix_attributes)); }
2904 | TYPENAME ':' expr_no_commas maybe_attribute
2905 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2906 &prefix_attributes);
2907 $<ttype>0 = current_declspecs;
2908 $$ = grokbitfield ($$, current_declspecs, $3);
2909 cplus_decl_attributes ($$, $4, prefix_attributes); }
2912 notype_component_declarator0:
2913 notype_declarator maybeasm maybe_attribute maybe_init
2914 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2915 &prefix_attributes);
2916 $<ttype>0 = current_declspecs;
2917 $$ = grokfield ($$, current_declspecs, $4, $2,
2918 build_tree_list ($3, prefix_attributes)); }
2919 | constructor_declarator maybeasm maybe_attribute maybe_init
2920 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2921 &prefix_attributes);
2922 $<ttype>0 = current_declspecs;
2923 $$ = grokfield ($$, current_declspecs, $4, $2,
2924 build_tree_list ($3, prefix_attributes)); }
2925 | IDENTIFIER ':' expr_no_commas maybe_attribute
2926 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2927 &prefix_attributes);
2928 $<ttype>0 = current_declspecs;
2929 $$ = grokbitfield ($$, current_declspecs, $3);
2930 cplus_decl_attributes ($$, $4, prefix_attributes); }
2931 | ':' expr_no_commas maybe_attribute
2932 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2933 &prefix_attributes);
2934 $<ttype>0 = current_declspecs;
2935 $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
2936 cplus_decl_attributes ($$, $3, prefix_attributes); }
2939 after_type_component_declarator:
2940 after_type_declarator maybeasm maybe_attribute maybe_init
2941 { $$ = grokfield ($$, current_declspecs, $4, $2,
2942 build_tree_list ($3, prefix_attributes)); }
2943 | TYPENAME ':' expr_no_commas maybe_attribute
2944 { $$ = grokbitfield ($$, current_declspecs, $3);
2945 cplus_decl_attributes ($$, $4, prefix_attributes); }
2948 notype_component_declarator:
2949 notype_declarator maybeasm maybe_attribute maybe_init
2950 { $$ = grokfield ($$, current_declspecs, $4, $2,
2951 build_tree_list ($3, prefix_attributes)); }
2952 | IDENTIFIER ':' expr_no_commas maybe_attribute
2953 { $$ = grokbitfield ($$, current_declspecs, $3);
2954 cplus_decl_attributes ($$, $4, prefix_attributes); }
2955 | ':' expr_no_commas maybe_attribute
2956 { $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
2957 cplus_decl_attributes ($$, $3, prefix_attributes); }
2960 /* We chain the enumerators in reverse order.
2961 Because of the way enums are built, the order is
2962 insignificant. Take advantage of this fact. */
2966 | enumlist ',' enumerator
2967 { TREE_CHAIN ($3) = $$; $$ = $3; }
2972 { $$ = build_enumerator ($$, NULL_TREE); }
2973 | identifier '=' expr_no_commas
2974 { $$ = build_enumerator ($$, $3); }
2977 /* ANSI new-type-id (5.3.4) */
2979 type_specifier_seq new_declarator
2980 { $$.t = build_decl_list ($1.t, $2);
2981 $$.new_type_flag = $1.new_type_flag; }
2982 | type_specifier_seq %prec EMPTY
2983 { $$.t = build_decl_list ($1.t, NULL_TREE);
2984 $$.new_type_flag = $1.new_type_flag; }
2985 /* GNU extension to allow arrays of arbitrary types with
2986 non-constant dimension. */
2987 | '(' type_id ')' '[' expr ']'
2990 pedwarn ("ANSI C++ forbids array dimensions with parenthesized type in new");
2991 $$.t = build_parse_node (ARRAY_REF, TREE_VALUE ($2.t), $5);
2992 $$.t = build_decl_list (TREE_PURPOSE ($2.t), $$.t);
2993 $$.new_type_flag = $2.new_type_flag;
2998 /* empty */ %prec EMPTY
3000 | cv_qualifiers CV_QUALIFIER
3001 { $$ = decl_tree_cons (NULL_TREE, $2, $$); }
3004 nonempty_cv_qualifiers:
3006 { $$.t = IDENTIFIER_AS_LIST ($1);
3007 $$.new_type_flag = 0; }
3008 | nonempty_cv_qualifiers CV_QUALIFIER
3009 { $$.t = decl_tree_cons (NULL_TREE, $2, $1.t);
3010 $$.new_type_flag = $1.new_type_flag; }
3013 /* These rules must follow the rules for function declarations
3014 and component declarations. That way, longer rules are preferred. */
3018 { $<itype>$ = suspend_momentary (); }
3020 /* An expression which will not live on the momentary obstack. */
3023 { resume_momentary ((int) $<itype>1); $$ = $2; }
3026 /* An expression which will not live on the momentary obstack. */
3028 suspend_mom '(' nonnull_exprlist ')'
3029 { resume_momentary ((int) $<itype>1); $$ = $3; }
3030 | suspend_mom '(' parmlist ')'
3031 { resume_momentary ((int) $<itype>1); $$ = $3; }
3032 | suspend_mom LEFT_RIGHT
3033 { resume_momentary ((int) $<itype>1); $$ = empty_parms (); }
3034 | suspend_mom '(' error ')'
3035 { resume_momentary ((int) $<itype>1); $$ = NULL_TREE; }
3038 /* A declarator that is allowed only after an explicit typespec. */
3039 /* may all be followed by prec '.' */
3040 after_type_declarator:
3041 '*' nonempty_cv_qualifiers after_type_declarator %prec UNARY
3042 { $$ = make_pointer_declarator ($2.t, $3); }
3043 | '&' nonempty_cv_qualifiers after_type_declarator %prec UNARY
3044 { $$ = make_reference_declarator ($2.t, $3); }
3045 | '*' after_type_declarator %prec UNARY
3046 { $$ = make_pointer_declarator (NULL_TREE, $2); }
3047 | '&' after_type_declarator %prec UNARY
3048 { $$ = make_reference_declarator (NULL_TREE, $2); }
3049 | ptr_to_mem cv_qualifiers after_type_declarator
3050 { tree arg = make_pointer_declarator ($2, $3);
3051 $$ = build_parse_node (SCOPE_REF, $1, arg);
3053 | direct_after_type_declarator
3057 type_name %prec EMPTY
3059 if (TREE_CODE ($1) == IDENTIFIER_NODE)
3061 arg_looking_for_template = processing_template_arg;
3062 $$ = lookup_name ($1, 1);
3063 arg_looking_for_template = 0;
3065 if (current_class_type
3066 && TYPE_BEING_DEFINED (current_class_type)
3067 && ! IDENTIFIER_CLASS_VALUE ($1))
3069 /* Remember that this name has been used in the class
3070 definition, as per [class.scope0] */
3071 pushdecl_class_level ($$);
3077 | global_scope type_name
3079 if (TREE_CODE ($2) == IDENTIFIER_NODE)
3080 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
3083 got_scope = NULL_TREE;
3090 | global_scope nested_type
3095 nested_name_specifier type_name %prec EMPTY
3096 { $$ = get_type_decl ($2); }
3099 direct_after_type_declarator:
3100 direct_after_type_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
3101 { $$ = make_call_declarator ($$, $2, $3, $4); }
3102 | direct_after_type_declarator '[' nonmomentary_expr ']'
3103 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3104 | direct_after_type_declarator '[' ']'
3105 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
3106 | '(' after_type_declarator ')'
3108 | nested_name_specifier type_name %prec EMPTY
3109 { push_nested_class ($1, 3);
3110 $$ = build_parse_node (SCOPE_REF, $$, $2);
3111 TREE_COMPLEXITY ($$) = current_class_depth; }
3112 | type_name %prec EMPTY
3115 /* A declarator allowed whether or not there has been
3116 an explicit typespec. These cannot redeclare a typedef-name. */
3119 '*' nonempty_cv_qualifiers notype_declarator %prec UNARY
3120 { $$ = make_pointer_declarator ($2.t, $3); }
3121 | '&' nonempty_cv_qualifiers notype_declarator %prec UNARY
3122 { $$ = make_reference_declarator ($2.t, $3); }
3123 | '*' notype_declarator %prec UNARY
3124 { $$ = make_pointer_declarator (NULL_TREE, $2); }
3125 | '&' notype_declarator %prec UNARY
3126 { $$ = make_reference_declarator (NULL_TREE, $2); }
3127 | ptr_to_mem cv_qualifiers notype_declarator
3128 { tree arg = make_pointer_declarator ($2, $3);
3129 $$ = build_parse_node (SCOPE_REF, $1, arg);
3131 | direct_notype_declarator
3134 complex_notype_declarator:
3135 '*' nonempty_cv_qualifiers notype_declarator %prec UNARY
3136 { $$ = make_pointer_declarator ($2.t, $3); }
3137 | '&' nonempty_cv_qualifiers notype_declarator %prec UNARY
3138 { $$ = make_reference_declarator ($2.t, $3); }
3139 | '*' complex_notype_declarator %prec UNARY
3140 { $$ = make_pointer_declarator (NULL_TREE, $2); }
3141 | '&' complex_notype_declarator %prec UNARY
3142 { $$ = make_reference_declarator (NULL_TREE, $2); }
3143 | ptr_to_mem cv_qualifiers notype_declarator
3144 { tree arg = make_pointer_declarator ($2, $3);
3145 $$ = build_parse_node (SCOPE_REF, $1, arg);
3147 | complex_direct_notype_declarator
3150 complex_direct_notype_declarator:
3151 direct_notype_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
3152 { $$ = make_call_declarator ($$, $2, $3, $4); }
3153 | '(' complex_notype_declarator ')'
3155 | direct_notype_declarator '[' nonmomentary_expr ']'
3156 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3157 | direct_notype_declarator '[' ']'
3158 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
3159 | notype_qualified_id
3160 { if (OP0 ($$) != current_class_type)
3162 push_nested_class (OP0 ($$), 3);
3163 TREE_COMPLEXITY ($$) = current_class_depth;
3166 | nested_name_specifier notype_template_declarator
3167 { got_scope = NULL_TREE;
3168 $$ = build_parse_node (SCOPE_REF, $1, $2);
3169 if ($1 != current_class_type)
3171 push_nested_class ($1, 3);
3172 TREE_COMPLEXITY ($$) = current_class_depth;
3178 nested_name_specifier unqualified_id
3179 { got_scope = NULL_TREE;
3180 $$ = build_parse_node (SCOPE_REF, $$, $2); }
3181 | nested_name_specifier object_template_id
3182 { got_scope = NULL_TREE;
3183 $$ = build_parse_node (SCOPE_REF, $1, $2); }
3186 notype_qualified_id:
3187 nested_name_specifier notype_unqualified_id
3188 { got_scope = NULL_TREE;
3189 $$ = build_parse_node (SCOPE_REF, $$, $2); }
3190 | nested_name_specifier object_template_id
3191 { got_scope = NULL_TREE;
3192 $$ = build_parse_node (SCOPE_REF, $1, $2); }
3197 | global_scope notype_qualified_id
3202 typespec '(' nonnull_exprlist ')'
3203 { $$ = build_functional_cast ($1.t, $3); }
3204 | typespec '(' expr_or_declarator ')'
3205 { $$ = reparse_decl_as_expr ($1.t, $3); }
3206 | typespec fcast_or_absdcl %prec EMPTY
3207 { $$ = reparse_absdcl_as_expr ($1.t, $2); }
3213 | template_type %prec EMPTY
3216 nested_name_specifier:
3217 nested_name_specifier_1
3218 | nested_name_specifier nested_name_specifier_1
3222 /* Why the @#$%^& do type_name and notype_identifier need to be expanded
3223 inline here?!? (jason) */
3224 nested_name_specifier_1:
3227 if (TREE_CODE ($1) == IDENTIFIER_NODE)
3230 /* Remember that this name has been used in the class
3231 definition, as per [class.scope0] */
3232 if (current_class_type
3233 && TYPE_BEING_DEFINED (current_class_type)
3234 && ! IDENTIFIER_CLASS_VALUE ($1))
3235 pushdecl_class_level ($$);
3237 got_scope = $$ = TREE_TYPE ($$);
3241 if (TREE_CODE ($1) == IDENTIFIER_NODE)
3243 got_scope = $$ = TREE_TYPE ($$);
3247 if (TREE_CODE ($$) == IDENTIFIER_NODE)
3251 | template_type SCOPE
3252 { got_scope = $$ = complete_type (TREE_TYPE ($1)); }
3253 /* These break 'const i;'
3257 cp_error ("`%D' is not an aggregate typedef",
3258 lastiddecl ? lastiddecl : $$);
3259 $$ = error_mark_node;
3262 { goto failed_scope; } */
3267 | global_scope typename_sub0
3272 typename_sub1 identifier
3274 if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't')
3275 $$ = make_typename_type ($1, $2);
3276 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
3277 cp_error ("`%T' is not a class or namespace", $2);
3281 if (TREE_CODE ($$) == TYPE_DECL)
3282 $$ = TREE_TYPE ($$);
3290 if (TREE_CODE ($1) == IDENTIFIER_NODE)
3291 cp_error ("`%T' is not a class or namespace", $1);
3293 | typename_sub1 typename_sub2
3295 if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't')
3296 $$ = make_typename_type ($1, $2);
3297 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
3298 cp_error ("`%T' is not a class or namespace", $2);
3302 if (TREE_CODE ($$) == TYPE_DECL)
3303 $$ = TREE_TYPE ($$);
3311 if (TREE_CODE ($1) != IDENTIFIER_NODE)
3313 got_scope = $$ = complete_type (TREE_TYPE ($$));
3317 if (TREE_CODE ($1) != IDENTIFIER_NODE)
3319 got_scope = $$ = complete_type (TREE_TYPE ($$));
3321 | template_type SCOPE
3322 { got_scope = $$ = complete_type (TREE_TYPE ($$)); }
3327 if (TREE_CODE ($$) == IDENTIFIER_NODE)
3334 global_scope type_name
3336 if (TREE_CODE ($2) == IDENTIFIER_NODE)
3337 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
3340 got_scope = NULL_TREE;
3343 | global_scope nested_type
3348 nested_name_specifier '*'
3349 { got_scope = NULL_TREE; }
3350 | global_scope nested_name_specifier '*'
3351 { $$ = $2; got_scope = NULL_TREE; }
3354 /* All uses of explicit global scope must go through this nonterminal so
3355 that got_scope will be set before yylex is called to get the next token. */
3358 { got_scope = void_type_node; }
3361 /* ANSI new-declarator (5.3.4) */
3363 '*' cv_qualifiers new_declarator
3364 { $$ = make_pointer_declarator ($2, $3); }
3365 | '*' cv_qualifiers %prec EMPTY
3366 { $$ = make_pointer_declarator ($2, NULL_TREE); }
3367 | '&' cv_qualifiers new_declarator %prec EMPTY
3368 { $$ = make_reference_declarator ($2, $3); }
3369 | '&' cv_qualifiers %prec EMPTY
3370 { $$ = make_reference_declarator ($2, NULL_TREE); }
3371 | ptr_to_mem cv_qualifiers %prec EMPTY
3372 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3373 $$ = build_parse_node (SCOPE_REF, $1, arg);
3375 | ptr_to_mem cv_qualifiers new_declarator
3376 { tree arg = make_pointer_declarator ($2, $3);
3377 $$ = build_parse_node (SCOPE_REF, $1, arg);
3379 | direct_new_declarator %prec EMPTY
3382 /* ANSI direct-new-declarator (5.3.4) */
3383 direct_new_declarator:
3385 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3386 | direct_new_declarator '[' nonmomentary_expr ']'
3387 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3390 /* ANSI abstract-declarator (8.1) */
3392 '*' nonempty_cv_qualifiers absdcl
3393 { $$ = make_pointer_declarator ($2.t, $3); }
3395 { $$ = make_pointer_declarator (NULL_TREE, $2); }
3396 | '*' nonempty_cv_qualifiers %prec EMPTY
3397 { $$ = make_pointer_declarator ($2.t, NULL_TREE); }
3399 { $$ = make_pointer_declarator (NULL_TREE, NULL_TREE); }
3400 | '&' nonempty_cv_qualifiers absdcl
3401 { $$ = make_reference_declarator ($2.t, $3); }
3403 { $$ = make_reference_declarator (NULL_TREE, $2); }
3404 | '&' nonempty_cv_qualifiers %prec EMPTY
3405 { $$ = make_reference_declarator ($2.t, NULL_TREE); }
3407 { $$ = make_reference_declarator (NULL_TREE, NULL_TREE); }
3408 | ptr_to_mem cv_qualifiers %prec EMPTY
3409 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3410 $$ = build_parse_node (SCOPE_REF, $1, arg);
3412 | ptr_to_mem cv_qualifiers absdcl
3413 { tree arg = make_pointer_declarator ($2, $3);
3414 $$ = build_parse_node (SCOPE_REF, $1, arg);
3416 | direct_abstract_declarator %prec EMPTY
3419 /* ANSI direct-abstract-declarator (8.1) */
3420 direct_abstract_declarator:
3423 /* `(typedef)1' is `int'. */
3425 | direct_abstract_declarator '(' parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3426 { $$ = make_call_declarator ($$, $3, $5, $6); }
3427 | direct_abstract_declarator LEFT_RIGHT cv_qualifiers exception_specification_opt %prec '.'
3428 { $$ = make_call_declarator ($$, empty_parms (), $3, $4); }
3429 | direct_abstract_declarator '[' nonmomentary_expr ']' %prec '.'
3430 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3431 | direct_abstract_declarator '[' ']' %prec '.'
3432 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
3433 | '(' complex_parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3434 { $$ = make_call_declarator (NULL_TREE, $2, $4, $5); }
3435 | regcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3436 { set_quals_and_spec ($$, $2, $3); }
3437 | fcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3438 { set_quals_and_spec ($$, $2, $3); }
3439 | '[' nonmomentary_expr ']' %prec '.'
3440 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3442 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, NULL_TREE); }
3445 /* For C++, decls and stmts can be intermixed, so we don't need to
3446 have a special rule that won't start parsing the stmt section
3447 until we have a stmt that parses without errors. */
3460 /* build the LET_STMT node before parsing its contents,
3461 so that any LET_STMTs within the context can have their display pointers
3462 set up to point at this one. */
3466 { do_pushlevel (); }
3471 { $$ = do_poplevel (); }
3474 /* Read zero or more forward-declarations for labels
3475 that nested functions can jump to. */
3480 pedwarn ("ANSI C++ forbids label declarations"); }
3485 | label_decls label_decl
3489 LABEL identifiers_or_typenames ';'
3491 for (link = $2; link; link = TREE_CHAIN (link))
3493 tree label = shadow_label (TREE_VALUE (link));
3494 C_DECLARED_LABEL_FLAG (label) = 1;
3495 declare_nonlocal_label (label);
3500 /* This is the body of a function definition.
3501 It causes syntax errors to ignore to the next openbrace. */
3511 if (processing_template_decl)
3513 $<ttype>$ = build_min_nt (COMPOUND_STMT, NULL_TREE);
3514 add_tree ($<ttype>$);
3517 .pushlevel compstmtend .poplevel
3519 if (processing_template_decl)
3521 TREE_OPERAND ($<ttype>2, 0) = TREE_CHAIN ($<ttype>2);
3522 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3523 last_tree = $<ttype>2;
3532 if (processing_template_decl)
3534 $<ttype>$ = build_min_nt (IF_STMT, NULL_TREE, NULL_TREE,
3536 add_tree ($<ttype>$);
3538 cond_stmt_keyword = "if";
3540 .pushlevel paren_cond_or_null
3542 if (processing_template_decl)
3544 if (last_tree != $<ttype>2)
3546 TREE_OPERAND ($<ttype>2, 0) = last_tree;
3547 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3548 last_tree = $<ttype>2;
3551 TREE_OPERAND ($<ttype>2, 0) = $4;
3555 emit_line_note (input_filename, lineno);
3556 expand_start_cond ($4, 0);
3559 implicitly_scoped_stmt
3561 if (processing_template_decl)
3563 TREE_OPERAND ($<ttype>2, 1) = TREE_CHAIN ($<ttype>2);
3564 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3565 $<ttype>$ = last_tree = $<ttype>2;
3570 implicitly_scoped_stmt:
3575 if (processing_template_decl)
3577 $<ttype>$ = build_min_nt (COMPOUND_STMT, NULL_TREE);
3578 add_tree ($<ttype>$);
3581 simple_stmt .poplevel
3583 if (processing_template_decl)
3585 TREE_OPERAND ($<ttype>2, 0) = TREE_CHAIN ($<ttype>2);
3586 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3587 last_tree = $<ttype>2;
3605 if (! processing_template_decl)
3607 emit_line_note (input_filename, lineno);
3608 /* Do default conversion if safe and possibly important,
3609 in case within ({...}). */
3610 if ((TREE_CODE (TREE_TYPE (expr)) == ARRAY_TYPE
3612 || TREE_CODE (TREE_TYPE (expr)) == FUNCTION_TYPE)
3613 expr = default_conversion (expr);
3615 cplus_expand_expr_stmt (expr);
3619 { if (! processing_template_decl) expand_start_else (); }
3620 implicitly_scoped_stmt
3622 if (processing_template_decl)
3624 TREE_OPERAND ($<ttype>1, 2) = TREE_CHAIN ($<ttype>1);
3625 TREE_CHAIN ($<ttype>1) = NULL_TREE;
3626 last_tree = $<ttype>1;
3633 | simple_if %prec IF
3634 { if (! processing_template_decl) expand_end_cond ();
3639 if (processing_template_decl)
3641 $<ttype>$ = build_min_nt (WHILE_STMT, NULL_TREE, NULL_TREE);
3642 add_tree ($<ttype>$);
3647 emit_line_note (input_filename, lineno);
3648 expand_start_loop (1);
3650 cond_stmt_keyword = "while";
3652 .pushlevel paren_cond_or_null
3654 if (processing_template_decl)
3656 if (last_tree != $<ttype>2)
3658 TREE_OPERAND ($<ttype>2, 0) = last_tree;
3659 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3660 last_tree = $<ttype>2;
3663 TREE_OPERAND ($<ttype>2, 0) = $4;
3667 emit_line_note (input_filename, lineno);
3668 expand_exit_loop_if_false (0, $4);
3671 already_scoped_stmt .poplevel
3673 if (processing_template_decl)
3675 TREE_OPERAND ($<ttype>2, 1) = TREE_CHAIN ($<ttype>2);
3676 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3677 last_tree = $<ttype>2;
3685 if (processing_template_decl)
3687 $<ttype>$ = build_min_nt (DO_STMT, NULL_TREE, NULL_TREE);
3688 add_tree ($<ttype>$);
3693 emit_line_note (input_filename, lineno);
3694 expand_start_loop_continue_elsewhere (1);
3697 implicitly_scoped_stmt WHILE
3699 if (processing_template_decl)
3701 TREE_OPERAND ($<ttype>2, 0) = TREE_CHAIN ($<ttype>2);
3702 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3703 last_tree = $<ttype>2;
3707 expand_loop_continue_here ();
3708 cond_stmt_keyword = "do";
3711 paren_expr_or_null ';'
3713 if (processing_template_decl)
3714 TREE_OPERAND ($<ttype>2, 1) = $6;
3717 emit_line_note (input_filename, lineno);
3718 expand_exit_loop_if_false (0, $6);
3725 { if (processing_template_decl)
3727 $<ttype>$ = build_min_nt (FOR_STMT, NULL_TREE, NULL_TREE,
3728 NULL_TREE, NULL_TREE);
3729 add_tree ($<ttype>$);
3732 emit_line_note (input_filename, lineno);
3733 if (flag_new_for_scope > 0)
3735 /* Conditionalize .pushlevel */
3737 note_level_for_for ();
3740 expand_start_bindings (0);
3743 '(' for.init.statement
3745 if (processing_template_decl)
3747 if (last_tree != $<ttype>2)
3749 TREE_OPERAND ($<ttype>2, 0) = TREE_CHAIN ($<ttype>2);
3750 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3751 last_tree = $<ttype>2;
3757 emit_line_note (input_filename, lineno);
3758 expand_start_loop_continue_elsewhere (1);
3761 .pushlevel xcond ';'
3763 if (processing_template_decl)
3765 if (last_tree != $<ttype>2)
3767 TREE_OPERAND ($<ttype>2, 1) = last_tree;
3768 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3769 last_tree = $<ttype>2;
3772 TREE_OPERAND ($<ttype>2, 1) = $7;
3776 emit_line_note (input_filename, lineno);
3777 if ($7) expand_exit_loop_if_false (0, $7);
3781 /* Don't let the tree nodes for $10 be discarded
3782 by clear_momentary during the parsing of the next stmt. */
3784 if (processing_template_decl)
3785 TREE_OPERAND ($<ttype>2, 2) = $10;
3788 already_scoped_stmt .poplevel
3790 if (processing_template_decl)
3792 TREE_OPERAND ($<ttype>2, 3) = TREE_CHAIN ($<ttype>2);
3793 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3794 last_tree = $<ttype>2;
3798 emit_line_note (input_filename, lineno);
3799 expand_loop_continue_here ();
3800 if ($10) cplus_expand_expr_stmt ($10);
3804 if (flag_new_for_scope > 0)
3809 | SWITCH .pushlevel '(' condition ')'
3811 if (processing_template_decl)
3813 $<ttype>$ = build_min_nt (SWITCH_STMT, $4, NULL_TREE);
3814 add_tree ($<ttype>$);
3818 emit_line_note (input_filename, lineno);
3819 c_expand_start_case ($4);
3822 /* Don't let the tree nodes for $4 be discarded by
3823 clear_momentary during the parsing of the next stmt. */
3826 implicitly_scoped_stmt
3828 if (processing_template_decl)
3830 TREE_OPERAND ($<ttype>6, 1) = TREE_CHAIN ($<ttype>6);
3831 TREE_CHAIN ($<ttype>6) = NULL_TREE;
3832 last_tree = $<ttype>6;
3835 expand_end_case ($4);
3841 | CASE expr_no_commas ':'
3842 { do_case ($2, NULL_TREE); }
3844 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
3845 { do_case ($2, $4); }
3848 { do_case (NULL_TREE, NULL_TREE); }
3851 { emit_line_note (input_filename, lineno);
3852 if (processing_template_decl)
3853 add_tree (build_min_nt (BREAK_STMT));
3854 else if ( ! expand_exit_something ())
3855 error ("break statement not within loop or switch"); }
3857 { emit_line_note (input_filename, lineno);
3858 if (processing_template_decl)
3859 add_tree (build_min_nt (CONTINUE_STMT));
3860 else if (! expand_continue_loop (0))
3861 error ("continue statement not within a loop"); }
3863 { emit_line_note (input_filename, lineno);
3864 c_expand_return (NULL_TREE); }
3866 { emit_line_note (input_filename, lineno);
3867 c_expand_return ($2);
3870 | asm_keyword maybe_cv_qualifier '(' string ')' ';'
3871 { if (TREE_CHAIN ($4)) $4 = combine_strings ($4);
3872 emit_line_note (input_filename, lineno);
3876 /* This is the case with just output operands. */
3877 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ')' ';'
3878 { if (TREE_CHAIN ($4)) $4 = combine_strings ($4);
3879 emit_line_note (input_filename, lineno);
3880 c_expand_asm_operands ($4, $6, NULL_TREE, NULL_TREE,
3881 $2 == ridpointers[(int)RID_VOLATILE],
3882 input_filename, lineno);
3885 /* This is the case with input operands as well. */
3886 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':' asm_operands ')' ';'
3887 { if (TREE_CHAIN ($4)) $4 = combine_strings ($4);
3888 emit_line_note (input_filename, lineno);
3889 c_expand_asm_operands ($4, $6, $8, NULL_TREE,
3890 $2 == ridpointers[(int)RID_VOLATILE],
3891 input_filename, lineno);
3894 /* This is the case with clobbered registers as well. */
3895 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':'
3896 asm_operands ':' asm_clobbers ')' ';'
3897 { if (TREE_CHAIN ($4)) $4 = combine_strings ($4);
3898 emit_line_note (input_filename, lineno);
3899 c_expand_asm_operands ($4, $6, $8, $10,
3900 $2 == ridpointers[(int)RID_VOLATILE],
3901 input_filename, lineno);
3906 if (processing_template_decl)
3907 add_tree (build_min_nt (GOTO_STMT, $3));
3909 { emit_line_note (input_filename, lineno);
3910 expand_computed_goto ($3); }
3912 | GOTO identifier ';'
3914 if (processing_template_decl)
3915 add_tree (build_min_nt (GOTO_STMT, $2));
3919 emit_line_note (input_filename, lineno);
3920 decl = lookup_label ($2);
3921 TREE_USED (decl) = 1;
3928 { error ("label must be followed by statement");
3939 if (! current_function_parms_stored)
3940 store_parm_decls ();
3941 expand_start_early_try_stmts ();
3943 ctor_initializer_opt compstmt
3944 { expand_start_all_catch (); }
3947 int nested = (hack_decl_function_context
3948 (current_function_decl) != NULL_TREE);
3949 expand_end_all_catch ();
3950 finish_function (lineno, (int)$3, nested);
3957 if (processing_template_decl)
3959 $<ttype>$ = build_min_nt (TRY_BLOCK, NULL_TREE,
3961 add_tree ($<ttype>$);
3965 emit_line_note (input_filename, lineno);
3966 expand_start_try_stmts ();
3971 if (processing_template_decl)
3973 TREE_OPERAND ($<ttype>2, 0) = TREE_CHAIN ($<ttype>2);
3974 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3975 last_tree = $<ttype>2;
3978 expand_start_all_catch ();
3982 if (processing_template_decl)
3984 TREE_OPERAND ($<ttype>2, 1) = TREE_CHAIN ($<ttype>2);
3985 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3986 last_tree = $<ttype>2;
3989 expand_end_all_catch ();
3995 | handler_seq handler
4001 if (processing_template_decl)
4003 $<ttype>$ = build_min_nt (HANDLER, NULL_TREE,
4005 add_tree ($<ttype>$);
4008 .pushlevel handler_args
4010 if (processing_template_decl)
4012 TREE_OPERAND ($<ttype>2, 0) = TREE_CHAIN ($<ttype>2);
4013 TREE_CHAIN ($<ttype>2) = NULL_TREE;
4014 last_tree = $<ttype>2;
4019 if (processing_template_decl)
4021 TREE_OPERAND ($<ttype>2, 1) = TREE_CHAIN ($<ttype>2);
4022 TREE_CHAIN ($<ttype>2) = NULL_TREE;
4023 last_tree = $<ttype>2;
4026 expand_end_catch_block ();
4032 typed_typespecs %prec EMPTY
4033 | nonempty_cv_qualifiers %prec EMPTY
4038 { expand_start_catch_block (NULL_TREE, NULL_TREE); }
4039 /* This doesn't allow reference parameters, the below does.
4040 | '(' type_specifier_seq absdcl ')'
4041 { check_for_new_type ("inside exception declarations", $2);
4042 expand_start_catch_block ($2.t, $3); }
4043 | '(' type_specifier_seq ')'
4044 { check_for_new_type ("inside exception declarations", $2);
4045 expand_start_catch_block ($2.t, NULL_TREE); }
4046 | '(' type_specifier_seq notype_declarator ')'
4047 { check_for_new_type ("inside exception declarations", $2);
4048 expand_start_catch_block ($2.t, $3); }
4049 | '(' typed_typespecs after_type_declarator ')'
4050 { check_for_new_type ("inside exception declarations", $2);
4051 expand_start_catch_block ($2.t, $3); }
4052 This allows reference parameters... */
4054 { check_for_new_type ("inside exception declarations", $2);
4055 expand_start_catch_block (TREE_PURPOSE ($2.t),
4056 TREE_VALUE ($2.t)); }
4063 label = define_label (input_filename, lineno, $1);
4064 if (label && ! minimal_parse_mode)
4065 expand_label (label);
4077 { if ($1) cplus_expand_expr_stmt ($1); }
4081 pedwarn ("ANSI C++ forbids compound statements inside for initializations");
4085 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
4089 { emit_line_note (input_filename, lineno);
4092 { emit_line_note (input_filename, lineno); }
4103 /* These are the operands other than the first string and colon
4104 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
4108 | nonnull_asm_operands
4111 nonnull_asm_operands:
4113 | nonnull_asm_operands ',' asm_operand
4114 { $$ = chainon ($$, $3); }
4119 { $$ = build_tree_list ($$, $3); }
4124 { $$ = tree_cons (NULL_TREE, $$, NULL_TREE); }
4125 | asm_clobbers ',' STRING
4126 { $$ = tree_cons (NULL_TREE, $3, $$); }
4129 /* This is what appears inside the parens in a function declarator.
4130 Its value is represented in the format that grokdeclarator expects.
4132 In C++, declaring a function with no parameters
4133 means that that function takes *no* parameters. */
4142 { $$ = tree_cons (NULL_TREE, $1.t, void_list_node);
4143 TREE_PARMLIST ($$) = 1;
4144 check_for_new_type ("inside parameter list", $1); }
4147 /* This nonterminal does not include the common sequence '(' type_id ')',
4148 as it is ambiguous and must be disambiguated elsewhere. */
4152 $$ = chainon ($$, void_list_node);
4153 TREE_PARMLIST ($$) = 1;
4155 | parms_comma ELLIPSIS
4157 TREE_PARMLIST ($$) = 1;
4159 /* C++ allows an ellipsis without a separating ',' */
4162 TREE_PARMLIST ($$) = 1;
4166 $$ = build_tree_list (NULL_TREE, $1.t);
4167 TREE_PARMLIST ($$) = 1;
4175 TREE_PARMLIST ($$) = 1;
4177 | parms TYPENAME_ELLIPSIS
4179 TREE_PARMLIST ($$) = 1;
4181 | type_id TYPENAME_ELLIPSIS
4183 $$ = build_tree_list (NULL_TREE, $1.t);
4184 TREE_PARMLIST ($$) = 1;
4188 /* This helps us recover from really nasty
4189 parse errors, for example, a missing right
4191 yyerror ("possibly missing ')'");
4192 $$ = chainon ($$, void_list_node);
4193 TREE_PARMLIST ($$) = 1;
4199 /* This helps us recover from really nasty
4200 parse errors, for example, a missing right
4202 yyerror ("possibly missing ')'");
4203 $$ = tree_cons (NULL_TREE, $1.t, void_list_node);
4204 TREE_PARMLIST ($$) = 1;
4210 /* A default argument to a */
4213 { maybe_snarf_defarg (); }
4223 /* A nonempty list of parameter declarations or type names. */
4226 { check_for_new_type ("in a parameter list", $1);
4227 $$ = build_tree_list (NULL_TREE, $1.t); }
4229 { check_for_new_type ("in a parameter list", $1);
4230 $$ = build_tree_list ($2, $1.t); }
4231 | parms_comma full_parm
4232 { check_for_new_type ("in a parameter list", $2);
4233 $$ = chainon ($$, $2.t); }
4234 | parms_comma bad_parm
4235 { $$ = chainon ($$, build_tree_list (NULL_TREE, $2)); }
4236 | parms_comma bad_parm '=' init
4237 { $$ = chainon ($$, build_tree_list ($4, $2)); }
4243 { check_for_new_type ("in a parameter list", $1);
4244 $$ = build_tree_list (NULL_TREE, $1.t); }
4247 /* A single parameter declaration or parameter type name,
4248 as found in a parmlist. */
4250 /* Here we expand typed_declspecs inline to avoid mis-parsing of
4251 TYPESPEC IDENTIFIER. */
4252 typed_declspecs1 declarator
4253 { tree specs = strip_attrs ($1.t);
4254 $$.new_type_flag = $1.new_type_flag;
4255 $$.t = build_tree_list (specs, $2); }
4256 | typed_typespecs declarator
4257 { $$.t = build_tree_list ($1.t, $2);
4258 $$.new_type_flag = $1.new_type_flag; }
4259 | typespec declarator
4260 { $$.t = build_tree_list (get_decl_list ($1.t), $2);
4261 $$.new_type_flag = $1.new_type_flag; }
4262 | typed_declspecs1 absdcl
4263 { tree specs = strip_attrs ($1.t);
4264 $$.t = build_tree_list (specs, $2);
4265 $$.new_type_flag = $1.new_type_flag; }
4266 | typed_declspecs1 %prec EMPTY
4267 { tree specs = strip_attrs ($1.t);
4268 $$.t = build_tree_list (specs, NULL_TREE);
4269 $$.new_type_flag = $1.new_type_flag; }
4270 | declmods notype_declarator
4271 { tree specs = strip_attrs ($1);
4272 $$.t = build_tree_list (specs, $2);
4273 $$.new_type_flag = 0; }
4278 { $$.t = build_tree_list (NULL_TREE, $1.t);
4279 $$.new_type_flag = $1.new_type_flag; }
4281 { $$.t = build_tree_list ($2, $1.t);
4282 $$.new_type_flag = $1.new_type_flag; }
4291 /* empty */ %prec EMPTY
4292 { see_typename (); }
4296 /* empty */ %prec EMPTY
4298 error ("type specifier omitted for parameter");
4299 $$ = build_tree_list (integer_type_node, NULL_TREE);
4303 error ("type specifier omitted for parameter");
4304 if (TREE_CODE ($$) == SCOPE_REF
4305 && (TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TYPE_PARM
4306 || TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TEMPLATE_PARM))
4307 cp_error (" perhaps you want `typename %E' to make it a type", $$);
4308 $$ = build_tree_list (integer_type_node, $$);
4312 exception_specification_opt:
4313 /* empty */ %prec EMPTY
4315 | THROW '(' ansi_raise_identifiers ')' %prec EMPTY
4317 | THROW LEFT_RIGHT %prec EMPTY
4318 { $$ = build_decl_list (NULL_TREE, NULL_TREE); }
4321 ansi_raise_identifier:
4323 { $$ = build_decl_list (NULL_TREE, groktypename($1.t)); }
4326 ansi_raise_identifiers:
4327 ansi_raise_identifier
4328 | ansi_raise_identifiers ',' ansi_raise_identifier
4330 TREE_CHAIN ($3) = $$;
4335 conversion_declarator:
4336 /* empty */ %prec EMPTY
4338 | '*' cv_qualifiers conversion_declarator
4339 { $$ = make_pointer_declarator ($2, $3); }
4340 | '&' cv_qualifiers conversion_declarator
4341 { $$ = make_reference_declarator ($2, $3); }
4342 | ptr_to_mem cv_qualifiers conversion_declarator
4343 { tree arg = make_pointer_declarator ($2, $3);
4344 $$ = build_parse_node (SCOPE_REF, $1, arg);
4350 { got_scope = NULL_TREE; }
4355 { $$ = ansi_opname[MULT_EXPR]; }
4357 { $$ = ansi_opname[TRUNC_DIV_EXPR]; }
4359 { $$ = ansi_opname[TRUNC_MOD_EXPR]; }
4361 { $$ = ansi_opname[PLUS_EXPR]; }
4363 { $$ = ansi_opname[MINUS_EXPR]; }
4365 { $$ = ansi_opname[BIT_AND_EXPR]; }
4367 { $$ = ansi_opname[BIT_IOR_EXPR]; }
4369 { $$ = ansi_opname[BIT_XOR_EXPR]; }
4371 { $$ = ansi_opname[BIT_NOT_EXPR]; }
4373 { $$ = ansi_opname[COMPOUND_EXPR]; }
4374 | operator ARITHCOMPARE
4375 { $$ = ansi_opname[$2]; }
4377 { $$ = ansi_opname[LT_EXPR]; }
4379 { $$ = ansi_opname[GT_EXPR]; }
4380 | operator EQCOMPARE
4381 { $$ = ansi_opname[$2]; }
4383 { $$ = ansi_assopname[$2]; }
4385 { $$ = ansi_opname [MODIFY_EXPR]; }
4387 { $$ = ansi_opname[$2]; }
4389 { $$ = ansi_opname[$2]; }
4391 { $$ = ansi_opname[POSTINCREMENT_EXPR]; }
4392 | operator MINUSMINUS
4393 { $$ = ansi_opname[PREDECREMENT_EXPR]; }
4395 { $$ = ansi_opname[TRUTH_ANDIF_EXPR]; }
4397 { $$ = ansi_opname[TRUTH_ORIF_EXPR]; }
4399 { $$ = ansi_opname[TRUTH_NOT_EXPR]; }
4401 { $$ = ansi_opname[COND_EXPR]; }
4403 { $$ = ansi_opname[$2]; }
4404 | operator POINTSAT %prec EMPTY
4405 { $$ = ansi_opname[COMPONENT_REF]; }
4406 | operator POINTSAT_STAR %prec EMPTY
4407 { $$ = ansi_opname[MEMBER_REF]; }
4408 | operator LEFT_RIGHT
4409 { $$ = ansi_opname[CALL_EXPR]; }
4411 { $$ = ansi_opname[ARRAY_REF]; }
4412 | operator NEW %prec EMPTY
4413 { $$ = ansi_opname[NEW_EXPR]; }
4414 | operator DELETE %prec EMPTY
4415 { $$ = ansi_opname[DELETE_EXPR]; }
4416 | operator NEW '[' ']'
4417 { $$ = ansi_opname[VEC_NEW_EXPR]; }
4418 | operator DELETE '[' ']'
4419 { $$ = ansi_opname[VEC_DELETE_EXPR]; }
4420 /* Names here should be looked up in class scope ALSO. */
4421 | operator type_specifier_seq conversion_declarator
4422 { $$ = grokoptypename ($2.t, $3); }
4424 { $$ = ansi_opname[ERROR_MARK]; }
4431 debug_yytranslate (value)
4434 return yytname[YYTRANSLATE (value)];