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 void 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. */
79 || current_class_type
!= NULL
)
80 parms
= void_list_node
;
95 flagged_type_tree ftype
;
96 struct pending_inline
*pi
;
99 /* All identifiers that are not reserved words
100 and are not declared typedefs in the current block */
103 /* All identifiers that are declared typedefs in the current block.
104 In some contexts, they are treated just like IDENTIFIER,
105 but they can also serve as typespecs in declarations. */
109 /* A template function. */
112 /* Reserved words that specify storage class.
113 yylval contains an IDENTIFIER_NODE which indicates which one. */
116 /* Reserved words that specify type.
117 yylval contains an IDENTIFIER_NODE which indicates which one. */
120 /* Reserved words that qualify type: "const" or "volatile".
121 yylval contains an IDENTIFIER_NODE which indicates which one. */
124 /* Character or numeric constants.
125 yylval is the node for the constant. */
128 /* String constants in raw form.
129 yylval is a STRING_CST node. */
132 /* "...", used for functions with variable arglists. */
135 /* the reserved words */
136 /* SCO include files test "ASM", so use something else. */
137 %token SIZEOF ENUM
/* STRUCT UNION */ IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
138 %token BREAK CONTINUE RETURN_KEYWORD GOTO ASM_KEYWORD TYPEOF ALIGNOF
140 %token ATTRIBUTE EXTENSION LABEL
141 %token REALPART IMAGPART VA_ARG
143 /* the reserved words... C++ extensions */
145 %token
<ttype
> VISSPEC
146 %token DELETE NEW THIS OPERATOR CXX_TRUE CXX_FALSE
147 %token NAMESPACE TYPENAME_KEYWORD USING
148 %token LEFT_RIGHT TEMPLATE
149 %token TYPEID DYNAMIC_CAST STATIC_CAST REINTERPRET_CAST CONST_CAST
152 /* Define the operator tokens and their precedences.
153 The value is an integer because, if used, it is the tree code
154 to use in the expression made from the operator. */
156 %left EMPTY
/* used to resolve s/r with epsilon */
160 /* Add precedence rules to solve dangling else s/r conflict */
164 %left IDENTIFIER PFUNCNAME TYPENAME SELFNAME PTYPENAME SCSPEC TYPESPEC CV_QUALIFIER ENUM AGGR ELLIPSIS TYPEOF SIGOF OPERATOR NSNAME TYPENAME_KEYWORD
170 %right
<code
> ASSIGN
'='
178 %left
<code
> EQCOMPARE
179 %left
<code
> ARITHCOMPARE
'<' '>'
180 %left
<code
> LSHIFT RSHIFT
182 %left
<code
> '*' '/' '%'
183 %left
<code
> POINTSAT_STAR DOT_STAR
184 %right
<code
> UNARY PLUSPLUS MINUSMINUS
'~'
186 %left
<ttype
> LEFT_RIGHT
187 %left
<code
> POINTSAT
'.' '(' '['
189 %right SCOPE
/* C++ extension */
190 %nonassoc NEW DELETE TRY CATCH
194 %type
<ttype
> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist
195 %type
<ttype
> PFUNCNAME maybe_identifier
196 %type
<ttype
> paren_expr_or_null nontrivial_exprlist SELFNAME
197 %type
<ttype
> expr_no_commas cast_expr unary_expr primary
string STRING
198 %type
<ttype
> reserved_declspecs boolean.literal
199 %type
<ttype
> reserved_typespecquals
200 %type
<ttype
> declmods
201 %type
<ttype
> SCSPEC TYPESPEC CV_QUALIFIER maybe_cv_qualifier
202 %type
<ttype
> init initlist maybeasm maybe_init defarg defarg1
203 %type
<ttype
> asm_operands nonnull_asm_operands asm_operand asm_clobbers
204 %type
<ttype
> maybe_attribute attributes attribute attribute_list attrib
205 %type
<ttype
> any_word
207 %type
<ttype
> compstmt implicitly_scoped_stmt
209 %type
<ttype
> declarator notype_declarator after_type_declarator
210 %type
<ttype
> notype_declarator_intern absdcl_intern
211 %type
<ttype
> after_type_declarator_intern
212 %type
<ttype
> direct_notype_declarator direct_after_type_declarator
213 %type
<itype
> components notype_components
214 %type
<ttype
> component_decl component_decl_1
215 %type
<ttype
> component_declarator component_declarator0
216 %type
<ttype
> notype_component_declarator notype_component_declarator0
217 %type
<ttype
> after_type_component_declarator after_type_component_declarator0
218 %type
<ttype
> absdcl cv_qualifiers
219 %type
<ttype
> direct_abstract_declarator conversion_declarator
220 %type
<ttype
> new_declarator direct_new_declarator
221 %type
<ttype
> xexpr parmlist parms bad_parm
222 %type
<ttype
> identifiers_or_typenames
223 %type
<ttype
> fcast_or_absdcl regcast_or_absdcl
224 %type
<ttype
> expr_or_declarator expr_or_declarator_intern
225 %type
<ttype
> complex_notype_declarator
226 %type
<ttype
> notype_unqualified_id unqualified_id qualified_id
227 %type
<ttype
> template_id do_id object_template_id notype_template_declarator
228 %type
<ttype
> overqualified_id notype_qualified_id any_id
229 %type
<ttype
> complex_direct_notype_declarator functional_cast
230 %type
<ttype
> complex_parmlist parms_comma
231 %type
<ttype
> namespace_qualifier namespace_using_decl
233 %type
<ftype
> type_id new_type_id typed_typespecs typespec typed_declspecs
234 %type
<ftype
> typed_declspecs1 type_specifier_seq nonempty_cv_qualifiers
235 %type
<ftype
> structsp typespecqual_reserved parm named_parm full_parm
237 %type
<itype
> extension
240 %token
<ttype
> PTYPENAME
241 %token
<ttype
> EXTERN_LANG_STRING ALL
242 %token
<ttype
> PRE_PARSED_CLASS_DECL DEFARG DEFARG_MARKER
243 %token
<pi
> PRE_PARSED_FUNCTION_DECL
244 %type
<ttype
> component_constructor_declarator
245 %type
<ttype
> fn.def2 return_id constructor_declarator
247 %type
<itype
> ctor_initializer_opt function_try_block
248 %type
<ttype
> named_class_head_sans_basetype
249 %type
<ftype
> class_head named_class_head
250 %type
<ftype
> named_complex_class_head_sans_basetype
251 %type
<ttype
> unnamed_class_head
252 %type
<ttype
> base_class_list
253 %type
<ttype
> base_class_access_list
254 %type
<ttype
> base_class maybe_base_class_list base_class
.1
255 %type
<ttype
> exception_specification_opt ansi_raise_identifier ansi_raise_identifiers
256 %type
<ttype
> operator_name
257 %type
<ttype
> object aggr
258 %type
<itype
> new delete
259 /* %type <ttype> primary_no_id */
260 %type
<ttype
> maybe_parmlist
261 %type
<itype
> member_init_list
262 %type
<ttype
> template_header template_parm_list template_parm
263 %type
<ttype
> template_type_parm template_template_parm
264 %type
<code
> template_close_bracket
265 %type
<ttype
> apparent_template_type
266 %type
<ttype
> template_type template_arg_list template_arg_list_opt
267 %type
<ttype
> template_arg
268 %type
<ttype
> condition xcond paren_cond_or_null
269 %type
<ttype
> type_name nested_name_specifier nested_type ptr_to_mem
270 %type
<ttype
> complete_type_name notype_identifier nonnested_type
271 %type
<ttype
> complex_type_name nested_name_specifier_1
272 %type
<ttype
> new_initializer new_placement
273 %type
<ttype
> using_decl
274 %type
<ttype
> typename_sub typename_sub0 typename_sub1 typename_sub2
275 %type
<ttype
> explicit_template_type
276 /* in order to recognize aggr tags as defining and thus shadowing. */
277 %token TYPENAME_DEFN IDENTIFIER_DEFN PTYPENAME_DEFN
278 %type
<ttype
> named_class_head_sans_basetype_defn
279 %type
<ttype
> identifier_defn IDENTIFIER_DEFN TYPENAME_DEFN PTYPENAME_DEFN
280 %type
<ttype
> handler_args
281 %type
<ttype
> self_template_type .finish_template_type
286 /* Used in lex.c for parsing pragmas. */
289 /* lex.c and pt.c depend on this being the last token. Define
290 any new tokens before this one! */
291 %token END_OF_SAVED_INPUT
294 /* List of types and structure classes of the current declaration. */
295 static tree current_declspecs
;
297 /* List of prefix attributes in effect.
298 Prefix attributes are parsed by the reserved_declspecs and declmods
299 rules. They create a list that contains *both* declspecs and attrs. */
300 /* ??? It is not clear yet that all cases where an attribute can now appear in
301 a declspec list have been updated. */
302 static tree prefix_attributes
;
304 /* When defining an aggregate, this is the kind of the most recent one
305 being defined. (For example, this might be class_type_node.) */
306 static tree current_aggr
;
308 /* When defining an enumeration, this is the type of the enumeration. */
309 static tree current_enum_type
;
311 /* Tell yyparse how to print a token's value, if yydebug is set. */
313 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
314 extern
void yyprint PROTO
((FILE *, int, YYSTYPE));
315 extern tree combine_strings PROTO
((tree
));
318 parse_decl
(declarator
, specs_attrs
, attributes
, initialized
, decl
)
325 split_specs_attrs
(specs_attrs
, ¤t_declspecs
, &prefix_attributes
);
326 if
(current_declspecs
327 && TREE_CODE
(current_declspecs
) != TREE_LIST
)
328 current_declspecs
= build_decl_list
(NULL_TREE
, current_declspecs
);
329 if
(have_extern_spec
&& !used_extern_spec
)
331 current_declspecs
= decl_tree_cons
(NULL_TREE
,
332 get_identifier
("extern"),
334 used_extern_spec
= 1;
336 *decl
= start_decl
(declarator
, current_declspecs
, initialized
,
337 attributes
, prefix_attributes
);
343 ggc_add_tree_root
(¤t_declspecs
, 1);
344 ggc_add_tree_root
(&prefix_attributes
, 1);
345 ggc_add_tree_root
(¤t_aggr
, 1);
346 ggc_add_tree_root
(¤t_enum_type
, 1);
354 { finish_translation_unit
(); }
357 /* the reason for the strange actions in this rule
358 is so that notype_initdecls when reached via datadef
359 can find a valid list of type and sc specs in $0. */
362 { $
<ttype
>$
= NULL_TREE
; }
364 { $
<ttype
>$
= NULL_TREE
; }
365 | extdefs lang_extdef
366 { $
<ttype
>$
= NULL_TREE
; }
375 { have_extern_spec
= 1;
376 used_extern_spec
= 0;
377 $
<ttype
>$
= NULL_TREE
; }
380 { have_extern_spec
= 0; }
394 { if
(pending_lang_change
) do_pending_lang_change
(); }
396 { if
(! toplevel_bindings_p
())
401 fndef eat_saved_input
402 { if
(pending_inlines
) do_pending_inlines
(); }
404 { if
(pending_inlines
) do_pending_inlines
(); }
406 { if
(pending_inlines
) do_pending_inlines
(); }
407 | asm_keyword
'(' string ')' ';'
408 { if
(TREE_CHAIN
($3)) $3 = combine_strings
($3);
410 | extern_lang_string
'{' extdefs_opt
'}'
411 { pop_lang_context
(); }
412 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
413 { if
(pending_inlines
) do_pending_inlines
();
414 pop_lang_context
(); }
415 | extern_lang_string .hush_warning datadef .warning_ok
416 { if
(pending_inlines
) do_pending_inlines
();
417 pop_lang_context
(); }
418 | NAMESPACE identifier
'{'
419 { push_namespace
($2); }
421 { pop_namespace
(); }
423 { push_namespace
(NULL_TREE
); }
425 { pop_namespace
(); }
428 { do_toplevel_using_decl
($1); }
435 NAMESPACE identifier
'='
436 { begin_only_namespace_names
(); }
439 end_only_namespace_names
();
442 do_namespace_alias
($2, $5);
449 | USING global_scope qualified_id
451 | USING global_scope unqualified_id
455 namespace_using_decl:
456 USING namespace_qualifier identifier
457 { $$
= build_parse_node
(SCOPE_REF
, $2, $3); }
458 | USING global_scope identifier
459 { $$
= build_parse_node
(SCOPE_REF
, global_namespace
, $3); }
460 | USING global_scope namespace_qualifier identifier
461 { $$
= build_parse_node
(SCOPE_REF
, $3, $4); }
466 { begin_only_namespace_names
(); }
469 end_only_namespace_names
();
470 /* If no declaration was found, the using-directive is
471 invalid. Since that was not reported, we need the
472 identifier for the error message. */
473 if
(TREE_CODE
($4) == IDENTIFIER_NODE
&& lastiddecl
)
475 do_using_directive
($4);
482 if
(TREE_CODE
($$
) == IDENTIFIER_NODE
)
486 | namespace_qualifier NSNAME SCOPE
489 if
(TREE_CODE
($$
) == IDENTIFIER_NODE
)
497 | global_scope qualified_id
499 | global_scope unqualified_id
505 { push_lang_context
($1); }
506 | extern_lang_string EXTERN_LANG_STRING
507 { if
(current_lang_name
!= $2)
508 cp_error
("use of linkage spec `%D' is different from previous spec `%D'", $2, current_lang_name
);
509 pop_lang_context
(); push_lang_context
($2); }
514 { begin_template_parm_list
(); }
515 template_parm_list
'>'
516 { $$
= end_template_parm_list
($4); }
518 { begin_specialization
();
524 { $$
= process_template_parm
(NULL_TREE
, $1); }
525 | template_parm_list
',' template_parm
526 { $$
= process_template_parm
($1, $3); }
536 aggr maybe_identifier
537 { $$
= finish_template_type_parm
($1, $2); }
538 | TYPENAME_KEYWORD maybe_identifier
539 { $$
= finish_template_type_parm
(class_type_node
, $2); }
542 template_template_parm:
543 template_header aggr maybe_identifier
544 { $$
= finish_template_template_parm
($2, $3); }
548 /* The following rules introduce a new reduce/reduce
549 conflict on the ',' and '>' input tokens: they are valid
550 prefixes for a `structsp', which means they could match a
551 nameless parameter. See 14.6, paragraph 3.
552 By putting them before the `parm' rule, we get
553 their match before considering them nameless parameter
556 { $$
= build_tree_list
(NULL_TREE
, $1); }
557 | template_type_parm
'=' type_id
558 { $$
= build_tree_list
(groktypename
($3.t
), $1); }
560 { $$
= build_tree_list
(NULL_TREE
, $1.t
); }
561 | parm
'=' expr_no_commas %prec ARITHCOMPARE
562 { $$
= build_tree_list
($3, $1.t
); }
563 | template_template_parm
564 { $$
= build_tree_list
(NULL_TREE
, $1); }
565 | template_template_parm
'=' template_arg
567 if
(TREE_CODE
($3) != TEMPLATE_DECL
568 && TREE_CODE
($3) != TEMPLATE_TEMPLATE_PARM
569 && TREE_CODE
($3) != TYPE_DECL
)
571 error ("invalid default template argument");
572 $3 = error_mark_node
;
574 $$
= build_tree_list
($3, $1);
579 template_header template_extdef
580 { finish_template_decl
($1); }
581 | template_header
error %prec EMPTY
582 { finish_template_decl
($1); }
586 fndef eat_saved_input
587 { if
(pending_inlines
) do_pending_inlines
(); }
589 { if
(pending_inlines
) do_pending_inlines
(); }
591 { if
(pending_inlines
) do_pending_inlines
(); }
592 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
593 { if
(pending_inlines
) do_pending_inlines
();
594 pop_lang_context
(); }
595 | extern_lang_string .hush_warning template_datadef .warning_ok
596 { if
(pending_inlines
) do_pending_inlines
();
597 pop_lang_context
(); }
598 | extension template_extdef
604 | declmods notype_initdecls
';'
606 | typed_declspecs initdecls
';'
607 { note_list_got_semicolon
($1.t
); }
609 { maybe_process_partial_specialization
($1.t
);
610 note_got_semicolon
($1.t
); }
615 | declmods notype_initdecls
';'
617 | typed_declspecs initdecls
';'
618 { note_list_got_semicolon
($1.t
); }
620 { pedwarn
("empty declaration"); }
621 | explicit_instantiation
';'
622 | typed_declspecs
';'
625 split_specs_attrs
($1.t
, &t
, &attrs
);
627 note_list_got_semicolon
($1.t
);
634 ctor_initializer_opt:
653 fn.def1 maybe_return_init ctor_initializer_opt compstmt_or_error
654 { expand_body
(finish_function
(lineno
, (int)$3)); }
655 | fn.def1 maybe_return_init function_try_block
656 { expand_body
(finish_function
(lineno
, (int)$3)); }
657 | fn.def1 maybe_return_init
error
661 constructor_declarator:
662 nested_name_specifier SELFNAME
'('
663 { $$
= begin_constructor_declarator
($1, $2); }
664 parmlist
')' cv_qualifiers exception_specification_opt
665 { $$
= make_call_declarator
($
<ttype
>4, $5, $7, $8); }
666 | nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
667 { $$
= begin_constructor_declarator
($1, $2);
668 $$
= make_call_declarator
($$
, empty_parms
(), $4, $5);
670 | global_scope nested_name_specifier SELFNAME
'('
671 { $$
= begin_constructor_declarator
($2, $3); }
672 parmlist
')' cv_qualifiers exception_specification_opt
673 { $$
= make_call_declarator
($
<ttype
>5, $6, $8, $9); }
674 | global_scope nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
675 { $$
= begin_constructor_declarator
($2, $3);
676 $$
= make_call_declarator
($$
, empty_parms
(), $5, $6);
678 | nested_name_specifier self_template_type
'('
679 { $$
= begin_constructor_declarator
($1, $2); }
680 parmlist
')' cv_qualifiers exception_specification_opt
681 { $$
= make_call_declarator
($
<ttype
>4, $5, $7, $8); }
682 | nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
683 { $$
= begin_constructor_declarator
($1, $2);
684 $$
= make_call_declarator
($$
, empty_parms
(), $4, $5);
686 | global_scope nested_name_specifier self_template_type
'('
687 { $$
= begin_constructor_declarator
($2, $3); }
688 parmlist
')' cv_qualifiers exception_specification_opt
689 { $$
= make_call_declarator
($
<ttype
>5, $6, $8, $9); }
690 | global_scope nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
691 { $$
= begin_constructor_declarator
($2, $3);
692 $$
= make_call_declarator
($$
, empty_parms
(), $5, $6);
697 typed_declspecs declarator
698 { if
(!begin_function_definition
($1.t
, $2))
700 | declmods notype_declarator
701 { if
(!begin_function_definition
($1, $2))
704 { if
(!begin_function_definition
(NULL_TREE
, $1))
706 | declmods constructor_declarator
707 { if
(!begin_function_definition
($1, $2))
709 | constructor_declarator
710 { if
(!begin_function_definition
(NULL_TREE
, $1))
714 component_constructor_declarator:
715 SELFNAME
'(' parmlist
')' cv_qualifiers exception_specification_opt
716 { $$
= make_call_declarator
($1, $3, $5, $6); }
717 | SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
718 { $$
= make_call_declarator
($1, empty_parms
(), $3, $4); }
719 | self_template_type
'(' parmlist
')' cv_qualifiers exception_specification_opt
720 { $$
= make_call_declarator
($1, $3, $5, $6); }
721 | self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
722 { $$
= make_call_declarator
($1, empty_parms
(), $3, $4); }
725 /* more C++ complexity. See component_decl for a comment on the
726 reduce/reduce conflict introduced by these rules. */
728 declmods component_constructor_declarator
730 split_specs_attrs
($1, &specs
, &attrs
);
731 attrs
= build_tree_list
(attrs
, NULL_TREE
);
732 $$
= start_method
(specs
, $2, attrs
);
736 if
(yychar == YYEMPTY
)
738 reinit_parse_for_method
(yychar, $$
); }
739 | component_constructor_declarator
740 { $$
= start_method
(NULL_TREE
, $1, NULL_TREE
);
742 | typed_declspecs declarator
744 split_specs_attrs
($1.t
, &specs
, &attrs
);
745 attrs
= build_tree_list
(attrs
, NULL_TREE
);
746 $$
= start_method
(specs
, $2, attrs
); goto rest_of_mdef
; }
747 | declmods notype_declarator
749 split_specs_attrs
($1, &specs
, &attrs
);
750 attrs
= build_tree_list
(attrs
, NULL_TREE
);
751 $$
= start_method
(specs
, $2, attrs
); goto rest_of_mdef
; }
753 { $$
= start_method
(NULL_TREE
, $$
, NULL_TREE
);
755 | declmods constructor_declarator
757 split_specs_attrs
($1, &specs
, &attrs
);
758 attrs
= build_tree_list
(attrs
, NULL_TREE
);
759 $$
= start_method
(specs
, $2, attrs
); goto rest_of_mdef
; }
760 | constructor_declarator
761 { $$
= start_method
(NULL_TREE
, $$
, NULL_TREE
);
766 RETURN_KEYWORD IDENTIFIER
768 if
(! current_function_parms_stored
)
776 { finish_named_return_value
($
<ttype
>$
, $2); }
777 | return_id
'(' nonnull_exprlist
')'
778 { finish_named_return_value
($
<ttype
>$
, $3); }
779 | return_id LEFT_RIGHT
780 { finish_named_return_value
($
<ttype
>$
, NULL_TREE
); }
784 ':' .set_base_init member_init_list
787 error ("no base initializers given following ':'");
795 if
(! current_function_parms_stored
)
798 if
(DECL_CONSTRUCTOR_P
(current_function_decl
))
799 /* Make a contour for the initializer list. */
801 else if
(current_class_type
== NULL_TREE
)
802 error ("base initializers not allowed for non-member functions");
803 else if
(! DECL_CONSTRUCTOR_P
(current_function_decl
))
804 error ("only constructors take base initializers");
813 | member_init_list
',' member_init
814 | member_init_list
error
818 '(' nonnull_exprlist
')'
820 if
(current_class_name
)
821 pedwarn
("anachronistic old style base class initializer");
822 expand_member_init
(current_class_ref
, NULL_TREE
, $2);
826 if
(current_class_name
)
827 pedwarn
("anachronistic old style base class initializer");
828 expand_member_init
(current_class_ref
, NULL_TREE
, void_type_node
);
830 | notype_identifier
'(' nonnull_exprlist
')'
831 { expand_member_init
(current_class_ref
, $1, $3); }
832 | notype_identifier LEFT_RIGHT
833 { expand_member_init
(current_class_ref
, $1, void_type_node
); }
834 | nonnested_type
'(' nonnull_exprlist
')'
835 { expand_member_init
(current_class_ref
, $1, $3); }
836 | nonnested_type LEFT_RIGHT
837 { expand_member_init
(current_class_ref
, $1, void_type_node
); }
838 | typename_sub
'(' nonnull_exprlist
')'
839 { expand_member_init
(current_class_ref
, TYPE_MAIN_DECL
($1),
841 | typename_sub LEFT_RIGHT
842 { expand_member_init
(current_class_ref
, TYPE_MAIN_DECL
($1),
867 explicit_instantiation:
868 TEMPLATE begin_explicit_instantiation typespec
';'
869 { do_type_instantiation
($3.t
, NULL_TREE
);
871 end_explicit_instantiation
872 | TEMPLATE begin_explicit_instantiation typed_declspecs declarator
873 { tree specs
= strip_attrs
($3.t
);
874 do_decl_instantiation
(specs
, $4, NULL_TREE
); }
875 end_explicit_instantiation
876 | TEMPLATE begin_explicit_instantiation notype_declarator
877 { do_decl_instantiation
(NULL_TREE
, $3, NULL_TREE
); }
878 end_explicit_instantiation
879 | TEMPLATE begin_explicit_instantiation constructor_declarator
880 { do_decl_instantiation
(NULL_TREE
, $3, NULL_TREE
); }
881 end_explicit_instantiation
882 | SCSPEC TEMPLATE begin_explicit_instantiation typespec
';'
883 { do_type_instantiation
($4.t
, $1);
885 end_explicit_instantiation
886 | SCSPEC TEMPLATE begin_explicit_instantiation typed_declspecs
888 { tree specs
= strip_attrs
($4.t
);
889 do_decl_instantiation
(specs
, $5, $1); }
890 end_explicit_instantiation
891 | SCSPEC TEMPLATE begin_explicit_instantiation notype_declarator
892 { do_decl_instantiation
(NULL_TREE
, $4, $1); }
893 end_explicit_instantiation
894 | SCSPEC TEMPLATE begin_explicit_instantiation constructor_declarator
895 { do_decl_instantiation
(NULL_TREE
, $4, $1); }
896 end_explicit_instantiation
899 begin_explicit_instantiation:
900 { begin_explicit_instantiation
(); }
902 end_explicit_instantiation:
903 { end_explicit_instantiation
(); }
905 /* The TYPENAME expansions are to deal with use of a template class name as
906 a template within the class itself, where the template decl is hidden by
907 a type decl. Got all that? */
910 PTYPENAME
'<' template_arg_list_opt template_close_bracket
911 .finish_template_type
913 | TYPENAME
'<' template_arg_list_opt template_close_bracket
914 .finish_template_type
919 apparent_template_type:
921 | identifier
'<' template_arg_list_opt
'>'
922 .finish_template_type
926 SELFNAME
'<' template_arg_list_opt template_close_bracket
927 .finish_template_type
931 .finish_template_type
:
933 if
(yychar == YYEMPTY
)
936 $$
= finish_template_type
($
<ttype
>-3, $
<ttype
>-1,
940 template_close_bracket:
944 /* Handle `Class<Class<Type>>' without space in the `>>' */
945 pedwarn
("`>>' should be `> >' in template class name");
950 template_arg_list_opt:
958 { $$
= build_tree_list
(NULL_TREE
, $$
); }
959 | template_arg_list
',' template_arg
960 { $$
= chainon
($$
, build_tree_list
(NULL_TREE
, $3)); }
965 { $$
= groktypename
($1.t
); }
968 | expr_no_commas %prec ARITHCOMPARE
973 { $$
= NEGATE_EXPR
; }
975 { $$
= CONVERT_EXPR
; }
977 { $$
= PREINCREMENT_EXPR
; }
979 { $$
= PREDECREMENT_EXPR
; }
981 { $$
= TRUTH_NOT_EXPR
; }
986 { $$
= build_x_compound_expr
($$
); }
992 { error ("ANSI C++ forbids an empty condition for `%s'",
994 $$
= integer_zero_node
; }
1001 { error ("ANSI C++ forbids an empty condition for `%s'",
1003 $$
= integer_zero_node
; }
1017 type_specifier_seq declarator maybeasm maybe_attribute
'='
1020 for
(d
= getdecls
(); d
; d
= TREE_CHAIN
(d
))
1021 if
(TREE_CODE
(d
) == TYPE_DECL
) {
1022 tree s
= TREE_TYPE
(d
);
1023 if
(TREE_CODE
(s
) == RECORD_TYPE
)
1024 cp_error
("definition of class `%T' in condition", s
);
1025 else if
(TREE_CODE
(s
) == ENUMERAL_TYPE
)
1026 cp_error
("definition of enum `%T' in condition", s
);
1029 current_declspecs
= $1.t
;
1030 $
<ttype
>$
= start_decl
($
<ttype
>2, current_declspecs
, 1,
1031 $4, /*prefix_attributes*/ NULL_TREE
);
1035 cp_finish_decl
($
<ttype
>6, $7, $4, LOOKUP_ONLYCONVERTING
);
1036 $$
= convert_from_reference
($
<ttype
>6);
1037 if
(TREE_CODE
(TREE_TYPE
($$
)) == ARRAY_TYPE
)
1038 cp_error
("definition of array `%#D' in condition", $$
);
1045 | maybe_label_decls stmts
'}'
1046 | maybe_label_decls stmts
error '}'
1047 | maybe_label_decls
error '}'
1050 already_scoped_stmt:
1052 { $
<ttype
>$
= begin_compound_stmt
(1); }
1054 { finish_compound_stmt
(1, $
<ttype
>2); }
1059 nontrivial_exprlist:
1060 expr_no_commas
',' expr_no_commas
1061 { $$
= tree_cons
(NULL_TREE
, $$
,
1062 build_expr_list
(NULL_TREE
, $3)); }
1063 | expr_no_commas
',' error
1064 { $$
= tree_cons
(NULL_TREE
, $$
,
1065 build_expr_list
(NULL_TREE
, error_mark_node
)); }
1066 | nontrivial_exprlist
',' expr_no_commas
1067 { chainon
($$
, build_expr_list
(NULL_TREE
, $3)); }
1068 | nontrivial_exprlist
',' error
1069 { chainon
($$
, build_expr_list
(NULL_TREE
, error_mark_node
)); }
1074 { $$
= build_expr_list
(NULL_TREE
, $$
); }
1075 | nontrivial_exprlist
1081 /* __extension__ turns off -pedantic for following primary. */
1082 | extension cast_expr %prec UNARY
1085 |
'*' cast_expr %prec UNARY
1086 { $$
= build_x_indirect_ref
($2, "unary *"); }
1087 |
'&' cast_expr %prec UNARY
1088 { $$
= build_x_unary_op
(ADDR_EXPR
, $2); }
1090 { $$
= build_x_unary_op
(BIT_NOT_EXPR
, $2); }
1091 | unop cast_expr %prec UNARY
1092 { $$
= finish_unary_op_expr
($1, $2); }
1093 /* Refer to the address of a label as a pointer. */
1096 pedwarn
("ANSI C++ forbids `&&'");
1097 $$
= finish_label_address_expr
($2); }
1098 | SIZEOF unary_expr %prec UNARY
1099 { $$
= expr_sizeof
($2); }
1100 | SIZEOF
'(' type_id
')' %prec HYPERUNARY
1101 { $$
= c_sizeof
(groktypename
($3.t
));
1102 check_for_new_type
("sizeof", $3); }
1103 | ALIGNOF unary_expr %prec UNARY
1104 { $$
= grok_alignof
($2); }
1105 | ALIGNOF
'(' type_id
')' %prec HYPERUNARY
1106 { $$
= c_alignof
(groktypename
($3.t
));
1107 check_for_new_type
("alignof", $3); }
1109 /* The %prec EMPTY's here are required by the = init initializer
1110 syntax extension; see below. */
1111 | new new_type_id %prec EMPTY
1112 { $$
= build_new
(NULL_TREE
, $2.t
, NULL_TREE
, $1);
1113 check_for_new_type
("new", $2); }
1114 | new new_type_id new_initializer
1115 { $$
= build_new
(NULL_TREE
, $2.t
, $3, $1);
1116 check_for_new_type
("new", $2); }
1117 | new new_placement new_type_id %prec EMPTY
1118 { $$
= build_new
($2, $3.t
, NULL_TREE
, $1);
1119 check_for_new_type
("new", $3); }
1120 | new new_placement new_type_id new_initializer
1121 { $$
= build_new
($2, $3.t
, $4, $1);
1122 check_for_new_type
("new", $3); }
1123 | new
'(' type_id
')'
1125 { $$
= build_new
(NULL_TREE
, groktypename
($3.t
),
1127 check_for_new_type
("new", $3); }
1128 | new
'(' type_id
')' new_initializer
1129 { $$
= build_new
(NULL_TREE
, groktypename
($3.t
), $5, $1);
1130 check_for_new_type
("new", $3); }
1131 | new new_placement
'(' type_id
')' %prec EMPTY
1132 { $$
= build_new
($2, groktypename
($4.t
), NULL_TREE
, $1);
1133 check_for_new_type
("new", $4); }
1134 | new new_placement
'(' type_id
')' new_initializer
1135 { $$
= build_new
($2, groktypename
($4.t
), $6, $1);
1136 check_for_new_type
("new", $4); }
1138 | delete cast_expr %prec UNARY
1139 { $$
= delete_sanity
($2, NULL_TREE
, 0, $1); }
1140 | delete
'[' ']' cast_expr %prec UNARY
1141 { $$
= delete_sanity
($4, NULL_TREE
, 1, $1);
1142 if
(yychar == YYEMPTY
)
1144 | delete
'[' expr
']' cast_expr %prec UNARY
1145 { $$
= delete_sanity
($5, $3, 2, $1);
1146 if
(yychar == YYEMPTY
)
1148 | REALPART cast_expr %prec UNARY
1149 { $$
= build_x_unary_op
(REALPART_EXPR
, $2); }
1150 | IMAGPART cast_expr %prec UNARY
1151 { $$
= build_x_unary_op
(IMAGPART_EXPR
, $2); }
1152 | VA_ARG
'(' expr_no_commas
',' type_id
')'
1153 { $$
= build_x_va_arg
($3, groktypename
($5.t
));
1154 check_for_new_type
("__builtin_va_arg", $5); }
1158 '(' nonnull_exprlist
')'
1160 |
'{' nonnull_exprlist
'}'
1161 { cp_pedwarn
("old style placement syntax, use () instead");
1166 '(' nonnull_exprlist
')'
1172 cp_error
("`%T' is not a valid expression", $2.t
);
1173 $$
= error_mark_node
;
1175 /* GNU extension so people can use initializer lists. Note that
1176 this alters the meaning of `new int = 1', which was previously
1177 syntactically valid but semantically invalid. */
1181 pedwarn
("ANSI C++ forbids initialization of new expression with `='");
1182 if
(TREE_CODE
($2) != TREE_LIST
1183 && TREE_CODE
($2) != CONSTRUCTOR
)
1184 $$
= build_expr_list
(NULL_TREE
, $2);
1190 /* This is necessary to postpone reduction of `int ((int)(int)(int))'. */
1192 '(' type_id
')' %prec EMPTY
1193 { $2.t
= finish_parmlist
(build_tree_list
(NULL_TREE
, $2.t
), 0);
1194 $$
= make_call_declarator
(NULL_TREE
, $2.t
, NULL_TREE
, NULL_TREE
);
1195 check_for_new_type
("cast", $2); }
1196 | regcast_or_absdcl
'(' type_id
')' %prec EMPTY
1197 { $3.t
= finish_parmlist
(build_tree_list
(NULL_TREE
, $3.t
), 0);
1198 $$
= make_call_declarator
($$
, $3.t
, NULL_TREE
, NULL_TREE
);
1199 check_for_new_type
("cast", $3); }
1204 | regcast_or_absdcl unary_expr %prec UNARY
1205 { $$
= reparse_absdcl_as_casts
($$
, $2); }
1206 | regcast_or_absdcl
'{' initlist maybecomma
'}' %prec UNARY
1208 tree init
= build_nt
(CONSTRUCTOR
, NULL_TREE
,
1211 pedwarn
("ANSI C++ forbids constructor-expressions");
1212 /* Indicate that this was a GNU C constructor expression. */
1213 TREE_HAS_CONSTRUCTOR
(init
) = 1;
1215 $$
= reparse_absdcl_as_casts
($$
, init
);
1221 /* Handle general members. */
1222 | expr_no_commas POINTSAT_STAR expr_no_commas
1223 { $$
= build_x_binary_op
(MEMBER_REF
, $$
, $3); }
1224 | expr_no_commas DOT_STAR expr_no_commas
1225 { $$
= build_m_component_ref
($$
, $3); }
1226 | expr_no_commas
'+' expr_no_commas
1227 { $$
= build_x_binary_op
($2, $$
, $3); }
1228 | expr_no_commas
'-' expr_no_commas
1229 { $$
= build_x_binary_op
($2, $$
, $3); }
1230 | expr_no_commas
'*' expr_no_commas
1231 { $$
= build_x_binary_op
($2, $$
, $3); }
1232 | expr_no_commas
'/' expr_no_commas
1233 { $$
= build_x_binary_op
($2, $$
, $3); }
1234 | expr_no_commas
'%' expr_no_commas
1235 { $$
= build_x_binary_op
($2, $$
, $3); }
1236 | expr_no_commas LSHIFT expr_no_commas
1237 { $$
= build_x_binary_op
($2, $$
, $3); }
1238 | expr_no_commas RSHIFT expr_no_commas
1239 { $$
= build_x_binary_op
($2, $$
, $3); }
1240 | expr_no_commas ARITHCOMPARE expr_no_commas
1241 { $$
= build_x_binary_op
($2, $$
, $3); }
1242 | expr_no_commas
'<' expr_no_commas
1243 { $$
= build_x_binary_op
(LT_EXPR
, $$
, $3); }
1244 | expr_no_commas
'>' expr_no_commas
1245 { $$
= build_x_binary_op
(GT_EXPR
, $$
, $3); }
1246 | expr_no_commas EQCOMPARE expr_no_commas
1247 { $$
= build_x_binary_op
($2, $$
, $3); }
1248 | expr_no_commas MIN_MAX expr_no_commas
1249 { $$
= build_x_binary_op
($2, $$
, $3); }
1250 | expr_no_commas
'&' expr_no_commas
1251 { $$
= build_x_binary_op
($2, $$
, $3); }
1252 | expr_no_commas
'|' expr_no_commas
1253 { $$
= build_x_binary_op
($2, $$
, $3); }
1254 | expr_no_commas
'^' expr_no_commas
1255 { $$
= build_x_binary_op
($2, $$
, $3); }
1256 | expr_no_commas ANDAND expr_no_commas
1257 { $$
= build_x_binary_op
(TRUTH_ANDIF_EXPR
, $$
, $3); }
1258 | expr_no_commas OROR expr_no_commas
1259 { $$
= build_x_binary_op
(TRUTH_ORIF_EXPR
, $$
, $3); }
1260 | expr_no_commas
'?' xexpr
':' expr_no_commas
1261 { $$
= build_x_conditional_expr
($$
, $3, $5); }
1262 | expr_no_commas
'=' expr_no_commas
1263 { $$
= build_x_modify_expr
($$
, NOP_EXPR
, $3);
1264 if
($$
!= error_mark_node
)
1265 C_SET_EXP_ORIGINAL_CODE
($$
, MODIFY_EXPR
); }
1266 | expr_no_commas ASSIGN expr_no_commas
1267 { $$
= build_x_modify_expr
($$
, $2, $3); }
1269 { $$
= build_throw
(NULL_TREE
); }
1270 | THROW expr_no_commas
1271 { $$
= build_throw
($2); }
1272 /* These extensions are not defined. The second arg to build_m_component_ref
1273 is old, build_m_component_ref now does an implicit
1274 build_indirect_ref (x, NULL_PTR) on the second argument.
1275 | object '&' expr_no_commas %prec UNARY
1276 { $$ = build_m_component_ref ($$, build_x_unary_op (ADDR_EXPR, $3)); }
1277 | object unop expr_no_commas %prec UNARY
1278 { $$ = build_m_component_ref ($$, build_x_unary_op ($2, $3)); }
1279 | object '(' type_id ')' expr_no_commas %prec UNARY
1280 { tree type = groktypename ($3.t);
1281 $$ = build_m_component_ref ($$, build_c_cast (type, $5)); }
1282 | object primary_no_id %prec UNARY
1283 { $$ = build_m_component_ref ($$, $2); }
1287 notype_unqualified_id:
1288 '~' see_typename identifier
1289 { $$
= build_parse_node
(BIT_NOT_EXPR
, $3); }
1290 |
'~' see_typename template_type
1291 { $$
= build_parse_node
(BIT_NOT_EXPR
, $3); }
1296 | NSNAME %prec EMPTY
1301 /* If lastiddecl is a TREE_LIST, it's a baselink, which
1302 means that we're in an expression like S::f<int>, so
1303 don't do_identifier; we only do that for unqualified
1305 if
(lastiddecl
&& TREE_CODE
(lastiddecl
) != TREE_LIST
)
1306 $$
= do_identifier
($
<ttype
>-1, 1, NULL_TREE
);
1312 PFUNCNAME
'<' do_id template_arg_list_opt template_close_bracket
1313 { $$
= lookup_template_function
($3, $4); }
1314 | operator_name
'<' do_id template_arg_list_opt template_close_bracket
1315 { $$
= lookup_template_function
($3, $4); }
1319 TEMPLATE identifier
'<' template_arg_list_opt template_close_bracket
1320 { $$
= lookup_template_function
($2, $4); }
1321 | TEMPLATE PFUNCNAME
'<' template_arg_list_opt template_close_bracket
1322 { $$
= lookup_template_function
($2, $4); }
1323 | TEMPLATE operator_name
'<' template_arg_list_opt
1324 template_close_bracket
1325 { $$
= lookup_template_function
($2, $4); }
1329 notype_unqualified_id
1334 expr_or_declarator_intern:
1336 | attributes expr_or_declarator
1338 /* Provide support for '(' attributes '*' declarator ')'
1340 $$
= decl_tree_cons
($1, $2, NULL_TREE
);
1345 notype_unqualified_id
1346 |
'*' expr_or_declarator_intern %prec UNARY
1347 { $$
= build_parse_node
(INDIRECT_REF
, $2); }
1348 |
'&' expr_or_declarator_intern %prec UNARY
1349 { $$
= build_parse_node
(ADDR_EXPR
, $2); }
1350 |
'(' expr_or_declarator_intern
')'
1354 notype_template_declarator:
1355 IDENTIFIER
'<' template_arg_list_opt template_close_bracket
1356 { $$
= lookup_template_function
($1, $3); }
1357 | NSNAME
'<' template_arg_list template_close_bracket
1358 { $$
= lookup_template_function
($1, $3); }
1361 direct_notype_declarator:
1362 complex_direct_notype_declarator
1363 /* This precedence declaration is to prefer this reduce
1364 to the Koenig lookup shift in primary, below. I hate yacc. */
1365 | notype_unqualified_id %prec
'('
1366 | notype_template_declarator
1367 |
'(' expr_or_declarator_intern
')'
1368 { $$
= finish_decl_parsing
($2); }
1372 notype_unqualified_id
1374 if
(TREE_CODE
($1) == BIT_NOT_EXPR
)
1375 $$
= build_x_unary_op
(BIT_NOT_EXPR
, TREE_OPERAND
($1, 0));
1377 $$
= finish_id_expr
($1);
1383 $$
= combine_strings
($$
);
1384 /* combine_strings doesn't set up TYPE_MAIN_VARIANT of
1385 a const array the way we want, so fix it. */
1386 if
(flag_const_strings
)
1387 TREE_TYPE
($$
) = build_cplus_array_type
1388 (TREE_TYPE
(TREE_TYPE
($$
)),
1389 TYPE_DOMAIN
(TREE_TYPE
($$
)));
1392 { $$
= finish_parenthesized_expr
($2); }
1393 |
'(' expr_or_declarator_intern
')'
1394 { $2 = reparse_decl_as_expr
(NULL_TREE
, $2);
1395 $$
= finish_parenthesized_expr
($2); }
1397 { $$
= error_mark_node
; }
1399 { tree scope
= current_scope
();
1400 if
(!scope || TREE_CODE
(scope
) != FUNCTION_DECL
)
1402 error ("braced-group within expression allowed only inside a function");
1406 pedwarn
("ANSI C++ forbids braced-groups within expressions");
1407 $
<ttype
>$
= begin_stmt_expr
();
1410 { $$
= finish_stmt_expr
($
<ttype
>2); }
1411 /* Koenig lookup support
1412 We could store lastiddecl in $1 to avoid another lookup,
1413 but that would result in many additional reduce/reduce conflicts. */
1414 | notype_unqualified_id
'(' nonnull_exprlist
')'
1415 { $$
= finish_call_expr
($1, $3, 1); }
1416 | notype_unqualified_id LEFT_RIGHT
1417 { $$
= finish_call_expr
($1, NULL_TREE
, 1); }
1418 | primary
'(' nonnull_exprlist
')'
1419 { $$
= finish_call_expr
($1, $3, 0); }
1420 | primary LEFT_RIGHT
1421 { $$
= finish_call_expr
($1, NULL_TREE
, 0); }
1422 | primary
'[' expr
']'
1423 { $$
= grok_array_decl
($$
, $3); }
1425 { $$
= finish_increment_expr
($1, POSTINCREMENT_EXPR
); }
1426 | primary MINUSMINUS
1427 { $$
= finish_increment_expr
($1, POSTDECREMENT_EXPR
); }
1428 /* C++ extensions */
1430 { $$
= finish_this_expr
(); }
1431 | CV_QUALIFIER
'(' nonnull_exprlist
')'
1433 /* This is a C cast in C++'s `functional' notation
1434 using the "implicit int" extension so that:
1435 `const (3)' is equivalent to `const int (3)'. */
1438 type
= hash_tree_cons
(NULL_TREE
, $1, NULL_TREE
);
1439 type
= groktypename
(build_decl_list
(type
, NULL_TREE
));
1440 $$
= build_functional_cast
(type
, $3);
1443 | DYNAMIC_CAST
'<' type_id
'>' '(' expr
')'
1444 { tree type
= groktypename
($3.t
);
1445 check_for_new_type
("dynamic_cast", $3);
1446 $$
= build_dynamic_cast
(type
, $6); }
1447 | STATIC_CAST
'<' type_id
'>' '(' expr
')'
1448 { tree type
= groktypename
($3.t
);
1449 check_for_new_type
("static_cast", $3);
1450 $$
= build_static_cast
(type
, $6); }
1451 | REINTERPRET_CAST
'<' type_id
'>' '(' expr
')'
1452 { tree type
= groktypename
($3.t
);
1453 check_for_new_type
("reinterpret_cast", $3);
1454 $$
= build_reinterpret_cast
(type
, $6); }
1455 | CONST_CAST
'<' type_id
'>' '(' expr
')'
1456 { tree type
= groktypename
($3.t
);
1457 check_for_new_type
("const_cast", $3);
1458 $$
= build_const_cast
(type
, $6); }
1459 | TYPEID
'(' expr
')'
1460 { $$
= build_x_typeid
($3); }
1461 | TYPEID
'(' type_id
')'
1462 { tree type
= groktypename
($3.t
);
1463 check_for_new_type
("typeid", $3);
1464 $$
= get_typeid
(TYPE_MAIN_VARIANT
(type
)); }
1465 | global_scope IDENTIFIER
1466 { $$
= do_scoped_id
($2, 1); }
1467 | global_scope template_id
1469 | global_scope operator_name
1471 got_scope
= NULL_TREE
;
1472 if
(TREE_CODE
($2) == IDENTIFIER_NODE
)
1473 $$
= do_scoped_id
($2, 1);
1477 | overqualified_id %prec HYPERUNARY
1478 { $$
= build_offset_ref
(OP0
($$
), OP1
($$
)); }
1479 | overqualified_id
'(' nonnull_exprlist
')'
1480 { $$
= finish_qualified_call_expr
($1, $3); }
1481 | overqualified_id LEFT_RIGHT
1482 { $$
= finish_qualified_call_expr
($1, NULL_TREE
); }
1483 | object object_template_id %prec UNARY
1485 $$
= build_x_component_ref
($$
, $2, NULL_TREE
, 1);
1487 | object object_template_id
'(' nonnull_exprlist
')'
1488 { $$
= finish_object_call_expr
($2, $1, $4); }
1489 | object object_template_id LEFT_RIGHT
1490 { $$
= finish_object_call_expr
($2, $1, NULL_TREE
); }
1491 | object unqualified_id %prec UNARY
1492 { $$
= build_x_component_ref
($$
, $2, NULL_TREE
, 1); }
1493 | object overqualified_id %prec UNARY
1494 { if
(processing_template_decl
)
1495 $$
= build_min_nt
(COMPONENT_REF
, $1, $2);
1497 $$
= build_object_ref
($$
, OP0
($2), OP1
($2)); }
1498 | object unqualified_id
'(' nonnull_exprlist
')'
1499 { $$
= finish_object_call_expr
($2, $1, $4); }
1500 | object unqualified_id LEFT_RIGHT
1501 { $$
= finish_object_call_expr
($2, $1, NULL_TREE
); }
1502 | object overqualified_id
'(' nonnull_exprlist
')'
1503 { $$
= finish_qualified_object_call_expr
($2, $1, $4); }
1504 | object overqualified_id LEFT_RIGHT
1505 { $$
= finish_qualified_object_call_expr
($2, $1, NULL_TREE
); }
1506 /* p->int::~int() is valid -- 12.4 */
1507 | object
'~' TYPESPEC LEFT_RIGHT
1508 { $$
= finish_pseudo_destructor_call_expr
($1, NULL_TREE
, $3); }
1509 | object TYPESPEC SCOPE
'~' TYPESPEC LEFT_RIGHT
1510 { $$
= finish_pseudo_destructor_call_expr
($1, $2, $5); }
1513 $$
= error_mark_node
;
1517 /* Not needed for now.
1523 { $$ = error_mark_node; }
1525 { if (current_function_decl == 0)
1527 error ("braced-group within expression allowed only inside a function");
1530 $<ttype>$ = expand_start_stmt_expr (); }
1533 pedwarn ("ANSI C++ forbids braced-groups within expressions");
1534 $$ = expand_end_stmt_expr ($<ttype>2); }
1535 | primary_no_id '(' nonnull_exprlist ')'
1536 { $$ = build_x_function_call ($$, $3, current_class_ref); }
1537 | primary_no_id LEFT_RIGHT
1538 { $$ = build_x_function_call ($$, NULL_TREE, current_class_ref); }
1539 | primary_no_id '[' expr ']'
1541 | primary_no_id PLUSPLUS
1542 { $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); }
1543 | primary_no_id MINUSMINUS
1544 { $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); }
1546 { goto do_scoped_id; }
1547 | SCOPE operator_name
1548 { if (TREE_CODE ($2) == IDENTIFIER_NODE)
1550 goto do_scoped_operator;
1559 { got_scope
= NULL_TREE
; $$
= 1; }
1565 | global_scope delete
1566 { got_scope
= NULL_TREE
; $$
= 1; }
1571 { $$
= boolean_true_node
; }
1573 { $$
= boolean_false_node
; }
1576 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
1580 { $$
= chainon
($$
, $2); }
1586 if
(! current_function_parms_stored
)
1587 store_parm_decls
();
1594 { got_object
= TREE_TYPE
($$
); }
1597 $$
= build_x_arrow
($$
);
1598 got_object
= TREE_TYPE
($$
);
1603 typespec initdecls
';'
1605 if
($1.t
&& IS_AGGR_TYPE_CODE
(TREE_CODE
($1.t
)))
1606 note_got_semicolon
($1.t
);
1608 | typed_declspecs initdecls
';'
1610 note_list_got_semicolon
($1.t
);
1612 | declmods notype_initdecls
';'
1614 | typed_declspecs
';'
1617 note_list_got_semicolon
($1.t
);
1620 { warning
("empty declaration"); }
1625 /* Any kind of declarator (thus, all declarators allowed
1626 after an explicit typespec). */
1629 after_type_declarator %prec EMPTY
1630 | notype_declarator %prec EMPTY
1633 /* This is necessary to postpone reduction of `int()()()()'. */
1635 LEFT_RIGHT %prec EMPTY
1636 { $$
= make_call_declarator
(NULL_TREE
, empty_parms
(),
1637 NULL_TREE
, NULL_TREE
); }
1638 | fcast_or_absdcl LEFT_RIGHT %prec EMPTY
1639 { $$
= make_call_declarator
($$
, empty_parms
(), NULL_TREE
,
1643 /* ANSI type-id (8.1) */
1645 typed_typespecs absdcl
1646 { $$.t
= build_decl_list
($1.t
, $2);
1647 $$.new_type_flag
= $1.new_type_flag
; }
1648 | nonempty_cv_qualifiers absdcl
1649 { $$.t
= build_decl_list
($1.t
, $2);
1650 $$.new_type_flag
= $1.new_type_flag
; }
1652 { $$.t
= build_decl_list
(build_decl_list
(NULL_TREE
, $1.t
),
1654 $$.new_type_flag
= $1.new_type_flag
; }
1655 | typed_typespecs %prec EMPTY
1656 { $$.t
= build_decl_list
($1.t
, NULL_TREE
);
1657 $$.new_type_flag
= $1.new_type_flag
; }
1658 | nonempty_cv_qualifiers %prec EMPTY
1659 { $$.t
= build_decl_list
($1.t
, NULL_TREE
);
1660 $$.new_type_flag
= $1.new_type_flag
; }
1663 /* Declspecs which contain at least one type specifier or typedef name.
1664 (Just `const' or `volatile' is not enough.)
1665 A typedef'd name following these is taken as a name to be declared.
1666 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1669 typed_typespecs %prec EMPTY
1675 { $$.t
= decl_tree_cons
(NULL_TREE
, $2.t
, $1);
1676 $$.new_type_flag
= $2.new_type_flag
; }
1677 | typespec reserved_declspecs %prec HYPERUNARY
1678 { $$.t
= decl_tree_cons
(NULL_TREE
, $1.t
, $2);
1679 $$.new_type_flag
= $1.new_type_flag
; }
1680 | typespec reserved_typespecquals reserved_declspecs
1681 { $$.t
= decl_tree_cons
(NULL_TREE
, $1.t
, chainon
($2, $3));
1682 $$.new_type_flag
= $1.new_type_flag
; }
1683 | declmods typespec reserved_declspecs
1684 { $$.t
= decl_tree_cons
(NULL_TREE
, $2.t
, chainon
($3, $1));
1685 $$.new_type_flag
= $2.new_type_flag
; }
1686 | declmods typespec reserved_typespecquals
1687 { $$.t
= decl_tree_cons
(NULL_TREE
, $2.t
, chainon
($3, $1));
1688 $$.new_type_flag
= $2.new_type_flag
; }
1689 | declmods typespec reserved_typespecquals reserved_declspecs
1690 { $$.t
= decl_tree_cons
(NULL_TREE
, $2.t
,
1691 chainon
($3, chainon
($4, $1)));
1692 $$.new_type_flag
= $2.new_type_flag
; }
1697 { if
(extra_warnings
)
1698 warning
("`%s' is not at beginning of declaration",
1699 IDENTIFIER_POINTER
($$
));
1700 $$
= build_decl_list
(NULL_TREE
, $$
); }
1701 | reserved_declspecs typespecqual_reserved
1702 { $$
= decl_tree_cons
(NULL_TREE
, $2.t
, $$
); }
1703 | reserved_declspecs SCSPEC
1704 { if
(extra_warnings
)
1705 warning
("`%s' is not at beginning of declaration",
1706 IDENTIFIER_POINTER
($2));
1707 $$
= decl_tree_cons
(NULL_TREE
, $2, $$
); }
1708 | reserved_declspecs attributes
1709 { $$
= decl_tree_cons
($2, NULL_TREE
, $1); }
1711 { $$
= decl_tree_cons
($1, NULL_TREE
, NULL_TREE
); }
1714 /* List of just storage classes and type modifiers.
1715 A declaration can start with just this, but then it cannot be used
1716 to redeclare a typedef-name.
1717 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1719 /* We use hash_tree_cons for lists of typeless declspecs so that they end
1720 up on a persistent obstack. Otherwise, they could appear at the
1721 beginning of something like
1723 static const struct { int foo () { } } b;
1725 and would be discarded after we finish compiling foo. We don't need to
1726 worry once we see a type. */
1729 nonempty_cv_qualifiers %prec EMPTY
1730 { $$
= $1.t
; TREE_STATIC
($$
) = 1; }
1732 { $$
= hash_tree_cons
(NULL_TREE
, $$
, NULL_TREE
); }
1733 | declmods CV_QUALIFIER
1734 { $$
= hash_tree_cons
(NULL_TREE
, $2, $$
);
1735 TREE_STATIC
($$
) = 1; }
1737 { if
(extra_warnings
&& TREE_STATIC
($$
))
1738 warning
("`%s' is not at beginning of declaration",
1739 IDENTIFIER_POINTER
($2));
1740 $$
= hash_tree_cons
(NULL_TREE
, $2, $$
);
1741 TREE_STATIC
($$
) = TREE_STATIC
($1); }
1742 | declmods attributes
1743 { $$
= hash_tree_cons
($2, NULL_TREE
, $1); }
1744 | attributes %prec EMPTY
1745 { $$
= hash_tree_cons
($1, NULL_TREE
, NULL_TREE
); }
1748 /* Used instead of declspecs where storage classes are not allowed
1749 (that is, for typenames and structure components).
1751 C++ can takes storage classes for structure components.
1752 Don't accept a typedef-name if anything but a modifier precedes it. */
1755 typespec %prec EMPTY
1756 { $$.t
= build_decl_list
(NULL_TREE
, $1.t
);
1757 $$.new_type_flag
= $1.new_type_flag
; }
1758 | nonempty_cv_qualifiers typespec
1759 { $$.t
= decl_tree_cons
(NULL_TREE
, $2.t
, $1.t
);
1760 $$.new_type_flag
= $2.new_type_flag
; }
1761 | typespec reserved_typespecquals
1762 { $$.t
= decl_tree_cons
(NULL_TREE
, $1.t
, $2);
1763 $$.new_type_flag
= $1.new_type_flag
; }
1764 | nonempty_cv_qualifiers typespec reserved_typespecquals
1765 { $$.t
= decl_tree_cons
(NULL_TREE
, $2.t
, chainon
($3, $1.t
));
1766 $$.new_type_flag
= $1.new_type_flag
; }
1769 reserved_typespecquals:
1770 typespecqual_reserved
1771 { $$
= build_decl_list
(NULL_TREE
, $1.t
); }
1772 | reserved_typespecquals typespecqual_reserved
1773 { $$
= decl_tree_cons
(NULL_TREE
, $2.t
, $1); }
1776 /* A typespec (but not a type qualifier).
1777 Once we have seen one of these in a declaration,
1778 if a typedef name appears then it is being redeclared. */
1782 | TYPESPEC %prec EMPTY
1783 { $$.t
= $1; $$.new_type_flag
= 0; }
1784 | complete_type_name
1785 { $$.t
= $1; $$.new_type_flag
= 0; }
1786 | TYPEOF
'(' expr
')'
1787 { $$.t
= finish_typeof
($3);
1788 $$.new_type_flag
= 0; }
1789 | TYPEOF
'(' type_id
')'
1790 { $$.t
= groktypename
($3.t
);
1791 $$.new_type_flag
= 0; }
1792 | SIGOF
'(' expr
')'
1793 { tree type
= TREE_TYPE
($3);
1795 $$.new_type_flag
= 0;
1796 if
(IS_AGGR_TYPE
(type
))
1798 sorry
("sigof type specifier");
1803 error ("`sigof' applied to non-aggregate expression");
1804 $$.t
= error_mark_node
;
1807 | SIGOF
'(' type_id
')'
1808 { tree type
= groktypename
($3.t
);
1810 $$.new_type_flag
= 0;
1811 if
(IS_AGGR_TYPE
(type
))
1813 sorry
("sigof type specifier");
1818 error("`sigof' applied to non-aggregate type");
1819 $$.t
= error_mark_node
;
1824 /* A typespec that is a reserved word, or a type qualifier. */
1826 typespecqual_reserved:
1828 { $$.t
= $1; $$.new_type_flag
= 0; }
1830 { $$.t
= $1; $$.new_type_flag
= 0; }
1836 | initdecls
',' initdcl
1837 { check_multiple_declarators
(); }
1842 | notype_initdecls
',' initdcl
1843 { check_multiple_declarators
(); }
1848 | nomods_initdecls
',' initdcl
1849 { check_multiple_declarators
(); }
1855 | asm_keyword
'(' string ')'
1856 { if
(TREE_CHAIN
($3)) $3 = combine_strings
($3); $$
= $3; }
1860 declarator maybeasm maybe_attribute
'='
1861 { $
<ttype
>$
= start_decl
($
<ttype
>1, current_declspecs
, 1,
1862 $3, prefix_attributes
); }
1864 /* Note how the declaration of the variable is in effect while its init is parsed! */
1865 { cp_finish_decl
($
<ttype
>5, $6, $2, LOOKUP_ONLYCONVERTING
); }
1866 | declarator maybeasm maybe_attribute
1867 { $
<ttype
>$
= start_decl
($
<ttype
>1, current_declspecs
, 0,
1868 $3, prefix_attributes
);
1869 cp_finish_decl
($
<ttype
>$
, NULL_TREE
, $2, 0); }
1872 /* This rule assumes a certain configuration of the parser stack.
1873 In particular, $0, the element directly before the beginning of
1874 this rule on the stack, must be a maybeasm. $-1 must be a
1875 declarator or notype_declarator. And $-2 must be some declmods
1876 or declspecs. We can't move the maybeasm into this rule because
1877 we need that reduce so we prefer fn.def1 when appropriate. */
1880 { parse_decl
($
<ttype
>-1, $
<ttype
>-2, $1, 1, &$
<ttype
>$
); }
1881 /* Note how the declaration of the variable is in effect
1882 while its init is parsed! */
1884 { cp_finish_decl
($
<ttype
>3, $4, $
<ttype
>0,
1885 LOOKUP_ONLYCONVERTING
); }
1888 parse_decl
($
<ttype
>-1, $
<ttype
>-2, $1, 0, &d
);
1889 cp_finish_decl
(d
, NULL_TREE
, $
<ttype
>0, 0); }
1893 declarator maybeasm initdcl0_innards
1898 notype_declarator maybeasm initdcl0_innards
1903 notype_declarator maybeasm
1904 { /* Set things up as initdcl0_innards expects. */
1909 | constructor_declarator maybeasm maybe_attribute
1911 parse_decl
($1, NULL_TREE
, $3, 0, &d
);
1912 cp_finish_decl
(d
, NULL_TREE
, $2, 0); }
1915 /* the * rules are dummies to accept the Apollo extended syntax
1916 so that the header files compile. */
1927 | attributes attribute
1928 { $$
= chainon
($1, $2); }
1932 ATTRIBUTE
'(' '(' attribute_list
')' ')'
1939 | attribute_list
',' attrib
1940 { $$
= chainon
($1, $3); }
1947 { $$
= build_tree_list
($1, NULL_TREE
); }
1948 | any_word
'(' IDENTIFIER
')'
1949 { $$
= build_tree_list
($1, build_tree_list
(NULL_TREE
, $3)); }
1950 | any_word
'(' IDENTIFIER
',' nonnull_exprlist
')'
1951 { $$
= build_tree_list
($1, tree_cons
(NULL_TREE
, $3, $5)); }
1952 | any_word
'(' nonnull_exprlist
')'
1953 { $$
= build_tree_list
($1, $3); }
1956 /* This still leaves out most reserved keywords,
1957 shouldn't we include them? */
1966 /* A nonempty list of identifiers, including typenames. */
1967 identifiers_or_typenames:
1969 { $$
= build_tree_list
(NULL_TREE
, $1); }
1970 | identifiers_or_typenames
',' identifier
1971 { $$
= chainon
($1, build_tree_list
(NULL_TREE
, $3)); }
1975 /* empty */ %prec EMPTY
1980 /* If we are processing a template, we don't want to expand this
1984 expr_no_commas %prec
'='
1986 { $$
= build_nt
(CONSTRUCTOR
, NULL_TREE
, NULL_TREE
);
1987 TREE_HAS_CONSTRUCTOR
($$
) = 1; }
1989 { $$
= build_nt
(CONSTRUCTOR
, NULL_TREE
, nreverse
($2));
1990 TREE_HAS_CONSTRUCTOR
($$
) = 1; }
1991 |
'{' initlist
',' '}'
1992 { $$
= build_nt
(CONSTRUCTOR
, NULL_TREE
, nreverse
($2));
1993 TREE_HAS_CONSTRUCTOR
($$
) = 1; }
1998 /* This chain is built in reverse order,
1999 and put in forward order where initlist is used. */
2002 { $$
= build_tree_list
(NULL_TREE
, $$
); }
2004 { $$
= tree_cons
(NULL_TREE
, $3, $$
); }
2005 /* These are for labeled elements. */
2006 |
'[' expr_no_commas
']' init
2007 { $$
= build_expr_list
($2, $4); }
2008 | identifier
':' init
2009 { $$
= build_expr_list
($$
, $3); }
2010 | initlist
',' identifier
':' init
2011 { $$
= tree_cons
($3, $5, $$
); }
2015 PRE_PARSED_FUNCTION_DECL
2016 { start_function
(NULL_TREE
, $1->fndecl
, NULL_TREE
,
2017 (SF_DEFAULT | SF_PRE_PARSED
2018 | SF_INCLASS_INLINE
));
2019 reinit_parse_for_function
(); }
2022 fn.defpen maybe_return_init ctor_initializer_opt compstmt_or_error
2024 expand_body
(finish_function
(lineno
, (int)$3 |
2));
2025 process_next_inline
($1);
2027 | fn.defpen maybe_return_init function_try_block
2029 expand_body
(finish_function
(lineno
, (int)$3 |
2));
2030 process_next_inline
($1);
2032 | fn.defpen maybe_return_init
error
2034 finish_function
(lineno
, 2);
2035 process_next_inline
($1); }
2040 | pending_inlines pending_inline eat_saved_input
2043 /* A regurgitated default argument. The value of DEFARG_MARKER will be
2044 the TREE_LIST node for the parameter in question. */
2046 DEFARG_MARKER expr_no_commas END_OF_SAVED_INPUT
2047 { replace_defarg
($1, $2); }
2048 | DEFARG_MARKER
error END_OF_SAVED_INPUT
2049 { replace_defarg
($1, error_mark_node
); }
2052 /* empty */ %prec EMPTY
2053 | pending_defargs defarg_again
2054 { do_pending_defargs
(); }
2055 | pending_defargs
error
2056 { do_pending_defargs
(); }
2061 { $
<ttype
>$
= current_enum_type
;
2062 current_enum_type
= start_enum
($2); }
2064 { $$.t
= finish_enum
(current_enum_type
);
2065 $$.new_type_flag
= 1;
2066 current_enum_type
= $
<ttype
>4;
2067 check_for_missing_semicolon
($$.t
); }
2069 { $
<ttype
>$
= current_enum_type
;
2070 current_enum_type
= start_enum
(make_anon_name
()); }
2072 { $$.t
= finish_enum
(current_enum_type
);
2073 $$.new_type_flag
= 1;
2074 current_enum_type
= $
<ttype
>3;
2075 check_for_missing_semicolon
($$.t
); }
2077 { $$.t
= xref_tag
(enum_type_node
, $2, 1);
2078 $$.new_type_flag
= 0; }
2079 | ENUM complex_type_name
2080 { $$.t
= xref_tag
(enum_type_node
, $2, 1);
2081 $$.new_type_flag
= 0; }
2082 | TYPENAME_KEYWORD typename_sub
2084 $$.new_type_flag
= 0;
2085 if
(!processing_template_decl
)
2086 cp_pedwarn
("using `typename' outside of template"); }
2087 /* C++ extensions, merged with C to avoid shift/reduce conflicts */
2089 { $1.t
= begin_class_definition
($1.t
); }
2090 opt.component_decl_list
'}' maybe_attribute
2094 if
(yychar == YYEMPTY
)
2096 semi
= yychar == ';';
2098 $
<ttype
>$
= finish_class_definition
($1.t
, $6, semi
,
2103 begin_inline_definitions
();
2107 finish_inline_definitions
();
2109 $$.new_type_flag
= 1;
2111 | class_head %prec EMPTY
2113 if
($1.new_type_flag
&& $1.t
!= error_mark_node
)
2114 pop_scope
(CP_DECL_CONTEXT
(TYPE_MAIN_DECL
($1.t
)));
2115 $$.new_type_flag
= 0;
2116 if
($1.t
== error_mark_node
)
2118 else if
(TYPE_BINFO
($1.t
) == NULL_TREE
)
2120 cp_error
("%T is not a class type", $1.t
);
2121 $$.t
= error_mark_node
;
2126 /* struct B: public A; is not accepted by the WP grammar. */
2127 if
(TYPE_BINFO_BASETYPES
($$.t
) && !TYPE_SIZE
($$.t
)
2128 && ! TYPE_BEING_DEFINED
($$.t
))
2129 cp_error
("base clause without member specification for `%#T'",
2143 { if
(pedantic
&& !in_system_header
)
2144 pedwarn
("comma at end of enumerator list"); }
2150 { error ("storage class specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER
($2)); }
2152 { error ("type specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER
($2)); }
2154 { error ("type qualifier `%s' not allowed after struct or class", IDENTIFIER_POINTER
($2)); }
2156 { error ("no body nor ';' separates two class, struct or union declarations"); }
2158 { $$
= build_decl_list
($2, $1); }
2161 named_class_head_sans_basetype:
2169 named_class_head_sans_basetype_defn:
2170 aggr identifier_defn %prec EMPTY
2171 { current_aggr
= $$
; $$
= $2; }
2172 | named_class_head_sans_basetype
'{'
2173 { yyungetc
('{', 1); }
2174 | named_class_head_sans_basetype
':'
2175 { yyungetc
(':', 1); }
2178 named_complex_class_head_sans_basetype:
2179 aggr nested_name_specifier identifier
2182 $$.t
= handle_class_head
($1, $2, $3);
2183 $$.new_type_flag
= 1;
2185 | aggr global_scope nested_name_specifier identifier
2188 $$.t
= handle_class_head
($1, $3, $4);
2189 $$.new_type_flag
= 1;
2191 | aggr global_scope identifier
2194 $$.t
= handle_class_head
($1, NULL_TREE
, $3);
2195 $$.new_type_flag
= 1;
2197 | aggr apparent_template_type
2201 $$.new_type_flag
= 0;
2203 | aggr nested_name_specifier apparent_template_type
2207 if
(CP_DECL_CONTEXT
($$.t
))
2208 push_scope
(CP_DECL_CONTEXT
($$.t
));
2209 $$.new_type_flag
= 1;
2214 named_class_head_sans_basetype %prec EMPTY
2216 $$.t
= xref_tag
(current_aggr
, $1, 1);
2217 $$.new_type_flag
= 0;
2219 | named_class_head_sans_basetype_defn
2220 { $
<ttype
>$
= xref_tag
(current_aggr
, $1, 0); }
2221 /* Class name is unqualified, so we look for base classes
2222 in the current scope. */
2223 maybe_base_class_list %prec EMPTY
2226 $$.new_type_flag
= 0;
2228 xref_basetypes
(current_aggr
, $1, $
<ttype
>2, $3);
2230 | named_complex_class_head_sans_basetype
2231 maybe_base_class_list
2233 if
($1.t
!= error_mark_node
)
2235 $$.t
= TREE_TYPE
($1.t
);
2236 $$.new_type_flag
= $1.new_type_flag
;
2237 if
(current_aggr
== union_type_node
2238 && TREE_CODE
($$.t
) != UNION_TYPE
)
2239 cp_pedwarn
("`union' tag used in declaring `%#T'",
2241 else if
(TREE_CODE
($$.t
) == UNION_TYPE
2242 && current_aggr
!= union_type_node
)
2243 cp_pedwarn
("non-`union' tag used in declaring `%#T'", $$
);
2244 else if
(TREE_CODE
($$.t
) == RECORD_TYPE
)
2245 /* We might be specializing a template with a different
2247 CLASSTYPE_DECLARED_CLASS
($$.t
)
2248 = (current_aggr
== class_type_node
);
2251 maybe_process_partial_specialization
($$.t
);
2252 xref_basetypes
(current_aggr
, $1.t
, $$.t
, $2);
2260 { $$
= xref_tag
($$
, make_anon_name
(), 0);
2261 yyungetc
('{', 1); }
2264 /* The tree output of this nonterminal a declarationf or the type
2265 named. If NEW_TYPE_FLAG is set, then the name used in this
2266 class-head was explicitly qualified, e.g.: `struct X::Y'. We have
2267 already called push_scope for X. */
2272 $$.new_type_flag
= 0;
2277 maybe_base_class_list:
2278 /* empty */ %prec EMPTY
2280 |
':' see_typename %prec EMPTY
2281 { yyungetc
(':', 1); $$
= NULL_TREE
; }
2282 |
':' see_typename base_class_list %prec EMPTY
2288 | base_class_list
',' see_typename base_class
2289 { $$
= chainon
($$
, $4); }
2294 { $$
= finish_base_specifier
(access_default_node
, $1); }
2295 | base_class_access_list see_typename base_class
.1
2296 { $$
= finish_base_specifier
($1, $3); }
2301 { if
($$
!= error_mark_node
) $$
= TYPE_MAIN_DECL
($1); }
2305 base_class_access_list:
2306 VISSPEC see_typename
2307 | SCSPEC see_typename
2308 { if
($1 != ridpointers
[(int)RID_VIRTUAL
])
2309 cp_error
("`%D' access", $1);
2310 $$
= access_default_virtual_node
; }
2311 | base_class_access_list VISSPEC see_typename
2313 if
($1 != access_default_virtual_node
)
2314 error ("multiple access specifiers");
2315 else if
($2 == access_public_node
)
2316 $$
= access_public_virtual_node
;
2317 else if
($2 == access_protected_node
)
2318 $$
= access_protected_virtual_node
;
2319 else
/* $2 == access_private_node */
2320 $$
= access_private_virtual_node
;
2322 | base_class_access_list SCSPEC see_typename
2323 { if
($2 != ridpointers
[(int)RID_VIRTUAL
])
2324 cp_error
("`%D' access", $2);
2325 else if
($$
== access_public_node
)
2326 $$
= access_public_virtual_node
;
2327 else if
($$
== access_protected_node
)
2328 $$
= access_protected_virtual_node
;
2329 else if
($$
== access_private_node
)
2330 $$
= access_private_virtual_node
;
2332 error ("multiple `virtual' specifiers");
2336 opt.component_decl_list
:
2337 | component_decl_list
2338 | opt.component_decl_list access_specifier component_decl_list
2339 | opt.component_decl_list access_specifier
2345 current_access_specifier
= $1;
2349 /* Note: we no longer warn about the semicolon after a component_decl_list.
2350 ARM $9.2 says that the semicolon is optional, and therefore allowed. */
2351 component_decl_list:
2354 finish_member_declaration
($1);
2356 | component_decl_list component_decl
2358 finish_member_declaration
($2);
2363 component_decl_1
';'
2364 | component_decl_1
'}'
2365 { error ("missing ';' before right brace");
2366 yyungetc
('}', 0); }
2367 /* C++: handle constructors, destructors and inline functions */
2368 /* note that INLINE is like a TYPESPEC */
2369 | fn.def2
':' /* base_init compstmt */
2370 { $$
= finish_method
($$
); }
2371 | fn.def2 TRY
/* base_init compstmt */
2372 { $$
= finish_method
($$
); }
2373 | fn.def2 RETURN_KEYWORD
/* base_init compstmt */
2374 { $$
= finish_method
($$
); }
2375 | fn.def2
'{' /* nodecls compstmt */
2376 { $$
= finish_method
($$
); }
2379 | extension component_decl
2382 | template_header component_decl
2385 $$
= finish_member_template_decl
($2);
2387 /* The component was already processed. */
2390 finish_template_decl
($1);
2392 | template_header typed_declspecs
';'
2394 $$
= finish_member_class_template
($2.t
);
2395 finish_template_decl
($1);
2400 /* Do not add a "typed_declspecs declarator" rule here for
2401 speed; we need to call grok_x_components for enums, so the
2402 speedup would be insignificant. */
2403 typed_declspecs components
2405 /* Most of the productions for component_decl only
2406 allow the creation of one new member, so we call
2407 finish_member_declaration in component_decl_list.
2408 For this rule and the next, however, there can be
2409 more than one member, e.g.:
2413 and we need the first member to be fully
2414 registered before the second is processed.
2415 Therefore, the rules for components take care of
2416 this processing. To avoid registering the
2417 components more than once, we send NULL_TREE up
2418 here; that lets finish_member_declaration know
2419 that there is nothing to do. */
2421 grok_x_components
($1.t
);
2424 | declmods notype_components
2427 grok_x_components
($1);
2430 | notype_declarator maybeasm maybe_attribute maybe_init
2431 { $$
= grokfield
($$
, NULL_TREE
, $4, $2,
2432 build_tree_list
($3, NULL_TREE
)); }
2433 | constructor_declarator maybeasm maybe_attribute maybe_init
2434 { $$
= grokfield
($$
, NULL_TREE
, $4, $2,
2435 build_tree_list
($3, NULL_TREE
)); }
2436 |
':' expr_no_commas
2437 { $$
= grokbitfield
(NULL_TREE
, NULL_TREE
, $2); }
2441 /* These rules introduce a reduce/reduce conflict; in
2442 typedef int foo, bar;
2446 should "A::foo" be declared as a function or "A::bar" as a data
2447 member? In other words, is "bar" an after_type_declarator or a
2449 | declmods component_constructor_declarator maybeasm maybe_attribute maybe_init
2450 { tree specs
, attrs
;
2451 split_specs_attrs
($1, &specs
, &attrs
);
2452 $$
= grokfield
($2, specs
, $5, $3,
2453 build_tree_list
($4, attrs
)); }
2454 | component_constructor_declarator maybeasm maybe_attribute maybe_init
2455 { $$
= grokfield
($$
, NULL_TREE
, $4, $2,
2456 build_tree_list
($3, NULL_TREE
)); }
2458 { $$
= do_class_using_decl
($1); }
2460 /* The case of exactly one component is handled directly by component_decl. */
2463 /* empty: possibly anonymous */
2465 | component_declarator0
2467 if
(PROCESSING_REAL_TEMPLATE_DECL_P
())
2468 $1 = finish_member_template_decl
($1);
2469 finish_member_declaration
($1);
2472 | components
',' component_declarator
2474 check_multiple_declarators
();
2475 if
(PROCESSING_REAL_TEMPLATE_DECL_P
())
2476 $3 = finish_member_template_decl
($3);
2477 finish_member_declaration
($3);
2483 /* empty: possibly anonymous */
2485 | notype_component_declarator0
2487 if
(PROCESSING_REAL_TEMPLATE_DECL_P
())
2488 $1 = finish_member_template_decl
($1);
2489 finish_member_declaration
($1);
2492 | notype_components
',' notype_component_declarator
2494 check_multiple_declarators
();
2495 if
(PROCESSING_REAL_TEMPLATE_DECL_P
())
2496 $3 = finish_member_template_decl
($3);
2497 finish_member_declaration
($3);
2502 component_declarator0:
2503 after_type_component_declarator0
2504 | notype_component_declarator0
2507 component_declarator:
2508 after_type_component_declarator
2509 | notype_component_declarator
2512 after_type_component_declarator0:
2513 after_type_declarator maybeasm maybe_attribute maybe_init
2514 { split_specs_attrs
($
<ttype
>0, ¤t_declspecs
,
2515 &prefix_attributes
);
2516 $
<ttype
>0 = current_declspecs
;
2517 $$
= grokfield
($$
, current_declspecs
, $4, $2,
2518 build_tree_list
($3, prefix_attributes
)); }
2519 | TYPENAME
':' expr_no_commas maybe_attribute
2520 { split_specs_attrs
($
<ttype
>0, ¤t_declspecs
,
2521 &prefix_attributes
);
2522 $
<ttype
>0 = current_declspecs
;
2523 $$
= grokbitfield
($$
, current_declspecs
, $3);
2524 cplus_decl_attributes
($$
, $4, prefix_attributes
); }
2527 notype_component_declarator0:
2528 notype_declarator maybeasm maybe_attribute maybe_init
2529 { split_specs_attrs
($
<ttype
>0, ¤t_declspecs
,
2530 &prefix_attributes
);
2531 $
<ttype
>0 = current_declspecs
;
2532 $$
= grokfield
($$
, current_declspecs
, $4, $2,
2533 build_tree_list
($3, prefix_attributes
)); }
2534 | constructor_declarator maybeasm maybe_attribute maybe_init
2535 { split_specs_attrs
($
<ttype
>0, ¤t_declspecs
,
2536 &prefix_attributes
);
2537 $
<ttype
>0 = current_declspecs
;
2538 $$
= grokfield
($$
, current_declspecs
, $4, $2,
2539 build_tree_list
($3, prefix_attributes
)); }
2540 | IDENTIFIER
':' expr_no_commas maybe_attribute
2541 { split_specs_attrs
($
<ttype
>0, ¤t_declspecs
,
2542 &prefix_attributes
);
2543 $
<ttype
>0 = current_declspecs
;
2544 $$
= grokbitfield
($$
, current_declspecs
, $3);
2545 cplus_decl_attributes
($$
, $4, prefix_attributes
); }
2546 |
':' expr_no_commas maybe_attribute
2547 { split_specs_attrs
($
<ttype
>0, ¤t_declspecs
,
2548 &prefix_attributes
);
2549 $
<ttype
>0 = current_declspecs
;
2550 $$
= grokbitfield
(NULL_TREE
, current_declspecs
, $2);
2551 cplus_decl_attributes
($$
, $3, prefix_attributes
); }
2554 after_type_component_declarator:
2555 after_type_declarator maybeasm maybe_attribute maybe_init
2556 { $$
= grokfield
($$
, current_declspecs
, $4, $2,
2557 build_tree_list
($3, prefix_attributes
)); }
2558 | TYPENAME
':' expr_no_commas maybe_attribute
2559 { $$
= grokbitfield
($$
, current_declspecs
, $3);
2560 cplus_decl_attributes
($$
, $4, prefix_attributes
); }
2563 notype_component_declarator:
2564 notype_declarator maybeasm maybe_attribute maybe_init
2565 { $$
= grokfield
($$
, current_declspecs
, $4, $2,
2566 build_tree_list
($3, prefix_attributes
)); }
2567 | IDENTIFIER
':' expr_no_commas maybe_attribute
2568 { $$
= grokbitfield
($$
, current_declspecs
, $3);
2569 cplus_decl_attributes
($$
, $4, prefix_attributes
); }
2570 |
':' expr_no_commas maybe_attribute
2571 { $$
= grokbitfield
(NULL_TREE
, current_declspecs
, $2);
2572 cplus_decl_attributes
($$
, $3, prefix_attributes
); }
2576 enumlist maybecomma_warn
2580 /* We chain the enumerators in reverse order.
2581 Because of the way enums are built, the order is
2582 insignificant. Take advantage of this fact. */
2586 | enumlist
',' enumerator
2591 { build_enumerator
($1, NULL_TREE
, current_enum_type
); }
2592 | identifier
'=' expr_no_commas
2593 { build_enumerator
($1, $3, current_enum_type
); }
2596 /* ANSI new-type-id (5.3.4) */
2598 type_specifier_seq new_declarator
2599 { $$.t
= build_decl_list
($1.t
, $2);
2600 $$.new_type_flag
= $1.new_type_flag
; }
2601 | type_specifier_seq %prec EMPTY
2602 { $$.t
= build_decl_list
($1.t
, NULL_TREE
);
2603 $$.new_type_flag
= $1.new_type_flag
; }
2604 /* GNU extension to allow arrays of arbitrary types with
2605 non-constant dimension. */
2606 |
'(' type_id
')' '[' expr
']'
2609 pedwarn
("ANSI C++ forbids array dimensions with parenthesized type in new");
2610 $$.t
= build_parse_node
(ARRAY_REF
, TREE_VALUE
($2.t
), $5);
2611 $$.t
= build_decl_list
(TREE_PURPOSE
($2.t
), $$.t
);
2612 $$.new_type_flag
= $2.new_type_flag
;
2617 /* empty */ %prec EMPTY
2619 | cv_qualifiers CV_QUALIFIER
2620 { $$
= decl_tree_cons
(NULL_TREE
, $2, $$
); }
2623 nonempty_cv_qualifiers:
2625 { $$.t
= hash_tree_cons
(NULL_TREE
, $1, NULL_TREE
);
2626 $$.new_type_flag
= 0; }
2627 | nonempty_cv_qualifiers CV_QUALIFIER
2628 { $$.t
= hash_tree_cons
(NULL_TREE
, $2, $1.t
);
2629 $$.new_type_flag
= $1.new_type_flag
; }
2632 /* These rules must follow the rules for function declarations
2633 and component declarations. That way, longer rules are preferred. */
2635 /* An expression which will not live on the momentary obstack. */
2637 '(' nonnull_exprlist
')'
2642 { $$
= empty_parms
(); }
2647 /* A declarator that is allowed only after an explicit typespec. */
2649 after_type_declarator_intern:
2650 after_type_declarator
2651 | attributes after_type_declarator
2653 /* Provide support for '(' attributes '*' declarator ')'
2655 $$
= decl_tree_cons
($1, $2, NULL_TREE
);
2659 /* may all be followed by prec '.' */
2660 after_type_declarator:
2661 '*' nonempty_cv_qualifiers after_type_declarator_intern %prec UNARY
2662 { $$
= make_pointer_declarator
($2.t
, $3); }
2663 |
'&' nonempty_cv_qualifiers after_type_declarator_intern %prec UNARY
2664 { $$
= make_reference_declarator
($2.t
, $3); }
2665 |
'*' after_type_declarator_intern %prec UNARY
2666 { $$
= make_pointer_declarator
(NULL_TREE
, $2); }
2667 |
'&' after_type_declarator_intern %prec UNARY
2668 { $$
= make_reference_declarator
(NULL_TREE
, $2); }
2669 | ptr_to_mem cv_qualifiers after_type_declarator_intern
2670 { tree arg
= make_pointer_declarator
($2, $3);
2671 $$
= build_parse_node
(SCOPE_REF
, $1, arg
);
2673 | direct_after_type_declarator
2676 direct_after_type_declarator:
2677 direct_after_type_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec
'.'
2678 { $$
= make_call_declarator
($$
, $2, $3, $4); }
2679 | direct_after_type_declarator
'[' expr
']'
2680 { $$
= build_parse_node
(ARRAY_REF
, $$
, $3); }
2681 | direct_after_type_declarator
'[' ']'
2682 { $$
= build_parse_node
(ARRAY_REF
, $$
, NULL_TREE
); }
2683 |
'(' after_type_declarator_intern
')'
2685 | nested_name_specifier type_name %prec EMPTY
2686 { push_nested_class
($1, 3);
2687 $$
= build_parse_node
(SCOPE_REF
, $$
, $2);
2688 TREE_COMPLEXITY
($$
) = current_class_depth
; }
2689 | type_name %prec EMPTY
2693 type_name %prec EMPTY
2695 if
(TREE_CODE
($1) == IDENTIFIER_NODE
)
2697 $$
= lookup_name
($1, 1);
2698 maybe_note_name_used_in_class
($1, $$
);
2703 | global_scope type_name
2705 if
(TREE_CODE
($2) == IDENTIFIER_NODE
)
2706 $$
= IDENTIFIER_GLOBAL_VALUE
($2);
2709 got_scope
= NULL_TREE
;
2716 | global_scope nested_type
2721 nested_name_specifier type_name %prec EMPTY
2722 { $$
= get_type_decl
($2); }
2725 /* A declarator allowed whether or not there has been
2726 an explicit typespec. These cannot redeclare a typedef-name. */
2728 notype_declarator_intern:
2730 | attributes notype_declarator
2732 /* Provide support for '(' attributes '*' declarator ')'
2734 $$
= decl_tree_cons
($1, $2, NULL_TREE
);
2739 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2740 { $$
= make_pointer_declarator
($2.t
, $3); }
2741 |
'&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2742 { $$
= make_reference_declarator
($2.t
, $3); }
2743 |
'*' notype_declarator_intern %prec UNARY
2744 { $$
= make_pointer_declarator
(NULL_TREE
, $2); }
2745 |
'&' notype_declarator_intern %prec UNARY
2746 { $$
= make_reference_declarator
(NULL_TREE
, $2); }
2747 | ptr_to_mem cv_qualifiers notype_declarator_intern
2748 { tree arg
= make_pointer_declarator
($2, $3);
2749 $$
= build_parse_node
(SCOPE_REF
, $1, arg
);
2751 | direct_notype_declarator
2754 complex_notype_declarator:
2755 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2756 { $$
= make_pointer_declarator
($2.t
, $3); }
2757 |
'&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2758 { $$
= make_reference_declarator
($2.t
, $3); }
2759 |
'*' complex_notype_declarator %prec UNARY
2760 { $$
= make_pointer_declarator
(NULL_TREE
, $2); }
2761 |
'&' complex_notype_declarator %prec UNARY
2762 { $$
= make_reference_declarator
(NULL_TREE
, $2); }
2763 | ptr_to_mem cv_qualifiers notype_declarator_intern
2764 { tree arg
= make_pointer_declarator
($2, $3);
2765 $$
= build_parse_node
(SCOPE_REF
, $1, arg
);
2767 | complex_direct_notype_declarator
2770 complex_direct_notype_declarator:
2771 direct_notype_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec
'.'
2772 { $$
= make_call_declarator
($$
, $2, $3, $4); }
2773 |
'(' complex_notype_declarator
')'
2775 | direct_notype_declarator
'[' expr
']'
2776 { $$
= build_parse_node
(ARRAY_REF
, $$
, $3); }
2777 | direct_notype_declarator
'[' ']'
2778 { $$
= build_parse_node
(ARRAY_REF
, $$
, NULL_TREE
); }
2779 | notype_qualified_id
2780 { enter_scope_of
($1); }
2781 | nested_name_specifier notype_template_declarator
2782 { got_scope
= NULL_TREE
;
2783 $$
= build_parse_node
(SCOPE_REF
, $1, $2);
2784 enter_scope_of
($$
);
2789 nested_name_specifier unqualified_id
2790 { got_scope
= NULL_TREE
;
2791 $$
= build_parse_node
(SCOPE_REF
, $$
, $2); }
2792 | nested_name_specifier object_template_id
2793 { got_scope
= NULL_TREE
;
2794 $$
= build_parse_node
(SCOPE_REF
, $1, $2); }
2797 notype_qualified_id:
2798 nested_name_specifier notype_unqualified_id
2799 { got_scope
= NULL_TREE
;
2800 $$
= build_parse_node
(SCOPE_REF
, $$
, $2); }
2801 | nested_name_specifier object_template_id
2802 { got_scope
= NULL_TREE
;
2803 $$
= build_parse_node
(SCOPE_REF
, $1, $2); }
2808 | global_scope notype_qualified_id
2813 typespec
'(' nonnull_exprlist
')'
2814 { $$
= build_functional_cast
($1.t
, $3); }
2815 | typespec
'(' expr_or_declarator_intern
')'
2816 { $$
= reparse_decl_as_expr
($1.t
, $3); }
2817 | typespec fcast_or_absdcl %prec EMPTY
2818 { $$
= reparse_absdcl_as_expr
($1.t
, $2); }
2823 | template_type %prec EMPTY
2826 nested_name_specifier:
2827 nested_name_specifier_1
2828 | nested_name_specifier nested_name_specifier_1
2830 | nested_name_specifier TEMPLATE explicit_template_type SCOPE
2832 = make_typename_type
($1, $3, /*complain=*/1); }
2835 /* Why the @#$%^& do type_name and notype_identifier need to be expanded
2836 inline here?!? (jason) */
2837 nested_name_specifier_1:
2840 if
(TREE_CODE
($1) == IDENTIFIER_NODE
)
2843 maybe_note_name_used_in_class
($1, $$
);
2846 complete_type
(TYPE_MAIN_VARIANT
(TREE_TYPE
($$
)));
2850 if
(TREE_CODE
($1) == IDENTIFIER_NODE
)
2852 got_scope
= $$
= TREE_TYPE
($$
);
2856 if
(TREE_CODE
($$
) == IDENTIFIER_NODE
)
2860 | template_type SCOPE
2861 { got_scope
= $$
= complete_type
(TREE_TYPE
($1)); }
2862 /* These break 'const i;'
2866 cp_error ("`%D' is not an aggregate typedef",
2867 lastiddecl ? lastiddecl : $$);
2868 $$ = error_mark_node;
2871 { goto failed_scope; } */
2876 | global_scope typename_sub0
2881 typename_sub1 identifier %prec EMPTY
2883 if
(TREE_CODE_CLASS
(TREE_CODE
($1)) == 't')
2884 $$
= make_typename_type
($1, $2, /*complain=*/1);
2885 else if
(TREE_CODE
($2) == IDENTIFIER_NODE
)
2886 cp_error
("`%T' is not a class or namespace", $2);
2890 if
(TREE_CODE
($$
) == TYPE_DECL
)
2891 $$
= TREE_TYPE
($$
);
2894 | typename_sub1 template_type %prec EMPTY
2895 { $$
= TREE_TYPE
($2); }
2896 | typename_sub1 explicit_template_type %prec EMPTY
2897 { $$
= make_typename_type
($1, $2, /*complain=*/1); }
2898 | typename_sub1 TEMPLATE explicit_template_type %prec EMPTY
2899 { $$
= make_typename_type
($1, $3, /*complain=*/1); }
2905 if
(TREE_CODE
($1) == IDENTIFIER_NODE
)
2906 cp_error
("`%T' is not a class or namespace", $1);
2908 | typename_sub1 typename_sub2
2910 if
(TREE_CODE_CLASS
(TREE_CODE
($1)) == 't')
2911 $$
= make_typename_type
($1, $2, /*complain=*/1);
2912 else if
(TREE_CODE
($2) == IDENTIFIER_NODE
)
2913 cp_error
("`%T' is not a class or namespace", $2);
2917 if
(TREE_CODE
($$
) == TYPE_DECL
)
2918 $$
= TREE_TYPE
($$
);
2921 | typename_sub1 explicit_template_type SCOPE
2923 = make_typename_type
($1, $2, /*complain=*/1); }
2924 | typename_sub1 TEMPLATE explicit_template_type SCOPE
2926 = make_typename_type
($1, $3, /*complain=*/1); }
2932 if
(TREE_CODE
($1) != IDENTIFIER_NODE
)
2935 /* Retrieve the type for the identifier, which might involve
2936 some computation. */
2937 got_scope
= $$
= complete_type
(IDENTIFIER_TYPE_VALUE
($1));
2939 if
($$
== error_mark_node
)
2940 cp_error
("`%T' is not a class or namespace", $1);
2944 if
(TREE_CODE
($1) != IDENTIFIER_NODE
)
2946 got_scope
= $$
= complete_type
(TREE_TYPE
($$
));
2948 | template_type SCOPE
2949 { got_scope
= $$
= complete_type
(TREE_TYPE
($$
)); }
2954 if
(TREE_CODE
($$
) == IDENTIFIER_NODE
)
2960 explicit_template_type:
2961 identifier
'<' template_arg_list_opt template_close_bracket
2962 { $$
= build_min_nt
(TEMPLATE_ID_EXPR
, $1, $3); }
2966 global_scope type_name
2968 if
(TREE_CODE
($2) == IDENTIFIER_NODE
)
2969 $$
= IDENTIFIER_GLOBAL_VALUE
($2);
2972 got_scope
= NULL_TREE
;
2975 | global_scope nested_type
2980 nested_name_specifier
'*'
2981 { got_scope
= NULL_TREE
; }
2982 | global_scope nested_name_specifier
'*'
2983 { $$
= $2; got_scope
= NULL_TREE
; }
2986 /* All uses of explicit global scope must go through this nonterminal so
2987 that got_scope will be set before yylex is called to get the next token. */
2990 { got_scope
= void_type_node
; }
2993 /* ANSI new-declarator (5.3.4) */
2995 '*' cv_qualifiers new_declarator
2996 { $$
= make_pointer_declarator
($2, $3); }
2997 |
'*' cv_qualifiers %prec EMPTY
2998 { $$
= make_pointer_declarator
($2, NULL_TREE
); }
2999 |
'&' cv_qualifiers new_declarator %prec EMPTY
3000 { $$
= make_reference_declarator
($2, $3); }
3001 |
'&' cv_qualifiers %prec EMPTY
3002 { $$
= make_reference_declarator
($2, NULL_TREE
); }
3003 | ptr_to_mem cv_qualifiers %prec EMPTY
3004 { tree arg
= make_pointer_declarator
($2, NULL_TREE
);
3005 $$
= build_parse_node
(SCOPE_REF
, $1, arg
);
3007 | ptr_to_mem cv_qualifiers new_declarator
3008 { tree arg
= make_pointer_declarator
($2, $3);
3009 $$
= build_parse_node
(SCOPE_REF
, $1, arg
);
3011 | direct_new_declarator %prec EMPTY
3014 /* ANSI direct-new-declarator (5.3.4) */
3015 direct_new_declarator:
3017 { $$
= build_parse_node
(ARRAY_REF
, NULL_TREE
, $2); }
3018 | direct_new_declarator
'[' expr
']'
3019 { $$
= build_parse_node
(ARRAY_REF
, $$
, $3); }
3026 /* Provide support for '(' attributes '*' declarator ')'
3028 $$
= decl_tree_cons
($1, $2, NULL_TREE
);
3032 /* ANSI abstract-declarator (8.1) */
3034 '*' nonempty_cv_qualifiers absdcl_intern
3035 { $$
= make_pointer_declarator
($2.t
, $3); }
3037 { $$
= make_pointer_declarator
(NULL_TREE
, $2); }
3038 |
'*' nonempty_cv_qualifiers %prec EMPTY
3039 { $$
= make_pointer_declarator
($2.t
, NULL_TREE
); }
3041 { $$
= make_pointer_declarator
(NULL_TREE
, NULL_TREE
); }
3042 |
'&' nonempty_cv_qualifiers absdcl_intern
3043 { $$
= make_reference_declarator
($2.t
, $3); }
3045 { $$
= make_reference_declarator
(NULL_TREE
, $2); }
3046 |
'&' nonempty_cv_qualifiers %prec EMPTY
3047 { $$
= make_reference_declarator
($2.t
, NULL_TREE
); }
3049 { $$
= make_reference_declarator
(NULL_TREE
, NULL_TREE
); }
3050 | ptr_to_mem cv_qualifiers %prec EMPTY
3051 { tree arg
= make_pointer_declarator
($2, NULL_TREE
);
3052 $$
= build_parse_node
(SCOPE_REF
, $1, arg
);
3054 | ptr_to_mem cv_qualifiers absdcl_intern
3055 { tree arg
= make_pointer_declarator
($2, $3);
3056 $$
= build_parse_node
(SCOPE_REF
, $1, arg
);
3058 | direct_abstract_declarator %prec EMPTY
3061 /* ANSI direct-abstract-declarator (8.1) */
3062 direct_abstract_declarator:
3063 '(' absdcl_intern
')'
3065 /* `(typedef)1' is `int'. */
3066 | direct_abstract_declarator
'(' parmlist
')' cv_qualifiers exception_specification_opt %prec
'.'
3067 { $$
= make_call_declarator
($$
, $3, $5, $6); }
3068 | direct_abstract_declarator LEFT_RIGHT cv_qualifiers exception_specification_opt %prec
'.'
3069 { $$
= make_call_declarator
($$
, empty_parms
(), $3, $4); }
3070 | direct_abstract_declarator
'[' expr
']' %prec
'.'
3071 { $$
= build_parse_node
(ARRAY_REF
, $$
, $3); }
3072 | direct_abstract_declarator
'[' ']' %prec
'.'
3073 { $$
= build_parse_node
(ARRAY_REF
, $$
, NULL_TREE
); }
3074 |
'(' complex_parmlist
')' cv_qualifiers exception_specification_opt %prec
'.'
3075 { $$
= make_call_declarator
(NULL_TREE
, $2, $4, $5); }
3076 | regcast_or_absdcl cv_qualifiers exception_specification_opt %prec
'.'
3077 { set_quals_and_spec
($$
, $2, $3); }
3078 | fcast_or_absdcl cv_qualifiers exception_specification_opt %prec
'.'
3079 { set_quals_and_spec
($$
, $2, $3); }
3080 |
'[' expr
']' %prec
'.'
3081 { $$
= build_parse_node
(ARRAY_REF
, NULL_TREE
, $2); }
3083 { $$
= build_parse_node
(ARRAY_REF
, NULL_TREE
, NULL_TREE
); }
3086 /* For C++, decls and stmts can be intermixed, so we don't need to
3087 have a special rule that won't start parsing the stmt section
3088 until we have a stmt that parses without errors. */
3101 /* Read zero or more forward-declarations for labels
3102 that nested functions can jump to. */
3107 pedwarn
("ANSI C++ forbids label declarations"); }
3112 | label_decls label_decl
3116 LABEL identifiers_or_typenames
';'
3120 finish_label_decl
(TREE_VALUE
($2));
3121 $2 = TREE_CHAIN
($2);
3126 /* This is the body of a function definition.
3127 It causes syntax errors to ignore to the next openbrace. */
3136 { $
<ttype
>$
= begin_compound_stmt
(0); }
3138 { $$
= finish_compound_stmt
(0, $
<ttype
>2); }
3144 $
<ttype
>$
= begin_if_stmt
();
3145 cond_stmt_keyword
= "if";
3148 { finish_if_stmt_cond
($3, $
<ttype
>2); }
3149 implicitly_scoped_stmt
3150 { $
<ttype
>$
= finish_then_clause
($
<ttype
>2); }
3153 implicitly_scoped_stmt:
3155 |
{ $
<ttype
>$
= begin_compound_stmt
(0); }
3157 { $$
= finish_compound_stmt
(0, $
<ttype
>1); }
3170 { finish_expr_stmt
($1); }
3172 { begin_else_clause
(); }
3173 implicitly_scoped_stmt
3175 finish_else_clause
($
<ttype
>1);
3178 | simple_if %prec IF
3179 { finish_if_stmt
(); }
3182 $
<ttype
>$
= begin_while_stmt
();
3183 cond_stmt_keyword
= "while";
3186 { finish_while_stmt_cond
($3, $
<ttype
>2); }
3188 { finish_while_stmt
($
<ttype
>2); }
3190 { $
<ttype
>$
= begin_do_stmt
(); }
3191 implicitly_scoped_stmt WHILE
3193 finish_do_body
($
<ttype
>2);
3194 cond_stmt_keyword
= "do";
3196 paren_expr_or_null
';'
3197 { finish_do_stmt
($6, $
<ttype
>2); }
3199 { $
<ttype
>$
= begin_for_stmt
(); }
3200 '(' for.init.statement
3201 { finish_for_init_stmt
($
<ttype
>2); }
3203 { finish_for_cond
($6, $
<ttype
>2); }
3205 { finish_for_expr
($9, $
<ttype
>2); }
3207 { finish_for_stmt
($9, $
<ttype
>2); }
3209 { $
<ttype
>$
= begin_switch_stmt
(); }
3211 { finish_switch_cond
($4, $
<ttype
>2); }
3212 implicitly_scoped_stmt
3213 { finish_switch_stmt
($4, $
<ttype
>2); }
3214 | CASE expr_no_commas
':'
3215 { finish_case_label
($2, NULL_TREE
); }
3217 | CASE expr_no_commas ELLIPSIS expr_no_commas
':'
3218 { finish_case_label
($2, $4); }
3221 { finish_case_label
(NULL_TREE
, NULL_TREE
); }
3224 { finish_break_stmt
(); }
3226 { finish_continue_stmt
(); }
3227 | RETURN_KEYWORD
';'
3228 { finish_return_stmt
(NULL_TREE
); }
3229 | RETURN_KEYWORD expr
';'
3230 { finish_return_stmt
($2); }
3231 | asm_keyword maybe_cv_qualifier
'(' string ')' ';'
3233 finish_asm_stmt
($2, $4, NULL_TREE
, NULL_TREE
,
3236 /* This is the case with just output operands. */
3237 | asm_keyword maybe_cv_qualifier
'(' string ':' asm_operands
')' ';'
3239 finish_asm_stmt
($2, $4, $6, NULL_TREE
,
3242 /* This is the case with input operands as well. */
3243 | asm_keyword maybe_cv_qualifier
'(' string ':' asm_operands
':' asm_operands
')' ';'
3244 { finish_asm_stmt
($2, $4, $6, $8, NULL_TREE
); }
3245 /* This is the case with clobbered registers as well. */
3246 | asm_keyword maybe_cv_qualifier
'(' string ':' asm_operands
':'
3247 asm_operands
':' asm_clobbers
')' ';'
3248 { finish_asm_stmt
($2, $4, $6, $8, $10); }
3252 pedwarn
("ANSI C++ forbids computed gotos");
3253 finish_goto_stmt
($3);
3255 | GOTO identifier
';'
3256 { finish_goto_stmt
($2); }
3259 { error ("label must be followed by statement");
3260 yyungetc
('}', 0); }
3265 | namespace_using_decl
3266 { do_local_using_decl
($1); }
3272 { $
<ttype
>$
= begin_function_try_block
(); }
3273 ctor_initializer_opt compstmt
3274 { finish_function_try_block
($
<ttype
>2); }
3277 finish_function_handler_sequence
($
<ttype
>2);
3284 { $
<ttype
>$
= begin_try_block
(); }
3286 { finish_try_block
($
<ttype
>2); }
3288 { finish_handler_sequence
($
<ttype
>2); }
3293 | handler_seq handler
3298 { $
<ttype
>$
= begin_handler
(); }
3300 { $
<ttype
>$
= finish_handler_parms
($3, $
<ttype
>2); }
3302 { finish_handler
($
<ttype
>4, $
<ttype
>2); }
3306 typed_typespecs %prec EMPTY
3307 | nonempty_cv_qualifiers %prec EMPTY
3313 /* This doesn't allow reference parameters, the below does.
3314 | '(' type_specifier_seq absdcl ')'
3315 { check_for_new_type ("inside exception declarations", $2);
3316 expand_start_catch_block ($2.t, $3); }
3317 | '(' type_specifier_seq ')'
3318 { check_for_new_type ("inside exception declarations", $2);
3319 expand_start_catch_block ($2.t, NULL_TREE); }
3320 | '(' type_specifier_seq notype_declarator ')'
3321 { check_for_new_type ("inside exception declarations", $2);
3322 expand_start_catch_block ($2.t, $3); }
3323 | '(' typed_typespecs after_type_declarator ')'
3324 { check_for_new_type ("inside exception declarations", $2);
3325 expand_start_catch_block ($2.t, $3); }
3326 This allows reference parameters... */
3329 check_for_new_type
("inside exception declarations", $2);
3330 $$
= start_handler_parms
(TREE_PURPOSE
($2.t
),
3337 { finish_label_stmt
($1); }
3339 { finish_label_stmt
($1); }
3341 { finish_label_stmt
($1); }
3343 { finish_label_stmt
($1); }
3348 { finish_expr_stmt
($1); }
3352 pedwarn
("ANSI C++ forbids compound statements inside for initializations");
3356 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
3360 { emit_line_note
(input_filename
, lineno
);
3363 { emit_line_note
(input_filename
, lineno
); }
3374 /* These are the operands other than the first string and colon
3375 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
3379 | nonnull_asm_operands
3382 nonnull_asm_operands:
3384 | nonnull_asm_operands
',' asm_operand
3385 { $$
= chainon
($$
, $3); }
3390 { $$
= build_tree_list
($$
, $3); }
3395 { $$
= tree_cons
(NULL_TREE
, $$
, NULL_TREE
); }
3396 | asm_clobbers
',' STRING
3397 { $$
= tree_cons
(NULL_TREE
, $3, $$
); }
3400 /* This is what appears inside the parens in a function declarator.
3401 Its value is represented in the format that grokdeclarator expects.
3403 In C++, declaring a function with no parameters
3404 means that that function takes *no* parameters. */
3413 { $$
= finish_parmlist
(build_tree_list
(NULL_TREE
, $1.t
), 0);
3414 check_for_new_type
("inside parameter list", $1); }
3417 /* This nonterminal does not include the common sequence '(' type_id ')',
3418 as it is ambiguous and must be disambiguated elsewhere. */
3421 { $$
= finish_parmlist
($$
, 0); }
3422 | parms_comma ELLIPSIS
3423 { $$
= finish_parmlist
($1, 1); }
3424 /* C++ allows an ellipsis without a separating ',' */
3426 { $$
= finish_parmlist
($1, 1); }
3428 { $$
= finish_parmlist
(build_tree_list
(NULL_TREE
,
3431 { $$
= finish_parmlist
(NULL_TREE
, 1); }
3434 /* This helps us recover from really nasty
3435 parse errors, for example, a missing right
3437 yyerror ("possibly missing ')'");
3438 $$
= finish_parmlist
($1, 0);
3444 /* This helps us recover from really nasty
3445 parse errors, for example, a missing right
3447 yyerror ("possibly missing ')'");
3448 $$
= finish_parmlist
(build_tree_list
(NULL_TREE
,
3455 /* A default argument to a */
3458 { maybe_snarf_defarg
(); }
3468 /* A nonempty list of parameter declarations or type names. */
3471 { check_for_new_type
("in a parameter list", $1);
3472 $$
= build_tree_list
(NULL_TREE
, $1.t
); }
3474 { check_for_new_type
("in a parameter list", $1);
3475 $$
= build_tree_list
($2, $1.t
); }
3476 | parms_comma full_parm
3477 { check_for_new_type
("in a parameter list", $2);
3478 $$
= chainon
($$
, $2.t
); }
3479 | parms_comma bad_parm
3480 { $$
= chainon
($$
, build_tree_list
(NULL_TREE
, $2)); }
3481 | parms_comma bad_parm
'=' init
3482 { $$
= chainon
($$
, build_tree_list
($4, $2)); }
3488 { check_for_new_type
("in a parameter list", $1);
3489 $$
= build_tree_list
(NULL_TREE
, $1.t
); }
3492 /* A single parameter declaration or parameter type name,
3493 as found in a parmlist. */
3495 /* Here we expand typed_declspecs inline to avoid mis-parsing of
3496 TYPESPEC IDENTIFIER. */
3497 typed_declspecs1 declarator
3498 { tree specs
= strip_attrs
($1.t
);
3499 $$.new_type_flag
= $1.new_type_flag
;
3500 $$.t
= build_tree_list
(specs
, $2); }
3501 | typed_typespecs declarator
3502 { $$.t
= build_tree_list
($1.t
, $2);
3503 $$.new_type_flag
= $1.new_type_flag
; }
3504 | typespec declarator
3505 { $$.t
= build_tree_list
(build_decl_list
(NULL_TREE
, $1.t
),
3507 $$.new_type_flag
= $1.new_type_flag
; }
3508 | typed_declspecs1 absdcl
3509 { tree specs
= strip_attrs
($1.t
);
3510 $$.t
= build_tree_list
(specs
, $2);
3511 $$.new_type_flag
= $1.new_type_flag
; }
3512 | typed_declspecs1 %prec EMPTY
3513 { tree specs
= strip_attrs
($1.t
);
3514 $$.t
= build_tree_list
(specs
, NULL_TREE
);
3515 $$.new_type_flag
= $1.new_type_flag
; }
3516 | declmods notype_declarator
3517 { tree specs
= strip_attrs
($1);
3518 $$.t
= build_tree_list
(specs
, $2);
3519 $$.new_type_flag
= 0; }
3524 { $$.t
= build_tree_list
(NULL_TREE
, $1.t
);
3525 $$.new_type_flag
= $1.new_type_flag
; }
3527 { $$.t
= build_tree_list
($2, $1.t
);
3528 $$.new_type_flag
= $1.new_type_flag
; }
3537 /* empty */ %prec EMPTY
3538 { see_typename
(); }
3542 /* empty */ %prec EMPTY
3544 error ("type specifier omitted for parameter");
3545 $$
= build_tree_list
(integer_type_node
, NULL_TREE
);
3549 error ("type specifier omitted for parameter");
3550 if
(TREE_CODE
($$
) == SCOPE_REF
3551 && (TREE_CODE
(TREE_OPERAND
($$
, 0)) == TEMPLATE_TYPE_PARM
3552 || TREE_CODE
(TREE_OPERAND
($$
, 0)) == TEMPLATE_TEMPLATE_PARM
))
3553 cp_error
(" perhaps you want `typename %E' to make it a type", $$
);
3554 $$
= build_tree_list
(integer_type_node
, $$
);
3558 exception_specification_opt:
3559 /* empty */ %prec EMPTY
3561 | THROW
'(' ansi_raise_identifiers
')' %prec EMPTY
3563 | THROW LEFT_RIGHT %prec EMPTY
3564 { $$
= empty_except_spec
; }
3567 ansi_raise_identifier:
3570 check_for_new_type
("exception specifier", $1);
3571 $$
= groktypename
($1.t
);
3575 ansi_raise_identifiers:
3576 ansi_raise_identifier
3577 { $$
= add_exception_specifier
(NULL_TREE
, $1, 1); }
3578 | ansi_raise_identifiers
',' ansi_raise_identifier
3579 { $$
= add_exception_specifier
($1, $3, 1); }
3582 conversion_declarator:
3583 /* empty */ %prec EMPTY
3585 |
'*' cv_qualifiers conversion_declarator
3586 { $$
= make_pointer_declarator
($2, $3); }
3587 |
'&' cv_qualifiers conversion_declarator
3588 { $$
= make_reference_declarator
($2, $3); }
3589 | ptr_to_mem cv_qualifiers conversion_declarator
3590 { tree arg
= make_pointer_declarator
($2, $3);
3591 $$
= build_parse_node
(SCOPE_REF
, $1, arg
);
3597 { got_scope
= NULL_TREE
; }
3602 { $$
= ansi_opname
[MULT_EXPR
]; }
3604 { $$
= ansi_opname
[TRUNC_DIV_EXPR
]; }
3606 { $$
= ansi_opname
[TRUNC_MOD_EXPR
]; }
3608 { $$
= ansi_opname
[PLUS_EXPR
]; }
3610 { $$
= ansi_opname
[MINUS_EXPR
]; }
3612 { $$
= ansi_opname
[BIT_AND_EXPR
]; }
3614 { $$
= ansi_opname
[BIT_IOR_EXPR
]; }
3616 { $$
= ansi_opname
[BIT_XOR_EXPR
]; }
3618 { $$
= ansi_opname
[BIT_NOT_EXPR
]; }
3620 { $$
= ansi_opname
[COMPOUND_EXPR
]; }
3621 | operator ARITHCOMPARE
3622 { $$
= ansi_opname
[$2]; }
3624 { $$
= ansi_opname
[LT_EXPR
]; }
3626 { $$
= ansi_opname
[GT_EXPR
]; }
3627 | operator EQCOMPARE
3628 { $$
= ansi_opname
[$2]; }
3630 { $$
= ansi_assopname
[$2]; }
3632 { $$
= ansi_opname
[MODIFY_EXPR
]; }
3634 { $$
= ansi_opname
[$2]; }
3636 { $$
= ansi_opname
[$2]; }
3638 { $$
= ansi_opname
[POSTINCREMENT_EXPR
]; }
3639 | operator MINUSMINUS
3640 { $$
= ansi_opname
[PREDECREMENT_EXPR
]; }
3642 { $$
= ansi_opname
[TRUTH_ANDIF_EXPR
]; }
3644 { $$
= ansi_opname
[TRUTH_ORIF_EXPR
]; }
3646 { $$
= ansi_opname
[TRUTH_NOT_EXPR
]; }
3648 { $$
= ansi_opname
[COND_EXPR
]; }
3650 { $$
= ansi_opname
[$2]; }
3651 | operator POINTSAT %prec EMPTY
3652 { $$
= ansi_opname
[COMPONENT_REF
]; }
3653 | operator POINTSAT_STAR %prec EMPTY
3654 { $$
= ansi_opname
[MEMBER_REF
]; }
3655 | operator LEFT_RIGHT
3656 { $$
= ansi_opname
[CALL_EXPR
]; }
3658 { $$
= ansi_opname
[ARRAY_REF
]; }
3659 | operator NEW %prec EMPTY
3660 { $$
= ansi_opname
[NEW_EXPR
]; }
3661 | operator DELETE %prec EMPTY
3662 { $$
= ansi_opname
[DELETE_EXPR
]; }
3663 | operator NEW
'[' ']'
3664 { $$
= ansi_opname
[VEC_NEW_EXPR
]; }
3665 | operator DELETE
'[' ']'
3666 { $$
= ansi_opname
[VEC_DELETE_EXPR
]; }
3667 /* Names here should be looked up in class scope ALSO. */
3668 | operator type_specifier_seq conversion_declarator
3669 { $$
= grokoptypename
($2.t
, $3); }
3671 { $$
= ansi_opname
[ERROR_MARK
]; }
3678 debug_yytranslate
(value
)
3681 return yytname
[YYTRANSLATE
(value
)];