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-98, 1999 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.) */
69 #ifdef MULTIBYTE_CHARS
74 /* Since parsers are distinct for each language, put the language string
76 char *language_string
= "GNU C";
78 /* Like YYERROR but do call yyerror. */
79 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
81 /* Cause the `yydebug' variable to be defined. */
87 %
union {long itype
; tree ttype
; enum tree_code code
;
88 char *filename
; int lineno
; int ends_in_label
; }
90 /* All identifiers that are not reserved words
91 and are not declared typedefs in the current block */
94 /* All identifiers that are declared typedefs in the current block.
95 In some contexts, they are treated just like IDENTIFIER,
96 but they can also serve as typespecs in declarations. */
99 /* Reserved words that specify storage class.
100 yylval contains an IDENTIFIER_NODE which indicates which one. */
103 /* Reserved words that specify type.
104 yylval contains an IDENTIFIER_NODE which indicates which one. */
107 /* Reserved words that qualify type: "const", "volatile", or "restrict".
108 yylval contains an IDENTIFIER_NODE which indicates which one. */
111 /* Character or numeric constants.
112 yylval is the node for the constant. */
115 /* String constants in raw form.
116 yylval is a STRING_CST node. */
119 /* "...", used for functions with variable arglists. */
122 /* the reserved words */
123 /* SCO include files test "ASM", so use something else. */
124 %token SIZEOF ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
125 %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD TYPEOF ALIGNOF
126 %token ATTRIBUTE EXTENSION LABEL
127 %token REALPART IMAGPART
129 /* Add precedence rules to solve dangling else s/r conflict */
133 /* Define the operator tokens and their precedences.
134 The value is an integer because, if used, it is the tree code
135 to use in the expression made from the operator. */
137 %right
<code
> ASSIGN
'='
138 %right
<code
> '?' ':'
144 %left
<code
> EQCOMPARE
145 %left
<code
> ARITHCOMPARE
146 %left
<code
> LSHIFT RSHIFT
148 %left
<code
> '*' '/' '%'
149 %right
<code
> UNARY PLUSPLUS MINUSMINUS
151 %left
<code
> POINTSAT
'.' '(' '['
153 /* The Objective-C keywords. These are included in C and in
154 Objective C, so that the token codes are the same in both. */
155 %token INTERFACE IMPLEMENTATION END SELECTOR DEFS ENCODE
156 %token CLASSNAME PUBLIC PRIVATE PROTECTED PROTOCOL OBJECTNAME CLASS ALIAS
158 /* Objective-C string constants in raw form.
159 yylval is an OBJC_STRING_CST node. */
165 %type
<ttype
> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist exprlist
166 %type
<ttype
> expr_no_commas cast_expr unary_expr primary
string STRING
167 %type
<ttype
> typed_declspecs reserved_declspecs
168 %type
<ttype
> typed_typespecs reserved_typespecquals
169 %type
<ttype
> declmods typespec typespecqual_reserved
170 %type
<ttype
> typed_declspecs_no_prefix_attr reserved_declspecs_no_prefix_attr
171 %type
<ttype
> declmods_no_prefix_attr
172 %type
<ttype
> SCSPEC TYPESPEC TYPE_QUAL nonempty_type_quals maybe_type_qual
173 %type
<ttype
> initdecls notype_initdecls initdcl notype_initdcl
174 %type
<ttype
> init maybeasm
175 %type
<ttype
> asm_operands nonnull_asm_operands asm_operand asm_clobbers
176 %type
<ttype
> maybe_attribute attributes attribute attribute_list attrib
177 %type
<ttype
> any_word
179 %type
<ttype
> compstmt
181 %type
<ttype
> declarator
182 %type
<ttype
> notype_declarator after_type_declarator
183 %type
<ttype
> parm_declarator
185 %type
<ttype
> structsp component_decl_list component_decl_list2
186 %type
<ttype
> component_decl components component_declarator
187 %type
<ttype
> enumlist enumerator
188 %type
<ttype
> struct_head union_head enum_head
189 %type
<ttype
> typename absdcl absdcl1 type_quals
190 %type
<ttype
> xexpr parms parm identifiers
192 %type
<ttype
> parmlist parmlist_1 parmlist_2
193 %type
<ttype
> parmlist_or_identifiers parmlist_or_identifiers_1
194 %type
<ttype
> identifiers_or_typenames
196 %type
<itype
> setspecs
198 %type
<ends_in_label
> lineno_stmt_or_label lineno_stmt_or_labels stmt_or_label
200 %type
<filename
> save_filename
201 %type
<lineno
> save_lineno
205 /* Number of statements (loosely speaking) and compound statements
207 static int stmt_count
;
208 static int compstmt_count
;
210 /* Input file and line number of the end of the body of last simple_if;
211 used by the stmt-rule immediately after simple_if returns. */
212 static char *if_stmt_file
;
213 static int if_stmt_line
;
215 /* List of types and structure classes of the current declaration. */
216 static tree current_declspecs
= NULL_TREE
;
217 static tree prefix_attributes
= NULL_TREE
;
219 /* Stack of saved values of current_declspecs and prefix_attributes. */
220 static tree declspec_stack
;
222 /* 1 if we explained undeclared var errors. */
223 static int undeclared_variable_notice
;
226 /* Tell yyparse how to print a token's value, if yydebug is set. */
228 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
229 extern
void yyprint PROTO
((FILE *, int, YYSTYPE));
235 pedwarn
("ANSI C forbids an empty source file");
240 /* In case there were missing closebraces,
241 get us back to the global binding level. */
242 while
(! global_bindings_p
())
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
260 | ASM_KEYWORD
'(' expr
')' ';'
262 if
((TREE_CODE
($3) == ADDR_EXPR
263 && TREE_CODE
(TREE_OPERAND
($3, 0)) == STRING_CST
)
264 || TREE_CODE
($3) == STRING_CST
)
267 error ("argument of `asm' is not a constant string"); }
269 { pedantic
= $
<itype
>1; }
273 setspecs notype_initdecls
';'
275 error ("ANSI C forbids data definition with no type or storage class");
276 else if
(!flag_traditional
)
277 warning
("data definition has no type or storage class");
279 current_declspecs
= TREE_VALUE
(declspec_stack
);
280 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
281 declspec_stack
= TREE_CHAIN
(declspec_stack
);
282 resume_momentary
($1); }
283 | declmods setspecs notype_initdecls
';'
284 { current_declspecs
= TREE_VALUE
(declspec_stack
);
285 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
286 declspec_stack
= TREE_CHAIN
(declspec_stack
);
287 resume_momentary
($2); }
288 | typed_declspecs setspecs initdecls
';'
289 { current_declspecs
= TREE_VALUE
(declspec_stack
);
290 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
291 declspec_stack
= TREE_CHAIN
(declspec_stack
);
292 resume_momentary
($2); }
294 { pedwarn
("empty declaration"); }
295 | typed_declspecs
';'
301 pedwarn
("ANSI C does not allow extra `;' outside of a function"); }
305 typed_declspecs setspecs declarator
306 { if
(! start_function
(current_declspecs
, $3,
307 prefix_attributes
, NULL_TREE
, 0))
309 reinit_parse_for_function
(); }
311 { store_parm_decls
(); }
313 { finish_function
(0);
314 current_declspecs
= TREE_VALUE
(declspec_stack
);
315 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
316 declspec_stack
= TREE_CHAIN
(declspec_stack
);
317 resume_momentary
($2); }
318 | typed_declspecs setspecs declarator
error
319 { current_declspecs
= TREE_VALUE
(declspec_stack
);
320 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
321 declspec_stack
= TREE_CHAIN
(declspec_stack
);
322 resume_momentary
($2); }
323 | declmods setspecs notype_declarator
324 { if
(! start_function
(current_declspecs
, $3,
325 prefix_attributes
, NULL_TREE
, 0))
327 reinit_parse_for_function
(); }
329 { store_parm_decls
(); }
331 { finish_function
(0);
332 current_declspecs
= TREE_VALUE
(declspec_stack
);
333 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
334 declspec_stack
= TREE_CHAIN
(declspec_stack
);
335 resume_momentary
($2); }
336 | declmods setspecs notype_declarator
error
337 { current_declspecs
= TREE_VALUE
(declspec_stack
);
338 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
339 declspec_stack
= TREE_CHAIN
(declspec_stack
);
340 resume_momentary
($2); }
341 | setspecs notype_declarator
342 { if
(! start_function
(NULL_TREE
, $2,
343 prefix_attributes
, NULL_TREE
, 0))
345 reinit_parse_for_function
(); }
347 { store_parm_decls
(); }
349 { finish_function
(0);
350 current_declspecs
= TREE_VALUE
(declspec_stack
);
351 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
352 declspec_stack
= TREE_CHAIN
(declspec_stack
);
353 resume_momentary
($1); }
354 | setspecs notype_declarator
error
355 { current_declspecs
= TREE_VALUE
(declspec_stack
);
356 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
357 declspec_stack
= TREE_CHAIN
(declspec_stack
);
358 resume_momentary
($1); }
369 { $$
= NEGATE_EXPR
; }
371 { $$
= CONVERT_EXPR
; }
373 { $$
= PREINCREMENT_EXPR
; }
375 { $$
= PREDECREMENT_EXPR
; }
377 { $$
= BIT_NOT_EXPR
; }
379 { $$
= TRUTH_NOT_EXPR
; }
382 expr: nonnull_exprlist
383 { $$
= build_compound_expr
($1); }
394 { $$
= build_tree_list
(NULL_TREE
, $1); }
395 | nonnull_exprlist
',' expr_no_commas
396 { chainon
($1, build_tree_list
(NULL_TREE
, $3)); }
401 |
'*' cast_expr %prec UNARY
402 { $$
= build_indirect_ref
($2, "unary *"); }
403 /* __extension__ turns off -pedantic for following primary. */
404 | extension cast_expr %prec UNARY
406 pedantic
= $
<itype
>1; }
407 | unop cast_expr %prec UNARY
408 { $$
= build_unary_op
($1, $2, 0);
409 overflow_warning
($$
); }
410 /* Refer to the address of a label as a pointer. */
412 { tree label
= lookup_label
($2);
414 pedwarn
("ANSI C forbids `&&'");
416 $$
= null_pointer_node
;
419 TREE_USED
(label
) = 1;
420 $$
= build1
(ADDR_EXPR
, ptr_type_node
, label
);
421 TREE_CONSTANT
($$
) = 1;
424 /* This seems to be impossible on some machines, so let's turn it off.
425 You can use __builtin_next_arg to find the anonymous stack args.
427 { tree types = TYPE_ARG_TYPES (TREE_TYPE (current_function_decl));
428 $$ = error_mark_node;
429 if (TREE_VALUE (tree_last (types)) == void_type_node)
430 error ("`&...' used in function with fixed number of arguments");
434 pedwarn ("ANSI C forbids `&...'");
435 $$ = tree_last (DECL_ARGUMENTS (current_function_decl));
436 $$ = build_unary_op (ADDR_EXPR, $$, 0);
439 | sizeof unary_expr %prec UNARY
441 if
(TREE_CODE
($2) == COMPONENT_REF
442 && DECL_C_BIT_FIELD
(TREE_OPERAND
($2, 1)))
443 error ("`sizeof' applied to a bit-field");
444 $$
= c_sizeof
(TREE_TYPE
($2)); }
445 | sizeof
'(' typename
')' %prec HYPERUNARY
447 $$
= c_sizeof
(groktypename
($3)); }
448 | alignof unary_expr %prec UNARY
450 $$
= c_alignof_expr
($2); }
451 | alignof
'(' typename
')' %prec HYPERUNARY
453 $$
= c_alignof
(groktypename
($3)); }
454 | REALPART cast_expr %prec UNARY
455 { $$
= build_unary_op
(REALPART_EXPR
, $2, 0); }
456 | IMAGPART cast_expr %prec UNARY
457 { $$
= build_unary_op
(IMAGPART_EXPR
, $2, 0); }
461 SIZEOF
{ skip_evaluation
++; }
465 ALIGNOF
{ skip_evaluation
++; }
470 |
'(' typename
')' cast_expr %prec UNARY
471 { tree type
= groktypename
($2);
472 $$
= build_c_cast
(type
, $4); }
473 |
'(' typename
')' '{'
474 { start_init
(NULL_TREE
, NULL
, 0);
475 $2 = groktypename
($2);
476 really_start_incremental_init
($2); }
477 initlist_maybe_comma
'}' %prec UNARY
479 tree result
= pop_init_level
(0);
483 if
(pedantic
&& ! flag_isoc9x
)
484 pedwarn
("ANSI C forbids constructor expressions");
485 if
(TYPE_NAME
(type
) != 0)
487 if
(TREE_CODE
(TYPE_NAME
(type
)) == IDENTIFIER_NODE
)
488 name
= IDENTIFIER_POINTER
(TYPE_NAME
(type
));
490 name
= IDENTIFIER_POINTER
(DECL_NAME
(TYPE_NAME
(type
)));
495 if
(TREE_CODE
(type
) == ARRAY_TYPE
&& TYPE_SIZE
(type
) == 0)
497 int failure
= complete_array_type
(type
, $$
, 1);
506 | expr_no_commas
'+' expr_no_commas
507 { $$
= parser_build_binary_op
($2, $1, $3); }
508 | expr_no_commas
'-' expr_no_commas
509 { $$
= parser_build_binary_op
($2, $1, $3); }
510 | expr_no_commas
'*' expr_no_commas
511 { $$
= parser_build_binary_op
($2, $1, $3); }
512 | expr_no_commas
'/' expr_no_commas
513 { $$
= parser_build_binary_op
($2, $1, $3); }
514 | expr_no_commas
'%' expr_no_commas
515 { $$
= parser_build_binary_op
($2, $1, $3); }
516 | expr_no_commas LSHIFT expr_no_commas
517 { $$
= parser_build_binary_op
($2, $1, $3); }
518 | expr_no_commas RSHIFT expr_no_commas
519 { $$
= parser_build_binary_op
($2, $1, $3); }
520 | expr_no_commas ARITHCOMPARE expr_no_commas
521 { $$
= parser_build_binary_op
($2, $1, $3); }
522 | expr_no_commas EQCOMPARE expr_no_commas
523 { $$
= parser_build_binary_op
($2, $1, $3); }
524 | expr_no_commas
'&' expr_no_commas
525 { $$
= parser_build_binary_op
($2, $1, $3); }
526 | expr_no_commas
'|' expr_no_commas
527 { $$
= parser_build_binary_op
($2, $1, $3); }
528 | expr_no_commas
'^' expr_no_commas
529 { $$
= parser_build_binary_op
($2, $1, $3); }
530 | expr_no_commas ANDAND
531 { $1 = truthvalue_conversion
(default_conversion
($1));
532 skip_evaluation
+= $1 == boolean_false_node
; }
534 { skip_evaluation
-= $1 == boolean_false_node
;
535 $$
= parser_build_binary_op
(TRUTH_ANDIF_EXPR
, $1, $4); }
536 | expr_no_commas OROR
537 { $1 = truthvalue_conversion
(default_conversion
($1));
538 skip_evaluation
+= $1 == boolean_true_node
; }
540 { skip_evaluation
-= $1 == boolean_true_node
;
541 $$
= parser_build_binary_op
(TRUTH_ORIF_EXPR
, $1, $4); }
543 { $1 = truthvalue_conversion
(default_conversion
($1));
544 skip_evaluation
+= $1 == boolean_false_node
; }
546 { skip_evaluation
+= (($1 == boolean_true_node
)
547 - ($1 == boolean_false_node
)); }
549 { skip_evaluation
-= $1 == boolean_true_node
;
550 $$
= build_conditional_expr
($1, $4, $7); }
553 pedwarn
("ANSI C forbids omitting the middle term of a ?: expression");
554 /* Make sure first operand is calculated only once. */
555 $
<ttype
>2 = save_expr
($1);
556 $1 = truthvalue_conversion
(default_conversion
($
<ttype
>2));
557 skip_evaluation
+= $1 == boolean_true_node
; }
559 { skip_evaluation
-= $1 == boolean_true_node
;
560 $$
= build_conditional_expr
($1, $
<ttype
>2, $5); }
561 | expr_no_commas
'=' expr_no_commas
563 $$
= build_modify_expr
($1, NOP_EXPR
, $3);
564 class
= TREE_CODE_CLASS
(TREE_CODE
($$
));
565 if
(class
== 'e' || class
== '1'
566 || class
== '2' || class
== '<')
567 C_SET_EXP_ORIGINAL_CODE
($$
, MODIFY_EXPR
);
569 | expr_no_commas ASSIGN expr_no_commas
571 $$
= build_modify_expr
($1, $2, $3);
572 /* This inhibits warnings in truthvalue_conversion. */
573 class
= TREE_CODE_CLASS
(TREE_CODE
($$
));
574 if
(class
== 'e' || class
== '1'
575 || class
== '2' || class
== '<')
576 C_SET_EXP_ORIGINAL_CODE
($$
, ERROR_MARK
);
584 if
(!$$ || $$
== error_mark_node
)
586 if
(yychar == YYEMPTY
)
591 /* Ordinary implicit function declaration. */
592 $$
= implicitly_declare
($1);
593 assemble_external
($$
);
597 else if
(current_function_decl
== 0)
599 error ("`%s' undeclared here (not in a function)",
600 IDENTIFIER_POINTER
($1));
601 $$
= error_mark_node
;
606 if
(IDENTIFIER_GLOBAL_VALUE
($1) != error_mark_node
607 || IDENTIFIER_ERROR_LOCUS
($1) != current_function_decl
)
609 error ("`%s' undeclared (first use in this function)",
610 IDENTIFIER_POINTER
($1));
612 if
(! undeclared_variable_notice
)
614 error ("(Each undeclared identifier is reported only once");
615 error ("for each function it appears in.)");
616 undeclared_variable_notice
= 1;
619 $$
= error_mark_node
;
620 /* Prevent repeated error messages. */
621 IDENTIFIER_GLOBAL_VALUE
($1) = error_mark_node
;
622 IDENTIFIER_ERROR_LOCUS
($1) = current_function_decl
;
626 else if
(TREE_TYPE
($$
) == error_mark_node
)
627 $$
= error_mark_node
;
628 else if
(C_DECL_ANTICIPATED
($$
))
630 /* The first time we see a build-in function used,
631 if it has not been declared. */
632 C_DECL_ANTICIPATED
($$
) = 0;
633 if
(yychar == YYEMPTY
)
637 /* Omit the implicit declaration we
638 would ordinarily do, so we don't lose
639 the actual built in type.
640 But print a diagnostic for the mismatch. */
641 if
(TREE_CODE
($$
) != FUNCTION_DECL
)
642 error ("`%s' implicitly declared as function",
643 IDENTIFIER_POINTER
(DECL_NAME
($$
)));
644 else if
((TYPE_MODE
(TREE_TYPE
(TREE_TYPE
($$
)))
645 != TYPE_MODE
(integer_type_node
))
646 && (TREE_TYPE
(TREE_TYPE
($$
))
648 pedwarn
("type mismatch in implicit declaration for built-in function `%s'",
649 IDENTIFIER_POINTER
(DECL_NAME
($$
)));
650 /* If it really returns void, change that to int. */
651 if
(TREE_TYPE
(TREE_TYPE
($$
)) == void_type_node
)
653 = build_function_type
(integer_type_node
,
654 TYPE_ARG_TYPES
(TREE_TYPE
($$
)));
657 pedwarn
("built-in function `%s' used without declaration",
658 IDENTIFIER_POINTER
(DECL_NAME
($$
)));
660 /* Do what we would ordinarily do when a fn is used. */
661 assemble_external
($$
);
666 assemble_external
($$
);
670 if
(TREE_CODE
($$
) == CONST_DECL
)
672 $$
= DECL_INITIAL
($$
);
673 /* This is to prevent an enum whose value is 0
674 from being considered a null pointer constant. */
675 $$
= build1
(NOP_EXPR
, TREE_TYPE
($$
), $$
);
676 TREE_CONSTANT
($$
) = 1;
681 { $$
= combine_strings
($1); }
683 { char class
= TREE_CODE_CLASS
(TREE_CODE
($2));
684 if
(class
== 'e' || class
== '1'
685 || class
== '2' || class
== '<')
686 C_SET_EXP_ORIGINAL_CODE
($2, ERROR_MARK
);
689 { $$
= error_mark_node
; }
691 { if
(current_function_decl
== 0)
693 error ("braced-group within expression allowed only inside a function");
696 /* We must force a BLOCK for this level
697 so that, if it is not expanded later,
698 there is a way to turn off the entire subtree of blocks
699 that are contained in it. */
701 push_iterator_stack
();
703 $
<ttype
>$
= expand_start_stmt_expr
(); }
707 pedwarn
("ANSI C forbids braced-groups within expressions");
708 pop_iterator_stack
();
710 rtl_exp
= expand_end_stmt_expr
($
<ttype
>2);
711 /* The statements have side effects, so the group does. */
712 TREE_SIDE_EFFECTS
(rtl_exp
) = 1;
714 if
(TREE_CODE
($3) == BLOCK
)
716 /* Make a BIND_EXPR for the BLOCK already made. */
717 $$
= build
(BIND_EXPR
, TREE_TYPE
(rtl_exp
),
718 NULL_TREE
, rtl_exp
, $3);
719 /* Remove the block from the tree at this point.
720 It gets put back at the proper place
721 when the BIND_EXPR is expanded. */
727 | primary
'(' exprlist
')' %prec
'.'
728 { $$
= build_function_call
($1, $3); }
729 | primary
'[' expr
']' %prec
'.'
730 { $$
= build_array_ref
($1, $3); }
731 | primary
'.' identifier
733 $$
= build_component_ref
($1, $3);
735 | primary POINTSAT identifier
737 tree expr
= build_indirect_ref
($1, "->");
739 $$
= build_component_ref
(expr
, $3);
742 { $$
= build_unary_op
(POSTINCREMENT_EXPR
, $1, 0); }
744 { $$
= build_unary_op
(POSTDECREMENT_EXPR
, $1, 0); }
747 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
751 { $$
= chainon
($1, $2); }
755 old_style_parm_decls:
759 /* ... is used here to indicate a varargs function. */
762 pedwarn
("ANSI C does not permit use of `varargs.h'"); }
765 /* The following are analogous to lineno_decl, decls and decl
766 except that they do not allow nested functions.
767 They are used for old-style parm decls. */
769 save_filename save_lineno datadecl
776 | datadecls lineno_datadecl
777 | lineno_datadecl errstmt
780 /* We don't allow prefix attributes here because they cause reduce/reduce
781 conflicts: we can't know whether we're parsing a function decl with
782 attribute suffix, or function defn with attribute prefix on first old
785 typed_declspecs_no_prefix_attr setspecs initdecls
';'
786 { current_declspecs
= TREE_VALUE
(declspec_stack
);
787 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
788 declspec_stack
= TREE_CHAIN
(declspec_stack
);
789 resume_momentary
($2); }
790 | declmods_no_prefix_attr setspecs notype_initdecls
';'
791 { current_declspecs
= TREE_VALUE
(declspec_stack
);
792 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
793 declspec_stack
= TREE_CHAIN
(declspec_stack
);
794 resume_momentary
($2); }
795 | typed_declspecs_no_prefix_attr
';'
796 { shadow_tag_warned
($1, 1);
797 pedwarn
("empty declaration"); }
798 | declmods_no_prefix_attr
';'
799 { pedwarn
("empty declaration"); }
802 /* This combination which saves a lineno before a decl
803 is the normal thing to use, rather than decl itself.
804 This is to avoid shift/reduce conflicts in contexts
805 where statement labels are allowed. */
807 save_filename save_lineno decl
815 | lineno_decl errstmt
818 /* records the type and storage class specs to use for processing
819 the declarators that follow.
820 Maintains a stack of outer-level values of current_declspecs,
821 for the sake of parm declarations nested in function declarators. */
822 setspecs: /* empty */
823 { $$
= suspend_momentary
();
824 pending_xref_error
();
825 declspec_stack
= tree_cons
(prefix_attributes
,
828 split_specs_attrs
($
<ttype
>0,
829 ¤t_declspecs
, &prefix_attributes
); }
832 /* ??? Yuck. See after_type_declarator. */
833 setattrs: /* empty */
834 { prefix_attributes
= chainon
(prefix_attributes
, $
<ttype
>0); }
838 typed_declspecs setspecs initdecls
';'
839 { current_declspecs
= TREE_VALUE
(declspec_stack
);
840 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
841 declspec_stack
= TREE_CHAIN
(declspec_stack
);
842 resume_momentary
($2); }
843 | declmods setspecs notype_initdecls
';'
844 { current_declspecs
= TREE_VALUE
(declspec_stack
);
845 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
846 declspec_stack
= TREE_CHAIN
(declspec_stack
);
847 resume_momentary
($2); }
848 | typed_declspecs setspecs nested_function
849 { current_declspecs
= TREE_VALUE
(declspec_stack
);
850 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
851 declspec_stack
= TREE_CHAIN
(declspec_stack
);
852 resume_momentary
($2); }
853 | declmods setspecs notype_nested_function
854 { current_declspecs
= TREE_VALUE
(declspec_stack
);
855 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
856 declspec_stack
= TREE_CHAIN
(declspec_stack
);
857 resume_momentary
($2); }
858 | typed_declspecs
';'
861 { pedwarn
("empty declaration"); }
863 { pedantic
= $
<itype
>1; }
866 /* Declspecs which contain at least one type specifier or typedef name.
867 (Just `const' or `volatile' is not enough.)
868 A typedef'd name following these is taken as a name to be declared.
869 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
872 typespec reserved_declspecs
873 { $$
= tree_cons
(NULL_TREE
, $1, $2); }
874 | declmods typespec reserved_declspecs
875 { $$
= chainon
($3, tree_cons
(NULL_TREE
, $2, $1)); }
878 reserved_declspecs: /* empty */
880 | reserved_declspecs typespecqual_reserved
881 { $$
= tree_cons
(NULL_TREE
, $2, $1); }
882 | reserved_declspecs SCSPEC
883 { if
(extra_warnings
)
884 warning
("`%s' is not at beginning of declaration",
885 IDENTIFIER_POINTER
($2));
886 $$
= tree_cons
(NULL_TREE
, $2, $1); }
887 | reserved_declspecs attributes
888 { $$
= tree_cons
($2, NULL_TREE
, $1); }
891 typed_declspecs_no_prefix_attr:
892 typespec reserved_declspecs_no_prefix_attr
893 { $$
= tree_cons
(NULL_TREE
, $1, $2); }
894 | declmods_no_prefix_attr typespec reserved_declspecs_no_prefix_attr
895 { $$
= chainon
($3, tree_cons
(NULL_TREE
, $2, $1)); }
898 reserved_declspecs_no_prefix_attr:
901 | reserved_declspecs_no_prefix_attr typespecqual_reserved
902 { $$
= tree_cons
(NULL_TREE
, $2, $1); }
903 | reserved_declspecs_no_prefix_attr SCSPEC
904 { if
(extra_warnings
)
905 warning
("`%s' is not at beginning of declaration",
906 IDENTIFIER_POINTER
($2));
907 $$
= tree_cons
(NULL_TREE
, $2, $1); }
910 /* List of just storage classes, type modifiers, and prefix attributes.
911 A declaration can start with just this, but then it cannot be used
912 to redeclare a typedef-name.
913 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
916 declmods_no_prefix_attr
919 { $$
= tree_cons
($1, NULL_TREE
, NULL_TREE
); }
920 | declmods declmods_no_prefix_attr
921 { $$
= chainon
($2, $1); }
922 | declmods attributes
923 { $$
= tree_cons
($2, NULL_TREE
, $1); }
926 declmods_no_prefix_attr:
928 { $$
= tree_cons
(NULL_TREE
, $1, NULL_TREE
);
929 TREE_STATIC
($$
) = 1; }
931 { $$
= tree_cons
(NULL_TREE
, $1, NULL_TREE
); }
932 | declmods_no_prefix_attr TYPE_QUAL
933 { $$
= tree_cons
(NULL_TREE
, $2, $1);
934 TREE_STATIC
($$
) = 1; }
935 | declmods_no_prefix_attr SCSPEC
936 { if
(extra_warnings
&& TREE_STATIC
($1))
937 warning
("`%s' is not at beginning of declaration",
938 IDENTIFIER_POINTER
($2));
939 $$
= tree_cons
(NULL_TREE
, $2, $1);
940 TREE_STATIC
($$
) = TREE_STATIC
($1); }
944 /* Used instead of declspecs where storage classes are not allowed
945 (that is, for typenames and structure components).
946 Don't accept a typedef-name if anything but a modifier precedes it. */
949 typespec reserved_typespecquals
950 { $$
= tree_cons
(NULL_TREE
, $1, $2); }
951 | nonempty_type_quals typespec reserved_typespecquals
952 { $$
= chainon
($3, tree_cons
(NULL_TREE
, $2, $1)); }
955 reserved_typespecquals: /* empty */
957 | reserved_typespecquals typespecqual_reserved
958 { $$
= tree_cons
(NULL_TREE
, $2, $1); }
961 /* A typespec (but not a type qualifier).
962 Once we have seen one of these in a declaration,
963 if a typedef name appears then it is being redeclared. */
968 { /* For a typedef name, record the meaning, not the name.
969 In case of `foo foo, bar;'. */
970 $$
= lookup_name
($1); }
971 | TYPEOF
'(' expr
')'
972 { $$
= TREE_TYPE
($3); }
973 | TYPEOF
'(' typename
')'
974 { $$
= groktypename
($3); }
977 /* A typespec that is a reserved word, or a type qualifier. */
979 typespecqual_reserved: TYPESPEC
986 | initdecls
',' initdcl
991 | notype_initdecls
',' initdcl
997 | ASM_KEYWORD
'(' string ')'
998 { if
(TREE_CHAIN
($3)) $3 = combine_strings
($3);
1004 declarator maybeasm maybe_attribute
'='
1005 { $
<ttype
>$
= start_decl
($1, current_declspecs
, 1,
1006 $3, prefix_attributes
);
1007 start_init
($
<ttype
>$
, $2, global_bindings_p
()); }
1009 /* Note how the declaration of the variable is in effect while its init is parsed! */
1011 finish_decl
($
<ttype
>5, $6, $2); }
1012 | declarator maybeasm maybe_attribute
1013 { tree d
= start_decl
($1, current_declspecs
, 0,
1014 $3, prefix_attributes
);
1015 finish_decl
(d
, NULL_TREE
, $2);
1020 notype_declarator maybeasm maybe_attribute
'='
1021 { $
<ttype
>$
= start_decl
($1, current_declspecs
, 1,
1022 $3, prefix_attributes
);
1023 start_init
($
<ttype
>$
, $2, global_bindings_p
()); }
1025 /* Note how the declaration of the variable is in effect while its init is parsed! */
1027 decl_attributes
($
<ttype
>5, $3, prefix_attributes
);
1028 finish_decl
($
<ttype
>5, $6, $2); }
1029 | notype_declarator maybeasm maybe_attribute
1030 { tree d
= start_decl
($1, current_declspecs
, 0,
1031 $3, prefix_attributes
);
1032 finish_decl
(d
, NULL_TREE
, $2); }
1034 /* the * rules are dummies to accept the Apollo extended syntax
1035 so that the header files compile. */
1046 | attributes attribute
1047 { $$
= chainon
($1, $2); }
1051 ATTRIBUTE
'(' '(' attribute_list
')' ')'
1058 | attribute_list
',' attrib
1059 { $$
= chainon
($1, $3); }
1066 { $$
= build_tree_list
($1, NULL_TREE
); }
1067 | any_word
'(' IDENTIFIER
')'
1068 { $$
= build_tree_list
($1, build_tree_list
(NULL_TREE
, $3)); }
1069 | any_word
'(' IDENTIFIER
',' nonnull_exprlist
')'
1070 { $$
= build_tree_list
($1, tree_cons
(NULL_TREE
, $3, $5)); }
1071 | any_word
'(' exprlist
')'
1072 { $$
= build_tree_list
($1, $3); }
1075 /* This still leaves out most reserved keywords,
1076 shouldn't we include them? */
1085 /* Initializers. `init' is the entry point. */
1090 { really_start_incremental_init
(NULL_TREE
);
1091 /* Note that the call to clear_momentary
1092 is in process_init_element. */
1093 push_momentary
(); }
1094 initlist_maybe_comma
'}'
1095 { $$
= pop_init_level
(0);
1096 if
($$
== error_mark_node
1097 && ! (yychar == STRING ||
yychar == CONSTANT
))
1100 pop_momentary_nofree
(); }
1103 { $$
= error_mark_node
; }
1106 /* `initlist_maybe_comma' is the guts of an initializer in braces. */
1107 initlist_maybe_comma:
1110 pedwarn
("ANSI C forbids empty initializer braces"); }
1111 | initlist1 maybecomma
1116 | initlist1
',' initelt
1119 /* `initelt' is a single element of an initializer.
1120 It may use braces. */
1122 designator_list
'=' initval
1123 | designator initval
1125 { set_init_label
($1); }
1132 { push_init_level
(0); }
1133 initlist_maybe_comma
'}'
1134 { process_init_element
(pop_init_level
(0)); }
1136 { process_init_element
($1); }
1142 | designator_list designator
1147 { set_init_label
($2); }
1148 /* These are for labeled elements. The syntax for an array element
1149 initializer conflicts with the syntax for an Objective-C message,
1150 so don't include these productions in the Objective-C grammar. */
1151 |
'[' expr_no_commas ELLIPSIS expr_no_commas
']'
1152 { set_init_index
($2, $4); }
1153 |
'[' expr_no_commas
']'
1154 { set_init_index
($2, NULL_TREE
); }
1159 { push_c_function_context
();
1160 if
(! start_function
(current_declspecs
, $1,
1161 prefix_attributes
, NULL_TREE
, 1))
1163 pop_c_function_context
();
1166 reinit_parse_for_function
(); }
1167 old_style_parm_decls
1168 { store_parm_decls
(); }
1169 /* This used to use compstmt_or_error.
1170 That caused a bug with input `f(g) int g {}',
1171 where the use of YYERROR1 above caused an error
1172 which then was handled by compstmt_or_error.
1173 There followed a repeated execution of that same rule,
1174 which called YYERROR1 again, and so on. */
1176 { finish_function
(1);
1177 pop_c_function_context
(); }
1180 notype_nested_function:
1182 { push_c_function_context
();
1183 if
(! start_function
(current_declspecs
, $1,
1184 prefix_attributes
, NULL_TREE
, 1))
1186 pop_c_function_context
();
1189 reinit_parse_for_function
(); }
1190 old_style_parm_decls
1191 { store_parm_decls
(); }
1192 /* This used to use compstmt_or_error.
1193 That caused a bug with input `f(g) int g {}',
1194 where the use of YYERROR1 above caused an error
1195 which then was handled by compstmt_or_error.
1196 There followed a repeated execution of that same rule,
1197 which called YYERROR1 again, and so on. */
1199 { finish_function
(1);
1200 pop_c_function_context
(); }
1203 /* Any kind of declarator (thus, all declarators allowed
1204 after an explicit typespec). */
1207 after_type_declarator
1211 /* A declarator that is allowed only after an explicit typespec. */
1213 after_type_declarator:
1214 '(' after_type_declarator
')'
1216 | after_type_declarator
'(' parmlist_or_identifiers %prec
'.'
1217 { $$
= build_nt
(CALL_EXPR
, $1, $3, NULL_TREE
); }
1218 /* | after_type_declarator '(' error ')' %prec '.'
1219 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1220 poplevel (0, 0, 0); } */
1221 | after_type_declarator
'[' expr
']' %prec
'.'
1222 { $$
= build_nt
(ARRAY_REF
, $1, $3); }
1223 | after_type_declarator
'[' ']' %prec
'.'
1224 { $$
= build_nt
(ARRAY_REF
, $1, NULL_TREE
); }
1225 |
'*' type_quals after_type_declarator %prec UNARY
1226 { $$
= make_pointer_declarator
($2, $3); }
1227 /* ??? Yuck. setattrs is a quick hack. We can't use
1228 prefix_attributes because $1 only applies to this
1229 declarator. We assume setspecs has already been done.
1230 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1231 attributes could be recognized here or in `attributes'). */
1232 | attributes setattrs after_type_declarator
1237 /* Kinds of declarator that can appear in a parameter list
1238 in addition to notype_declarator. This is like after_type_declarator
1239 but does not allow a typedef name in parentheses as an identifier
1240 (because it would conflict with a function with that typedef as arg). */
1243 parm_declarator
'(' parmlist_or_identifiers %prec
'.'
1244 { $$
= build_nt
(CALL_EXPR
, $1, $3, NULL_TREE
); }
1245 /* | parm_declarator '(' error ')' %prec '.'
1246 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1247 poplevel (0, 0, 0); } */
1248 | parm_declarator
'[' '*' ']' %prec
'.'
1249 { $$
= build_nt
(ARRAY_REF
, $1, NULL_TREE
);
1251 error ("`[*]' in parameter declaration only allowed in ISO C 9x");
1253 | parm_declarator
'[' expr
']' %prec
'.'
1254 { $$
= build_nt
(ARRAY_REF
, $1, $3); }
1255 | parm_declarator
'[' ']' %prec
'.'
1256 { $$
= build_nt
(ARRAY_REF
, $1, NULL_TREE
); }
1257 |
'*' type_quals parm_declarator %prec UNARY
1258 { $$
= make_pointer_declarator
($2, $3); }
1259 /* ??? Yuck. setattrs is a quick hack. We can't use
1260 prefix_attributes because $1 only applies to this
1261 declarator. We assume setspecs has already been done.
1262 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1263 attributes could be recognized here or in `attributes'). */
1264 | attributes setattrs parm_declarator
1269 /* A declarator allowed whether or not there has been
1270 an explicit typespec. These cannot redeclare a typedef-name. */
1273 notype_declarator
'(' parmlist_or_identifiers %prec
'.'
1274 { $$
= build_nt
(CALL_EXPR
, $1, $3, NULL_TREE
); }
1275 /* | notype_declarator '(' error ')' %prec '.'
1276 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1277 poplevel (0, 0, 0); } */
1278 |
'(' notype_declarator
')'
1280 |
'*' type_quals notype_declarator %prec UNARY
1281 { $$
= make_pointer_declarator
($2, $3); }
1282 | notype_declarator
'[' '*' ']' %prec
'.'
1283 { $$
= build_nt
(ARRAY_REF
, $1, NULL_TREE
);
1285 error ("`[*]' in parameter declaration only allowed in ISO C 9x");
1287 | notype_declarator
'[' expr
']' %prec
'.'
1288 { $$
= build_nt
(ARRAY_REF
, $1, $3); }
1289 | notype_declarator
'[' ']' %prec
'.'
1290 { $$
= build_nt
(ARRAY_REF
, $1, NULL_TREE
); }
1291 /* ??? Yuck. setattrs is a quick hack. We can't use
1292 prefix_attributes because $1 only applies to this
1293 declarator. We assume setspecs has already been done.
1294 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1295 attributes could be recognized here or in `attributes'). */
1296 | attributes setattrs notype_declarator
1323 struct_head identifier
'{'
1324 { $$
= start_struct
(RECORD_TYPE
, $2);
1325 /* Start scope of tag before parsing components. */
1327 component_decl_list
'}' maybe_attribute
1328 { $$
= finish_struct
($
<ttype
>4, $5, chainon
($1, $7)); }
1329 | struct_head
'{' component_decl_list
'}' maybe_attribute
1330 { $$
= finish_struct
(start_struct
(RECORD_TYPE
, NULL_TREE
),
1331 $3, chainon
($1, $5));
1333 | struct_head identifier
1334 { $$
= xref_tag
(RECORD_TYPE
, $2); }
1335 | union_head identifier
'{'
1336 { $$
= start_struct
(UNION_TYPE
, $2); }
1337 component_decl_list
'}' maybe_attribute
1338 { $$
= finish_struct
($
<ttype
>4, $5, chainon
($1, $7)); }
1339 | union_head
'{' component_decl_list
'}' maybe_attribute
1340 { $$
= finish_struct
(start_struct
(UNION_TYPE
, NULL_TREE
),
1341 $3, chainon
($1, $5));
1343 | union_head identifier
1344 { $$
= xref_tag
(UNION_TYPE
, $2); }
1345 | enum_head identifier
'{'
1346 { $
<itype
>3 = suspend_momentary
();
1347 $$
= start_enum
($2); }
1348 enumlist maybecomma_warn
'}' maybe_attribute
1349 { $$
= finish_enum
($
<ttype
>4, nreverse
($5), chainon
($1, $8));
1350 resume_momentary
($
<itype
>3); }
1352 { $
<itype
>2 = suspend_momentary
();
1353 $$
= start_enum
(NULL_TREE
); }
1354 enumlist maybecomma_warn
'}' maybe_attribute
1355 { $$
= finish_enum
($
<ttype
>3, nreverse
($4), chainon
($1, $7));
1356 resume_momentary
($
<itype
>2); }
1357 | enum_head identifier
1358 { $$
= xref_tag
(ENUMERAL_TYPE
, $2); }
1369 { if
(pedantic
&& ! flag_isoc9x
)
1370 pedwarn
("comma at end of enumerator list"); }
1373 component_decl_list:
1374 component_decl_list2
1376 | component_decl_list2 component_decl
1377 { $$
= chainon
($1, $2);
1378 pedwarn
("no semicolon at end of struct or union"); }
1381 component_decl_list2: /* empty */
1383 | component_decl_list2 component_decl
';'
1384 { $$
= chainon
($1, $2); }
1385 | component_decl_list2
';'
1387 pedwarn
("extra semicolon in struct or union specified"); }
1390 /* There is a shift-reduce conflict here, because `components' may
1391 start with a `typename'. It happens that shifting (the default resolution)
1392 does the right thing, because it treats the `typename' as part of
1393 a `typed_typespecs'.
1395 It is possible that this same technique would allow the distinction
1396 between `notype_initdecls' and `initdecls' to be eliminated.
1397 But I am being cautious and not trying it. */
1400 typed_typespecs setspecs components
1402 current_declspecs
= TREE_VALUE
(declspec_stack
);
1403 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
1404 declspec_stack
= TREE_CHAIN
(declspec_stack
);
1405 resume_momentary
($2); }
1408 pedwarn
("ANSI C forbids member declarations with no members");
1411 | nonempty_type_quals setspecs components
1413 current_declspecs
= TREE_VALUE
(declspec_stack
);
1414 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
1415 declspec_stack
= TREE_CHAIN
(declspec_stack
);
1416 resume_momentary
($2); }
1417 | nonempty_type_quals
1419 pedwarn
("ANSI C forbids member declarations with no members");
1424 | extension component_decl
1426 pedantic
= $
<itype
>1; }
1430 component_declarator
1431 | components
',' component_declarator
1432 { $$
= chainon
($1, $3); }
1435 component_declarator:
1436 save_filename save_lineno declarator maybe_attribute
1437 { $$
= grokfield
($1, $2, $3, current_declspecs
, NULL_TREE
);
1438 decl_attributes
($$
, $4, prefix_attributes
); }
1439 | save_filename save_lineno
1440 declarator
':' expr_no_commas maybe_attribute
1441 { $$
= grokfield
($1, $2, $3, current_declspecs
, $5);
1442 decl_attributes
($$
, $6, prefix_attributes
); }
1443 | save_filename save_lineno
':' expr_no_commas maybe_attribute
1444 { $$
= grokfield
($1, $2, NULL_TREE
, current_declspecs
, $4);
1445 decl_attributes
($$
, $5, prefix_attributes
); }
1448 /* We chain the enumerators in reverse order.
1449 They are put in forward order where enumlist is used.
1450 (The order used to be significant, but no longer is so.
1451 However, we still maintain the order, just to be clean.) */
1455 | enumlist
',' enumerator
1456 { if
($1 == error_mark_node
)
1459 $$
= chainon
($3, $1); }
1461 { $$
= error_mark_node
; }
1467 { $$
= build_enumerator
($1, NULL_TREE
); }
1468 | identifier
'=' expr_no_commas
1469 { $$
= build_enumerator
($1, $3); }
1473 typed_typespecs absdcl
1474 { $$
= build_tree_list
($1, $2); }
1475 | nonempty_type_quals absdcl
1476 { $$
= build_tree_list
($1, $2); }
1479 absdcl: /* an absolute declarator */
1485 nonempty_type_quals:
1487 { $$
= tree_cons
(NULL_TREE
, $1, NULL_TREE
); }
1488 | nonempty_type_quals TYPE_QUAL
1489 { $$
= tree_cons
(NULL_TREE
, $2, $1); }
1495 | type_quals TYPE_QUAL
1496 { $$
= tree_cons
(NULL_TREE
, $2, $1); }
1499 absdcl1: /* a nonempty absolute declarator */
1502 /* `(typedef)1' is `int'. */
1503 |
'*' type_quals absdcl1 %prec UNARY
1504 { $$
= make_pointer_declarator
($2, $3); }
1505 |
'*' type_quals %prec UNARY
1506 { $$
= make_pointer_declarator
($2, NULL_TREE
); }
1507 | absdcl1
'(' parmlist %prec
'.'
1508 { $$
= build_nt
(CALL_EXPR
, $1, $3, NULL_TREE
); }
1509 | absdcl1
'[' expr
']' %prec
'.'
1510 { $$
= build_nt
(ARRAY_REF
, $1, $3); }
1511 | absdcl1
'[' ']' %prec
'.'
1512 { $$
= build_nt
(ARRAY_REF
, $1, NULL_TREE
); }
1513 |
'(' parmlist %prec
'.'
1514 { $$
= build_nt
(CALL_EXPR
, NULL_TREE
, $2, NULL_TREE
); }
1515 |
'[' expr
']' %prec
'.'
1516 { $$
= build_nt
(ARRAY_REF
, NULL_TREE
, $2); }
1518 { $$
= build_nt
(ARRAY_REF
, NULL_TREE
, NULL_TREE
); }
1519 /* ??? It appears we have to support attributes here, however
1520 using prefix_attributes is wrong. */
1521 | attributes setattrs absdcl1
1525 /* at least one statement, the first of which parses without error. */
1526 /* stmts is used only after decls, so an invalid first statement
1527 is actually regarded as an invalid decl and part of the decls. */
1530 lineno_stmt_or_labels
1533 pedwarn
("ANSI C forbids label at end of compound statement");
1537 lineno_stmt_or_labels:
1538 lineno_stmt_or_label
1539 | lineno_stmt_or_labels lineno_stmt_or_label
1541 | lineno_stmt_or_labels errstmt
1553 pushlevel: /* empty */
1554 { emit_line_note
(input_filename
, lineno
);
1558 expand_start_bindings
(0);
1562 /* Read zero or more forward-declarations for labels
1563 that nested functions can jump to. */
1568 pedwarn
("ANSI C forbids label declarations"); }
1573 | label_decls label_decl
1577 LABEL identifiers_or_typenames
';'
1579 for
(link
= $2; link
; link
= TREE_CHAIN
(link
))
1581 tree label
= shadow_label
(TREE_VALUE
(link
));
1582 C_DECLARED_LABEL_FLAG
(label
) = 1;
1583 declare_nonlocal_label
(label
);
1588 /* This is the body of a function definition.
1589 It causes syntax errors to ignore to the next openbrace. */
1596 compstmt_start: '{' { compstmt_count
++; }
1598 compstmt: compstmt_start
'}'
1599 { $$
= convert
(void_type_node
, integer_zero_node
); }
1600 | compstmt_start pushlevel maybe_label_decls decls xstmts
'}'
1601 { emit_line_note
(input_filename
, lineno
);
1602 expand_end_bindings
(getdecls
(), 1, 0);
1603 $$
= poplevel
(1, 1, 0);
1604 if
(yychar == CONSTANT ||
yychar == STRING
)
1605 pop_momentary_nofree
();
1608 | compstmt_start pushlevel maybe_label_decls
error '}'
1609 { emit_line_note
(input_filename
, lineno
);
1610 expand_end_bindings
(getdecls
(), kept_level_p
(), 0);
1611 $$
= poplevel
(kept_level_p
(), 0, 0);
1612 if
(yychar == CONSTANT ||
yychar == STRING
)
1613 pop_momentary_nofree
();
1616 | compstmt_start pushlevel maybe_label_decls stmts
'}'
1617 { emit_line_note
(input_filename
, lineno
);
1618 expand_end_bindings
(getdecls
(), kept_level_p
(), 0);
1619 $$
= poplevel
(kept_level_p
(), 0, 0);
1620 if
(yychar == CONSTANT ||
yychar == STRING
)
1621 pop_momentary_nofree
();
1626 /* Value is number of statements counted as of the closeparen. */
1628 if_prefix lineno_labeled_stmt
1629 /* Make sure c_expand_end_cond is run once
1630 for each call to c_expand_start_cond.
1631 Otherwise a crash is likely. */
1637 { emit_line_note
($
<filename
>-1, $
<lineno
>0);
1638 c_expand_start_cond
(truthvalue_conversion
($3), 0,
1640 $
<itype
>$
= stmt_count
;
1641 if_stmt_file
= $
<filename
>-1;
1642 if_stmt_line
= $
<lineno
>0;
1643 position_after_white_space
(); }
1646 /* This is a subroutine of stmt.
1647 It is used twice, once for valid DO statements
1648 and once for catching errors in parsing the end test. */
1653 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1654 /* See comment in `while' alternative, above. */
1656 expand_start_loop_continue_elsewhere
(1);
1657 position_after_white_space
(); }
1658 lineno_labeled_stmt WHILE
1659 { expand_loop_continue_here
(); }
1663 { $$
= input_filename
; }
1670 lineno_labeled_stmt:
1671 save_filename save_lineno stmt
1673 /* | save_filename save_lineno error
1676 | save_filename save_lineno label lineno_labeled_stmt
1680 lineno_stmt_or_label:
1681 save_filename save_lineno stmt_or_label
1692 /* Parse a single real statement, not including any labels. */
1699 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1700 /* It appears that this should not be done--that a non-lvalue array
1701 shouldn't get an error if the value isn't used.
1702 Section 3.2.2.1 says that an array lvalue gets converted to a pointer
1703 if it appears as a top-level expression,
1704 but says nothing about non-lvalue arrays. */
1706 /* Call default_conversion to get an error
1707 on referring to a register array if pedantic. */
1708 if
(TREE_CODE
(TREE_TYPE
($1)) == ARRAY_TYPE
1709 || TREE_CODE
(TREE_TYPE
($1)) == FUNCTION_TYPE
)
1710 $1 = default_conversion
($1);
1712 iterator_expand
($1);
1713 clear_momentary
(); }
1715 { c_expand_start_else
();
1716 $
<itype
>1 = stmt_count
;
1717 position_after_white_space
(); }
1719 { c_expand_end_cond
();
1720 if
(extra_warnings
&& stmt_count
== $
<itype
>1)
1721 warning
("empty body in an else-statement"); }
1722 | simple_if %prec IF
1723 { c_expand_end_cond
();
1724 /* This warning is here instead of in simple_if, because we
1725 do not want a warning if an empty if is followed by an
1726 else statement. Increment stmt_count so we don't
1727 give a second error if this is a nested `if'. */
1728 if
(extra_warnings
&& stmt_count
++ == $
<itype
>1)
1729 warning_with_file_and_line
(if_stmt_file
, if_stmt_line
,
1730 "empty body in an if-statement"); }
1731 /* Make sure c_expand_end_cond is run once
1732 for each call to c_expand_start_cond.
1733 Otherwise a crash is likely. */
1734 | simple_if ELSE
error
1735 { c_expand_end_cond
(); }
1738 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1739 /* The emit_nop used to come before emit_line_note,
1740 but that made the nop seem like part of the preceding line.
1741 And that was confusing when the preceding line was
1742 inside of an if statement and was not really executed.
1743 I think it ought to work to put the nop after the line number.
1744 We will see. --rms, July 15, 1991. */
1747 { /* Don't start the loop till we have succeeded
1748 in parsing the end test. This is to make sure
1749 that we end every loop we start. */
1750 expand_start_loop
(1);
1751 emit_line_note
(input_filename
, lineno
);
1752 expand_exit_loop_if_false
(NULL_PTR
,
1753 truthvalue_conversion
($4));
1754 position_after_white_space
(); }
1756 { expand_end_loop
(); }
1759 { emit_line_note
(input_filename
, lineno
);
1760 expand_exit_loop_if_false
(NULL_PTR
,
1761 truthvalue_conversion
($3));
1763 clear_momentary
(); }
1764 /* This rule is needed to make sure we end every loop we start. */
1765 | do_stmt_start
error
1766 { expand_end_loop
();
1767 clear_momentary
(); }
1771 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1772 /* See comment in `while' alternative, above. */
1774 if
($3) c_expand_expr_stmt
($3);
1775 /* Next step is to call expand_start_loop_continue_elsewhere,
1776 but wait till after we parse the entire for (...).
1777 Otherwise, invalid input might cause us to call that
1778 fn without calling expand_end_loop. */
1781 /* Can't emit now; wait till after expand_start_loop... */
1782 { $
<lineno
>7 = lineno
;
1783 $
<filename
>$
= input_filename
; }
1786 /* Start the loop. Doing this after parsing
1787 all the expressions ensures we will end the loop. */
1788 expand_start_loop_continue_elsewhere
(1);
1789 /* Emit the end-test, with a line number. */
1790 emit_line_note
($
<filename
>8, $
<lineno
>7);
1792 expand_exit_loop_if_false
(NULL_PTR
,
1793 truthvalue_conversion
($6));
1794 /* Don't let the tree nodes for $9 be discarded by
1795 clear_momentary during the parsing of the next stmt. */
1797 $
<lineno
>7 = lineno
;
1798 $
<filename
>8 = input_filename
;
1799 position_after_white_space
(); }
1801 { /* Emit the increment expression, with a line number. */
1802 emit_line_note
($
<filename
>8, $
<lineno
>7);
1803 expand_loop_continue_here
();
1805 c_expand_expr_stmt
($9);
1806 if
(yychar == CONSTANT ||
yychar == STRING
)
1807 pop_momentary_nofree
();
1810 expand_end_loop
(); }
1811 | SWITCH
'(' expr
')'
1813 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1814 c_expand_start_case
($3);
1815 /* Don't let the tree nodes for $3 be discarded by
1816 clear_momentary during the parsing of the next stmt. */
1818 position_after_white_space
(); }
1820 { expand_end_case
($3);
1821 if
(yychar == CONSTANT ||
yychar == STRING
)
1822 pop_momentary_nofree
();
1827 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1828 if
( ! expand_exit_something
())
1829 error ("break statement not within loop or switch"); }
1832 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1833 if
(! expand_continue_loop
(NULL_PTR
))
1834 error ("continue statement not within a loop"); }
1837 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1838 c_expand_return
(NULL_TREE
); }
1841 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1842 c_expand_return
($2); }
1843 | ASM_KEYWORD maybe_type_qual
'(' expr
')' ';'
1845 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1847 if
((TREE_CODE
($4) == ADDR_EXPR
1848 && TREE_CODE
(TREE_OPERAND
($4, 0)) == STRING_CST
)
1849 || TREE_CODE
($4) == STRING_CST
)
1852 error ("argument of `asm' is not a constant string"); }
1853 /* This is the case with just output operands. */
1854 | ASM_KEYWORD maybe_type_qual
'(' expr
':' asm_operands
')' ';'
1856 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1857 c_expand_asm_operands
($4, $6, NULL_TREE
, NULL_TREE
,
1858 $2 == ridpointers
[(int)RID_VOLATILE
],
1859 input_filename
, lineno
); }
1860 /* This is the case with input operands as well. */
1861 | ASM_KEYWORD maybe_type_qual
'(' expr
':' asm_operands
':' asm_operands
')' ';'
1863 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1864 c_expand_asm_operands
($4, $6, $8, NULL_TREE
,
1865 $2 == ridpointers
[(int)RID_VOLATILE
],
1866 input_filename
, lineno
); }
1867 /* This is the case with clobbered registers as well. */
1868 | ASM_KEYWORD maybe_type_qual
'(' expr
':' asm_operands
':'
1869 asm_operands
':' asm_clobbers
')' ';'
1871 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1872 c_expand_asm_operands
($4, $6, $8, $10,
1873 $2 == ridpointers
[(int)RID_VOLATILE
],
1874 input_filename
, lineno
); }
1875 | GOTO identifier
';'
1878 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1879 decl
= lookup_label
($2);
1882 TREE_USED
(decl
) = 1;
1888 pedwarn
("ANSI C forbids `goto *expr;'");
1890 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1891 expand_computed_goto
(convert
(ptr_type_node
, $3)); }
1896 all_iter_stmt_simple
1897 /* | all_iter_stmt_with_decl */
1900 all_iter_stmt_simple:
1903 /* The value returned by this action is */
1904 /* 1 if everything is OK */
1905 /* 0 in case of error or already bound iterator */
1908 if
(TREE_CODE
($3) != VAR_DECL
)
1909 error ("invalid `for (ITERATOR)' syntax");
1910 else if
(! ITERATOR_P
($3))
1911 error ("`%s' is not an iterator",
1912 IDENTIFIER_POINTER
(DECL_NAME
($3)));
1913 else if
(ITERATOR_BOUND_P
($3))
1914 error ("`for (%s)' inside expansion of same iterator",
1915 IDENTIFIER_POINTER
(DECL_NAME
($3)));
1919 iterator_for_loop_start
($3);
1925 iterator_for_loop_end
($3);
1928 /* This really should allow any kind of declaration,
1929 for generality. Fix it before turning it back on.
1931 all_iter_stmt_with_decl:
1932 FOR '(' ITERATOR pushlevel setspecs iterator_spec ')'
1934 */ /* The value returned by this action is */
1935 /* 1 if everything is OK */
1936 /* 0 in case of error or already bound iterator */
1938 iterator_for_loop_start ($6);
1942 iterator_for_loop_end ($6);
1943 emit_line_note (input_filename, lineno);
1944 expand_end_bindings (getdecls (), 1, 0);
1945 $<ttype>$ = poplevel (1, 1, 0);
1946 if (yychar == CONSTANT || yychar == STRING)
1947 pop_momentary_nofree ();
1953 /* Any kind of label, including jump labels and case labels.
1954 ANSI C accepts labels only before statements, but we allow them
1955 also at the end of a compound statement. */
1957 label: CASE expr_no_commas
':'
1958 { register tree value
= check_case_value
($2);
1960 = build_decl
(LABEL_DECL
, NULL_TREE
, NULL_TREE
);
1964 if
(value
!= error_mark_node
)
1969 if
(pedantic
&& ! INTEGRAL_TYPE_P
(TREE_TYPE
(value
)))
1970 pedwarn
("label must have integral type in ANSI C");
1972 success
= pushcase
(value
, convert_and_check
,
1976 error ("case label not within a switch statement");
1977 else if
(success
== 2)
1979 error ("duplicate case value");
1980 error_with_decl
(duplicate
, "this is the first entry for that value");
1982 else if
(success
== 3)
1983 warning
("case value out of range");
1984 else if
(success
== 5)
1985 error ("case label within scope of cleanup or variable array");
1987 position_after_white_space
(); }
1988 | CASE expr_no_commas ELLIPSIS expr_no_commas
':'
1989 { register tree value1
= check_case_value
($2);
1990 register tree value2
= check_case_value
($4);
1992 = build_decl
(LABEL_DECL
, NULL_TREE
, NULL_TREE
);
1995 pedwarn
("ANSI C forbids case ranges");
1998 if
(value1
!= error_mark_node
&& value2
!= error_mark_node
)
2001 int success
= pushcase_range
(value1
, value2
,
2002 convert_and_check
, label
,
2005 error ("case label not within a switch statement");
2006 else if
(success
== 2)
2008 error ("duplicate case value");
2009 error_with_decl
(duplicate
, "this is the first entry for that value");
2011 else if
(success
== 3)
2012 warning
("case value out of range");
2013 else if
(success
== 4)
2014 warning
("empty case range");
2015 else if
(success
== 5)
2016 error ("case label within scope of cleanup or variable array");
2018 position_after_white_space
(); }
2023 = build_decl
(LABEL_DECL
, NULL_TREE
, NULL_TREE
);
2024 int success
= pushcase
(NULL_TREE
, 0, label
, &duplicate
);
2027 error ("default label not within a switch statement");
2028 else if
(success
== 2)
2030 error ("multiple default labels in one switch");
2031 error_with_decl
(duplicate
, "this is the first default label");
2033 position_after_white_space
(); }
2034 | identifier
':' maybe_attribute
2035 { tree label
= define_label
(input_filename
, lineno
, $1);
2040 expand_label
(label
);
2041 decl_attributes
(label
, $3, NULL_TREE
);
2043 position_after_white_space
(); }
2046 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
2050 { emit_line_note
(input_filename
, lineno
);
2053 { emit_line_note
(input_filename
, lineno
); }
2062 /* These are the operands other than the first string and colon
2063 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
2064 asm_operands: /* empty */
2066 | nonnull_asm_operands
2069 nonnull_asm_operands:
2071 | nonnull_asm_operands
',' asm_operand
2072 { $$
= chainon
($1, $3); }
2077 { $$
= build_tree_list
($1, $3); }
2082 { $$
= tree_cons
(NULL_TREE
, combine_strings
($1), NULL_TREE
); }
2083 | asm_clobbers
',' string
2084 { $$
= tree_cons
(NULL_TREE
, combine_strings
($3), $1); }
2087 /* This is what appears inside the parens in a function declarator.
2088 Its value is a list of ..._TYPE nodes. */
2091 clear_parm_order
();
2092 declare_parm_level
(0); }
2095 parmlist_tags_warning
();
2096 poplevel
(0, 0, 0); }
2104 pedwarn
("ANSI C forbids forward parameter declarations");
2105 /* Mark the forward decls as such. */
2106 for
(parm
= getdecls
(); parm
; parm
= TREE_CHAIN
(parm
))
2107 TREE_ASM_WRITTEN
(parm
) = 1;
2108 clear_parm_order
(); }
2112 { $$
= tree_cons
(NULL_TREE
, NULL_TREE
, NULL_TREE
); }
2115 /* This is what appears inside the parens in a function declarator.
2116 Is value is represented in the format that grokdeclarator expects. */
2117 parmlist_2: /* empty */
2118 { $$
= get_parm_info
(0); }
2120 { $$
= get_parm_info
(0);
2121 /* Gcc used to allow this as an extension. However, it does
2122 not work for all targets, and thus has been disabled.
2123 Also, since func (...) and func () are indistinguishable,
2124 it caused problems with the code in expand_builtin which
2125 tries to verify that BUILT_IN_NEXT_ARG is being used
2127 error ("ANSI C requires a named argument before `...'");
2130 { $$
= get_parm_info
(1); }
2131 | parms
',' ELLIPSIS
2132 { $$
= get_parm_info
(0); }
2137 { push_parm_decl
($1); }
2139 { push_parm_decl
($3); }
2142 /* A single parameter declaration or parameter type name,
2143 as found in a parmlist. */
2145 typed_declspecs setspecs parm_declarator maybe_attribute
2146 { $$
= build_tree_list
(build_tree_list
(current_declspecs
,
2148 build_tree_list
(prefix_attributes
,
2150 current_declspecs
= TREE_VALUE
(declspec_stack
);
2151 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
2152 declspec_stack
= TREE_CHAIN
(declspec_stack
);
2153 resume_momentary
($2); }
2154 | typed_declspecs setspecs notype_declarator maybe_attribute
2155 { $$
= build_tree_list
(build_tree_list
(current_declspecs
,
2157 build_tree_list
(prefix_attributes
,
2159 current_declspecs
= TREE_VALUE
(declspec_stack
);
2160 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
2161 declspec_stack
= TREE_CHAIN
(declspec_stack
);
2162 resume_momentary
($2); }
2163 | typed_declspecs setspecs absdcl maybe_attribute
2164 { $$
= build_tree_list
(build_tree_list
(current_declspecs
,
2166 build_tree_list
(prefix_attributes
,
2168 current_declspecs
= TREE_VALUE
(declspec_stack
);
2169 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
2170 declspec_stack
= TREE_CHAIN
(declspec_stack
);
2171 resume_momentary
($2); }
2172 | declmods setspecs notype_declarator maybe_attribute
2173 { $$
= build_tree_list
(build_tree_list
(current_declspecs
,
2175 build_tree_list
(prefix_attributes
,
2177 current_declspecs
= TREE_VALUE
(declspec_stack
);
2178 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
2179 declspec_stack
= TREE_CHAIN
(declspec_stack
);
2180 resume_momentary
($2); }
2182 | declmods setspecs absdcl maybe_attribute
2183 { $$
= build_tree_list
(build_tree_list
(current_declspecs
,
2185 build_tree_list
(prefix_attributes
,
2187 current_declspecs
= TREE_VALUE
(declspec_stack
);
2188 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
2189 declspec_stack
= TREE_CHAIN
(declspec_stack
);
2190 resume_momentary
($2); }
2193 /* This is used in a function definition
2194 where either a parmlist or an identifier list is ok.
2195 Its value is a list of ..._TYPE nodes or a list of identifiers. */
2196 parmlist_or_identifiers:
2198 clear_parm_order
();
2199 declare_parm_level
(1); }
2200 parmlist_or_identifiers_1
2202 parmlist_tags_warning
();
2203 poplevel
(0, 0, 0); }
2206 parmlist_or_identifiers_1:
2210 for
(t
= $1; t
; t
= TREE_CHAIN
(t
))
2211 if
(TREE_VALUE
(t
) == NULL_TREE
)
2212 error ("`...' in old-style identifier list");
2213 $$
= tree_cons
(NULL_TREE
, NULL_TREE
, $1); }
2216 /* A nonempty list of identifiers. */
2219 { $$
= build_tree_list
(NULL_TREE
, $1); }
2220 | identifiers
',' IDENTIFIER
2221 { $$
= chainon
($1, build_tree_list
(NULL_TREE
, $3)); }
2224 /* A nonempty list of identifiers, including typenames. */
2225 identifiers_or_typenames:
2227 { $$
= build_tree_list
(NULL_TREE
, $1); }
2228 | identifiers_or_typenames
',' identifier
2229 { $$
= chainon
($1, build_tree_list
(NULL_TREE
, $3)); }
2234 { $
<itype
>$
= pedantic
;