1 /* YACC parser for C++ syntax.
2 Copyright (C) 1988, 89, 93-98, 1999, 2000 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 PARAMS
((void));
66 static void parse_decl PARAMS
((tree
, 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
> SCSPEC TYPESPEC CV_QUALIFIER maybe_cv_qualifier
201 %type
<ttype
> init initlist maybeasm maybe_init defarg defarg1
202 %type
<ttype
> asm_operands nonnull_asm_operands asm_operand asm_clobbers
203 %type
<ttype
> maybe_attribute attributes attribute attribute_list attrib
204 %type
<ttype
> any_word
206 %type
<ttype
> compstmt implicitly_scoped_stmt
208 %type
<ttype
> declarator notype_declarator after_type_declarator
209 %type
<ttype
> notype_declarator_intern absdcl_intern
210 %type
<ttype
> after_type_declarator_intern
211 %type
<ttype
> direct_notype_declarator direct_after_type_declarator
212 %type
<itype
> components notype_components
213 %type
<ttype
> component_decl component_decl_1
214 %type
<ttype
> component_declarator component_declarator0
215 %type
<ttype
> notype_component_declarator notype_component_declarator0
216 %type
<ttype
> after_type_component_declarator after_type_component_declarator0
217 %type
<ttype
> absdcl cv_qualifiers
218 %type
<ttype
> direct_abstract_declarator conversion_declarator
219 %type
<ttype
> new_declarator direct_new_declarator
220 %type
<ttype
> xexpr parmlist parms bad_parm
221 %type
<ttype
> identifiers_or_typenames
222 %type
<ttype
> fcast_or_absdcl regcast_or_absdcl
223 %type
<ttype
> expr_or_declarator expr_or_declarator_intern
224 %type
<ttype
> complex_notype_declarator
225 %type
<ttype
> notype_unqualified_id unqualified_id qualified_id
226 %type
<ttype
> template_id do_id object_template_id notype_template_declarator
227 %type
<ttype
> overqualified_id notype_qualified_id any_id
228 %type
<ttype
> complex_direct_notype_declarator functional_cast
229 %type
<ttype
> complex_parmlist parms_comma
230 %type
<ttype
> namespace_qualifier namespace_using_decl
232 %type
<ftype
> type_id new_type_id typed_typespecs typespec typed_declspecs
233 %type
<ftype
> typed_declspecs1 type_specifier_seq nonempty_cv_qualifiers
234 %type
<ftype
> structsp typespecqual_reserved parm named_parm full_parm
235 %type
<ftype
> declmods
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 PARAMS
((FILE *, int, YYSTYPE));
315 extern tree combine_strings PARAMS
((tree
));
318 parse_decl
(declarator
, specs_attrs
, lookups
, attributes
, initialized
, decl
)
326 initial_deferred_type_access_control
(lookups
);
328 split_specs_attrs
(specs_attrs
, ¤t_declspecs
, &prefix_attributes
);
329 if
(current_declspecs
330 && TREE_CODE
(current_declspecs
) != TREE_LIST
)
331 current_declspecs
= build_decl_list
(NULL_TREE
, current_declspecs
);
332 if
(have_extern_spec
&& !used_extern_spec
)
334 current_declspecs
= decl_tree_cons
(NULL_TREE
,
335 get_identifier
("extern"),
337 used_extern_spec
= 1;
339 *decl
= start_decl
(declarator
, current_declspecs
, initialized
,
340 attributes
, prefix_attributes
);
346 ggc_add_tree_root
(¤t_declspecs
, 1);
347 ggc_add_tree_root
(&prefix_attributes
, 1);
348 ggc_add_tree_root
(¤t_aggr
, 1);
349 ggc_add_tree_root
(¤t_enum_type
, 1);
357 { finish_translation_unit
(); }
360 /* the reason for the strange actions in this rule
361 is so that notype_initdecls when reached via datadef
362 can find a valid list of type and sc specs in $0. */
365 { $
<ttype
>$
= NULL_TREE
; }
367 { $
<ttype
>$
= NULL_TREE
; }
368 | extdefs lang_extdef
369 { $
<ttype
>$
= NULL_TREE
; }
378 { have_extern_spec
= 1;
379 used_extern_spec
= 0;
380 $
<ttype
>$
= NULL_TREE
; }
383 { have_extern_spec
= 0; }
397 { if
(pending_lang_change
) do_pending_lang_change
();
398 type_lookups
= NULL_TREE
; }
400 { if
(! toplevel_bindings_p
())
405 fndef eat_saved_input
406 { if
(pending_inlines
) do_pending_inlines
(); }
408 { if
(pending_inlines
) do_pending_inlines
(); }
410 { if
(pending_inlines
) do_pending_inlines
(); }
411 | asm_keyword
'(' string ')' ';'
412 { if
(TREE_CHAIN
($3)) $3 = combine_strings
($3);
414 | extern_lang_string
'{' extdefs_opt
'}'
415 { pop_lang_context
(); }
416 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
417 { if
(pending_inlines
) do_pending_inlines
();
418 pop_lang_context
(); }
419 | extern_lang_string .hush_warning datadef .warning_ok
420 { if
(pending_inlines
) do_pending_inlines
();
421 pop_lang_context
(); }
422 | NAMESPACE identifier
'{'
423 { push_namespace
($2); }
425 { pop_namespace
(); }
427 { push_namespace
(NULL_TREE
); }
429 { pop_namespace
(); }
432 { do_toplevel_using_decl
($1); }
439 NAMESPACE identifier
'='
440 { begin_only_namespace_names
(); }
443 end_only_namespace_names
();
446 do_namespace_alias
($2, $5);
453 | USING global_scope qualified_id
455 | USING global_scope unqualified_id
459 namespace_using_decl:
460 USING namespace_qualifier identifier
461 { $$
= build_parse_node
(SCOPE_REF
, $2, $3); }
462 | USING global_scope identifier
463 { $$
= build_parse_node
(SCOPE_REF
, global_namespace
, $3); }
464 | USING global_scope namespace_qualifier identifier
465 { $$
= build_parse_node
(SCOPE_REF
, $3, $4); }
470 { begin_only_namespace_names
(); }
473 end_only_namespace_names
();
474 /* If no declaration was found, the using-directive is
475 invalid. Since that was not reported, we need the
476 identifier for the error message. */
477 if
(TREE_CODE
($4) == IDENTIFIER_NODE
&& lastiddecl
)
479 do_using_directive
($4);
486 if
(TREE_CODE
($$
) == IDENTIFIER_NODE
)
490 | namespace_qualifier NSNAME SCOPE
493 if
(TREE_CODE
($$
) == IDENTIFIER_NODE
)
501 | global_scope qualified_id
503 | global_scope unqualified_id
509 { push_lang_context
($1); }
510 | extern_lang_string EXTERN_LANG_STRING
511 { if
(current_lang_name
!= $2)
512 cp_error
("use of linkage spec `%D' is different from previous spec `%D'", $2, current_lang_name
);
513 pop_lang_context
(); push_lang_context
($2); }
518 { begin_template_parm_list
(); }
519 template_parm_list
'>'
520 { $$
= end_template_parm_list
($4); }
522 { begin_specialization
();
528 { $$
= process_template_parm
(NULL_TREE
, $1); }
529 | template_parm_list
',' template_parm
530 { $$
= process_template_parm
($1, $3); }
540 aggr maybe_identifier
541 { $$
= finish_template_type_parm
($1, $2); }
542 | TYPENAME_KEYWORD maybe_identifier
543 { $$
= finish_template_type_parm
(class_type_node
, $2); }
546 template_template_parm:
547 template_header aggr maybe_identifier
548 { $$
= finish_template_template_parm
($2, $3); }
552 /* The following rules introduce a new reduce/reduce
553 conflict on the ',' and '>' input tokens: they are valid
554 prefixes for a `structsp', which means they could match a
555 nameless parameter. See 14.6, paragraph 3.
556 By putting them before the `parm' rule, we get
557 their match before considering them nameless parameter
560 { $$
= build_tree_list
(NULL_TREE
, $1); }
561 | template_type_parm
'=' type_id
562 { $$
= build_tree_list
(groktypename
($3.t
), $1); }
564 { $$
= build_tree_list
(NULL_TREE
, $1.t
); }
565 | parm
'=' expr_no_commas %prec ARITHCOMPARE
566 { $$
= build_tree_list
($3, $1.t
); }
567 | template_template_parm
568 { $$
= build_tree_list
(NULL_TREE
, $1); }
569 | template_template_parm
'=' template_arg
571 if
(TREE_CODE
($3) != TEMPLATE_DECL
572 && TREE_CODE
($3) != TEMPLATE_TEMPLATE_PARM
573 && TREE_CODE
($3) != TYPE_DECL
)
575 error ("invalid default template argument");
576 $3 = error_mark_node
;
578 $$
= build_tree_list
($3, $1);
583 template_header template_extdef
584 { finish_template_decl
($1); }
585 | template_header
error %prec EMPTY
586 { finish_template_decl
($1); }
590 fndef eat_saved_input
591 { if
(pending_inlines
) do_pending_inlines
(); }
593 { if
(pending_inlines
) do_pending_inlines
(); }
595 { if
(pending_inlines
) do_pending_inlines
(); }
596 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
597 { if
(pending_inlines
) do_pending_inlines
();
598 pop_lang_context
(); }
599 | extern_lang_string .hush_warning template_datadef .warning_ok
600 { if
(pending_inlines
) do_pending_inlines
();
601 pop_lang_context
(); }
602 | extension template_extdef
608 | declmods notype_initdecls
';'
610 | typed_declspecs initdecls
';'
611 { note_list_got_semicolon
($1.t
); }
613 { maybe_process_partial_specialization
($1.t
);
614 note_got_semicolon
($1.t
); }
619 | declmods notype_initdecls
';'
621 | typed_declspecs initdecls
';'
622 { note_list_got_semicolon
($1.t
); }
624 { pedwarn
("empty declaration"); }
625 | explicit_instantiation
';'
626 | typed_declspecs
';'
629 split_specs_attrs
($1.t
, &t
, &attrs
);
631 note_list_got_semicolon
($1.t
);
638 ctor_initializer_opt:
657 fn.def1 maybe_return_init ctor_initializer_opt compstmt_or_error
658 { expand_body
(finish_function
(lineno
, (int)$3)); }
659 | fn.def1 maybe_return_init function_try_block
660 { expand_body
(finish_function
(lineno
, (int)$3)); }
661 | fn.def1 maybe_return_init
error
665 constructor_declarator:
666 nested_name_specifier SELFNAME
'('
667 { $$
= begin_constructor_declarator
($1, $2); }
668 parmlist
')' cv_qualifiers exception_specification_opt
669 { $$
= make_call_declarator
($
<ttype
>4, $5, $7, $8); }
670 | nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
671 { $$
= begin_constructor_declarator
($1, $2);
672 $$
= make_call_declarator
($$
, empty_parms
(), $4, $5);
674 | global_scope nested_name_specifier SELFNAME
'('
675 { $$
= begin_constructor_declarator
($2, $3); }
676 parmlist
')' cv_qualifiers exception_specification_opt
677 { $$
= make_call_declarator
($
<ttype
>5, $6, $8, $9); }
678 | global_scope nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
679 { $$
= begin_constructor_declarator
($2, $3);
680 $$
= make_call_declarator
($$
, empty_parms
(), $5, $6);
682 | nested_name_specifier self_template_type
'('
683 { $$
= begin_constructor_declarator
($1, $2); }
684 parmlist
')' cv_qualifiers exception_specification_opt
685 { $$
= make_call_declarator
($
<ttype
>4, $5, $7, $8); }
686 | nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
687 { $$
= begin_constructor_declarator
($1, $2);
688 $$
= make_call_declarator
($$
, empty_parms
(), $4, $5);
690 | global_scope nested_name_specifier self_template_type
'('
691 { $$
= begin_constructor_declarator
($2, $3); }
692 parmlist
')' cv_qualifiers exception_specification_opt
693 { $$
= make_call_declarator
($
<ttype
>5, $6, $8, $9); }
694 | global_scope nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
695 { $$
= begin_constructor_declarator
($2, $3);
696 $$
= make_call_declarator
($$
, empty_parms
(), $5, $6);
701 typed_declspecs declarator
702 { if
(!begin_function_definition
($1.t
, $1.lookups
, $2))
704 | declmods notype_declarator
705 { if
(!begin_function_definition
($1.t
, NULL_TREE
, $2))
708 { if
(!begin_function_definition
(NULL_TREE
, NULL_TREE
, $1))
710 | declmods constructor_declarator
711 { if
(!begin_function_definition
($1.t
, NULL_TREE
, $2))
713 | constructor_declarator
714 { if
(!begin_function_definition
(NULL_TREE
, NULL_TREE
, $1))
718 component_constructor_declarator:
719 SELFNAME
'(' parmlist
')' cv_qualifiers exception_specification_opt
720 { $$
= make_call_declarator
($1, $3, $5, $6); }
721 | SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
722 { $$
= make_call_declarator
($1, empty_parms
(), $3, $4); }
723 | self_template_type
'(' parmlist
')' cv_qualifiers exception_specification_opt
724 { $$
= make_call_declarator
($1, $3, $5, $6); }
725 | self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
726 { $$
= make_call_declarator
($1, empty_parms
(), $3, $4); }
729 /* more C++ complexity. See component_decl for a comment on the
730 reduce/reduce conflict introduced by these rules. */
732 declmods component_constructor_declarator
734 split_specs_attrs
($1.t
, &specs
, &attrs
);
735 attrs
= build_tree_list
(attrs
, NULL_TREE
);
736 $$
= start_method
(specs
, $2, attrs
);
740 if
(yychar == YYEMPTY
)
742 reinit_parse_for_method
(yychar, $$
); }
743 | component_constructor_declarator
744 { $$
= start_method
(NULL_TREE
, $1, NULL_TREE
);
746 | typed_declspecs declarator
748 split_specs_attrs
($1.t
, &specs
, &attrs
);
749 attrs
= build_tree_list
(attrs
, NULL_TREE
);
750 $$
= start_method
(specs
, $2, attrs
); goto rest_of_mdef
; }
751 | declmods notype_declarator
753 split_specs_attrs
($1.t
, &specs
, &attrs
);
754 attrs
= build_tree_list
(attrs
, NULL_TREE
);
755 $$
= start_method
(specs
, $2, attrs
); goto rest_of_mdef
; }
757 { $$
= start_method
(NULL_TREE
, $$
, NULL_TREE
);
759 | declmods constructor_declarator
761 split_specs_attrs
($1.t
, &specs
, &attrs
);
762 attrs
= build_tree_list
(attrs
, NULL_TREE
);
763 $$
= start_method
(specs
, $2, attrs
); goto rest_of_mdef
; }
764 | constructor_declarator
765 { $$
= start_method
(NULL_TREE
, $$
, NULL_TREE
);
770 RETURN_KEYWORD IDENTIFIER
772 if
(! current_function_parms_stored
)
780 { finish_named_return_value
($
<ttype
>$
, $2); }
781 | return_id
'(' nonnull_exprlist
')'
782 { finish_named_return_value
($
<ttype
>$
, $3); }
783 | return_id LEFT_RIGHT
784 { finish_named_return_value
($
<ttype
>$
, NULL_TREE
); }
788 ':' .set_base_init member_init_list
791 error ("no base initializers given following ':'");
799 if
(! current_function_parms_stored
)
802 if
(DECL_CONSTRUCTOR_P
(current_function_decl
))
803 /* Make a contour for the initializer list. */
805 else if
(current_class_type
== NULL_TREE
)
806 error ("base initializers not allowed for non-member functions");
807 else if
(! DECL_CONSTRUCTOR_P
(current_function_decl
))
808 error ("only constructors take base initializers");
817 | member_init_list
',' member_init
818 | member_init_list
error
822 '(' nonnull_exprlist
')'
824 if
(current_class_name
)
825 pedwarn
("anachronistic old style base class initializer");
826 expand_member_init
(current_class_ref
, NULL_TREE
, $2);
830 if
(current_class_name
)
831 pedwarn
("anachronistic old style base class initializer");
832 expand_member_init
(current_class_ref
, NULL_TREE
, void_type_node
);
834 | notype_identifier
'(' nonnull_exprlist
')'
835 { expand_member_init
(current_class_ref
, $1, $3); }
836 | notype_identifier LEFT_RIGHT
837 { expand_member_init
(current_class_ref
, $1, void_type_node
); }
838 | nonnested_type
'(' nonnull_exprlist
')'
839 { expand_member_init
(current_class_ref
, $1, $3); }
840 | nonnested_type LEFT_RIGHT
841 { expand_member_init
(current_class_ref
, $1, void_type_node
); }
842 | typename_sub
'(' nonnull_exprlist
')'
843 { expand_member_init
(current_class_ref
, TYPE_MAIN_DECL
($1),
845 | typename_sub LEFT_RIGHT
846 { expand_member_init
(current_class_ref
, TYPE_MAIN_DECL
($1),
871 explicit_instantiation:
872 TEMPLATE begin_explicit_instantiation typespec
';'
873 { do_type_instantiation
($3.t
, NULL_TREE
);
875 end_explicit_instantiation
876 | TEMPLATE begin_explicit_instantiation typed_declspecs declarator
877 { tree specs
= strip_attrs
($3.t
);
878 do_decl_instantiation
(specs
, $4, NULL_TREE
); }
879 end_explicit_instantiation
880 | TEMPLATE begin_explicit_instantiation notype_declarator
881 { do_decl_instantiation
(NULL_TREE
, $3, NULL_TREE
); }
882 end_explicit_instantiation
883 | TEMPLATE begin_explicit_instantiation constructor_declarator
884 { do_decl_instantiation
(NULL_TREE
, $3, NULL_TREE
); }
885 end_explicit_instantiation
886 | SCSPEC TEMPLATE begin_explicit_instantiation typespec
';'
887 { do_type_instantiation
($4.t
, $1);
889 end_explicit_instantiation
890 | SCSPEC TEMPLATE begin_explicit_instantiation typed_declspecs
892 { tree specs
= strip_attrs
($4.t
);
893 do_decl_instantiation
(specs
, $5, $1); }
894 end_explicit_instantiation
895 | SCSPEC TEMPLATE begin_explicit_instantiation notype_declarator
896 { do_decl_instantiation
(NULL_TREE
, $4, $1); }
897 end_explicit_instantiation
898 | SCSPEC TEMPLATE begin_explicit_instantiation constructor_declarator
899 { do_decl_instantiation
(NULL_TREE
, $4, $1); }
900 end_explicit_instantiation
903 begin_explicit_instantiation:
904 { begin_explicit_instantiation
(); }
906 end_explicit_instantiation:
907 { end_explicit_instantiation
(); }
909 /* The TYPENAME expansions are to deal with use of a template class name as
910 a template within the class itself, where the template decl is hidden by
911 a type decl. Got all that? */
914 PTYPENAME
'<' template_arg_list_opt template_close_bracket
915 .finish_template_type
917 | TYPENAME
'<' template_arg_list_opt template_close_bracket
918 .finish_template_type
923 apparent_template_type:
925 | identifier
'<' template_arg_list_opt
'>'
926 .finish_template_type
930 SELFNAME
'<' template_arg_list_opt template_close_bracket
931 .finish_template_type
935 .finish_template_type
:
937 if
(yychar == YYEMPTY
)
940 $$
= finish_template_type
($
<ttype
>-3, $
<ttype
>-1,
944 template_close_bracket:
948 /* Handle `Class<Class<Type>>' without space in the `>>' */
949 pedwarn
("`>>' should be `> >' in template class name");
954 template_arg_list_opt:
962 { $$
= build_tree_list
(NULL_TREE
, $$
); }
963 | template_arg_list
',' template_arg
964 { $$
= chainon
($$
, build_tree_list
(NULL_TREE
, $3)); }
969 { $$
= groktypename
($1.t
); }
972 | expr_no_commas %prec ARITHCOMPARE
977 { $$
= NEGATE_EXPR
; }
979 { $$
= CONVERT_EXPR
; }
981 { $$
= PREINCREMENT_EXPR
; }
983 { $$
= PREDECREMENT_EXPR
; }
985 { $$
= TRUTH_NOT_EXPR
; }
990 { $$
= build_x_compound_expr
($$
); }
996 { error ("ANSI C++ forbids an empty condition for `%s'",
998 $$
= integer_zero_node
; }
1005 { error ("ANSI C++ forbids an empty condition for `%s'",
1007 $$
= integer_zero_node
; }
1021 type_specifier_seq declarator maybeasm maybe_attribute
'='
1024 for
(d
= getdecls
(); d
; d
= TREE_CHAIN
(d
))
1025 if
(TREE_CODE
(d
) == TYPE_DECL
) {
1026 tree s
= TREE_TYPE
(d
);
1027 if
(TREE_CODE
(s
) == RECORD_TYPE
)
1028 cp_error
("definition of class `%T' in condition", s
);
1029 else if
(TREE_CODE
(s
) == ENUMERAL_TYPE
)
1030 cp_error
("definition of enum `%T' in condition", s
);
1033 current_declspecs
= $1.t
;
1034 $
<ttype
>$
= start_decl
($
<ttype
>2, current_declspecs
, 1,
1035 $4, /*prefix_attributes*/ NULL_TREE
);
1039 cp_finish_decl
($
<ttype
>6, $7, $4, LOOKUP_ONLYCONVERTING
);
1040 $$
= convert_from_reference
($
<ttype
>6);
1041 if
(TREE_CODE
(TREE_TYPE
($$
)) == ARRAY_TYPE
)
1042 cp_error
("definition of array `%#D' in condition", $$
);
1049 | maybe_label_decls stmts
'}'
1050 | maybe_label_decls stmts
error '}'
1051 | maybe_label_decls
error '}'
1054 already_scoped_stmt:
1056 { $
<ttype
>$
= begin_compound_stmt
(1); }
1058 { finish_compound_stmt
(1, $
<ttype
>2); }
1063 nontrivial_exprlist:
1064 expr_no_commas
',' expr_no_commas
1065 { $$
= tree_cons
(NULL_TREE
, $$
,
1066 build_tree_list
(NULL_TREE
, $3)); }
1067 | expr_no_commas
',' error
1068 { $$
= tree_cons
(NULL_TREE
, $$
,
1069 build_tree_list
(NULL_TREE
, error_mark_node
)); }
1070 | nontrivial_exprlist
',' expr_no_commas
1071 { chainon
($$
, build_tree_list
(NULL_TREE
, $3)); }
1072 | nontrivial_exprlist
',' error
1073 { chainon
($$
, build_tree_list
(NULL_TREE
, error_mark_node
)); }
1078 { $$
= build_tree_list
(NULL_TREE
, $$
); }
1079 | nontrivial_exprlist
1085 /* __extension__ turns off -pedantic for following primary. */
1086 | extension cast_expr %prec UNARY
1089 |
'*' cast_expr %prec UNARY
1090 { $$
= build_x_indirect_ref
($2, "unary *"); }
1091 |
'&' cast_expr %prec UNARY
1092 { $$
= build_x_unary_op
(ADDR_EXPR
, $2); }
1094 { $$
= build_x_unary_op
(BIT_NOT_EXPR
, $2); }
1095 | unop cast_expr %prec UNARY
1096 { $$
= finish_unary_op_expr
($1, $2); }
1097 /* Refer to the address of a label as a pointer. */
1100 pedwarn
("ANSI C++ forbids `&&'");
1101 $$
= finish_label_address_expr
($2); }
1102 | SIZEOF unary_expr %prec UNARY
1103 { $$
= expr_sizeof
($2); }
1104 | SIZEOF
'(' type_id
')' %prec HYPERUNARY
1105 { $$
= c_sizeof
(groktypename
($3.t
));
1106 check_for_new_type
("sizeof", $3); }
1107 | ALIGNOF unary_expr %prec UNARY
1108 { $$
= grok_alignof
($2); }
1109 | ALIGNOF
'(' type_id
')' %prec HYPERUNARY
1110 { $$
= c_alignof
(groktypename
($3.t
));
1111 check_for_new_type
("alignof", $3); }
1113 /* The %prec EMPTY's here are required by the = init initializer
1114 syntax extension; see below. */
1115 | new new_type_id %prec EMPTY
1116 { $$
= build_new
(NULL_TREE
, $2.t
, NULL_TREE
, $1);
1117 check_for_new_type
("new", $2); }
1118 | new new_type_id new_initializer
1119 { $$
= build_new
(NULL_TREE
, $2.t
, $3, $1);
1120 check_for_new_type
("new", $2); }
1121 | new new_placement new_type_id %prec EMPTY
1122 { $$
= build_new
($2, $3.t
, NULL_TREE
, $1);
1123 check_for_new_type
("new", $3); }
1124 | new new_placement new_type_id new_initializer
1125 { $$
= build_new
($2, $3.t
, $4, $1);
1126 check_for_new_type
("new", $3); }
1127 | new
'(' type_id
')'
1129 { $$
= build_new
(NULL_TREE
, groktypename
($3.t
),
1131 check_for_new_type
("new", $3); }
1132 | new
'(' type_id
')' new_initializer
1133 { $$
= build_new
(NULL_TREE
, groktypename
($3.t
), $5, $1);
1134 check_for_new_type
("new", $3); }
1135 | new new_placement
'(' type_id
')' %prec EMPTY
1136 { $$
= build_new
($2, groktypename
($4.t
), NULL_TREE
, $1);
1137 check_for_new_type
("new", $4); }
1138 | new new_placement
'(' type_id
')' new_initializer
1139 { $$
= build_new
($2, groktypename
($4.t
), $6, $1);
1140 check_for_new_type
("new", $4); }
1142 | delete cast_expr %prec UNARY
1143 { $$
= delete_sanity
($2, NULL_TREE
, 0, $1); }
1144 | delete
'[' ']' cast_expr %prec UNARY
1145 { $$
= delete_sanity
($4, NULL_TREE
, 1, $1);
1146 if
(yychar == YYEMPTY
)
1148 | delete
'[' expr
']' cast_expr %prec UNARY
1149 { $$
= delete_sanity
($5, $3, 2, $1);
1150 if
(yychar == YYEMPTY
)
1152 | REALPART cast_expr %prec UNARY
1153 { $$
= build_x_unary_op
(REALPART_EXPR
, $2); }
1154 | IMAGPART cast_expr %prec UNARY
1155 { $$
= build_x_unary_op
(IMAGPART_EXPR
, $2); }
1156 | VA_ARG
'(' expr_no_commas
',' type_id
')'
1157 { $$
= build_x_va_arg
($3, groktypename
($5.t
));
1158 check_for_new_type
("__builtin_va_arg", $5); }
1162 '(' nonnull_exprlist
')'
1164 |
'{' nonnull_exprlist
'}'
1165 { cp_pedwarn
("old style placement syntax, use () instead");
1170 '(' nonnull_exprlist
')'
1176 cp_error
("`%T' is not a valid expression", $2.t
);
1177 $$
= error_mark_node
;
1179 /* GNU extension so people can use initializer lists. Note that
1180 this alters the meaning of `new int = 1', which was previously
1181 syntactically valid but semantically invalid. */
1185 pedwarn
("ANSI C++ forbids initialization of new expression with `='");
1186 if
(TREE_CODE
($2) != TREE_LIST
1187 && TREE_CODE
($2) != CONSTRUCTOR
)
1188 $$
= build_tree_list
(NULL_TREE
, $2);
1194 /* This is necessary to postpone reduction of `int ((int)(int)(int))'. */
1196 '(' type_id
')' %prec EMPTY
1197 { $2.t
= finish_parmlist
(build_tree_list
(NULL_TREE
, $2.t
), 0);
1198 $$
= make_call_declarator
(NULL_TREE
, $2.t
, NULL_TREE
, NULL_TREE
);
1199 check_for_new_type
("cast", $2); }
1200 | regcast_or_absdcl
'(' type_id
')' %prec EMPTY
1201 { $3.t
= finish_parmlist
(build_tree_list
(NULL_TREE
, $3.t
), 0);
1202 $$
= make_call_declarator
($$
, $3.t
, NULL_TREE
, NULL_TREE
);
1203 check_for_new_type
("cast", $3); }
1208 | regcast_or_absdcl unary_expr %prec UNARY
1209 { $$
= reparse_absdcl_as_casts
($$
, $2); }
1210 | regcast_or_absdcl
'{' initlist maybecomma
'}' %prec UNARY
1212 tree init
= build_nt
(CONSTRUCTOR
, NULL_TREE
,
1215 pedwarn
("ANSI C++ forbids constructor-expressions");
1216 /* Indicate that this was a GNU C constructor expression. */
1217 TREE_HAS_CONSTRUCTOR
(init
) = 1;
1219 $$
= reparse_absdcl_as_casts
($$
, init
);
1225 /* Handle general members. */
1226 | expr_no_commas POINTSAT_STAR expr_no_commas
1227 { $$
= build_x_binary_op
(MEMBER_REF
, $$
, $3); }
1228 | expr_no_commas DOT_STAR expr_no_commas
1229 { $$
= build_m_component_ref
($$
, $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
'/' expr_no_commas
1237 { $$
= build_x_binary_op
($2, $$
, $3); }
1238 | expr_no_commas
'%' expr_no_commas
1239 { $$
= build_x_binary_op
($2, $$
, $3); }
1240 | expr_no_commas LSHIFT expr_no_commas
1241 { $$
= build_x_binary_op
($2, $$
, $3); }
1242 | expr_no_commas RSHIFT expr_no_commas
1243 { $$
= build_x_binary_op
($2, $$
, $3); }
1244 | expr_no_commas ARITHCOMPARE expr_no_commas
1245 { $$
= build_x_binary_op
($2, $$
, $3); }
1246 | expr_no_commas
'<' expr_no_commas
1247 { $$
= build_x_binary_op
(LT_EXPR
, $$
, $3); }
1248 | expr_no_commas
'>' expr_no_commas
1249 { $$
= build_x_binary_op
(GT_EXPR
, $$
, $3); }
1250 | expr_no_commas EQCOMPARE expr_no_commas
1251 { $$
= build_x_binary_op
($2, $$
, $3); }
1252 | expr_no_commas MIN_MAX 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
'|' expr_no_commas
1257 { $$
= build_x_binary_op
($2, $$
, $3); }
1258 | expr_no_commas
'^' expr_no_commas
1259 { $$
= build_x_binary_op
($2, $$
, $3); }
1260 | expr_no_commas ANDAND expr_no_commas
1261 { $$
= build_x_binary_op
(TRUTH_ANDIF_EXPR
, $$
, $3); }
1262 | expr_no_commas OROR expr_no_commas
1263 { $$
= build_x_binary_op
(TRUTH_ORIF_EXPR
, $$
, $3); }
1264 | expr_no_commas
'?' xexpr
':' expr_no_commas
1265 { $$
= build_x_conditional_expr
($$
, $3, $5); }
1266 | expr_no_commas
'=' expr_no_commas
1267 { $$
= build_x_modify_expr
($$
, NOP_EXPR
, $3);
1268 if
($$
!= error_mark_node
)
1269 C_SET_EXP_ORIGINAL_CODE
($$
, MODIFY_EXPR
); }
1270 | expr_no_commas ASSIGN expr_no_commas
1271 { $$
= build_x_modify_expr
($$
, $2, $3); }
1273 { $$
= build_throw
(NULL_TREE
); }
1274 | THROW expr_no_commas
1275 { $$
= build_throw
($2); }
1276 /* These extensions are not defined. The second arg to build_m_component_ref
1277 is old, build_m_component_ref now does an implicit
1278 build_indirect_ref (x, NULL_PTR) on the second argument.
1279 | object '&' expr_no_commas %prec UNARY
1280 { $$ = build_m_component_ref ($$, build_x_unary_op (ADDR_EXPR, $3)); }
1281 | object unop expr_no_commas %prec UNARY
1282 { $$ = build_m_component_ref ($$, build_x_unary_op ($2, $3)); }
1283 | object '(' type_id ')' expr_no_commas %prec UNARY
1284 { tree type = groktypename ($3.t);
1285 $$ = build_m_component_ref ($$, build_c_cast (type, $5)); }
1286 | object primary_no_id %prec UNARY
1287 { $$ = build_m_component_ref ($$, $2); }
1291 notype_unqualified_id:
1292 '~' see_typename identifier
1293 { $$
= build_parse_node
(BIT_NOT_EXPR
, $3); }
1294 |
'~' see_typename template_type
1295 { $$
= build_parse_node
(BIT_NOT_EXPR
, $3); }
1300 | NSNAME %prec EMPTY
1305 /* If lastiddecl is a TREE_LIST, it's a baselink, which
1306 means that we're in an expression like S::f<int>, so
1307 don't do_identifier; we only do that for unqualified
1309 if
(lastiddecl
&& TREE_CODE
(lastiddecl
) != TREE_LIST
)
1310 $$
= do_identifier
($
<ttype
>-1, 1, NULL_TREE
);
1316 PFUNCNAME
'<' do_id template_arg_list_opt template_close_bracket
1317 { $$
= lookup_template_function
($3, $4); }
1318 | operator_name
'<' do_id template_arg_list_opt template_close_bracket
1319 { $$
= lookup_template_function
($3, $4); }
1323 TEMPLATE identifier
'<' template_arg_list_opt template_close_bracket
1324 { $$
= lookup_template_function
($2, $4); }
1325 | TEMPLATE PFUNCNAME
'<' template_arg_list_opt template_close_bracket
1326 { $$
= lookup_template_function
($2, $4); }
1327 | TEMPLATE operator_name
'<' template_arg_list_opt
1328 template_close_bracket
1329 { $$
= lookup_template_function
($2, $4); }
1333 notype_unqualified_id
1338 expr_or_declarator_intern:
1340 | attributes expr_or_declarator
1342 /* Provide support for '(' attributes '*' declarator ')'
1344 $$
= decl_tree_cons
($1, $2, NULL_TREE
);
1349 notype_unqualified_id
1350 |
'*' expr_or_declarator_intern %prec UNARY
1351 { $$
= build_parse_node
(INDIRECT_REF
, $2); }
1352 |
'&' expr_or_declarator_intern %prec UNARY
1353 { $$
= build_parse_node
(ADDR_EXPR
, $2); }
1354 |
'(' expr_or_declarator_intern
')'
1358 notype_template_declarator:
1359 IDENTIFIER
'<' template_arg_list_opt template_close_bracket
1360 { $$
= lookup_template_function
($1, $3); }
1361 | NSNAME
'<' template_arg_list template_close_bracket
1362 { $$
= lookup_template_function
($1, $3); }
1365 direct_notype_declarator:
1366 complex_direct_notype_declarator
1367 /* This precedence declaration is to prefer this reduce
1368 to the Koenig lookup shift in primary, below. I hate yacc. */
1369 | notype_unqualified_id %prec
'('
1370 | notype_template_declarator
1371 |
'(' expr_or_declarator_intern
')'
1372 { $$
= finish_decl_parsing
($2); }
1376 notype_unqualified_id
1378 if
(TREE_CODE
($1) == BIT_NOT_EXPR
)
1379 $$
= build_x_unary_op
(BIT_NOT_EXPR
, TREE_OPERAND
($1, 0));
1381 $$
= finish_id_expr
($1);
1387 $$
= combine_strings
($$
);
1388 /* combine_strings doesn't set up TYPE_MAIN_VARIANT of
1389 a const array the way we want, so fix it. */
1390 if
(flag_const_strings
)
1391 TREE_TYPE
($$
) = build_cplus_array_type
1392 (TREE_TYPE
(TREE_TYPE
($$
)),
1393 TYPE_DOMAIN
(TREE_TYPE
($$
)));
1396 { $$
= finish_parenthesized_expr
($2); }
1397 |
'(' expr_or_declarator_intern
')'
1398 { $2 = reparse_decl_as_expr
(NULL_TREE
, $2);
1399 $$
= finish_parenthesized_expr
($2); }
1401 { $$
= error_mark_node
; }
1403 { tree scope
= current_scope
();
1404 if
(!scope || TREE_CODE
(scope
) != FUNCTION_DECL
)
1406 error ("braced-group within expression allowed only inside a function");
1410 pedwarn
("ANSI C++ forbids braced-groups within expressions");
1411 $
<ttype
>$
= begin_stmt_expr
();
1414 { $$
= finish_stmt_expr
($
<ttype
>2); }
1415 /* Koenig lookup support
1416 We could store lastiddecl in $1 to avoid another lookup,
1417 but that would result in many additional reduce/reduce conflicts. */
1418 | notype_unqualified_id
'(' nonnull_exprlist
')'
1419 { $$
= finish_call_expr
($1, $3, 1); }
1420 | notype_unqualified_id LEFT_RIGHT
1421 { $$
= finish_call_expr
($1, NULL_TREE
, 1); }
1422 | primary
'(' nonnull_exprlist
')'
1423 { $$
= finish_call_expr
($1, $3, 0); }
1424 | primary LEFT_RIGHT
1425 { $$
= finish_call_expr
($1, NULL_TREE
, 0); }
1426 | primary
'[' expr
']'
1427 { $$
= grok_array_decl
($$
, $3); }
1429 { $$
= finish_increment_expr
($1, POSTINCREMENT_EXPR
); }
1430 | primary MINUSMINUS
1431 { $$
= finish_increment_expr
($1, POSTDECREMENT_EXPR
); }
1432 /* C++ extensions */
1434 { $$
= finish_this_expr
(); }
1435 | CV_QUALIFIER
'(' nonnull_exprlist
')'
1437 /* This is a C cast in C++'s `functional' notation
1438 using the "implicit int" extension so that:
1439 `const (3)' is equivalent to `const int (3)'. */
1442 type
= hash_tree_cons
(NULL_TREE
, $1, NULL_TREE
);
1443 type
= groktypename
(build_decl_list
(type
, NULL_TREE
));
1444 $$
= build_functional_cast
(type
, $3);
1447 | DYNAMIC_CAST
'<' type_id
'>' '(' expr
')'
1448 { tree type
= groktypename
($3.t
);
1449 check_for_new_type
("dynamic_cast", $3);
1450 $$
= build_dynamic_cast
(type
, $6); }
1451 | STATIC_CAST
'<' type_id
'>' '(' expr
')'
1452 { tree type
= groktypename
($3.t
);
1453 check_for_new_type
("static_cast", $3);
1454 $$
= build_static_cast
(type
, $6); }
1455 | REINTERPRET_CAST
'<' type_id
'>' '(' expr
')'
1456 { tree type
= groktypename
($3.t
);
1457 check_for_new_type
("reinterpret_cast", $3);
1458 $$
= build_reinterpret_cast
(type
, $6); }
1459 | CONST_CAST
'<' type_id
'>' '(' expr
')'
1460 { tree type
= groktypename
($3.t
);
1461 check_for_new_type
("const_cast", $3);
1462 $$
= build_const_cast
(type
, $6); }
1463 | TYPEID
'(' expr
')'
1464 { $$
= build_typeid
($3); }
1465 | TYPEID
'(' type_id
')'
1466 { tree type
= groktypename
($3.t
);
1467 check_for_new_type
("typeid", $3);
1468 $$
= get_typeid
(TYPE_MAIN_VARIANT
(type
)); }
1469 | global_scope IDENTIFIER
1470 { $$
= do_scoped_id
($2, 1); }
1471 | global_scope template_id
1473 | global_scope operator_name
1475 got_scope
= NULL_TREE
;
1476 if
(TREE_CODE
($2) == IDENTIFIER_NODE
)
1477 $$
= do_scoped_id
($2, 1);
1481 | overqualified_id %prec HYPERUNARY
1482 { $$
= build_offset_ref
(OP0
($$
), OP1
($$
)); }
1483 | overqualified_id
'(' nonnull_exprlist
')'
1484 { $$
= finish_qualified_call_expr
($1, $3); }
1485 | overqualified_id LEFT_RIGHT
1486 { $$
= finish_qualified_call_expr
($1, NULL_TREE
); }
1487 | object object_template_id %prec UNARY
1489 $$
= build_x_component_ref
($$
, $2, NULL_TREE
, 1);
1491 | object object_template_id
'(' nonnull_exprlist
')'
1492 { $$
= finish_object_call_expr
($2, $1, $4); }
1493 | object object_template_id LEFT_RIGHT
1494 { $$
= finish_object_call_expr
($2, $1, NULL_TREE
); }
1495 | object unqualified_id %prec UNARY
1496 { $$
= build_x_component_ref
($$
, $2, NULL_TREE
, 1); }
1497 | object overqualified_id %prec UNARY
1498 { if
(processing_template_decl
)
1499 $$
= build_min_nt
(COMPONENT_REF
, $1, $2);
1501 $$
= build_object_ref
($$
, OP0
($2), OP1
($2)); }
1502 | object unqualified_id
'(' nonnull_exprlist
')'
1503 { $$
= finish_object_call_expr
($2, $1, $4); }
1504 | object unqualified_id LEFT_RIGHT
1505 { $$
= finish_object_call_expr
($2, $1, NULL_TREE
); }
1506 | object overqualified_id
'(' nonnull_exprlist
')'
1507 { $$
= finish_qualified_object_call_expr
($2, $1, $4); }
1508 | object overqualified_id LEFT_RIGHT
1509 { $$
= finish_qualified_object_call_expr
($2, $1, NULL_TREE
); }
1510 /* p->int::~int() is valid -- 12.4 */
1511 | object
'~' TYPESPEC LEFT_RIGHT
1512 { $$
= finish_pseudo_destructor_call_expr
($1, NULL_TREE
, $3); }
1513 | object TYPESPEC SCOPE
'~' TYPESPEC LEFT_RIGHT
1514 { $$
= finish_pseudo_destructor_call_expr
($1, $2, $5); }
1517 $$
= error_mark_node
;
1521 /* Not needed for now.
1527 { $$ = error_mark_node; }
1529 { if (current_function_decl == 0)
1531 error ("braced-group within expression allowed only inside a function");
1534 $<ttype>$ = expand_start_stmt_expr (); }
1537 pedwarn ("ANSI C++ forbids braced-groups within expressions");
1538 $$ = expand_end_stmt_expr ($<ttype>2); }
1539 | primary_no_id '(' nonnull_exprlist ')'
1540 { $$ = build_x_function_call ($$, $3, current_class_ref); }
1541 | primary_no_id LEFT_RIGHT
1542 { $$ = build_x_function_call ($$, NULL_TREE, current_class_ref); }
1543 | primary_no_id '[' expr ']'
1545 | primary_no_id PLUSPLUS
1546 { $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); }
1547 | primary_no_id MINUSMINUS
1548 { $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); }
1550 { goto do_scoped_id; }
1551 | SCOPE operator_name
1552 { if (TREE_CODE ($2) == IDENTIFIER_NODE)
1554 goto do_scoped_operator;
1563 { got_scope
= NULL_TREE
; $$
= 1; }
1569 | global_scope delete
1570 { got_scope
= NULL_TREE
; $$
= 1; }
1575 { $$
= boolean_true_node
; }
1577 { $$
= boolean_false_node
; }
1580 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
1584 { $$
= chainon
($$
, $2); }
1590 if
(! current_function_parms_stored
)
1591 store_parm_decls
();
1598 { got_object
= TREE_TYPE
($$
); }
1601 $$
= build_x_arrow
($$
);
1602 got_object
= TREE_TYPE
($$
);
1607 typespec initdecls
';'
1609 if
($1.t
&& IS_AGGR_TYPE_CODE
(TREE_CODE
($1.t
)))
1610 note_got_semicolon
($1.t
);
1612 | typed_declspecs initdecls
';'
1614 note_list_got_semicolon
($1.t
);
1616 | declmods notype_initdecls
';'
1618 | typed_declspecs
';'
1621 note_list_got_semicolon
($1.t
);
1624 { warning
("empty declaration"); }
1629 /* Any kind of declarator (thus, all declarators allowed
1630 after an explicit typespec). */
1633 after_type_declarator %prec EMPTY
1634 | notype_declarator %prec EMPTY
1637 /* This is necessary to postpone reduction of `int()()()()'. */
1639 LEFT_RIGHT %prec EMPTY
1640 { $$
= make_call_declarator
(NULL_TREE
, empty_parms
(),
1641 NULL_TREE
, NULL_TREE
); }
1642 | fcast_or_absdcl LEFT_RIGHT %prec EMPTY
1643 { $$
= make_call_declarator
($$
, empty_parms
(), NULL_TREE
,
1647 /* ANSI type-id (8.1) */
1649 typed_typespecs absdcl
1650 { $$.t
= build_decl_list
($1.t
, $2);
1651 $$.new_type_flag
= $1.new_type_flag
; }
1652 | nonempty_cv_qualifiers absdcl
1653 { $$.t
= build_decl_list
($1.t
, $2);
1654 $$.new_type_flag
= $1.new_type_flag
; }
1656 { $$.t
= build_decl_list
(build_decl_list
(NULL_TREE
, $1.t
),
1658 $$.new_type_flag
= $1.new_type_flag
; }
1659 | typed_typespecs %prec EMPTY
1660 { $$.t
= build_decl_list
($1.t
, NULL_TREE
);
1661 $$.new_type_flag
= $1.new_type_flag
; }
1662 | nonempty_cv_qualifiers %prec EMPTY
1663 { $$.t
= build_decl_list
($1.t
, NULL_TREE
);
1664 $$.new_type_flag
= $1.new_type_flag
; }
1667 /* Declspecs which contain at least one type specifier or typedef name.
1668 (Just `const' or `volatile' is not enough.)
1669 A typedef'd name following these is taken as a name to be declared.
1670 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1673 typed_typespecs %prec EMPTY
1674 { $$.lookups
= type_lookups
; }
1676 { $$.lookups
= type_lookups
; }
1681 { $$.t
= decl_tree_cons
(NULL_TREE
, $2.t
, $1.t
);
1682 $$.new_type_flag
= $2.new_type_flag
; }
1683 | typespec reserved_declspecs %prec HYPERUNARY
1684 { $$.t
= decl_tree_cons
(NULL_TREE
, $1.t
, $2);
1685 $$.new_type_flag
= $1.new_type_flag
; }
1686 | typespec reserved_typespecquals reserved_declspecs
1687 { $$.t
= decl_tree_cons
(NULL_TREE
, $1.t
, chainon
($2, $3));
1688 $$.new_type_flag
= $1.new_type_flag
; }
1689 | declmods typespec reserved_declspecs
1690 { $$.t
= decl_tree_cons
(NULL_TREE
, $2.t
, chainon
($3, $1.t
));
1691 $$.new_type_flag
= $2.new_type_flag
; }
1692 | declmods typespec reserved_typespecquals
1693 { $$.t
= decl_tree_cons
(NULL_TREE
, $2.t
, chainon
($3, $1.t
));
1694 $$.new_type_flag
= $2.new_type_flag
; }
1695 | declmods typespec reserved_typespecquals reserved_declspecs
1696 { $$.t
= decl_tree_cons
(NULL_TREE
, $2.t
,
1697 chainon
($3, chainon
($4, $1.t
)));
1698 $$.new_type_flag
= $2.new_type_flag
; }
1703 { if
(extra_warnings
)
1704 warning
("`%s' is not at beginning of declaration",
1705 IDENTIFIER_POINTER
($$
));
1706 $$
= build_decl_list
(NULL_TREE
, $$
); }
1707 | reserved_declspecs typespecqual_reserved
1708 { $$
= decl_tree_cons
(NULL_TREE
, $2.t
, $$
); }
1709 | reserved_declspecs SCSPEC
1710 { if
(extra_warnings
)
1711 warning
("`%s' is not at beginning of declaration",
1712 IDENTIFIER_POINTER
($2));
1713 $$
= decl_tree_cons
(NULL_TREE
, $2, $$
); }
1714 | reserved_declspecs attributes
1715 { $$
= decl_tree_cons
($2, NULL_TREE
, $1); }
1717 { $$
= decl_tree_cons
($1, NULL_TREE
, NULL_TREE
); }
1720 /* List of just storage classes and type modifiers.
1721 A declaration can start with just this, but then it cannot be used
1722 to redeclare a typedef-name.
1723 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1725 /* We use hash_tree_cons for lists of typeless declspecs so that they end
1726 up on a persistent obstack. Otherwise, they could appear at the
1727 beginning of something like
1729 static const struct { int foo () { } } b;
1731 and would be discarded after we finish compiling foo. We don't need to
1732 worry once we see a type. */
1735 nonempty_cv_qualifiers %prec EMPTY
1736 { $$.lookups
= NULL_TREE
; TREE_STATIC
($$.t
) = 1; }
1739 $$.t
= hash_tree_cons
(NULL_TREE
, $1, NULL_TREE
);
1740 $$.new_type_flag
= 0; $$.lookups
= NULL_TREE
;
1742 | declmods CV_QUALIFIER
1744 $$.t
= hash_tree_cons
(NULL_TREE
, $2, $1.t
);
1745 TREE_STATIC
($$.t
) = 1;
1749 if
(extra_warnings
&& TREE_STATIC
($$.t
))
1750 warning
("`%s' is not at beginning of declaration",
1751 IDENTIFIER_POINTER
($2));
1752 $$.t
= hash_tree_cons
(NULL_TREE
, $2, $1.t
);
1753 TREE_STATIC
($$.t
) = TREE_STATIC
($1.t
);
1755 | declmods attributes
1756 { $$.t
= hash_tree_cons
($2, NULL_TREE
, $1.t
); }
1757 | attributes %prec EMPTY
1759 $$.t
= hash_tree_cons
($1, NULL_TREE
, NULL_TREE
);
1760 $$.new_type_flag
= 0; $$.lookups
= NULL_TREE
;
1764 /* Used instead of declspecs where storage classes are not allowed
1765 (that is, for typenames and structure components).
1767 C++ can takes storage classes for structure components.
1768 Don't accept a typedef-name if anything but a modifier precedes it. */
1771 typespec %prec EMPTY
1772 { $$.t
= build_decl_list
(NULL_TREE
, $1.t
);
1773 $$.new_type_flag
= $1.new_type_flag
; }
1774 | nonempty_cv_qualifiers typespec
1775 { $$.t
= decl_tree_cons
(NULL_TREE
, $2.t
, $1.t
);
1776 $$.new_type_flag
= $2.new_type_flag
; }
1777 | typespec reserved_typespecquals
1778 { $$.t
= decl_tree_cons
(NULL_TREE
, $1.t
, $2);
1779 $$.new_type_flag
= $1.new_type_flag
; }
1780 | nonempty_cv_qualifiers typespec reserved_typespecquals
1781 { $$.t
= decl_tree_cons
(NULL_TREE
, $2.t
, chainon
($3, $1.t
));
1782 $$.new_type_flag
= $2.new_type_flag
; }
1785 reserved_typespecquals:
1786 typespecqual_reserved
1787 { $$
= build_decl_list
(NULL_TREE
, $1.t
); }
1788 | reserved_typespecquals typespecqual_reserved
1789 { $$
= decl_tree_cons
(NULL_TREE
, $2.t
, $1); }
1792 /* A typespec (but not a type qualifier).
1793 Once we have seen one of these in a declaration,
1794 if a typedef name appears then it is being redeclared. */
1798 { $$.lookups
= NULL_TREE
; }
1799 | TYPESPEC %prec EMPTY
1800 { $$.t
= $1; $$.new_type_flag
= 0; $$.lookups
= NULL_TREE
; }
1801 | complete_type_name
1802 { $$.t
= $1; $$.new_type_flag
= 0; $$.lookups
= NULL_TREE
; }
1803 | TYPEOF
'(' expr
')'
1804 { $$.t
= finish_typeof
($3);
1805 $$.new_type_flag
= 0; $$.lookups
= NULL_TREE
; }
1806 | TYPEOF
'(' type_id
')'
1807 { $$.t
= groktypename
($3.t
);
1808 $$.new_type_flag
= 0; $$.lookups
= NULL_TREE
; }
1809 | SIGOF
'(' expr
')'
1810 { tree type
= TREE_TYPE
($3);
1812 $$.new_type_flag
= 0; $$.lookups
= NULL_TREE
;
1813 if
(IS_AGGR_TYPE
(type
))
1815 sorry
("sigof type specifier");
1820 error ("`sigof' applied to non-aggregate expression");
1821 $$.t
= error_mark_node
;
1824 | SIGOF
'(' type_id
')'
1825 { tree type
= groktypename
($3.t
);
1827 $$.new_type_flag
= 0; $$.lookups
= NULL_TREE
;
1828 if
(IS_AGGR_TYPE
(type
))
1830 sorry
("sigof type specifier");
1835 error("`sigof' applied to non-aggregate type");
1836 $$.t
= error_mark_node
;
1841 /* A typespec that is a reserved word, or a type qualifier. */
1843 typespecqual_reserved:
1845 { $$.t
= $1; $$.new_type_flag
= 0; }
1847 { $$.t
= $1; $$.new_type_flag
= 0; }
1853 | initdecls
',' initdcl
1854 { check_multiple_declarators
(); }
1859 | notype_initdecls
',' initdcl
1860 { check_multiple_declarators
(); }
1865 | nomods_initdecls
',' initdcl
1866 { check_multiple_declarators
(); }
1872 | asm_keyword
'(' string ')'
1873 { if
(TREE_CHAIN
($3)) $3 = combine_strings
($3); $$
= $3; }
1877 declarator maybeasm maybe_attribute
'='
1879 deferred_type_access_control
();
1880 $
<ttype
>$
= start_decl
($
<ttype
>1, current_declspecs
, 1,
1881 $3, prefix_attributes
);
1884 /* Note how the declaration of the variable is in effect while its init is parsed! */
1885 { cp_finish_decl
($
<ttype
>5, $6, $2, LOOKUP_ONLYCONVERTING
); }
1886 | declarator maybeasm maybe_attribute
1888 deferred_type_access_control
();
1889 $
<ttype
>$
= start_decl
($
<ttype
>1, current_declspecs
, 0,
1890 $3, prefix_attributes
);
1891 cp_finish_decl
($
<ttype
>$
, NULL_TREE
, $2, 0);
1895 /* This rule assumes a certain configuration of the parser stack.
1896 In particular, $0, the element directly before the beginning of
1897 this rule on the stack, must be a maybeasm. $-1 must be a
1898 declarator or notype_declarator. And $-2 must be some declmods
1899 or declspecs. We can't move the maybeasm into this rule because
1900 we need that reduce so we prefer fn.def1 when appropriate. */
1903 { parse_decl
($
<ttype
>-1, $
<ftype
>-2.t
, $
<ftype
>-2.lookups
,
1904 $1, 1, &$
<ttype
>$
); }
1905 /* Note how the declaration of the variable is in effect
1906 while its init is parsed! */
1908 { cp_finish_decl
($
<ttype
>3, $4, $
<ttype
>0,
1909 LOOKUP_ONLYCONVERTING
); }
1912 parse_decl
($
<ttype
>-1, $
<ftype
>-2.t
, $
<ftype
>-2.lookups
,
1914 cp_finish_decl
(d
, NULL_TREE
, $
<ttype
>0, 0); }
1918 declarator maybeasm initdcl0_innards
1923 notype_declarator maybeasm initdcl0_innards
1928 notype_declarator maybeasm
1929 { /* Set things up as initdcl0_innards expects. */
1934 | constructor_declarator maybeasm maybe_attribute
1936 parse_decl
($1, NULL_TREE
, NULL_TREE
, $3, 0, &d
);
1937 cp_finish_decl
(d
, NULL_TREE
, $2, 0); }
1940 /* the * rules are dummies to accept the Apollo extended syntax
1941 so that the header files compile. */
1952 | attributes attribute
1953 { $$
= chainon
($1, $2); }
1957 ATTRIBUTE
'(' '(' attribute_list
')' ')'
1964 | attribute_list
',' attrib
1965 { $$
= chainon
($1, $3); }
1972 { $$
= build_tree_list
($1, NULL_TREE
); }
1973 | any_word
'(' IDENTIFIER
')'
1974 { $$
= build_tree_list
($1, build_tree_list
(NULL_TREE
, $3)); }
1975 | any_word
'(' IDENTIFIER
',' nonnull_exprlist
')'
1976 { $$
= build_tree_list
($1, tree_cons
(NULL_TREE
, $3, $5)); }
1977 | any_word
'(' nonnull_exprlist
')'
1978 { $$
= build_tree_list
($1, $3); }
1981 /* This still leaves out most reserved keywords,
1982 shouldn't we include them? */
1991 /* A nonempty list of identifiers, including typenames. */
1992 identifiers_or_typenames:
1994 { $$
= build_tree_list
(NULL_TREE
, $1); }
1995 | identifiers_or_typenames
',' identifier
1996 { $$
= chainon
($1, build_tree_list
(NULL_TREE
, $3)); }
2000 /* empty */ %prec EMPTY
2005 /* If we are processing a template, we don't want to expand this
2009 expr_no_commas %prec
'='
2011 { $$
= build_nt
(CONSTRUCTOR
, NULL_TREE
, NULL_TREE
);
2012 TREE_HAS_CONSTRUCTOR
($$
) = 1; }
2014 { $$
= build_nt
(CONSTRUCTOR
, NULL_TREE
, nreverse
($2));
2015 TREE_HAS_CONSTRUCTOR
($$
) = 1; }
2016 |
'{' initlist
',' '}'
2017 { $$
= build_nt
(CONSTRUCTOR
, NULL_TREE
, nreverse
($2));
2018 TREE_HAS_CONSTRUCTOR
($$
) = 1; }
2023 /* This chain is built in reverse order,
2024 and put in forward order where initlist is used. */
2027 { $$
= build_tree_list
(NULL_TREE
, $$
); }
2029 { $$
= tree_cons
(NULL_TREE
, $3, $$
); }
2030 /* These are for labeled elements. */
2031 |
'[' expr_no_commas
']' init
2032 { $$
= build_tree_list
($2, $4); }
2033 | identifier
':' init
2034 { $$
= build_tree_list
($$
, $3); }
2035 | initlist
',' identifier
':' init
2036 { $$
= tree_cons
($3, $5, $$
); }
2040 PRE_PARSED_FUNCTION_DECL
2041 { start_function
(NULL_TREE
, $1->fndecl
, NULL_TREE
,
2042 (SF_DEFAULT | SF_PRE_PARSED
2043 | SF_INCLASS_INLINE
));
2044 reinit_parse_for_function
(); }
2047 fn.defpen maybe_return_init ctor_initializer_opt compstmt_or_error
2049 expand_body
(finish_function
(lineno
, (int)$3 |
2));
2050 process_next_inline
($1);
2052 | fn.defpen maybe_return_init function_try_block
2054 expand_body
(finish_function
(lineno
, (int)$3 |
2));
2055 process_next_inline
($1);
2057 | fn.defpen maybe_return_init
error
2059 finish_function
(lineno
, 2);
2060 process_next_inline
($1); }
2065 | pending_inlines pending_inline eat_saved_input
2068 /* A regurgitated default argument. The value of DEFARG_MARKER will be
2069 the TREE_LIST node for the parameter in question. */
2071 DEFARG_MARKER expr_no_commas END_OF_SAVED_INPUT
2072 { replace_defarg
($1, $2); }
2073 | DEFARG_MARKER
error END_OF_SAVED_INPUT
2074 { replace_defarg
($1, error_mark_node
); }
2077 /* empty */ %prec EMPTY
2078 | pending_defargs defarg_again
2079 { do_pending_defargs
(); }
2080 | pending_defargs
error
2081 { do_pending_defargs
(); }
2086 { $
<ttype
>$
= current_enum_type
;
2087 current_enum_type
= start_enum
($2); }
2089 { $$.t
= finish_enum
(current_enum_type
);
2090 $$.new_type_flag
= 1;
2091 current_enum_type
= $
<ttype
>4;
2092 check_for_missing_semicolon
($$.t
); }
2094 { $
<ttype
>$
= current_enum_type
;
2095 current_enum_type
= start_enum
(make_anon_name
()); }
2097 { $$.t
= finish_enum
(current_enum_type
);
2098 $$.new_type_flag
= 1;
2099 current_enum_type
= $
<ttype
>3;
2100 check_for_missing_semicolon
($$.t
); }
2102 { $$.t
= xref_tag
(enum_type_node
, $2, 1);
2103 $$.new_type_flag
= 0; }
2104 | ENUM complex_type_name
2105 { $$.t
= xref_tag
(enum_type_node
, $2, 1);
2106 $$.new_type_flag
= 0; }
2107 | TYPENAME_KEYWORD typename_sub
2109 $$.new_type_flag
= 0;
2110 if
(!processing_template_decl
)
2111 cp_pedwarn
("using `typename' outside of template"); }
2112 /* C++ extensions, merged with C to avoid shift/reduce conflicts */
2114 { $1.t
= begin_class_definition
($1.t
); }
2115 opt.component_decl_list
'}' maybe_attribute
2119 if
(yychar == YYEMPTY
)
2121 semi
= yychar == ';';
2123 $
<ttype
>$
= finish_class_definition
($1.t
, $6, semi
,
2128 begin_inline_definitions
();
2132 finish_inline_definitions
();
2134 $$.new_type_flag
= 1;
2136 | class_head %prec EMPTY
2138 if
($1.new_type_flag
&& $1.t
!= error_mark_node
)
2139 pop_scope
(CP_DECL_CONTEXT
(TYPE_MAIN_DECL
($1.t
)));
2140 $$.new_type_flag
= 0;
2141 if
($1.t
== error_mark_node
)
2143 else if
(TYPE_BINFO
($1.t
) == NULL_TREE
)
2145 cp_error
("%T is not a class type", $1.t
);
2146 $$.t
= error_mark_node
;
2151 /* struct B: public A; is not accepted by the WP grammar. */
2152 if
(CLASS_TYPE_P
($$.t
)
2153 && TYPE_BINFO_BASETYPES
($$.t
)
2154 && !TYPE_SIZE
($$.t
)
2155 && ! TYPE_BEING_DEFINED
($$.t
))
2156 cp_error
("base clause without member specification for `%#T'",
2170 { if
(pedantic
&& !in_system_header
)
2171 pedwarn
("comma at end of enumerator list"); }
2177 { error ("storage class specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER
($2)); }
2179 { error ("type specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER
($2)); }
2181 { error ("type qualifier `%s' not allowed after struct or class", IDENTIFIER_POINTER
($2)); }
2183 { error ("no body nor ';' separates two class, struct or union declarations"); }
2185 { $$
= build_decl_list
($2, $1); }
2188 named_class_head_sans_basetype:
2196 named_class_head_sans_basetype_defn:
2197 aggr identifier_defn %prec EMPTY
2198 { current_aggr
= $$
; $$
= $2; }
2199 | named_class_head_sans_basetype
'{'
2200 { yyungetc
('{', 1); }
2201 | named_class_head_sans_basetype
':'
2202 { yyungetc
(':', 1); }
2205 named_complex_class_head_sans_basetype:
2206 aggr nested_name_specifier identifier
2209 $$.t
= handle_class_head
($1, $2, $3);
2210 $$.new_type_flag
= 1;
2212 | aggr global_scope nested_name_specifier identifier
2215 $$.t
= handle_class_head
($1, $3, $4);
2216 $$.new_type_flag
= 1;
2218 | aggr global_scope identifier
2221 $$.t
= handle_class_head
($1, NULL_TREE
, $3);
2222 $$.new_type_flag
= 1;
2224 | aggr apparent_template_type
2228 $$.new_type_flag
= 0;
2230 | aggr nested_name_specifier apparent_template_type
2234 if
(CP_DECL_CONTEXT
($$.t
))
2235 push_scope
(CP_DECL_CONTEXT
($$.t
));
2236 $$.new_type_flag
= 1;
2241 named_class_head_sans_basetype %prec EMPTY
2243 $$.t
= xref_tag
(current_aggr
, $1, 1);
2244 $$.new_type_flag
= 0;
2246 | named_class_head_sans_basetype_defn
2247 { $
<ttype
>$
= xref_tag
(current_aggr
, $1, 0); }
2248 /* Class name is unqualified, so we look for base classes
2249 in the current scope. */
2250 maybe_base_class_list %prec EMPTY
2253 $$.new_type_flag
= 0;
2255 xref_basetypes
(current_aggr
, $1, $
<ttype
>2, $3);
2257 | named_complex_class_head_sans_basetype
2258 maybe_base_class_list
2260 if
($1.t
!= error_mark_node
)
2262 $$.t
= TREE_TYPE
($1.t
);
2263 $$.new_type_flag
= $1.new_type_flag
;
2264 if
(current_aggr
== union_type_node
2265 && TREE_CODE
($$.t
) != UNION_TYPE
)
2266 cp_pedwarn
("`union' tag used in declaring `%#T'",
2268 else if
(TREE_CODE
($$.t
) == UNION_TYPE
2269 && current_aggr
!= union_type_node
)
2270 cp_pedwarn
("non-`union' tag used in declaring `%#T'", $$
);
2271 else if
(TREE_CODE
($$.t
) == RECORD_TYPE
)
2272 /* We might be specializing a template with a different
2274 CLASSTYPE_DECLARED_CLASS
($$.t
)
2275 = (current_aggr
== class_type_node
);
2278 maybe_process_partial_specialization
($$.t
);
2279 xref_basetypes
(current_aggr
, $1.t
, $$.t
, $2);
2287 { $$
= xref_tag
($$
, make_anon_name
(), 0);
2288 yyungetc
('{', 1); }
2291 /* The tree output of this nonterminal a declarationf or the type
2292 named. If NEW_TYPE_FLAG is set, then the name used in this
2293 class-head was explicitly qualified, e.g.: `struct X::Y'. We have
2294 already called push_scope for X. */
2299 $$.new_type_flag
= 0;
2304 maybe_base_class_list:
2305 /* empty */ %prec EMPTY
2307 |
':' see_typename %prec EMPTY
2308 { yyungetc
(':', 1); $$
= NULL_TREE
; }
2309 |
':' see_typename base_class_list %prec EMPTY
2315 | base_class_list
',' see_typename base_class
2316 { $$
= chainon
($$
, $4); }
2321 { $$
= finish_base_specifier
(access_default_node
, $1); }
2322 | base_class_access_list see_typename base_class
.1
2323 { $$
= finish_base_specifier
($1, $3); }
2328 { if
($$
== error_mark_node
)
2330 else if
(!TYPE_P
($$
))
2331 $$
= error_mark_node
;
2333 $$
= TYPE_MAIN_DECL
($1); }
2337 base_class_access_list:
2338 VISSPEC see_typename
2339 | SCSPEC see_typename
2340 { if
($1 != ridpointers
[(int)RID_VIRTUAL
])
2341 cp_error
("`%D' access", $1);
2342 $$
= access_default_virtual_node
; }
2343 | base_class_access_list VISSPEC see_typename
2345 if
($1 != access_default_virtual_node
)
2346 error ("multiple access specifiers");
2347 else if
($2 == access_public_node
)
2348 $$
= access_public_virtual_node
;
2349 else if
($2 == access_protected_node
)
2350 $$
= access_protected_virtual_node
;
2351 else
/* $2 == access_private_node */
2352 $$
= access_private_virtual_node
;
2354 | base_class_access_list SCSPEC see_typename
2355 { if
($2 != ridpointers
[(int)RID_VIRTUAL
])
2356 cp_error
("`%D' access", $2);
2357 else if
($$
== access_public_node
)
2358 $$
= access_public_virtual_node
;
2359 else if
($$
== access_protected_node
)
2360 $$
= access_protected_virtual_node
;
2361 else if
($$
== access_private_node
)
2362 $$
= access_private_virtual_node
;
2364 error ("multiple `virtual' specifiers");
2368 opt.component_decl_list
:
2369 | component_decl_list
2370 | opt.component_decl_list access_specifier component_decl_list
2371 | opt.component_decl_list access_specifier
2377 current_access_specifier
= $1;
2381 /* Note: we no longer warn about the semicolon after a component_decl_list.
2382 ARM $9.2 says that the semicolon is optional, and therefore allowed. */
2383 component_decl_list:
2386 finish_member_declaration
($1);
2388 | component_decl_list component_decl
2390 finish_member_declaration
($2);
2395 component_decl_1
';'
2396 | component_decl_1
'}'
2397 { error ("missing ';' before right brace");
2398 yyungetc
('}', 0); }
2399 /* C++: handle constructors, destructors and inline functions */
2400 /* note that INLINE is like a TYPESPEC */
2401 | fn.def2
':' /* base_init compstmt */
2402 { $$
= finish_method
($$
); }
2403 | fn.def2 TRY
/* base_init compstmt */
2404 { $$
= finish_method
($$
); }
2405 | fn.def2 RETURN_KEYWORD
/* base_init compstmt */
2406 { $$
= finish_method
($$
); }
2407 | fn.def2
'{' /* nodecls compstmt */
2408 { $$
= finish_method
($$
); }
2411 | extension component_decl
2414 | template_header component_decl
2417 $$
= finish_member_template_decl
($2);
2419 /* The component was already processed. */
2422 finish_template_decl
($1);
2424 | template_header typed_declspecs
';'
2426 $$
= finish_member_class_template
($2.t
);
2427 finish_template_decl
($1);
2432 /* Do not add a "typed_declspecs declarator" rule here for
2433 speed; we need to call grok_x_components for enums, so the
2434 speedup would be insignificant. */
2435 typed_declspecs components
2437 /* Most of the productions for component_decl only
2438 allow the creation of one new member, so we call
2439 finish_member_declaration in component_decl_list.
2440 For this rule and the next, however, there can be
2441 more than one member, e.g.:
2445 and we need the first member to be fully
2446 registered before the second is processed.
2447 Therefore, the rules for components take care of
2448 this processing. To avoid registering the
2449 components more than once, we send NULL_TREE up
2450 here; that lets finish_member_declaration know
2451 that there is nothing to do. */
2453 grok_x_components
($1.t
);
2456 | declmods notype_components
2459 grok_x_components
($1.t
);
2462 | notype_declarator maybeasm maybe_attribute maybe_init
2463 { $$
= grokfield
($$
, NULL_TREE
, $4, $2,
2464 build_tree_list
($3, NULL_TREE
)); }
2465 | constructor_declarator maybeasm maybe_attribute maybe_init
2466 { $$
= grokfield
($$
, NULL_TREE
, $4, $2,
2467 build_tree_list
($3, NULL_TREE
)); }
2468 |
':' expr_no_commas
2469 { $$
= grokbitfield
(NULL_TREE
, NULL_TREE
, $2); }
2473 /* These rules introduce a reduce/reduce conflict; in
2474 typedef int foo, bar;
2478 should "A::foo" be declared as a function or "A::bar" as a data
2479 member? In other words, is "bar" an after_type_declarator or a
2481 | declmods component_constructor_declarator maybeasm maybe_attribute maybe_init
2482 { tree specs
, attrs
;
2483 split_specs_attrs
($1.t
, &specs
, &attrs
);
2484 $$
= grokfield
($2, specs
, $5, $3,
2485 build_tree_list
($4, attrs
)); }
2486 | component_constructor_declarator maybeasm maybe_attribute maybe_init
2487 { $$
= grokfield
($$
, NULL_TREE
, $4, $2,
2488 build_tree_list
($3, NULL_TREE
)); }
2490 { $$
= do_class_using_decl
($1); }
2492 /* The case of exactly one component is handled directly by component_decl. */
2495 /* empty: possibly anonymous */
2497 | component_declarator0
2499 if
(PROCESSING_REAL_TEMPLATE_DECL_P
())
2500 $1 = finish_member_template_decl
($1);
2501 finish_member_declaration
($1);
2504 | components
',' component_declarator
2506 check_multiple_declarators
();
2507 if
(PROCESSING_REAL_TEMPLATE_DECL_P
())
2508 $3 = finish_member_template_decl
($3);
2509 finish_member_declaration
($3);
2515 /* empty: possibly anonymous */
2517 | notype_component_declarator0
2519 if
(PROCESSING_REAL_TEMPLATE_DECL_P
())
2520 $1 = finish_member_template_decl
($1);
2521 finish_member_declaration
($1);
2524 | notype_components
',' notype_component_declarator
2526 check_multiple_declarators
();
2527 if
(PROCESSING_REAL_TEMPLATE_DECL_P
())
2528 $3 = finish_member_template_decl
($3);
2529 finish_member_declaration
($3);
2534 component_declarator0:
2535 after_type_component_declarator0
2536 | notype_component_declarator0
2539 component_declarator:
2540 after_type_component_declarator
2541 | notype_component_declarator
2544 after_type_component_declarator0:
2545 after_type_declarator maybeasm maybe_attribute maybe_init
2546 { split_specs_attrs
($
<ttype
>0, ¤t_declspecs
,
2547 &prefix_attributes
);
2548 $
<ttype
>0 = current_declspecs
;
2549 $$
= grokfield
($$
, current_declspecs
, $4, $2,
2550 build_tree_list
($3, prefix_attributes
)); }
2551 | TYPENAME
':' expr_no_commas maybe_attribute
2552 { split_specs_attrs
($
<ttype
>0, ¤t_declspecs
,
2553 &prefix_attributes
);
2554 $
<ttype
>0 = current_declspecs
;
2555 $$
= grokbitfield
($$
, current_declspecs
, $3);
2556 cplus_decl_attributes
($$
, $4, prefix_attributes
); }
2559 notype_component_declarator0:
2560 notype_declarator maybeasm maybe_attribute maybe_init
2561 { split_specs_attrs
($
<ttype
>0, ¤t_declspecs
,
2562 &prefix_attributes
);
2563 $
<ttype
>0 = current_declspecs
;
2564 $$
= grokfield
($$
, current_declspecs
, $4, $2,
2565 build_tree_list
($3, prefix_attributes
)); }
2566 | constructor_declarator maybeasm maybe_attribute maybe_init
2567 { split_specs_attrs
($
<ttype
>0, ¤t_declspecs
,
2568 &prefix_attributes
);
2569 $
<ttype
>0 = current_declspecs
;
2570 $$
= grokfield
($$
, current_declspecs
, $4, $2,
2571 build_tree_list
($3, prefix_attributes
)); }
2572 | IDENTIFIER
':' expr_no_commas maybe_attribute
2573 { split_specs_attrs
($
<ttype
>0, ¤t_declspecs
,
2574 &prefix_attributes
);
2575 $
<ttype
>0 = current_declspecs
;
2576 $$
= grokbitfield
($$
, current_declspecs
, $3);
2577 cplus_decl_attributes
($$
, $4, prefix_attributes
); }
2578 |
':' expr_no_commas maybe_attribute
2579 { split_specs_attrs
($
<ttype
>0, ¤t_declspecs
,
2580 &prefix_attributes
);
2581 $
<ttype
>0 = current_declspecs
;
2582 $$
= grokbitfield
(NULL_TREE
, current_declspecs
, $2);
2583 cplus_decl_attributes
($$
, $3, prefix_attributes
); }
2586 after_type_component_declarator:
2587 after_type_declarator maybeasm maybe_attribute maybe_init
2588 { $$
= grokfield
($$
, current_declspecs
, $4, $2,
2589 build_tree_list
($3, prefix_attributes
)); }
2590 | TYPENAME
':' expr_no_commas maybe_attribute
2591 { $$
= grokbitfield
($$
, current_declspecs
, $3);
2592 cplus_decl_attributes
($$
, $4, prefix_attributes
); }
2595 notype_component_declarator:
2596 notype_declarator maybeasm maybe_attribute maybe_init
2597 { $$
= grokfield
($$
, current_declspecs
, $4, $2,
2598 build_tree_list
($3, prefix_attributes
)); }
2599 | IDENTIFIER
':' expr_no_commas maybe_attribute
2600 { $$
= grokbitfield
($$
, current_declspecs
, $3);
2601 cplus_decl_attributes
($$
, $4, prefix_attributes
); }
2602 |
':' expr_no_commas maybe_attribute
2603 { $$
= grokbitfield
(NULL_TREE
, current_declspecs
, $2);
2604 cplus_decl_attributes
($$
, $3, prefix_attributes
); }
2608 enumlist maybecomma_warn
2612 /* We chain the enumerators in reverse order.
2613 Because of the way enums are built, the order is
2614 insignificant. Take advantage of this fact. */
2618 | enumlist
',' enumerator
2623 { build_enumerator
($1, NULL_TREE
, current_enum_type
); }
2624 | identifier
'=' expr_no_commas
2625 { build_enumerator
($1, $3, current_enum_type
); }
2628 /* ANSI new-type-id (5.3.4) */
2630 type_specifier_seq new_declarator
2631 { $$.t
= build_decl_list
($1.t
, $2);
2632 $$.new_type_flag
= $1.new_type_flag
; }
2633 | type_specifier_seq %prec EMPTY
2634 { $$.t
= build_decl_list
($1.t
, NULL_TREE
);
2635 $$.new_type_flag
= $1.new_type_flag
; }
2636 /* GNU extension to allow arrays of arbitrary types with
2637 non-constant dimension. */
2638 |
'(' type_id
')' '[' expr
']'
2641 pedwarn
("ANSI C++ forbids array dimensions with parenthesized type in new");
2642 $$.t
= build_parse_node
(ARRAY_REF
, TREE_VALUE
($2.t
), $5);
2643 $$.t
= build_decl_list
(TREE_PURPOSE
($2.t
), $$.t
);
2644 $$.new_type_flag
= $2.new_type_flag
;
2649 /* empty */ %prec EMPTY
2651 | cv_qualifiers CV_QUALIFIER
2652 { $$
= decl_tree_cons
(NULL_TREE
, $2, $$
); }
2655 nonempty_cv_qualifiers:
2657 { $$.t
= hash_tree_cons
(NULL_TREE
, $1, NULL_TREE
);
2658 $$.new_type_flag
= 0; }
2659 | nonempty_cv_qualifiers CV_QUALIFIER
2660 { $$.t
= hash_tree_cons
(NULL_TREE
, $2, $1.t
);
2661 $$.new_type_flag
= $1.new_type_flag
; }
2664 /* These rules must follow the rules for function declarations
2665 and component declarations. That way, longer rules are preferred. */
2667 /* An expression which will not live on the momentary obstack. */
2669 '(' nonnull_exprlist
')'
2674 { $$
= empty_parms
(); }
2679 /* A declarator that is allowed only after an explicit typespec. */
2681 after_type_declarator_intern:
2682 after_type_declarator
2683 | attributes after_type_declarator
2685 /* Provide support for '(' attributes '*' declarator ')'
2687 $$
= decl_tree_cons
($1, $2, NULL_TREE
);
2691 /* may all be followed by prec '.' */
2692 after_type_declarator:
2693 '*' nonempty_cv_qualifiers after_type_declarator_intern %prec UNARY
2694 { $$
= make_pointer_declarator
($2.t
, $3); }
2695 |
'&' nonempty_cv_qualifiers after_type_declarator_intern %prec UNARY
2696 { $$
= make_reference_declarator
($2.t
, $3); }
2697 |
'*' after_type_declarator_intern %prec UNARY
2698 { $$
= make_pointer_declarator
(NULL_TREE
, $2); }
2699 |
'&' after_type_declarator_intern %prec UNARY
2700 { $$
= make_reference_declarator
(NULL_TREE
, $2); }
2701 | ptr_to_mem cv_qualifiers after_type_declarator_intern
2702 { tree arg
= make_pointer_declarator
($2, $3);
2703 $$
= build_parse_node
(SCOPE_REF
, $1, arg
);
2705 | direct_after_type_declarator
2708 direct_after_type_declarator:
2709 direct_after_type_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec
'.'
2710 { $$
= make_call_declarator
($$
, $2, $3, $4); }
2711 | direct_after_type_declarator
'[' expr
']'
2712 { $$
= build_parse_node
(ARRAY_REF
, $$
, $3); }
2713 | direct_after_type_declarator
'[' ']'
2714 { $$
= build_parse_node
(ARRAY_REF
, $$
, NULL_TREE
); }
2715 |
'(' after_type_declarator_intern
')'
2717 | nested_name_specifier type_name %prec EMPTY
2718 { push_nested_class
($1, 3);
2719 $$
= build_parse_node
(SCOPE_REF
, $$
, $2);
2720 TREE_COMPLEXITY
($$
) = current_class_depth
; }
2721 | type_name %prec EMPTY
2725 type_name %prec EMPTY
2727 if
(TREE_CODE
($1) == IDENTIFIER_NODE
)
2729 $$
= lookup_name
($1, 1);
2730 maybe_note_name_used_in_class
($1, $$
);
2735 | global_scope type_name
2737 if
(TREE_CODE
($2) == IDENTIFIER_NODE
)
2738 $$
= IDENTIFIER_GLOBAL_VALUE
($2);
2741 got_scope
= NULL_TREE
;
2748 | global_scope nested_type
2753 nested_name_specifier type_name %prec EMPTY
2754 { $$
= get_type_decl
($2); }
2757 /* A declarator allowed whether or not there has been
2758 an explicit typespec. These cannot redeclare a typedef-name. */
2760 notype_declarator_intern:
2762 | attributes notype_declarator
2764 /* Provide support for '(' attributes '*' declarator ')'
2766 $$
= decl_tree_cons
($1, $2, NULL_TREE
);
2771 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2772 { $$
= make_pointer_declarator
($2.t
, $3); }
2773 |
'&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2774 { $$
= make_reference_declarator
($2.t
, $3); }
2775 |
'*' notype_declarator_intern %prec UNARY
2776 { $$
= make_pointer_declarator
(NULL_TREE
, $2); }
2777 |
'&' notype_declarator_intern %prec UNARY
2778 { $$
= make_reference_declarator
(NULL_TREE
, $2); }
2779 | ptr_to_mem cv_qualifiers notype_declarator_intern
2780 { tree arg
= make_pointer_declarator
($2, $3);
2781 $$
= build_parse_node
(SCOPE_REF
, $1, arg
);
2783 | direct_notype_declarator
2786 complex_notype_declarator:
2787 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2788 { $$
= make_pointer_declarator
($2.t
, $3); }
2789 |
'&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2790 { $$
= make_reference_declarator
($2.t
, $3); }
2791 |
'*' complex_notype_declarator %prec UNARY
2792 { $$
= make_pointer_declarator
(NULL_TREE
, $2); }
2793 |
'&' complex_notype_declarator %prec UNARY
2794 { $$
= make_reference_declarator
(NULL_TREE
, $2); }
2795 | ptr_to_mem cv_qualifiers notype_declarator_intern
2796 { tree arg
= make_pointer_declarator
($2, $3);
2797 $$
= build_parse_node
(SCOPE_REF
, $1, arg
);
2799 | complex_direct_notype_declarator
2802 complex_direct_notype_declarator:
2803 direct_notype_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec
'.'
2804 { $$
= make_call_declarator
($$
, $2, $3, $4); }
2805 |
'(' complex_notype_declarator
')'
2807 | direct_notype_declarator
'[' expr
']'
2808 { $$
= build_parse_node
(ARRAY_REF
, $$
, $3); }
2809 | direct_notype_declarator
'[' ']'
2810 { $$
= build_parse_node
(ARRAY_REF
, $$
, NULL_TREE
); }
2811 | notype_qualified_id
2812 { enter_scope_of
($1); }
2813 | nested_name_specifier notype_template_declarator
2814 { got_scope
= NULL_TREE
;
2815 $$
= build_parse_node
(SCOPE_REF
, $1, $2);
2816 enter_scope_of
($$
);
2821 nested_name_specifier unqualified_id
2822 { got_scope
= NULL_TREE
;
2823 $$
= build_parse_node
(SCOPE_REF
, $$
, $2); }
2824 | nested_name_specifier object_template_id
2825 { got_scope
= NULL_TREE
;
2826 $$
= build_parse_node
(SCOPE_REF
, $1, $2); }
2829 notype_qualified_id:
2830 nested_name_specifier notype_unqualified_id
2831 { got_scope
= NULL_TREE
;
2832 $$
= build_parse_node
(SCOPE_REF
, $$
, $2); }
2833 | nested_name_specifier object_template_id
2834 { got_scope
= NULL_TREE
;
2835 $$
= build_parse_node
(SCOPE_REF
, $1, $2); }
2840 | global_scope notype_qualified_id
2845 typespec
'(' nonnull_exprlist
')'
2846 { $$
= build_functional_cast
($1.t
, $3); }
2847 | typespec
'(' expr_or_declarator_intern
')'
2848 { $$
= reparse_decl_as_expr
($1.t
, $3); }
2849 | typespec fcast_or_absdcl %prec EMPTY
2850 { $$
= reparse_absdcl_as_expr
($1.t
, $2); }
2856 | template_type %prec EMPTY
2859 nested_name_specifier:
2860 nested_name_specifier_1
2861 | nested_name_specifier nested_name_specifier_1
2863 | nested_name_specifier TEMPLATE explicit_template_type SCOPE
2865 = make_typename_type
($1, $3, /*complain=*/1); }
2868 /* Why the @#$%^& do type_name and notype_identifier need to be expanded
2869 inline here?!? (jason) */
2870 nested_name_specifier_1:
2873 if
(TREE_CODE
($1) == IDENTIFIER_NODE
)
2876 maybe_note_name_used_in_class
($1, $$
);
2879 complete_type
(TYPE_MAIN_VARIANT
(TREE_TYPE
($$
)));
2883 if
(TREE_CODE
($1) == IDENTIFIER_NODE
)
2885 got_scope
= $$
= TREE_TYPE
($$
);
2889 if
(TREE_CODE
($$
) == IDENTIFIER_NODE
)
2893 | template_type SCOPE
2894 { got_scope
= $$
= complete_type
(TREE_TYPE
($1)); }
2895 /* These break 'const i;'
2899 cp_error ("`%D' is not an aggregate typedef",
2900 lastiddecl ? lastiddecl : $$);
2901 $$ = error_mark_node;
2904 { goto failed_scope; } */
2909 | global_scope typename_sub0
2914 typename_sub1 identifier %prec EMPTY
2916 if
(TREE_CODE_CLASS
(TREE_CODE
($1)) == 't')
2917 $$
= make_typename_type
($1, $2, /*complain=*/1);
2918 else if
(TREE_CODE
($2) == IDENTIFIER_NODE
)
2919 cp_error
("`%T' is not a class or namespace", $2);
2923 if
(TREE_CODE
($$
) == TYPE_DECL
)
2924 $$
= TREE_TYPE
($$
);
2927 | typename_sub1 template_type %prec EMPTY
2928 { $$
= TREE_TYPE
($2); }
2929 | typename_sub1 explicit_template_type %prec EMPTY
2930 { $$
= make_typename_type
($1, $2, /*complain=*/1); }
2931 | typename_sub1 TEMPLATE explicit_template_type %prec EMPTY
2932 { $$
= make_typename_type
($1, $3, /*complain=*/1); }
2938 if
(TREE_CODE
($1) == IDENTIFIER_NODE
)
2939 cp_error
("`%T' is not a class or namespace", $1);
2941 | typename_sub1 typename_sub2
2943 if
(TREE_CODE_CLASS
(TREE_CODE
($1)) == 't')
2944 $$
= make_typename_type
($1, $2, /*complain=*/1);
2945 else if
(TREE_CODE
($2) == IDENTIFIER_NODE
)
2946 cp_error
("`%T' is not a class or namespace", $2);
2950 if
(TREE_CODE
($$
) == TYPE_DECL
)
2951 $$
= TREE_TYPE
($$
);
2954 | typename_sub1 explicit_template_type SCOPE
2956 = make_typename_type
($1, $2, /*complain=*/1); }
2957 | typename_sub1 TEMPLATE explicit_template_type SCOPE
2959 = make_typename_type
($1, $3, /*complain=*/1); }
2965 if
(TREE_CODE
($1) != IDENTIFIER_NODE
)
2968 /* Retrieve the type for the identifier, which might involve
2969 some computation. */
2970 got_scope
= $$
= complete_type
(IDENTIFIER_TYPE_VALUE
($1));
2972 if
($$
== error_mark_node
)
2973 cp_error
("`%T' is not a class or namespace", $1);
2977 if
(TREE_CODE
($1) != IDENTIFIER_NODE
)
2979 got_scope
= $$
= complete_type
(TREE_TYPE
($$
));
2981 | template_type SCOPE
2982 { got_scope
= $$
= complete_type
(TREE_TYPE
($$
)); }
2987 if
(TREE_CODE
($$
) == IDENTIFIER_NODE
)
2993 explicit_template_type:
2994 identifier
'<' template_arg_list_opt template_close_bracket
2995 { $$
= build_min_nt
(TEMPLATE_ID_EXPR
, $1, $3); }
2999 global_scope type_name
3001 if
(TREE_CODE
($2) == IDENTIFIER_NODE
)
3002 $$
= IDENTIFIER_GLOBAL_VALUE
($2);
3005 got_scope
= NULL_TREE
;
3008 | global_scope nested_type
3013 nested_name_specifier
'*'
3014 { got_scope
= NULL_TREE
; }
3015 | global_scope nested_name_specifier
'*'
3016 { $$
= $2; got_scope
= NULL_TREE
; }
3019 /* All uses of explicit global scope must go through this nonterminal so
3020 that got_scope will be set before yylex is called to get the next token. */
3023 { got_scope
= void_type_node
; }
3026 /* ANSI new-declarator (5.3.4) */
3028 '*' cv_qualifiers new_declarator
3029 { $$
= make_pointer_declarator
($2, $3); }
3030 |
'*' cv_qualifiers %prec EMPTY
3031 { $$
= make_pointer_declarator
($2, NULL_TREE
); }
3032 |
'&' cv_qualifiers new_declarator %prec EMPTY
3033 { $$
= make_reference_declarator
($2, $3); }
3034 |
'&' cv_qualifiers %prec EMPTY
3035 { $$
= make_reference_declarator
($2, NULL_TREE
); }
3036 | ptr_to_mem cv_qualifiers %prec EMPTY
3037 { tree arg
= make_pointer_declarator
($2, NULL_TREE
);
3038 $$
= build_parse_node
(SCOPE_REF
, $1, arg
);
3040 | ptr_to_mem cv_qualifiers new_declarator
3041 { tree arg
= make_pointer_declarator
($2, $3);
3042 $$
= build_parse_node
(SCOPE_REF
, $1, arg
);
3044 | direct_new_declarator %prec EMPTY
3047 /* ANSI direct-new-declarator (5.3.4) */
3048 direct_new_declarator:
3050 { $$
= build_parse_node
(ARRAY_REF
, NULL_TREE
, $2); }
3051 | direct_new_declarator
'[' expr
']'
3052 { $$
= build_parse_node
(ARRAY_REF
, $$
, $3); }
3059 /* Provide support for '(' attributes '*' declarator ')'
3061 $$
= decl_tree_cons
($1, $2, NULL_TREE
);
3065 /* ANSI abstract-declarator (8.1) */
3067 '*' nonempty_cv_qualifiers absdcl_intern
3068 { $$
= make_pointer_declarator
($2.t
, $3); }
3070 { $$
= make_pointer_declarator
(NULL_TREE
, $2); }
3071 |
'*' nonempty_cv_qualifiers %prec EMPTY
3072 { $$
= make_pointer_declarator
($2.t
, NULL_TREE
); }
3074 { $$
= make_pointer_declarator
(NULL_TREE
, NULL_TREE
); }
3075 |
'&' nonempty_cv_qualifiers absdcl_intern
3076 { $$
= make_reference_declarator
($2.t
, $3); }
3078 { $$
= make_reference_declarator
(NULL_TREE
, $2); }
3079 |
'&' nonempty_cv_qualifiers %prec EMPTY
3080 { $$
= make_reference_declarator
($2.t
, NULL_TREE
); }
3082 { $$
= make_reference_declarator
(NULL_TREE
, NULL_TREE
); }
3083 | ptr_to_mem cv_qualifiers %prec EMPTY
3084 { tree arg
= make_pointer_declarator
($2, NULL_TREE
);
3085 $$
= build_parse_node
(SCOPE_REF
, $1, arg
);
3087 | ptr_to_mem cv_qualifiers absdcl_intern
3088 { tree arg
= make_pointer_declarator
($2, $3);
3089 $$
= build_parse_node
(SCOPE_REF
, $1, arg
);
3091 | direct_abstract_declarator %prec EMPTY
3094 /* ANSI direct-abstract-declarator (8.1) */
3095 direct_abstract_declarator:
3096 '(' absdcl_intern
')'
3098 /* `(typedef)1' is `int'. */
3099 | direct_abstract_declarator
'(' parmlist
')' cv_qualifiers exception_specification_opt %prec
'.'
3100 { $$
= make_call_declarator
($$
, $3, $5, $6); }
3101 | direct_abstract_declarator LEFT_RIGHT cv_qualifiers exception_specification_opt %prec
'.'
3102 { $$
= make_call_declarator
($$
, empty_parms
(), $3, $4); }
3103 | direct_abstract_declarator
'[' expr
']' %prec
'.'
3104 { $$
= build_parse_node
(ARRAY_REF
, $$
, $3); }
3105 | direct_abstract_declarator
'[' ']' %prec
'.'
3106 { $$
= build_parse_node
(ARRAY_REF
, $$
, NULL_TREE
); }
3107 |
'(' complex_parmlist
')' cv_qualifiers exception_specification_opt %prec
'.'
3108 { $$
= make_call_declarator
(NULL_TREE
, $2, $4, $5); }
3109 | regcast_or_absdcl cv_qualifiers exception_specification_opt %prec
'.'
3110 { set_quals_and_spec
($$
, $2, $3); }
3111 | fcast_or_absdcl cv_qualifiers exception_specification_opt %prec
'.'
3112 { set_quals_and_spec
($$
, $2, $3); }
3113 |
'[' expr
']' %prec
'.'
3114 { $$
= build_parse_node
(ARRAY_REF
, NULL_TREE
, $2); }
3116 { $$
= build_parse_node
(ARRAY_REF
, NULL_TREE
, NULL_TREE
); }
3119 /* For C++, decls and stmts can be intermixed, so we don't need to
3120 have a special rule that won't start parsing the stmt section
3121 until we have a stmt that parses without errors. */
3134 /* Read zero or more forward-declarations for labels
3135 that nested functions can jump to. */
3140 pedwarn
("ANSI C++ forbids label declarations"); }
3145 | label_decls label_decl
3149 LABEL identifiers_or_typenames
';'
3153 finish_label_decl
(TREE_VALUE
($2));
3154 $2 = TREE_CHAIN
($2);
3159 /* This is the body of a function definition.
3160 It causes syntax errors to ignore to the next openbrace. */
3169 { $
<ttype
>$
= begin_compound_stmt
(0); }
3171 { $$
= finish_compound_stmt
(0, $
<ttype
>2); }
3177 $
<ttype
>$
= begin_if_stmt
();
3178 cond_stmt_keyword
= "if";
3181 { finish_if_stmt_cond
($3, $
<ttype
>2); }
3182 implicitly_scoped_stmt
3183 { $
<ttype
>$
= finish_then_clause
($
<ttype
>2); }
3186 implicitly_scoped_stmt:
3188 |
{ $
<ttype
>$
= begin_compound_stmt
(0); }
3190 { $$
= finish_compound_stmt
(0, $
<ttype
>1); }
3203 { finish_expr_stmt
($1); }
3205 { begin_else_clause
(); }
3206 implicitly_scoped_stmt
3208 finish_else_clause
($
<ttype
>1);
3211 | simple_if %prec IF
3212 { finish_if_stmt
(); }
3215 $
<ttype
>$
= begin_while_stmt
();
3216 cond_stmt_keyword
= "while";
3219 { finish_while_stmt_cond
($3, $
<ttype
>2); }
3221 { finish_while_stmt
($
<ttype
>2); }
3223 { $
<ttype
>$
= begin_do_stmt
(); }
3224 implicitly_scoped_stmt WHILE
3226 finish_do_body
($
<ttype
>2);
3227 cond_stmt_keyword
= "do";
3229 paren_expr_or_null
';'
3230 { finish_do_stmt
($6, $
<ttype
>2); }
3232 { $
<ttype
>$
= begin_for_stmt
(); }
3233 '(' for.init.statement
3234 { finish_for_init_stmt
($
<ttype
>2); }
3236 { finish_for_cond
($6, $
<ttype
>2); }
3238 { finish_for_expr
($9, $
<ttype
>2); }
3240 { finish_for_stmt
($9, $
<ttype
>2); }
3242 { $
<ttype
>$
= begin_switch_stmt
(); }
3244 { finish_switch_cond
($4, $
<ttype
>2); }
3245 implicitly_scoped_stmt
3246 { finish_switch_stmt
($4, $
<ttype
>2); }
3247 | CASE expr_no_commas
':'
3248 { finish_case_label
($2, NULL_TREE
); }
3250 | CASE expr_no_commas ELLIPSIS expr_no_commas
':'
3251 { finish_case_label
($2, $4); }
3254 { finish_case_label
(NULL_TREE
, NULL_TREE
); }
3257 { finish_break_stmt
(); }
3259 { finish_continue_stmt
(); }
3260 | RETURN_KEYWORD
';'
3261 { finish_return_stmt
(NULL_TREE
); }
3262 | RETURN_KEYWORD expr
';'
3263 { finish_return_stmt
($2); }
3264 | asm_keyword maybe_cv_qualifier
'(' string ')' ';'
3266 finish_asm_stmt
($2, $4, NULL_TREE
, NULL_TREE
,
3269 /* This is the case with just output operands. */
3270 | asm_keyword maybe_cv_qualifier
'(' string ':' asm_operands
')' ';'
3272 finish_asm_stmt
($2, $4, $6, NULL_TREE
,
3275 /* This is the case with input operands as well. */
3276 | asm_keyword maybe_cv_qualifier
'(' string ':' asm_operands
':' asm_operands
')' ';'
3277 { finish_asm_stmt
($2, $4, $6, $8, NULL_TREE
); }
3278 | asm_keyword maybe_cv_qualifier
'(' string SCOPE asm_operands
')' ';'
3279 { finish_asm_stmt
($2, $4, NULL_TREE
, $6, NULL_TREE
); }
3280 /* This is the case with clobbered registers as well. */
3281 | asm_keyword maybe_cv_qualifier
'(' string ':' asm_operands
':'
3282 asm_operands
':' asm_clobbers
')' ';'
3283 { finish_asm_stmt
($2, $4, $6, $8, $10); }
3284 | asm_keyword maybe_cv_qualifier
'(' string SCOPE asm_operands
':'
3285 asm_clobbers
')' ';'
3286 { finish_asm_stmt
($2, $4, NULL_TREE
, $6, $8); }
3287 | asm_keyword maybe_cv_qualifier
'(' string ':' asm_operands SCOPE
3288 asm_clobbers
')' ';'
3289 { finish_asm_stmt
($2, $4, $6, NULL_TREE
, $8); }
3293 pedwarn
("ANSI C++ forbids computed gotos");
3294 finish_goto_stmt
($3);
3296 | GOTO identifier
';'
3297 { finish_goto_stmt
($2); }
3300 { error ("label must be followed by statement");
3301 yyungetc
('}', 0); }
3306 | namespace_using_decl
3307 { do_local_using_decl
($1); }
3313 { $
<ttype
>$
= begin_function_try_block
(); }
3314 ctor_initializer_opt compstmt
3315 { finish_function_try_block
($
<ttype
>2); }
3318 finish_function_handler_sequence
($
<ttype
>2);
3325 { $
<ttype
>$
= begin_try_block
(); }
3327 { finish_try_block
($
<ttype
>2); }
3329 { finish_handler_sequence
($
<ttype
>2); }
3334 | handler_seq handler
3339 { $
<ttype
>$
= begin_handler
(); }
3341 { $
<ttype
>$
= finish_handler_parms
($3, $
<ttype
>2); }
3343 { finish_handler
($
<ttype
>4, $
<ttype
>2); }
3347 typed_typespecs %prec EMPTY
3348 | nonempty_cv_qualifiers %prec EMPTY
3354 /* This doesn't allow reference parameters, the below does.
3355 | '(' type_specifier_seq absdcl ')'
3356 { check_for_new_type ("inside exception declarations", $2);
3357 expand_start_catch_block ($2.t, $3); }
3358 | '(' type_specifier_seq ')'
3359 { check_for_new_type ("inside exception declarations", $2);
3360 expand_start_catch_block ($2.t, NULL_TREE); }
3361 | '(' type_specifier_seq notype_declarator ')'
3362 { check_for_new_type ("inside exception declarations", $2);
3363 expand_start_catch_block ($2.t, $3); }
3364 | '(' typed_typespecs after_type_declarator ')'
3365 { check_for_new_type ("inside exception declarations", $2);
3366 expand_start_catch_block ($2.t, $3); }
3367 This allows reference parameters... */
3370 check_for_new_type
("inside exception declarations", $2);
3371 $$
= start_handler_parms
(TREE_PURPOSE
($2.t
),
3378 { finish_label_stmt
($1); }
3380 { finish_label_stmt
($1); }
3382 { finish_label_stmt
($1); }
3384 { finish_label_stmt
($1); }
3389 { finish_expr_stmt
($1); }
3393 pedwarn
("ANSI C++ forbids compound statements inside for initializations");
3397 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
3401 { emit_line_note
(input_filename
, lineno
);
3404 { emit_line_note
(input_filename
, lineno
); }
3415 /* These are the operands other than the first string and colon
3416 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
3420 | nonnull_asm_operands
3423 nonnull_asm_operands:
3425 | nonnull_asm_operands
',' asm_operand
3426 { $$
= chainon
($$
, $3); }
3431 { $$
= build_tree_list
($$
, $3); }
3436 { $$
= tree_cons
(NULL_TREE
, $$
, NULL_TREE
); }
3437 | asm_clobbers
',' STRING
3438 { $$
= tree_cons
(NULL_TREE
, $3, $$
); }
3441 /* This is what appears inside the parens in a function declarator.
3442 Its value is represented in the format that grokdeclarator expects.
3444 In C++, declaring a function with no parameters
3445 means that that function takes *no* parameters. */
3454 { $$
= finish_parmlist
(build_tree_list
(NULL_TREE
, $1.t
), 0);
3455 check_for_new_type
("inside parameter list", $1); }
3458 /* This nonterminal does not include the common sequence '(' type_id ')',
3459 as it is ambiguous and must be disambiguated elsewhere. */
3462 { $$
= finish_parmlist
($$
, 0); }
3463 | parms_comma ELLIPSIS
3464 { $$
= finish_parmlist
($1, 1); }
3465 /* C++ allows an ellipsis without a separating ',' */
3467 { $$
= finish_parmlist
($1, 1); }
3469 { $$
= finish_parmlist
(build_tree_list
(NULL_TREE
,
3472 { $$
= finish_parmlist
(NULL_TREE
, 1); }
3475 /* This helps us recover from really nasty
3476 parse errors, for example, a missing right
3478 yyerror ("possibly missing ')'");
3479 $$
= finish_parmlist
($1, 0);
3485 /* This helps us recover from really nasty
3486 parse errors, for example, a missing right
3488 yyerror ("possibly missing ')'");
3489 $$
= finish_parmlist
(build_tree_list
(NULL_TREE
,
3496 /* A default argument to a */
3499 { maybe_snarf_defarg
(); }
3509 /* A nonempty list of parameter declarations or type names. */
3512 { check_for_new_type
("in a parameter list", $1);
3513 $$
= build_tree_list
(NULL_TREE
, $1.t
); }
3515 { check_for_new_type
("in a parameter list", $1);
3516 $$
= build_tree_list
($2, $1.t
); }
3517 | parms_comma full_parm
3518 { check_for_new_type
("in a parameter list", $2);
3519 $$
= chainon
($$
, $2.t
); }
3520 | parms_comma bad_parm
3521 { $$
= chainon
($$
, build_tree_list
(NULL_TREE
, $2)); }
3522 | parms_comma bad_parm
'=' init
3523 { $$
= chainon
($$
, build_tree_list
($4, $2)); }
3529 { check_for_new_type
("in a parameter list", $1);
3530 $$
= build_tree_list
(NULL_TREE
, $1.t
); }
3533 /* A single parameter declaration or parameter type name,
3534 as found in a parmlist. */
3536 /* Here we expand typed_declspecs inline to avoid mis-parsing of
3537 TYPESPEC IDENTIFIER. */
3538 typed_declspecs1 declarator
3539 { tree specs
= strip_attrs
($1.t
);
3540 $$.new_type_flag
= $1.new_type_flag
;
3541 $$.t
= build_tree_list
(specs
, $2); }
3542 | typed_typespecs declarator
3543 { $$.t
= build_tree_list
($1.t
, $2);
3544 $$.new_type_flag
= $1.new_type_flag
; }
3545 | typespec declarator
3546 { $$.t
= build_tree_list
(build_decl_list
(NULL_TREE
, $1.t
),
3548 $$.new_type_flag
= $1.new_type_flag
; }
3549 | typed_declspecs1 absdcl
3550 { tree specs
= strip_attrs
($1.t
);
3551 $$.t
= build_tree_list
(specs
, $2);
3552 $$.new_type_flag
= $1.new_type_flag
; }
3553 | typed_declspecs1 %prec EMPTY
3554 { tree specs
= strip_attrs
($1.t
);
3555 $$.t
= build_tree_list
(specs
, NULL_TREE
);
3556 $$.new_type_flag
= $1.new_type_flag
; }
3557 | declmods notype_declarator
3558 { tree specs
= strip_attrs
($1.t
);
3559 $$.t
= build_tree_list
(specs
, $2);
3560 $$.new_type_flag
= 0; }
3565 { $$.t
= build_tree_list
(NULL_TREE
, $1.t
);
3566 $$.new_type_flag
= $1.new_type_flag
; }
3568 { $$.t
= build_tree_list
($2, $1.t
);
3569 $$.new_type_flag
= $1.new_type_flag
; }
3578 /* empty */ %prec EMPTY
3579 { see_typename
(); }
3583 /* empty */ %prec EMPTY
3585 error ("type specifier omitted for parameter");
3586 $$
= build_tree_list
(integer_type_node
, NULL_TREE
);
3590 error ("type specifier omitted for parameter");
3591 if
(TREE_CODE
($$
) == SCOPE_REF
3592 && (TREE_CODE
(TREE_OPERAND
($$
, 0)) == TEMPLATE_TYPE_PARM
3593 || TREE_CODE
(TREE_OPERAND
($$
, 0)) == TEMPLATE_TEMPLATE_PARM
))
3594 cp_error
(" perhaps you want `typename %E' to make it a type", $$
);
3595 $$
= build_tree_list
(integer_type_node
, $$
);
3599 exception_specification_opt:
3600 /* empty */ %prec EMPTY
3602 | THROW
'(' ansi_raise_identifiers
')' %prec EMPTY
3604 | THROW LEFT_RIGHT %prec EMPTY
3605 { $$
= empty_except_spec
; }
3608 ansi_raise_identifier:
3611 check_for_new_type
("exception specifier", $1);
3612 $$
= groktypename
($1.t
);
3616 ansi_raise_identifiers:
3617 ansi_raise_identifier
3618 { $$
= add_exception_specifier
(NULL_TREE
, $1, 1); }
3619 | ansi_raise_identifiers
',' ansi_raise_identifier
3620 { $$
= add_exception_specifier
($1, $3, 1); }
3623 conversion_declarator:
3624 /* empty */ %prec EMPTY
3626 |
'*' cv_qualifiers conversion_declarator
3627 { $$
= make_pointer_declarator
($2, $3); }
3628 |
'&' cv_qualifiers conversion_declarator
3629 { $$
= make_reference_declarator
($2, $3); }
3630 | ptr_to_mem cv_qualifiers conversion_declarator
3631 { tree arg
= make_pointer_declarator
($2, $3);
3632 $$
= build_parse_node
(SCOPE_REF
, $1, arg
);
3638 { got_scope
= NULL_TREE
; }
3643 { $$
= ansi_opname
[MULT_EXPR
]; }
3645 { $$
= ansi_opname
[TRUNC_DIV_EXPR
]; }
3647 { $$
= ansi_opname
[TRUNC_MOD_EXPR
]; }
3649 { $$
= ansi_opname
[PLUS_EXPR
]; }
3651 { $$
= ansi_opname
[MINUS_EXPR
]; }
3653 { $$
= ansi_opname
[BIT_AND_EXPR
]; }
3655 { $$
= ansi_opname
[BIT_IOR_EXPR
]; }
3657 { $$
= ansi_opname
[BIT_XOR_EXPR
]; }
3659 { $$
= ansi_opname
[BIT_NOT_EXPR
]; }
3661 { $$
= ansi_opname
[COMPOUND_EXPR
]; }
3662 | operator ARITHCOMPARE
3663 { $$
= ansi_opname
[$2]; }
3665 { $$
= ansi_opname
[LT_EXPR
]; }
3667 { $$
= ansi_opname
[GT_EXPR
]; }
3668 | operator EQCOMPARE
3669 { $$
= ansi_opname
[$2]; }
3671 { $$
= ansi_assopname
[$2]; }
3673 { $$
= ansi_opname
[MODIFY_EXPR
]; }
3675 { $$
= ansi_opname
[$2]; }
3677 { $$
= ansi_opname
[$2]; }
3679 { $$
= ansi_opname
[POSTINCREMENT_EXPR
]; }
3680 | operator MINUSMINUS
3681 { $$
= ansi_opname
[PREDECREMENT_EXPR
]; }
3683 { $$
= ansi_opname
[TRUTH_ANDIF_EXPR
]; }
3685 { $$
= ansi_opname
[TRUTH_ORIF_EXPR
]; }
3687 { $$
= ansi_opname
[TRUTH_NOT_EXPR
]; }
3689 { $$
= ansi_opname
[COND_EXPR
]; }
3691 { $$
= ansi_opname
[$2]; }
3692 | operator POINTSAT %prec EMPTY
3693 { $$
= ansi_opname
[COMPONENT_REF
]; }
3694 | operator POINTSAT_STAR %prec EMPTY
3695 { $$
= ansi_opname
[MEMBER_REF
]; }
3696 | operator LEFT_RIGHT
3697 { $$
= ansi_opname
[CALL_EXPR
]; }
3699 { $$
= ansi_opname
[ARRAY_REF
]; }
3700 | operator NEW %prec EMPTY
3701 { $$
= ansi_opname
[NEW_EXPR
]; }
3702 | operator DELETE %prec EMPTY
3703 { $$
= ansi_opname
[DELETE_EXPR
]; }
3704 | operator NEW
'[' ']'
3705 { $$
= ansi_opname
[VEC_NEW_EXPR
]; }
3706 | operator DELETE
'[' ']'
3707 { $$
= ansi_opname
[VEC_DELETE_EXPR
]; }
3708 /* Names here should be looked up in class scope ALSO. */
3709 | operator type_specifier_seq conversion_declarator
3710 { $$
= grokoptypename
($2.t
, $3); }
3712 { $$
= ansi_opname
[ERROR_MARK
]; }
3719 debug_yytranslate
(value
)
3722 return yytname
[YYTRANSLATE
(value
)];