2 * This code is derived from software copyrighted by the Free Software
5 * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
8 /* YACC parser for C++ syntax.
9 Copyright (C) 1988, 1989 Free Software Foundation, Inc.
10 Hacked by Michael Tiemann (tiemann@mcc.com)
12 This file is part of GNU CC.
14 GNU CC is free software; you can redistribute it and/or modify
15 it under the terms of the GNU General Public License as published by
16 the Free Software Foundation; either version 1, or (at your option)
19 GNU CC is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details.
24 You should have received a copy of the GNU General Public License
25 along with GNU CC; see the file COPYING. If not, write to
26 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
29 /* This grammar is based on the GNU CC grammar. */
31 /* Also note: this version contains experimental exception
32 handling features. They could break, change, disappear,
33 or otherwise exhibit volatile behavior. Don't depend on
34 me (Michael Tiemann) to protect you from any negative impact
35 this may have on your professional, personal, or spiritual life. */
39 static char sccsid
[] = "@(#)cplus-parse.y 6.3 (Berkeley) 5/8/91";
45 #include "cplus-parse.h"
46 #include "cplus-tree.h"
50 extern tree ridpointers
[]; /* need this up here */
51 extern tree void_list_node
;
53 /* Bison compatibility */
64 extern
int end_of_file
;
68 /* Contains error message to give if user tries to declare
69 a variable where one does not belong. */
70 static char *stmt_decl_msg
= 0;
73 /* Cause the `yydebug' variable to be defined. */
77 /* Cons up an empty parameter list. */
87 parms
= void_list_node
;
98 %
union {long itype
; tree ttype
; enum tree_code code
; }
100 /* All identifiers that are not reserved words
101 and are not declared typedefs in the current block */
104 /* All identifiers that are declared typedefs in the current block.
105 In some contexts, they are treated just like IDENTIFIER,
106 but they can also serve as typespecs in declarations. */
109 /* Reserved words that specify storage class.
110 yylval contains an IDENTIFIER_NODE which indicates which one. */
113 /* Reserved words that specify type.
114 yylval contains an IDENTIFIER_NODE which indicates which one. */
117 /* Reserved words that qualify type: "const" or "volatile".
118 yylval contains an IDENTIFIER_NODE which indicates which one. */
121 /* Character or numeric constants.
122 yylval is the node for the constant. */
125 /* String constants in raw form.
126 yylval is a STRING_CST node. */
129 /* "...", used for functions with variable arglists. */
132 /* the reserved words */
133 %token SIZEOF ENUM
/* STRUCT UNION */ IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
134 %token BREAK CONTINUE RETURN GOTO ASM TYPEOF ALIGNOF
137 /* the reserved words... C++ extensions */
139 %token DELETE NEW OVERLOAD PRIVATE PUBLIC PROTECTED THIS OPERATOR
140 %token DYNAMIC POINTSAT_LEFT_RIGHT LEFT_RIGHT
143 /* Define the operator tokens and their precedences.
144 The value is an integer because, if used, it is the tree code
145 to use in the expression made from the operator. */
147 %left EMPTY
/* used to resolve s/r with epsilon */
149 /* Add precedence rules to solve dangling else s/r conflict */
153 %left IDENTIFIER TYPENAME TYPENAME_COLON SCSPEC TYPESPEC TYPE_QUAL ENUM AGGR
157 %right
<code
> ASSIGN
'='
158 %right
<code
> '?' ':' RANGE
165 %left
<code
> EQCOMPARE
166 %left
<code
> ARITHCOMPARE
167 %left
<code
> LSHIFT RSHIFT
169 %left
<code
> '*' '/' '%'
170 %right
<code
> UNARY PLUSPLUS MINUSMINUS
172 %left
<ttype
> PAREN_STAR_PAREN PAREN_X_SCOPE_STAR_PAREN PAREN_X_SCOPE_REF_PAREN LEFT_RIGHT
173 %left
<code
> POINTSAT
'.' '(' '['
175 %right SCOPE
/* C++ extension */
176 %nonassoc NEW DELETE RAISE RAISES RERAISE TRY EXCEPT CATCH
181 %type
<ttype
> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist
/* exprlist */
182 %type
<ttype
> expr_no_commas cast_expr unary_expr primary
string STRING
183 %type
<ttype
> typed_declspecs reserved_declspecs
184 %type
<ttype
> typed_typespecs reserved_typespecquals
185 %type
<ttype
> declmods typespec typespecqual_reserved
186 %type
<ttype
> SCSPEC TYPESPEC TYPE_QUAL nonempty_type_quals maybe_type_qual
187 %type
<itype
> initdecls notype_initdecls initdcl
/* C++ modification */
188 %type
<ttype
> init initlist maybeasm
189 %type
<ttype
> asm_operands nonnull_asm_operands asm_operand asm_clobbers
190 %type
<ttype
> maybe_attribute attribute_list attrib
192 %type
<ttype
> compstmt except_stmts
194 %type
<ttype
> declarator notype_declarator after_type_declarator
196 %type
<ttype
> structsp opt.component_decl_list component_decl_list component_decl components component_declarator
197 %type
<ttype
> enumlist enumerator
198 %type
<ttype
> typename absdcl absdcl1 type_quals
199 %type
<ttype
> xexpr see_typename parmlist parms parm bad_parm
202 %token
<ttype
> TYPENAME_COLON TYPENAME_SCOPE TYPENAME_ELLIPSIS
203 %token
<ttype
> PRE_PARSED_FUNCTION_DECL EXTERN_LANG_STRING ALL
204 %type
<ttype
> fn.def2 dummy_decl x_typespec return_id
205 %type
<ttype
> class_head opt.init base_class_list base_class_visibility_list
206 %type
<ttype
> after_type_declarator_no_typename
207 %type
<ttype
> maybe_raises raise_identifier raise_identifiers
208 %type
<ttype
> component_declarator0 scoped_identifier
209 %type
<ttype
> forhead
.1 identifier_or_opname operator_name
210 %type
<ttype
> new delete object primary_no_id aggr nonmomentary_expr
211 %type
<itype
> LC forhead
.2 initdcl0 notype_initdcl0 wrapper member_init_list
212 %type
<itype
> .scope try
215 /* the declaration found for the last IDENTIFIER token read in.
216 yylex must look this up to detect typedefs, which get token type TYPENAME,
217 so it is left around in case the identifier is not a typedef but is
218 used in a context which makes it a reference to a variable. */
221 tree make_pointer_declarator
(), make_reference_declarator
();
223 tree combine_strings
();
224 void reinit_parse_for_function
();
225 void reinit_parse_for_method
();
227 /* List of types and structure classes of the current declaration. */
228 tree current_declspecs
;
230 int undeclared_variable_notice
; /* 1 if we explained undeclared var errors. */
237 program: .program
/* empty */
242 .program
: /* empty */
248 /* the reason for the strange actions in this rule
249 is so that notype_initdecls when reached via datadef
250 can find a valid list of type and sc specs in $0. */
253 {$
<ttype
>$
= NULL_TREE
; } extdef
254 | extdefs
{$
<ttype
>$
= NULL_TREE
; } extdef
259 { if
(pending_inlines
) do_pending_inlines
(); }
261 { if
(pending_inlines
) do_pending_inlines
(); }
263 | ASM
'(' string ')' ';'
265 warning
("ANSI C forbids use of `asm' keyword");
266 if
(TREE_CHAIN
($3)) $3 = combine_strings
($3);
268 | extern_lang_string
'{' extdefs
'}'
269 { pop_lang_context
(); }
270 | extern_lang_string
'{' '}'
271 { pop_lang_context
(); }
272 | extern_lang_string fndef
273 { if
(pending_inlines
) do_pending_inlines
();
274 pop_lang_context
(); }
275 | extern_lang_string datadef
276 { if
(pending_inlines
) do_pending_inlines
();
277 pop_lang_context
(); }
282 { push_lang_context
($1); }
286 OVERLOAD ov_identifiers
';'
288 ov_identifiers: IDENTIFIER
289 { declare_overloaded
($1); }
290 | ov_identifiers
',' IDENTIFIER
291 { declare_overloaded
($3); }
294 dummy_decl: /* empty */
299 dummy_decl notype_initdecls
';'
301 error ("ANSI C forbids data definition lacking type or storage class");
302 else if
(! flag_traditional
)
303 warning
("data definition lacks type or storage class"); }
304 | declmods notype_initdecls
';'
306 /* Normal case to make fast: "int i;". */
307 | declmods declarator
';'
309 d
= start_decl
($2, $1, 0, NULL_TREE
);
310 finish_decl
(d
, NULL_TREE
, NULL_TREE
);
312 | typed_declspecs initdecls
';'
314 end_exception_decls
();
315 note_got_semicolon
($1);
317 /* Normal case: make this fast. */
318 | typed_declspecs declarator
';'
320 d
= start_decl
($2, $1, 0, NULL_TREE
);
321 finish_decl
(d
, NULL_TREE
, NULL_TREE
);
322 end_exception_decls
();
323 note_got_semicolon
($1);
326 { error ("empty declaration"); }
327 | typed_declspecs
';'
330 note_got_semicolon
($1);
338 fn.def1 base_init compstmt_or_error
340 finish_function
(lineno
, 1);
341 /* finish_function performs these three statements:
343 expand_end_bindings (getdecls (), 1, 0);
346 expand_end_bindings (0, 0, 0);
350 | fn.def1 return_init base_init compstmt_or_error
352 finish_function
(lineno
, 1);
353 /* finish_function performs these three statements:
355 expand_end_bindings (getdecls (), 1, 0);
358 expand_end_bindings (0, 0, 0);
362 | fn.def1 nodecls compstmt_or_error
363 { finish_function
(lineno
, 0); }
364 | fn.def1 return_init
';' nodecls compstmt_or_error
365 { finish_function
(lineno
, 0); }
366 | fn.def1 return_init nodecls compstmt_or_error
367 { finish_function
(lineno
, 0); }
368 | typed_declspecs declarator
error
370 | declmods notype_declarator
error
372 | dummy_decl notype_declarator
error
377 typed_declspecs declarator maybe_raises
378 { if
(! start_function
($1, $2, $3, 0))
380 reinit_parse_for_function
(); }
381 | declmods notype_declarator maybe_raises
382 { if
(! start_function
($1, $2, $3, 0))
384 reinit_parse_for_function
(); }
385 | dummy_decl notype_declarator maybe_raises
386 { if
(! start_function
(NULL_TREE
, $2, $3, 0))
388 reinit_parse_for_function
(); }
389 | dummy_decl TYPENAME
'(' parmlist
')' type_quals maybe_raises
390 { if
(! start_function
(NULL_TREE
, build_parse_node
(CALL_EXPR
, $2, $4, $6), $7, 0))
392 reinit_parse_for_function
(); }
393 | dummy_decl TYPENAME LEFT_RIGHT type_quals maybe_raises
394 { if
(! start_function
(NULL_TREE
, build_parse_node
(CALL_EXPR
, $2, empty_parms
(), $4), $5, 0))
396 reinit_parse_for_function
(); }
397 | PRE_PARSED_FUNCTION_DECL
398 { start_function
(NULL_TREE
, $1, NULL_TREE
, 1);
399 reinit_parse_for_function
(); }
402 /* more C++ complexity */
404 typed_declspecs
'(' parmlist
')' type_quals maybe_raises
406 tree decl
= build_parse_node
(CALL_EXPR
, TREE_VALUE
($1), $3, $5);
407 $$
= start_method
(TREE_CHAIN
($1), decl
, $6);
412 reinit_parse_for_method
(yychar, $$
); }
413 | typed_declspecs LEFT_RIGHT type_quals maybe_raises
415 tree decl
= build_parse_node
(CALL_EXPR
, TREE_VALUE
($1), empty_parms
(), $3);
416 $$
= start_method
(TREE_CHAIN
($1), decl
, $4);
419 if
(yychar == YYEMPTY
)
421 reinit_parse_for_method
(yychar, $$
); }
422 | typed_declspecs declarator maybe_raises
423 { $$
= start_method
($1, $2, $3);
426 if
(yychar == YYEMPTY
)
428 reinit_parse_for_method
(yychar, $$
); }
429 | declmods
'(' parmlist
')' type_quals maybe_raises
431 tree decl
= build_parse_node
(CALL_EXPR
, TREE_VALUE
($1), $3, $5);
432 $$
= start_method
(TREE_CHAIN
($1), decl
, $6);
435 if
(yychar == YYEMPTY
)
437 reinit_parse_for_method
(yychar, $$
); }
438 | declmods LEFT_RIGHT type_quals maybe_raises
440 tree decl
= build_parse_node
(CALL_EXPR
, TREE_VALUE
($1), empty_parms
(), $3);
441 $$
= start_method
(TREE_CHAIN
($1), decl
, $4);
444 if
(yychar == YYEMPTY
)
446 reinit_parse_for_method
(yychar, $$
); }
447 | declmods declarator maybe_raises
448 { $$
= start_method
($1, $2, $3);
451 if
(yychar == YYEMPTY
)
453 reinit_parse_for_method
(yychar, $$
); }
454 | dummy_decl notype_declarator maybe_raises
455 { $$
= start_method
(NULL_TREE
, $2, $3);
458 if
(yychar == YYEMPTY
)
460 reinit_parse_for_method
(yychar, $$
); }
463 return_id: RETURN IDENTIFIER
465 if
(! current_function_parms_stored
)
471 return_init: return_id opt.init
473 extern tree value_identifier
;
476 result
= DECL_RESULT
(current_function_decl
);
477 if
(DECL_NAME
(result
) == value_identifier
)
478 DECL_NAME
(result
) = $1;
480 error ("return identifier `%s' already in place",
481 IDENTIFIER_POINTER
(DECL_NAME
(result
)));
482 store_return_init
($2);
484 | return_id
'(' nonnull_exprlist
')'
486 extern tree value_identifier
;
489 result
= DECL_RESULT
(current_function_decl
);
490 if
(DECL_NAME
(result
) == value_identifier
)
491 DECL_NAME
(result
) = $1;
493 error ("return identifier `%s' already in place",
494 IDENTIFIER_POINTER
(DECL_NAME
(result
)));
495 store_return_init
($3);
497 | return_id LEFT_RIGHT
499 extern tree value_identifier
;
502 result
= DECL_RESULT
(current_function_decl
);
503 if
(DECL_NAME
(result
) == value_identifier
)
504 DECL_NAME
(result
) = $1;
506 error ("return identifier `%s' already in place",
507 IDENTIFIER_POINTER
(DECL_NAME
(result
)));
508 store_return_init
(NULL_TREE
);
513 ':' .set_base_init member_init_list
516 error ("no base initializers given following ':'");
524 int preserve
= (current_class_type
525 && TYPE_USES_VIRTUAL_BASECLASSES
(current_class_type
));
526 preserve
= 0; /* "in charge" arg means we no longer
528 if
(! current_function_parms_stored
)
533 /* Flag that we are processing base and member initializers. */
534 current_vtable_decl
= error_mark_node
;
536 if
(DECL_CONSTRUCTOR_P
(current_function_decl
))
538 /* Make a contour for the initializer list. */
541 expand_start_bindings
(0);
543 else if
(current_class_type
== NULL_TREE
)
544 error ("base initializers not allowed for non-member functions");
545 else if
(! DECL_CONSTRUCTOR_P
(current_function_decl
))
546 error ("only constructors take base initializers");
555 | member_init_list
',' member_init
556 | member_init_list
error
561 member_init: '(' nonnull_exprlist
')'
563 if
(current_class_name
&& pedantic
)
564 warning
("old style base class initialization; use `%s (...)'",
565 IDENTIFIER_POINTER
(current_class_name
));
566 expand_member_init
(C_C_D
, NULL_TREE
, $2);
570 if
(current_class_name
&& pedantic
)
571 warning
("old style base class initialization; use `%s (...)'",
572 IDENTIFIER_POINTER
(current_class_name
));
573 expand_member_init
(C_C_D
, NULL_TREE
, void_type_node
);
575 | identifier
'(' nonnull_exprlist
')'
577 expand_member_init
(C_C_D
, $1, $3);
579 | identifier LEFT_RIGHT
580 { expand_member_init
(C_C_D
, $1, void_type_node
); }
581 | scoped_identifier identifier
'(' nonnull_exprlist
')'
586 if
(TREE_CODE
(scopes
) == SCOPE_REF
)
587 /* just a pain to do this right now. */
590 if
(current_class_type
== NULL_TREE
591 ||
! is_aggr_typedef
(scopes
, 1))
593 basetype
= get_base_type
(TREE_TYPE
(TREE_TYPE
(scopes
)),
594 current_class_type
, 1);
595 if
(basetype
== error_mark_node
)
599 error_not_base_type
(TREE_TYPE
(TREE_TYPE
(scopes
)), current_class_type
);
603 base
= convert_pointer_to
(basetype
, current_class_decl
);
604 expand_member_init
(build_indirect_ref
(base
), $2, $4);
606 | scoped_identifier identifier LEFT_RIGHT
610 if
(TREE_CODE
(scopes
) == SCOPE_REF
)
611 /* just a pain to do this right now. */
614 if
(current_class_type
== NULL_TREE
615 ||
! is_aggr_typedef
(scopes
, 1))
617 basetype
= get_base_type
(TREE_TYPE
(TREE_TYPE
(scopes
)),
618 current_class_type
, 1);
619 if
(basetype
== error_mark_node
)
623 error_not_base_type
(TREE_TYPE
(TREE_TYPE
(scopes
)), current_class_type
);
627 base
= convert_pointer_to
(basetype
, current_class_decl
);
628 expand_member_init
(build_indirect_ref
(base
), $2, void_type_node
);
637 identifier_or_opname:
641 { $$
= build_parse_node
(BIT_NOT_EXPR
, $2); }
643 { $$
= hack_operator
($1);
644 if
($$
== error_mark_node
)
645 $$
= get_identifier
("<missing operator>"); }
647 { $$
= hack_wrapper
($1, NULL_TREE
, $2); }
649 { $$
= hack_wrapper
($1, NULL_TREE
, $2); }
650 | wrapper operator_name
651 { $$
= hack_wrapper
($1, NULL_TREE
, $2); }
652 | wrapper scoped_identifier IDENTIFIER
653 { $$
= hack_wrapper
($1, $2, $3); }
654 | wrapper scoped_identifier operator_name
655 { $$
= hack_wrapper
($1, $2, $3); }
667 { $$
= NEGATE_EXPR
; }
669 { $$
= CONVERT_EXPR
; }
671 { $$
= PREINCREMENT_EXPR
; }
673 { $$
= PREDECREMENT_EXPR
; }
675 { $$
= TRUTH_NOT_EXPR
; }
678 expr: nonnull_exprlist
679 { $$
= build_x_compound_expr
($1); }
680 /* Ugly, but faster. */
683 if
(TREE_CODE
($1) == CALL_EXPR
684 && TYPE_NEEDS_DESTRUCTOR
(TREE_TYPE
($1)))
685 $$
= cleanup_after_call
($1);
699 { $$
= build_tree_list
(NULL_TREE
, $1); }
700 | nonnull_exprlist
',' expr_no_commas
701 { chainon
($1, build_tree_list
(NULL_TREE
, $3)); }
702 | nonnull_exprlist
',' error
703 { chainon
($1, build_tree_list
(NULL_TREE
, error_mark_node
)); }
709 if
(TREE_CODE
($1) == TYPE_EXPR
)
710 $$
= build_component_type_expr
(C_C_D
, $1, NULL_TREE
, 1);
714 |
'*' cast_expr %prec UNARY
715 { $$
= build_x_indirect_ref
($2, "unary *"); }
716 |
'&' cast_expr %prec UNARY
717 { $$
= build_x_unary_op
(ADDR_EXPR
, $2); }
718 |
'~' cast_expr %prec UNARY
719 { $$
= build_x_unary_op
(BIT_NOT_EXPR
, $2); }
720 | unop cast_expr %prec UNARY
721 { $$
= build_x_unary_op
($1, $2);
722 if
($1 == NEGATE_EXPR
&& TREE_CODE
($2) == INTEGER_CST
)
723 TREE_NEGATED_INT
($$
) = 1;
725 | SIZEOF unary_expr %prec UNARY
726 { if
(TREE_CODE
($2) == COMPONENT_REF
727 && TREE_PACKED
(TREE_OPERAND
($2, 1)))
728 error ("sizeof applied to a bit-field");
729 /* ANSI says arrays and functions are converted inside comma.
730 But we can't really convert them in build_compound_expr
731 because that would break commas in lvalues.
732 So do the conversion here if operand was a comma. */
733 if
(TREE_CODE
($2) == COMPOUND_EXPR
734 && (TREE_CODE
(TREE_TYPE
($2)) == ARRAY_TYPE
735 || TREE_CODE
(TREE_TYPE
($2)) == FUNCTION_TYPE
))
736 $2 = default_conversion
($2);
737 $$
= c_sizeof
(TREE_TYPE
($2)); }
738 | SIZEOF
'(' typename
')' %prec HYPERUNARY
739 { $$
= c_sizeof
(groktypename
($3)); }
740 | ALIGNOF unary_expr %prec UNARY
741 { if
(TREE_CODE
($2) == COMPONENT_REF
742 && TREE_PACKED
(TREE_OPERAND
($2, 1)))
743 error ("`__alignof' applied to a bit-field");
744 if
(TREE_CODE
($2) == INDIRECT_REF
)
746 tree t
= TREE_OPERAND
($2, 0);
748 int bestalign
= TYPE_ALIGN
(TREE_TYPE
(TREE_TYPE
(t
)));
749 while
(TREE_CODE
(t
) == NOP_EXPR
750 && TREE_CODE
(TREE_TYPE
(TREE_OPERAND
(t
, 0))) == POINTER_TYPE
)
753 t
= TREE_OPERAND
(t
, 0);
754 thisalign
= TYPE_ALIGN
(TREE_TYPE
(TREE_TYPE
(t
)));
755 if
(thisalign
> bestalign
)
756 best
= t
, bestalign
= thisalign
;
758 $$
= c_alignof
(TREE_TYPE
(TREE_TYPE
(best
)));
762 /* ANSI says arrays and fns are converted inside comma.
763 But we can't convert them in build_compound_expr
764 because that would break commas in lvalues.
765 So do the conversion here if operand was a comma. */
766 if
(TREE_CODE
($2) == COMPOUND_EXPR
767 && (TREE_CODE
(TREE_TYPE
($2)) == ARRAY_TYPE
768 || TREE_CODE
(TREE_TYPE
($2)) == FUNCTION_TYPE
))
769 $2 = default_conversion
($2);
770 $$
= c_alignof
(TREE_TYPE
($2));
773 | ALIGNOF
'(' typename
')' %prec HYPERUNARY
774 { $$
= c_alignof
(groktypename
($3)); }
776 | .scope new typename %prec
'='
777 { $$
= build_new
($2, $3, NULL_TREE
, $1); }
778 | .scope new x_typespec
'(' nonnull_exprlist
')'
779 { $$
= build_new
($2, $3, $5, $1); }
780 | .scope new x_typespec LEFT_RIGHT
781 { $$
= build_new
($2, $3, NULL_TREE
, $1); }
782 | .scope new typename
'=' init %prec
'='
783 { $$
= build_new
($2, $3, $5, $1); }
784 | .scope new
'(' typename
')'
785 { $$
= build_new
($2, $4, NULL_TREE
, $1); }
786 /* Unswallow a ':' which is probably meant for ?: expression. */
787 | .scope new TYPENAME_COLON
789 $$
= build_new
($2, $3, NULL_TREE
, $1); }
791 | delete cast_expr %prec UNARY
792 { tree expr
= stabilize_reference
(convert_from_reference
($2));
793 tree type
= TREE_TYPE
(expr
);
795 if
(integer_zerop
(expr
))
796 $$
= build1
(NOP_EXPR
, void_type_node
, expr
);
797 else if
(TREE_CODE
(type
) != POINTER_TYPE
)
799 error ("non-pointer type to `delete'");
800 $$
= error_mark_node
;
803 if
(TYPE_HAS_DESTRUCTOR
(TREE_TYPE
(type
)))
804 $$
= build_delete
(type
, expr
, integer_three_node
,
805 LOOKUP_NORMAL|LOOKUP_HAS_IN_CHARGE
, $1);
806 else if
(! TYPE_NEEDS_DESTRUCTOR
(TREE_TYPE
(type
)))
807 $$
= build_x_delete
(type
, expr
, $1);
809 $$
= build_delete
(type
, expr
, integer_three_node
,
810 LOOKUP_NORMAL|LOOKUP_HAS_IN_CHARGE
, 0);
812 | delete
'[' expr
']' cast_expr %prec UNARY
814 tree maxindex
= build_binary_op
(MINUS_EXPR
, $3, integer_one_node
);
815 tree exp
= stabilize_reference
(convert_from_reference
($5));
816 tree elt_size
= c_sizeof
(TREE_TYPE
(exp
));
818 if
(yychar == YYEMPTY
)
821 $$
= build_vec_delete
(exp
, maxindex
, elt_size
, NULL_TREE
,
822 integer_one_node
, integer_two_node
);
828 |
'(' typename
')' expr_no_commas %prec UNARY
829 { tree type
= groktypename
($2);
830 $$
= build_c_cast
(type
, $4); }
831 |
'(' typename
')' '{' initlist maybecomma
'}' %prec UNARY
832 { tree type
= groktypename
($2);
833 tree init
= build_nt
(CONSTRUCTOR
, NULL_TREE
, nreverse
($5));
835 warning
("ANSI C forbids constructor-expressions");
836 /* Indicate that this was a GNU C constructor expression. */
837 TREE_HAS_CONSTRUCTOR
(init
) = 1;
838 $$
= digest_init
(type
, init
, 0);
839 if
(TREE_CODE
(type
) == ARRAY_TYPE
&& TYPE_SIZE
(type
) == 0)
841 int failure
= complete_array_type
(type
, $$
, 1);
850 | expr_no_commas
'+' expr_no_commas
851 { $$
= build_x_binary_op
($2, $1, $3); }
852 | expr_no_commas
'-' expr_no_commas
853 { $$
= build_x_binary_op
($2, $1, $3); }
854 | expr_no_commas
'*' expr_no_commas
855 { $$
= build_x_binary_op
($2, $1, $3); }
856 | expr_no_commas
'/' expr_no_commas
857 { $$
= build_x_binary_op
($2, $1, $3); }
858 | expr_no_commas
'%' expr_no_commas
859 { $$
= build_x_binary_op
($2, $1, $3); }
860 | expr_no_commas LSHIFT expr_no_commas
861 { $$
= build_x_binary_op
($2, $1, $3); }
862 | expr_no_commas RSHIFT expr_no_commas
863 { $$
= build_x_binary_op
($2, $1, $3); }
864 | expr_no_commas ARITHCOMPARE expr_no_commas
865 { $$
= build_x_binary_op
($2, $1, $3); }
866 | expr_no_commas EQCOMPARE expr_no_commas
867 { $$
= build_x_binary_op
($2, $1, $3); }
868 | expr_no_commas MIN_MAX expr_no_commas
869 { $$
= build_x_binary_op
($2, $1, $3); }
870 | expr_no_commas
'&' expr_no_commas
871 { $$
= build_x_binary_op
($2, $1, $3); }
872 | expr_no_commas
'|' expr_no_commas
873 { $$
= build_x_binary_op
($2, $1, $3); }
874 | expr_no_commas
'^' expr_no_commas
875 { $$
= build_x_binary_op
($2, $1, $3); }
876 | expr_no_commas ANDAND expr_no_commas
877 { $$
= build_x_binary_op
(TRUTH_ANDIF_EXPR
, $1, $3); }
878 | expr_no_commas OROR expr_no_commas
879 { $$
= build_x_binary_op
(TRUTH_ORIF_EXPR
, $1, $3); }
880 | expr_no_commas
'?' xexpr
':' expr_no_commas
881 { $$
= build_x_conditional_expr
($1, $3, $5); }
882 | expr_no_commas
'=' expr_no_commas
883 { $$
= build_modify_expr
($1, NOP_EXPR
, $3); }
884 | expr_no_commas ASSIGN expr_no_commas
885 { register tree rval
;
886 if
(rval
= build_opfncall
(MODIFY_EXPR
, LOOKUP_NORMAL
, $1, $3, $2))
889 $$
= build_modify_expr
($1, $2, $3); }
891 /* Handle general members. */
892 | object
'*' expr_no_commas %prec UNARY
893 { $$
= build_m_component_ref
($1, build_x_indirect_ref
($3, "unary *")); }
894 | object
'&' expr_no_commas %prec UNARY
895 { $$
= build_m_component_ref
($1, build_x_unary_op
(ADDR_EXPR
, $3)); }
896 | object unop expr_no_commas %prec UNARY
897 { $$
= build_m_component_ref
($1, build_x_unary_op
($2, $3)); }
898 | object
'(' typename
')' expr_no_commas %prec UNARY
899 { tree type
= groktypename
($3);
900 $$
= build_m_component_ref
($1, build_c_cast
(type
, $5)); }
901 | object primary_no_id %prec UNARY
902 { $$
= build_m_component_ref
($1, $2); }
907 { $$
= do_identifier
($1); }
910 tree op
= hack_operator
($1);
911 if
(TREE_CODE
(op
) != IDENTIFIER_NODE
)
915 $$
= lookup_name
(op
);
918 error ("operator %s not defined", operator_name_string
(op
));
919 $$
= error_mark_node
;
925 { $$
= combine_strings
($1); }
929 { $$
= error_mark_node
; }
931 { if
(current_function_decl
== 0)
933 error ("braced-group within expression allowed only inside a function");
937 $
<ttype
>$
= expand_start_stmt_expr
(); }
941 warning
("ANSI C forbids braced-groups within expressions");
942 rtl_exp
= expand_end_stmt_expr
($
<ttype
>2);
945 /* Since the statements have side effects,
946 consider this volatile. */
947 TREE_VOLATILE
($$
) = 1;
948 TREE_TYPE
($$
) = TREE_TYPE
(rtl_exp
);
949 STMT_BODY
($$
) = rtl_exp
; }
950 | primary
'(' nonnull_exprlist
')'
951 { $$
= build_x_function_call
($1, $3, current_class_decl
); }
953 { $$
= build_x_function_call
($1, NULL_TREE
, current_class_decl
); }
954 | primary
'[' expr
']'
958 tree type
= TREE_TYPE
($1);
959 if
(type
== error_mark_node ||
$3 == error_mark_node
)
960 $$
= error_mark_node
;
961 else if
(type
== NULL_TREE
)
963 /* Something has gone very wrong. Assume we
964 are mistakenly reducing an expression
965 instead of a declaration. */
966 error ("parser may be lost: is there a '{' missing somewhere?");
971 if
(TREE_CODE
(type
) == OFFSET_TYPE
)
972 type
= TREE_TYPE
(type
);
973 if
(TREE_CODE
(type
) == REFERENCE_TYPE
)
974 type
= TREE_TYPE
(type
);
976 if
(TYPE_LANG_SPECIFIC
(type
) &&
977 TYPE_OVERLOADS_ARRAY_REF
(type
))
978 $$
= build_opfncall
(ARRAY_REF
, LOOKUP_NORMAL
, $1, $3);
979 else if
(TREE_CODE
(type
) == POINTER_TYPE
980 || TREE_CODE
(type
) == ARRAY_TYPE
)
981 $$
= build_array_ref
($1, $3);
983 error("[] applied to non-pointer type");
987 | object identifier_or_opname %prec UNARY
988 { $$
= build_component_ref
($1, $2, NULL_TREE
, 1); }
989 | object scoped_identifier identifier_or_opname %prec UNARY
991 tree basetype
= (TREE_CODE
($2) == SCOPE_REF
) ? TREE_OPERAND
($2, 1) : $2;
992 if
(is_aggr_typedef
(basetype
, 1))
994 basetype
= TREE_TYPE
(TREE_TYPE
(basetype
));
996 if
($1 == error_mark_node
)
997 $$
= error_mark_node
;
998 else if
(basetype_or_else
(basetype
, TREE_TYPE
($1)))
999 $$
= build_component_ref
(build_scoped_ref
($1, $2), $3, NULL_TREE
, 1);
1001 $$
= error_mark_node
;
1003 else $$
= error_mark_node
;
1006 { $$
= build_x_unary_op
(POSTINCREMENT_EXPR
, $1); }
1007 | primary MINUSMINUS
1008 { $$
= build_x_unary_op
(POSTDECREMENT_EXPR
, $1); }
1010 /* C++ extensions */
1012 { if
(current_class_decl
)
1014 #ifdef WARNING_ABOUT_CCD
1015 TREE_USED
(current_class_decl
) = 1;
1017 $$
= current_class_decl
;
1019 else if
(current_function_decl
1020 && DECL_STATIC_FUNCTION_P
(current_function_decl
))
1022 error ("`this' is unavailable for static member functions");
1023 $$
= error_mark_node
;
1027 if
(current_function_decl
)
1028 error ("invalid use of `this' in non-member function");
1030 error ("invalid use of `this' at top level");
1031 $$
= error_mark_node
;
1034 | dummy_decl TYPE_QUAL
'(' nonnull_exprlist
')'
1039 /* This is a C cast in C++'s `functional' notation. */
1040 if
($4 == error_mark_node
)
1042 $$
= error_mark_node
;
1046 if
($4 == NULL_TREE
)
1048 error ("cannot cast null list to type `%s'",
1049 IDENTIFIER_POINTER
(TYPE_NAME
($2)));
1050 $$
= error_mark_node
;
1054 if
(type
== error_mark_node
)
1055 $$
= error_mark_node
;
1058 if
(id
== ridpointers
[(int) RID_CONST
])
1059 type
= build_type_variant
(integer_type_node
, 1, 0);
1060 else if
(id
== ridpointers
[(int) RID_VOLATILE
])
1061 type
= build_type_variant
(integer_type_node
, 0, 1);
1062 else if
(id
== ridpointers
[(int) RID_FRIEND
])
1064 error ("cannot cast expression to `friend' type");
1065 $$
= error_mark_node
;
1069 $$
= build_c_cast
(type
, build_compound_expr
($4));
1072 | x_typespec
'(' nonnull_exprlist
')'
1073 { $$
= build_functional_cast
($1, $3); }
1074 | x_typespec LEFT_RIGHT
1075 { $$
= build_functional_cast
($1, NULL_TREE
); }
1078 do_scoped_identifier
:
1079 $$
= IDENTIFIER_GLOBAL_VALUE
($2);
1080 if
(yychar == YYEMPTY
)
1084 if
(yychar == '(' ||
yychar == LEFT_RIGHT
)
1086 $$
= implicitly_declare
($2);
1090 if
(IDENTIFIER_GLOBAL_VALUE
($2) != error_mark_node
)
1091 error ("undeclared variable `%s' (first use here)",
1092 IDENTIFIER_POINTER
($2));
1093 $$
= error_mark_node
;
1094 /* Prevent repeated error messages. */
1095 IDENTIFIER_GLOBAL_VALUE
($2) = error_mark_node
;
1098 else if
(TREE_CODE
($$
) == CONST_DECL
)
1099 $$
= DECL_INITIAL
($$
);
1100 if
(! TREE_USED
($$
))
1102 if
(TREE_EXTERNAL
($$
))
1103 assemble_external
($$
);
1107 | SCOPE operator_name
1109 $2 = hack_operator
($2);
1110 if
(TREE_CODE
($2) == IDENTIFIER_NODE
)
1111 goto do_scoped_identifier
;
1115 | scoped_identifier identifier_or_opname %prec HYPERUNARY
1116 { $$
= build_offset_ref
($1, $2); }
1117 | scoped_identifier identifier_or_opname
'(' nonnull_exprlist
')'
1118 { $$
= build_member_call
($1, $2, $4); }
1119 | scoped_identifier identifier_or_opname LEFT_RIGHT
1120 { $$
= build_member_call
($1, $2, NULL_TREE
); }
1122 | object identifier_or_opname
'(' nonnull_exprlist
')'
1123 { $$
= build_method_call
($1, $2, $4, NULL_TREE
,
1124 (LOOKUP_NORMAL|LOOKUP_AGGR
)); }
1125 | object identifier_or_opname LEFT_RIGHT
1126 { $$
= build_method_call
($1, $2, NULL_TREE
, NULL_TREE
,
1127 (LOOKUP_NORMAL|LOOKUP_AGGR
)); }
1128 | object scoped_identifier identifier_or_opname
'(' nonnull_exprlist
')'
1129 { $$
= build_scoped_method_call
($1, $2, $3, $5); }
1130 | object scoped_identifier identifier_or_opname LEFT_RIGHT
1131 { $$
= build_scoped_method_call
($1, $2, $3, NULL_TREE
); }
1138 { $$
= error_mark_node
; }
1140 { if
(current_function_decl
== 0)
1142 error ("braced-group within expression allowed only inside a function");
1145 $
<ttype
>$
= expand_start_stmt_expr
(); }
1148 warning
("ANSI C forbids braced-groups within expressions");
1149 $$
= expand_end_stmt_expr
($
<ttype
>2); }
1150 | primary_no_id
'(' nonnull_exprlist
')'
1151 { $$
= build_x_function_call
($1, $3, current_class_decl
); }
1152 | primary_no_id LEFT_RIGHT
1153 { $$
= build_x_function_call
($1, NULL_TREE
, current_class_decl
); }
1154 | primary_no_id
'[' expr
']'
1156 | primary_no_id PLUSPLUS
1157 { $$
= build_x_unary_op
(POSTINCREMENT_EXPR
, $1); }
1158 | primary_no_id MINUSMINUS
1159 { $$
= build_x_unary_op
(POSTDECREMENT_EXPR
, $1); }
1161 { goto do_scoped_identifier
; }
1162 | SCOPE operator_name
1163 { $2 = hack_operator
($2);
1164 if
(TREE_CODE
($2) == IDENTIFIER_NODE
)
1165 goto do_scoped_identifier
;
1166 goto do_scoped_operator
;
1172 | NEW
'{' nonnull_exprlist
'}'
1174 | NEW DYNAMIC %prec EMPTY
1175 { $$
= void_type_node
; }
1176 | NEW DYNAMIC
'(' string ')'
1177 { $$
= combine_strings
($4); }
1191 error ("extra `::' before `delete' ignored");
1192 $$
= error_mark_node
;
1196 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
1200 { $$
= chainon
($1, $2); }
1206 if
(! current_function_parms_stored
)
1207 store_parm_decls
();
1214 if
($1 == error_mark_node
)
1215 $$
= error_mark_node
;
1218 tree type
= TREE_TYPE
($1);
1220 if
(IS_AGGR_TYPE
(type
)
1221 ||
(TREE_CODE
(type
) == REFERENCE_TYPE
1222 && IS_AGGR_TYPE
(TREE_TYPE
(type
))))
1226 error ("object in '.' expression is not of aggregate type");
1227 $$
= error_mark_node
;
1233 $$
= build_x_arrow
($1);
1238 typed_declspecs initdecls
';'
1240 resume_momentary
($2);
1241 note_got_semicolon
($1);
1243 /* Normal case: make this fast. */
1244 | typed_declspecs declarator
';'
1246 int yes
= suspend_momentary
();
1247 d
= start_decl
($2, $1, 0, NULL_TREE
);
1248 finish_decl
(d
, NULL_TREE
, NULL_TREE
);
1249 resume_momentary
(yes
);
1250 note_got_semicolon
($1);
1252 | declmods notype_initdecls
';'
1253 { resume_momentary
($2); }
1254 /* Normal case: make this fast. */
1255 | declmods declarator
';'
1257 int yes
= suspend_momentary
();
1258 d
= start_decl
($2, $1, 0, NULL_TREE
);
1259 finish_decl
(d
, NULL_TREE
, NULL_TREE
);
1260 resume_momentary
(yes
);
1262 | typed_declspecs
';'
1265 note_got_semicolon
($1);
1268 { warning
("empty declaration"); }
1271 /* Any kind of declarator (thus, all declarators allowed
1272 after an explicit typespec). */
1275 after_type_declarator
1279 /* Declspecs which contain at least one type specifier or typedef name.
1280 (Just `const' or `volatile' is not enough.)
1281 A typedef'd name following these is taken as a name to be declared. */
1285 { $$
= list_hash_lookup_or_cons
($1); }
1287 { $$
= hash_tree_chain
($2, $1); }
1288 | x_typespec reserved_declspecs
1289 { $$
= hash_tree_chain
($1, $2); }
1290 | declmods typespec reserved_declspecs
1291 { $$
= hash_tree_chain
($2, hash_chainon
($3, $1)); }
1294 reserved_declspecs: /* empty
1295 { $$ = NULL_TREE; } */
1296 typespecqual_reserved
1297 { $$
= build_decl_list
(NULL_TREE
, $1); }
1299 { $$
= build_decl_list
(NULL_TREE
, $1); }
1300 | reserved_declspecs typespecqual_reserved
1301 { $$
= decl_tree_cons
(NULL_TREE
, $2, $1); }
1302 | reserved_declspecs SCSPEC
1303 { $$
= decl_tree_cons
(NULL_TREE
, $2, $1); }
1306 /* List of just storage classes and type modifiers.
1307 A declaration can start with just this, but then it cannot be used
1308 to redeclare a typedef-name. */
1311 dummy_decl TYPE_QUAL
1312 { $$
= IDENTIFIER_AS_LIST
($2); }
1314 { $$
= IDENTIFIER_AS_LIST
($2); }
1315 | declmods TYPE_QUAL
1316 { $$
= hash_tree_chain
($2, $1); }
1318 { $$
= hash_tree_chain
($2, $1); }
1322 /* Used instead of declspecs where storage classes are not allowed
1323 (that is, for typenames and structure components).
1325 C++ can takes storage classes for structure components.
1326 Don't accept a typedef-name if anything but a modifier precedes it. */
1329 x_typespec %prec EMPTY
1330 { $$
= build_decl_list_1
($1); }
1331 | nonempty_type_quals typespec
1332 { $$
= decl_tree_cons
(NULL_TREE
, $2, $1); }
1333 | x_typespec reserved_typespecquals
1334 { $$
= decl_tree_cons
(NULL_TREE
, $1, $2); }
1335 | nonempty_type_quals typespec reserved_typespecquals
1336 { $$
= decl_tree_cons
(NULL_TREE
, $2, hash_chainon
($3, $1)); }
1339 reserved_typespecquals:
1340 typespecqual_reserved
1341 { $$
= build_decl_list_1
($1); }
1342 | reserved_typespecquals typespecqual_reserved
1343 { $$
= decl_tree_cons
(NULL_TREE
, $2, $1); }
1346 /* A typespec (but not a type qualifier).
1347 Once we have seen one of these in a declaration,
1348 if a typedef name appears then it is being redeclared. */
1353 | TYPEOF
'(' expr
')'
1354 { $$
= TREE_TYPE
($3);
1356 warning
("ANSI C forbids `typeof'"); }
1357 | TYPEOF
'(' typename
')'
1358 { $$
= groktypename
($3);
1360 warning
("ANSI C forbids `typeof'"); }
1363 /* A typespec that is a reserved word, or a type qualifier. */
1365 typespecqual_reserved: TYPESPEC
1373 | dummy_decl structsp
1375 | dummy_decl TYPENAME
1377 | dummy_decl TYPEOF
'(' expr
')'
1378 { $$
= TREE_TYPE
($4);
1380 warning
("ANSI C forbids `typeof'"); }
1381 | dummy_decl TYPEOF
'(' typename
')'
1382 { $$
= groktypename
($4);
1384 warning
("ANSI C forbids `typeof'"); }
1389 | initdecls
',' initdcl
1394 | notype_initdecls
',' initdcl
1400 | ASM
'(' string ')'
1401 { if
(TREE_CHAIN
($3)) $3 = combine_strings
($3);
1404 warning
("ANSI C forbids use of `asm' keyword");
1409 declarator maybe_raises maybeasm maybe_attribute
'='
1410 { current_declspecs
= $
<ttype
>0;
1411 $
<itype
>5 = suspend_momentary
();
1412 $
<ttype
>$
= start_decl
($1, current_declspecs
, 1, $2); }
1414 /* Note how the declaration of the variable is in effect while its init is parsed! */
1415 { finish_decl
($
<ttype
>6, $7, $3);
1417 | declarator maybe_raises maybeasm maybe_attribute
1419 current_declspecs
= $
<ttype
>0;
1420 $$
= suspend_momentary
();
1421 d
= start_decl
($1, current_declspecs
, 0, $2);
1422 finish_decl
(d
, NULL_TREE
, $3); }
1426 declarator maybe_raises maybeasm maybe_attribute
'='
1427 { $
<ttype
>$
= start_decl
($1, current_declspecs
, 1, $2); }
1429 /* Note how the declaration of the variable is in effect while its init is parsed! */
1430 { finish_decl
($
<ttype
>6, $7, $3); }
1431 | declarator maybe_raises maybeasm maybe_attribute
1432 { tree d
= start_decl
($1, current_declspecs
, 0, $2);
1433 finish_decl
(d
, NULL_TREE
, $3); }
1437 notype_declarator maybe_raises maybeasm maybe_attribute
'='
1438 { current_declspecs
= $
<ttype
>0;
1439 $
<itype
>5 = suspend_momentary
();
1440 $
<ttype
>$
= start_decl
($1, current_declspecs
, 1, $2); }
1442 /* Note how the declaration of the variable is in effect while its init is parsed! */
1443 { finish_decl
($
<ttype
>6, $7, $3);
1445 | notype_declarator maybe_raises maybeasm maybe_attribute
1447 current_declspecs
= $
<ttype
>0;
1448 $$
= suspend_momentary
();
1449 d
= start_decl
($1, current_declspecs
, 0, $2);
1450 finish_decl
(d
, NULL_TREE
, $3); }
1453 /* the * rules are dummies to accept the Apollo extended syntax
1454 so that the header files compile. */
1458 | ATTRIBUTE
'(' '(' attribute_list
')' ')'
1464 | attribute_list
',' attrib
1469 { warning
("`%s' attribute directive ignored",
1470 IDENTIFIER_POINTER
($1));
1472 | IDENTIFIER
'(' CONSTANT
')'
1473 { /* if not "aligned(1)", then issue warning */
1474 if
(strcmp
(IDENTIFIER_POINTER
($1), "aligned") != 0
1475 || TREE_CODE
($3) != INTEGER_CST
1476 || TREE_INT_CST_LOW
($3) != 1)
1477 warning
("`%s' attribute directive ignored",
1478 IDENTIFIER_POINTER
($1));
1480 | IDENTIFIER
'(' identifiers
')'
1481 { warning
("`%s' attribute directive ignored",
1482 IDENTIFIER_POINTER
($1));
1489 | identifiers
',' IDENTIFIER
1494 expr_no_commas %prec
'='
1496 { $$
= build_nt
(CONSTRUCTOR
, NULL_TREE
, NULL_TREE
);
1497 TREE_HAS_CONSTRUCTOR
($$
) = 1;
1499 warning
("ANSI C forbids empty initializer braces"); }
1501 { $$
= build_nt
(CONSTRUCTOR
, NULL_TREE
, nreverse
($2));
1502 TREE_HAS_CONSTRUCTOR
($$
) = 1; }
1503 |
'{' initlist
',' '}'
1504 { $$
= build_nt
(CONSTRUCTOR
, NULL_TREE
, nreverse
($2));
1505 TREE_HAS_CONSTRUCTOR
($$
) = 1; }
1510 /* This chain is built in reverse order,
1511 and put in forward order where initlist is used. */
1514 { $$
= build_tree_list
(NULL_TREE
, $1); }
1516 { $$
= tree_cons
(NULL_TREE
, $3, $1); }
1521 { $
<itype
>3 = suspend_momentary
();
1522 $$
= start_enum
($2); }
1523 enumlist maybecomma_warn
'}'
1524 { $$
= finish_enum
($
<ttype
>4, $5);
1525 resume_momentary
($
<itype
>3);
1526 check_for_missing_semicolon
($
<ttype
>4); }
1527 | ENUM identifier
'{' '}'
1528 { $$
= finish_enum
(start_enum
($2), NULL_TREE
);
1529 check_for_missing_semicolon
($$
); }
1531 { $
<itype
>2 = suspend_momentary
();
1532 $$
= start_enum
(make_anon_name
()); }
1533 enumlist maybecomma_warn
'}'
1534 { $$
= finish_enum
($
<ttype
>3, $4);
1535 resume_momentary
($
<itype
>1);
1536 check_for_missing_semicolon
($
<ttype
>3); }
1538 { $$
= finish_enum
(start_enum
(make_anon_name
()), NULL_TREE
);
1539 check_for_missing_semicolon
($$
); }
1541 { $$
= xref_tag
(enum_type_node
, $2, NULL_TREE
); }
1543 /* C++ extensions, merged with C to avoid shift/reduce conflicts */
1544 | class_head LC opt.component_decl_list
'}'
1546 if
(TREE_CODE
($1) == ENUMERAL_TYPE
)
1548 else if
(CLASSTYPE_DECLARED_EXCEPTION
($1))
1549 $$
= finish_exception
($1, $3);
1551 $$
= finish_struct
($1, $3, 0, 0);
1554 resume_temporary_allocation
();
1556 resume_momentary
(1);
1557 check_for_missing_semicolon
($$
);
1559 | class_head LC opt.component_decl_list
'}' ';'
1560 { if
(TREE_CODE
($1) == ENUMERAL_TYPE
)
1562 else if
(CLASSTYPE_DECLARED_EXCEPTION
($1))
1563 warning
("empty exception declaration\n");
1565 $$
= finish_struct
($1, $3, 1, 1);
1567 resume_temporary_allocation
();
1569 resume_momentary
(1);
1570 note_got_semicolon
($$
);
1571 yyungetc
(';', 0); }
1572 | class_head %prec EMPTY
1584 { if
(pedantic
) warning
("comma at end of enumerator list"); }
1590 { $$
= build_tree_list
(NULL_TREE
, $2); }
1591 | DYNAMIC
'(' string ')' AGGR
1592 { $$
= build_tree_list
($3, $5); }
1594 { error ("storage class specifier `%s' not allow after struct or class", IDENTIFIER_POINTER
($2));
1597 { error ("type specifier `%s' not allow after struct or class", IDENTIFIER_POINTER
($2));
1600 { error ("type qualifier `%s' not allow after struct or class", IDENTIFIER_POINTER
($2));
1603 { error ("no body nor ';' separates two class, struct or union declarations");
1608 { $$
= xref_tag
($1, make_anon_name
(), NULL_TREE
); }
1609 | aggr identifier %prec EMPTY
1610 { $$
= xref_tag
($1, $2, NULL_TREE
); }
1611 | aggr IDENTIFIER
':' base_class_list %prec EMPTY
1612 { $$
= xref_tag
($1, $2, $4); }
1613 | aggr TYPENAME_COLON %prec EMPTY
1614 { yyungetc
(':', 1);
1615 $$
= xref_tag
($1, $2, NULL_TREE
); }
1616 | aggr TYPENAME_COLON base_class_list %prec EMPTY
1617 { $$
= xref_tag
($1, $2, $3); }
1622 { if
(! is_aggr_typedef
($1, 1))
1624 else $$
= build_tree_list
((tree
)visibility_default
, $1); }
1625 | base_class_visibility_list identifier
1626 { if
(! is_aggr_typedef
($2, 1))
1628 else $$
= build_tree_list
($1, $2); }
1629 | base_class_list
',' identifier
1630 { if
(! is_aggr_typedef
($3, 1))
1632 else $$
= chainon
($1, build_tree_list
((tree
)visibility_default
, $3)); }
1633 | base_class_list
',' base_class_visibility_list identifier
1634 { if
(! is_aggr_typedef
($4, 1))
1636 else $$
= chainon
($1, build_tree_list
($3, $4)); }
1639 base_class_visibility_list:
1641 { $$
= (tree
)visibility_public
; }
1643 { $$
= (tree
)visibility_private
; }
1645 { if
($1 != ridpointers
[(int)RID_VIRTUAL
])
1646 sorry
("non-virtual visibility");
1647 $$
= (tree
)visibility_default_virtual
; }
1648 | base_class_visibility_list PUBLIC
1649 { if
($1 == (tree
)visibility_private
)
1650 error ("base class cannot be public and private");
1651 else if
($1 == (tree
)visibility_default_virtual
)
1652 $$
= (tree
)visibility_public_virtual
; }
1653 | base_class_visibility_list PRIVATE
1654 { if
($1 == (tree
)visibility_public
)
1655 error ("base class cannot be private and public");
1656 else if
($1 == (tree
)visibility_default_virtual
)
1657 $$
= (tree
)visibility_private_virtual
; }
1658 | base_class_visibility_list SCSPEC
1659 { if
($2 != ridpointers
[(int)RID_VIRTUAL
])
1660 sorry
("non-virtual visibility");
1661 if
($1 == (tree
)visibility_public
)
1662 $$
= (tree
)visibility_public_virtual
;
1663 else if
($1 == (tree
)visibility_private
)
1664 $$
= (tree
)visibility_private_virtual
; }
1668 { int temp
= allocation_temporary_p
();
1669 int momentary
= suspend_momentary
();
1671 end_temporary_allocation
();
1672 $$
= (momentary
<< 1) | temp
;
1673 if
(! IS_AGGR_TYPE
($
<ttype
>0))
1675 $
<ttype
>0 = make_lang_type
(RECORD_TYPE
);
1676 TYPE_NAME
($
<ttype
>0) = get_identifier
("erroneous type");
1678 pushclass
($
<ttype
>0, 0); }
1680 opt.component_decl_list
:
1683 | component_decl_list
1684 { $$
= build_tree_list
((tree
)visibility_default
, $1); }
1685 | opt.component_decl_list PUBLIC
':' component_decl_list
1686 { $$
= chainon
($1, build_tree_list
((tree
)visibility_public
, $4)); }
1687 | opt.component_decl_list PRIVATE
':' component_decl_list
1688 { $$
= chainon
($1, build_tree_list
((tree
)visibility_private
, $4)); }
1689 | opt.component_decl_list PROTECTED
':' component_decl_list
1690 { $$
= chainon
($1, build_tree_list
((tree
)visibility_protected
, $4)); }
1691 | opt.component_decl_list PUBLIC
':'
1692 | opt.component_decl_list PRIVATE
':'
1693 | opt.component_decl_list PROTECTED
':'
1696 component_decl_list:
1698 { if
($1 == void_type_node
) $$
= NULL_TREE
; }
1699 | component_decl_list component_decl
1700 { if
($2 != NULL_TREE
&& $2 != void_type_node
)
1701 $$
= chainon
($1, $2); }
1702 | component_decl_list
';'
1704 warning
("extra semicolon in struct or union specified"); }
1708 typed_declspecs components
';'
1711 if
($2 == void_type_node
)
1712 /* We just got some friends.
1713 They have been recorded elsewhere. */
1715 else if
($2 == NULL_TREE
)
1717 tree t
= groktypename
(build_decl_list
($1, NULL_TREE
));
1720 error ("error in component specification");
1723 else if
(TREE_CODE
(t
) == UNION_TYPE
)
1725 /* handle anonymous unions */
1726 if
(CLASSTYPE_METHOD_VEC
(t
))
1727 sorry
("methods in anonymous unions");
1728 $$
= build_lang_field_decl
(FIELD_DECL
, NULL_TREE
, t
);
1729 DECL_ANON_UNION_ELEM
($$
) = 1;
1731 else if
(TREE_CODE
(t
) == ENUMERAL_TYPE
)
1732 $$
= grok_enum_decls
(t
, NULL_TREE
);
1733 else if
(TREE_CODE
(t
) == RECORD_TYPE
)
1735 if
(TYPE_LANG_SPECIFIC
(t
)
1736 && CLASSTYPE_DECLARED_EXCEPTION
(t
))
1740 else if
(t
!= void_type_node
)
1742 error ("empty component declaration");
1745 else $$
= NULL_TREE
;
1749 tree t
= TREE_TYPE
($2);
1750 if
(TREE_CODE
(t
) == ENUMERAL_TYPE
&& TREE_NONLOCAL
(t
))
1751 $$
= grok_enum_decls
(t
, $2);
1755 end_exception_decls
();
1757 | typed_declspecs
'(' parmlist
')' ';'
1758 { $$
= groktypefield
($1, $3); }
1759 | typed_declspecs
'(' parmlist
')' '}'
1760 { error ("missing ';' before right brace");
1762 $$
= groktypefield
($1, $3); }
1763 | typed_declspecs LEFT_RIGHT
';'
1764 { $$
= groktypefield
($1, empty_parms
()); }
1765 | typed_declspecs LEFT_RIGHT
'}'
1766 { error ("missing ';' before right brace");
1768 $$
= groktypefield
($1, empty_parms
()); }
1769 | declmods components
';'
1770 { goto do_components
; }
1771 /* Normal case: make this fast. */
1772 | declmods declarator
';'
1773 { $$
= grokfield
($2, $1, 0, 0, 0, 0); }
1774 | declmods components
'}'
1775 { error ("missing ';' before right brace");
1777 goto do_components
; }
1778 | declmods
'(' parmlist
')' ';'
1779 { $$
= groktypefield
($1, $3); }
1780 | declmods
'(' parmlist
')' '}'
1781 { error ("missing ';' before right brace");
1783 $$
= groktypefield
($1, $3); }
1784 | declmods LEFT_RIGHT
';'
1785 { $$
= groktypefield
($1, empty_parms
()); }
1786 | declmods LEFT_RIGHT
'}'
1787 { error ("missing ';' before right brace");
1789 $$
= groktypefield
($1, empty_parms
()); }
1790 |
':' expr_no_commas
';'
1791 { $$
= grokbitfield
(NULL_TREE
, NULL_TREE
, $2); }
1792 |
':' expr_no_commas
'}'
1793 { error ("missing ';' before right brace");
1795 $$
= grokbitfield
(NULL_TREE
, NULL_TREE
, $2); }
1799 /* C++: handle constructors, destructors and inline functions */
1800 /* note that INLINE is like a TYPESPEC */
1801 | fn.def2
':' /* base_init compstmt */
1802 { $$
= finish_method
($1); }
1803 | fn.def2
'{' /* nodecls compstmt */
1804 { $$
= finish_method
($1); }
1805 | dummy_decl notype_declarator maybe_raises
';'
1806 { $$
= grokfield
($2, NULL_TREE
, $3, NULL_TREE
, NULL_TREE
); }
1807 | dummy_decl notype_declarator maybe_raises
'}'
1808 { error ("missing ';' before right brace");
1810 $$
= grokfield
($2, NULL_TREE
, $3, NULL_TREE
, NULL_TREE
); }
1814 /* empty: possibly anonymous */
1816 | component_declarator0
1817 | components
',' component_declarator
1819 /* In this context, void_type_node encodes
1820 friends. They have been recorded elsewhere. */
1821 if
($1 == void_type_node
)
1824 $$
= chainon
($1, $3);
1828 component_declarator0:
1829 declarator maybe_raises maybeasm opt.init
1830 { current_declspecs
= $
<ttype
>0;
1831 $$
= grokfield
($1, current_declspecs
, $2, $4, $3); }
1832 | IDENTIFIER
':' expr_no_commas
1833 { current_declspecs
= $
<ttype
>0;
1834 $$
= grokbitfield
($1, current_declspecs
, $3); }
1835 | TYPENAME_COLON expr_no_commas
1836 { current_declspecs
= $
<ttype
>0;
1837 $$
= grokbitfield
($1, current_declspecs
, $2); }
1838 |
':' expr_no_commas
1839 { current_declspecs
= $
<ttype
>0;
1840 $$
= grokbitfield
(NULL_TREE
, NULL_TREE
, $2); }
1843 component_declarator:
1844 declarator maybe_raises maybeasm opt.init
1845 { $$
= grokfield
($1, current_declspecs
, $2, $4, $3); }
1846 | IDENTIFIER
':' expr_no_commas
1847 { $$
= grokbitfield
($1, current_declspecs
, $3); }
1848 | TYPENAME_COLON expr_no_commas
1849 { $$
= grokbitfield
($1, current_declspecs
, $2); }
1850 |
':' expr_no_commas
1851 { $$
= grokbitfield
(NULL_TREE
, NULL_TREE
, $2); }
1854 /* We chain the enumerators in reverse order.
1855 Because of the way enums are built, the order is
1856 insignificant. Take advantage of this fact. */
1860 | enumlist
',' enumerator
1861 { TREE_CHAIN
($3) = $1; $$
= $3; }
1866 { $$
= build_enumerator
($1, NULL_TREE
); }
1867 | identifier
'=' expr_no_commas
1868 { $$
= build_enumerator
($1, $3); }
1872 typed_typespecs absdcl
1873 { $$
= build_decl_list
($1, $2); }
1874 | nonempty_type_quals absdcl
1875 { $$
= build_decl_list
($1, $2); }
1878 absdcl: /* an abstract declarator */
1879 /* empty */ %prec EMPTY
1881 | absdcl1 %prec EMPTY
1884 nonempty_type_quals:
1885 dummy_decl TYPE_QUAL
1886 { $$
= IDENTIFIER_AS_LIST
($2); }
1887 | nonempty_type_quals TYPE_QUAL
1888 { $$
= decl_tree_cons
(NULL_TREE
, $2, $1); }
1894 | type_quals TYPE_QUAL
1895 { $$
= decl_tree_cons
(NULL_TREE
, $2, $1); }
1898 /* These rules must follow the rules for function declarations
1899 and component declarations. That way, longer rules are prefered. */
1901 /* An expression which will not live on the momentary obstack. */
1903 { $
<itype
>$
= suspend_momentary
(); } expr
1904 { resume_momentary
($
<itype
>1); $$
= $2; }
1906 /* A declarator that is allowed only after an explicit typespec. */
1907 /* may all be followed by prec '.' */
1908 after_type_declarator:
1909 after_type_declarator
'(' nonnull_exprlist
')' type_quals %prec
'.'
1910 { $$
= build_parse_node
(CALL_EXPR
, $1, $3, $5); }
1911 | after_type_declarator
'(' parmlist
')' type_quals %prec
'.'
1912 { $$
= build_parse_node
(CALL_EXPR
, $1, $3, $5); }
1913 | after_type_declarator LEFT_RIGHT type_quals %prec
'.'
1914 { $$
= build_parse_node
(CALL_EXPR
, $1, empty_parms
(), $3); }
1915 | after_type_declarator
'(' error ')' type_quals %prec
'.'
1916 { $$
= build_parse_node
(CALL_EXPR
, $1, NULL_TREE
, NULL_TREE
); }
1917 | after_type_declarator
'[' nonmomentary_expr
']'
1918 { $$
= build_parse_node
(ARRAY_REF
, $1, $3); }
1919 | after_type_declarator
'[' ']'
1920 { $$
= build_parse_node
(ARRAY_REF
, $1, NULL_TREE
); }
1921 |
'(' dummy_decl after_type_declarator_no_typename
')'
1923 |
'(' '*' type_quals after_type_declarator
')'
1924 { $$
= make_pointer_declarator
($3, $4); }
1928 | PAREN_X_SCOPE_STAR_PAREN
1931 | PAREN_X_SCOPE_REF_PAREN
1934 |
'(' '&' type_quals after_type_declarator
')'
1935 { $$
= make_reference_declarator
($3, $4); }
1936 |
'*' type_quals after_type_declarator %prec UNARY
1937 { $$
= make_pointer_declarator
($2, $3); }
1938 |
'&' type_quals after_type_declarator %prec UNARY
1939 { $$
= make_reference_declarator
($2, $3); }
1943 after_type_declarator_no_typename:
1944 after_type_declarator_no_typename
'(' nonnull_exprlist
')' type_quals %prec
'.'
1945 { $$
= build_parse_node
(CALL_EXPR
, $1, $3, $5); }
1946 | after_type_declarator_no_typename
'(' parmlist
')' type_quals %prec
'.'
1947 { $$
= build_parse_node
(CALL_EXPR
, $1, $3, $5); }
1948 | after_type_declarator_no_typename LEFT_RIGHT type_quals %prec
'.'
1949 { $$
= build_parse_node
(CALL_EXPR
, $1, empty_parms
(), $3); }
1950 | after_type_declarator_no_typename
'(' error ')' type_quals %prec
'.'
1951 { $$
= build_parse_node
(CALL_EXPR
, $1, NULL_TREE
, NULL_TREE
); }
1952 | after_type_declarator_no_typename
'[' nonmomentary_expr
']'
1953 { $$
= build_parse_node
(ARRAY_REF
, $1, $3); }
1954 | after_type_declarator_no_typename
'[' ']'
1955 { $$
= build_parse_node
(ARRAY_REF
, $1, NULL_TREE
); }
1956 |
'(' dummy_decl after_type_declarator_no_typename
')'
1961 | PAREN_X_SCOPE_STAR_PAREN
1964 | PAREN_X_SCOPE_REF_PAREN
1967 |
'*' type_quals after_type_declarator %prec UNARY
1968 { $$
= make_pointer_declarator
($2, $3); }
1969 |
'&' type_quals after_type_declarator %prec UNARY
1970 { $$
= make_reference_declarator
($2, $3); }
1973 /* A declarator allowed whether or not there has been
1974 an explicit typespec. These cannot redeclare a typedef-name. */
1977 notype_declarator
'(' nonnull_exprlist
')' type_quals %prec
'.'
1978 { $$
= build_parse_node
(CALL_EXPR
, $1, $3, $5); }
1979 | notype_declarator
'(' parmlist
')' type_quals %prec
'.'
1980 { $$
= build_parse_node
(CALL_EXPR
, $1, $3, $5); }
1981 | notype_declarator LEFT_RIGHT type_quals %prec
'.'
1982 { $$
= build_parse_node
(CALL_EXPR
, $1, empty_parms
(), $3); }
1983 | notype_declarator
'(' error ')' type_quals %prec
'.'
1984 { $$
= build_parse_node
(CALL_EXPR
, $1, NULL_TREE
, NULL_TREE
); }
1985 |
'(' notype_declarator
')'
1987 |
'*' type_quals notype_declarator %prec UNARY
1988 { $$
= make_pointer_declarator
($2, $3); }
1989 |
'&' type_quals notype_declarator %prec UNARY
1990 { $$
= make_reference_declarator
($2, $3); }
1991 | notype_declarator
'[' nonmomentary_expr
']'
1992 { $$
= build_parse_node
(ARRAY_REF
, $1, $3); }
1993 | notype_declarator
'[' ']'
1994 { $$
= build_parse_node
(ARRAY_REF
, $1, NULL_TREE
); }
1996 { see_typename
(); }
1998 /* C++ extensions. */
2000 { see_typename
(); }
2004 $$
= build_parse_node
(BIT_NOT_EXPR
, $2); }
2007 $$
= build_parse_node
(BIT_NOT_EXPR
, $2); }
2008 | LEFT_RIGHT identifier
2011 $$
= build_parse_node
(WRAPPER_EXPR
, $2);
2013 | LEFT_RIGHT
'?' identifier
2016 $$
= build_parse_node
(WRAPPER_EXPR
,
2017 build_parse_node
(COND_EXPR
, $3, NULL_TREE
, NULL_TREE
));
2019 |
'~' LEFT_RIGHT identifier
2021 $$
= build_parse_node
(ANTI_WRAPPER_EXPR
, $3); }
2022 | TYPENAME_SCOPE type_quals notype_declarator %prec
'('
2024 $$
= build_parse_node
(SCOPE_REF
, $1, $3); }
2025 | TYPENAME_SCOPE TYPENAME %prec
'('
2026 { $$
= build_parse_node
(SCOPE_REF
, $1, $2); }
2027 | TYPENAME_SCOPE see_typename TYPENAME
'(' nonnull_exprlist
')' type_quals %prec
'.'
2028 { $$
= build_parse_node
(SCOPE_REF
, $1,
2029 build_parse_node
(CALL_EXPR
, $3, $5, $7)); }
2030 | TYPENAME_SCOPE see_typename TYPENAME
'(' parmlist
')' type_quals %prec
'.'
2031 { $$
= build_parse_node
(SCOPE_REF
, $1,
2032 build_parse_node
(CALL_EXPR
, $3, $5, $7)); }
2033 | TYPENAME_SCOPE see_typename TYPENAME LEFT_RIGHT type_quals %prec
'.'
2034 { $$
= build_parse_node
(SCOPE_REF
, $1,
2035 build_parse_node
(CALL_EXPR
, $3, empty_parms
(), $5)); }
2036 | TYPENAME_SCOPE see_typename TYPENAME
'(' error ')' type_quals %prec
'.'
2037 { $$
= build_parse_node
(SCOPE_REF
, $1, build_parse_node
(CALL_EXPR
, $3, NULL_TREE
, NULL_TREE
)); }
2038 | SCOPE see_typename notype_declarator
2039 { $$
= build_parse_node
(SCOPE_REF
, NULL_TREE
, $3); }
2045 | scoped_identifier TYPENAME_SCOPE
2046 { $$
= build_parse_node
(SCOPE_REF
, $1, $2); }
2049 absdcl1: /* a nonempty abstract declarator */
2053 /* `(typedef)1' is `int'. */
2054 |
'*' type_quals absdcl1 %prec EMPTY
2055 { $$
= make_pointer_declarator
($2, $3); }
2056 |
'*' type_quals %prec EMPTY
2057 { $$
= make_pointer_declarator
($2, NULL_TREE
); }
2061 | PAREN_X_SCOPE_STAR_PAREN
2064 | PAREN_X_SCOPE_REF_PAREN
2067 |
'&' type_quals absdcl1 %prec EMPTY
2068 { $$
= make_reference_declarator
($2, $3); }
2069 |
'&' type_quals %prec EMPTY
2070 { $$
= make_reference_declarator
($2, NULL_TREE
); }
2071 | absdcl1
'(' parmlist
')' type_quals %prec
'.'
2072 { $$
= build_parse_node
(CALL_EXPR
, $1, $3, $5); }
2073 | absdcl1 LEFT_RIGHT type_quals %prec
'.'
2074 { $$
= build_parse_node
(CALL_EXPR
, $1, empty_parms
(), $3); }
2075 | absdcl1
'[' nonmomentary_expr
']' %prec
'.'
2076 { $$
= build_parse_node
(ARRAY_REF
, $1, $3); }
2077 | absdcl1
'[' ']' %prec
'.'
2078 { $$
= build_parse_node
(ARRAY_REF
, $1, NULL_TREE
); }
2079 |
'(' parmlist
')' type_quals %prec
'.'
2080 { $$
= build_parse_node
(CALL_EXPR
, NULL_TREE
, $2, $4); }
2081 | LEFT_RIGHT type_quals %prec
'.'
2082 { $$
= build_parse_node
(CALL_EXPR
, NULL_TREE
, empty_parms
(), $2); }
2083 |
'[' nonmomentary_expr
']' %prec
'.'
2084 { $$
= build_parse_node
(ARRAY_REF
, NULL_TREE
, $2); }
2086 { $$
= build_parse_node
(ARRAY_REF
, NULL_TREE
, NULL_TREE
); }
2087 | TYPENAME_SCOPE type_quals absdcl1 %prec EMPTY
2088 { $$
= build_parse_node
(SCOPE_REF
, $1, $3); }
2089 | IDENTIFIER SCOPE type_quals absdcl1 %prec EMPTY
2090 { $$
= build_parse_node
(SCOPE_REF
, $1, $4); }
2091 | TYPENAME_SCOPE type_quals %prec EMPTY
2092 { $$
= build_parse_node
(SCOPE_REF
, $1, 0); }
2093 | IDENTIFIER SCOPE type_quals %prec EMPTY
2094 { $$
= build_parse_node
(SCOPE_REF
, $1, 0); }
2097 /* at least one statement, the first of which parses without error. */
2098 /* stmts is used only after decls, so an invalid first statement
2099 is actually regarded as an invalid decl and part of the decls. */
2110 /* build the LET_STMT node before parsing its contents,
2111 so that any LET_STMTs within the context can have their display pointers
2112 set up to point at this one. */
2114 .pushlevel
: /* empty */
2119 expand_start_bindings
(0);
2124 /* This is the body of a function definition.
2125 It causes syntax errors to ignore to the next openbrace. */
2134 |
'{' .pushlevel stmts
'}'
2137 pop_implicit_try_blocks
(NULL_TREE
);
2138 decls
= getdecls
();
2139 expand_end_bindings
(decls
, decls
!= 0, 1);
2140 $$
= poplevel
(decls
!= 0, 1, 0);
2142 |
'{' .pushlevel
error '}'
2143 { pop_implicit_try_blocks
(NULL_TREE
);
2144 expand_end_bindings
(getdecls
(), 0, 1);
2145 $$
= poplevel
(0, 0, 0);
2151 { emit_line_note
(input_filename
, lineno
);
2152 expand_start_cond
(truthvalue_conversion
($3), 0);
2153 stmt_decl_msg
= "if"; }
2155 { stmt_decl_msg
= 0; }
2162 { if
(stmt_decl_msg
)
2163 error ("declaration after %s invalid", stmt_decl_msg
);
2167 { emit_line_note
(input_filename
, lineno
);
2168 /* Do default conversion if safe and possibly important,
2169 in case within ({...}). */
2170 if
((TREE_CODE
(TREE_TYPE
($1)) == ARRAY_TYPE
2172 || TREE_CODE
(TREE_TYPE
($1)) == FUNCTION_TYPE
)
2173 $1 = default_conversion
($1);
2174 cplus_expand_expr_stmt
($1);
2178 { expand_start_else
();
2179 stmt_decl_msg
= "else"; }
2181 { expand_end_else
();
2184 | simple_if %prec IF
2185 { expand_end_cond
();
2190 emit_line_note
(input_filename
, lineno
);
2191 expand_start_loop
(1); }
2193 { expand_exit_loop_if_false
(truthvalue_conversion
($4));
2194 stmt_decl_msg
= "while"; }
2202 emit_line_note
(input_filename
, lineno
);
2203 expand_start_loop_continue_elsewhere
(1);
2204 stmt_decl_msg
= "do"; }
2206 { stmt_decl_msg
= 0;
2207 expand_loop_continue_here
(); }
2209 { emit_line_note
(input_filename
, lineno
);
2210 expand_exit_loop_if_false
(truthvalue_conversion
($7));
2216 emit_line_note
(input_filename
, lineno
);
2217 if
($1) cplus_expand_expr_stmt
($1);
2218 expand_start_loop_continue_elsewhere
(1); }
2220 { emit_line_note
(input_filename
, lineno
);
2221 if
($3) expand_exit_loop_if_false
(truthvalue_conversion
($3)); }
2223 /* Don't let the tree nodes for $6 be discarded
2224 by clear_momentary during the parsing of the next stmt. */
2225 { push_momentary
();
2226 stmt_decl_msg
= "for"; }
2228 { emit_line_note
(input_filename
, lineno
);
2229 expand_loop_continue_here
();
2230 if
($6) cplus_expand_expr_stmt
($6);
2237 emit_line_note
(input_filename
, lineno
);
2238 expand_start_loop_continue_elsewhere
(1); }
2240 { emit_line_note
(input_filename
, lineno
);
2241 if
($3) expand_exit_loop_if_false
(truthvalue_conversion
($3)); }
2243 /* Don't let the tree nodes for $6 be discarded
2244 by clear_momentary during the parsing of the next stmt. */
2245 { push_momentary
();
2246 stmt_decl_msg
= "for";
2247 $
<itype
>7 = lineno
; }
2249 { emit_line_note
(input_filename
, $
<itype
>7);
2250 expand_loop_continue_here
();
2251 if
($6) cplus_expand_expr_stmt
($6);
2254 pop_implicit_try_blocks
(NULL_TREE
);
2257 register keep
= $1 > 0;
2258 if
(keep
) expand_end_bindings
(0, keep
, 1);
2259 poplevel
(keep
, 1, 0);
2265 | SWITCH
'(' expr
')'
2266 { emit_line_note
(input_filename
, lineno
);
2267 c_expand_start_case
($3);
2268 /* Don't let the tree nodes for $3 be discarded by
2269 clear_momentary during the parsing of the next stmt. */
2271 stmt_decl_msg
= "switch"; }
2273 { expand_end_case
($3);
2278 { register tree value
= $2;
2280 = build_decl
(LABEL_DECL
, NULL_TREE
, NULL_TREE
);
2282 /* build_c_cast puts on a NOP_EXPR to make a non-lvalue.
2283 Strip such NOP_EXPRs. */
2284 if
(TREE_CODE
(value
) == NOP_EXPR
2285 && TREE_TYPE
(value
) == TREE_TYPE
(TREE_OPERAND
(value
, 0)))
2286 value
= TREE_OPERAND
(value
, 0);
2288 if
(TREE_READONLY_DECL_P
(value
))
2290 value
= decl_constant_value
(value
);
2291 /* build_c_cast puts on a NOP_EXPR to make a non-lvalue.
2292 Strip such NOP_EXPRs. */
2293 if
(TREE_CODE
(value
) == NOP_EXPR
2294 && TREE_TYPE
(value
) == TREE_TYPE
(TREE_OPERAND
(value
, 0)))
2295 value
= TREE_OPERAND
(value
, 0);
2297 value
= fold
(value
);
2299 if
(TREE_CODE
(value
) != INTEGER_CST
2300 && value
!= error_mark_node
)
2302 error ("case label does not reduce to an integer constant");
2303 value
= error_mark_node
;
2306 /* Promote char or short to int. */
2307 value
= default_conversion
(value
);
2308 if
(value
!= error_mark_node
)
2310 int success
= pushcase
(value
, label
);
2312 error ("case label not within a switch statement");
2313 else if
(success
== 2)
2314 error ("duplicate case value");
2315 else if
(success
== 3)
2316 warning
("case value out of range");
2318 define_case_label
(label
);
2321 | CASE expr RANGE expr
':'
2322 { register tree value1
= $2;
2323 register tree value2
= $4;
2325 = build_decl
(LABEL_DECL
, NULL_TREE
, NULL_TREE
);
2329 error ("ANSI C does not allow range expressions in switch statement");
2330 value1
= error_mark_node
;
2331 value2
= error_mark_node
;
2334 /* build_c_cast puts on a NOP_EXPR to make a non-lvalue.
2335 Strip such NOP_EXPRs. */
2336 if
(TREE_CODE
(value1
) == NOP_EXPR
2337 && TREE_TYPE
(value1
) == TREE_TYPE
(TREE_OPERAND
(value1
, 0)))
2338 value1
= TREE_OPERAND
(value1
, 0);
2340 if
(TREE_READONLY_DECL_P
(value1
))
2342 value1
= decl_constant_value
(value1
);
2343 /* build_c_cast puts on a NOP_EXPR to make a non-lvalue.
2344 Strip such NOP_EXPRs. */
2345 if
(TREE_CODE
(value1
) == NOP_EXPR
2346 && TREE_TYPE
(value1
) == TREE_TYPE
(TREE_OPERAND
(value1
, 0)))
2347 value1
= TREE_OPERAND
(value1
, 0);
2349 value1
= fold
(value1
);
2351 /* build_c_cast puts on a NOP_EXPR to make a non-lvalue.
2352 Strip such NOP_EXPRs. */
2353 if
(TREE_CODE
(value2
) == NOP_EXPR
2354 && TREE_TYPE
(value2
) == TREE_TYPE
(TREE_OPERAND
(value2
, 0)))
2355 value2
= TREE_OPERAND
(value2
, 0);
2357 if
(TREE_READONLY_DECL_P
(value2
))
2359 value2
= decl_constant_value
(value2
);
2360 /* build_c_cast puts on a NOP_EXPR to make a non-lvalue.
2361 Strip such NOP_EXPRs. */
2362 if
(TREE_CODE
(value2
) == NOP_EXPR
2363 && TREE_TYPE
(value2
) == TREE_TYPE
(TREE_OPERAND
(value2
, 0)))
2364 value2
= TREE_OPERAND
(value2
, 0);
2366 value2
= fold
(value2
);
2369 if
(TREE_CODE
(value1
) != INTEGER_CST
2370 && value1
!= error_mark_node
)
2372 error ("case label does not reduce to an integer constant");
2373 value1
= error_mark_node
;
2375 if
(TREE_CODE
(value2
) != INTEGER_CST
2376 && value2
!= error_mark_node
)
2378 error ("case label does not reduce to an integer constant");
2379 value2
= error_mark_node
;
2381 if
(value1
!= error_mark_node
2382 && value2
!= error_mark_node
)
2384 int success
= pushcase_range
(value1
, value2
, label
);
2386 error ("case label not within a switch statement");
2387 else if
(success
== 2)
2388 error ("duplicate (or overlapping) case value");
2389 else if
(success
== 3)
2390 warning
("case value out of range");
2391 else if
(success
== 4)
2392 warning
("empty range specified");
2394 define_case_label
(label
);
2400 = build_decl
(LABEL_DECL
, NULL_TREE
, NULL_TREE
);
2401 int success
= pushcase
(NULL_TREE
, label
);
2403 error ("default label not within a switch statement");
2404 else if
(success
== 2)
2405 error ("multiple default labels in one switch");
2409 { emit_line_note
(input_filename
, lineno
);
2410 if
( ! expand_exit_something
())
2411 error ("break statement not within loop or switch"); }
2413 { emit_line_note
(input_filename
, lineno
);
2414 if
(! expand_continue_loop
())
2415 error ("continue statement not within a loop"); }
2417 { emit_line_note
(input_filename
, lineno
);
2418 c_expand_return
(NULL_TREE
); }
2420 { emit_line_note
(input_filename
, lineno
);
2421 c_expand_return
($2);
2424 | ASM maybe_type_qual
'(' string ')' ';'
2425 { if
(TREE_CHAIN
($4)) $4 = combine_strings
($4);
2426 emit_line_note
(input_filename
, lineno
);
2430 /* This is the case with just output operands. */
2431 | ASM maybe_type_qual
'(' string ':' asm_operands
')' ';'
2432 { if
(TREE_CHAIN
($4)) $4 = combine_strings
($4);
2433 emit_line_note
(input_filename
, lineno
);
2434 c_expand_asm_operands
($4, $6, NULL_TREE
, NULL_TREE
,
2435 $2 == ridpointers
[(int)RID_VOLATILE
],
2436 input_filename
, lineno
);
2439 /* This is the case with input operands as well. */
2440 | ASM maybe_type_qual
'(' string ':' asm_operands
':' asm_operands
')' ';'
2441 { if
(TREE_CHAIN
($4)) $4 = combine_strings
($4);
2442 emit_line_note
(input_filename
, lineno
);
2443 c_expand_asm_operands
($4, $6, $8, NULL_TREE
,
2444 $2 == ridpointers
[(int)RID_VOLATILE
],
2445 input_filename
, lineno
);
2448 /* This is the case with clobbered registers as well. */
2449 | ASM maybe_type_qual
'(' string ':' asm_operands
':'
2450 asm_operands
':' asm_clobbers
')' ';'
2451 { if
(TREE_CHAIN
($4)) $4 = combine_strings
($4);
2452 emit_line_note
(input_filename
, lineno
);
2453 c_expand_asm_operands
($4, $6, $8, $10,
2454 $2 == ridpointers
[(int)RID_VOLATILE
],
2455 input_filename
, lineno
);
2458 | GOTO identifier
';'
2460 emit_line_note
(input_filename
, lineno
);
2461 decl
= lookup_label
($2);
2462 TREE_USED
(decl
) = 1;
2463 expand_goto
(decl
); }
2465 { tree label
= define_label
(input_filename
, lineno
, $1);
2468 expand_label
(label
); }
2472 { tree label
= define_label
(input_filename
, lineno
, $1);
2474 expand_label
(label
); }
2480 /* Exception handling extentions. */
2481 | RAISE raise_identifier
'(' nonnull_exprlist
')' ';'
2482 { cplus_expand_raise
($2, $4, NULL_TREE
);
2484 | RAISE raise_identifier LEFT_RIGHT
';'
2485 { cplus_expand_raise
($2, NULL_TREE
, NULL_TREE
);
2487 | RAISE identifier
';'
2488 { cplus_expand_reraise
($2);
2490 | try EXCEPT identifier
'{'
2492 tree decl
= cplus_expand_end_try
($1);
2493 $
<ttype
>2 = current_exception_type
;
2494 $
<ttype
>4 = current_exception_decl
;
2495 $
<ttype
>$
= current_exception_object
;
2496 cplus_expand_start_except
($3, decl
);
2500 expand_start_bindings
(0);
2505 tree decls
= getdecls
();
2507 /* If there is a default exception to handle,
2511 tree decl
= build_decl
(CPLUS_CATCH_DECL
, NULL_TREE
, 0);
2514 expand_start_bindings
(0);
2515 expand_expr
($6, 0, 0, 0);
2516 expand_end_bindings
(0, 1, 0);
2517 block
= poplevel
(1, 0, 0);
2519 /* This is a catch block. */
2520 TREE_LANG_FLAG_2
(block
) = 1;
2521 STMT_VARS
(block
) = decl
;
2524 expand_end_bindings
(decls
, 1, 1);
2525 block
= poplevel
(1, 1, 0);
2526 TREE_LANG_FLAG_3
(block
) = 1;
2528 current_exception_type
= $
<ttype
>2;
2529 current_exception_decl
= $
<ttype
>4;
2530 current_exception_object
= $
<ttype
>5;
2531 cplus_expand_end_except
($6);
2533 | try RERAISE raise_identifiers
/* ';' checked for at bottom. */
2534 { tree name
= get_identifier
("(compiler error)");
2535 tree orig_ex_type
= current_exception_type
;
2536 tree orig_ex_decl
= current_exception_decl
;
2537 tree orig_ex_obj
= current_exception_object
;
2538 tree decl
= cplus_expand_end_try
($1), decls
;
2541 /* Start hidden EXCEPT. */
2542 cplus_expand_start_except
(name
, decl
);
2546 expand_start_bindings
(0);
2549 /* This sets up the reraise. */
2550 cplus_expand_reraise
($3);
2552 decls
= getdecls
();
2553 expand_end_bindings
(decls
, 1, 1);
2554 block
= poplevel
(1, 1, 0);
2555 TREE_LANG_FLAG_3
(block
) = 1;
2557 current_exception_type
= orig_ex_type
;
2558 current_exception_decl
= orig_ex_decl
;
2559 current_exception_object
= orig_ex_obj
;
2560 /* This will reraise for us. */
2561 cplus_expand_end_except
(error_mark_node
);
2562 if
(yychar == YYEMPTY
)
2565 error ("missing ';' after reraise statement");
2568 { yyerror ("`except' missing after `try' statement");
2569 /* Terminate the binding contour started by special
2570 code in `.pushlevel'. Automagically pops off
2571 the conditional we started for `try' stmt. */
2572 cplus_expand_end_try
($1);
2573 expand_end_bindings
(0, 0, 1);
2581 | try_head stmts
'}'
2584 pop_implicit_try_blocks
(NULL_TREE
);
2586 | try_head
error '}'
2589 pop_implicit_try_blocks
(NULL_TREE
);
2593 try_head: TRY
'{' { cplus_expand_start_try
(0); } .pushlevel
2598 | except_stmts raise_identifier
2600 tree type
= lookup_exception_type
(current_class_type
, current_class_name
, $2);
2601 if
(type
== NULL_TREE
)
2603 error ("`%s' is not an exception type",
2604 IDENTIFIER_POINTER
(TREE_VALUE
($2)));
2605 current_exception_type
= NULL_TREE
;
2606 TREE_TYPE
(current_exception_object
) = error_mark_node
;
2610 current_exception_type
= type
;
2611 /* In-place union. */
2612 TREE_TYPE
(current_exception_object
) = type
;
2614 $2 = cplus_expand_start_catch
($2);
2616 expand_start_bindings
(0);
2620 expand_end_bindings
(0, 1, 0);
2621 $4 = poplevel
(1, 0, 0);
2623 cplus_expand_end_catch
(0);
2625 /* Mark this as a catch block. */
2626 TREE_LANG_FLAG_2
($4) = 1;
2627 if
($2 != error_mark_node
)
2629 tree decl
= build_decl
(CPLUS_CATCH_DECL
, DECL_NAME
($2), 0);
2630 DECL_RTL
(decl
) = DECL_RTL
($2);
2631 TREE_CHAIN
(decl
) = STMT_VARS
($4);
2632 STMT_VARS
($4) = decl
;
2635 | except_stmts DEFAULT
2638 error ("duplicate default in exception handler");
2639 current_exception_type
= NULL_TREE
;
2640 /* Takes it right out of scope. */
2641 TREE_TYPE
(current_exception_object
) = error_mark_node
;
2643 if
(! expand_catch_default
())
2644 compiler_error
("default catch botch");
2646 /* The default exception is handled as the
2647 last in the chain of exceptions handled. */
2648 do_pending_stack_adjust
();
2650 $1 = make_node
(RTL_EXPR
);
2651 TREE_TYPE
($1) = void_type_node
;
2655 do_pending_stack_adjust
();
2656 if
(! expand_catch
(NULL_TREE
))
2657 compiler_error
("except nesting botch");
2658 if
(! expand_end_catch
())
2659 compiler_error
("except nesting botch");
2660 RTL_EXPR_SEQUENCE
($1) = (struct rtx_def
*)get_insns
();
2663 /* Mark this block as the default catch block. */
2664 TREE_LANG_FLAG_1
($4) = 1;
2665 TREE_LANG_FLAG_2
($4) = 1;
2685 | FOR
'(' '{' .pushlevel stmts
'}'
2687 | FOR
'(' '{' .pushlevel
error '}'
2691 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
2696 warning
("ANSI C forbids use of `asm' keyword");
2697 emit_line_note
(input_filename
, lineno
); }
2700 warning
("ANSI C forbids use of `asm' keyword");
2701 emit_line_note
(input_filename
, lineno
); }
2712 /* These are the operands other than the first string and colon
2713 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
2714 asm_operands: /* empty */
2716 | nonnull_asm_operands
2719 nonnull_asm_operands:
2721 | nonnull_asm_operands
',' asm_operand
2722 { $$
= chainon
($1, $3); }
2727 { $$
= build_tree_list
($1, $3); }
2732 { $$
= tree_cons
(NULL_TREE
, $1, NULL_TREE
); }
2733 | asm_clobbers
',' STRING
2734 { $$
= tree_cons
(NULL_TREE
, $3, $1); }
2737 /* This is what appears inside the parens in a function declarator.
2738 Its value is represented in the format that grokdeclarator expects.
2740 In C++, declaring a function with no parameters
2741 means that that function takes *no* parameters. */
2742 parmlist: /* empty */
2744 if
(strict_prototype
)
2745 $$
= void_list_node
;
2751 $$
= chainon
($1, void_list_node
);
2752 TREE_PARMLIST
($$
) = 1;
2754 | parms
',' ELLIPSIS
2757 TREE_PARMLIST
($$
) = 1;
2759 /* C++ allows an ellipsis without a separating ',' */
2763 TREE_PARMLIST
($$
) = 1;
2772 TREE_PARMLIST
($$
) = 1;
2774 | parms TYPENAME_ELLIPSIS
2777 TREE_PARMLIST
($$
) = 1;
2781 /* This helps us recover from really nasty
2782 parse errors, for example, a missing right
2784 yyerror ("possibly missing ')'");
2785 $$
= chainon
($1, void_list_node
);
2786 TREE_PARMLIST
($$
) = 1;
2792 /* A nonempty list of parameter declarations or type names. */
2795 { $$
= build_tree_list
($2, $1); }
2796 | parms
',' parm opt.init
2797 { $$
= chainon
($1, build_tree_list
($4, $3)); }
2798 | parms
',' bad_parm opt.init
2799 { $$
= chainon
($1, build_tree_list
($4, $3)); }
2802 /* A single parameter declaration or parameter type name,
2803 as found in a parmlist. */
2805 typed_declspecs dont_see_typename notype_declarator
2806 { $$
= build_tree_list
($1, $3);
2808 | typed_declspecs dont_see_typename absdcl
2809 { $$
= build_tree_list
($1, $3);
2811 | declmods dont_see_typename notype_declarator
2812 { $$
= build_tree_list
($1, $3);
2814 | declmods dont_see_typename absdcl
2815 { $$
= build_tree_list
($1, $3);
2819 see_typename: type_quals
2820 { see_typename
(); }
2823 dont_see_typename: /* empty */
2824 { dont_see_typename
(); }
2828 dummy_decl notype_declarator
2830 warning
("type specifier omitted for parameter");
2831 $$
= build_tree_list
(TREE_PURPOSE
(TREE_VALUE
($
<ttype
>-1)), $2);
2835 warning
("type specifier omitted for parameter");
2836 $$
= build_tree_list
(TREE_PURPOSE
(TREE_VALUE
($
<ttype
>-1)), $2);
2840 /* C++ extension: allow for initialization */
2851 | RAISES raise_identifiers %prec EMPTY
2857 { $$
= void_list_node
; }
2859 { $$
= build_decl_list
(NULL_TREE
, $1); }
2861 { $$
= build_decl_list
(NULL_TREE
, $1); }
2863 { $$
= build_decl_list
(void_type_node
, $2); }
2865 { $$
= build_decl_list
(void_type_node
, $2); }
2866 | scoped_identifier IDENTIFIER
2867 { $$
= build_decl_list
($1, $2); }
2868 | scoped_identifier TYPENAME
2869 { $$
= build_decl_list
($1, $2); }
2873 | raise_identifiers
',' raise_identifier
2875 TREE_CHAIN
($3) = $1;
2882 { $$
= build_opid
(0, MULT_EXPR
); }
2884 { $$
= build_opid
(0, TRUNC_DIV_EXPR
); }
2886 { $$
= build_opid
(0, TRUNC_MOD_EXPR
); }
2888 { $$
= build_opid
(0, PLUS_EXPR
); }
2890 { $$
= build_opid
(0, MINUS_EXPR
); }
2892 { $$
= build_opid
(0, BIT_AND_EXPR
); }
2894 { $$
= build_opid
(0, BIT_IOR_EXPR
); }
2896 { $$
= build_opid
(0, BIT_XOR_EXPR
); }
2898 { $$
= build_opid
(0, BIT_NOT_EXPR
); }
2900 { $$
= build_opid
(0, COMPOUND_EXPR
); }
2901 | OPERATOR ARITHCOMPARE
2902 { $$
= build_opid
(0, $2); }
2903 | OPERATOR EQCOMPARE
2904 { $$
= build_opid
(0, $2); }
2906 { $$
= build_opid
(MODIFY_EXPR
, $2); }
2909 $$
= build_opid
(MODIFY_EXPR
, NOP_EXPR
);
2910 if
(current_class_type
)
2912 TYPE_HAS_ASSIGNMENT
(current_class_type
) = 1;
2913 TYPE_GETS_ASSIGNMENT
(current_class_type
) = 1;
2917 { $$
= build_opid
(0, $2); }
2919 { $$
= build_opid
(0, $2); }
2921 { $$
= build_opid
(0, POSTINCREMENT_EXPR
); }
2922 | OPERATOR MINUSMINUS
2923 { $$
= build_opid
(0, PREDECREMENT_EXPR
); }
2925 { $$
= build_opid
(0, TRUTH_ANDIF_EXPR
); }
2927 { $$
= build_opid
(0, TRUTH_ORIF_EXPR
); }
2929 { $$
= build_opid
(0, TRUTH_NOT_EXPR
); }
2931 { $$
= build_opid
(0, COND_EXPR
); }
2933 { $$
= build_opid
(0, $2); }
2934 | OPERATOR POINTSAT %prec EMPTY
2935 { $$
= build_opid
(0, COMPONENT_REF
); }
2936 | OPERATOR POINTSAT_LEFT_RIGHT type_quals %prec
'.'
2938 if
(yychar == YYEMPTY
)
2940 if
(yychar == '(' ||
yychar == LEFT_RIGHT
)
2942 $$
= build_opid
(0, METHOD_CALL_EXPR
);
2943 if
(current_class_type
)
2945 tree t
= current_class_type
;
2948 TYPE_OVERLOADS_METHOD_CALL_EXPR
(t
) = 1;
2949 t
= TYPE_NEXT_VARIANT
(t
);
2954 $$
= build_parse_node
(CALL_EXPR
, build_opid
(0, COMPONENT_REF
), void_list_node
, $3);
2956 | OPERATOR LEFT_RIGHT
2957 { $$
= build_opid
(0, CALL_EXPR
);
2958 if
(current_class_type
)
2960 tree t
= current_class_type
;
2963 TYPE_OVERLOADS_CALL_EXPR
(t
) = 1;
2964 t
= TYPE_NEXT_VARIANT
(t
);
2969 { $$
= build_opid
(0, ARRAY_REF
);
2970 if
(current_class_type
)
2972 tree t
= current_class_type
;
2975 TYPE_OVERLOADS_ARRAY_REF
(t
) = 1;
2976 t
= TYPE_NEXT_VARIANT
(t
);
2982 $$
= build_opid
(0, NEW_EXPR
);
2983 if
(current_class_type
)
2985 tree t
= current_class_type
;
2988 TREE_GETS_NEW
(t
) = 1;
2989 t
= TYPE_NEXT_VARIANT
(t
);
2995 $$
= build_opid
(0, DELETE_EXPR
);
2996 if
(current_class_type
)
2998 tree t
= current_class_type
;
3001 TREE_GETS_DELETE
(t
) = 1;
3002 t
= TYPE_NEXT_VARIANT
(t
);
3007 /* These should do `groktypename' and set up TREE_HAS_X_CONVERSION
3008 here, rather than doing it in class.c . */
3009 | OPERATOR typed_typespecs absdcl
3011 $$
= build1
(TYPE_EXPR
, $2, $3);
3014 { $$
= build_opid
(ERROR_MARK
, ERROR_MARK
); }
3020 db_yyerror
(s
, yyps
, yychar)
3030 printf
("State is %d, input token number is %d.\n", *yyps
, yychar);
3033 if
(*yyps
< 1) fatal
("Cannot start from here");
3034 else if
((yyout
= fopen
(PARSE_OUTPUT
, "r")) == NULL
)
3035 error ("cannot open file %s", PARSE_OUTPUT
);
3038 printf
("That is to say,\n\n");
3039 while
(fgets
(buf
, sizeof
(buf
)-1, yyout
))
3041 if
(buf
[0] != 's') continue
;
3043 if
(st
!= *yyps
) continue
;
3045 while
(fgets
(buf
, sizeof
(buf
)-1, yyout
))
3047 if
(buf
[0] == 's') break
;
3052 printf
("With the token %s\n", yytname
[YYTRANSLATE
(yychar)]);
3063 extern
FILE *finput
;
3064 extern
char *token_buffer
;
3067 strcpy
(buf
, string);
3069 /* We can't print string and character constants well
3070 because the token_buffer contains the result of processing escapes. */
3071 if
(end_of_file || feof
(finput
))
3072 strcat
(buf
, " at end of input");
3073 else if
(token_buffer
[0] == 0)
3074 strcat
(buf
, " at null character");
3075 else if
(token_buffer
[0] == '"')
3076 strcat
(buf
, " before string constant");
3077 else if
(token_buffer
[0] == '\'')
3078 strcat
(buf
, " before character constant");
3080 strcat
(buf
, " before `%s'");
3082 error (buf
, token_buffer
);
3085 #ifndef GATHER_STATISTICS
3086 int *init_parse
() { return
0; }
3088 static int *reduce_count
;
3089 static int *token_count
;
3091 #define REDUCE_LENGTH (sizeof (yyr2) / sizeof (yyr2[0]))
3092 #define TOKEN_LENGTH (256 + YYNTBASE + 1)
3097 reduce_count
= (int *)malloc
(sizeof
(int) * (REDUCE_LENGTH
+ 1));
3098 bzero
(reduce_count
, sizeof
(int) * (REDUCE_LENGTH
+ 1));
3100 token_count
= (int *)malloc
(sizeof
(int) * (TOKEN_LENGTH
+ 1));
3101 bzero
(token_count
, sizeof
(int) * (TOKEN_LENGTH
+ 1));
3110 reduce_count
[yyn
] += 1;
3113 static int reduce_cmp
(p
, q
)
3116 return reduce_count
[*q
] - reduce_count
[*p
];
3119 static int token_cmp
(p
, q
)
3122 return token_count
[*q
] - token_count
[*p
];
3126 print_parse_statistics
()
3129 int maxlen
= REDUCE_LENGTH
;
3132 if
(reduce_count
[-1] == 0)
3135 if
(TOKEN_LENGTH
> REDUCE_LENGTH
)
3136 maxlen
= TOKEN_LENGTH
;
3137 sorted
= (unsigned *) alloca
(sizeof
(int) * maxlen
);
3139 for
(i
= 0; i
< TOKEN_LENGTH
; i
++)
3141 qsort
(sorted
, TOKEN_LENGTH
, sizeof
(int), token_cmp
);
3142 for
(i
= 0; i
< TOKEN_LENGTH
; i
++)
3144 int index
= sorted
[i
];
3145 if
(token_count
[index
] == 0)
3147 if
(token_count
[index
] < token_count
[-1])
3149 fprintf
(stderr
, "token %d", index
);
3151 fprintf
(stderr
, ", `%s'", yytname
[YYTRANSLATE
(index
)]);
3153 fprintf
(stderr
, ", count = %d\n", token_count
[index
]);
3155 fprintf
(stderr
, "\n");
3156 for
(i
= 0; i
< REDUCE_LENGTH
; i
++)
3158 qsort
(sorted
, REDUCE_LENGTH
, sizeof
(int), reduce_cmp
);
3159 for
(i
= 0; i
< REDUCE_LENGTH
; i
++)
3161 int index
= sorted
[i
];
3162 if
(reduce_count
[index
] == 0)
3164 if
(reduce_count
[index
] < reduce_count
[-1])
3166 fprintf
(stderr
, "rule %d", index
);
3168 fprintf
(stderr
, ", line %d", yyrline
[index
]);
3170 fprintf
(stderr
, ", count = %d\n", reduce_count
[index
]);
3172 fprintf
(stderr
, "\n");