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> 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 $<itype>2 = $1 == boolean_false_node;
581 skip_evaluation += $<itype>2; }
583 { skip_evaluation -= $<itype>2;
584 $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $4); }
585 | expr_no_commas OROR
586 { $1 = truthvalue_conversion (default_conversion ($1));
587 $<itype>3 = $1 == boolean_true_node;
588 skip_evaluation += $<itype>3; }
590 { skip_evaluation -= $<itype>3;
591 $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $4); }
593 { $1 = truthvalue_conversion (default_conversion ($1));
594 $<itype>3 = $1 == boolean_true_node;
595 $<itype>2 = $1 == boolean_false_node;
596 skip_evaluation += $<itype>2; }
598 { skip_evaluation += $<itype>3 - $<itype>2; }
600 { skip_evaluation -= $<itype>3;
601 $$ = build_conditional_expr ($1, $4, $7); }
604 pedwarn ("ANSI C forbids omitting the middle term of a ?: expression");
605 /* Make sure first operand is calculated only once. */
606 $<ttype>2 = save_expr ($1);
607 $1 = truthvalue_conversion (default_conversion ($<ttype>2));
608 $<itype>3 = $1 == boolean_true_node;
609 skip_evaluation += $<itype>3; }
611 { skip_evaluation -= $<itype>3;
612 $$ = build_conditional_expr ($1, $<ttype>2, $5); }
613 | expr_no_commas '=' expr_no_commas
614 { $$ = build_modify_expr ($1, NOP_EXPR, $3);
615 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
616 | expr_no_commas ASSIGN expr_no_commas
617 { $$ = build_modify_expr ($1, $2, $3);
618 /* This inhibits warnings in truthvalue_conversion. */
619 C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK); }
626 if (!$$ || $$ == error_mark_node)
628 if (yychar == YYEMPTY)
635 if (objc_receiver_context
636 && ! (objc_receiver_context
637 && strcmp (IDENTIFIER_POINTER ($1), "super")))
638 /* we have a message to super */
639 $$ = get_super_receiver ();
640 else if (objc_method_context
641 && (decl = is_ivar (objc_ivar_chain, $1)))
643 if (is_private (decl))
644 $$ = error_mark_node;
646 $$ = build_ivar_reference ($1);
651 /* Ordinary implicit function declaration. */
652 $$ = implicitly_declare ($1);
653 assemble_external ($$);
657 else if (current_function_decl == 0)
659 error ("`%s' undeclared here (not in a function)",
660 IDENTIFIER_POINTER ($1));
661 $$ = error_mark_node;
668 if (objc_receiver_context
669 && ! strcmp (IDENTIFIER_POINTER ($1), "super"))
670 /* we have a message to super */
671 $$ = get_super_receiver ();
672 else if (objc_method_context
673 && (decl = is_ivar (objc_ivar_chain, $1)))
675 if (is_private (decl))
676 $$ = error_mark_node;
678 $$ = build_ivar_reference ($1);
683 if (IDENTIFIER_GLOBAL_VALUE ($1) != error_mark_node
684 || IDENTIFIER_ERROR_LOCUS ($1) != current_function_decl)
686 error ("`%s' undeclared (first use this function)",
687 IDENTIFIER_POINTER ($1));
689 if (! undeclared_variable_notice)
691 error ("(Each undeclared identifier is reported only once");
692 error ("for each function it appears in.)");
693 undeclared_variable_notice = 1;
696 $$ = error_mark_node;
697 /* Prevent repeated error messages. */
698 IDENTIFIER_GLOBAL_VALUE ($1) = error_mark_node;
699 IDENTIFIER_ERROR_LOCUS ($1) = current_function_decl;
703 else if (TREE_TYPE ($$) == error_mark_node)
704 $$ = error_mark_node;
705 else if (C_DECL_ANTICIPATED ($$))
707 /* The first time we see a build-in function used,
708 if it has not been declared. */
709 C_DECL_ANTICIPATED ($$) = 0;
710 if (yychar == YYEMPTY)
714 /* Omit the implicit declaration we
715 would ordinarily do, so we don't lose
716 the actual built in type.
717 But print a diagnostic for the mismatch. */
719 if (objc_method_context
720 && is_ivar (objc_ivar_chain, $1))
721 error ("Instance variable `%s' implicitly declared as function",
722 IDENTIFIER_POINTER (DECL_NAME ($$)));
725 if (TREE_CODE ($$) != FUNCTION_DECL)
726 error ("`%s' implicitly declared as function",
727 IDENTIFIER_POINTER (DECL_NAME ($$)));
728 else if ((TYPE_MODE (TREE_TYPE (TREE_TYPE ($$)))
729 != TYPE_MODE (integer_type_node))
730 && (TREE_TYPE (TREE_TYPE ($$))
732 pedwarn ("type mismatch in implicit declaration for built-in function `%s'",
733 IDENTIFIER_POINTER (DECL_NAME ($$)));
734 /* If it really returns void, change that to int. */
735 if (TREE_TYPE (TREE_TYPE ($$)) == void_type_node)
737 = build_function_type (integer_type_node,
738 TYPE_ARG_TYPES (TREE_TYPE ($$)));
741 pedwarn ("built-in function `%s' used without declaration",
742 IDENTIFIER_POINTER (DECL_NAME ($$)));
744 /* Do what we would ordinarily do when a fn is used. */
745 assemble_external ($$);
750 assemble_external ($$);
753 /* we have a definition - still check if iVariable */
755 if (!objc_receiver_context
756 || (objc_receiver_context
757 && strcmp (IDENTIFIER_POINTER ($1), "super")))
761 if (objc_method_context
762 && (decl = is_ivar (objc_ivar_chain, $1)))
764 if (IDENTIFIER_LOCAL_VALUE ($1))
765 warning ("local declaration of `%s' hides instance variable",
766 IDENTIFIER_POINTER ($1));
769 if (is_private (decl))
770 $$ = error_mark_node;
772 $$ = build_ivar_reference ($1);
776 else /* we have a message to super */
777 $$ = get_super_receiver ();
781 if (TREE_CODE ($$) == CONST_DECL)
783 $$ = DECL_INITIAL ($$);
784 /* This is to prevent an enum whose value is 0
785 from being considered a null pointer constant. */
786 $$ = build1 (NOP_EXPR, TREE_TYPE ($$), $$);
787 TREE_CONSTANT ($$) = 1;
792 { $$ = combine_strings ($1); }
794 { char class = TREE_CODE_CLASS (TREE_CODE ($2));
795 if (class == 'e' || class == '1'
796 || class == '2' || class == '<')
797 C_SET_EXP_ORIGINAL_CODE ($2, ERROR_MARK);
800 { $$ = error_mark_node; }
802 { if (current_function_decl == 0)
804 error ("braced-group within expression allowed only inside a function");
807 /* We must force a BLOCK for this level
808 so that, if it is not expanded later,
809 there is a way to turn off the entire subtree of blocks
810 that are contained in it. */
812 push_iterator_stack ();
814 $<ttype>$ = expand_start_stmt_expr (); }
818 pedwarn ("ANSI C forbids braced-groups within expressions");
819 pop_iterator_stack ();
821 rtl_exp = expand_end_stmt_expr ($<ttype>2);
822 /* The statements have side effects, so the group does. */
823 TREE_SIDE_EFFECTS (rtl_exp) = 1;
825 if (TREE_CODE ($3) == BLOCK)
827 /* Make a BIND_EXPR for the BLOCK already made. */
828 $$ = build (BIND_EXPR, TREE_TYPE (rtl_exp),
829 NULL_TREE, rtl_exp, $3);
830 /* Remove the block from the tree at this point.
831 It gets put back at the proper place
832 when the BIND_EXPR is expanded. */
838 | primary '(' exprlist ')' %prec '.'
839 { $$ = build_function_call ($1, $3); }
840 | primary '[' expr ']' %prec '.'
841 { $$ = build_array_ref ($1, $3); }
842 | primary '.' identifier
845 if (doing_objc_thang)
847 if (is_public ($1, $3))
848 $$ = build_component_ref ($1, $3);
850 $$ = error_mark_node;
854 $$ = build_component_ref ($1, $3);
856 | primary POINTSAT identifier
858 tree expr = build_indirect_ref ($1, "->");
861 if (doing_objc_thang)
863 if (is_public (expr, $3))
864 $$ = build_component_ref (expr, $3);
866 $$ = error_mark_node;
870 $$ = build_component_ref (expr, $3);
873 { $$ = build_unary_op (POSTINCREMENT_EXPR, $1, 0); }
875 { $$ = build_unary_op (POSTDECREMENT_EXPR, $1, 0); }
878 { $$ = build_message_expr ($1); }
880 { $$ = build_selector_expr ($1); }
882 { $$ = build_protocol_expr ($1); }
884 { $$ = build_encode_expr ($1); }
886 { $$ = build_objc_string_object ($1); }
890 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
894 { $$ = chainon ($1, $2); }
898 /* Produces an OBJC_STRING_CST with perhaps more OBJC_STRING_CSTs chained
902 | objc_string OBJC_STRING
903 { $$ = chainon ($1, $2); }
907 old_style_parm_decls:
911 /* ... is used here to indicate a varargs function. */
914 pedwarn ("ANSI C does not permit use of `varargs.h'"); }
917 /* The following are analogous to lineno_decl, decls and decl
918 except that they do not allow nested functions.
919 They are used for old-style parm decls. */
921 save_filename save_lineno datadecl
928 | datadecls lineno_datadecl
929 | lineno_datadecl errstmt
932 /* We don't allow prefix attributes here because they cause reduce/reduce
933 conflicts: we can't know whether we're parsing a function decl with
934 attribute suffix, or function defn with attribute prefix on first old
937 typed_declspecs_no_prefix_attr setspecs initdecls ';'
938 { current_declspecs = TREE_VALUE (declspec_stack);
939 prefix_attributes = TREE_PURPOSE (declspec_stack);
940 declspec_stack = TREE_CHAIN (declspec_stack);
941 resume_momentary ($2); }
942 | declmods_no_prefix_attr setspecs notype_initdecls ';'
943 { current_declspecs = TREE_VALUE (declspec_stack);
944 prefix_attributes = TREE_PURPOSE (declspec_stack);
945 declspec_stack = TREE_CHAIN (declspec_stack);
946 resume_momentary ($2); }
947 | typed_declspecs_no_prefix_attr ';'
948 { shadow_tag_warned ($1, 1);
949 pedwarn ("empty declaration"); }
950 | declmods_no_prefix_attr ';'
951 { pedwarn ("empty declaration"); }
954 /* This combination which saves a lineno before a decl
955 is the normal thing to use, rather than decl itself.
956 This is to avoid shift/reduce conflicts in contexts
957 where statement labels are allowed. */
959 save_filename save_lineno decl
967 | lineno_decl errstmt
970 /* records the type and storage class specs to use for processing
971 the declarators that follow.
972 Maintains a stack of outer-level values of current_declspecs,
973 for the sake of parm declarations nested in function declarators. */
974 setspecs: /* empty */
975 { $$ = suspend_momentary ();
976 pending_xref_error ();
977 declspec_stack = tree_cons (prefix_attributes,
980 split_specs_attrs ($<ttype>0,
981 ¤t_declspecs, &prefix_attributes); }
984 /* ??? Yuck. See after_type_declarator. */
985 setattrs: /* empty */
986 { prefix_attributes = chainon (prefix_attributes, $<ttype>0); }
990 typed_declspecs setspecs initdecls ';'
991 { current_declspecs = TREE_VALUE (declspec_stack);
992 prefix_attributes = TREE_PURPOSE (declspec_stack);
993 declspec_stack = TREE_CHAIN (declspec_stack);
994 resume_momentary ($2); }
995 | declmods setspecs notype_initdecls ';'
996 { current_declspecs = TREE_VALUE (declspec_stack);
997 prefix_attributes = TREE_PURPOSE (declspec_stack);
998 declspec_stack = TREE_CHAIN (declspec_stack);
999 resume_momentary ($2); }
1000 | typed_declspecs setspecs nested_function
1001 { current_declspecs = TREE_VALUE (declspec_stack);
1002 prefix_attributes = TREE_PURPOSE (declspec_stack);
1003 declspec_stack = TREE_CHAIN (declspec_stack);
1004 resume_momentary ($2); }
1005 | declmods setspecs notype_nested_function
1006 { current_declspecs = TREE_VALUE (declspec_stack);
1007 prefix_attributes = TREE_PURPOSE (declspec_stack);
1008 declspec_stack = TREE_CHAIN (declspec_stack);
1009 resume_momentary ($2); }
1010 | typed_declspecs ';'
1011 { shadow_tag ($1); }
1013 { pedwarn ("empty declaration"); }
1015 { pedantic = $<itype>1; }
1018 /* Declspecs which contain at least one type specifier or typedef name.
1019 (Just `const' or `volatile' is not enough.)
1020 A typedef'd name following these is taken as a name to be declared.
1021 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
1024 typespec reserved_declspecs
1025 { $$ = tree_cons (NULL_TREE, $1, $2); }
1026 | declmods typespec reserved_declspecs
1027 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
1030 reserved_declspecs: /* empty */
1032 | reserved_declspecs typespecqual_reserved
1033 { $$ = tree_cons (NULL_TREE, $2, $1); }
1034 | reserved_declspecs SCSPEC
1035 { if (extra_warnings)
1036 warning ("`%s' is not at beginning of declaration",
1037 IDENTIFIER_POINTER ($2));
1038 $$ = tree_cons (NULL_TREE, $2, $1); }
1039 | reserved_declspecs attributes
1040 { $$ = tree_cons ($2, NULL_TREE, $1); }
1043 typed_declspecs_no_prefix_attr:
1044 typespec reserved_declspecs_no_prefix_attr
1045 { $$ = tree_cons (NULL_TREE, $1, $2); }
1046 | declmods_no_prefix_attr typespec reserved_declspecs_no_prefix_attr
1047 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
1050 reserved_declspecs_no_prefix_attr:
1053 | reserved_declspecs_no_prefix_attr typespecqual_reserved
1054 { $$ = tree_cons (NULL_TREE, $2, $1); }
1055 | reserved_declspecs_no_prefix_attr SCSPEC
1056 { if (extra_warnings)
1057 warning ("`%s' is not at beginning of declaration",
1058 IDENTIFIER_POINTER ($2));
1059 $$ = tree_cons (NULL_TREE, $2, $1); }
1062 /* List of just storage classes, type modifiers, and prefix attributes.
1063 A declaration can start with just this, but then it cannot be used
1064 to redeclare a typedef-name.
1065 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
1068 declmods_no_prefix_attr
1071 { $$ = tree_cons ($1, NULL_TREE, NULL_TREE); }
1072 | declmods declmods_no_prefix_attr
1073 { $$ = chainon ($2, $1); }
1074 | declmods attributes
1075 { $$ = tree_cons ($2, NULL_TREE, $1); }
1078 declmods_no_prefix_attr:
1080 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
1081 TREE_STATIC ($$) = 1; }
1083 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
1084 | declmods_no_prefix_attr TYPE_QUAL
1085 { $$ = tree_cons (NULL_TREE, $2, $1);
1086 TREE_STATIC ($$) = 1; }
1087 | declmods_no_prefix_attr SCSPEC
1088 { if (extra_warnings && TREE_STATIC ($1))
1089 warning ("`%s' is not at beginning of declaration",
1090 IDENTIFIER_POINTER ($2));
1091 $$ = tree_cons (NULL_TREE, $2, $1);
1092 TREE_STATIC ($$) = TREE_STATIC ($1); }
1096 /* Used instead of declspecs where storage classes are not allowed
1097 (that is, for typenames and structure components).
1098 Don't accept a typedef-name if anything but a modifier precedes it. */
1101 typespec reserved_typespecquals
1102 { $$ = tree_cons (NULL_TREE, $1, $2); }
1103 | nonempty_type_quals typespec reserved_typespecquals
1104 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
1107 reserved_typespecquals: /* empty */
1109 | reserved_typespecquals typespecqual_reserved
1110 { $$ = tree_cons (NULL_TREE, $2, $1); }
1113 /* A typespec (but not a type qualifier).
1114 Once we have seen one of these in a declaration,
1115 if a typedef name appears then it is being redeclared. */
1120 { /* For a typedef name, record the meaning, not the name.
1121 In case of `foo foo, bar;'. */
1122 $$ = lookup_name ($1); }
1124 | CLASSNAME protocolrefs
1125 { $$ = get_static_reference ($1, $2); }
1126 | OBJECTNAME protocolrefs
1127 { $$ = get_object_reference ($2); }
1129 /* Make "<SomeProtocol>" equivalent to "id <SomeProtocol>"
1130 - nisse@lysator.liu.se */
1131 | non_empty_protocolrefs
1132 { $$ = get_object_reference ($1); }
1134 | TYPEOF '(' expr ')'
1135 { $$ = TREE_TYPE ($3); }
1136 | TYPEOF '(' typename ')'
1137 { $$ = groktypename ($3); }
1140 /* A typespec that is a reserved word, or a type qualifier. */
1142 typespecqual_reserved: TYPESPEC
1149 | initdecls ',' initdcl
1154 | notype_initdecls ',' initdcl
1160 | ASM_KEYWORD '(' string ')'
1161 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
1167 declarator maybeasm maybe_attribute '='
1168 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1169 $3, prefix_attributes);
1170 start_init ($<ttype>$, $2, global_bindings_p ()); }
1172 /* Note how the declaration of the variable is in effect while its init is parsed! */
1174 finish_decl ($<ttype>5, $6, $2); }
1175 | declarator maybeasm maybe_attribute
1176 { tree d = start_decl ($1, current_declspecs, 0,
1177 $3, prefix_attributes);
1178 finish_decl (d, NULL_TREE, $2);
1183 notype_declarator maybeasm maybe_attribute '='
1184 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1185 $3, prefix_attributes);
1186 start_init ($<ttype>$, $2, global_bindings_p ()); }
1188 /* Note how the declaration of the variable is in effect while its init is parsed! */
1190 decl_attributes ($<ttype>5, $3, prefix_attributes);
1191 finish_decl ($<ttype>5, $6, $2); }
1192 | notype_declarator maybeasm maybe_attribute
1193 { tree d = start_decl ($1, current_declspecs, 0,
1194 $3, prefix_attributes);
1195 finish_decl (d, NULL_TREE, $2); }
1197 /* the * rules are dummies to accept the Apollo extended syntax
1198 so that the header files compile. */
1209 | attributes attribute
1210 { $$ = chainon ($1, $2); }
1214 ATTRIBUTE '(' '(' attribute_list ')' ')'
1221 | attribute_list ',' attrib
1222 { $$ = chainon ($1, $3); }
1229 { $$ = build_tree_list ($1, NULL_TREE); }
1230 | any_word '(' IDENTIFIER ')'
1231 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1232 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1233 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1234 | any_word '(' exprlist ')'
1235 { $$ = build_tree_list ($1, $3); }
1238 /* This still leaves out most reserved keywords,
1239 shouldn't we include them? */
1248 /* Initializers. `init' is the entry point. */
1253 { really_start_incremental_init (NULL_TREE);
1254 /* Note that the call to clear_momentary
1255 is in process_init_element. */
1256 push_momentary (); }
1257 initlist_maybe_comma '}'
1258 { $$ = pop_init_level (0);
1259 if ($$ == error_mark_node
1260 && ! (yychar == STRING || yychar == CONSTANT))
1263 pop_momentary_nofree (); }
1266 { $$ = error_mark_node; }
1269 /* `initlist_maybe_comma' is the guts of an initializer in braces. */
1270 initlist_maybe_comma:
1273 pedwarn ("ANSI C forbids empty initializer braces"); }
1274 | initlist1 maybecomma
1279 | initlist1 ',' initelt
1282 /* `initelt' is a single element of an initializer.
1283 It may use braces. */
1286 { process_init_element ($1); }
1288 { push_init_level (0); }
1289 initlist_maybe_comma '}'
1290 { process_init_element (pop_init_level (0)); }
1292 /* These are for labeled elements. The syntax for an array element
1293 initializer conflicts with the syntax for an Objective-C message,
1294 so don't include these productions in the Objective-C grammar. */
1296 | '[' expr_no_commas ELLIPSIS expr_no_commas ']' '='
1297 { set_init_index ($2, $4); }
1299 | '[' expr_no_commas ']' '='
1300 { set_init_index ($2, NULL_TREE); }
1302 | '[' expr_no_commas ']'
1303 { set_init_index ($2, NULL_TREE); }
1307 { set_init_label ($1); }
1309 | '.' identifier '='
1310 { set_init_label ($2); }
1316 { push_c_function_context ();
1317 if (! start_function (current_declspecs, $1,
1318 prefix_attributes, NULL_TREE, 1))
1320 pop_c_function_context ();
1323 reinit_parse_for_function (); }
1324 old_style_parm_decls
1325 { store_parm_decls (); }
1326 /* This used to use compstmt_or_error.
1327 That caused a bug with input `f(g) int g {}',
1328 where the use of YYERROR1 above caused an error
1329 which then was handled by compstmt_or_error.
1330 There followed a repeated execution of that same rule,
1331 which called YYERROR1 again, and so on. */
1333 { finish_function (1);
1334 pop_c_function_context (); }
1337 notype_nested_function:
1339 { push_c_function_context ();
1340 if (! start_function (current_declspecs, $1,
1341 prefix_attributes, NULL_TREE, 1))
1343 pop_c_function_context ();
1346 reinit_parse_for_function (); }
1347 old_style_parm_decls
1348 { store_parm_decls (); }
1349 /* This used to use compstmt_or_error.
1350 That caused a bug with input `f(g) int g {}',
1351 where the use of YYERROR1 above caused an error
1352 which then was handled by compstmt_or_error.
1353 There followed a repeated execution of that same rule,
1354 which called YYERROR1 again, and so on. */
1356 { finish_function (1);
1357 pop_c_function_context (); }
1360 /* Any kind of declarator (thus, all declarators allowed
1361 after an explicit typespec). */
1364 after_type_declarator
1368 /* A declarator that is allowed only after an explicit typespec. */
1370 after_type_declarator:
1371 '(' after_type_declarator ')'
1373 | after_type_declarator '(' parmlist_or_identifiers %prec '.'
1374 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1375 /* | after_type_declarator '(' error ')' %prec '.'
1376 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1377 poplevel (0, 0, 0); } */
1378 | after_type_declarator '[' expr ']' %prec '.'
1379 { $$ = build_nt (ARRAY_REF, $1, $3); }
1380 | after_type_declarator '[' ']' %prec '.'
1381 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1382 | '*' type_quals after_type_declarator %prec UNARY
1383 { $$ = make_pointer_declarator ($2, $3); }
1384 /* ??? Yuck. setattrs is a quick hack. We can't use
1385 prefix_attributes because $1 only applies to this
1386 declarator. We assume setspecs has already been done.
1387 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1388 attributes could be recognized here or in `attributes'). */
1389 | attributes setattrs after_type_declarator
1397 /* Kinds of declarator that can appear in a parameter list
1398 in addition to notype_declarator. This is like after_type_declarator
1399 but does not allow a typedef name in parentheses as an identifier
1400 (because it would conflict with a function with that typedef as arg). */
1403 parm_declarator '(' parmlist_or_identifiers %prec '.'
1404 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1405 /* | parm_declarator '(' error ')' %prec '.'
1406 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1407 poplevel (0, 0, 0); } */
1408 | parm_declarator '[' expr ']' %prec '.'
1409 { $$ = build_nt (ARRAY_REF, $1, $3); }
1410 | parm_declarator '[' ']' %prec '.'
1411 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1412 | '*' type_quals parm_declarator %prec UNARY
1413 { $$ = make_pointer_declarator ($2, $3); }
1414 /* ??? Yuck. setattrs is a quick hack. We can't use
1415 prefix_attributes because $1 only applies to this
1416 declarator. We assume setspecs has already been done.
1417 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1418 attributes could be recognized here or in `attributes'). */
1419 | attributes setattrs parm_declarator
1424 /* A declarator allowed whether or not there has been
1425 an explicit typespec. These cannot redeclare a typedef-name. */
1428 notype_declarator '(' parmlist_or_identifiers %prec '.'
1429 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1430 /* | notype_declarator '(' error ')' %prec '.'
1431 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1432 poplevel (0, 0, 0); } */
1433 | '(' notype_declarator ')'
1435 | '*' type_quals notype_declarator %prec UNARY
1436 { $$ = make_pointer_declarator ($2, $3); }
1437 | notype_declarator '[' expr ']' %prec '.'
1438 { $$ = build_nt (ARRAY_REF, $1, $3); }
1439 | notype_declarator '[' ']' %prec '.'
1440 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1441 /* ??? Yuck. setattrs is a quick hack. We can't use
1442 prefix_attributes because $1 only applies to this
1443 declarator. We assume setspecs has already been done.
1444 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1445 attributes could be recognized here or in `attributes'). */
1446 | attributes setattrs notype_declarator
1452 STRUCT identifier '{'
1453 { $$ = start_struct (RECORD_TYPE, $2);
1454 /* Start scope of tag before parsing components. */
1456 component_decl_list '}' maybe_attribute
1457 { $$ = finish_struct ($<ttype>4, $5, $7); }
1458 | STRUCT '{' component_decl_list '}' maybe_attribute
1459 { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
1463 { $$ = xref_tag (RECORD_TYPE, $2); }
1464 | UNION identifier '{'
1465 { $$ = start_struct (UNION_TYPE, $2); }
1466 component_decl_list '}' maybe_attribute
1467 { $$ = finish_struct ($<ttype>4, $5, $7); }
1468 | UNION '{' component_decl_list '}' maybe_attribute
1469 { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
1473 { $$ = xref_tag (UNION_TYPE, $2); }
1474 | ENUM identifier '{'
1475 { $<itype>3 = suspend_momentary ();
1476 $$ = start_enum ($2); }
1477 enumlist maybecomma_warn '}' maybe_attribute
1478 { $$ = finish_enum ($<ttype>4, nreverse ($5), $8);
1479 resume_momentary ($<itype>3); }
1481 { $<itype>2 = suspend_momentary ();
1482 $$ = start_enum (NULL_TREE); }
1483 enumlist maybecomma_warn '}' maybe_attribute
1484 { $$ = finish_enum ($<ttype>3, nreverse ($4), $7);
1485 resume_momentary ($<itype>2); }
1487 { $$ = xref_tag (ENUMERAL_TYPE, $2); }
1498 { if (pedantic) pedwarn ("comma at end of enumerator list"); }
1501 component_decl_list:
1502 component_decl_list2
1504 | component_decl_list2 component_decl
1505 { $$ = chainon ($1, $2);
1506 pedwarn ("no semicolon at end of struct or union"); }
1509 component_decl_list2: /* empty */
1511 | component_decl_list2 component_decl ';'
1512 { $$ = chainon ($1, $2); }
1513 | component_decl_list2 ';'
1515 pedwarn ("extra semicolon in struct or union specified"); }
1517 /* foo(sizeof(struct{ @defs(ClassName)})); */
1518 | DEFS '(' CLASSNAME ')'
1520 tree interface = lookup_interface ($3);
1523 $$ = get_class_ivars (interface);
1526 error ("Cannot find interface declaration for `%s'",
1527 IDENTIFIER_POINTER ($3));
1534 /* There is a shift-reduce conflict here, because `components' may
1535 start with a `typename'. It happens that shifting (the default resolution)
1536 does the right thing, because it treats the `typename' as part of
1537 a `typed_typespecs'.
1539 It is possible that this same technique would allow the distinction
1540 between `notype_initdecls' and `initdecls' to be eliminated.
1541 But I am being cautious and not trying it. */
1544 typed_typespecs setspecs components
1546 current_declspecs = TREE_VALUE (declspec_stack);
1547 prefix_attributes = TREE_PURPOSE (declspec_stack);
1548 declspec_stack = TREE_CHAIN (declspec_stack);
1549 resume_momentary ($2); }
1552 pedwarn ("ANSI C forbids member declarations with no members");
1555 | nonempty_type_quals setspecs components
1557 current_declspecs = TREE_VALUE (declspec_stack);
1558 prefix_attributes = TREE_PURPOSE (declspec_stack);
1559 declspec_stack = TREE_CHAIN (declspec_stack);
1560 resume_momentary ($2); }
1561 | nonempty_type_quals
1563 pedwarn ("ANSI C forbids member declarations with no members");
1568 | extension component_decl
1570 pedantic = $<itype>1; }
1574 component_declarator
1575 | components ',' component_declarator
1576 { $$ = chainon ($1, $3); }
1579 component_declarator:
1580 save_filename save_lineno declarator maybe_attribute
1581 { $$ = grokfield ($1, $2, $3, current_declspecs, NULL_TREE);
1582 decl_attributes ($$, $4, prefix_attributes); }
1583 | save_filename save_lineno
1584 declarator ':' expr_no_commas maybe_attribute
1585 { $$ = grokfield ($1, $2, $3, current_declspecs, $5);
1586 decl_attributes ($$, $6, prefix_attributes); }
1587 | save_filename save_lineno ':' expr_no_commas maybe_attribute
1588 { $$ = grokfield ($1, $2, NULL_TREE, current_declspecs, $4);
1589 decl_attributes ($$, $5, prefix_attributes); }
1592 /* We chain the enumerators in reverse order.
1593 They are put in forward order where enumlist is used.
1594 (The order used to be significant, but no longer is so.
1595 However, we still maintain the order, just to be clean.) */
1599 | enumlist ',' enumerator
1600 { if ($1 == error_mark_node)
1603 $$ = chainon ($3, $1); }
1605 { $$ = error_mark_node; }
1611 { $$ = build_enumerator ($1, NULL_TREE); }
1612 | identifier '=' expr_no_commas
1613 { $$ = build_enumerator ($1, $3); }
1617 typed_typespecs absdcl
1618 { $$ = build_tree_list ($1, $2); }
1619 | nonempty_type_quals absdcl
1620 { $$ = build_tree_list ($1, $2); }
1623 absdcl: /* an absolute declarator */
1629 nonempty_type_quals:
1631 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
1632 | nonempty_type_quals TYPE_QUAL
1633 { $$ = tree_cons (NULL_TREE, $2, $1); }
1639 | type_quals TYPE_QUAL
1640 { $$ = tree_cons (NULL_TREE, $2, $1); }
1643 absdcl1: /* a nonempty absolute declarator */
1646 /* `(typedef)1' is `int'. */
1647 | '*' type_quals absdcl1 %prec UNARY
1648 { $$ = make_pointer_declarator ($2, $3); }
1649 | '*' type_quals %prec UNARY
1650 { $$ = make_pointer_declarator ($2, NULL_TREE); }
1651 | absdcl1 '(' parmlist %prec '.'
1652 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1653 | absdcl1 '[' expr ']' %prec '.'
1654 { $$ = build_nt (ARRAY_REF, $1, $3); }
1655 | absdcl1 '[' ']' %prec '.'
1656 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1657 | '(' parmlist %prec '.'
1658 { $$ = build_nt (CALL_EXPR, NULL_TREE, $2, NULL_TREE); }
1659 | '[' expr ']' %prec '.'
1660 { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
1662 { $$ = build_nt (ARRAY_REF, NULL_TREE, NULL_TREE); }
1663 /* ??? It appears we have to support attributes here, however
1664 using prefix_attributes is wrong. */
1667 /* at least one statement, the first of which parses without error. */
1668 /* stmts is used only after decls, so an invalid first statement
1669 is actually regarded as an invalid decl and part of the decls. */
1672 lineno_stmt_or_labels
1675 pedwarn ("ANSI C forbids label at end of compound statement");
1679 lineno_stmt_or_labels:
1680 lineno_stmt_or_label
1681 | lineno_stmt_or_labels lineno_stmt_or_label
1683 | lineno_stmt_or_labels errstmt
1695 pushlevel: /* empty */
1696 { emit_line_note (input_filename, lineno);
1700 expand_start_bindings (0);
1702 if (objc_method_context)
1708 /* Read zero or more forward-declarations for labels
1709 that nested functions can jump to. */
1714 pedwarn ("ANSI C forbids label declarations"); }
1719 | label_decls label_decl
1723 LABEL identifiers_or_typenames ';'
1725 for (link = $2; link; link = TREE_CHAIN (link))
1727 tree label = shadow_label (TREE_VALUE (link));
1728 C_DECLARED_LABEL_FLAG (label) = 1;
1729 declare_nonlocal_label (label);
1734 /* This is the body of a function definition.
1735 It causes syntax errors to ignore to the next openbrace. */
1743 { $$ = convert (void_type_node, integer_zero_node); }
1744 | '{' pushlevel maybe_label_decls decls xstmts '}'
1745 { emit_line_note (input_filename, lineno);
1746 expand_end_bindings (getdecls (), 1, 0);
1747 $$ = poplevel (1, 1, 0);
1748 if (yychar == CONSTANT || yychar == STRING)
1749 pop_momentary_nofree ();
1752 | '{' pushlevel maybe_label_decls error '}'
1753 { emit_line_note (input_filename, lineno);
1754 expand_end_bindings (getdecls (), kept_level_p (), 0);
1755 $$ = poplevel (kept_level_p (), 0, 0);
1756 if (yychar == CONSTANT || yychar == STRING)
1757 pop_momentary_nofree ();
1760 | '{' pushlevel maybe_label_decls stmts '}'
1761 { emit_line_note (input_filename, lineno);
1762 expand_end_bindings (getdecls (), kept_level_p (), 0);
1763 $$ = poplevel (kept_level_p (), 0, 0);
1764 if (yychar == CONSTANT || yychar == STRING)
1765 pop_momentary_nofree ();
1770 /* Value is number of statements counted as of the closeparen. */
1772 if_prefix lineno_labeled_stmt
1773 /* Make sure expand_end_cond is run once
1774 for each call to expand_start_cond.
1775 Otherwise a crash is likely. */
1781 { emit_line_note ($<filename>-1, $<lineno>0);
1782 expand_start_cond (truthvalue_conversion ($3), 0);
1783 $<itype>$ = stmt_count;
1784 if_stmt_file = $<filename>-1;
1785 if_stmt_line = $<lineno>0;
1786 position_after_white_space (); }
1789 /* This is a subroutine of stmt.
1790 It is used twice, once for valid DO statements
1791 and once for catching errors in parsing the end test. */
1795 emit_line_note ($<filename>-1, $<lineno>0);
1796 /* See comment in `while' alternative, above. */
1798 expand_start_loop_continue_elsewhere (1);
1799 position_after_white_space (); }
1800 lineno_labeled_stmt WHILE
1801 { expand_loop_continue_here (); }
1805 { $$ = input_filename; }
1812 lineno_labeled_stmt:
1813 save_filename save_lineno stmt
1815 /* | save_filename save_lineno error
1818 | save_filename save_lineno label lineno_labeled_stmt
1822 lineno_stmt_or_label:
1823 save_filename save_lineno stmt_or_label
1834 /* Parse a single real statement, not including any labels. */
1841 emit_line_note ($<filename>-1, $<lineno>0);
1842 /* It appears that this should not be done--that a non-lvalue array
1843 shouldn't get an error if the value isn't used.
1844 Section 3.2.2.1 says that an array lvalue gets converted to a pointer
1845 if it appears as a top-level expression,
1846 but says nothing about non-lvalue arrays. */
1848 /* Call default_conversion to get an error
1849 on referring to a register array if pedantic. */
1850 if (TREE_CODE (TREE_TYPE ($1)) == ARRAY_TYPE
1851 || TREE_CODE (TREE_TYPE ($1)) == FUNCTION_TYPE)
1852 $1 = default_conversion ($1);
1854 iterator_expand ($1);
1855 clear_momentary (); }
1857 { expand_start_else ();
1858 $<itype>1 = stmt_count;
1859 position_after_white_space (); }
1861 { expand_end_cond ();
1862 if (extra_warnings && stmt_count == $<itype>1)
1863 warning ("empty body in an else-statement"); }
1864 | simple_if %prec IF
1865 { expand_end_cond ();
1866 /* This warning is here instead of in simple_if, because we
1867 do not want a warning if an empty if is followed by an
1868 else statement. Increment stmt_count so we don't
1869 give a second error if this is a nested `if'. */
1870 if (extra_warnings && stmt_count++ == $<itype>1)
1871 warning_with_file_and_line (if_stmt_file, if_stmt_line,
1872 "empty body in an if-statement"); }
1873 /* Make sure expand_end_cond is run once
1874 for each call to expand_start_cond.
1875 Otherwise a crash is likely. */
1876 | simple_if ELSE error
1877 { expand_end_cond (); }
1880 emit_line_note ($<filename>-1, $<lineno>0);
1881 /* The emit_nop used to come before emit_line_note,
1882 but that made the nop seem like part of the preceding line.
1883 And that was confusing when the preceding line was
1884 inside of an if statement and was not really executed.
1885 I think it ought to work to put the nop after the line number.
1886 We will see. --rms, July 15, 1991. */
1889 { /* Don't start the loop till we have succeeded
1890 in parsing the end test. This is to make sure
1891 that we end every loop we start. */
1892 expand_start_loop (1);
1893 emit_line_note (input_filename, lineno);
1894 expand_exit_loop_if_false (NULL_PTR,
1895 truthvalue_conversion ($4));
1896 position_after_white_space (); }
1898 { expand_end_loop (); }
1901 { emit_line_note (input_filename, lineno);
1902 expand_exit_loop_if_false (NULL_PTR,
1903 truthvalue_conversion ($3));
1905 clear_momentary (); }
1906 /* This rule is needed to make sure we end every loop we start. */
1907 | do_stmt_start error
1908 { expand_end_loop ();
1909 clear_momentary (); }
1913 emit_line_note ($<filename>-1, $<lineno>0);
1914 /* See comment in `while' alternative, above. */
1916 if ($3) c_expand_expr_stmt ($3);
1917 /* Next step is to call expand_start_loop_continue_elsewhere,
1918 but wait till after we parse the entire for (...).
1919 Otherwise, invalid input might cause us to call that
1920 fn without calling expand_end_loop. */
1923 /* Can't emit now; wait till after expand_start_loop... */
1924 { $<lineno>7 = lineno;
1925 $<filename>$ = input_filename; }
1928 /* Start the loop. Doing this after parsing
1929 all the expressions ensures we will end the loop. */
1930 expand_start_loop_continue_elsewhere (1);
1931 /* Emit the end-test, with a line number. */
1932 emit_line_note ($<filename>8, $<lineno>7);
1934 expand_exit_loop_if_false (NULL_PTR,
1935 truthvalue_conversion ($6));
1936 /* Don't let the tree nodes for $9 be discarded by
1937 clear_momentary during the parsing of the next stmt. */
1939 $<lineno>7 = lineno;
1940 $<filename>8 = input_filename;
1941 position_after_white_space (); }
1943 { /* Emit the increment expression, with a line number. */
1944 emit_line_note ($<filename>8, $<lineno>7);
1945 expand_loop_continue_here ();
1947 c_expand_expr_stmt ($9);
1948 if (yychar == CONSTANT || yychar == STRING)
1949 pop_momentary_nofree ();
1952 expand_end_loop (); }
1953 | SWITCH '(' expr ')'
1955 emit_line_note ($<filename>-1, $<lineno>0);
1956 c_expand_start_case ($3);
1957 /* Don't let the tree nodes for $3 be discarded by
1958 clear_momentary during the parsing of the next stmt. */
1960 position_after_white_space (); }
1962 { expand_end_case ($3);
1963 if (yychar == CONSTANT || yychar == STRING)
1964 pop_momentary_nofree ();
1969 emit_line_note ($<filename>-1, $<lineno>0);
1970 if ( ! expand_exit_something ())
1971 error ("break statement not within loop or switch"); }
1974 emit_line_note ($<filename>-1, $<lineno>0);
1975 if (! expand_continue_loop (NULL_PTR))
1976 error ("continue statement not within a loop"); }
1979 emit_line_note ($<filename>-1, $<lineno>0);
1980 c_expand_return (NULL_TREE); }
1983 emit_line_note ($<filename>-1, $<lineno>0);
1984 c_expand_return ($2); }
1985 | ASM_KEYWORD maybe_type_qual '(' expr ')' ';'
1987 emit_line_note ($<filename>-1, $<lineno>0);
1989 if ((TREE_CODE ($4) == ADDR_EXPR
1990 && TREE_CODE (TREE_OPERAND ($4, 0)) == STRING_CST)
1991 || TREE_CODE ($4) == STRING_CST)
1994 error ("argument of `asm' is not a constant string"); }
1995 /* This is the case with just output operands. */
1996 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ')' ';'
1998 emit_line_note ($<filename>-1, $<lineno>0);
1999 c_expand_asm_operands ($4, $6, NULL_TREE, NULL_TREE,
2000 $2 == ridpointers[(int)RID_VOLATILE],
2001 input_filename, lineno); }
2002 /* This is the case with input operands as well. */
2003 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':' asm_operands ')' ';'
2005 emit_line_note ($<filename>-1, $<lineno>0);
2006 c_expand_asm_operands ($4, $6, $8, NULL_TREE,
2007 $2 == ridpointers[(int)RID_VOLATILE],
2008 input_filename, lineno); }
2009 /* This is the case with clobbered registers as well. */
2010 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':'
2011 asm_operands ':' asm_clobbers ')' ';'
2013 emit_line_note ($<filename>-1, $<lineno>0);
2014 c_expand_asm_operands ($4, $6, $8, $10,
2015 $2 == ridpointers[(int)RID_VOLATILE],
2016 input_filename, lineno); }
2017 | GOTO identifier ';'
2020 emit_line_note ($<filename>-1, $<lineno>0);
2021 decl = lookup_label ($2);
2024 TREE_USED (decl) = 1;
2030 pedwarn ("ANSI C forbids `goto *expr;'");
2032 emit_line_note ($<filename>-1, $<lineno>0);
2033 expand_computed_goto (convert (ptr_type_node, $3)); }
2038 all_iter_stmt_simple
2039 /* | all_iter_stmt_with_decl */
2042 all_iter_stmt_simple:
2045 /* The value returned by this action is */
2046 /* 1 if everything is OK */
2047 /* 0 in case of error or already bound iterator */
2050 if (TREE_CODE ($3) != VAR_DECL)
2051 error ("invalid `for (ITERATOR)' syntax");
2052 else if (! ITERATOR_P ($3))
2053 error ("`%s' is not an iterator",
2054 IDENTIFIER_POINTER (DECL_NAME ($3)));
2055 else if (ITERATOR_BOUND_P ($3))
2056 error ("`for (%s)' inside expansion of same iterator",
2057 IDENTIFIER_POINTER (DECL_NAME ($3)));
2061 iterator_for_loop_start ($3);
2067 iterator_for_loop_end ($3);
2070 /* This really should allow any kind of declaration,
2071 for generality. Fix it before turning it back on.
2073 all_iter_stmt_with_decl:
2074 FOR '(' ITERATOR pushlevel setspecs iterator_spec ')'
2076 */ /* The value returned by this action is */
2077 /* 1 if everything is OK */
2078 /* 0 in case of error or already bound iterator */
2080 iterator_for_loop_start ($6);
2084 iterator_for_loop_end ($6);
2085 emit_line_note (input_filename, lineno);
2086 expand_end_bindings (getdecls (), 1, 0);
2087 $<ttype>$ = poplevel (1, 1, 0);
2088 if (yychar == CONSTANT || yychar == STRING)
2089 pop_momentary_nofree ();
2095 /* Any kind of label, including jump labels and case labels.
2096 ANSI C accepts labels only before statements, but we allow them
2097 also at the end of a compound statement. */
2099 label: CASE expr_no_commas ':'
2100 { register tree value = check_case_value ($2);
2102 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
2106 if (value != error_mark_node)
2109 int success = pushcase (value, convert_and_check,
2112 error ("case label not within a switch statement");
2113 else if (success == 2)
2115 error ("duplicate case value");
2116 error_with_decl (duplicate, "this is the first entry for that value");
2118 else if (success == 3)
2119 warning ("case value out of range");
2120 else if (success == 5)
2121 error ("case label within scope of cleanup or variable array");
2123 position_after_white_space (); }
2124 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
2125 { register tree value1 = check_case_value ($2);
2126 register tree value2 = check_case_value ($4);
2128 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
2131 pedwarn ("ANSI C forbids case ranges");
2134 if (value1 != error_mark_node && value2 != error_mark_node)
2137 int success = pushcase_range (value1, value2,
2138 convert_and_check, label,
2141 error ("case label not within a switch statement");
2142 else if (success == 2)
2144 error ("duplicate case value");
2145 error_with_decl (duplicate, "this is the first entry for that value");
2147 else if (success == 3)
2148 warning ("case value out of range");
2149 else if (success == 4)
2150 warning ("empty case range");
2151 else if (success == 5)
2152 error ("case label within scope of cleanup or variable array");
2154 position_after_white_space (); }
2159 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
2160 int success = pushcase (NULL_TREE, 0, label, &duplicate);
2163 error ("default label not within a switch statement");
2164 else if (success == 2)
2166 error ("multiple default labels in one switch");
2167 error_with_decl (duplicate, "this is the first default label");
2169 position_after_white_space (); }
2171 { tree label = define_label (input_filename, lineno, $1);
2175 expand_label (label);
2176 position_after_white_space (); }
2179 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
2183 { emit_line_note (input_filename, lineno);
2186 { emit_line_note (input_filename, lineno); }
2195 /* These are the operands other than the first string and colon
2196 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
2197 asm_operands: /* empty */
2199 | nonnull_asm_operands
2202 nonnull_asm_operands:
2204 | nonnull_asm_operands ',' asm_operand
2205 { $$ = chainon ($1, $3); }
2210 { $$ = build_tree_list ($1, $3); }
2215 { $$ = tree_cons (NULL_TREE, combine_strings ($1), NULL_TREE); }
2216 | asm_clobbers ',' string
2217 { $$ = tree_cons (NULL_TREE, combine_strings ($3), $1); }
2220 /* This is what appears inside the parens in a function declarator.
2221 Its value is a list of ..._TYPE nodes. */
2224 clear_parm_order ();
2225 declare_parm_level (0); }
2228 parmlist_tags_warning ();
2229 poplevel (0, 0, 0); }
2237 pedwarn ("ANSI C forbids forward parameter declarations");
2238 /* Mark the forward decls as such. */
2239 for (parm = getdecls (); parm; parm = TREE_CHAIN (parm))
2240 TREE_ASM_WRITTEN (parm) = 1;
2241 clear_parm_order (); }
2245 { $$ = tree_cons (NULL_TREE, NULL_TREE, NULL_TREE); }
2248 /* This is what appears inside the parens in a function declarator.
2249 Is value is represented in the format that grokdeclarator expects. */
2250 parmlist_2: /* empty */
2251 { $$ = get_parm_info (0); }
2253 { $$ = get_parm_info (0);
2254 /* Gcc used to allow this as an extension. However, it does
2255 not work for all targets, and thus has been disabled.
2256 Also, since func (...) and func () are indistinguishable,
2257 it caused problems with the code in expand_builtin which
2258 tries to verify that BUILT_IN_NEXT_ARG is being used
2260 error ("ANSI C requires a named argument before `...'");
2263 { $$ = get_parm_info (1); }
2264 | parms ',' ELLIPSIS
2265 { $$ = get_parm_info (0); }
2270 { push_parm_decl ($1); }
2272 { push_parm_decl ($3); }
2275 /* A single parameter declaration or parameter type name,
2276 as found in a parmlist. */
2278 typed_declspecs setspecs parm_declarator maybe_attribute
2279 { $$ = build_tree_list (build_tree_list (current_declspecs,
2281 build_tree_list (prefix_attributes,
2283 current_declspecs = TREE_VALUE (declspec_stack);
2284 prefix_attributes = TREE_PURPOSE (declspec_stack);
2285 declspec_stack = TREE_CHAIN (declspec_stack);
2286 resume_momentary ($2); }
2287 | typed_declspecs setspecs notype_declarator maybe_attribute
2288 { $$ = build_tree_list (build_tree_list (current_declspecs,
2290 build_tree_list (prefix_attributes,
2292 current_declspecs = TREE_VALUE (declspec_stack);
2293 prefix_attributes = TREE_PURPOSE (declspec_stack);
2294 declspec_stack = TREE_CHAIN (declspec_stack);
2295 resume_momentary ($2); }
2296 | typed_declspecs setspecs absdcl maybe_attribute
2297 { $$ = build_tree_list (build_tree_list (current_declspecs,
2299 build_tree_list (prefix_attributes,
2301 current_declspecs = TREE_VALUE (declspec_stack);
2302 prefix_attributes = TREE_PURPOSE (declspec_stack);
2303 declspec_stack = TREE_CHAIN (declspec_stack);
2304 resume_momentary ($2); }
2305 | declmods setspecs notype_declarator maybe_attribute
2306 { $$ = build_tree_list (build_tree_list (current_declspecs,
2308 build_tree_list (prefix_attributes,
2310 current_declspecs = TREE_VALUE (declspec_stack);
2311 prefix_attributes = TREE_PURPOSE (declspec_stack);
2312 declspec_stack = TREE_CHAIN (declspec_stack);
2313 resume_momentary ($2); }
2315 | declmods setspecs absdcl maybe_attribute
2316 { $$ = build_tree_list (build_tree_list (current_declspecs,
2318 build_tree_list (prefix_attributes,
2320 current_declspecs = TREE_VALUE (declspec_stack);
2321 prefix_attributes = TREE_PURPOSE (declspec_stack);
2322 declspec_stack = TREE_CHAIN (declspec_stack);
2323 resume_momentary ($2); }
2326 /* This is used in a function definition
2327 where either a parmlist or an identifier list is ok.
2328 Its value is a list of ..._TYPE nodes or a list of identifiers. */
2329 parmlist_or_identifiers:
2331 clear_parm_order ();
2332 declare_parm_level (1); }
2333 parmlist_or_identifiers_1
2335 parmlist_tags_warning ();
2336 poplevel (0, 0, 0); }
2339 parmlist_or_identifiers_1:
2343 for (t = $1; t; t = TREE_CHAIN (t))
2344 if (TREE_VALUE (t) == NULL_TREE)
2345 error ("`...' in old-style identifier list");
2346 $$ = tree_cons (NULL_TREE, NULL_TREE, $1); }
2349 /* A nonempty list of identifiers. */
2352 { $$ = build_tree_list (NULL_TREE, $1); }
2353 | identifiers ',' IDENTIFIER
2354 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2357 /* A nonempty list of identifiers, including typenames. */
2358 identifiers_or_typenames:
2360 { $$ = build_tree_list (NULL_TREE, $1); }
2361 | identifiers_or_typenames ',' identifier
2362 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2367 { $<itype>$ = pedantic;
2372 /* Objective-C productions. */
2382 if (objc_implementation_context)
2384 finish_class (objc_implementation_context);
2385 objc_ivar_chain = NULL_TREE;
2386 objc_implementation_context = NULL_TREE;
2389 warning ("`@end' must appear in an implementation context");
2393 /* A nonempty list of identifiers. */
2396 { $$ = build_tree_list (NULL_TREE, $1); }
2397 | identifier_list ',' identifier
2398 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2402 CLASS identifier_list ';'
2404 objc_declare_class ($2);
2408 ALIAS identifier identifier ';'
2410 objc_declare_alias ($2, $3);
2414 INTERFACE identifier protocolrefs '{'
2416 objc_interface_context = objc_ivar_context
2417 = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, $3);
2418 objc_public_flag = 0;
2422 continue_class (objc_interface_context);
2427 finish_class (objc_interface_context);
2428 objc_interface_context = NULL_TREE;
2431 | INTERFACE identifier protocolrefs
2433 objc_interface_context
2434 = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, $3);
2435 continue_class (objc_interface_context);
2440 finish_class (objc_interface_context);
2441 objc_interface_context = NULL_TREE;
2444 | INTERFACE identifier ':' identifier protocolrefs '{'
2446 objc_interface_context = objc_ivar_context
2447 = start_class (CLASS_INTERFACE_TYPE, $2, $4, $5);
2448 objc_public_flag = 0;
2452 continue_class (objc_interface_context);
2457 finish_class (objc_interface_context);
2458 objc_interface_context = NULL_TREE;
2461 | INTERFACE identifier ':' identifier protocolrefs
2463 objc_interface_context
2464 = start_class (CLASS_INTERFACE_TYPE, $2, $4, $5);
2465 continue_class (objc_interface_context);
2470 finish_class (objc_interface_context);
2471 objc_interface_context = NULL_TREE;
2474 | IMPLEMENTATION identifier '{'
2476 objc_implementation_context = objc_ivar_context
2477 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, NULL_TREE, NULL_TREE);
2478 objc_public_flag = 0;
2483 = continue_class (objc_implementation_context);
2486 | IMPLEMENTATION identifier
2488 objc_implementation_context
2489 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, NULL_TREE, NULL_TREE);
2491 = continue_class (objc_implementation_context);
2494 | IMPLEMENTATION identifier ':' identifier '{'
2496 objc_implementation_context = objc_ivar_context
2497 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2498 objc_public_flag = 0;
2503 = continue_class (objc_implementation_context);
2506 | IMPLEMENTATION identifier ':' identifier
2508 objc_implementation_context
2509 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2511 = continue_class (objc_implementation_context);
2514 | INTERFACE identifier '(' identifier ')' protocolrefs
2516 objc_interface_context
2517 = start_class (CATEGORY_INTERFACE_TYPE, $2, $4, $6);
2518 continue_class (objc_interface_context);
2523 finish_class (objc_interface_context);
2524 objc_interface_context = NULL_TREE;
2527 | IMPLEMENTATION identifier '(' identifier ')'
2529 objc_implementation_context
2530 = start_class (CATEGORY_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2532 = continue_class (objc_implementation_context);
2537 PROTOCOL identifier protocolrefs
2539 remember_protocol_qualifiers ();
2540 objc_interface_context
2541 = start_protocol(PROTOCOL_INTERFACE_TYPE, $2, $3);
2545 forget_protocol_qualifiers();
2546 finish_protocol(objc_interface_context);
2547 objc_interface_context = NULL_TREE;
2556 | non_empty_protocolrefs
2559 non_empty_protocolrefs:
2560 ARITHCOMPARE identifier_list ARITHCOMPARE
2562 if ($1 == LT_EXPR && $3 == GT_EXPR)
2570 ivar_decl_list visibility_spec ivar_decls
2575 PRIVATE { objc_public_flag = 2; }
2576 | PROTECTED { objc_public_flag = 0; }
2577 | PUBLIC { objc_public_flag = 1; }
2585 | ivar_decls ivar_decl ';'
2589 pedwarn ("extra semicolon in struct or union specified");
2594 /* There is a shift-reduce conflict here, because `components' may
2595 start with a `typename'. It happens that shifting (the default resolution)
2596 does the right thing, because it treats the `typename' as part of
2597 a `typed_typespecs'.
2599 It is possible that this same technique would allow the distinction
2600 between `notype_initdecls' and `initdecls' to be eliminated.
2601 But I am being cautious and not trying it. */
2604 typed_typespecs setspecs ivars
2606 current_declspecs = TREE_VALUE (declspec_stack);
2607 prefix_attributes = TREE_PURPOSE (declspec_stack);
2608 declspec_stack = TREE_CHAIN (declspec_stack);
2609 resume_momentary ($2); }
2610 | nonempty_type_quals setspecs ivars
2612 current_declspecs = TREE_VALUE (declspec_stack);
2613 prefix_attributes = TREE_PURPOSE (declspec_stack);
2614 declspec_stack = TREE_CHAIN (declspec_stack);
2615 resume_momentary ($2); }
2624 | ivars ',' ivar_declarator
2630 $$ = add_instance_variable (objc_ivar_context,
2632 $1, current_declspecs,
2635 | declarator ':' expr_no_commas
2637 $$ = add_instance_variable (objc_ivar_context,
2639 $1, current_declspecs, $3);
2641 | ':' expr_no_commas
2643 $$ = add_instance_variable (objc_ivar_context,
2646 current_declspecs, $2);
2653 remember_protocol_qualifiers ();
2654 if (objc_implementation_context)
2655 objc_inherit_code = CLASS_METHOD_DECL;
2657 fatal ("method definition not in class context");
2661 forget_protocol_qualifiers ();
2662 add_class_method (objc_implementation_context, $3);
2663 start_method_def ($3);
2664 objc_method_context = $3;
2668 continue_method_def ();
2672 finish_method_def ();
2673 objc_method_context = NULL_TREE;
2678 remember_protocol_qualifiers ();
2679 if (objc_implementation_context)
2680 objc_inherit_code = INSTANCE_METHOD_DECL;
2682 fatal ("method definition not in class context");
2686 forget_protocol_qualifiers ();
2687 add_instance_method (objc_implementation_context, $3);
2688 start_method_def ($3);
2689 objc_method_context = $3;
2693 continue_method_def ();
2697 finish_method_def ();
2698 objc_method_context = NULL_TREE;
2702 /* the reason for the strange actions in this rule
2703 is so that notype_initdecls when reached via datadef
2704 can find a valid list of type and sc specs in $0. */
2708 | {$<ttype>$ = NULL_TREE; } methodprotolist2
2711 methodprotolist2: /* eliminates a shift/reduce conflict */
2714 | methodprotolist2 methodproto
2715 | methodprotolist2 {$<ttype>$ = NULL_TREE; } datadef
2726 objc_inherit_code = CLASS_METHOD_DECL;
2730 add_class_method (objc_interface_context, $3);
2736 objc_inherit_code = INSTANCE_METHOD_DECL;
2740 add_instance_method (objc_interface_context, $3);
2746 '(' typename ')' unaryselector
2748 $$ = build_method_decl (objc_inherit_code, $2, $4, NULL_TREE);
2753 $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, NULL_TREE);
2756 | '(' typename ')' keywordselector optparmlist
2758 $$ = build_method_decl (objc_inherit_code, $2, $4, $5);
2761 | keywordselector optparmlist
2763 $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, $2);
2767 /* "optarglist" assumes that start_method_def has already been called...
2768 if it is not, the "xdecls" will not be placed in the proper scope */
2775 /* to get around the following situation: "int foo (int a) int b; {}" that
2776 is synthesized when parsing "- a:a b:b; id c; id d; { ... }" */
2791 typed_declspecs setspecs myparms ';'
2792 { current_declspecs = TREE_VALUE (declspec_stack);
2793 prefix_attributes = TREE_PURPOSE (declspec_stack);
2794 declspec_stack = TREE_CHAIN (declspec_stack);
2795 resume_momentary ($2); }
2796 | typed_declspecs ';'
2797 { shadow_tag ($1); }
2799 { pedwarn ("empty declaration"); }
2804 { push_parm_decl ($1); }
2805 | myparms ',' myparm
2806 { push_parm_decl ($3); }
2809 /* A single parameter declaration or parameter type name,
2810 as found in a parmlist. DOES NOT ALLOW AN INITIALIZER OR ASMSPEC */
2813 parm_declarator maybe_attribute
2814 { $$ = build_tree_list (build_tree_list (current_declspecs,
2816 build_tree_list (prefix_attributes,
2818 | notype_declarator maybe_attribute
2819 { $$ = build_tree_list (build_tree_list (current_declspecs,
2821 build_tree_list (prefix_attributes,
2823 | absdcl maybe_attribute
2824 { $$ = build_tree_list (build_tree_list (current_declspecs,
2826 build_tree_list (prefix_attributes,
2837 /* oh what a kludge! */
2846 /* returns a tree list node generated by get_parm_info */
2859 | keywordselector keyworddecl
2861 $$ = chainon ($1, $2);
2873 ENUM { $$ = get_identifier (token_buffer); }
2874 | STRUCT { $$ = get_identifier (token_buffer); }
2875 | UNION { $$ = get_identifier (token_buffer); }
2876 | IF { $$ = get_identifier (token_buffer); }
2877 | ELSE { $$ = get_identifier (token_buffer); }
2878 | WHILE { $$ = get_identifier (token_buffer); }
2879 | DO { $$ = get_identifier (token_buffer); }
2880 | FOR { $$ = get_identifier (token_buffer); }
2881 | SWITCH { $$ = get_identifier (token_buffer); }
2882 | CASE { $$ = get_identifier (token_buffer); }
2883 | DEFAULT { $$ = get_identifier (token_buffer); }
2884 | BREAK { $$ = get_identifier (token_buffer); }
2885 | CONTINUE { $$ = get_identifier (token_buffer); }
2886 | RETURN { $$ = get_identifier (token_buffer); }
2887 | GOTO { $$ = get_identifier (token_buffer); }
2888 | ASM_KEYWORD { $$ = get_identifier (token_buffer); }
2889 | SIZEOF { $$ = get_identifier (token_buffer); }
2890 | TYPEOF { $$ = get_identifier (token_buffer); }
2891 | ALIGNOF { $$ = get_identifier (token_buffer); }
2892 | TYPESPEC | TYPE_QUAL
2896 selector ':' '(' typename ')' identifier
2898 $$ = build_keyword_decl ($1, $4, $6);
2901 | selector ':' identifier
2903 $$ = build_keyword_decl ($1, NULL_TREE, $3);
2906 | ':' '(' typename ')' identifier
2908 $$ = build_keyword_decl (NULL_TREE, $3, $5);
2913 $$ = build_keyword_decl (NULL_TREE, NULL_TREE, $2);
2924 | keywordarglist keywordarg
2926 $$ = chainon ($1, $2);
2934 if (TREE_CHAIN ($1) == NULL_TREE)
2935 /* just return the expr., remove a level of indirection */
2936 $$ = TREE_VALUE ($1);
2938 /* we have a comma expr., we will collapse later */
2944 selector ':' keywordexpr
2946 $$ = build_tree_list ($1, $3);
2950 $$ = build_tree_list (NULL_TREE, $2);
2958 $$ = get_class_reference ($1);
2964 { objc_receiver_context = 1; }
2966 { objc_receiver_context = 0; }
2969 $$ = build_tree_list ($3, $5);
2980 | keywordnamelist keywordname
2982 $$ = chainon ($1, $2);
2989 $$ = build_tree_list ($1, NULL_TREE);
2993 $$ = build_tree_list (NULL_TREE, NULL_TREE);
2998 SELECTOR '(' selectorarg ')'
3005 PROTOCOL '(' identifier ')'
3011 /* extension to support C-structures in the archiver */
3014 ENCODE '(' typename ')'
3016 $$ = groktypename ($3);