1 /* YACC parser for C syntax and for Objective C. -*-c-*-
2 Copyright (C) 1987, 88, 89, 92, 93, 94, 1995 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 /* This file defines the grammar of C and that of Objective C.
22 ifobjc ... end ifobjc conditionals contain code for Objective C only.
23 ifc ... end ifc conditionals contain code for C only.
24 Sed commands in Makefile.in are used to convert this file into
25 c-parse.y and into objc-parse.y. */
27 /* To whomever it may concern: I have heard that such a thing was once
28 written by AT&T, but I have never seen it. */
36 /* These are the 23 conflicts you should get in parse.output;
37 the state numbers may vary if minor changes in the grammar are made.
39 State 42 contains 1 shift/reduce conflict. (Two ways to parse ATTRIBUTE.)
40 State 44 contains 1 shift/reduce conflict. (Two ways to recover from error.)
41 State 103 contains 1 shift/reduce conflict. (Two ways to recover from error.)
42 State 110 contains 1 shift/reduce conflict. (Two ways to parse ATTRIBUTE.)
43 State 111 contains 1 shift/reduce conflict. (Two ways to recover from error.)
44 State 115 contains 1 shift/reduce conflict. (Two ways to recover from error.)
45 State 132 contains 1 shift/reduce conflict. (See comment at component_decl.)
46 State 180 contains 1 shift/reduce conflict. (Two ways to parse ATTRIBUTE.)
47 State 194 contains 2 shift/reduce conflict. (Four ways to parse this.)
48 State 202 contains 1 shift/reduce conflict. (Two ways to recover from error.)
49 State 214 contains 1 shift/reduce conflict. (Two ways to recover from error.)
50 State 220 contains 1 shift/reduce conflict. (Two ways to recover from error.)
51 State 304 contains 2 shift/reduce conflicts. (Four ways to parse this.)
52 State 335 contains 2 shift/reduce conflicts. (Four ways to parse this.)
53 State 347 contains 1 shift/reduce conflict. (Two ways to parse ATTRIBUTES.)
54 State 352 contains 1 shift/reduce conflict. (Two ways to parse ATTRIBUTES.)
55 State 383 contains 2 shift/reduce conflicts. (Four ways to parse this.)
56 State 434 contains 2 shift/reduce conflicts. (Four ways to parse this.) */
72 #ifdef MULTIBYTE_CHARS
81 /* Since parsers are distinct for each language, put the language string
84 char *language_string = "GNU Obj-C";
87 char *language_string = "GNU C";
96 /* Like YYERROR but do call yyerror. */
97 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
99 /* Cause the `yydebug' variable to be defined. */
105 %union {long itype; tree ttype; enum tree_code code;
106 char *filename; int lineno; }
108 /* All identifiers that are not reserved words
109 and are not declared typedefs in the current block */
112 /* All identifiers that are declared typedefs in the current block.
113 In some contexts, they are treated just like IDENTIFIER,
114 but they can also serve as typespecs in declarations. */
117 /* Reserved words that specify storage class.
118 yylval contains an IDENTIFIER_NODE which indicates which one. */
121 /* Reserved words that specify type.
122 yylval contains an IDENTIFIER_NODE which indicates which one. */
125 /* Reserved words that qualify type: "const" or "volatile".
126 yylval contains an IDENTIFIER_NODE which indicates which one. */
129 /* Character or numeric constants.
130 yylval is the node for the constant. */
133 /* String constants in raw form.
134 yylval is a STRING_CST node. */
137 /* "...", used for functions with variable arglists. */
140 /* the reserved words */
141 /* SCO include files test "ASM", so use something else. */
142 %token SIZEOF ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
143 %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD TYPEOF ALIGNOF
144 %token ATTRIBUTE EXTENSION LABEL
145 %token REALPART IMAGPART
147 /* Add precedence rules to solve dangling else s/r conflict */
151 /* Define the operator tokens and their precedences.
152 The value is an integer because, if used, it is the tree code
153 to use in the expression made from the operator. */
155 %right <code> ASSIGN '='
156 %right <code> '?' ':'
162 %left <code> EQCOMPARE
163 %left <code> ARITHCOMPARE
164 %left <code> LSHIFT RSHIFT
166 %left <code> '*' '/' '%'
167 %right <code> UNARY PLUSPLUS MINUSMINUS
169 %left <code> POINTSAT '.' '(' '['
171 /* The Objective-C keywords. These are included in C and in
172 Objective C, so that the token codes are the same in both. */
173 %token INTERFACE IMPLEMENTATION END SELECTOR DEFS ENCODE
174 %token CLASSNAME PUBLIC PRIVATE PROTECTED PROTOCOL OBJECTNAME CLASS ALIAS
176 /* Objective-C string constants in raw form.
177 yylval is an OBJC_STRING_CST node. */
183 %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist exprlist
184 %type <ttype> expr_no_commas cast_expr unary_expr primary string STRING
185 %type <ttype> typed_declspecs reserved_declspecs
186 %type <ttype> typed_typespecs reserved_typespecquals
187 %type <ttype> declmods typespec typespecqual_reserved
188 %type <ttype> SCSPEC TYPESPEC TYPE_QUAL nonempty_type_quals maybe_type_qual
189 %type <ttype> initdecls notype_initdecls initdcl notype_initdcl
190 %type <ttype> init maybeasm
191 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
192 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
193 %type <ttype> any_word
195 %type <ttype> compstmt
197 %type <ttype> declarator
198 %type <ttype> notype_declarator after_type_declarator
199 %type <ttype> parm_declarator
201 %type <ttype> structsp component_decl_list component_decl_list2
202 %type <ttype> component_decl components component_declarator
203 %type <ttype> enumlist enumerator
204 %type <ttype> typename absdcl absdcl1 type_quals
205 %type <ttype> xexpr parms parm identifiers
207 %type <ttype> parmlist parmlist_1 parmlist_2
208 %type <ttype> parmlist_or_identifiers parmlist_or_identifiers_1
209 %type <ttype> identifiers_or_typenames
211 %type <itype> setspecs
213 %type <filename> save_filename
214 %type <lineno> save_lineno
217 /* the Objective-C nonterminals */
219 %type <ttype> ivar_decl_list ivar_decls ivar_decl ivars ivar_declarator
220 %type <ttype> methoddecl unaryselector keywordselector selector
221 %type <ttype> keyworddecl receiver objcmessageexpr messageargs
222 %type <ttype> keywordexpr keywordarglist keywordarg
223 %type <ttype> myparms myparm optparmlist reservedwords objcselectorexpr
224 %type <ttype> selectorarg keywordnamelist keywordname objcencodeexpr
225 %type <ttype> objc_string protocolrefs identifier_list objcprotocolexpr
226 %type <ttype> CLASSNAME OBJC_STRING OBJECTNAME
230 /* Number of statements (loosely speaking) seen so far. */
231 static int stmt_count;
233 /* Input file and line number of the end of the body of last simple_if;
234 used by the stmt-rule immediately after simple_if returns. */
235 static char *if_stmt_file;
236 static int if_stmt_line;
238 /* List of types and structure classes of the current declaration. */
239 static tree current_declspecs;
240 static tree prefix_attributes = NULL_TREE;
242 /* Stack of saved values of current_declspecs and prefix_attributes. */
243 static tree declspec_stack;
245 /* 1 if we explained undeclared var errors. */
246 static int undeclared_variable_notice;
249 /* Objective-C specific information */
251 tree objc_interface_context;
252 tree objc_implementation_context;
253 tree objc_method_context;
254 tree objc_ivar_chain;
255 tree objc_ivar_context;
256 enum tree_code objc_inherit_code;
257 int objc_receiver_context;
258 int objc_public_flag;
262 /* Tell yyparse how to print a token's value, if yydebug is set. */
264 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
265 extern void yyprint ();
271 pedwarn ("ANSI C forbids an empty source file");
276 /* In case there were missing closebraces,
277 get us back to the global binding level. */
278 while (! global_bindings_p ())
284 /* the reason for the strange actions in this rule
285 is so that notype_initdecls when reached via datadef
286 can find a valid list of type and sc specs in $0. */
289 {$<ttype>$ = NULL_TREE; } extdef
290 | extdefs {$<ttype>$ = NULL_TREE; } extdef
299 | ASM_KEYWORD '(' expr ')' ';'
301 if ((TREE_CODE ($3) == ADDR_EXPR
302 && TREE_CODE (TREE_OPERAND ($3, 0)) == STRING_CST)
303 || TREE_CODE ($3) == STRING_CST)
306 error ("argument of `asm' is not a constant string"); }
310 setspecs notype_initdecls ';'
312 error ("ANSI C forbids data definition with no type or storage class");
313 else if (!flag_traditional)
314 warning ("data definition has no type or storage class");
316 current_declspecs = TREE_VALUE (declspec_stack);
317 prefix_attributes = TREE_PURPOSE (declspec_stack);
318 declspec_stack = TREE_CHAIN (declspec_stack);
319 resume_momentary ($1); }
320 | declmods setspecs notype_initdecls ';'
321 { current_declspecs = TREE_VALUE (declspec_stack);
322 prefix_attributes = TREE_PURPOSE (declspec_stack);
323 declspec_stack = TREE_CHAIN (declspec_stack);
324 resume_momentary ($2); }
325 | typed_declspecs setspecs initdecls ';'
326 { current_declspecs = TREE_VALUE (declspec_stack);
327 prefix_attributes = TREE_PURPOSE (declspec_stack);
328 declspec_stack = TREE_CHAIN (declspec_stack);
329 resume_momentary ($2); }
331 { pedwarn ("empty declaration"); }
332 | typed_declspecs ';'
338 pedwarn ("ANSI C does not allow extra `;' outside of a function"); }
342 typed_declspecs setspecs declarator
343 { if (! start_function ($1, $3, prefix_attributes,
346 reinit_parse_for_function (); }
348 { store_parm_decls (); }
350 { finish_function (0);
351 current_declspecs = TREE_VALUE (declspec_stack);
352 prefix_attributes = TREE_PURPOSE (declspec_stack);
353 declspec_stack = TREE_CHAIN (declspec_stack);
354 resume_momentary ($2); }
355 | typed_declspecs setspecs declarator error
356 { current_declspecs = TREE_VALUE (declspec_stack);
357 prefix_attributes = TREE_PURPOSE (declspec_stack);
358 declspec_stack = TREE_CHAIN (declspec_stack);
359 resume_momentary ($2); }
360 | declmods setspecs notype_declarator
361 { if (! start_function ($1, $3, prefix_attributes,
364 reinit_parse_for_function (); }
366 { store_parm_decls (); }
368 { finish_function (0);
369 current_declspecs = TREE_VALUE (declspec_stack);
370 prefix_attributes = TREE_PURPOSE (declspec_stack);
371 declspec_stack = TREE_CHAIN (declspec_stack);
372 resume_momentary ($2); }
373 | declmods setspecs notype_declarator error
374 { current_declspecs = TREE_VALUE (declspec_stack);
375 prefix_attributes = TREE_PURPOSE (declspec_stack);
376 declspec_stack = TREE_CHAIN (declspec_stack);
377 resume_momentary ($2); }
378 | setspecs notype_declarator
379 { if (! start_function (NULL_TREE, $2,
380 prefix_attributes, NULL_TREE, 0))
382 reinit_parse_for_function (); }
384 { store_parm_decls (); }
386 { finish_function (0);
387 current_declspecs = TREE_VALUE (declspec_stack);
388 prefix_attributes = TREE_PURPOSE (declspec_stack);
389 declspec_stack = TREE_CHAIN (declspec_stack);
390 resume_momentary ($1); }
391 | setspecs notype_declarator error
392 { current_declspecs = TREE_VALUE (declspec_stack);
393 prefix_attributes = TREE_PURPOSE (declspec_stack);
394 declspec_stack = TREE_CHAIN (declspec_stack);
395 resume_momentary ($1); }
410 { $$ = NEGATE_EXPR; }
412 { $$ = CONVERT_EXPR; }
414 { $$ = PREINCREMENT_EXPR; }
416 { $$ = PREDECREMENT_EXPR; }
418 { $$ = BIT_NOT_EXPR; }
420 { $$ = TRUTH_NOT_EXPR; }
423 expr: nonnull_exprlist
424 { $$ = build_compound_expr ($1); }
435 { $$ = build_tree_list (NULL_TREE, $1); }
436 | nonnull_exprlist ',' expr_no_commas
437 { chainon ($1, build_tree_list (NULL_TREE, $3)); }
442 | '*' cast_expr %prec UNARY
443 { $$ = build_indirect_ref ($2, "unary *"); }
444 /* __extension__ turns off -pedantic for following primary. */
446 { $<itype>1 = pedantic;
448 cast_expr %prec UNARY
450 pedantic = $<itype>1; }
451 | unop cast_expr %prec UNARY
452 { $$ = build_unary_op ($1, $2, 0);
453 overflow_warning ($$); }
454 /* Refer to the address of a label as a pointer. */
456 { tree label = lookup_label ($2);
458 pedwarn ("ANSI C forbids `&&'");
460 $$ = null_pointer_node;
463 TREE_USED (label) = 1;
464 $$ = build1 (ADDR_EXPR, ptr_type_node, label);
465 TREE_CONSTANT ($$) = 1;
468 /* This seems to be impossible on some machines, so let's turn it off.
469 You can use __builtin_next_arg to find the anonymous stack args.
471 { tree types = TYPE_ARG_TYPES (TREE_TYPE (current_function_decl));
472 $$ = error_mark_node;
473 if (TREE_VALUE (tree_last (types)) == void_type_node)
474 error ("`&...' used in function with fixed number of arguments");
478 pedwarn ("ANSI C forbids `&...'");
479 $$ = tree_last (DECL_ARGUMENTS (current_function_decl));
480 $$ = build_unary_op (ADDR_EXPR, $$, 0);
483 | SIZEOF unary_expr %prec UNARY
484 { if (TREE_CODE ($2) == COMPONENT_REF
485 && DECL_BIT_FIELD (TREE_OPERAND ($2, 1)))
486 error ("`sizeof' applied to a bit-field");
487 $$ = c_sizeof (TREE_TYPE ($2)); }
488 | SIZEOF '(' typename ')' %prec HYPERUNARY
489 { $$ = c_sizeof (groktypename ($3)); }
490 | ALIGNOF unary_expr %prec UNARY
491 { $$ = c_alignof_expr ($2); }
492 | ALIGNOF '(' typename ')' %prec HYPERUNARY
493 { $$ = c_alignof (groktypename ($3)); }
494 | REALPART cast_expr %prec UNARY
495 { $$ = build_unary_op (REALPART_EXPR, $2, 0); }
496 | IMAGPART cast_expr %prec UNARY
497 { $$ = build_unary_op (IMAGPART_EXPR, $2, 0); }
502 | '(' typename ')' cast_expr %prec UNARY
503 { tree type = groktypename ($2);
504 $$ = build_c_cast (type, $4); }
505 | '(' typename ')' '{'
506 { start_init (NULL_TREE, NULL, 0);
507 $2 = groktypename ($2);
508 really_start_incremental_init ($2); }
509 initlist_maybe_comma '}' %prec UNARY
511 tree result = pop_init_level (0);
516 pedwarn ("ANSI C forbids constructor expressions");
517 if (TYPE_NAME (type) != 0)
519 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
520 name = IDENTIFIER_POINTER (TYPE_NAME (type));
522 name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
527 if (TREE_CODE (type) == ARRAY_TYPE && TYPE_SIZE (type) == 0)
529 int failure = complete_array_type (type, $$, 1);
538 | expr_no_commas '+' expr_no_commas
539 { $$ = parser_build_binary_op ($2, $1, $3); }
540 | expr_no_commas '-' expr_no_commas
541 { $$ = parser_build_binary_op ($2, $1, $3); }
542 | expr_no_commas '*' expr_no_commas
543 { $$ = parser_build_binary_op ($2, $1, $3); }
544 | expr_no_commas '/' expr_no_commas
545 { $$ = parser_build_binary_op ($2, $1, $3); }
546 | expr_no_commas '%' expr_no_commas
547 { $$ = parser_build_binary_op ($2, $1, $3); }
548 | expr_no_commas LSHIFT expr_no_commas
549 { $$ = parser_build_binary_op ($2, $1, $3); }
550 | expr_no_commas RSHIFT expr_no_commas
551 { $$ = parser_build_binary_op ($2, $1, $3); }
552 | expr_no_commas ARITHCOMPARE expr_no_commas
553 { $$ = parser_build_binary_op ($2, $1, $3); }
554 | expr_no_commas EQCOMPARE expr_no_commas
555 { $$ = parser_build_binary_op ($2, $1, $3); }
556 | expr_no_commas '&' expr_no_commas
557 { $$ = parser_build_binary_op ($2, $1, $3); }
558 | expr_no_commas '|' expr_no_commas
559 { $$ = parser_build_binary_op ($2, $1, $3); }
560 | expr_no_commas '^' expr_no_commas
561 { $$ = parser_build_binary_op ($2, $1, $3); }
562 | expr_no_commas ANDAND expr_no_commas
563 { $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $3); }
564 | expr_no_commas OROR expr_no_commas
565 { $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $3); }
566 | expr_no_commas '?' xexpr ':' expr_no_commas
567 { $$ = build_conditional_expr ($1, $3, $5); }
568 | expr_no_commas '=' expr_no_commas
569 { $$ = build_modify_expr ($1, NOP_EXPR, $3);
570 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
571 | expr_no_commas ASSIGN expr_no_commas
572 { $$ = build_modify_expr ($1, $2, $3);
573 /* This inhibits warnings in truthvalue_conversion. */
574 C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK); }
581 if (!$$ || $$ == error_mark_node)
583 if (yychar == YYEMPTY)
590 if (objc_receiver_context
591 && ! (objc_receiver_context
592 && strcmp (IDENTIFIER_POINTER ($1), "super")))
593 /* we have a message to super */
594 $$ = get_super_receiver ();
595 else if (objc_method_context
596 && (decl = is_ivar (objc_ivar_chain, $1)))
598 if (is_private (decl))
599 $$ = error_mark_node;
601 $$ = build_ivar_reference ($1);
606 /* Ordinary implicit function declaration. */
607 $$ = implicitly_declare ($1);
608 assemble_external ($$);
612 else if (current_function_decl == 0)
614 error ("`%s' undeclared here (not in a function)",
615 IDENTIFIER_POINTER ($1));
616 $$ = error_mark_node;
623 if (objc_receiver_context
624 && ! strcmp (IDENTIFIER_POINTER ($1), "super"))
625 /* we have a message to super */
626 $$ = get_super_receiver ();
627 else if (objc_method_context
628 && (decl = is_ivar (objc_ivar_chain, $1)))
630 if (is_private (decl))
631 $$ = error_mark_node;
633 $$ = build_ivar_reference ($1);
638 if (IDENTIFIER_GLOBAL_VALUE ($1) != error_mark_node
639 || IDENTIFIER_ERROR_LOCUS ($1) != current_function_decl)
641 error ("`%s' undeclared (first use this function)",
642 IDENTIFIER_POINTER ($1));
644 if (! undeclared_variable_notice)
646 error ("(Each undeclared identifier is reported only once");
647 error ("for each function it appears in.)");
648 undeclared_variable_notice = 1;
651 $$ = error_mark_node;
652 /* Prevent repeated error messages. */
653 IDENTIFIER_GLOBAL_VALUE ($1) = error_mark_node;
654 IDENTIFIER_ERROR_LOCUS ($1) = current_function_decl;
658 else if (TREE_TYPE ($$) == error_mark_node)
659 $$ = error_mark_node;
660 else if (C_DECL_ANTICIPATED ($$))
662 /* The first time we see a build-in function used,
663 if it has not been declared. */
664 C_DECL_ANTICIPATED ($$) = 0;
665 if (yychar == YYEMPTY)
669 /* Omit the implicit declaration we
670 would ordinarily do, so we don't lose
671 the actual built in type.
672 But print a diagnostic for the mismatch. */
674 if (objc_method_context
675 && is_ivar (objc_ivar_chain, $1))
676 error ("Instance variable `%s' implicitly declared as function",
677 IDENTIFIER_POINTER (DECL_NAME ($$)));
680 if (TREE_CODE ($$) != FUNCTION_DECL)
681 error ("`%s' implicitly declared as function",
682 IDENTIFIER_POINTER (DECL_NAME ($$)));
683 else if ((TYPE_MODE (TREE_TYPE (TREE_TYPE ($$)))
684 != TYPE_MODE (integer_type_node))
685 && (TREE_TYPE (TREE_TYPE ($$))
687 pedwarn ("type mismatch in implicit declaration for built-in function `%s'",
688 IDENTIFIER_POINTER (DECL_NAME ($$)));
689 /* If it really returns void, change that to int. */
690 if (TREE_TYPE (TREE_TYPE ($$)) == void_type_node)
692 = build_function_type (integer_type_node,
693 TYPE_ARG_TYPES (TREE_TYPE ($$)));
696 pedwarn ("built-in function `%s' used without declaration",
697 IDENTIFIER_POINTER (DECL_NAME ($$)));
699 /* Do what we would ordinarily do when a fn is used. */
700 assemble_external ($$);
705 assemble_external ($$);
708 /* we have a definition - still check if iVariable */
710 if (!objc_receiver_context
711 || (objc_receiver_context
712 && strcmp (IDENTIFIER_POINTER ($1), "super")))
716 if (objc_method_context
717 && (decl = is_ivar (objc_ivar_chain, $1)))
719 if (IDENTIFIER_LOCAL_VALUE ($1))
720 warning ("local declaration of `%s' hides instance variable",
721 IDENTIFIER_POINTER ($1));
724 if (is_private (decl))
725 $$ = error_mark_node;
727 $$ = build_ivar_reference ($1);
731 else /* we have a message to super */
732 $$ = get_super_receiver ();
736 if (TREE_CODE ($$) == CONST_DECL)
738 $$ = DECL_INITIAL ($$);
739 /* This is to prevent an enum whose value is 0
740 from being considered a null pointer constant. */
741 $$ = build1 (NOP_EXPR, TREE_TYPE ($$), $$);
742 TREE_CONSTANT ($$) = 1;
747 { $$ = combine_strings ($1); }
749 { char class = TREE_CODE_CLASS (TREE_CODE ($2));
750 if (class == 'e' || class == '1'
751 || class == '2' || class == '<')
752 C_SET_EXP_ORIGINAL_CODE ($2, ERROR_MARK);
755 { $$ = error_mark_node; }
757 { if (current_function_decl == 0)
759 error ("braced-group within expression allowed only inside a function");
762 /* We must force a BLOCK for this level
763 so that, if it is not expanded later,
764 there is a way to turn off the entire subtree of blocks
765 that are contained in it. */
767 push_iterator_stack ();
769 $<ttype>$ = expand_start_stmt_expr (); }
773 pedwarn ("ANSI C forbids braced-groups within expressions");
774 pop_iterator_stack ();
776 rtl_exp = expand_end_stmt_expr ($<ttype>2);
777 /* The statements have side effects, so the group does. */
778 TREE_SIDE_EFFECTS (rtl_exp) = 1;
780 if (TREE_CODE ($3) == BLOCK)
782 /* Make a BIND_EXPR for the BLOCK already made. */
783 $$ = build (BIND_EXPR, TREE_TYPE (rtl_exp),
784 NULL_TREE, rtl_exp, $3);
785 /* Remove the block from the tree at this point.
786 It gets put back at the proper place
787 when the BIND_EXPR is expanded. */
793 | primary '(' exprlist ')' %prec '.'
794 { $$ = build_function_call ($1, $3); }
795 | primary '[' expr ']' %prec '.'
796 { $$ = build_array_ref ($1, $3); }
797 | primary '.' identifier
800 if (doing_objc_thang)
802 if (is_public ($1, $3))
803 $$ = build_component_ref ($1, $3);
805 $$ = error_mark_node;
809 $$ = build_component_ref ($1, $3);
811 | primary POINTSAT identifier
813 tree expr = build_indirect_ref ($1, "->");
816 if (doing_objc_thang)
818 if (is_public (expr, $3))
819 $$ = build_component_ref (expr, $3);
821 $$ = error_mark_node;
825 $$ = build_component_ref (expr, $3);
828 { $$ = build_unary_op (POSTINCREMENT_EXPR, $1, 0); }
830 { $$ = build_unary_op (POSTDECREMENT_EXPR, $1, 0); }
833 { $$ = build_message_expr ($1); }
835 { $$ = build_selector_expr ($1); }
837 { $$ = build_protocol_expr ($1); }
839 { $$ = build_encode_expr ($1); }
841 { $$ = build_objc_string_object ($1); }
845 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
849 { $$ = chainon ($1, $2); }
853 /* Produces an OBJC_STRING_CST with perhaps more OBJC_STRING_CSTs chained
857 | objc_string OBJC_STRING
858 { $$ = chainon ($1, $2); }
866 /* ... is used here to indicate a varargs function. */
869 pedwarn ("ANSI C does not permit use of `varargs.h'"); }
872 /* The following are analogous to lineno_decl, decls and decl
873 except that they do not allow nested functions.
874 They are used for old-style parm decls. */
876 save_filename save_lineno datadecl
883 | datadecls lineno_datadecl
884 | lineno_datadecl errstmt
888 typed_declspecs setspecs initdecls ';'
889 { current_declspecs = TREE_VALUE (declspec_stack);
890 prefix_attributes = TREE_PURPOSE (declspec_stack);
891 declspec_stack = TREE_CHAIN (declspec_stack);
892 resume_momentary ($2); }
893 | declmods setspecs notype_initdecls ';'
894 { current_declspecs = TREE_VALUE (declspec_stack);
895 prefix_attributes = TREE_PURPOSE (declspec_stack);
896 declspec_stack = TREE_CHAIN (declspec_stack);
897 resume_momentary ($2); }
898 | typed_declspecs ';'
899 { shadow_tag_warned ($1, 1);
900 pedwarn ("empty declaration"); }
902 { pedwarn ("empty declaration"); }
905 /* This combination which saves a lineno before a decl
906 is the normal thing to use, rather than decl itself.
907 This is to avoid shift/reduce conflicts in contexts
908 where statement labels are allowed. */
910 save_filename save_lineno decl
918 | lineno_decl errstmt
921 /* records the type and storage class specs to use for processing
922 the declarators that follow.
923 Maintains a stack of outer-level values of current_declspecs,
924 for the sake of parm declarations nested in function declarators. */
925 setspecs: /* empty */
926 { $$ = suspend_momentary ();
927 pending_xref_error ();
928 declspec_stack = tree_cons (prefix_attributes,
931 current_declspecs = $<ttype>0;
932 prefix_attributes = NULL_TREE; }
935 setattrs: /* empty */
936 { prefix_attributes = chainon (prefix_attributes, $<ttype>0); }
940 typed_declspecs setspecs initdecls ';'
941 { current_declspecs = TREE_VALUE (declspec_stack);
942 prefix_attributes = TREE_PURPOSE (declspec_stack);
943 declspec_stack = TREE_CHAIN (declspec_stack);
944 resume_momentary ($2); }
945 | declmods setspecs notype_initdecls ';'
946 { current_declspecs = TREE_VALUE (declspec_stack);
947 prefix_attributes = TREE_PURPOSE (declspec_stack);
948 declspec_stack = TREE_CHAIN (declspec_stack);
949 resume_momentary ($2); }
950 | typed_declspecs setspecs nested_function
951 { current_declspecs = TREE_VALUE (declspec_stack);
952 prefix_attributes = TREE_PURPOSE (declspec_stack);
953 declspec_stack = TREE_CHAIN (declspec_stack);
954 resume_momentary ($2); }
955 | declmods setspecs notype_nested_function
956 { current_declspecs = TREE_VALUE (declspec_stack);
957 prefix_attributes = TREE_PURPOSE (declspec_stack);
958 declspec_stack = TREE_CHAIN (declspec_stack);
959 resume_momentary ($2); }
960 | typed_declspecs ';'
963 { pedwarn ("empty declaration"); }
966 /* Declspecs which contain at least one type specifier or typedef name.
967 (Just `const' or `volatile' is not enough.)
968 A typedef'd name following these is taken as a name to be declared. */
971 typespec reserved_declspecs
972 { $$ = tree_cons (NULL_TREE, $1, $2); }
973 | declmods typespec reserved_declspecs
974 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
977 reserved_declspecs: /* empty */
979 | reserved_declspecs typespecqual_reserved
980 { $$ = tree_cons (NULL_TREE, $2, $1); }
981 | reserved_declspecs SCSPEC
982 { if (extra_warnings)
983 warning ("`%s' is not at beginning of declaration",
984 IDENTIFIER_POINTER ($2));
985 $$ = tree_cons (NULL_TREE, $2, $1); }
988 /* List of just storage classes and type modifiers.
989 A declaration can start with just this, but then it cannot be used
990 to redeclare a typedef-name. */
994 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
995 TREE_STATIC ($$) = 1; }
997 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
999 { $$ = tree_cons (NULL_TREE, $2, $1);
1000 TREE_STATIC ($$) = 1; }
1002 { if (extra_warnings && TREE_STATIC ($1))
1003 warning ("`%s' is not at beginning of declaration",
1004 IDENTIFIER_POINTER ($2));
1005 $$ = tree_cons (NULL_TREE, $2, $1);
1006 TREE_STATIC ($$) = TREE_STATIC ($1); }
1010 /* Used instead of declspecs where storage classes are not allowed
1011 (that is, for typenames and structure components).
1012 Don't accept a typedef-name if anything but a modifier precedes it. */
1015 typespec reserved_typespecquals
1016 { $$ = tree_cons (NULL_TREE, $1, $2); }
1017 | nonempty_type_quals typespec reserved_typespecquals
1018 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
1021 reserved_typespecquals: /* empty */
1023 | reserved_typespecquals typespecqual_reserved
1024 { $$ = tree_cons (NULL_TREE, $2, $1); }
1027 /* A typespec (but not a type qualifier).
1028 Once we have seen one of these in a declaration,
1029 if a typedef name appears then it is being redeclared. */
1034 { /* For a typedef name, record the meaning, not the name.
1035 In case of `foo foo, bar;'. */
1036 $$ = lookup_name ($1); }
1038 | CLASSNAME protocolrefs
1039 { $$ = get_static_reference ($1, $2); }
1040 | OBJECTNAME protocolrefs
1041 { $$ = get_object_reference ($2); }
1043 | TYPEOF '(' expr ')'
1044 { $$ = TREE_TYPE ($3); }
1045 | TYPEOF '(' typename ')'
1046 { $$ = groktypename ($3); }
1049 /* A typespec that is a reserved word, or a type qualifier. */
1051 typespecqual_reserved: TYPESPEC
1058 | initdecls ',' initdcl
1063 | notype_initdecls ',' initdcl
1069 | ASM_KEYWORD '(' string ')'
1070 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
1076 declarator maybeasm maybe_attribute '='
1077 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1078 $3, prefix_attributes);
1079 start_init ($<ttype>$, $2, global_bindings_p ()); }
1081 /* Note how the declaration of the variable is in effect while its init is parsed! */
1083 finish_decl ($<ttype>5, $6, $2); }
1084 | declarator maybeasm maybe_attribute
1085 { tree d = start_decl ($1, current_declspecs, 0,
1086 $3, prefix_attributes);
1087 finish_decl (d, NULL_TREE, $2);
1092 notype_declarator maybeasm maybe_attribute '='
1093 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1094 $3, prefix_attributes);
1095 start_init ($<ttype>$, $2, global_bindings_p ()); }
1097 /* Note how the declaration of the variable is in effect while its init is parsed! */
1099 decl_attributes ($<ttype>5, $3, prefix_attributes);
1100 finish_decl ($<ttype>5, $6, $2); }
1101 | notype_declarator maybeasm maybe_attribute
1102 { tree d = start_decl ($1, current_declspecs, 0,
1103 $3, prefix_attributes);
1104 finish_decl (d, NULL_TREE, $2); }
1106 /* the * rules are dummies to accept the Apollo extended syntax
1107 so that the header files compile. */
1118 | attributes attribute
1119 { $$ = chainon ($1, $2); }
1123 ATTRIBUTE '(' '(' attribute_list ')' ')'
1130 | attribute_list ',' attrib
1131 { $$ = chainon ($1, $3); }
1138 { $$ = build_tree_list ($1, NULL_TREE); }
1139 | any_word '(' IDENTIFIER ')'
1140 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1141 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1142 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1143 | any_word '(' exprlist ')'
1144 { $$ = build_tree_list ($1, $3); }
1147 /* This still leaves out most reserved keywords,
1148 shouldn't we include them? */
1157 /* Initializers. `init' is the entry point. */
1162 { really_start_incremental_init (NULL_TREE);
1163 /* Note that the call to clear_momentary
1164 is in process_init_element. */
1165 push_momentary (); }
1166 initlist_maybe_comma '}'
1167 { $$ = pop_init_level (0);
1168 if ($$ == error_mark_node
1169 && ! (yychar == STRING || yychar == CONSTANT))
1172 pop_momentary_nofree (); }
1175 { $$ = error_mark_node; }
1178 /* `initlist_maybe_comma' is the guts of an initializer in braces. */
1179 initlist_maybe_comma:
1182 pedwarn ("ANSI C forbids empty initializer braces"); }
1183 | initlist1 maybecomma
1188 | initlist1 ',' initelt
1191 /* `initelt' is a single element of an initializer.
1192 It may use braces. */
1195 { process_init_element ($1); }
1197 { push_init_level (0); }
1198 initlist_maybe_comma '}'
1199 { process_init_element (pop_init_level (0)); }
1201 /* These are for labeled elements. The syntax for an array element
1202 initializer conflicts with the syntax for an Objective-C message,
1203 so don't include these productions in the Objective-C grammar. */
1205 | '[' expr_no_commas ELLIPSIS expr_no_commas ']' '='
1206 { set_init_index ($2, $4); }
1208 | '[' expr_no_commas ']' '='
1209 { set_init_index ($2, NULL_TREE); }
1211 | '[' expr_no_commas ']'
1212 { set_init_index ($2, NULL_TREE); }
1216 { set_init_label ($1); }
1218 | '.' identifier '='
1219 { set_init_label ($2); }
1225 { push_c_function_context ();
1226 if (! start_function (current_declspecs, $1,
1227 prefix_attributes, NULL_TREE, 1))
1229 pop_c_function_context ();
1232 reinit_parse_for_function (); }
1234 { store_parm_decls (); }
1235 /* This used to use compstmt_or_error.
1236 That caused a bug with input `f(g) int g {}',
1237 where the use of YYERROR1 above caused an error
1238 which then was handled by compstmt_or_error.
1239 There followed a repeated execution of that same rule,
1240 which called YYERROR1 again, and so on. */
1242 { finish_function (1);
1243 pop_c_function_context (); }
1246 notype_nested_function:
1248 { push_c_function_context ();
1249 if (! start_function (current_declspecs, $1,
1250 prefix_attributes, NULL_TREE, 1))
1252 pop_c_function_context ();
1255 reinit_parse_for_function (); }
1257 { store_parm_decls (); }
1258 /* This used to use compstmt_or_error.
1259 That caused a bug with input `f(g) int g {}',
1260 where the use of YYERROR1 above caused an error
1261 which then was handled by compstmt_or_error.
1262 There followed a repeated execution of that same rule,
1263 which called YYERROR1 again, and so on. */
1265 { finish_function (1);
1266 pop_c_function_context (); }
1269 /* Any kind of declarator (thus, all declarators allowed
1270 after an explicit typespec). */
1273 after_type_declarator
1277 /* A declarator that is allowed only after an explicit typespec. */
1279 after_type_declarator:
1280 '(' after_type_declarator ')'
1282 | after_type_declarator '(' parmlist_or_identifiers %prec '.'
1283 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1284 /* | after_type_declarator '(' error ')' %prec '.'
1285 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1286 poplevel (0, 0, 0); } */
1287 | after_type_declarator '[' expr ']' %prec '.'
1288 { $$ = build_nt (ARRAY_REF, $1, $3); }
1289 | after_type_declarator '[' ']' %prec '.'
1290 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1291 | '*' type_quals after_type_declarator %prec UNARY
1292 { $$ = make_pointer_declarator ($2, $3); }
1293 | attributes setattrs after_type_declarator
1301 /* Kinds of declarator that can appear in a parameter list
1302 in addition to notype_declarator. This is like after_type_declarator
1303 but does not allow a typedef name in parentheses as an identifier
1304 (because it would conflict with a function with that typedef as arg). */
1307 parm_declarator '(' parmlist_or_identifiers %prec '.'
1308 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1309 /* | parm_declarator '(' error ')' %prec '.'
1310 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1311 poplevel (0, 0, 0); } */
1312 | parm_declarator '[' expr ']' %prec '.'
1313 { $$ = build_nt (ARRAY_REF, $1, $3); }
1314 | parm_declarator '[' ']' %prec '.'
1315 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1316 | '*' type_quals parm_declarator %prec UNARY
1317 { $$ = make_pointer_declarator ($2, $3); }
1318 | attributes setattrs parm_declarator
1323 /* A declarator allowed whether or not there has been
1324 an explicit typespec. These cannot redeclare a typedef-name. */
1327 notype_declarator '(' parmlist_or_identifiers %prec '.'
1328 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1329 /* | notype_declarator '(' error ')' %prec '.'
1330 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1331 poplevel (0, 0, 0); } */
1332 | '(' notype_declarator ')'
1334 | '*' type_quals notype_declarator %prec UNARY
1335 { $$ = make_pointer_declarator ($2, $3); }
1336 | notype_declarator '[' expr ']' %prec '.'
1337 { $$ = build_nt (ARRAY_REF, $1, $3); }
1338 | notype_declarator '[' ']' %prec '.'
1339 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1340 | attributes setattrs notype_declarator
1346 STRUCT identifier '{'
1347 { $$ = start_struct (RECORD_TYPE, $2);
1348 /* Start scope of tag before parsing components. */
1350 component_decl_list '}' maybe_attribute
1351 { $$ = finish_struct ($<ttype>4, $5, $7); }
1352 | STRUCT '{' component_decl_list '}' maybe_attribute
1353 { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
1357 { $$ = xref_tag (RECORD_TYPE, $2); }
1358 | UNION identifier '{'
1359 { $$ = start_struct (UNION_TYPE, $2); }
1360 component_decl_list '}' maybe_attribute
1361 { $$ = finish_struct ($<ttype>4, $5, $7); }
1362 | UNION '{' component_decl_list '}' maybe_attribute
1363 { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
1367 { $$ = xref_tag (UNION_TYPE, $2); }
1368 | ENUM identifier '{'
1369 { $<itype>3 = suspend_momentary ();
1370 $$ = start_enum ($2); }
1371 enumlist maybecomma_warn '}' maybe_attribute
1372 { $$ = finish_enum ($<ttype>4, nreverse ($5), $8);
1373 resume_momentary ($<itype>3); }
1375 { $<itype>2 = suspend_momentary ();
1376 $$ = start_enum (NULL_TREE); }
1377 enumlist maybecomma_warn '}' maybe_attribute
1378 { $$ = finish_enum ($<ttype>3, nreverse ($4), $7);
1379 resume_momentary ($<itype>2); }
1381 { $$ = xref_tag (ENUMERAL_TYPE, $2); }
1392 { if (pedantic) pedwarn ("comma at end of enumerator list"); }
1395 component_decl_list:
1396 component_decl_list2
1398 | component_decl_list2 component_decl
1399 { $$ = chainon ($1, $2);
1400 pedwarn ("no semicolon at end of struct or union"); }
1403 component_decl_list2: /* empty */
1405 | component_decl_list2 component_decl ';'
1406 { $$ = chainon ($1, $2); }
1407 | component_decl_list2 ';'
1409 pedwarn ("extra semicolon in struct or union specified"); }
1411 /* foo(sizeof(struct{ @defs(ClassName)})); */
1412 | DEFS '(' CLASSNAME ')'
1414 tree interface = lookup_interface ($3);
1417 $$ = get_class_ivars (interface);
1420 error ("Cannot find interface declaration for `%s'",
1421 IDENTIFIER_POINTER ($3));
1428 /* There is a shift-reduce conflict here, because `components' may
1429 start with a `typename'. It happens that shifting (the default resolution)
1430 does the right thing, because it treats the `typename' as part of
1431 a `typed_typespecs'.
1433 It is possible that this same technique would allow the distinction
1434 between `notype_initdecls' and `initdecls' to be eliminated.
1435 But I am being cautious and not trying it. */
1438 typed_typespecs setspecs components
1440 current_declspecs = TREE_VALUE (declspec_stack);
1441 prefix_attributes = TREE_PURPOSE (declspec_stack);
1442 declspec_stack = TREE_CHAIN (declspec_stack);
1443 resume_momentary ($2); }
1446 pedwarn ("ANSI C forbids member declarations with no members");
1449 | nonempty_type_quals setspecs components
1451 current_declspecs = TREE_VALUE (declspec_stack);
1452 prefix_attributes = TREE_PURPOSE (declspec_stack);
1453 declspec_stack = TREE_CHAIN (declspec_stack);
1454 resume_momentary ($2); }
1455 | nonempty_type_quals
1457 pedwarn ("ANSI C forbids member declarations with no members");
1465 component_declarator
1466 | components ',' component_declarator
1467 { $$ = chainon ($1, $3); }
1470 component_declarator:
1471 save_filename save_lineno declarator maybe_attribute
1472 { $$ = grokfield ($1, $2, $3, current_declspecs, NULL_TREE);
1473 decl_attributes ($$, $4, prefix_attributes); }
1474 | save_filename save_lineno
1475 declarator ':' expr_no_commas maybe_attribute
1476 { $$ = grokfield ($1, $2, $3, current_declspecs, $5);
1477 decl_attributes ($$, $6, prefix_attributes); }
1478 | save_filename save_lineno ':' expr_no_commas maybe_attribute
1479 { $$ = grokfield ($1, $2, NULL_TREE, current_declspecs, $4);
1480 decl_attributes ($$, $5, prefix_attributes); }
1483 /* We chain the enumerators in reverse order.
1484 They are put in forward order where enumlist is used.
1485 (The order used to be significant, but no longer is so.
1486 However, we still maintain the order, just to be clean.) */
1490 | enumlist ',' enumerator
1491 { $$ = chainon ($3, $1); }
1493 { $$ = error_mark_node; }
1499 { $$ = build_enumerator ($1, NULL_TREE); }
1500 | identifier '=' expr_no_commas
1501 { $$ = build_enumerator ($1, $3); }
1505 typed_typespecs absdcl
1506 { $$ = build_tree_list ($1, $2); }
1507 | nonempty_type_quals absdcl
1508 { $$ = build_tree_list ($1, $2); }
1511 absdcl: /* an absolute declarator */
1517 nonempty_type_quals:
1519 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
1520 | nonempty_type_quals TYPE_QUAL
1521 { $$ = tree_cons (NULL_TREE, $2, $1); }
1527 | type_quals TYPE_QUAL
1528 { $$ = tree_cons (NULL_TREE, $2, $1); }
1531 absdcl1: /* a nonempty absolute declarator */
1534 /* `(typedef)1' is `int'. */
1535 | '*' type_quals absdcl1 %prec UNARY
1536 { $$ = make_pointer_declarator ($2, $3); }
1537 | '*' type_quals %prec UNARY
1538 { $$ = make_pointer_declarator ($2, NULL_TREE); }
1539 | absdcl1 '(' parmlist %prec '.'
1540 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1541 | absdcl1 '[' expr ']' %prec '.'
1542 { $$ = build_nt (ARRAY_REF, $1, $3); }
1543 | absdcl1 '[' ']' %prec '.'
1544 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1545 | '(' parmlist %prec '.'
1546 { $$ = build_nt (CALL_EXPR, NULL_TREE, $2, NULL_TREE); }
1547 | '[' expr ']' %prec '.'
1548 { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
1550 { $$ = build_nt (ARRAY_REF, NULL_TREE, NULL_TREE); }
1551 | attributes setattrs absdcl1
1555 /* at least one statement, the first of which parses without error. */
1556 /* stmts is used only after decls, so an invalid first statement
1557 is actually regarded as an invalid decl and part of the decls. */
1560 lineno_stmt_or_label
1561 | stmts lineno_stmt_or_label
1573 pushlevel: /* empty */
1574 { emit_line_note (input_filename, lineno);
1578 expand_start_bindings (0);
1580 if (objc_method_context)
1586 /* Read zero or more forward-declarations for labels
1587 that nested functions can jump to. */
1592 pedwarn ("ANSI C forbids label declarations"); }
1597 | label_decls label_decl
1601 LABEL identifiers_or_typenames ';'
1603 for (link = $2; link; link = TREE_CHAIN (link))
1605 tree label = shadow_label (TREE_VALUE (link));
1606 C_DECLARED_LABEL_FLAG (label) = 1;
1607 declare_nonlocal_label (label);
1612 /* This is the body of a function definition.
1613 It causes syntax errors to ignore to the next openbrace. */
1621 { $$ = convert (void_type_node, integer_zero_node); }
1622 | '{' pushlevel maybe_label_decls decls xstmts '}'
1623 { emit_line_note (input_filename, lineno);
1624 expand_end_bindings (getdecls (), 1, 0);
1625 $$ = poplevel (1, 1, 0);
1626 if (yychar == CONSTANT || yychar == STRING)
1627 pop_momentary_nofree ();
1630 | '{' pushlevel maybe_label_decls error '}'
1631 { emit_line_note (input_filename, lineno);
1632 expand_end_bindings (getdecls (), kept_level_p (), 0);
1633 $$ = poplevel (kept_level_p (), 0, 0);
1634 if (yychar == CONSTANT || yychar == STRING)
1635 pop_momentary_nofree ();
1638 | '{' pushlevel maybe_label_decls stmts '}'
1639 { emit_line_note (input_filename, lineno);
1640 expand_end_bindings (getdecls (), kept_level_p (), 0);
1641 $$ = poplevel (kept_level_p (), 0, 0);
1642 if (yychar == CONSTANT || yychar == STRING)
1643 pop_momentary_nofree ();
1648 /* Value is number of statements counted as of the closeparen. */
1650 if_prefix lineno_labeled_stmt
1651 /* Make sure expand_end_cond is run once
1652 for each call to expand_start_cond.
1653 Otherwise a crash is likely. */
1659 { emit_line_note ($<filename>-1, $<lineno>0);
1660 expand_start_cond (truthvalue_conversion ($3), 0);
1661 $<itype>$ = stmt_count;
1662 if_stmt_file = $<filename>-1;
1663 if_stmt_line = $<lineno>0;
1664 position_after_white_space (); }
1667 /* This is a subroutine of stmt.
1668 It is used twice, once for valid DO statements
1669 and once for catching errors in parsing the end test. */
1673 emit_line_note ($<filename>-1, $<lineno>0);
1674 /* See comment in `while' alternative, above. */
1676 expand_start_loop_continue_elsewhere (1);
1677 position_after_white_space (); }
1678 lineno_labeled_stmt WHILE
1679 { expand_loop_continue_here (); }
1683 { $$ = input_filename; }
1690 lineno_labeled_stmt:
1691 save_filename save_lineno stmt
1693 /* | save_filename save_lineno error
1696 | save_filename save_lineno label lineno_labeled_stmt
1700 lineno_stmt_or_label:
1701 save_filename save_lineno stmt_or_label
1709 position_after_white_space ();
1710 next = getc (finput);
1711 ungetc (next, finput);
1712 if (pedantic && next == '}')
1713 pedwarn ("ANSI C forbids label at end of compound statement");
1717 /* Parse a single real statement, not including any labels. */
1724 emit_line_note ($<filename>-1, $<lineno>0);
1725 /* It appears that this should not be done--that a non-lvalue array
1726 shouldn't get an error if the value isn't used.
1727 Section 3.2.2.1 says that an array lvalue gets converted to a pointer
1728 if it appears as a top-level expression,
1729 but says nothing about non-lvalue arrays. */
1731 /* Call default_conversion to get an error
1732 on referring to a register array if pedantic. */
1733 if (TREE_CODE (TREE_TYPE ($1)) == ARRAY_TYPE
1734 || TREE_CODE (TREE_TYPE ($1)) == FUNCTION_TYPE)
1735 $1 = default_conversion ($1);
1737 iterator_expand ($1);
1738 clear_momentary (); }
1740 { expand_start_else ();
1741 $<itype>1 = stmt_count;
1742 position_after_white_space (); }
1744 { expand_end_cond ();
1745 if (extra_warnings && stmt_count == $<itype>1)
1746 warning ("empty body in an else-statement"); }
1747 | simple_if %prec IF
1748 { expand_end_cond ();
1749 /* This warning is here instead of in simple_if, because we
1750 do not want a warning if an empty if is followed by an
1751 else statement. Increment stmt_count so we don't
1752 give a second error if this is a nested `if'. */
1753 if (extra_warnings && stmt_count++ == $<itype>1)
1754 warning_with_file_and_line (if_stmt_file, if_stmt_line,
1755 "empty body in an if-statement"); }
1756 /* Make sure expand_end_cond is run once
1757 for each call to expand_start_cond.
1758 Otherwise a crash is likely. */
1759 | simple_if ELSE error
1760 { expand_end_cond (); }
1763 emit_line_note ($<filename>-1, $<lineno>0);
1764 /* The emit_nop used to come before emit_line_note,
1765 but that made the nop seem like part of the preceding line.
1766 And that was confusing when the preceding line was
1767 inside of an if statement and was not really executed.
1768 I think it ought to work to put the nop after the line number.
1769 We will see. --rms, July 15, 1991. */
1772 { /* Don't start the loop till we have succeeded
1773 in parsing the end test. This is to make sure
1774 that we end every loop we start. */
1775 expand_start_loop (1);
1776 emit_line_note (input_filename, lineno);
1777 expand_exit_loop_if_false (NULL_PTR,
1778 truthvalue_conversion ($4));
1779 position_after_white_space (); }
1781 { expand_end_loop (); }
1784 { emit_line_note (input_filename, lineno);
1785 expand_exit_loop_if_false (NULL_PTR,
1786 truthvalue_conversion ($3));
1788 clear_momentary (); }
1789 /* This rule is needed to make sure we end every loop we start. */
1790 | do_stmt_start error
1791 { expand_end_loop ();
1792 clear_momentary (); }
1796 emit_line_note ($<filename>-1, $<lineno>0);
1797 /* See comment in `while' alternative, above. */
1799 if ($3) c_expand_expr_stmt ($3);
1800 /* Next step is to call expand_start_loop_continue_elsewhere,
1801 but wait till after we parse the entire for (...).
1802 Otherwise, invalid input might cause us to call that
1803 fn without calling expand_end_loop. */
1806 /* Can't emit now; wait till after expand_start_loop... */
1807 { $<lineno>7 = lineno;
1808 $<filename>$ = input_filename; }
1811 /* Start the loop. Doing this after parsing
1812 all the expressions ensures we will end the loop. */
1813 expand_start_loop_continue_elsewhere (1);
1814 /* Emit the end-test, with a line number. */
1815 emit_line_note ($<filename>8, $<lineno>7);
1817 expand_exit_loop_if_false (NULL_PTR,
1818 truthvalue_conversion ($6));
1819 /* Don't let the tree nodes for $9 be discarded by
1820 clear_momentary during the parsing of the next stmt. */
1822 $<lineno>7 = lineno;
1823 $<filename>8 = input_filename;
1824 position_after_white_space (); }
1826 { /* Emit the increment expression, with a line number. */
1827 emit_line_note ($<filename>8, $<lineno>7);
1828 expand_loop_continue_here ();
1830 c_expand_expr_stmt ($9);
1831 if (yychar == CONSTANT || yychar == STRING)
1832 pop_momentary_nofree ();
1835 expand_end_loop (); }
1836 | SWITCH '(' expr ')'
1838 emit_line_note ($<filename>-1, $<lineno>0);
1839 c_expand_start_case ($3);
1840 /* Don't let the tree nodes for $3 be discarded by
1841 clear_momentary during the parsing of the next stmt. */
1843 position_after_white_space (); }
1845 { expand_end_case ($3);
1846 if (yychar == CONSTANT || yychar == STRING)
1847 pop_momentary_nofree ();
1852 emit_line_note ($<filename>-1, $<lineno>0);
1853 if ( ! expand_exit_something ())
1854 error ("break statement not within loop or switch"); }
1857 emit_line_note ($<filename>-1, $<lineno>0);
1858 if (! expand_continue_loop (NULL_PTR))
1859 error ("continue statement not within a loop"); }
1862 emit_line_note ($<filename>-1, $<lineno>0);
1863 c_expand_return (NULL_TREE); }
1866 emit_line_note ($<filename>-1, $<lineno>0);
1867 c_expand_return ($2); }
1868 | ASM_KEYWORD maybe_type_qual '(' expr ')' ';'
1870 emit_line_note ($<filename>-1, $<lineno>0);
1872 if ((TREE_CODE ($4) == ADDR_EXPR
1873 && TREE_CODE (TREE_OPERAND ($4, 0)) == STRING_CST)
1874 || TREE_CODE ($4) == STRING_CST)
1877 error ("argument of `asm' is not a constant string"); }
1878 /* This is the case with just output operands. */
1879 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ')' ';'
1881 emit_line_note ($<filename>-1, $<lineno>0);
1882 c_expand_asm_operands ($4, $6, NULL_TREE, NULL_TREE,
1883 $2 == ridpointers[(int)RID_VOLATILE],
1884 input_filename, lineno); }
1885 /* This is the case with input operands as well. */
1886 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':' asm_operands ')' ';'
1888 emit_line_note ($<filename>-1, $<lineno>0);
1889 c_expand_asm_operands ($4, $6, $8, NULL_TREE,
1890 $2 == ridpointers[(int)RID_VOLATILE],
1891 input_filename, lineno); }
1892 /* This is the case with clobbered registers as well. */
1893 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':'
1894 asm_operands ':' asm_clobbers ')' ';'
1896 emit_line_note ($<filename>-1, $<lineno>0);
1897 c_expand_asm_operands ($4, $6, $8, $10,
1898 $2 == ridpointers[(int)RID_VOLATILE],
1899 input_filename, lineno); }
1900 | GOTO identifier ';'
1903 emit_line_note ($<filename>-1, $<lineno>0);
1904 decl = lookup_label ($2);
1907 TREE_USED (decl) = 1;
1913 emit_line_note ($<filename>-1, $<lineno>0);
1914 expand_computed_goto (convert (ptr_type_node, $3)); }
1919 all_iter_stmt_simple
1920 /* | all_iter_stmt_with_decl */
1923 all_iter_stmt_simple:
1926 /* The value returned by this action is */
1927 /* 1 if everything is OK */
1928 /* 0 in case of error or already bound iterator */
1931 if (TREE_CODE ($3) != VAR_DECL)
1932 error ("invalid `for (ITERATOR)' syntax");
1933 else if (! ITERATOR_P ($3))
1934 error ("`%s' is not an iterator",
1935 IDENTIFIER_POINTER (DECL_NAME ($3)));
1936 else if (ITERATOR_BOUND_P ($3))
1937 error ("`for (%s)' inside expansion of same iterator",
1938 IDENTIFIER_POINTER (DECL_NAME ($3)));
1942 iterator_for_loop_start ($3);
1948 iterator_for_loop_end ($3);
1951 /* This really should allow any kind of declaration,
1952 for generality. Fix it before turning it back on.
1954 all_iter_stmt_with_decl:
1955 FOR '(' ITERATOR pushlevel setspecs iterator_spec ')'
1957 */ /* The value returned by this action is */
1958 /* 1 if everything is OK */
1959 /* 0 in case of error or already bound iterator */
1961 iterator_for_loop_start ($6);
1965 iterator_for_loop_end ($6);
1966 emit_line_note (input_filename, lineno);
1967 expand_end_bindings (getdecls (), 1, 0);
1968 $<ttype>$ = poplevel (1, 1, 0);
1969 if (yychar == CONSTANT || yychar == STRING)
1970 pop_momentary_nofree ();
1976 /* Any kind of label, including jump labels and case labels.
1977 ANSI C accepts labels only before statements, but we allow them
1978 also at the end of a compound statement. */
1980 label: CASE expr_no_commas ':'
1981 { register tree value = check_case_value ($2);
1983 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
1987 if (value != error_mark_node)
1990 int success = pushcase (value, convert_and_check,
1993 error ("case label not within a switch statement");
1994 else if (success == 2)
1996 error ("duplicate case value");
1997 error_with_decl (duplicate, "this is the first entry for that value");
1999 else if (success == 3)
2000 warning ("case value out of range");
2001 else if (success == 5)
2002 error ("case label within scope of cleanup or variable array");
2004 position_after_white_space (); }
2005 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
2006 { register tree value1 = check_case_value ($2);
2007 register tree value2 = check_case_value ($4);
2009 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
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 (); }
2050 { tree label = define_label (input_filename, lineno, $1);
2054 expand_label (label);
2055 position_after_white_space (); }
2058 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
2062 { emit_line_note (input_filename, lineno);
2065 { emit_line_note (input_filename, lineno); }
2074 /* These are the operands other than the first string and colon
2075 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
2076 asm_operands: /* empty */
2078 | nonnull_asm_operands
2081 nonnull_asm_operands:
2083 | nonnull_asm_operands ',' asm_operand
2084 { $$ = chainon ($1, $3); }
2089 { $$ = build_tree_list ($1, $3); }
2094 { $$ = tree_cons (NULL_TREE, combine_strings ($1), NULL_TREE); }
2095 | asm_clobbers ',' string
2096 { $$ = tree_cons (NULL_TREE, combine_strings ($3), $1); }
2099 /* This is what appears inside the parens in a function declarator.
2100 Its value is a list of ..._TYPE nodes. */
2103 clear_parm_order ();
2104 declare_parm_level (0); }
2107 parmlist_tags_warning ();
2108 poplevel (0, 0, 0); }
2116 pedwarn ("ANSI C forbids forward parameter declarations");
2117 /* Mark the forward decls as such. */
2118 for (parm = getdecls (); parm; parm = TREE_CHAIN (parm))
2119 TREE_ASM_WRITTEN (parm) = 1;
2120 clear_parm_order (); }
2124 { $$ = tree_cons (NULL_TREE, NULL_TREE, NULL_TREE); }
2127 /* This is what appears inside the parens in a function declarator.
2128 Is value is represented in the format that grokdeclarator expects. */
2129 parmlist_2: /* empty */
2130 { $$ = get_parm_info (0); }
2132 { $$ = get_parm_info (0);
2133 /* Gcc used to allow this as an extension. However, it does
2134 not work for all targets, and thus has been disabled.
2135 Also, since func (...) and func () are indistinguishable,
2136 it caused problems with the code in expand_builtin which
2137 tries to verify that BUILT_IN_NEXT_ARG is being used
2139 error ("ANSI C requires a named argument before `...'");
2142 { $$ = get_parm_info (1); }
2143 | parms ',' ELLIPSIS
2144 { $$ = get_parm_info (0); }
2149 { push_parm_decl ($1); }
2151 { push_parm_decl ($3); }
2154 /* A single parameter declaration or parameter type name,
2155 as found in a parmlist. */
2157 typed_declspecs setspecs parm_declarator maybe_attribute
2158 { $$ = build_tree_list (build_tree_list (current_declspecs,
2160 build_tree_list (prefix_attributes,
2162 current_declspecs = TREE_VALUE (declspec_stack);
2163 prefix_attributes = TREE_PURPOSE (declspec_stack);
2164 declspec_stack = TREE_CHAIN (declspec_stack);
2165 resume_momentary ($2); }
2166 | typed_declspecs setspecs notype_declarator maybe_attribute
2167 { $$ = build_tree_list (build_tree_list (current_declspecs,
2169 build_tree_list (prefix_attributes,
2171 current_declspecs = TREE_VALUE (declspec_stack);
2172 prefix_attributes = TREE_PURPOSE (declspec_stack);
2173 declspec_stack = TREE_CHAIN (declspec_stack);
2174 resume_momentary ($2); }
2175 | typed_declspecs setspecs absdcl maybe_attribute
2176 { $$ = build_tree_list (build_tree_list (current_declspecs,
2178 build_tree_list (prefix_attributes,
2180 current_declspecs = TREE_VALUE (declspec_stack);
2181 prefix_attributes = TREE_PURPOSE (declspec_stack);
2182 declspec_stack = TREE_CHAIN (declspec_stack);
2183 resume_momentary ($2); }
2184 | declmods setspecs notype_declarator maybe_attribute
2185 { $$ = build_tree_list (build_tree_list (current_declspecs,
2187 build_tree_list (prefix_attributes,
2189 current_declspecs = TREE_VALUE (declspec_stack);
2190 prefix_attributes = TREE_PURPOSE (declspec_stack);
2191 declspec_stack = TREE_CHAIN (declspec_stack);
2192 resume_momentary ($2); }
2194 | declmods setspecs absdcl maybe_attribute
2195 { $$ = build_tree_list (build_tree_list (current_declspecs,
2197 build_tree_list (prefix_attributes,
2199 current_declspecs = TREE_VALUE (declspec_stack);
2200 prefix_attributes = TREE_PURPOSE (declspec_stack);
2201 declspec_stack = TREE_CHAIN (declspec_stack);
2202 resume_momentary ($2); }
2205 /* This is used in a function definition
2206 where either a parmlist or an identifier list is ok.
2207 Its value is a list of ..._TYPE nodes or a list of identifiers. */
2208 parmlist_or_identifiers:
2210 clear_parm_order ();
2211 declare_parm_level (1); }
2212 parmlist_or_identifiers_1
2214 parmlist_tags_warning ();
2215 poplevel (0, 0, 0); }
2218 parmlist_or_identifiers_1:
2222 for (t = $1; t; t = TREE_CHAIN (t))
2223 if (TREE_VALUE (t) == NULL_TREE)
2224 error ("`...' in old-style identifier list");
2225 $$ = tree_cons (NULL_TREE, NULL_TREE, $1); }
2228 /* A nonempty list of identifiers. */
2231 { $$ = build_tree_list (NULL_TREE, $1); }
2232 | identifiers ',' IDENTIFIER
2233 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2236 /* A nonempty list of identifiers, including typenames. */
2237 identifiers_or_typenames:
2239 { $$ = build_tree_list (NULL_TREE, $1); }
2240 | identifiers_or_typenames ',' identifier
2241 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2245 /* Objective-C productions. */
2255 if (objc_implementation_context)
2257 finish_class (objc_implementation_context);
2258 objc_ivar_chain = NULL_TREE;
2259 objc_implementation_context = NULL_TREE;
2262 warning ("`@end' must appear in an implementation context");
2266 /* A nonempty list of identifiers. */
2269 { $$ = build_tree_list (NULL_TREE, $1); }
2270 | identifier_list ',' identifier
2271 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2275 CLASS identifier_list ';'
2277 objc_declare_class ($2);
2281 ALIAS identifier identifier ';'
2283 objc_declare_alias ($2, $3);
2287 INTERFACE identifier protocolrefs '{'
2289 objc_interface_context = objc_ivar_context
2290 = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, $3);
2291 objc_public_flag = 0;
2295 continue_class (objc_interface_context);
2300 finish_class (objc_interface_context);
2301 objc_interface_context = NULL_TREE;
2304 | INTERFACE identifier protocolrefs
2306 objc_interface_context
2307 = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, $3);
2308 continue_class (objc_interface_context);
2313 finish_class (objc_interface_context);
2314 objc_interface_context = NULL_TREE;
2317 | INTERFACE identifier ':' identifier protocolrefs '{'
2319 objc_interface_context = objc_ivar_context
2320 = start_class (CLASS_INTERFACE_TYPE, $2, $4, $5);
2321 objc_public_flag = 0;
2325 continue_class (objc_interface_context);
2330 finish_class (objc_interface_context);
2331 objc_interface_context = NULL_TREE;
2334 | INTERFACE identifier ':' identifier protocolrefs
2336 objc_interface_context
2337 = start_class (CLASS_INTERFACE_TYPE, $2, $4, $5);
2338 continue_class (objc_interface_context);
2343 finish_class (objc_interface_context);
2344 objc_interface_context = NULL_TREE;
2347 | IMPLEMENTATION identifier '{'
2349 objc_implementation_context = objc_ivar_context
2350 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, NULL_TREE, NULL_TREE);
2351 objc_public_flag = 0;
2356 = continue_class (objc_implementation_context);
2359 | IMPLEMENTATION identifier
2361 objc_implementation_context
2362 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, NULL_TREE, NULL_TREE);
2364 = continue_class (objc_implementation_context);
2367 | IMPLEMENTATION identifier ':' identifier '{'
2369 objc_implementation_context = objc_ivar_context
2370 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2371 objc_public_flag = 0;
2376 = continue_class (objc_implementation_context);
2379 | IMPLEMENTATION identifier ':' identifier
2381 objc_implementation_context
2382 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2384 = continue_class (objc_implementation_context);
2387 | INTERFACE identifier '(' identifier ')' protocolrefs
2389 objc_interface_context
2390 = start_class (CATEGORY_INTERFACE_TYPE, $2, $4, $6);
2391 continue_class (objc_interface_context);
2396 finish_class (objc_interface_context);
2397 objc_interface_context = NULL_TREE;
2400 | IMPLEMENTATION identifier '(' identifier ')'
2402 objc_implementation_context
2403 = start_class (CATEGORY_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2405 = continue_class (objc_implementation_context);
2410 PROTOCOL identifier protocolrefs
2412 remember_protocol_qualifiers ();
2413 objc_interface_context
2414 = start_protocol(PROTOCOL_INTERFACE_TYPE, $2, $3);
2418 forget_protocol_qualifiers();
2419 finish_protocol(objc_interface_context);
2420 objc_interface_context = NULL_TREE;
2429 | ARITHCOMPARE identifier_list ARITHCOMPARE
2431 if ($1 == LT_EXPR && $3 == GT_EXPR)
2439 ivar_decl_list visibility_spec ivar_decls
2444 PRIVATE { objc_public_flag = 2; }
2445 | PROTECTED { objc_public_flag = 0; }
2446 | PUBLIC { objc_public_flag = 1; }
2454 | ivar_decls ivar_decl ';'
2458 pedwarn ("extra semicolon in struct or union specified");
2463 /* There is a shift-reduce conflict here, because `components' may
2464 start with a `typename'. It happens that shifting (the default resolution)
2465 does the right thing, because it treats the `typename' as part of
2466 a `typed_typespecs'.
2468 It is possible that this same technique would allow the distinction
2469 between `notype_initdecls' and `initdecls' to be eliminated.
2470 But I am being cautious and not trying it. */
2473 typed_typespecs setspecs ivars
2475 current_declspecs = TREE_VALUE (declspec_stack);
2476 prefix_attributes = TREE_PURPOSE (declspec_stack);
2477 declspec_stack = TREE_CHAIN (declspec_stack);
2478 resume_momentary ($2); }
2479 | nonempty_type_quals setspecs ivars
2481 current_declspecs = TREE_VALUE (declspec_stack);
2482 prefix_attributes = TREE_PURPOSE (declspec_stack);
2483 declspec_stack = TREE_CHAIN (declspec_stack);
2484 resume_momentary ($2); }
2493 | ivars ',' ivar_declarator
2499 $$ = add_instance_variable (objc_ivar_context,
2501 $1, current_declspecs,
2504 | declarator ':' expr_no_commas
2506 $$ = add_instance_variable (objc_ivar_context,
2508 $1, current_declspecs, $3);
2510 | ':' expr_no_commas
2512 $$ = add_instance_variable (objc_ivar_context,
2515 current_declspecs, $2);
2522 remember_protocol_qualifiers ();
2523 if (objc_implementation_context)
2524 objc_inherit_code = CLASS_METHOD_DECL;
2526 fatal ("method definition not in class context");
2530 forget_protocol_qualifiers ();
2531 add_class_method (objc_implementation_context, $3);
2532 start_method_def ($3);
2533 objc_method_context = $3;
2537 continue_method_def ();
2541 finish_method_def ();
2542 objc_method_context = NULL_TREE;
2547 remember_protocol_qualifiers ();
2548 if (objc_implementation_context)
2549 objc_inherit_code = INSTANCE_METHOD_DECL;
2551 fatal ("method definition not in class context");
2555 forget_protocol_qualifiers ();
2556 add_instance_method (objc_implementation_context, $3);
2557 start_method_def ($3);
2558 objc_method_context = $3;
2562 continue_method_def ();
2566 finish_method_def ();
2567 objc_method_context = NULL_TREE;
2571 /* the reason for the strange actions in this rule
2572 is so that notype_initdecls when reached via datadef
2573 can find a valid list of type and sc specs in $0. */
2577 | {$<ttype>$ = NULL_TREE; } methodprotolist2
2580 methodprotolist2: /* eliminates a shift/reduce conflict */
2583 | methodprotolist2 methodproto
2584 | methodprotolist2 {$<ttype>$ = NULL_TREE; } datadef
2595 objc_inherit_code = CLASS_METHOD_DECL;
2599 add_class_method (objc_interface_context, $3);
2605 objc_inherit_code = INSTANCE_METHOD_DECL;
2609 add_instance_method (objc_interface_context, $3);
2615 '(' typename ')' unaryselector
2617 $$ = build_method_decl (objc_inherit_code, $2, $4, NULL_TREE);
2622 $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, NULL_TREE);
2625 | '(' typename ')' keywordselector optparmlist
2627 $$ = build_method_decl (objc_inherit_code, $2, $4, $5);
2630 | keywordselector optparmlist
2632 $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, $2);
2636 /* "optarglist" assumes that start_method_def has already been called...
2637 if it is not, the "xdecls" will not be placed in the proper scope */
2644 /* to get around the following situation: "int foo (int a) int b; {}" that
2645 is synthesized when parsing "- a:a b:b; id c; id d; { ... }" */
2660 typed_declspecs setspecs myparms ';'
2661 { current_declspecs = TREE_VALUE (declspec_stack);
2662 prefix_attributes = TREE_PURPOSE (declspec_stack);
2663 declspec_stack = TREE_CHAIN (declspec_stack);
2664 resume_momentary ($2); }
2665 | typed_declspecs ';'
2666 { shadow_tag ($1); }
2668 { pedwarn ("empty declaration"); }
2673 { push_parm_decl ($1); }
2674 | myparms ',' myparm
2675 { push_parm_decl ($3); }
2678 /* A single parameter declaration or parameter type name,
2679 as found in a parmlist. DOES NOT ALLOW AN INITIALIZER OR ASMSPEC */
2682 parm_declarator maybe_attribute
2683 { $$ = build_tree_list (build_tree_list (current_declspecs,
2685 build_tree_list (prefix_attributes,
2687 | notype_declarator maybe_attribute
2688 { $$ = build_tree_list (build_tree_list (current_declspecs,
2690 build_tree_list (prefix_attributes,
2692 | absdcl maybe_attribute
2693 { $$ = build_tree_list (build_tree_list (current_declspecs,
2695 build_tree_list (prefix_attributes,
2706 /* oh what a kludge! */
2715 /* returns a tree list node generated by get_parm_info */
2728 | keywordselector keyworddecl
2730 $$ = chainon ($1, $2);
2742 ENUM { $$ = get_identifier (token_buffer); }
2743 | STRUCT { $$ = get_identifier (token_buffer); }
2744 | UNION { $$ = get_identifier (token_buffer); }
2745 | IF { $$ = get_identifier (token_buffer); }
2746 | ELSE { $$ = get_identifier (token_buffer); }
2747 | WHILE { $$ = get_identifier (token_buffer); }
2748 | DO { $$ = get_identifier (token_buffer); }
2749 | FOR { $$ = get_identifier (token_buffer); }
2750 | SWITCH { $$ = get_identifier (token_buffer); }
2751 | CASE { $$ = get_identifier (token_buffer); }
2752 | DEFAULT { $$ = get_identifier (token_buffer); }
2753 | BREAK { $$ = get_identifier (token_buffer); }
2754 | CONTINUE { $$ = get_identifier (token_buffer); }
2755 | RETURN { $$ = get_identifier (token_buffer); }
2756 | GOTO { $$ = get_identifier (token_buffer); }
2757 | ASM_KEYWORD { $$ = get_identifier (token_buffer); }
2758 | SIZEOF { $$ = get_identifier (token_buffer); }
2759 | TYPEOF { $$ = get_identifier (token_buffer); }
2760 | ALIGNOF { $$ = get_identifier (token_buffer); }
2761 | TYPESPEC | TYPE_QUAL
2765 selector ':' '(' typename ')' identifier
2767 $$ = build_keyword_decl ($1, $4, $6);
2770 | selector ':' identifier
2772 $$ = build_keyword_decl ($1, NULL_TREE, $3);
2775 | ':' '(' typename ')' identifier
2777 $$ = build_keyword_decl (NULL_TREE, $3, $5);
2782 $$ = build_keyword_decl (NULL_TREE, NULL_TREE, $2);
2793 | keywordarglist keywordarg
2795 $$ = chainon ($1, $2);
2803 if (TREE_CHAIN ($1) == NULL_TREE)
2804 /* just return the expr., remove a level of indirection */
2805 $$ = TREE_VALUE ($1);
2807 /* we have a comma expr., we will collapse later */
2813 selector ':' keywordexpr
2815 $$ = build_tree_list ($1, $3);
2819 $$ = build_tree_list (NULL_TREE, $2);
2827 $$ = get_class_reference ($1);
2833 { objc_receiver_context = 1; }
2835 { objc_receiver_context = 0; }
2838 $$ = build_tree_list ($3, $5);
2849 | keywordnamelist keywordname
2851 $$ = chainon ($1, $2);
2858 $$ = build_tree_list ($1, NULL_TREE);
2862 $$ = build_tree_list (NULL_TREE, NULL_TREE);
2867 SELECTOR '(' selectorarg ')'
2874 PROTOCOL '(' identifier ')'
2880 /* extension to support C-structures in the archiver */
2883 ENCODE '(' typename ')'
2885 $$ = groktypename ($3);