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. */
46 #ifdef MULTIBYTE_CHARS
51 /* Since parsers are distinct for each language, put the language string
53 const char * const language_string = "GNU C";
55 /* Like YYERROR but do call yyerror. */
56 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
58 /* Cause the `yydebug' variable to be defined. */
64 %union {long itype; tree ttype; enum tree_code code;
65 char *filename; int lineno; int ends_in_label; }
67 /* All identifiers that are not reserved words
68 and are not declared typedefs in the current block */
71 /* All identifiers that are declared typedefs in the current block.
72 In some contexts, they are treated just like IDENTIFIER,
73 but they can also serve as typespecs in declarations. */
76 /* Reserved words that specify storage class.
77 yylval contains an IDENTIFIER_NODE which indicates which one. */
80 /* Reserved words that specify type.
81 yylval contains an IDENTIFIER_NODE which indicates which one. */
84 /* Reserved words that qualify type: "const", "volatile", or "restrict".
85 yylval contains an IDENTIFIER_NODE which indicates which one. */
88 /* Character or numeric constants.
89 yylval is the node for the constant. */
92 /* String constants in raw form.
93 yylval is a STRING_CST node. */
96 /* "...", used for functions with variable arglists. */
99 /* the reserved words */
100 /* SCO include files test "ASM", so use something else. */
101 %token SIZEOF ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
102 %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD TYPEOF ALIGNOF
103 %token ATTRIBUTE EXTENSION LABEL
104 %token REALPART IMAGPART VA_ARG
106 /* Used in c-lex.c for parsing pragmas. */
109 /* Add precedence rules to solve dangling else s/r conflict */
113 /* Define the operator tokens and their precedences.
114 The value is an integer because, if used, it is the tree code
115 to use in the expression made from the operator. */
117 %right <code> ASSIGN '='
118 %right <code> '?' ':'
124 %left <code> EQCOMPARE
125 %left <code> ARITHCOMPARE
126 %left <code> LSHIFT RSHIFT
128 %left <code> '*' '/' '%'
129 %right <code> UNARY PLUSPLUS MINUSMINUS
131 %left <code> POINTSAT '.' '(' '['
133 /* The Objective-C keywords. These are included in C and in
134 Objective C, so that the token codes are the same in both. */
135 %token INTERFACE IMPLEMENTATION END SELECTOR DEFS ENCODE
136 %token CLASSNAME PUBLIC PRIVATE PROTECTED PROTOCOL OBJECTNAME CLASS ALIAS
138 /* Objective-C string constants in raw form.
139 yylval is an OBJC_STRING_CST node. */
145 %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist exprlist
146 %type <ttype> expr_no_commas cast_expr unary_expr primary string STRING
147 %type <ttype> typed_declspecs reserved_declspecs
148 %type <ttype> typed_typespecs reserved_typespecquals
149 %type <ttype> declmods typespec typespecqual_reserved
150 %type <ttype> typed_declspecs_no_prefix_attr reserved_declspecs_no_prefix_attr
151 %type <ttype> declmods_no_prefix_attr
152 %type <ttype> SCSPEC TYPESPEC TYPE_QUAL nonempty_type_quals maybe_type_qual
153 %type <ttype> initdecls notype_initdecls initdcl notype_initdcl
154 %type <ttype> init maybeasm
155 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
156 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
157 %type <ttype> any_word
159 %type <ttype> compstmt compstmt_nostart compstmt_primary_start
161 %type <ttype> declarator
162 %type <ttype> notype_declarator after_type_declarator
163 %type <ttype> parm_declarator
165 %type <ttype> structsp component_decl_list component_decl_list2
166 %type <ttype> component_decl components component_declarator
167 %type <ttype> enumlist enumerator
168 %type <ttype> struct_head union_head enum_head
169 %type <ttype> typename absdcl absdcl1 type_quals
170 %type <ttype> xexpr parms parm identifiers
172 %type <ttype> parmlist parmlist_1 parmlist_2
173 %type <ttype> parmlist_or_identifiers parmlist_or_identifiers_1
174 %type <ttype> identifiers_or_typenames
176 %type <itype> setspecs
178 %type <ends_in_label> lineno_stmt_or_label lineno_stmt_or_labels stmt_or_label
180 %type <filename> save_filename
181 %type <lineno> save_lineno
185 /* Number of statements (loosely speaking) and compound statements
187 static int stmt_count;
188 static int compstmt_count;
190 /* Input file and line number of the end of the body of last simple_if;
191 used by the stmt-rule immediately after simple_if returns. */
192 static char *if_stmt_file;
193 static int if_stmt_line;
195 /* List of types and structure classes of the current declaration. */
196 static tree current_declspecs = NULL_TREE;
197 static tree prefix_attributes = NULL_TREE;
199 /* Stack of saved values of current_declspecs and prefix_attributes. */
200 static tree declspec_stack;
202 /* 1 if we explained undeclared var errors. */
203 static int undeclared_variable_notice;
206 /* Tell yyparse how to print a token's value, if yydebug is set. */
208 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
209 extern void yyprint PROTO ((FILE *, int, YYSTYPE));
211 /* Add GC roots for variables local to this file. */
215 ggc_add_tree_root (&declspec_stack, 1);
216 ggc_add_tree_root (¤t_declspecs, 1);
217 ggc_add_tree_root (&prefix_attributes, 1);
225 pedwarn ("ANSI C forbids an empty source file");
230 /* In case there were missing closebraces,
231 get us back to the global binding level. */
232 while (! global_bindings_p ())
238 /* the reason for the strange actions in this rule
239 is so that notype_initdecls when reached via datadef
240 can find a valid list of type and sc specs in $0. */
243 {$<ttype>$ = NULL_TREE; } extdef
244 | extdefs {$<ttype>$ = NULL_TREE; } extdef
250 | ASM_KEYWORD '(' expr ')' ';'
252 if ((TREE_CODE ($3) == ADDR_EXPR
253 && TREE_CODE (TREE_OPERAND ($3, 0)) == STRING_CST)
254 || TREE_CODE ($3) == STRING_CST)
257 error ("argument of `asm' is not a constant string"); }
259 { pedantic = $<itype>1; }
263 setspecs notype_initdecls ';'
265 error ("ANSI C forbids data definition with no type or storage class");
266 else if (!flag_traditional)
267 warning ("data definition has no type or storage class");
269 current_declspecs = TREE_VALUE (declspec_stack);
270 prefix_attributes = TREE_PURPOSE (declspec_stack);
271 declspec_stack = TREE_CHAIN (declspec_stack);
272 resume_momentary ($1); }
273 | declmods setspecs notype_initdecls ';'
274 { current_declspecs = TREE_VALUE (declspec_stack);
275 prefix_attributes = TREE_PURPOSE (declspec_stack);
276 declspec_stack = TREE_CHAIN (declspec_stack);
277 resume_momentary ($2); }
278 | typed_declspecs setspecs initdecls ';'
279 { current_declspecs = TREE_VALUE (declspec_stack);
280 prefix_attributes = TREE_PURPOSE (declspec_stack);
281 declspec_stack = TREE_CHAIN (declspec_stack);
282 resume_momentary ($2); }
284 { pedwarn ("empty declaration"); }
285 | typed_declspecs ';'
291 pedwarn ("ANSI C does not allow extra `;' outside of a function"); }
295 typed_declspecs setspecs declarator
296 { if (! start_function (current_declspecs, $3,
297 prefix_attributes, NULL_TREE, 0))
299 reinit_parse_for_function (); }
301 { store_parm_decls (); }
303 { finish_function (0);
304 current_declspecs = TREE_VALUE (declspec_stack);
305 prefix_attributes = TREE_PURPOSE (declspec_stack);
306 declspec_stack = TREE_CHAIN (declspec_stack);
307 resume_momentary ($2); }
308 | typed_declspecs setspecs declarator error
309 { current_declspecs = TREE_VALUE (declspec_stack);
310 prefix_attributes = TREE_PURPOSE (declspec_stack);
311 declspec_stack = TREE_CHAIN (declspec_stack);
312 resume_momentary ($2); }
313 | declmods setspecs notype_declarator
314 { if (! start_function (current_declspecs, $3,
315 prefix_attributes, NULL_TREE, 0))
317 reinit_parse_for_function (); }
319 { store_parm_decls (); }
321 { finish_function (0);
322 current_declspecs = TREE_VALUE (declspec_stack);
323 prefix_attributes = TREE_PURPOSE (declspec_stack);
324 declspec_stack = TREE_CHAIN (declspec_stack);
325 resume_momentary ($2); }
326 | declmods setspecs notype_declarator error
327 { current_declspecs = TREE_VALUE (declspec_stack);
328 prefix_attributes = TREE_PURPOSE (declspec_stack);
329 declspec_stack = TREE_CHAIN (declspec_stack);
330 resume_momentary ($2); }
331 | setspecs notype_declarator
332 { if (! start_function (NULL_TREE, $2,
333 prefix_attributes, NULL_TREE, 0))
335 reinit_parse_for_function (); }
337 { store_parm_decls (); }
339 { finish_function (0);
340 current_declspecs = TREE_VALUE (declspec_stack);
341 prefix_attributes = TREE_PURPOSE (declspec_stack);
342 declspec_stack = TREE_CHAIN (declspec_stack);
343 resume_momentary ($1); }
344 | setspecs notype_declarator error
345 { current_declspecs = TREE_VALUE (declspec_stack);
346 prefix_attributes = TREE_PURPOSE (declspec_stack);
347 declspec_stack = TREE_CHAIN (declspec_stack);
348 resume_momentary ($1); }
359 { $$ = NEGATE_EXPR; }
361 { $$ = CONVERT_EXPR; }
363 { $$ = PREINCREMENT_EXPR; }
365 { $$ = PREDECREMENT_EXPR; }
367 { $$ = BIT_NOT_EXPR; }
369 { $$ = TRUTH_NOT_EXPR; }
372 expr: nonnull_exprlist
373 { $$ = build_compound_expr ($1); }
384 { $$ = build_tree_list (NULL_TREE, $1); }
385 | nonnull_exprlist ',' expr_no_commas
386 { chainon ($1, build_tree_list (NULL_TREE, $3)); }
391 | '*' cast_expr %prec UNARY
392 { $$ = build_indirect_ref ($2, "unary *"); }
393 /* __extension__ turns off -pedantic for following primary. */
394 | extension cast_expr %prec UNARY
396 pedantic = $<itype>1; }
397 | unop cast_expr %prec UNARY
398 { $$ = build_unary_op ($1, $2, 0);
399 overflow_warning ($$); }
400 /* Refer to the address of a label as a pointer. */
402 { tree label = lookup_label ($2);
404 pedwarn ("ANSI C forbids `&&'");
406 $$ = null_pointer_node;
409 TREE_USED (label) = 1;
410 $$ = build1 (ADDR_EXPR, ptr_type_node, label);
411 TREE_CONSTANT ($$) = 1;
414 /* This seems to be impossible on some machines, so let's turn it off.
415 You can use __builtin_next_arg to find the anonymous stack args.
417 { tree types = TYPE_ARG_TYPES (TREE_TYPE (current_function_decl));
418 $$ = error_mark_node;
419 if (TREE_VALUE (tree_last (types)) == void_type_node)
420 error ("`&...' used in function with fixed number of arguments");
424 pedwarn ("ANSI C forbids `&...'");
425 $$ = tree_last (DECL_ARGUMENTS (current_function_decl));
426 $$ = build_unary_op (ADDR_EXPR, $$, 0);
429 | sizeof unary_expr %prec UNARY
431 if (TREE_CODE ($2) == COMPONENT_REF
432 && DECL_C_BIT_FIELD (TREE_OPERAND ($2, 1)))
433 error ("`sizeof' applied to a bit-field");
434 $$ = c_sizeof (TREE_TYPE ($2)); }
435 | sizeof '(' typename ')' %prec HYPERUNARY
437 $$ = c_sizeof (groktypename ($3)); }
438 | alignof unary_expr %prec UNARY
440 $$ = c_alignof_expr ($2); }
441 | alignof '(' typename ')' %prec HYPERUNARY
443 $$ = c_alignof (groktypename ($3)); }
444 | REALPART cast_expr %prec UNARY
445 { $$ = build_unary_op (REALPART_EXPR, $2, 0); }
446 | IMAGPART cast_expr %prec UNARY
447 { $$ = build_unary_op (IMAGPART_EXPR, $2, 0); }
448 | VA_ARG '(' expr_no_commas ',' typename ')'
449 { $$ = build_va_arg ($3, groktypename ($5)); }
453 SIZEOF { skip_evaluation++; }
457 ALIGNOF { skip_evaluation++; }
462 | '(' typename ')' cast_expr %prec UNARY
463 { tree type = groktypename ($2);
464 $$ = build_c_cast (type, $4); }
465 | '(' typename ')' '{'
466 { start_init (NULL_TREE, NULL, 0);
467 $2 = groktypename ($2);
468 really_start_incremental_init ($2); }
469 initlist_maybe_comma '}' %prec UNARY
471 tree result = pop_init_level (0);
475 if (pedantic && ! flag_isoc9x)
476 pedwarn ("ANSI C forbids constructor expressions");
477 if (TYPE_NAME (type) != 0)
479 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
480 name = IDENTIFIER_POINTER (TYPE_NAME (type));
482 name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
487 if (TREE_CODE (type) == ARRAY_TYPE && TYPE_SIZE (type) == 0)
489 int failure = complete_array_type (type, $$, 1);
498 | expr_no_commas '+' expr_no_commas
499 { $$ = parser_build_binary_op ($2, $1, $3); }
500 | expr_no_commas '-' expr_no_commas
501 { $$ = parser_build_binary_op ($2, $1, $3); }
502 | expr_no_commas '*' expr_no_commas
503 { $$ = parser_build_binary_op ($2, $1, $3); }
504 | expr_no_commas '/' expr_no_commas
505 { $$ = parser_build_binary_op ($2, $1, $3); }
506 | expr_no_commas '%' expr_no_commas
507 { $$ = parser_build_binary_op ($2, $1, $3); }
508 | expr_no_commas LSHIFT expr_no_commas
509 { $$ = parser_build_binary_op ($2, $1, $3); }
510 | expr_no_commas RSHIFT expr_no_commas
511 { $$ = parser_build_binary_op ($2, $1, $3); }
512 | expr_no_commas ARITHCOMPARE expr_no_commas
513 { $$ = parser_build_binary_op ($2, $1, $3); }
514 | expr_no_commas EQCOMPARE expr_no_commas
515 { $$ = parser_build_binary_op ($2, $1, $3); }
516 | expr_no_commas '&' expr_no_commas
517 { $$ = parser_build_binary_op ($2, $1, $3); }
518 | expr_no_commas '|' expr_no_commas
519 { $$ = parser_build_binary_op ($2, $1, $3); }
520 | expr_no_commas '^' expr_no_commas
521 { $$ = parser_build_binary_op ($2, $1, $3); }
522 | expr_no_commas ANDAND
523 { $1 = truthvalue_conversion (default_conversion ($1));
524 skip_evaluation += $1 == boolean_false_node; }
526 { skip_evaluation -= $1 == boolean_false_node;
527 $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $4); }
528 | expr_no_commas OROR
529 { $1 = truthvalue_conversion (default_conversion ($1));
530 skip_evaluation += $1 == boolean_true_node; }
532 { skip_evaluation -= $1 == boolean_true_node;
533 $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $4); }
535 { $1 = truthvalue_conversion (default_conversion ($1));
536 skip_evaluation += $1 == boolean_false_node; }
538 { skip_evaluation += (($1 == boolean_true_node)
539 - ($1 == boolean_false_node)); }
541 { skip_evaluation -= $1 == boolean_true_node;
542 $$ = build_conditional_expr ($1, $4, $7); }
545 pedwarn ("ANSI C forbids omitting the middle term of a ?: expression");
546 /* Make sure first operand is calculated only once. */
547 $<ttype>2 = save_expr ($1);
548 $1 = truthvalue_conversion (default_conversion ($<ttype>2));
549 skip_evaluation += $1 == boolean_true_node; }
551 { skip_evaluation -= $1 == boolean_true_node;
552 $$ = build_conditional_expr ($1, $<ttype>2, $5); }
553 | expr_no_commas '=' expr_no_commas
555 $$ = build_modify_expr ($1, NOP_EXPR, $3);
556 class = TREE_CODE_CLASS (TREE_CODE ($$));
557 if (class == 'e' || class == '1'
558 || class == '2' || class == '<')
559 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR);
561 | expr_no_commas ASSIGN expr_no_commas
563 $$ = build_modify_expr ($1, $2, $3);
564 /* This inhibits warnings in truthvalue_conversion. */
565 class = TREE_CODE_CLASS (TREE_CODE ($$));
566 if (class == 'e' || class == '1'
567 || class == '2' || class == '<')
568 C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK);
576 if (!$$ || $$ == error_mark_node)
578 if (yychar == YYEMPTY)
583 /* Ordinary implicit function declaration. */
584 $$ = implicitly_declare ($1);
585 assemble_external ($$);
589 else if (current_function_decl == 0)
591 error ("`%s' undeclared here (not in a function)",
592 IDENTIFIER_POINTER ($1));
593 $$ = error_mark_node;
598 if (IDENTIFIER_GLOBAL_VALUE ($1) != error_mark_node
599 || IDENTIFIER_ERROR_LOCUS ($1) != current_function_decl)
601 error ("`%s' undeclared (first use in this function)",
602 IDENTIFIER_POINTER ($1));
604 if (! undeclared_variable_notice)
606 error ("(Each undeclared identifier is reported only once");
607 error ("for each function it appears in.)");
608 undeclared_variable_notice = 1;
611 $$ = error_mark_node;
612 /* Prevent repeated error messages. */
613 IDENTIFIER_GLOBAL_VALUE ($1) = error_mark_node;
614 IDENTIFIER_ERROR_LOCUS ($1) = current_function_decl;
618 else if (TREE_TYPE ($$) == error_mark_node)
619 $$ = error_mark_node;
620 else if (C_DECL_ANTICIPATED ($$))
622 /* The first time we see a build-in function used,
623 if it has not been declared. */
624 C_DECL_ANTICIPATED ($$) = 0;
625 if (yychar == YYEMPTY)
629 /* Omit the implicit declaration we
630 would ordinarily do, so we don't lose
631 the actual built in type.
632 But print a diagnostic for the mismatch. */
633 if (TREE_CODE ($$) != FUNCTION_DECL)
634 error ("`%s' implicitly declared as function",
635 IDENTIFIER_POINTER (DECL_NAME ($$)));
636 else if ((TYPE_MODE (TREE_TYPE (TREE_TYPE ($$)))
637 != TYPE_MODE (integer_type_node))
638 && (TREE_TYPE (TREE_TYPE ($$))
640 pedwarn ("type mismatch in implicit declaration for built-in function `%s'",
641 IDENTIFIER_POINTER (DECL_NAME ($$)));
642 /* If it really returns void, change that to int. */
643 if (TREE_TYPE (TREE_TYPE ($$)) == void_type_node)
645 = build_function_type (integer_type_node,
646 TYPE_ARG_TYPES (TREE_TYPE ($$)));
649 pedwarn ("built-in function `%s' used without declaration",
650 IDENTIFIER_POINTER (DECL_NAME ($$)));
652 /* Do what we would ordinarily do when a fn is used. */
653 assemble_external ($$);
658 assemble_external ($$);
662 if (TREE_CODE ($$) == CONST_DECL)
664 $$ = DECL_INITIAL ($$);
665 /* This is to prevent an enum whose value is 0
666 from being considered a null pointer constant. */
667 $$ = build1 (NOP_EXPR, TREE_TYPE ($$), $$);
668 TREE_CONSTANT ($$) = 1;
673 { $$ = combine_strings ($1); }
675 { char class = TREE_CODE_CLASS (TREE_CODE ($2));
676 if (class == 'e' || class == '1'
677 || class == '2' || class == '<')
678 C_SET_EXP_ORIGINAL_CODE ($2, ERROR_MARK);
681 { $$ = error_mark_node; }
682 | compstmt_primary_start compstmt_nostart ')'
685 pedwarn ("ANSI C forbids braced-groups within expressions");
686 pop_iterator_stack ();
688 rtl_exp = expand_end_stmt_expr ($1);
689 /* The statements have side effects, so the group does. */
690 TREE_SIDE_EFFECTS (rtl_exp) = 1;
692 if (TREE_CODE ($2) == BLOCK)
694 /* Make a BIND_EXPR for the BLOCK already made. */
695 $$ = build (BIND_EXPR, TREE_TYPE (rtl_exp),
696 NULL_TREE, rtl_exp, $2);
697 /* Remove the block from the tree at this point.
698 It gets put back at the proper place
699 when the BIND_EXPR is expanded. */
705 | compstmt_primary_start error ')'
707 /* Make sure we call expand_end_stmt_expr. Otherwise
708 we are likely to lose sequences and crash later. */
709 pop_iterator_stack ();
711 expand_end_stmt_expr ($1);
712 $$ = error_mark_node;
714 | primary '(' exprlist ')' %prec '.'
715 { $$ = build_function_call ($1, $3); }
716 | primary '[' expr ']' %prec '.'
717 { $$ = build_array_ref ($1, $3); }
718 | primary '.' identifier
720 $$ = build_component_ref ($1, $3);
722 | primary POINTSAT identifier
724 tree expr = build_indirect_ref ($1, "->");
726 $$ = build_component_ref (expr, $3);
729 { $$ = build_unary_op (POSTINCREMENT_EXPR, $1, 0); }
731 { $$ = build_unary_op (POSTDECREMENT_EXPR, $1, 0); }
734 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
738 { $$ = chainon ($1, $2); }
742 old_style_parm_decls:
746 /* ... is used here to indicate a varargs function. */
749 pedwarn ("ANSI C does not permit use of `varargs.h'"); }
752 /* The following are analogous to lineno_decl, decls and decl
753 except that they do not allow nested functions.
754 They are used for old-style parm decls. */
756 save_filename save_lineno datadecl
763 | datadecls lineno_datadecl
764 | lineno_datadecl errstmt
767 /* We don't allow prefix attributes here because they cause reduce/reduce
768 conflicts: we can't know whether we're parsing a function decl with
769 attribute suffix, or function defn with attribute prefix on first old
772 typed_declspecs_no_prefix_attr setspecs initdecls ';'
773 { current_declspecs = TREE_VALUE (declspec_stack);
774 prefix_attributes = TREE_PURPOSE (declspec_stack);
775 declspec_stack = TREE_CHAIN (declspec_stack);
776 resume_momentary ($2); }
777 | declmods_no_prefix_attr setspecs notype_initdecls ';'
778 { current_declspecs = TREE_VALUE (declspec_stack);
779 prefix_attributes = TREE_PURPOSE (declspec_stack);
780 declspec_stack = TREE_CHAIN (declspec_stack);
781 resume_momentary ($2); }
782 | typed_declspecs_no_prefix_attr ';'
783 { shadow_tag_warned ($1, 1);
784 pedwarn ("empty declaration"); }
785 | declmods_no_prefix_attr ';'
786 { pedwarn ("empty declaration"); }
789 /* This combination which saves a lineno before a decl
790 is the normal thing to use, rather than decl itself.
791 This is to avoid shift/reduce conflicts in contexts
792 where statement labels are allowed. */
794 save_filename save_lineno decl
802 | lineno_decl errstmt
805 /* records the type and storage class specs to use for processing
806 the declarators that follow.
807 Maintains a stack of outer-level values of current_declspecs,
808 for the sake of parm declarations nested in function declarators. */
809 setspecs: /* empty */
810 { $$ = suspend_momentary ();
811 pending_xref_error ();
812 declspec_stack = tree_cons (prefix_attributes,
815 split_specs_attrs ($<ttype>0,
816 ¤t_declspecs, &prefix_attributes); }
819 /* ??? Yuck. See after_type_declarator. */
820 setattrs: /* empty */
821 { prefix_attributes = chainon (prefix_attributes, $<ttype>0); }
825 typed_declspecs setspecs initdecls ';'
826 { current_declspecs = TREE_VALUE (declspec_stack);
827 prefix_attributes = TREE_PURPOSE (declspec_stack);
828 declspec_stack = TREE_CHAIN (declspec_stack);
829 resume_momentary ($2); }
830 | declmods setspecs notype_initdecls ';'
831 { current_declspecs = TREE_VALUE (declspec_stack);
832 prefix_attributes = TREE_PURPOSE (declspec_stack);
833 declspec_stack = TREE_CHAIN (declspec_stack);
834 resume_momentary ($2); }
835 | typed_declspecs setspecs nested_function
836 { current_declspecs = TREE_VALUE (declspec_stack);
837 prefix_attributes = TREE_PURPOSE (declspec_stack);
838 declspec_stack = TREE_CHAIN (declspec_stack);
839 resume_momentary ($2); }
840 | declmods setspecs notype_nested_function
841 { current_declspecs = TREE_VALUE (declspec_stack);
842 prefix_attributes = TREE_PURPOSE (declspec_stack);
843 declspec_stack = TREE_CHAIN (declspec_stack);
844 resume_momentary ($2); }
845 | typed_declspecs ';'
848 { pedwarn ("empty declaration"); }
850 { pedantic = $<itype>1; }
853 /* Declspecs which contain at least one type specifier or typedef name.
854 (Just `const' or `volatile' is not enough.)
855 A typedef'd name following these is taken as a name to be declared.
856 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
859 typespec reserved_declspecs
860 { $$ = tree_cons (NULL_TREE, $1, $2); }
861 | declmods typespec reserved_declspecs
862 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
865 reserved_declspecs: /* empty */
867 | reserved_declspecs typespecqual_reserved
868 { $$ = tree_cons (NULL_TREE, $2, $1); }
869 | reserved_declspecs SCSPEC
870 { if (extra_warnings)
871 warning ("`%s' is not at beginning of declaration",
872 IDENTIFIER_POINTER ($2));
873 $$ = tree_cons (NULL_TREE, $2, $1); }
874 | reserved_declspecs attributes
875 { $$ = tree_cons ($2, NULL_TREE, $1); }
878 typed_declspecs_no_prefix_attr:
879 typespec reserved_declspecs_no_prefix_attr
880 { $$ = tree_cons (NULL_TREE, $1, $2); }
881 | declmods_no_prefix_attr typespec reserved_declspecs_no_prefix_attr
882 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
885 reserved_declspecs_no_prefix_attr:
888 | reserved_declspecs_no_prefix_attr typespecqual_reserved
889 { $$ = tree_cons (NULL_TREE, $2, $1); }
890 | reserved_declspecs_no_prefix_attr SCSPEC
891 { if (extra_warnings)
892 warning ("`%s' is not at beginning of declaration",
893 IDENTIFIER_POINTER ($2));
894 $$ = tree_cons (NULL_TREE, $2, $1); }
897 /* List of just storage classes, type modifiers, and prefix attributes.
898 A declaration can start with just this, but then it cannot be used
899 to redeclare a typedef-name.
900 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
903 declmods_no_prefix_attr
906 { $$ = tree_cons ($1, NULL_TREE, NULL_TREE); }
907 | declmods declmods_no_prefix_attr
908 { $$ = chainon ($2, $1); }
909 | declmods attributes
910 { $$ = tree_cons ($2, NULL_TREE, $1); }
913 declmods_no_prefix_attr:
915 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
916 TREE_STATIC ($$) = 1; }
918 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
919 | declmods_no_prefix_attr TYPE_QUAL
920 { $$ = tree_cons (NULL_TREE, $2, $1);
921 TREE_STATIC ($$) = 1; }
922 | declmods_no_prefix_attr SCSPEC
923 { if (extra_warnings && TREE_STATIC ($1))
924 warning ("`%s' is not at beginning of declaration",
925 IDENTIFIER_POINTER ($2));
926 $$ = tree_cons (NULL_TREE, $2, $1);
927 TREE_STATIC ($$) = TREE_STATIC ($1); }
931 /* Used instead of declspecs where storage classes are not allowed
932 (that is, for typenames and structure components).
933 Don't accept a typedef-name if anything but a modifier precedes it. */
936 typespec reserved_typespecquals
937 { $$ = tree_cons (NULL_TREE, $1, $2); }
938 | nonempty_type_quals typespec reserved_typespecquals
939 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
942 reserved_typespecquals: /* empty */
944 | reserved_typespecquals typespecqual_reserved
945 { $$ = tree_cons (NULL_TREE, $2, $1); }
948 /* A typespec (but not a type qualifier).
949 Once we have seen one of these in a declaration,
950 if a typedef name appears then it is being redeclared. */
955 { /* For a typedef name, record the meaning, not the name.
956 In case of `foo foo, bar;'. */
957 $$ = lookup_name ($1); }
958 | TYPEOF '(' expr ')'
959 { $$ = TREE_TYPE ($3); }
960 | TYPEOF '(' typename ')'
961 { $$ = groktypename ($3); }
964 /* A typespec that is a reserved word, or a type qualifier. */
966 typespecqual_reserved: TYPESPEC
973 | initdecls ',' initdcl
978 | notype_initdecls ',' initdcl
984 | ASM_KEYWORD '(' string ')'
985 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
991 declarator maybeasm maybe_attribute '='
992 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
993 $3, prefix_attributes);
994 start_init ($<ttype>$, $2, global_bindings_p ()); }
996 /* Note how the declaration of the variable is in effect while its init is parsed! */
998 finish_decl ($<ttype>5, $6, $2); }
999 | declarator maybeasm maybe_attribute
1000 { tree d = start_decl ($1, current_declspecs, 0,
1001 $3, prefix_attributes);
1002 finish_decl (d, NULL_TREE, $2);
1007 notype_declarator maybeasm maybe_attribute '='
1008 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1009 $3, prefix_attributes);
1010 start_init ($<ttype>$, $2, global_bindings_p ()); }
1012 /* Note how the declaration of the variable is in effect while its init is parsed! */
1014 decl_attributes ($<ttype>5, $3, prefix_attributes);
1015 finish_decl ($<ttype>5, $6, $2); }
1016 | notype_declarator maybeasm maybe_attribute
1017 { tree d = start_decl ($1, current_declspecs, 0,
1018 $3, prefix_attributes);
1019 finish_decl (d, NULL_TREE, $2); }
1021 /* the * rules are dummies to accept the Apollo extended syntax
1022 so that the header files compile. */
1033 | attributes attribute
1034 { $$ = chainon ($1, $2); }
1038 ATTRIBUTE '(' '(' attribute_list ')' ')'
1045 | attribute_list ',' attrib
1046 { $$ = chainon ($1, $3); }
1053 { $$ = build_tree_list ($1, NULL_TREE); }
1054 | any_word '(' IDENTIFIER ')'
1055 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1056 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1057 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1058 | any_word '(' exprlist ')'
1059 { $$ = build_tree_list ($1, $3); }
1062 /* This still leaves out most reserved keywords,
1063 shouldn't we include them? */
1072 /* Initializers. `init' is the entry point. */
1077 { really_start_incremental_init (NULL_TREE);
1078 /* Note that the call to clear_momentary
1079 is in process_init_element. */
1080 push_momentary (); }
1081 initlist_maybe_comma '}'
1082 { $$ = pop_init_level (0);
1083 if ($$ == error_mark_node
1084 && ! (yychar == STRING || yychar == CONSTANT))
1087 pop_momentary_nofree (); }
1090 { $$ = error_mark_node; }
1093 /* `initlist_maybe_comma' is the guts of an initializer in braces. */
1094 initlist_maybe_comma:
1097 pedwarn ("ANSI C forbids empty initializer braces"); }
1098 | initlist1 maybecomma
1103 | initlist1 ',' initelt
1106 /* `initelt' is a single element of an initializer.
1107 It may use braces. */
1109 designator_list '=' initval
1110 | designator initval
1112 { set_init_label ($1); }
1119 { push_init_level (0); }
1120 initlist_maybe_comma '}'
1121 { process_init_element (pop_init_level (0)); }
1123 { process_init_element ($1); }
1129 | designator_list designator
1134 { set_init_label ($2); }
1135 /* These are for labeled elements. The syntax for an array element
1136 initializer conflicts with the syntax for an Objective-C message,
1137 so don't include these productions in the Objective-C grammar. */
1138 | '[' expr_no_commas ELLIPSIS expr_no_commas ']'
1139 { set_init_index ($2, $4); }
1140 | '[' expr_no_commas ']'
1141 { set_init_index ($2, NULL_TREE); }
1147 pedwarn ("ANSI C forbids nested functions");
1149 push_function_context ();
1150 if (! start_function (current_declspecs, $1,
1151 prefix_attributes, NULL_TREE, 1))
1153 pop_function_context ();
1156 reinit_parse_for_function (); }
1157 old_style_parm_decls
1158 { store_parm_decls (); }
1159 /* This used to use compstmt_or_error.
1160 That caused a bug with input `f(g) int g {}',
1161 where the use of YYERROR1 above caused an error
1162 which then was handled by compstmt_or_error.
1163 There followed a repeated execution of that same rule,
1164 which called YYERROR1 again, and so on. */
1166 { finish_function (1);
1167 pop_function_context (); }
1170 notype_nested_function:
1173 pedwarn ("ANSI C forbids nested functions");
1175 push_function_context ();
1176 if (! start_function (current_declspecs, $1,
1177 prefix_attributes, NULL_TREE, 1))
1179 pop_function_context ();
1182 reinit_parse_for_function (); }
1183 old_style_parm_decls
1184 { store_parm_decls (); }
1185 /* This used to use compstmt_or_error.
1186 That caused a bug with input `f(g) int g {}',
1187 where the use of YYERROR1 above caused an error
1188 which then was handled by compstmt_or_error.
1189 There followed a repeated execution of that same rule,
1190 which called YYERROR1 again, and so on. */
1192 { finish_function (1);
1193 pop_function_context (); }
1196 /* Any kind of declarator (thus, all declarators allowed
1197 after an explicit typespec). */
1200 after_type_declarator
1204 /* A declarator that is allowed only after an explicit typespec. */
1206 after_type_declarator:
1207 '(' after_type_declarator ')'
1209 | after_type_declarator '(' parmlist_or_identifiers %prec '.'
1210 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1211 /* | after_type_declarator '(' error ')' %prec '.'
1212 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1213 poplevel (0, 0, 0); } */
1214 | after_type_declarator '[' expr ']' %prec '.'
1215 { $$ = build_nt (ARRAY_REF, $1, $3); }
1216 | after_type_declarator '[' ']' %prec '.'
1217 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1218 | '*' type_quals after_type_declarator %prec UNARY
1219 { $$ = make_pointer_declarator ($2, $3); }
1220 /* ??? Yuck. setattrs is a quick hack. We can't use
1221 prefix_attributes because $1 only applies to this
1222 declarator. We assume setspecs has already been done.
1223 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1224 attributes could be recognized here or in `attributes'). */
1225 | attributes setattrs after_type_declarator
1230 /* Kinds of declarator that can appear in a parameter list
1231 in addition to notype_declarator. This is like after_type_declarator
1232 but does not allow a typedef name in parentheses as an identifier
1233 (because it would conflict with a function with that typedef as arg). */
1236 parm_declarator '(' parmlist_or_identifiers %prec '.'
1237 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1238 /* | parm_declarator '(' error ')' %prec '.'
1239 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1240 poplevel (0, 0, 0); } */
1241 | parm_declarator '[' '*' ']' %prec '.'
1242 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE);
1244 error ("`[*]' in parameter declaration only allowed in ISO C 9x");
1246 | parm_declarator '[' expr ']' %prec '.'
1247 { $$ = build_nt (ARRAY_REF, $1, $3); }
1248 | parm_declarator '[' ']' %prec '.'
1249 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1250 | '*' type_quals parm_declarator %prec UNARY
1251 { $$ = make_pointer_declarator ($2, $3); }
1252 /* ??? Yuck. setattrs is a quick hack. We can't use
1253 prefix_attributes because $1 only applies to this
1254 declarator. We assume setspecs has already been done.
1255 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1256 attributes could be recognized here or in `attributes'). */
1257 | attributes setattrs parm_declarator
1262 /* A declarator allowed whether or not there has been
1263 an explicit typespec. These cannot redeclare a typedef-name. */
1266 notype_declarator '(' parmlist_or_identifiers %prec '.'
1267 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1268 /* | notype_declarator '(' error ')' %prec '.'
1269 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1270 poplevel (0, 0, 0); } */
1271 | '(' notype_declarator ')'
1273 | '*' type_quals notype_declarator %prec UNARY
1274 { $$ = make_pointer_declarator ($2, $3); }
1275 | notype_declarator '[' '*' ']' %prec '.'
1276 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE);
1278 error ("`[*]' in parameter declaration only allowed in ISO C 9x");
1280 | notype_declarator '[' expr ']' %prec '.'
1281 { $$ = build_nt (ARRAY_REF, $1, $3); }
1282 | notype_declarator '[' ']' %prec '.'
1283 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1284 /* ??? Yuck. setattrs is a quick hack. We can't use
1285 prefix_attributes because $1 only applies to this
1286 declarator. We assume setspecs has already been done.
1287 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1288 attributes could be recognized here or in `attributes'). */
1289 | attributes setattrs notype_declarator
1316 struct_head identifier '{'
1317 { $$ = start_struct (RECORD_TYPE, $2);
1318 /* Start scope of tag before parsing components. */
1320 component_decl_list '}' maybe_attribute
1321 { $$ = finish_struct ($<ttype>4, $5, chainon ($1, $7)); }
1322 | struct_head '{' component_decl_list '}' maybe_attribute
1323 { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
1324 $3, chainon ($1, $5));
1326 | struct_head identifier
1327 { $$ = xref_tag (RECORD_TYPE, $2); }
1328 | union_head identifier '{'
1329 { $$ = start_struct (UNION_TYPE, $2); }
1330 component_decl_list '}' maybe_attribute
1331 { $$ = finish_struct ($<ttype>4, $5, chainon ($1, $7)); }
1332 | union_head '{' component_decl_list '}' maybe_attribute
1333 { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
1334 $3, chainon ($1, $5));
1336 | union_head identifier
1337 { $$ = xref_tag (UNION_TYPE, $2); }
1338 | enum_head identifier '{'
1339 { $<itype>3 = suspend_momentary ();
1340 $$ = start_enum ($2); }
1341 enumlist maybecomma_warn '}' maybe_attribute
1342 { $$= finish_enum ($<ttype>4, nreverse ($5), chainon ($1, $8));
1343 resume_momentary ($<itype>3); }
1345 { $<itype>2 = suspend_momentary ();
1346 $$ = start_enum (NULL_TREE); }
1347 enumlist maybecomma_warn '}' maybe_attribute
1348 { $$= finish_enum ($<ttype>3, nreverse ($4), chainon ($1, $7));
1349 resume_momentary ($<itype>2); }
1350 | enum_head identifier
1351 { $$ = xref_tag (ENUMERAL_TYPE, $2); }
1362 { if (pedantic && ! flag_isoc9x)
1363 pedwarn ("comma at end of enumerator list"); }
1366 component_decl_list:
1367 component_decl_list2
1369 | component_decl_list2 component_decl
1370 { $$ = chainon ($1, $2);
1371 pedwarn ("no semicolon at end of struct or union"); }
1374 component_decl_list2: /* empty */
1376 | component_decl_list2 component_decl ';'
1377 { $$ = chainon ($1, $2); }
1378 | component_decl_list2 ';'
1380 pedwarn ("extra semicolon in struct or union specified"); }
1383 /* There is a shift-reduce conflict here, because `components' may
1384 start with a `typename'. It happens that shifting (the default resolution)
1385 does the right thing, because it treats the `typename' as part of
1386 a `typed_typespecs'.
1388 It is possible that this same technique would allow the distinction
1389 between `notype_initdecls' and `initdecls' to be eliminated.
1390 But I am being cautious and not trying it. */
1393 typed_typespecs setspecs components
1395 current_declspecs = TREE_VALUE (declspec_stack);
1396 prefix_attributes = TREE_PURPOSE (declspec_stack);
1397 declspec_stack = TREE_CHAIN (declspec_stack);
1398 resume_momentary ($2); }
1401 pedwarn ("ANSI C forbids member declarations with no members");
1404 | nonempty_type_quals setspecs components
1406 current_declspecs = TREE_VALUE (declspec_stack);
1407 prefix_attributes = TREE_PURPOSE (declspec_stack);
1408 declspec_stack = TREE_CHAIN (declspec_stack);
1409 resume_momentary ($2); }
1410 | nonempty_type_quals
1412 pedwarn ("ANSI C forbids member declarations with no members");
1417 | extension component_decl
1419 pedantic = $<itype>1; }
1423 component_declarator
1424 | components ',' component_declarator
1425 { $$ = chainon ($1, $3); }
1428 component_declarator:
1429 save_filename save_lineno declarator maybe_attribute
1430 { $$ = grokfield ($1, $2, $3, current_declspecs, NULL_TREE);
1431 decl_attributes ($$, $4, prefix_attributes); }
1432 | save_filename save_lineno
1433 declarator ':' expr_no_commas maybe_attribute
1434 { $$ = grokfield ($1, $2, $3, current_declspecs, $5);
1435 decl_attributes ($$, $6, prefix_attributes); }
1436 | save_filename save_lineno ':' expr_no_commas maybe_attribute
1437 { $$ = grokfield ($1, $2, NULL_TREE, current_declspecs, $4);
1438 decl_attributes ($$, $5, prefix_attributes); }
1441 /* We chain the enumerators in reverse order.
1442 They are put in forward order where enumlist is used.
1443 (The order used to be significant, but no longer is so.
1444 However, we still maintain the order, just to be clean.) */
1448 | enumlist ',' enumerator
1449 { if ($1 == error_mark_node)
1452 $$ = chainon ($3, $1); }
1454 { $$ = error_mark_node; }
1460 { $$ = build_enumerator ($1, NULL_TREE); }
1461 | identifier '=' expr_no_commas
1462 { $$ = build_enumerator ($1, $3); }
1466 typed_typespecs absdcl
1467 { $$ = build_tree_list ($1, $2); }
1468 | nonempty_type_quals absdcl
1469 { $$ = build_tree_list ($1, $2); }
1472 absdcl: /* an absolute declarator */
1478 nonempty_type_quals:
1480 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
1481 | nonempty_type_quals TYPE_QUAL
1482 { $$ = tree_cons (NULL_TREE, $2, $1); }
1488 | type_quals TYPE_QUAL
1489 { $$ = tree_cons (NULL_TREE, $2, $1); }
1492 absdcl1: /* a nonempty absolute declarator */
1495 /* `(typedef)1' is `int'. */
1496 | '*' type_quals absdcl1 %prec UNARY
1497 { $$ = make_pointer_declarator ($2, $3); }
1498 | '*' type_quals %prec UNARY
1499 { $$ = make_pointer_declarator ($2, NULL_TREE); }
1500 | absdcl1 '(' parmlist %prec '.'
1501 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1502 | absdcl1 '[' expr ']' %prec '.'
1503 { $$ = build_nt (ARRAY_REF, $1, $3); }
1504 | absdcl1 '[' ']' %prec '.'
1505 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1506 | '(' parmlist %prec '.'
1507 { $$ = build_nt (CALL_EXPR, NULL_TREE, $2, NULL_TREE); }
1508 | '[' expr ']' %prec '.'
1509 { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
1511 { $$ = build_nt (ARRAY_REF, NULL_TREE, NULL_TREE); }
1512 /* ??? It appears we have to support attributes here, however
1513 using prefix_attributes is wrong. */
1514 | attributes setattrs absdcl1
1518 /* at least one statement, the first of which parses without error. */
1519 /* stmts is used only after decls, so an invalid first statement
1520 is actually regarded as an invalid decl and part of the decls. */
1523 lineno_stmt_or_labels
1526 pedwarn ("ANSI C forbids label at end of compound statement");
1530 lineno_stmt_or_labels:
1531 lineno_stmt_or_label
1532 | lineno_stmt_or_labels lineno_stmt_or_label
1534 | lineno_stmt_or_labels errstmt
1546 pushlevel: /* empty */
1547 { emit_line_note (input_filename, lineno);
1551 expand_start_bindings (0);
1555 /* Read zero or more forward-declarations for labels
1556 that nested functions can jump to. */
1561 pedwarn ("ANSI C forbids label declarations"); }
1566 | label_decls label_decl
1570 LABEL identifiers_or_typenames ';'
1572 for (link = $2; link; link = TREE_CHAIN (link))
1574 tree label = shadow_label (TREE_VALUE (link));
1575 C_DECLARED_LABEL_FLAG (label) = 1;
1576 declare_nonlocal_label (label);
1581 /* This is the body of a function definition.
1582 It causes syntax errors to ignore to the next openbrace. */
1589 compstmt_start: '{' { compstmt_count++; }
1591 compstmt_nostart: '}'
1592 { $$ = convert (void_type_node, integer_zero_node); }
1593 | pushlevel maybe_label_decls decls xstmts '}'
1594 { emit_line_note (input_filename, lineno);
1595 expand_end_bindings (getdecls (), 1, 0);
1596 $$ = poplevel (1, 1, 0);
1597 if (yychar == CONSTANT || yychar == STRING)
1598 pop_momentary_nofree ();
1601 | pushlevel maybe_label_decls error '}'
1602 { emit_line_note (input_filename, lineno);
1603 expand_end_bindings (getdecls (), kept_level_p (), 0);
1604 $$ = poplevel (kept_level_p (), 0, 0);
1605 if (yychar == CONSTANT || yychar == STRING)
1606 pop_momentary_nofree ();
1609 | pushlevel maybe_label_decls stmts '}'
1610 { emit_line_note (input_filename, lineno);
1611 expand_end_bindings (getdecls (), kept_level_p (), 0);
1612 $$ = poplevel (kept_level_p (), 0, 0);
1613 if (yychar == CONSTANT || yychar == STRING)
1614 pop_momentary_nofree ();
1619 compstmt_primary_start:
1621 { if (current_function_decl == 0)
1623 error ("braced-group within expression allowed only inside a function");
1626 /* We must force a BLOCK for this level
1627 so that, if it is not expanded later,
1628 there is a way to turn off the entire subtree of blocks
1629 that are contained in it. */
1631 push_iterator_stack ();
1632 push_label_level ();
1633 $$ = expand_start_stmt_expr ();
1637 compstmt: compstmt_start compstmt_nostart
1641 /* Value is number of statements counted as of the closeparen. */
1643 if_prefix lineno_labeled_stmt
1644 /* Make sure c_expand_end_cond is run once
1645 for each call to c_expand_start_cond.
1646 Otherwise a crash is likely. */
1652 { emit_line_note ($<filename>-1, $<lineno>0);
1653 c_expand_start_cond (truthvalue_conversion ($3), 0,
1655 $<itype>$ = stmt_count;
1656 if_stmt_file = $<filename>-1;
1657 if_stmt_line = $<lineno>0;
1658 position_after_white_space (); }
1661 /* This is a subroutine of stmt.
1662 It is used twice, once for valid DO statements
1663 and once for catching errors in parsing the end test. */
1668 emit_line_note ($<filename>-1, $<lineno>0);
1669 /* See comment in `while' alternative, above. */
1671 expand_start_loop_continue_elsewhere (1);
1672 position_after_white_space (); }
1673 lineno_labeled_stmt WHILE
1674 { expand_loop_continue_here (); }
1678 { $$ = input_filename; }
1685 lineno_labeled_stmt:
1686 save_filename save_lineno stmt
1688 /* | save_filename save_lineno error
1691 | save_filename save_lineno label lineno_labeled_stmt
1695 lineno_stmt_or_label:
1696 save_filename save_lineno stmt_or_label
1707 /* Parse a single real statement, not including any labels. */
1714 emit_line_note ($<filename>-1, $<lineno>0);
1715 /* It appears that this should not be done--that a non-lvalue array
1716 shouldn't get an error if the value isn't used.
1717 Section 3.2.2.1 says that an array lvalue gets converted to a pointer
1718 if it appears as a top-level expression,
1719 but says nothing about non-lvalue arrays. */
1721 /* Call default_conversion to get an error
1722 on referring to a register array if pedantic. */
1723 if (TREE_CODE (TREE_TYPE ($1)) == ARRAY_TYPE
1724 || TREE_CODE (TREE_TYPE ($1)) == FUNCTION_TYPE)
1725 $1 = default_conversion ($1);
1727 iterator_expand ($1);
1728 clear_momentary (); }
1730 { c_expand_start_else ();
1731 $<itype>1 = stmt_count;
1732 position_after_white_space (); }
1734 { c_expand_end_cond ();
1735 if (extra_warnings && stmt_count == $<itype>1)
1736 warning ("empty body in an else-statement"); }
1737 | simple_if %prec IF
1738 { c_expand_end_cond ();
1739 /* This warning is here instead of in simple_if, because we
1740 do not want a warning if an empty if is followed by an
1741 else statement. Increment stmt_count so we don't
1742 give a second error if this is a nested `if'. */
1743 if (extra_warnings && stmt_count++ == $<itype>1)
1744 warning_with_file_and_line (if_stmt_file, if_stmt_line,
1745 "empty body in an if-statement"); }
1746 /* Make sure c_expand_end_cond is run once
1747 for each call to c_expand_start_cond.
1748 Otherwise a crash is likely. */
1749 | simple_if ELSE error
1750 { c_expand_end_cond (); }
1753 emit_line_note ($<filename>-1, $<lineno>0);
1754 /* The emit_nop used to come before emit_line_note,
1755 but that made the nop seem like part of the preceding line.
1756 And that was confusing when the preceding line was
1757 inside of an if statement and was not really executed.
1758 I think it ought to work to put the nop after the line number.
1759 We will see. --rms, July 15, 1991. */
1762 { /* Don't start the loop till we have succeeded
1763 in parsing the end test. This is to make sure
1764 that we end every loop we start. */
1765 expand_start_loop (1);
1766 emit_line_note (input_filename, lineno);
1767 expand_exit_loop_if_false (NULL_PTR,
1768 truthvalue_conversion ($4));
1769 position_after_white_space (); }
1771 { expand_end_loop (); }
1774 { emit_line_note (input_filename, lineno);
1775 expand_exit_loop_if_false (NULL_PTR,
1776 truthvalue_conversion ($3));
1778 clear_momentary (); }
1779 /* This rule is needed to make sure we end every loop we start. */
1780 | do_stmt_start error
1781 { expand_end_loop ();
1782 clear_momentary (); }
1786 emit_line_note ($<filename>-1, $<lineno>0);
1787 /* See comment in `while' alternative, above. */
1789 if ($3) c_expand_expr_stmt ($3);
1790 /* Next step is to call expand_start_loop_continue_elsewhere,
1791 but wait till after we parse the entire for (...).
1792 Otherwise, invalid input might cause us to call that
1793 fn without calling expand_end_loop. */
1796 /* Can't emit now; wait till after expand_start_loop... */
1797 { $<lineno>7 = lineno;
1798 $<filename>$ = input_filename; }
1801 /* Start the loop. Doing this after parsing
1802 all the expressions ensures we will end the loop. */
1803 expand_start_loop_continue_elsewhere (1);
1804 /* Emit the end-test, with a line number. */
1805 emit_line_note ($<filename>8, $<lineno>7);
1807 expand_exit_loop_if_false (NULL_PTR,
1808 truthvalue_conversion ($6));
1809 /* Don't let the tree nodes for $9 be discarded by
1810 clear_momentary during the parsing of the next stmt. */
1812 $<lineno>7 = lineno;
1813 $<filename>8 = input_filename;
1814 position_after_white_space (); }
1816 { /* Emit the increment expression, with a line number. */
1817 emit_line_note ($<filename>8, $<lineno>7);
1818 expand_loop_continue_here ();
1820 c_expand_expr_stmt ($9);
1821 if (yychar == CONSTANT || yychar == STRING)
1822 pop_momentary_nofree ();
1825 expand_end_loop (); }
1826 | SWITCH '(' expr ')'
1828 emit_line_note ($<filename>-1, $<lineno>0);
1829 c_expand_start_case ($3);
1830 /* Don't let the tree nodes for $3 be discarded by
1831 clear_momentary during the parsing of the next stmt. */
1833 position_after_white_space (); }
1835 { expand_end_case ($3);
1836 if (yychar == CONSTANT || yychar == STRING)
1837 pop_momentary_nofree ();
1842 emit_line_note ($<filename>-1, $<lineno>0);
1843 if ( ! expand_exit_something ())
1844 error ("break statement not within loop or switch"); }
1847 emit_line_note ($<filename>-1, $<lineno>0);
1848 if (! expand_continue_loop (NULL_PTR))
1849 error ("continue statement not within a loop"); }
1852 emit_line_note ($<filename>-1, $<lineno>0);
1853 c_expand_return (NULL_TREE); }
1856 emit_line_note ($<filename>-1, $<lineno>0);
1857 c_expand_return ($2); }
1858 | ASM_KEYWORD maybe_type_qual '(' expr ')' ';'
1860 emit_line_note ($<filename>-1, $<lineno>0);
1862 if ((TREE_CODE ($4) == ADDR_EXPR
1863 && TREE_CODE (TREE_OPERAND ($4, 0)) == STRING_CST)
1864 || TREE_CODE ($4) == STRING_CST)
1867 error ("argument of `asm' is not a constant string"); }
1868 /* This is the case with just output operands. */
1869 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ')' ';'
1871 emit_line_note ($<filename>-1, $<lineno>0);
1872 c_expand_asm_operands ($4, $6, NULL_TREE, NULL_TREE,
1873 $2 == ridpointers[(int)RID_VOLATILE],
1874 input_filename, lineno); }
1875 /* This is the case with input operands as well. */
1876 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':' asm_operands ')' ';'
1878 emit_line_note ($<filename>-1, $<lineno>0);
1879 c_expand_asm_operands ($4, $6, $8, NULL_TREE,
1880 $2 == ridpointers[(int)RID_VOLATILE],
1881 input_filename, lineno); }
1882 /* This is the case with clobbered registers as well. */
1883 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':'
1884 asm_operands ':' asm_clobbers ')' ';'
1886 emit_line_note ($<filename>-1, $<lineno>0);
1887 c_expand_asm_operands ($4, $6, $8, $10,
1888 $2 == ridpointers[(int)RID_VOLATILE],
1889 input_filename, lineno); }
1890 | GOTO identifier ';'
1893 emit_line_note ($<filename>-1, $<lineno>0);
1894 decl = lookup_label ($2);
1897 TREE_USED (decl) = 1;
1903 pedwarn ("ANSI C forbids `goto *expr;'");
1905 emit_line_note ($<filename>-1, $<lineno>0);
1906 expand_computed_goto (convert (ptr_type_node, $3)); }
1911 all_iter_stmt_simple
1912 /* | all_iter_stmt_with_decl */
1915 all_iter_stmt_simple:
1918 /* The value returned by this action is */
1919 /* 1 if everything is OK */
1920 /* 0 in case of error or already bound iterator */
1923 if (TREE_CODE ($3) != VAR_DECL)
1924 error ("invalid `for (ITERATOR)' syntax");
1925 else if (! ITERATOR_P ($3))
1926 error ("`%s' is not an iterator",
1927 IDENTIFIER_POINTER (DECL_NAME ($3)));
1928 else if (ITERATOR_BOUND_P ($3))
1929 error ("`for (%s)' inside expansion of same iterator",
1930 IDENTIFIER_POINTER (DECL_NAME ($3)));
1934 iterator_for_loop_start ($3);
1940 iterator_for_loop_end ($3);
1943 /* This really should allow any kind of declaration,
1944 for generality. Fix it before turning it back on.
1946 all_iter_stmt_with_decl:
1947 FOR '(' ITERATOR pushlevel setspecs iterator_spec ')'
1949 */ /* The value returned by this action is */
1950 /* 1 if everything is OK */
1951 /* 0 in case of error or already bound iterator */
1953 iterator_for_loop_start ($6);
1957 iterator_for_loop_end ($6);
1958 emit_line_note (input_filename, lineno);
1959 expand_end_bindings (getdecls (), 1, 0);
1960 $<ttype>$ = poplevel (1, 1, 0);
1961 if (yychar == CONSTANT || yychar == STRING)
1962 pop_momentary_nofree ();
1968 /* Any kind of label, including jump labels and case labels.
1969 ANSI C accepts labels only before statements, but we allow them
1970 also at the end of a compound statement. */
1972 label: CASE expr_no_commas ':'
1973 { register tree value = check_case_value ($2);
1975 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
1979 if (value != error_mark_node)
1984 if (pedantic && ! INTEGRAL_TYPE_P (TREE_TYPE (value)))
1985 pedwarn ("label must have integral type in ANSI C");
1987 success = pushcase (value, convert_and_check,
1991 error ("case label not within a switch statement");
1992 else if (success == 2)
1994 error ("duplicate case value");
1995 error_with_decl (duplicate, "this is the first entry for that value");
1997 else if (success == 3)
1998 warning ("case value out of range");
1999 else if (success == 5)
2000 error ("case label within scope of cleanup or variable array");
2002 position_after_white_space (); }
2003 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
2004 { register tree value1 = check_case_value ($2);
2005 register tree value2 = check_case_value ($4);
2007 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
2010 pedwarn ("ANSI C forbids case ranges");
2013 if (value1 != error_mark_node && value2 != error_mark_node)
2016 int success = pushcase_range (value1, value2,
2017 convert_and_check, label,
2020 error ("case label not within a switch statement");
2021 else if (success == 2)
2023 error ("duplicate case value");
2024 error_with_decl (duplicate, "this is the first entry for that value");
2026 else if (success == 3)
2027 warning ("case value out of range");
2028 else if (success == 4)
2029 warning ("empty case range");
2030 else if (success == 5)
2031 error ("case label within scope of cleanup or variable array");
2033 position_after_white_space (); }
2038 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
2039 int success = pushcase (NULL_TREE, 0, label, &duplicate);
2042 error ("default label not within a switch statement");
2043 else if (success == 2)
2045 error ("multiple default labels in one switch");
2046 error_with_decl (duplicate, "this is the first default label");
2048 position_after_white_space (); }
2049 | identifier ':' maybe_attribute
2050 { tree label = define_label (input_filename, lineno, $1);
2055 expand_label (label);
2056 decl_attributes (label, $3, NULL_TREE);
2058 position_after_white_space (); }
2061 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
2065 { emit_line_note (input_filename, lineno);
2068 { emit_line_note (input_filename, lineno); }
2077 /* These are the operands other than the first string and colon
2078 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
2079 asm_operands: /* empty */
2081 | nonnull_asm_operands
2084 nonnull_asm_operands:
2086 | nonnull_asm_operands ',' asm_operand
2087 { $$ = chainon ($1, $3); }
2092 { $$ = build_tree_list ($1, $3); }
2097 { $$ = tree_cons (NULL_TREE, combine_strings ($1), NULL_TREE); }
2098 | asm_clobbers ',' string
2099 { $$ = tree_cons (NULL_TREE, combine_strings ($3), $1); }
2102 /* This is what appears inside the parens in a function declarator.
2103 Its value is a list of ..._TYPE nodes. */
2106 clear_parm_order ();
2107 declare_parm_level (0); }
2110 parmlist_tags_warning ();
2111 poplevel (0, 0, 0); }
2119 pedwarn ("ANSI C forbids forward parameter declarations");
2120 /* Mark the forward decls as such. */
2121 for (parm = getdecls (); parm; parm = TREE_CHAIN (parm))
2122 TREE_ASM_WRITTEN (parm) = 1;
2123 clear_parm_order (); }
2127 { $$ = tree_cons (NULL_TREE, NULL_TREE, NULL_TREE); }
2130 /* This is what appears inside the parens in a function declarator.
2131 Is value is represented in the format that grokdeclarator expects. */
2132 parmlist_2: /* empty */
2133 { $$ = get_parm_info (0); }
2135 { $$ = get_parm_info (0);
2136 /* Gcc used to allow this as an extension. However, it does
2137 not work for all targets, and thus has been disabled.
2138 Also, since func (...) and func () are indistinguishable,
2139 it caused problems with the code in expand_builtin which
2140 tries to verify that BUILT_IN_NEXT_ARG is being used
2142 error ("ANSI C requires a named argument before `...'");
2145 { $$ = get_parm_info (1); }
2146 | parms ',' ELLIPSIS
2147 { $$ = get_parm_info (0); }
2152 { push_parm_decl ($1); }
2154 { push_parm_decl ($3); }
2157 /* A single parameter declaration or parameter type name,
2158 as found in a parmlist. */
2160 typed_declspecs setspecs parm_declarator maybe_attribute
2161 { $$ = build_tree_list (build_tree_list (current_declspecs,
2163 build_tree_list (prefix_attributes,
2165 current_declspecs = TREE_VALUE (declspec_stack);
2166 prefix_attributes = TREE_PURPOSE (declspec_stack);
2167 declspec_stack = TREE_CHAIN (declspec_stack);
2168 resume_momentary ($2); }
2169 | typed_declspecs setspecs notype_declarator maybe_attribute
2170 { $$ = build_tree_list (build_tree_list (current_declspecs,
2172 build_tree_list (prefix_attributes,
2174 current_declspecs = TREE_VALUE (declspec_stack);
2175 prefix_attributes = TREE_PURPOSE (declspec_stack);
2176 declspec_stack = TREE_CHAIN (declspec_stack);
2177 resume_momentary ($2); }
2178 | typed_declspecs setspecs absdcl maybe_attribute
2179 { $$ = build_tree_list (build_tree_list (current_declspecs,
2181 build_tree_list (prefix_attributes,
2183 current_declspecs = TREE_VALUE (declspec_stack);
2184 prefix_attributes = TREE_PURPOSE (declspec_stack);
2185 declspec_stack = TREE_CHAIN (declspec_stack);
2186 resume_momentary ($2); }
2187 | declmods setspecs notype_declarator maybe_attribute
2188 { $$ = build_tree_list (build_tree_list (current_declspecs,
2190 build_tree_list (prefix_attributes,
2192 current_declspecs = TREE_VALUE (declspec_stack);
2193 prefix_attributes = TREE_PURPOSE (declspec_stack);
2194 declspec_stack = TREE_CHAIN (declspec_stack);
2195 resume_momentary ($2); }
2197 | declmods setspecs absdcl maybe_attribute
2198 { $$ = build_tree_list (build_tree_list (current_declspecs,
2200 build_tree_list (prefix_attributes,
2202 current_declspecs = TREE_VALUE (declspec_stack);
2203 prefix_attributes = TREE_PURPOSE (declspec_stack);
2204 declspec_stack = TREE_CHAIN (declspec_stack);
2205 resume_momentary ($2); }
2208 /* This is used in a function definition
2209 where either a parmlist or an identifier list is ok.
2210 Its value is a list of ..._TYPE nodes or a list of identifiers. */
2211 parmlist_or_identifiers:
2213 clear_parm_order ();
2214 declare_parm_level (1); }
2215 parmlist_or_identifiers_1
2217 parmlist_tags_warning ();
2218 poplevel (0, 0, 0); }
2221 parmlist_or_identifiers_1:
2225 for (t = $1; t; t = TREE_CHAIN (t))
2226 if (TREE_VALUE (t) == NULL_TREE)
2227 error ("`...' in old-style identifier list");
2228 $$ = tree_cons (NULL_TREE, NULL_TREE, $1); }
2231 /* A nonempty list of identifiers. */
2234 { $$ = build_tree_list (NULL_TREE, $1); }
2235 | identifiers ',' IDENTIFIER
2236 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2239 /* A nonempty list of identifiers, including typenames. */
2240 identifiers_or_typenames:
2242 { $$ = build_tree_list (NULL_TREE, $1); }
2243 | identifiers_or_typenames ',' identifier
2244 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2249 { $<itype>$ = pedantic;