1 /*WARNING: This file is automatically generated!*/
2 /* YACC parser for C syntax and for Objective C. -*-c-*-
3 Copyright (C) 1987, 88, 89, 92-6, 1997 Free Software Foundation, Inc.
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. */
22 /* This file defines the grammar of C and that of Objective C.
23 ifobjc ... end ifobjc conditionals contain code for Objective C only.
24 ifc ... end ifc conditionals contain code for C only.
25 Sed commands in Makefile.in are used to convert this file into
26 c-parse.y and into objc-parse.y. */
28 /* To whomever it may concern: I have heard that such a thing was once
29 written by AT&T, but I have never seen it. */
33 /* These are the 23 conflicts you should get in parse.output;
34 the state numbers may vary if minor changes in the grammar are made.
36 State 42 contains 1 shift/reduce conflict. (Two ways to parse ATTRIBUTE.)
37 State 44 contains 1 shift/reduce conflict. (Two ways to recover from error.)
38 State 103 contains 1 shift/reduce conflict. (Two ways to recover from error.)
39 State 110 contains 1 shift/reduce conflict. (Two ways to parse ATTRIBUTE.)
40 State 111 contains 1 shift/reduce conflict. (Two ways to recover from error.)
41 State 115 contains 1 shift/reduce conflict. (Two ways to recover from error.)
42 State 132 contains 1 shift/reduce conflict. (See comment at component_decl.)
43 State 180 contains 1 shift/reduce conflict. (Two ways to parse ATTRIBUTE.)
44 State 194 contains 2 shift/reduce conflict. (Four ways to parse this.)
45 State 202 contains 1 shift/reduce conflict. (Two ways to recover from error.)
46 State 214 contains 1 shift/reduce conflict. (Two ways to recover from error.)
47 State 220 contains 1 shift/reduce conflict. (Two ways to recover from error.)
48 State 304 contains 2 shift/reduce conflicts. (Four ways to parse this.)
49 State 335 contains 2 shift/reduce conflicts. (Four ways to parse this.)
50 State 347 contains 1 shift/reduce conflict. (Two ways to parse ATTRIBUTES.)
51 State 352 contains 1 shift/reduce conflict. (Two ways to parse ATTRIBUTES.)
52 State 383 contains 2 shift/reduce conflicts. (Four ways to parse this.)
53 State 434 contains 2 shift/reduce conflicts. (Four ways to parse this.) */
68 #ifdef MULTIBYTE_CHARS
74 /* Since parsers are distinct for each language, put the language string
76 char *language_string
= "GNU C";
84 /* Like YYERROR but do call yyerror. */
85 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
87 /* Cause the `yydebug' variable to be defined. */
93 %
union {long itype
; tree ttype
; enum tree_code code
;
94 char *filename
; int lineno
; int ends_in_label
; }
96 /* All identifiers that are not reserved words
97 and are not declared typedefs in the current block */
100 /* All identifiers that are declared typedefs in the current block.
101 In some contexts, they are treated just like IDENTIFIER,
102 but they can also serve as typespecs in declarations. */
105 /* Reserved words that specify storage class.
106 yylval contains an IDENTIFIER_NODE which indicates which one. */
109 /* Reserved words that specify type.
110 yylval contains an IDENTIFIER_NODE which indicates which one. */
113 /* Reserved words that qualify type: "const" or "volatile".
114 yylval contains an IDENTIFIER_NODE which indicates which one. */
117 /* Character or numeric constants.
118 yylval is the node for the constant. */
121 /* String constants in raw form.
122 yylval is a STRING_CST node. */
125 /* "...", used for functions with variable arglists. */
128 /* the reserved words */
129 /* SCO include files test "ASM", so use something else. */
130 %token SIZEOF ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
131 %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD TYPEOF ALIGNOF
132 %token ATTRIBUTE EXTENSION LABEL
133 %token REALPART IMAGPART
135 /* Add precedence rules to solve dangling else s/r conflict */
139 /* Define the operator tokens and their precedences.
140 The value is an integer because, if used, it is the tree code
141 to use in the expression made from the operator. */
143 %right
<code
> ASSIGN
'='
144 %right
<code
> '?' ':'
150 %left
<code
> EQCOMPARE
151 %left
<code
> ARITHCOMPARE
152 %left
<code
> LSHIFT RSHIFT
154 %left
<code
> '*' '/' '%'
155 %right
<code
> UNARY PLUSPLUS MINUSMINUS
157 %left
<code
> POINTSAT
'.' '(' '['
159 /* The Objective-C keywords. These are included in C and in
160 Objective C, so that the token codes are the same in both. */
161 %token INTERFACE IMPLEMENTATION END SELECTOR DEFS ENCODE
162 %token CLASSNAME PUBLIC PRIVATE PROTECTED PROTOCOL OBJECTNAME CLASS ALIAS
164 /* Objective-C string constants in raw form.
165 yylval is an OBJC_STRING_CST node. */
171 %type
<ttype
> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist exprlist
172 %type
<ttype
> expr_no_commas cast_expr unary_expr primary
string STRING
173 %type
<ttype
> typed_declspecs reserved_declspecs
174 %type
<ttype
> typed_typespecs reserved_typespecquals
175 %type
<ttype
> declmods typespec typespecqual_reserved
176 %type
<ttype
> typed_declspecs_no_prefix_attr reserved_declspecs_no_prefix_attr
177 %type
<ttype
> declmods_no_prefix_attr
178 %type
<ttype
> SCSPEC TYPESPEC TYPE_QUAL nonempty_type_quals maybe_type_qual
179 %type
<ttype
> initdecls notype_initdecls initdcl notype_initdcl
180 %type
<ttype
> init maybeasm
181 %type
<ttype
> asm_operands nonnull_asm_operands asm_operand asm_clobbers
182 %type
<ttype
> maybe_attribute attributes attribute attribute_list attrib
183 %type
<ttype
> any_word
185 %type
<ttype
> compstmt
187 %type
<ttype
> declarator
188 %type
<ttype
> notype_declarator after_type_declarator
189 %type
<ttype
> parm_declarator
191 %type
<ttype
> structsp component_decl_list component_decl_list2
192 %type
<ttype
> component_decl components component_declarator
193 %type
<ttype
> enumlist enumerator
194 %type
<ttype
> typename absdcl absdcl1 type_quals
195 %type
<ttype
> xexpr parms parm identifiers
197 %type
<ttype
> parmlist parmlist_1 parmlist_2
198 %type
<ttype
> parmlist_or_identifiers parmlist_or_identifiers_1
199 %type
<ttype
> identifiers_or_typenames
201 %type
<itype
> setspecs
203 %type
<ends_in_label
> lineno_stmt_or_label lineno_stmt_or_labels stmt_or_label
205 %type
<filename
> save_filename
206 %type
<lineno
> save_lineno
210 /* Number of statements (loosely speaking) seen so far. */
211 static int stmt_count
;
213 /* Input file and line number of the end of the body of last simple_if;
214 used by the stmt-rule immediately after simple_if returns. */
215 static char *if_stmt_file
;
216 static int if_stmt_line
;
218 /* List of types and structure classes of the current declaration. */
219 static tree current_declspecs
= NULL_TREE
;
220 static tree prefix_attributes
= NULL_TREE
;
222 /* Stack of saved values of current_declspecs and prefix_attributes. */
223 static tree declspec_stack
;
225 /* 1 if we explained undeclared var errors. */
226 static int undeclared_variable_notice
;
229 /* Tell yyparse how to print a token's value, if yydebug is set. */
231 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
232 extern
void yyprint
();
238 pedwarn
("ANSI C forbids an empty source file");
243 /* In case there were missing closebraces,
244 get us back to the global binding level. */
245 while
(! global_bindings_p
())
251 /* the reason for the strange actions in this rule
252 is so that notype_initdecls when reached via datadef
253 can find a valid list of type and sc specs in $0. */
256 {$
<ttype
>$
= NULL_TREE
; } extdef
257 | extdefs
{$
<ttype
>$
= NULL_TREE
; } extdef
263 | ASM_KEYWORD
'(' expr
')' ';'
265 if
((TREE_CODE
($3) == ADDR_EXPR
266 && TREE_CODE
(TREE_OPERAND
($3, 0)) == STRING_CST
)
267 || TREE_CODE
($3) == STRING_CST
)
270 error ("argument of `asm' is not a constant string"); }
272 { pedantic
= $
<itype
>1; }
276 setspecs notype_initdecls
';'
278 error ("ANSI C forbids data definition with no type or storage class");
279 else if
(!flag_traditional
)
280 warning
("data definition has no type or storage class");
282 current_declspecs
= TREE_VALUE
(declspec_stack
);
283 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
284 declspec_stack
= TREE_CHAIN
(declspec_stack
);
285 resume_momentary
($1); }
286 | declmods setspecs notype_initdecls
';'
287 { current_declspecs
= TREE_VALUE
(declspec_stack
);
288 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
289 declspec_stack
= TREE_CHAIN
(declspec_stack
);
290 resume_momentary
($2); }
291 | typed_declspecs setspecs initdecls
';'
292 { current_declspecs
= TREE_VALUE
(declspec_stack
);
293 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
294 declspec_stack
= TREE_CHAIN
(declspec_stack
);
295 resume_momentary
($2); }
297 { pedwarn
("empty declaration"); }
298 | typed_declspecs
';'
304 pedwarn
("ANSI C does not allow extra `;' outside of a function"); }
308 typed_declspecs setspecs declarator
309 { if
(! start_function
(current_declspecs
, $3,
310 prefix_attributes
, NULL_TREE
, 0))
312 reinit_parse_for_function
(); }
314 { store_parm_decls
(); }
316 { finish_function
(0);
317 current_declspecs
= TREE_VALUE
(declspec_stack
);
318 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
319 declspec_stack
= TREE_CHAIN
(declspec_stack
);
320 resume_momentary
($2); }
321 | typed_declspecs setspecs declarator
error
322 { current_declspecs
= TREE_VALUE
(declspec_stack
);
323 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
324 declspec_stack
= TREE_CHAIN
(declspec_stack
);
325 resume_momentary
($2); }
326 | declmods setspecs notype_declarator
327 { if
(! start_function
(current_declspecs
, $3,
328 prefix_attributes
, NULL_TREE
, 0))
330 reinit_parse_for_function
(); }
332 { store_parm_decls
(); }
334 { finish_function
(0);
335 current_declspecs
= TREE_VALUE
(declspec_stack
);
336 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
337 declspec_stack
= TREE_CHAIN
(declspec_stack
);
338 resume_momentary
($2); }
339 | declmods setspecs notype_declarator
error
340 { current_declspecs
= TREE_VALUE
(declspec_stack
);
341 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
342 declspec_stack
= TREE_CHAIN
(declspec_stack
);
343 resume_momentary
($2); }
344 | setspecs notype_declarator
345 { if
(! start_function
(NULL_TREE
, $2,
346 prefix_attributes
, NULL_TREE
, 0))
348 reinit_parse_for_function
(); }
350 { store_parm_decls
(); }
352 { finish_function
(0);
353 current_declspecs
= TREE_VALUE
(declspec_stack
);
354 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
355 declspec_stack
= TREE_CHAIN
(declspec_stack
);
356 resume_momentary
($1); }
357 | setspecs notype_declarator
error
358 { current_declspecs
= TREE_VALUE
(declspec_stack
);
359 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
360 declspec_stack
= TREE_CHAIN
(declspec_stack
);
361 resume_momentary
($1); }
372 { $$
= NEGATE_EXPR
; }
374 { $$
= CONVERT_EXPR
; }
376 { $$
= PREINCREMENT_EXPR
; }
378 { $$
= PREDECREMENT_EXPR
; }
380 { $$
= BIT_NOT_EXPR
; }
382 { $$
= TRUTH_NOT_EXPR
; }
385 expr: nonnull_exprlist
386 { $$
= build_compound_expr
($1); }
397 { $$
= build_tree_list
(NULL_TREE
, $1); }
398 | nonnull_exprlist
',' expr_no_commas
399 { chainon
($1, build_tree_list
(NULL_TREE
, $3)); }
404 |
'*' cast_expr %prec UNARY
405 { $$
= build_indirect_ref
($2, "unary *"); }
406 /* __extension__ turns off -pedantic for following primary. */
407 | extension cast_expr %prec UNARY
409 pedantic
= $
<itype
>1; }
410 | unop cast_expr %prec UNARY
411 { $$
= build_unary_op
($1, $2, 0);
412 overflow_warning
($$
); }
413 /* Refer to the address of a label as a pointer. */
415 { tree label
= lookup_label
($2);
417 pedwarn
("ANSI C forbids `&&'");
419 $$
= null_pointer_node
;
422 TREE_USED
(label
) = 1;
423 $$
= build1
(ADDR_EXPR
, ptr_type_node
, label
);
424 TREE_CONSTANT
($$
) = 1;
427 /* This seems to be impossible on some machines, so let's turn it off.
428 You can use __builtin_next_arg to find the anonymous stack args.
430 { tree types = TYPE_ARG_TYPES (TREE_TYPE (current_function_decl));
431 $$ = error_mark_node;
432 if (TREE_VALUE (tree_last (types)) == void_type_node)
433 error ("`&...' used in function with fixed number of arguments");
437 pedwarn ("ANSI C forbids `&...'");
438 $$ = tree_last (DECL_ARGUMENTS (current_function_decl));
439 $$ = build_unary_op (ADDR_EXPR, $$, 0);
442 | sizeof unary_expr %prec UNARY
444 if
(TREE_CODE
($2) == COMPONENT_REF
445 && DECL_BIT_FIELD
(TREE_OPERAND
($2, 1)))
446 error ("`sizeof' applied to a bit-field");
447 $$
= c_sizeof
(TREE_TYPE
($2)); }
448 | sizeof
'(' typename
')' %prec HYPERUNARY
450 $$
= c_sizeof
(groktypename
($3)); }
451 | alignof unary_expr %prec UNARY
453 $$
= c_alignof_expr
($2); }
454 | alignof
'(' typename
')' %prec HYPERUNARY
456 $$
= c_alignof
(groktypename
($3)); }
457 | REALPART cast_expr %prec UNARY
458 { $$
= build_unary_op
(REALPART_EXPR
, $2, 0); }
459 | IMAGPART cast_expr %prec UNARY
460 { $$
= build_unary_op
(IMAGPART_EXPR
, $2, 0); }
464 SIZEOF
{ skip_evaluation
++; }
468 ALIGNOF
{ skip_evaluation
++; }
473 |
'(' typename
')' cast_expr %prec UNARY
474 { tree type
= groktypename
($2);
475 $$
= build_c_cast
(type
, $4); }
476 |
'(' typename
')' '{'
477 { start_init
(NULL_TREE
, NULL
, 0);
478 $2 = groktypename
($2);
479 really_start_incremental_init
($2); }
480 initlist_maybe_comma
'}' %prec UNARY
482 tree result
= pop_init_level
(0);
487 pedwarn
("ANSI C forbids constructor expressions");
488 if
(TYPE_NAME
(type
) != 0)
490 if
(TREE_CODE
(TYPE_NAME
(type
)) == IDENTIFIER_NODE
)
491 name
= IDENTIFIER_POINTER
(TYPE_NAME
(type
));
493 name
= IDENTIFIER_POINTER
(DECL_NAME
(TYPE_NAME
(type
)));
498 if
(TREE_CODE
(type
) == ARRAY_TYPE
&& TYPE_SIZE
(type
) == 0)
500 int failure
= complete_array_type
(type
, $$
, 1);
509 | expr_no_commas
'+' expr_no_commas
510 { $$
= parser_build_binary_op
($2, $1, $3); }
511 | expr_no_commas
'-' expr_no_commas
512 { $$
= parser_build_binary_op
($2, $1, $3); }
513 | expr_no_commas
'*' expr_no_commas
514 { $$
= parser_build_binary_op
($2, $1, $3); }
515 | expr_no_commas
'/' expr_no_commas
516 { $$
= parser_build_binary_op
($2, $1, $3); }
517 | expr_no_commas
'%' expr_no_commas
518 { $$
= parser_build_binary_op
($2, $1, $3); }
519 | expr_no_commas LSHIFT expr_no_commas
520 { $$
= parser_build_binary_op
($2, $1, $3); }
521 | expr_no_commas RSHIFT expr_no_commas
522 { $$
= parser_build_binary_op
($2, $1, $3); }
523 | expr_no_commas ARITHCOMPARE expr_no_commas
524 { $$
= parser_build_binary_op
($2, $1, $3); }
525 | expr_no_commas EQCOMPARE expr_no_commas
526 { $$
= parser_build_binary_op
($2, $1, $3); }
527 | expr_no_commas
'&' expr_no_commas
528 { $$
= parser_build_binary_op
($2, $1, $3); }
529 | expr_no_commas
'|' expr_no_commas
530 { $$
= parser_build_binary_op
($2, $1, $3); }
531 | expr_no_commas
'^' expr_no_commas
532 { $$
= parser_build_binary_op
($2, $1, $3); }
533 | expr_no_commas ANDAND
534 { $1 = truthvalue_conversion
(default_conversion
($1));
535 skip_evaluation
+= $1 == boolean_false_node
; }
537 { skip_evaluation
-= $1 == boolean_false_node
;
538 $$
= parser_build_binary_op
(TRUTH_ANDIF_EXPR
, $1, $4); }
539 | expr_no_commas OROR
540 { $1 = truthvalue_conversion
(default_conversion
($1));
541 skip_evaluation
+= $1 == boolean_true_node
; }
543 { skip_evaluation
-= $1 == boolean_true_node
;
544 $$
= parser_build_binary_op
(TRUTH_ORIF_EXPR
, $1, $4); }
546 { $1 = truthvalue_conversion
(default_conversion
($1));
547 skip_evaluation
+= $1 == boolean_false_node
; }
549 { skip_evaluation
+= (($1 == boolean_true_node
)
550 - ($1 == boolean_false_node
)); }
552 { skip_evaluation
-= $1 == boolean_true_node
;
553 $$
= build_conditional_expr
($1, $4, $7); }
556 pedwarn
("ANSI C forbids omitting the middle term of a ?: expression");
557 /* Make sure first operand is calculated only once. */
558 $
<ttype
>2 = save_expr
($1);
559 $1 = truthvalue_conversion
(default_conversion
($
<ttype
>2));
560 skip_evaluation
+= $1 == boolean_true_node
; }
562 { skip_evaluation
-= $1 == boolean_true_node
;
563 $$
= build_conditional_expr
($1, $
<ttype
>2, $5); }
564 | expr_no_commas
'=' expr_no_commas
565 { $$
= build_modify_expr
($1, NOP_EXPR
, $3);
566 C_SET_EXP_ORIGINAL_CODE
($$
, MODIFY_EXPR
); }
567 | expr_no_commas ASSIGN expr_no_commas
568 { $$
= build_modify_expr
($1, $2, $3);
569 /* This inhibits warnings in truthvalue_conversion. */
570 C_SET_EXP_ORIGINAL_CODE
($$
, ERROR_MARK
); }
577 if
(!$$ || $$
== error_mark_node
)
579 if
(yychar == YYEMPTY
)
584 /* Ordinary implicit function declaration. */
585 $$
= implicitly_declare
($1);
586 assemble_external
($$
);
590 else if
(current_function_decl
== 0)
592 error ("`%s' undeclared here (not in a function)",
593 IDENTIFIER_POINTER
($1));
594 $$
= error_mark_node
;
599 if
(IDENTIFIER_GLOBAL_VALUE
($1) != error_mark_node
600 || IDENTIFIER_ERROR_LOCUS
($1) != current_function_decl
)
602 error ("`%s' undeclared (first use this function)",
603 IDENTIFIER_POINTER
($1));
605 if
(! undeclared_variable_notice
)
607 error ("(Each undeclared identifier is reported only once");
608 error ("for each function it appears in.)");
609 undeclared_variable_notice
= 1;
612 $$
= error_mark_node
;
613 /* Prevent repeated error messages. */
614 IDENTIFIER_GLOBAL_VALUE
($1) = error_mark_node
;
615 IDENTIFIER_ERROR_LOCUS
($1) = current_function_decl
;
619 else if
(TREE_TYPE
($$
) == error_mark_node
)
620 $$
= error_mark_node
;
621 else if
(C_DECL_ANTICIPATED
($$
))
623 /* The first time we see a build-in function used,
624 if it has not been declared. */
625 C_DECL_ANTICIPATED
($$
) = 0;
626 if
(yychar == YYEMPTY
)
630 /* Omit the implicit declaration we
631 would ordinarily do, so we don't lose
632 the actual built in type.
633 But print a diagnostic for the mismatch. */
634 if
(TREE_CODE
($$
) != FUNCTION_DECL
)
635 error ("`%s' implicitly declared as function",
636 IDENTIFIER_POINTER
(DECL_NAME
($$
)));
637 else if
((TYPE_MODE
(TREE_TYPE
(TREE_TYPE
($$
)))
638 != TYPE_MODE
(integer_type_node
))
639 && (TREE_TYPE
(TREE_TYPE
($$
))
641 pedwarn
("type mismatch in implicit declaration for built-in function `%s'",
642 IDENTIFIER_POINTER
(DECL_NAME
($$
)));
643 /* If it really returns void, change that to int. */
644 if
(TREE_TYPE
(TREE_TYPE
($$
)) == void_type_node
)
646 = build_function_type
(integer_type_node
,
647 TYPE_ARG_TYPES
(TREE_TYPE
($$
)));
650 pedwarn
("built-in function `%s' used without declaration",
651 IDENTIFIER_POINTER
(DECL_NAME
($$
)));
653 /* Do what we would ordinarily do when a fn is used. */
654 assemble_external
($$
);
659 assemble_external
($$
);
663 if
(TREE_CODE
($$
) == CONST_DECL
)
665 $$
= DECL_INITIAL
($$
);
666 /* This is to prevent an enum whose value is 0
667 from being considered a null pointer constant. */
668 $$
= build1
(NOP_EXPR
, TREE_TYPE
($$
), $$
);
669 TREE_CONSTANT
($$
) = 1;
674 { $$
= combine_strings
($1); }
676 { char class
= TREE_CODE_CLASS
(TREE_CODE
($2));
677 if
(class
== 'e' || class
== '1'
678 || class
== '2' || class
== '<')
679 C_SET_EXP_ORIGINAL_CODE
($2, ERROR_MARK
);
682 { $$
= error_mark_node
; }
684 { if
(current_function_decl
== 0)
686 error ("braced-group within expression allowed only inside a function");
689 /* We must force a BLOCK for this level
690 so that, if it is not expanded later,
691 there is a way to turn off the entire subtree of blocks
692 that are contained in it. */
694 push_iterator_stack
();
696 $
<ttype
>$
= expand_start_stmt_expr
(); }
700 pedwarn
("ANSI C forbids braced-groups within expressions");
701 pop_iterator_stack
();
703 rtl_exp
= expand_end_stmt_expr
($
<ttype
>2);
704 /* The statements have side effects, so the group does. */
705 TREE_SIDE_EFFECTS
(rtl_exp
) = 1;
707 if
(TREE_CODE
($3) == BLOCK
)
709 /* Make a BIND_EXPR for the BLOCK already made. */
710 $$
= build
(BIND_EXPR
, TREE_TYPE
(rtl_exp
),
711 NULL_TREE
, rtl_exp
, $3);
712 /* Remove the block from the tree at this point.
713 It gets put back at the proper place
714 when the BIND_EXPR is expanded. */
720 | primary
'(' exprlist
')' %prec
'.'
721 { $$
= build_function_call
($1, $3); }
722 | primary
'[' expr
']' %prec
'.'
723 { $$
= build_array_ref
($1, $3); }
724 | primary
'.' identifier
726 $$
= build_component_ref
($1, $3);
728 | primary POINTSAT identifier
730 tree expr
= build_indirect_ref
($1, "->");
732 $$
= build_component_ref
(expr
, $3);
735 { $$
= build_unary_op
(POSTINCREMENT_EXPR
, $1, 0); }
737 { $$
= build_unary_op
(POSTDECREMENT_EXPR
, $1, 0); }
740 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
744 { $$
= chainon
($1, $2); }
748 old_style_parm_decls:
752 /* ... is used here to indicate a varargs function. */
755 pedwarn
("ANSI C does not permit use of `varargs.h'"); }
758 /* The following are analogous to lineno_decl, decls and decl
759 except that they do not allow nested functions.
760 They are used for old-style parm decls. */
762 save_filename save_lineno datadecl
769 | datadecls lineno_datadecl
770 | lineno_datadecl errstmt
773 /* We don't allow prefix attributes here because they cause reduce/reduce
774 conflicts: we can't know whether we're parsing a function decl with
775 attribute suffix, or function defn with attribute prefix on first old
778 typed_declspecs_no_prefix_attr setspecs initdecls
';'
779 { current_declspecs
= TREE_VALUE
(declspec_stack
);
780 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
781 declspec_stack
= TREE_CHAIN
(declspec_stack
);
782 resume_momentary
($2); }
783 | declmods_no_prefix_attr setspecs notype_initdecls
';'
784 { current_declspecs
= TREE_VALUE
(declspec_stack
);
785 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
786 declspec_stack
= TREE_CHAIN
(declspec_stack
);
787 resume_momentary
($2); }
788 | typed_declspecs_no_prefix_attr
';'
789 { shadow_tag_warned
($1, 1);
790 pedwarn
("empty declaration"); }
791 | declmods_no_prefix_attr
';'
792 { pedwarn
("empty declaration"); }
795 /* This combination which saves a lineno before a decl
796 is the normal thing to use, rather than decl itself.
797 This is to avoid shift/reduce conflicts in contexts
798 where statement labels are allowed. */
800 save_filename save_lineno decl
808 | lineno_decl errstmt
811 /* records the type and storage class specs to use for processing
812 the declarators that follow.
813 Maintains a stack of outer-level values of current_declspecs,
814 for the sake of parm declarations nested in function declarators. */
815 setspecs: /* empty */
816 { $$
= suspend_momentary
();
817 pending_xref_error
();
818 declspec_stack
= tree_cons
(prefix_attributes
,
821 split_specs_attrs
($
<ttype
>0,
822 ¤t_declspecs
, &prefix_attributes
); }
825 /* ??? Yuck. See after_type_declarator. */
826 setattrs: /* empty */
827 { prefix_attributes
= chainon
(prefix_attributes
, $
<ttype
>0); }
831 typed_declspecs setspecs initdecls
';'
832 { current_declspecs
= TREE_VALUE
(declspec_stack
);
833 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
834 declspec_stack
= TREE_CHAIN
(declspec_stack
);
835 resume_momentary
($2); }
836 | declmods setspecs notype_initdecls
';'
837 { current_declspecs
= TREE_VALUE
(declspec_stack
);
838 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
839 declspec_stack
= TREE_CHAIN
(declspec_stack
);
840 resume_momentary
($2); }
841 | typed_declspecs setspecs nested_function
842 { current_declspecs
= TREE_VALUE
(declspec_stack
);
843 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
844 declspec_stack
= TREE_CHAIN
(declspec_stack
);
845 resume_momentary
($2); }
846 | declmods setspecs notype_nested_function
847 { current_declspecs
= TREE_VALUE
(declspec_stack
);
848 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
849 declspec_stack
= TREE_CHAIN
(declspec_stack
);
850 resume_momentary
($2); }
851 | typed_declspecs
';'
854 { pedwarn
("empty declaration"); }
856 { pedantic
= $
<itype
>1; }
859 /* Declspecs which contain at least one type specifier or typedef name.
860 (Just `const' or `volatile' is not enough.)
861 A typedef'd name following these is taken as a name to be declared.
862 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
865 typespec reserved_declspecs
866 { $$
= tree_cons
(NULL_TREE
, $1, $2); }
867 | declmods typespec reserved_declspecs
868 { $$
= chainon
($3, tree_cons
(NULL_TREE
, $2, $1)); }
871 reserved_declspecs: /* empty */
873 | reserved_declspecs typespecqual_reserved
874 { $$
= tree_cons
(NULL_TREE
, $2, $1); }
875 | reserved_declspecs SCSPEC
876 { if
(extra_warnings
)
877 warning
("`%s' is not at beginning of declaration",
878 IDENTIFIER_POINTER
($2));
879 $$
= tree_cons
(NULL_TREE
, $2, $1); }
880 | reserved_declspecs attributes
881 { $$
= tree_cons
($2, NULL_TREE
, $1); }
884 typed_declspecs_no_prefix_attr:
885 typespec reserved_declspecs_no_prefix_attr
886 { $$
= tree_cons
(NULL_TREE
, $1, $2); }
887 | declmods_no_prefix_attr typespec reserved_declspecs_no_prefix_attr
888 { $$
= chainon
($3, tree_cons
(NULL_TREE
, $2, $1)); }
891 reserved_declspecs_no_prefix_attr:
894 | reserved_declspecs_no_prefix_attr typespecqual_reserved
895 { $$
= tree_cons
(NULL_TREE
, $2, $1); }
896 | reserved_declspecs_no_prefix_attr SCSPEC
897 { if
(extra_warnings
)
898 warning
("`%s' is not at beginning of declaration",
899 IDENTIFIER_POINTER
($2));
900 $$
= tree_cons
(NULL_TREE
, $2, $1); }
903 /* List of just storage classes, type modifiers, and prefix attributes.
904 A declaration can start with just this, but then it cannot be used
905 to redeclare a typedef-name.
906 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
909 declmods_no_prefix_attr
912 { $$
= tree_cons
($1, NULL_TREE
, NULL_TREE
); }
913 | declmods declmods_no_prefix_attr
914 { $$
= chainon
($2, $1); }
915 | declmods attributes
916 { $$
= tree_cons
($2, NULL_TREE
, $1); }
919 declmods_no_prefix_attr:
921 { $$
= tree_cons
(NULL_TREE
, $1, NULL_TREE
);
922 TREE_STATIC
($$
) = 1; }
924 { $$
= tree_cons
(NULL_TREE
, $1, NULL_TREE
); }
925 | declmods_no_prefix_attr TYPE_QUAL
926 { $$
= tree_cons
(NULL_TREE
, $2, $1);
927 TREE_STATIC
($$
) = 1; }
928 | declmods_no_prefix_attr SCSPEC
929 { if
(extra_warnings
&& TREE_STATIC
($1))
930 warning
("`%s' is not at beginning of declaration",
931 IDENTIFIER_POINTER
($2));
932 $$
= tree_cons
(NULL_TREE
, $2, $1);
933 TREE_STATIC
($$
) = TREE_STATIC
($1); }
937 /* Used instead of declspecs where storage classes are not allowed
938 (that is, for typenames and structure components).
939 Don't accept a typedef-name if anything but a modifier precedes it. */
942 typespec reserved_typespecquals
943 { $$
= tree_cons
(NULL_TREE
, $1, $2); }
944 | nonempty_type_quals typespec reserved_typespecquals
945 { $$
= chainon
($3, tree_cons
(NULL_TREE
, $2, $1)); }
948 reserved_typespecquals: /* empty */
950 | reserved_typespecquals typespecqual_reserved
951 { $$
= tree_cons
(NULL_TREE
, $2, $1); }
954 /* A typespec (but not a type qualifier).
955 Once we have seen one of these in a declaration,
956 if a typedef name appears then it is being redeclared. */
961 { /* For a typedef name, record the meaning, not the name.
962 In case of `foo foo, bar;'. */
963 $$
= lookup_name
($1); }
964 | TYPEOF
'(' expr
')'
965 { $$
= TREE_TYPE
($3); }
966 | TYPEOF
'(' typename
')'
967 { $$
= groktypename
($3); }
970 /* A typespec that is a reserved word, or a type qualifier. */
972 typespecqual_reserved: TYPESPEC
979 | initdecls
',' initdcl
984 | notype_initdecls
',' initdcl
990 | ASM_KEYWORD
'(' string ')'
991 { if
(TREE_CHAIN
($3)) $3 = combine_strings
($3);
997 declarator maybeasm maybe_attribute
'='
998 { $
<ttype
>$
= start_decl
($1, current_declspecs
, 1,
999 $3, prefix_attributes
);
1000 start_init
($
<ttype
>$
, $2, global_bindings_p
()); }
1002 /* Note how the declaration of the variable is in effect while its init is parsed! */
1004 finish_decl
($
<ttype
>5, $6, $2); }
1005 | declarator maybeasm maybe_attribute
1006 { tree d
= start_decl
($1, current_declspecs
, 0,
1007 $3, prefix_attributes
);
1008 finish_decl
(d
, NULL_TREE
, $2);
1013 notype_declarator maybeasm maybe_attribute
'='
1014 { $
<ttype
>$
= start_decl
($1, current_declspecs
, 1,
1015 $3, prefix_attributes
);
1016 start_init
($
<ttype
>$
, $2, global_bindings_p
()); }
1018 /* Note how the declaration of the variable is in effect while its init is parsed! */
1020 decl_attributes
($
<ttype
>5, $3, prefix_attributes
);
1021 finish_decl
($
<ttype
>5, $6, $2); }
1022 | notype_declarator maybeasm maybe_attribute
1023 { tree d
= start_decl
($1, current_declspecs
, 0,
1024 $3, prefix_attributes
);
1025 finish_decl
(d
, NULL_TREE
, $2); }
1027 /* the * rules are dummies to accept the Apollo extended syntax
1028 so that the header files compile. */
1039 | attributes attribute
1040 { $$
= chainon
($1, $2); }
1044 ATTRIBUTE
'(' '(' attribute_list
')' ')'
1051 | attribute_list
',' attrib
1052 { $$
= chainon
($1, $3); }
1059 { $$
= build_tree_list
($1, NULL_TREE
); }
1060 | any_word
'(' IDENTIFIER
')'
1061 { $$
= build_tree_list
($1, build_tree_list
(NULL_TREE
, $3)); }
1062 | any_word
'(' IDENTIFIER
',' nonnull_exprlist
')'
1063 { $$
= build_tree_list
($1, tree_cons
(NULL_TREE
, $3, $5)); }
1064 | any_word
'(' exprlist
')'
1065 { $$
= build_tree_list
($1, $3); }
1068 /* This still leaves out most reserved keywords,
1069 shouldn't we include them? */
1078 /* Initializers. `init' is the entry point. */
1083 { really_start_incremental_init
(NULL_TREE
);
1084 /* Note that the call to clear_momentary
1085 is in process_init_element. */
1086 push_momentary
(); }
1087 initlist_maybe_comma
'}'
1088 { $$
= pop_init_level
(0);
1089 if
($$
== error_mark_node
1090 && ! (yychar == STRING ||
yychar == CONSTANT
))
1093 pop_momentary_nofree
(); }
1096 { $$
= error_mark_node
; }
1099 /* `initlist_maybe_comma' is the guts of an initializer in braces. */
1100 initlist_maybe_comma:
1103 pedwarn
("ANSI C forbids empty initializer braces"); }
1104 | initlist1 maybecomma
1109 | initlist1
',' initelt
1112 /* `initelt' is a single element of an initializer.
1113 It may use braces. */
1116 { process_init_element
($1); }
1118 { push_init_level
(0); }
1119 initlist_maybe_comma
'}'
1120 { process_init_element
(pop_init_level
(0)); }
1122 /* These are for labeled elements. The syntax for an array element
1123 initializer conflicts with the syntax for an Objective-C message,
1124 so don't include these productions in the Objective-C grammar. */
1125 |
'[' expr_no_commas ELLIPSIS expr_no_commas
']' '='
1126 { set_init_index
($2, $4); }
1128 |
'[' expr_no_commas
']' '='
1129 { set_init_index
($2, NULL_TREE
); }
1131 |
'[' expr_no_commas
']'
1132 { set_init_index
($2, NULL_TREE
); }
1135 { set_init_label
($1); }
1137 |
'.' identifier
'='
1138 { set_init_label
($2); }
1144 { push_c_function_context
();
1145 if
(! start_function
(current_declspecs
, $1,
1146 prefix_attributes
, NULL_TREE
, 1))
1148 pop_c_function_context
();
1151 reinit_parse_for_function
(); }
1152 old_style_parm_decls
1153 { store_parm_decls
(); }
1154 /* This used to use compstmt_or_error.
1155 That caused a bug with input `f(g) int g {}',
1156 where the use of YYERROR1 above caused an error
1157 which then was handled by compstmt_or_error.
1158 There followed a repeated execution of that same rule,
1159 which called YYERROR1 again, and so on. */
1161 { finish_function
(1);
1162 pop_c_function_context
(); }
1165 notype_nested_function:
1167 { push_c_function_context
();
1168 if
(! start_function
(current_declspecs
, $1,
1169 prefix_attributes
, NULL_TREE
, 1))
1171 pop_c_function_context
();
1174 reinit_parse_for_function
(); }
1175 old_style_parm_decls
1176 { store_parm_decls
(); }
1177 /* This used to use compstmt_or_error.
1178 That caused a bug with input `f(g) int g {}',
1179 where the use of YYERROR1 above caused an error
1180 which then was handled by compstmt_or_error.
1181 There followed a repeated execution of that same rule,
1182 which called YYERROR1 again, and so on. */
1184 { finish_function
(1);
1185 pop_c_function_context
(); }
1188 /* Any kind of declarator (thus, all declarators allowed
1189 after an explicit typespec). */
1192 after_type_declarator
1196 /* A declarator that is allowed only after an explicit typespec. */
1198 after_type_declarator:
1199 '(' after_type_declarator
')'
1201 | after_type_declarator
'(' parmlist_or_identifiers %prec
'.'
1202 { $$
= build_nt
(CALL_EXPR
, $1, $3, NULL_TREE
); }
1203 /* | after_type_declarator '(' error ')' %prec '.'
1204 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1205 poplevel (0, 0, 0); } */
1206 | after_type_declarator
'[' expr
']' %prec
'.'
1207 { $$
= build_nt
(ARRAY_REF
, $1, $3); }
1208 | after_type_declarator
'[' ']' %prec
'.'
1209 { $$
= build_nt
(ARRAY_REF
, $1, NULL_TREE
); }
1210 |
'*' type_quals after_type_declarator %prec UNARY
1211 { $$
= make_pointer_declarator
($2, $3); }
1212 /* ??? Yuck. setattrs is a quick hack. We can't use
1213 prefix_attributes because $1 only applies to this
1214 declarator. We assume setspecs has already been done.
1215 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1216 attributes could be recognized here or in `attributes'). */
1217 | attributes setattrs after_type_declarator
1222 /* Kinds of declarator that can appear in a parameter list
1223 in addition to notype_declarator. This is like after_type_declarator
1224 but does not allow a typedef name in parentheses as an identifier
1225 (because it would conflict with a function with that typedef as arg). */
1228 parm_declarator
'(' parmlist_or_identifiers %prec
'.'
1229 { $$
= build_nt
(CALL_EXPR
, $1, $3, NULL_TREE
); }
1230 /* | parm_declarator '(' error ')' %prec '.'
1231 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1232 poplevel (0, 0, 0); } */
1233 | parm_declarator
'[' expr
']' %prec
'.'
1234 { $$
= build_nt
(ARRAY_REF
, $1, $3); }
1235 | parm_declarator
'[' ']' %prec
'.'
1236 { $$
= build_nt
(ARRAY_REF
, $1, NULL_TREE
); }
1237 |
'*' type_quals parm_declarator %prec UNARY
1238 { $$
= make_pointer_declarator
($2, $3); }
1239 /* ??? Yuck. setattrs is a quick hack. We can't use
1240 prefix_attributes because $1 only applies to this
1241 declarator. We assume setspecs has already been done.
1242 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1243 attributes could be recognized here or in `attributes'). */
1244 | attributes setattrs parm_declarator
1249 /* A declarator allowed whether or not there has been
1250 an explicit typespec. These cannot redeclare a typedef-name. */
1253 notype_declarator
'(' parmlist_or_identifiers %prec
'.'
1254 { $$
= build_nt
(CALL_EXPR
, $1, $3, NULL_TREE
); }
1255 /* | notype_declarator '(' error ')' %prec '.'
1256 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1257 poplevel (0, 0, 0); } */
1258 |
'(' notype_declarator
')'
1260 |
'*' type_quals notype_declarator %prec UNARY
1261 { $$
= make_pointer_declarator
($2, $3); }
1262 | notype_declarator
'[' expr
']' %prec
'.'
1263 { $$
= build_nt
(ARRAY_REF
, $1, $3); }
1264 | notype_declarator
'[' ']' %prec
'.'
1265 { $$
= build_nt
(ARRAY_REF
, $1, NULL_TREE
); }
1266 /* ??? Yuck. setattrs is a quick hack. We can't use
1267 prefix_attributes because $1 only applies to this
1268 declarator. We assume setspecs has already been done.
1269 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1270 attributes could be recognized here or in `attributes'). */
1271 | attributes setattrs notype_declarator
1277 STRUCT identifier
'{'
1278 { $$
= start_struct
(RECORD_TYPE
, $2);
1279 /* Start scope of tag before parsing components. */
1281 component_decl_list
'}' maybe_attribute
1282 { $$
= finish_struct
($
<ttype
>4, $5, $7); }
1283 | STRUCT
'{' component_decl_list
'}' maybe_attribute
1284 { $$
= finish_struct
(start_struct
(RECORD_TYPE
, NULL_TREE
),
1288 { $$
= xref_tag
(RECORD_TYPE
, $2); }
1289 | UNION identifier
'{'
1290 { $$
= start_struct
(UNION_TYPE
, $2); }
1291 component_decl_list
'}' maybe_attribute
1292 { $$
= finish_struct
($
<ttype
>4, $5, $7); }
1293 | UNION
'{' component_decl_list
'}' maybe_attribute
1294 { $$
= finish_struct
(start_struct
(UNION_TYPE
, NULL_TREE
),
1298 { $$
= xref_tag
(UNION_TYPE
, $2); }
1299 | ENUM identifier
'{'
1300 { $
<itype
>3 = suspend_momentary
();
1301 $$
= start_enum
($2); }
1302 enumlist maybecomma_warn
'}' maybe_attribute
1303 { $$
= finish_enum
($
<ttype
>4, nreverse
($5), $8);
1304 resume_momentary
($
<itype
>3); }
1306 { $
<itype
>2 = suspend_momentary
();
1307 $$
= start_enum
(NULL_TREE
); }
1308 enumlist maybecomma_warn
'}' maybe_attribute
1309 { $$
= finish_enum
($
<ttype
>3, nreverse
($4), $7);
1310 resume_momentary
($
<itype
>2); }
1312 { $$
= xref_tag
(ENUMERAL_TYPE
, $2); }
1323 { if
(pedantic
) pedwarn
("comma at end of enumerator list"); }
1326 component_decl_list:
1327 component_decl_list2
1329 | component_decl_list2 component_decl
1330 { $$
= chainon
($1, $2);
1331 pedwarn
("no semicolon at end of struct or union"); }
1334 component_decl_list2: /* empty */
1336 | component_decl_list2 component_decl
';'
1337 { $$
= chainon
($1, $2); }
1338 | component_decl_list2
';'
1340 pedwarn
("extra semicolon in struct or union specified"); }
1343 /* There is a shift-reduce conflict here, because `components' may
1344 start with a `typename'. It happens that shifting (the default resolution)
1345 does the right thing, because it treats the `typename' as part of
1346 a `typed_typespecs'.
1348 It is possible that this same technique would allow the distinction
1349 between `notype_initdecls' and `initdecls' to be eliminated.
1350 But I am being cautious and not trying it. */
1353 typed_typespecs setspecs components
1355 current_declspecs
= TREE_VALUE
(declspec_stack
);
1356 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
1357 declspec_stack
= TREE_CHAIN
(declspec_stack
);
1358 resume_momentary
($2); }
1361 pedwarn
("ANSI C forbids member declarations with no members");
1364 | nonempty_type_quals setspecs components
1366 current_declspecs
= TREE_VALUE
(declspec_stack
);
1367 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
1368 declspec_stack
= TREE_CHAIN
(declspec_stack
);
1369 resume_momentary
($2); }
1370 | nonempty_type_quals
1372 pedwarn
("ANSI C forbids member declarations with no members");
1377 | extension component_decl
1379 pedantic
= $
<itype
>1; }
1383 component_declarator
1384 | components
',' component_declarator
1385 { $$
= chainon
($1, $3); }
1388 component_declarator:
1389 save_filename save_lineno declarator maybe_attribute
1390 { $$
= grokfield
($1, $2, $3, current_declspecs
, NULL_TREE
);
1391 decl_attributes
($$
, $4, prefix_attributes
); }
1392 | save_filename save_lineno
1393 declarator
':' expr_no_commas maybe_attribute
1394 { $$
= grokfield
($1, $2, $3, current_declspecs
, $5);
1395 decl_attributes
($$
, $6, prefix_attributes
); }
1396 | save_filename save_lineno
':' expr_no_commas maybe_attribute
1397 { $$
= grokfield
($1, $2, NULL_TREE
, current_declspecs
, $4);
1398 decl_attributes
($$
, $5, prefix_attributes
); }
1401 /* We chain the enumerators in reverse order.
1402 They are put in forward order where enumlist is used.
1403 (The order used to be significant, but no longer is so.
1404 However, we still maintain the order, just to be clean.) */
1408 | enumlist
',' enumerator
1409 { if
($1 == error_mark_node
)
1412 $$
= chainon
($3, $1); }
1414 { $$
= error_mark_node
; }
1420 { $$
= build_enumerator
($1, NULL_TREE
); }
1421 | identifier
'=' expr_no_commas
1422 { $$
= build_enumerator
($1, $3); }
1426 typed_typespecs absdcl
1427 { $$
= build_tree_list
($1, $2); }
1428 | nonempty_type_quals absdcl
1429 { $$
= build_tree_list
($1, $2); }
1432 absdcl: /* an absolute declarator */
1438 nonempty_type_quals:
1440 { $$
= tree_cons
(NULL_TREE
, $1, NULL_TREE
); }
1441 | nonempty_type_quals TYPE_QUAL
1442 { $$
= tree_cons
(NULL_TREE
, $2, $1); }
1448 | type_quals TYPE_QUAL
1449 { $$
= tree_cons
(NULL_TREE
, $2, $1); }
1452 absdcl1: /* a nonempty absolute declarator */
1455 /* `(typedef)1' is `int'. */
1456 |
'*' type_quals absdcl1 %prec UNARY
1457 { $$
= make_pointer_declarator
($2, $3); }
1458 |
'*' type_quals %prec UNARY
1459 { $$
= make_pointer_declarator
($2, NULL_TREE
); }
1460 | absdcl1
'(' parmlist %prec
'.'
1461 { $$
= build_nt
(CALL_EXPR
, $1, $3, NULL_TREE
); }
1462 | absdcl1
'[' expr
']' %prec
'.'
1463 { $$
= build_nt
(ARRAY_REF
, $1, $3); }
1464 | absdcl1
'[' ']' %prec
'.'
1465 { $$
= build_nt
(ARRAY_REF
, $1, NULL_TREE
); }
1466 |
'(' parmlist %prec
'.'
1467 { $$
= build_nt
(CALL_EXPR
, NULL_TREE
, $2, NULL_TREE
); }
1468 |
'[' expr
']' %prec
'.'
1469 { $$
= build_nt
(ARRAY_REF
, NULL_TREE
, $2); }
1471 { $$
= build_nt
(ARRAY_REF
, NULL_TREE
, NULL_TREE
); }
1472 /* ??? It appears we have to support attributes here, however
1473 using prefix_attributes is wrong. */
1476 /* at least one statement, the first of which parses without error. */
1477 /* stmts is used only after decls, so an invalid first statement
1478 is actually regarded as an invalid decl and part of the decls. */
1481 lineno_stmt_or_labels
1484 pedwarn
("ANSI C forbids label at end of compound statement");
1488 lineno_stmt_or_labels:
1489 lineno_stmt_or_label
1490 | lineno_stmt_or_labels lineno_stmt_or_label
1492 | lineno_stmt_or_labels errstmt
1504 pushlevel: /* empty */
1505 { emit_line_note
(input_filename
, lineno
);
1509 expand_start_bindings
(0);
1513 /* Read zero or more forward-declarations for labels
1514 that nested functions can jump to. */
1519 pedwarn
("ANSI C forbids label declarations"); }
1524 | label_decls label_decl
1528 LABEL identifiers_or_typenames
';'
1530 for
(link
= $2; link
; link
= TREE_CHAIN
(link
))
1532 tree label
= shadow_label
(TREE_VALUE
(link
));
1533 C_DECLARED_LABEL_FLAG
(label
) = 1;
1534 declare_nonlocal_label
(label
);
1539 /* This is the body of a function definition.
1540 It causes syntax errors to ignore to the next openbrace. */
1548 { $$
= convert
(void_type_node
, integer_zero_node
); }
1549 |
'{' pushlevel maybe_label_decls decls xstmts
'}'
1550 { emit_line_note
(input_filename
, lineno
);
1551 expand_end_bindings
(getdecls
(), 1, 0);
1552 $$
= poplevel
(1, 1, 0);
1553 if
(yychar == CONSTANT ||
yychar == STRING
)
1554 pop_momentary_nofree
();
1557 |
'{' pushlevel maybe_label_decls
error '}'
1558 { emit_line_note
(input_filename
, lineno
);
1559 expand_end_bindings
(getdecls
(), kept_level_p
(), 0);
1560 $$
= poplevel
(kept_level_p
(), 0, 0);
1561 if
(yychar == CONSTANT ||
yychar == STRING
)
1562 pop_momentary_nofree
();
1565 |
'{' pushlevel maybe_label_decls stmts
'}'
1566 { emit_line_note
(input_filename
, lineno
);
1567 expand_end_bindings
(getdecls
(), kept_level_p
(), 0);
1568 $$
= poplevel
(kept_level_p
(), 0, 0);
1569 if
(yychar == CONSTANT ||
yychar == STRING
)
1570 pop_momentary_nofree
();
1575 /* Value is number of statements counted as of the closeparen. */
1577 if_prefix lineno_labeled_stmt
1578 /* Make sure expand_end_cond is run once
1579 for each call to expand_start_cond.
1580 Otherwise a crash is likely. */
1586 { emit_line_note
($
<filename
>-1, $
<lineno
>0);
1587 expand_start_cond
(truthvalue_conversion
($3), 0);
1588 $
<itype
>$
= stmt_count
;
1589 if_stmt_file
= $
<filename
>-1;
1590 if_stmt_line
= $
<lineno
>0;
1591 position_after_white_space
(); }
1594 /* This is a subroutine of stmt.
1595 It is used twice, once for valid DO statements
1596 and once for catching errors in parsing the end test. */
1600 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1601 /* See comment in `while' alternative, above. */
1603 expand_start_loop_continue_elsewhere
(1);
1604 position_after_white_space
(); }
1605 lineno_labeled_stmt WHILE
1606 { expand_loop_continue_here
(); }
1610 { $$
= input_filename
; }
1617 lineno_labeled_stmt:
1618 save_filename save_lineno stmt
1620 /* | save_filename save_lineno error
1623 | save_filename save_lineno label lineno_labeled_stmt
1627 lineno_stmt_or_label:
1628 save_filename save_lineno stmt_or_label
1639 /* Parse a single real statement, not including any labels. */
1646 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1647 /* It appears that this should not be done--that a non-lvalue array
1648 shouldn't get an error if the value isn't used.
1649 Section 3.2.2.1 says that an array lvalue gets converted to a pointer
1650 if it appears as a top-level expression,
1651 but says nothing about non-lvalue arrays. */
1653 /* Call default_conversion to get an error
1654 on referring to a register array if pedantic. */
1655 if
(TREE_CODE
(TREE_TYPE
($1)) == ARRAY_TYPE
1656 || TREE_CODE
(TREE_TYPE
($1)) == FUNCTION_TYPE
)
1657 $1 = default_conversion
($1);
1659 iterator_expand
($1);
1660 clear_momentary
(); }
1662 { expand_start_else
();
1663 $
<itype
>1 = stmt_count
;
1664 position_after_white_space
(); }
1666 { expand_end_cond
();
1667 if
(extra_warnings
&& stmt_count
== $
<itype
>1)
1668 warning
("empty body in an else-statement"); }
1669 | simple_if %prec IF
1670 { expand_end_cond
();
1671 /* This warning is here instead of in simple_if, because we
1672 do not want a warning if an empty if is followed by an
1673 else statement. Increment stmt_count so we don't
1674 give a second error if this is a nested `if'. */
1675 if
(extra_warnings
&& stmt_count
++ == $
<itype
>1)
1676 warning_with_file_and_line
(if_stmt_file
, if_stmt_line
,
1677 "empty body in an if-statement"); }
1678 /* Make sure expand_end_cond is run once
1679 for each call to expand_start_cond.
1680 Otherwise a crash is likely. */
1681 | simple_if ELSE
error
1682 { expand_end_cond
(); }
1685 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1686 /* The emit_nop used to come before emit_line_note,
1687 but that made the nop seem like part of the preceding line.
1688 And that was confusing when the preceding line was
1689 inside of an if statement and was not really executed.
1690 I think it ought to work to put the nop after the line number.
1691 We will see. --rms, July 15, 1991. */
1694 { /* Don't start the loop till we have succeeded
1695 in parsing the end test. This is to make sure
1696 that we end every loop we start. */
1697 expand_start_loop
(1);
1698 emit_line_note
(input_filename
, lineno
);
1699 expand_exit_loop_if_false
(NULL_PTR
,
1700 truthvalue_conversion
($4));
1701 position_after_white_space
(); }
1703 { expand_end_loop
(); }
1706 { emit_line_note
(input_filename
, lineno
);
1707 expand_exit_loop_if_false
(NULL_PTR
,
1708 truthvalue_conversion
($3));
1710 clear_momentary
(); }
1711 /* This rule is needed to make sure we end every loop we start. */
1712 | do_stmt_start
error
1713 { expand_end_loop
();
1714 clear_momentary
(); }
1718 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1719 /* See comment in `while' alternative, above. */
1721 if
($3) c_expand_expr_stmt
($3);
1722 /* Next step is to call expand_start_loop_continue_elsewhere,
1723 but wait till after we parse the entire for (...).
1724 Otherwise, invalid input might cause us to call that
1725 fn without calling expand_end_loop. */
1728 /* Can't emit now; wait till after expand_start_loop... */
1729 { $
<lineno
>7 = lineno
;
1730 $
<filename
>$
= input_filename
; }
1733 /* Start the loop. Doing this after parsing
1734 all the expressions ensures we will end the loop. */
1735 expand_start_loop_continue_elsewhere
(1);
1736 /* Emit the end-test, with a line number. */
1737 emit_line_note
($
<filename
>8, $
<lineno
>7);
1739 expand_exit_loop_if_false
(NULL_PTR
,
1740 truthvalue_conversion
($6));
1741 /* Don't let the tree nodes for $9 be discarded by
1742 clear_momentary during the parsing of the next stmt. */
1744 $
<lineno
>7 = lineno
;
1745 $
<filename
>8 = input_filename
;
1746 position_after_white_space
(); }
1748 { /* Emit the increment expression, with a line number. */
1749 emit_line_note
($
<filename
>8, $
<lineno
>7);
1750 expand_loop_continue_here
();
1752 c_expand_expr_stmt
($9);
1753 if
(yychar == CONSTANT ||
yychar == STRING
)
1754 pop_momentary_nofree
();
1757 expand_end_loop
(); }
1758 | SWITCH
'(' expr
')'
1760 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1761 c_expand_start_case
($3);
1762 /* Don't let the tree nodes for $3 be discarded by
1763 clear_momentary during the parsing of the next stmt. */
1765 position_after_white_space
(); }
1767 { expand_end_case
($3);
1768 if
(yychar == CONSTANT ||
yychar == STRING
)
1769 pop_momentary_nofree
();
1774 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1775 if
( ! expand_exit_something
())
1776 error ("break statement not within loop or switch"); }
1779 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1780 if
(! expand_continue_loop
(NULL_PTR
))
1781 error ("continue statement not within a loop"); }
1784 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1785 c_expand_return
(NULL_TREE
); }
1788 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1789 c_expand_return
($2); }
1790 | ASM_KEYWORD maybe_type_qual
'(' expr
')' ';'
1792 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1794 if
((TREE_CODE
($4) == ADDR_EXPR
1795 && TREE_CODE
(TREE_OPERAND
($4, 0)) == STRING_CST
)
1796 || TREE_CODE
($4) == STRING_CST
)
1799 error ("argument of `asm' is not a constant string"); }
1800 /* This is the case with just output operands. */
1801 | ASM_KEYWORD maybe_type_qual
'(' expr
':' asm_operands
')' ';'
1803 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1804 c_expand_asm_operands
($4, $6, NULL_TREE
, NULL_TREE
,
1805 $2 == ridpointers
[(int)RID_VOLATILE
],
1806 input_filename
, lineno
); }
1807 /* This is the case with input operands as well. */
1808 | ASM_KEYWORD maybe_type_qual
'(' expr
':' asm_operands
':' asm_operands
')' ';'
1810 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1811 c_expand_asm_operands
($4, $6, $8, NULL_TREE
,
1812 $2 == ridpointers
[(int)RID_VOLATILE
],
1813 input_filename
, lineno
); }
1814 /* This is the case with clobbered registers as well. */
1815 | ASM_KEYWORD maybe_type_qual
'(' expr
':' asm_operands
':'
1816 asm_operands
':' asm_clobbers
')' ';'
1818 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1819 c_expand_asm_operands
($4, $6, $8, $10,
1820 $2 == ridpointers
[(int)RID_VOLATILE
],
1821 input_filename
, lineno
); }
1822 | GOTO identifier
';'
1825 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1826 decl
= lookup_label
($2);
1829 TREE_USED
(decl
) = 1;
1835 pedwarn
("ANSI C forbids `goto *expr;'");
1837 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1838 expand_computed_goto
(convert
(ptr_type_node
, $3)); }
1843 all_iter_stmt_simple
1844 /* | all_iter_stmt_with_decl */
1847 all_iter_stmt_simple:
1850 /* The value returned by this action is */
1851 /* 1 if everything is OK */
1852 /* 0 in case of error or already bound iterator */
1855 if
(TREE_CODE
($3) != VAR_DECL
)
1856 error ("invalid `for (ITERATOR)' syntax");
1857 else if
(! ITERATOR_P
($3))
1858 error ("`%s' is not an iterator",
1859 IDENTIFIER_POINTER
(DECL_NAME
($3)));
1860 else if
(ITERATOR_BOUND_P
($3))
1861 error ("`for (%s)' inside expansion of same iterator",
1862 IDENTIFIER_POINTER
(DECL_NAME
($3)));
1866 iterator_for_loop_start
($3);
1872 iterator_for_loop_end
($3);
1875 /* This really should allow any kind of declaration,
1876 for generality. Fix it before turning it back on.
1878 all_iter_stmt_with_decl:
1879 FOR '(' ITERATOR pushlevel setspecs iterator_spec ')'
1881 */ /* The value returned by this action is */
1882 /* 1 if everything is OK */
1883 /* 0 in case of error or already bound iterator */
1885 iterator_for_loop_start ($6);
1889 iterator_for_loop_end ($6);
1890 emit_line_note (input_filename, lineno);
1891 expand_end_bindings (getdecls (), 1, 0);
1892 $<ttype>$ = poplevel (1, 1, 0);
1893 if (yychar == CONSTANT || yychar == STRING)
1894 pop_momentary_nofree ();
1900 /* Any kind of label, including jump labels and case labels.
1901 ANSI C accepts labels only before statements, but we allow them
1902 also at the end of a compound statement. */
1904 label: CASE expr_no_commas
':'
1905 { register tree value
= check_case_value
($2);
1907 = build_decl
(LABEL_DECL
, NULL_TREE
, NULL_TREE
);
1911 if
(value
!= error_mark_node
)
1914 int success
= pushcase
(value
, convert_and_check
,
1917 error ("case label not within a switch statement");
1918 else if
(success
== 2)
1920 error ("duplicate case value");
1921 error_with_decl
(duplicate
, "this is the first entry for that value");
1923 else if
(success
== 3)
1924 warning
("case value out of range");
1925 else if
(success
== 5)
1926 error ("case label within scope of cleanup or variable array");
1928 position_after_white_space
(); }
1929 | CASE expr_no_commas ELLIPSIS expr_no_commas
':'
1930 { register tree value1
= check_case_value
($2);
1931 register tree value2
= check_case_value
($4);
1933 = build_decl
(LABEL_DECL
, NULL_TREE
, NULL_TREE
);
1936 pedwarn
("ANSI C forbids case ranges");
1939 if
(value1
!= error_mark_node
&& value2
!= error_mark_node
)
1942 int success
= pushcase_range
(value1
, value2
,
1943 convert_and_check
, label
,
1946 error ("case label not within a switch statement");
1947 else if
(success
== 2)
1949 error ("duplicate case value");
1950 error_with_decl
(duplicate
, "this is the first entry for that value");
1952 else if
(success
== 3)
1953 warning
("case value out of range");
1954 else if
(success
== 4)
1955 warning
("empty case range");
1956 else if
(success
== 5)
1957 error ("case label within scope of cleanup or variable array");
1959 position_after_white_space
(); }
1964 = build_decl
(LABEL_DECL
, NULL_TREE
, NULL_TREE
);
1965 int success
= pushcase
(NULL_TREE
, 0, label
, &duplicate
);
1968 error ("default label not within a switch statement");
1969 else if
(success
== 2)
1971 error ("multiple default labels in one switch");
1972 error_with_decl
(duplicate
, "this is the first default label");
1974 position_after_white_space
(); }
1976 { tree label
= define_label
(input_filename
, lineno
, $1);
1980 expand_label
(label
);
1981 position_after_white_space
(); }
1984 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
1988 { emit_line_note
(input_filename
, lineno
);
1991 { emit_line_note
(input_filename
, lineno
); }
2000 /* These are the operands other than the first string and colon
2001 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
2002 asm_operands: /* empty */
2004 | nonnull_asm_operands
2007 nonnull_asm_operands:
2009 | nonnull_asm_operands
',' asm_operand
2010 { $$
= chainon
($1, $3); }
2015 { $$
= build_tree_list
($1, $3); }
2020 { $$
= tree_cons
(NULL_TREE
, combine_strings
($1), NULL_TREE
); }
2021 | asm_clobbers
',' string
2022 { $$
= tree_cons
(NULL_TREE
, combine_strings
($3), $1); }
2025 /* This is what appears inside the parens in a function declarator.
2026 Its value is a list of ..._TYPE nodes. */
2029 clear_parm_order
();
2030 declare_parm_level
(0); }
2033 parmlist_tags_warning
();
2034 poplevel
(0, 0, 0); }
2042 pedwarn
("ANSI C forbids forward parameter declarations");
2043 /* Mark the forward decls as such. */
2044 for
(parm
= getdecls
(); parm
; parm
= TREE_CHAIN
(parm
))
2045 TREE_ASM_WRITTEN
(parm
) = 1;
2046 clear_parm_order
(); }
2050 { $$
= tree_cons
(NULL_TREE
, NULL_TREE
, NULL_TREE
); }
2053 /* This is what appears inside the parens in a function declarator.
2054 Is value is represented in the format that grokdeclarator expects. */
2055 parmlist_2: /* empty */
2056 { $$
= get_parm_info
(0); }
2058 { $$
= get_parm_info
(0);
2059 /* Gcc used to allow this as an extension. However, it does
2060 not work for all targets, and thus has been disabled.
2061 Also, since func (...) and func () are indistinguishable,
2062 it caused problems with the code in expand_builtin which
2063 tries to verify that BUILT_IN_NEXT_ARG is being used
2065 error ("ANSI C requires a named argument before `...'");
2068 { $$
= get_parm_info
(1); }
2069 | parms
',' ELLIPSIS
2070 { $$
= get_parm_info
(0); }
2075 { push_parm_decl
($1); }
2077 { push_parm_decl
($3); }
2080 /* A single parameter declaration or parameter type name,
2081 as found in a parmlist. */
2083 typed_declspecs setspecs parm_declarator maybe_attribute
2084 { $$
= build_tree_list
(build_tree_list
(current_declspecs
,
2086 build_tree_list
(prefix_attributes
,
2088 current_declspecs
= TREE_VALUE
(declspec_stack
);
2089 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
2090 declspec_stack
= TREE_CHAIN
(declspec_stack
);
2091 resume_momentary
($2); }
2092 | typed_declspecs setspecs notype_declarator maybe_attribute
2093 { $$
= build_tree_list
(build_tree_list
(current_declspecs
,
2095 build_tree_list
(prefix_attributes
,
2097 current_declspecs
= TREE_VALUE
(declspec_stack
);
2098 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
2099 declspec_stack
= TREE_CHAIN
(declspec_stack
);
2100 resume_momentary
($2); }
2101 | typed_declspecs setspecs absdcl maybe_attribute
2102 { $$
= build_tree_list
(build_tree_list
(current_declspecs
,
2104 build_tree_list
(prefix_attributes
,
2106 current_declspecs
= TREE_VALUE
(declspec_stack
);
2107 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
2108 declspec_stack
= TREE_CHAIN
(declspec_stack
);
2109 resume_momentary
($2); }
2110 | declmods setspecs notype_declarator maybe_attribute
2111 { $$
= build_tree_list
(build_tree_list
(current_declspecs
,
2113 build_tree_list
(prefix_attributes
,
2115 current_declspecs
= TREE_VALUE
(declspec_stack
);
2116 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
2117 declspec_stack
= TREE_CHAIN
(declspec_stack
);
2118 resume_momentary
($2); }
2120 | declmods setspecs absdcl maybe_attribute
2121 { $$
= build_tree_list
(build_tree_list
(current_declspecs
,
2123 build_tree_list
(prefix_attributes
,
2125 current_declspecs
= TREE_VALUE
(declspec_stack
);
2126 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
2127 declspec_stack
= TREE_CHAIN
(declspec_stack
);
2128 resume_momentary
($2); }
2131 /* This is used in a function definition
2132 where either a parmlist or an identifier list is ok.
2133 Its value is a list of ..._TYPE nodes or a list of identifiers. */
2134 parmlist_or_identifiers:
2136 clear_parm_order
();
2137 declare_parm_level
(1); }
2138 parmlist_or_identifiers_1
2140 parmlist_tags_warning
();
2141 poplevel
(0, 0, 0); }
2144 parmlist_or_identifiers_1:
2148 for
(t
= $1; t
; t
= TREE_CHAIN
(t
))
2149 if
(TREE_VALUE
(t
) == NULL_TREE
)
2150 error ("`...' in old-style identifier list");
2151 $$
= tree_cons
(NULL_TREE
, NULL_TREE
, $1); }
2154 /* A nonempty list of identifiers. */
2157 { $$
= build_tree_list
(NULL_TREE
, $1); }
2158 | identifiers
',' IDENTIFIER
2159 { $$
= chainon
($1, build_tree_list
(NULL_TREE
, $3)); }
2162 /* A nonempty list of identifiers, including typenames. */
2163 identifiers_or_typenames:
2165 { $$
= build_tree_list
(NULL_TREE
, $1); }
2166 | identifiers_or_typenames
',' identifier
2167 { $$
= chainon
($1, build_tree_list
(NULL_TREE
, $3)); }
2172 { $
<itype
>$
= pedantic
;