1 /* YACC parser for C++ syntax.
2 Copyright (C) 1988, 1989, 1993, 1994, 1995 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. */
45 /* Since parsers are distinct for each language, put the language string
46 definition here. (fnf) */
47 char *language_string = "GNU C++";
49 extern tree void_list_node;
50 extern struct obstack permanent_obstack;
56 extern int end_of_file;
57 extern int current_class_depth;
58 extern tree last_tree;
60 /* FSF LOCAL dje prefix attributes */
61 extern tree strip_attrs PROTO((tree));
66 /* Like YYERROR but do call yyerror. */
67 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
69 #define OP0(NODE) (TREE_OPERAND (NODE, 0))
70 #define OP1(NODE) (TREE_OPERAND (NODE, 1))
72 /* Contains the statement keyword (if/while/do) to include in an
73 error message if the user supplies an empty conditional expression. */
74 static char *cond_stmt_keyword;
76 /* Nonzero if we have an `extern "C"' acting as an extern specifier. */
82 /* Cons up an empty parameter list. */
92 parms = void_list_node;
101 %union {long itype; tree ttype; char *strtype; enum tree_code code; }
103 /* All identifiers that are not reserved words
104 and are not declared typedefs in the current block */
107 /* All identifiers that are declared typedefs in the current block.
108 In some contexts, they are treated just like IDENTIFIER,
109 but they can also serve as typespecs in declarations. */
112 /* Reserved words that specify storage class.
113 yylval contains an IDENTIFIER_NODE which indicates which one. */
116 /* Reserved words that specify type.
117 yylval contains an IDENTIFIER_NODE which indicates which one. */
120 /* Reserved words that qualify type: "const" or "volatile".
121 yylval contains an IDENTIFIER_NODE which indicates which one. */
124 /* Character or numeric constants.
125 yylval is the node for the constant. */
128 /* String constants in raw form.
129 yylval is a STRING_CST node. */
132 /* "...", used for functions with variable arglists. */
135 /* the reserved words */
136 /* SCO include files test "ASM", so use something else. */
137 %token SIZEOF ENUM /* STRUCT UNION */ IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
138 %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD GCC_ASM_KEYWORD TYPEOF ALIGNOF
140 %token ATTRIBUTE EXTENSION LABEL
142 /* the reserved words... C++ extensions */
144 %token <ttype> VISSPEC
145 %token DELETE NEW OVERLOAD THIS OPERATOR CXX_TRUE CXX_FALSE
146 %token NAMESPACE TYPENAME_KEYWORD USING
147 %token LEFT_RIGHT TEMPLATE
148 %token TYPEID DYNAMIC_CAST STATIC_CAST REINTERPRET_CAST CONST_CAST
151 /* Define the operator tokens and their precedences.
152 The value is an integer because, if used, it is the tree code
153 to use in the expression made from the operator. */
155 %left EMPTY /* used to resolve s/r with epsilon */
159 /* Add precedence rules to solve dangling else s/r conflict */
163 %left IDENTIFIER TYPENAME PTYPENAME SCSPEC TYPESPEC TYPE_QUAL ENUM AGGR ELLIPSIS TYPEOF SIGOF OPERATOR NSNAME TYPENAME_KEYWORD
169 %right <code> ASSIGN '='
177 %left <code> EQCOMPARE
178 %left <code> ARITHCOMPARE '<' '>'
179 %left <code> LSHIFT RSHIFT
181 %left <code> '*' '/' '%'
182 %left <code> POINTSAT_STAR DOT_STAR
183 %right <code> UNARY PLUSPLUS MINUSMINUS '~'
185 %left <ttype> PAREN_STAR_PAREN LEFT_RIGHT
186 %left <code> POINTSAT '.' '(' '['
188 %right SCOPE /* C++ extension */
189 %nonassoc NEW DELETE TRY CATCH
193 %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist
194 %type <ttype> paren_expr_or_null nontrivial_exprlist
195 %type <ttype> expr_no_commas cast_expr unary_expr primary string STRING
196 %type <ttype> typed_declspecs reserved_declspecs boolean.literal
197 %type <ttype> typed_typespecs reserved_typespecquals
198 %type <ttype> declmods typespec typespecqual_reserved
199 %type <ttype> SCSPEC TYPESPEC TYPE_QUAL nonempty_type_quals maybe_type_qual
200 %type <itype> initdecls notype_initdecls initdcl /* C++ modification */
201 %type <ttype> init initlist maybeasm maybe_init
202 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
203 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
204 %type <ttype> any_word
206 %type <ttype> compstmt implicitly_scoped_stmt
208 %type <ttype> declarator notype_declarator after_type_declarator
209 %type <ttype> direct_notype_declarator direct_after_type_declarator
211 %type <ttype> structsp opt.component_decl_list component_decl_list
212 %type <ttype> component_decl component_decl_1 components notype_components
213 %type <ttype> component_declarator component_declarator0
214 %type <ttype> notype_component_declarator notype_component_declarator0
215 %type <ttype> after_type_component_declarator after_type_component_declarator0
216 %type <ttype> enumlist enumerator
217 %type <ttype> type_id absdcl type_quals
218 %type <ttype> direct_abstract_declarator conversion_declarator
219 %type <ttype> new_type_id new_declarator direct_new_declarator
220 %type <ttype> xexpr parmlist parms parm bad_parm full_parm
221 %type <ttype> identifiers_or_typenames
222 %type <ttype> fcast_or_absdcl regcast_or_absdcl
223 %type <ttype> expr_or_declarator complex_notype_declarator
224 %type <ttype> notype_unqualified_id unqualified_id qualified_id
225 %type <ttype> overqualified_id notype_qualified_id any_id
226 %type <ttype> complex_direct_notype_declarator functional_cast
227 %type <ttype> named_parm complex_parmlist typed_declspecs1 parms_comma
230 %token <ttype> TYPENAME_ELLIPSIS PTYPENAME
231 %token <ttype> PRE_PARSED_FUNCTION_DECL EXTERN_LANG_STRING ALL
232 %token <ttype> PRE_PARSED_CLASS_DECL
233 %type <ttype> fn.def1 /* Not really! */
234 %type <ttype> fn.def2 return_id fn.defpen
235 %type <itype> ctor_initializer_opt
236 %type <ttype> named_class_head named_class_head_sans_basetype
237 %type <ttype> named_complex_class_head_sans_basetype
238 %type <ttype> unnamed_class_head
239 %type <ttype> class_head base_class_list
240 %type <ttype> base_class_access_list
241 %type <ttype> base_class maybe_base_class_list base_class.1
242 %type <ttype> exception_specification_opt ansi_raise_identifier ansi_raise_identifiers
243 %type <ttype> operator_name
244 %type <ttype> object aggr
245 %type <itype> new delete
246 /* %type <ttype> primary_no_id */
247 %type <ttype> nonmomentary_expr maybe_parmlist
248 %type <itype> initdcl0 notype_initdcl0 member_init_list
249 %type <ttype> template_header template_parm_list template_parm
250 %type <ttype> template_type_parm
251 %type <code> template_close_bracket
252 %type <ttype> template_type template_arg_list template_arg
253 /* %type <itype> try_for_typename */
254 %type <ttype> condition xcond paren_cond_or_null
255 %type <ttype> type_name nested_name_specifier nested_type ptr_to_mem
256 %type <ttype> complete_type_name notype_identifier
257 %type <ttype> complex_type_name nested_name_specifier_1
258 %type <itype> nomods_initdecls nomods_initdcl0
259 %type <ttype> new_initializer new_placement type_specifier_seq
260 %type <ttype> using_decl .poplevel
262 /* in order to recognize aggr tags as defining and thus shadowing. */
263 %token TYPENAME_DEFN IDENTIFIER_DEFN PTYPENAME_DEFN
264 %type <ttype> named_class_head_sans_basetype_defn
265 %type <ttype> identifier_defn IDENTIFIER_DEFN TYPENAME_DEFN PTYPENAME_DEFN
270 /* Used in lex.c for parsing pragmas. */
273 /* lex.c and pt.c depend on this being the last token. Define
274 any new tokens before this one! */
275 %token END_OF_SAVED_INPUT
278 /* List of types and structure classes of the current declaration. */
279 static tree current_declspecs;
280 /* List of prefix attributes in effect.
281 Prefix attributes are parsed by the reserved_declspecs and declmods
282 rules. They create a list that contains *both* declspecs and attrs. */
283 /* ??? It is not clear yet that all cases where an attribute can now appear in
284 a declspec list have been updated. */
285 static tree prefix_attributes;
287 /* When defining an aggregate, this is the most recent one being defined. */
288 static tree current_aggr;
290 /* Tell yyparse how to print a token's value, if yydebug is set. */
292 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
293 extern void yyprint ();
294 extern tree combine_strings PROTO((tree));
301 /* In case there were missing closebraces,
302 get us back to the global binding level. */
303 while (! global_bindings_p ())
309 /* the reason for the strange actions in this rule
310 is so that notype_initdecls when reached via datadef
311 can find a valid list of type and sc specs in $0. */
314 { $<ttype>$ = NULL_TREE; } lang_extdef
315 { $<ttype>$ = NULL_TREE; }
316 | extdefs lang_extdef
317 { $<ttype>$ = NULL_TREE; }
326 { have_extern_spec = 1;
327 used_extern_spec = 0;
328 $<ttype>$ = NULL_TREE; }
331 { have_extern_spec = 0; }
340 { if (pending_lang_change) do_pending_lang_change(); }
342 { if (! toplevel_bindings_p () && ! pseudo_global_level_p())
348 { if (pending_inlines) do_pending_inlines (); }
350 { if (pending_inlines) do_pending_inlines (); }
352 { if (pending_inlines) do_pending_inlines (); }
354 | asm_keyword '(' string ')' ';'
355 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
357 | extern_lang_string '{' extdefs_opt '}'
358 { pop_lang_context (); }
359 | extern_lang_string .hush_warning fndef .warning_ok
360 { if (pending_inlines) do_pending_inlines ();
361 pop_lang_context (); }
362 | extern_lang_string .hush_warning datadef .warning_ok
363 { if (pending_inlines) do_pending_inlines ();
364 pop_lang_context (); }
365 | NAMESPACE identifier '{'
366 { push_namespace ($2); }
368 { pop_namespace (); }
370 { push_namespace (NULL_TREE); }
372 { pop_namespace (); }
373 | NAMESPACE identifier '=' any_id ';'
374 { do_namespace_alias ($2, $4); }
376 { do_toplevel_using_decl ($1); }
377 | USING NAMESPACE any_id ';'
378 { do_using_directive ($3); }
384 | USING global_scope qualified_id
386 | USING global_scope unqualified_id
393 | global_scope qualified_id
395 | global_scope unqualified_id
401 { push_lang_context ($1); }
402 | extern_lang_string EXTERN_LANG_STRING
403 { if (current_lang_name != $2)
404 cp_error ("use of linkage spec `%D' is different from previous spec `%D'", $2, current_lang_name);
405 pop_lang_context (); push_lang_context ($2); }
410 { begin_template_parm_list (); }
411 template_parm_list '>'
412 { $$ = end_template_parm_list ($4); }
417 { $$ = process_template_parm (NULL_TREE, $1); }
418 | template_parm_list ',' template_parm
419 { $$ = process_template_parm ($1, $3); }
425 $$ = build_tree_list ($1, NULL_TREE);
427 if (TREE_PURPOSE ($$) == signature_type_node)
428 sorry ("signature as template type parameter");
429 else if (TREE_PURPOSE ($$) != class_type_node)
431 pedwarn ("template type parameters must use the keyword `class'");
432 TREE_PURPOSE ($$) = class_type_node;
436 { $$ = build_tree_list ($1, $2); goto ttpa; }
438 { $$ = build_tree_list (class_type_node, NULL_TREE); }
439 | TYPENAME_KEYWORD identifier
440 { $$ = build_tree_list (class_type_node, $2); }
444 /* The following rules introduce a new reduce/reduce
445 conflict on the ',' and '>' input tokens: they are valid
446 prefixes for a `structsp', which means they could match a
447 nameless parameter. See 14.6, paragraph 3.
448 By putting them before the `parm' rule, we get
449 their match before considering them nameless parameter
452 { $$ = build_tree_list (NULL_TREE, $1); }
453 | template_type_parm '=' type_id
454 { $$ = build_tree_list (groktypename ($3), $1); }
456 { $$ = build_tree_list (NULL_TREE, $1); }
457 | parm '=' expr_no_commas %prec ARITHCOMPARE
458 { $$ = build_tree_list ($3, $1); }
462 OVERLOAD ov_identifiers ';'
463 { warning ("use of `overload' is an anachronism"); }
466 ov_identifiers: IDENTIFIER
467 { declare_overloaded ($1); }
468 | ov_identifiers ',' IDENTIFIER
469 { declare_overloaded ($3); }
475 { end_template_decl (); }
478 { end_template_decl (); }
484 | declmods notype_initdecls ';'
486 /* Normal case to make fast: "const i;". */
487 | declmods notype_declarator ';'
488 { tree d, specs, attrs;
489 split_specs_attrs ($1, &specs, &attrs);
490 d = start_decl ($<ttype>2, specs, 0, NULL_TREE);
491 cplus_decl_attributes (d, NULL_TREE, attrs);
492 cp_finish_decl (d, NULL_TREE, NULL_TREE, 1, 0);
494 | typed_declspecs initdecls ';'
496 note_list_got_semicolon ($<ttype>$);
498 /* Normal case: make this fast. */
499 | typed_declspecs declarator ';'
500 { tree d, specs, attrs;
501 split_specs_attrs ($1, &specs, &attrs);
502 d = start_decl ($<ttype>2, specs, 0, NULL_TREE);
503 cplus_decl_attributes (d, NULL_TREE, attrs);
504 cp_finish_decl (d, NULL_TREE, NULL_TREE, 1, 0);
505 note_list_got_semicolon ($<ttype>$);
508 { pedwarn ("empty declaration"); }
509 | explicit_instantiation ';'
510 | typed_declspecs ';'
513 split_specs_attrs ($1, &t, &attrs);
515 note_list_got_semicolon ($<ttype>$);
522 ctor_initializer_opt:
541 fn.def1 maybe_return_init ctor_initializer_opt compstmt_or_error
542 { finish_function (lineno, (int)$3, 0); }
543 | fn.def1 maybe_return_init function_try_block
544 { if ($<ttype>$) process_next_inline ($<ttype>$); }
546 | typed_declspecs declarator error
548 | declmods notype_declarator error
550 | notype_declarator error
555 typed_declspecs declarator exception_specification_opt
557 split_specs_attrs ($1, &specs, &attrs);
558 if (! start_function (specs, $2, $3, attrs, 0))
560 reinit_parse_for_function ();
562 | declmods notype_declarator exception_specification_opt
564 split_specs_attrs ($1, &specs, &attrs);
565 if (! start_function (specs, $2, $3, attrs, 0))
567 reinit_parse_for_function ();
569 | notype_declarator exception_specification_opt
570 { if (! start_function (NULL_TREE, $$, $2, NULL_TREE, 0))
572 reinit_parse_for_function ();
576 /* more C++ complexity. See component_decl for a comment on the
577 reduce/reduce conflict introduced by these rules. */
579 typed_declspecs '(' parmlist ')' type_quals exception_specification_opt
580 { tree specs = strip_attrs ($1);
581 if (TREE_VALUE (specs) == current_class_type)
583 if (TREE_CHAIN (specs) == NULL_TREE)
584 specs = get_decl_list (current_class_name);
586 TREE_VALUE (specs) = current_class_name;
588 $$ = build_parse_node (CALL_EXPR, TREE_VALUE (specs), $3, $5);
589 $$ = start_method (TREE_CHAIN (specs), $$, $6);
593 if (yychar == YYEMPTY)
595 reinit_parse_for_method (yychar, $$); }
596 | typed_declspecs LEFT_RIGHT type_quals exception_specification_opt
597 { tree specs = strip_attrs ($1);
598 $$ = build_parse_node (CALL_EXPR, TREE_VALUE (specs),
600 $$ = start_method (TREE_CHAIN (specs), $$, $4);
603 | typed_declspecs declarator exception_specification_opt
604 { tree specs = strip_attrs ($1);
605 $$ = start_method (specs, $2, $3); goto rest_of_mdef; }
606 | declmods notype_declarator exception_specification_opt
607 { tree specs = strip_attrs ($1);
608 $$ = start_method (specs, $2, $3); goto rest_of_mdef; }
609 | notype_declarator exception_specification_opt
610 { $$ = start_method (NULL_TREE, $$, $2); goto rest_of_mdef; }
613 return_id: RETURN IDENTIFIER
615 if (! current_function_parms_stored)
621 return_init: return_id maybe_init
622 { store_return_init ($<ttype>$, $2); }
623 | return_id '(' nonnull_exprlist ')'
624 { store_return_init ($<ttype>$, $3); }
625 | return_id LEFT_RIGHT
626 { store_return_init ($<ttype>$, NULL_TREE); }
630 ':' .set_base_init member_init_list
633 error ("no base initializers given following ':'");
635 /* Always keep the BLOCK node associated with the outermost
636 pair of curley braces of a function. These are needed
637 for correct operation of dwarfout.c. */
645 if (! current_function_parms_stored)
648 if (DECL_CONSTRUCTOR_P (current_function_decl))
650 /* Make a contour for the initializer list. */
653 expand_start_bindings (0);
655 else if (current_class_type == NULL_TREE)
656 error ("base initializers not allowed for non-member functions");
657 else if (! DECL_CONSTRUCTOR_P (current_function_decl))
658 error ("only constructors take base initializers");
667 | member_init_list ',' member_init
668 | member_init_list error
671 member_init: '(' nonnull_exprlist ')'
673 if (current_class_name && !flag_traditional)
674 pedwarn ("anachronistic old style base class initializer");
675 expand_member_init (C_C_D, NULL_TREE, $2);
679 if (current_class_name && !flag_traditional)
680 pedwarn ("anachronistic old style base class initializer");
681 expand_member_init (C_C_D, NULL_TREE, void_type_node);
683 | notype_identifier '(' nonnull_exprlist ')'
684 { expand_member_init (C_C_D, $1, $3); }
685 | notype_identifier LEFT_RIGHT
686 { expand_member_init (C_C_D, $1, void_type_node); }
687 | complete_type_name '(' nonnull_exprlist ')'
688 { expand_member_init (C_C_D, $1, $3); }
689 | complete_type_name LEFT_RIGHT
690 { expand_member_init (C_C_D, $1, void_type_node); }
692 | notype_qualified_id '(' nonnull_exprlist ')'
694 do_member_init (OP0 ($1), OP1 ($1), $3);
696 | notype_qualified_id LEFT_RIGHT
698 do_member_init (OP0 ($1), OP1 ($1), void_type_node);
721 explicit_instantiation:
722 TEMPLATE aggr template_type
723 { do_type_instantiation ($3, NULL_TREE); }
724 | TEMPLATE typed_declspecs declarator
725 { tree specs = strip_attrs ($2);
726 do_function_instantiation (specs, $3, NULL_TREE); }
727 | TEMPLATE notype_declarator
728 { do_function_instantiation (NULL_TREE, $2, NULL_TREE); }
729 | SCSPEC TEMPLATE aggr template_type
730 { do_type_instantiation ($4, $1); }
731 | SCSPEC TEMPLATE typed_declspecs declarator
732 { tree specs = strip_attrs ($3);
733 do_function_instantiation (specs, $4, $1); }
734 | SCSPEC TEMPLATE notype_declarator
735 { do_function_instantiation (NULL_TREE, $3, $1); }
738 /* The TYPENAME expansions are to deal with use of a template class name as
739 a template within the class itself, where the template decl is hidden by
740 a type decl. Got all that? */
743 PTYPENAME '<' template_arg_list template_close_bracket
745 $$ = lookup_template_class ($1, $3, NULL_TREE);
746 if ($$ != error_mark_node)
747 $$ = TYPE_STUB_DECL ($$);
749 | PTYPENAME '<' template_close_bracket
751 $$ = lookup_template_class ($1, NULL_TREE, NULL_TREE);
752 if ($$ != error_mark_node)
753 $$ = TYPE_STUB_DECL ($$);
755 | TYPENAME '<' template_arg_list template_close_bracket
757 $$ = lookup_template_class ($1, $3, NULL_TREE);
758 if ($$ != error_mark_node)
759 $$ = TYPE_STUB_DECL ($$);
761 | TYPENAME '<' template_close_bracket
763 $$ = lookup_template_class ($1, NULL_TREE, NULL_TREE);
764 if ($$ != error_mark_node)
765 $$ = TYPE_STUB_DECL ($$);
769 template_close_bracket:
773 /* Handle `Class<Class<Type>>' without space in the `>>' */
774 pedwarn ("`>>' should be `> >' in template class name");
781 { $$ = build_tree_list (NULL_TREE, $$); }
782 | template_arg_list ',' template_arg
783 { $$ = chainon ($$, build_tree_list (NULL_TREE, $3)); }
788 { $$ = groktypename ($$); }
789 | expr_no_commas %prec ARITHCOMPARE
793 { $$ = NEGATE_EXPR; }
795 { $$ = CONVERT_EXPR; }
797 { $$ = PREINCREMENT_EXPR; }
799 { $$ = PREDECREMENT_EXPR; }
801 { $$ = TRUTH_NOT_EXPR; }
804 expr: nontrivial_exprlist
805 { $$ = build_x_compound_expr ($$); }
811 { error ("ANSI C++ forbids an empty condition for `%s'",
813 $$ = integer_zero_node; }
815 { $$ = condition_conversion ($2); }
820 { error ("ANSI C++ forbids an empty condition for `%s'",
822 $$ = integer_zero_node; }
824 { $$ = condition_conversion ($2); }
831 { $$ = condition_conversion ($$); }
837 type_specifier_seq declarator exception_specification_opt maybeasm maybe_attribute '='
840 for (d = getdecls (); d; d = TREE_CHAIN (d))
841 if (TREE_CODE (d) == TYPE_DECL) {
842 tree s = TREE_TYPE (d);
843 if (TREE_CODE (s) == RECORD_TYPE)
844 cp_error ("definition of class `%T' in condition", s);
845 else if (TREE_CODE (s) == ENUMERAL_TYPE)
846 cp_error ("definition of enum `%T' in condition", s);
849 current_declspecs = $1;
850 $<itype>6 = suspend_momentary ();
851 $<ttype>$ = start_decl ($<ttype>2, current_declspecs, 1, $3);
852 cplus_decl_attributes ($<ttype>$, $5,
853 /*prefix_attributes*/ NULL_TREE);
857 cp_finish_decl ($<ttype>7, $8, $5, 1, LOOKUP_ONLYCONVERTING);
858 resume_momentary ($<itype>6);
860 if (TREE_CODE (TREE_TYPE ($$)) == ARRAY_TYPE)
861 cp_error ("definition of array `%#D' in condition", $$);
868 | maybe_label_decls stmts '}'
869 | maybe_label_decls stmts error '}'
870 | maybe_label_decls error '}'
876 if (current_template_parms)
878 $<ttype>$ = build_min_nt (COMPOUND_STMT, NULL_TREE);
879 COMPOUND_STMT_NO_SCOPE ($<ttype>$) = 1;
880 add_tree ($<ttype>$);
885 if (current_template_parms)
887 TREE_OPERAND ($<ttype>2, 0) = TREE_CHAIN ($<ttype>2);
888 TREE_CHAIN ($<ttype>2) = NULL_TREE;
889 last_tree = $<ttype>2;
898 expr_no_commas ',' expr_no_commas
899 { $$ = tree_cons (NULL_TREE, $$,
900 build_tree_list (NULL_TREE, $3)); }
901 | expr_no_commas ',' error
902 { $$ = tree_cons (NULL_TREE, $$,
903 build_tree_list (NULL_TREE, error_mark_node)); }
904 | nontrivial_exprlist ',' expr_no_commas
905 { chainon ($$, build_tree_list (NULL_TREE, $3)); }
906 | nontrivial_exprlist ',' error
907 { chainon ($$, build_tree_list (NULL_TREE, error_mark_node)); }
912 { $$ = build_tree_list (NULL_TREE, $$); }
913 | nontrivial_exprlist
920 if (TREE_CODE ($$) == TYPE_EXPR)
921 $$ = build_component_type_expr (C_C_D, $$, NULL_TREE, 1);
924 /* __extension__ turns off -pedantic for following primary. */
926 { $<itype>1 = pedantic;
928 cast_expr %prec UNARY
930 pedantic = $<itype>1; }
931 | '*' cast_expr %prec UNARY
932 { $$ = build_x_indirect_ref ($2, "unary *"); }
933 | '&' cast_expr %prec UNARY
934 { $$ = build_x_unary_op (ADDR_EXPR, $2); }
936 { $$ = build_x_unary_op (BIT_NOT_EXPR, $2); }
937 | unop cast_expr %prec UNARY
938 { $$ = build_x_unary_op ($1, $2);
939 if ($1 == NEGATE_EXPR && TREE_CODE ($2) == INTEGER_CST)
940 TREE_NEGATED_INT ($$) = 1;
941 overflow_warning ($$);
943 /* Refer to the address of a label as a pointer. */
945 { tree label = lookup_label ($2);
946 if (label == NULL_TREE)
947 $$ = null_pointer_node;
950 TREE_USED (label) = 1;
951 $$ = build1 (ADDR_EXPR, ptr_type_node, label);
952 TREE_CONSTANT ($$) = 1;
955 | SIZEOF unary_expr %prec UNARY
956 { $$ = expr_sizeof ($2); }
957 | SIZEOF '(' type_id ')' %prec HYPERUNARY
958 { $$ = c_sizeof (groktypename ($3)); }
959 | ALIGNOF unary_expr %prec UNARY
960 { $$ = grok_alignof ($2); }
961 | ALIGNOF '(' type_id ')' %prec HYPERUNARY
962 { $$ = c_alignof (groktypename ($3)); }
964 /* The %prec EMPTY's here are required by the = init initializer
965 syntax extension; see below. */
966 | new new_type_id %prec EMPTY
967 { $$ = build_new (NULL_TREE, $2, NULL_TREE, $1); }
968 | new new_type_id new_initializer
969 { $$ = build_new (NULL_TREE, $2, $3, $1); }
970 | new new_placement new_type_id %prec EMPTY
971 { $$ = build_new ($2, $3, NULL_TREE, $1); }
972 | new new_placement new_type_id new_initializer
973 { $$ = build_new ($2, $3, $4, $1); }
974 | new '(' type_id ')' %prec EMPTY
975 { $$ = build_new (NULL_TREE, groktypename($3),
977 | new '(' type_id ')' new_initializer
978 { $$ = build_new (NULL_TREE, groktypename($3), $5, $1); }
979 | new new_placement '(' type_id ')' %prec EMPTY
980 { $$ = build_new ($2, groktypename($4), NULL_TREE, $1); }
981 | new new_placement '(' type_id ')' new_initializer
982 { $$ = build_new ($2, groktypename($4), $6, $1); }
984 | delete cast_expr %prec UNARY
985 { $$ = delete_sanity ($2, NULL_TREE, 0, $1); }
986 | delete '[' ']' cast_expr %prec UNARY
987 { $$ = delete_sanity ($4, NULL_TREE, 1, $1);
988 if (yychar == YYEMPTY)
990 | delete '[' expr ']' cast_expr %prec UNARY
991 { $$ = delete_sanity ($5, $3, 2, $1);
992 if (yychar == YYEMPTY)
997 '(' nonnull_exprlist ')'
999 | '{' nonnull_exprlist '}'
1002 pedwarn ("old style placement syntax, use () instead");
1007 '(' nonnull_exprlist ')'
1013 cp_error ("`%T' is not a valid expression", $2);
1014 $$ = error_mark_node;
1016 /* GNU extension so people can use initializer lists. Note that
1017 this alters the meaning of `new int = 1', which was previously
1018 syntactically valid but semantically invalid. */
1022 pedwarn ("ANSI C++ forbids initialization of new expression with `='");
1027 /* This is necessary to postpone reduction of `int ((int)(int)(int))'. */
1029 '(' type_id ')' %prec EMPTY
1030 { $2 = tree_cons (NULL_TREE, $2, void_list_node);
1031 TREE_PARMLIST ($2) = 1;
1032 $$ = build_parse_node (CALL_EXPR, NULL_TREE, $2,
1034 | regcast_or_absdcl '(' type_id ')' %prec EMPTY
1035 { $3 = tree_cons (NULL_TREE, $3, void_list_node);
1036 TREE_PARMLIST ($3) = 1;
1037 $$ = build_parse_node (CALL_EXPR, $$, $3, NULL_TREE); }
1042 | regcast_or_absdcl unary_expr %prec UNARY
1043 { $$ = reparse_absdcl_as_casts ($$, $2); }
1044 | regcast_or_absdcl '{' initlist maybecomma '}' %prec UNARY
1046 tree init = build_nt (CONSTRUCTOR, NULL_TREE,
1049 pedwarn ("ANSI C++ forbids constructor-expressions");
1050 /* Indicate that this was a GNU C constructor expression. */
1051 TREE_HAS_CONSTRUCTOR (init) = 1;
1053 $$ = reparse_absdcl_as_casts ($$, init);
1059 /* Handle general members. */
1060 | expr_no_commas POINTSAT_STAR expr_no_commas
1061 { $$ = build_x_binary_op (MEMBER_REF, $$, $3); }
1062 | expr_no_commas DOT_STAR expr_no_commas
1063 { $$ = build_m_component_ref ($$, $3); }
1064 | expr_no_commas '+' expr_no_commas
1065 { $$ = build_x_binary_op ($2, $$, $3); }
1066 | expr_no_commas '-' expr_no_commas
1067 { $$ = build_x_binary_op ($2, $$, $3); }
1068 | expr_no_commas '*' expr_no_commas
1069 { $$ = build_x_binary_op ($2, $$, $3); }
1070 | expr_no_commas '/' expr_no_commas
1071 { $$ = build_x_binary_op ($2, $$, $3); }
1072 | expr_no_commas '%' expr_no_commas
1073 { $$ = build_x_binary_op ($2, $$, $3); }
1074 | expr_no_commas LSHIFT expr_no_commas
1075 { $$ = build_x_binary_op ($2, $$, $3); }
1076 | expr_no_commas RSHIFT expr_no_commas
1077 { $$ = build_x_binary_op ($2, $$, $3); }
1078 | expr_no_commas ARITHCOMPARE expr_no_commas
1079 { $$ = build_x_binary_op ($2, $$, $3); }
1080 | expr_no_commas '<' expr_no_commas
1081 { $$ = build_x_binary_op (LT_EXPR, $$, $3); }
1082 | expr_no_commas '>' expr_no_commas
1083 { $$ = build_x_binary_op (GT_EXPR, $$, $3); }
1084 | expr_no_commas EQCOMPARE expr_no_commas
1085 { $$ = build_x_binary_op ($2, $$, $3); }
1086 | expr_no_commas MIN_MAX expr_no_commas
1087 { $$ = build_x_binary_op ($2, $$, $3); }
1088 | expr_no_commas '&' expr_no_commas
1089 { $$ = build_x_binary_op ($2, $$, $3); }
1090 | expr_no_commas '|' expr_no_commas
1091 { $$ = build_x_binary_op ($2, $$, $3); }
1092 | expr_no_commas '^' expr_no_commas
1093 { $$ = build_x_binary_op ($2, $$, $3); }
1094 | expr_no_commas ANDAND expr_no_commas
1095 { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $$, $3); }
1096 | expr_no_commas OROR expr_no_commas
1097 { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $$, $3); }
1098 | expr_no_commas '?' xexpr ':' expr_no_commas
1099 { $$ = build_x_conditional_expr ($$, $3, $5); }
1100 | expr_no_commas '=' expr_no_commas
1101 { $$ = build_x_modify_expr ($$, NOP_EXPR, $3);
1102 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
1103 | expr_no_commas ASSIGN expr_no_commas
1104 { $$ = build_x_modify_expr ($$, $2, $3); }
1106 { $$ = build_throw (NULL_TREE); }
1107 | THROW expr_no_commas
1108 { $$ = build_throw ($2); }
1109 /* These extensions are not defined. The second arg to build_m_component_ref
1110 is old, build_m_component_ref now does an implicit
1111 build_indirect_ref (x, NULL_PTR) on the second argument.
1112 | object '&' expr_no_commas %prec UNARY
1113 { $$ = build_m_component_ref ($$, build_x_unary_op (ADDR_EXPR, $3)); }
1114 | object unop expr_no_commas %prec UNARY
1115 { $$ = build_m_component_ref ($$, build_x_unary_op ($2, $3)); }
1116 | object '(' type_id ')' expr_no_commas %prec UNARY
1117 { tree type = groktypename ($3);
1118 $$ = build_m_component_ref ($$, build_c_cast (type, $5, 0)); }
1119 | object primary_no_id %prec UNARY
1120 { $$ = build_m_component_ref ($$, $2); }
1124 notype_unqualified_id:
1125 '~' see_typename identifier
1126 { $$ = build_parse_node (BIT_NOT_EXPR, $3); }
1130 | NSNAME %prec EMPTY
1134 notype_unqualified_id
1139 notype_unqualified_id
1140 | '*' expr_or_declarator %prec UNARY
1141 { $$ = build_parse_node (INDIRECT_REF, $2); }
1142 | '&' expr_or_declarator %prec UNARY
1143 { $$ = build_parse_node (ADDR_EXPR, $2); }
1144 | '(' expr_or_declarator ')'
1148 direct_notype_declarator:
1149 complex_direct_notype_declarator
1150 | notype_unqualified_id
1151 | '(' expr_or_declarator ')'
1152 { $$ = finish_decl_parsing ($2); }
1156 notype_unqualified_id
1158 if (TREE_CODE ($$) == BIT_NOT_EXPR)
1159 $$ = build_x_unary_op (BIT_NOT_EXPR, TREE_OPERAND ($$, 0));
1161 $$ = do_identifier ($$, 1);
1167 if (current_template_parms)
1168 push_obstacks (&permanent_obstack, &permanent_obstack);
1169 $$ = combine_strings ($$);
1170 if (current_template_parms)
1176 class = TREE_CODE_CLASS (TREE_CODE ($$));
1177 if (class == 'e' || class == '1'
1178 || class == '2' || class == '<')
1179 /* This inhibits warnings in truthvalue_conversion. */
1180 C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK); }
1181 | '(' expr_or_declarator ')'
1183 $$ = reparse_decl_as_expr (NULL_TREE, $2);
1184 class = TREE_CODE_CLASS (TREE_CODE ($$));
1185 if (class == 'e' || class == '1'
1186 || class == '2' || class == '<')
1187 /* This inhibits warnings in truthvalue_conversion. */
1188 C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK); }
1190 { $$ = error_mark_node; }
1192 { if (current_function_decl == 0)
1194 error ("braced-group within expression allowed only inside a function");
1198 $<ttype>$ = expand_start_stmt_expr (); }
1202 pedwarn ("ANSI C++ forbids braced-groups within expressions");
1203 rtl_exp = expand_end_stmt_expr ($<ttype>2);
1204 /* The statements have side effects, so the group does. */
1205 TREE_SIDE_EFFECTS (rtl_exp) = 1;
1207 if (TREE_CODE ($3) == BLOCK)
1209 /* Make a BIND_EXPR for the BLOCK already made. */
1210 $$ = build (BIND_EXPR, TREE_TYPE (rtl_exp),
1211 NULL_TREE, rtl_exp, $3);
1212 /* Remove the block from the tree at this point.
1213 It gets put back at the proper place
1214 when the BIND_EXPR is expanded. */
1220 | primary '(' nonnull_exprlist ')'
1222 $$ = build_x_function_call ($1, $3, current_class_decl);
1223 if (TREE_CODE ($$) == CALL_EXPR
1224 && TREE_TYPE ($$) != void_type_node)
1225 $$ = require_complete_type ($$);
1227 | primary LEFT_RIGHT
1229 $$ = build_x_function_call ($$, NULL_TREE, current_class_decl);
1230 if (TREE_CODE ($$) == CALL_EXPR
1231 && TREE_TYPE ($$) != void_type_node)
1232 $$ = require_complete_type ($$);
1234 | primary '[' expr ']'
1235 { $$ = grok_array_decl ($$, $3); }
1237 { /* If we get an OFFSET_REF, turn it into what it really
1238 means (e.g., a COMPONENT_REF). This way if we've got,
1239 say, a reference to a static member that's being operated
1240 on, we don't end up trying to find a member operator for
1241 the class it's in. */
1242 if (TREE_CODE ($$) == OFFSET_REF)
1243 $$ = resolve_offset_ref ($$);
1244 $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); }
1245 | primary MINUSMINUS
1246 { if (TREE_CODE ($$) == OFFSET_REF)
1247 $$ = resolve_offset_ref ($$);
1248 $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); }
1249 /* C++ extensions */
1251 { if (current_class_decl)
1253 #ifdef WARNING_ABOUT_CCD
1254 TREE_USED (current_class_decl) = 1;
1256 $$ = current_class_decl;
1258 else if (current_function_decl
1259 && DECL_STATIC_FUNCTION_P (current_function_decl))
1261 error ("`this' is unavailable for static member functions");
1262 $$ = error_mark_node;
1266 if (current_function_decl)
1267 error ("invalid use of `this' in non-member function");
1269 error ("invalid use of `this' at top level");
1270 $$ = error_mark_node;
1273 | TYPE_QUAL '(' nonnull_exprlist ')'
1278 /* This is a C cast in C++'s `functional' notation. */
1279 if ($3 == error_mark_node)
1281 $$ = error_mark_node;
1285 if ($3 == NULL_TREE)
1287 error ("cannot cast null list to type `%s'",
1288 IDENTIFIER_POINTER (TYPE_NAME (id)));
1289 $$ = error_mark_node;
1294 /* type is not set! (mrs) */
1295 if (type == error_mark_node)
1296 $$ = error_mark_node;
1300 if (id == ridpointers[(int) RID_CONST])
1301 type = build_type_variant (integer_type_node, 1, 0);
1302 else if (id == ridpointers[(int) RID_VOLATILE])
1303 type = build_type_variant (integer_type_node, 0, 1);
1305 /* should not be able to get here (mrs) */
1306 else if (id == ridpointers[(int) RID_FRIEND])
1308 error ("cannot cast expression to `friend' type");
1309 $$ = error_mark_node;
1313 else my_friendly_abort (79);
1314 $$ = build_c_cast (type, build_compound_expr ($3), 1);
1319 { dont_allow_type_definitions = "inside dynamic_cast"; }
1321 { dont_allow_type_definitions = 0; }
1323 { tree type = groktypename ($4);
1324 $$ = build_dynamic_cast (type, $8); }
1326 { dont_allow_type_definitions = "inside static_cast"; }
1328 { dont_allow_type_definitions = 0; }
1330 { tree type = groktypename ($4);
1331 $$ = build_static_cast (type, $8); }
1332 | REINTERPRET_CAST '<'
1333 { dont_allow_type_definitions = "inside reinterpret_cast"; }
1335 { dont_allow_type_definitions = 0; }
1337 { tree type = groktypename ($4);
1338 $$ = build_reinterpret_cast (type, $8); }
1340 { dont_allow_type_definitions = "inside const_cast"; }
1342 { dont_allow_type_definitions = 0; }
1344 { tree type = groktypename ($4);
1345 $$ = build_const_cast (type, $8); }
1346 | TYPEID '(' expr ')'
1347 { $$ = build_typeid ($3); }
1348 | TYPEID '(' type_id ')'
1349 { tree type = groktypename ($3);
1350 $$ = get_typeid (TYPE_MAIN_VARIANT (type)); }
1351 | global_scope IDENTIFIER
1352 { $$ = do_scoped_id ($2, 1); }
1353 | global_scope operator_name
1355 got_scope = NULL_TREE;
1356 if (TREE_CODE ($2) == IDENTIFIER_NODE)
1357 $$ = do_scoped_id ($2, 1);
1361 | overqualified_id %prec HYPERUNARY
1362 { $$ = build_offset_ref (OP0 ($$), OP1 ($$)); }
1363 | overqualified_id '(' nonnull_exprlist ')'
1364 { if (current_template_parms)
1365 $$ = build_min_nt (CALL_EXPR, copy_to_permanent ($1), $3, 0);
1367 $$ = build_member_call (OP0 ($$), OP1 ($$), $3); }
1368 | overqualified_id LEFT_RIGHT
1369 { if (current_template_parms)
1370 $$ = build_min_nt (CALL_EXPR, copy_to_permanent ($1),
1373 $$ = build_member_call (OP0 ($$), OP1 ($$), NULL_TREE); }
1374 | object unqualified_id %prec UNARY
1375 { $$ = build_component_ref ($$, $2, NULL_TREE, 1); }
1376 | object overqualified_id %prec UNARY
1377 { if (current_template_parms)
1378 $$ = build_min_nt (COMPONENT_REF, $1, copy_to_permanent ($2));
1380 $$ = build_object_ref ($$, OP0 ($2), OP1 ($2)); }
1381 | object unqualified_id '(' nonnull_exprlist ')'
1384 /* This is a future direction of this code, but because
1385 build_x_function_call cannot always undo what is done
1386 in build_component_ref entirely yet, we cannot do this. */
1387 $$ = build_x_function_call (build_component_ref ($$, $2, NULL_TREE, 1), $4, $$);
1388 if (TREE_CODE ($$) == CALL_EXPR
1389 && TREE_TYPE ($$) != void_type_node)
1390 $$ = require_complete_type ($$);
1392 $$ = build_method_call ($$, $2, $4, NULL_TREE,
1393 (LOOKUP_NORMAL|LOOKUP_AGGR));
1396 | object unqualified_id LEFT_RIGHT
1399 /* This is a future direction of this code, but because
1400 build_x_function_call cannot always undo what is done
1401 in build_component_ref entirely yet, we cannot do this. */
1402 $$ = build_x_function_call (build_component_ref ($$, $2, NULL_TREE, 1), NULL_TREE, $$);
1403 if (TREE_CODE ($$) == CALL_EXPR
1404 && TREE_TYPE ($$) != void_type_node)
1405 $$ = require_complete_type ($$);
1407 $$ = build_method_call ($$, $2, NULL_TREE, NULL_TREE,
1408 (LOOKUP_NORMAL|LOOKUP_AGGR));
1411 | object overqualified_id '(' nonnull_exprlist ')'
1413 if (IS_SIGNATURE (OP0 ($2)))
1415 warning ("signature name in scope resolution ignored");
1416 $$ = build_method_call ($$, OP1 ($2), $4, NULL_TREE,
1417 (LOOKUP_NORMAL|LOOKUP_AGGR));
1420 $$ = build_scoped_method_call ($$, OP0 ($2), OP1 ($2), $4);
1422 | object overqualified_id LEFT_RIGHT
1424 if (IS_SIGNATURE (OP0 ($2)))
1426 warning ("signature name in scope resolution ignored");
1427 $$ = build_method_call ($$, OP1 ($2), NULL_TREE, NULL_TREE,
1428 (LOOKUP_NORMAL|LOOKUP_AGGR));
1431 $$ = build_scoped_method_call ($$, OP0 ($2), OP1 ($2), NULL_TREE);
1433 /* p->int::~int() is valid -- 12.4 */
1434 | object '~' TYPESPEC LEFT_RIGHT
1436 if (IDENTIFIER_GLOBAL_VALUE ($3)
1437 && (TREE_CODE (TREE_TYPE ($1))
1438 != TREE_CODE (TREE_TYPE (IDENTIFIER_GLOBAL_VALUE ($3)))))
1439 cp_error ("`%E' is not of type `%T'", $1, $3);
1440 $$ = convert (void_type_node, $1);
1442 | object TYPESPEC SCOPE '~' TYPESPEC LEFT_RIGHT
1445 cp_error ("destructor specifier `%T::~%T()' must have matching names", $2, $5);
1446 if (TREE_CODE (TREE_TYPE ($1))
1447 != TREE_CODE (TREE_TYPE (IDENTIFIER_GLOBAL_VALUE ($2))))
1448 cp_error ("`%E' is not of type `%T'", $1, $2);
1449 $$ = convert (void_type_node, $1);
1453 $$ = error_mark_node;
1457 /* Not needed for now.
1463 { $$ = error_mark_node; }
1465 { if (current_function_decl == 0)
1467 error ("braced-group within expression allowed only inside a function");
1470 $<ttype>$ = expand_start_stmt_expr (); }
1473 pedwarn ("ANSI C++ forbids braced-groups within expressions");
1474 $$ = expand_end_stmt_expr ($<ttype>2); }
1475 | primary_no_id '(' nonnull_exprlist ')'
1476 { $$ = build_x_function_call ($$, $3, current_class_decl); }
1477 | primary_no_id LEFT_RIGHT
1478 { $$ = build_x_function_call ($$, NULL_TREE, current_class_decl); }
1479 | primary_no_id '[' expr ']'
1481 | primary_no_id PLUSPLUS
1482 { $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); }
1483 | primary_no_id MINUSMINUS
1484 { $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); }
1486 { goto do_scoped_id; }
1487 | SCOPE operator_name
1488 { if (TREE_CODE ($2) == IDENTIFIER_NODE)
1490 goto do_scoped_operator;
1498 { got_scope = NULL_TREE; $$ = 1; }
1503 | global_scope delete
1504 { got_scope = NULL_TREE; $$ = 1; }
1509 { $$ = boolean_true_node; }
1511 { $$ = boolean_false_node; }
1514 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
1518 { $$ = chainon ($$, $2); }
1524 if (! current_function_parms_stored)
1525 store_parm_decls ();
1527 /* Always keep the BLOCK node associated with the outermost
1528 pair of curley braces of a function. These are needed
1529 for correct operation of dwarfout.c. */
1535 { got_object = TREE_TYPE ($$); }
1538 $$ = build_x_arrow ($$);
1539 got_object = TREE_TYPE ($$);
1544 /* Normal case: make this fast. */
1545 typespec declarator ';'
1546 { tree d = get_decl_list ($1);
1547 int yes = suspend_momentary ();
1548 d = start_decl ($2, d, 0, NULL_TREE);
1549 cp_finish_decl (d, NULL_TREE, NULL_TREE, 1, 0);
1550 resume_momentary (yes);
1551 if (IS_AGGR_TYPE_CODE (TREE_CODE ($1)))
1552 note_got_semicolon ($1);
1554 | typed_declspecs declarator ';'
1555 { tree d, specs, attrs;
1557 split_specs_attrs ($1, &specs, &attrs);
1558 yes = suspend_momentary ();
1559 d = start_decl ($2, specs, 0, NULL_TREE);
1560 cplus_decl_attributes (d, NULL_TREE, attrs);
1561 cp_finish_decl (d, NULL_TREE, NULL_TREE, 1, 0);
1562 resume_momentary (yes);
1563 note_list_got_semicolon ($1);
1565 | typespec initdecls ';'
1567 resume_momentary ($2);
1568 if (IS_AGGR_TYPE_CODE (TREE_CODE ($1)))
1569 note_got_semicolon ($1);
1571 | typed_declspecs initdecls ';'
1573 resume_momentary ($2);
1574 note_list_got_semicolon ($1);
1576 | declmods notype_initdecls ';'
1577 { resume_momentary ($2); }
1578 | typed_declspecs ';'
1581 note_list_got_semicolon ($1);
1584 { warning ("empty declaration"); }
1587 /* Any kind of declarator (thus, all declarators allowed
1588 after an explicit typespec). */
1591 after_type_declarator %prec EMPTY
1592 | notype_declarator %prec EMPTY
1595 /* This is necessary to postpone reduction of `int()()()()'. */
1597 LEFT_RIGHT %prec EMPTY
1598 { $$ = build_parse_node (CALL_EXPR, NULL_TREE, empty_parms (),
1600 | fcast_or_absdcl LEFT_RIGHT %prec EMPTY
1601 { $$ = build_parse_node (CALL_EXPR, $$, empty_parms (),
1605 /* ANSI type-id (8.1) */
1607 typed_typespecs absdcl
1608 { $$ = build_decl_list ($$, $2); }
1609 | nonempty_type_quals absdcl
1610 { $$ = build_decl_list ($$, $2); }
1612 { $$ = build_decl_list (get_decl_list ($$), $2); }
1613 | typed_typespecs %prec EMPTY
1614 { $$ = build_decl_list ($$, NULL_TREE); }
1615 | nonempty_type_quals %prec EMPTY
1616 { $$ = build_decl_list ($$, NULL_TREE); }
1619 /* Declspecs which contain at least one type specifier or typedef name.
1620 (Just `const' or `volatile' is not enough.)
1621 A typedef'd name following these is taken as a name to be declared.
1622 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1625 typed_typespecs %prec EMPTY
1631 { $$ = decl_tree_cons (NULL_TREE, $2, $$); }
1632 | typespec reserved_declspecs %prec HYPERUNARY
1633 { $$ = decl_tree_cons (NULL_TREE, $$, $2); }
1634 | typespec reserved_typespecquals reserved_declspecs
1635 { $$ = decl_tree_cons (NULL_TREE, $$, chainon ($2, $3)); }
1636 | declmods typespec reserved_declspecs
1637 { $$ = decl_tree_cons (NULL_TREE, $2, chainon ($3, $$)); }
1638 | declmods typespec reserved_typespecquals
1639 { $$ = decl_tree_cons (NULL_TREE, $2, chainon ($3, $$)); }
1640 | declmods typespec reserved_typespecquals reserved_declspecs
1641 { $$ = decl_tree_cons (NULL_TREE, $2,
1642 chainon ($3, chainon ($4, $$))); }
1647 { if (extra_warnings)
1648 warning ("`%s' is not at beginning of declaration",
1649 IDENTIFIER_POINTER ($$));
1650 $$ = build_decl_list (NULL_TREE, $$); }
1651 | reserved_declspecs typespecqual_reserved
1652 { $$ = decl_tree_cons (NULL_TREE, $2, $$); }
1653 | reserved_declspecs SCSPEC
1654 { if (extra_warnings)
1655 warning ("`%s' is not at beginning of declaration",
1656 IDENTIFIER_POINTER ($2));
1657 $$ = decl_tree_cons (NULL_TREE, $2, $$); }
1658 | reserved_declspecs attributes
1659 { $$ = decl_tree_cons ($2, NULL_TREE, $1); }
1661 { $$ = decl_tree_cons ($1, NULL_TREE, NULL_TREE); }
1664 /* List of just storage classes and type modifiers.
1665 A declaration can start with just this, but then it cannot be used
1666 to redeclare a typedef-name.
1667 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1670 nonempty_type_quals %prec EMPTY
1671 { TREE_STATIC ($$) = 1; }
1673 { $$ = IDENTIFIER_AS_LIST ($$); }
1674 | declmods TYPE_QUAL
1675 { $$ = decl_tree_cons (NULL_TREE, $2, $$);
1676 TREE_STATIC ($$) = 1; }
1678 { if (extra_warnings && TREE_STATIC ($$))
1679 warning ("`%s' is not at beginning of declaration",
1680 IDENTIFIER_POINTER ($2));
1681 $$ = decl_tree_cons (NULL_TREE, $2, $$);
1682 TREE_STATIC ($$) = TREE_STATIC ($1); }
1683 | declmods attributes
1684 { $$ = decl_tree_cons ($2, NULL_TREE, $1); }
1686 { $$ = decl_tree_cons ($1, NULL_TREE, NULL_TREE); }
1689 /* Used instead of declspecs where storage classes are not allowed
1690 (that is, for typenames and structure components).
1692 C++ can takes storage classes for structure components.
1693 Don't accept a typedef-name if anything but a modifier precedes it. */
1696 typespec %prec EMPTY
1697 { $$ = get_decl_list ($$); }
1698 | nonempty_type_quals typespec
1699 { $$ = decl_tree_cons (NULL_TREE, $2, $$); }
1700 | typespec reserved_typespecquals
1701 { $$ = decl_tree_cons (NULL_TREE, $$, $2); }
1702 | nonempty_type_quals typespec reserved_typespecquals
1703 { $$ = decl_tree_cons (NULL_TREE, $2, chainon ($3, $$)); }
1706 reserved_typespecquals:
1707 typespecqual_reserved
1708 { $$ = build_decl_list (NULL_TREE, $$); }
1709 | reserved_typespecquals typespecqual_reserved
1710 { $$ = decl_tree_cons (NULL_TREE, $2, $$); }
1713 /* A typespec (but not a type qualifier).
1714 Once we have seen one of these in a declaration,
1715 if a typedef name appears then it is being redeclared. */
1718 | TYPESPEC %prec EMPTY
1719 | complete_type_name
1720 | TYPEOF '(' expr ')'
1721 { $$ = TREE_TYPE ($3);
1722 if (pedantic && !in_system_header)
1723 pedwarn ("ANSI C++ forbids `typeof'"); }
1724 | TYPEOF '(' type_id ')'
1725 { $$ = groktypename ($3);
1726 if (pedantic && !in_system_header)
1727 pedwarn ("ANSI C++ forbids `typeof'"); }
1728 | SIGOF '(' expr ')'
1729 { tree type = TREE_TYPE ($3);
1731 if (IS_AGGR_TYPE (type))
1733 sorry ("sigof type specifier");
1738 error ("`sigof' applied to non-aggregate expression");
1739 $$ = error_mark_node;
1742 | SIGOF '(' type_id ')'
1743 { tree type = groktypename ($3);
1745 if (IS_AGGR_TYPE (type))
1747 sorry ("sigof type specifier");
1752 error("`sigof' applied to non-aggregate type");
1753 $$ = error_mark_node;
1758 /* A typespec that is a reserved word, or a type qualifier. */
1760 typespecqual_reserved: TYPESPEC
1767 | initdecls ',' initdcl
1772 | notype_initdecls ',' initdcl
1777 | nomods_initdecls ',' initdcl
1783 | asm_keyword '(' string ')'
1784 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3); $$ = $3; }
1788 declarator exception_specification_opt maybeasm maybe_attribute '='
1789 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
1790 &prefix_attributes);
1791 if (TREE_CODE (current_declspecs) != TREE_LIST)
1792 current_declspecs = get_decl_list (current_declspecs);
1793 if (have_extern_spec && !used_extern_spec)
1795 current_declspecs = decl_tree_cons
1796 (NULL_TREE, get_identifier ("extern"),
1798 used_extern_spec = 1;
1800 $<itype>5 = suspend_momentary ();
1801 $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1, $2);
1802 cplus_decl_attributes ($<ttype>$, $4, prefix_attributes); }
1804 /* Note how the declaration of the variable is in effect while its init is parsed! */
1805 { cp_finish_decl ($<ttype>6, $7, $3, 1, LOOKUP_ONLYCONVERTING);
1807 | declarator exception_specification_opt maybeasm maybe_attribute
1809 split_specs_attrs ($<ttype>0, ¤t_declspecs,
1810 &prefix_attributes);
1811 if (TREE_CODE (current_declspecs) != TREE_LIST)
1812 current_declspecs = get_decl_list (current_declspecs);
1813 if (have_extern_spec && !used_extern_spec)
1815 current_declspecs = decl_tree_cons
1816 (NULL_TREE, get_identifier ("extern"),
1818 used_extern_spec = 1;
1820 $$ = suspend_momentary ();
1821 d = start_decl ($<ttype>1, current_declspecs, 0, $2);
1822 cplus_decl_attributes (d, $4, prefix_attributes);
1823 cp_finish_decl (d, NULL_TREE, $3, 1, 0); }
1827 declarator exception_specification_opt maybeasm maybe_attribute '='
1828 { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1, $2);
1829 cplus_decl_attributes ($<ttype>$, $4, prefix_attributes); }
1831 /* Note how the declaration of the variable is in effect while its init is parsed! */
1832 { cp_finish_decl ($<ttype>6, $7, $3, 1, LOOKUP_ONLYCONVERTING); }
1833 | declarator exception_specification_opt maybeasm maybe_attribute
1834 { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 0, $2);
1835 cplus_decl_attributes ($<ttype>$, $4, prefix_attributes);
1836 cp_finish_decl ($<ttype>$, NULL_TREE, $3, 1, 0); }
1840 notype_declarator exception_specification_opt maybeasm maybe_attribute '='
1841 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
1842 &prefix_attributes);
1843 $<itype>5 = suspend_momentary ();
1844 $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1, $2);
1845 cplus_decl_attributes ($<ttype>$, $4, prefix_attributes); }
1847 /* Note how the declaration of the variable is in effect while its init is parsed! */
1848 { cp_finish_decl ($<ttype>6, $7, $3, 1, LOOKUP_ONLYCONVERTING);
1850 | notype_declarator exception_specification_opt maybeasm maybe_attribute
1852 split_specs_attrs ($<ttype>0, ¤t_declspecs,
1853 &prefix_attributes);
1854 $$ = suspend_momentary ();
1855 d = start_decl ($<ttype>1, current_declspecs, 0, $2);
1856 cplus_decl_attributes (d, $4, prefix_attributes);
1857 cp_finish_decl (d, NULL_TREE, $3, 1, 0); }
1861 notype_declarator exception_specification_opt maybeasm maybe_attribute '='
1862 { current_declspecs = NULL_TREE;
1863 prefix_attributes = NULL_TREE;
1864 $<itype>5 = suspend_momentary ();
1865 $<ttype>$ = start_decl ($1, current_declspecs, 1, $2);
1866 cplus_decl_attributes ($<ttype>$, $4, prefix_attributes); }
1868 /* Note how the declaration of the variable is in effect while its init is parsed! */
1869 { cp_finish_decl ($<ttype>6, $7, $3, 1, LOOKUP_ONLYCONVERTING);
1871 | notype_declarator exception_specification_opt maybeasm maybe_attribute
1873 current_declspecs = NULL_TREE;
1874 prefix_attributes = NULL_TREE;
1875 $$ = suspend_momentary ();
1876 d = start_decl ($1, current_declspecs, 0, $2);
1877 cplus_decl_attributes (d, $4, prefix_attributes);
1878 cp_finish_decl (d, NULL_TREE, $3, 1, 0); }
1881 /* the * rules are dummies to accept the Apollo extended syntax
1882 so that the header files compile. */
1893 | attributes attribute
1894 { $$ = chainon ($1, $2); }
1898 ATTRIBUTE '(' '(' attribute_list ')' ')'
1905 | attribute_list ',' attrib
1906 { $$ = chainon ($1, $3); }
1913 { $$ = build_tree_list ($1, NULL_TREE); }
1914 | any_word '(' IDENTIFIER ')'
1915 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1916 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1917 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1918 | any_word '(' nonnull_exprlist ')'
1919 { $$ = build_tree_list ($1, $3); }
1922 /* This still leaves out most reserved keywords,
1923 shouldn't we include them? */
1932 /* A nonempty list of identifiers, including typenames. */
1933 identifiers_or_typenames:
1935 { $$ = build_tree_list (NULL_TREE, $1); }
1936 | identifiers_or_typenames ',' identifier
1937 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
1941 %prec EMPTY /* empty */
1946 /* If we are processing a template, we don't want to expand this
1950 expr_no_commas %prec '='
1952 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, NULL_TREE);
1953 TREE_HAS_CONSTRUCTOR ($$) = 1; }
1955 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
1956 TREE_HAS_CONSTRUCTOR ($$) = 1; }
1957 | '{' initlist ',' '}'
1958 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
1959 TREE_HAS_CONSTRUCTOR ($$) = 1; }
1964 /* This chain is built in reverse order,
1965 and put in forward order where initlist is used. */
1968 { $$ = build_tree_list (NULL_TREE, $$); }
1970 { $$ = tree_cons (NULL_TREE, $3, $$); }
1971 /* These are for labeled elements. */
1972 | '[' expr_no_commas ']' init
1973 { $$ = build_tree_list ($2, $4); }
1974 | initlist ',' CASE expr_no_commas ':' init
1975 { $$ = tree_cons ($4, $6, $$); }
1976 | identifier ':' init
1977 { $$ = build_tree_list ($$, $3); }
1978 | initlist ',' identifier ':' init
1979 { $$ = tree_cons ($3, $5, $$); }
1983 PRE_PARSED_FUNCTION_DECL
1984 { start_function (NULL_TREE, TREE_VALUE ($1),
1985 NULL_TREE, NULL_TREE, 1);
1986 reinit_parse_for_function (); }
1990 | pending_inlines fn.defpen maybe_return_init ctor_initializer_opt
1993 finish_function (lineno, (int)$4, 0);
1994 process_next_inline ($2);
1996 | pending_inlines fn.defpen maybe_return_init function_try_block
1997 { process_next_inline ($2); }
2003 { $<itype>3 = suspend_momentary ();
2004 $$ = start_enum ($2); }
2005 enumlist maybecomma_warn '}'
2006 { $$ = finish_enum ($<ttype>4, $5);
2007 resume_momentary ((int) $<itype>3);
2008 check_for_missing_semicolon ($<ttype>4); }
2009 | ENUM identifier '{' '}'
2010 { $$ = finish_enum (start_enum ($2), NULL_TREE);
2011 check_for_missing_semicolon ($$); }
2013 { $<itype>2 = suspend_momentary ();
2014 $$ = start_enum (make_anon_name ()); }
2015 enumlist maybecomma_warn '}'
2016 { $$ = finish_enum ($<ttype>3, $4);
2017 resume_momentary ((int) $<itype>1);
2018 check_for_missing_semicolon ($<ttype>3); }
2020 { $$ = finish_enum (start_enum (make_anon_name()), NULL_TREE);
2021 check_for_missing_semicolon ($$); }
2023 { $$ = xref_tag (enum_type_node, $2, NULL_TREE, 1); }
2024 | ENUM complex_type_name
2025 { $$ = xref_tag (enum_type_node, $2, NULL_TREE, 1); }
2026 | TYPENAME_KEYWORD nested_name_specifier identifier
2027 { $$ = make_typename_type ($2, $3); }
2028 | TYPENAME_KEYWORD global_scope nested_name_specifier identifier
2029 { $$ = make_typename_type ($3, $4); }
2030 /* C++ extensions, merged with C to avoid shift/reduce conflicts */
2031 | class_head left_curly opt.component_decl_list '}' maybe_attribute
2037 /* Need to rework class nesting in the
2038 presence of nested classes, etc. */
2039 shadow_tag (CLASSTYPE_AS_LIST ($1)); */
2041 if (yychar == YYEMPTY)
2043 semi = yychar == ';';
2044 /* finish_struct nukes this anyway; if
2045 finish_exception does too, then it can go. */
2047 note_got_semicolon ($1);
2049 if (TREE_CODE ($1) == ENUMERAL_TYPE)
2053 $<ttype>$ = finish_struct ($1, $3, $5, semi);
2054 if (semi) note_got_semicolon ($<ttype>$);
2060 check_for_missing_semicolon ($1);
2062 && current_scope () == current_function_decl)
2063 do_pending_inlines ();
2067 | class_head %prec EMPTY
2069 /* struct B: public A; is not accepted by the WP grammar. */
2070 if (TYPE_BINFO_BASETYPES ($$) && !TYPE_SIZE ($$)
2071 && ! TYPE_BEING_DEFINED ($$))
2072 cp_error ("base clause without member specification for `%#T'",
2085 { if (pedantic) pedwarn ("comma at end of enumerator list"); }
2090 { error ("storage class specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2092 { error ("type specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2094 { error ("type qualifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2096 { error ("no body nor ';' separates two class, struct or union declarations"); }
2099 named_class_head_sans_basetype:
2101 { current_aggr = $$; $$ = $2; }
2104 named_class_head_sans_basetype_defn:
2105 aggr identifier_defn %prec EMPTY
2106 { current_aggr = $$; $$ = $2; }
2109 named_complex_class_head_sans_basetype:
2110 aggr nested_name_specifier identifier
2111 { current_aggr = $$; $$ = $3; }
2112 | aggr template_type
2113 { current_aggr = $$; $$ = $2; }
2114 | aggr nested_name_specifier template_type
2115 { current_aggr = $$; $$ = $3; }
2118 do_xref_defn: /* empty */ %prec EMPTY
2119 { $<ttype>$ = xref_tag (current_aggr, $<ttype>0, NULL_TREE, 0); }
2123 named_class_head_sans_basetype %prec EMPTY
2124 { $$ = xref_tag (current_aggr, $1, NULL_TREE, 1); }
2125 | named_class_head_sans_basetype_defn do_xref_defn
2126 maybe_base_class_list %prec EMPTY
2130 xref_basetypes (current_aggr, $1, $<ttype>2, $3);
2132 | named_complex_class_head_sans_basetype maybe_base_class_list
2134 $$ = TREE_TYPE ($1);
2135 if (TREE_INT_CST_LOW (current_aggr) == union_type
2136 && TREE_CODE ($$) != UNION_TYPE)
2137 cp_pedwarn ("`union' tag used in declaring `%#T'", $$);
2138 else if (TREE_CODE ($$) == UNION_TYPE
2139 && TREE_INT_CST_LOW (current_aggr) != union_type)
2140 cp_pedwarn ("non-`union' tag used in declaring `%#T'", $$);
2143 if (IS_AGGR_TYPE ($$) && CLASSTYPE_USE_TEMPLATE ($$))
2145 if (CLASSTYPE_IMPLICIT_INSTANTIATION ($$)
2146 && TYPE_SIZE ($$) == NULL_TREE)
2147 SET_CLASSTYPE_TEMPLATE_SPECIALIZATION ($$);
2148 else if (CLASSTYPE_TEMPLATE_INSTANTIATION ($$))
2149 cp_error ("specialization after instantiation of `%T'", $$);
2151 xref_basetypes (current_aggr, $1, $$, $2);
2156 unnamed_class_head: aggr '{'
2157 { $$ = xref_tag ($$, make_anon_name (), NULL_TREE, 0);
2158 yyungetc ('{', 1); }
2161 class_head: unnamed_class_head | named_class_head ;
2163 maybe_base_class_list:
2164 %prec EMPTY /* empty */
2166 | ':' see_typename %prec EMPTY
2167 { yyungetc(':', 1); $$ = NULL_TREE; }
2168 | ':' see_typename base_class_list %prec EMPTY
2174 | base_class_list ',' see_typename base_class
2175 { $$ = chainon ($$, $4); }
2181 tree type = TREE_TYPE ($1);
2182 if (! is_aggr_type (type, 1))
2184 else if (current_aggr == signature_type_node
2185 && (! type) && (! IS_SIGNATURE (type)))
2187 error ("class name not allowed as base signature");
2190 else if (current_aggr == signature_type_node)
2192 sorry ("signature inheritance, base type `%s' ignored",
2193 IDENTIFIER_POINTER ($$));
2194 $$ = build_tree_list (access_public_node, type);
2196 else if (type && IS_SIGNATURE (type))
2198 error ("signature name not allowed as base class");
2202 $$ = build_tree_list (access_default_node, type);
2204 | base_class_access_list see_typename base_class.1
2206 tree type = TREE_TYPE ($3);
2207 if (current_aggr == signature_type_node)
2208 error ("access and source specifiers not allowed in signature");
2209 if (! IS_AGGR_TYPE (type))
2211 else if (current_aggr == signature_type_node
2212 && (! type) && (! IS_SIGNATURE (type)))
2214 error ("class name not allowed as base signature");
2217 else if (current_aggr == signature_type_node)
2219 sorry ("signature inheritance, base type `%s' ignored",
2220 IDENTIFIER_POINTER ($$));
2221 $$ = build_tree_list (access_public_node, type);
2223 else if (type && IS_SIGNATURE (type))
2225 error ("signature name not allowed as base class");
2229 $$ = build_tree_list ($$, type);
2235 | SIGOF '(' expr ')'
2237 if (current_aggr == signature_type_node)
2239 if (IS_AGGR_TYPE (TREE_TYPE ($3)))
2241 sorry ("`sigof' as base signature specifier");
2242 $$ = TREE_TYPE ($3);
2246 error ("`sigof' applied to non-aggregate expression");
2247 $$ = error_mark_node;
2252 error ("`sigof' in struct or class declaration");
2253 $$ = error_mark_node;
2256 | SIGOF '(' type_id ')'
2258 if (current_aggr == signature_type_node)
2260 if (IS_AGGR_TYPE (groktypename ($3)))
2262 sorry ("`sigof' as base signature specifier");
2263 $$ = groktypename ($3);
2267 error ("`sigof' applied to non-aggregate expression");
2268 $$ = error_mark_node;
2273 error ("`sigof' in struct or class declaration");
2274 $$ = error_mark_node;
2279 base_class_access_list:
2280 VISSPEC see_typename
2281 | SCSPEC see_typename
2282 { if ($<ttype>$ != ridpointers[(int)RID_VIRTUAL])
2283 sorry ("non-virtual access");
2284 $$ = access_default_virtual_node; }
2285 | base_class_access_list VISSPEC see_typename
2287 if ($2 == access_protected_node)
2289 warning ("`protected' access not implemented");
2290 $2 = access_public_node;
2293 else if ($2 == access_public_node)
2295 if ($1 == access_private_node)
2298 error ("base class cannot be public and private");
2300 else if ($1 == access_default_virtual_node)
2301 $$ = access_public_virtual_node;
2303 else /* $2 == access_private_node */
2305 if ($1 == access_public_node)
2307 else if ($1 == access_default_virtual_node)
2308 $$ = access_private_virtual_node;
2311 | base_class_access_list SCSPEC see_typename
2312 { if ($2 != ridpointers[(int)RID_VIRTUAL])
2313 sorry ("non-virtual access");
2314 if ($$ == access_public_node)
2315 $$ = access_public_virtual_node;
2316 else if ($$ == access_private_node)
2317 $$ = access_private_virtual_node; }
2321 { tree t = $<ttype>0;
2322 push_obstacks_nochange ();
2323 end_temporary_allocation ();
2325 if (! IS_AGGR_TYPE (t))
2327 t = $<ttype>0 = make_lang_type (RECORD_TYPE);
2328 TYPE_NAME (t) = get_identifier ("erroneous type");
2331 duplicate_tag_error (t);
2332 if (TYPE_SIZE (t) || TYPE_BEING_DEFINED (t))
2334 t = make_lang_type (TREE_CODE (t));
2335 pushtag (TYPE_IDENTIFIER ($<ttype>0), t, 0);
2338 if (current_template_parms && TYPE_CONTEXT (t)
2339 && ! current_class_type)
2340 push_template_decl (TYPE_STUB_DECL (t));
2342 TYPE_BEING_DEFINED (t) = 1;
2343 if (IS_AGGR_TYPE (t) && CLASSTYPE_USE_TEMPLATE (t))
2345 if (CLASSTYPE_IMPLICIT_INSTANTIATION (t)
2346 && TYPE_SIZE (t) == NULL_TREE)
2347 SET_CLASSTYPE_TEMPLATE_SPECIALIZATION (t);
2348 else if (CLASSTYPE_TEMPLATE_INSTANTIATION (t))
2349 cp_error ("specialization after instantiation of `%T'", t);
2351 /* Reset the interface data, at the earliest possible
2352 moment, as it might have been set via a class foo;
2354 /* Don't change signatures. */
2355 if (! IS_SIGNATURE (t))
2357 extern tree pending_vtables;
2359 tree name = TYPE_IDENTIFIER (t);
2361 if (! ANON_AGGRNAME_P (name))
2363 CLASSTYPE_INTERFACE_ONLY (t) = interface_only;
2364 SET_CLASSTYPE_INTERFACE_UNKNOWN_X
2365 (t, interface_unknown);
2368 /* Record how to set the access of this class's
2369 virtual functions. If write_virtuals == 2 or 3, then
2370 inline virtuals are ``extern inline''. */
2371 switch (write_virtuals)
2378 needs_writing = !! value_member (name, pending_vtables);
2381 needs_writing = ! CLASSTYPE_INTERFACE_ONLY (t)
2382 && CLASSTYPE_INTERFACE_KNOWN (t);
2387 CLASSTYPE_VTABLE_NEEDS_WRITING (t) = needs_writing;
2390 t = TYPE_IDENTIFIER ($<ttype>0);
2391 if (t && IDENTIFIER_TEMPLATE (t))
2392 overload_template_name (t, 1);
2397 opt.component_decl_list:
2400 | component_decl_list
2402 if (current_aggr == signature_type_node)
2403 $$ = build_tree_list (access_public_node, $$);
2405 $$ = build_tree_list (access_default_node, $$);
2407 | opt.component_decl_list VISSPEC ':' component_decl_list
2411 if (current_aggr == signature_type_node)
2413 error ("access specifier not allowed in signature");
2414 visspec = access_public_node;
2416 $$ = chainon ($$, build_tree_list (visspec, $4));
2418 | opt.component_decl_list VISSPEC ':'
2420 if (current_aggr == signature_type_node)
2421 error ("access specifier not allowed in signature");
2425 /* Note: we no longer warn about the semicolon after a component_decl_list.
2426 ARM $9.2 says that the semicolon is optional, and therefore allowed. */
2427 component_decl_list:
2429 { if ($$ == void_type_node) $$ = NULL_TREE;
2431 | component_decl_list component_decl
2432 { /* In pushdecl, we created a reverse list of names
2433 in this binding level. Make sure that the chain
2434 of what we're trying to add isn't the item itself
2435 (which can happen with what pushdecl's doing). */
2436 if ($2 != NULL_TREE && $2 != void_type_node)
2438 if (TREE_CHAIN ($2) != $$)
2439 $$ = chainon ($$, $2);
2447 component_decl_1 ';'
2449 | component_decl_1 '}'
2450 { error ("missing ';' before right brace");
2451 yyungetc ('}', 0); }
2452 /* C++: handle constructors, destructors and inline functions */
2453 /* note that INLINE is like a TYPESPEC */
2454 | fn.def2 ':' /* base_init compstmt */
2455 { $$ = finish_method ($$); }
2456 | fn.def2 TRY /* base_init compstmt */
2457 { $$ = finish_method ($$); }
2458 | fn.def2 RETURN /* base_init compstmt */
2459 { $$ = finish_method ($$); }
2460 | fn.def2 '{' /* nodecls compstmt */
2461 { $$ = finish_method ($$); }
2467 /* Do not add a "typed_declspecs declarator" rule here for
2468 speed; we need to call grok_x_components for enums, so the
2469 speedup would be insignificant. */
2470 typed_declspecs components
2471 { $$ = grok_x_components ($1, $2); }
2472 | declmods notype_components
2473 { $$ = grok_x_components ($1, $2); }
2474 | notype_declarator exception_specification_opt maybeasm maybe_attribute maybe_init
2475 { $$ = grokfield ($$, NULL_TREE, $2, $5, $3,
2476 build_tree_list ($4, NULL_TREE)); }
2477 | ':' expr_no_commas
2478 { $$ = grokbitfield (NULL_TREE, NULL_TREE, $2); }
2482 /* These rules introduce a reduce/reduce conflict; in
2483 typedef int foo, bar;
2487 should "A::foo" be declared as a function or "A::bar" as a data
2488 member? In other words, is "bar" an after_type_declarator or a
2490 | typed_declspecs '(' parmlist ')' type_quals exception_specification_opt maybeasm maybe_attribute maybe_init
2491 { tree specs, attrs;
2492 split_specs_attrs ($1, &specs, &attrs);
2493 if (TREE_VALUE (specs) == current_class_type)
2495 if (TREE_CHAIN (specs) == NULL_TREE)
2496 specs = get_decl_list (current_class_name);
2498 TREE_VALUE (specs) = current_class_name;
2500 $$ = build_parse_node (CALL_EXPR, TREE_VALUE (specs),
2502 $$ = grokfield ($$, TREE_CHAIN (specs), $6, $9, $7,
2503 build_tree_list ($8, attrs)); }
2504 | typed_declspecs LEFT_RIGHT type_quals exception_specification_opt maybeasm maybe_attribute maybe_init
2505 { tree specs, attrs;
2506 split_specs_attrs ($1, &specs, &attrs);
2507 if (TREE_VALUE (specs) == current_class_type)
2509 if (TREE_CHAIN (specs) == NULL_TREE)
2510 specs = get_decl_list (current_class_name);
2512 TREE_VALUE (specs) = current_class_name;
2514 $$ = build_parse_node (CALL_EXPR, TREE_VALUE (specs),
2515 empty_parms (), $3);
2516 $$ = grokfield ($$, TREE_CHAIN (specs), $4, $7, $5,
2517 build_tree_list ($6, attrs)); }
2519 { $$ = do_class_using_decl ($1); }
2522 /* The case of exactly one component is handled directly by component_decl. */
2525 /* empty: possibly anonymous */
2527 | component_declarator0
2528 | components ',' component_declarator
2530 /* In this context, void_type_node encodes
2531 friends. They have been recorded elsewhere. */
2532 if ($$ == void_type_node)
2535 $$ = chainon ($$, $3);
2540 /* empty: possibly anonymous */
2542 | notype_component_declarator0
2543 | notype_components ',' notype_component_declarator
2545 /* In this context, void_type_node encodes
2546 friends. They have been recorded elsewhere. */
2547 if ($$ == void_type_node)
2550 $$ = chainon ($$, $3);
2554 component_declarator0:
2555 after_type_component_declarator0
2556 | notype_component_declarator0
2559 component_declarator:
2560 after_type_component_declarator
2561 | notype_component_declarator
2564 after_type_component_declarator0:
2565 after_type_declarator exception_specification_opt maybeasm maybe_attribute maybe_init
2566 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2567 &prefix_attributes);
2568 $<ttype>0 = current_declspecs;
2569 $$ = grokfield ($$, current_declspecs, $2, $5, $3,
2570 build_tree_list ($4, prefix_attributes)); }
2571 | TYPENAME ':' expr_no_commas maybe_attribute
2572 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2573 &prefix_attributes);
2574 $<ttype>0 = current_declspecs;
2575 $$ = grokbitfield ($$, current_declspecs, $3);
2576 cplus_decl_attributes ($$, $4, prefix_attributes); }
2579 notype_component_declarator0:
2580 notype_declarator exception_specification_opt maybeasm maybe_attribute maybe_init
2581 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2582 &prefix_attributes);
2583 $<ttype>0 = current_declspecs;
2584 $$ = grokfield ($$, current_declspecs, $2, $5, $3,
2585 build_tree_list ($4, prefix_attributes)); }
2586 | IDENTIFIER ':' expr_no_commas maybe_attribute
2587 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2588 &prefix_attributes);
2589 $<ttype>0 = current_declspecs;
2590 $$ = grokbitfield ($$, current_declspecs, $3);
2591 cplus_decl_attributes ($$, $4, prefix_attributes); }
2592 | ':' expr_no_commas maybe_attribute
2593 { split_specs_attrs ($<ttype>0, ¤t_declspecs,
2594 &prefix_attributes);
2595 $<ttype>0 = current_declspecs;
2596 $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
2597 cplus_decl_attributes ($$, $3, prefix_attributes); }
2600 after_type_component_declarator:
2601 after_type_declarator exception_specification_opt maybeasm maybe_attribute maybe_init
2602 { $$ = grokfield ($$, current_declspecs, $2, $5, $3,
2603 build_tree_list ($4, prefix_attributes)); }
2604 | TYPENAME ':' expr_no_commas maybe_attribute
2605 { $$ = grokbitfield ($$, current_declspecs, $3);
2606 cplus_decl_attributes ($$, $4, prefix_attributes); }
2609 notype_component_declarator:
2610 notype_declarator exception_specification_opt maybeasm maybe_attribute maybe_init
2611 { $$ = grokfield ($$, current_declspecs, $2, $5, $3,
2612 build_tree_list ($4, prefix_attributes)); }
2613 | IDENTIFIER ':' expr_no_commas maybe_attribute
2614 { $$ = grokbitfield ($$, current_declspecs, $3);
2615 cplus_decl_attributes ($$, $4, prefix_attributes); }
2616 | ':' expr_no_commas maybe_attribute
2617 { $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
2618 cplus_decl_attributes ($$, $3, prefix_attributes); }
2621 /* We chain the enumerators in reverse order.
2622 Because of the way enums are built, the order is
2623 insignificant. Take advantage of this fact. */
2627 | enumlist ',' enumerator
2628 { TREE_CHAIN ($3) = $$; $$ = $3; }
2633 { $$ = build_enumerator ($$, NULL_TREE); }
2634 | identifier '=' expr_no_commas
2635 { $$ = build_enumerator ($$, $3); }
2638 /* ANSI new-type-id (5.3.4) */
2640 type_specifier_seq new_declarator
2641 { $$ = build_decl_list ($$, $2); }
2642 | type_specifier_seq %prec EMPTY
2643 { $$ = build_decl_list ($$, NULL_TREE); }
2644 /* GNU extension to allow arrays of arbitrary types with
2645 non-constant dimension. */
2646 | '(' type_id ')' '[' expr ']'
2649 pedwarn ("ANSI C++ forbids array dimensions with parenthesized type in new");
2650 $$ = build_parse_node (ARRAY_REF, TREE_VALUE ($2), $5);
2651 $$ = build_decl_list (TREE_PURPOSE ($2), $$);
2656 /* empty */ %prec EMPTY
2658 | type_quals TYPE_QUAL
2659 { $$ = decl_tree_cons (NULL_TREE, $2, $$); }
2662 nonempty_type_quals:
2664 { $$ = IDENTIFIER_AS_LIST ($$); }
2665 | nonempty_type_quals TYPE_QUAL
2666 { $$ = decl_tree_cons (NULL_TREE, $2, $$); }
2669 /* These rules must follow the rules for function declarations
2670 and component declarations. That way, longer rules are preferred. */
2673 { $<itype>$ = suspend_momentary (); }
2675 /* An expression which will not live on the momentary obstack. */
2678 { resume_momentary ((int) $<itype>1); $$ = $2; }
2681 /* An expression which will not live on the momentary obstack. */
2683 suspend_mom '(' nonnull_exprlist ')'
2684 { resume_momentary ((int) $<itype>1); $$ = $3; }
2685 | suspend_mom '(' parmlist ')'
2686 { resume_momentary ((int) $<itype>1); $$ = $3; }
2687 | suspend_mom LEFT_RIGHT
2688 { resume_momentary ((int) $<itype>1); $$ = empty_parms (); }
2689 | suspend_mom '(' error ')'
2690 { resume_momentary ((int) $<itype>1); $$ = NULL_TREE; }
2693 /* A declarator that is allowed only after an explicit typespec. */
2694 /* may all be followed by prec '.' */
2695 after_type_declarator:
2696 '*' nonempty_type_quals after_type_declarator %prec UNARY
2697 { $$ = make_pointer_declarator ($2, $3); }
2698 | '&' nonempty_type_quals after_type_declarator %prec UNARY
2699 { $$ = make_reference_declarator ($2, $3); }
2700 | '*' after_type_declarator %prec UNARY
2701 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2702 | '&' after_type_declarator %prec UNARY
2703 { $$ = make_reference_declarator (NULL_TREE, $2); }
2704 | ptr_to_mem type_quals after_type_declarator
2705 { tree arg = make_pointer_declarator ($2, $3);
2706 $$ = build_parse_node (SCOPE_REF, $1, arg);
2708 | direct_after_type_declarator
2712 type_name %prec EMPTY
2714 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2716 if (current_class_type
2717 && TYPE_BEING_DEFINED (current_class_type)
2718 && ! TREE_MANGLED ($1)
2719 && ! IDENTIFIER_CLASS_VALUE ($1))
2721 /* Be sure to get an inherited typedef. */
2722 $$ = lookup_name ($1, 1);
2723 /* Remember that this name has been used in the class
2724 definition, as per [class.scope0] */
2725 pushdecl_class_level ($$);
2728 $$ = identifier_typedecl_value ($1);
2733 | global_scope type_name
2735 if (TREE_CODE ($2) == IDENTIFIER_NODE)
2737 if (current_class_type
2738 && TYPE_BEING_DEFINED (current_class_type)
2739 && ! TREE_MANGLED ($2)
2740 && ! IDENTIFIER_CLASS_VALUE ($2))
2741 /* Be sure to get an inherited typedef. */
2742 $$ = lookup_name ($2, 1);
2744 $$ = identifier_typedecl_value ($2);
2748 got_scope = NULL_TREE;
2751 | global_scope nested_type
2756 nested_name_specifier type_name %prec EMPTY
2757 { $$ = get_type_decl ($2); }
2760 direct_after_type_declarator:
2761 direct_after_type_declarator maybe_parmlist type_quals %prec '.'
2762 { $$ = build_parse_node (CALL_EXPR, $$, $2, $3); }
2763 | direct_after_type_declarator '[' nonmomentary_expr ']'
2764 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
2765 | direct_after_type_declarator '[' ']'
2766 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
2767 | '(' after_type_declarator ')'
2769 | nested_name_specifier type_name %prec EMPTY
2770 { push_nested_class (TREE_TYPE ($$), 3);
2771 $$ = build_parse_node (SCOPE_REF, $$, $2);
2772 TREE_COMPLEXITY ($$) = current_class_depth; }
2773 | type_name %prec EMPTY
2776 /* A declarator allowed whether or not there has been
2777 an explicit typespec. These cannot redeclare a typedef-name. */
2780 '*' nonempty_type_quals notype_declarator %prec UNARY
2781 { $$ = make_pointer_declarator ($2, $3); }
2782 | '&' nonempty_type_quals notype_declarator %prec UNARY
2783 { $$ = make_reference_declarator ($2, $3); }
2784 | '*' notype_declarator %prec UNARY
2785 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2786 | '&' notype_declarator %prec UNARY
2787 { $$ = make_reference_declarator (NULL_TREE, $2); }
2788 | ptr_to_mem type_quals notype_declarator
2789 { tree arg = make_pointer_declarator ($2, $3);
2790 $$ = build_parse_node (SCOPE_REF, $1, arg);
2792 | direct_notype_declarator
2795 complex_notype_declarator:
2796 '*' nonempty_type_quals notype_declarator %prec UNARY
2797 { $$ = make_pointer_declarator ($2, $3); }
2798 | '&' nonempty_type_quals notype_declarator %prec UNARY
2799 { $$ = make_reference_declarator ($2, $3); }
2800 | '*' complex_notype_declarator %prec UNARY
2801 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2802 | '&' complex_notype_declarator %prec UNARY
2803 { $$ = make_reference_declarator (NULL_TREE, $2); }
2804 | ptr_to_mem type_quals notype_declarator
2805 { tree arg = make_pointer_declarator ($2, $3);
2806 $$ = build_parse_node (SCOPE_REF, $1, arg);
2808 | complex_direct_notype_declarator
2811 complex_direct_notype_declarator:
2812 direct_notype_declarator maybe_parmlist type_quals %prec '.'
2813 { $$ = build_parse_node (CALL_EXPR, $$, $2, $3); }
2814 | '(' complex_notype_declarator ')'
2816 | direct_notype_declarator '[' nonmomentary_expr ']'
2817 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
2818 | direct_notype_declarator '[' ']'
2819 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
2820 | notype_qualified_id
2821 { if (OP0 ($$) != current_class_type)
2823 push_nested_class (OP0 ($$), 3);
2824 TREE_COMPLEXITY ($$) = current_class_depth;
2830 nested_name_specifier unqualified_id
2831 { got_scope = NULL_TREE;
2832 $$ = build_parse_node (SCOPE_REF, $$, $2); }
2835 notype_qualified_id:
2836 nested_name_specifier notype_unqualified_id
2837 { got_scope = NULL_TREE;
2838 $$ = build_parse_node (SCOPE_REF, $$, $2); }
2843 | global_scope notype_qualified_id
2848 typespec '(' nonnull_exprlist ')'
2849 { $$ = build_functional_cast ($$, $3); }
2850 | typespec '(' expr_or_declarator ')'
2851 { $$ = reparse_decl_as_expr ($$, $3); }
2852 | typespec fcast_or_absdcl %prec EMPTY
2853 { $$ = reparse_absdcl_as_expr ($$, $2); }
2858 | template_type %prec EMPTY
2861 nested_name_specifier:
2862 nested_name_specifier_1
2863 | nested_name_specifier nested_name_specifier_1
2867 /* Why the @#$%^& do type_name and notype_identifier need to be expanded
2868 inline here?!? (jason) */
2869 nested_name_specifier_1:
2873 /* Remember that this name has been used in the class
2874 definition, as per [class.scope0] */
2875 if (current_class_type
2876 && TYPE_BEING_DEFINED (current_class_type)
2877 && ! TREE_MANGLED ($1)
2878 && ! IDENTIFIER_CLASS_VALUE ($1))
2879 pushdecl_class_level ($$);
2880 got_scope = $$ = TREE_TYPE ($$);
2883 { got_scope = $$ = $1; }
2884 | template_type SCOPE
2885 { got_scope = $$ = complete_type (TREE_TYPE ($1)); }
2886 /* These break 'const i;'
2890 cp_error ("`%D' is not an aggregate typedef",
2891 lastiddecl ? lastiddecl : $$);
2892 $$ = error_mark_node;
2895 { goto failed_scope; } */
2899 global_scope type_name
2901 if (TREE_CODE ($2) == IDENTIFIER_NODE)
2903 if (current_class_type
2904 && TYPE_BEING_DEFINED (current_class_type)
2905 && ! TREE_MANGLED ($2)
2906 && ! IDENTIFIER_CLASS_VALUE ($2))
2907 /* Be sure to get an inherited typedef. */
2908 $$ = lookup_name ($2, 1);
2910 $$ = identifier_typedecl_value ($2);
2914 got_scope = NULL_TREE;
2917 | global_scope nested_type
2922 nested_name_specifier '*'
2923 { got_scope = NULL_TREE; }
2924 | global_scope nested_name_specifier '*'
2925 { $$ = $2; got_scope = NULL_TREE; }
2928 /* All uses of explicit global scope must go through this nonterminal so
2929 that got_scope will be set before yylex is called to get the next token. */
2932 { got_scope = void_type_node; }
2935 /* ANSI new-declarator (5.3.4) */
2937 '*' type_quals new_declarator
2938 { $$ = make_pointer_declarator ($2, $3); }
2939 | '*' type_quals %prec EMPTY
2940 { $$ = make_pointer_declarator ($2, NULL_TREE); }
2941 | '&' type_quals new_declarator %prec EMPTY
2942 { $$ = make_reference_declarator ($2, $3); }
2943 | '&' type_quals %prec EMPTY
2944 { $$ = make_reference_declarator ($2, NULL_TREE); }
2945 | ptr_to_mem type_quals %prec EMPTY
2946 { tree arg = make_pointer_declarator ($2, NULL_TREE);
2947 $$ = build_parse_node (SCOPE_REF, $1, arg);
2949 | ptr_to_mem type_quals new_declarator
2950 { tree arg = make_pointer_declarator ($2, $3);
2951 $$ = build_parse_node (SCOPE_REF, $1, arg);
2953 | direct_new_declarator %prec EMPTY
2956 /* ANSI direct-new-declarator (5.3.4) */
2957 direct_new_declarator:
2959 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
2960 | direct_new_declarator '[' nonmomentary_expr ']'
2961 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
2964 /* ANSI abstract-declarator (8.1) */
2966 '*' nonempty_type_quals absdcl
2967 { $$ = make_pointer_declarator ($2, $3); }
2969 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2970 | '*' nonempty_type_quals %prec EMPTY
2971 { $$ = make_pointer_declarator ($2, NULL_TREE); }
2973 { $$ = make_pointer_declarator (NULL_TREE, NULL_TREE); }
2974 | '&' nonempty_type_quals absdcl
2975 { $$ = make_reference_declarator ($2, $3); }
2977 { $$ = make_reference_declarator (NULL_TREE, $2); }
2978 | '&' nonempty_type_quals %prec EMPTY
2979 { $$ = make_reference_declarator ($2, NULL_TREE); }
2981 { $$ = make_reference_declarator (NULL_TREE, NULL_TREE); }
2982 | ptr_to_mem type_quals %prec EMPTY
2983 { tree arg = make_pointer_declarator ($2, NULL_TREE);
2984 $$ = build_parse_node (SCOPE_REF, $1, arg);
2986 | ptr_to_mem type_quals absdcl
2987 { tree arg = make_pointer_declarator ($2, $3);
2988 $$ = build_parse_node (SCOPE_REF, $1, arg);
2990 | direct_abstract_declarator %prec EMPTY
2993 /* ANSI direct-abstract-declarator (8.1) */
2994 direct_abstract_declarator:
2997 /* `(typedef)1' is `int'. */
2999 | direct_abstract_declarator '(' parmlist ')' type_quals %prec '.'
3000 { $$ = build_parse_node (CALL_EXPR, $$, $3, $5); }
3001 | direct_abstract_declarator LEFT_RIGHT type_quals %prec '.'
3002 { $$ = build_parse_node (CALL_EXPR, $$, empty_parms (), $3); }
3003 | direct_abstract_declarator '[' nonmomentary_expr ']' %prec '.'
3004 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3005 | direct_abstract_declarator '[' ']' %prec '.'
3006 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
3007 | '(' complex_parmlist ')' type_quals %prec '.'
3008 { $$ = build_parse_node (CALL_EXPR, NULL_TREE, $2, $4); }
3009 | regcast_or_absdcl type_quals %prec '.'
3010 { TREE_OPERAND ($$, 2) = $2; }
3011 | fcast_or_absdcl type_quals %prec '.'
3012 { TREE_OPERAND ($$, 2) = $2; }
3013 | '[' nonmomentary_expr ']' %prec '.'
3014 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3016 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, NULL_TREE); }
3019 /* For C++, decls and stmts can be intermixed, so we don't need to
3020 have a special rule that won't start parsing the stmt section
3021 until we have a stmt that parses without errors. */
3033 /* build the LET_STMT node before parsing its contents,
3034 so that any LET_STMTs within the context can have their display pointers
3035 set up to point at this one. */
3037 .pushlevel: /* empty */
3038 { do_pushlevel (); }
3041 .poplevel: /* empty */
3042 { $$ = do_poplevel (); }
3045 /* Read zero or more forward-declarations for labels
3046 that nested functions can jump to. */
3051 pedwarn ("ANSI C++ forbids label declarations"); }
3056 | label_decls label_decl
3060 LABEL identifiers_or_typenames ';'
3062 for (link = $2; link; link = TREE_CHAIN (link))
3064 tree label = shadow_label (TREE_VALUE (link));
3065 C_DECLARED_LABEL_FLAG (label) = 1;
3066 declare_nonlocal_label (label);
3071 /* This is the body of a function definition.
3072 It causes syntax errors to ignore to the next openbrace. */
3081 if (current_template_parms)
3083 $<ttype>$ = build_min_nt (COMPOUND_STMT, NULL_TREE);
3084 add_tree ($<ttype>$);
3087 .pushlevel compstmtend .poplevel
3089 if (current_template_parms)
3091 TREE_OPERAND ($<ttype>2, 0) = TREE_CHAIN ($<ttype>2);
3092 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3093 last_tree = $<ttype>2;
3102 if (current_template_parms)
3104 $<ttype>$ = build_min_nt (IF_STMT, NULL_TREE, NULL_TREE,
3106 add_tree ($<ttype>$);
3108 cond_stmt_keyword = "if";
3110 .pushlevel paren_cond_or_null
3112 if (current_template_parms)
3114 if (last_tree != $<ttype>2)
3116 TREE_OPERAND ($<ttype>2, 0) = last_tree;
3117 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3118 last_tree = $<ttype>2;
3121 TREE_OPERAND ($<ttype>2, 0) = $4;
3125 emit_line_note (input_filename, lineno);
3126 expand_start_cond ($4, 0);
3129 implicitly_scoped_stmt
3131 if (current_template_parms)
3133 TREE_OPERAND ($<ttype>2, 1) = TREE_CHAIN ($<ttype>2);
3134 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3135 $<ttype>$ = last_tree = $<ttype>2;
3140 implicitly_scoped_stmt:
3145 if (current_template_parms)
3147 $<ttype>$ = build_min_nt (COMPOUND_STMT, NULL_TREE);
3148 add_tree ($<ttype>$);
3151 simple_stmt .poplevel
3153 if (current_template_parms)
3155 TREE_OPERAND ($<ttype>2, 0) = TREE_CHAIN ($<ttype>2);
3156 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3157 last_tree = $<ttype>2;
3175 if (! current_template_parms)
3177 emit_line_note (input_filename, lineno);
3178 /* Do default conversion if safe and possibly important,
3179 in case within ({...}). */
3180 if ((TREE_CODE (TREE_TYPE (expr)) == ARRAY_TYPE
3182 || TREE_CODE (TREE_TYPE (expr)) == FUNCTION_TYPE)
3183 expr = default_conversion (expr);
3185 cplus_expand_expr_stmt (expr);
3189 { if (! current_template_parms) expand_start_else (); }
3190 implicitly_scoped_stmt
3192 if (current_template_parms)
3194 TREE_OPERAND ($<ttype>1, 2) = TREE_CHAIN ($<ttype>1);
3195 TREE_CHAIN ($<ttype>1) = NULL_TREE;
3196 last_tree = $<ttype>1;
3203 | simple_if %prec IF
3204 { if (! current_template_parms) expand_end_cond ();
3205 expand_end_bindings (getdecls (), kept_level_p (), 1);
3206 poplevel (kept_level_p (), 1, 0);
3211 if (current_template_parms)
3213 $<ttype>$ = build_min_nt (WHILE_STMT, NULL_TREE, NULL_TREE);
3214 add_tree ($<ttype>$);
3219 emit_line_note (input_filename, lineno);
3220 expand_start_loop (1);
3222 cond_stmt_keyword = "while";
3224 .pushlevel paren_cond_or_null
3226 if (current_template_parms)
3228 if (last_tree != $<ttype>2)
3230 TREE_OPERAND ($<ttype>2, 0) = last_tree;
3231 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3232 last_tree = $<ttype>2;
3235 TREE_OPERAND ($<ttype>2, 0) = $4;
3239 emit_line_note (input_filename, lineno);
3240 expand_exit_loop_if_false (0, $4);
3243 already_scoped_stmt .poplevel
3245 if (current_template_parms)
3247 TREE_OPERAND ($<ttype>2, 1) = TREE_CHAIN ($<ttype>2);
3248 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3249 last_tree = $<ttype>2;
3257 if (current_template_parms)
3259 $<ttype>$ = build_min_nt (DO_STMT, NULL_TREE, NULL_TREE);
3260 add_tree ($<ttype>$);
3265 emit_line_note (input_filename, lineno);
3266 expand_start_loop_continue_elsewhere (1);
3269 implicitly_scoped_stmt WHILE
3271 if (current_template_parms)
3273 TREE_OPERAND ($<ttype>2, 0) = TREE_CHAIN ($<ttype>2);
3274 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3275 last_tree = $<ttype>2;
3279 expand_loop_continue_here ();
3280 cond_stmt_keyword = "do";
3283 paren_expr_or_null ';'
3285 if (current_template_parms)
3286 TREE_OPERAND ($<ttype>2, 1) = $6;
3289 emit_line_note (input_filename, lineno);
3290 expand_exit_loop_if_false (0, $6);
3297 { if (current_template_parms)
3299 $<ttype>$ = build_min_nt (FOR_STMT, NULL_TREE, NULL_TREE,
3300 NULL_TREE, NULL_TREE);
3301 add_tree ($<ttype>$);
3304 emit_line_note (input_filename, lineno);
3305 if (flag_new_for_scope > 0)
3307 /* Conditionalize .pushlevel */
3309 note_level_for_for ();
3312 expand_start_bindings (0);
3315 '(' for.init.statement
3317 if (current_template_parms)
3319 if (last_tree != $<ttype>2)
3321 TREE_OPERAND ($<ttype>2, 0) = last_tree;
3322 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3323 last_tree = $<ttype>2;
3329 emit_line_note (input_filename, lineno);
3330 expand_start_loop_continue_elsewhere (1);
3333 .pushlevel xcond ';'
3335 if (current_template_parms)
3337 if (last_tree != $<ttype>2)
3339 TREE_OPERAND ($<ttype>2, 1) = last_tree;
3340 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3341 last_tree = $<ttype>2;
3344 TREE_OPERAND ($<ttype>2, 1) = $7;
3348 emit_line_note (input_filename, lineno);
3349 if ($7) expand_exit_loop_if_false (0, $7);
3353 /* Don't let the tree nodes for $10 be discarded
3354 by clear_momentary during the parsing of the next stmt. */
3356 if (current_template_parms)
3357 TREE_OPERAND ($<ttype>2, 2) = $10;
3360 already_scoped_stmt .poplevel
3362 if (current_template_parms)
3364 TREE_OPERAND ($<ttype>2, 3) = TREE_CHAIN ($<ttype>2);
3365 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3366 last_tree = $<ttype>2;
3370 emit_line_note (input_filename, lineno);
3371 expand_loop_continue_here ();
3372 if ($10) cplus_expand_expr_stmt ($10);
3376 if (flag_new_for_scope > 0)
3378 expand_end_bindings (getdecls (), kept_level_p (), 1);
3379 poplevel (kept_level_p (), 1, 0);
3383 | SWITCH .pushlevel '(' condition ')'
3385 if (current_template_parms)
3387 $<ttype>$ = build_min_nt (SWITCH_STMT, $4, NULL_TREE);
3388 add_tree ($<ttype>$);
3392 emit_line_note (input_filename, lineno);
3393 c_expand_start_case ($4);
3396 /* Don't let the tree nodes for $4 be discarded by
3397 clear_momentary during the parsing of the next stmt. */
3400 implicitly_scoped_stmt
3402 if (current_template_parms)
3404 TREE_OPERAND ($<ttype>6, 1) = TREE_CHAIN ($<ttype>6);
3405 TREE_CHAIN ($<ttype>6) = NULL_TREE;
3406 last_tree = $<ttype>6;
3409 expand_end_case ($4);
3415 | CASE expr_no_commas ':'
3416 { do_case ($2, NULL_TREE); }
3418 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
3419 { do_case ($2, $4); }
3422 { do_case (NULL_TREE, NULL_TREE); }
3425 { emit_line_note (input_filename, lineno);
3426 if (current_template_parms)
3427 add_tree (build_min_nt (BREAK_STMT));
3428 else if ( ! expand_exit_something ())
3429 error ("break statement not within loop or switch"); }
3431 { emit_line_note (input_filename, lineno);
3432 if (current_template_parms)
3433 add_tree (build_min_nt (CONTINUE_STMT));
3434 else if (! expand_continue_loop (0))
3435 error ("continue statement not within a loop"); }
3437 { emit_line_note (input_filename, lineno);
3438 c_expand_return (NULL_TREE); }
3440 { emit_line_note (input_filename, lineno);
3441 c_expand_return ($2);
3444 | asm_keyword maybe_type_qual '(' string ')' ';'
3445 { if (TREE_CHAIN ($4)) $4 = combine_strings ($4);
3446 emit_line_note (input_filename, lineno);
3450 /* This is the case with just output operands. */
3451 | asm_keyword maybe_type_qual '(' string ':' asm_operands ')' ';'
3452 { if (TREE_CHAIN ($4)) $4 = combine_strings ($4);
3453 emit_line_note (input_filename, lineno);
3454 c_expand_asm_operands ($4, $6, NULL_TREE, NULL_TREE,
3455 $2 == ridpointers[(int)RID_VOLATILE],
3456 input_filename, lineno);
3459 /* This is the case with input operands as well. */
3460 | asm_keyword maybe_type_qual '(' string ':' asm_operands ':' asm_operands ')' ';'
3461 { if (TREE_CHAIN ($4)) $4 = combine_strings ($4);
3462 emit_line_note (input_filename, lineno);
3463 c_expand_asm_operands ($4, $6, $8, NULL_TREE,
3464 $2 == ridpointers[(int)RID_VOLATILE],
3465 input_filename, lineno);
3468 /* This is the case with clobbered registers as well. */
3469 | asm_keyword maybe_type_qual '(' string ':' asm_operands ':'
3470 asm_operands ':' asm_clobbers ')' ';'
3471 { if (TREE_CHAIN ($4)) $4 = combine_strings ($4);
3472 emit_line_note (input_filename, lineno);
3473 c_expand_asm_operands ($4, $6, $8, $10,
3474 $2 == ridpointers[(int)RID_VOLATILE],
3475 input_filename, lineno);
3480 if (current_template_parms)
3481 add_tree (build_min_nt (GOTO_STMT, $3));
3483 { emit_line_note (input_filename, lineno);
3484 expand_computed_goto ($3); }
3486 | GOTO identifier ';'
3488 if (current_template_parms)
3489 add_tree (build_min_nt (GOTO_STMT, $2));
3493 emit_line_note (input_filename, lineno);
3494 decl = lookup_label ($2);
3495 TREE_USED (decl) = 1;
3502 { error ("label must be followed by statement");
3513 if (! current_function_parms_stored)
3514 store_parm_decls ();
3515 expand_start_early_try_stmts ();
3517 ctor_initializer_opt compstmt_or_error
3518 { expand_end_try_stmts ();
3519 expand_start_all_catch (); }
3522 expand_end_all_catch ();
3523 finish_function (lineno, (int)$3, 0);
3529 { expand_start_try_stmts (); }
3531 { expand_end_try_stmts ();
3532 expand_start_all_catch (); }
3534 { expand_end_all_catch (); }
3539 | handler_seq CATCH .pushlevel
3540 { dont_allow_type_definitions = "inside exception declarations"; }
3542 { dont_allow_type_definitions = 0; }
3544 { expand_end_catch_block (); }
3549 typed_typespecs %prec EMPTY
3550 | nonempty_type_quals %prec EMPTY
3555 { expand_start_catch_block (NULL_TREE, NULL_TREE); }
3556 /* This doesn't allow reference parameters, the below does.
3557 | '(' type_specifier_seq absdcl ')'
3558 { expand_start_catch_block ($2, $3); }
3559 | '(' type_specifier_seq ')'
3560 { expand_start_catch_block ($2, NULL_TREE); }
3561 | '(' type_specifier_seq notype_declarator ')'
3562 { expand_start_catch_block ($2, $3); }
3563 | '(' typed_typespecs after_type_declarator ')'
3564 { expand_start_catch_block ($2, $3); }
3565 This allows reference parameters... */
3567 { expand_start_catch_block (TREE_PURPOSE ($2),
3575 label = define_label (input_filename, lineno, $1);
3576 if (label && ! minimal_parse_mode)
3577 expand_label (label);
3587 { if ($1) cplus_expand_expr_stmt ($1); }
3591 pedwarn ("ANSI C++ forbids compound statements inside for initializations");
3595 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
3599 { emit_line_note (input_filename, lineno);
3602 { emit_line_note (input_filename, lineno); }
3613 /* These are the operands other than the first string and colon
3614 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
3615 asm_operands: /* empty */
3617 | nonnull_asm_operands
3620 nonnull_asm_operands:
3622 | nonnull_asm_operands ',' asm_operand
3623 { $$ = chainon ($$, $3); }
3628 { $$ = build_tree_list ($$, $3); }
3633 { $$ = tree_cons (NULL_TREE, $$, NULL_TREE); }
3634 | asm_clobbers ',' STRING
3635 { $$ = tree_cons (NULL_TREE, $3, $$); }
3638 /* This is what appears inside the parens in a function declarator.
3639 Its value is represented in the format that grokdeclarator expects.
3641 In C++, declaring a function with no parameters
3642 means that that function takes *no* parameters. */
3644 parmlist: /* empty */
3646 if (strict_prototype)
3647 $$ = void_list_node;
3653 { $$ = tree_cons (NULL_TREE, $$, void_list_node);
3654 TREE_PARMLIST ($$) = 1; }
3657 /* This nonterminal does not include the common sequence '(' type_id ')',
3658 as it is ambiguous and must be disambiguated elsewhere. */
3662 $$ = chainon ($$, void_list_node);
3663 TREE_PARMLIST ($$) = 1;
3665 | parms_comma ELLIPSIS
3667 TREE_PARMLIST ($$) = 1;
3669 /* C++ allows an ellipsis without a separating ',' */
3672 TREE_PARMLIST ($$) = 1;
3676 $$ = build_tree_list (NULL_TREE, $$);
3677 TREE_PARMLIST ($$) = 1;
3681 /* ARM $8.2.5 has this as a boxed-off comment. */
3683 warning ("use of `...' without a first argument is non-portable");
3688 TREE_PARMLIST ($$) = 1;
3690 | parms TYPENAME_ELLIPSIS
3692 TREE_PARMLIST ($$) = 1;
3694 | type_id TYPENAME_ELLIPSIS
3696 $$ = build_tree_list (NULL_TREE, $$);
3697 TREE_PARMLIST ($$) = 1;
3701 /* This helps us recover from really nasty
3702 parse errors, for example, a missing right
3704 yyerror ("possibly missing ')'");
3705 $$ = chainon ($$, void_list_node);
3706 TREE_PARMLIST ($$) = 1;
3712 /* This helps us recover from really nasty
3713 parse errors, for example, a missing right
3715 yyerror ("possibly missing ')'");
3716 $$ = tree_cons (NULL_TREE, $$, void_list_node);
3717 TREE_PARMLIST ($$) = 1;
3723 /* A nonempty list of parameter declarations or type names. */
3726 { $$ = build_tree_list (NULL_TREE, $$); }
3728 { $$ = build_tree_list ($3, $$); }
3729 | parms_comma full_parm
3730 { $$ = chainon ($$, $2); }
3731 | parms_comma bad_parm
3732 { $$ = chainon ($$, build_tree_list (NULL_TREE, $2)); }
3733 | parms_comma bad_parm '=' init
3734 { $$ = chainon ($$, build_tree_list ($4, $2)); }
3740 { $$ = build_tree_list (NULL_TREE, $$); }
3743 /* A single parameter declaration or parameter type name,
3744 as found in a parmlist. The first four cases make up for 10%
3745 of the time spent parsing C++. We cannot use them because
3746 of `int id[]' which won't get parsed properly. */
3749 typed_declspecs dont_see_typename '*' IDENTIFIER
3750 { tree specs = strip_attrs ($1);
3751 $$ = build_tree_list (specs, build_parse_node (INDIRECT_REF, $4));
3753 | typed_declspecs dont_see_typename '&' IDENTIFIER
3754 { tree specs = strip_attrs ($1);
3755 $$ = build_tree_list (specs, build_parse_node (ADDR_EXPR, $4));
3757 | TYPENAME IDENTIFIER
3758 { $$ = build_tree_list (get_decl_list ($$), $2); }
3759 | TYPESPEC IDENTIFIER
3760 { $$ = build_tree_list (get_decl_list ($$), $2); }
3762 /* Here we expand typed_declspecs inline to avoid mis-parsing of
3763 TYPESPEC IDENTIFIER. */
3764 typed_declspecs1 declarator
3765 { tree specs = strip_attrs ($1);
3766 $$ = build_tree_list (specs, $2); }
3767 | typed_typespecs declarator
3768 { $$ = build_tree_list ($$, $2); }
3769 | typespec declarator
3770 { $$ = build_tree_list (get_decl_list ($$), $2); }
3771 | typed_declspecs1 absdcl
3772 { tree specs = strip_attrs ($1);
3773 $$ = build_tree_list (specs, $2); }
3774 | typed_declspecs1 %prec EMPTY
3775 { tree specs = strip_attrs ($1);
3776 $$ = build_tree_list (specs, NULL_TREE); }
3777 | declmods notype_declarator
3778 { tree specs = strip_attrs ($1);
3779 $$ = build_tree_list (specs, $2); }
3784 { $$ = build_tree_list ($2, $$); }
3792 see_typename: %prec EMPTY
3793 { see_typename (); }
3797 dont_see_typename: %prec EMPTY
3798 { dont_see_typename (); }
3803 if ($<ttype>-1 == error_mark_node)
3808 pushclass ($<ttype>-1, 1);
3815 /* empty */ %prec EMPTY
3817 error ("type specifier omitted for parameter");
3818 $$ = build_tree_list (integer_type_node, NULL_TREE);
3822 error ("type specifier omitted for parameter");
3823 $$ = build_tree_list (integer_type_node, $$);
3827 exception_specification_opt:
3828 %prec EMPTY /* empty */
3830 | THROW '(' ansi_raise_identifiers ')' %prec EMPTY
3832 | THROW LEFT_RIGHT %prec EMPTY
3833 { $$ = build_decl_list (NULL_TREE, NULL_TREE); }
3836 ansi_raise_identifier:
3838 { $$ = build_decl_list (NULL_TREE, groktypename($$)); }
3841 ansi_raise_identifiers:
3842 ansi_raise_identifier
3843 | ansi_raise_identifiers ',' ansi_raise_identifier
3845 TREE_CHAIN ($3) = $$;
3850 conversion_declarator:
3851 /* empty */ %prec EMPTY
3853 | '*' type_quals conversion_declarator
3854 { $$ = make_pointer_declarator ($2, $3); }
3855 | '&' type_quals conversion_declarator
3856 { $$ = make_reference_declarator ($2, $3); }
3857 | ptr_to_mem type_quals conversion_declarator
3858 { tree arg = make_pointer_declarator ($2, $3);
3859 $$ = build_parse_node (SCOPE_REF, $1, arg);
3864 { got_scope = NULL_TREE; }
3869 { $$ = ansi_opname[MULT_EXPR]; }
3871 { $$ = ansi_opname[TRUNC_DIV_EXPR]; }
3873 { $$ = ansi_opname[TRUNC_MOD_EXPR]; }
3875 { $$ = ansi_opname[PLUS_EXPR]; }
3877 { $$ = ansi_opname[MINUS_EXPR]; }
3879 { $$ = ansi_opname[BIT_AND_EXPR]; }
3881 { $$ = ansi_opname[BIT_IOR_EXPR]; }
3883 { $$ = ansi_opname[BIT_XOR_EXPR]; }
3885 { $$ = ansi_opname[BIT_NOT_EXPR]; }
3887 { $$ = ansi_opname[COMPOUND_EXPR]; }
3888 | operator ARITHCOMPARE
3889 { $$ = ansi_opname[$2]; }
3891 { $$ = ansi_opname[LT_EXPR]; }
3893 { $$ = ansi_opname[GT_EXPR]; }
3894 | operator EQCOMPARE
3895 { $$ = ansi_opname[$2]; }
3897 { $$ = ansi_assopname[$2]; }
3899 { $$ = ansi_opname [MODIFY_EXPR]; }
3901 { $$ = ansi_opname[$2]; }
3903 { $$ = ansi_opname[$2]; }
3905 { $$ = ansi_opname[POSTINCREMENT_EXPR]; }
3906 | operator MINUSMINUS
3907 { $$ = ansi_opname[PREDECREMENT_EXPR]; }
3909 { $$ = ansi_opname[TRUTH_ANDIF_EXPR]; }
3911 { $$ = ansi_opname[TRUTH_ORIF_EXPR]; }
3913 { $$ = ansi_opname[TRUTH_NOT_EXPR]; }
3915 { $$ = ansi_opname[COND_EXPR]; }
3917 { $$ = ansi_opname[$2]; }
3918 | operator POINTSAT %prec EMPTY
3919 { $$ = ansi_opname[COMPONENT_REF]; }
3920 | operator POINTSAT_STAR %prec EMPTY
3921 { $$ = ansi_opname[MEMBER_REF]; }
3922 | operator LEFT_RIGHT
3923 { $$ = ansi_opname[CALL_EXPR]; }
3925 { $$ = ansi_opname[ARRAY_REF]; }
3926 | operator NEW %prec EMPTY
3927 { $$ = ansi_opname[NEW_EXPR]; }
3928 | operator DELETE %prec EMPTY
3929 { $$ = ansi_opname[DELETE_EXPR]; }
3930 | operator NEW '[' ']'
3931 { $$ = ansi_opname[VEC_NEW_EXPR]; }
3932 | operator DELETE '[' ']'
3933 { $$ = ansi_opname[VEC_DELETE_EXPR]; }
3934 /* Names here should be looked up in class scope ALSO. */
3935 | operator type_specifier_seq conversion_declarator
3936 { $$ = grokoptypename ($2, $3); }
3938 { $$ = ansi_opname[ERROR_MARK]; }
3945 debug_yytranslate (value)
3948 return yytname[YYTRANSLATE (value)];