1 /* YACC parser for C syntax and for Objective C. -*-c-*-
2 Copyright (C) 1987, 88, 89, 92-5, 1996 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; int ends_in_label; }
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 <ends_in_label> lineno_stmt_or_label lineno_stmt_or_labels stmt_or_label
215 %type <filename> save_filename
216 %type <lineno> save_lineno
219 /* the Objective-C nonterminals */
221 %type <ttype> ivar_decl_list ivar_decls ivar_decl ivars ivar_declarator
222 %type <ttype> methoddecl unaryselector keywordselector selector
223 %type <ttype> keyworddecl receiver objcmessageexpr messageargs
224 %type <ttype> keywordexpr keywordarglist keywordarg
225 %type <ttype> myparms myparm optparmlist reservedwords objcselectorexpr
226 %type <ttype> selectorarg keywordnamelist keywordname objcencodeexpr
227 %type <ttype> objc_string non_empty_protocolrefs protocolrefs identifier_list objcprotocolexpr
229 %type <ttype> CLASSNAME OBJC_STRING OBJECTNAME
233 /* Number of statements (loosely speaking) seen so far. */
234 static int stmt_count;
236 /* Input file and line number of the end of the body of last simple_if;
237 used by the stmt-rule immediately after simple_if returns. */
238 static char *if_stmt_file;
239 static int if_stmt_line;
241 /* List of types and structure classes of the current declaration. */
242 static tree current_declspecs;
243 static tree prefix_attributes = NULL_TREE;
245 /* Stack of saved values of current_declspecs and prefix_attributes. */
246 static tree declspec_stack;
248 /* 1 if we explained undeclared var errors. */
249 static int undeclared_variable_notice;
252 /* Objective-C specific information */
254 tree objc_interface_context;
255 tree objc_implementation_context;
256 tree objc_method_context;
257 tree objc_ivar_chain;
258 tree objc_ivar_context;
259 enum tree_code objc_inherit_code;
260 int objc_receiver_context;
261 int objc_public_flag;
265 /* Tell yyparse how to print a token's value, if yydebug is set. */
267 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
268 extern void yyprint ();
274 pedwarn ("ANSI C forbids an empty source file");
279 /* In case there were missing closebraces,
280 get us back to the global binding level. */
281 while (! global_bindings_p ())
287 /* the reason for the strange actions in this rule
288 is so that notype_initdecls when reached via datadef
289 can find a valid list of type and sc specs in $0. */
292 {$<ttype>$ = NULL_TREE; } extdef
293 | extdefs {$<ttype>$ = NULL_TREE; } extdef
302 | ASM_KEYWORD '(' expr ')' ';'
304 if ((TREE_CODE ($3) == ADDR_EXPR
305 && TREE_CODE (TREE_OPERAND ($3, 0)) == STRING_CST)
306 || TREE_CODE ($3) == STRING_CST)
309 error ("argument of `asm' is not a constant string"); }
313 setspecs notype_initdecls ';'
315 error ("ANSI C forbids data definition with no type or storage class");
316 else if (!flag_traditional)
317 warning ("data definition has no type or storage class");
319 current_declspecs = TREE_VALUE (declspec_stack);
320 prefix_attributes = TREE_PURPOSE (declspec_stack);
321 declspec_stack = TREE_CHAIN (declspec_stack);
322 resume_momentary ($1); }
323 | declmods setspecs notype_initdecls ';'
324 { current_declspecs = TREE_VALUE (declspec_stack);
325 prefix_attributes = TREE_PURPOSE (declspec_stack);
326 declspec_stack = TREE_CHAIN (declspec_stack);
327 resume_momentary ($2); }
328 | typed_declspecs setspecs initdecls ';'
329 { current_declspecs = TREE_VALUE (declspec_stack);
330 prefix_attributes = TREE_PURPOSE (declspec_stack);
331 declspec_stack = TREE_CHAIN (declspec_stack);
332 resume_momentary ($2); }
334 { pedwarn ("empty declaration"); }
335 | typed_declspecs ';'
341 pedwarn ("ANSI C does not allow extra `;' outside of a function"); }
345 typed_declspecs setspecs declarator
346 { if (! start_function ($1, $3, prefix_attributes,
349 reinit_parse_for_function (); }
351 { store_parm_decls (); }
353 { finish_function (0);
354 current_declspecs = TREE_VALUE (declspec_stack);
355 prefix_attributes = TREE_PURPOSE (declspec_stack);
356 declspec_stack = TREE_CHAIN (declspec_stack);
357 resume_momentary ($2); }
358 | typed_declspecs setspecs declarator error
359 { current_declspecs = TREE_VALUE (declspec_stack);
360 prefix_attributes = TREE_PURPOSE (declspec_stack);
361 declspec_stack = TREE_CHAIN (declspec_stack);
362 resume_momentary ($2); }
363 | declmods setspecs notype_declarator
364 { if (! start_function ($1, $3, prefix_attributes,
367 reinit_parse_for_function (); }
369 { store_parm_decls (); }
371 { finish_function (0);
372 current_declspecs = TREE_VALUE (declspec_stack);
373 prefix_attributes = TREE_PURPOSE (declspec_stack);
374 declspec_stack = TREE_CHAIN (declspec_stack);
375 resume_momentary ($2); }
376 | declmods setspecs notype_declarator error
377 { current_declspecs = TREE_VALUE (declspec_stack);
378 prefix_attributes = TREE_PURPOSE (declspec_stack);
379 declspec_stack = TREE_CHAIN (declspec_stack);
380 resume_momentary ($2); }
381 | setspecs notype_declarator
382 { if (! start_function (NULL_TREE, $2,
383 prefix_attributes, NULL_TREE, 0))
385 reinit_parse_for_function (); }
387 { store_parm_decls (); }
389 { finish_function (0);
390 current_declspecs = TREE_VALUE (declspec_stack);
391 prefix_attributes = TREE_PURPOSE (declspec_stack);
392 declspec_stack = TREE_CHAIN (declspec_stack);
393 resume_momentary ($1); }
394 | setspecs notype_declarator error
395 { current_declspecs = TREE_VALUE (declspec_stack);
396 prefix_attributes = TREE_PURPOSE (declspec_stack);
397 declspec_stack = TREE_CHAIN (declspec_stack);
398 resume_momentary ($1); }
413 { $$ = NEGATE_EXPR; }
415 { $$ = CONVERT_EXPR; }
417 { $$ = PREINCREMENT_EXPR; }
419 { $$ = PREDECREMENT_EXPR; }
421 { $$ = BIT_NOT_EXPR; }
423 { $$ = TRUTH_NOT_EXPR; }
426 expr: nonnull_exprlist
427 { $$ = build_compound_expr ($1); }
438 { $$ = build_tree_list (NULL_TREE, $1); }
439 | nonnull_exprlist ',' expr_no_commas
440 { chainon ($1, build_tree_list (NULL_TREE, $3)); }
445 | '*' cast_expr %prec UNARY
446 { $$ = build_indirect_ref ($2, "unary *"); }
447 /* __extension__ turns off -pedantic for following primary. */
449 { $<itype>1 = pedantic;
451 cast_expr %prec UNARY
453 pedantic = $<itype>1; }
454 | unop cast_expr %prec UNARY
455 { $$ = build_unary_op ($1, $2, 0);
456 overflow_warning ($$); }
457 /* Refer to the address of a label as a pointer. */
459 { tree label = lookup_label ($2);
461 pedwarn ("ANSI C forbids `&&'");
463 $$ = null_pointer_node;
466 TREE_USED (label) = 1;
467 $$ = build1 (ADDR_EXPR, ptr_type_node, label);
468 TREE_CONSTANT ($$) = 1;
471 /* This seems to be impossible on some machines, so let's turn it off.
472 You can use __builtin_next_arg to find the anonymous stack args.
474 { tree types = TYPE_ARG_TYPES (TREE_TYPE (current_function_decl));
475 $$ = error_mark_node;
476 if (TREE_VALUE (tree_last (types)) == void_type_node)
477 error ("`&...' used in function with fixed number of arguments");
481 pedwarn ("ANSI C forbids `&...'");
482 $$ = tree_last (DECL_ARGUMENTS (current_function_decl));
483 $$ = build_unary_op (ADDR_EXPR, $$, 0);
486 | SIZEOF unary_expr %prec UNARY
487 { if (TREE_CODE ($2) == COMPONENT_REF
488 && DECL_BIT_FIELD (TREE_OPERAND ($2, 1)))
489 error ("`sizeof' applied to a bit-field");
490 $$ = c_sizeof (TREE_TYPE ($2)); }
491 | SIZEOF '(' typename ')' %prec HYPERUNARY
492 { $$ = c_sizeof (groktypename ($3)); }
493 | ALIGNOF unary_expr %prec UNARY
494 { $$ = c_alignof_expr ($2); }
495 | ALIGNOF '(' typename ')' %prec HYPERUNARY
496 { $$ = c_alignof (groktypename ($3)); }
497 | REALPART cast_expr %prec UNARY
498 { $$ = build_unary_op (REALPART_EXPR, $2, 0); }
499 | IMAGPART cast_expr %prec UNARY
500 { $$ = build_unary_op (IMAGPART_EXPR, $2, 0); }
505 | '(' typename ')' cast_expr %prec UNARY
506 { tree type = groktypename ($2);
507 $$ = build_c_cast (type, $4); }
508 | '(' typename ')' '{'
509 { start_init (NULL_TREE, NULL, 0);
510 $2 = groktypename ($2);
511 really_start_incremental_init ($2); }
512 initlist_maybe_comma '}' %prec UNARY
514 tree result = pop_init_level (0);
519 pedwarn ("ANSI C forbids constructor expressions");
520 if (TYPE_NAME (type) != 0)
522 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
523 name = IDENTIFIER_POINTER (TYPE_NAME (type));
525 name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
530 if (TREE_CODE (type) == ARRAY_TYPE && TYPE_SIZE (type) == 0)
532 int failure = complete_array_type (type, $$, 1);
541 | expr_no_commas '+' expr_no_commas
542 { $$ = parser_build_binary_op ($2, $1, $3); }
543 | expr_no_commas '-' expr_no_commas
544 { $$ = parser_build_binary_op ($2, $1, $3); }
545 | expr_no_commas '*' expr_no_commas
546 { $$ = parser_build_binary_op ($2, $1, $3); }
547 | expr_no_commas '/' expr_no_commas
548 { $$ = parser_build_binary_op ($2, $1, $3); }
549 | expr_no_commas '%' expr_no_commas
550 { $$ = parser_build_binary_op ($2, $1, $3); }
551 | expr_no_commas LSHIFT expr_no_commas
552 { $$ = parser_build_binary_op ($2, $1, $3); }
553 | expr_no_commas RSHIFT expr_no_commas
554 { $$ = parser_build_binary_op ($2, $1, $3); }
555 | expr_no_commas ARITHCOMPARE expr_no_commas
556 { $$ = parser_build_binary_op ($2, $1, $3); }
557 | expr_no_commas EQCOMPARE expr_no_commas
558 { $$ = parser_build_binary_op ($2, $1, $3); }
559 | expr_no_commas '&' expr_no_commas
560 { $$ = parser_build_binary_op ($2, $1, $3); }
561 | expr_no_commas '|' expr_no_commas
562 { $$ = parser_build_binary_op ($2, $1, $3); }
563 | expr_no_commas '^' expr_no_commas
564 { $$ = parser_build_binary_op ($2, $1, $3); }
565 | expr_no_commas ANDAND expr_no_commas
566 { $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $3); }
567 | expr_no_commas OROR expr_no_commas
568 { $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $3); }
569 | expr_no_commas '?' xexpr ':' expr_no_commas
570 { $$ = build_conditional_expr ($1, $3, $5); }
571 | expr_no_commas '=' expr_no_commas
572 { $$ = build_modify_expr ($1, NOP_EXPR, $3);
573 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
574 | expr_no_commas ASSIGN expr_no_commas
575 { $$ = build_modify_expr ($1, $2, $3);
576 /* This inhibits warnings in truthvalue_conversion. */
577 C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK); }
584 if (!$$ || $$ == error_mark_node)
586 if (yychar == YYEMPTY)
593 if (objc_receiver_context
594 && ! (objc_receiver_context
595 && strcmp (IDENTIFIER_POINTER ($1), "super")))
596 /* we have a message to super */
597 $$ = get_super_receiver ();
598 else if (objc_method_context
599 && (decl = is_ivar (objc_ivar_chain, $1)))
601 if (is_private (decl))
602 $$ = error_mark_node;
604 $$ = build_ivar_reference ($1);
609 /* Ordinary implicit function declaration. */
610 $$ = implicitly_declare ($1);
611 assemble_external ($$);
615 else if (current_function_decl == 0)
617 error ("`%s' undeclared here (not in a function)",
618 IDENTIFIER_POINTER ($1));
619 $$ = error_mark_node;
626 if (objc_receiver_context
627 && ! strcmp (IDENTIFIER_POINTER ($1), "super"))
628 /* we have a message to super */
629 $$ = get_super_receiver ();
630 else if (objc_method_context
631 && (decl = is_ivar (objc_ivar_chain, $1)))
633 if (is_private (decl))
634 $$ = error_mark_node;
636 $$ = build_ivar_reference ($1);
641 if (IDENTIFIER_GLOBAL_VALUE ($1) != error_mark_node
642 || IDENTIFIER_ERROR_LOCUS ($1) != current_function_decl)
644 error ("`%s' undeclared (first use this function)",
645 IDENTIFIER_POINTER ($1));
647 if (! undeclared_variable_notice)
649 error ("(Each undeclared identifier is reported only once");
650 error ("for each function it appears in.)");
651 undeclared_variable_notice = 1;
654 $$ = error_mark_node;
655 /* Prevent repeated error messages. */
656 IDENTIFIER_GLOBAL_VALUE ($1) = error_mark_node;
657 IDENTIFIER_ERROR_LOCUS ($1) = current_function_decl;
661 else if (TREE_TYPE ($$) == error_mark_node)
662 $$ = error_mark_node;
663 else if (C_DECL_ANTICIPATED ($$))
665 /* The first time we see a build-in function used,
666 if it has not been declared. */
667 C_DECL_ANTICIPATED ($$) = 0;
668 if (yychar == YYEMPTY)
672 /* Omit the implicit declaration we
673 would ordinarily do, so we don't lose
674 the actual built in type.
675 But print a diagnostic for the mismatch. */
677 if (objc_method_context
678 && is_ivar (objc_ivar_chain, $1))
679 error ("Instance variable `%s' implicitly declared as function",
680 IDENTIFIER_POINTER (DECL_NAME ($$)));
683 if (TREE_CODE ($$) != FUNCTION_DECL)
684 error ("`%s' implicitly declared as function",
685 IDENTIFIER_POINTER (DECL_NAME ($$)));
686 else if ((TYPE_MODE (TREE_TYPE (TREE_TYPE ($$)))
687 != TYPE_MODE (integer_type_node))
688 && (TREE_TYPE (TREE_TYPE ($$))
690 pedwarn ("type mismatch in implicit declaration for built-in function `%s'",
691 IDENTIFIER_POINTER (DECL_NAME ($$)));
692 /* If it really returns void, change that to int. */
693 if (TREE_TYPE (TREE_TYPE ($$)) == void_type_node)
695 = build_function_type (integer_type_node,
696 TYPE_ARG_TYPES (TREE_TYPE ($$)));
699 pedwarn ("built-in function `%s' used without declaration",
700 IDENTIFIER_POINTER (DECL_NAME ($$)));
702 /* Do what we would ordinarily do when a fn is used. */
703 assemble_external ($$);
708 assemble_external ($$);
711 /* we have a definition - still check if iVariable */
713 if (!objc_receiver_context
714 || (objc_receiver_context
715 && strcmp (IDENTIFIER_POINTER ($1), "super")))
719 if (objc_method_context
720 && (decl = is_ivar (objc_ivar_chain, $1)))
722 if (IDENTIFIER_LOCAL_VALUE ($1))
723 warning ("local declaration of `%s' hides instance variable",
724 IDENTIFIER_POINTER ($1));
727 if (is_private (decl))
728 $$ = error_mark_node;
730 $$ = build_ivar_reference ($1);
734 else /* we have a message to super */
735 $$ = get_super_receiver ();
739 if (TREE_CODE ($$) == CONST_DECL)
741 $$ = DECL_INITIAL ($$);
742 /* This is to prevent an enum whose value is 0
743 from being considered a null pointer constant. */
744 $$ = build1 (NOP_EXPR, TREE_TYPE ($$), $$);
745 TREE_CONSTANT ($$) = 1;
750 { $$ = combine_strings ($1); }
752 { char class = TREE_CODE_CLASS (TREE_CODE ($2));
753 if (class == 'e' || class == '1'
754 || class == '2' || class == '<')
755 C_SET_EXP_ORIGINAL_CODE ($2, ERROR_MARK);
758 { $$ = error_mark_node; }
760 { if (current_function_decl == 0)
762 error ("braced-group within expression allowed only inside a function");
765 /* We must force a BLOCK for this level
766 so that, if it is not expanded later,
767 there is a way to turn off the entire subtree of blocks
768 that are contained in it. */
770 push_iterator_stack ();
772 $<ttype>$ = expand_start_stmt_expr (); }
776 pedwarn ("ANSI C forbids braced-groups within expressions");
777 pop_iterator_stack ();
779 rtl_exp = expand_end_stmt_expr ($<ttype>2);
780 /* The statements have side effects, so the group does. */
781 TREE_SIDE_EFFECTS (rtl_exp) = 1;
783 if (TREE_CODE ($3) == BLOCK)
785 /* Make a BIND_EXPR for the BLOCK already made. */
786 $$ = build (BIND_EXPR, TREE_TYPE (rtl_exp),
787 NULL_TREE, rtl_exp, $3);
788 /* Remove the block from the tree at this point.
789 It gets put back at the proper place
790 when the BIND_EXPR is expanded. */
796 | primary '(' exprlist ')' %prec '.'
797 { $$ = build_function_call ($1, $3); }
798 | primary '[' expr ']' %prec '.'
799 { $$ = build_array_ref ($1, $3); }
800 | primary '.' identifier
803 if (doing_objc_thang)
805 if (is_public ($1, $3))
806 $$ = build_component_ref ($1, $3);
808 $$ = error_mark_node;
812 $$ = build_component_ref ($1, $3);
814 | primary POINTSAT identifier
816 tree expr = build_indirect_ref ($1, "->");
819 if (doing_objc_thang)
821 if (is_public (expr, $3))
822 $$ = build_component_ref (expr, $3);
824 $$ = error_mark_node;
828 $$ = build_component_ref (expr, $3);
831 { $$ = build_unary_op (POSTINCREMENT_EXPR, $1, 0); }
833 { $$ = build_unary_op (POSTDECREMENT_EXPR, $1, 0); }
836 { $$ = build_message_expr ($1); }
838 { $$ = build_selector_expr ($1); }
840 { $$ = build_protocol_expr ($1); }
842 { $$ = build_encode_expr ($1); }
844 { $$ = build_objc_string_object ($1); }
848 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
852 { $$ = chainon ($1, $2); }
856 /* Produces an OBJC_STRING_CST with perhaps more OBJC_STRING_CSTs chained
860 | objc_string OBJC_STRING
861 { $$ = chainon ($1, $2); }
869 /* ... is used here to indicate a varargs function. */
872 pedwarn ("ANSI C does not permit use of `varargs.h'"); }
875 /* The following are analogous to lineno_decl, decls and decl
876 except that they do not allow nested functions.
877 They are used for old-style parm decls. */
879 save_filename save_lineno datadecl
886 | datadecls lineno_datadecl
887 | lineno_datadecl errstmt
891 typed_declspecs setspecs initdecls ';'
892 { current_declspecs = TREE_VALUE (declspec_stack);
893 prefix_attributes = TREE_PURPOSE (declspec_stack);
894 declspec_stack = TREE_CHAIN (declspec_stack);
895 resume_momentary ($2); }
896 | declmods setspecs notype_initdecls ';'
897 { current_declspecs = TREE_VALUE (declspec_stack);
898 prefix_attributes = TREE_PURPOSE (declspec_stack);
899 declspec_stack = TREE_CHAIN (declspec_stack);
900 resume_momentary ($2); }
901 | typed_declspecs ';'
902 { shadow_tag_warned ($1, 1);
903 pedwarn ("empty declaration"); }
905 { pedwarn ("empty declaration"); }
908 /* This combination which saves a lineno before a decl
909 is the normal thing to use, rather than decl itself.
910 This is to avoid shift/reduce conflicts in contexts
911 where statement labels are allowed. */
913 save_filename save_lineno decl
921 | lineno_decl errstmt
924 /* records the type and storage class specs to use for processing
925 the declarators that follow.
926 Maintains a stack of outer-level values of current_declspecs,
927 for the sake of parm declarations nested in function declarators. */
928 setspecs: /* empty */
929 { $$ = suspend_momentary ();
930 pending_xref_error ();
931 declspec_stack = tree_cons (prefix_attributes,
934 current_declspecs = $<ttype>0;
935 prefix_attributes = NULL_TREE; }
938 setattrs: /* empty */
939 { prefix_attributes = chainon (prefix_attributes, $<ttype>0); }
943 typed_declspecs setspecs initdecls ';'
944 { current_declspecs = TREE_VALUE (declspec_stack);
945 prefix_attributes = TREE_PURPOSE (declspec_stack);
946 declspec_stack = TREE_CHAIN (declspec_stack);
947 resume_momentary ($2); }
948 | declmods setspecs notype_initdecls ';'
949 { current_declspecs = TREE_VALUE (declspec_stack);
950 prefix_attributes = TREE_PURPOSE (declspec_stack);
951 declspec_stack = TREE_CHAIN (declspec_stack);
952 resume_momentary ($2); }
953 | typed_declspecs setspecs nested_function
954 { current_declspecs = TREE_VALUE (declspec_stack);
955 prefix_attributes = TREE_PURPOSE (declspec_stack);
956 declspec_stack = TREE_CHAIN (declspec_stack);
957 resume_momentary ($2); }
958 | declmods setspecs notype_nested_function
959 { current_declspecs = TREE_VALUE (declspec_stack);
960 prefix_attributes = TREE_PURPOSE (declspec_stack);
961 declspec_stack = TREE_CHAIN (declspec_stack);
962 resume_momentary ($2); }
963 | typed_declspecs ';'
966 { pedwarn ("empty declaration"); }
969 /* Declspecs which contain at least one type specifier or typedef name.
970 (Just `const' or `volatile' is not enough.)
971 A typedef'd name following these is taken as a name to be declared. */
974 typespec reserved_declspecs
975 { $$ = tree_cons (NULL_TREE, $1, $2); }
976 | declmods typespec reserved_declspecs
977 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
980 reserved_declspecs: /* empty */
982 | reserved_declspecs typespecqual_reserved
983 { $$ = tree_cons (NULL_TREE, $2, $1); }
984 | reserved_declspecs SCSPEC
985 { if (extra_warnings)
986 warning ("`%s' is not at beginning of declaration",
987 IDENTIFIER_POINTER ($2));
988 $$ = tree_cons (NULL_TREE, $2, $1); }
991 /* List of just storage classes and type modifiers.
992 A declaration can start with just this, but then it cannot be used
993 to redeclare a typedef-name. */
997 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
998 TREE_STATIC ($$) = 1; }
1000 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
1001 | declmods TYPE_QUAL
1002 { $$ = tree_cons (NULL_TREE, $2, $1);
1003 TREE_STATIC ($$) = 1; }
1005 { if (extra_warnings && TREE_STATIC ($1))
1006 warning ("`%s' is not at beginning of declaration",
1007 IDENTIFIER_POINTER ($2));
1008 $$ = tree_cons (NULL_TREE, $2, $1);
1009 TREE_STATIC ($$) = TREE_STATIC ($1); }
1013 /* Used instead of declspecs where storage classes are not allowed
1014 (that is, for typenames and structure components).
1015 Don't accept a typedef-name if anything but a modifier precedes it. */
1018 typespec reserved_typespecquals
1019 { $$ = tree_cons (NULL_TREE, $1, $2); }
1020 | nonempty_type_quals typespec reserved_typespecquals
1021 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
1024 reserved_typespecquals: /* empty */
1026 | reserved_typespecquals typespecqual_reserved
1027 { $$ = tree_cons (NULL_TREE, $2, $1); }
1030 /* A typespec (but not a type qualifier).
1031 Once we have seen one of these in a declaration,
1032 if a typedef name appears then it is being redeclared. */
1037 { /* For a typedef name, record the meaning, not the name.
1038 In case of `foo foo, bar;'. */
1039 $$ = lookup_name ($1); }
1041 | CLASSNAME protocolrefs
1042 { $$ = get_static_reference ($1, $2); }
1043 | OBJECTNAME protocolrefs
1044 { $$ = get_object_reference ($2); }
1046 /* Make "<SomeProtocol>" equivalent to "id <SomeProtocol>"
1047 - nisse@lysator.liu.se */
1048 | non_empty_protocolrefs
1049 { $$ = get_object_reference ($1); }
1051 | TYPEOF '(' expr ')'
1052 { $$ = TREE_TYPE ($3); }
1053 | TYPEOF '(' typename ')'
1054 { $$ = groktypename ($3); }
1057 /* A typespec that is a reserved word, or a type qualifier. */
1059 typespecqual_reserved: TYPESPEC
1066 | initdecls ',' initdcl
1071 | notype_initdecls ',' initdcl
1077 | ASM_KEYWORD '(' string ')'
1078 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
1084 declarator maybeasm maybe_attribute '='
1085 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1086 $3, prefix_attributes);
1087 start_init ($<ttype>$, $2, global_bindings_p ()); }
1089 /* Note how the declaration of the variable is in effect while its init is parsed! */
1091 finish_decl ($<ttype>5, $6, $2); }
1092 | declarator maybeasm maybe_attribute
1093 { tree d = start_decl ($1, current_declspecs, 0,
1094 $3, prefix_attributes);
1095 finish_decl (d, NULL_TREE, $2);
1100 notype_declarator maybeasm maybe_attribute '='
1101 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1102 $3, prefix_attributes);
1103 start_init ($<ttype>$, $2, global_bindings_p ()); }
1105 /* Note how the declaration of the variable is in effect while its init is parsed! */
1107 decl_attributes ($<ttype>5, $3, prefix_attributes);
1108 finish_decl ($<ttype>5, $6, $2); }
1109 | notype_declarator maybeasm maybe_attribute
1110 { tree d = start_decl ($1, current_declspecs, 0,
1111 $3, prefix_attributes);
1112 finish_decl (d, NULL_TREE, $2); }
1114 /* the * rules are dummies to accept the Apollo extended syntax
1115 so that the header files compile. */
1126 | attributes attribute
1127 { $$ = chainon ($1, $2); }
1131 ATTRIBUTE '(' '(' attribute_list ')' ')'
1138 | attribute_list ',' attrib
1139 { $$ = chainon ($1, $3); }
1146 { $$ = build_tree_list ($1, NULL_TREE); }
1147 | any_word '(' IDENTIFIER ')'
1148 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1149 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1150 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1151 | any_word '(' exprlist ')'
1152 { $$ = build_tree_list ($1, $3); }
1155 /* This still leaves out most reserved keywords,
1156 shouldn't we include them? */
1165 /* Initializers. `init' is the entry point. */
1170 { really_start_incremental_init (NULL_TREE);
1171 /* Note that the call to clear_momentary
1172 is in process_init_element. */
1173 push_momentary (); }
1174 initlist_maybe_comma '}'
1175 { $$ = pop_init_level (0);
1176 if ($$ == error_mark_node
1177 && ! (yychar == STRING || yychar == CONSTANT))
1180 pop_momentary_nofree (); }
1183 { $$ = error_mark_node; }
1186 /* `initlist_maybe_comma' is the guts of an initializer in braces. */
1187 initlist_maybe_comma:
1190 pedwarn ("ANSI C forbids empty initializer braces"); }
1191 | initlist1 maybecomma
1196 | initlist1 ',' initelt
1199 /* `initelt' is a single element of an initializer.
1200 It may use braces. */
1203 { process_init_element ($1); }
1205 { push_init_level (0); }
1206 initlist_maybe_comma '}'
1207 { process_init_element (pop_init_level (0)); }
1209 /* These are for labeled elements. The syntax for an array element
1210 initializer conflicts with the syntax for an Objective-C message,
1211 so don't include these productions in the Objective-C grammar. */
1213 | '[' expr_no_commas ELLIPSIS expr_no_commas ']' '='
1214 { set_init_index ($2, $4); }
1216 | '[' expr_no_commas ']' '='
1217 { set_init_index ($2, NULL_TREE); }
1219 | '[' expr_no_commas ']'
1220 { set_init_index ($2, NULL_TREE); }
1224 { set_init_label ($1); }
1226 | '.' identifier '='
1227 { set_init_label ($2); }
1233 { push_c_function_context ();
1234 if (! start_function (current_declspecs, $1,
1235 prefix_attributes, NULL_TREE, 1))
1237 pop_c_function_context ();
1240 reinit_parse_for_function (); }
1242 { store_parm_decls (); }
1243 /* This used to use compstmt_or_error.
1244 That caused a bug with input `f(g) int g {}',
1245 where the use of YYERROR1 above caused an error
1246 which then was handled by compstmt_or_error.
1247 There followed a repeated execution of that same rule,
1248 which called YYERROR1 again, and so on. */
1250 { finish_function (1);
1251 pop_c_function_context (); }
1254 notype_nested_function:
1256 { push_c_function_context ();
1257 if (! start_function (current_declspecs, $1,
1258 prefix_attributes, NULL_TREE, 1))
1260 pop_c_function_context ();
1263 reinit_parse_for_function (); }
1265 { store_parm_decls (); }
1266 /* This used to use compstmt_or_error.
1267 That caused a bug with input `f(g) int g {}',
1268 where the use of YYERROR1 above caused an error
1269 which then was handled by compstmt_or_error.
1270 There followed a repeated execution of that same rule,
1271 which called YYERROR1 again, and so on. */
1273 { finish_function (1);
1274 pop_c_function_context (); }
1277 /* Any kind of declarator (thus, all declarators allowed
1278 after an explicit typespec). */
1281 after_type_declarator
1285 /* A declarator that is allowed only after an explicit typespec. */
1287 after_type_declarator:
1288 '(' after_type_declarator ')'
1290 | after_type_declarator '(' parmlist_or_identifiers %prec '.'
1291 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1292 /* | after_type_declarator '(' error ')' %prec '.'
1293 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1294 poplevel (0, 0, 0); } */
1295 | after_type_declarator '[' expr ']' %prec '.'
1296 { $$ = build_nt (ARRAY_REF, $1, $3); }
1297 | after_type_declarator '[' ']' %prec '.'
1298 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1299 | '*' type_quals after_type_declarator %prec UNARY
1300 { $$ = make_pointer_declarator ($2, $3); }
1301 | attributes setattrs after_type_declarator
1309 /* Kinds of declarator that can appear in a parameter list
1310 in addition to notype_declarator. This is like after_type_declarator
1311 but does not allow a typedef name in parentheses as an identifier
1312 (because it would conflict with a function with that typedef as arg). */
1315 parm_declarator '(' parmlist_or_identifiers %prec '.'
1316 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1317 /* | parm_declarator '(' error ')' %prec '.'
1318 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1319 poplevel (0, 0, 0); } */
1320 | parm_declarator '[' expr ']' %prec '.'
1321 { $$ = build_nt (ARRAY_REF, $1, $3); }
1322 | parm_declarator '[' ']' %prec '.'
1323 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1324 | '*' type_quals parm_declarator %prec UNARY
1325 { $$ = make_pointer_declarator ($2, $3); }
1326 | attributes setattrs parm_declarator
1331 /* A declarator allowed whether or not there has been
1332 an explicit typespec. These cannot redeclare a typedef-name. */
1335 notype_declarator '(' parmlist_or_identifiers %prec '.'
1336 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1337 /* | notype_declarator '(' error ')' %prec '.'
1338 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1339 poplevel (0, 0, 0); } */
1340 | '(' notype_declarator ')'
1342 | '*' type_quals notype_declarator %prec UNARY
1343 { $$ = make_pointer_declarator ($2, $3); }
1344 | notype_declarator '[' expr ']' %prec '.'
1345 { $$ = build_nt (ARRAY_REF, $1, $3); }
1346 | notype_declarator '[' ']' %prec '.'
1347 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1348 | attributes setattrs notype_declarator
1354 STRUCT identifier '{'
1355 { $$ = start_struct (RECORD_TYPE, $2);
1356 /* Start scope of tag before parsing components. */
1358 component_decl_list '}' maybe_attribute
1359 { $$ = finish_struct ($<ttype>4, $5, $7); }
1360 | STRUCT '{' component_decl_list '}' maybe_attribute
1361 { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
1365 { $$ = xref_tag (RECORD_TYPE, $2); }
1366 | UNION identifier '{'
1367 { $$ = start_struct (UNION_TYPE, $2); }
1368 component_decl_list '}' maybe_attribute
1369 { $$ = finish_struct ($<ttype>4, $5, $7); }
1370 | UNION '{' component_decl_list '}' maybe_attribute
1371 { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
1375 { $$ = xref_tag (UNION_TYPE, $2); }
1376 | ENUM identifier '{'
1377 { $<itype>3 = suspend_momentary ();
1378 $$ = start_enum ($2); }
1379 enumlist maybecomma_warn '}' maybe_attribute
1380 { $$ = finish_enum ($<ttype>4, nreverse ($5), $8);
1381 resume_momentary ($<itype>3); }
1383 { $<itype>2 = suspend_momentary ();
1384 $$ = start_enum (NULL_TREE); }
1385 enumlist maybecomma_warn '}' maybe_attribute
1386 { $$ = finish_enum ($<ttype>3, nreverse ($4), $7);
1387 resume_momentary ($<itype>2); }
1389 { $$ = xref_tag (ENUMERAL_TYPE, $2); }
1400 { if (pedantic) pedwarn ("comma at end of enumerator list"); }
1403 component_decl_list:
1404 component_decl_list2
1406 | component_decl_list2 component_decl
1407 { $$ = chainon ($1, $2);
1408 pedwarn ("no semicolon at end of struct or union"); }
1411 component_decl_list2: /* empty */
1413 | component_decl_list2 component_decl ';'
1414 { $$ = chainon ($1, $2); }
1415 | component_decl_list2 ';'
1417 pedwarn ("extra semicolon in struct or union specified"); }
1419 /* foo(sizeof(struct{ @defs(ClassName)})); */
1420 | DEFS '(' CLASSNAME ')'
1422 tree interface = lookup_interface ($3);
1425 $$ = get_class_ivars (interface);
1428 error ("Cannot find interface declaration for `%s'",
1429 IDENTIFIER_POINTER ($3));
1436 /* There is a shift-reduce conflict here, because `components' may
1437 start with a `typename'. It happens that shifting (the default resolution)
1438 does the right thing, because it treats the `typename' as part of
1439 a `typed_typespecs'.
1441 It is possible that this same technique would allow the distinction
1442 between `notype_initdecls' and `initdecls' to be eliminated.
1443 But I am being cautious and not trying it. */
1446 typed_typespecs setspecs components
1448 current_declspecs = TREE_VALUE (declspec_stack);
1449 prefix_attributes = TREE_PURPOSE (declspec_stack);
1450 declspec_stack = TREE_CHAIN (declspec_stack);
1451 resume_momentary ($2); }
1454 pedwarn ("ANSI C forbids member declarations with no members");
1457 | nonempty_type_quals setspecs components
1459 current_declspecs = TREE_VALUE (declspec_stack);
1460 prefix_attributes = TREE_PURPOSE (declspec_stack);
1461 declspec_stack = TREE_CHAIN (declspec_stack);
1462 resume_momentary ($2); }
1463 | nonempty_type_quals
1465 pedwarn ("ANSI C forbids member declarations with no members");
1473 component_declarator
1474 | components ',' component_declarator
1475 { $$ = chainon ($1, $3); }
1478 component_declarator:
1479 save_filename save_lineno declarator maybe_attribute
1480 { $$ = grokfield ($1, $2, $3, current_declspecs, NULL_TREE);
1481 decl_attributes ($$, $4, prefix_attributes); }
1482 | save_filename save_lineno
1483 declarator ':' expr_no_commas maybe_attribute
1484 { $$ = grokfield ($1, $2, $3, current_declspecs, $5);
1485 decl_attributes ($$, $6, prefix_attributes); }
1486 | save_filename save_lineno ':' expr_no_commas maybe_attribute
1487 { $$ = grokfield ($1, $2, NULL_TREE, current_declspecs, $4);
1488 decl_attributes ($$, $5, prefix_attributes); }
1491 /* We chain the enumerators in reverse order.
1492 They are put in forward order where enumlist is used.
1493 (The order used to be significant, but no longer is so.
1494 However, we still maintain the order, just to be clean.) */
1498 | enumlist ',' enumerator
1499 { if ($1 == error_mark_node)
1502 $$ = chainon ($3, $1); }
1504 { $$ = error_mark_node; }
1510 { $$ = build_enumerator ($1, NULL_TREE); }
1511 | identifier '=' expr_no_commas
1512 { $$ = build_enumerator ($1, $3); }
1516 typed_typespecs absdcl
1517 { $$ = build_tree_list ($1, $2); }
1518 | nonempty_type_quals absdcl
1519 { $$ = build_tree_list ($1, $2); }
1522 absdcl: /* an absolute declarator */
1528 nonempty_type_quals:
1530 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
1531 | nonempty_type_quals TYPE_QUAL
1532 { $$ = tree_cons (NULL_TREE, $2, $1); }
1538 | type_quals TYPE_QUAL
1539 { $$ = tree_cons (NULL_TREE, $2, $1); }
1542 absdcl1: /* a nonempty absolute declarator */
1545 /* `(typedef)1' is `int'. */
1546 | '*' type_quals absdcl1 %prec UNARY
1547 { $$ = make_pointer_declarator ($2, $3); }
1548 | '*' type_quals %prec UNARY
1549 { $$ = make_pointer_declarator ($2, NULL_TREE); }
1550 | absdcl1 '(' parmlist %prec '.'
1551 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1552 | absdcl1 '[' expr ']' %prec '.'
1553 { $$ = build_nt (ARRAY_REF, $1, $3); }
1554 | absdcl1 '[' ']' %prec '.'
1555 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1556 | '(' parmlist %prec '.'
1557 { $$ = build_nt (CALL_EXPR, NULL_TREE, $2, NULL_TREE); }
1558 | '[' expr ']' %prec '.'
1559 { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
1561 { $$ = build_nt (ARRAY_REF, NULL_TREE, NULL_TREE); }
1562 | attributes setattrs absdcl1
1566 /* at least one statement, the first of which parses without error. */
1567 /* stmts is used only after decls, so an invalid first statement
1568 is actually regarded as an invalid decl and part of the decls. */
1571 lineno_stmt_or_labels
1574 pedwarn ("ANSI C forbids label at end of compound statement");
1578 lineno_stmt_or_labels:
1579 lineno_stmt_or_label
1580 | lineno_stmt_or_labels lineno_stmt_or_label
1582 | lineno_stmt_or_labels errstmt
1594 pushlevel: /* empty */
1595 { emit_line_note (input_filename, lineno);
1599 expand_start_bindings (0);
1601 if (objc_method_context)
1607 /* Read zero or more forward-declarations for labels
1608 that nested functions can jump to. */
1613 pedwarn ("ANSI C forbids label declarations"); }
1618 | label_decls label_decl
1622 LABEL identifiers_or_typenames ';'
1624 for (link = $2; link; link = TREE_CHAIN (link))
1626 tree label = shadow_label (TREE_VALUE (link));
1627 C_DECLARED_LABEL_FLAG (label) = 1;
1628 declare_nonlocal_label (label);
1633 /* This is the body of a function definition.
1634 It causes syntax errors to ignore to the next openbrace. */
1642 { $$ = convert (void_type_node, integer_zero_node); }
1643 | '{' pushlevel maybe_label_decls decls xstmts '}'
1644 { emit_line_note (input_filename, lineno);
1645 expand_end_bindings (getdecls (), 1, 0);
1646 $$ = poplevel (1, 1, 0);
1647 if (yychar == CONSTANT || yychar == STRING)
1648 pop_momentary_nofree ();
1651 | '{' pushlevel maybe_label_decls error '}'
1652 { emit_line_note (input_filename, lineno);
1653 expand_end_bindings (getdecls (), kept_level_p (), 0);
1654 $$ = poplevel (kept_level_p (), 0, 0);
1655 if (yychar == CONSTANT || yychar == STRING)
1656 pop_momentary_nofree ();
1659 | '{' pushlevel maybe_label_decls stmts '}'
1660 { emit_line_note (input_filename, lineno);
1661 expand_end_bindings (getdecls (), kept_level_p (), 0);
1662 $$ = poplevel (kept_level_p (), 0, 0);
1663 if (yychar == CONSTANT || yychar == STRING)
1664 pop_momentary_nofree ();
1669 /* Value is number of statements counted as of the closeparen. */
1671 if_prefix lineno_labeled_stmt
1672 /* Make sure expand_end_cond is run once
1673 for each call to expand_start_cond.
1674 Otherwise a crash is likely. */
1680 { emit_line_note ($<filename>-1, $<lineno>0);
1681 expand_start_cond (truthvalue_conversion ($3), 0);
1682 $<itype>$ = stmt_count;
1683 if_stmt_file = $<filename>-1;
1684 if_stmt_line = $<lineno>0;
1685 position_after_white_space (); }
1688 /* This is a subroutine of stmt.
1689 It is used twice, once for valid DO statements
1690 and once for catching errors in parsing the end test. */
1694 emit_line_note ($<filename>-1, $<lineno>0);
1695 /* See comment in `while' alternative, above. */
1697 expand_start_loop_continue_elsewhere (1);
1698 position_after_white_space (); }
1699 lineno_labeled_stmt WHILE
1700 { expand_loop_continue_here (); }
1704 { $$ = input_filename; }
1711 lineno_labeled_stmt:
1712 save_filename save_lineno stmt
1714 /* | save_filename save_lineno error
1717 | save_filename save_lineno label lineno_labeled_stmt
1721 lineno_stmt_or_label:
1722 save_filename save_lineno stmt_or_label
1733 /* Parse a single real statement, not including any labels. */
1740 emit_line_note ($<filename>-1, $<lineno>0);
1741 /* It appears that this should not be done--that a non-lvalue array
1742 shouldn't get an error if the value isn't used.
1743 Section 3.2.2.1 says that an array lvalue gets converted to a pointer
1744 if it appears as a top-level expression,
1745 but says nothing about non-lvalue arrays. */
1747 /* Call default_conversion to get an error
1748 on referring to a register array if pedantic. */
1749 if (TREE_CODE (TREE_TYPE ($1)) == ARRAY_TYPE
1750 || TREE_CODE (TREE_TYPE ($1)) == FUNCTION_TYPE)
1751 $1 = default_conversion ($1);
1753 iterator_expand ($1);
1754 clear_momentary (); }
1756 { expand_start_else ();
1757 $<itype>1 = stmt_count;
1758 position_after_white_space (); }
1760 { expand_end_cond ();
1761 if (extra_warnings && stmt_count == $<itype>1)
1762 warning ("empty body in an else-statement"); }
1763 | simple_if %prec IF
1764 { expand_end_cond ();
1765 /* This warning is here instead of in simple_if, because we
1766 do not want a warning if an empty if is followed by an
1767 else statement. Increment stmt_count so we don't
1768 give a second error if this is a nested `if'. */
1769 if (extra_warnings && stmt_count++ == $<itype>1)
1770 warning_with_file_and_line (if_stmt_file, if_stmt_line,
1771 "empty body in an if-statement"); }
1772 /* Make sure expand_end_cond is run once
1773 for each call to expand_start_cond.
1774 Otherwise a crash is likely. */
1775 | simple_if ELSE error
1776 { expand_end_cond (); }
1779 emit_line_note ($<filename>-1, $<lineno>0);
1780 /* The emit_nop used to come before emit_line_note,
1781 but that made the nop seem like part of the preceding line.
1782 And that was confusing when the preceding line was
1783 inside of an if statement and was not really executed.
1784 I think it ought to work to put the nop after the line number.
1785 We will see. --rms, July 15, 1991. */
1788 { /* Don't start the loop till we have succeeded
1789 in parsing the end test. This is to make sure
1790 that we end every loop we start. */
1791 expand_start_loop (1);
1792 emit_line_note (input_filename, lineno);
1793 expand_exit_loop_if_false (NULL_PTR,
1794 truthvalue_conversion ($4));
1795 position_after_white_space (); }
1797 { expand_end_loop (); }
1800 { emit_line_note (input_filename, lineno);
1801 expand_exit_loop_if_false (NULL_PTR,
1802 truthvalue_conversion ($3));
1804 clear_momentary (); }
1805 /* This rule is needed to make sure we end every loop we start. */
1806 | do_stmt_start error
1807 { expand_end_loop ();
1808 clear_momentary (); }
1812 emit_line_note ($<filename>-1, $<lineno>0);
1813 /* See comment in `while' alternative, above. */
1815 if ($3) c_expand_expr_stmt ($3);
1816 /* Next step is to call expand_start_loop_continue_elsewhere,
1817 but wait till after we parse the entire for (...).
1818 Otherwise, invalid input might cause us to call that
1819 fn without calling expand_end_loop. */
1822 /* Can't emit now; wait till after expand_start_loop... */
1823 { $<lineno>7 = lineno;
1824 $<filename>$ = input_filename; }
1827 /* Start the loop. Doing this after parsing
1828 all the expressions ensures we will end the loop. */
1829 expand_start_loop_continue_elsewhere (1);
1830 /* Emit the end-test, with a line number. */
1831 emit_line_note ($<filename>8, $<lineno>7);
1833 expand_exit_loop_if_false (NULL_PTR,
1834 truthvalue_conversion ($6));
1835 /* Don't let the tree nodes for $9 be discarded by
1836 clear_momentary during the parsing of the next stmt. */
1838 $<lineno>7 = lineno;
1839 $<filename>8 = input_filename;
1840 position_after_white_space (); }
1842 { /* Emit the increment expression, with a line number. */
1843 emit_line_note ($<filename>8, $<lineno>7);
1844 expand_loop_continue_here ();
1846 c_expand_expr_stmt ($9);
1847 if (yychar == CONSTANT || yychar == STRING)
1848 pop_momentary_nofree ();
1851 expand_end_loop (); }
1852 | SWITCH '(' expr ')'
1854 emit_line_note ($<filename>-1, $<lineno>0);
1855 c_expand_start_case ($3);
1856 /* Don't let the tree nodes for $3 be discarded by
1857 clear_momentary during the parsing of the next stmt. */
1859 position_after_white_space (); }
1861 { expand_end_case ($3);
1862 if (yychar == CONSTANT || yychar == STRING)
1863 pop_momentary_nofree ();
1868 emit_line_note ($<filename>-1, $<lineno>0);
1869 if ( ! expand_exit_something ())
1870 error ("break statement not within loop or switch"); }
1873 emit_line_note ($<filename>-1, $<lineno>0);
1874 if (! expand_continue_loop (NULL_PTR))
1875 error ("continue statement not within a loop"); }
1878 emit_line_note ($<filename>-1, $<lineno>0);
1879 c_expand_return (NULL_TREE); }
1882 emit_line_note ($<filename>-1, $<lineno>0);
1883 c_expand_return ($2); }
1884 | ASM_KEYWORD maybe_type_qual '(' expr ')' ';'
1886 emit_line_note ($<filename>-1, $<lineno>0);
1888 if ((TREE_CODE ($4) == ADDR_EXPR
1889 && TREE_CODE (TREE_OPERAND ($4, 0)) == STRING_CST)
1890 || TREE_CODE ($4) == STRING_CST)
1893 error ("argument of `asm' is not a constant string"); }
1894 /* This is the case with just output operands. */
1895 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ')' ';'
1897 emit_line_note ($<filename>-1, $<lineno>0);
1898 c_expand_asm_operands ($4, $6, NULL_TREE, NULL_TREE,
1899 $2 == ridpointers[(int)RID_VOLATILE],
1900 input_filename, lineno); }
1901 /* This is the case with input operands as well. */
1902 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':' asm_operands ')' ';'
1904 emit_line_note ($<filename>-1, $<lineno>0);
1905 c_expand_asm_operands ($4, $6, $8, NULL_TREE,
1906 $2 == ridpointers[(int)RID_VOLATILE],
1907 input_filename, lineno); }
1908 /* This is the case with clobbered registers as well. */
1909 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':'
1910 asm_operands ':' asm_clobbers ')' ';'
1912 emit_line_note ($<filename>-1, $<lineno>0);
1913 c_expand_asm_operands ($4, $6, $8, $10,
1914 $2 == ridpointers[(int)RID_VOLATILE],
1915 input_filename, lineno); }
1916 | GOTO identifier ';'
1919 emit_line_note ($<filename>-1, $<lineno>0);
1920 decl = lookup_label ($2);
1923 TREE_USED (decl) = 1;
1929 pedwarn ("ANSI C forbids `goto *expr;'");
1931 emit_line_note ($<filename>-1, $<lineno>0);
1932 expand_computed_goto (convert (ptr_type_node, $3)); }
1937 all_iter_stmt_simple
1938 /* | all_iter_stmt_with_decl */
1941 all_iter_stmt_simple:
1944 /* The value returned by this action is */
1945 /* 1 if everything is OK */
1946 /* 0 in case of error or already bound iterator */
1949 if (TREE_CODE ($3) != VAR_DECL)
1950 error ("invalid `for (ITERATOR)' syntax");
1951 else if (! ITERATOR_P ($3))
1952 error ("`%s' is not an iterator",
1953 IDENTIFIER_POINTER (DECL_NAME ($3)));
1954 else if (ITERATOR_BOUND_P ($3))
1955 error ("`for (%s)' inside expansion of same iterator",
1956 IDENTIFIER_POINTER (DECL_NAME ($3)));
1960 iterator_for_loop_start ($3);
1966 iterator_for_loop_end ($3);
1969 /* This really should allow any kind of declaration,
1970 for generality. Fix it before turning it back on.
1972 all_iter_stmt_with_decl:
1973 FOR '(' ITERATOR pushlevel setspecs iterator_spec ')'
1975 */ /* The value returned by this action is */
1976 /* 1 if everything is OK */
1977 /* 0 in case of error or already bound iterator */
1979 iterator_for_loop_start ($6);
1983 iterator_for_loop_end ($6);
1984 emit_line_note (input_filename, lineno);
1985 expand_end_bindings (getdecls (), 1, 0);
1986 $<ttype>$ = poplevel (1, 1, 0);
1987 if (yychar == CONSTANT || yychar == STRING)
1988 pop_momentary_nofree ();
1994 /* Any kind of label, including jump labels and case labels.
1995 ANSI C accepts labels only before statements, but we allow them
1996 also at the end of a compound statement. */
1998 label: CASE expr_no_commas ':'
1999 { register tree value = check_case_value ($2);
2001 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
2005 if (value != error_mark_node)
2008 int success = pushcase (value, convert_and_check,
2011 error ("case label not within a switch statement");
2012 else if (success == 2)
2014 error ("duplicate case value");
2015 error_with_decl (duplicate, "this is the first entry for that value");
2017 else if (success == 3)
2018 warning ("case value out of range");
2019 else if (success == 5)
2020 error ("case label within scope of cleanup or variable array");
2022 position_after_white_space (); }
2023 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
2024 { register tree value1 = check_case_value ($2);
2025 register tree value2 = check_case_value ($4);
2027 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
2030 pedwarn ("ANSI C forbids case ranges");
2033 if (value1 != error_mark_node && value2 != error_mark_node)
2036 int success = pushcase_range (value1, value2,
2037 convert_and_check, label,
2040 error ("case label not within a switch statement");
2041 else if (success == 2)
2043 error ("duplicate case value");
2044 error_with_decl (duplicate, "this is the first entry for that value");
2046 else if (success == 3)
2047 warning ("case value out of range");
2048 else if (success == 4)
2049 warning ("empty case range");
2050 else if (success == 5)
2051 error ("case label within scope of cleanup or variable array");
2053 position_after_white_space (); }
2058 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
2059 int success = pushcase (NULL_TREE, 0, label, &duplicate);
2062 error ("default label not within a switch statement");
2063 else if (success == 2)
2065 error ("multiple default labels in one switch");
2066 error_with_decl (duplicate, "this is the first default label");
2068 position_after_white_space (); }
2070 { tree label = define_label (input_filename, lineno, $1);
2074 expand_label (label);
2075 position_after_white_space (); }
2078 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
2082 { emit_line_note (input_filename, lineno);
2085 { emit_line_note (input_filename, lineno); }
2094 /* These are the operands other than the first string and colon
2095 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
2096 asm_operands: /* empty */
2098 | nonnull_asm_operands
2101 nonnull_asm_operands:
2103 | nonnull_asm_operands ',' asm_operand
2104 { $$ = chainon ($1, $3); }
2109 { $$ = build_tree_list ($1, $3); }
2114 { $$ = tree_cons (NULL_TREE, combine_strings ($1), NULL_TREE); }
2115 | asm_clobbers ',' string
2116 { $$ = tree_cons (NULL_TREE, combine_strings ($3), $1); }
2119 /* This is what appears inside the parens in a function declarator.
2120 Its value is a list of ..._TYPE nodes. */
2123 clear_parm_order ();
2124 declare_parm_level (0); }
2127 parmlist_tags_warning ();
2128 poplevel (0, 0, 0); }
2136 pedwarn ("ANSI C forbids forward parameter declarations");
2137 /* Mark the forward decls as such. */
2138 for (parm = getdecls (); parm; parm = TREE_CHAIN (parm))
2139 TREE_ASM_WRITTEN (parm) = 1;
2140 clear_parm_order (); }
2144 { $$ = tree_cons (NULL_TREE, NULL_TREE, NULL_TREE); }
2147 /* This is what appears inside the parens in a function declarator.
2148 Is value is represented in the format that grokdeclarator expects. */
2149 parmlist_2: /* empty */
2150 { $$ = get_parm_info (0); }
2152 { $$ = get_parm_info (0);
2153 /* Gcc used to allow this as an extension. However, it does
2154 not work for all targets, and thus has been disabled.
2155 Also, since func (...) and func () are indistinguishable,
2156 it caused problems with the code in expand_builtin which
2157 tries to verify that BUILT_IN_NEXT_ARG is being used
2159 error ("ANSI C requires a named argument before `...'");
2162 { $$ = get_parm_info (1); }
2163 | parms ',' ELLIPSIS
2164 { $$ = get_parm_info (0); }
2169 { push_parm_decl ($1); }
2171 { push_parm_decl ($3); }
2174 /* A single parameter declaration or parameter type name,
2175 as found in a parmlist. */
2177 typed_declspecs setspecs parm_declarator maybe_attribute
2178 { $$ = build_tree_list (build_tree_list (current_declspecs,
2180 build_tree_list (prefix_attributes,
2182 current_declspecs = TREE_VALUE (declspec_stack);
2183 prefix_attributes = TREE_PURPOSE (declspec_stack);
2184 declspec_stack = TREE_CHAIN (declspec_stack);
2185 resume_momentary ($2); }
2186 | typed_declspecs setspecs notype_declarator maybe_attribute
2187 { $$ = build_tree_list (build_tree_list (current_declspecs,
2189 build_tree_list (prefix_attributes,
2191 current_declspecs = TREE_VALUE (declspec_stack);
2192 prefix_attributes = TREE_PURPOSE (declspec_stack);
2193 declspec_stack = TREE_CHAIN (declspec_stack);
2194 resume_momentary ($2); }
2195 | typed_declspecs setspecs absdcl maybe_attribute
2196 { $$ = build_tree_list (build_tree_list (current_declspecs,
2198 build_tree_list (prefix_attributes,
2200 current_declspecs = TREE_VALUE (declspec_stack);
2201 prefix_attributes = TREE_PURPOSE (declspec_stack);
2202 declspec_stack = TREE_CHAIN (declspec_stack);
2203 resume_momentary ($2); }
2204 | declmods setspecs notype_declarator maybe_attribute
2205 { $$ = build_tree_list (build_tree_list (current_declspecs,
2207 build_tree_list (prefix_attributes,
2209 current_declspecs = TREE_VALUE (declspec_stack);
2210 prefix_attributes = TREE_PURPOSE (declspec_stack);
2211 declspec_stack = TREE_CHAIN (declspec_stack);
2212 resume_momentary ($2); }
2214 | declmods setspecs absdcl maybe_attribute
2215 { $$ = build_tree_list (build_tree_list (current_declspecs,
2217 build_tree_list (prefix_attributes,
2219 current_declspecs = TREE_VALUE (declspec_stack);
2220 prefix_attributes = TREE_PURPOSE (declspec_stack);
2221 declspec_stack = TREE_CHAIN (declspec_stack);
2222 resume_momentary ($2); }
2225 /* This is used in a function definition
2226 where either a parmlist or an identifier list is ok.
2227 Its value is a list of ..._TYPE nodes or a list of identifiers. */
2228 parmlist_or_identifiers:
2230 clear_parm_order ();
2231 declare_parm_level (1); }
2232 parmlist_or_identifiers_1
2234 parmlist_tags_warning ();
2235 poplevel (0, 0, 0); }
2238 parmlist_or_identifiers_1:
2242 for (t = $1; t; t = TREE_CHAIN (t))
2243 if (TREE_VALUE (t) == NULL_TREE)
2244 error ("`...' in old-style identifier list");
2245 $$ = tree_cons (NULL_TREE, NULL_TREE, $1); }
2248 /* A nonempty list of identifiers. */
2251 { $$ = build_tree_list (NULL_TREE, $1); }
2252 | identifiers ',' IDENTIFIER
2253 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2256 /* A nonempty list of identifiers, including typenames. */
2257 identifiers_or_typenames:
2259 { $$ = build_tree_list (NULL_TREE, $1); }
2260 | identifiers_or_typenames ',' identifier
2261 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2265 /* Objective-C productions. */
2275 if (objc_implementation_context)
2277 finish_class (objc_implementation_context);
2278 objc_ivar_chain = NULL_TREE;
2279 objc_implementation_context = NULL_TREE;
2282 warning ("`@end' must appear in an implementation context");
2286 /* A nonempty list of identifiers. */
2289 { $$ = build_tree_list (NULL_TREE, $1); }
2290 | identifier_list ',' identifier
2291 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2295 CLASS identifier_list ';'
2297 objc_declare_class ($2);
2301 ALIAS identifier identifier ';'
2303 objc_declare_alias ($2, $3);
2307 INTERFACE identifier protocolrefs '{'
2309 objc_interface_context = objc_ivar_context
2310 = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, $3);
2311 objc_public_flag = 0;
2315 continue_class (objc_interface_context);
2320 finish_class (objc_interface_context);
2321 objc_interface_context = NULL_TREE;
2324 | INTERFACE identifier protocolrefs
2326 objc_interface_context
2327 = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, $3);
2328 continue_class (objc_interface_context);
2333 finish_class (objc_interface_context);
2334 objc_interface_context = NULL_TREE;
2337 | INTERFACE identifier ':' identifier protocolrefs '{'
2339 objc_interface_context = objc_ivar_context
2340 = start_class (CLASS_INTERFACE_TYPE, $2, $4, $5);
2341 objc_public_flag = 0;
2345 continue_class (objc_interface_context);
2350 finish_class (objc_interface_context);
2351 objc_interface_context = NULL_TREE;
2354 | INTERFACE identifier ':' identifier protocolrefs
2356 objc_interface_context
2357 = start_class (CLASS_INTERFACE_TYPE, $2, $4, $5);
2358 continue_class (objc_interface_context);
2363 finish_class (objc_interface_context);
2364 objc_interface_context = NULL_TREE;
2367 | IMPLEMENTATION identifier '{'
2369 objc_implementation_context = objc_ivar_context
2370 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, NULL_TREE, NULL_TREE);
2371 objc_public_flag = 0;
2376 = continue_class (objc_implementation_context);
2379 | IMPLEMENTATION identifier
2381 objc_implementation_context
2382 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, NULL_TREE, NULL_TREE);
2384 = continue_class (objc_implementation_context);
2387 | IMPLEMENTATION identifier ':' identifier '{'
2389 objc_implementation_context = objc_ivar_context
2390 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2391 objc_public_flag = 0;
2396 = continue_class (objc_implementation_context);
2399 | IMPLEMENTATION identifier ':' identifier
2401 objc_implementation_context
2402 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2404 = continue_class (objc_implementation_context);
2407 | INTERFACE identifier '(' identifier ')' protocolrefs
2409 objc_interface_context
2410 = start_class (CATEGORY_INTERFACE_TYPE, $2, $4, $6);
2411 continue_class (objc_interface_context);
2416 finish_class (objc_interface_context);
2417 objc_interface_context = NULL_TREE;
2420 | IMPLEMENTATION identifier '(' identifier ')'
2422 objc_implementation_context
2423 = start_class (CATEGORY_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2425 = continue_class (objc_implementation_context);
2430 PROTOCOL identifier protocolrefs
2432 remember_protocol_qualifiers ();
2433 objc_interface_context
2434 = start_protocol(PROTOCOL_INTERFACE_TYPE, $2, $3);
2438 forget_protocol_qualifiers();
2439 finish_protocol(objc_interface_context);
2440 objc_interface_context = NULL_TREE;
2449 | non_empty_protocolrefs
2452 non_empty_protocolrefs:
2453 ARITHCOMPARE identifier_list ARITHCOMPARE
2455 if ($1 == LT_EXPR && $3 == GT_EXPR)
2463 ivar_decl_list visibility_spec ivar_decls
2468 PRIVATE { objc_public_flag = 2; }
2469 | PROTECTED { objc_public_flag = 0; }
2470 | PUBLIC { objc_public_flag = 1; }
2478 | ivar_decls ivar_decl ';'
2482 pedwarn ("extra semicolon in struct or union specified");
2487 /* There is a shift-reduce conflict here, because `components' may
2488 start with a `typename'. It happens that shifting (the default resolution)
2489 does the right thing, because it treats the `typename' as part of
2490 a `typed_typespecs'.
2492 It is possible that this same technique would allow the distinction
2493 between `notype_initdecls' and `initdecls' to be eliminated.
2494 But I am being cautious and not trying it. */
2497 typed_typespecs setspecs ivars
2499 current_declspecs = TREE_VALUE (declspec_stack);
2500 prefix_attributes = TREE_PURPOSE (declspec_stack);
2501 declspec_stack = TREE_CHAIN (declspec_stack);
2502 resume_momentary ($2); }
2503 | nonempty_type_quals setspecs ivars
2505 current_declspecs = TREE_VALUE (declspec_stack);
2506 prefix_attributes = TREE_PURPOSE (declspec_stack);
2507 declspec_stack = TREE_CHAIN (declspec_stack);
2508 resume_momentary ($2); }
2517 | ivars ',' ivar_declarator
2523 $$ = add_instance_variable (objc_ivar_context,
2525 $1, current_declspecs,
2528 | declarator ':' expr_no_commas
2530 $$ = add_instance_variable (objc_ivar_context,
2532 $1, current_declspecs, $3);
2534 | ':' expr_no_commas
2536 $$ = add_instance_variable (objc_ivar_context,
2539 current_declspecs, $2);
2546 remember_protocol_qualifiers ();
2547 if (objc_implementation_context)
2548 objc_inherit_code = CLASS_METHOD_DECL;
2550 fatal ("method definition not in class context");
2554 forget_protocol_qualifiers ();
2555 add_class_method (objc_implementation_context, $3);
2556 start_method_def ($3);
2557 objc_method_context = $3;
2561 continue_method_def ();
2565 finish_method_def ();
2566 objc_method_context = NULL_TREE;
2571 remember_protocol_qualifiers ();
2572 if (objc_implementation_context)
2573 objc_inherit_code = INSTANCE_METHOD_DECL;
2575 fatal ("method definition not in class context");
2579 forget_protocol_qualifiers ();
2580 add_instance_method (objc_implementation_context, $3);
2581 start_method_def ($3);
2582 objc_method_context = $3;
2586 continue_method_def ();
2590 finish_method_def ();
2591 objc_method_context = NULL_TREE;
2595 /* the reason for the strange actions in this rule
2596 is so that notype_initdecls when reached via datadef
2597 can find a valid list of type and sc specs in $0. */
2601 | {$<ttype>$ = NULL_TREE; } methodprotolist2
2604 methodprotolist2: /* eliminates a shift/reduce conflict */
2607 | methodprotolist2 methodproto
2608 | methodprotolist2 {$<ttype>$ = NULL_TREE; } datadef
2619 objc_inherit_code = CLASS_METHOD_DECL;
2623 add_class_method (objc_interface_context, $3);
2629 objc_inherit_code = INSTANCE_METHOD_DECL;
2633 add_instance_method (objc_interface_context, $3);
2639 '(' typename ')' unaryselector
2641 $$ = build_method_decl (objc_inherit_code, $2, $4, NULL_TREE);
2646 $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, NULL_TREE);
2649 | '(' typename ')' keywordselector optparmlist
2651 $$ = build_method_decl (objc_inherit_code, $2, $4, $5);
2654 | keywordselector optparmlist
2656 $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, $2);
2660 /* "optarglist" assumes that start_method_def has already been called...
2661 if it is not, the "xdecls" will not be placed in the proper scope */
2668 /* to get around the following situation: "int foo (int a) int b; {}" that
2669 is synthesized when parsing "- a:a b:b; id c; id d; { ... }" */
2684 typed_declspecs setspecs myparms ';'
2685 { current_declspecs = TREE_VALUE (declspec_stack);
2686 prefix_attributes = TREE_PURPOSE (declspec_stack);
2687 declspec_stack = TREE_CHAIN (declspec_stack);
2688 resume_momentary ($2); }
2689 | typed_declspecs ';'
2690 { shadow_tag ($1); }
2692 { pedwarn ("empty declaration"); }
2697 { push_parm_decl ($1); }
2698 | myparms ',' myparm
2699 { push_parm_decl ($3); }
2702 /* A single parameter declaration or parameter type name,
2703 as found in a parmlist. DOES NOT ALLOW AN INITIALIZER OR ASMSPEC */
2706 parm_declarator maybe_attribute
2707 { $$ = build_tree_list (build_tree_list (current_declspecs,
2709 build_tree_list (prefix_attributes,
2711 | notype_declarator maybe_attribute
2712 { $$ = build_tree_list (build_tree_list (current_declspecs,
2714 build_tree_list (prefix_attributes,
2716 | absdcl maybe_attribute
2717 { $$ = build_tree_list (build_tree_list (current_declspecs,
2719 build_tree_list (prefix_attributes,
2730 /* oh what a kludge! */
2739 /* returns a tree list node generated by get_parm_info */
2752 | keywordselector keyworddecl
2754 $$ = chainon ($1, $2);
2766 ENUM { $$ = get_identifier (token_buffer); }
2767 | STRUCT { $$ = get_identifier (token_buffer); }
2768 | UNION { $$ = get_identifier (token_buffer); }
2769 | IF { $$ = get_identifier (token_buffer); }
2770 | ELSE { $$ = get_identifier (token_buffer); }
2771 | WHILE { $$ = get_identifier (token_buffer); }
2772 | DO { $$ = get_identifier (token_buffer); }
2773 | FOR { $$ = get_identifier (token_buffer); }
2774 | SWITCH { $$ = get_identifier (token_buffer); }
2775 | CASE { $$ = get_identifier (token_buffer); }
2776 | DEFAULT { $$ = get_identifier (token_buffer); }
2777 | BREAK { $$ = get_identifier (token_buffer); }
2778 | CONTINUE { $$ = get_identifier (token_buffer); }
2779 | RETURN { $$ = get_identifier (token_buffer); }
2780 | GOTO { $$ = get_identifier (token_buffer); }
2781 | ASM_KEYWORD { $$ = get_identifier (token_buffer); }
2782 | SIZEOF { $$ = get_identifier (token_buffer); }
2783 | TYPEOF { $$ = get_identifier (token_buffer); }
2784 | ALIGNOF { $$ = get_identifier (token_buffer); }
2785 | TYPESPEC | TYPE_QUAL
2789 selector ':' '(' typename ')' identifier
2791 $$ = build_keyword_decl ($1, $4, $6);
2794 | selector ':' identifier
2796 $$ = build_keyword_decl ($1, NULL_TREE, $3);
2799 | ':' '(' typename ')' identifier
2801 $$ = build_keyword_decl (NULL_TREE, $3, $5);
2806 $$ = build_keyword_decl (NULL_TREE, NULL_TREE, $2);
2817 | keywordarglist keywordarg
2819 $$ = chainon ($1, $2);
2827 if (TREE_CHAIN ($1) == NULL_TREE)
2828 /* just return the expr., remove a level of indirection */
2829 $$ = TREE_VALUE ($1);
2831 /* we have a comma expr., we will collapse later */
2837 selector ':' keywordexpr
2839 $$ = build_tree_list ($1, $3);
2843 $$ = build_tree_list (NULL_TREE, $2);
2851 $$ = get_class_reference ($1);
2857 { objc_receiver_context = 1; }
2859 { objc_receiver_context = 0; }
2862 $$ = build_tree_list ($3, $5);
2873 | keywordnamelist keywordname
2875 $$ = chainon ($1, $2);
2882 $$ = build_tree_list ($1, NULL_TREE);
2886 $$ = build_tree_list (NULL_TREE, NULL_TREE);
2891 SELECTOR '(' selectorarg ')'
2898 PROTOCOL '(' identifier ')'
2904 /* extension to support C-structures in the archiver */
2907 ENCODE '(' typename ')'
2909 $$ = groktypename ($3);