1 /* YACC parser for C++ syntax.
2 Copyright (C) 1988, 89, 93-98, 1999 Free Software Foundation, Inc.
3 Hacked by Michael Tiemann (tiemann@cygnus.com)
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
23 /* This grammar is based on the GNU CC grammar. */
25 /* Note: Bison automatically applies a default action of "$$ = $1" for
26 all derivations; this is applied before the explicit action, if one
27 is given. Keep this in mind when reading the actions. */
30 /* Cause the `yydebug' variable to be defined. */
47 /* Since parsers are distinct for each language, put the language string
48 definition here. (fnf) */
49 const char * const language_string
= "GNU C++";
51 extern
struct obstack permanent_obstack
;
53 extern
int end_of_file
;
55 /* Like YYERROR but do call yyerror. */
56 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
58 #define OP0(NODE) (TREE_OPERAND (NODE, 0))
59 #define OP1(NODE) (TREE_OPERAND (NODE, 1))
61 /* Contains the statement keyword (if/while/do) to include in an
62 error message if the user supplies an empty conditional expression. */
63 static const char *cond_stmt_keyword
;
65 static tree empty_parms PROTO
((void));
66 static int parse_decl PROTO
((tree
, tree
, tree
, int, tree
*));
68 /* Nonzero if we have an `extern "C"' acting as an extern specifier. */
72 /* Cons up an empty parameter list. */
82 || current_class_type
!= NULL
)
83 parms
= void_list_node
;
98 flagged_type_tree ftype
;
99 struct pending_inline
*pi
;
102 /* All identifiers that are not reserved words
103 and are not declared typedefs in the current block */
106 /* All identifiers that are declared typedefs in the current block.
107 In some contexts, they are treated just like IDENTIFIER,
108 but they can also serve as typespecs in declarations. */
112 /* A template function. */
115 /* Reserved words that specify storage class.
116 yylval contains an IDENTIFIER_NODE which indicates which one. */
119 /* Reserved words that specify type.
120 yylval contains an IDENTIFIER_NODE which indicates which one. */
123 /* Reserved words that qualify type: "const" or "volatile".
124 yylval contains an IDENTIFIER_NODE which indicates which one. */
127 /* Character or numeric constants.
128 yylval is the node for the constant. */
131 /* String constants in raw form.
132 yylval is a STRING_CST node. */
135 /* "...", used for functions with variable arglists. */
138 /* the reserved words */
139 /* SCO include files test "ASM", so use something else. */
140 %token SIZEOF ENUM
/* STRUCT UNION */ IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
141 %token BREAK CONTINUE RETURN_KEYWORD GOTO ASM_KEYWORD TYPEOF ALIGNOF
143 %token ATTRIBUTE EXTENSION LABEL
144 %token REALPART IMAGPART VA_ARG
146 /* the reserved words... C++ extensions */
148 %token
<ttype
> VISSPEC
149 %token DELETE NEW THIS OPERATOR CXX_TRUE CXX_FALSE
150 %token NAMESPACE TYPENAME_KEYWORD USING
151 %token LEFT_RIGHT TEMPLATE
152 %token TYPEID DYNAMIC_CAST STATIC_CAST REINTERPRET_CAST CONST_CAST
155 /* Define the operator tokens and their precedences.
156 The value is an integer because, if used, it is the tree code
157 to use in the expression made from the operator. */
159 %left EMPTY
/* used to resolve s/r with epsilon */
163 /* Add precedence rules to solve dangling else s/r conflict */
167 %left IDENTIFIER PFUNCNAME TYPENAME SELFNAME PTYPENAME SCSPEC TYPESPEC CV_QUALIFIER ENUM AGGR ELLIPSIS TYPEOF SIGOF OPERATOR NSNAME TYPENAME_KEYWORD
173 %right
<code
> ASSIGN
'='
181 %left
<code
> EQCOMPARE
182 %left
<code
> ARITHCOMPARE
'<' '>'
183 %left
<code
> LSHIFT RSHIFT
185 %left
<code
> '*' '/' '%'
186 %left
<code
> POINTSAT_STAR DOT_STAR
187 %right
<code
> UNARY PLUSPLUS MINUSMINUS
'~'
189 %left
<ttype
> LEFT_RIGHT
190 %left
<code
> POINTSAT
'.' '(' '['
192 %right SCOPE
/* C++ extension */
193 %nonassoc NEW DELETE TRY CATCH
197 %type
<ttype
> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist
198 %type
<ttype
> PFUNCNAME maybe_identifier
199 %type
<ttype
> paren_expr_or_null nontrivial_exprlist SELFNAME
200 %type
<ttype
> expr_no_commas cast_expr unary_expr primary
string STRING
201 %type
<ttype
> reserved_declspecs boolean.literal
202 %type
<ttype
> reserved_typespecquals
203 %type
<ttype
> declmods
204 %type
<ttype
> SCSPEC TYPESPEC CV_QUALIFIER maybe_cv_qualifier
205 %type
<itype
> initdecls notype_initdecls initdcl
/* C++ modification */
206 %type
<ttype
> init initlist maybeasm maybe_init defarg defarg1
207 %type
<ttype
> asm_operands nonnull_asm_operands asm_operand asm_clobbers
208 %type
<ttype
> maybe_attribute attributes attribute attribute_list attrib
209 %type
<ttype
> any_word
211 %type
<ttype
> compstmt implicitly_scoped_stmt
213 %type
<ttype
> declarator notype_declarator after_type_declarator
214 %type
<ttype
> notype_declarator_intern absdcl_intern
215 %type
<ttype
> after_type_declarator_intern
216 %type
<ttype
> direct_notype_declarator direct_after_type_declarator
217 %type
<itype
> components notype_components
218 %type
<ttype
> component_decl component_decl_1
219 %type
<ttype
> component_declarator component_declarator0
220 %type
<ttype
> notype_component_declarator notype_component_declarator0
221 %type
<ttype
> after_type_component_declarator after_type_component_declarator0
222 %type
<ttype
> enumlist_opt enumlist enumerator
223 %type
<ttype
> absdcl cv_qualifiers
224 %type
<ttype
> direct_abstract_declarator conversion_declarator
225 %type
<ttype
> new_declarator direct_new_declarator
226 %type
<ttype
> xexpr parmlist parms bad_parm
227 %type
<ttype
> identifiers_or_typenames
228 %type
<ttype
> fcast_or_absdcl regcast_or_absdcl
229 %type
<ttype
> expr_or_declarator expr_or_declarator_intern
230 %type
<ttype
> complex_notype_declarator
231 %type
<ttype
> notype_unqualified_id unqualified_id qualified_id
232 %type
<ttype
> template_id do_id object_template_id notype_template_declarator
233 %type
<ttype
> overqualified_id notype_qualified_id any_id
234 %type
<ttype
> complex_direct_notype_declarator functional_cast
235 %type
<ttype
> complex_parmlist parms_comma
236 %type
<ttype
> namespace_qualifier namespace_using_decl
238 %type
<ftype
> type_id new_type_id typed_typespecs typespec typed_declspecs
239 %type
<ftype
> typed_declspecs1 type_specifier_seq nonempty_cv_qualifiers
240 %type
<ftype
> structsp typespecqual_reserved parm named_parm full_parm
242 %type
<itype
> extension
245 %token
<ttype
> PTYPENAME
246 %token
<ttype
> EXTERN_LANG_STRING ALL
247 %token
<ttype
> PRE_PARSED_CLASS_DECL DEFARG DEFARG_MARKER
248 %token
<pi
> PRE_PARSED_FUNCTION_DECL
249 %type
<ttype
> component_constructor_declarator
250 %type
<ttype
> fn.def2 return_id constructor_declarator
252 %type
<itype
> ctor_initializer_opt function_try_block
253 %type
<ttype
> named_class_head_sans_basetype
254 %type
<ftype
> class_head named_class_head
255 %type
<ftype
> named_complex_class_head_sans_basetype
256 %type
<ttype
> unnamed_class_head
257 %type
<ttype
> base_class_list
258 %type
<ttype
> base_class_access_list
259 %type
<ttype
> base_class maybe_base_class_list base_class
.1
260 %type
<ttype
> exception_specification_opt ansi_raise_identifier ansi_raise_identifiers
261 %type
<ttype
> operator_name
262 %type
<ttype
> object aggr
263 %type
<itype
> new delete .begin_new_placement
264 /* %type <ttype> primary_no_id */
265 %type
<ttype
> nonmomentary_expr maybe_parmlist
266 %type
<itype
> initdcl0 notype_initdcl0 member_init_list initdcl0_innards
267 %type
<ttype
> template_header template_parm_list template_parm
268 %type
<ttype
> template_type_parm template_template_parm
269 %type
<code
> template_close_bracket
270 %type
<ttype
> apparent_template_type
271 %type
<ttype
> template_type template_arg_list template_arg_list_opt
272 %type
<ttype
> template_arg
273 %type
<ttype
> condition xcond paren_cond_or_null
274 %type
<ttype
> type_name nested_name_specifier nested_type ptr_to_mem
275 %type
<ttype
> complete_type_name notype_identifier nonnested_type
276 %type
<ttype
> complex_type_name nested_name_specifier_1
277 %type
<ttype
> new_initializer new_placement
278 %type
<ttype
> using_decl
279 %type
<ttype
> typename_sub typename_sub0 typename_sub1 typename_sub2
280 %type
<ttype
> explicit_template_type
281 /* in order to recognize aggr tags as defining and thus shadowing. */
282 %token TYPENAME_DEFN IDENTIFIER_DEFN PTYPENAME_DEFN
283 %type
<ttype
> named_class_head_sans_basetype_defn
284 %type
<ttype
> identifier_defn IDENTIFIER_DEFN TYPENAME_DEFN PTYPENAME_DEFN
286 %type
<ttype
> self_template_type .finish_template_type
291 /* Used in lex.c for parsing pragmas. */
294 /* lex.c and pt.c depend on this being the last token. Define
295 any new tokens before this one! */
296 %token END_OF_SAVED_INPUT
299 /* List of types and structure classes of the current declaration. */
300 static tree current_declspecs
;
302 /* List of prefix attributes in effect.
303 Prefix attributes are parsed by the reserved_declspecs and declmods
304 rules. They create a list that contains *both* declspecs and attrs. */
305 /* ??? It is not clear yet that all cases where an attribute can now appear in
306 a declspec list have been updated. */
307 static tree prefix_attributes
;
309 /* When defining an aggregate, this is the kind of the most recent one
310 being defined. (For example, this might be class_type_node.) */
311 static tree current_aggr
;
313 /* When defining an enumeration, this is the type of the enumeration. */
314 static tree current_enum_type
;
316 /* Tell yyparse how to print a token's value, if yydebug is set. */
318 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
319 extern
void yyprint PROTO
((FILE *, int, YYSTYPE));
320 extern tree combine_strings PROTO
((tree
));
323 parse_decl
(declarator
, specs_attrs
, attributes
, initialized
, decl
)
332 split_specs_attrs
(specs_attrs
, ¤t_declspecs
, &prefix_attributes
);
333 if
(current_declspecs
334 && TREE_CODE
(current_declspecs
) != TREE_LIST
)
335 current_declspecs
= build_decl_list
(NULL_TREE
, current_declspecs
);
336 if
(have_extern_spec
&& !used_extern_spec
)
338 current_declspecs
= decl_tree_cons
(NULL_TREE
,
339 get_identifier
("extern"),
341 used_extern_spec
= 1;
343 sm
= suspend_momentary
();
344 *decl
= start_decl
(declarator
, current_declspecs
, initialized
,
345 attributes
, prefix_attributes
);
352 ggc_add_tree_root
(¤t_declspecs
, 1);
353 ggc_add_tree_root
(&prefix_attributes
, 1);
354 ggc_add_tree_root
(¤t_aggr
, 1);
355 ggc_add_tree_root
(¤t_enum_type
, 1);
363 { finish_translation_unit
(); }
366 /* the reason for the strange actions in this rule
367 is so that notype_initdecls when reached via datadef
368 can find a valid list of type and sc specs in $0. */
371 { $
<ttype
>$
= NULL_TREE
; }
373 { $
<ttype
>$
= NULL_TREE
; }
374 | extdefs lang_extdef
375 { $
<ttype
>$
= NULL_TREE
; }
384 { have_extern_spec
= 1;
385 used_extern_spec
= 0;
386 $
<ttype
>$
= NULL_TREE
; }
389 { have_extern_spec
= 0; }
403 { if
(pending_lang_change
) do_pending_lang_change
(); }
405 { if
(! toplevel_bindings_p
())
410 fndef eat_saved_input
411 { if
(pending_inlines
) do_pending_inlines
(); }
413 { if
(pending_inlines
) do_pending_inlines
(); }
415 { if
(pending_inlines
) do_pending_inlines
(); }
416 | asm_keyword
'(' string ')' ';'
417 { if
(TREE_CHAIN
($3)) $3 = combine_strings
($3);
419 | extern_lang_string
'{' extdefs_opt
'}'
420 { pop_lang_context
(); }
421 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
422 { if
(pending_inlines
) do_pending_inlines
();
423 pop_lang_context
(); }
424 | extern_lang_string .hush_warning datadef .warning_ok
425 { if
(pending_inlines
) do_pending_inlines
();
426 pop_lang_context
(); }
427 | NAMESPACE identifier
'{'
428 { push_namespace
($2); }
430 { pop_namespace
(); }
432 { push_namespace
(NULL_TREE
); }
434 { pop_namespace
(); }
437 { do_toplevel_using_decl
($1); }
444 NAMESPACE identifier
'='
445 { begin_only_namespace_names
(); }
448 end_only_namespace_names
();
451 do_namespace_alias
($2, $5);
458 | USING global_scope qualified_id
460 | USING global_scope unqualified_id
464 namespace_using_decl:
465 USING namespace_qualifier identifier
466 { $$
= build_parse_node
(SCOPE_REF
, $2, $3); }
467 | USING global_scope identifier
468 { $$
= build_parse_node
(SCOPE_REF
, global_namespace
, $3); }
469 | USING global_scope namespace_qualifier identifier
470 { $$
= build_parse_node
(SCOPE_REF
, $3, $4); }
475 { begin_only_namespace_names
(); }
478 end_only_namespace_names
();
479 /* If no declaration was found, the using-directive is
480 invalid. Since that was not reported, we need the
481 identifier for the error message. */
482 if
(TREE_CODE
($4) == IDENTIFIER_NODE
&& lastiddecl
)
484 do_using_directive
($4);
491 if
(TREE_CODE
($$
) == IDENTIFIER_NODE
)
495 | namespace_qualifier NSNAME SCOPE
498 if
(TREE_CODE
($$
) == IDENTIFIER_NODE
)
506 | global_scope qualified_id
508 | global_scope unqualified_id
514 { push_lang_context
($1); }
515 | extern_lang_string EXTERN_LANG_STRING
516 { if
(current_lang_name
!= $2)
517 cp_error
("use of linkage spec `%D' is different from previous spec `%D'", $2, current_lang_name
);
518 pop_lang_context
(); push_lang_context
($2); }
523 { begin_template_parm_list
(); }
524 template_parm_list
'>'
525 { $$
= end_template_parm_list
($4); }
527 { begin_specialization
();
533 { $$
= process_template_parm
(NULL_TREE
, $1); }
534 | template_parm_list
',' template_parm
535 { $$
= process_template_parm
($1, $3); }
545 aggr maybe_identifier
546 { $$
= finish_template_type_parm
($1, $2); }
547 | TYPENAME_KEYWORD maybe_identifier
548 { $$
= finish_template_type_parm
(class_type_node
, $2); }
551 template_template_parm:
552 template_header aggr maybe_identifier
553 { $$
= finish_template_template_parm
($2, $3); }
557 /* The following rules introduce a new reduce/reduce
558 conflict on the ',' and '>' input tokens: they are valid
559 prefixes for a `structsp', which means they could match a
560 nameless parameter. See 14.6, paragraph 3.
561 By putting them before the `parm' rule, we get
562 their match before considering them nameless parameter
565 { $$
= build_tree_list
(NULL_TREE
, $1); }
566 | template_type_parm
'=' type_id
567 { $$
= build_tree_list
(groktypename
($3.t
), $1); }
569 { $$
= build_tree_list
(NULL_TREE
, $1.t
); }
570 | parm
'=' expr_no_commas %prec ARITHCOMPARE
571 { $$
= build_tree_list
($3, $1.t
); }
572 | template_template_parm
573 { $$
= build_tree_list
(NULL_TREE
, $1); }
574 | template_template_parm
'=' template_arg
576 if
(TREE_CODE
($3) != TEMPLATE_DECL
577 && TREE_CODE
($3) != TEMPLATE_TEMPLATE_PARM
578 && TREE_CODE
($3) != TYPE_DECL
)
580 error ("invalid default template argument");
581 $3 = error_mark_node
;
583 $$
= build_tree_list
($3, $1);
588 template_header template_extdef
589 { finish_template_decl
($1); }
590 | template_header
error %prec EMPTY
591 { finish_template_decl
($1); }
595 fndef eat_saved_input
596 { if
(pending_inlines
) do_pending_inlines
(); }
598 { if
(pending_inlines
) do_pending_inlines
(); }
600 { if
(pending_inlines
) do_pending_inlines
(); }
601 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
602 { if
(pending_inlines
) do_pending_inlines
();
603 pop_lang_context
(); }
604 | extern_lang_string .hush_warning template_datadef .warning_ok
605 { if
(pending_inlines
) do_pending_inlines
();
606 pop_lang_context
(); }
607 | extension template_extdef
613 | declmods notype_initdecls
';'
615 | typed_declspecs initdecls
';'
616 { note_list_got_semicolon
($1.t
); }
618 { maybe_process_partial_specialization
($1.t
);
619 note_got_semicolon
($1.t
); }
624 | declmods notype_initdecls
';'
626 | typed_declspecs initdecls
';'
627 { note_list_got_semicolon
($1.t
); }
629 { pedwarn
("empty declaration"); }
630 | explicit_instantiation
';'
631 | typed_declspecs
';'
634 split_specs_attrs
($1.t
, &t
, &attrs
);
636 note_list_got_semicolon
($1.t
);
643 ctor_initializer_opt:
662 fn.def1 maybe_return_init ctor_initializer_opt compstmt_or_error
663 { finish_function
(lineno
, (int)$3); }
664 | fn.def1 maybe_return_init function_try_block
665 { finish_function
(lineno
, (int)$3); }
666 | fn.def1 maybe_return_init
error
670 constructor_declarator:
671 nested_name_specifier SELFNAME
'('
672 { $$
= begin_constructor_declarator
($1, $2); }
673 parmlist
')' cv_qualifiers exception_specification_opt
674 { $$
= make_call_declarator
($
<ttype
>4, $5, $7, $8); }
675 | nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
676 { $$
= begin_constructor_declarator
($1, $2);
677 $$
= make_call_declarator
($$
, empty_parms
(), $4, $5);
679 | global_scope nested_name_specifier SELFNAME
'('
680 { $$
= begin_constructor_declarator
($2, $3); }
681 parmlist
')' cv_qualifiers exception_specification_opt
682 { $$
= make_call_declarator
($
<ttype
>5, $6, $8, $9); }
683 | global_scope nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
684 { $$
= begin_constructor_declarator
($2, $3);
685 $$
= make_call_declarator
($$
, empty_parms
(), $5, $6);
687 | nested_name_specifier self_template_type
'('
688 { $$
= begin_constructor_declarator
($1, $2); }
689 parmlist
')' cv_qualifiers exception_specification_opt
690 { $$
= make_call_declarator
($
<ttype
>4, $5, $7, $8); }
691 | nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
692 { $$
= begin_constructor_declarator
($1, $2);
693 $$
= make_call_declarator
($$
, empty_parms
(), $4, $5);
695 | global_scope nested_name_specifier self_template_type
'('
696 { $$
= begin_constructor_declarator
($2, $3); }
697 parmlist
')' cv_qualifiers exception_specification_opt
698 { $$
= make_call_declarator
($
<ttype
>5, $6, $8, $9); }
699 | global_scope nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
700 { $$
= begin_constructor_declarator
($2, $3);
701 $$
= make_call_declarator
($$
, empty_parms
(), $5, $6);
706 typed_declspecs declarator
707 { if
(!begin_function_definition
($1.t
, $2))
709 | declmods notype_declarator
710 { if
(!begin_function_definition
($1, $2))
713 { if
(!begin_function_definition
(NULL_TREE
, $1))
715 | declmods constructor_declarator
716 { if
(!begin_function_definition
($1, $2))
718 | constructor_declarator
719 { if
(!begin_function_definition
(NULL_TREE
, $1))
723 component_constructor_declarator:
724 SELFNAME
'(' parmlist
')' cv_qualifiers exception_specification_opt
725 { $$
= make_call_declarator
($1, $3, $5, $6); }
726 | SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
727 { $$
= make_call_declarator
($1, empty_parms
(), $3, $4); }
728 | self_template_type
'(' parmlist
')' cv_qualifiers exception_specification_opt
729 { $$
= make_call_declarator
($1, $3, $5, $6); }
730 | self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
731 { $$
= make_call_declarator
($1, empty_parms
(), $3, $4); }
734 /* more C++ complexity. See component_decl for a comment on the
735 reduce/reduce conflict introduced by these rules. */
737 declmods component_constructor_declarator
739 split_specs_attrs
($1, &specs
, &attrs
);
740 attrs
= build_tree_list
(attrs
, NULL_TREE
);
741 $$
= start_method
(specs
, $2, attrs
);
745 if
(yychar == YYEMPTY
)
747 reinit_parse_for_method
(yychar, $$
); }
748 | component_constructor_declarator
749 { $$
= start_method
(NULL_TREE
, $1, NULL_TREE
);
751 | typed_declspecs declarator
753 split_specs_attrs
($1.t
, &specs
, &attrs
);
754 attrs
= build_tree_list
(attrs
, NULL_TREE
);
755 $$
= start_method
(specs
, $2, attrs
); goto rest_of_mdef
; }
756 | declmods notype_declarator
758 split_specs_attrs
($1, &specs
, &attrs
);
759 attrs
= build_tree_list
(attrs
, NULL_TREE
);
760 $$
= start_method
(specs
, $2, attrs
); goto rest_of_mdef
; }
762 { $$
= start_method
(NULL_TREE
, $$
, NULL_TREE
);
764 | declmods constructor_declarator
766 split_specs_attrs
($1, &specs
, &attrs
);
767 attrs
= build_tree_list
(attrs
, NULL_TREE
);
768 $$
= start_method
(specs
, $2, attrs
); goto rest_of_mdef
; }
769 | constructor_declarator
770 { $$
= start_method
(NULL_TREE
, $$
, NULL_TREE
);
775 RETURN_KEYWORD IDENTIFIER
777 if
(! current_function_parms_stored
)
785 { finish_named_return_value
($
<ttype
>$
, $2); }
786 | return_id
'(' nonnull_exprlist
')'
787 { finish_named_return_value
($
<ttype
>$
, $3); }
788 | return_id LEFT_RIGHT
789 { finish_named_return_value
($
<ttype
>$
, NULL_TREE
); }
793 ':' .set_base_init member_init_list
796 error ("no base initializers given following ':'");
804 if
(! current_function_parms_stored
)
807 if
(DECL_CONSTRUCTOR_P
(current_function_decl
))
809 /* Make a contour for the initializer list. */
812 expand_start_bindings
(0);
814 else if
(current_class_type
== NULL_TREE
)
815 error ("base initializers not allowed for non-member functions");
816 else if
(! DECL_CONSTRUCTOR_P
(current_function_decl
))
817 error ("only constructors take base initializers");
826 | member_init_list
',' member_init
827 | member_init_list
error
831 '(' nonnull_exprlist
')'
833 if
(current_class_name
)
834 pedwarn
("anachronistic old style base class initializer");
835 expand_member_init
(current_class_ref
, NULL_TREE
, $2);
839 if
(current_class_name
)
840 pedwarn
("anachronistic old style base class initializer");
841 expand_member_init
(current_class_ref
, NULL_TREE
, void_type_node
);
843 | notype_identifier
'(' nonnull_exprlist
')'
844 { expand_member_init
(current_class_ref
, $1, $3); }
845 | notype_identifier LEFT_RIGHT
846 { expand_member_init
(current_class_ref
, $1, void_type_node
); }
847 | nonnested_type
'(' nonnull_exprlist
')'
848 { expand_member_init
(current_class_ref
, $1, $3); }
849 | nonnested_type LEFT_RIGHT
850 { expand_member_init
(current_class_ref
, $1, void_type_node
); }
851 | typename_sub
'(' nonnull_exprlist
')'
852 { expand_member_init
(current_class_ref
, TYPE_MAIN_DECL
($1),
854 | typename_sub LEFT_RIGHT
855 { expand_member_init
(current_class_ref
, TYPE_MAIN_DECL
($1),
879 explicit_instantiation:
880 TEMPLATE begin_explicit_instantiation typespec
';'
881 { do_type_instantiation
($3.t
, NULL_TREE
);
883 end_explicit_instantiation
884 | TEMPLATE begin_explicit_instantiation typed_declspecs declarator
885 { tree specs
= strip_attrs
($3.t
);
886 do_decl_instantiation
(specs
, $4, NULL_TREE
); }
887 end_explicit_instantiation
888 | TEMPLATE begin_explicit_instantiation notype_declarator
889 { do_decl_instantiation
(NULL_TREE
, $3, NULL_TREE
); }
890 end_explicit_instantiation
891 | TEMPLATE begin_explicit_instantiation constructor_declarator
892 { do_decl_instantiation
(NULL_TREE
, $3, NULL_TREE
); }
893 end_explicit_instantiation
894 | SCSPEC TEMPLATE begin_explicit_instantiation typespec
';'
895 { do_type_instantiation
($4.t
, $1);
897 end_explicit_instantiation
898 | SCSPEC TEMPLATE begin_explicit_instantiation typed_declspecs
900 { tree specs
= strip_attrs
($4.t
);
901 do_decl_instantiation
(specs
, $5, $1); }
902 end_explicit_instantiation
903 | SCSPEC TEMPLATE begin_explicit_instantiation notype_declarator
904 { do_decl_instantiation
(NULL_TREE
, $4, $1); }
905 end_explicit_instantiation
906 | SCSPEC TEMPLATE begin_explicit_instantiation constructor_declarator
907 { do_decl_instantiation
(NULL_TREE
, $4, $1); }
908 end_explicit_instantiation
911 begin_explicit_instantiation:
912 { begin_explicit_instantiation
(); }
914 end_explicit_instantiation:
915 { end_explicit_instantiation
(); }
917 /* The TYPENAME expansions are to deal with use of a template class name as
918 a template within the class itself, where the template decl is hidden by
919 a type decl. Got all that? */
922 PTYPENAME
'<' template_arg_list_opt template_close_bracket
923 .finish_template_type
925 | TYPENAME
'<' template_arg_list_opt template_close_bracket
926 .finish_template_type
931 apparent_template_type:
933 | identifier
'<' template_arg_list_opt
'>'
934 .finish_template_type
938 SELFNAME
'<' template_arg_list_opt template_close_bracket
939 .finish_template_type
943 .finish_template_type
:
945 if
(yychar == YYEMPTY
)
948 $$
= finish_template_type
($
<ttype
>-3, $
<ttype
>-1,
952 template_close_bracket:
956 /* Handle `Class<Class<Type>>' without space in the `>>' */
957 pedwarn
("`>>' should be `> >' in template class name");
962 template_arg_list_opt:
970 { $$
= build_tree_list
(NULL_TREE
, $$
); }
971 | template_arg_list
',' template_arg
972 { $$
= chainon
($$
, build_tree_list
(NULL_TREE
, $3)); }
977 { $$
= groktypename
($1.t
); }
980 | expr_no_commas %prec ARITHCOMPARE
985 { $$
= NEGATE_EXPR
; }
987 { $$
= CONVERT_EXPR
; }
989 { $$
= PREINCREMENT_EXPR
; }
991 { $$
= PREDECREMENT_EXPR
; }
993 { $$
= TRUTH_NOT_EXPR
; }
998 { $$
= build_x_compound_expr
($$
); }
1004 { error ("ANSI C++ forbids an empty condition for `%s'",
1006 $$
= integer_zero_node
; }
1013 { error ("ANSI C++ forbids an empty condition for `%s'",
1015 $$
= integer_zero_node
; }
1029 type_specifier_seq declarator maybeasm maybe_attribute
'='
1032 for
(d
= getdecls
(); d
; d
= TREE_CHAIN
(d
))
1033 if
(TREE_CODE
(d
) == TYPE_DECL
) {
1034 tree s
= TREE_TYPE
(d
);
1035 if
(TREE_CODE
(s
) == RECORD_TYPE
)
1036 cp_error
("definition of class `%T' in condition", s
);
1037 else if
(TREE_CODE
(s
) == ENUMERAL_TYPE
)
1038 cp_error
("definition of enum `%T' in condition", s
);
1041 current_declspecs
= $1.t
;
1042 $
<itype
>5 = suspend_momentary
();
1043 $
<ttype
>$
= start_decl
($
<ttype
>2, current_declspecs
, 1,
1044 $4, /*prefix_attributes*/ NULL_TREE
);
1048 cp_finish_decl
($
<ttype
>6, $7, $4, 1, LOOKUP_ONLYCONVERTING
);
1049 resume_momentary
($
<itype
>5);
1050 $$
= convert_from_reference
($
<ttype
>6);
1051 if
(TREE_CODE
(TREE_TYPE
($$
)) == ARRAY_TYPE
)
1052 cp_error
("definition of array `%#D' in condition", $$
);
1059 | maybe_label_decls stmts
'}'
1060 | maybe_label_decls stmts
error '}'
1061 | maybe_label_decls
error '}'
1064 already_scoped_stmt:
1066 { $
<ttype
>$
= begin_compound_stmt
(1); }
1068 { finish_compound_stmt
(1, $
<ttype
>2); }
1073 nontrivial_exprlist:
1074 expr_no_commas
',' expr_no_commas
1075 { $$
= tree_cons
(NULL_TREE
, $$
,
1076 build_expr_list
(NULL_TREE
, $3)); }
1077 | expr_no_commas
',' error
1078 { $$
= tree_cons
(NULL_TREE
, $$
,
1079 build_expr_list
(NULL_TREE
, error_mark_node
)); }
1080 | nontrivial_exprlist
',' expr_no_commas
1081 { chainon
($$
, build_expr_list
(NULL_TREE
, $3)); }
1082 | nontrivial_exprlist
',' error
1083 { chainon
($$
, build_expr_list
(NULL_TREE
, error_mark_node
)); }
1088 { $$
= build_expr_list
(NULL_TREE
, $$
); }
1089 | nontrivial_exprlist
1095 /* __extension__ turns off -pedantic for following primary. */
1096 | extension cast_expr %prec UNARY
1099 |
'*' cast_expr %prec UNARY
1100 { $$
= build_x_indirect_ref
($2, "unary *"); }
1101 |
'&' cast_expr %prec UNARY
1102 { $$
= build_x_unary_op
(ADDR_EXPR
, $2); }
1104 { $$
= build_x_unary_op
(BIT_NOT_EXPR
, $2); }
1105 | unop cast_expr %prec UNARY
1106 { $$
= finish_unary_op_expr
($1, $2); }
1107 /* Refer to the address of a label as a pointer. */
1110 pedwarn
("ANSI C++ forbids `&&'");
1111 $$
= finish_label_address_expr
($2); }
1112 | SIZEOF unary_expr %prec UNARY
1113 { $$
= expr_sizeof
($2); }
1114 | SIZEOF
'(' type_id
')' %prec HYPERUNARY
1115 { $$
= c_sizeof
(groktypename
($3.t
));
1116 check_for_new_type
("sizeof", $3); }
1117 | ALIGNOF unary_expr %prec UNARY
1118 { $$
= grok_alignof
($2); }
1119 | ALIGNOF
'(' type_id
')' %prec HYPERUNARY
1120 { $$
= c_alignof
(groktypename
($3.t
));
1121 check_for_new_type
("alignof", $3); }
1123 /* The %prec EMPTY's here are required by the = init initializer
1124 syntax extension; see below. */
1125 | new new_type_id %prec EMPTY
1126 { $$
= build_new
(NULL_TREE
, $2.t
, NULL_TREE
, $1);
1127 check_for_new_type
("new", $2); }
1128 | new new_type_id new_initializer
1129 { $$
= build_new
(NULL_TREE
, $2.t
, $3, $1);
1130 check_for_new_type
("new", $2); }
1131 | new new_placement new_type_id %prec EMPTY
1132 { $$
= build_new
($2, $3.t
, NULL_TREE
, $1);
1133 check_for_new_type
("new", $3); }
1134 | new new_placement new_type_id new_initializer
1135 { $$
= build_new
($2, $3.t
, $4, $1);
1136 check_for_new_type
("new", $3); }
1137 /* The .begin_new_placement in the following rules is
1138 necessary to avoid shift/reduce conflicts that lead to
1139 mis-parsing some expressions. Of course, these constructs
1140 are not really new-placement and it is bogus to call
1141 begin_new_placement. But, the parser cannot always tell at this
1142 point whether the next thing is an expression or a type-id,
1143 so there is nothing we can do. Fortunately,
1144 begin_new_placement does nothing harmful. When we rewrite
1145 the parser, this lossage should be removed, of course. */
1146 | new
'(' .begin_new_placement type_id .finish_new_placement
1148 { $$
= build_new
(NULL_TREE
, groktypename
($4.t
),
1150 check_for_new_type
("new", $4); }
1151 | new
'(' .begin_new_placement type_id .finish_new_placement
1153 { $$
= build_new
(NULL_TREE
, groktypename
($4.t
), $6, $1);
1154 check_for_new_type
("new", $4); }
1155 | new new_placement
'(' .begin_new_placement type_id
1156 .finish_new_placement %prec EMPTY
1157 { $$
= build_new
($2, groktypename
($5.t
), NULL_TREE
, $1);
1158 check_for_new_type
("new", $5); }
1159 | new new_placement
'(' .begin_new_placement type_id
1160 .finish_new_placement new_initializer
1161 { $$
= build_new
($2, groktypename
($5.t
), $7, $1);
1162 check_for_new_type
("new", $5); }
1164 | delete cast_expr %prec UNARY
1165 { $$
= delete_sanity
($2, NULL_TREE
, 0, $1); }
1166 | delete
'[' ']' cast_expr %prec UNARY
1167 { $$
= delete_sanity
($4, NULL_TREE
, 1, $1);
1168 if
(yychar == YYEMPTY
)
1170 | delete
'[' expr
']' cast_expr %prec UNARY
1171 { $$
= delete_sanity
($5, $3, 2, $1);
1172 if
(yychar == YYEMPTY
)
1174 | REALPART cast_expr %prec UNARY
1175 { $$
= build_x_unary_op
(REALPART_EXPR
, $2); }
1176 | IMAGPART cast_expr %prec UNARY
1177 { $$
= build_x_unary_op
(IMAGPART_EXPR
, $2); }
1178 | VA_ARG
'(' expr_no_commas
',' type_id
')'
1179 { $$
= build_va_arg
($3, groktypename
($5.t
));
1180 check_for_new_type
("__builtin_va_arg", $5); }
1183 /* Note this rule is not suitable for use in new_placement
1184 since it uses NULL_TREE as the argument to
1185 finish_new_placement. This rule serves only to avoid
1186 reduce/reduce conflicts in unary_expr. See the comments
1187 there on the use of begin/finish_new_placement. */
1188 .finish_new_placement
:
1190 { finish_new_placement
(NULL_TREE
, $
<itype
>-1); }
1192 .begin_new_placement
:
1193 { $$
= begin_new_placement
(); }
1196 '(' .begin_new_placement nonnull_exprlist
')'
1197 { $$
= finish_new_placement
($3, $2); }
1198 |
'{' .begin_new_placement nonnull_exprlist
'}'
1199 { cp_pedwarn
("old style placement syntax, use () instead");
1200 $$
= finish_new_placement
($3, $2); }
1204 '(' nonnull_exprlist
')'
1210 cp_error
("`%T' is not a valid expression", $2.t
);
1211 $$
= error_mark_node
;
1213 /* GNU extension so people can use initializer lists. Note that
1214 this alters the meaning of `new int = 1', which was previously
1215 syntactically valid but semantically invalid. */
1219 pedwarn
("ANSI C++ forbids initialization of new expression with `='");
1220 if
(TREE_CODE
($2) != TREE_LIST
1221 && TREE_CODE
($2) != CONSTRUCTOR
)
1222 $$
= build_expr_list
(NULL_TREE
, $2);
1228 /* This is necessary to postpone reduction of `int ((int)(int)(int))'. */
1230 '(' type_id
')' %prec EMPTY
1231 { $2.t
= finish_parmlist
(build_tree_list
(NULL_TREE
, $2.t
), 0);
1232 $$
= make_call_declarator
(NULL_TREE
, $2.t
, NULL_TREE
, NULL_TREE
);
1233 check_for_new_type
("cast", $2); }
1234 | regcast_or_absdcl
'(' type_id
')' %prec EMPTY
1235 { $3.t
= finish_parmlist
(build_tree_list
(NULL_TREE
, $3.t
), 0);
1236 $$
= make_call_declarator
($$
, $3.t
, NULL_TREE
, NULL_TREE
);
1237 check_for_new_type
("cast", $3); }
1242 | regcast_or_absdcl unary_expr %prec UNARY
1243 { $$
= reparse_absdcl_as_casts
($$
, $2); }
1244 | regcast_or_absdcl
'{' initlist maybecomma
'}' %prec UNARY
1246 tree init
= build_nt
(CONSTRUCTOR
, NULL_TREE
,
1249 pedwarn
("ANSI C++ forbids constructor-expressions");
1250 /* Indicate that this was a GNU C constructor expression. */
1251 TREE_HAS_CONSTRUCTOR
(init
) = 1;
1253 $$
= reparse_absdcl_as_casts
($$
, init
);
1259 /* Handle general members. */
1260 | expr_no_commas POINTSAT_STAR expr_no_commas
1261 { $$
= build_x_binary_op
(MEMBER_REF
, $$
, $3); }
1262 | expr_no_commas DOT_STAR expr_no_commas
1263 { $$
= build_m_component_ref
($$
, $3); }
1264 | expr_no_commas
'+' expr_no_commas
1265 { $$
= build_x_binary_op
($2, $$
, $3); }
1266 | expr_no_commas
'-' expr_no_commas
1267 { $$
= build_x_binary_op
($2, $$
, $3); }
1268 | expr_no_commas
'*' expr_no_commas
1269 { $$
= build_x_binary_op
($2, $$
, $3); }
1270 | expr_no_commas
'/' expr_no_commas
1271 { $$
= build_x_binary_op
($2, $$
, $3); }
1272 | expr_no_commas
'%' expr_no_commas
1273 { $$
= build_x_binary_op
($2, $$
, $3); }
1274 | expr_no_commas LSHIFT expr_no_commas
1275 { $$
= build_x_binary_op
($2, $$
, $3); }
1276 | expr_no_commas RSHIFT expr_no_commas
1277 { $$
= build_x_binary_op
($2, $$
, $3); }
1278 | expr_no_commas ARITHCOMPARE expr_no_commas
1279 { $$
= build_x_binary_op
($2, $$
, $3); }
1280 | expr_no_commas
'<' expr_no_commas
1281 { $$
= build_x_binary_op
(LT_EXPR
, $$
, $3); }
1282 | expr_no_commas
'>' expr_no_commas
1283 { $$
= build_x_binary_op
(GT_EXPR
, $$
, $3); }
1284 | expr_no_commas EQCOMPARE expr_no_commas
1285 { $$
= build_x_binary_op
($2, $$
, $3); }
1286 | expr_no_commas MIN_MAX expr_no_commas
1287 { $$
= build_x_binary_op
($2, $$
, $3); }
1288 | expr_no_commas
'&' expr_no_commas
1289 { $$
= build_x_binary_op
($2, $$
, $3); }
1290 | expr_no_commas
'|' expr_no_commas
1291 { $$
= build_x_binary_op
($2, $$
, $3); }
1292 | expr_no_commas
'^' expr_no_commas
1293 { $$
= build_x_binary_op
($2, $$
, $3); }
1294 | expr_no_commas ANDAND expr_no_commas
1295 { $$
= build_x_binary_op
(TRUTH_ANDIF_EXPR
, $$
, $3); }
1296 | expr_no_commas OROR expr_no_commas
1297 { $$
= build_x_binary_op
(TRUTH_ORIF_EXPR
, $$
, $3); }
1298 | expr_no_commas
'?' xexpr
':' expr_no_commas
1299 { $$
= build_x_conditional_expr
($$
, $3, $5); }
1300 | expr_no_commas
'=' expr_no_commas
1301 { $$
= build_x_modify_expr
($$
, NOP_EXPR
, $3);
1302 if
($$
!= error_mark_node
)
1303 C_SET_EXP_ORIGINAL_CODE
($$
, MODIFY_EXPR
); }
1304 | expr_no_commas ASSIGN expr_no_commas
1305 { $$
= build_x_modify_expr
($$
, $2, $3); }
1307 { $$
= build_throw
(NULL_TREE
); }
1308 | THROW expr_no_commas
1309 { $$
= build_throw
($2); }
1310 /* These extensions are not defined. The second arg to build_m_component_ref
1311 is old, build_m_component_ref now does an implicit
1312 build_indirect_ref (x, NULL_PTR) on the second argument.
1313 | object '&' expr_no_commas %prec UNARY
1314 { $$ = build_m_component_ref ($$, build_x_unary_op (ADDR_EXPR, $3)); }
1315 | object unop expr_no_commas %prec UNARY
1316 { $$ = build_m_component_ref ($$, build_x_unary_op ($2, $3)); }
1317 | object '(' type_id ')' expr_no_commas %prec UNARY
1318 { tree type = groktypename ($3.t);
1319 $$ = build_m_component_ref ($$, build_c_cast (type, $5)); }
1320 | object primary_no_id %prec UNARY
1321 { $$ = build_m_component_ref ($$, $2); }
1325 notype_unqualified_id:
1326 '~' see_typename identifier
1327 { $$
= build_parse_node
(BIT_NOT_EXPR
, $3); }
1328 |
'~' see_typename template_type
1329 { $$
= build_parse_node
(BIT_NOT_EXPR
, $3); }
1334 | NSNAME %prec EMPTY
1339 /* If lastiddecl is a TREE_LIST, it's a baselink, which
1340 means that we're in an expression like S::f<int>, so
1341 don't do_identifier; we only do that for unqualified
1343 if
(lastiddecl
&& TREE_CODE
(lastiddecl
) != TREE_LIST
)
1344 $$
= do_identifier
($
<ttype
>-1, 1, NULL_TREE
);
1350 PFUNCNAME
'<' do_id template_arg_list_opt template_close_bracket
1351 { $$
= lookup_template_function
($3, $4); }
1352 | operator_name
'<' do_id template_arg_list_opt template_close_bracket
1353 { $$
= lookup_template_function
($3, $4); }
1357 TEMPLATE identifier
'<' template_arg_list_opt template_close_bracket
1358 { $$
= lookup_template_function
($2, $4); }
1359 | TEMPLATE PFUNCNAME
'<' template_arg_list_opt template_close_bracket
1360 { $$
= lookup_template_function
($2, $4); }
1361 | TEMPLATE operator_name
'<' template_arg_list_opt
1362 template_close_bracket
1363 { $$
= lookup_template_function
($2, $4); }
1367 notype_unqualified_id
1372 expr_or_declarator_intern:
1374 | attributes expr_or_declarator
1376 /* Provide support for '(' attributes '*' declarator ')'
1378 $$
= decl_tree_cons
($1, $2, NULL_TREE
);
1383 notype_unqualified_id
1384 |
'*' expr_or_declarator_intern %prec UNARY
1385 { $$
= build_parse_node
(INDIRECT_REF
, $2); }
1386 |
'&' expr_or_declarator_intern %prec UNARY
1387 { $$
= build_parse_node
(ADDR_EXPR
, $2); }
1388 |
'(' expr_or_declarator_intern
')'
1392 notype_template_declarator:
1393 IDENTIFIER
'<' template_arg_list_opt template_close_bracket
1394 { $$
= lookup_template_function
($1, $3); }
1395 | NSNAME
'<' template_arg_list template_close_bracket
1396 { $$
= lookup_template_function
($1, $3); }
1399 direct_notype_declarator:
1400 complex_direct_notype_declarator
1401 /* This precedence declaration is to prefer this reduce
1402 to the Koenig lookup shift in primary, below. I hate yacc. */
1403 | notype_unqualified_id %prec
'('
1404 | notype_template_declarator
1405 |
'(' expr_or_declarator_intern
')'
1406 { $$
= finish_decl_parsing
($2); }
1410 notype_unqualified_id
1412 if
(TREE_CODE
($1) == BIT_NOT_EXPR
)
1413 $$
= build_x_unary_op
(BIT_NOT_EXPR
, TREE_OPERAND
($1, 0));
1415 $$
= finish_id_expr
($1);
1421 if
(processing_template_decl
)
1422 push_obstacks
(&permanent_obstack
, &permanent_obstack
);
1423 $$
= combine_strings
($$
);
1424 /* combine_strings doesn't set up TYPE_MAIN_VARIANT of
1425 a const array the way we want, so fix it. */
1426 if
(flag_const_strings
)
1427 TREE_TYPE
($$
) = build_cplus_array_type
1428 (TREE_TYPE
(TREE_TYPE
($$
)),
1429 TYPE_DOMAIN
(TREE_TYPE
($$
)));
1430 if
(processing_template_decl
)
1434 { $$
= finish_parenthesized_expr
($2); }
1435 |
'(' expr_or_declarator_intern
')'
1436 { $2 = reparse_decl_as_expr
(NULL_TREE
, $2);
1437 $$
= finish_parenthesized_expr
($2); }
1439 { $$
= error_mark_node
; }
1441 { tree scope
= current_scope
();
1442 if
(!scope || TREE_CODE
(scope
) != FUNCTION_DECL
)
1444 error ("braced-group within expression allowed only inside a function");
1448 pedwarn
("ANSI C++ forbids braced-groups within expressions");
1449 $
<ttype
>$
= begin_stmt_expr
();
1452 { $$
= finish_stmt_expr
($
<ttype
>2, $3); }
1453 /* Koenig lookup support
1454 We could store lastiddecl in $1 to avoid another lookup,
1455 but that would result in many additional reduce/reduce conflicts. */
1456 | notype_unqualified_id
'(' nonnull_exprlist
')'
1457 { $$
= finish_call_expr
($1, $3, 1); }
1458 | notype_unqualified_id LEFT_RIGHT
1459 { $$
= finish_call_expr
($1, NULL_TREE
, 1); }
1460 | primary
'(' nonnull_exprlist
')'
1461 { $$
= finish_call_expr
($1, $3, 0); }
1462 | primary LEFT_RIGHT
1463 { $$
= finish_call_expr
($1, NULL_TREE
, 0); }
1464 | primary
'[' expr
']'
1465 { $$
= grok_array_decl
($$
, $3); }
1467 { $$
= finish_increment_expr
($1, POSTINCREMENT_EXPR
); }
1468 | primary MINUSMINUS
1469 { $$
= finish_increment_expr
($1, POSTDECREMENT_EXPR
); }
1470 /* C++ extensions */
1472 { $$
= finish_this_expr
(); }
1473 | CV_QUALIFIER
'(' nonnull_exprlist
')'
1475 /* This is a C cast in C++'s `functional' notation
1476 using the "implicit int" extension so that:
1477 `const (3)' is equivalent to `const int (3)'. */
1480 if
($3 == error_mark_node
)
1482 $$
= error_mark_node
;
1486 type
= cp_build_qualified_type
(integer_type_node
,
1487 cp_type_qual_from_rid
($1));
1488 $$
= build_c_cast
(type
, build_compound_expr
($3));
1491 | DYNAMIC_CAST
'<' type_id
'>' '(' expr
')'
1492 { tree type
= groktypename
($3.t
);
1493 check_for_new_type
("dynamic_cast", $3);
1494 $$
= build_dynamic_cast
(type
, $6); }
1495 | STATIC_CAST
'<' type_id
'>' '(' expr
')'
1496 { tree type
= groktypename
($3.t
);
1497 check_for_new_type
("static_cast", $3);
1498 $$
= build_static_cast
(type
, $6); }
1499 | REINTERPRET_CAST
'<' type_id
'>' '(' expr
')'
1500 { tree type
= groktypename
($3.t
);
1501 check_for_new_type
("reinterpret_cast", $3);
1502 $$
= build_reinterpret_cast
(type
, $6); }
1503 | CONST_CAST
'<' type_id
'>' '(' expr
')'
1504 { tree type
= groktypename
($3.t
);
1505 check_for_new_type
("const_cast", $3);
1506 $$
= build_const_cast
(type
, $6); }
1507 | TYPEID
'(' expr
')'
1508 { $$
= build_x_typeid
($3); }
1509 | TYPEID
'(' type_id
')'
1510 { tree type
= groktypename
($3.t
);
1511 check_for_new_type
("typeid", $3);
1512 $$
= get_typeid
(TYPE_MAIN_VARIANT
(type
)); }
1513 | global_scope IDENTIFIER
1514 { $$
= do_scoped_id
($2, 1); }
1515 | global_scope template_id
1517 | global_scope operator_name
1519 got_scope
= NULL_TREE
;
1520 if
(TREE_CODE
($2) == IDENTIFIER_NODE
)
1521 $$
= do_scoped_id
($2, 1);
1525 | overqualified_id %prec HYPERUNARY
1526 { $$
= build_offset_ref
(OP0
($$
), OP1
($$
)); }
1527 | overqualified_id
'(' nonnull_exprlist
')'
1528 { $$
= finish_qualified_call_expr
($1, $3); }
1529 | overqualified_id LEFT_RIGHT
1530 { $$
= finish_qualified_call_expr
($1, NULL_TREE
); }
1531 | object object_template_id %prec UNARY
1533 $$
= build_x_component_ref
($$
, $2, NULL_TREE
, 1);
1535 | object object_template_id
'(' nonnull_exprlist
')'
1536 { $$
= finish_object_call_expr
($2, $1, $4); }
1537 | object object_template_id LEFT_RIGHT
1538 { $$
= finish_object_call_expr
($2, $1, NULL_TREE
); }
1539 | object unqualified_id %prec UNARY
1540 { $$
= build_x_component_ref
($$
, $2, NULL_TREE
, 1); }
1541 | object overqualified_id %prec UNARY
1542 { if
(processing_template_decl
)
1543 $$
= build_min_nt
(COMPONENT_REF
, $1, $2);
1545 $$
= build_object_ref
($$
, OP0
($2), OP1
($2)); }
1546 | object unqualified_id
'(' nonnull_exprlist
')'
1547 { $$
= finish_object_call_expr
($2, $1, $4); }
1548 | object unqualified_id LEFT_RIGHT
1549 { $$
= finish_object_call_expr
($2, $1, NULL_TREE
); }
1550 | object overqualified_id
'(' nonnull_exprlist
')'
1551 { $$
= finish_qualified_object_call_expr
($2, $1, $4); }
1552 | object overqualified_id LEFT_RIGHT
1553 { $$
= finish_qualified_object_call_expr
($2, $1, NULL_TREE
); }
1554 /* p->int::~int() is valid -- 12.4 */
1555 | object
'~' TYPESPEC LEFT_RIGHT
1556 { $$
= finish_pseudo_destructor_call_expr
($1, NULL_TREE
, $3); }
1557 | object TYPESPEC SCOPE
'~' TYPESPEC LEFT_RIGHT
1558 { $$
= finish_pseudo_destructor_call_expr
($1, $2, $5); }
1561 $$
= error_mark_node
;
1565 /* Not needed for now.
1571 { $$ = error_mark_node; }
1573 { if (current_function_decl == 0)
1575 error ("braced-group within expression allowed only inside a function");
1578 $<ttype>$ = expand_start_stmt_expr (); }
1581 pedwarn ("ANSI C++ forbids braced-groups within expressions");
1582 $$ = expand_end_stmt_expr ($<ttype>2); }
1583 | primary_no_id '(' nonnull_exprlist ')'
1584 { $$ = build_x_function_call ($$, $3, current_class_ref); }
1585 | primary_no_id LEFT_RIGHT
1586 { $$ = build_x_function_call ($$, NULL_TREE, current_class_ref); }
1587 | primary_no_id '[' expr ']'
1589 | primary_no_id PLUSPLUS
1590 { $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); }
1591 | primary_no_id MINUSMINUS
1592 { $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); }
1594 { goto do_scoped_id; }
1595 | SCOPE operator_name
1596 { if (TREE_CODE ($2) == IDENTIFIER_NODE)
1598 goto do_scoped_operator;
1607 { got_scope
= NULL_TREE
; $$
= 1; }
1613 | global_scope delete
1614 { got_scope
= NULL_TREE
; $$
= 1; }
1619 { $$
= boolean_true_node
; }
1621 { $$
= boolean_false_node
; }
1624 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
1628 { $$
= chainon
($$
, $2); }
1634 if
(! current_function_parms_stored
)
1635 store_parm_decls
();
1642 { got_object
= TREE_TYPE
($$
); }
1645 $$
= build_x_arrow
($$
);
1646 got_object
= TREE_TYPE
($$
);
1651 typespec initdecls
';'
1653 resume_momentary
($2);
1654 if
($1.t
&& IS_AGGR_TYPE_CODE
(TREE_CODE
($1.t
)))
1655 note_got_semicolon
($1.t
);
1657 | typed_declspecs initdecls
';'
1659 resume_momentary
($2);
1660 note_list_got_semicolon
($1.t
);
1662 | declmods notype_initdecls
';'
1663 { resume_momentary
($2); }
1664 | typed_declspecs
';'
1667 note_list_got_semicolon
($1.t
);
1670 { warning
("empty declaration"); }
1675 /* Any kind of declarator (thus, all declarators allowed
1676 after an explicit typespec). */
1679 after_type_declarator %prec EMPTY
1680 | notype_declarator %prec EMPTY
1683 /* This is necessary to postpone reduction of `int()()()()'. */
1685 LEFT_RIGHT %prec EMPTY
1686 { $$
= make_call_declarator
(NULL_TREE
, empty_parms
(),
1687 NULL_TREE
, NULL_TREE
); }
1688 | fcast_or_absdcl LEFT_RIGHT %prec EMPTY
1689 { $$
= make_call_declarator
($$
, empty_parms
(), NULL_TREE
,
1693 /* ANSI type-id (8.1) */
1695 typed_typespecs absdcl
1696 { $$.t
= build_decl_list
($1.t
, $2);
1697 $$.new_type_flag
= $1.new_type_flag
; }
1698 | nonempty_cv_qualifiers absdcl
1699 { $$.t
= build_decl_list
($1.t
, $2);
1700 $$.new_type_flag
= $1.new_type_flag
; }
1702 { $$.t
= build_decl_list
(build_decl_list
(NULL_TREE
, $1.t
),
1704 $$.new_type_flag
= $1.new_type_flag
; }
1705 | typed_typespecs %prec EMPTY
1706 { $$.t
= build_decl_list
($1.t
, NULL_TREE
);
1707 $$.new_type_flag
= $1.new_type_flag
; }
1708 | nonempty_cv_qualifiers %prec EMPTY
1709 { $$.t
= build_decl_list
($1.t
, NULL_TREE
);
1710 $$.new_type_flag
= $1.new_type_flag
; }
1713 /* Declspecs which contain at least one type specifier or typedef name.
1714 (Just `const' or `volatile' is not enough.)
1715 A typedef'd name following these is taken as a name to be declared.
1716 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1719 typed_typespecs %prec EMPTY
1725 { $$.t
= decl_tree_cons
(NULL_TREE
, $2.t
, $1);
1726 $$.new_type_flag
= $2.new_type_flag
; }
1727 | typespec reserved_declspecs %prec HYPERUNARY
1728 { $$.t
= decl_tree_cons
(NULL_TREE
, $1.t
, $2);
1729 $$.new_type_flag
= $1.new_type_flag
; }
1730 | typespec reserved_typespecquals reserved_declspecs
1731 { $$.t
= decl_tree_cons
(NULL_TREE
, $1.t
, chainon
($2, $3));
1732 $$.new_type_flag
= $1.new_type_flag
; }
1733 | declmods typespec reserved_declspecs
1734 { $$.t
= decl_tree_cons
(NULL_TREE
, $2.t
, chainon
($3, $1));
1735 $$.new_type_flag
= $2.new_type_flag
; }
1736 | declmods typespec reserved_typespecquals
1737 { $$.t
= decl_tree_cons
(NULL_TREE
, $2.t
, chainon
($3, $1));
1738 $$.new_type_flag
= $2.new_type_flag
; }
1739 | declmods typespec reserved_typespecquals reserved_declspecs
1740 { $$.t
= decl_tree_cons
(NULL_TREE
, $2.t
,
1741 chainon
($3, chainon
($4, $1)));
1742 $$.new_type_flag
= $2.new_type_flag
; }
1747 { if
(extra_warnings
)
1748 warning
("`%s' is not at beginning of declaration",
1749 IDENTIFIER_POINTER
($$
));
1750 $$
= build_decl_list
(NULL_TREE
, $$
); }
1751 | reserved_declspecs typespecqual_reserved
1752 { $$
= decl_tree_cons
(NULL_TREE
, $2.t
, $$
); }
1753 | reserved_declspecs SCSPEC
1754 { if
(extra_warnings
)
1755 warning
("`%s' is not at beginning of declaration",
1756 IDENTIFIER_POINTER
($2));
1757 $$
= decl_tree_cons
(NULL_TREE
, $2, $$
); }
1758 | reserved_declspecs attributes
1759 { $$
= decl_tree_cons
($2, NULL_TREE
, $1); }
1761 { $$
= decl_tree_cons
($1, NULL_TREE
, NULL_TREE
); }
1764 /* List of just storage classes and type modifiers.
1765 A declaration can start with just this, but then it cannot be used
1766 to redeclare a typedef-name.
1767 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1769 /* We use hash_tree_cons for lists of typeless declspecs so that they end
1770 up on a persistent obstack. Otherwise, they could appear at the
1771 beginning of something like
1773 static const struct { int foo () { } } b;
1775 and would be discarded after we finish compiling foo. We don't need to
1776 worry once we see a type. */
1779 nonempty_cv_qualifiers %prec EMPTY
1780 { $$
= $1.t
; TREE_STATIC
($$
) = 1; }
1782 { $$
= hash_tree_cons
(NULL_TREE
, $$
, NULL_TREE
); }
1783 | declmods CV_QUALIFIER
1784 { $$
= hash_tree_cons
(NULL_TREE
, $2, $$
);
1785 TREE_STATIC
($$
) = 1; }
1787 { if
(extra_warnings
&& TREE_STATIC
($$
))
1788 warning
("`%s' is not at beginning of declaration",
1789 IDENTIFIER_POINTER
($2));
1790 $$
= hash_tree_cons
(NULL_TREE
, $2, $$
);
1791 TREE_STATIC
($$
) = TREE_STATIC
($1); }
1792 | declmods attributes
1793 { $$
= hash_tree_cons
($2, NULL_TREE
, $1); }
1794 | attributes %prec EMPTY
1795 { $$
= hash_tree_cons
($1, NULL_TREE
, NULL_TREE
); }
1798 /* Used instead of declspecs where storage classes are not allowed
1799 (that is, for typenames and structure components).
1801 C++ can takes storage classes for structure components.
1802 Don't accept a typedef-name if anything but a modifier precedes it. */
1805 typespec %prec EMPTY
1806 { $$.t
= build_decl_list
(NULL_TREE
, $1.t
);
1807 $$.new_type_flag
= $1.new_type_flag
; }
1808 | nonempty_cv_qualifiers typespec
1809 { $$.t
= decl_tree_cons
(NULL_TREE
, $2.t
, $1.t
);
1810 $$.new_type_flag
= $2.new_type_flag
; }
1811 | typespec reserved_typespecquals
1812 { $$.t
= decl_tree_cons
(NULL_TREE
, $1.t
, $2);
1813 $$.new_type_flag
= $1.new_type_flag
; }
1814 | nonempty_cv_qualifiers typespec reserved_typespecquals
1815 { $$.t
= decl_tree_cons
(NULL_TREE
, $2.t
, chainon
($3, $1.t
));
1816 $$.new_type_flag
= $1.new_type_flag
; }
1819 reserved_typespecquals:
1820 typespecqual_reserved
1821 { $$
= build_decl_list
(NULL_TREE
, $1.t
); }
1822 | reserved_typespecquals typespecqual_reserved
1823 { $$
= decl_tree_cons
(NULL_TREE
, $2.t
, $1); }
1826 /* A typespec (but not a type qualifier).
1827 Once we have seen one of these in a declaration,
1828 if a typedef name appears then it is being redeclared. */
1832 | TYPESPEC %prec EMPTY
1833 { $$.t
= $1; $$.new_type_flag
= 0; }
1834 | complete_type_name
1835 { $$.t
= $1; $$.new_type_flag
= 0; }
1836 | TYPEOF
'(' expr
')'
1837 { $$.t
= finish_typeof
($3);
1838 $$.new_type_flag
= 0; }
1839 | TYPEOF
'(' type_id
')'
1840 { $$.t
= groktypename
($3.t
);
1841 $$.new_type_flag
= 0; }
1842 | SIGOF
'(' expr
')'
1843 { tree type
= TREE_TYPE
($3);
1845 $$.new_type_flag
= 0;
1846 if
(IS_AGGR_TYPE
(type
))
1848 sorry
("sigof type specifier");
1853 error ("`sigof' applied to non-aggregate expression");
1854 $$.t
= error_mark_node
;
1857 | SIGOF
'(' type_id
')'
1858 { tree type
= groktypename
($3.t
);
1860 $$.new_type_flag
= 0;
1861 if
(IS_AGGR_TYPE
(type
))
1863 sorry
("sigof type specifier");
1868 error("`sigof' applied to non-aggregate type");
1869 $$.t
= error_mark_node
;
1874 /* A typespec that is a reserved word, or a type qualifier. */
1876 typespecqual_reserved:
1878 { $$.t
= $1; $$.new_type_flag
= 0; }
1880 { $$.t
= $1; $$.new_type_flag
= 0; }
1886 | initdecls
',' initdcl
1887 { check_multiple_declarators
(); }
1892 | notype_initdecls
',' initdcl
1893 { check_multiple_declarators
(); }
1898 | nomods_initdecls
',' initdcl
1899 { check_multiple_declarators
(); }
1905 | asm_keyword
'(' string ')'
1906 { if
(TREE_CHAIN
($3)) $3 = combine_strings
($3); $$
= $3; }
1910 declarator maybeasm maybe_attribute
'='
1911 { $
<ttype
>$
= start_decl
($
<ttype
>1, current_declspecs
, 1,
1912 $3, prefix_attributes
); }
1914 /* Note how the declaration of the variable is in effect while its init is parsed! */
1915 { cp_finish_decl
($
<ttype
>5, $6, $2, 1, LOOKUP_ONLYCONVERTING
); }
1916 | declarator maybeasm maybe_attribute
1917 { $
<ttype
>$
= start_decl
($
<ttype
>1, current_declspecs
, 0,
1918 $3, prefix_attributes
);
1919 cp_finish_decl
($
<ttype
>$
, NULL_TREE
, $2, 1, 0); }
1922 /* This rule assumes a certain configuration of the parser stack.
1923 In particular, $0, the element directly before the beginning of
1924 this rule on the stack, must be a maybeasm. $-1 must be a
1925 declarator or notype_declarator. And $-2 must be some declmods
1926 or declspecs. We can't move the maybeasm into this rule because
1927 we need that reduce so we prefer fn.def1 when appropriate. */
1930 { $
<itype
>2 = parse_decl
($
<ttype
>-1, $
<ttype
>-2,
1931 $1, 1, &$
<ttype
>$
); }
1932 /* Note how the declaration of the variable is in effect
1933 while its init is parsed! */
1935 { cp_finish_decl
($
<ttype
>3, $4, $
<ttype
>0, 1,
1936 LOOKUP_ONLYCONVERTING
);
1940 $$
= parse_decl
($
<ttype
>-1, $
<ttype
>-2, $1, 0, &d
);
1941 cp_finish_decl
(d
, NULL_TREE
, $
<ttype
>0, 1, 0); }
1945 declarator maybeasm initdcl0_innards
1949 notype_declarator maybeasm initdcl0_innards
1954 notype_declarator maybeasm
1955 { /* Set things up as initdcl0_innards expects. */
1960 | constructor_declarator maybeasm maybe_attribute
1962 parse_decl
($1, NULL_TREE
, $3, 0, &d
);
1963 cp_finish_decl
(d
, NULL_TREE
, $2, 1, 0); }
1966 /* the * rules are dummies to accept the Apollo extended syntax
1967 so that the header files compile. */
1978 | attributes attribute
1979 { $$
= chainon
($1, $2); }
1983 ATTRIBUTE
'(' '(' attribute_list
')' ')'
1990 | attribute_list
',' attrib
1991 { $$
= chainon
($1, $3); }
1998 { $$
= build_tree_list
($1, NULL_TREE
); }
1999 | any_word
'(' IDENTIFIER
')'
2000 { $$
= build_tree_list
($1, build_tree_list
(NULL_TREE
, $3)); }
2001 | any_word
'(' IDENTIFIER
',' nonnull_exprlist
')'
2002 { $$
= build_tree_list
($1, tree_cons
(NULL_TREE
, $3, $5)); }
2003 | any_word
'(' nonnull_exprlist
')'
2004 { $$
= build_tree_list
($1, $3); }
2007 /* This still leaves out most reserved keywords,
2008 shouldn't we include them? */
2017 /* A nonempty list of identifiers, including typenames. */
2018 identifiers_or_typenames:
2020 { $$
= build_tree_list
(NULL_TREE
, $1); }
2021 | identifiers_or_typenames
',' identifier
2022 { $$
= chainon
($1, build_tree_list
(NULL_TREE
, $3)); }
2026 /* empty */ %prec EMPTY
2031 /* If we are processing a template, we don't want to expand this
2035 expr_no_commas %prec
'='
2037 { $$
= build_nt
(CONSTRUCTOR
, NULL_TREE
, NULL_TREE
);
2038 TREE_HAS_CONSTRUCTOR
($$
) = 1; }
2040 { $$
= build_nt
(CONSTRUCTOR
, NULL_TREE
, nreverse
($2));
2041 TREE_HAS_CONSTRUCTOR
($$
) = 1; }
2042 |
'{' initlist
',' '}'
2043 { $$
= build_nt
(CONSTRUCTOR
, NULL_TREE
, nreverse
($2));
2044 TREE_HAS_CONSTRUCTOR
($$
) = 1; }
2049 /* This chain is built in reverse order,
2050 and put in forward order where initlist is used. */
2053 { $$
= build_tree_list
(NULL_TREE
, $$
); }
2055 { $$
= tree_cons
(NULL_TREE
, $3, $$
); }
2056 /* These are for labeled elements. */
2057 |
'[' expr_no_commas
']' init
2058 { $$
= build_expr_list
($2, $4); }
2059 | identifier
':' init
2060 { $$
= build_expr_list
($$
, $3); }
2061 | initlist
',' identifier
':' init
2062 { $$
= tree_cons
($3, $5, $$
); }
2066 PRE_PARSED_FUNCTION_DECL
2067 { start_function
(NULL_TREE
, $1->fndecl
, NULL_TREE
,
2068 (SF_DEFAULT | SF_PRE_PARSED
2069 | SF_INCLASS_INLINE
));
2070 reinit_parse_for_function
(); }
2073 fn.defpen maybe_return_init ctor_initializer_opt compstmt_or_error
2075 finish_function
(lineno
, (int)$3 |
2);
2076 process_next_inline
($1);
2078 | fn.defpen maybe_return_init function_try_block
2080 finish_function
(lineno
, (int)$3 |
2);
2081 process_next_inline
($1);
2083 | fn.defpen maybe_return_init
error
2084 { free_after_compilation
(current_function
);
2085 current_function
= NULL
;
2086 process_next_inline
($1); }
2091 | pending_inlines pending_inline eat_saved_input
2094 /* A regurgitated default argument. The value of DEFARG_MARKER will be
2095 the TREE_LIST node for the parameter in question. */
2097 DEFARG_MARKER expr_no_commas END_OF_SAVED_INPUT
2098 { replace_defarg
($1, $2); }
2099 | DEFARG_MARKER
error END_OF_SAVED_INPUT
2100 { replace_defarg
($1, error_mark_node
); }
2103 /* empty */ %prec EMPTY
2104 | pending_defargs defarg_again
2105 { do_pending_defargs
(); }
2106 | pending_defargs
error
2107 { do_pending_defargs
(); }
2112 { $
<itype
>3 = suspend_momentary
();
2113 $
<ttype
>$
= current_enum_type
;
2114 current_enum_type
= start_enum
($2); }
2116 { TYPE_VALUES
(current_enum_type
) = $5;
2117 $$.t
= finish_enum
(current_enum_type
);
2118 $$.new_type_flag
= 1;
2119 current_enum_type
= $
<ttype
>4;
2120 resume_momentary
((int) $
<itype
>3);
2121 check_for_missing_semicolon
($$.t
); }
2123 { $
<itype
>2 = suspend_momentary
();
2124 $
<ttype
>$
= current_enum_type
;
2125 current_enum_type
= start_enum
(make_anon_name
()); }
2127 { TYPE_VALUES
(current_enum_type
) = $4;
2128 $$.t
= finish_enum
(current_enum_type
);
2129 $$.new_type_flag
= 1;
2130 current_enum_type
= $
<ttype
>3;
2131 resume_momentary
((int) $
<itype
>1);
2132 check_for_missing_semicolon
($$.t
); }
2134 { $$.t
= xref_tag
(enum_type_node
, $2, 1);
2135 $$.new_type_flag
= 0; }
2136 | ENUM complex_type_name
2137 { $$.t
= xref_tag
(enum_type_node
, $2, 1);
2138 $$.new_type_flag
= 0; }
2139 | TYPENAME_KEYWORD typename_sub
2141 $$.new_type_flag
= 0;
2142 if
(!processing_template_decl
)
2143 cp_pedwarn
("using `typename' outside of template"); }
2144 /* C++ extensions, merged with C to avoid shift/reduce conflicts */
2146 { $1.t
= begin_class_definition
($1.t
); }
2147 opt.component_decl_list
'}' maybe_attribute
2151 if
(yychar == YYEMPTY
)
2153 semi
= yychar == ';';
2155 $
<ttype
>$
= finish_class_definition
($1.t
, $6, semi
,
2160 begin_inline_definitions
();
2164 finish_inline_definitions
();
2166 $$.new_type_flag
= 1;
2168 | class_head %prec EMPTY
2170 if
($1.new_type_flag
&& $1.t
!= error_mark_node
)
2171 pop_scope
(CP_DECL_CONTEXT
(TYPE_MAIN_DECL
($1.t
)));
2172 $$.new_type_flag
= 0;
2173 if
($1.t
== error_mark_node
)
2175 else if
(TYPE_BINFO
($1.t
) == NULL_TREE
)
2177 cp_error
("%T is not a class type", $1.t
);
2178 $$.t
= error_mark_node
;
2183 /* struct B: public A; is not accepted by the WP grammar. */
2184 if
(TYPE_BINFO_BASETYPES
($$.t
) && !TYPE_SIZE
($$.t
)
2185 && ! TYPE_BEING_DEFINED
($$.t
))
2186 cp_error
("base clause without member specification for `%#T'",
2200 { if
(pedantic
&& !in_system_header
)
2201 pedwarn
("comma at end of enumerator list"); }
2207 { error ("storage class specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER
($2)); }
2209 { error ("type specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER
($2)); }
2211 { error ("type qualifier `%s' not allowed after struct or class", IDENTIFIER_POINTER
($2)); }
2213 { error ("no body nor ';' separates two class, struct or union declarations"); }
2215 { $$
= build_decl_list
($2, $1); }
2218 named_class_head_sans_basetype:
2226 named_class_head_sans_basetype_defn:
2227 aggr identifier_defn %prec EMPTY
2228 { current_aggr
= $$
; $$
= $2; }
2229 | named_class_head_sans_basetype
'{'
2230 { yyungetc
('{', 1); }
2231 | named_class_head_sans_basetype
':'
2232 { yyungetc
(':', 1); }
2235 named_complex_class_head_sans_basetype:
2236 aggr nested_name_specifier identifier
2239 $$.t
= handle_class_head
($1, $2, $3);
2240 $$.new_type_flag
= 1;
2242 | aggr global_scope nested_name_specifier identifier
2245 $$.t
= handle_class_head
($1, $3, $4);
2246 $$.new_type_flag
= 1;
2248 | aggr global_scope identifier
2251 $$.t
= handle_class_head
($1, NULL_TREE
, $3);
2252 $$.new_type_flag
= 1;
2254 | aggr apparent_template_type
2258 $$.new_type_flag
= 0;
2260 | aggr nested_name_specifier apparent_template_type
2264 if
(CP_DECL_CONTEXT
($$.t
))
2265 push_scope
(CP_DECL_CONTEXT
($$.t
));
2266 $$.new_type_flag
= 1;
2271 named_class_head_sans_basetype %prec EMPTY
2273 $$.t
= xref_tag
(current_aggr
, $1, 1);
2274 $$.new_type_flag
= 0;
2276 | named_class_head_sans_basetype_defn
2277 { $
<ttype
>$
= xref_tag
(current_aggr
, $1, 0); }
2278 /* Class name is unqualified, so we look for base classes
2279 in the current scope. */
2280 maybe_base_class_list %prec EMPTY
2283 $$.new_type_flag
= 0;
2285 xref_basetypes
(current_aggr
, $1, $
<ttype
>2, $3);
2287 | named_complex_class_head_sans_basetype
2288 maybe_base_class_list
2290 if
($1.t
!= error_mark_node
)
2292 $$.t
= TREE_TYPE
($1.t
);
2293 $$.new_type_flag
= $1.new_type_flag
;
2294 if
(current_aggr
== union_type_node
2295 && TREE_CODE
($$.t
) != UNION_TYPE
)
2296 cp_pedwarn
("`union' tag used in declaring `%#T'",
2298 else if
(TREE_CODE
($$.t
) == UNION_TYPE
2299 && current_aggr
!= union_type_node
)
2300 cp_pedwarn
("non-`union' tag used in declaring `%#T'", $$
);
2301 else if
(TREE_CODE
($$.t
) == RECORD_TYPE
)
2302 /* We might be specializing a template with a different
2304 CLASSTYPE_DECLARED_CLASS
($$.t
)
2305 = (current_aggr
== class_type_node
);
2308 maybe_process_partial_specialization
($$.t
);
2309 xref_basetypes
(current_aggr
, $1.t
, $$.t
, $2);
2317 { $$
= xref_tag
($$
, make_anon_name
(), 0);
2318 yyungetc
('{', 1); }
2321 /* The tree output of this nonterminal a declarationf or the type
2322 named. If NEW_TYPE_FLAG is set, then the name used in this
2323 class-head was explicitly qualified, e.g.: `struct X::Y'. We have
2324 already called push_scope for X. */
2329 $$.new_type_flag
= 0;
2334 maybe_base_class_list:
2335 /* empty */ %prec EMPTY
2337 |
':' see_typename %prec EMPTY
2338 { yyungetc
(':', 1); $$
= NULL_TREE
; }
2339 |
':' see_typename base_class_list %prec EMPTY
2345 | base_class_list
',' see_typename base_class
2346 { $$
= chainon
($$
, $4); }
2351 { $$
= finish_base_specifier
(access_default_node
, $1); }
2352 | base_class_access_list see_typename base_class
.1
2353 { $$
= finish_base_specifier
($1, $3); }
2358 { if
($$
!= error_mark_node
) $$
= TYPE_MAIN_DECL
($1); }
2362 base_class_access_list:
2363 VISSPEC see_typename
2364 | SCSPEC see_typename
2365 { if
($1 != ridpointers
[(int)RID_VIRTUAL
])
2366 cp_error
("`%D' access", $1);
2367 $$
= access_default_virtual_node
; }
2368 | base_class_access_list VISSPEC see_typename
2370 if
($1 != access_default_virtual_node
)
2371 error ("multiple access specifiers");
2372 else if
($2 == access_public_node
)
2373 $$
= access_public_virtual_node
;
2374 else if
($2 == access_protected_node
)
2375 $$
= access_protected_virtual_node
;
2376 else
/* $2 == access_private_node */
2377 $$
= access_private_virtual_node
;
2379 | base_class_access_list SCSPEC see_typename
2380 { if
($2 != ridpointers
[(int)RID_VIRTUAL
])
2381 cp_error
("`%D' access", $2);
2382 else if
($$
== access_public_node
)
2383 $$
= access_public_virtual_node
;
2384 else if
($$
== access_protected_node
)
2385 $$
= access_protected_virtual_node
;
2386 else if
($$
== access_private_node
)
2387 $$
= access_private_virtual_node
;
2389 error ("multiple `virtual' specifiers");
2393 opt.component_decl_list
:
2394 | component_decl_list
2395 | opt.component_decl_list access_specifier component_decl_list
2396 | opt.component_decl_list access_specifier
2402 current_access_specifier
= $1;
2406 /* Note: we no longer warn about the semicolon after a component_decl_list.
2407 ARM $9.2 says that the semicolon is optional, and therefore allowed. */
2408 component_decl_list:
2411 finish_member_declaration
($1);
2413 | component_decl_list component_decl
2415 finish_member_declaration
($2);
2420 component_decl_1
';'
2421 | component_decl_1
'}'
2422 { error ("missing ';' before right brace");
2423 yyungetc
('}', 0); }
2424 /* C++: handle constructors, destructors and inline functions */
2425 /* note that INLINE is like a TYPESPEC */
2426 | fn.def2
':' /* base_init compstmt */
2427 { $$
= finish_method
($$
); }
2428 | fn.def2 TRY
/* base_init compstmt */
2429 { $$
= finish_method
($$
); }
2430 | fn.def2 RETURN_KEYWORD
/* base_init compstmt */
2431 { $$
= finish_method
($$
); }
2432 | fn.def2
'{' /* nodecls compstmt */
2433 { $$
= finish_method
($$
); }
2436 | extension component_decl
2439 | template_header component_decl
2442 $$
= finish_member_template_decl
($2);
2444 /* The component was already processed. */
2447 finish_template_decl
($1);
2449 | template_header typed_declspecs
';'
2451 $$
= finish_member_class_template
($2.t
);
2452 finish_template_decl
($1);
2457 /* Do not add a "typed_declspecs declarator" rule here for
2458 speed; we need to call grok_x_components for enums, so the
2459 speedup would be insignificant. */
2460 typed_declspecs components
2462 /* Most of the productions for component_decl only
2463 allow the creation of one new member, so we call
2464 finish_member_declaration in component_decl_list.
2465 For this rule and the next, however, there can be
2466 more than one member, e.g.:
2470 and we need the first member to be fully
2471 registered before the second is processed.
2472 Therefore, the rules for components take care of
2473 this processing. To avoid registering the
2474 components more than once, we send NULL_TREE up
2475 here; that lets finish_member_declaration know
2476 that there is nothing to do. */
2478 grok_x_components
($1.t
);
2481 | declmods notype_components
2484 grok_x_components
($1);
2487 | notype_declarator maybeasm maybe_attribute maybe_init
2488 { $$
= grokfield
($$
, NULL_TREE
, $4, $2,
2489 build_tree_list
($3, NULL_TREE
)); }
2490 | constructor_declarator maybeasm maybe_attribute maybe_init
2491 { $$
= grokfield
($$
, NULL_TREE
, $4, $2,
2492 build_tree_list
($3, NULL_TREE
)); }
2493 |
':' expr_no_commas
2494 { $$
= grokbitfield
(NULL_TREE
, NULL_TREE
, $2); }
2498 /* These rules introduce a reduce/reduce conflict; in
2499 typedef int foo, bar;
2503 should "A::foo" be declared as a function or "A::bar" as a data
2504 member? In other words, is "bar" an after_type_declarator or a
2506 | declmods component_constructor_declarator maybeasm maybe_attribute maybe_init
2507 { tree specs
, attrs
;
2508 split_specs_attrs
($1, &specs
, &attrs
);
2509 $$
= grokfield
($2, specs
, $5, $3,
2510 build_tree_list
($4, attrs
)); }
2511 | component_constructor_declarator maybeasm maybe_attribute maybe_init
2512 { $$
= grokfield
($$
, NULL_TREE
, $4, $2,
2513 build_tree_list
($3, NULL_TREE
)); }
2515 { $$
= do_class_using_decl
($1); }
2517 /* The case of exactly one component is handled directly by component_decl. */
2520 /* empty: possibly anonymous */
2522 | component_declarator0
2524 if
(PROCESSING_REAL_TEMPLATE_DECL_P
())
2525 $1 = finish_member_template_decl
($1);
2526 finish_member_declaration
($1);
2529 | components
',' component_declarator
2531 check_multiple_declarators
();
2532 if
(PROCESSING_REAL_TEMPLATE_DECL_P
())
2533 $3 = finish_member_template_decl
($3);
2534 finish_member_declaration
($3);
2540 /* empty: possibly anonymous */
2542 | notype_component_declarator0
2544 if
(PROCESSING_REAL_TEMPLATE_DECL_P
())
2545 $1 = finish_member_template_decl
($1);
2546 finish_member_declaration
($1);
2549 | notype_components
',' notype_component_declarator
2551 check_multiple_declarators
();
2552 if
(PROCESSING_REAL_TEMPLATE_DECL_P
())
2553 $3 = finish_member_template_decl
($3);
2554 finish_member_declaration
($3);
2559 component_declarator0:
2560 after_type_component_declarator0
2561 | notype_component_declarator0
2564 component_declarator:
2565 after_type_component_declarator
2566 | notype_component_declarator
2569 after_type_component_declarator0:
2570 after_type_declarator maybeasm maybe_attribute maybe_init
2571 { split_specs_attrs
($
<ttype
>0, ¤t_declspecs
,
2572 &prefix_attributes
);
2573 $
<ttype
>0 = current_declspecs
;
2574 $$
= grokfield
($$
, current_declspecs
, $4, $2,
2575 build_tree_list
($3, prefix_attributes
)); }
2576 | TYPENAME
':' expr_no_commas maybe_attribute
2577 { split_specs_attrs
($
<ttype
>0, ¤t_declspecs
,
2578 &prefix_attributes
);
2579 $
<ttype
>0 = current_declspecs
;
2580 $$
= grokbitfield
($$
, current_declspecs
, $3);
2581 cplus_decl_attributes
($$
, $4, prefix_attributes
); }
2584 notype_component_declarator0:
2585 notype_declarator maybeasm maybe_attribute maybe_init
2586 { split_specs_attrs
($
<ttype
>0, ¤t_declspecs
,
2587 &prefix_attributes
);
2588 $
<ttype
>0 = current_declspecs
;
2589 $$
= grokfield
($$
, current_declspecs
, $4, $2,
2590 build_tree_list
($3, prefix_attributes
)); }
2591 | constructor_declarator maybeasm maybe_attribute maybe_init
2592 { split_specs_attrs
($
<ttype
>0, ¤t_declspecs
,
2593 &prefix_attributes
);
2594 $
<ttype
>0 = current_declspecs
;
2595 $$
= grokfield
($$
, current_declspecs
, $4, $2,
2596 build_tree_list
($3, prefix_attributes
)); }
2597 | IDENTIFIER
':' expr_no_commas maybe_attribute
2598 { split_specs_attrs
($
<ttype
>0, ¤t_declspecs
,
2599 &prefix_attributes
);
2600 $
<ttype
>0 = current_declspecs
;
2601 $$
= grokbitfield
($$
, current_declspecs
, $3);
2602 cplus_decl_attributes
($$
, $4, prefix_attributes
); }
2603 |
':' expr_no_commas maybe_attribute
2604 { split_specs_attrs
($
<ttype
>0, ¤t_declspecs
,
2605 &prefix_attributes
);
2606 $
<ttype
>0 = current_declspecs
;
2607 $$
= grokbitfield
(NULL_TREE
, current_declspecs
, $2);
2608 cplus_decl_attributes
($$
, $3, prefix_attributes
); }
2611 after_type_component_declarator:
2612 after_type_declarator maybeasm maybe_attribute maybe_init
2613 { $$
= grokfield
($$
, current_declspecs
, $4, $2,
2614 build_tree_list
($3, prefix_attributes
)); }
2615 | TYPENAME
':' expr_no_commas maybe_attribute
2616 { $$
= grokbitfield
($$
, current_declspecs
, $3);
2617 cplus_decl_attributes
($$
, $4, prefix_attributes
); }
2620 notype_component_declarator:
2621 notype_declarator maybeasm maybe_attribute maybe_init
2622 { $$
= grokfield
($$
, current_declspecs
, $4, $2,
2623 build_tree_list
($3, prefix_attributes
)); }
2624 | IDENTIFIER
':' expr_no_commas maybe_attribute
2625 { $$
= grokbitfield
($$
, current_declspecs
, $3);
2626 cplus_decl_attributes
($$
, $4, prefix_attributes
); }
2627 |
':' expr_no_commas maybe_attribute
2628 { $$
= grokbitfield
(NULL_TREE
, current_declspecs
, $2);
2629 cplus_decl_attributes
($$
, $3, prefix_attributes
); }
2633 enumlist maybecomma_warn
2638 /* We chain the enumerators in reverse order.
2639 Because of the way enums are built, the order is
2640 insignificant. Take advantage of this fact. */
2644 | enumlist
',' enumerator
2645 { TREE_CHAIN
($3) = $$
; $$
= $3; }
2650 { $$
= build_enumerator
($$
, NULL_TREE
, current_enum_type
); }
2651 | identifier
'=' expr_no_commas
2652 { $$
= build_enumerator
($$
, $3, current_enum_type
); }
2655 /* ANSI new-type-id (5.3.4) */
2657 type_specifier_seq new_declarator
2658 { $$.t
= build_decl_list
($1.t
, $2);
2659 $$.new_type_flag
= $1.new_type_flag
; }
2660 | type_specifier_seq %prec EMPTY
2661 { $$.t
= build_decl_list
($1.t
, NULL_TREE
);
2662 $$.new_type_flag
= $1.new_type_flag
; }
2663 /* GNU extension to allow arrays of arbitrary types with
2664 non-constant dimension. For the use of begin_new_placement
2665 here, see the comments in unary_expr above. */
2666 |
'(' .begin_new_placement type_id .finish_new_placement
2670 pedwarn
("ANSI C++ forbids array dimensions with parenthesized type in new");
2671 $$.t
= build_parse_node
(ARRAY_REF
, TREE_VALUE
($3.t
), $6);
2672 $$.t
= build_decl_list
(TREE_PURPOSE
($3.t
), $$.t
);
2673 $$.new_type_flag
= $3.new_type_flag
;
2678 /* empty */ %prec EMPTY
2680 | cv_qualifiers CV_QUALIFIER
2681 { $$
= decl_tree_cons
(NULL_TREE
, $2, $$
); }
2684 nonempty_cv_qualifiers:
2686 { $$.t
= hash_tree_cons
(NULL_TREE
, $1, NULL_TREE
);
2687 $$.new_type_flag
= 0; }
2688 | nonempty_cv_qualifiers CV_QUALIFIER
2689 { $$.t
= hash_tree_cons
(NULL_TREE
, $2, $1.t
);
2690 $$.new_type_flag
= $1.new_type_flag
; }
2693 /* These rules must follow the rules for function declarations
2694 and component declarations. That way, longer rules are preferred. */
2698 { $
<itype
>$
= suspend_momentary
(); }
2700 /* An expression which will not live on the momentary obstack. */
2703 { resume_momentary
((int) $
<itype
>1); $$
= $2; }
2706 /* An expression which will not live on the momentary obstack. */
2708 suspend_mom
'(' nonnull_exprlist
')'
2709 { resume_momentary
((int) $
<itype
>1); $$
= $3; }
2710 | suspend_mom
'(' parmlist
')'
2711 { resume_momentary
((int) $
<itype
>1); $$
= $3; }
2712 | suspend_mom LEFT_RIGHT
2713 { resume_momentary
((int) $
<itype
>1); $$
= empty_parms
(); }
2714 | suspend_mom
'(' error ')'
2715 { resume_momentary
((int) $
<itype
>1); $$
= NULL_TREE
; }
2718 /* A declarator that is allowed only after an explicit typespec. */
2720 after_type_declarator_intern:
2721 after_type_declarator
2722 | attributes after_type_declarator
2724 /* Provide support for '(' attributes '*' declarator ')'
2726 $$
= decl_tree_cons
($1, $2, NULL_TREE
);
2730 /* may all be followed by prec '.' */
2731 after_type_declarator:
2732 '*' nonempty_cv_qualifiers after_type_declarator_intern %prec UNARY
2733 { $$
= make_pointer_declarator
($2.t
, $3); }
2734 |
'&' nonempty_cv_qualifiers after_type_declarator_intern %prec UNARY
2735 { $$
= make_reference_declarator
($2.t
, $3); }
2736 |
'*' after_type_declarator_intern %prec UNARY
2737 { $$
= make_pointer_declarator
(NULL_TREE
, $2); }
2738 |
'&' after_type_declarator_intern %prec UNARY
2739 { $$
= make_reference_declarator
(NULL_TREE
, $2); }
2740 | ptr_to_mem cv_qualifiers after_type_declarator_intern
2741 { tree arg
= make_pointer_declarator
($2, $3);
2742 $$
= build_parse_node
(SCOPE_REF
, $1, arg
);
2744 | direct_after_type_declarator
2747 direct_after_type_declarator:
2748 direct_after_type_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec
'.'
2749 { $$
= make_call_declarator
($$
, $2, $3, $4); }
2750 | direct_after_type_declarator
'[' nonmomentary_expr
']'
2751 { $$
= build_parse_node
(ARRAY_REF
, $$
, $3); }
2752 | direct_after_type_declarator
'[' ']'
2753 { $$
= build_parse_node
(ARRAY_REF
, $$
, NULL_TREE
); }
2754 |
'(' after_type_declarator_intern
')'
2756 | nested_name_specifier type_name %prec EMPTY
2757 { push_nested_class
($1, 3);
2758 $$
= build_parse_node
(SCOPE_REF
, $$
, $2);
2759 TREE_COMPLEXITY
($$
) = current_class_depth
; }
2760 | type_name %prec EMPTY
2764 type_name %prec EMPTY
2766 if
(TREE_CODE
($1) == IDENTIFIER_NODE
)
2768 $$
= lookup_name
($1, 1);
2769 maybe_note_name_used_in_class
($1, $$
);
2774 | global_scope type_name
2776 if
(TREE_CODE
($2) == IDENTIFIER_NODE
)
2777 $$
= IDENTIFIER_GLOBAL_VALUE
($2);
2780 got_scope
= NULL_TREE
;
2787 | global_scope nested_type
2792 nested_name_specifier type_name %prec EMPTY
2793 { $$
= get_type_decl
($2); }
2796 /* A declarator allowed whether or not there has been
2797 an explicit typespec. These cannot redeclare a typedef-name. */
2799 notype_declarator_intern:
2801 | attributes notype_declarator
2803 /* Provide support for '(' attributes '*' declarator ')'
2805 $$
= decl_tree_cons
($1, $2, NULL_TREE
);
2810 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2811 { $$
= make_pointer_declarator
($2.t
, $3); }
2812 |
'&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2813 { $$
= make_reference_declarator
($2.t
, $3); }
2814 |
'*' notype_declarator_intern %prec UNARY
2815 { $$
= make_pointer_declarator
(NULL_TREE
, $2); }
2816 |
'&' notype_declarator_intern %prec UNARY
2817 { $$
= make_reference_declarator
(NULL_TREE
, $2); }
2818 | ptr_to_mem cv_qualifiers notype_declarator_intern
2819 { tree arg
= make_pointer_declarator
($2, $3);
2820 $$
= build_parse_node
(SCOPE_REF
, $1, arg
);
2822 | direct_notype_declarator
2825 complex_notype_declarator:
2826 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2827 { $$
= make_pointer_declarator
($2.t
, $3); }
2828 |
'&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2829 { $$
= make_reference_declarator
($2.t
, $3); }
2830 |
'*' complex_notype_declarator %prec UNARY
2831 { $$
= make_pointer_declarator
(NULL_TREE
, $2); }
2832 |
'&' complex_notype_declarator %prec UNARY
2833 { $$
= make_reference_declarator
(NULL_TREE
, $2); }
2834 | ptr_to_mem cv_qualifiers notype_declarator_intern
2835 { tree arg
= make_pointer_declarator
($2, $3);
2836 $$
= build_parse_node
(SCOPE_REF
, $1, arg
);
2838 | complex_direct_notype_declarator
2841 complex_direct_notype_declarator:
2842 direct_notype_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec
'.'
2843 { $$
= make_call_declarator
($$
, $2, $3, $4); }
2844 |
'(' complex_notype_declarator
')'
2846 | direct_notype_declarator
'[' nonmomentary_expr
']'
2847 { $$
= build_parse_node
(ARRAY_REF
, $$
, $3); }
2848 | direct_notype_declarator
'[' ']'
2849 { $$
= build_parse_node
(ARRAY_REF
, $$
, NULL_TREE
); }
2850 | notype_qualified_id
2851 { enter_scope_of
($1); }
2852 | nested_name_specifier notype_template_declarator
2853 { got_scope
= NULL_TREE
;
2854 $$
= build_parse_node
(SCOPE_REF
, $1, $2);
2855 enter_scope_of
($$
);
2860 nested_name_specifier unqualified_id
2861 { got_scope
= NULL_TREE
;
2862 $$
= build_parse_node
(SCOPE_REF
, $$
, $2); }
2863 | nested_name_specifier object_template_id
2864 { got_scope
= NULL_TREE
;
2865 $$
= build_parse_node
(SCOPE_REF
, $1, $2); }
2868 notype_qualified_id:
2869 nested_name_specifier notype_unqualified_id
2870 { got_scope
= NULL_TREE
;
2871 $$
= build_parse_node
(SCOPE_REF
, $$
, $2); }
2872 | nested_name_specifier object_template_id
2873 { got_scope
= NULL_TREE
;
2874 $$
= build_parse_node
(SCOPE_REF
, $1, $2); }
2879 | global_scope notype_qualified_id
2884 typespec
'(' nonnull_exprlist
')'
2885 { $$
= build_functional_cast
($1.t
, $3); }
2886 | typespec
'(' expr_or_declarator_intern
')'
2887 { $$
= reparse_decl_as_expr
($1.t
, $3); }
2888 | typespec fcast_or_absdcl %prec EMPTY
2889 { $$
= reparse_absdcl_as_expr
($1.t
, $2); }
2894 | template_type %prec EMPTY
2897 nested_name_specifier:
2898 nested_name_specifier_1
2899 | nested_name_specifier nested_name_specifier_1
2901 | nested_name_specifier TEMPLATE explicit_template_type SCOPE
2902 { got_scope
= $$
= make_typename_type
($1, $3); }
2905 /* Why the @#$%^& do type_name and notype_identifier need to be expanded
2906 inline here?!? (jason) */
2907 nested_name_specifier_1:
2910 if
(TREE_CODE
($1) == IDENTIFIER_NODE
)
2913 maybe_note_name_used_in_class
($1, $$
);
2916 complete_type
(TYPE_MAIN_VARIANT
(TREE_TYPE
($$
)));
2920 if
(TREE_CODE
($1) == IDENTIFIER_NODE
)
2922 got_scope
= $$
= TREE_TYPE
($$
);
2926 if
(TREE_CODE
($$
) == IDENTIFIER_NODE
)
2930 | template_type SCOPE
2931 { got_scope
= $$
= complete_type
(TREE_TYPE
($1)); }
2932 /* These break 'const i;'
2936 cp_error ("`%D' is not an aggregate typedef",
2937 lastiddecl ? lastiddecl : $$);
2938 $$ = error_mark_node;
2941 { goto failed_scope; } */
2946 | global_scope typename_sub0
2951 typename_sub1 identifier %prec EMPTY
2953 if
(TREE_CODE_CLASS
(TREE_CODE
($1)) == 't')
2954 $$
= make_typename_type
($1, $2);
2955 else if
(TREE_CODE
($2) == IDENTIFIER_NODE
)
2956 cp_error
("`%T' is not a class or namespace", $2);
2960 if
(TREE_CODE
($$
) == TYPE_DECL
)
2961 $$
= TREE_TYPE
($$
);
2964 | typename_sub1 template_type %prec EMPTY
2965 { $$
= TREE_TYPE
($2); }
2966 | typename_sub1 explicit_template_type %prec EMPTY
2967 { $$
= make_typename_type
($1, $2); }
2968 | typename_sub1 TEMPLATE explicit_template_type %prec EMPTY
2969 { $$
= make_typename_type
($1, $3); }
2975 if
(TREE_CODE
($1) == IDENTIFIER_NODE
)
2976 cp_error
("`%T' is not a class or namespace", $1);
2978 | typename_sub1 typename_sub2
2980 if
(TREE_CODE_CLASS
(TREE_CODE
($1)) == 't')
2981 $$
= make_typename_type
($1, $2);
2982 else if
(TREE_CODE
($2) == IDENTIFIER_NODE
)
2983 cp_error
("`%T' is not a class or namespace", $2);
2987 if
(TREE_CODE
($$
) == TYPE_DECL
)
2988 $$
= TREE_TYPE
($$
);
2991 | typename_sub1 explicit_template_type SCOPE
2992 { got_scope
= $$
= make_typename_type
($1, $2); }
2993 | typename_sub1 TEMPLATE explicit_template_type SCOPE
2994 { got_scope
= $$
= make_typename_type
($1, $3); }
3000 if
(TREE_CODE
($1) != IDENTIFIER_NODE
)
3003 /* Retrieve the type for the identifier, which might involve
3004 some computation. */
3005 got_scope
= $$
= complete_type
(IDENTIFIER_TYPE_VALUE
($1));
3007 if
($$
== error_mark_node
)
3008 cp_error
("`%T' is not a class or namespace", $1);
3012 if
(TREE_CODE
($1) != IDENTIFIER_NODE
)
3014 got_scope
= $$
= complete_type
(TREE_TYPE
($$
));
3016 | template_type SCOPE
3017 { got_scope
= $$
= complete_type
(TREE_TYPE
($$
)); }
3022 if
(TREE_CODE
($$
) == IDENTIFIER_NODE
)
3028 explicit_template_type:
3029 identifier
'<' template_arg_list_opt template_close_bracket
3030 { $$
= build_min_nt
(TEMPLATE_ID_EXPR
, $1, $3); }
3034 global_scope type_name
3036 if
(TREE_CODE
($2) == IDENTIFIER_NODE
)
3037 $$
= IDENTIFIER_GLOBAL_VALUE
($2);
3040 got_scope
= NULL_TREE
;
3043 | global_scope nested_type
3048 nested_name_specifier
'*'
3049 { got_scope
= NULL_TREE
; }
3050 | global_scope nested_name_specifier
'*'
3051 { $$
= $2; got_scope
= NULL_TREE
; }
3054 /* All uses of explicit global scope must go through this nonterminal so
3055 that got_scope will be set before yylex is called to get the next token. */
3058 { got_scope
= void_type_node
; }
3061 /* ANSI new-declarator (5.3.4) */
3063 '*' cv_qualifiers new_declarator
3064 { $$
= make_pointer_declarator
($2, $3); }
3065 |
'*' cv_qualifiers %prec EMPTY
3066 { $$
= make_pointer_declarator
($2, NULL_TREE
); }
3067 |
'&' cv_qualifiers new_declarator %prec EMPTY
3068 { $$
= make_reference_declarator
($2, $3); }
3069 |
'&' cv_qualifiers %prec EMPTY
3070 { $$
= make_reference_declarator
($2, NULL_TREE
); }
3071 | ptr_to_mem cv_qualifiers %prec EMPTY
3072 { tree arg
= make_pointer_declarator
($2, NULL_TREE
);
3073 $$
= build_parse_node
(SCOPE_REF
, $1, arg
);
3075 | ptr_to_mem cv_qualifiers new_declarator
3076 { tree arg
= make_pointer_declarator
($2, $3);
3077 $$
= build_parse_node
(SCOPE_REF
, $1, arg
);
3079 | direct_new_declarator %prec EMPTY
3082 /* ANSI direct-new-declarator (5.3.4) */
3083 direct_new_declarator:
3085 { $$
= build_parse_node
(ARRAY_REF
, NULL_TREE
, $2); }
3086 | direct_new_declarator
'[' nonmomentary_expr
']'
3087 { $$
= build_parse_node
(ARRAY_REF
, $$
, $3); }
3094 /* Provide support for '(' attributes '*' declarator ')'
3096 $$
= decl_tree_cons
($1, $2, NULL_TREE
);
3100 /* ANSI abstract-declarator (8.1) */
3102 '*' nonempty_cv_qualifiers absdcl_intern
3103 { $$
= make_pointer_declarator
($2.t
, $3); }
3105 { $$
= make_pointer_declarator
(NULL_TREE
, $2); }
3106 |
'*' nonempty_cv_qualifiers %prec EMPTY
3107 { $$
= make_pointer_declarator
($2.t
, NULL_TREE
); }
3109 { $$
= make_pointer_declarator
(NULL_TREE
, NULL_TREE
); }
3110 |
'&' nonempty_cv_qualifiers absdcl_intern
3111 { $$
= make_reference_declarator
($2.t
, $3); }
3113 { $$
= make_reference_declarator
(NULL_TREE
, $2); }
3114 |
'&' nonempty_cv_qualifiers %prec EMPTY
3115 { $$
= make_reference_declarator
($2.t
, NULL_TREE
); }
3117 { $$
= make_reference_declarator
(NULL_TREE
, NULL_TREE
); }
3118 | ptr_to_mem cv_qualifiers %prec EMPTY
3119 { tree arg
= make_pointer_declarator
($2, NULL_TREE
);
3120 $$
= build_parse_node
(SCOPE_REF
, $1, arg
);
3122 | ptr_to_mem cv_qualifiers absdcl_intern
3123 { tree arg
= make_pointer_declarator
($2, $3);
3124 $$
= build_parse_node
(SCOPE_REF
, $1, arg
);
3126 | direct_abstract_declarator %prec EMPTY
3129 /* ANSI direct-abstract-declarator (8.1) */
3130 direct_abstract_declarator:
3131 '(' absdcl_intern
')'
3133 /* `(typedef)1' is `int'. */
3134 | direct_abstract_declarator
'(' parmlist
')' cv_qualifiers exception_specification_opt %prec
'.'
3135 { $$
= make_call_declarator
($$
, $3, $5, $6); }
3136 | direct_abstract_declarator LEFT_RIGHT cv_qualifiers exception_specification_opt %prec
'.'
3137 { $$
= make_call_declarator
($$
, empty_parms
(), $3, $4); }
3138 | direct_abstract_declarator
'[' nonmomentary_expr
']' %prec
'.'
3139 { $$
= build_parse_node
(ARRAY_REF
, $$
, $3); }
3140 | direct_abstract_declarator
'[' ']' %prec
'.'
3141 { $$
= build_parse_node
(ARRAY_REF
, $$
, NULL_TREE
); }
3142 |
'(' complex_parmlist
')' cv_qualifiers exception_specification_opt %prec
'.'
3143 { $$
= make_call_declarator
(NULL_TREE
, $2, $4, $5); }
3144 | regcast_or_absdcl cv_qualifiers exception_specification_opt %prec
'.'
3145 { set_quals_and_spec
($$
, $2, $3); }
3146 | fcast_or_absdcl cv_qualifiers exception_specification_opt %prec
'.'
3147 { set_quals_and_spec
($$
, $2, $3); }
3148 |
'[' nonmomentary_expr
']' %prec
'.'
3149 { $$
= build_parse_node
(ARRAY_REF
, NULL_TREE
, $2); }
3151 { $$
= build_parse_node
(ARRAY_REF
, NULL_TREE
, NULL_TREE
); }
3154 /* For C++, decls and stmts can be intermixed, so we don't need to
3155 have a special rule that won't start parsing the stmt section
3156 until we have a stmt that parses without errors. */
3169 /* Read zero or more forward-declarations for labels
3170 that nested functions can jump to. */
3175 pedwarn
("ANSI C++ forbids label declarations"); }
3180 | label_decls label_decl
3184 LABEL identifiers_or_typenames
';'
3188 finish_label_decl
(TREE_VALUE
($2));
3189 $2 = TREE_CHAIN
($2);
3194 /* This is the body of a function definition.
3195 It causes syntax errors to ignore to the next openbrace. */
3204 { $
<ttype
>$
= begin_compound_stmt
(0); }
3206 { $$
= finish_compound_stmt
(0, $
<ttype
>2); }
3212 $
<ttype
>$
= begin_if_stmt
();
3213 cond_stmt_keyword
= "if";
3216 { finish_if_stmt_cond
($3, $
<ttype
>2); }
3217 implicitly_scoped_stmt
3218 { $
<ttype
>$
= finish_then_clause
($
<ttype
>2); }
3221 implicitly_scoped_stmt:
3223 |
{ $
<ttype
>$
= begin_compound_stmt
(0); }
3225 { $$
= finish_compound_stmt
(0, $
<ttype
>1); }
3238 { finish_expr_stmt
($1); }
3240 { begin_else_clause
(); }
3241 implicitly_scoped_stmt
3243 finish_else_clause
($
<ttype
>1);
3246 | simple_if %prec IF
3247 { finish_if_stmt
(); }
3250 $
<ttype
>$
= begin_while_stmt
();
3251 cond_stmt_keyword
= "while";
3254 { finish_while_stmt_cond
($3, $
<ttype
>2); }
3256 { finish_while_stmt
($
<ttype
>2); }
3258 { $
<ttype
>$
= begin_do_stmt
(); }
3259 implicitly_scoped_stmt WHILE
3261 finish_do_body
($
<ttype
>2);
3262 cond_stmt_keyword
= "do";
3264 paren_expr_or_null
';'
3265 { finish_do_stmt
($6, $
<ttype
>2); }
3267 { $
<ttype
>$
= begin_for_stmt
(); }
3268 '(' for.init.statement
3269 { finish_for_init_stmt
($
<ttype
>2); }
3271 { finish_for_cond
($6, $
<ttype
>2); }
3273 { finish_for_expr
($9, $
<ttype
>2); }
3275 { finish_for_stmt
($9, $
<ttype
>2); }
3277 { $
<ttype
>$
= begin_switch_stmt
(); }
3279 { finish_switch_cond
($4, $
<ttype
>2); }
3280 implicitly_scoped_stmt
3281 { finish_switch_stmt
($4, $
<ttype
>6); }
3282 | CASE expr_no_commas
':'
3283 { finish_case_label
($2, NULL_TREE
); }
3285 | CASE expr_no_commas ELLIPSIS expr_no_commas
':'
3286 { finish_case_label
($2, $4); }
3289 { finish_case_label
(NULL_TREE
, NULL_TREE
); }
3292 { finish_break_stmt
(); }
3294 { finish_continue_stmt
(); }
3295 | RETURN_KEYWORD
';'
3296 { finish_return_stmt
(NULL_TREE
); }
3297 | RETURN_KEYWORD expr
';'
3298 { finish_return_stmt
($2); }
3299 | asm_keyword maybe_cv_qualifier
'(' string ')' ';'
3301 finish_asm_stmt
($2, $4, NULL_TREE
, NULL_TREE
,
3304 /* This is the case with just output operands. */
3305 | asm_keyword maybe_cv_qualifier
'(' string ':' asm_operands
')' ';'
3307 finish_asm_stmt
($2, $4, $6, NULL_TREE
,
3310 /* This is the case with input operands as well. */
3311 | asm_keyword maybe_cv_qualifier
'(' string ':' asm_operands
':' asm_operands
')' ';'
3312 { finish_asm_stmt
($2, $4, $6, $8, NULL_TREE
); }
3313 /* This is the case with clobbered registers as well. */
3314 | asm_keyword maybe_cv_qualifier
'(' string ':' asm_operands
':'
3315 asm_operands
':' asm_clobbers
')' ';'
3316 { finish_asm_stmt
($2, $4, $6, $8, $10); }
3320 pedwarn
("ANSI C++ forbids computed gotos");
3321 finish_goto_stmt
($3);
3323 | GOTO identifier
';'
3324 { finish_goto_stmt
($2); }
3328 { error ("label must be followed by statement");
3335 | namespace_using_decl
3336 { do_local_using_decl
($1); }
3342 { $
<ttype
>$
= begin_function_try_block
(); }
3343 ctor_initializer_opt compstmt
3344 { finish_function_try_block
($
<ttype
>2); }
3347 finish_function_handler_sequence
($
<ttype
>2);
3354 { $
<ttype
>$
= begin_try_block
(); }
3356 { finish_try_block
($
<ttype
>2); }
3358 { finish_handler_sequence
($
<ttype
>2); }
3363 | handler_seq handler
3368 { $
<ttype
>$
= begin_handler
(); }
3370 { finish_handler_parms
($
<ttype
>2); }
3372 { finish_handler
($
<ttype
>2); }
3376 typed_typespecs %prec EMPTY
3377 | nonempty_cv_qualifiers %prec EMPTY
3382 { expand_start_catch_block
(NULL_TREE
); }
3383 /* This doesn't allow reference parameters, the below does.
3384 | '(' type_specifier_seq absdcl ')'
3385 { check_for_new_type ("inside exception declarations", $2);
3386 expand_start_catch_block ($2.t, $3); }
3387 | '(' type_specifier_seq ')'
3388 { check_for_new_type ("inside exception declarations", $2);
3389 expand_start_catch_block ($2.t, NULL_TREE); }
3390 | '(' type_specifier_seq notype_declarator ')'
3391 { check_for_new_type ("inside exception declarations", $2);
3392 expand_start_catch_block ($2.t, $3); }
3393 | '(' typed_typespecs after_type_declarator ')'
3394 { check_for_new_type ("inside exception declarations", $2);
3395 expand_start_catch_block ($2.t, $3); }
3396 This allows reference parameters... */
3399 check_for_new_type
("inside exception declarations", $2);
3400 start_handler_parms
(TREE_PURPOSE
($2.t
),
3407 { finish_label_stmt
($1); }
3409 { finish_label_stmt
($1); }
3411 { finish_label_stmt
($1); }
3413 { finish_label_stmt
($1); }
3418 { finish_expr_stmt
($1); }
3422 pedwarn
("ANSI C++ forbids compound statements inside for initializations");
3426 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
3430 { emit_line_note
(input_filename
, lineno
);
3433 { emit_line_note
(input_filename
, lineno
); }
3444 /* These are the operands other than the first string and colon
3445 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
3449 | nonnull_asm_operands
3452 nonnull_asm_operands:
3454 | nonnull_asm_operands
',' asm_operand
3455 { $$
= chainon
($$
, $3); }
3460 { $$
= build_tree_list
($$
, $3); }
3465 { $$
= tree_cons
(NULL_TREE
, $$
, NULL_TREE
); }
3466 | asm_clobbers
',' STRING
3467 { $$
= tree_cons
(NULL_TREE
, $3, $$
); }
3470 /* This is what appears inside the parens in a function declarator.
3471 Its value is represented in the format that grokdeclarator expects.
3473 In C++, declaring a function with no parameters
3474 means that that function takes *no* parameters. */
3483 { $$
= finish_parmlist
(build_tree_list
(NULL_TREE
, $1.t
), 0);
3484 check_for_new_type
("inside parameter list", $1); }
3487 /* This nonterminal does not include the common sequence '(' type_id ')',
3488 as it is ambiguous and must be disambiguated elsewhere. */
3491 { $$
= finish_parmlist
($$
, 0); }
3492 | parms_comma ELLIPSIS
3493 { $$
= finish_parmlist
($1, 1); }
3494 /* C++ allows an ellipsis without a separating ',' */
3496 { $$
= finish_parmlist
($1, 1); }
3498 { $$
= finish_parmlist
(build_tree_list
(NULL_TREE
,
3501 { $$
= finish_parmlist
(NULL_TREE
, 1); }
3504 /* This helps us recover from really nasty
3505 parse errors, for example, a missing right
3507 yyerror ("possibly missing ')'");
3508 $$
= finish_parmlist
($1, 0);
3514 /* This helps us recover from really nasty
3515 parse errors, for example, a missing right
3517 yyerror ("possibly missing ')'");
3518 $$
= finish_parmlist
(build_tree_list
(NULL_TREE
,
3525 /* A default argument to a */
3528 { maybe_snarf_defarg
(); }
3538 /* A nonempty list of parameter declarations or type names. */
3541 { check_for_new_type
("in a parameter list", $1);
3542 $$
= build_tree_list
(NULL_TREE
, $1.t
); }
3544 { check_for_new_type
("in a parameter list", $1);
3545 $$
= build_tree_list
($2, $1.t
); }
3546 | parms_comma full_parm
3547 { check_for_new_type
("in a parameter list", $2);
3548 $$
= chainon
($$
, $2.t
); }
3549 | parms_comma bad_parm
3550 { $$
= chainon
($$
, build_tree_list
(NULL_TREE
, $2)); }
3551 | parms_comma bad_parm
'=' init
3552 { $$
= chainon
($$
, build_tree_list
($4, $2)); }
3558 { check_for_new_type
("in a parameter list", $1);
3559 $$
= build_tree_list
(NULL_TREE
, $1.t
); }
3562 /* A single parameter declaration or parameter type name,
3563 as found in a parmlist. */
3565 /* Here we expand typed_declspecs inline to avoid mis-parsing of
3566 TYPESPEC IDENTIFIER. */
3567 typed_declspecs1 declarator
3568 { tree specs
= strip_attrs
($1.t
);
3569 $$.new_type_flag
= $1.new_type_flag
;
3570 $$.t
= build_tree_list
(specs
, $2); }
3571 | typed_typespecs declarator
3572 { $$.t
= build_tree_list
($1.t
, $2);
3573 $$.new_type_flag
= $1.new_type_flag
; }
3574 | typespec declarator
3575 { $$.t
= build_tree_list
(build_decl_list
(NULL_TREE
, $1.t
),
3577 $$.new_type_flag
= $1.new_type_flag
; }
3578 | typed_declspecs1 absdcl
3579 { tree specs
= strip_attrs
($1.t
);
3580 $$.t
= build_tree_list
(specs
, $2);
3581 $$.new_type_flag
= $1.new_type_flag
; }
3582 | typed_declspecs1 %prec EMPTY
3583 { tree specs
= strip_attrs
($1.t
);
3584 $$.t
= build_tree_list
(specs
, NULL_TREE
);
3585 $$.new_type_flag
= $1.new_type_flag
; }
3586 | declmods notype_declarator
3587 { tree specs
= strip_attrs
($1);
3588 $$.t
= build_tree_list
(specs
, $2);
3589 $$.new_type_flag
= 0; }
3594 { $$.t
= build_tree_list
(NULL_TREE
, $1.t
);
3595 $$.new_type_flag
= $1.new_type_flag
; }
3597 { $$.t
= build_tree_list
($2, $1.t
);
3598 $$.new_type_flag
= $1.new_type_flag
; }
3607 /* empty */ %prec EMPTY
3608 { see_typename
(); }
3612 /* empty */ %prec EMPTY
3614 error ("type specifier omitted for parameter");
3615 $$
= build_tree_list
(integer_type_node
, NULL_TREE
);
3619 error ("type specifier omitted for parameter");
3620 if
(TREE_CODE
($$
) == SCOPE_REF
3621 && (TREE_CODE
(TREE_OPERAND
($$
, 0)) == TEMPLATE_TYPE_PARM
3622 || TREE_CODE
(TREE_OPERAND
($$
, 0)) == TEMPLATE_TEMPLATE_PARM
))
3623 cp_error
(" perhaps you want `typename %E' to make it a type", $$
);
3624 $$
= build_tree_list
(integer_type_node
, $$
);
3628 exception_specification_opt:
3629 /* empty */ %prec EMPTY
3631 | THROW
'(' ansi_raise_identifiers
')' %prec EMPTY
3633 | THROW LEFT_RIGHT %prec EMPTY
3634 { $$
= empty_except_spec
; }
3637 ansi_raise_identifier:
3640 check_for_new_type
("exception specifier", $1);
3641 $$
= groktypename
($1.t
);
3645 ansi_raise_identifiers:
3646 ansi_raise_identifier
3647 { $$
= add_exception_specifier
(NULL_TREE
, $1, 1); }
3648 | ansi_raise_identifiers
',' ansi_raise_identifier
3649 { $$
= add_exception_specifier
($1, $3, 1); }
3652 conversion_declarator:
3653 /* empty */ %prec EMPTY
3655 |
'*' cv_qualifiers conversion_declarator
3656 { $$
= make_pointer_declarator
($2, $3); }
3657 |
'&' cv_qualifiers conversion_declarator
3658 { $$
= make_reference_declarator
($2, $3); }
3659 | ptr_to_mem cv_qualifiers conversion_declarator
3660 { tree arg
= make_pointer_declarator
($2, $3);
3661 $$
= build_parse_node
(SCOPE_REF
, $1, arg
);
3667 { got_scope
= NULL_TREE
; }
3672 { $$
= ansi_opname
[MULT_EXPR
]; }
3674 { $$
= ansi_opname
[TRUNC_DIV_EXPR
]; }
3676 { $$
= ansi_opname
[TRUNC_MOD_EXPR
]; }
3678 { $$
= ansi_opname
[PLUS_EXPR
]; }
3680 { $$
= ansi_opname
[MINUS_EXPR
]; }
3682 { $$
= ansi_opname
[BIT_AND_EXPR
]; }
3684 { $$
= ansi_opname
[BIT_IOR_EXPR
]; }
3686 { $$
= ansi_opname
[BIT_XOR_EXPR
]; }
3688 { $$
= ansi_opname
[BIT_NOT_EXPR
]; }
3690 { $$
= ansi_opname
[COMPOUND_EXPR
]; }
3691 | operator ARITHCOMPARE
3692 { $$
= ansi_opname
[$2]; }
3694 { $$
= ansi_opname
[LT_EXPR
]; }
3696 { $$
= ansi_opname
[GT_EXPR
]; }
3697 | operator EQCOMPARE
3698 { $$
= ansi_opname
[$2]; }
3700 { $$
= ansi_assopname
[$2]; }
3702 { $$
= ansi_opname
[MODIFY_EXPR
]; }
3704 { $$
= ansi_opname
[$2]; }
3706 { $$
= ansi_opname
[$2]; }
3708 { $$
= ansi_opname
[POSTINCREMENT_EXPR
]; }
3709 | operator MINUSMINUS
3710 { $$
= ansi_opname
[PREDECREMENT_EXPR
]; }
3712 { $$
= ansi_opname
[TRUTH_ANDIF_EXPR
]; }
3714 { $$
= ansi_opname
[TRUTH_ORIF_EXPR
]; }
3716 { $$
= ansi_opname
[TRUTH_NOT_EXPR
]; }
3718 { $$
= ansi_opname
[COND_EXPR
]; }
3720 { $$
= ansi_opname
[$2]; }
3721 | operator POINTSAT %prec EMPTY
3722 { $$
= ansi_opname
[COMPONENT_REF
]; }
3723 | operator POINTSAT_STAR %prec EMPTY
3724 { $$
= ansi_opname
[MEMBER_REF
]; }
3725 | operator LEFT_RIGHT
3726 { $$
= ansi_opname
[CALL_EXPR
]; }
3728 { $$
= ansi_opname
[ARRAY_REF
]; }
3729 | operator NEW %prec EMPTY
3730 { $$
= ansi_opname
[NEW_EXPR
]; }
3731 | operator DELETE %prec EMPTY
3732 { $$
= ansi_opname
[DELETE_EXPR
]; }
3733 | operator NEW
'[' ']'
3734 { $$
= ansi_opname
[VEC_NEW_EXPR
]; }
3735 | operator DELETE
'[' ']'
3736 { $$
= ansi_opname
[VEC_DELETE_EXPR
]; }
3737 /* Names here should be looked up in class scope ALSO. */
3738 | operator type_specifier_seq conversion_declarator
3739 { $$
= grokoptypename
($2.t
, $3); }
3741 { $$
= ansi_opname
[ERROR_MARK
]; }
3748 debug_yytranslate
(value
)
3751 return yytname
[YYTRANSLATE
(value
)];