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)
1384 if (processing_template_arg)
1387 arg_looking_for_template = processing_template_arg;
1388 id = lookup_name ($$, 0);
1389 arg_looking_for_template = 0;
1391 if (!id || id == error_mark_node
1392 || (TREE_CODE (id) != TEMPLATE_DECL
1393 && TREE_CODE (id) != TEMPLATE_TEMPLATE_PARM))
1394 id = do_identifier ($$, 1);
1398 $$ = do_identifier ($$, 1);
1404 if (processing_template_decl)
1405 push_obstacks (&permanent_obstack, &permanent_obstack);
1406 $$ = combine_strings ($$);
1407 if (processing_template_decl)
1413 class = TREE_CODE_CLASS (TREE_CODE ($$));
1414 if (class == 'e' || class == '1'
1415 || class == '2' || class == '<')
1416 /* This inhibits warnings in truthvalue_conversion. */
1417 C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK); }
1418 | '(' expr_or_declarator ')'
1420 $$ = reparse_decl_as_expr (NULL_TREE, $2);
1421 class = TREE_CODE_CLASS (TREE_CODE ($$));
1422 if (class == 'e' || class == '1'
1423 || class == '2' || class == '<')
1424 /* This inhibits warnings in truthvalue_conversion. */
1425 C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK); }
1427 { $$ = error_mark_node; }
1429 { if (current_function_decl == 0)
1431 error ("braced-group within expression allowed only inside a function");
1435 $<ttype>$ = expand_start_stmt_expr (); }
1439 pedwarn ("ANSI C++ forbids braced-groups within expressions");
1440 rtl_exp = expand_end_stmt_expr ($<ttype>2);
1441 /* The statements have side effects, so the group does. */
1442 TREE_SIDE_EFFECTS (rtl_exp) = 1;
1444 if (TREE_CODE ($3) == BLOCK)
1446 /* Make a BIND_EXPR for the BLOCK already made. */
1447 $$ = build (BIND_EXPR, TREE_TYPE (rtl_exp),
1448 NULL_TREE, rtl_exp, $3);
1449 /* Remove the block from the tree at this point.
1450 It gets put back at the proper place
1451 when the BIND_EXPR is expanded. */
1457 | primary '(' nonnull_exprlist ')'
1459 $$ = build_x_function_call ($1, $3, current_class_ref);
1460 if (TREE_CODE ($$) == CALL_EXPR
1461 && TREE_TYPE ($$) != void_type_node)
1462 $$ = require_complete_type ($$);
1464 | primary LEFT_RIGHT
1466 $$ = build_x_function_call ($$, NULL_TREE, current_class_ref);
1467 if (TREE_CODE ($$) == CALL_EXPR
1468 && TREE_TYPE ($$) != void_type_node)
1469 $$ = require_complete_type ($$);
1471 | primary '[' expr ']'
1472 { $$ = grok_array_decl ($$, $3); }
1474 { /* If we get an OFFSET_REF, turn it into what it really
1475 means (e.g., a COMPONENT_REF). This way if we've got,
1476 say, a reference to a static member that's being operated
1477 on, we don't end up trying to find a member operator for
1478 the class it's in. */
1479 if (TREE_CODE ($$) == OFFSET_REF)
1480 $$ = resolve_offset_ref ($$);
1481 $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); }
1482 | primary MINUSMINUS
1483 { if (TREE_CODE ($$) == OFFSET_REF)
1484 $$ = resolve_offset_ref ($$);
1485 $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); }
1486 /* C++ extensions */
1488 { if (current_class_ptr)
1490 #ifdef WARNING_ABOUT_CCD
1491 TREE_USED (current_class_ptr) = 1;
1493 $$ = current_class_ptr;
1495 else if (current_function_decl
1496 && DECL_STATIC_FUNCTION_P (current_function_decl))
1498 error ("`this' is unavailable for static member functions");
1499 $$ = error_mark_node;
1503 if (current_function_decl)
1504 error ("invalid use of `this' in non-member function");
1506 error ("invalid use of `this' at top level");
1507 $$ = error_mark_node;
1510 | CV_QUALIFIER '(' nonnull_exprlist ')'
1515 /* This is a C cast in C++'s `functional' notation. */
1516 if ($3 == error_mark_node)
1518 $$ = error_mark_node;
1522 if ($3 == NULL_TREE)
1524 error ("cannot cast null list to type `%s'",
1525 IDENTIFIER_POINTER (TYPE_NAME (id)));
1526 $$ = error_mark_node;
1531 /* type is not set! (mrs) */
1532 if (type == error_mark_node)
1533 $$ = error_mark_node;
1537 if (id == ridpointers[(int) RID_CONST])
1538 type = build_type_variant (integer_type_node, 1, 0);
1539 else if (id == ridpointers[(int) RID_VOLATILE])
1540 type = build_type_variant (integer_type_node, 0, 1);
1542 /* should not be able to get here (mrs) */
1543 else if (id == ridpointers[(int) RID_FRIEND])
1545 error ("cannot cast expression to `friend' type");
1546 $$ = error_mark_node;
1550 else my_friendly_abort (79);
1551 $$ = build_c_cast (type, build_compound_expr ($3));
1555 | DYNAMIC_CAST '<' type_id '>' '(' expr ')'
1556 { tree type = groktypename ($3.t);
1557 check_for_new_type ("dynamic_cast", $3);
1558 $$ = build_dynamic_cast (type, $6); }
1559 | STATIC_CAST '<' type_id '>' '(' expr ')'
1560 { tree type = groktypename ($3.t);
1561 check_for_new_type ("static_cast", $3);
1562 $$ = build_static_cast (type, $6); }
1563 | REINTERPRET_CAST '<' type_id '>' '(' expr ')'
1564 { tree type = groktypename ($3.t);
1565 check_for_new_type ("reinterpret_cast", $3);
1566 $$ = build_reinterpret_cast (type, $6); }
1567 | CONST_CAST '<' type_id '>' '(' expr ')'
1568 { tree type = groktypename ($3.t);
1569 check_for_new_type ("const_cast", $3);
1570 $$ = build_const_cast (type, $6); }
1571 | TYPEID '(' expr ')'
1572 { $$ = build_x_typeid ($3); }
1573 | TYPEID '(' type_id ')'
1574 { tree type = groktypename ($3.t);
1575 check_for_new_type ("typeid", $3);
1576 $$ = get_typeid (TYPE_MAIN_VARIANT (type)); }
1577 | global_scope IDENTIFIER
1578 { $$ = do_scoped_id ($2, 1); }
1579 | global_scope operator_name
1581 got_scope = NULL_TREE;
1582 if (TREE_CODE ($2) == IDENTIFIER_NODE)
1583 $$ = do_scoped_id ($2, 1);
1587 | overqualified_id %prec HYPERUNARY
1588 { $$ = build_offset_ref (OP0 ($$), OP1 ($$)); }
1589 | overqualified_id '(' nonnull_exprlist ')'
1590 { if (processing_template_decl)
1591 $$ = build_min_nt (CALL_EXPR, copy_to_permanent ($1), $3, NULL_TREE);
1593 $$ = build_member_call (OP0 ($$), OP1 ($$), $3); }
1594 | overqualified_id LEFT_RIGHT
1595 { if (processing_template_decl)
1596 $$ = build_min_nt (CALL_EXPR, copy_to_permanent ($1),
1597 NULL_TREE, NULL_TREE);
1599 $$ = build_member_call (OP0 ($$), OP1 ($$), NULL_TREE); }
1600 | object object_template_id %prec UNARY
1602 $$ = build_x_component_ref ($$, $2, NULL_TREE, 1);
1604 | object object_template_id '(' nonnull_exprlist ')'
1606 $$ = build_method_call ($1, $2, $4,
1607 NULL_TREE, LOOKUP_NORMAL);
1609 | object object_template_id LEFT_RIGHT
1611 $$ = build_method_call ($1, $2, NULL_TREE,
1612 NULL_TREE, LOOKUP_NORMAL);
1614 | object unqualified_id %prec UNARY
1615 { $$ = build_x_component_ref ($$, $2, NULL_TREE, 1); }
1616 | object overqualified_id %prec UNARY
1617 { if (processing_template_decl)
1618 $$ = build_min_nt (COMPONENT_REF, $1, copy_to_permanent ($2));
1620 $$ = build_object_ref ($$, OP0 ($2), OP1 ($2)); }
1621 | object unqualified_id '(' nonnull_exprlist ')'
1624 /* This is a future direction of this code, but because
1625 build_x_function_call cannot always undo what is done
1626 in build_component_ref entirely yet, we cannot do this. */
1627 $$ = build_x_function_call (build_component_ref ($$, $2, NULL_TREE, 1), $4, current_class_ref);
1628 if (TREE_CODE ($$) == CALL_EXPR
1629 && TREE_TYPE ($$) != void_type_node)
1630 $$ = require_complete_type ($$);
1632 $$ = build_method_call ($$, $2, $4, NULL_TREE,
1636 | object unqualified_id LEFT_RIGHT
1639 /* This is a future direction of this code, but because
1640 build_x_function_call cannot always undo what is done
1641 in build_component_ref entirely yet, we cannot do this. */
1642 $$ = build_x_function_call (build_component_ref ($$, $2, NULL_TREE, 1), NULL_TREE, current_class_ref);
1643 if (TREE_CODE ($$) == CALL_EXPR
1644 && TREE_TYPE ($$) != void_type_node)
1645 $$ = require_complete_type ($$);
1647 $$ = build_method_call ($$, $2, NULL_TREE, NULL_TREE,
1651 | object overqualified_id '(' nonnull_exprlist ')'
1653 if (IS_SIGNATURE (OP0 ($2)))
1655 warning ("signature name in scope resolution ignored");
1656 $$ = build_method_call ($$, OP1 ($2), $4, NULL_TREE,
1660 $$ = build_scoped_method_call ($$, OP0 ($2), OP1 ($2), $4);
1662 | object overqualified_id LEFT_RIGHT
1664 if (IS_SIGNATURE (OP0 ($2)))
1666 warning ("signature name in scope resolution ignored");
1667 $$ = build_method_call ($$, OP1 ($2), NULL_TREE, NULL_TREE,
1671 $$ = build_scoped_method_call ($$, OP0 ($2), OP1 ($2), NULL_TREE);
1673 /* p->int::~int() is valid -- 12.4 */
1674 | object '~' TYPESPEC LEFT_RIGHT
1676 if (IDENTIFIER_GLOBAL_VALUE ($3)
1677 && (TREE_CODE (TREE_TYPE ($1))
1678 != TREE_CODE (TREE_TYPE (IDENTIFIER_GLOBAL_VALUE ($3)))))
1679 cp_error ("`%E' is not of type `%T'", $1, $3);
1680 $$ = cp_convert (void_type_node, $1);
1682 | object TYPESPEC SCOPE '~' TYPESPEC LEFT_RIGHT
1685 cp_error ("destructor specifier `%T::~%T()' must have matching names", $2, $5);
1686 if (TREE_CODE (TREE_TYPE ($1))
1687 != TREE_CODE (TREE_TYPE (IDENTIFIER_GLOBAL_VALUE ($2))))
1688 cp_error ("`%E' is not of type `%T'", $1, $2);
1689 $$ = cp_convert (void_type_node, $1);
1693 $$ = error_mark_node;
1697 /* Not needed for now.
1703 { $$ = error_mark_node; }
1705 { if (current_function_decl == 0)
1707 error ("braced-group within expression allowed only inside a function");
1710 $<ttype>$ = expand_start_stmt_expr (); }
1713 pedwarn ("ANSI C++ forbids braced-groups within expressions");
1714 $$ = expand_end_stmt_expr ($<ttype>2); }
1715 | primary_no_id '(' nonnull_exprlist ')'
1716 { $$ = build_x_function_call ($$, $3, current_class_ref); }
1717 | primary_no_id LEFT_RIGHT
1718 { $$ = build_x_function_call ($$, NULL_TREE, current_class_ref); }
1719 | primary_no_id '[' expr ']'
1721 | primary_no_id PLUSPLUS
1722 { $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); }
1723 | primary_no_id MINUSMINUS
1724 { $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); }
1726 { goto do_scoped_id; }
1727 | SCOPE operator_name
1728 { if (TREE_CODE ($2) == IDENTIFIER_NODE)
1730 goto do_scoped_operator;
1739 { got_scope = NULL_TREE; $$ = 1; }
1745 | global_scope delete
1746 { got_scope = NULL_TREE; $$ = 1; }
1751 { $$ = boolean_true_node; }
1753 { $$ = boolean_false_node; }
1756 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
1760 { $$ = chainon ($$, $2); }
1766 if (! current_function_parms_stored)
1767 store_parm_decls ();
1769 /* Always keep the BLOCK node associated with the outermost
1770 pair of curley braces of a function. These are needed
1771 for correct operation of dwarfout.c. */
1778 { got_object = TREE_TYPE ($$); }
1781 $$ = build_x_arrow ($$);
1782 got_object = TREE_TYPE ($$);
1787 typespec initdecls ';'
1789 resume_momentary ($2);
1790 if ($1.t && IS_AGGR_TYPE_CODE (TREE_CODE ($1.t)))
1791 note_got_semicolon ($1.t);
1793 | typed_declspecs initdecls ';'
1795 resume_momentary ($2);
1796 note_list_got_semicolon ($1.t);
1798 | declmods notype_initdecls ';'
1799 { resume_momentary ($2); }
1800 | typed_declspecs ';'
1803 note_list_got_semicolon ($1.t);
1806 { warning ("empty declaration"); }
1808 { pedantic = $<itype>1; }
1811 /* Any kind of declarator (thus, all declarators allowed
1812 after an explicit typespec). */
1815 after_type_declarator %prec EMPTY
1816 | notype_declarator %prec EMPTY
1819 /* This is necessary to postpone reduction of `int()()()()'. */
1821 LEFT_RIGHT %prec EMPTY
1822 { $$ = make_call_declarator (NULL_TREE, empty_parms (),
1823 NULL_TREE, NULL_TREE); }
1824 | fcast_or_absdcl LEFT_RIGHT %prec EMPTY
1825 { $$ = make_call_declarator ($$, empty_parms (), NULL_TREE,
1829 /* ANSI type-id (8.1) */
1831 typed_typespecs absdcl
1832 { $$.t = build_decl_list ($1.t, $2);
1833 $$.new_type_flag = $1.new_type_flag; }
1834 | nonempty_cv_qualifiers absdcl
1835 { $$.t = build_decl_list ($1.t, $2);
1836 $$.new_type_flag = $1.new_type_flag; }
1838 { $$.t = build_decl_list (get_decl_list ($1.t), $2);
1839 $$.new_type_flag = $1.new_type_flag; }
1840 | typed_typespecs %prec EMPTY
1841 { $$.t = build_decl_list ($1.t, NULL_TREE);
1842 $$.new_type_flag = $1.new_type_flag; }
1843 | nonempty_cv_qualifiers %prec EMPTY
1844 { $$.t = build_decl_list ($1.t, NULL_TREE);
1845 $$.new_type_flag = $1.new_type_flag; }
1848 /* Declspecs which contain at least one type specifier or typedef name.
1849 (Just `const' or `volatile' is not enough.)
1850 A typedef'd name following these is taken as a name to be declared.
1851 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1854 typed_typespecs %prec EMPTY
1860 { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1);
1861 $$.new_type_flag = $2.new_type_flag; }
1862 | typespec reserved_declspecs %prec HYPERUNARY
1863 { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2);
1864 $$.new_type_flag = $1.new_type_flag; }
1865 | typespec reserved_typespecquals reserved_declspecs
1866 { $$.t = decl_tree_cons (NULL_TREE, $1.t, chainon ($2, $3));
1867 $$.new_type_flag = $1.new_type_flag; }
1868 | declmods typespec reserved_declspecs
1869 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1));
1870 $$.new_type_flag = $2.new_type_flag; }
1871 | declmods typespec reserved_typespecquals
1872 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1));
1873 $$.new_type_flag = $2.new_type_flag; }
1874 | declmods typespec reserved_typespecquals reserved_declspecs
1875 { $$.t = decl_tree_cons (NULL_TREE, $2.t,
1876 chainon ($3, chainon ($4, $1)));
1877 $$.new_type_flag = $2.new_type_flag; }
1882 { if (extra_warnings)
1883 warning ("`%s' is not at beginning of declaration",
1884 IDENTIFIER_POINTER ($$));
1885 $$ = build_decl_list (NULL_TREE, $$); }
1886 | reserved_declspecs typespecqual_reserved
1887 { $$ = decl_tree_cons (NULL_TREE, $2.t, $$); }
1888 | reserved_declspecs SCSPEC
1889 { if (extra_warnings)
1890 warning ("`%s' is not at beginning of declaration",
1891 IDENTIFIER_POINTER ($2));
1892 $$ = decl_tree_cons (NULL_TREE, $2, $$); }
1893 | reserved_declspecs attributes
1894 { $$ = decl_tree_cons ($2, NULL_TREE, $1); }
1896 { $$ = decl_tree_cons ($1, NULL_TREE, NULL_TREE); }
1899 /* List of just storage classes and type modifiers.
1900 A declaration can start with just this, but then it cannot be used
1901 to redeclare a typedef-name.
1902 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1905 nonempty_cv_qualifiers %prec EMPTY
1906 { $$ = $1.t; TREE_STATIC ($$) = 1; }
1908 { $$ = IDENTIFIER_AS_LIST ($$); }
1909 | declmods CV_QUALIFIER
1910 { $$ = decl_tree_cons (NULL_TREE, $2, $$);
1911 TREE_STATIC ($$) = 1; }
1913 { if (extra_warnings && TREE_STATIC ($$))
1914 warning ("`%s' is not at beginning of declaration",
1915 IDENTIFIER_POINTER ($2));
1916 $$ = decl_tree_cons (NULL_TREE, $2, $$);
1917 TREE_STATIC ($$) = TREE_STATIC ($1); }
1918 | declmods attributes
1919 { $$ = decl_tree_cons ($2, NULL_TREE, $1); }
1921 { $$ = decl_tree_cons ($1, NULL_TREE, NULL_TREE); }
1924 /* Used instead of declspecs where storage classes are not allowed
1925 (that is, for typenames and structure components).
1927 C++ can takes storage classes for structure components.
1928 Don't accept a typedef-name if anything but a modifier precedes it. */
1931 typespec %prec EMPTY
1932 { $$.t = get_decl_list ($1.t);
1933 $$.new_type_flag = $1.new_type_flag; }
1934 | nonempty_cv_qualifiers typespec
1935 { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1.t);
1936 $$.new_type_flag = $2.new_type_flag; }
1937 | typespec reserved_typespecquals
1938 { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2);
1939 $$.new_type_flag = $1.new_type_flag; }
1940 | nonempty_cv_qualifiers typespec reserved_typespecquals
1941 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1942 $$.new_type_flag = $1.new_type_flag; }
1945 reserved_typespecquals:
1946 typespecqual_reserved
1947 { $$ = build_decl_list (NULL_TREE, $1.t); }
1948 | reserved_typespecquals typespecqual_reserved
1949 { $$ = decl_tree_cons (NULL_TREE, $2.t, $1); }
1952 /* A typespec (but not a type qualifier).
1953 Once we have seen one of these in a declaration,
1954 if a typedef name appears then it is being redeclared. */
1958 | TYPESPEC %prec EMPTY
1959 { $$.t = $1; $$.new_type_flag = 0; }
1960 | complete_type_name
1961 { $$.t = $1; $$.new_type_flag = 0; }
1962 | TYPEOF '(' expr ')'
1963 { $$.t = TREE_TYPE ($3);
1964 $$.new_type_flag = 0; }
1965 | TYPEOF '(' type_id ')'
1966 { $$.t = groktypename ($3.t);
1967 $$.new_type_flag = 0; }
1968 | SIGOF '(' expr ')'
1969 { tree type = TREE_TYPE ($3);
1971 $$.new_type_flag = 0;
1972 if (IS_AGGR_TYPE (type))
1974 sorry ("sigof type specifier");
1979 error ("`sigof' applied to non-aggregate expression");
1980 $$.t = error_mark_node;
1983 | SIGOF '(' type_id ')'
1984 { tree type = groktypename ($3.t);
1986 $$.new_type_flag = 0;
1987 if (IS_AGGR_TYPE (type))
1989 sorry ("sigof type specifier");
1994 error("`sigof' applied to non-aggregate type");
1995 $$.t = error_mark_node;
2000 /* A typespec that is a reserved word, or a type qualifier. */
2002 typespecqual_reserved:
2004 { $$.t = $1; $$.new_type_flag = 0; }
2006 { $$.t = $1; $$.new_type_flag = 0; }
2012 | initdecls ',' initdcl
2017 | notype_initdecls ',' initdcl
2022 | nomods_initdecls ',' initdcl
2028 | asm_keyword '(' string ')'
2029 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3); $$ = $3; }
2033 declarator maybeasm maybe_attribute '='
2034 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2035 &prefix_attributes);
2036 if (current_declspecs
2037 && TREE_CODE (current_declspecs) != TREE_LIST)
2038 current_declspecs = get_decl_list (current_declspecs);
2039 if (have_extern_spec && !used_extern_spec)
2041 current_declspecs = decl_tree_cons
2042 (NULL_TREE, get_identifier ("extern"),
2044 used_extern_spec = 1;
2046 $<itype>4 = suspend_momentary ();
2047 $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1);
2048 cplus_decl_attributes ($<ttype>$, $3, prefix_attributes); }
2050 /* Note how the declaration of the variable is in effect while its init is parsed! */
2051 { cp_finish_decl ($<ttype>5, $6, $2, 1, LOOKUP_ONLYCONVERTING);
2053 | declarator maybeasm maybe_attribute
2055 split_specs_attrs ($<ttype>0, ¤t_declspecs,
2056 &prefix_attributes);
2057 if (current_declspecs
2058 && TREE_CODE (current_declspecs) != TREE_LIST)
2059 current_declspecs = get_decl_list (current_declspecs);
2060 if (have_extern_spec && !used_extern_spec)
2062 current_declspecs = decl_tree_cons
2063 (NULL_TREE, get_identifier ("extern"),
2065 used_extern_spec = 1;
2067 $$ = suspend_momentary ();
2068 d = start_decl ($<ttype>1, current_declspecs, 0);
2069 cplus_decl_attributes (d, $3, prefix_attributes);
2070 cp_finish_decl (d, NULL_TREE, $2, 1, 0); }
2074 declarator maybeasm maybe_attribute '='
2075 { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1);
2076 cplus_decl_attributes ($<ttype>$, $3, prefix_attributes); }
2078 /* Note how the declaration of the variable is in effect while its init is parsed! */
2079 { cp_finish_decl ($<ttype>5, $6, $2, 1, LOOKUP_ONLYCONVERTING); }
2080 | declarator maybeasm maybe_attribute
2081 { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 0);
2082 cplus_decl_attributes ($<ttype>$, $3, prefix_attributes);
2083 cp_finish_decl ($<ttype>$, NULL_TREE, $2, 1, 0); }
2087 notype_declarator maybeasm maybe_attribute '='
2088 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2089 &prefix_attributes);
2090 $<itype>4 = suspend_momentary ();
2091 $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1);
2092 cplus_decl_attributes ($<ttype>$, $3, prefix_attributes); }
2094 /* Note how the declaration of the variable is in effect while its init is parsed! */
2095 { cp_finish_decl ($<ttype>5, $6, $2, 1, LOOKUP_ONLYCONVERTING);
2097 | notype_declarator maybeasm maybe_attribute
2099 split_specs_attrs ($<ttype>0, ¤t_declspecs,
2100 &prefix_attributes);
2101 $$ = suspend_momentary ();
2102 d = start_decl ($<ttype>1, current_declspecs, 0);
2103 cplus_decl_attributes (d, $3, prefix_attributes);
2104 cp_finish_decl (d, NULL_TREE, $2, 1, 0); }
2108 notype_declarator maybeasm maybe_attribute '='
2109 { current_declspecs = NULL_TREE;
2110 prefix_attributes = NULL_TREE;
2111 $<itype>4 = suspend_momentary ();
2112 $<ttype>$ = start_decl ($1, current_declspecs, 1);
2113 cplus_decl_attributes ($<ttype>$, $3, prefix_attributes); }
2115 /* Note how the declaration of the variable is in effect while its init is parsed! */
2116 { cp_finish_decl ($<ttype>5, $6, $2, 1, LOOKUP_ONLYCONVERTING);
2118 | notype_declarator maybeasm maybe_attribute
2120 current_declspecs = NULL_TREE;
2121 prefix_attributes = NULL_TREE;
2122 $$ = suspend_momentary ();
2123 d = start_decl ($1, current_declspecs, 0);
2124 cplus_decl_attributes (d, $3, prefix_attributes);
2125 cp_finish_decl (d, NULL_TREE, $2, 1, 0); }
2128 /* the * rules are dummies to accept the Apollo extended syntax
2129 so that the header files compile. */
2140 | attributes attribute
2141 { $$ = chainon ($1, $2); }
2145 ATTRIBUTE '(' '(' attribute_list ')' ')'
2152 | attribute_list ',' attrib
2153 { $$ = chainon ($1, $3); }
2160 { $$ = build_tree_list ($1, NULL_TREE); }
2161 | any_word '(' IDENTIFIER ')'
2162 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
2163 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
2164 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
2165 | any_word '(' nonnull_exprlist ')'
2166 { $$ = build_tree_list ($1, $3); }
2169 /* This still leaves out most reserved keywords,
2170 shouldn't we include them? */
2179 /* A nonempty list of identifiers, including typenames. */
2180 identifiers_or_typenames:
2182 { $$ = build_tree_list (NULL_TREE, $1); }
2183 | identifiers_or_typenames ',' identifier
2184 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2188 /* empty */ %prec EMPTY
2193 /* If we are processing a template, we don't want to expand this
2197 expr_no_commas %prec '='
2199 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, NULL_TREE);
2200 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2202 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2203 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2204 | '{' initlist ',' '}'
2205 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2206 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2211 /* This chain is built in reverse order,
2212 and put in forward order where initlist is used. */
2215 { $$ = build_tree_list (NULL_TREE, $$); }
2217 { $$ = expr_tree_cons (NULL_TREE, $3, $$); }
2218 /* These are for labeled elements. */
2219 | '[' expr_no_commas ']' init
2220 { $$ = build_expr_list ($2, $4); }
2221 | initlist ',' CASE expr_no_commas ':' init
2222 { $$ = expr_tree_cons ($4, $6, $$); }
2223 | identifier ':' init
2224 { $$ = build_expr_list ($$, $3); }
2225 | initlist ',' identifier ':' init
2226 { $$ = expr_tree_cons ($3, $5, $$); }
2230 PRE_PARSED_FUNCTION_DECL
2231 { start_function (NULL_TREE, TREE_VALUE ($1),
2233 reinit_parse_for_function (); }
2236 fn.defpen maybe_return_init ctor_initializer_opt compstmt_or_error
2238 int nested = (hack_decl_function_context
2239 (current_function_decl) != NULL_TREE);
2240 finish_function (lineno, (int)$3, nested);
2241 process_next_inline ($1);
2243 | fn.defpen maybe_return_init function_try_block
2244 { process_next_inline ($1); }
2245 | fn.defpen maybe_return_init error
2246 { process_next_inline ($1); }
2251 | pending_inlines pending_inline eat_saved_input
2254 /* A regurgitated default argument. The value of DEFARG_MARKER will be
2255 the TREE_LIST node for the parameter in question. */
2257 DEFARG_MARKER expr_no_commas END_OF_SAVED_INPUT
2258 { replace_defarg ($1, $2); }
2259 | DEFARG_MARKER error END_OF_SAVED_INPUT
2260 { replace_defarg ($1, error_mark_node); }
2263 /* empty */ %prec EMPTY
2264 | pending_defargs defarg_again
2265 { do_pending_defargs (); }
2266 | pending_defargs error
2267 { do_pending_defargs (); }
2272 { $<itype>3 = suspend_momentary ();
2273 $<ttype>$ = start_enum ($2); }
2274 enumlist maybecomma_warn '}'
2275 { $$.t = finish_enum ($<ttype>4, $5);
2276 $$.new_type_flag = 1;
2277 resume_momentary ((int) $<itype>3);
2278 check_for_missing_semicolon ($<ttype>4); }
2279 | ENUM identifier '{' '}'
2280 { $$.t = finish_enum (start_enum ($2), NULL_TREE);
2281 $$.new_type_flag = 1;
2282 check_for_missing_semicolon ($$.t); }
2284 { $<itype>2 = suspend_momentary ();
2285 $<ttype>$ = start_enum (make_anon_name ()); }
2286 enumlist maybecomma_warn '}'
2287 { $$.t = finish_enum ($<ttype>3, $4);
2288 resume_momentary ((int) $<itype>1);
2289 check_for_missing_semicolon ($<ttype>3);
2290 $$.new_type_flag = 1; }
2292 { $$.t = finish_enum (start_enum (make_anon_name()), NULL_TREE);
2293 $$.new_type_flag = 1;
2294 check_for_missing_semicolon ($$.t); }
2296 { $$.t = xref_tag (enum_type_node, $2, NULL_TREE, 1);
2297 $$.new_type_flag = 0; }
2298 | ENUM complex_type_name
2299 { $$.t = xref_tag (enum_type_node, $2, NULL_TREE, 1);
2300 $$.new_type_flag = 0; }
2301 | TYPENAME_KEYWORD typename_sub
2303 $$.new_type_flag = 0; }
2304 /* C++ extensions, merged with C to avoid shift/reduce conflicts */
2305 | class_head left_curly
2306 opt.component_decl_list '}' maybe_attribute
2313 /* Need to rework class nesting in the
2314 presence of nested classes, etc. */
2315 shadow_tag (CLASSTYPE_AS_LIST ($1)); */
2317 if (yychar == YYEMPTY)
2319 semi = yychar == ';';
2320 /* finish_struct nukes this anyway; if
2321 finish_exception does too, then it can go. */
2323 note_got_semicolon ($1);
2325 if (TREE_CODE ($1) == ENUMERAL_TYPE)
2329 $<ttype>$ = finish_struct ($1, $3, $5, semi);
2330 if (semi) note_got_semicolon ($<ttype>$);
2336 check_for_missing_semicolon ($1);
2337 if (current_scope () == current_function_decl)
2338 do_pending_defargs ();
2343 && current_scope () == current_function_decl)
2344 do_pending_inlines ();
2349 $$.new_type_flag = 1;
2350 if (current_class_type == NULL_TREE)
2351 clear_inline_text_obstack ();
2353 /* Undo the begin_tree in left_curly. */
2356 | class_head %prec EMPTY
2358 $$.new_type_flag = 0;
2359 if (TYPE_BINFO ($1) == NULL_TREE)
2361 cp_error ("%T is not a class type", $1);
2362 $$.t = error_mark_node;
2367 /* struct B: public A; is not accepted by the WP grammar. */
2368 if (TYPE_BINFO_BASETYPES ($$.t) && !TYPE_SIZE ($$.t)
2369 && ! TYPE_BEING_DEFINED ($$.t))
2370 cp_error ("base clause without member specification for `%#T'",
2384 { if (pedantic && !in_system_header)
2385 pedwarn ("comma at end of enumerator list"); }
2391 { error ("storage class specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2393 { error ("type specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2395 { error ("type qualifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2397 { error ("no body nor ';' separates two class, struct or union declarations"); }
2400 named_class_head_sans_basetype:
2402 { current_aggr = $$; $$ = $2; }
2405 named_class_head_sans_basetype_defn:
2406 aggr identifier_defn %prec EMPTY
2407 { current_aggr = $$; $$ = $2; }
2410 named_complex_class_head_sans_basetype:
2411 aggr nested_name_specifier identifier
2414 $$ = handle_class_head ($1, $2, $3);
2416 | aggr global_scope nested_name_specifier identifier
2419 $$ = handle_class_head ($1, $3, $4);
2421 | aggr global_scope identifier
2424 $$ = handle_class_head ($1, NULL_TREE, $3);
2426 | aggr template_type
2427 { current_aggr = $$; $$ = $2; }
2428 | aggr nested_name_specifier template_type
2429 { current_aggr = $$; $$ = $3; }
2433 /* empty */ %prec EMPTY
2434 { $<ttype>$ = xref_tag (current_aggr, $<ttype>0, NULL_TREE, 0); }
2438 named_class_head_sans_basetype %prec EMPTY
2439 { $$ = xref_tag (current_aggr, $1, NULL_TREE, 1); }
2440 | named_class_head_sans_basetype_defn do_xref_defn
2441 maybe_base_class_list %prec EMPTY
2445 xref_basetypes (current_aggr, $1, $<ttype>2, $3);
2447 | named_complex_class_head_sans_basetype maybe_base_class_list
2449 $$ = TREE_TYPE ($1);
2450 if (TREE_INT_CST_LOW (current_aggr) == union_type
2451 && TREE_CODE ($$) != UNION_TYPE)
2452 cp_pedwarn ("`union' tag used in declaring `%#T'", $$);
2453 else if (TREE_CODE ($$) == UNION_TYPE
2454 && TREE_INT_CST_LOW (current_aggr) != union_type)
2455 cp_pedwarn ("non-`union' tag used in declaring `%#T'", $$);
2458 if (IS_AGGR_TYPE ($$) && CLASSTYPE_USE_TEMPLATE ($$))
2460 if (CLASSTYPE_IMPLICIT_INSTANTIATION ($$)
2461 && TYPE_SIZE ($$) == NULL_TREE)
2463 SET_CLASSTYPE_TEMPLATE_SPECIALIZATION ($$);
2464 if (processing_template_decl)
2465 push_template_decl (TYPE_MAIN_DECL ($$));
2467 else if (CLASSTYPE_TEMPLATE_INSTANTIATION ($$))
2468 cp_error ("specialization after instantiation of `%T'", $$);
2470 xref_basetypes (current_aggr, $1, $$, $2);
2477 { $$ = xref_tag ($$, make_anon_name (), NULL_TREE, 0);
2478 yyungetc ('{', 1); }
2486 maybe_base_class_list:
2487 /* empty */ %prec EMPTY
2489 | ':' see_typename %prec EMPTY
2490 { yyungetc(':', 1); $$ = NULL_TREE; }
2491 | ':' see_typename base_class_list %prec EMPTY
2497 | base_class_list ',' see_typename base_class
2498 { $$ = chainon ($$, $4); }
2504 tree type = TREE_TYPE ($1);
2505 if (! is_aggr_type (type, 1))
2507 else if (current_aggr == signature_type_node
2508 && (! type) && (! IS_SIGNATURE (type)))
2510 error ("class name not allowed as base signature");
2513 else if (current_aggr == signature_type_node)
2515 sorry ("signature inheritance, base type `%s' ignored",
2516 IDENTIFIER_POINTER ($$));
2517 $$ = build_tree_list (access_public_node, type);
2519 else if (type && IS_SIGNATURE (type))
2521 error ("signature name not allowed as base class");
2525 $$ = build_tree_list (access_default_node, type);
2527 | base_class_access_list see_typename base_class.1
2529 tree type = TREE_TYPE ($3);
2530 if (current_aggr == signature_type_node)
2531 error ("access and source specifiers not allowed in signature");
2532 if (! IS_AGGR_TYPE (type))
2534 else if (current_aggr == signature_type_node
2535 && (! type) && (! IS_SIGNATURE (type)))
2537 error ("class name not allowed as base signature");
2540 else if (current_aggr == signature_type_node)
2542 sorry ("signature inheritance, base type `%s' ignored",
2543 IDENTIFIER_POINTER ($$));
2544 $$ = build_tree_list (access_public_node, type);
2546 else if (type && IS_SIGNATURE (type))
2548 error ("signature name not allowed as base class");
2552 $$ = build_tree_list ($$, type);
2558 { $$ = TYPE_MAIN_DECL ($1); }
2560 | SIGOF '(' expr ')'
2562 if (current_aggr == signature_type_node)
2564 if (IS_AGGR_TYPE (TREE_TYPE ($3)))
2566 sorry ("`sigof' as base signature specifier");
2567 $$ = TREE_TYPE ($3);
2571 error ("`sigof' applied to non-aggregate expression");
2572 $$ = error_mark_node;
2577 error ("`sigof' in struct or class declaration");
2578 $$ = error_mark_node;
2581 | SIGOF '(' type_id ')'
2583 if (current_aggr == signature_type_node)
2585 if (IS_AGGR_TYPE (groktypename ($3.t)))
2587 sorry ("`sigof' as base signature specifier");
2588 $$ = groktypename ($3.t);
2592 error ("`sigof' applied to non-aggregate expression");
2593 $$ = error_mark_node;
2598 error ("`sigof' in struct or class declaration");
2599 $$ = error_mark_node;
2604 base_class_access_list:
2605 VISSPEC see_typename
2606 | SCSPEC see_typename
2607 { if ($<ttype>$ != ridpointers[(int)RID_VIRTUAL])
2608 sorry ("non-virtual access");
2609 $$ = access_default_virtual_node; }
2610 | base_class_access_list VISSPEC see_typename
2612 if ($2 == access_protected_node)
2614 warning ("`protected' access not implemented");
2615 $2 = access_public_node;
2618 else if ($2 == access_public_node)
2620 if ($1 == access_private_node)
2623 error ("base class cannot be public and private");
2625 else if ($1 == access_default_virtual_node)
2626 $$ = access_public_virtual_node;
2628 else /* $2 == access_private_node */
2630 if ($1 == access_public_node)
2632 else if ($1 == access_default_virtual_node)
2633 $$ = access_private_virtual_node;
2636 | base_class_access_list SCSPEC see_typename
2637 { if ($2 != ridpointers[(int)RID_VIRTUAL])
2638 sorry ("non-virtual access");
2639 if ($$ == access_public_node)
2640 $$ = access_public_virtual_node;
2641 else if ($$ == access_private_node)
2642 $$ = access_private_virtual_node; }
2647 { tree t = $<ttype>0;
2648 push_obstacks_nochange ();
2649 end_temporary_allocation ();
2651 if (t == error_mark_node
2652 || ! IS_AGGR_TYPE (t))
2654 t = $<ttype>0 = make_lang_type (RECORD_TYPE);
2655 pushtag (make_anon_name (), t, 0);
2658 duplicate_tag_error (t);
2659 if (TYPE_SIZE (t) || TYPE_BEING_DEFINED (t))
2661 t = make_lang_type (TREE_CODE (t));
2662 pushtag (TYPE_IDENTIFIER ($<ttype>0), t, 0);
2665 if (processing_template_decl && TYPE_CONTEXT (t)
2666 && ! current_class_type)
2667 push_template_decl (TYPE_STUB_DECL (t));
2669 TYPE_BEING_DEFINED (t) = 1;
2670 if (IS_AGGR_TYPE (t) && CLASSTYPE_USE_TEMPLATE (t))
2672 if (CLASSTYPE_IMPLICIT_INSTANTIATION (t)
2673 && TYPE_SIZE (t) == NULL_TREE)
2675 SET_CLASSTYPE_TEMPLATE_SPECIALIZATION (t);
2676 if (processing_template_decl)
2677 push_template_decl (TYPE_MAIN_DECL (t));
2679 else if (CLASSTYPE_TEMPLATE_INSTANTIATION (t))
2680 cp_error ("specialization after instantiation of `%T'", t);
2682 /* Reset the interface data, at the earliest possible
2683 moment, as it might have been set via a class foo;
2685 /* Don't change signatures. */
2686 if (! IS_SIGNATURE (t))
2688 extern tree pending_vtables;
2690 tree name = TYPE_IDENTIFIER (t);
2692 if (! ANON_AGGRNAME_P (name))
2694 CLASSTYPE_INTERFACE_ONLY (t) = interface_only;
2695 SET_CLASSTYPE_INTERFACE_UNKNOWN_X
2696 (t, interface_unknown);
2699 /* Record how to set the access of this class's
2700 virtual functions. If write_virtuals == 2 or 3, then
2701 inline virtuals are ``extern inline''. */
2702 switch (write_virtuals)
2709 needs_writing = !! value_member (name, pending_vtables);
2712 needs_writing = ! CLASSTYPE_INTERFACE_ONLY (t)
2713 && CLASSTYPE_INTERFACE_KNOWN (t);
2718 CLASSTYPE_VTABLE_NEEDS_WRITING (t) = needs_writing;
2721 t = TYPE_IDENTIFIER ($<ttype>0);
2722 if (t && IDENTIFIER_TEMPLATE (t))
2723 overload_template_name (t, 1);
2725 reset_specialization();
2727 /* In case this is a local class within a template
2728 function, we save the current tree structure so
2729 that we can get it back later. */
2737 $$ = build_self_reference ();
2741 opt.component_decl_list:
2743 { if ($$) $$ = build_tree_list (access_public_node, $$); }
2744 | self_reference component_decl_list
2746 if (current_aggr == signature_type_node)
2747 $$ = build_tree_list (access_public_node, $2);
2749 $$ = build_tree_list (access_default_node, $2);
2750 if ($1) $$ = tree_cons (access_public_node, $1, $$);
2752 | opt.component_decl_list VISSPEC ':' component_decl_list
2756 if (current_aggr == signature_type_node)
2758 error ("access specifier not allowed in signature");
2759 visspec = access_public_node;
2761 $$ = chainon ($$, build_tree_list (visspec, $4));
2763 | opt.component_decl_list VISSPEC ':'
2765 if (current_aggr == signature_type_node)
2766 error ("access specifier not allowed in signature");
2770 /* Note: we no longer warn about the semicolon after a component_decl_list.
2771 ARM $9.2 says that the semicolon is optional, and therefore allowed. */
2772 component_decl_list:
2774 { if ($$ == void_type_node) $$ = NULL_TREE;
2776 | component_decl_list component_decl
2777 { /* In pushdecl, we created a reverse list of names
2778 in this binding level. Make sure that the chain
2779 of what we're trying to add isn't the item itself
2780 (which can happen with what pushdecl's doing). */
2781 if ($2 != NULL_TREE && $2 != void_type_node)
2783 if (TREE_CHAIN ($2) != $$)
2784 $$ = chainon ($$, $2);
2792 component_decl_1 ';'
2794 | component_decl_1 '}'
2795 { error ("missing ';' before right brace");
2796 yyungetc ('}', 0); }
2797 /* C++: handle constructors, destructors and inline functions */
2798 /* note that INLINE is like a TYPESPEC */
2799 | fn.def2 ':' /* base_init compstmt */
2800 { $$ = finish_method ($$); }
2801 | fn.def2 TRY /* base_init compstmt */
2802 { $$ = finish_method ($$); }
2803 | fn.def2 RETURN /* base_init compstmt */
2804 { $$ = finish_method ($$); }
2805 | fn.def2 '{' /* nodecls compstmt */
2806 { $$ = finish_method ($$); }
2809 | extension component_decl
2811 pedantic = $<itype>1; }
2815 /* Do not add a "typed_declspecs declarator" rule here for
2816 speed; we need to call grok_x_components for enums, so the
2817 speedup would be insignificant. */
2818 typed_declspecs components
2819 { $$ = grok_x_components ($1.t, $2); }
2820 | declmods notype_components
2821 { $$ = grok_x_components ($1, $2); }
2822 | notype_declarator maybeasm maybe_attribute maybe_init
2823 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2824 build_tree_list ($3, NULL_TREE)); }
2825 | constructor_declarator maybeasm maybe_attribute maybe_init
2826 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2827 build_tree_list ($3, NULL_TREE)); }
2828 | ':' expr_no_commas
2829 { $$ = grokbitfield (NULL_TREE, NULL_TREE, $2); }
2833 /* These rules introduce a reduce/reduce conflict; in
2834 typedef int foo, bar;
2838 should "A::foo" be declared as a function or "A::bar" as a data
2839 member? In other words, is "bar" an after_type_declarator or a
2841 | declmods component_constructor_declarator maybeasm maybe_attribute maybe_init
2842 { tree specs, attrs;
2843 split_specs_attrs ($1, &specs, &attrs);
2844 $$ = grokfield ($2, specs, $5, $3,
2845 build_tree_list ($4, attrs)); }
2846 | component_constructor_declarator maybeasm maybe_attribute maybe_init
2847 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2848 build_tree_list ($3, NULL_TREE)); }
2850 { $$ = do_class_using_decl ($1); }
2851 | template_header component_decl_1
2852 { $$ = finish_member_template_decl ($1, $2); }
2854 /* The case of exactly one component is handled directly by component_decl. */
2857 /* empty: possibly anonymous */
2859 | component_declarator0
2860 | components ',' component_declarator
2862 /* In this context, void_type_node encodes
2863 friends. They have been recorded elsewhere. */
2864 if ($$ == void_type_node)
2867 $$ = chainon ($$, $3);
2872 /* empty: possibly anonymous */
2874 | notype_component_declarator0
2875 | notype_components ',' notype_component_declarator
2877 /* In this context, void_type_node encodes
2878 friends. They have been recorded elsewhere. */
2879 if ($$ == void_type_node)
2882 $$ = chainon ($$, $3);
2886 component_declarator0:
2887 after_type_component_declarator0
2888 | notype_component_declarator0
2891 component_declarator:
2892 after_type_component_declarator
2893 | notype_component_declarator
2896 after_type_component_declarator0:
2897 after_type_declarator maybeasm maybe_attribute maybe_init
2898 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2899 &prefix_attributes);
2900 $<ttype>0 = current_declspecs;
2901 $$ = grokfield ($$, current_declspecs, $4, $2,
2902 build_tree_list ($3, prefix_attributes)); }
2903 | TYPENAME ':' expr_no_commas maybe_attribute
2904 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2905 &prefix_attributes);
2906 $<ttype>0 = current_declspecs;
2907 $$ = grokbitfield ($$, current_declspecs, $3);
2908 cplus_decl_attributes ($$, $4, prefix_attributes); }
2911 notype_component_declarator0:
2912 notype_declarator maybeasm maybe_attribute maybe_init
2913 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2914 &prefix_attributes);
2915 $<ttype>0 = current_declspecs;
2916 $$ = grokfield ($$, current_declspecs, $4, $2,
2917 build_tree_list ($3, prefix_attributes)); }
2918 | constructor_declarator maybeasm maybe_attribute maybe_init
2919 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2920 &prefix_attributes);
2921 $<ttype>0 = current_declspecs;
2922 $$ = grokfield ($$, current_declspecs, $4, $2,
2923 build_tree_list ($3, prefix_attributes)); }
2924 | IDENTIFIER ':' expr_no_commas maybe_attribute
2925 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2926 &prefix_attributes);
2927 $<ttype>0 = current_declspecs;
2928 $$ = grokbitfield ($$, current_declspecs, $3);
2929 cplus_decl_attributes ($$, $4, prefix_attributes); }
2930 | ':' expr_no_commas maybe_attribute
2931 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2932 &prefix_attributes);
2933 $<ttype>0 = current_declspecs;
2934 $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
2935 cplus_decl_attributes ($$, $3, prefix_attributes); }
2938 after_type_component_declarator:
2939 after_type_declarator maybeasm maybe_attribute maybe_init
2940 { $$ = grokfield ($$, current_declspecs, $4, $2,
2941 build_tree_list ($3, prefix_attributes)); }
2942 | TYPENAME ':' expr_no_commas maybe_attribute
2943 { $$ = grokbitfield ($$, current_declspecs, $3);
2944 cplus_decl_attributes ($$, $4, prefix_attributes); }
2947 notype_component_declarator:
2948 notype_declarator maybeasm maybe_attribute maybe_init
2949 { $$ = grokfield ($$, current_declspecs, $4, $2,
2950 build_tree_list ($3, prefix_attributes)); }
2951 | IDENTIFIER ':' expr_no_commas maybe_attribute
2952 { $$ = grokbitfield ($$, current_declspecs, $3);
2953 cplus_decl_attributes ($$, $4, prefix_attributes); }
2954 | ':' expr_no_commas maybe_attribute
2955 { $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
2956 cplus_decl_attributes ($$, $3, prefix_attributes); }
2959 /* We chain the enumerators in reverse order.
2960 Because of the way enums are built, the order is
2961 insignificant. Take advantage of this fact. */
2965 | enumlist ',' enumerator
2966 { TREE_CHAIN ($3) = $$; $$ = $3; }
2971 { $$ = build_enumerator ($$, NULL_TREE); }
2972 | identifier '=' expr_no_commas
2973 { $$ = build_enumerator ($$, $3); }
2976 /* ANSI new-type-id (5.3.4) */
2978 type_specifier_seq new_declarator
2979 { $$.t = build_decl_list ($1.t, $2);
2980 $$.new_type_flag = $1.new_type_flag; }
2981 | type_specifier_seq %prec EMPTY
2982 { $$.t = build_decl_list ($1.t, NULL_TREE);
2983 $$.new_type_flag = $1.new_type_flag; }
2984 /* GNU extension to allow arrays of arbitrary types with
2985 non-constant dimension. */
2986 | '(' type_id ')' '[' expr ']'
2989 pedwarn ("ANSI C++ forbids array dimensions with parenthesized type in new");
2990 $$.t = build_parse_node (ARRAY_REF, TREE_VALUE ($2.t), $5);
2991 $$.t = build_decl_list (TREE_PURPOSE ($2.t), $$.t);
2992 $$.new_type_flag = $2.new_type_flag;
2997 /* empty */ %prec EMPTY
2999 | cv_qualifiers CV_QUALIFIER
3000 { $$ = decl_tree_cons (NULL_TREE, $2, $$); }
3003 nonempty_cv_qualifiers:
3005 { $$.t = IDENTIFIER_AS_LIST ($1);
3006 $$.new_type_flag = 0; }
3007 | nonempty_cv_qualifiers CV_QUALIFIER
3008 { $$.t = decl_tree_cons (NULL_TREE, $2, $1.t);
3009 $$.new_type_flag = $1.new_type_flag; }
3012 /* These rules must follow the rules for function declarations
3013 and component declarations. That way, longer rules are preferred. */
3017 { $<itype>$ = suspend_momentary (); }
3019 /* An expression which will not live on the momentary obstack. */
3022 { resume_momentary ((int) $<itype>1); $$ = $2; }
3025 /* An expression which will not live on the momentary obstack. */
3027 suspend_mom '(' nonnull_exprlist ')'
3028 { resume_momentary ((int) $<itype>1); $$ = $3; }
3029 | suspend_mom '(' parmlist ')'
3030 { resume_momentary ((int) $<itype>1); $$ = $3; }
3031 | suspend_mom LEFT_RIGHT
3032 { resume_momentary ((int) $<itype>1); $$ = empty_parms (); }
3033 | suspend_mom '(' error ')'
3034 { resume_momentary ((int) $<itype>1); $$ = NULL_TREE; }
3037 /* A declarator that is allowed only after an explicit typespec. */
3038 /* may all be followed by prec '.' */
3039 after_type_declarator:
3040 '*' nonempty_cv_qualifiers after_type_declarator %prec UNARY
3041 { $$ = make_pointer_declarator ($2.t, $3); }
3042 | '&' nonempty_cv_qualifiers after_type_declarator %prec UNARY
3043 { $$ = make_reference_declarator ($2.t, $3); }
3044 | '*' after_type_declarator %prec UNARY
3045 { $$ = make_pointer_declarator (NULL_TREE, $2); }
3046 | '&' after_type_declarator %prec UNARY
3047 { $$ = make_reference_declarator (NULL_TREE, $2); }
3048 | ptr_to_mem cv_qualifiers after_type_declarator
3049 { tree arg = make_pointer_declarator ($2, $3);
3050 $$ = build_parse_node (SCOPE_REF, $1, arg);
3052 | direct_after_type_declarator
3056 type_name %prec EMPTY
3058 if (TREE_CODE ($1) == IDENTIFIER_NODE)
3060 arg_looking_for_template = processing_template_arg;
3061 $$ = lookup_name ($1, 1);
3062 arg_looking_for_template = 0;
3064 if (current_class_type
3065 && TYPE_BEING_DEFINED (current_class_type)
3066 && ! IDENTIFIER_CLASS_VALUE ($1))
3068 /* Remember that this name has been used in the class
3069 definition, as per [class.scope0] */
3070 pushdecl_class_level ($$);
3076 | global_scope type_name
3078 if (TREE_CODE ($2) == IDENTIFIER_NODE)
3079 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
3082 got_scope = NULL_TREE;
3089 | global_scope nested_type
3094 nested_name_specifier type_name %prec EMPTY
3095 { $$ = get_type_decl ($2); }
3098 direct_after_type_declarator:
3099 direct_after_type_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
3100 { $$ = make_call_declarator ($$, $2, $3, $4); }
3101 | direct_after_type_declarator '[' nonmomentary_expr ']'
3102 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3103 | direct_after_type_declarator '[' ']'
3104 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
3105 | '(' after_type_declarator ')'
3107 | nested_name_specifier type_name %prec EMPTY
3108 { push_nested_class ($1, 3);
3109 $$ = build_parse_node (SCOPE_REF, $$, $2);
3110 TREE_COMPLEXITY ($$) = current_class_depth; }
3111 | type_name %prec EMPTY
3114 /* A declarator allowed whether or not there has been
3115 an explicit typespec. These cannot redeclare a typedef-name. */
3118 '*' nonempty_cv_qualifiers notype_declarator %prec UNARY
3119 { $$ = make_pointer_declarator ($2.t, $3); }
3120 | '&' nonempty_cv_qualifiers notype_declarator %prec UNARY
3121 { $$ = make_reference_declarator ($2.t, $3); }
3122 | '*' notype_declarator %prec UNARY
3123 { $$ = make_pointer_declarator (NULL_TREE, $2); }
3124 | '&' notype_declarator %prec UNARY
3125 { $$ = make_reference_declarator (NULL_TREE, $2); }
3126 | ptr_to_mem cv_qualifiers notype_declarator
3127 { tree arg = make_pointer_declarator ($2, $3);
3128 $$ = build_parse_node (SCOPE_REF, $1, arg);
3130 | direct_notype_declarator
3133 complex_notype_declarator:
3134 '*' nonempty_cv_qualifiers notype_declarator %prec UNARY
3135 { $$ = make_pointer_declarator ($2.t, $3); }
3136 | '&' nonempty_cv_qualifiers notype_declarator %prec UNARY
3137 { $$ = make_reference_declarator ($2.t, $3); }
3138 | '*' complex_notype_declarator %prec UNARY
3139 { $$ = make_pointer_declarator (NULL_TREE, $2); }
3140 | '&' complex_notype_declarator %prec UNARY
3141 { $$ = make_reference_declarator (NULL_TREE, $2); }
3142 | ptr_to_mem cv_qualifiers notype_declarator
3143 { tree arg = make_pointer_declarator ($2, $3);
3144 $$ = build_parse_node (SCOPE_REF, $1, arg);
3146 | complex_direct_notype_declarator
3149 complex_direct_notype_declarator:
3150 direct_notype_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
3151 { $$ = make_call_declarator ($$, $2, $3, $4); }
3152 | '(' complex_notype_declarator ')'
3154 | direct_notype_declarator '[' nonmomentary_expr ']'
3155 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3156 | direct_notype_declarator '[' ']'
3157 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
3158 | notype_qualified_id
3159 { if (OP0 ($$) != current_class_type)
3161 push_nested_class (OP0 ($$), 3);
3162 TREE_COMPLEXITY ($$) = current_class_depth;
3165 | nested_name_specifier notype_template_declarator
3166 { got_scope = NULL_TREE;
3167 $$ = build_parse_node (SCOPE_REF, $1, $2);
3168 if ($1 != current_class_type)
3170 push_nested_class ($1, 3);
3171 TREE_COMPLEXITY ($$) = current_class_depth;
3177 nested_name_specifier unqualified_id
3178 { got_scope = NULL_TREE;
3179 $$ = build_parse_node (SCOPE_REF, $$, $2); }
3180 | nested_name_specifier object_template_id
3181 { got_scope = NULL_TREE;
3182 $$ = build_parse_node (SCOPE_REF, $1, $2); }
3185 notype_qualified_id:
3186 nested_name_specifier notype_unqualified_id
3187 { got_scope = NULL_TREE;
3188 $$ = build_parse_node (SCOPE_REF, $$, $2); }
3189 | nested_name_specifier object_template_id
3190 { got_scope = NULL_TREE;
3191 $$ = build_parse_node (SCOPE_REF, $1, $2); }
3196 | global_scope notype_qualified_id
3201 typespec '(' nonnull_exprlist ')'
3202 { $$ = build_functional_cast ($1.t, $3); }
3203 | typespec '(' expr_or_declarator ')'
3204 { $$ = reparse_decl_as_expr ($1.t, $3); }
3205 | typespec fcast_or_absdcl %prec EMPTY
3206 { $$ = reparse_absdcl_as_expr ($1.t, $2); }
3212 | template_type %prec EMPTY
3215 nested_name_specifier:
3216 nested_name_specifier_1
3217 | nested_name_specifier nested_name_specifier_1
3221 /* Why the @#$%^& do type_name and notype_identifier need to be expanded
3222 inline here?!? (jason) */
3223 nested_name_specifier_1:
3226 if (TREE_CODE ($1) == IDENTIFIER_NODE)
3229 /* Remember that this name has been used in the class
3230 definition, as per [class.scope0] */
3231 if (current_class_type
3232 && TYPE_BEING_DEFINED (current_class_type)
3233 && ! IDENTIFIER_CLASS_VALUE ($1))
3234 pushdecl_class_level ($$);
3236 got_scope = $$ = TREE_TYPE ($$);
3240 if (TREE_CODE ($1) == IDENTIFIER_NODE)
3242 got_scope = $$ = TREE_TYPE ($$);
3246 if (TREE_CODE ($$) == IDENTIFIER_NODE)
3250 | template_type SCOPE
3251 { got_scope = $$ = complete_type (TREE_TYPE ($1)); }
3252 /* These break 'const i;'
3256 cp_error ("`%D' is not an aggregate typedef",
3257 lastiddecl ? lastiddecl : $$);
3258 $$ = error_mark_node;
3261 { goto failed_scope; } */
3266 | global_scope typename_sub0
3271 typename_sub1 identifier
3273 if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't')
3274 $$ = make_typename_type ($1, $2);
3275 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
3276 cp_error ("`%T' is not a class or namespace", $2);
3280 if (TREE_CODE ($$) == TYPE_DECL)
3281 $$ = TREE_TYPE ($$);
3289 if (TREE_CODE ($1) == IDENTIFIER_NODE)
3290 cp_error ("`%T' is not a class or namespace", $1);
3292 | typename_sub1 typename_sub2
3294 if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't')
3295 $$ = make_typename_type ($1, $2);
3296 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
3297 cp_error ("`%T' is not a class or namespace", $2);
3301 if (TREE_CODE ($$) == TYPE_DECL)
3302 $$ = TREE_TYPE ($$);
3310 if (TREE_CODE ($1) != IDENTIFIER_NODE)
3312 got_scope = $$ = complete_type (TREE_TYPE ($$));
3316 if (TREE_CODE ($1) != IDENTIFIER_NODE)
3318 got_scope = $$ = complete_type (TREE_TYPE ($$));
3320 | template_type SCOPE
3321 { got_scope = $$ = complete_type (TREE_TYPE ($$)); }
3326 if (TREE_CODE ($$) == IDENTIFIER_NODE)
3333 global_scope type_name
3335 if (TREE_CODE ($2) == IDENTIFIER_NODE)
3336 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
3339 got_scope = NULL_TREE;
3342 | global_scope nested_type
3347 nested_name_specifier '*'
3348 { got_scope = NULL_TREE; }
3349 | global_scope nested_name_specifier '*'
3350 { $$ = $2; got_scope = NULL_TREE; }
3353 /* All uses of explicit global scope must go through this nonterminal so
3354 that got_scope will be set before yylex is called to get the next token. */
3357 { got_scope = void_type_node; }
3360 /* ANSI new-declarator (5.3.4) */
3362 '*' cv_qualifiers new_declarator
3363 { $$ = make_pointer_declarator ($2, $3); }
3364 | '*' cv_qualifiers %prec EMPTY
3365 { $$ = make_pointer_declarator ($2, NULL_TREE); }
3366 | '&' cv_qualifiers new_declarator %prec EMPTY
3367 { $$ = make_reference_declarator ($2, $3); }
3368 | '&' cv_qualifiers %prec EMPTY
3369 { $$ = make_reference_declarator ($2, NULL_TREE); }
3370 | ptr_to_mem cv_qualifiers %prec EMPTY
3371 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3372 $$ = build_parse_node (SCOPE_REF, $1, arg);
3374 | ptr_to_mem cv_qualifiers new_declarator
3375 { tree arg = make_pointer_declarator ($2, $3);
3376 $$ = build_parse_node (SCOPE_REF, $1, arg);
3378 | direct_new_declarator %prec EMPTY
3381 /* ANSI direct-new-declarator (5.3.4) */
3382 direct_new_declarator:
3384 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3385 | direct_new_declarator '[' nonmomentary_expr ']'
3386 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3389 /* ANSI abstract-declarator (8.1) */
3391 '*' nonempty_cv_qualifiers absdcl
3392 { $$ = make_pointer_declarator ($2.t, $3); }
3394 { $$ = make_pointer_declarator (NULL_TREE, $2); }
3395 | '*' nonempty_cv_qualifiers %prec EMPTY
3396 { $$ = make_pointer_declarator ($2.t, NULL_TREE); }
3398 { $$ = make_pointer_declarator (NULL_TREE, NULL_TREE); }
3399 | '&' nonempty_cv_qualifiers absdcl
3400 { $$ = make_reference_declarator ($2.t, $3); }
3402 { $$ = make_reference_declarator (NULL_TREE, $2); }
3403 | '&' nonempty_cv_qualifiers %prec EMPTY
3404 { $$ = make_reference_declarator ($2.t, NULL_TREE); }
3406 { $$ = make_reference_declarator (NULL_TREE, NULL_TREE); }
3407 | ptr_to_mem cv_qualifiers %prec EMPTY
3408 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3409 $$ = build_parse_node (SCOPE_REF, $1, arg);
3411 | ptr_to_mem cv_qualifiers absdcl
3412 { tree arg = make_pointer_declarator ($2, $3);
3413 $$ = build_parse_node (SCOPE_REF, $1, arg);
3415 | direct_abstract_declarator %prec EMPTY
3418 /* ANSI direct-abstract-declarator (8.1) */
3419 direct_abstract_declarator:
3422 /* `(typedef)1' is `int'. */
3424 | direct_abstract_declarator '(' parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3425 { $$ = make_call_declarator ($$, $3, $5, $6); }
3426 | direct_abstract_declarator LEFT_RIGHT cv_qualifiers exception_specification_opt %prec '.'
3427 { $$ = make_call_declarator ($$, empty_parms (), $3, $4); }
3428 | direct_abstract_declarator '[' nonmomentary_expr ']' %prec '.'
3429 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3430 | direct_abstract_declarator '[' ']' %prec '.'
3431 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
3432 | '(' complex_parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3433 { $$ = make_call_declarator (NULL_TREE, $2, $4, $5); }
3434 | regcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3435 { set_quals_and_spec ($$, $2, $3); }
3436 | fcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3437 { set_quals_and_spec ($$, $2, $3); }
3438 | '[' nonmomentary_expr ']' %prec '.'
3439 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3441 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, NULL_TREE); }
3444 /* For C++, decls and stmts can be intermixed, so we don't need to
3445 have a special rule that won't start parsing the stmt section
3446 until we have a stmt that parses without errors. */
3459 /* build the LET_STMT node before parsing its contents,
3460 so that any LET_STMTs within the context can have their display pointers
3461 set up to point at this one. */
3465 { do_pushlevel (); }
3470 { $$ = do_poplevel (); }
3473 /* Read zero or more forward-declarations for labels
3474 that nested functions can jump to. */
3479 pedwarn ("ANSI C++ forbids label declarations"); }
3484 | label_decls label_decl
3488 LABEL identifiers_or_typenames ';'
3490 for (link = $2; link; link = TREE_CHAIN (link))
3492 tree label = shadow_label (TREE_VALUE (link));
3493 C_DECLARED_LABEL_FLAG (label) = 1;
3494 declare_nonlocal_label (label);
3499 /* This is the body of a function definition.
3500 It causes syntax errors to ignore to the next openbrace. */
3510 if (processing_template_decl)
3512 $<ttype>$ = build_min_nt (COMPOUND_STMT, NULL_TREE);
3513 add_tree ($<ttype>$);
3516 .pushlevel compstmtend .poplevel
3518 if (processing_template_decl)
3520 TREE_OPERAND ($<ttype>2, 0) = TREE_CHAIN ($<ttype>2);
3521 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3522 last_tree = $<ttype>2;
3531 if (processing_template_decl)
3533 $<ttype>$ = build_min_nt (IF_STMT, NULL_TREE, NULL_TREE,
3535 add_tree ($<ttype>$);
3537 cond_stmt_keyword = "if";
3539 .pushlevel paren_cond_or_null
3541 if (processing_template_decl)
3543 if (last_tree != $<ttype>2)
3545 TREE_OPERAND ($<ttype>2, 0) = last_tree;
3546 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3547 last_tree = $<ttype>2;
3550 TREE_OPERAND ($<ttype>2, 0) = $4;
3554 emit_line_note (input_filename, lineno);
3555 expand_start_cond ($4, 0);
3558 implicitly_scoped_stmt
3560 if (processing_template_decl)
3562 TREE_OPERAND ($<ttype>2, 1) = TREE_CHAIN ($<ttype>2);
3563 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3564 $<ttype>$ = last_tree = $<ttype>2;
3569 implicitly_scoped_stmt:
3574 if (processing_template_decl)
3576 $<ttype>$ = build_min_nt (COMPOUND_STMT, NULL_TREE);
3577 add_tree ($<ttype>$);
3580 simple_stmt .poplevel
3582 if (processing_template_decl)
3584 TREE_OPERAND ($<ttype>2, 0) = TREE_CHAIN ($<ttype>2);
3585 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3586 last_tree = $<ttype>2;
3604 if (! processing_template_decl)
3606 emit_line_note (input_filename, lineno);
3607 /* Do default conversion if safe and possibly important,
3608 in case within ({...}). */
3609 if ((TREE_CODE (TREE_TYPE (expr)) == ARRAY_TYPE
3611 || TREE_CODE (TREE_TYPE (expr)) == FUNCTION_TYPE)
3612 expr = default_conversion (expr);
3614 cplus_expand_expr_stmt (expr);
3618 { if (! processing_template_decl) expand_start_else (); }
3619 implicitly_scoped_stmt
3621 if (processing_template_decl)
3623 TREE_OPERAND ($<ttype>1, 2) = TREE_CHAIN ($<ttype>1);
3624 TREE_CHAIN ($<ttype>1) = NULL_TREE;
3625 last_tree = $<ttype>1;
3632 | simple_if %prec IF
3633 { if (! processing_template_decl) expand_end_cond ();
3638 if (processing_template_decl)
3640 $<ttype>$ = build_min_nt (WHILE_STMT, NULL_TREE, NULL_TREE);
3641 add_tree ($<ttype>$);
3646 emit_line_note (input_filename, lineno);
3647 expand_start_loop (1);
3649 cond_stmt_keyword = "while";
3651 .pushlevel paren_cond_or_null
3653 if (processing_template_decl)
3655 if (last_tree != $<ttype>2)
3657 TREE_OPERAND ($<ttype>2, 0) = last_tree;
3658 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3659 last_tree = $<ttype>2;
3662 TREE_OPERAND ($<ttype>2, 0) = $4;
3666 emit_line_note (input_filename, lineno);
3667 expand_exit_loop_if_false (0, $4);
3670 already_scoped_stmt .poplevel
3672 if (processing_template_decl)
3674 TREE_OPERAND ($<ttype>2, 1) = TREE_CHAIN ($<ttype>2);
3675 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3676 last_tree = $<ttype>2;
3684 if (processing_template_decl)
3686 $<ttype>$ = build_min_nt (DO_STMT, NULL_TREE, NULL_TREE);
3687 add_tree ($<ttype>$);
3692 emit_line_note (input_filename, lineno);
3693 expand_start_loop_continue_elsewhere (1);
3696 implicitly_scoped_stmt WHILE
3698 if (processing_template_decl)
3700 TREE_OPERAND ($<ttype>2, 0) = TREE_CHAIN ($<ttype>2);
3701 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3702 last_tree = $<ttype>2;
3706 expand_loop_continue_here ();
3707 cond_stmt_keyword = "do";
3710 paren_expr_or_null ';'
3712 if (processing_template_decl)
3713 TREE_OPERAND ($<ttype>2, 1) = $6;
3716 emit_line_note (input_filename, lineno);
3717 expand_exit_loop_if_false (0, $6);
3724 { if (processing_template_decl)
3726 $<ttype>$ = build_min_nt (FOR_STMT, NULL_TREE, NULL_TREE,
3727 NULL_TREE, NULL_TREE);
3728 add_tree ($<ttype>$);
3731 emit_line_note (input_filename, lineno);
3732 if (flag_new_for_scope > 0)
3734 /* Conditionalize .pushlevel */
3736 note_level_for_for ();
3739 expand_start_bindings (0);
3742 '(' for.init.statement
3744 if (processing_template_decl)
3746 if (last_tree != $<ttype>2)
3748 TREE_OPERAND ($<ttype>2, 0) = TREE_CHAIN ($<ttype>2);
3749 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3750 last_tree = $<ttype>2;
3756 emit_line_note (input_filename, lineno);
3757 expand_start_loop_continue_elsewhere (1);
3760 .pushlevel xcond ';'
3762 if (processing_template_decl)
3764 if (last_tree != $<ttype>2)
3766 TREE_OPERAND ($<ttype>2, 1) = last_tree;
3767 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3768 last_tree = $<ttype>2;
3771 TREE_OPERAND ($<ttype>2, 1) = $7;
3775 emit_line_note (input_filename, lineno);
3776 if ($7) expand_exit_loop_if_false (0, $7);
3780 /* Don't let the tree nodes for $10 be discarded
3781 by clear_momentary during the parsing of the next stmt. */
3783 if (processing_template_decl)
3784 TREE_OPERAND ($<ttype>2, 2) = $10;
3787 already_scoped_stmt .poplevel
3789 if (processing_template_decl)
3791 TREE_OPERAND ($<ttype>2, 3) = TREE_CHAIN ($<ttype>2);
3792 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3793 last_tree = $<ttype>2;
3797 emit_line_note (input_filename, lineno);
3798 expand_loop_continue_here ();
3799 if ($10) cplus_expand_expr_stmt ($10);
3803 if (flag_new_for_scope > 0)
3808 | SWITCH .pushlevel '(' condition ')'
3810 if (processing_template_decl)
3812 $<ttype>$ = build_min_nt (SWITCH_STMT, $4, NULL_TREE);
3813 add_tree ($<ttype>$);
3817 emit_line_note (input_filename, lineno);
3818 c_expand_start_case ($4);
3821 /* Don't let the tree nodes for $4 be discarded by
3822 clear_momentary during the parsing of the next stmt. */
3825 implicitly_scoped_stmt
3827 if (processing_template_decl)
3829 TREE_OPERAND ($<ttype>6, 1) = TREE_CHAIN ($<ttype>6);
3830 TREE_CHAIN ($<ttype>6) = NULL_TREE;
3831 last_tree = $<ttype>6;
3834 expand_end_case ($4);
3840 | CASE expr_no_commas ':'
3841 { do_case ($2, NULL_TREE); }
3843 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
3844 { do_case ($2, $4); }
3847 { do_case (NULL_TREE, NULL_TREE); }
3850 { emit_line_note (input_filename, lineno);
3851 if (processing_template_decl)
3852 add_tree (build_min_nt (BREAK_STMT));
3853 else if ( ! expand_exit_something ())
3854 error ("break statement not within loop or switch"); }
3856 { emit_line_note (input_filename, lineno);
3857 if (processing_template_decl)
3858 add_tree (build_min_nt (CONTINUE_STMT));
3859 else if (! expand_continue_loop (0))
3860 error ("continue statement not within a loop"); }
3862 { emit_line_note (input_filename, lineno);
3863 c_expand_return (NULL_TREE); }
3865 { emit_line_note (input_filename, lineno);
3866 c_expand_return ($2);
3869 | asm_keyword maybe_cv_qualifier '(' string ')' ';'
3870 { if (TREE_CHAIN ($4)) $4 = combine_strings ($4);
3871 emit_line_note (input_filename, lineno);
3875 /* This is the case with just output operands. */
3876 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ')' ';'
3877 { if (TREE_CHAIN ($4)) $4 = combine_strings ($4);
3878 emit_line_note (input_filename, lineno);
3879 c_expand_asm_operands ($4, $6, NULL_TREE, NULL_TREE,
3880 $2 == ridpointers[(int)RID_VOLATILE],
3881 input_filename, lineno);
3884 /* This is the case with input operands as well. */
3885 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':' asm_operands ')' ';'
3886 { if (TREE_CHAIN ($4)) $4 = combine_strings ($4);
3887 emit_line_note (input_filename, lineno);
3888 c_expand_asm_operands ($4, $6, $8, NULL_TREE,
3889 $2 == ridpointers[(int)RID_VOLATILE],
3890 input_filename, lineno);
3893 /* This is the case with clobbered registers as well. */
3894 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':'
3895 asm_operands ':' asm_clobbers ')' ';'
3896 { if (TREE_CHAIN ($4)) $4 = combine_strings ($4);
3897 emit_line_note (input_filename, lineno);
3898 c_expand_asm_operands ($4, $6, $8, $10,
3899 $2 == ridpointers[(int)RID_VOLATILE],
3900 input_filename, lineno);
3905 if (processing_template_decl)
3906 add_tree (build_min_nt (GOTO_STMT, $3));
3908 { emit_line_note (input_filename, lineno);
3909 expand_computed_goto ($3); }
3911 | GOTO identifier ';'
3913 if (processing_template_decl)
3914 add_tree (build_min_nt (GOTO_STMT, $2));
3918 emit_line_note (input_filename, lineno);
3919 decl = lookup_label ($2);
3920 TREE_USED (decl) = 1;
3927 { error ("label must be followed by statement");
3938 if (! current_function_parms_stored)
3939 store_parm_decls ();
3940 expand_start_early_try_stmts ();
3942 ctor_initializer_opt compstmt
3943 { expand_start_all_catch (); }
3946 int nested = (hack_decl_function_context
3947 (current_function_decl) != NULL_TREE);
3948 expand_end_all_catch ();
3949 finish_function (lineno, (int)$3, nested);
3956 if (processing_template_decl)
3958 $<ttype>$ = build_min_nt (TRY_BLOCK, NULL_TREE,
3960 add_tree ($<ttype>$);
3964 emit_line_note (input_filename, lineno);
3965 expand_start_try_stmts ();
3970 if (processing_template_decl)
3972 TREE_OPERAND ($<ttype>2, 0) = TREE_CHAIN ($<ttype>2);
3973 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3974 last_tree = $<ttype>2;
3977 expand_start_all_catch ();
3981 if (processing_template_decl)
3983 TREE_OPERAND ($<ttype>2, 1) = TREE_CHAIN ($<ttype>2);
3984 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3985 last_tree = $<ttype>2;
3988 expand_end_all_catch ();
3994 | handler_seq handler
4000 if (processing_template_decl)
4002 $<ttype>$ = build_min_nt (HANDLER, NULL_TREE,
4004 add_tree ($<ttype>$);
4007 .pushlevel handler_args
4009 if (processing_template_decl)
4011 TREE_OPERAND ($<ttype>2, 0) = TREE_CHAIN ($<ttype>2);
4012 TREE_CHAIN ($<ttype>2) = NULL_TREE;
4013 last_tree = $<ttype>2;
4018 if (processing_template_decl)
4020 TREE_OPERAND ($<ttype>2, 1) = TREE_CHAIN ($<ttype>2);
4021 TREE_CHAIN ($<ttype>2) = NULL_TREE;
4022 last_tree = $<ttype>2;
4025 expand_end_catch_block ();
4031 typed_typespecs %prec EMPTY
4032 | nonempty_cv_qualifiers %prec EMPTY
4037 { expand_start_catch_block (NULL_TREE, NULL_TREE); }
4038 /* This doesn't allow reference parameters, the below does.
4039 | '(' type_specifier_seq absdcl ')'
4040 { check_for_new_type ("inside exception declarations", $2);
4041 expand_start_catch_block ($2.t, $3); }
4042 | '(' type_specifier_seq ')'
4043 { check_for_new_type ("inside exception declarations", $2);
4044 expand_start_catch_block ($2.t, NULL_TREE); }
4045 | '(' type_specifier_seq notype_declarator ')'
4046 { check_for_new_type ("inside exception declarations", $2);
4047 expand_start_catch_block ($2.t, $3); }
4048 | '(' typed_typespecs after_type_declarator ')'
4049 { check_for_new_type ("inside exception declarations", $2);
4050 expand_start_catch_block ($2.t, $3); }
4051 This allows reference parameters... */
4053 { check_for_new_type ("inside exception declarations", $2);
4054 expand_start_catch_block (TREE_PURPOSE ($2.t),
4055 TREE_VALUE ($2.t)); }
4062 label = define_label (input_filename, lineno, $1);
4063 if (label && ! minimal_parse_mode)
4064 expand_label (label);
4076 { if ($1) cplus_expand_expr_stmt ($1); }
4080 pedwarn ("ANSI C++ forbids compound statements inside for initializations");
4084 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
4088 { emit_line_note (input_filename, lineno);
4091 { emit_line_note (input_filename, lineno); }
4102 /* These are the operands other than the first string and colon
4103 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
4107 | nonnull_asm_operands
4110 nonnull_asm_operands:
4112 | nonnull_asm_operands ',' asm_operand
4113 { $$ = chainon ($$, $3); }
4118 { $$ = build_tree_list ($$, $3); }
4123 { $$ = tree_cons (NULL_TREE, $$, NULL_TREE); }
4124 | asm_clobbers ',' STRING
4125 { $$ = tree_cons (NULL_TREE, $3, $$); }
4128 /* This is what appears inside the parens in a function declarator.
4129 Its value is represented in the format that grokdeclarator expects.
4131 In C++, declaring a function with no parameters
4132 means that that function takes *no* parameters. */
4141 { $$ = tree_cons (NULL_TREE, $1.t, void_list_node);
4142 TREE_PARMLIST ($$) = 1;
4143 check_for_new_type ("inside parameter list", $1); }
4146 /* This nonterminal does not include the common sequence '(' type_id ')',
4147 as it is ambiguous and must be disambiguated elsewhere. */
4151 $$ = chainon ($$, void_list_node);
4152 TREE_PARMLIST ($$) = 1;
4154 | parms_comma ELLIPSIS
4156 TREE_PARMLIST ($$) = 1;
4158 /* C++ allows an ellipsis without a separating ',' */
4161 TREE_PARMLIST ($$) = 1;
4165 $$ = build_tree_list (NULL_TREE, $1.t);
4166 TREE_PARMLIST ($$) = 1;
4174 TREE_PARMLIST ($$) = 1;
4176 | parms TYPENAME_ELLIPSIS
4178 TREE_PARMLIST ($$) = 1;
4180 | type_id TYPENAME_ELLIPSIS
4182 $$ = build_tree_list (NULL_TREE, $1.t);
4183 TREE_PARMLIST ($$) = 1;
4187 /* This helps us recover from really nasty
4188 parse errors, for example, a missing right
4190 yyerror ("possibly missing ')'");
4191 $$ = chainon ($$, void_list_node);
4192 TREE_PARMLIST ($$) = 1;
4198 /* This helps us recover from really nasty
4199 parse errors, for example, a missing right
4201 yyerror ("possibly missing ')'");
4202 $$ = tree_cons (NULL_TREE, $1.t, void_list_node);
4203 TREE_PARMLIST ($$) = 1;
4209 /* A default argument to a */
4212 { maybe_snarf_defarg (); }
4222 /* A nonempty list of parameter declarations or type names. */
4225 { check_for_new_type ("in a parameter list", $1);
4226 $$ = build_tree_list (NULL_TREE, $1.t); }
4228 { check_for_new_type ("in a parameter list", $1);
4229 $$ = build_tree_list ($2, $1.t); }
4230 | parms_comma full_parm
4231 { check_for_new_type ("in a parameter list", $2);
4232 $$ = chainon ($$, $2.t); }
4233 | parms_comma bad_parm
4234 { $$ = chainon ($$, build_tree_list (NULL_TREE, $2)); }
4235 | parms_comma bad_parm '=' init
4236 { $$ = chainon ($$, build_tree_list ($4, $2)); }
4242 { check_for_new_type ("in a parameter list", $1);
4243 $$ = build_tree_list (NULL_TREE, $1.t); }
4246 /* A single parameter declaration or parameter type name,
4247 as found in a parmlist. */
4249 /* Here we expand typed_declspecs inline to avoid mis-parsing of
4250 TYPESPEC IDENTIFIER. */
4251 typed_declspecs1 declarator
4252 { tree specs = strip_attrs ($1.t);
4253 $$.new_type_flag = $1.new_type_flag;
4254 $$.t = build_tree_list (specs, $2); }
4255 | typed_typespecs declarator
4256 { $$.t = build_tree_list ($1.t, $2);
4257 $$.new_type_flag = $1.new_type_flag; }
4258 | typespec declarator
4259 { $$.t = build_tree_list (get_decl_list ($1.t), $2);
4260 $$.new_type_flag = $1.new_type_flag; }
4261 | typed_declspecs1 absdcl
4262 { tree specs = strip_attrs ($1.t);
4263 $$.t = build_tree_list (specs, $2);
4264 $$.new_type_flag = $1.new_type_flag; }
4265 | typed_declspecs1 %prec EMPTY
4266 { tree specs = strip_attrs ($1.t);
4267 $$.t = build_tree_list (specs, NULL_TREE);
4268 $$.new_type_flag = $1.new_type_flag; }
4269 | declmods notype_declarator
4270 { tree specs = strip_attrs ($1);
4271 $$.t = build_tree_list (specs, $2);
4272 $$.new_type_flag = 0; }
4277 { $$.t = build_tree_list (NULL_TREE, $1.t);
4278 $$.new_type_flag = $1.new_type_flag; }
4280 { $$.t = build_tree_list ($2, $1.t);
4281 $$.new_type_flag = $1.new_type_flag; }
4290 /* empty */ %prec EMPTY
4291 { see_typename (); }
4295 /* empty */ %prec EMPTY
4297 error ("type specifier omitted for parameter");
4298 $$ = build_tree_list (integer_type_node, NULL_TREE);
4302 error ("type specifier omitted for parameter");
4303 if (TREE_CODE ($$) == SCOPE_REF
4304 && (TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TYPE_PARM
4305 || TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TEMPLATE_PARM))
4306 cp_error (" perhaps you want `typename %E' to make it a type", $$);
4307 $$ = build_tree_list (integer_type_node, $$);
4311 exception_specification_opt:
4312 /* empty */ %prec EMPTY
4314 | THROW '(' ansi_raise_identifiers ')' %prec EMPTY
4316 | THROW LEFT_RIGHT %prec EMPTY
4317 { $$ = build_decl_list (NULL_TREE, NULL_TREE); }
4320 ansi_raise_identifier:
4322 { $$ = build_decl_list (NULL_TREE, groktypename($1.t)); }
4325 ansi_raise_identifiers:
4326 ansi_raise_identifier
4327 | ansi_raise_identifiers ',' ansi_raise_identifier
4329 TREE_CHAIN ($3) = $$;
4334 conversion_declarator:
4335 /* empty */ %prec EMPTY
4337 | '*' cv_qualifiers conversion_declarator
4338 { $$ = make_pointer_declarator ($2, $3); }
4339 | '&' cv_qualifiers conversion_declarator
4340 { $$ = make_reference_declarator ($2, $3); }
4341 | ptr_to_mem cv_qualifiers conversion_declarator
4342 { tree arg = make_pointer_declarator ($2, $3);
4343 $$ = build_parse_node (SCOPE_REF, $1, arg);
4349 { got_scope = NULL_TREE; }
4354 { $$ = ansi_opname[MULT_EXPR]; }
4356 { $$ = ansi_opname[TRUNC_DIV_EXPR]; }
4358 { $$ = ansi_opname[TRUNC_MOD_EXPR]; }
4360 { $$ = ansi_opname[PLUS_EXPR]; }
4362 { $$ = ansi_opname[MINUS_EXPR]; }
4364 { $$ = ansi_opname[BIT_AND_EXPR]; }
4366 { $$ = ansi_opname[BIT_IOR_EXPR]; }
4368 { $$ = ansi_opname[BIT_XOR_EXPR]; }
4370 { $$ = ansi_opname[BIT_NOT_EXPR]; }
4372 { $$ = ansi_opname[COMPOUND_EXPR]; }
4373 | operator ARITHCOMPARE
4374 { $$ = ansi_opname[$2]; }
4376 { $$ = ansi_opname[LT_EXPR]; }
4378 { $$ = ansi_opname[GT_EXPR]; }
4379 | operator EQCOMPARE
4380 { $$ = ansi_opname[$2]; }
4382 { $$ = ansi_assopname[$2]; }
4384 { $$ = ansi_opname [MODIFY_EXPR]; }
4386 { $$ = ansi_opname[$2]; }
4388 { $$ = ansi_opname[$2]; }
4390 { $$ = ansi_opname[POSTINCREMENT_EXPR]; }
4391 | operator MINUSMINUS
4392 { $$ = ansi_opname[PREDECREMENT_EXPR]; }
4394 { $$ = ansi_opname[TRUTH_ANDIF_EXPR]; }
4396 { $$ = ansi_opname[TRUTH_ORIF_EXPR]; }
4398 { $$ = ansi_opname[TRUTH_NOT_EXPR]; }
4400 { $$ = ansi_opname[COND_EXPR]; }
4402 { $$ = ansi_opname[$2]; }
4403 | operator POINTSAT %prec EMPTY
4404 { $$ = ansi_opname[COMPONENT_REF]; }
4405 | operator POINTSAT_STAR %prec EMPTY
4406 { $$ = ansi_opname[MEMBER_REF]; }
4407 | operator LEFT_RIGHT
4408 { $$ = ansi_opname[CALL_EXPR]; }
4410 { $$ = ansi_opname[ARRAY_REF]; }
4411 | operator NEW %prec EMPTY
4412 { $$ = ansi_opname[NEW_EXPR]; }
4413 | operator DELETE %prec EMPTY
4414 { $$ = ansi_opname[DELETE_EXPR]; }
4415 | operator NEW '[' ']'
4416 { $$ = ansi_opname[VEC_NEW_EXPR]; }
4417 | operator DELETE '[' ']'
4418 { $$ = ansi_opname[VEC_DELETE_EXPR]; }
4419 /* Names here should be looked up in class scope ALSO. */
4420 | operator type_specifier_seq conversion_declarator
4421 { $$ = grokoptypename ($2.t, $3); }
4423 { $$ = ansi_opname[ERROR_MARK]; }
4430 debug_yytranslate (value)
4433 return yytname[YYTRANSLATE (value)];