1 /* YACC parser for C++ syntax.
2 Copyright (C) 1988, 1989, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000 Free Software Foundation, Inc.
4 Hacked by Michael Tiemann (tiemann@cygnus.com)
6 This file is part of GNU CC.
8 GNU CC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 GNU CC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU CC; see the file COPYING. If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
24 /* This grammar is based on the GNU CC grammar. */
26 /* Note: Bison automatically applies a default action of "$$ = $1" for
27 all derivations; this is applied before the explicit action, if one
28 is given. Keep this in mind when reading the actions. */
31 /* Cause the `yydebug' variable to be defined. */
48 /* Since parsers are distinct for each language, put the language string
49 definition here. (fnf) */
50 const char * const language_string = "GNU C++";
52 extern struct obstack permanent_obstack;
54 /* Like YYERROR but do call yyerror. */
55 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
57 #define OP0(NODE) (TREE_OPERAND (NODE, 0))
58 #define OP1(NODE) (TREE_OPERAND (NODE, 1))
60 /* Contains the statement keyword (if/while/do) to include in an
61 error message if the user supplies an empty conditional expression. */
62 static const char *cond_stmt_keyword;
64 /* Nonzero if we have an `extern "C"' acting as an extern specifier. */
68 /* List of types and structure classes of the current declaration. */
69 static tree current_declspecs;
71 /* List of prefix attributes in effect.
72 Prefix attributes are parsed by the reserved_declspecs and declmods
73 rules. They create a list that contains *both* declspecs and attrs. */
74 /* ??? It is not clear yet that all cases where an attribute can now appear in
75 a declspec list have been updated. */
76 static tree prefix_attributes;
78 /* When defining an enumeration, this is the type of the enumeration. */
79 static tree current_enum_type;
81 /* When parsing a conversion operator name, this is the scope of the
83 static tree saved_scopes;
85 static tree empty_parms PARAMS ((void));
86 static tree parse_decl0 PARAMS ((tree, tree, tree, tree, int));
87 static tree parse_decl PARAMS ((tree, tree, int));
88 static void parse_end_decl PARAMS ((tree, tree, tree));
89 static tree parse_field0 PARAMS ((tree, tree, tree, tree, tree, tree));
90 static tree parse_field PARAMS ((tree, tree, tree, tree));
91 static tree parse_bitfield0 PARAMS ((tree, tree, tree, tree, tree));
92 static tree parse_bitfield PARAMS ((tree, tree, tree));
93 static tree parse_method PARAMS ((tree, tree, tree));
94 static void frob_specs PARAMS ((tree, tree));
96 /* Cons up an empty parameter list. */
102 #ifndef NO_IMPLICIT_EXTERN_C
103 if (in_system_header && current_class_type == NULL
104 && current_lang_name == lang_name_c)
108 parms = void_list_node;
112 /* Record the decl-specifiers, attributes and type lookups from the
113 decl-specifier-seq in a declaration. */
116 frob_specs (specs_attrs, lookups)
117 tree specs_attrs, lookups;
119 save_type_access_control (lookups);
120 split_specs_attrs (specs_attrs, ¤t_declspecs, &prefix_attributes);
121 if (current_declspecs
122 && TREE_CODE (current_declspecs) != TREE_LIST)
123 current_declspecs = build_tree_list (NULL_TREE, current_declspecs);
124 if (have_extern_spec && !used_extern_spec)
126 current_declspecs = tree_cons (NULL_TREE,
127 get_identifier ("extern"),
129 used_extern_spec = 1;
134 parse_decl (declarator, attributes, initialized)
135 tree declarator, attributes;
138 return start_decl (declarator, current_declspecs, initialized,
139 attributes, prefix_attributes);
143 parse_decl0 (declarator, specs_attrs, lookups, attributes, initialized)
144 tree declarator, specs_attrs, lookups, attributes;
147 frob_specs (specs_attrs, lookups);
148 return parse_decl (declarator, attributes, initialized);
152 parse_end_decl (decl, init, asmspec)
153 tree decl, init, asmspec;
155 /* If decl is NULL_TREE, then this was a variable declaration using
156 () syntax for the initializer, so we handled it in grokdeclarator. */
158 decl_type_access_control (decl);
159 cp_finish_decl (decl, init, asmspec, init ? LOOKUP_ONLYCONVERTING : 0);
163 parse_field (declarator, attributes, asmspec, init)
164 tree declarator, attributes, asmspec, init;
166 tree d = grokfield (declarator, current_declspecs, init, asmspec,
167 build_tree_list (attributes, prefix_attributes));
168 decl_type_access_control (d);
173 parse_field0 (declarator, specs_attrs, lookups, attributes, asmspec, init)
174 tree declarator, specs_attrs, lookups, attributes, asmspec, init;
176 frob_specs (specs_attrs, lookups);
177 return parse_field (declarator, attributes, asmspec, init);
181 parse_bitfield (declarator, attributes, width)
182 tree declarator, attributes, width;
184 tree d = grokbitfield (declarator, current_declspecs, width);
185 cplus_decl_attributes (d, attributes, prefix_attributes);
186 decl_type_access_control (d);
191 parse_bitfield0 (declarator, specs_attrs, lookups, attributes, width)
192 tree declarator, specs_attrs, lookups, attributes, width;
194 frob_specs (specs_attrs, lookups);
195 return parse_bitfield (declarator, attributes, width);
199 parse_method (declarator, specs_attrs, lookups)
200 tree declarator, specs_attrs, lookups;
203 frob_specs (specs_attrs, lookups);
204 d = start_method (current_declspecs, declarator, prefix_attributes);
205 decl_type_access_control (d);
212 ggc_add_tree_root (¤t_declspecs, 1);
213 ggc_add_tree_root (&prefix_attributes, 1);
214 ggc_add_tree_root (¤t_enum_type, 1);
215 ggc_add_tree_root (&saved_scopes, 1);
218 /* Rename the "yyparse" function so that we can override it elsewhere. */
219 #define yyparse yyparse_1
229 flagged_type_tree ftype;
230 struct unparsed_text *pi;
233 /* All identifiers that are not reserved words
234 and are not declared typedefs in the current block */
237 /* All identifiers that are declared typedefs in the current block.
238 In some contexts, they are treated just like IDENTIFIER,
239 but they can also serve as typespecs in declarations. */
243 /* A template function. */
246 /* Reserved words that specify storage class.
247 yylval contains an IDENTIFIER_NODE which indicates which one. */
250 /* Reserved words that specify type.
251 yylval contains an IDENTIFIER_NODE which indicates which one. */
254 /* Reserved words that qualify type: "const" or "volatile".
255 yylval contains an IDENTIFIER_NODE which indicates which one. */
258 /* Character or numeric constants.
259 yylval is the node for the constant. */
262 /* String constants in raw form.
263 yylval is a STRING_CST node. */
266 /* "...", used for functions with variable arglists. */
269 /* the reserved words */
270 /* SCO include files test "ASM", so use something else. */
271 %token SIZEOF ENUM /* STRUCT UNION */ IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
272 %token BREAK CONTINUE RETURN_KEYWORD GOTO ASM_KEYWORD TYPEOF ALIGNOF
274 %token ATTRIBUTE EXTENSION LABEL
275 %token REALPART IMAGPART VA_ARG
277 /* the reserved words... C++ extensions */
279 %token <ttype> VISSPEC
280 %token DELETE NEW THIS OPERATOR CXX_TRUE CXX_FALSE
281 %token NAMESPACE TYPENAME_KEYWORD USING
282 %token LEFT_RIGHT TEMPLATE
283 %token TYPEID DYNAMIC_CAST STATIC_CAST REINTERPRET_CAST CONST_CAST
286 /* Define the operator tokens and their precedences.
287 The value is an integer because, if used, it is the tree code
288 to use in the expression made from the operator. */
290 %left EMPTY /* used to resolve s/r with epsilon */
294 /* Add precedence rules to solve dangling else s/r conflict */
298 %left IDENTIFIER PFUNCNAME TYPENAME SELFNAME PTYPENAME SCSPEC TYPESPEC CV_QUALIFIER ENUM AGGR ELLIPSIS TYPEOF SIGOF OPERATOR NSNAME TYPENAME_KEYWORD
304 %right <code> ASSIGN '='
312 %left <code> EQCOMPARE
313 %left <code> ARITHCOMPARE '<' '>'
314 %left <code> LSHIFT RSHIFT
316 %left <code> '*' '/' '%'
317 %left <code> POINTSAT_STAR DOT_STAR
318 %right <code> UNARY PLUSPLUS MINUSMINUS '~'
320 %left <ttype> LEFT_RIGHT
321 %left <code> POINTSAT '.' '(' '['
323 %right SCOPE /* C++ extension */
324 %nonassoc NEW DELETE TRY CATCH
328 %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist
329 %type <ttype> PFUNCNAME maybe_identifier
330 %type <ttype> paren_expr_or_null nontrivial_exprlist SELFNAME
331 %type <ttype> expr_no_commas expr_no_comma_rangle
332 %type <ttype> cast_expr unary_expr primary string STRING
333 %type <ttype> reserved_declspecs boolean.literal
334 %type <ttype> reserved_typespecquals
335 %type <ttype> SCSPEC TYPESPEC CV_QUALIFIER maybe_cv_qualifier
336 %type <ttype> init initlist maybeasm maybe_init defarg defarg1
337 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
338 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
339 %type <ttype> any_word
341 %type <ttype> compstmt implicitly_scoped_stmt
343 %type <ttype> declarator notype_declarator after_type_declarator
344 %type <ttype> notype_declarator_intern absdcl_intern
345 %type <ttype> after_type_declarator_intern
346 %type <ttype> direct_notype_declarator direct_after_type_declarator
347 %type <itype> components notype_components
348 %type <ttype> component_decl component_decl_1
349 %type <ttype> component_declarator component_declarator0
350 %type <ttype> notype_component_declarator notype_component_declarator0
351 %type <ttype> after_type_component_declarator after_type_component_declarator0
352 %type <ttype> absdcl cv_qualifiers
353 %type <ttype> direct_abstract_declarator conversion_declarator
354 %type <ttype> new_declarator direct_new_declarator
355 %type <ttype> xexpr parmlist parms bad_parm
356 %type <ttype> identifiers_or_typenames
357 %type <ttype> fcast_or_absdcl regcast_or_absdcl
358 %type <ttype> expr_or_declarator expr_or_declarator_intern
359 %type <ttype> complex_notype_declarator
360 %type <ttype> notype_unqualified_id unqualified_id qualified_id
361 %type <ttype> template_id do_id object_template_id notype_template_declarator
362 %type <ttype> overqualified_id notype_qualified_id any_id
363 %type <ttype> complex_direct_notype_declarator functional_cast
364 %type <ttype> complex_parmlist parms_comma
365 %type <ttype> namespace_qualifier namespace_using_decl
367 %type <ftype> type_id new_type_id typed_typespecs typespec typed_declspecs
368 %type <ftype> typed_declspecs1 type_specifier_seq nonempty_cv_qualifiers
369 %type <ftype> structsp typespecqual_reserved parm named_parm full_parm
370 %type <ftype> declmods
372 %type <itype> extension
375 %token <ttype> PTYPENAME
376 %token <ttype> EXTERN_LANG_STRING ALL
377 %token <ttype> PRE_PARSED_CLASS_DECL DEFARG DEFARG_MARKER
378 %token <pi> PRE_PARSED_FUNCTION_DECL
379 %type <ttype> component_constructor_declarator
380 %type <ttype> fn.def2 return_id constructor_declarator
381 %type <itype> ctor_initializer_opt function_try_block
382 %type <ttype> named_class_head_sans_basetype
383 %type <ftype> class_head named_class_head
384 %type <ftype> named_complex_class_head_sans_basetype
385 %type <ttype> unnamed_class_head
386 %type <ttype> base_class_list
387 %type <ttype> base_class_access_list
388 %type <ttype> base_class maybe_base_class_list base_class.1
389 %type <ttype> exception_specification_opt ansi_raise_identifier ansi_raise_identifiers
390 %type <ttype> operator_name
391 %type <ttype> object aggr
392 %type <itype> new delete
393 /* %type <ttype> primary_no_id */
394 %type <ttype> maybe_parmlist
395 %type <ttype> member_init
396 %type <ftype> member_init_list
397 %type <ttype> template_header template_parm_list template_parm
398 %type <ttype> template_type_parm template_template_parm
399 %type <code> template_close_bracket
400 %type <ttype> apparent_template_type
401 %type <ttype> template_type template_arg_list template_arg_list_opt
402 %type <ttype> template_arg
403 %type <ttype> condition xcond paren_cond_or_null
404 %type <ttype> type_name nested_name_specifier nested_type ptr_to_mem
405 %type <ttype> complete_type_name notype_identifier nonnested_type
406 %type <ttype> complex_type_name nested_name_specifier_1
407 %type <ttype> new_initializer new_placement
408 %type <ttype> using_decl
409 %type <ttype> typename_sub typename_sub0 typename_sub1 typename_sub2
410 %type <ttype> explicit_template_type
411 /* in order to recognize aggr tags as defining and thus shadowing. */
412 %token TYPENAME_DEFN IDENTIFIER_DEFN PTYPENAME_DEFN
413 %type <ttype> named_class_head_sans_basetype_defn
414 %type <ttype> identifier_defn IDENTIFIER_DEFN TYPENAME_DEFN PTYPENAME_DEFN
415 %type <ttype> handler_args
416 %type <ttype> self_template_type .finish_template_type
421 /* Used in lex.c for parsing pragmas. */
424 /* lex.c and pt.c depend on this being the last token. Define
425 any new tokens before this one! */
426 %token END_OF_SAVED_INPUT
429 /* Tell yyparse how to print a token's value, if yydebug is set. */
430 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
431 extern void yyprint PARAMS ((FILE *, int, YYSTYPE));
437 { finish_translation_unit (); }
439 { finish_translation_unit (); }
442 /* the reason for the strange actions in this rule
443 is so that notype_initdecls when reached via datadef
444 can find a valid list of type and sc specs in $0. */
447 { $<ttype>$ = NULL_TREE; }
449 { $<ttype>$ = NULL_TREE; ggc_collect (); }
450 | extdefs lang_extdef
451 { $<ttype>$ = NULL_TREE; ggc_collect (); }
460 { have_extern_spec = 1;
461 used_extern_spec = 0;
462 $<ttype>$ = NULL_TREE; }
465 { have_extern_spec = 0; }
479 { if (pending_lang_change) do_pending_lang_change();
480 type_lookups = NULL_TREE; }
482 { if (! toplevel_bindings_p ())
487 fndef eat_saved_input
488 { do_pending_inlines (); }
490 { do_pending_inlines (); }
493 { cp_warning ("keyword `export' not implemented, and will be ignored"); }
495 { do_pending_inlines (); }
497 { do_pending_inlines (); }
498 | asm_keyword '(' string ')' ';'
499 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
501 | extern_lang_string '{' extdefs_opt '}'
502 { pop_lang_context (); }
503 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
504 { do_pending_inlines (); pop_lang_context (); }
505 | extern_lang_string .hush_warning datadef .warning_ok
506 { do_pending_inlines (); pop_lang_context (); }
507 | NAMESPACE identifier '{'
508 { push_namespace ($2); }
510 { pop_namespace (); }
512 { push_namespace (NULL_TREE); }
514 { pop_namespace (); }
517 { do_toplevel_using_decl ($1); }
524 NAMESPACE identifier '='
525 { begin_only_namespace_names (); }
528 end_only_namespace_names ();
531 do_namespace_alias ($2, $5);
538 | USING global_scope qualified_id
540 | USING global_scope unqualified_id
544 namespace_using_decl:
545 USING namespace_qualifier identifier
546 { $$ = build_parse_node (SCOPE_REF, $2, $3); }
547 | USING global_scope identifier
548 { $$ = build_parse_node (SCOPE_REF, global_namespace, $3); }
549 | USING global_scope namespace_qualifier identifier
550 { $$ = build_parse_node (SCOPE_REF, $3, $4); }
555 { begin_only_namespace_names (); }
558 end_only_namespace_names ();
559 /* If no declaration was found, the using-directive is
560 invalid. Since that was not reported, we need the
561 identifier for the error message. */
562 if (TREE_CODE ($4) == IDENTIFIER_NODE && lastiddecl)
564 do_using_directive ($4);
571 if (TREE_CODE ($$) == IDENTIFIER_NODE)
575 | namespace_qualifier NSNAME SCOPE
578 if (TREE_CODE ($$) == IDENTIFIER_NODE)
586 | global_scope qualified_id
588 | global_scope unqualified_id
594 { push_lang_context ($1); }
595 | extern_lang_string EXTERN_LANG_STRING
596 { if (current_lang_name != $2)
597 cp_error ("use of linkage spec `%D' is different from previous spec `%D'", $2, current_lang_name);
598 pop_lang_context (); push_lang_context ($2); }
603 { begin_template_parm_list (); }
604 template_parm_list '>'
605 { $$ = end_template_parm_list ($4); }
607 { begin_specialization();
613 { $$ = process_template_parm (NULL_TREE, $1); }
614 | template_parm_list ',' template_parm
615 { $$ = process_template_parm ($1, $3); }
625 aggr maybe_identifier
626 { $$ = finish_template_type_parm ($1, $2); }
627 | TYPENAME_KEYWORD maybe_identifier
628 { $$ = finish_template_type_parm (class_type_node, $2); }
631 template_template_parm:
632 template_header aggr maybe_identifier
633 { $$ = finish_template_template_parm ($2, $3); }
637 /* The following rules introduce a new reduce/reduce
638 conflict on the ',' and '>' input tokens: they are valid
639 prefixes for a `structsp', which means they could match a
640 nameless parameter. See 14.6, paragraph 3.
641 By putting them before the `parm' rule, we get
642 their match before considering them nameless parameter
645 { $$ = build_tree_list (NULL_TREE, $1); }
646 | template_type_parm '=' type_id
647 { $$ = build_tree_list (groktypename ($3.t), $1); }
649 { $$ = build_tree_list (NULL_TREE, $1.t); }
650 | parm '=' expr_no_comma_rangle
651 { $$ = build_tree_list ($3, $1.t); }
652 | template_template_parm
653 { $$ = build_tree_list (NULL_TREE, $1); }
654 | template_template_parm '=' template_arg
656 if (TREE_CODE ($3) != TEMPLATE_DECL
657 && TREE_CODE ($3) != TEMPLATE_TEMPLATE_PARM
658 && TREE_CODE ($3) != TYPE_DECL)
660 error ("invalid default template argument");
661 $3 = error_mark_node;
663 $$ = build_tree_list ($3, $1);
668 template_header template_extdef
669 { finish_template_decl ($1); }
670 | template_header error %prec EMPTY
671 { finish_template_decl ($1); }
675 fndef eat_saved_input
676 { do_pending_inlines (); }
678 { do_pending_inlines (); }
680 { do_pending_inlines (); }
681 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
682 { do_pending_inlines ();
683 pop_lang_context (); }
684 | extern_lang_string .hush_warning template_datadef .warning_ok
685 { do_pending_inlines ();
686 pop_lang_context (); }
687 | extension template_extdef
693 | declmods notype_initdecls ';'
695 | typed_declspecs initdecls ';'
696 { note_list_got_semicolon ($1.t); }
698 { maybe_process_partial_specialization ($1.t);
699 note_got_semicolon ($1.t); }
704 | declmods notype_initdecls ';'
706 | typed_declspecs initdecls ';'
707 { note_list_got_semicolon ($1.t); }
709 { pedwarn ("empty declaration"); }
710 | explicit_instantiation ';'
711 | typed_declspecs ';'
714 split_specs_attrs ($1.t, &t, &attrs);
716 note_list_got_semicolon ($1.t);
723 ctor_initializer_opt:
742 fn.def1 maybe_return_init ctor_initializer_opt compstmt_or_error
743 { expand_body (finish_function ((int)$3)); }
744 | fn.def1 maybe_return_init function_try_block
745 { expand_body (finish_function ((int)$3)); }
746 | fn.def1 maybe_return_init error
750 constructor_declarator:
751 nested_name_specifier SELFNAME '('
752 { $$ = begin_constructor_declarator ($1, $2); }
753 parmlist ')' cv_qualifiers exception_specification_opt
754 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
755 | nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
756 { $$ = begin_constructor_declarator ($1, $2);
757 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
759 | global_scope nested_name_specifier SELFNAME '('
760 { $$ = begin_constructor_declarator ($2, $3); }
761 parmlist ')' cv_qualifiers exception_specification_opt
762 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
763 | global_scope nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
764 { $$ = begin_constructor_declarator ($2, $3);
765 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
767 | nested_name_specifier self_template_type '('
768 { $$ = begin_constructor_declarator ($1, $2); }
769 parmlist ')' cv_qualifiers exception_specification_opt
770 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
771 | nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
772 { $$ = begin_constructor_declarator ($1, $2);
773 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
775 | global_scope nested_name_specifier self_template_type '('
776 { $$ = begin_constructor_declarator ($2, $3); }
777 parmlist ')' cv_qualifiers exception_specification_opt
778 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
779 | global_scope nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
780 { $$ = begin_constructor_declarator ($2, $3);
781 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
786 typed_declspecs declarator
787 { check_for_new_type ("return type", $1);
788 if (!begin_function_definition ($1.t, $2))
790 | declmods notype_declarator
791 { if (!begin_function_definition ($1.t, $2))
794 { if (!begin_function_definition (NULL_TREE, $1))
796 | declmods constructor_declarator
797 { if (!begin_function_definition ($1.t, $2))
799 | constructor_declarator
800 { if (!begin_function_definition (NULL_TREE, $1))
804 component_constructor_declarator:
805 SELFNAME '(' parmlist ')' cv_qualifiers exception_specification_opt
806 { $$ = make_call_declarator ($1, $3, $5, $6); }
807 | SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
808 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
809 | self_template_type '(' parmlist ')' cv_qualifiers exception_specification_opt
810 { $$ = make_call_declarator ($1, $3, $5, $6); }
811 | self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
812 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
815 /* more C++ complexity. See component_decl for a comment on the
816 reduce/reduce conflict introduced by these rules. */
818 declmods component_constructor_declarator
819 { $$ = parse_method ($2, $1.t, $1.lookups);
823 if (yychar == YYEMPTY)
826 | component_constructor_declarator
827 { $$ = parse_method ($1, NULL_TREE, NULL_TREE);
829 | typed_declspecs declarator
830 { $$ = parse_method ($2, $1.t, $1.lookups); goto rest_of_mdef;}
831 | declmods notype_declarator
832 { $$ = parse_method ($2, $1.t, $1.lookups); goto rest_of_mdef;}
834 { $$ = parse_method ($1, NULL_TREE, NULL_TREE);
836 | declmods constructor_declarator
837 { $$ = parse_method ($2, $1.t, $1.lookups); goto rest_of_mdef;}
838 | constructor_declarator
839 { $$ = parse_method ($1, NULL_TREE, NULL_TREE);
844 RETURN_KEYWORD IDENTIFIER
852 { finish_named_return_value ($<ttype>$, $2); }
853 | return_id '(' nonnull_exprlist ')'
854 { finish_named_return_value ($<ttype>$, $3); }
855 | return_id LEFT_RIGHT
856 { finish_named_return_value ($<ttype>$, NULL_TREE); }
860 ':' .set_base_init member_init_list
862 if ($3.new_type_flag == 0)
863 error ("no base or member initializers given following ':'");
865 finish_mem_initializers ($3.t);
872 if (DECL_CONSTRUCTOR_P (current_function_decl))
873 /* Make a contour for the initializer list. */
875 else if (current_class_type == NULL_TREE)
876 error ("base initializers not allowed for non-member functions");
877 else if (! DECL_CONSTRUCTOR_P (current_function_decl))
878 error ("only constructors take base initializers");
885 $$.new_type_flag = 0;
890 $$.new_type_flag = 1;
893 | member_init_list ',' member_init
897 $$.new_type_flag = 1;
898 TREE_CHAIN ($3) = $1.t;
904 | member_init_list error
908 '(' nonnull_exprlist ')'
910 if (current_class_name)
911 pedwarn ("anachronistic old style base class initializer");
912 $$ = expand_member_init (current_class_ref, NULL_TREE, $2);
916 if (current_class_name)
917 pedwarn ("anachronistic old style base class initializer");
918 $$ = expand_member_init (current_class_ref,
922 | notype_identifier '(' nonnull_exprlist ')'
923 { $$ = expand_member_init (current_class_ref, $1, $3); }
924 | notype_identifier LEFT_RIGHT
925 { $$ = expand_member_init (current_class_ref, $1,
927 | nonnested_type '(' nonnull_exprlist ')'
928 { $$ = expand_member_init (current_class_ref, $1, $3); }
929 | nonnested_type LEFT_RIGHT
930 { $$ = expand_member_init (current_class_ref, $1,
932 | typename_sub '(' nonnull_exprlist ')'
933 { $$ = expand_member_init (current_class_ref, $1, $3); }
934 | typename_sub LEFT_RIGHT
935 { $$ = expand_member_init (current_class_ref, $1,
961 explicit_instantiation:
962 TEMPLATE begin_explicit_instantiation typespec ';'
963 { do_type_instantiation ($3.t, NULL_TREE, 1);
965 end_explicit_instantiation
966 | TEMPLATE begin_explicit_instantiation typed_declspecs declarator
967 { tree specs = strip_attrs ($3.t);
968 do_decl_instantiation (specs, $4, NULL_TREE); }
969 end_explicit_instantiation
970 | TEMPLATE begin_explicit_instantiation notype_declarator
971 { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
972 end_explicit_instantiation
973 | TEMPLATE begin_explicit_instantiation constructor_declarator
974 { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
975 end_explicit_instantiation
976 | SCSPEC TEMPLATE begin_explicit_instantiation typespec ';'
977 { do_type_instantiation ($4.t, $1, 1);
979 end_explicit_instantiation
980 | SCSPEC TEMPLATE begin_explicit_instantiation typed_declspecs
982 { tree specs = strip_attrs ($4.t);
983 do_decl_instantiation (specs, $5, $1); }
984 end_explicit_instantiation
985 | SCSPEC TEMPLATE begin_explicit_instantiation notype_declarator
986 { do_decl_instantiation (NULL_TREE, $4, $1); }
987 end_explicit_instantiation
988 | SCSPEC TEMPLATE begin_explicit_instantiation constructor_declarator
989 { do_decl_instantiation (NULL_TREE, $4, $1); }
990 end_explicit_instantiation
993 begin_explicit_instantiation:
994 { begin_explicit_instantiation(); }
996 end_explicit_instantiation:
997 { end_explicit_instantiation(); }
999 /* The TYPENAME expansions are to deal with use of a template class name as
1000 a template within the class itself, where the template decl is hidden by
1001 a type decl. Got all that? */
1004 PTYPENAME '<' template_arg_list_opt template_close_bracket
1005 .finish_template_type
1007 | TYPENAME '<' template_arg_list_opt template_close_bracket
1008 .finish_template_type
1010 | self_template_type
1013 apparent_template_type:
1015 | identifier '<' template_arg_list_opt '>'
1016 .finish_template_type
1020 SELFNAME '<' template_arg_list_opt template_close_bracket
1021 .finish_template_type
1025 .finish_template_type:
1027 if (yychar == YYEMPTY)
1030 $$ = finish_template_type ($<ttype>-3, $<ttype>-1,
1034 template_close_bracket:
1038 /* Handle `Class<Class<Type>>' without space in the `>>' */
1039 pedwarn ("`>>' should be `> >' in template class name");
1044 template_arg_list_opt:
1052 { $$ = build_tree_list (NULL_TREE, $$); }
1053 | template_arg_list ',' template_arg
1054 { $$ = chainon ($$, build_tree_list (NULL_TREE, $3)); }
1059 { $$ = groktypename ($1.t); }
1063 if (DECL_TEMPLATE_TEMPLATE_PARM_P ($$))
1064 $$ = TREE_TYPE ($$);
1066 | global_scope PTYPENAME
1069 if (DECL_TEMPLATE_TEMPLATE_PARM_P ($$))
1070 $$ = TREE_TYPE ($$);
1072 | expr_no_comma_rangle
1077 { $$ = NEGATE_EXPR; }
1079 { $$ = CONVERT_EXPR; }
1081 { $$ = PREINCREMENT_EXPR; }
1083 { $$ = PREDECREMENT_EXPR; }
1085 { $$ = TRUTH_NOT_EXPR; }
1090 { $$ = build_x_compound_expr ($$); }
1096 { error ("ISO C++ forbids an empty condition for `%s'",
1098 $$ = integer_zero_node; }
1105 { error ("ISO C++ forbids an empty condition for `%s'",
1107 $$ = integer_zero_node; }
1121 type_specifier_seq declarator maybeasm maybe_attribute '='
1124 for (d = getdecls (); d; d = TREE_CHAIN (d))
1125 if (TREE_CODE (d) == TYPE_DECL) {
1126 tree s = TREE_TYPE (d);
1127 if (TREE_CODE (s) == RECORD_TYPE)
1128 cp_error ("definition of class `%T' in condition", s);
1129 else if (TREE_CODE (s) == ENUMERAL_TYPE)
1130 cp_error ("definition of enum `%T' in condition", s);
1133 current_declspecs = $1.t;
1134 $<ttype>$ = parse_decl ($<ttype>2, $4, 1);
1138 parse_end_decl ($<ttype>6, $7, $4);
1139 $$ = convert_from_reference ($<ttype>6);
1140 if (TREE_CODE (TREE_TYPE ($$)) == ARRAY_TYPE)
1141 cp_error ("definition of array `%#D' in condition", $$);
1148 | maybe_label_decls stmts '}'
1149 | maybe_label_decls stmts error '}'
1150 | maybe_label_decls error '}'
1153 already_scoped_stmt:
1155 { $<ttype>$ = begin_compound_stmt (1); }
1157 { finish_compound_stmt (1, $<ttype>2); }
1162 nontrivial_exprlist:
1163 expr_no_commas ',' expr_no_commas
1164 { $$ = tree_cons (NULL_TREE, $$,
1165 build_tree_list (NULL_TREE, $3)); }
1166 | expr_no_commas ',' error
1167 { $$ = tree_cons (NULL_TREE, $$,
1168 build_tree_list (NULL_TREE, error_mark_node)); }
1169 | nontrivial_exprlist ',' expr_no_commas
1170 { chainon ($$, build_tree_list (NULL_TREE, $3)); }
1171 | nontrivial_exprlist ',' error
1172 { chainon ($$, build_tree_list (NULL_TREE, error_mark_node)); }
1177 { $$ = build_tree_list (NULL_TREE, $$); }
1178 | nontrivial_exprlist
1184 /* __extension__ turns off -pedantic for following primary. */
1185 | extension cast_expr %prec UNARY
1188 | '*' cast_expr %prec UNARY
1189 { $$ = build_x_indirect_ref ($2, "unary *"); }
1190 | '&' cast_expr %prec UNARY
1191 { $$ = build_x_unary_op (ADDR_EXPR, $2); }
1193 { $$ = build_x_unary_op (BIT_NOT_EXPR, $2); }
1194 | unop cast_expr %prec UNARY
1195 { $$ = finish_unary_op_expr ($1, $2); }
1196 /* Refer to the address of a label as a pointer. */
1199 pedwarn ("ISO C++ forbids `&&'");
1200 $$ = finish_label_address_expr ($2); }
1201 | SIZEOF unary_expr %prec UNARY
1202 { $$ = expr_sizeof ($2); }
1203 | SIZEOF '(' type_id ')' %prec HYPERUNARY
1204 { $$ = c_sizeof (groktypename ($3.t));
1205 check_for_new_type ("sizeof", $3); }
1206 | ALIGNOF unary_expr %prec UNARY
1207 { $$ = grok_alignof ($2); }
1208 | ALIGNOF '(' type_id ')' %prec HYPERUNARY
1209 { $$ = c_alignof (groktypename ($3.t));
1210 check_for_new_type ("alignof", $3); }
1212 /* The %prec EMPTY's here are required by the = init initializer
1213 syntax extension; see below. */
1214 | new new_type_id %prec EMPTY
1215 { $$ = build_new (NULL_TREE, $2.t, NULL_TREE, $1);
1216 check_for_new_type ("new", $2); }
1217 | new new_type_id new_initializer
1218 { $$ = build_new (NULL_TREE, $2.t, $3, $1);
1219 check_for_new_type ("new", $2); }
1220 | new new_placement new_type_id %prec EMPTY
1221 { $$ = build_new ($2, $3.t, NULL_TREE, $1);
1222 check_for_new_type ("new", $3); }
1223 | new new_placement new_type_id new_initializer
1224 { $$ = build_new ($2, $3.t, $4, $1);
1225 check_for_new_type ("new", $3); }
1226 | new '(' type_id ')'
1228 { $$ = build_new (NULL_TREE, groktypename($3.t),
1230 check_for_new_type ("new", $3); }
1231 | new '(' type_id ')' new_initializer
1232 { $$ = build_new (NULL_TREE, groktypename($3.t), $5, $1);
1233 check_for_new_type ("new", $3); }
1234 | new new_placement '(' type_id ')' %prec EMPTY
1235 { $$ = build_new ($2, groktypename($4.t), NULL_TREE, $1);
1236 check_for_new_type ("new", $4); }
1237 | new new_placement '(' type_id ')' new_initializer
1238 { $$ = build_new ($2, groktypename($4.t), $6, $1);
1239 check_for_new_type ("new", $4); }
1241 | delete cast_expr %prec UNARY
1242 { $$ = delete_sanity ($2, NULL_TREE, 0, $1); }
1243 | delete '[' ']' cast_expr %prec UNARY
1244 { $$ = delete_sanity ($4, NULL_TREE, 1, $1);
1245 if (yychar == YYEMPTY)
1247 | delete '[' expr ']' cast_expr %prec UNARY
1248 { $$ = delete_sanity ($5, $3, 2, $1);
1249 if (yychar == YYEMPTY)
1251 | REALPART cast_expr %prec UNARY
1252 { $$ = build_x_unary_op (REALPART_EXPR, $2); }
1253 | IMAGPART cast_expr %prec UNARY
1254 { $$ = build_x_unary_op (IMAGPART_EXPR, $2); }
1258 '(' nonnull_exprlist ')'
1260 | '{' nonnull_exprlist '}'
1261 { cp_pedwarn ("old style placement syntax, use () instead");
1266 '(' nonnull_exprlist ')'
1272 cp_error ("`%T' is not a valid expression", $2.t);
1273 $$ = error_mark_node;
1275 /* GNU extension so people can use initializer lists. Note that
1276 this alters the meaning of `new int = 1', which was previously
1277 syntactically valid but semantically invalid. */
1281 pedwarn ("ISO C++ forbids initialization of new expression with `='");
1282 if (TREE_CODE ($2) != TREE_LIST
1283 && TREE_CODE ($2) != CONSTRUCTOR)
1284 $$ = build_tree_list (NULL_TREE, $2);
1290 /* This is necessary to postpone reduction of `int ((int)(int)(int))'. */
1292 '(' type_id ')' %prec EMPTY
1293 { $2.t = finish_parmlist (build_tree_list (NULL_TREE, $2.t), 0);
1294 $$ = make_call_declarator (NULL_TREE, $2.t, NULL_TREE, NULL_TREE);
1295 check_for_new_type ("cast", $2); }
1296 | regcast_or_absdcl '(' type_id ')' %prec EMPTY
1297 { $3.t = finish_parmlist (build_tree_list (NULL_TREE, $3.t), 0);
1298 $$ = make_call_declarator ($$, $3.t, NULL_TREE, NULL_TREE);
1299 check_for_new_type ("cast", $3); }
1304 | regcast_or_absdcl unary_expr %prec UNARY
1305 { $$ = reparse_absdcl_as_casts ($$, $2); }
1306 | regcast_or_absdcl '{' initlist maybecomma '}' %prec UNARY
1308 tree init = build_nt (CONSTRUCTOR, NULL_TREE,
1311 pedwarn ("ISO C++ forbids constructor-expressions");
1312 /* Indicate that this was a GNU C constructor expression. */
1313 TREE_HAS_CONSTRUCTOR (init) = 1;
1315 $$ = reparse_absdcl_as_casts ($$, init);
1321 /* Handle general members. */
1322 | expr_no_commas POINTSAT_STAR expr_no_commas
1323 { $$ = build_x_binary_op (MEMBER_REF, $$, $3); }
1324 | expr_no_commas DOT_STAR expr_no_commas
1325 { $$ = build_m_component_ref ($$, $3); }
1326 | expr_no_commas '+' expr_no_commas
1327 { $$ = build_x_binary_op ($2, $$, $3); }
1328 | expr_no_commas '-' expr_no_commas
1329 { $$ = build_x_binary_op ($2, $$, $3); }
1330 | expr_no_commas '*' expr_no_commas
1331 { $$ = build_x_binary_op ($2, $$, $3); }
1332 | expr_no_commas '/' expr_no_commas
1333 { $$ = build_x_binary_op ($2, $$, $3); }
1334 | expr_no_commas '%' expr_no_commas
1335 { $$ = build_x_binary_op ($2, $$, $3); }
1336 | expr_no_commas LSHIFT expr_no_commas
1337 { $$ = build_x_binary_op ($2, $$, $3); }
1338 | expr_no_commas RSHIFT expr_no_commas
1339 { $$ = build_x_binary_op ($2, $$, $3); }
1340 | expr_no_commas ARITHCOMPARE expr_no_commas
1341 { $$ = build_x_binary_op ($2, $$, $3); }
1342 | expr_no_commas '<' expr_no_commas
1343 { $$ = build_x_binary_op (LT_EXPR, $$, $3); }
1344 | expr_no_commas '>' expr_no_commas
1345 { $$ = build_x_binary_op (GT_EXPR, $$, $3); }
1346 | expr_no_commas EQCOMPARE expr_no_commas
1347 { $$ = build_x_binary_op ($2, $$, $3); }
1348 | expr_no_commas MIN_MAX expr_no_commas
1349 { $$ = build_x_binary_op ($2, $$, $3); }
1350 | expr_no_commas '&' expr_no_commas
1351 { $$ = build_x_binary_op ($2, $$, $3); }
1352 | expr_no_commas '|' expr_no_commas
1353 { $$ = build_x_binary_op ($2, $$, $3); }
1354 | expr_no_commas '^' expr_no_commas
1355 { $$ = build_x_binary_op ($2, $$, $3); }
1356 | expr_no_commas ANDAND expr_no_commas
1357 { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $$, $3); }
1358 | expr_no_commas OROR expr_no_commas
1359 { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $$, $3); }
1360 | expr_no_commas '?' xexpr ':' expr_no_commas
1361 { $$ = build_x_conditional_expr ($$, $3, $5); }
1362 | expr_no_commas '=' expr_no_commas
1363 { $$ = build_x_modify_expr ($$, NOP_EXPR, $3);
1364 if ($$ != error_mark_node)
1365 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
1366 | expr_no_commas ASSIGN expr_no_commas
1367 { $$ = build_x_modify_expr ($$, $2, $3); }
1369 { $$ = build_throw (NULL_TREE); }
1370 | THROW expr_no_commas
1371 { $$ = build_throw ($2); }
1374 expr_no_comma_rangle:
1376 /* Handle general members. */
1377 | expr_no_comma_rangle POINTSAT_STAR expr_no_comma_rangle
1378 { $$ = build_x_binary_op (MEMBER_REF, $$, $3); }
1379 | expr_no_comma_rangle DOT_STAR expr_no_comma_rangle
1380 { $$ = build_m_component_ref ($$, $3); }
1381 | expr_no_comma_rangle '+' expr_no_comma_rangle
1382 { $$ = build_x_binary_op ($2, $$, $3); }
1383 | expr_no_comma_rangle '-' expr_no_comma_rangle
1384 { $$ = build_x_binary_op ($2, $$, $3); }
1385 | expr_no_comma_rangle '*' expr_no_comma_rangle
1386 { $$ = build_x_binary_op ($2, $$, $3); }
1387 | expr_no_comma_rangle '/' expr_no_comma_rangle
1388 { $$ = build_x_binary_op ($2, $$, $3); }
1389 | expr_no_comma_rangle '%' expr_no_comma_rangle
1390 { $$ = build_x_binary_op ($2, $$, $3); }
1391 | expr_no_comma_rangle LSHIFT expr_no_comma_rangle
1392 { $$ = build_x_binary_op ($2, $$, $3); }
1393 | expr_no_comma_rangle RSHIFT expr_no_comma_rangle
1394 { $$ = build_x_binary_op ($2, $$, $3); }
1395 | expr_no_comma_rangle ARITHCOMPARE expr_no_comma_rangle
1396 { $$ = build_x_binary_op ($2, $$, $3); }
1397 | expr_no_comma_rangle '<' expr_no_comma_rangle
1398 { $$ = build_x_binary_op (LT_EXPR, $$, $3); }
1399 | expr_no_comma_rangle EQCOMPARE expr_no_comma_rangle
1400 { $$ = build_x_binary_op ($2, $$, $3); }
1401 | expr_no_comma_rangle MIN_MAX expr_no_comma_rangle
1402 { $$ = build_x_binary_op ($2, $$, $3); }
1403 | expr_no_comma_rangle '&' expr_no_comma_rangle
1404 { $$ = build_x_binary_op ($2, $$, $3); }
1405 | expr_no_comma_rangle '|' expr_no_comma_rangle
1406 { $$ = build_x_binary_op ($2, $$, $3); }
1407 | expr_no_comma_rangle '^' expr_no_comma_rangle
1408 { $$ = build_x_binary_op ($2, $$, $3); }
1409 | expr_no_comma_rangle ANDAND expr_no_comma_rangle
1410 { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $$, $3); }
1411 | expr_no_comma_rangle OROR expr_no_comma_rangle
1412 { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $$, $3); }
1413 | expr_no_comma_rangle '?' xexpr ':' expr_no_comma_rangle
1414 { $$ = build_x_conditional_expr ($$, $3, $5); }
1415 | expr_no_comma_rangle '=' expr_no_comma_rangle
1416 { $$ = build_x_modify_expr ($$, NOP_EXPR, $3);
1417 if ($$ != error_mark_node)
1418 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
1419 | expr_no_comma_rangle ASSIGN expr_no_comma_rangle
1420 { $$ = build_x_modify_expr ($$, $2, $3); }
1422 { $$ = build_throw (NULL_TREE); }
1423 | THROW expr_no_comma_rangle
1424 { $$ = build_throw ($2); }
1427 notype_unqualified_id:
1428 '~' see_typename identifier
1429 { $$ = build_parse_node (BIT_NOT_EXPR, $3); }
1430 | '~' see_typename template_type
1431 { $$ = build_parse_node (BIT_NOT_EXPR, $3); }
1436 | NSNAME %prec EMPTY
1441 /* If lastiddecl is a TREE_LIST, it's a baselink, which
1442 means that we're in an expression like S::f<int>, so
1443 don't do_identifier; we only do that for unqualified
1445 if (!lastiddecl || TREE_CODE (lastiddecl) != TREE_LIST)
1446 $$ = do_identifier ($<ttype>-1, 1, NULL_TREE);
1452 PFUNCNAME '<' do_id template_arg_list_opt template_close_bracket
1453 { $$ = lookup_template_function ($3, $4); }
1454 | operator_name '<' do_id template_arg_list_opt template_close_bracket
1455 { $$ = lookup_template_function ($3, $4); }
1459 TEMPLATE identifier '<' template_arg_list_opt template_close_bracket
1460 { $$ = lookup_template_function ($2, $4); }
1461 | TEMPLATE PFUNCNAME '<' template_arg_list_opt template_close_bracket
1462 { $$ = lookup_template_function ($2, $4); }
1463 | TEMPLATE operator_name '<' template_arg_list_opt
1464 template_close_bracket
1465 { $$ = lookup_template_function ($2, $4); }
1469 notype_unqualified_id
1474 expr_or_declarator_intern:
1476 | attributes expr_or_declarator
1478 /* Provide support for '(' attributes '*' declarator ')'
1480 $$ = tree_cons ($1, $2, NULL_TREE);
1485 notype_unqualified_id
1486 | '*' expr_or_declarator_intern %prec UNARY
1487 { $$ = build_parse_node (INDIRECT_REF, $2); }
1488 | '&' expr_or_declarator_intern %prec UNARY
1489 { $$ = build_parse_node (ADDR_EXPR, $2); }
1490 | '(' expr_or_declarator_intern ')'
1494 notype_template_declarator:
1495 IDENTIFIER '<' template_arg_list_opt template_close_bracket
1496 { $$ = lookup_template_function ($1, $3); }
1497 | NSNAME '<' template_arg_list template_close_bracket
1498 { $$ = lookup_template_function ($1, $3); }
1501 direct_notype_declarator:
1502 complex_direct_notype_declarator
1503 /* This precedence declaration is to prefer this reduce
1504 to the Koenig lookup shift in primary, below. I hate yacc. */
1505 | notype_unqualified_id %prec '('
1506 | notype_template_declarator
1507 | '(' expr_or_declarator_intern ')'
1508 { $$ = finish_decl_parsing ($2); }
1512 notype_unqualified_id
1514 if (TREE_CODE ($1) == BIT_NOT_EXPR)
1515 $$ = build_x_unary_op (BIT_NOT_EXPR, TREE_OPERAND ($1, 0));
1517 $$ = finish_id_expr ($1);
1523 $$ = combine_strings ($$);
1524 /* combine_strings doesn't set up TYPE_MAIN_VARIANT of
1525 a const array the way we want, so fix it. */
1526 if (flag_const_strings)
1527 TREE_TYPE ($$) = build_cplus_array_type
1528 (TREE_TYPE (TREE_TYPE ($$)),
1529 TYPE_DOMAIN (TREE_TYPE ($$)));
1532 { $$ = finish_parenthesized_expr ($2); }
1533 | '(' expr_or_declarator_intern ')'
1534 { $2 = reparse_decl_as_expr (NULL_TREE, $2);
1535 $$ = finish_parenthesized_expr ($2); }
1537 { $$ = error_mark_node; }
1539 { tree scope = current_scope ();
1540 if (!scope || TREE_CODE (scope) != FUNCTION_DECL)
1542 error ("braced-group within expression allowed only inside a function");
1546 pedwarn ("ISO C++ forbids braced-groups within expressions");
1547 $<ttype>$ = begin_stmt_expr ();
1550 { $$ = finish_stmt_expr ($<ttype>2); }
1551 /* Koenig lookup support
1552 We could store lastiddecl in $1 to avoid another lookup,
1553 but that would result in many additional reduce/reduce conflicts. */
1554 | notype_unqualified_id '(' nonnull_exprlist ')'
1555 { $$ = finish_call_expr ($1, $3, 1); }
1556 | notype_unqualified_id LEFT_RIGHT
1557 { $$ = finish_call_expr ($1, NULL_TREE, 1); }
1558 | primary '(' nonnull_exprlist ')'
1559 { $$ = finish_call_expr ($1, $3, 0); }
1560 | primary LEFT_RIGHT
1561 { $$ = finish_call_expr ($1, NULL_TREE, 0); }
1562 | VA_ARG '(' expr_no_commas ',' type_id ')'
1563 { $$ = build_x_va_arg ($3, groktypename ($5.t));
1564 check_for_new_type ("__builtin_va_arg", $5); }
1565 | primary '[' expr ']'
1566 { $$ = grok_array_decl ($$, $3); }
1568 { $$ = finish_increment_expr ($1, POSTINCREMENT_EXPR); }
1569 | primary MINUSMINUS
1570 { $$ = finish_increment_expr ($1, POSTDECREMENT_EXPR); }
1571 /* C++ extensions */
1573 { $$ = finish_this_expr (); }
1574 | CV_QUALIFIER '(' nonnull_exprlist ')'
1576 /* This is a C cast in C++'s `functional' notation
1577 using the "implicit int" extension so that:
1578 `const (3)' is equivalent to `const int (3)'. */
1581 type = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
1582 type = groktypename (build_tree_list (type, NULL_TREE));
1583 $$ = build_functional_cast (type, $3);
1586 | DYNAMIC_CAST '<' type_id '>' '(' expr ')'
1587 { tree type = groktypename ($3.t);
1588 check_for_new_type ("dynamic_cast", $3);
1589 $$ = build_dynamic_cast (type, $6); }
1590 | STATIC_CAST '<' type_id '>' '(' expr ')'
1591 { tree type = groktypename ($3.t);
1592 check_for_new_type ("static_cast", $3);
1593 $$ = build_static_cast (type, $6); }
1594 | REINTERPRET_CAST '<' type_id '>' '(' expr ')'
1595 { tree type = groktypename ($3.t);
1596 check_for_new_type ("reinterpret_cast", $3);
1597 $$ = build_reinterpret_cast (type, $6); }
1598 | CONST_CAST '<' type_id '>' '(' expr ')'
1599 { tree type = groktypename ($3.t);
1600 check_for_new_type ("const_cast", $3);
1601 $$ = build_const_cast (type, $6); }
1602 | TYPEID '(' expr ')'
1603 { $$ = build_typeid ($3); }
1604 | TYPEID '(' type_id ')'
1605 { tree type = groktypename ($3.t);
1606 check_for_new_type ("typeid", $3);
1607 $$ = get_typeid (TYPE_MAIN_VARIANT (type)); }
1608 | global_scope IDENTIFIER
1609 { $$ = do_scoped_id ($2, 1); }
1610 | global_scope template_id
1612 | global_scope operator_name
1614 got_scope = NULL_TREE;
1615 if (TREE_CODE ($2) == IDENTIFIER_NODE)
1616 $$ = do_scoped_id ($2, 1);
1620 | overqualified_id %prec HYPERUNARY
1621 { $$ = build_offset_ref (OP0 ($$), OP1 ($$)); }
1622 | overqualified_id '(' nonnull_exprlist ')'
1623 { $$ = finish_qualified_call_expr ($1, $3); }
1624 | overqualified_id LEFT_RIGHT
1625 { $$ = finish_qualified_call_expr ($1, NULL_TREE); }
1626 | object object_template_id %prec UNARY
1628 $$ = build_x_component_ref ($$, $2, NULL_TREE, 1);
1630 | object object_template_id '(' nonnull_exprlist ')'
1631 { $$ = finish_object_call_expr ($2, $1, $4); }
1632 | object object_template_id LEFT_RIGHT
1633 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1634 | object unqualified_id %prec UNARY
1635 { $$ = build_x_component_ref ($$, $2, NULL_TREE, 1); }
1636 | object overqualified_id %prec UNARY
1637 { if (processing_template_decl)
1638 $$ = build_min_nt (COMPONENT_REF, $1, $2);
1640 $$ = build_object_ref ($$, OP0 ($2), OP1 ($2)); }
1641 | object unqualified_id '(' nonnull_exprlist ')'
1642 { $$ = finish_object_call_expr ($2, $1, $4); }
1643 | object unqualified_id LEFT_RIGHT
1644 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1645 | object overqualified_id '(' nonnull_exprlist ')'
1646 { $$ = finish_qualified_object_call_expr ($2, $1, $4); }
1647 | object overqualified_id LEFT_RIGHT
1648 { $$ = finish_qualified_object_call_expr ($2, $1, NULL_TREE); }
1649 /* p->int::~int() is valid -- 12.4 */
1650 | object '~' TYPESPEC LEFT_RIGHT
1651 { $$ = finish_pseudo_destructor_call_expr ($1, NULL_TREE, $3); }
1652 | object TYPESPEC SCOPE '~' TYPESPEC LEFT_RIGHT
1653 { $$ = finish_pseudo_destructor_call_expr ($1, $2, $5); }
1656 $$ = error_mark_node;
1660 /* Not needed for now.
1666 { $$ = error_mark_node; }
1668 { if (current_function_decl == 0)
1670 error ("braced-group within expression allowed only inside a function");
1673 $<ttype>$ = expand_start_stmt_expr (); }
1676 pedwarn ("ISO C++ forbids braced-groups within expressions");
1677 $$ = expand_end_stmt_expr ($<ttype>2); }
1678 | primary_no_id '(' nonnull_exprlist ')'
1679 { $$ = build_x_function_call ($$, $3, current_class_ref); }
1680 | primary_no_id LEFT_RIGHT
1681 { $$ = build_x_function_call ($$, NULL_TREE, current_class_ref); }
1682 | primary_no_id '[' expr ']'
1684 | primary_no_id PLUSPLUS
1685 { $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); }
1686 | primary_no_id MINUSMINUS
1687 { $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); }
1689 { goto do_scoped_id; }
1690 | SCOPE operator_name
1691 { if (TREE_CODE ($2) == IDENTIFIER_NODE)
1693 goto do_scoped_operator;
1702 { got_scope = NULL_TREE; $$ = 1; }
1708 | global_scope delete
1709 { got_scope = NULL_TREE; $$ = 1; }
1714 { $$ = boolean_true_node; }
1716 { $$ = boolean_false_node; }
1719 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
1723 { $$ = chainon ($$, $2); }
1729 setup_vtbl_ptr (NULL_TREE, NULL_TREE);
1735 { got_object = TREE_TYPE ($$); }
1738 $$ = build_x_arrow ($$);
1739 got_object = TREE_TYPE ($$);
1744 typespec initdecls ';'
1746 if ($1.t && IS_AGGR_TYPE_CODE (TREE_CODE ($1.t)))
1747 note_got_semicolon ($1.t);
1749 | typed_declspecs initdecls ';'
1751 note_list_got_semicolon ($1.t);
1753 | declmods notype_initdecls ';'
1755 | typed_declspecs ';'
1758 note_list_got_semicolon ($1.t);
1761 { warning ("empty declaration"); }
1766 /* Any kind of declarator (thus, all declarators allowed
1767 after an explicit typespec). */
1770 after_type_declarator %prec EMPTY
1771 | notype_declarator %prec EMPTY
1774 /* This is necessary to postpone reduction of `int()()()()'. */
1776 LEFT_RIGHT %prec EMPTY
1777 { $$ = make_call_declarator (NULL_TREE, empty_parms (),
1778 NULL_TREE, NULL_TREE); }
1779 | fcast_or_absdcl LEFT_RIGHT %prec EMPTY
1780 { $$ = make_call_declarator ($$, empty_parms (), NULL_TREE,
1784 /* ISO type-id (8.1) */
1786 typed_typespecs absdcl
1787 { $$.t = build_tree_list ($1.t, $2);
1788 $$.new_type_flag = $1.new_type_flag; }
1789 | nonempty_cv_qualifiers absdcl
1790 { $$.t = build_tree_list ($1.t, $2);
1791 $$.new_type_flag = $1.new_type_flag; }
1793 { $$.t = build_tree_list (build_tree_list (NULL_TREE, $1.t),
1795 $$.new_type_flag = $1.new_type_flag; }
1796 | typed_typespecs %prec EMPTY
1797 { $$.t = build_tree_list ($1.t, NULL_TREE);
1798 $$.new_type_flag = $1.new_type_flag; }
1799 | nonempty_cv_qualifiers %prec EMPTY
1800 { $$.t = build_tree_list ($1.t, NULL_TREE);
1801 $$.new_type_flag = $1.new_type_flag; }
1804 /* Declspecs which contain at least one type specifier or typedef name.
1805 (Just `const' or `volatile' is not enough.)
1806 A typedef'd name following these is taken as a name to be declared.
1807 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1810 typed_typespecs %prec EMPTY
1811 { $$.lookups = type_lookups; }
1813 { $$.lookups = type_lookups; }
1818 { $$.t = tree_cons (NULL_TREE, $2.t, $1.t);
1819 $$.new_type_flag = $2.new_type_flag; }
1820 | typespec reserved_declspecs %prec HYPERUNARY
1821 { $$.t = tree_cons (NULL_TREE, $1.t, $2);
1822 $$.new_type_flag = $1.new_type_flag; }
1823 | typespec reserved_typespecquals reserved_declspecs
1824 { $$.t = tree_cons (NULL_TREE, $1.t, chainon ($2, $3));
1825 $$.new_type_flag = $1.new_type_flag; }
1826 | declmods typespec reserved_declspecs
1827 { $$.t = tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1828 $$.new_type_flag = $2.new_type_flag; }
1829 | declmods typespec reserved_typespecquals
1830 { $$.t = tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1831 $$.new_type_flag = $2.new_type_flag; }
1832 | declmods typespec reserved_typespecquals reserved_declspecs
1833 { $$.t = tree_cons (NULL_TREE, $2.t,
1834 chainon ($3, chainon ($4, $1.t)));
1835 $$.new_type_flag = $2.new_type_flag; }
1840 { if (extra_warnings)
1841 warning ("`%s' is not at beginning of declaration",
1842 IDENTIFIER_POINTER ($$));
1843 $$ = build_tree_list (NULL_TREE, $$); }
1844 | reserved_declspecs typespecqual_reserved
1845 { $$ = tree_cons (NULL_TREE, $2.t, $$); }
1846 | reserved_declspecs SCSPEC
1847 { if (extra_warnings)
1848 warning ("`%s' is not at beginning of declaration",
1849 IDENTIFIER_POINTER ($2));
1850 $$ = tree_cons (NULL_TREE, $2, $$); }
1851 | reserved_declspecs attributes
1852 { $$ = tree_cons ($2, NULL_TREE, $1); }
1854 { $$ = tree_cons ($1, NULL_TREE, NULL_TREE); }
1857 /* List of just storage classes and type modifiers.
1858 A declaration can start with just this, but then it cannot be used
1859 to redeclare a typedef-name.
1860 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1862 /* We use hash_tree_cons for lists of typeless declspecs so that they end
1863 up on a persistent obstack. Otherwise, they could appear at the
1864 beginning of something like
1866 static const struct { int foo () { } } b;
1868 and would be discarded after we finish compiling foo. We don't need to
1869 worry once we see a type. */
1872 nonempty_cv_qualifiers %prec EMPTY
1873 { $$.lookups = NULL_TREE; TREE_STATIC ($$.t) = 1; }
1876 $$.t = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
1877 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
1879 | declmods CV_QUALIFIER
1881 $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
1882 TREE_STATIC ($$.t) = 1;
1886 if (extra_warnings && TREE_STATIC ($$.t))
1887 warning ("`%s' is not at beginning of declaration",
1888 IDENTIFIER_POINTER ($2));
1889 $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
1890 TREE_STATIC ($$.t) = TREE_STATIC ($1.t);
1892 | declmods attributes
1893 { $$.t = hash_tree_cons ($2, NULL_TREE, $1.t); }
1894 | attributes %prec EMPTY
1896 $$.t = hash_tree_cons ($1, NULL_TREE, NULL_TREE);
1897 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
1901 /* Used instead of declspecs where storage classes are not allowed
1902 (that is, for typenames and structure components).
1904 C++ can takes storage classes for structure components.
1905 Don't accept a typedef-name if anything but a modifier precedes it. */
1908 typespec %prec EMPTY
1909 { $$.t = build_tree_list (NULL_TREE, $1.t);
1910 $$.new_type_flag = $1.new_type_flag; }
1911 | nonempty_cv_qualifiers typespec
1912 { $$.t = tree_cons (NULL_TREE, $2.t, $1.t);
1913 $$.new_type_flag = $2.new_type_flag; }
1914 | typespec reserved_typespecquals
1915 { $$.t = tree_cons (NULL_TREE, $1.t, $2);
1916 $$.new_type_flag = $1.new_type_flag; }
1917 | nonempty_cv_qualifiers typespec reserved_typespecquals
1918 { $$.t = tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1919 $$.new_type_flag = $2.new_type_flag; }
1922 reserved_typespecquals:
1923 typespecqual_reserved
1924 { $$ = build_tree_list (NULL_TREE, $1.t); }
1925 | reserved_typespecquals typespecqual_reserved
1926 { $$ = tree_cons (NULL_TREE, $2.t, $1); }
1929 /* A typespec (but not a type qualifier).
1930 Once we have seen one of these in a declaration,
1931 if a typedef name appears then it is being redeclared. */
1935 { $$.lookups = NULL_TREE; }
1936 | TYPESPEC %prec EMPTY
1937 { $$.t = $1; $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
1938 | complete_type_name
1939 { $$.t = $1; $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
1940 | TYPEOF '(' expr ')'
1941 { $$.t = finish_typeof ($3);
1942 $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
1943 | TYPEOF '(' type_id ')'
1944 { $$.t = groktypename ($3.t);
1945 $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
1946 | SIGOF '(' expr ')'
1947 { tree type = TREE_TYPE ($3);
1949 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
1950 if (IS_AGGR_TYPE (type))
1952 sorry ("sigof type specifier");
1957 error ("`sigof' applied to non-aggregate expression");
1958 $$.t = error_mark_node;
1961 | SIGOF '(' type_id ')'
1962 { tree type = groktypename ($3.t);
1964 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
1965 if (IS_AGGR_TYPE (type))
1967 sorry ("sigof type specifier");
1972 error("`sigof' applied to non-aggregate type");
1973 $$.t = error_mark_node;
1978 /* A typespec that is a reserved word, or a type qualifier. */
1980 typespecqual_reserved:
1982 { $$.t = $1; $$.new_type_flag = 0; }
1984 { $$.t = $1; $$.new_type_flag = 0; }
1990 | initdecls ',' initdcl
1991 { check_multiple_declarators (); }
1996 | notype_initdecls ',' initdcl
1997 { check_multiple_declarators (); }
2002 | nomods_initdecls ',' initdcl
2003 { check_multiple_declarators (); }
2009 | asm_keyword '(' string ')'
2010 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3); $$ = $3; }
2014 declarator maybeasm maybe_attribute '='
2015 { $<ttype>$ = parse_decl ($<ttype>1, $3, 1); }
2017 /* Note how the declaration of the variable is in effect while its init is parsed! */
2018 { parse_end_decl ($<ttype>5, $6, $2); }
2019 | declarator maybeasm maybe_attribute
2021 $<ttype>$ = parse_decl ($<ttype>1, $3, 0);
2022 parse_end_decl ($<ttype>$, NULL_TREE, $2);
2026 /* This rule assumes a certain configuration of the parser stack.
2027 In particular, $0, the element directly before the beginning of
2028 this rule on the stack, must be a maybeasm. $-1 must be a
2029 declarator or notype_declarator. And $-2 must be some declmods
2030 or declspecs. We can't move the maybeasm into this rule because
2031 we need that reduce so we prefer fn.def1 when appropriate. */
2034 { $<ttype>$ = parse_decl0 ($<ttype>-1, $<ftype>-2.t,
2035 $<ftype>-2.lookups, $1, 1); }
2036 /* Note how the declaration of the variable is in effect
2037 while its init is parsed! */
2039 { parse_end_decl ($<ttype>3, $4, $<ttype>0); }
2041 { tree d = parse_decl0 ($<ttype>-1, $<ftype>-2.t,
2042 $<ftype>-2.lookups, $1, 0);
2043 parse_end_decl (d, NULL_TREE, $<ttype>0); }
2047 declarator maybeasm initdcl0_innards
2052 notype_declarator maybeasm initdcl0_innards
2057 notype_declarator maybeasm
2058 { /* Set things up as initdcl0_innards expects. */
2063 | constructor_declarator maybeasm maybe_attribute
2064 { tree d = parse_decl0 ($1, NULL_TREE, NULL_TREE, $3, 0);
2065 parse_end_decl (d, NULL_TREE, $2); }
2068 /* the * rules are dummies to accept the Apollo extended syntax
2069 so that the header files compile. */
2080 | attributes attribute
2081 { $$ = chainon ($1, $2); }
2085 ATTRIBUTE '(' '(' attribute_list ')' ')'
2092 | attribute_list ',' attrib
2093 { $$ = chainon ($1, $3); }
2100 { $$ = build_tree_list ($1, NULL_TREE); }
2101 | any_word '(' IDENTIFIER ')'
2102 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
2103 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
2104 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
2105 | any_word '(' nonnull_exprlist ')'
2106 { $$ = build_tree_list ($1, $3); }
2109 /* This still leaves out most reserved keywords,
2110 shouldn't we include them? */
2119 /* A nonempty list of identifiers, including typenames. */
2120 identifiers_or_typenames:
2122 { $$ = build_tree_list (NULL_TREE, $1); }
2123 | identifiers_or_typenames ',' identifier
2124 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2128 /* empty */ %prec EMPTY
2133 /* If we are processing a template, we don't want to expand this
2137 expr_no_commas %prec '='
2139 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, NULL_TREE);
2140 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2142 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2143 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2144 | '{' initlist ',' '}'
2145 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2146 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2151 /* This chain is built in reverse order,
2152 and put in forward order where initlist is used. */
2155 { $$ = build_tree_list (NULL_TREE, $$); }
2157 { $$ = tree_cons (NULL_TREE, $3, $$); }
2158 /* These are for labeled elements. */
2159 | '[' expr_no_commas ']' init
2160 { $$ = build_tree_list ($2, $4); }
2161 | identifier ':' init
2162 { $$ = build_tree_list ($$, $3); }
2163 | initlist ',' identifier ':' init
2164 { $$ = tree_cons ($3, $5, $$); }
2168 PRE_PARSED_FUNCTION_DECL maybe_return_init ctor_initializer_opt compstmt_or_error
2170 expand_body (finish_function ((int)$3 | 2));
2171 process_next_inline ($1);
2173 | PRE_PARSED_FUNCTION_DECL maybe_return_init function_try_block
2175 expand_body (finish_function ((int)$3 | 2));
2176 process_next_inline ($1);
2178 | PRE_PARSED_FUNCTION_DECL maybe_return_init error
2180 finish_function (2);
2181 process_next_inline ($1); }
2186 | pending_inlines pending_inline eat_saved_input
2189 /* A regurgitated default argument. The value of DEFARG_MARKER will be
2190 the TREE_LIST node for the parameter in question. */
2192 DEFARG_MARKER expr_no_commas END_OF_SAVED_INPUT
2193 { replace_defarg ($1, $2); }
2194 | DEFARG_MARKER error END_OF_SAVED_INPUT
2195 { replace_defarg ($1, error_mark_node); }
2198 /* empty */ %prec EMPTY
2199 | pending_defargs defarg_again
2200 { do_pending_defargs (); }
2201 | pending_defargs error
2202 { do_pending_defargs (); }
2207 { $<ttype>$ = current_enum_type;
2208 current_enum_type = start_enum ($2); }
2210 { $$.t = finish_enum (current_enum_type);
2211 $$.new_type_flag = 1;
2212 current_enum_type = $<ttype>4;
2213 check_for_missing_semicolon ($$.t); }
2215 { $<ttype>$ = current_enum_type;
2216 current_enum_type = start_enum (make_anon_name ()); }
2218 { $$.t = finish_enum (current_enum_type);
2219 $$.new_type_flag = 1;
2220 current_enum_type = $<ttype>3;
2221 check_for_missing_semicolon ($$.t); }
2223 { $$.t = xref_tag (enum_type_node, $2, 1);
2224 $$.new_type_flag = 0; }
2225 | ENUM complex_type_name
2226 { $$.t = xref_tag (enum_type_node, $2, 1);
2227 $$.new_type_flag = 0; }
2228 | TYPENAME_KEYWORD typename_sub
2230 $$.new_type_flag = 0;
2231 if (!processing_template_decl)
2232 cp_pedwarn ("using `typename' outside of template"); }
2233 /* C++ extensions, merged with C to avoid shift/reduce conflicts */
2235 { $1.t = begin_class_definition ($1.t);
2236 current_aggr = NULL_TREE; }
2237 opt.component_decl_list '}' maybe_attribute
2242 if (yychar == YYEMPTY)
2244 semi = yychar == ';';
2246 t = finish_class_definition ($1.t, $6, semi,
2250 /* restore current_aggr */
2251 current_aggr = TREE_CODE (t) != RECORD_TYPE
2253 : CLASSTYPE_DECLARED_CLASS (t)
2254 ? class_type_node : record_type_node;
2258 begin_inline_definitions ();
2262 finish_inline_definitions ();
2264 $$.new_type_flag = 1;
2266 | class_head %prec EMPTY
2268 if ($1.new_type_flag && $1.t != error_mark_node)
2269 pop_scope (CP_DECL_CONTEXT (TYPE_MAIN_DECL ($1.t)));
2270 $$.new_type_flag = 0;
2271 if ($1.t == error_mark_node)
2273 else if (TYPE_BINFO ($1.t) == NULL_TREE)
2275 cp_error ("%T is not a class type", $1.t);
2276 $$.t = error_mark_node;
2281 /* struct B: public A; is not accepted by the standard grammar. */
2282 if (CLASS_TYPE_P ($$.t)
2283 && TYPE_BINFO_BASETYPES ($$.t)
2284 && !COMPLETE_TYPE_P ($$.t)
2285 && ! TYPE_BEING_DEFINED ($$.t))
2286 cp_error ("base clause without member specification for `%#T'",
2300 { if (pedantic && !in_system_header)
2301 pedwarn ("comma at end of enumerator list"); }
2307 { error ("storage class specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2309 { error ("type specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2311 { error ("type qualifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2313 { error ("no body nor ';' separates two class, struct or union declarations"); }
2315 { $$ = build_tree_list ($2, $1); }
2318 named_class_head_sans_basetype:
2326 named_class_head_sans_basetype_defn:
2327 aggr identifier_defn %prec EMPTY
2328 { current_aggr = $$; $$ = $2; }
2329 | named_class_head_sans_basetype '{'
2330 { yyungetc ('{', 1); }
2331 | named_class_head_sans_basetype ':'
2332 { yyungetc (':', 1); }
2335 named_complex_class_head_sans_basetype:
2336 aggr nested_name_specifier identifier
2339 $$.t = handle_class_head ($1, $2, $3);
2340 $$.new_type_flag = 1;
2342 | aggr global_scope nested_name_specifier identifier
2345 $$.t = handle_class_head ($1, $3, $4);
2346 $$.new_type_flag = 1;
2348 | aggr global_scope identifier
2351 $$.t = handle_class_head ($1, NULL_TREE, $3);
2352 $$.new_type_flag = 1;
2354 | aggr apparent_template_type
2358 $$.new_type_flag = 0;
2360 | aggr nested_name_specifier apparent_template_type
2364 push_scope (CP_DECL_CONTEXT ($$.t));
2365 $$.new_type_flag = 1;
2370 named_class_head_sans_basetype %prec EMPTY
2372 $$.t = xref_tag (current_aggr, $1, 1);
2373 $$.new_type_flag = 0;
2375 | named_class_head_sans_basetype_defn
2376 { $<ttype>$ = xref_tag (current_aggr, $1, 0); }
2377 /* Class name is unqualified, so we look for base classes
2378 in the current scope. */
2379 maybe_base_class_list %prec EMPTY
2382 $$.new_type_flag = 0;
2384 xref_basetypes (current_aggr, $1, $<ttype>2, $3);
2386 | named_complex_class_head_sans_basetype
2387 maybe_base_class_list
2389 if ($1.t != error_mark_node)
2391 tree type = TREE_TYPE ($1.t);
2394 $$.new_type_flag = $1.new_type_flag;
2395 if ((current_aggr == union_type_node)
2396 != (TREE_CODE (type) == UNION_TYPE))
2397 cp_pedwarn (current_aggr == union_type_node
2398 ? "`union' tag used in declaring `%#T'"
2399 : "non-`union' tag used in declaring `%#T'",
2401 else if (TREE_CODE (type) == RECORD_TYPE)
2402 /* We might be specializing a template with a different
2404 CLASSTYPE_DECLARED_CLASS (type)
2405 = (current_aggr == class_type_node);
2408 if (TREE_CODE (type) == TYPENAME_TYPE)
2409 /* In a definition of a member class template, we
2410 will get here with an implicit typename, a
2411 TYPENAME_TYPE with a type. */
2412 type = TREE_TYPE (type);
2413 maybe_process_partial_specialization (type);
2414 xref_basetypes (current_aggr, $1.t, type, $2);
2422 { $$ = xref_tag ($$, make_anon_name (), 0);
2423 yyungetc ('{', 1); }
2426 /* The tree output of this nonterminal a declarationf or the type
2427 named. If NEW_TYPE_FLAG is set, then the name used in this
2428 class-head was explicitly qualified, e.g.: `struct X::Y'. We have
2429 already called push_scope for X. */
2434 $$.new_type_flag = 0;
2439 maybe_base_class_list:
2440 /* empty */ %prec EMPTY
2442 | ':' see_typename %prec EMPTY
2443 { yyungetc(':', 1); $$ = NULL_TREE; }
2444 | ':' see_typename base_class_list %prec EMPTY
2450 | base_class_list ',' see_typename base_class
2451 { $$ = chainon ($$, $4); }
2456 { $$ = finish_base_specifier (access_default_node, $1); }
2457 | base_class_access_list see_typename base_class.1
2458 { $$ = finish_base_specifier ($1, $3); }
2464 $$ = error_mark_node; }
2466 { $$ = TREE_TYPE ($$); }
2469 base_class_access_list:
2470 VISSPEC see_typename
2471 | SCSPEC see_typename
2472 { if ($1 != ridpointers[(int)RID_VIRTUAL])
2473 cp_error ("`%D' access", $1);
2474 $$ = access_default_virtual_node; }
2475 | base_class_access_list VISSPEC see_typename
2477 if ($1 != access_default_virtual_node)
2478 error ("multiple access specifiers");
2479 else if ($2 == access_public_node)
2480 $$ = access_public_virtual_node;
2481 else if ($2 == access_protected_node)
2482 $$ = access_protected_virtual_node;
2483 else /* $2 == access_private_node */
2484 $$ = access_private_virtual_node;
2486 | base_class_access_list SCSPEC see_typename
2487 { if ($2 != ridpointers[(int)RID_VIRTUAL])
2488 cp_error ("`%D' access", $2);
2489 else if ($$ == access_public_node)
2490 $$ = access_public_virtual_node;
2491 else if ($$ == access_protected_node)
2492 $$ = access_protected_virtual_node;
2493 else if ($$ == access_private_node)
2494 $$ = access_private_virtual_node;
2496 error ("multiple `virtual' specifiers");
2500 opt.component_decl_list:
2501 | component_decl_list
2502 | opt.component_decl_list access_specifier component_decl_list
2503 | opt.component_decl_list access_specifier
2509 current_access_specifier = $1;
2513 /* Note: we no longer warn about the semicolon after a component_decl_list.
2514 ARM $9.2 says that the semicolon is optional, and therefore allowed. */
2515 component_decl_list:
2518 finish_member_declaration ($1);
2519 current_aggr = NULL_TREE;
2521 | component_decl_list component_decl
2523 finish_member_declaration ($2);
2524 current_aggr = NULL_TREE;
2529 component_decl_1 ';'
2530 | component_decl_1 '}'
2531 { error ("missing ';' before right brace");
2532 yyungetc ('}', 0); }
2533 /* C++: handle constructors, destructors and inline functions */
2534 /* note that INLINE is like a TYPESPEC */
2535 | fn.def2 ':' /* base_init compstmt */
2536 { $$ = finish_method ($$); }
2537 | fn.def2 TRY /* base_init compstmt */
2538 { $$ = finish_method ($$); }
2539 | fn.def2 RETURN_KEYWORD /* base_init compstmt */
2540 { $$ = finish_method ($$); }
2541 | fn.def2 '{' /* nodecls compstmt */
2542 { $$ = finish_method ($$); }
2545 | extension component_decl
2548 | template_header component_decl
2551 $$ = finish_member_template_decl ($2);
2553 /* The component was already processed. */
2556 finish_template_decl ($1);
2558 | template_header typed_declspecs ';'
2560 $$ = finish_member_class_template ($2.t);
2561 finish_template_decl ($1);
2566 /* Do not add a "typed_declspecs declarator" rule here for
2567 speed; we need to call grok_x_components for enums, so the
2568 speedup would be insignificant. */
2569 typed_declspecs components
2571 /* Most of the productions for component_decl only
2572 allow the creation of one new member, so we call
2573 finish_member_declaration in component_decl_list.
2574 For this rule and the next, however, there can be
2575 more than one member, e.g.:
2579 and we need the first member to be fully
2580 registered before the second is processed.
2581 Therefore, the rules for components take care of
2582 this processing. To avoid registering the
2583 components more than once, we send NULL_TREE up
2584 here; that lets finish_member_declaration know
2585 that there is nothing to do. */
2587 grok_x_components ($1.t);
2590 | declmods notype_components
2593 grok_x_components ($1.t);
2596 | notype_declarator maybeasm maybe_attribute maybe_init
2597 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2598 build_tree_list ($3, NULL_TREE)); }
2599 | constructor_declarator maybeasm maybe_attribute maybe_init
2600 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2601 build_tree_list ($3, NULL_TREE)); }
2602 | ':' expr_no_commas
2603 { $$ = grokbitfield (NULL_TREE, NULL_TREE, $2); }
2607 /* These rules introduce a reduce/reduce conflict; in
2608 typedef int foo, bar;
2612 should "A::foo" be declared as a function or "A::bar" as a data
2613 member? In other words, is "bar" an after_type_declarator or a
2615 | declmods component_constructor_declarator maybeasm maybe_attribute maybe_init
2616 { tree specs, attrs;
2617 split_specs_attrs ($1.t, &specs, &attrs);
2618 $$ = grokfield ($2, specs, $5, $3,
2619 build_tree_list ($4, attrs)); }
2620 | component_constructor_declarator maybeasm maybe_attribute maybe_init
2621 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2622 build_tree_list ($3, NULL_TREE)); }
2624 { $$ = do_class_using_decl ($1); }
2626 /* The case of exactly one component is handled directly by component_decl. */
2629 /* empty: possibly anonymous */
2631 | component_declarator0
2633 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2634 $1 = finish_member_template_decl ($1);
2635 finish_member_declaration ($1);
2638 | components ',' component_declarator
2640 check_multiple_declarators ();
2641 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2642 $3 = finish_member_template_decl ($3);
2643 finish_member_declaration ($3);
2649 /* empty: possibly anonymous */
2651 | notype_component_declarator0
2653 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2654 $1 = finish_member_template_decl ($1);
2655 finish_member_declaration ($1);
2658 | notype_components ',' notype_component_declarator
2660 check_multiple_declarators ();
2661 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2662 $3 = finish_member_template_decl ($3);
2663 finish_member_declaration ($3);
2668 component_declarator0:
2669 after_type_component_declarator0
2670 | notype_component_declarator0
2673 component_declarator:
2674 after_type_component_declarator
2675 | notype_component_declarator
2678 after_type_component_declarator0:
2679 after_type_declarator maybeasm maybe_attribute maybe_init
2680 { $$ = parse_field0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2682 | TYPENAME ':' expr_no_commas maybe_attribute
2683 { $$ = parse_bitfield0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2687 notype_component_declarator0:
2688 notype_declarator maybeasm maybe_attribute maybe_init
2689 { $$ = parse_field0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2691 | constructor_declarator maybeasm maybe_attribute maybe_init
2692 { $$ = parse_field0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2694 | IDENTIFIER ':' expr_no_commas maybe_attribute
2695 { $$ = parse_bitfield0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2697 | ':' expr_no_commas maybe_attribute
2698 { $$ = parse_bitfield0 (NULL_TREE, $<ftype>0.t,
2699 $<ftype>0.lookups, $3, $2); }
2702 after_type_component_declarator:
2703 after_type_declarator maybeasm maybe_attribute maybe_init
2704 { $$ = parse_field ($1, $3, $2, $4); }
2705 | TYPENAME ':' expr_no_commas maybe_attribute
2706 { $$ = parse_bitfield ($1, $4, $3); }
2709 notype_component_declarator:
2710 notype_declarator maybeasm maybe_attribute maybe_init
2711 { $$ = parse_field ($1, $3, $2, $4); }
2712 | IDENTIFIER ':' expr_no_commas maybe_attribute
2713 { $$ = parse_bitfield ($1, $4, $3); }
2714 | ':' expr_no_commas maybe_attribute
2715 { $$ = parse_bitfield (NULL_TREE, $3, $2); }
2719 enumlist maybecomma_warn
2723 /* We chain the enumerators in reverse order.
2724 Because of the way enums are built, the order is
2725 insignificant. Take advantage of this fact. */
2729 | enumlist ',' enumerator
2734 { build_enumerator ($1, NULL_TREE, current_enum_type); }
2735 | identifier '=' expr_no_commas
2736 { build_enumerator ($1, $3, current_enum_type); }
2739 /* ISO new-type-id (5.3.4) */
2741 type_specifier_seq new_declarator
2742 { $$.t = build_tree_list ($1.t, $2);
2743 $$.new_type_flag = $1.new_type_flag; }
2744 | type_specifier_seq %prec EMPTY
2745 { $$.t = build_tree_list ($1.t, NULL_TREE);
2746 $$.new_type_flag = $1.new_type_flag; }
2747 /* GNU extension to allow arrays of arbitrary types with
2748 non-constant dimension. */
2749 | '(' type_id ')' '[' expr ']'
2752 pedwarn ("ISO C++ forbids array dimensions with parenthesized type in new");
2753 $$.t = build_parse_node (ARRAY_REF, TREE_VALUE ($2.t), $5);
2754 $$.t = build_tree_list (TREE_PURPOSE ($2.t), $$.t);
2755 $$.new_type_flag = $2.new_type_flag;
2760 /* empty */ %prec EMPTY
2762 | cv_qualifiers CV_QUALIFIER
2763 { $$ = tree_cons (NULL_TREE, $2, $$); }
2766 nonempty_cv_qualifiers:
2768 { $$.t = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
2769 $$.new_type_flag = 0; }
2770 | nonempty_cv_qualifiers CV_QUALIFIER
2771 { $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
2772 $$.new_type_flag = $1.new_type_flag; }
2775 /* These rules must follow the rules for function declarations
2776 and component declarations. That way, longer rules are preferred. */
2778 /* An expression which will not live on the momentary obstack. */
2780 '(' nonnull_exprlist ')'
2785 { $$ = empty_parms (); }
2790 /* A declarator that is allowed only after an explicit typespec. */
2792 after_type_declarator_intern:
2793 after_type_declarator
2794 | attributes after_type_declarator
2796 /* Provide support for '(' attributes '*' declarator ')'
2798 $$ = tree_cons ($1, $2, NULL_TREE);
2802 /* may all be followed by prec '.' */
2803 after_type_declarator:
2804 '*' nonempty_cv_qualifiers after_type_declarator_intern %prec UNARY
2805 { $$ = make_pointer_declarator ($2.t, $3); }
2806 | '&' nonempty_cv_qualifiers after_type_declarator_intern %prec UNARY
2807 { $$ = make_reference_declarator ($2.t, $3); }
2808 | '*' after_type_declarator_intern %prec UNARY
2809 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2810 | '&' after_type_declarator_intern %prec UNARY
2811 { $$ = make_reference_declarator (NULL_TREE, $2); }
2812 | ptr_to_mem cv_qualifiers after_type_declarator_intern
2813 { tree arg = make_pointer_declarator ($2, $3);
2814 $$ = build_parse_node (SCOPE_REF, $1, arg);
2816 | direct_after_type_declarator
2819 direct_after_type_declarator:
2820 direct_after_type_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2821 { $$ = make_call_declarator ($$, $2, $3, $4); }
2822 | direct_after_type_declarator '[' expr ']'
2823 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
2824 | direct_after_type_declarator '[' ']'
2825 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
2826 | '(' after_type_declarator_intern ')'
2828 | nested_name_specifier type_name %prec EMPTY
2829 { push_nested_class ($1, 3);
2830 $$ = build_parse_node (SCOPE_REF, $$, $2);
2831 TREE_COMPLEXITY ($$) = current_class_depth; }
2832 | type_name %prec EMPTY
2836 type_name %prec EMPTY
2838 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2840 $$ = lookup_name ($1, 1);
2841 maybe_note_name_used_in_class ($1, $$);
2846 | global_scope type_name
2848 if (TREE_CODE ($2) == IDENTIFIER_NODE)
2849 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
2852 got_scope = NULL_TREE;
2859 | global_scope nested_type
2864 nested_name_specifier type_name %prec EMPTY
2865 { $$ = get_type_decl ($2); }
2868 /* A declarator allowed whether or not there has been
2869 an explicit typespec. These cannot redeclare a typedef-name. */
2871 notype_declarator_intern:
2873 | attributes notype_declarator
2875 /* Provide support for '(' attributes '*' declarator ')'
2877 $$ = tree_cons ($1, $2, NULL_TREE);
2882 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2883 { $$ = make_pointer_declarator ($2.t, $3); }
2884 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2885 { $$ = make_reference_declarator ($2.t, $3); }
2886 | '*' notype_declarator_intern %prec UNARY
2887 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2888 | '&' notype_declarator_intern %prec UNARY
2889 { $$ = make_reference_declarator (NULL_TREE, $2); }
2890 | ptr_to_mem cv_qualifiers notype_declarator_intern
2891 { tree arg = make_pointer_declarator ($2, $3);
2892 $$ = build_parse_node (SCOPE_REF, $1, arg);
2894 | direct_notype_declarator
2897 complex_notype_declarator:
2898 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2899 { $$ = make_pointer_declarator ($2.t, $3); }
2900 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2901 { $$ = make_reference_declarator ($2.t, $3); }
2902 | '*' complex_notype_declarator %prec UNARY
2903 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2904 | '&' complex_notype_declarator %prec UNARY
2905 { $$ = make_reference_declarator (NULL_TREE, $2); }
2906 | ptr_to_mem cv_qualifiers notype_declarator_intern
2907 { tree arg = make_pointer_declarator ($2, $3);
2908 $$ = build_parse_node (SCOPE_REF, $1, arg);
2910 | complex_direct_notype_declarator
2913 complex_direct_notype_declarator:
2914 direct_notype_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2915 { $$ = make_call_declarator ($$, $2, $3, $4); }
2916 | '(' complex_notype_declarator ')'
2918 | direct_notype_declarator '[' expr ']'
2919 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
2920 | direct_notype_declarator '[' ']'
2921 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
2922 | notype_qualified_id
2923 { enter_scope_of ($1); }
2924 | global_scope notype_qualified_id
2925 { enter_scope_of ($2); $$ = $2;}
2926 | global_scope notype_unqualified_id
2927 { $$ = build_parse_node (SCOPE_REF, global_namespace, $2);
2928 enter_scope_of ($$);
2930 | nested_name_specifier notype_template_declarator
2931 { got_scope = NULL_TREE;
2932 $$ = build_parse_node (SCOPE_REF, $1, $2);
2933 enter_scope_of ($$);
2938 nested_name_specifier unqualified_id
2939 { got_scope = NULL_TREE;
2940 $$ = build_parse_node (SCOPE_REF, $$, $2); }
2941 | nested_name_specifier object_template_id
2942 { got_scope = NULL_TREE;
2943 $$ = build_parse_node (SCOPE_REF, $1, $2); }
2946 notype_qualified_id:
2947 nested_name_specifier notype_unqualified_id
2948 { got_scope = NULL_TREE;
2949 $$ = build_parse_node (SCOPE_REF, $$, $2); }
2950 | nested_name_specifier object_template_id
2951 { got_scope = NULL_TREE;
2952 $$ = build_parse_node (SCOPE_REF, $1, $2); }
2957 | global_scope notype_qualified_id
2962 typespec '(' nonnull_exprlist ')'
2963 { $$ = build_functional_cast ($1.t, $3); }
2964 | typespec '(' expr_or_declarator_intern ')'
2965 { $$ = reparse_decl_as_expr ($1.t, $3); }
2966 | typespec fcast_or_absdcl %prec EMPTY
2967 { $$ = reparse_absdcl_as_expr ($1.t, $2); }
2973 | template_type %prec EMPTY
2976 nested_name_specifier:
2977 nested_name_specifier_1
2978 | nested_name_specifier nested_name_specifier_1
2980 | nested_name_specifier TEMPLATE explicit_template_type SCOPE
2982 = make_typename_type ($1, $3, /*complain=*/1); }
2985 /* Why the @#$%^& do type_name and notype_identifier need to be expanded
2986 inline here?!? (jason) */
2987 nested_name_specifier_1:
2990 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2993 maybe_note_name_used_in_class ($1, $$);
2996 complete_type (TYPE_MAIN_VARIANT (TREE_TYPE ($$)));
3000 if (TREE_CODE ($1) == IDENTIFIER_NODE)
3002 got_scope = $$ = TREE_TYPE ($$);
3006 if (TREE_CODE ($$) == IDENTIFIER_NODE)
3010 | template_type SCOPE
3011 { got_scope = $$ = complete_type (TREE_TYPE ($1)); }
3012 /* These break 'const i;'
3016 cp_error ("`%D' is not an aggregate typedef",
3017 lastiddecl ? lastiddecl : $$);
3018 $$ = error_mark_node;
3021 { goto failed_scope; } */
3026 | global_scope typename_sub0
3031 typename_sub1 identifier %prec EMPTY
3034 $$ = make_typename_type ($1, $2, /*complain=*/1);
3035 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
3036 cp_error ("`%T' is not a class or namespace", $2);
3040 if (TREE_CODE ($$) == TYPE_DECL)
3041 $$ = TREE_TYPE ($$);
3044 | typename_sub1 template_type %prec EMPTY
3045 { $$ = TREE_TYPE ($2); }
3046 | typename_sub1 explicit_template_type %prec EMPTY
3047 { $$ = make_typename_type ($1, $2, /*complain=*/1); }
3048 | typename_sub1 TEMPLATE explicit_template_type %prec EMPTY
3049 { $$ = make_typename_type ($1, $3, /*complain=*/1); }
3055 if (TREE_CODE ($1) == IDENTIFIER_NODE)
3056 cp_error ("`%T' is not a class or namespace", $1);
3058 | typename_sub1 typename_sub2
3061 $$ = make_typename_type ($1, $2, /*complain=*/1);
3062 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
3063 cp_error ("`%T' is not a class or namespace", $2);
3067 if (TREE_CODE ($$) == TYPE_DECL)
3068 $$ = TREE_TYPE ($$);
3071 | typename_sub1 explicit_template_type SCOPE
3073 = make_typename_type ($1, $2, /*complain=*/1); }
3074 | typename_sub1 TEMPLATE explicit_template_type SCOPE
3076 = make_typename_type ($1, $3, /*complain=*/1); }
3082 if (TREE_CODE ($1) != IDENTIFIER_NODE)
3085 /* Retrieve the type for the identifier, which might involve
3086 some computation. */
3087 got_scope = $$ = complete_type (IDENTIFIER_TYPE_VALUE ($1));
3089 if ($$ == error_mark_node)
3090 cp_error ("`%T' is not a class or namespace", $1);
3094 if (TREE_CODE ($1) != IDENTIFIER_NODE)
3096 got_scope = $$ = complete_type (TREE_TYPE ($$));
3098 | template_type SCOPE
3099 { got_scope = $$ = complete_type (TREE_TYPE ($$)); }
3104 if (TREE_CODE ($$) == IDENTIFIER_NODE)
3110 explicit_template_type:
3111 identifier '<' template_arg_list_opt template_close_bracket
3112 { $$ = build_min_nt (TEMPLATE_ID_EXPR, $1, $3); }
3116 global_scope type_name
3118 if (TREE_CODE ($2) == IDENTIFIER_NODE)
3119 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
3122 got_scope = NULL_TREE;
3125 | global_scope nested_type
3130 nested_name_specifier '*'
3131 { got_scope = NULL_TREE; }
3132 | global_scope nested_name_specifier '*'
3133 { $$ = $2; got_scope = NULL_TREE; }
3136 /* All uses of explicit global scope must go through this nonterminal so
3137 that got_scope will be set before yylex is called to get the next token. */
3140 { got_scope = void_type_node; }
3143 /* ISO new-declarator (5.3.4) */
3145 '*' cv_qualifiers new_declarator
3146 { $$ = make_pointer_declarator ($2, $3); }
3147 | '*' cv_qualifiers %prec EMPTY
3148 { $$ = make_pointer_declarator ($2, NULL_TREE); }
3149 | '&' cv_qualifiers new_declarator %prec EMPTY
3150 { $$ = make_reference_declarator ($2, $3); }
3151 | '&' cv_qualifiers %prec EMPTY
3152 { $$ = make_reference_declarator ($2, NULL_TREE); }
3153 | ptr_to_mem cv_qualifiers %prec EMPTY
3154 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3155 $$ = build_parse_node (SCOPE_REF, $1, arg);
3157 | ptr_to_mem cv_qualifiers new_declarator
3158 { tree arg = make_pointer_declarator ($2, $3);
3159 $$ = build_parse_node (SCOPE_REF, $1, arg);
3161 | direct_new_declarator %prec EMPTY
3164 /* ISO direct-new-declarator (5.3.4) */
3165 direct_new_declarator:
3167 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3168 | direct_new_declarator '[' expr ']'
3169 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3176 /* Provide support for '(' attributes '*' declarator ')'
3178 $$ = tree_cons ($1, $2, NULL_TREE);
3182 /* ISO abstract-declarator (8.1) */
3184 '*' nonempty_cv_qualifiers absdcl_intern
3185 { $$ = make_pointer_declarator ($2.t, $3); }
3187 { $$ = make_pointer_declarator (NULL_TREE, $2); }
3188 | '*' nonempty_cv_qualifiers %prec EMPTY
3189 { $$ = make_pointer_declarator ($2.t, NULL_TREE); }
3191 { $$ = make_pointer_declarator (NULL_TREE, NULL_TREE); }
3192 | '&' nonempty_cv_qualifiers absdcl_intern
3193 { $$ = make_reference_declarator ($2.t, $3); }
3195 { $$ = make_reference_declarator (NULL_TREE, $2); }
3196 | '&' nonempty_cv_qualifiers %prec EMPTY
3197 { $$ = make_reference_declarator ($2.t, NULL_TREE); }
3199 { $$ = make_reference_declarator (NULL_TREE, NULL_TREE); }
3200 | ptr_to_mem cv_qualifiers %prec EMPTY
3201 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3202 $$ = build_parse_node (SCOPE_REF, $1, arg);
3204 | ptr_to_mem cv_qualifiers absdcl_intern
3205 { tree arg = make_pointer_declarator ($2, $3);
3206 $$ = build_parse_node (SCOPE_REF, $1, arg);
3208 | direct_abstract_declarator %prec EMPTY
3211 /* ISO direct-abstract-declarator (8.1) */
3212 direct_abstract_declarator:
3213 '(' absdcl_intern ')'
3215 /* `(typedef)1' is `int'. */
3216 | direct_abstract_declarator '(' parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3217 { $$ = make_call_declarator ($$, $3, $5, $6); }
3218 | direct_abstract_declarator LEFT_RIGHT cv_qualifiers exception_specification_opt %prec '.'
3219 { $$ = make_call_declarator ($$, empty_parms (), $3, $4); }
3220 | direct_abstract_declarator '[' expr ']' %prec '.'
3221 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3222 | direct_abstract_declarator '[' ']' %prec '.'
3223 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
3224 | '(' complex_parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3225 { $$ = make_call_declarator (NULL_TREE, $2, $4, $5); }
3226 | regcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3227 { set_quals_and_spec ($$, $2, $3); }
3228 | fcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3229 { set_quals_and_spec ($$, $2, $3); }
3230 | '[' expr ']' %prec '.'
3231 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3233 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, NULL_TREE); }
3236 /* For C++, decls and stmts can be intermixed, so we don't need to
3237 have a special rule that won't start parsing the stmt section
3238 until we have a stmt that parses without errors. */
3251 /* Read zero or more forward-declarations for labels
3252 that nested functions can jump to. */
3257 pedwarn ("ISO C++ forbids label declarations"); }
3262 | label_decls label_decl
3266 LABEL identifiers_or_typenames ';'
3270 finish_label_decl (TREE_VALUE ($2));
3271 $2 = TREE_CHAIN ($2);
3276 /* This is the body of a function definition.
3277 It causes syntax errors to ignore to the next openbrace. */
3286 { $<ttype>$ = begin_compound_stmt (0); }
3288 { $$ = finish_compound_stmt (0, $<ttype>2); }
3294 $<ttype>$ = begin_if_stmt ();
3295 cond_stmt_keyword = "if";
3298 { finish_if_stmt_cond ($3, $<ttype>2); }
3299 implicitly_scoped_stmt
3300 { $<ttype>$ = finish_then_clause ($<ttype>2); }
3303 implicitly_scoped_stmt:
3305 | { $<ttype>$ = begin_compound_stmt (0); }
3307 { $$ = finish_compound_stmt (0, $<ttype>1); }
3320 { finish_expr_stmt ($1); }
3322 { begin_else_clause (); }
3323 implicitly_scoped_stmt
3325 finish_else_clause ($<ttype>1);
3328 | simple_if %prec IF
3329 { finish_if_stmt (); }
3332 $<ttype>$ = begin_while_stmt ();
3333 cond_stmt_keyword = "while";
3336 { finish_while_stmt_cond ($3, $<ttype>2); }
3338 { finish_while_stmt ($<ttype>2); }
3340 { $<ttype>$ = begin_do_stmt (); }
3341 implicitly_scoped_stmt WHILE
3343 finish_do_body ($<ttype>2);
3344 cond_stmt_keyword = "do";
3346 paren_expr_or_null ';'
3347 { finish_do_stmt ($6, $<ttype>2); }
3349 { $<ttype>$ = begin_for_stmt (); }
3350 '(' for.init.statement
3351 { finish_for_init_stmt ($<ttype>2); }
3353 { finish_for_cond ($6, $<ttype>2); }
3355 { finish_for_expr ($9, $<ttype>2); }
3357 { finish_for_stmt ($<ttype>2); }
3359 { $<ttype>$ = begin_switch_stmt (); }
3361 { finish_switch_cond ($4, $<ttype>2); }
3362 implicitly_scoped_stmt
3363 { finish_switch_stmt ($<ttype>2); }
3364 | CASE expr_no_commas ':'
3365 { finish_case_label ($2, NULL_TREE); }
3367 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
3368 { finish_case_label ($2, $4); }
3371 { finish_case_label (NULL_TREE, NULL_TREE); }
3374 { finish_break_stmt (); }
3376 { finish_continue_stmt (); }
3377 | RETURN_KEYWORD ';'
3378 { finish_return_stmt (NULL_TREE); }
3379 | RETURN_KEYWORD expr ';'
3380 { finish_return_stmt ($2); }
3381 | asm_keyword maybe_cv_qualifier '(' string ')' ';'
3383 finish_asm_stmt ($2, $4, NULL_TREE, NULL_TREE,
3386 /* This is the case with just output operands. */
3387 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ')' ';'
3389 finish_asm_stmt ($2, $4, $6, NULL_TREE,
3392 /* This is the case with input operands as well. */
3393 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':' asm_operands ')' ';'
3394 { finish_asm_stmt ($2, $4, $6, $8, NULL_TREE); }
3395 | asm_keyword maybe_cv_qualifier '(' string SCOPE asm_operands ')' ';'
3396 { finish_asm_stmt ($2, $4, NULL_TREE, $6, NULL_TREE); }
3397 /* This is the case with clobbered registers as well. */
3398 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':'
3399 asm_operands ':' asm_clobbers ')' ';'
3400 { finish_asm_stmt ($2, $4, $6, $8, $10); }
3401 | asm_keyword maybe_cv_qualifier '(' string SCOPE asm_operands ':'
3402 asm_clobbers ')' ';'
3403 { finish_asm_stmt ($2, $4, NULL_TREE, $6, $8); }
3404 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands SCOPE
3405 asm_clobbers ')' ';'
3406 { finish_asm_stmt ($2, $4, $6, NULL_TREE, $8); }
3410 pedwarn ("ISO C++ forbids computed gotos");
3411 finish_goto_stmt ($3);
3413 | GOTO identifier ';'
3414 { finish_goto_stmt ($2); }
3417 { error ("label must be followed by statement");
3418 yyungetc ('}', 0); }
3423 | namespace_using_decl
3424 { do_local_using_decl ($1); }
3430 { $<ttype>$ = begin_function_try_block (); }
3431 ctor_initializer_opt compstmt
3432 { finish_function_try_block ($<ttype>2); }
3435 finish_function_handler_sequence ($<ttype>2);
3442 { $<ttype>$ = begin_try_block (); }
3444 { finish_try_block ($<ttype>2); }
3446 { finish_handler_sequence ($<ttype>2); }
3451 | handler_seq handler
3456 { $<ttype>$ = begin_handler(); }
3458 { $<ttype>$ = finish_handler_parms ($3, $<ttype>2); }
3460 { finish_handler ($<ttype>4, $<ttype>2); }
3464 typed_typespecs %prec EMPTY
3465 | nonempty_cv_qualifiers %prec EMPTY
3471 /* This doesn't allow reference parameters, the below does.
3472 | '(' type_specifier_seq absdcl ')'
3473 { check_for_new_type ("inside exception declarations", $2);
3474 expand_start_catch_block ($2.t, $3); }
3475 | '(' type_specifier_seq ')'
3476 { check_for_new_type ("inside exception declarations", $2);
3477 expand_start_catch_block ($2.t, NULL_TREE); }
3478 | '(' type_specifier_seq notype_declarator ')'
3479 { check_for_new_type ("inside exception declarations", $2);
3480 expand_start_catch_block ($2.t, $3); }
3481 | '(' typed_typespecs after_type_declarator ')'
3482 { check_for_new_type ("inside exception declarations", $2);
3483 expand_start_catch_block ($2.t, $3); }
3484 This allows reference parameters... */
3487 check_for_new_type ("inside exception declarations", $2);
3488 $$ = start_handler_parms (TREE_PURPOSE ($2.t),
3495 { finish_label_stmt ($1); }
3497 { finish_label_stmt ($1); }
3499 { finish_label_stmt ($1); }
3501 { finish_label_stmt ($1); }
3506 { finish_expr_stmt ($1); }
3510 pedwarn ("ISO C++ forbids compound statements inside for initializations");
3514 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
3530 /* These are the operands other than the first string and colon
3531 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
3535 | nonnull_asm_operands
3538 nonnull_asm_operands:
3540 | nonnull_asm_operands ',' asm_operand
3541 { $$ = chainon ($$, $3); }
3546 { $$ = build_tree_list ($$, $3); }
3551 { $$ = tree_cons (NULL_TREE, combine_strings ($1), NULL_TREE);}
3552 | asm_clobbers ',' string
3553 { $$ = tree_cons (NULL_TREE, combine_strings ($3), $1); }
3556 /* This is what appears inside the parens in a function declarator.
3557 Its value is represented in the format that grokdeclarator expects.
3559 In C++, declaring a function with no parameters
3560 means that that function takes *no* parameters. */
3569 { $$ = finish_parmlist (build_tree_list (NULL_TREE, $1.t), 0);
3570 check_for_new_type ("inside parameter list", $1); }
3573 /* This nonterminal does not include the common sequence '(' type_id ')',
3574 as it is ambiguous and must be disambiguated elsewhere. */
3577 { $$ = finish_parmlist ($$, 0); }
3578 | parms_comma ELLIPSIS
3579 { $$ = finish_parmlist ($1, 1); }
3580 /* C++ allows an ellipsis without a separating ',' */
3582 { $$ = finish_parmlist ($1, 1); }
3584 { $$ = finish_parmlist (build_tree_list (NULL_TREE,
3587 { $$ = finish_parmlist (NULL_TREE, 1); }
3590 /* This helps us recover from really nasty
3591 parse errors, for example, a missing right
3593 yyerror ("possibly missing ')'");
3594 $$ = finish_parmlist ($1, 0);
3600 /* This helps us recover from really nasty
3601 parse errors, for example, a missing right
3603 yyerror ("possibly missing ')'");
3604 $$ = finish_parmlist (build_tree_list (NULL_TREE,
3611 /* A default argument to a */
3614 { maybe_snarf_defarg (); }
3624 /* A nonempty list of parameter declarations or type names. */
3627 { check_for_new_type ("in a parameter list", $1);
3628 $$ = build_tree_list (NULL_TREE, $1.t); }
3630 { check_for_new_type ("in a parameter list", $1);
3631 $$ = build_tree_list ($2, $1.t); }
3632 | parms_comma full_parm
3633 { check_for_new_type ("in a parameter list", $2);
3634 $$ = chainon ($$, $2.t); }
3635 | parms_comma bad_parm
3636 { $$ = chainon ($$, build_tree_list (NULL_TREE, $2)); }
3637 | parms_comma bad_parm '=' init
3638 { $$ = chainon ($$, build_tree_list ($4, $2)); }
3644 { check_for_new_type ("in a parameter list", $1);
3645 $$ = build_tree_list (NULL_TREE, $1.t); }
3648 /* A single parameter declaration or parameter type name,
3649 as found in a parmlist. */
3651 /* Here we expand typed_declspecs inline to avoid mis-parsing of
3652 TYPESPEC IDENTIFIER. */
3653 typed_declspecs1 declarator
3654 { tree specs = strip_attrs ($1.t);
3655 $$.new_type_flag = $1.new_type_flag;
3656 $$.t = build_tree_list (specs, $2); }
3657 | typed_typespecs declarator
3658 { $$.t = build_tree_list ($1.t, $2);
3659 $$.new_type_flag = $1.new_type_flag; }
3660 | typespec declarator
3661 { $$.t = build_tree_list (build_tree_list (NULL_TREE, $1.t),
3663 $$.new_type_flag = $1.new_type_flag; }
3664 | typed_declspecs1 absdcl
3665 { tree specs = strip_attrs ($1.t);
3666 $$.t = build_tree_list (specs, $2);
3667 $$.new_type_flag = $1.new_type_flag; }
3668 | typed_declspecs1 %prec EMPTY
3669 { tree specs = strip_attrs ($1.t);
3670 $$.t = build_tree_list (specs, NULL_TREE);
3671 $$.new_type_flag = $1.new_type_flag; }
3672 | declmods notype_declarator
3673 { tree specs = strip_attrs ($1.t);
3674 $$.t = build_tree_list (specs, $2);
3675 $$.new_type_flag = 0; }
3680 { $$.t = build_tree_list (NULL_TREE, $1.t);
3681 $$.new_type_flag = $1.new_type_flag; }
3683 { $$.t = build_tree_list ($2, $1.t);
3684 $$.new_type_flag = $1.new_type_flag; }
3693 /* empty */ %prec EMPTY
3694 { see_typename (); }
3698 /* empty */ %prec EMPTY
3700 error ("type specifier omitted for parameter");
3701 $$ = build_tree_list (integer_type_node, NULL_TREE);
3705 error ("type specifier omitted for parameter");
3706 if (TREE_CODE ($$) == SCOPE_REF
3707 && (TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TYPE_PARM
3708 || TREE_CODE (TREE_OPERAND ($$, 0)) == BOUND_TEMPLATE_TEMPLATE_PARM))
3709 cp_error (" perhaps you want `typename %E' to make it a type", $$);
3710 $$ = build_tree_list (integer_type_node, $$);
3714 exception_specification_opt:
3715 /* empty */ %prec EMPTY
3717 | THROW '(' ansi_raise_identifiers ')' %prec EMPTY
3719 | THROW LEFT_RIGHT %prec EMPTY
3720 { $$ = empty_except_spec; }
3723 ansi_raise_identifier:
3726 check_for_new_type ("exception specifier", $1);
3727 $$ = groktypename ($1.t);
3731 ansi_raise_identifiers:
3732 ansi_raise_identifier
3733 { $$ = add_exception_specifier (NULL_TREE, $1, 1); }
3734 | ansi_raise_identifiers ',' ansi_raise_identifier
3735 { $$ = add_exception_specifier ($1, $3, 1); }
3738 conversion_declarator:
3739 /* empty */ %prec EMPTY
3741 | '*' cv_qualifiers conversion_declarator
3742 { $$ = make_pointer_declarator ($2, $3); }
3743 | '&' cv_qualifiers conversion_declarator
3744 { $$ = make_reference_declarator ($2, $3); }
3745 | ptr_to_mem cv_qualifiers conversion_declarator
3746 { tree arg = make_pointer_declarator ($2, $3);
3747 $$ = build_parse_node (SCOPE_REF, $1, arg);
3754 saved_scopes = tree_cons (got_scope, got_object, saved_scopes);
3755 TREE_LANG_FLAG_0 (saved_scopes) = looking_for_typename;
3756 /* We look for conversion-type-id's in both the class and current
3757 scopes, just as for ID in 'ptr->ID::'. */
3758 looking_for_typename = 1;
3759 got_object = got_scope;
3760 got_scope = NULL_TREE;
3765 { got_scope = TREE_PURPOSE (saved_scopes);
3766 got_object = TREE_VALUE (saved_scopes);
3767 looking_for_typename = TREE_LANG_FLAG_0 (saved_scopes);
3768 saved_scopes = TREE_CHAIN (saved_scopes);
3773 operator '*' unoperator
3774 { $$ = frob_opname (ansi_opname (MULT_EXPR)); }
3775 | operator '/' unoperator
3776 { $$ = frob_opname (ansi_opname (TRUNC_DIV_EXPR)); }
3777 | operator '%' unoperator
3778 { $$ = frob_opname (ansi_opname (TRUNC_MOD_EXPR)); }
3779 | operator '+' unoperator
3780 { $$ = frob_opname (ansi_opname (PLUS_EXPR)); }
3781 | operator '-' unoperator
3782 { $$ = frob_opname (ansi_opname (MINUS_EXPR)); }
3783 | operator '&' unoperator
3784 { $$ = frob_opname (ansi_opname (BIT_AND_EXPR)); }
3785 | operator '|' unoperator
3786 { $$ = frob_opname (ansi_opname (BIT_IOR_EXPR)); }
3787 | operator '^' unoperator
3788 { $$ = frob_opname (ansi_opname (BIT_XOR_EXPR)); }
3789 | operator '~' unoperator
3790 { $$ = frob_opname (ansi_opname (BIT_NOT_EXPR)); }
3791 | operator ',' unoperator
3792 { $$ = frob_opname (ansi_opname (COMPOUND_EXPR)); }
3793 | operator ARITHCOMPARE unoperator
3794 { $$ = frob_opname (ansi_opname ($2)); }
3795 | operator '<' unoperator
3796 { $$ = frob_opname (ansi_opname (LT_EXPR)); }
3797 | operator '>' unoperator
3798 { $$ = frob_opname (ansi_opname (GT_EXPR)); }
3799 | operator EQCOMPARE unoperator
3800 { $$ = frob_opname (ansi_opname ($2)); }
3801 | operator ASSIGN unoperator
3802 { $$ = frob_opname (ansi_assopname ($2)); }
3803 | operator '=' unoperator
3804 { $$ = frob_opname (ansi_assopname (NOP_EXPR)); }
3805 | operator LSHIFT unoperator
3806 { $$ = frob_opname (ansi_opname ($2)); }
3807 | operator RSHIFT unoperator
3808 { $$ = frob_opname (ansi_opname ($2)); }
3809 | operator PLUSPLUS unoperator
3810 { $$ = frob_opname (ansi_opname (POSTINCREMENT_EXPR)); }
3811 | operator MINUSMINUS unoperator
3812 { $$ = frob_opname (ansi_opname (PREDECREMENT_EXPR)); }
3813 | operator ANDAND unoperator
3814 { $$ = frob_opname (ansi_opname (TRUTH_ANDIF_EXPR)); }
3815 | operator OROR unoperator
3816 { $$ = frob_opname (ansi_opname (TRUTH_ORIF_EXPR)); }
3817 | operator '!' unoperator
3818 { $$ = frob_opname (ansi_opname (TRUTH_NOT_EXPR)); }
3819 | operator '?' ':' unoperator
3820 { $$ = frob_opname (ansi_opname (COND_EXPR)); }
3821 | operator MIN_MAX unoperator
3822 { $$ = frob_opname (ansi_opname ($2)); }
3823 | operator POINTSAT unoperator %prec EMPTY
3824 { $$ = frob_opname (ansi_opname (COMPONENT_REF)); }
3825 | operator POINTSAT_STAR unoperator %prec EMPTY
3826 { $$ = frob_opname (ansi_opname (MEMBER_REF)); }
3827 | operator LEFT_RIGHT unoperator
3828 { $$ = frob_opname (ansi_opname (CALL_EXPR)); }
3829 | operator '[' ']' unoperator
3830 { $$ = frob_opname (ansi_opname (ARRAY_REF)); }
3831 | operator NEW unoperator %prec EMPTY
3832 { $$ = frob_opname (ansi_opname (NEW_EXPR)); }
3833 | operator DELETE unoperator %prec EMPTY
3834 { $$ = frob_opname (ansi_opname (DELETE_EXPR)); }
3835 | operator NEW '[' ']' unoperator
3836 { $$ = frob_opname (ansi_opname (VEC_NEW_EXPR)); }
3837 | operator DELETE '[' ']' unoperator
3838 { $$ = frob_opname (ansi_opname (VEC_DELETE_EXPR)); }
3839 | operator type_specifier_seq conversion_declarator unoperator
3840 { $$ = frob_opname (grokoptypename ($2.t, $3)); }
3841 | operator error unoperator
3842 { $$ = frob_opname (ansi_opname (ERROR_MARK)); }
3849 debug_yytranslate (value)
3852 return yytname[YYTRANSLATE (value)];