1 /* YACC parser for C syntax and for Objective C. -*-c-*-
2 Copyright (C) 1987, 88, 89, 92-6, 1997 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> typed_declspecs_no_prefix_attr reserved_declspecs_no_prefix_attr
189 %type <ttype> declmods_no_prefix_attr
190 %type <ttype> SCSPEC TYPESPEC TYPE_QUAL nonempty_type_quals maybe_type_qual
191 %type <ttype> initdecls notype_initdecls initdcl notype_initdcl
192 %type <ttype> init maybeasm
193 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
194 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
195 %type <ttype> any_word
197 %type <ttype> compstmt
199 %type <ttype> declarator
200 %type <ttype> notype_declarator after_type_declarator
201 %type <ttype> parm_declarator
203 %type <ttype> structsp component_decl_list component_decl_list2
204 %type <ttype> component_decl components component_declarator
205 %type <ttype> enumlist enumerator
206 %type <ttype> typename absdcl absdcl1 type_quals
207 %type <ttype> xexpr parms parm identifiers
209 %type <ttype> parmlist parmlist_1 parmlist_2
210 %type <ttype> parmlist_or_identifiers parmlist_or_identifiers_1
211 %type <ttype> identifiers_or_typenames
213 %type <itype> setspecs
215 %type <ends_in_label> lineno_stmt_or_label lineno_stmt_or_labels stmt_or_label
217 %type <filename> save_filename
218 %type <lineno> save_lineno
221 /* the Objective-C nonterminals */
223 %type <ttype> ivar_decl_list ivar_decls ivar_decl ivars ivar_declarator
224 %type <ttype> methoddecl unaryselector keywordselector selector
225 %type <ttype> keyworddecl receiver objcmessageexpr messageargs
226 %type <ttype> keywordexpr keywordarglist keywordarg
227 %type <ttype> myparms myparm optparmlist reservedwords objcselectorexpr
228 %type <ttype> selectorarg keywordnamelist keywordname objcencodeexpr
229 %type <ttype> objc_string non_empty_protocolrefs protocolrefs identifier_list objcprotocolexpr
231 %type <ttype> CLASSNAME OBJC_STRING OBJECTNAME
235 /* Number of statements (loosely speaking) seen so far. */
236 static int stmt_count;
238 /* Input file and line number of the end of the body of last simple_if;
239 used by the stmt-rule immediately after simple_if returns. */
240 static char *if_stmt_file;
241 static int if_stmt_line;
243 /* List of types and structure classes of the current declaration. */
244 static tree current_declspecs = NULL_TREE;
245 static tree prefix_attributes = NULL_TREE;
247 /* Stack of saved values of current_declspecs and prefix_attributes. */
248 static tree declspec_stack;
250 /* 1 if we explained undeclared var errors. */
251 static int undeclared_variable_notice;
254 /* Objective-C specific information */
256 tree objc_interface_context;
257 tree objc_implementation_context;
258 tree objc_method_context;
259 tree objc_ivar_chain;
260 tree objc_ivar_context;
261 enum tree_code objc_inherit_code;
262 int objc_receiver_context;
263 int objc_public_flag;
267 /* Tell yyparse how to print a token's value, if yydebug is set. */
269 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
270 extern void yyprint ();
276 pedwarn ("ANSI C forbids an empty source file");
281 /* In case there were missing closebraces,
282 get us back to the global binding level. */
283 while (! global_bindings_p ())
289 /* the reason for the strange actions in this rule
290 is so that notype_initdecls when reached via datadef
291 can find a valid list of type and sc specs in $0. */
294 {$<ttype>$ = NULL_TREE; } extdef
295 | extdefs {$<ttype>$ = NULL_TREE; } extdef
304 | ASM_KEYWORD '(' expr ')' ';'
306 if ((TREE_CODE ($3) == ADDR_EXPR
307 && TREE_CODE (TREE_OPERAND ($3, 0)) == STRING_CST)
308 || TREE_CODE ($3) == STRING_CST)
311 error ("argument of `asm' is not a constant string"); }
313 { pedantic = $<itype>1; }
317 setspecs notype_initdecls ';'
319 error ("ANSI C forbids data definition with no type or storage class");
320 else if (!flag_traditional)
321 warning ("data definition has no type or storage class");
323 current_declspecs = TREE_VALUE (declspec_stack);
324 prefix_attributes = TREE_PURPOSE (declspec_stack);
325 declspec_stack = TREE_CHAIN (declspec_stack);
326 resume_momentary ($1); }
327 | declmods setspecs notype_initdecls ';'
328 { current_declspecs = TREE_VALUE (declspec_stack);
329 prefix_attributes = TREE_PURPOSE (declspec_stack);
330 declspec_stack = TREE_CHAIN (declspec_stack);
331 resume_momentary ($2); }
332 | typed_declspecs setspecs initdecls ';'
333 { current_declspecs = TREE_VALUE (declspec_stack);
334 prefix_attributes = TREE_PURPOSE (declspec_stack);
335 declspec_stack = TREE_CHAIN (declspec_stack);
336 resume_momentary ($2); }
338 { pedwarn ("empty declaration"); }
339 | typed_declspecs ';'
345 pedwarn ("ANSI C does not allow extra `;' outside of a function"); }
349 typed_declspecs setspecs declarator
350 { if (! start_function (current_declspecs, $3,
351 prefix_attributes, NULL_TREE, 0))
353 reinit_parse_for_function (); }
355 { store_parm_decls (); }
357 { finish_function (0);
358 current_declspecs = TREE_VALUE (declspec_stack);
359 prefix_attributes = TREE_PURPOSE (declspec_stack);
360 declspec_stack = TREE_CHAIN (declspec_stack);
361 resume_momentary ($2); }
362 | typed_declspecs setspecs declarator error
363 { current_declspecs = TREE_VALUE (declspec_stack);
364 prefix_attributes = TREE_PURPOSE (declspec_stack);
365 declspec_stack = TREE_CHAIN (declspec_stack);
366 resume_momentary ($2); }
367 | declmods setspecs notype_declarator
368 { if (! start_function (current_declspecs, $3,
369 prefix_attributes, NULL_TREE, 0))
371 reinit_parse_for_function (); }
373 { store_parm_decls (); }
375 { finish_function (0);
376 current_declspecs = TREE_VALUE (declspec_stack);
377 prefix_attributes = TREE_PURPOSE (declspec_stack);
378 declspec_stack = TREE_CHAIN (declspec_stack);
379 resume_momentary ($2); }
380 | declmods setspecs notype_declarator error
381 { current_declspecs = TREE_VALUE (declspec_stack);
382 prefix_attributes = TREE_PURPOSE (declspec_stack);
383 declspec_stack = TREE_CHAIN (declspec_stack);
384 resume_momentary ($2); }
385 | setspecs notype_declarator
386 { if (! start_function (NULL_TREE, $2,
387 prefix_attributes, NULL_TREE, 0))
389 reinit_parse_for_function (); }
391 { store_parm_decls (); }
393 { finish_function (0);
394 current_declspecs = TREE_VALUE (declspec_stack);
395 prefix_attributes = TREE_PURPOSE (declspec_stack);
396 declspec_stack = TREE_CHAIN (declspec_stack);
397 resume_momentary ($1); }
398 | setspecs notype_declarator error
399 { current_declspecs = TREE_VALUE (declspec_stack);
400 prefix_attributes = TREE_PURPOSE (declspec_stack);
401 declspec_stack = TREE_CHAIN (declspec_stack);
402 resume_momentary ($1); }
417 { $$ = NEGATE_EXPR; }
419 { $$ = CONVERT_EXPR; }
421 { $$ = PREINCREMENT_EXPR; }
423 { $$ = PREDECREMENT_EXPR; }
425 { $$ = BIT_NOT_EXPR; }
427 { $$ = TRUTH_NOT_EXPR; }
430 expr: nonnull_exprlist
431 { $$ = build_compound_expr ($1); }
442 { $$ = build_tree_list (NULL_TREE, $1); }
443 | nonnull_exprlist ',' expr_no_commas
444 { chainon ($1, build_tree_list (NULL_TREE, $3)); }
449 | '*' cast_expr %prec UNARY
450 { $$ = build_indirect_ref ($2, "unary *"); }
451 /* __extension__ turns off -pedantic for following primary. */
452 | extension cast_expr %prec UNARY
454 pedantic = $<itype>1; }
455 | unop cast_expr %prec UNARY
456 { $$ = build_unary_op ($1, $2, 0);
457 overflow_warning ($$); }
458 /* Refer to the address of a label as a pointer. */
460 { tree label = lookup_label ($2);
462 pedwarn ("ANSI C forbids `&&'");
464 $$ = null_pointer_node;
467 TREE_USED (label) = 1;
468 $$ = build1 (ADDR_EXPR, ptr_type_node, label);
469 TREE_CONSTANT ($$) = 1;
472 /* This seems to be impossible on some machines, so let's turn it off.
473 You can use __builtin_next_arg to find the anonymous stack args.
475 { tree types = TYPE_ARG_TYPES (TREE_TYPE (current_function_decl));
476 $$ = error_mark_node;
477 if (TREE_VALUE (tree_last (types)) == void_type_node)
478 error ("`&...' used in function with fixed number of arguments");
482 pedwarn ("ANSI C forbids `&...'");
483 $$ = tree_last (DECL_ARGUMENTS (current_function_decl));
484 $$ = build_unary_op (ADDR_EXPR, $$, 0);
487 | sizeof unary_expr %prec UNARY
489 if (TREE_CODE ($2) == COMPONENT_REF
490 && DECL_BIT_FIELD (TREE_OPERAND ($2, 1)))
491 error ("`sizeof' applied to a bit-field");
492 $$ = c_sizeof (TREE_TYPE ($2)); }
493 | sizeof '(' typename ')' %prec HYPERUNARY
495 $$ = c_sizeof (groktypename ($3)); }
496 | alignof unary_expr %prec UNARY
498 $$ = c_alignof_expr ($2); }
499 | alignof '(' typename ')' %prec HYPERUNARY
501 $$ = c_alignof (groktypename ($3)); }
502 | REALPART cast_expr %prec UNARY
503 { $$ = build_unary_op (REALPART_EXPR, $2, 0); }
504 | IMAGPART cast_expr %prec UNARY
505 { $$ = build_unary_op (IMAGPART_EXPR, $2, 0); }
509 SIZEOF { skip_evaluation++; }
513 ALIGNOF { skip_evaluation++; }
518 | '(' typename ')' cast_expr %prec UNARY
519 { tree type = groktypename ($2);
520 $$ = build_c_cast (type, $4); }
521 | '(' typename ')' '{'
522 { start_init (NULL_TREE, NULL, 0);
523 $2 = groktypename ($2);
524 really_start_incremental_init ($2); }
525 initlist_maybe_comma '}' %prec UNARY
527 tree result = pop_init_level (0);
532 pedwarn ("ANSI C forbids constructor expressions");
533 if (TYPE_NAME (type) != 0)
535 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
536 name = IDENTIFIER_POINTER (TYPE_NAME (type));
538 name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
543 if (TREE_CODE (type) == ARRAY_TYPE && TYPE_SIZE (type) == 0)
545 int failure = complete_array_type (type, $$, 1);
554 | expr_no_commas '+' 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 '%' expr_no_commas
563 { $$ = parser_build_binary_op ($2, $1, $3); }
564 | expr_no_commas LSHIFT expr_no_commas
565 { $$ = parser_build_binary_op ($2, $1, $3); }
566 | expr_no_commas RSHIFT expr_no_commas
567 { $$ = parser_build_binary_op ($2, $1, $3); }
568 | expr_no_commas ARITHCOMPARE expr_no_commas
569 { $$ = parser_build_binary_op ($2, $1, $3); }
570 | expr_no_commas EQCOMPARE expr_no_commas
571 { $$ = parser_build_binary_op ($2, $1, $3); }
572 | expr_no_commas '&' expr_no_commas
573 { $$ = parser_build_binary_op ($2, $1, $3); }
574 | expr_no_commas '|' expr_no_commas
575 { $$ = parser_build_binary_op ($2, $1, $3); }
576 | expr_no_commas '^' expr_no_commas
577 { $$ = parser_build_binary_op ($2, $1, $3); }
578 | expr_no_commas ANDAND
579 { $1 = truthvalue_conversion (default_conversion ($1));
580 skip_evaluation += $1 == boolean_false_node; }
582 { skip_evaluation -= $1 == boolean_false_node;
583 $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $4); }
584 | expr_no_commas OROR
585 { $1 = truthvalue_conversion (default_conversion ($1));
586 skip_evaluation += $1 == boolean_true_node; }
588 { skip_evaluation -= $1 == boolean_true_node;
589 $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $4); }
591 { $1 = truthvalue_conversion (default_conversion ($1));
592 skip_evaluation += $1 == boolean_false_node; }
594 { skip_evaluation += (($1 == boolean_true_node)
595 - ($1 == boolean_false_node)); }
597 { skip_evaluation -= $1 == boolean_true_node;
598 $$ = build_conditional_expr ($1, $4, $7); }
601 pedwarn ("ANSI C forbids omitting the middle term of a ?: expression");
602 /* Make sure first operand is calculated only once. */
603 $<ttype>2 = save_expr ($1);
604 $1 = truthvalue_conversion (default_conversion ($<ttype>2));
605 skip_evaluation += $1 == boolean_true_node; }
607 { skip_evaluation -= $1 == boolean_true_node;
608 $$ = build_conditional_expr ($1, $<ttype>2, $5); }
609 | expr_no_commas '=' expr_no_commas
610 { $$ = build_modify_expr ($1, NOP_EXPR, $3);
611 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
612 | expr_no_commas ASSIGN expr_no_commas
613 { $$ = build_modify_expr ($1, $2, $3);
614 /* This inhibits warnings in truthvalue_conversion. */
615 C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK); }
622 if (!$$ || $$ == error_mark_node)
624 if (yychar == YYEMPTY)
631 if (objc_receiver_context
632 && ! (objc_receiver_context
633 && strcmp (IDENTIFIER_POINTER ($1), "super")))
634 /* we have a message to super */
635 $$ = get_super_receiver ();
636 else if (objc_method_context
637 && (decl = is_ivar (objc_ivar_chain, $1)))
639 if (is_private (decl))
640 $$ = error_mark_node;
642 $$ = build_ivar_reference ($1);
647 /* Ordinary implicit function declaration. */
648 $$ = implicitly_declare ($1);
649 assemble_external ($$);
653 else if (current_function_decl == 0)
655 error ("`%s' undeclared here (not in a function)",
656 IDENTIFIER_POINTER ($1));
657 $$ = error_mark_node;
664 if (objc_receiver_context
665 && ! strcmp (IDENTIFIER_POINTER ($1), "super"))
666 /* we have a message to super */
667 $$ = get_super_receiver ();
668 else if (objc_method_context
669 && (decl = is_ivar (objc_ivar_chain, $1)))
671 if (is_private (decl))
672 $$ = error_mark_node;
674 $$ = build_ivar_reference ($1);
679 if (IDENTIFIER_GLOBAL_VALUE ($1) != error_mark_node
680 || IDENTIFIER_ERROR_LOCUS ($1) != current_function_decl)
682 error ("`%s' undeclared (first use this function)",
683 IDENTIFIER_POINTER ($1));
685 if (! undeclared_variable_notice)
687 error ("(Each undeclared identifier is reported only once");
688 error ("for each function it appears in.)");
689 undeclared_variable_notice = 1;
692 $$ = error_mark_node;
693 /* Prevent repeated error messages. */
694 IDENTIFIER_GLOBAL_VALUE ($1) = error_mark_node;
695 IDENTIFIER_ERROR_LOCUS ($1) = current_function_decl;
699 else if (TREE_TYPE ($$) == error_mark_node)
700 $$ = error_mark_node;
701 else if (C_DECL_ANTICIPATED ($$))
703 /* The first time we see a build-in function used,
704 if it has not been declared. */
705 C_DECL_ANTICIPATED ($$) = 0;
706 if (yychar == YYEMPTY)
710 /* Omit the implicit declaration we
711 would ordinarily do, so we don't lose
712 the actual built in type.
713 But print a diagnostic for the mismatch. */
715 if (objc_method_context
716 && is_ivar (objc_ivar_chain, $1))
717 error ("Instance variable `%s' implicitly declared as function",
718 IDENTIFIER_POINTER (DECL_NAME ($$)));
721 if (TREE_CODE ($$) != FUNCTION_DECL)
722 error ("`%s' implicitly declared as function",
723 IDENTIFIER_POINTER (DECL_NAME ($$)));
724 else if ((TYPE_MODE (TREE_TYPE (TREE_TYPE ($$)))
725 != TYPE_MODE (integer_type_node))
726 && (TREE_TYPE (TREE_TYPE ($$))
728 pedwarn ("type mismatch in implicit declaration for built-in function `%s'",
729 IDENTIFIER_POINTER (DECL_NAME ($$)));
730 /* If it really returns void, change that to int. */
731 if (TREE_TYPE (TREE_TYPE ($$)) == void_type_node)
733 = build_function_type (integer_type_node,
734 TYPE_ARG_TYPES (TREE_TYPE ($$)));
737 pedwarn ("built-in function `%s' used without declaration",
738 IDENTIFIER_POINTER (DECL_NAME ($$)));
740 /* Do what we would ordinarily do when a fn is used. */
741 assemble_external ($$);
746 assemble_external ($$);
749 /* we have a definition - still check if iVariable */
751 if (!objc_receiver_context
752 || (objc_receiver_context
753 && strcmp (IDENTIFIER_POINTER ($1), "super")))
757 if (objc_method_context
758 && (decl = is_ivar (objc_ivar_chain, $1)))
760 if (IDENTIFIER_LOCAL_VALUE ($1))
761 warning ("local declaration of `%s' hides instance variable",
762 IDENTIFIER_POINTER ($1));
765 if (is_private (decl))
766 $$ = error_mark_node;
768 $$ = build_ivar_reference ($1);
772 else /* we have a message to super */
773 $$ = get_super_receiver ();
777 if (TREE_CODE ($$) == CONST_DECL)
779 $$ = DECL_INITIAL ($$);
780 /* This is to prevent an enum whose value is 0
781 from being considered a null pointer constant. */
782 $$ = build1 (NOP_EXPR, TREE_TYPE ($$), $$);
783 TREE_CONSTANT ($$) = 1;
788 { $$ = combine_strings ($1); }
790 { char class = TREE_CODE_CLASS (TREE_CODE ($2));
791 if (class == 'e' || class == '1'
792 || class == '2' || class == '<')
793 C_SET_EXP_ORIGINAL_CODE ($2, ERROR_MARK);
796 { $$ = error_mark_node; }
798 { if (current_function_decl == 0)
800 error ("braced-group within expression allowed only inside a function");
803 /* We must force a BLOCK for this level
804 so that, if it is not expanded later,
805 there is a way to turn off the entire subtree of blocks
806 that are contained in it. */
808 push_iterator_stack ();
810 $<ttype>$ = expand_start_stmt_expr (); }
814 pedwarn ("ANSI C forbids braced-groups within expressions");
815 pop_iterator_stack ();
817 rtl_exp = expand_end_stmt_expr ($<ttype>2);
818 /* The statements have side effects, so the group does. */
819 TREE_SIDE_EFFECTS (rtl_exp) = 1;
821 if (TREE_CODE ($3) == BLOCK)
823 /* Make a BIND_EXPR for the BLOCK already made. */
824 $$ = build (BIND_EXPR, TREE_TYPE (rtl_exp),
825 NULL_TREE, rtl_exp, $3);
826 /* Remove the block from the tree at this point.
827 It gets put back at the proper place
828 when the BIND_EXPR is expanded. */
834 | primary '(' exprlist ')' %prec '.'
835 { $$ = build_function_call ($1, $3); }
836 | primary '[' expr ']' %prec '.'
837 { $$ = build_array_ref ($1, $3); }
838 | primary '.' identifier
841 if (doing_objc_thang)
843 if (is_public ($1, $3))
844 $$ = build_component_ref ($1, $3);
846 $$ = error_mark_node;
850 $$ = build_component_ref ($1, $3);
852 | primary POINTSAT identifier
854 tree expr = build_indirect_ref ($1, "->");
857 if (doing_objc_thang)
859 if (is_public (expr, $3))
860 $$ = build_component_ref (expr, $3);
862 $$ = error_mark_node;
866 $$ = build_component_ref (expr, $3);
869 { $$ = build_unary_op (POSTINCREMENT_EXPR, $1, 0); }
871 { $$ = build_unary_op (POSTDECREMENT_EXPR, $1, 0); }
874 { $$ = build_message_expr ($1); }
876 { $$ = build_selector_expr ($1); }
878 { $$ = build_protocol_expr ($1); }
880 { $$ = build_encode_expr ($1); }
882 { $$ = build_objc_string_object ($1); }
886 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
890 { $$ = chainon ($1, $2); }
894 /* Produces an OBJC_STRING_CST with perhaps more OBJC_STRING_CSTs chained
898 | objc_string OBJC_STRING
899 { $$ = chainon ($1, $2); }
903 old_style_parm_decls:
907 /* ... is used here to indicate a varargs function. */
910 pedwarn ("ANSI C does not permit use of `varargs.h'"); }
913 /* The following are analogous to lineno_decl, decls and decl
914 except that they do not allow nested functions.
915 They are used for old-style parm decls. */
917 save_filename save_lineno datadecl
924 | datadecls lineno_datadecl
925 | lineno_datadecl errstmt
928 /* We don't allow prefix attributes here because they cause reduce/reduce
929 conflicts: we can't know whether we're parsing a function decl with
930 attribute suffix, or function defn with attribute prefix on first old
933 typed_declspecs_no_prefix_attr setspecs initdecls ';'
934 { current_declspecs = TREE_VALUE (declspec_stack);
935 prefix_attributes = TREE_PURPOSE (declspec_stack);
936 declspec_stack = TREE_CHAIN (declspec_stack);
937 resume_momentary ($2); }
938 | declmods_no_prefix_attr setspecs notype_initdecls ';'
939 { current_declspecs = TREE_VALUE (declspec_stack);
940 prefix_attributes = TREE_PURPOSE (declspec_stack);
941 declspec_stack = TREE_CHAIN (declspec_stack);
942 resume_momentary ($2); }
943 | typed_declspecs_no_prefix_attr ';'
944 { shadow_tag_warned ($1, 1);
945 pedwarn ("empty declaration"); }
946 | declmods_no_prefix_attr ';'
947 { pedwarn ("empty declaration"); }
950 /* This combination which saves a lineno before a decl
951 is the normal thing to use, rather than decl itself.
952 This is to avoid shift/reduce conflicts in contexts
953 where statement labels are allowed. */
955 save_filename save_lineno decl
963 | lineno_decl errstmt
966 /* records the type and storage class specs to use for processing
967 the declarators that follow.
968 Maintains a stack of outer-level values of current_declspecs,
969 for the sake of parm declarations nested in function declarators. */
970 setspecs: /* empty */
971 { $$ = suspend_momentary ();
972 pending_xref_error ();
973 declspec_stack = tree_cons (prefix_attributes,
976 split_specs_attrs ($<ttype>0,
977 ¤t_declspecs, &prefix_attributes); }
980 /* ??? Yuck. See after_type_declarator. */
981 setattrs: /* empty */
982 { prefix_attributes = chainon (prefix_attributes, $<ttype>0); }
986 typed_declspecs setspecs initdecls ';'
987 { current_declspecs = TREE_VALUE (declspec_stack);
988 prefix_attributes = TREE_PURPOSE (declspec_stack);
989 declspec_stack = TREE_CHAIN (declspec_stack);
990 resume_momentary ($2); }
991 | declmods setspecs notype_initdecls ';'
992 { current_declspecs = TREE_VALUE (declspec_stack);
993 prefix_attributes = TREE_PURPOSE (declspec_stack);
994 declspec_stack = TREE_CHAIN (declspec_stack);
995 resume_momentary ($2); }
996 | typed_declspecs setspecs nested_function
997 { current_declspecs = TREE_VALUE (declspec_stack);
998 prefix_attributes = TREE_PURPOSE (declspec_stack);
999 declspec_stack = TREE_CHAIN (declspec_stack);
1000 resume_momentary ($2); }
1001 | declmods setspecs notype_nested_function
1002 { current_declspecs = TREE_VALUE (declspec_stack);
1003 prefix_attributes = TREE_PURPOSE (declspec_stack);
1004 declspec_stack = TREE_CHAIN (declspec_stack);
1005 resume_momentary ($2); }
1006 | typed_declspecs ';'
1007 { shadow_tag ($1); }
1009 { pedwarn ("empty declaration"); }
1011 { pedantic = $<itype>1; }
1014 /* Declspecs which contain at least one type specifier or typedef name.
1015 (Just `const' or `volatile' is not enough.)
1016 A typedef'd name following these is taken as a name to be declared.
1017 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
1020 typespec reserved_declspecs
1021 { $$ = tree_cons (NULL_TREE, $1, $2); }
1022 | declmods typespec reserved_declspecs
1023 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
1026 reserved_declspecs: /* empty */
1028 | reserved_declspecs typespecqual_reserved
1029 { $$ = tree_cons (NULL_TREE, $2, $1); }
1030 | reserved_declspecs SCSPEC
1031 { if (extra_warnings)
1032 warning ("`%s' is not at beginning of declaration",
1033 IDENTIFIER_POINTER ($2));
1034 $$ = tree_cons (NULL_TREE, $2, $1); }
1035 | reserved_declspecs attributes
1036 { $$ = tree_cons ($2, NULL_TREE, $1); }
1039 typed_declspecs_no_prefix_attr:
1040 typespec reserved_declspecs_no_prefix_attr
1041 { $$ = tree_cons (NULL_TREE, $1, $2); }
1042 | declmods_no_prefix_attr typespec reserved_declspecs_no_prefix_attr
1043 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
1046 reserved_declspecs_no_prefix_attr:
1049 | reserved_declspecs_no_prefix_attr typespecqual_reserved
1050 { $$ = tree_cons (NULL_TREE, $2, $1); }
1051 | reserved_declspecs_no_prefix_attr SCSPEC
1052 { if (extra_warnings)
1053 warning ("`%s' is not at beginning of declaration",
1054 IDENTIFIER_POINTER ($2));
1055 $$ = tree_cons (NULL_TREE, $2, $1); }
1058 /* List of just storage classes, type modifiers, and prefix attributes.
1059 A declaration can start with just this, but then it cannot be used
1060 to redeclare a typedef-name.
1061 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
1064 declmods_no_prefix_attr
1067 { $$ = tree_cons ($1, NULL_TREE, NULL_TREE); }
1068 | declmods declmods_no_prefix_attr
1069 { $$ = chainon ($2, $1); }
1070 | declmods attributes
1071 { $$ = tree_cons ($2, NULL_TREE, $1); }
1074 declmods_no_prefix_attr:
1076 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
1077 TREE_STATIC ($$) = 1; }
1079 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
1080 | declmods_no_prefix_attr TYPE_QUAL
1081 { $$ = tree_cons (NULL_TREE, $2, $1);
1082 TREE_STATIC ($$) = 1; }
1083 | declmods_no_prefix_attr SCSPEC
1084 { if (extra_warnings && TREE_STATIC ($1))
1085 warning ("`%s' is not at beginning of declaration",
1086 IDENTIFIER_POINTER ($2));
1087 $$ = tree_cons (NULL_TREE, $2, $1);
1088 TREE_STATIC ($$) = TREE_STATIC ($1); }
1092 /* Used instead of declspecs where storage classes are not allowed
1093 (that is, for typenames and structure components).
1094 Don't accept a typedef-name if anything but a modifier precedes it. */
1097 typespec reserved_typespecquals
1098 { $$ = tree_cons (NULL_TREE, $1, $2); }
1099 | nonempty_type_quals typespec reserved_typespecquals
1100 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
1103 reserved_typespecquals: /* empty */
1105 | reserved_typespecquals typespecqual_reserved
1106 { $$ = tree_cons (NULL_TREE, $2, $1); }
1109 /* A typespec (but not a type qualifier).
1110 Once we have seen one of these in a declaration,
1111 if a typedef name appears then it is being redeclared. */
1116 { /* For a typedef name, record the meaning, not the name.
1117 In case of `foo foo, bar;'. */
1118 $$ = lookup_name ($1); }
1120 | CLASSNAME protocolrefs
1121 { $$ = get_static_reference ($1, $2); }
1122 | OBJECTNAME protocolrefs
1123 { $$ = get_object_reference ($2); }
1125 /* Make "<SomeProtocol>" equivalent to "id <SomeProtocol>"
1126 - nisse@lysator.liu.se */
1127 | non_empty_protocolrefs
1128 { $$ = get_object_reference ($1); }
1130 | TYPEOF '(' expr ')'
1131 { $$ = TREE_TYPE ($3); }
1132 | TYPEOF '(' typename ')'
1133 { $$ = groktypename ($3); }
1136 /* A typespec that is a reserved word, or a type qualifier. */
1138 typespecqual_reserved: TYPESPEC
1145 | initdecls ',' initdcl
1150 | notype_initdecls ',' initdcl
1156 | ASM_KEYWORD '(' string ')'
1157 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
1163 declarator maybeasm maybe_attribute '='
1164 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1165 $3, prefix_attributes);
1166 start_init ($<ttype>$, $2, global_bindings_p ()); }
1168 /* Note how the declaration of the variable is in effect while its init is parsed! */
1170 finish_decl ($<ttype>5, $6, $2); }
1171 | declarator maybeasm maybe_attribute
1172 { tree d = start_decl ($1, current_declspecs, 0,
1173 $3, prefix_attributes);
1174 finish_decl (d, NULL_TREE, $2);
1179 notype_declarator maybeasm maybe_attribute '='
1180 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1181 $3, prefix_attributes);
1182 start_init ($<ttype>$, $2, global_bindings_p ()); }
1184 /* Note how the declaration of the variable is in effect while its init is parsed! */
1186 decl_attributes ($<ttype>5, $3, prefix_attributes);
1187 finish_decl ($<ttype>5, $6, $2); }
1188 | notype_declarator maybeasm maybe_attribute
1189 { tree d = start_decl ($1, current_declspecs, 0,
1190 $3, prefix_attributes);
1191 finish_decl (d, NULL_TREE, $2); }
1193 /* the * rules are dummies to accept the Apollo extended syntax
1194 so that the header files compile. */
1205 | attributes attribute
1206 { $$ = chainon ($1, $2); }
1210 ATTRIBUTE '(' '(' attribute_list ')' ')'
1217 | attribute_list ',' attrib
1218 { $$ = chainon ($1, $3); }
1225 { $$ = build_tree_list ($1, NULL_TREE); }
1226 | any_word '(' IDENTIFIER ')'
1227 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1228 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1229 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1230 | any_word '(' exprlist ')'
1231 { $$ = build_tree_list ($1, $3); }
1234 /* This still leaves out most reserved keywords,
1235 shouldn't we include them? */
1244 /* Initializers. `init' is the entry point. */
1249 { really_start_incremental_init (NULL_TREE);
1250 /* Note that the call to clear_momentary
1251 is in process_init_element. */
1252 push_momentary (); }
1253 initlist_maybe_comma '}'
1254 { $$ = pop_init_level (0);
1255 if ($$ == error_mark_node
1256 && ! (yychar == STRING || yychar == CONSTANT))
1259 pop_momentary_nofree (); }
1262 { $$ = error_mark_node; }
1265 /* `initlist_maybe_comma' is the guts of an initializer in braces. */
1266 initlist_maybe_comma:
1269 pedwarn ("ANSI C forbids empty initializer braces"); }
1270 | initlist1 maybecomma
1275 | initlist1 ',' initelt
1278 /* `initelt' is a single element of an initializer.
1279 It may use braces. */
1282 { process_init_element ($1); }
1284 { push_init_level (0); }
1285 initlist_maybe_comma '}'
1286 { process_init_element (pop_init_level (0)); }
1288 /* These are for labeled elements. The syntax for an array element
1289 initializer conflicts with the syntax for an Objective-C message,
1290 so don't include these productions in the Objective-C grammar. */
1292 | '[' expr_no_commas ELLIPSIS expr_no_commas ']' '='
1293 { set_init_index ($2, $4); }
1295 | '[' expr_no_commas ']' '='
1296 { set_init_index ($2, NULL_TREE); }
1298 | '[' expr_no_commas ']'
1299 { set_init_index ($2, NULL_TREE); }
1303 { set_init_label ($1); }
1305 | '.' identifier '='
1306 { set_init_label ($2); }
1312 { push_c_function_context ();
1313 if (! start_function (current_declspecs, $1,
1314 prefix_attributes, NULL_TREE, 1))
1316 pop_c_function_context ();
1319 reinit_parse_for_function (); }
1320 old_style_parm_decls
1321 { store_parm_decls (); }
1322 /* This used to use compstmt_or_error.
1323 That caused a bug with input `f(g) int g {}',
1324 where the use of YYERROR1 above caused an error
1325 which then was handled by compstmt_or_error.
1326 There followed a repeated execution of that same rule,
1327 which called YYERROR1 again, and so on. */
1329 { finish_function (1);
1330 pop_c_function_context (); }
1333 notype_nested_function:
1335 { push_c_function_context ();
1336 if (! start_function (current_declspecs, $1,
1337 prefix_attributes, NULL_TREE, 1))
1339 pop_c_function_context ();
1342 reinit_parse_for_function (); }
1343 old_style_parm_decls
1344 { store_parm_decls (); }
1345 /* This used to use compstmt_or_error.
1346 That caused a bug with input `f(g) int g {}',
1347 where the use of YYERROR1 above caused an error
1348 which then was handled by compstmt_or_error.
1349 There followed a repeated execution of that same rule,
1350 which called YYERROR1 again, and so on. */
1352 { finish_function (1);
1353 pop_c_function_context (); }
1356 /* Any kind of declarator (thus, all declarators allowed
1357 after an explicit typespec). */
1360 after_type_declarator
1364 /* A declarator that is allowed only after an explicit typespec. */
1366 after_type_declarator:
1367 '(' after_type_declarator ')'
1369 | after_type_declarator '(' parmlist_or_identifiers %prec '.'
1370 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1371 /* | after_type_declarator '(' error ')' %prec '.'
1372 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1373 poplevel (0, 0, 0); } */
1374 | after_type_declarator '[' expr ']' %prec '.'
1375 { $$ = build_nt (ARRAY_REF, $1, $3); }
1376 | after_type_declarator '[' ']' %prec '.'
1377 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1378 | '*' type_quals after_type_declarator %prec UNARY
1379 { $$ = make_pointer_declarator ($2, $3); }
1380 /* ??? Yuck. setattrs is a quick hack. We can't use
1381 prefix_attributes because $1 only applies to this
1382 declarator. We assume setspecs has already been done.
1383 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1384 attributes could be recognized here or in `attributes'). */
1385 | attributes setattrs after_type_declarator
1393 /* Kinds of declarator that can appear in a parameter list
1394 in addition to notype_declarator. This is like after_type_declarator
1395 but does not allow a typedef name in parentheses as an identifier
1396 (because it would conflict with a function with that typedef as arg). */
1399 parm_declarator '(' parmlist_or_identifiers %prec '.'
1400 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1401 /* | parm_declarator '(' error ')' %prec '.'
1402 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1403 poplevel (0, 0, 0); } */
1404 | parm_declarator '[' expr ']' %prec '.'
1405 { $$ = build_nt (ARRAY_REF, $1, $3); }
1406 | parm_declarator '[' ']' %prec '.'
1407 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1408 | '*' type_quals parm_declarator %prec UNARY
1409 { $$ = make_pointer_declarator ($2, $3); }
1410 /* ??? Yuck. setattrs is a quick hack. We can't use
1411 prefix_attributes because $1 only applies to this
1412 declarator. We assume setspecs has already been done.
1413 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1414 attributes could be recognized here or in `attributes'). */
1415 | attributes setattrs parm_declarator
1420 /* A declarator allowed whether or not there has been
1421 an explicit typespec. These cannot redeclare a typedef-name. */
1424 notype_declarator '(' parmlist_or_identifiers %prec '.'
1425 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1426 /* | notype_declarator '(' error ')' %prec '.'
1427 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1428 poplevel (0, 0, 0); } */
1429 | '(' notype_declarator ')'
1431 | '*' type_quals notype_declarator %prec UNARY
1432 { $$ = make_pointer_declarator ($2, $3); }
1433 | notype_declarator '[' expr ']' %prec '.'
1434 { $$ = build_nt (ARRAY_REF, $1, $3); }
1435 | notype_declarator '[' ']' %prec '.'
1436 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1437 /* ??? Yuck. setattrs is a quick hack. We can't use
1438 prefix_attributes because $1 only applies to this
1439 declarator. We assume setspecs has already been done.
1440 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1441 attributes could be recognized here or in `attributes'). */
1442 | attributes setattrs notype_declarator
1448 STRUCT identifier '{'
1449 { $$ = start_struct (RECORD_TYPE, $2);
1450 /* Start scope of tag before parsing components. */
1452 component_decl_list '}' maybe_attribute
1453 { $$ = finish_struct ($<ttype>4, $5, $7); }
1454 | STRUCT '{' component_decl_list '}' maybe_attribute
1455 { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
1459 { $$ = xref_tag (RECORD_TYPE, $2); }
1460 | UNION identifier '{'
1461 { $$ = start_struct (UNION_TYPE, $2); }
1462 component_decl_list '}' maybe_attribute
1463 { $$ = finish_struct ($<ttype>4, $5, $7); }
1464 | UNION '{' component_decl_list '}' maybe_attribute
1465 { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
1469 { $$ = xref_tag (UNION_TYPE, $2); }
1470 | ENUM identifier '{'
1471 { $<itype>3 = suspend_momentary ();
1472 $$ = start_enum ($2); }
1473 enumlist maybecomma_warn '}' maybe_attribute
1474 { $$ = finish_enum ($<ttype>4, nreverse ($5), $8);
1475 resume_momentary ($<itype>3); }
1477 { $<itype>2 = suspend_momentary ();
1478 $$ = start_enum (NULL_TREE); }
1479 enumlist maybecomma_warn '}' maybe_attribute
1480 { $$ = finish_enum ($<ttype>3, nreverse ($4), $7);
1481 resume_momentary ($<itype>2); }
1483 { $$ = xref_tag (ENUMERAL_TYPE, $2); }
1494 { if (pedantic) pedwarn ("comma at end of enumerator list"); }
1497 component_decl_list:
1498 component_decl_list2
1500 | component_decl_list2 component_decl
1501 { $$ = chainon ($1, $2);
1502 pedwarn ("no semicolon at end of struct or union"); }
1505 component_decl_list2: /* empty */
1507 | component_decl_list2 component_decl ';'
1508 { $$ = chainon ($1, $2); }
1509 | component_decl_list2 ';'
1511 pedwarn ("extra semicolon in struct or union specified"); }
1513 /* foo(sizeof(struct{ @defs(ClassName)})); */
1514 | DEFS '(' CLASSNAME ')'
1516 tree interface = lookup_interface ($3);
1519 $$ = get_class_ivars (interface);
1522 error ("Cannot find interface declaration for `%s'",
1523 IDENTIFIER_POINTER ($3));
1530 /* There is a shift-reduce conflict here, because `components' may
1531 start with a `typename'. It happens that shifting (the default resolution)
1532 does the right thing, because it treats the `typename' as part of
1533 a `typed_typespecs'.
1535 It is possible that this same technique would allow the distinction
1536 between `notype_initdecls' and `initdecls' to be eliminated.
1537 But I am being cautious and not trying it. */
1540 typed_typespecs setspecs components
1542 current_declspecs = TREE_VALUE (declspec_stack);
1543 prefix_attributes = TREE_PURPOSE (declspec_stack);
1544 declspec_stack = TREE_CHAIN (declspec_stack);
1545 resume_momentary ($2); }
1548 pedwarn ("ANSI C forbids member declarations with no members");
1551 | nonempty_type_quals setspecs components
1553 current_declspecs = TREE_VALUE (declspec_stack);
1554 prefix_attributes = TREE_PURPOSE (declspec_stack);
1555 declspec_stack = TREE_CHAIN (declspec_stack);
1556 resume_momentary ($2); }
1557 | nonempty_type_quals
1559 pedwarn ("ANSI C forbids member declarations with no members");
1564 | extension component_decl
1566 pedantic = $<itype>1; }
1570 component_declarator
1571 | components ',' component_declarator
1572 { $$ = chainon ($1, $3); }
1575 component_declarator:
1576 save_filename save_lineno declarator maybe_attribute
1577 { $$ = grokfield ($1, $2, $3, current_declspecs, NULL_TREE);
1578 decl_attributes ($$, $4, prefix_attributes); }
1579 | save_filename save_lineno
1580 declarator ':' expr_no_commas maybe_attribute
1581 { $$ = grokfield ($1, $2, $3, current_declspecs, $5);
1582 decl_attributes ($$, $6, prefix_attributes); }
1583 | save_filename save_lineno ':' expr_no_commas maybe_attribute
1584 { $$ = grokfield ($1, $2, NULL_TREE, current_declspecs, $4);
1585 decl_attributes ($$, $5, prefix_attributes); }
1588 /* We chain the enumerators in reverse order.
1589 They are put in forward order where enumlist is used.
1590 (The order used to be significant, but no longer is so.
1591 However, we still maintain the order, just to be clean.) */
1595 | enumlist ',' enumerator
1596 { if ($1 == error_mark_node)
1599 $$ = chainon ($3, $1); }
1601 { $$ = error_mark_node; }
1607 { $$ = build_enumerator ($1, NULL_TREE); }
1608 | identifier '=' expr_no_commas
1609 { $$ = build_enumerator ($1, $3); }
1613 typed_typespecs absdcl
1614 { $$ = build_tree_list ($1, $2); }
1615 | nonempty_type_quals absdcl
1616 { $$ = build_tree_list ($1, $2); }
1619 absdcl: /* an absolute declarator */
1625 nonempty_type_quals:
1627 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
1628 | nonempty_type_quals TYPE_QUAL
1629 { $$ = tree_cons (NULL_TREE, $2, $1); }
1635 | type_quals TYPE_QUAL
1636 { $$ = tree_cons (NULL_TREE, $2, $1); }
1639 absdcl1: /* a nonempty absolute declarator */
1642 /* `(typedef)1' is `int'. */
1643 | '*' type_quals absdcl1 %prec UNARY
1644 { $$ = make_pointer_declarator ($2, $3); }
1645 | '*' type_quals %prec UNARY
1646 { $$ = make_pointer_declarator ($2, NULL_TREE); }
1647 | absdcl1 '(' parmlist %prec '.'
1648 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1649 | absdcl1 '[' expr ']' %prec '.'
1650 { $$ = build_nt (ARRAY_REF, $1, $3); }
1651 | absdcl1 '[' ']' %prec '.'
1652 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1653 | '(' parmlist %prec '.'
1654 { $$ = build_nt (CALL_EXPR, NULL_TREE, $2, NULL_TREE); }
1655 | '[' expr ']' %prec '.'
1656 { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
1658 { $$ = build_nt (ARRAY_REF, NULL_TREE, NULL_TREE); }
1659 /* ??? It appears we have to support attributes here, however
1660 using prefix_attributes is wrong. */
1663 /* at least one statement, the first of which parses without error. */
1664 /* stmts is used only after decls, so an invalid first statement
1665 is actually regarded as an invalid decl and part of the decls. */
1668 lineno_stmt_or_labels
1671 pedwarn ("ANSI C forbids label at end of compound statement");
1675 lineno_stmt_or_labels:
1676 lineno_stmt_or_label
1677 | lineno_stmt_or_labels lineno_stmt_or_label
1679 | lineno_stmt_or_labels errstmt
1691 pushlevel: /* empty */
1692 { emit_line_note (input_filename, lineno);
1696 expand_start_bindings (0);
1698 if (objc_method_context)
1704 /* Read zero or more forward-declarations for labels
1705 that nested functions can jump to. */
1710 pedwarn ("ANSI C forbids label declarations"); }
1715 | label_decls label_decl
1719 LABEL identifiers_or_typenames ';'
1721 for (link = $2; link; link = TREE_CHAIN (link))
1723 tree label = shadow_label (TREE_VALUE (link));
1724 C_DECLARED_LABEL_FLAG (label) = 1;
1725 declare_nonlocal_label (label);
1730 /* This is the body of a function definition.
1731 It causes syntax errors to ignore to the next openbrace. */
1739 { $$ = convert (void_type_node, integer_zero_node); }
1740 | '{' pushlevel maybe_label_decls decls xstmts '}'
1741 { emit_line_note (input_filename, lineno);
1742 expand_end_bindings (getdecls (), 1, 0);
1743 $$ = poplevel (1, 1, 0);
1744 if (yychar == CONSTANT || yychar == STRING)
1745 pop_momentary_nofree ();
1748 | '{' pushlevel maybe_label_decls error '}'
1749 { emit_line_note (input_filename, lineno);
1750 expand_end_bindings (getdecls (), kept_level_p (), 0);
1751 $$ = poplevel (kept_level_p (), 0, 0);
1752 if (yychar == CONSTANT || yychar == STRING)
1753 pop_momentary_nofree ();
1756 | '{' pushlevel maybe_label_decls stmts '}'
1757 { emit_line_note (input_filename, lineno);
1758 expand_end_bindings (getdecls (), kept_level_p (), 0);
1759 $$ = poplevel (kept_level_p (), 0, 0);
1760 if (yychar == CONSTANT || yychar == STRING)
1761 pop_momentary_nofree ();
1766 /* Value is number of statements counted as of the closeparen. */
1768 if_prefix lineno_labeled_stmt
1769 /* Make sure expand_end_cond is run once
1770 for each call to expand_start_cond.
1771 Otherwise a crash is likely. */
1777 { emit_line_note ($<filename>-1, $<lineno>0);
1778 expand_start_cond (truthvalue_conversion ($3), 0);
1779 $<itype>$ = stmt_count;
1780 if_stmt_file = $<filename>-1;
1781 if_stmt_line = $<lineno>0;
1782 position_after_white_space (); }
1785 /* This is a subroutine of stmt.
1786 It is used twice, once for valid DO statements
1787 and once for catching errors in parsing the end test. */
1791 emit_line_note ($<filename>-1, $<lineno>0);
1792 /* See comment in `while' alternative, above. */
1794 expand_start_loop_continue_elsewhere (1);
1795 position_after_white_space (); }
1796 lineno_labeled_stmt WHILE
1797 { expand_loop_continue_here (); }
1801 { $$ = input_filename; }
1808 lineno_labeled_stmt:
1809 save_filename save_lineno stmt
1811 /* | save_filename save_lineno error
1814 | save_filename save_lineno label lineno_labeled_stmt
1818 lineno_stmt_or_label:
1819 save_filename save_lineno stmt_or_label
1830 /* Parse a single real statement, not including any labels. */
1837 emit_line_note ($<filename>-1, $<lineno>0);
1838 /* It appears that this should not be done--that a non-lvalue array
1839 shouldn't get an error if the value isn't used.
1840 Section 3.2.2.1 says that an array lvalue gets converted to a pointer
1841 if it appears as a top-level expression,
1842 but says nothing about non-lvalue arrays. */
1844 /* Call default_conversion to get an error
1845 on referring to a register array if pedantic. */
1846 if (TREE_CODE (TREE_TYPE ($1)) == ARRAY_TYPE
1847 || TREE_CODE (TREE_TYPE ($1)) == FUNCTION_TYPE)
1848 $1 = default_conversion ($1);
1850 iterator_expand ($1);
1851 clear_momentary (); }
1853 { expand_start_else ();
1854 $<itype>1 = stmt_count;
1855 position_after_white_space (); }
1857 { expand_end_cond ();
1858 if (extra_warnings && stmt_count == $<itype>1)
1859 warning ("empty body in an else-statement"); }
1860 | simple_if %prec IF
1861 { expand_end_cond ();
1862 /* This warning is here instead of in simple_if, because we
1863 do not want a warning if an empty if is followed by an
1864 else statement. Increment stmt_count so we don't
1865 give a second error if this is a nested `if'. */
1866 if (extra_warnings && stmt_count++ == $<itype>1)
1867 warning_with_file_and_line (if_stmt_file, if_stmt_line,
1868 "empty body in an if-statement"); }
1869 /* Make sure expand_end_cond is run once
1870 for each call to expand_start_cond.
1871 Otherwise a crash is likely. */
1872 | simple_if ELSE error
1873 { expand_end_cond (); }
1876 emit_line_note ($<filename>-1, $<lineno>0);
1877 /* The emit_nop used to come before emit_line_note,
1878 but that made the nop seem like part of the preceding line.
1879 And that was confusing when the preceding line was
1880 inside of an if statement and was not really executed.
1881 I think it ought to work to put the nop after the line number.
1882 We will see. --rms, July 15, 1991. */
1885 { /* Don't start the loop till we have succeeded
1886 in parsing the end test. This is to make sure
1887 that we end every loop we start. */
1888 expand_start_loop (1);
1889 emit_line_note (input_filename, lineno);
1890 expand_exit_loop_if_false (NULL_PTR,
1891 truthvalue_conversion ($4));
1892 position_after_white_space (); }
1894 { expand_end_loop (); }
1897 { emit_line_note (input_filename, lineno);
1898 expand_exit_loop_if_false (NULL_PTR,
1899 truthvalue_conversion ($3));
1901 clear_momentary (); }
1902 /* This rule is needed to make sure we end every loop we start. */
1903 | do_stmt_start error
1904 { expand_end_loop ();
1905 clear_momentary (); }
1909 emit_line_note ($<filename>-1, $<lineno>0);
1910 /* See comment in `while' alternative, above. */
1912 if ($3) c_expand_expr_stmt ($3);
1913 /* Next step is to call expand_start_loop_continue_elsewhere,
1914 but wait till after we parse the entire for (...).
1915 Otherwise, invalid input might cause us to call that
1916 fn without calling expand_end_loop. */
1919 /* Can't emit now; wait till after expand_start_loop... */
1920 { $<lineno>7 = lineno;
1921 $<filename>$ = input_filename; }
1924 /* Start the loop. Doing this after parsing
1925 all the expressions ensures we will end the loop. */
1926 expand_start_loop_continue_elsewhere (1);
1927 /* Emit the end-test, with a line number. */
1928 emit_line_note ($<filename>8, $<lineno>7);
1930 expand_exit_loop_if_false (NULL_PTR,
1931 truthvalue_conversion ($6));
1932 /* Don't let the tree nodes for $9 be discarded by
1933 clear_momentary during the parsing of the next stmt. */
1935 $<lineno>7 = lineno;
1936 $<filename>8 = input_filename;
1937 position_after_white_space (); }
1939 { /* Emit the increment expression, with a line number. */
1940 emit_line_note ($<filename>8, $<lineno>7);
1941 expand_loop_continue_here ();
1943 c_expand_expr_stmt ($9);
1944 if (yychar == CONSTANT || yychar == STRING)
1945 pop_momentary_nofree ();
1948 expand_end_loop (); }
1949 | SWITCH '(' expr ')'
1951 emit_line_note ($<filename>-1, $<lineno>0);
1952 c_expand_start_case ($3);
1953 /* Don't let the tree nodes for $3 be discarded by
1954 clear_momentary during the parsing of the next stmt. */
1956 position_after_white_space (); }
1958 { expand_end_case ($3);
1959 if (yychar == CONSTANT || yychar == STRING)
1960 pop_momentary_nofree ();
1965 emit_line_note ($<filename>-1, $<lineno>0);
1966 if ( ! expand_exit_something ())
1967 error ("break statement not within loop or switch"); }
1970 emit_line_note ($<filename>-1, $<lineno>0);
1971 if (! expand_continue_loop (NULL_PTR))
1972 error ("continue statement not within a loop"); }
1975 emit_line_note ($<filename>-1, $<lineno>0);
1976 c_expand_return (NULL_TREE); }
1979 emit_line_note ($<filename>-1, $<lineno>0);
1980 c_expand_return ($2); }
1981 | ASM_KEYWORD maybe_type_qual '(' expr ')' ';'
1983 emit_line_note ($<filename>-1, $<lineno>0);
1985 if ((TREE_CODE ($4) == ADDR_EXPR
1986 && TREE_CODE (TREE_OPERAND ($4, 0)) == STRING_CST)
1987 || TREE_CODE ($4) == STRING_CST)
1990 error ("argument of `asm' is not a constant string"); }
1991 /* This is the case with just output operands. */
1992 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ')' ';'
1994 emit_line_note ($<filename>-1, $<lineno>0);
1995 c_expand_asm_operands ($4, $6, NULL_TREE, NULL_TREE,
1996 $2 == ridpointers[(int)RID_VOLATILE],
1997 input_filename, lineno); }
1998 /* This is the case with input operands as well. */
1999 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':' asm_operands ')' ';'
2001 emit_line_note ($<filename>-1, $<lineno>0);
2002 c_expand_asm_operands ($4, $6, $8, NULL_TREE,
2003 $2 == ridpointers[(int)RID_VOLATILE],
2004 input_filename, lineno); }
2005 /* This is the case with clobbered registers as well. */
2006 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':'
2007 asm_operands ':' asm_clobbers ')' ';'
2009 emit_line_note ($<filename>-1, $<lineno>0);
2010 c_expand_asm_operands ($4, $6, $8, $10,
2011 $2 == ridpointers[(int)RID_VOLATILE],
2012 input_filename, lineno); }
2013 | GOTO identifier ';'
2016 emit_line_note ($<filename>-1, $<lineno>0);
2017 decl = lookup_label ($2);
2020 TREE_USED (decl) = 1;
2026 pedwarn ("ANSI C forbids `goto *expr;'");
2028 emit_line_note ($<filename>-1, $<lineno>0);
2029 expand_computed_goto (convert (ptr_type_node, $3)); }
2034 all_iter_stmt_simple
2035 /* | all_iter_stmt_with_decl */
2038 all_iter_stmt_simple:
2041 /* The value returned by this action is */
2042 /* 1 if everything is OK */
2043 /* 0 in case of error or already bound iterator */
2046 if (TREE_CODE ($3) != VAR_DECL)
2047 error ("invalid `for (ITERATOR)' syntax");
2048 else if (! ITERATOR_P ($3))
2049 error ("`%s' is not an iterator",
2050 IDENTIFIER_POINTER (DECL_NAME ($3)));
2051 else if (ITERATOR_BOUND_P ($3))
2052 error ("`for (%s)' inside expansion of same iterator",
2053 IDENTIFIER_POINTER (DECL_NAME ($3)));
2057 iterator_for_loop_start ($3);
2063 iterator_for_loop_end ($3);
2066 /* This really should allow any kind of declaration,
2067 for generality. Fix it before turning it back on.
2069 all_iter_stmt_with_decl:
2070 FOR '(' ITERATOR pushlevel setspecs iterator_spec ')'
2072 */ /* The value returned by this action is */
2073 /* 1 if everything is OK */
2074 /* 0 in case of error or already bound iterator */
2076 iterator_for_loop_start ($6);
2080 iterator_for_loop_end ($6);
2081 emit_line_note (input_filename, lineno);
2082 expand_end_bindings (getdecls (), 1, 0);
2083 $<ttype>$ = poplevel (1, 1, 0);
2084 if (yychar == CONSTANT || yychar == STRING)
2085 pop_momentary_nofree ();
2091 /* Any kind of label, including jump labels and case labels.
2092 ANSI C accepts labels only before statements, but we allow them
2093 also at the end of a compound statement. */
2095 label: CASE expr_no_commas ':'
2096 { register tree value = check_case_value ($2);
2098 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
2102 if (value != error_mark_node)
2105 int success = pushcase (value, convert_and_check,
2108 error ("case label not within a switch statement");
2109 else if (success == 2)
2111 error ("duplicate case value");
2112 error_with_decl (duplicate, "this is the first entry for that value");
2114 else if (success == 3)
2115 warning ("case value out of range");
2116 else if (success == 5)
2117 error ("case label within scope of cleanup or variable array");
2119 position_after_white_space (); }
2120 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
2121 { register tree value1 = check_case_value ($2);
2122 register tree value2 = check_case_value ($4);
2124 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
2127 pedwarn ("ANSI C forbids case ranges");
2130 if (value1 != error_mark_node && value2 != error_mark_node)
2133 int success = pushcase_range (value1, value2,
2134 convert_and_check, label,
2137 error ("case label not within a switch statement");
2138 else if (success == 2)
2140 error ("duplicate case value");
2141 error_with_decl (duplicate, "this is the first entry for that value");
2143 else if (success == 3)
2144 warning ("case value out of range");
2145 else if (success == 4)
2146 warning ("empty case range");
2147 else if (success == 5)
2148 error ("case label within scope of cleanup or variable array");
2150 position_after_white_space (); }
2155 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
2156 int success = pushcase (NULL_TREE, 0, label, &duplicate);
2159 error ("default label not within a switch statement");
2160 else if (success == 2)
2162 error ("multiple default labels in one switch");
2163 error_with_decl (duplicate, "this is the first default label");
2165 position_after_white_space (); }
2167 { tree label = define_label (input_filename, lineno, $1);
2171 expand_label (label);
2172 position_after_white_space (); }
2175 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
2179 { emit_line_note (input_filename, lineno);
2182 { emit_line_note (input_filename, lineno); }
2191 /* These are the operands other than the first string and colon
2192 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
2193 asm_operands: /* empty */
2195 | nonnull_asm_operands
2198 nonnull_asm_operands:
2200 | nonnull_asm_operands ',' asm_operand
2201 { $$ = chainon ($1, $3); }
2206 { $$ = build_tree_list ($1, $3); }
2211 { $$ = tree_cons (NULL_TREE, combine_strings ($1), NULL_TREE); }
2212 | asm_clobbers ',' string
2213 { $$ = tree_cons (NULL_TREE, combine_strings ($3), $1); }
2216 /* This is what appears inside the parens in a function declarator.
2217 Its value is a list of ..._TYPE nodes. */
2220 clear_parm_order ();
2221 declare_parm_level (0); }
2224 parmlist_tags_warning ();
2225 poplevel (0, 0, 0); }
2233 pedwarn ("ANSI C forbids forward parameter declarations");
2234 /* Mark the forward decls as such. */
2235 for (parm = getdecls (); parm; parm = TREE_CHAIN (parm))
2236 TREE_ASM_WRITTEN (parm) = 1;
2237 clear_parm_order (); }
2241 { $$ = tree_cons (NULL_TREE, NULL_TREE, NULL_TREE); }
2244 /* This is what appears inside the parens in a function declarator.
2245 Is value is represented in the format that grokdeclarator expects. */
2246 parmlist_2: /* empty */
2247 { $$ = get_parm_info (0); }
2249 { $$ = get_parm_info (0);
2250 /* Gcc used to allow this as an extension. However, it does
2251 not work for all targets, and thus has been disabled.
2252 Also, since func (...) and func () are indistinguishable,
2253 it caused problems with the code in expand_builtin which
2254 tries to verify that BUILT_IN_NEXT_ARG is being used
2256 error ("ANSI C requires a named argument before `...'");
2259 { $$ = get_parm_info (1); }
2260 | parms ',' ELLIPSIS
2261 { $$ = get_parm_info (0); }
2266 { push_parm_decl ($1); }
2268 { push_parm_decl ($3); }
2271 /* A single parameter declaration or parameter type name,
2272 as found in a parmlist. */
2274 typed_declspecs setspecs parm_declarator maybe_attribute
2275 { $$ = build_tree_list (build_tree_list (current_declspecs,
2277 build_tree_list (prefix_attributes,
2279 current_declspecs = TREE_VALUE (declspec_stack);
2280 prefix_attributes = TREE_PURPOSE (declspec_stack);
2281 declspec_stack = TREE_CHAIN (declspec_stack);
2282 resume_momentary ($2); }
2283 | typed_declspecs setspecs notype_declarator maybe_attribute
2284 { $$ = build_tree_list (build_tree_list (current_declspecs,
2286 build_tree_list (prefix_attributes,
2288 current_declspecs = TREE_VALUE (declspec_stack);
2289 prefix_attributes = TREE_PURPOSE (declspec_stack);
2290 declspec_stack = TREE_CHAIN (declspec_stack);
2291 resume_momentary ($2); }
2292 | typed_declspecs setspecs absdcl maybe_attribute
2293 { $$ = build_tree_list (build_tree_list (current_declspecs,
2295 build_tree_list (prefix_attributes,
2297 current_declspecs = TREE_VALUE (declspec_stack);
2298 prefix_attributes = TREE_PURPOSE (declspec_stack);
2299 declspec_stack = TREE_CHAIN (declspec_stack);
2300 resume_momentary ($2); }
2301 | declmods setspecs notype_declarator maybe_attribute
2302 { $$ = build_tree_list (build_tree_list (current_declspecs,
2304 build_tree_list (prefix_attributes,
2306 current_declspecs = TREE_VALUE (declspec_stack);
2307 prefix_attributes = TREE_PURPOSE (declspec_stack);
2308 declspec_stack = TREE_CHAIN (declspec_stack);
2309 resume_momentary ($2); }
2311 | declmods setspecs absdcl maybe_attribute
2312 { $$ = build_tree_list (build_tree_list (current_declspecs,
2314 build_tree_list (prefix_attributes,
2316 current_declspecs = TREE_VALUE (declspec_stack);
2317 prefix_attributes = TREE_PURPOSE (declspec_stack);
2318 declspec_stack = TREE_CHAIN (declspec_stack);
2319 resume_momentary ($2); }
2322 /* This is used in a function definition
2323 where either a parmlist or an identifier list is ok.
2324 Its value is a list of ..._TYPE nodes or a list of identifiers. */
2325 parmlist_or_identifiers:
2327 clear_parm_order ();
2328 declare_parm_level (1); }
2329 parmlist_or_identifiers_1
2331 parmlist_tags_warning ();
2332 poplevel (0, 0, 0); }
2335 parmlist_or_identifiers_1:
2339 for (t = $1; t; t = TREE_CHAIN (t))
2340 if (TREE_VALUE (t) == NULL_TREE)
2341 error ("`...' in old-style identifier list");
2342 $$ = tree_cons (NULL_TREE, NULL_TREE, $1); }
2345 /* A nonempty list of identifiers. */
2348 { $$ = build_tree_list (NULL_TREE, $1); }
2349 | identifiers ',' IDENTIFIER
2350 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2353 /* A nonempty list of identifiers, including typenames. */
2354 identifiers_or_typenames:
2356 { $$ = build_tree_list (NULL_TREE, $1); }
2357 | identifiers_or_typenames ',' identifier
2358 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2363 { $<itype>$ = pedantic;
2368 /* Objective-C productions. */
2378 if (objc_implementation_context)
2380 finish_class (objc_implementation_context);
2381 objc_ivar_chain = NULL_TREE;
2382 objc_implementation_context = NULL_TREE;
2385 warning ("`@end' must appear in an implementation context");
2389 /* A nonempty list of identifiers. */
2392 { $$ = build_tree_list (NULL_TREE, $1); }
2393 | identifier_list ',' identifier
2394 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2398 CLASS identifier_list ';'
2400 objc_declare_class ($2);
2404 ALIAS identifier identifier ';'
2406 objc_declare_alias ($2, $3);
2410 INTERFACE identifier protocolrefs '{'
2412 objc_interface_context = objc_ivar_context
2413 = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, $3);
2414 objc_public_flag = 0;
2418 continue_class (objc_interface_context);
2423 finish_class (objc_interface_context);
2424 objc_interface_context = NULL_TREE;
2427 | INTERFACE identifier protocolrefs
2429 objc_interface_context
2430 = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, $3);
2431 continue_class (objc_interface_context);
2436 finish_class (objc_interface_context);
2437 objc_interface_context = NULL_TREE;
2440 | INTERFACE identifier ':' identifier protocolrefs '{'
2442 objc_interface_context = objc_ivar_context
2443 = start_class (CLASS_INTERFACE_TYPE, $2, $4, $5);
2444 objc_public_flag = 0;
2448 continue_class (objc_interface_context);
2453 finish_class (objc_interface_context);
2454 objc_interface_context = NULL_TREE;
2457 | INTERFACE identifier ':' identifier protocolrefs
2459 objc_interface_context
2460 = start_class (CLASS_INTERFACE_TYPE, $2, $4, $5);
2461 continue_class (objc_interface_context);
2466 finish_class (objc_interface_context);
2467 objc_interface_context = NULL_TREE;
2470 | IMPLEMENTATION identifier '{'
2472 objc_implementation_context = objc_ivar_context
2473 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, NULL_TREE, NULL_TREE);
2474 objc_public_flag = 0;
2479 = continue_class (objc_implementation_context);
2482 | IMPLEMENTATION identifier
2484 objc_implementation_context
2485 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, NULL_TREE, NULL_TREE);
2487 = continue_class (objc_implementation_context);
2490 | IMPLEMENTATION identifier ':' identifier '{'
2492 objc_implementation_context = objc_ivar_context
2493 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2494 objc_public_flag = 0;
2499 = continue_class (objc_implementation_context);
2502 | IMPLEMENTATION identifier ':' identifier
2504 objc_implementation_context
2505 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2507 = continue_class (objc_implementation_context);
2510 | INTERFACE identifier '(' identifier ')' protocolrefs
2512 objc_interface_context
2513 = start_class (CATEGORY_INTERFACE_TYPE, $2, $4, $6);
2514 continue_class (objc_interface_context);
2519 finish_class (objc_interface_context);
2520 objc_interface_context = NULL_TREE;
2523 | IMPLEMENTATION identifier '(' identifier ')'
2525 objc_implementation_context
2526 = start_class (CATEGORY_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2528 = continue_class (objc_implementation_context);
2533 PROTOCOL identifier protocolrefs
2535 remember_protocol_qualifiers ();
2536 objc_interface_context
2537 = start_protocol(PROTOCOL_INTERFACE_TYPE, $2, $3);
2541 forget_protocol_qualifiers();
2542 finish_protocol(objc_interface_context);
2543 objc_interface_context = NULL_TREE;
2552 | non_empty_protocolrefs
2555 non_empty_protocolrefs:
2556 ARITHCOMPARE identifier_list ARITHCOMPARE
2558 if ($1 == LT_EXPR && $3 == GT_EXPR)
2566 ivar_decl_list visibility_spec ivar_decls
2571 PRIVATE { objc_public_flag = 2; }
2572 | PROTECTED { objc_public_flag = 0; }
2573 | PUBLIC { objc_public_flag = 1; }
2581 | ivar_decls ivar_decl ';'
2585 pedwarn ("extra semicolon in struct or union specified");
2590 /* There is a shift-reduce conflict here, because `components' may
2591 start with a `typename'. It happens that shifting (the default resolution)
2592 does the right thing, because it treats the `typename' as part of
2593 a `typed_typespecs'.
2595 It is possible that this same technique would allow the distinction
2596 between `notype_initdecls' and `initdecls' to be eliminated.
2597 But I am being cautious and not trying it. */
2600 typed_typespecs setspecs ivars
2602 current_declspecs = TREE_VALUE (declspec_stack);
2603 prefix_attributes = TREE_PURPOSE (declspec_stack);
2604 declspec_stack = TREE_CHAIN (declspec_stack);
2605 resume_momentary ($2); }
2606 | nonempty_type_quals setspecs ivars
2608 current_declspecs = TREE_VALUE (declspec_stack);
2609 prefix_attributes = TREE_PURPOSE (declspec_stack);
2610 declspec_stack = TREE_CHAIN (declspec_stack);
2611 resume_momentary ($2); }
2620 | ivars ',' ivar_declarator
2626 $$ = add_instance_variable (objc_ivar_context,
2628 $1, current_declspecs,
2631 | declarator ':' expr_no_commas
2633 $$ = add_instance_variable (objc_ivar_context,
2635 $1, current_declspecs, $3);
2637 | ':' expr_no_commas
2639 $$ = add_instance_variable (objc_ivar_context,
2642 current_declspecs, $2);
2649 remember_protocol_qualifiers ();
2650 if (objc_implementation_context)
2651 objc_inherit_code = CLASS_METHOD_DECL;
2653 fatal ("method definition not in class context");
2657 forget_protocol_qualifiers ();
2658 add_class_method (objc_implementation_context, $3);
2659 start_method_def ($3);
2660 objc_method_context = $3;
2664 continue_method_def ();
2668 finish_method_def ();
2669 objc_method_context = NULL_TREE;
2674 remember_protocol_qualifiers ();
2675 if (objc_implementation_context)
2676 objc_inherit_code = INSTANCE_METHOD_DECL;
2678 fatal ("method definition not in class context");
2682 forget_protocol_qualifiers ();
2683 add_instance_method (objc_implementation_context, $3);
2684 start_method_def ($3);
2685 objc_method_context = $3;
2689 continue_method_def ();
2693 finish_method_def ();
2694 objc_method_context = NULL_TREE;
2698 /* the reason for the strange actions in this rule
2699 is so that notype_initdecls when reached via datadef
2700 can find a valid list of type and sc specs in $0. */
2704 | {$<ttype>$ = NULL_TREE; } methodprotolist2
2707 methodprotolist2: /* eliminates a shift/reduce conflict */
2710 | methodprotolist2 methodproto
2711 | methodprotolist2 {$<ttype>$ = NULL_TREE; } datadef
2722 objc_inherit_code = CLASS_METHOD_DECL;
2726 add_class_method (objc_interface_context, $3);
2732 objc_inherit_code = INSTANCE_METHOD_DECL;
2736 add_instance_method (objc_interface_context, $3);
2742 '(' typename ')' unaryselector
2744 $$ = build_method_decl (objc_inherit_code, $2, $4, NULL_TREE);
2749 $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, NULL_TREE);
2752 | '(' typename ')' keywordselector optparmlist
2754 $$ = build_method_decl (objc_inherit_code, $2, $4, $5);
2757 | keywordselector optparmlist
2759 $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, $2);
2763 /* "optarglist" assumes that start_method_def has already been called...
2764 if it is not, the "xdecls" will not be placed in the proper scope */
2771 /* to get around the following situation: "int foo (int a) int b; {}" that
2772 is synthesized when parsing "- a:a b:b; id c; id d; { ... }" */
2787 typed_declspecs setspecs myparms ';'
2788 { current_declspecs = TREE_VALUE (declspec_stack);
2789 prefix_attributes = TREE_PURPOSE (declspec_stack);
2790 declspec_stack = TREE_CHAIN (declspec_stack);
2791 resume_momentary ($2); }
2792 | typed_declspecs ';'
2793 { shadow_tag ($1); }
2795 { pedwarn ("empty declaration"); }
2800 { push_parm_decl ($1); }
2801 | myparms ',' myparm
2802 { push_parm_decl ($3); }
2805 /* A single parameter declaration or parameter type name,
2806 as found in a parmlist. DOES NOT ALLOW AN INITIALIZER OR ASMSPEC */
2809 parm_declarator maybe_attribute
2810 { $$ = build_tree_list (build_tree_list (current_declspecs,
2812 build_tree_list (prefix_attributes,
2814 | notype_declarator maybe_attribute
2815 { $$ = build_tree_list (build_tree_list (current_declspecs,
2817 build_tree_list (prefix_attributes,
2819 | absdcl maybe_attribute
2820 { $$ = build_tree_list (build_tree_list (current_declspecs,
2822 build_tree_list (prefix_attributes,
2833 /* oh what a kludge! */
2842 /* returns a tree list node generated by get_parm_info */
2855 | keywordselector keyworddecl
2857 $$ = chainon ($1, $2);
2869 ENUM { $$ = get_identifier (token_buffer); }
2870 | STRUCT { $$ = get_identifier (token_buffer); }
2871 | UNION { $$ = get_identifier (token_buffer); }
2872 | IF { $$ = get_identifier (token_buffer); }
2873 | ELSE { $$ = get_identifier (token_buffer); }
2874 | WHILE { $$ = get_identifier (token_buffer); }
2875 | DO { $$ = get_identifier (token_buffer); }
2876 | FOR { $$ = get_identifier (token_buffer); }
2877 | SWITCH { $$ = get_identifier (token_buffer); }
2878 | CASE { $$ = get_identifier (token_buffer); }
2879 | DEFAULT { $$ = get_identifier (token_buffer); }
2880 | BREAK { $$ = get_identifier (token_buffer); }
2881 | CONTINUE { $$ = get_identifier (token_buffer); }
2882 | RETURN { $$ = get_identifier (token_buffer); }
2883 | GOTO { $$ = get_identifier (token_buffer); }
2884 | ASM_KEYWORD { $$ = get_identifier (token_buffer); }
2885 | SIZEOF { $$ = get_identifier (token_buffer); }
2886 | TYPEOF { $$ = get_identifier (token_buffer); }
2887 | ALIGNOF { $$ = get_identifier (token_buffer); }
2888 | TYPESPEC | TYPE_QUAL
2892 selector ':' '(' typename ')' identifier
2894 $$ = build_keyword_decl ($1, $4, $6);
2897 | selector ':' identifier
2899 $$ = build_keyword_decl ($1, NULL_TREE, $3);
2902 | ':' '(' typename ')' identifier
2904 $$ = build_keyword_decl (NULL_TREE, $3, $5);
2909 $$ = build_keyword_decl (NULL_TREE, NULL_TREE, $2);
2920 | keywordarglist keywordarg
2922 $$ = chainon ($1, $2);
2930 if (TREE_CHAIN ($1) == NULL_TREE)
2931 /* just return the expr., remove a level of indirection */
2932 $$ = TREE_VALUE ($1);
2934 /* we have a comma expr., we will collapse later */
2940 selector ':' keywordexpr
2942 $$ = build_tree_list ($1, $3);
2946 $$ = build_tree_list (NULL_TREE, $2);
2954 $$ = get_class_reference ($1);
2960 { objc_receiver_context = 1; }
2962 { objc_receiver_context = 0; }
2965 $$ = build_tree_list ($3, $5);
2976 | keywordnamelist keywordname
2978 $$ = chainon ($1, $2);
2985 $$ = build_tree_list ($1, NULL_TREE);
2989 $$ = build_tree_list (NULL_TREE, NULL_TREE);
2994 SELECTOR '(' selectorarg ')'
3001 PROTOCOL '(' identifier ')'
3007 /* extension to support C-structures in the archiver */
3010 ENCODE '(' typename ')'
3012 $$ = groktypename ($3);