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. */
47 #ifdef MULTIBYTE_CHARS
52 /* Since parsers are distinct for each language, put the language string
54 const char * const language_string = "GNU C";
56 /* Like YYERROR but do call yyerror. */
57 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
59 /* Cause the `yydebug' variable to be defined. */
65 %union {long itype; tree ttype; enum tree_code code;
66 char *filename; int lineno; int ends_in_label; }
68 /* All identifiers that are not reserved words
69 and are not declared typedefs in the current block */
72 /* All identifiers that are declared typedefs in the current block.
73 In some contexts, they are treated just like IDENTIFIER,
74 but they can also serve as typespecs in declarations. */
77 /* Reserved words that specify storage class.
78 yylval contains an IDENTIFIER_NODE which indicates which one. */
81 /* Reserved words that specify type.
82 yylval contains an IDENTIFIER_NODE which indicates which one. */
85 /* Reserved words that qualify type: "const", "volatile", or "restrict".
86 yylval contains an IDENTIFIER_NODE which indicates which one. */
89 /* Character or numeric constants.
90 yylval is the node for the constant. */
93 /* String constants in raw form.
94 yylval is a STRING_CST node. */
97 /* "...", used for functions with variable arglists. */
100 /* the reserved words */
101 /* SCO include files test "ASM", so use something else. */
102 %token SIZEOF ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
103 %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD TYPEOF ALIGNOF
104 %token ATTRIBUTE EXTENSION LABEL
105 %token REALPART IMAGPART VA_ARG
107 /* Used in c-lex.c for parsing pragmas. */
110 /* Add precedence rules to solve dangling else s/r conflict */
114 /* Define the operator tokens and their precedences.
115 The value is an integer because, if used, it is the tree code
116 to use in the expression made from the operator. */
118 %right <code> ASSIGN '='
119 %right <code> '?' ':'
125 %left <code> EQCOMPARE
126 %left <code> ARITHCOMPARE
127 %left <code> LSHIFT RSHIFT
129 %left <code> '*' '/' '%'
130 %right <code> UNARY PLUSPLUS MINUSMINUS
132 %left <code> POINTSAT '.' '(' '['
134 /* The Objective-C keywords. These are included in C and in
135 Objective C, so that the token codes are the same in both. */
136 %token INTERFACE IMPLEMENTATION END SELECTOR DEFS ENCODE
137 %token CLASSNAME PUBLIC PRIVATE PROTECTED PROTOCOL OBJECTNAME CLASS ALIAS
139 /* Objective-C string constants in raw form.
140 yylval is an OBJC_STRING_CST node. */
146 %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist exprlist
147 %type <ttype> expr_no_commas cast_expr unary_expr primary string STRING
148 %type <ttype> typed_declspecs reserved_declspecs
149 %type <ttype> typed_typespecs reserved_typespecquals
150 %type <ttype> declmods typespec typespecqual_reserved
151 %type <ttype> typed_declspecs_no_prefix_attr reserved_declspecs_no_prefix_attr
152 %type <ttype> declmods_no_prefix_attr
153 %type <ttype> SCSPEC TYPESPEC TYPE_QUAL nonempty_type_quals maybe_type_qual
154 %type <ttype> initdecls notype_initdecls initdcl notype_initdcl
155 %type <ttype> init maybeasm
156 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
157 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
158 %type <ttype> any_word
160 %type <ttype> compstmt compstmt_nostart compstmt_primary_start
162 %type <ttype> declarator
163 %type <ttype> notype_declarator after_type_declarator
164 %type <ttype> parm_declarator
166 %type <ttype> structsp component_decl_list component_decl_list2
167 %type <ttype> component_decl components component_declarator
168 %type <ttype> enumlist enumerator
169 %type <ttype> struct_head union_head enum_head
170 %type <ttype> typename absdcl absdcl1 type_quals
171 %type <ttype> xexpr parms parm identifiers
173 %type <ttype> parmlist parmlist_1 parmlist_2
174 %type <ttype> parmlist_or_identifiers parmlist_or_identifiers_1
175 %type <ttype> identifiers_or_typenames
177 %type <itype> setspecs
179 %type <ends_in_label> lineno_stmt_or_label lineno_stmt_or_labels stmt_or_label
181 %type <filename> save_filename
182 %type <lineno> save_lineno
186 /* Number of statements (loosely speaking) and compound statements
188 static int stmt_count;
189 static int compstmt_count;
191 /* Input file and line number of the end of the body of last simple_if;
192 used by the stmt-rule immediately after simple_if returns. */
193 static char *if_stmt_file;
194 static int if_stmt_line;
196 /* List of types and structure classes of the current declaration. */
197 static tree current_declspecs = NULL_TREE;
198 static tree prefix_attributes = NULL_TREE;
200 /* Stack of saved values of current_declspecs and prefix_attributes. */
201 static tree declspec_stack;
203 /* 1 if we explained undeclared var errors. */
204 static int undeclared_variable_notice;
207 /* Tell yyparse how to print a token's value, if yydebug is set. */
209 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
210 extern void yyprint PROTO ((FILE *, int, YYSTYPE));
212 /* Add GC roots for variables local to this file. */
216 ggc_add_tree_root (&declspec_stack, 1);
217 ggc_add_tree_root (¤t_declspecs, 1);
218 ggc_add_tree_root (&prefix_attributes, 1);
226 pedwarn ("ANSI C forbids an empty source file");
231 /* In case there were missing closebraces,
232 get us back to the global binding level. */
233 while (! global_bindings_p ())
239 /* the reason for the strange actions in this rule
240 is so that notype_initdecls when reached via datadef
241 can find a valid list of type and sc specs in $0. */
244 {$<ttype>$ = NULL_TREE; } extdef
245 | extdefs {$<ttype>$ = NULL_TREE; } extdef
251 | ASM_KEYWORD '(' expr ')' ';'
253 if ((TREE_CODE ($3) == ADDR_EXPR
254 && TREE_CODE (TREE_OPERAND ($3, 0)) == STRING_CST)
255 || TREE_CODE ($3) == STRING_CST)
258 error ("argument of `asm' is not a constant string"); }
260 { pedantic = $<itype>1; }
264 setspecs notype_initdecls ';'
266 error ("ANSI C forbids data definition with no type or storage class");
267 else if (!flag_traditional)
268 warning ("data definition has no type or storage class");
270 current_declspecs = TREE_VALUE (declspec_stack);
271 prefix_attributes = TREE_PURPOSE (declspec_stack);
272 declspec_stack = TREE_CHAIN (declspec_stack);
273 resume_momentary ($1); }
274 | declmods setspecs notype_initdecls ';'
275 { current_declspecs = TREE_VALUE (declspec_stack);
276 prefix_attributes = TREE_PURPOSE (declspec_stack);
277 declspec_stack = TREE_CHAIN (declspec_stack);
278 resume_momentary ($2); }
279 | typed_declspecs setspecs initdecls ';'
280 { current_declspecs = TREE_VALUE (declspec_stack);
281 prefix_attributes = TREE_PURPOSE (declspec_stack);
282 declspec_stack = TREE_CHAIN (declspec_stack);
283 resume_momentary ($2); }
285 { pedwarn ("empty declaration"); }
286 | typed_declspecs ';'
292 pedwarn ("ANSI C does not allow extra `;' outside of a function"); }
296 typed_declspecs setspecs declarator
297 { if (! start_function (current_declspecs, $3,
298 prefix_attributes, NULL_TREE, 0))
300 reinit_parse_for_function (); }
302 { store_parm_decls (); }
304 { finish_function (0);
305 current_declspecs = TREE_VALUE (declspec_stack);
306 prefix_attributes = TREE_PURPOSE (declspec_stack);
307 declspec_stack = TREE_CHAIN (declspec_stack);
308 resume_momentary ($2); }
309 | typed_declspecs setspecs declarator error
310 { current_declspecs = TREE_VALUE (declspec_stack);
311 prefix_attributes = TREE_PURPOSE (declspec_stack);
312 declspec_stack = TREE_CHAIN (declspec_stack);
313 resume_momentary ($2); }
314 | declmods setspecs notype_declarator
315 { if (! start_function (current_declspecs, $3,
316 prefix_attributes, NULL_TREE, 0))
318 reinit_parse_for_function (); }
320 { store_parm_decls (); }
322 { finish_function (0);
323 current_declspecs = TREE_VALUE (declspec_stack);
324 prefix_attributes = TREE_PURPOSE (declspec_stack);
325 declspec_stack = TREE_CHAIN (declspec_stack);
326 resume_momentary ($2); }
327 | declmods setspecs notype_declarator error
328 { current_declspecs = TREE_VALUE (declspec_stack);
329 prefix_attributes = TREE_PURPOSE (declspec_stack);
330 declspec_stack = TREE_CHAIN (declspec_stack);
331 resume_momentary ($2); }
332 | setspecs notype_declarator
333 { if (! start_function (NULL_TREE, $2,
334 prefix_attributes, NULL_TREE, 0))
336 reinit_parse_for_function (); }
338 { store_parm_decls (); }
340 { finish_function (0);
341 current_declspecs = TREE_VALUE (declspec_stack);
342 prefix_attributes = TREE_PURPOSE (declspec_stack);
343 declspec_stack = TREE_CHAIN (declspec_stack);
344 resume_momentary ($1); }
345 | setspecs notype_declarator error
346 { current_declspecs = TREE_VALUE (declspec_stack);
347 prefix_attributes = TREE_PURPOSE (declspec_stack);
348 declspec_stack = TREE_CHAIN (declspec_stack);
349 resume_momentary ($1); }
360 { $$ = NEGATE_EXPR; }
362 { $$ = CONVERT_EXPR; }
364 { $$ = PREINCREMENT_EXPR; }
366 { $$ = PREDECREMENT_EXPR; }
368 { $$ = BIT_NOT_EXPR; }
370 { $$ = TRUTH_NOT_EXPR; }
373 expr: nonnull_exprlist
374 { $$ = build_compound_expr ($1); }
385 { $$ = build_tree_list (NULL_TREE, $1); }
386 | nonnull_exprlist ',' expr_no_commas
387 { chainon ($1, build_tree_list (NULL_TREE, $3)); }
392 | '*' cast_expr %prec UNARY
393 { $$ = build_indirect_ref ($2, "unary *"); }
394 /* __extension__ turns off -pedantic for following primary. */
395 | extension cast_expr %prec UNARY
397 pedantic = $<itype>1; }
398 | unop cast_expr %prec UNARY
399 { $$ = build_unary_op ($1, $2, 0);
400 overflow_warning ($$); }
401 /* Refer to the address of a label as a pointer. */
403 { tree label = lookup_label ($2);
405 pedwarn ("ANSI C forbids `&&'");
407 $$ = null_pointer_node;
410 TREE_USED (label) = 1;
411 $$ = build1 (ADDR_EXPR, ptr_type_node, label);
412 TREE_CONSTANT ($$) = 1;
415 /* This seems to be impossible on some machines, so let's turn it off.
416 You can use __builtin_next_arg to find the anonymous stack args.
418 { tree types = TYPE_ARG_TYPES (TREE_TYPE (current_function_decl));
419 $$ = error_mark_node;
420 if (TREE_VALUE (tree_last (types)) == void_type_node)
421 error ("`&...' used in function with fixed number of arguments");
425 pedwarn ("ANSI C forbids `&...'");
426 $$ = tree_last (DECL_ARGUMENTS (current_function_decl));
427 $$ = build_unary_op (ADDR_EXPR, $$, 0);
430 | sizeof unary_expr %prec UNARY
432 if (TREE_CODE ($2) == COMPONENT_REF
433 && DECL_C_BIT_FIELD (TREE_OPERAND ($2, 1)))
434 error ("`sizeof' applied to a bit-field");
435 $$ = c_sizeof (TREE_TYPE ($2)); }
436 | sizeof '(' typename ')' %prec HYPERUNARY
438 $$ = c_sizeof (groktypename ($3)); }
439 | alignof unary_expr %prec UNARY
441 $$ = c_alignof_expr ($2); }
442 | alignof '(' typename ')' %prec HYPERUNARY
444 $$ = c_alignof (groktypename ($3)); }
445 | REALPART cast_expr %prec UNARY
446 { $$ = build_unary_op (REALPART_EXPR, $2, 0); }
447 | IMAGPART cast_expr %prec UNARY
448 { $$ = build_unary_op (IMAGPART_EXPR, $2, 0); }
449 | VA_ARG '(' expr_no_commas ',' typename ')'
450 { $$ = build_va_arg ($3, groktypename ($5)); }
454 SIZEOF { skip_evaluation++; }
458 ALIGNOF { skip_evaluation++; }
463 | '(' typename ')' cast_expr %prec UNARY
464 { tree type = groktypename ($2);
465 $$ = build_c_cast (type, $4); }
466 | '(' typename ')' '{'
467 { start_init (NULL_TREE, NULL, 0);
468 $2 = groktypename ($2);
469 really_start_incremental_init ($2); }
470 initlist_maybe_comma '}' %prec UNARY
472 tree result = pop_init_level (0);
476 if (pedantic && ! flag_isoc9x)
477 pedwarn ("ANSI C forbids constructor expressions");
478 if (TYPE_NAME (type) != 0)
480 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
481 name = IDENTIFIER_POINTER (TYPE_NAME (type));
483 name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
488 if (TREE_CODE (type) == ARRAY_TYPE && TYPE_SIZE (type) == 0)
490 int failure = complete_array_type (type, $$, 1);
499 | expr_no_commas '+' expr_no_commas
500 { $$ = parser_build_binary_op ($2, $1, $3); }
501 | expr_no_commas '-' expr_no_commas
502 { $$ = parser_build_binary_op ($2, $1, $3); }
503 | expr_no_commas '*' expr_no_commas
504 { $$ = parser_build_binary_op ($2, $1, $3); }
505 | expr_no_commas '/' expr_no_commas
506 { $$ = parser_build_binary_op ($2, $1, $3); }
507 | expr_no_commas '%' expr_no_commas
508 { $$ = parser_build_binary_op ($2, $1, $3); }
509 | expr_no_commas LSHIFT expr_no_commas
510 { $$ = parser_build_binary_op ($2, $1, $3); }
511 | expr_no_commas RSHIFT expr_no_commas
512 { $$ = parser_build_binary_op ($2, $1, $3); }
513 | expr_no_commas ARITHCOMPARE expr_no_commas
514 { $$ = parser_build_binary_op ($2, $1, $3); }
515 | expr_no_commas EQCOMPARE 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 '|' expr_no_commas
520 { $$ = parser_build_binary_op ($2, $1, $3); }
521 | expr_no_commas '^' expr_no_commas
522 { $$ = parser_build_binary_op ($2, $1, $3); }
523 | expr_no_commas ANDAND
524 { $1 = truthvalue_conversion (default_conversion ($1));
525 skip_evaluation += $1 == boolean_false_node; }
527 { skip_evaluation -= $1 == boolean_false_node;
528 $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $4); }
529 | expr_no_commas OROR
530 { $1 = truthvalue_conversion (default_conversion ($1));
531 skip_evaluation += $1 == boolean_true_node; }
533 { skip_evaluation -= $1 == boolean_true_node;
534 $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $4); }
536 { $1 = truthvalue_conversion (default_conversion ($1));
537 skip_evaluation += $1 == boolean_false_node; }
539 { skip_evaluation += (($1 == boolean_true_node)
540 - ($1 == boolean_false_node)); }
542 { skip_evaluation -= $1 == boolean_true_node;
543 $$ = build_conditional_expr ($1, $4, $7); }
546 pedwarn ("ANSI C forbids omitting the middle term of a ?: expression");
547 /* Make sure first operand is calculated only once. */
548 $<ttype>2 = save_expr ($1);
549 $1 = truthvalue_conversion (default_conversion ($<ttype>2));
550 skip_evaluation += $1 == boolean_true_node; }
552 { skip_evaluation -= $1 == boolean_true_node;
553 $$ = build_conditional_expr ($1, $<ttype>2, $5); }
554 | expr_no_commas '=' expr_no_commas
556 $$ = build_modify_expr ($1, NOP_EXPR, $3);
557 class = TREE_CODE_CLASS (TREE_CODE ($$));
558 if (class == 'e' || class == '1'
559 || class == '2' || class == '<')
560 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR);
562 | expr_no_commas ASSIGN expr_no_commas
564 $$ = build_modify_expr ($1, $2, $3);
565 /* This inhibits warnings in truthvalue_conversion. */
566 class = TREE_CODE_CLASS (TREE_CODE ($$));
567 if (class == 'e' || class == '1'
568 || class == '2' || class == '<')
569 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 in 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; }
683 | compstmt_primary_start compstmt_nostart ')'
686 pedwarn ("ANSI C forbids braced-groups within expressions");
687 pop_iterator_stack ();
689 rtl_exp = expand_end_stmt_expr ($1);
690 /* The statements have side effects, so the group does. */
691 TREE_SIDE_EFFECTS (rtl_exp) = 1;
693 if (TREE_CODE ($2) == BLOCK)
695 /* Make a BIND_EXPR for the BLOCK already made. */
696 $$ = build (BIND_EXPR, TREE_TYPE (rtl_exp),
697 NULL_TREE, rtl_exp, $2);
698 /* Remove the block from the tree at this point.
699 It gets put back at the proper place
700 when the BIND_EXPR is expanded. */
706 | compstmt_primary_start error ')'
708 /* Make sure we call expand_end_stmt_expr. Otherwise
709 we are likely to lose sequences and crash later. */
710 pop_iterator_stack ();
712 expand_end_stmt_expr ($1);
713 $$ = error_mark_node;
715 | primary '(' exprlist ')' %prec '.'
716 { $$ = build_function_call ($1, $3); }
717 | primary '[' expr ']' %prec '.'
718 { $$ = build_array_ref ($1, $3); }
719 | primary '.' identifier
721 $$ = build_component_ref ($1, $3);
723 | primary POINTSAT identifier
725 tree expr = build_indirect_ref ($1, "->");
727 $$ = build_component_ref (expr, $3);
730 { $$ = build_unary_op (POSTINCREMENT_EXPR, $1, 0); }
732 { $$ = build_unary_op (POSTDECREMENT_EXPR, $1, 0); }
735 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
739 { $$ = chainon ($1, $2); }
743 old_style_parm_decls:
747 /* ... is used here to indicate a varargs function. */
750 pedwarn ("ANSI C does not permit use of `varargs.h'"); }
753 /* The following are analogous to lineno_decl, decls and decl
754 except that they do not allow nested functions.
755 They are used for old-style parm decls. */
757 save_filename save_lineno datadecl
764 | datadecls lineno_datadecl
765 | lineno_datadecl errstmt
768 /* We don't allow prefix attributes here because they cause reduce/reduce
769 conflicts: we can't know whether we're parsing a function decl with
770 attribute suffix, or function defn with attribute prefix on first old
773 typed_declspecs_no_prefix_attr setspecs initdecls ';'
774 { current_declspecs = TREE_VALUE (declspec_stack);
775 prefix_attributes = TREE_PURPOSE (declspec_stack);
776 declspec_stack = TREE_CHAIN (declspec_stack);
777 resume_momentary ($2); }
778 | declmods_no_prefix_attr setspecs notype_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 | typed_declspecs_no_prefix_attr ';'
784 { shadow_tag_warned ($1, 1);
785 pedwarn ("empty declaration"); }
786 | declmods_no_prefix_attr ';'
787 { pedwarn ("empty declaration"); }
790 /* This combination which saves a lineno before a decl
791 is the normal thing to use, rather than decl itself.
792 This is to avoid shift/reduce conflicts in contexts
793 where statement labels are allowed. */
795 save_filename save_lineno decl
803 | lineno_decl errstmt
806 /* records the type and storage class specs to use for processing
807 the declarators that follow.
808 Maintains a stack of outer-level values of current_declspecs,
809 for the sake of parm declarations nested in function declarators. */
810 setspecs: /* empty */
811 { $$ = suspend_momentary ();
812 pending_xref_error ();
813 declspec_stack = tree_cons (prefix_attributes,
816 split_specs_attrs ($<ttype>0,
817 ¤t_declspecs, &prefix_attributes); }
820 /* ??? Yuck. See after_type_declarator. */
821 setattrs: /* empty */
822 { prefix_attributes = chainon (prefix_attributes, $<ttype>0); }
826 typed_declspecs setspecs initdecls ';'
827 { current_declspecs = TREE_VALUE (declspec_stack);
828 prefix_attributes = TREE_PURPOSE (declspec_stack);
829 declspec_stack = TREE_CHAIN (declspec_stack);
830 resume_momentary ($2); }
831 | declmods setspecs notype_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 | typed_declspecs setspecs nested_function
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 | declmods setspecs notype_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 | typed_declspecs ';'
849 { pedwarn ("empty declaration"); }
851 { pedantic = $<itype>1; }
854 /* Declspecs which contain at least one type specifier or typedef name.
855 (Just `const' or `volatile' is not enough.)
856 A typedef'd name following these is taken as a name to be declared.
857 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
860 typespec reserved_declspecs
861 { $$ = tree_cons (NULL_TREE, $1, $2); }
862 | declmods typespec reserved_declspecs
863 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
866 reserved_declspecs: /* empty */
868 | reserved_declspecs typespecqual_reserved
869 { $$ = tree_cons (NULL_TREE, $2, $1); }
870 | reserved_declspecs SCSPEC
871 { if (extra_warnings)
872 warning ("`%s' is not at beginning of declaration",
873 IDENTIFIER_POINTER ($2));
874 $$ = tree_cons (NULL_TREE, $2, $1); }
875 | reserved_declspecs attributes
876 { $$ = tree_cons ($2, NULL_TREE, $1); }
879 typed_declspecs_no_prefix_attr:
880 typespec reserved_declspecs_no_prefix_attr
881 { $$ = tree_cons (NULL_TREE, $1, $2); }
882 | declmods_no_prefix_attr typespec reserved_declspecs_no_prefix_attr
883 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
886 reserved_declspecs_no_prefix_attr:
889 | reserved_declspecs_no_prefix_attr typespecqual_reserved
890 { $$ = tree_cons (NULL_TREE, $2, $1); }
891 | reserved_declspecs_no_prefix_attr SCSPEC
892 { if (extra_warnings)
893 warning ("`%s' is not at beginning of declaration",
894 IDENTIFIER_POINTER ($2));
895 $$ = tree_cons (NULL_TREE, $2, $1); }
898 /* List of just storage classes, type modifiers, and prefix attributes.
899 A declaration can start with just this, but then it cannot be used
900 to redeclare a typedef-name.
901 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
904 declmods_no_prefix_attr
907 { $$ = tree_cons ($1, NULL_TREE, NULL_TREE); }
908 | declmods declmods_no_prefix_attr
909 { $$ = chainon ($2, $1); }
910 | declmods attributes
911 { $$ = tree_cons ($2, NULL_TREE, $1); }
914 declmods_no_prefix_attr:
916 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
917 TREE_STATIC ($$) = 1; }
919 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
920 | declmods_no_prefix_attr TYPE_QUAL
921 { $$ = tree_cons (NULL_TREE, $2, $1);
922 TREE_STATIC ($$) = 1; }
923 | declmods_no_prefix_attr SCSPEC
924 { if (extra_warnings && TREE_STATIC ($1))
925 warning ("`%s' is not at beginning of declaration",
926 IDENTIFIER_POINTER ($2));
927 $$ = tree_cons (NULL_TREE, $2, $1);
928 TREE_STATIC ($$) = TREE_STATIC ($1); }
932 /* Used instead of declspecs where storage classes are not allowed
933 (that is, for typenames and structure components).
934 Don't accept a typedef-name if anything but a modifier precedes it. */
937 typespec reserved_typespecquals
938 { $$ = tree_cons (NULL_TREE, $1, $2); }
939 | nonempty_type_quals typespec reserved_typespecquals
940 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
943 reserved_typespecquals: /* empty */
945 | reserved_typespecquals typespecqual_reserved
946 { $$ = tree_cons (NULL_TREE, $2, $1); }
949 /* A typespec (but not a type qualifier).
950 Once we have seen one of these in a declaration,
951 if a typedef name appears then it is being redeclared. */
956 { /* For a typedef name, record the meaning, not the name.
957 In case of `foo foo, bar;'. */
958 $$ = lookup_name ($1); }
959 | TYPEOF '(' expr ')'
960 { $$ = TREE_TYPE ($3); }
961 | TYPEOF '(' typename ')'
962 { $$ = groktypename ($3); }
965 /* A typespec that is a reserved word, or a type qualifier. */
967 typespecqual_reserved: TYPESPEC
974 | initdecls ',' initdcl
979 | notype_initdecls ',' initdcl
985 | ASM_KEYWORD '(' string ')'
986 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
992 declarator maybeasm maybe_attribute '='
993 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
994 $3, prefix_attributes);
995 start_init ($<ttype>$, $2, global_bindings_p ()); }
997 /* Note how the declaration of the variable is in effect while its init is parsed! */
999 finish_decl ($<ttype>5, $6, $2); }
1000 | declarator maybeasm maybe_attribute
1001 { tree d = start_decl ($1, current_declspecs, 0,
1002 $3, prefix_attributes);
1003 finish_decl (d, NULL_TREE, $2);
1008 notype_declarator maybeasm maybe_attribute '='
1009 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1010 $3, prefix_attributes);
1011 start_init ($<ttype>$, $2, global_bindings_p ()); }
1013 /* Note how the declaration of the variable is in effect while its init is parsed! */
1015 decl_attributes ($<ttype>5, $3, prefix_attributes);
1016 finish_decl ($<ttype>5, $6, $2); }
1017 | notype_declarator maybeasm maybe_attribute
1018 { tree d = start_decl ($1, current_declspecs, 0,
1019 $3, prefix_attributes);
1020 finish_decl (d, NULL_TREE, $2); }
1022 /* the * rules are dummies to accept the Apollo extended syntax
1023 so that the header files compile. */
1034 | attributes attribute
1035 { $$ = chainon ($1, $2); }
1039 ATTRIBUTE '(' '(' attribute_list ')' ')'
1046 | attribute_list ',' attrib
1047 { $$ = chainon ($1, $3); }
1054 { $$ = build_tree_list ($1, NULL_TREE); }
1055 | any_word '(' IDENTIFIER ')'
1056 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1057 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1058 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1059 | any_word '(' exprlist ')'
1060 { $$ = build_tree_list ($1, $3); }
1063 /* This still leaves out most reserved keywords,
1064 shouldn't we include them? */
1073 /* Initializers. `init' is the entry point. */
1078 { really_start_incremental_init (NULL_TREE);
1079 /* Note that the call to clear_momentary
1080 is in process_init_element. */
1081 push_momentary (); }
1082 initlist_maybe_comma '}'
1083 { $$ = pop_init_level (0);
1084 if ($$ == error_mark_node
1085 && ! (yychar == STRING || yychar == CONSTANT))
1088 pop_momentary_nofree (); }
1091 { $$ = error_mark_node; }
1094 /* `initlist_maybe_comma' is the guts of an initializer in braces. */
1095 initlist_maybe_comma:
1098 pedwarn ("ANSI C forbids empty initializer braces"); }
1099 | initlist1 maybecomma
1104 | initlist1 ',' initelt
1107 /* `initelt' is a single element of an initializer.
1108 It may use braces. */
1110 designator_list '=' initval
1111 | designator initval
1113 { set_init_label ($1); }
1120 { push_init_level (0); }
1121 initlist_maybe_comma '}'
1122 { process_init_element (pop_init_level (0)); }
1124 { process_init_element ($1); }
1130 | designator_list designator
1135 { set_init_label ($2); }
1136 /* These are for labeled elements. The syntax for an array element
1137 initializer conflicts with the syntax for an Objective-C message,
1138 so don't include these productions in the Objective-C grammar. */
1139 | '[' expr_no_commas ELLIPSIS expr_no_commas ']'
1140 { set_init_index ($2, $4); }
1141 | '[' expr_no_commas ']'
1142 { set_init_index ($2, NULL_TREE); }
1148 pedwarn ("ANSI C forbids nested functions");
1150 push_function_context ();
1151 if (! start_function (current_declspecs, $1,
1152 prefix_attributes, NULL_TREE, 1))
1154 pop_function_context ();
1157 reinit_parse_for_function (); }
1158 old_style_parm_decls
1159 { store_parm_decls (); }
1160 /* This used to use compstmt_or_error.
1161 That caused a bug with input `f(g) int g {}',
1162 where the use of YYERROR1 above caused an error
1163 which then was handled by compstmt_or_error.
1164 There followed a repeated execution of that same rule,
1165 which called YYERROR1 again, and so on. */
1167 { finish_function (1);
1168 pop_function_context (); }
1171 notype_nested_function:
1174 pedwarn ("ANSI C forbids nested functions");
1176 push_function_context ();
1177 if (! start_function (current_declspecs, $1,
1178 prefix_attributes, NULL_TREE, 1))
1180 pop_function_context ();
1183 reinit_parse_for_function (); }
1184 old_style_parm_decls
1185 { store_parm_decls (); }
1186 /* This used to use compstmt_or_error.
1187 That caused a bug with input `f(g) int g {}',
1188 where the use of YYERROR1 above caused an error
1189 which then was handled by compstmt_or_error.
1190 There followed a repeated execution of that same rule,
1191 which called YYERROR1 again, and so on. */
1193 { finish_function (1);
1194 pop_function_context (); }
1197 /* Any kind of declarator (thus, all declarators allowed
1198 after an explicit typespec). */
1201 after_type_declarator
1205 /* A declarator that is allowed only after an explicit typespec. */
1207 after_type_declarator:
1208 '(' after_type_declarator ')'
1210 | after_type_declarator '(' parmlist_or_identifiers %prec '.'
1211 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1212 /* | after_type_declarator '(' error ')' %prec '.'
1213 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1214 poplevel (0, 0, 0); } */
1215 | after_type_declarator '[' expr ']' %prec '.'
1216 { $$ = build_nt (ARRAY_REF, $1, $3); }
1217 | after_type_declarator '[' ']' %prec '.'
1218 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1219 | '*' type_quals after_type_declarator %prec UNARY
1220 { $$ = make_pointer_declarator ($2, $3); }
1221 /* ??? Yuck. setattrs is a quick hack. We can't use
1222 prefix_attributes because $1 only applies to this
1223 declarator. We assume setspecs has already been done.
1224 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1225 attributes could be recognized here or in `attributes'). */
1226 | attributes setattrs after_type_declarator
1231 /* Kinds of declarator that can appear in a parameter list
1232 in addition to notype_declarator. This is like after_type_declarator
1233 but does not allow a typedef name in parentheses as an identifier
1234 (because it would conflict with a function with that typedef as arg). */
1237 parm_declarator '(' parmlist_or_identifiers %prec '.'
1238 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1239 /* | parm_declarator '(' error ')' %prec '.'
1240 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1241 poplevel (0, 0, 0); } */
1242 | parm_declarator '[' '*' ']' %prec '.'
1243 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE);
1245 error ("`[*]' in parameter declaration only allowed in ISO C 9x");
1247 | parm_declarator '[' expr ']' %prec '.'
1248 { $$ = build_nt (ARRAY_REF, $1, $3); }
1249 | parm_declarator '[' ']' %prec '.'
1250 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1251 | '*' type_quals parm_declarator %prec UNARY
1252 { $$ = make_pointer_declarator ($2, $3); }
1253 /* ??? Yuck. setattrs is a quick hack. We can't use
1254 prefix_attributes because $1 only applies to this
1255 declarator. We assume setspecs has already been done.
1256 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1257 attributes could be recognized here or in `attributes'). */
1258 | attributes setattrs parm_declarator
1263 /* A declarator allowed whether or not there has been
1264 an explicit typespec. These cannot redeclare a typedef-name. */
1267 notype_declarator '(' parmlist_or_identifiers %prec '.'
1268 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1269 /* | notype_declarator '(' error ')' %prec '.'
1270 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1271 poplevel (0, 0, 0); } */
1272 | '(' notype_declarator ')'
1274 | '*' type_quals notype_declarator %prec UNARY
1275 { $$ = make_pointer_declarator ($2, $3); }
1276 | notype_declarator '[' '*' ']' %prec '.'
1277 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE);
1279 error ("`[*]' in parameter declaration only allowed in ISO C 9x");
1281 | notype_declarator '[' expr ']' %prec '.'
1282 { $$ = build_nt (ARRAY_REF, $1, $3); }
1283 | notype_declarator '[' ']' %prec '.'
1284 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1285 /* ??? Yuck. setattrs is a quick hack. We can't use
1286 prefix_attributes because $1 only applies to this
1287 declarator. We assume setspecs has already been done.
1288 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1289 attributes could be recognized here or in `attributes'). */
1290 | attributes setattrs notype_declarator
1317 struct_head identifier '{'
1318 { $$ = start_struct (RECORD_TYPE, $2);
1319 /* Start scope of tag before parsing components. */
1321 component_decl_list '}' maybe_attribute
1322 { $$ = finish_struct ($<ttype>4, $5, chainon ($1, $7)); }
1323 | struct_head '{' component_decl_list '}' maybe_attribute
1324 { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
1325 $3, chainon ($1, $5));
1327 | struct_head identifier
1328 { $$ = xref_tag (RECORD_TYPE, $2); }
1329 | union_head identifier '{'
1330 { $$ = start_struct (UNION_TYPE, $2); }
1331 component_decl_list '}' maybe_attribute
1332 { $$ = finish_struct ($<ttype>4, $5, chainon ($1, $7)); }
1333 | union_head '{' component_decl_list '}' maybe_attribute
1334 { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
1335 $3, chainon ($1, $5));
1337 | union_head identifier
1338 { $$ = xref_tag (UNION_TYPE, $2); }
1339 | enum_head identifier '{'
1340 { $<itype>3 = suspend_momentary ();
1341 $$ = start_enum ($2); }
1342 enumlist maybecomma_warn '}' maybe_attribute
1343 { $$= finish_enum ($<ttype>4, nreverse ($5), chainon ($1, $8));
1344 resume_momentary ($<itype>3); }
1346 { $<itype>2 = suspend_momentary ();
1347 $$ = start_enum (NULL_TREE); }
1348 enumlist maybecomma_warn '}' maybe_attribute
1349 { $$= finish_enum ($<ttype>3, nreverse ($4), chainon ($1, $7));
1350 resume_momentary ($<itype>2); }
1351 | enum_head identifier
1352 { $$ = xref_tag (ENUMERAL_TYPE, $2); }
1363 { if (pedantic && ! flag_isoc9x)
1364 pedwarn ("comma at end of enumerator list"); }
1367 component_decl_list:
1368 component_decl_list2
1370 | component_decl_list2 component_decl
1371 { $$ = chainon ($1, $2);
1372 pedwarn ("no semicolon at end of struct or union"); }
1375 component_decl_list2: /* empty */
1377 | component_decl_list2 component_decl ';'
1378 { $$ = chainon ($1, $2); }
1379 | component_decl_list2 ';'
1381 pedwarn ("extra semicolon in struct or union specified"); }
1384 /* There is a shift-reduce conflict here, because `components' may
1385 start with a `typename'. It happens that shifting (the default resolution)
1386 does the right thing, because it treats the `typename' as part of
1387 a `typed_typespecs'.
1389 It is possible that this same technique would allow the distinction
1390 between `notype_initdecls' and `initdecls' to be eliminated.
1391 But I am being cautious and not trying it. */
1394 typed_typespecs setspecs components
1396 current_declspecs = TREE_VALUE (declspec_stack);
1397 prefix_attributes = TREE_PURPOSE (declspec_stack);
1398 declspec_stack = TREE_CHAIN (declspec_stack);
1399 resume_momentary ($2); }
1402 pedwarn ("ANSI C forbids member declarations with no members");
1405 | nonempty_type_quals setspecs components
1407 current_declspecs = TREE_VALUE (declspec_stack);
1408 prefix_attributes = TREE_PURPOSE (declspec_stack);
1409 declspec_stack = TREE_CHAIN (declspec_stack);
1410 resume_momentary ($2); }
1411 | nonempty_type_quals
1413 pedwarn ("ANSI C forbids member declarations with no members");
1418 | extension component_decl
1420 pedantic = $<itype>1; }
1424 component_declarator
1425 | components ',' component_declarator
1426 { $$ = chainon ($1, $3); }
1429 component_declarator:
1430 save_filename save_lineno declarator maybe_attribute
1431 { $$ = grokfield ($1, $2, $3, current_declspecs, NULL_TREE);
1432 decl_attributes ($$, $4, prefix_attributes); }
1433 | save_filename save_lineno
1434 declarator ':' expr_no_commas maybe_attribute
1435 { $$ = grokfield ($1, $2, $3, current_declspecs, $5);
1436 decl_attributes ($$, $6, prefix_attributes); }
1437 | save_filename save_lineno ':' expr_no_commas maybe_attribute
1438 { $$ = grokfield ($1, $2, NULL_TREE, current_declspecs, $4);
1439 decl_attributes ($$, $5, prefix_attributes); }
1442 /* We chain the enumerators in reverse order.
1443 They are put in forward order where enumlist is used.
1444 (The order used to be significant, but no longer is so.
1445 However, we still maintain the order, just to be clean.) */
1449 | enumlist ',' enumerator
1450 { if ($1 == error_mark_node)
1453 $$ = chainon ($3, $1); }
1455 { $$ = error_mark_node; }
1461 { $$ = build_enumerator ($1, NULL_TREE); }
1462 | identifier '=' expr_no_commas
1463 { $$ = build_enumerator ($1, $3); }
1467 typed_typespecs absdcl
1468 { $$ = build_tree_list ($1, $2); }
1469 | nonempty_type_quals absdcl
1470 { $$ = build_tree_list ($1, $2); }
1473 absdcl: /* an absolute declarator */
1479 nonempty_type_quals:
1481 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
1482 | nonempty_type_quals TYPE_QUAL
1483 { $$ = tree_cons (NULL_TREE, $2, $1); }
1489 | type_quals TYPE_QUAL
1490 { $$ = tree_cons (NULL_TREE, $2, $1); }
1493 absdcl1: /* a nonempty absolute declarator */
1496 /* `(typedef)1' is `int'. */
1497 | '*' type_quals absdcl1 %prec UNARY
1498 { $$ = make_pointer_declarator ($2, $3); }
1499 | '*' type_quals %prec UNARY
1500 { $$ = make_pointer_declarator ($2, NULL_TREE); }
1501 | absdcl1 '(' parmlist %prec '.'
1502 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1503 | absdcl1 '[' expr ']' %prec '.'
1504 { $$ = build_nt (ARRAY_REF, $1, $3); }
1505 | absdcl1 '[' ']' %prec '.'
1506 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1507 | '(' parmlist %prec '.'
1508 { $$ = build_nt (CALL_EXPR, NULL_TREE, $2, NULL_TREE); }
1509 | '[' expr ']' %prec '.'
1510 { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
1512 { $$ = build_nt (ARRAY_REF, NULL_TREE, NULL_TREE); }
1513 /* ??? It appears we have to support attributes here, however
1514 using prefix_attributes is wrong. */
1515 | attributes setattrs absdcl1
1519 /* at least one statement, the first of which parses without error. */
1520 /* stmts is used only after decls, so an invalid first statement
1521 is actually regarded as an invalid decl and part of the decls. */
1524 lineno_stmt_or_labels
1527 pedwarn ("ANSI C forbids label at end of compound statement");
1531 lineno_stmt_or_labels:
1532 lineno_stmt_or_label
1533 | lineno_stmt_or_labels lineno_stmt_or_label
1535 | lineno_stmt_or_labels errstmt
1547 pushlevel: /* empty */
1548 { emit_line_note (input_filename, lineno);
1552 expand_start_bindings (0);
1556 /* Read zero or more forward-declarations for labels
1557 that nested functions can jump to. */
1562 pedwarn ("ANSI C forbids label declarations"); }
1567 | label_decls label_decl
1571 LABEL identifiers_or_typenames ';'
1573 for (link = $2; link; link = TREE_CHAIN (link))
1575 tree label = shadow_label (TREE_VALUE (link));
1576 C_DECLARED_LABEL_FLAG (label) = 1;
1577 declare_nonlocal_label (label);
1582 /* This is the body of a function definition.
1583 It causes syntax errors to ignore to the next openbrace. */
1590 compstmt_start: '{' { compstmt_count++; }
1592 compstmt_nostart: '}'
1593 { $$ = convert (void_type_node, integer_zero_node); }
1594 | pushlevel maybe_label_decls decls xstmts '}'
1595 { emit_line_note (input_filename, lineno);
1596 expand_end_bindings (getdecls (), 1, 0);
1597 $$ = poplevel (1, 1, 0);
1598 if (yychar == CONSTANT || yychar == STRING)
1599 pop_momentary_nofree ();
1602 | pushlevel maybe_label_decls error '}'
1603 { emit_line_note (input_filename, lineno);
1604 expand_end_bindings (getdecls (), kept_level_p (), 0);
1605 $$ = poplevel (kept_level_p (), 0, 0);
1606 if (yychar == CONSTANT || yychar == STRING)
1607 pop_momentary_nofree ();
1610 | pushlevel maybe_label_decls stmts '}'
1611 { emit_line_note (input_filename, lineno);
1612 expand_end_bindings (getdecls (), kept_level_p (), 0);
1613 $$ = poplevel (kept_level_p (), 0, 0);
1614 if (yychar == CONSTANT || yychar == STRING)
1615 pop_momentary_nofree ();
1620 compstmt_primary_start:
1622 { if (current_function_decl == 0)
1624 error ("braced-group within expression allowed only inside a function");
1627 /* We must force a BLOCK for this level
1628 so that, if it is not expanded later,
1629 there is a way to turn off the entire subtree of blocks
1630 that are contained in it. */
1632 push_iterator_stack ();
1633 push_label_level ();
1634 $$ = expand_start_stmt_expr ();
1638 compstmt: compstmt_start compstmt_nostart
1642 /* Value is number of statements counted as of the closeparen. */
1644 if_prefix lineno_labeled_stmt
1645 /* Make sure c_expand_end_cond is run once
1646 for each call to c_expand_start_cond.
1647 Otherwise a crash is likely. */
1653 { emit_line_note ($<filename>-1, $<lineno>0);
1654 c_expand_start_cond (truthvalue_conversion ($3), 0,
1656 $<itype>$ = stmt_count;
1657 if_stmt_file = $<filename>-1;
1658 if_stmt_line = $<lineno>0;
1659 position_after_white_space (); }
1662 /* This is a subroutine of stmt.
1663 It is used twice, once for valid DO statements
1664 and once for catching errors in parsing the end test. */
1669 emit_line_note ($<filename>-1, $<lineno>0);
1670 /* See comment in `while' alternative, above. */
1672 expand_start_loop_continue_elsewhere (1);
1673 position_after_white_space (); }
1674 lineno_labeled_stmt WHILE
1675 { expand_loop_continue_here (); }
1679 { $$ = input_filename; }
1686 lineno_labeled_stmt:
1687 save_filename save_lineno stmt
1689 /* | save_filename save_lineno error
1692 | save_filename save_lineno label lineno_labeled_stmt
1696 lineno_stmt_or_label:
1697 save_filename save_lineno stmt_or_label
1708 /* Parse a single real statement, not including any labels. */
1715 emit_line_note ($<filename>-1, $<lineno>0);
1716 /* It appears that this should not be done--that a non-lvalue array
1717 shouldn't get an error if the value isn't used.
1718 Section 3.2.2.1 says that an array lvalue gets converted to a pointer
1719 if it appears as a top-level expression,
1720 but says nothing about non-lvalue arrays. */
1722 /* Call default_conversion to get an error
1723 on referring to a register array if pedantic. */
1724 if (TREE_CODE (TREE_TYPE ($1)) == ARRAY_TYPE
1725 || TREE_CODE (TREE_TYPE ($1)) == FUNCTION_TYPE)
1726 $1 = default_conversion ($1);
1728 iterator_expand ($1);
1729 clear_momentary (); }
1731 { c_expand_start_else ();
1732 $<itype>1 = stmt_count;
1733 position_after_white_space (); }
1735 { c_expand_end_cond ();
1736 if (extra_warnings && stmt_count == $<itype>1)
1737 warning ("empty body in an else-statement"); }
1738 | simple_if %prec IF
1739 { c_expand_end_cond ();
1740 /* This warning is here instead of in simple_if, because we
1741 do not want a warning if an empty if is followed by an
1742 else statement. Increment stmt_count so we don't
1743 give a second error if this is a nested `if'. */
1744 if (extra_warnings && stmt_count++ == $<itype>1)
1745 warning_with_file_and_line (if_stmt_file, if_stmt_line,
1746 "empty body in an if-statement"); }
1747 /* Make sure c_expand_end_cond is run once
1748 for each call to c_expand_start_cond.
1749 Otherwise a crash is likely. */
1750 | simple_if ELSE error
1751 { c_expand_end_cond (); }
1754 emit_line_note ($<filename>-1, $<lineno>0);
1755 /* The emit_nop used to come before emit_line_note,
1756 but that made the nop seem like part of the preceding line.
1757 And that was confusing when the preceding line was
1758 inside of an if statement and was not really executed.
1759 I think it ought to work to put the nop after the line number.
1760 We will see. --rms, July 15, 1991. */
1763 { /* Don't start the loop till we have succeeded
1764 in parsing the end test. This is to make sure
1765 that we end every loop we start. */
1766 expand_start_loop (1);
1767 emit_line_note (input_filename, lineno);
1768 expand_exit_loop_if_false (NULL_PTR,
1769 truthvalue_conversion ($4));
1770 position_after_white_space (); }
1772 { expand_end_loop (); }
1775 { emit_line_note (input_filename, lineno);
1776 expand_exit_loop_if_false (NULL_PTR,
1777 truthvalue_conversion ($3));
1779 clear_momentary (); }
1780 /* This rule is needed to make sure we end every loop we start. */
1781 | do_stmt_start error
1782 { expand_end_loop ();
1783 clear_momentary (); }
1787 emit_line_note ($<filename>-1, $<lineno>0);
1788 /* See comment in `while' alternative, above. */
1790 if ($3) c_expand_expr_stmt ($3);
1791 /* Next step is to call expand_start_loop_continue_elsewhere,
1792 but wait till after we parse the entire for (...).
1793 Otherwise, invalid input might cause us to call that
1794 fn without calling expand_end_loop. */
1797 /* Can't emit now; wait till after expand_start_loop... */
1798 { $<lineno>7 = lineno;
1799 $<filename>$ = input_filename; }
1802 /* Start the loop. Doing this after parsing
1803 all the expressions ensures we will end the loop. */
1804 expand_start_loop_continue_elsewhere (1);
1805 /* Emit the end-test, with a line number. */
1806 emit_line_note ($<filename>8, $<lineno>7);
1808 expand_exit_loop_if_false (NULL_PTR,
1809 truthvalue_conversion ($6));
1810 /* Don't let the tree nodes for $9 be discarded by
1811 clear_momentary during the parsing of the next stmt. */
1813 $<lineno>7 = lineno;
1814 $<filename>8 = input_filename;
1815 position_after_white_space (); }
1817 { /* Emit the increment expression, with a line number. */
1818 emit_line_note ($<filename>8, $<lineno>7);
1819 expand_loop_continue_here ();
1821 c_expand_expr_stmt ($9);
1822 if (yychar == CONSTANT || yychar == STRING)
1823 pop_momentary_nofree ();
1826 expand_end_loop (); }
1827 | SWITCH '(' expr ')'
1829 emit_line_note ($<filename>-1, $<lineno>0);
1830 c_expand_start_case ($3);
1831 /* Don't let the tree nodes for $3 be discarded by
1832 clear_momentary during the parsing of the next stmt. */
1834 position_after_white_space (); }
1836 { expand_end_case ($3);
1837 if (yychar == CONSTANT || yychar == STRING)
1838 pop_momentary_nofree ();
1843 emit_line_note ($<filename>-1, $<lineno>0);
1844 if ( ! expand_exit_something ())
1845 error ("break statement not within loop or switch"); }
1848 emit_line_note ($<filename>-1, $<lineno>0);
1849 if (! expand_continue_loop (NULL_PTR))
1850 error ("continue statement not within a loop"); }
1853 emit_line_note ($<filename>-1, $<lineno>0);
1854 c_expand_return (NULL_TREE); }
1857 emit_line_note ($<filename>-1, $<lineno>0);
1858 c_expand_return ($2); }
1859 | ASM_KEYWORD maybe_type_qual '(' expr ')' ';'
1861 emit_line_note ($<filename>-1, $<lineno>0);
1863 if ((TREE_CODE ($4) == ADDR_EXPR
1864 && TREE_CODE (TREE_OPERAND ($4, 0)) == STRING_CST)
1865 || TREE_CODE ($4) == STRING_CST)
1868 error ("argument of `asm' is not a constant string"); }
1869 /* This is the case with just output operands. */
1870 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ')' ';'
1872 emit_line_note ($<filename>-1, $<lineno>0);
1873 c_expand_asm_operands ($4, $6, NULL_TREE, NULL_TREE,
1874 $2 == ridpointers[(int)RID_VOLATILE],
1875 input_filename, lineno); }
1876 /* This is the case with input operands as well. */
1877 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':' asm_operands ')' ';'
1879 emit_line_note ($<filename>-1, $<lineno>0);
1880 c_expand_asm_operands ($4, $6, $8, NULL_TREE,
1881 $2 == ridpointers[(int)RID_VOLATILE],
1882 input_filename, lineno); }
1883 /* This is the case with clobbered registers as well. */
1884 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':'
1885 asm_operands ':' asm_clobbers ')' ';'
1887 emit_line_note ($<filename>-1, $<lineno>0);
1888 c_expand_asm_operands ($4, $6, $8, $10,
1889 $2 == ridpointers[(int)RID_VOLATILE],
1890 input_filename, lineno); }
1891 | GOTO identifier ';'
1894 emit_line_note ($<filename>-1, $<lineno>0);
1895 decl = lookup_label ($2);
1898 TREE_USED (decl) = 1;
1904 pedwarn ("ANSI C forbids `goto *expr;'");
1906 emit_line_note ($<filename>-1, $<lineno>0);
1907 expand_computed_goto (convert (ptr_type_node, $3)); }
1912 all_iter_stmt_simple
1913 /* | all_iter_stmt_with_decl */
1916 all_iter_stmt_simple:
1919 /* The value returned by this action is */
1920 /* 1 if everything is OK */
1921 /* 0 in case of error or already bound iterator */
1924 if (TREE_CODE ($3) != VAR_DECL)
1925 error ("invalid `for (ITERATOR)' syntax");
1926 else if (! ITERATOR_P ($3))
1927 error ("`%s' is not an iterator",
1928 IDENTIFIER_POINTER (DECL_NAME ($3)));
1929 else if (ITERATOR_BOUND_P ($3))
1930 error ("`for (%s)' inside expansion of same iterator",
1931 IDENTIFIER_POINTER (DECL_NAME ($3)));
1935 iterator_for_loop_start ($3);
1941 iterator_for_loop_end ($3);
1944 /* This really should allow any kind of declaration,
1945 for generality. Fix it before turning it back on.
1947 all_iter_stmt_with_decl:
1948 FOR '(' ITERATOR pushlevel setspecs iterator_spec ')'
1950 */ /* The value returned by this action is */
1951 /* 1 if everything is OK */
1952 /* 0 in case of error or already bound iterator */
1954 iterator_for_loop_start ($6);
1958 iterator_for_loop_end ($6);
1959 emit_line_note (input_filename, lineno);
1960 expand_end_bindings (getdecls (), 1, 0);
1961 $<ttype>$ = poplevel (1, 1, 0);
1962 if (yychar == CONSTANT || yychar == STRING)
1963 pop_momentary_nofree ();
1969 /* Any kind of label, including jump labels and case labels.
1970 ANSI C accepts labels only before statements, but we allow them
1971 also at the end of a compound statement. */
1973 label: CASE expr_no_commas ':'
1974 { register tree value = check_case_value ($2);
1976 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
1980 if (value != error_mark_node)
1985 if (pedantic && ! INTEGRAL_TYPE_P (TREE_TYPE (value)))
1986 pedwarn ("label must have integral type in ANSI C");
1988 success = pushcase (value, convert_and_check,
1992 error ("case label not within a switch statement");
1993 else if (success == 2)
1995 error ("duplicate case value");
1996 error_with_decl (duplicate, "this is the first entry for that value");
1998 else if (success == 3)
1999 warning ("case value out of range");
2000 else if (success == 5)
2001 error ("case label within scope of cleanup or variable array");
2003 position_after_white_space (); }
2004 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
2005 { register tree value1 = check_case_value ($2);
2006 register tree value2 = check_case_value ($4);
2008 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
2011 pedwarn ("ANSI C forbids case ranges");
2014 if (value1 != error_mark_node && value2 != error_mark_node)
2017 int success = pushcase_range (value1, value2,
2018 convert_and_check, label,
2021 error ("case label not within a switch statement");
2022 else if (success == 2)
2024 error ("duplicate case value");
2025 error_with_decl (duplicate, "this is the first entry for that value");
2027 else if (success == 3)
2028 warning ("case value out of range");
2029 else if (success == 4)
2030 warning ("empty case range");
2031 else if (success == 5)
2032 error ("case label within scope of cleanup or variable array");
2034 position_after_white_space (); }
2039 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
2040 int success = pushcase (NULL_TREE, 0, label, &duplicate);
2043 error ("default label not within a switch statement");
2044 else if (success == 2)
2046 error ("multiple default labels in one switch");
2047 error_with_decl (duplicate, "this is the first default label");
2049 position_after_white_space (); }
2050 | identifier ':' maybe_attribute
2051 { tree label = define_label (input_filename, lineno, $1);
2056 expand_label (label);
2057 decl_attributes (label, $3, NULL_TREE);
2059 position_after_white_space (); }
2062 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
2066 { emit_line_note (input_filename, lineno);
2069 { emit_line_note (input_filename, lineno); }
2078 /* These are the operands other than the first string and colon
2079 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
2080 asm_operands: /* empty */
2082 | nonnull_asm_operands
2085 nonnull_asm_operands:
2087 | nonnull_asm_operands ',' asm_operand
2088 { $$ = chainon ($1, $3); }
2093 { $$ = build_tree_list ($1, $3); }
2098 { $$ = tree_cons (NULL_TREE, combine_strings ($1), NULL_TREE); }
2099 | asm_clobbers ',' string
2100 { $$ = tree_cons (NULL_TREE, combine_strings ($3), $1); }
2103 /* This is what appears inside the parens in a function declarator.
2104 Its value is a list of ..._TYPE nodes. */
2107 clear_parm_order ();
2108 declare_parm_level (0); }
2111 parmlist_tags_warning ();
2112 poplevel (0, 0, 0); }
2120 pedwarn ("ANSI C forbids forward parameter declarations");
2121 /* Mark the forward decls as such. */
2122 for (parm = getdecls (); parm; parm = TREE_CHAIN (parm))
2123 TREE_ASM_WRITTEN (parm) = 1;
2124 clear_parm_order (); }
2128 { $$ = tree_cons (NULL_TREE, NULL_TREE, NULL_TREE); }
2131 /* This is what appears inside the parens in a function declarator.
2132 Is value is represented in the format that grokdeclarator expects. */
2133 parmlist_2: /* empty */
2134 { $$ = get_parm_info (0); }
2136 { $$ = get_parm_info (0);
2137 /* Gcc used to allow this as an extension. However, it does
2138 not work for all targets, and thus has been disabled.
2139 Also, since func (...) and func () are indistinguishable,
2140 it caused problems with the code in expand_builtin which
2141 tries to verify that BUILT_IN_NEXT_ARG is being used
2143 error ("ANSI C requires a named argument before `...'");
2146 { $$ = get_parm_info (1); }
2147 | parms ',' ELLIPSIS
2148 { $$ = get_parm_info (0); }
2153 { push_parm_decl ($1); }
2155 { push_parm_decl ($3); }
2158 /* A single parameter declaration or parameter type name,
2159 as found in a parmlist. */
2161 typed_declspecs setspecs parm_declarator maybe_attribute
2162 { $$ = build_tree_list (build_tree_list (current_declspecs,
2164 build_tree_list (prefix_attributes,
2166 current_declspecs = TREE_VALUE (declspec_stack);
2167 prefix_attributes = TREE_PURPOSE (declspec_stack);
2168 declspec_stack = TREE_CHAIN (declspec_stack);
2169 resume_momentary ($2); }
2170 | typed_declspecs setspecs notype_declarator maybe_attribute
2171 { $$ = build_tree_list (build_tree_list (current_declspecs,
2173 build_tree_list (prefix_attributes,
2175 current_declspecs = TREE_VALUE (declspec_stack);
2176 prefix_attributes = TREE_PURPOSE (declspec_stack);
2177 declspec_stack = TREE_CHAIN (declspec_stack);
2178 resume_momentary ($2); }
2179 | typed_declspecs setspecs absdcl maybe_attribute
2180 { $$ = build_tree_list (build_tree_list (current_declspecs,
2182 build_tree_list (prefix_attributes,
2184 current_declspecs = TREE_VALUE (declspec_stack);
2185 prefix_attributes = TREE_PURPOSE (declspec_stack);
2186 declspec_stack = TREE_CHAIN (declspec_stack);
2187 resume_momentary ($2); }
2188 | declmods setspecs notype_declarator maybe_attribute
2189 { $$ = build_tree_list (build_tree_list (current_declspecs,
2191 build_tree_list (prefix_attributes,
2193 current_declspecs = TREE_VALUE (declspec_stack);
2194 prefix_attributes = TREE_PURPOSE (declspec_stack);
2195 declspec_stack = TREE_CHAIN (declspec_stack);
2196 resume_momentary ($2); }
2198 | declmods setspecs absdcl maybe_attribute
2199 { $$ = build_tree_list (build_tree_list (current_declspecs,
2201 build_tree_list (prefix_attributes,
2203 current_declspecs = TREE_VALUE (declspec_stack);
2204 prefix_attributes = TREE_PURPOSE (declspec_stack);
2205 declspec_stack = TREE_CHAIN (declspec_stack);
2206 resume_momentary ($2); }
2209 /* This is used in a function definition
2210 where either a parmlist or an identifier list is ok.
2211 Its value is a list of ..._TYPE nodes or a list of identifiers. */
2212 parmlist_or_identifiers:
2214 clear_parm_order ();
2215 declare_parm_level (1); }
2216 parmlist_or_identifiers_1
2218 parmlist_tags_warning ();
2219 poplevel (0, 0, 0); }
2222 parmlist_or_identifiers_1:
2226 for (t = $1; t; t = TREE_CHAIN (t))
2227 if (TREE_VALUE (t) == NULL_TREE)
2228 error ("`...' in old-style identifier list");
2229 $$ = tree_cons (NULL_TREE, NULL_TREE, $1); }
2232 /* A nonempty list of identifiers. */
2235 { $$ = build_tree_list (NULL_TREE, $1); }
2236 | identifiers ',' IDENTIFIER
2237 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2240 /* A nonempty list of identifiers, including typenames. */
2241 identifiers_or_typenames:
2243 { $$ = build_tree_list (NULL_TREE, $1); }
2244 | identifiers_or_typenames ',' identifier
2245 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2250 { $<itype>$ = pedantic;