1 /* YACC parser for C syntax and for Objective C. -*-c-*-
2 Copyright (C) 1987, 88, 89, 92-97, 1998 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.) */
73 #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";
90 /* Like YYERROR but do call yyerror. */
91 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
93 /* Cause the `yydebug' variable to be defined. */
99 %union {long itype; tree ttype; enum tree_code code;
100 char *filename; int lineno; int ends_in_label; }
102 /* All identifiers that are not reserved words
103 and are not declared typedefs in the current block */
106 /* All identifiers that are declared typedefs in the current block.
107 In some contexts, they are treated just like IDENTIFIER,
108 but they can also serve as typespecs in declarations. */
111 /* Reserved words that specify storage class.
112 yylval contains an IDENTIFIER_NODE which indicates which one. */
115 /* Reserved words that specify type.
116 yylval contains an IDENTIFIER_NODE which indicates which one. */
119 /* Reserved words that qualify type: "const", "volatile", or "restrict".
120 yylval contains an IDENTIFIER_NODE which indicates which one. */
123 /* Character or numeric constants.
124 yylval is the node for the constant. */
127 /* String constants in raw form.
128 yylval is a STRING_CST node. */
131 /* "...", used for functions with variable arglists. */
134 /* the reserved words */
135 /* SCO include files test "ASM", so use something else. */
136 %token SIZEOF ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
137 %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD TYPEOF ALIGNOF
138 %token ATTRIBUTE EXTENSION LABEL
139 %token REALPART IMAGPART
141 /* Add precedence rules to solve dangling else s/r conflict */
145 /* Define the operator tokens and their precedences.
146 The value is an integer because, if used, it is the tree code
147 to use in the expression made from the operator. */
149 %right <code> ASSIGN '='
150 %right <code> '?' ':'
156 %left <code> EQCOMPARE
157 %left <code> ARITHCOMPARE
158 %left <code> LSHIFT RSHIFT
160 %left <code> '*' '/' '%'
161 %right <code> UNARY PLUSPLUS MINUSMINUS
163 %left <code> POINTSAT '.' '(' '['
165 /* The Objective-C keywords. These are included in C and in
166 Objective C, so that the token codes are the same in both. */
167 %token INTERFACE IMPLEMENTATION END SELECTOR DEFS ENCODE
168 %token CLASSNAME PUBLIC PRIVATE PROTECTED PROTOCOL OBJECTNAME CLASS ALIAS
170 /* Objective-C string constants in raw form.
171 yylval is an OBJC_STRING_CST node. */
177 %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist exprlist
178 %type <ttype> expr_no_commas cast_expr unary_expr primary string STRING
179 %type <ttype> typed_declspecs reserved_declspecs
180 %type <ttype> typed_typespecs reserved_typespecquals
181 %type <ttype> declmods typespec typespecqual_reserved
182 %type <ttype> typed_declspecs_no_prefix_attr reserved_declspecs_no_prefix_attr
183 %type <ttype> declmods_no_prefix_attr
184 %type <ttype> SCSPEC TYPESPEC TYPE_QUAL nonempty_type_quals maybe_type_qual
185 %type <ttype> initdecls notype_initdecls initdcl notype_initdcl
186 %type <ttype> init maybeasm
187 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
188 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
189 %type <ttype> any_word
191 %type <ttype> compstmt
193 %type <ttype> declarator
194 %type <ttype> notype_declarator after_type_declarator
195 %type <ttype> parm_declarator
197 %type <ttype> structsp component_decl_list component_decl_list2
198 %type <ttype> component_decl components component_declarator
199 %type <ttype> enumlist enumerator
200 %type <ttype> struct_head union_head enum_head
201 %type <ttype> typename absdcl absdcl1 type_quals
202 %type <ttype> xexpr parms parm identifiers
204 %type <ttype> parmlist parmlist_1 parmlist_2
205 %type <ttype> parmlist_or_identifiers parmlist_or_identifiers_1
206 %type <ttype> identifiers_or_typenames
208 %type <itype> setspecs
210 %type <ends_in_label> lineno_stmt_or_label lineno_stmt_or_labels stmt_or_label
212 %type <filename> save_filename
213 %type <lineno> save_lineno
216 /* the Objective-C nonterminals */
218 %type <ttype> ivar_decl_list ivar_decls ivar_decl ivars ivar_declarator
219 %type <ttype> methoddecl unaryselector keywordselector selector
220 %type <ttype> keyworddecl receiver objcmessageexpr messageargs
221 %type <ttype> keywordexpr keywordarglist keywordarg
222 %type <ttype> myparms myparm optparmlist reservedwords objcselectorexpr
223 %type <ttype> selectorarg keywordnamelist keywordname objcencodeexpr
224 %type <ttype> objc_string non_empty_protocolrefs protocolrefs identifier_list objcprotocolexpr
226 %type <ttype> CLASSNAME OBJC_STRING OBJECTNAME
230 /* Number of statements (loosely speaking) and compound statements
232 static int stmt_count;
233 static int compstmt_count;
235 /* Input file and line number of the end of the body of last simple_if;
236 used by the stmt-rule immediately after simple_if returns. */
237 static char *if_stmt_file;
238 static int if_stmt_line;
240 /* List of types and structure classes of the current declaration. */
241 static tree current_declspecs = NULL_TREE;
242 static tree prefix_attributes = NULL_TREE;
244 /* Stack of saved values of current_declspecs and prefix_attributes. */
245 static tree declspec_stack;
247 /* 1 if we explained undeclared var errors. */
248 static int undeclared_variable_notice;
251 /* Objective-C specific information */
253 tree objc_interface_context;
254 tree objc_implementation_context;
255 tree objc_method_context;
256 tree objc_ivar_chain;
257 tree objc_ivar_context;
258 enum tree_code objc_inherit_code;
259 int objc_receiver_context;
260 int objc_public_flag;
264 /* Tell yyparse how to print a token's value, if yydebug is set. */
266 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
267 extern void yyprint PROTO ((FILE *, int, YYSTYPE));
273 pedwarn ("ANSI C forbids an empty source file");
278 /* In case there were missing closebraces,
279 get us back to the global binding level. */
280 while (! global_bindings_p ())
286 /* the reason for the strange actions in this rule
287 is so that notype_initdecls when reached via datadef
288 can find a valid list of type and sc specs in $0. */
291 {$<ttype>$ = NULL_TREE; } extdef
292 | extdefs {$<ttype>$ = NULL_TREE; } extdef
301 | ASM_KEYWORD '(' expr ')' ';'
303 if ((TREE_CODE ($3) == ADDR_EXPR
304 && TREE_CODE (TREE_OPERAND ($3, 0)) == STRING_CST)
305 || TREE_CODE ($3) == STRING_CST)
308 error ("argument of `asm' is not a constant string"); }
310 { pedantic = $<itype>1; }
314 setspecs notype_initdecls ';'
316 error ("ANSI C forbids data definition with no type or storage class");
317 else if (!flag_traditional)
318 warning ("data definition has no type or storage class");
320 current_declspecs = TREE_VALUE (declspec_stack);
321 prefix_attributes = TREE_PURPOSE (declspec_stack);
322 declspec_stack = TREE_CHAIN (declspec_stack);
323 resume_momentary ($1); }
324 | declmods setspecs notype_initdecls ';'
325 { current_declspecs = TREE_VALUE (declspec_stack);
326 prefix_attributes = TREE_PURPOSE (declspec_stack);
327 declspec_stack = TREE_CHAIN (declspec_stack);
328 resume_momentary ($2); }
329 | typed_declspecs setspecs initdecls ';'
330 { current_declspecs = TREE_VALUE (declspec_stack);
331 prefix_attributes = TREE_PURPOSE (declspec_stack);
332 declspec_stack = TREE_CHAIN (declspec_stack);
333 resume_momentary ($2); }
335 { pedwarn ("empty declaration"); }
336 | typed_declspecs ';'
342 pedwarn ("ANSI C does not allow extra `;' outside of a function"); }
346 typed_declspecs setspecs declarator
347 { if (! start_function (current_declspecs, $3,
348 prefix_attributes, NULL_TREE, 0))
350 reinit_parse_for_function (); }
352 { store_parm_decls (); }
354 { finish_function (0);
355 current_declspecs = TREE_VALUE (declspec_stack);
356 prefix_attributes = TREE_PURPOSE (declspec_stack);
357 declspec_stack = TREE_CHAIN (declspec_stack);
358 resume_momentary ($2); }
359 | typed_declspecs setspecs declarator error
360 { current_declspecs = TREE_VALUE (declspec_stack);
361 prefix_attributes = TREE_PURPOSE (declspec_stack);
362 declspec_stack = TREE_CHAIN (declspec_stack);
363 resume_momentary ($2); }
364 | declmods setspecs notype_declarator
365 { if (! start_function (current_declspecs, $3,
366 prefix_attributes, NULL_TREE, 0))
368 reinit_parse_for_function (); }
370 { store_parm_decls (); }
372 { finish_function (0);
373 current_declspecs = TREE_VALUE (declspec_stack);
374 prefix_attributes = TREE_PURPOSE (declspec_stack);
375 declspec_stack = TREE_CHAIN (declspec_stack);
376 resume_momentary ($2); }
377 | declmods setspecs notype_declarator error
378 { current_declspecs = TREE_VALUE (declspec_stack);
379 prefix_attributes = TREE_PURPOSE (declspec_stack);
380 declspec_stack = TREE_CHAIN (declspec_stack);
381 resume_momentary ($2); }
382 | setspecs notype_declarator
383 { if (! start_function (NULL_TREE, $2,
384 prefix_attributes, NULL_TREE, 0))
386 reinit_parse_for_function (); }
388 { store_parm_decls (); }
390 { finish_function (0);
391 current_declspecs = TREE_VALUE (declspec_stack);
392 prefix_attributes = TREE_PURPOSE (declspec_stack);
393 declspec_stack = TREE_CHAIN (declspec_stack);
394 resume_momentary ($1); }
395 | setspecs notype_declarator error
396 { current_declspecs = TREE_VALUE (declspec_stack);
397 prefix_attributes = TREE_PURPOSE (declspec_stack);
398 declspec_stack = TREE_CHAIN (declspec_stack);
399 resume_momentary ($1); }
414 { $$ = NEGATE_EXPR; }
416 { $$ = CONVERT_EXPR; }
418 { $$ = PREINCREMENT_EXPR; }
420 { $$ = PREDECREMENT_EXPR; }
422 { $$ = BIT_NOT_EXPR; }
424 { $$ = TRUTH_NOT_EXPR; }
427 expr: nonnull_exprlist
428 { $$ = build_compound_expr ($1); }
439 { $$ = build_tree_list (NULL_TREE, $1); }
440 | nonnull_exprlist ',' expr_no_commas
441 { chainon ($1, build_tree_list (NULL_TREE, $3)); }
446 | '*' cast_expr %prec UNARY
447 { $$ = build_indirect_ref ($2, "unary *"); }
448 /* __extension__ turns off -pedantic for following primary. */
449 | extension cast_expr %prec UNARY
451 pedantic = $<itype>1; }
452 | unop cast_expr %prec UNARY
453 { $$ = build_unary_op ($1, $2, 0);
454 overflow_warning ($$); }
455 /* Refer to the address of a label as a pointer. */
457 { tree label = lookup_label ($2);
459 pedwarn ("ANSI C forbids `&&'");
461 $$ = null_pointer_node;
464 TREE_USED (label) = 1;
465 $$ = build1 (ADDR_EXPR, ptr_type_node, label);
466 TREE_CONSTANT ($$) = 1;
469 /* This seems to be impossible on some machines, so let's turn it off.
470 You can use __builtin_next_arg to find the anonymous stack args.
472 { tree types = TYPE_ARG_TYPES (TREE_TYPE (current_function_decl));
473 $$ = error_mark_node;
474 if (TREE_VALUE (tree_last (types)) == void_type_node)
475 error ("`&...' used in function with fixed number of arguments");
479 pedwarn ("ANSI C forbids `&...'");
480 $$ = tree_last (DECL_ARGUMENTS (current_function_decl));
481 $$ = build_unary_op (ADDR_EXPR, $$, 0);
484 | sizeof unary_expr %prec UNARY
486 if (TREE_CODE ($2) == COMPONENT_REF
487 && DECL_C_BIT_FIELD (TREE_OPERAND ($2, 1)))
488 error ("`sizeof' applied to a bit-field");
489 $$ = c_sizeof (TREE_TYPE ($2)); }
490 | sizeof '(' typename ')' %prec HYPERUNARY
492 $$ = c_sizeof (groktypename ($3)); }
493 | alignof unary_expr %prec UNARY
495 $$ = c_alignof_expr ($2); }
496 | alignof '(' typename ')' %prec HYPERUNARY
498 $$ = c_alignof (groktypename ($3)); }
499 | REALPART cast_expr %prec UNARY
500 { $$ = build_unary_op (REALPART_EXPR, $2, 0); }
501 | IMAGPART cast_expr %prec UNARY
502 { $$ = build_unary_op (IMAGPART_EXPR, $2, 0); }
506 SIZEOF { skip_evaluation++; }
510 ALIGNOF { skip_evaluation++; }
515 | '(' typename ')' cast_expr %prec UNARY
516 { tree type = groktypename ($2);
517 $$ = build_c_cast (type, $4); }
518 | '(' typename ')' '{'
519 { start_init (NULL_TREE, NULL, 0);
520 $2 = groktypename ($2);
521 really_start_incremental_init ($2); }
522 initlist_maybe_comma '}' %prec UNARY
524 tree result = pop_init_level (0);
528 if (pedantic && ! flag_isoc9x)
529 pedwarn ("ANSI C forbids constructor expressions");
530 if (TYPE_NAME (type) != 0)
532 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
533 name = IDENTIFIER_POINTER (TYPE_NAME (type));
535 name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
540 if (TREE_CODE (type) == ARRAY_TYPE && TYPE_SIZE (type) == 0)
542 int failure = complete_array_type (type, $$, 1);
551 | expr_no_commas '+' expr_no_commas
552 { $$ = parser_build_binary_op ($2, $1, $3); }
553 | expr_no_commas '-' expr_no_commas
554 { $$ = parser_build_binary_op ($2, $1, $3); }
555 | expr_no_commas '*' expr_no_commas
556 { $$ = parser_build_binary_op ($2, $1, $3); }
557 | expr_no_commas '/' expr_no_commas
558 { $$ = parser_build_binary_op ($2, $1, $3); }
559 | expr_no_commas '%' expr_no_commas
560 { $$ = parser_build_binary_op ($2, $1, $3); }
561 | expr_no_commas LSHIFT expr_no_commas
562 { $$ = parser_build_binary_op ($2, $1, $3); }
563 | expr_no_commas RSHIFT expr_no_commas
564 { $$ = parser_build_binary_op ($2, $1, $3); }
565 | expr_no_commas ARITHCOMPARE expr_no_commas
566 { $$ = parser_build_binary_op ($2, $1, $3); }
567 | expr_no_commas EQCOMPARE expr_no_commas
568 { $$ = parser_build_binary_op ($2, $1, $3); }
569 | expr_no_commas '&' expr_no_commas
570 { $$ = parser_build_binary_op ($2, $1, $3); }
571 | expr_no_commas '|' expr_no_commas
572 { $$ = parser_build_binary_op ($2, $1, $3); }
573 | expr_no_commas '^' expr_no_commas
574 { $$ = parser_build_binary_op ($2, $1, $3); }
575 | expr_no_commas ANDAND
576 { $1 = truthvalue_conversion (default_conversion ($1));
577 skip_evaluation += $1 == boolean_false_node; }
579 { skip_evaluation -= $1 == boolean_false_node;
580 $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $4); }
581 | expr_no_commas OROR
582 { $1 = truthvalue_conversion (default_conversion ($1));
583 skip_evaluation += $1 == boolean_true_node; }
585 { skip_evaluation -= $1 == boolean_true_node;
586 $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $4); }
588 { $1 = truthvalue_conversion (default_conversion ($1));
589 skip_evaluation += $1 == boolean_false_node; }
591 { skip_evaluation += (($1 == boolean_true_node)
592 - ($1 == boolean_false_node)); }
594 { skip_evaluation -= $1 == boolean_true_node;
595 $$ = build_conditional_expr ($1, $4, $7); }
598 pedwarn ("ANSI C forbids omitting the middle term of a ?: expression");
599 /* Make sure first operand is calculated only once. */
600 $<ttype>2 = save_expr ($1);
601 $1 = truthvalue_conversion (default_conversion ($<ttype>2));
602 skip_evaluation += $1 == boolean_true_node; }
604 { skip_evaluation -= $1 == boolean_true_node;
605 $$ = build_conditional_expr ($1, $<ttype>2, $5); }
606 | expr_no_commas '=' expr_no_commas
607 { $$ = build_modify_expr ($1, NOP_EXPR, $3);
608 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
609 | expr_no_commas ASSIGN expr_no_commas
610 { $$ = build_modify_expr ($1, $2, $3);
611 /* This inhibits warnings in truthvalue_conversion. */
612 C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK); }
619 if (!$$ || $$ == error_mark_node)
621 if (yychar == YYEMPTY)
628 if (objc_receiver_context
629 && ! (objc_receiver_context
630 && strcmp (IDENTIFIER_POINTER ($1), "super")))
631 /* we have a message to super */
632 $$ = get_super_receiver ();
633 else if (objc_method_context
634 && (decl = is_ivar (objc_ivar_chain, $1)))
636 if (is_private (decl))
637 $$ = error_mark_node;
639 $$ = build_ivar_reference ($1);
644 /* Ordinary implicit function declaration. */
645 $$ = implicitly_declare ($1);
646 assemble_external ($$);
650 else if (current_function_decl == 0)
652 error ("`%s' undeclared here (not in a function)",
653 IDENTIFIER_POINTER ($1));
654 $$ = error_mark_node;
661 if (objc_receiver_context
662 && ! strcmp (IDENTIFIER_POINTER ($1), "super"))
663 /* we have a message to super */
664 $$ = get_super_receiver ();
665 else if (objc_method_context
666 && (decl = is_ivar (objc_ivar_chain, $1)))
668 if (is_private (decl))
669 $$ = error_mark_node;
671 $$ = build_ivar_reference ($1);
676 if (IDENTIFIER_GLOBAL_VALUE ($1) != error_mark_node
677 || IDENTIFIER_ERROR_LOCUS ($1) != current_function_decl)
679 error ("`%s' undeclared (first use in this function)",
680 IDENTIFIER_POINTER ($1));
682 if (! undeclared_variable_notice)
684 error ("(Each undeclared identifier is reported only once");
685 error ("for each function it appears in.)");
686 undeclared_variable_notice = 1;
689 $$ = error_mark_node;
690 /* Prevent repeated error messages. */
691 IDENTIFIER_GLOBAL_VALUE ($1) = error_mark_node;
692 IDENTIFIER_ERROR_LOCUS ($1) = current_function_decl;
696 else if (TREE_TYPE ($$) == error_mark_node)
697 $$ = error_mark_node;
698 else if (C_DECL_ANTICIPATED ($$))
700 /* The first time we see a build-in function used,
701 if it has not been declared. */
702 C_DECL_ANTICIPATED ($$) = 0;
703 if (yychar == YYEMPTY)
707 /* Omit the implicit declaration we
708 would ordinarily do, so we don't lose
709 the actual built in type.
710 But print a diagnostic for the mismatch. */
712 if (objc_method_context
713 && is_ivar (objc_ivar_chain, $1))
714 error ("Instance variable `%s' implicitly declared as function",
715 IDENTIFIER_POINTER (DECL_NAME ($$)));
718 if (TREE_CODE ($$) != FUNCTION_DECL)
719 error ("`%s' implicitly declared as function",
720 IDENTIFIER_POINTER (DECL_NAME ($$)));
721 else if ((TYPE_MODE (TREE_TYPE (TREE_TYPE ($$)))
722 != TYPE_MODE (integer_type_node))
723 && (TREE_TYPE (TREE_TYPE ($$))
725 pedwarn ("type mismatch in implicit declaration for built-in function `%s'",
726 IDENTIFIER_POINTER (DECL_NAME ($$)));
727 /* If it really returns void, change that to int. */
728 if (TREE_TYPE (TREE_TYPE ($$)) == void_type_node)
730 = build_function_type (integer_type_node,
731 TYPE_ARG_TYPES (TREE_TYPE ($$)));
734 pedwarn ("built-in function `%s' used without declaration",
735 IDENTIFIER_POINTER (DECL_NAME ($$)));
737 /* Do what we would ordinarily do when a fn is used. */
738 assemble_external ($$);
743 assemble_external ($$);
746 /* we have a definition - still check if iVariable */
748 if (!objc_receiver_context
749 || (objc_receiver_context
750 && strcmp (IDENTIFIER_POINTER ($1), "super")))
754 if (objc_method_context
755 && (decl = is_ivar (objc_ivar_chain, $1)))
757 if (IDENTIFIER_LOCAL_VALUE ($1))
758 warning ("local declaration of `%s' hides instance variable",
759 IDENTIFIER_POINTER ($1));
762 if (is_private (decl))
763 $$ = error_mark_node;
765 $$ = build_ivar_reference ($1);
769 else /* we have a message to super */
770 $$ = get_super_receiver ();
774 if (TREE_CODE ($$) == CONST_DECL)
776 $$ = DECL_INITIAL ($$);
777 /* This is to prevent an enum whose value is 0
778 from being considered a null pointer constant. */
779 $$ = build1 (NOP_EXPR, TREE_TYPE ($$), $$);
780 TREE_CONSTANT ($$) = 1;
785 { $$ = combine_strings ($1); }
787 { char class = TREE_CODE_CLASS (TREE_CODE ($2));
788 if (class == 'e' || class == '1'
789 || class == '2' || class == '<')
790 C_SET_EXP_ORIGINAL_CODE ($2, ERROR_MARK);
793 { $$ = error_mark_node; }
795 { if (current_function_decl == 0)
797 error ("braced-group within expression allowed only inside a function");
800 /* We must force a BLOCK for this level
801 so that, if it is not expanded later,
802 there is a way to turn off the entire subtree of blocks
803 that are contained in it. */
805 push_iterator_stack ();
807 $<ttype>$ = expand_start_stmt_expr (); }
811 pedwarn ("ANSI C forbids braced-groups within expressions");
812 pop_iterator_stack ();
814 rtl_exp = expand_end_stmt_expr ($<ttype>2);
815 /* The statements have side effects, so the group does. */
816 TREE_SIDE_EFFECTS (rtl_exp) = 1;
818 if (TREE_CODE ($3) == BLOCK)
820 /* Make a BIND_EXPR for the BLOCK already made. */
821 $$ = build (BIND_EXPR, TREE_TYPE (rtl_exp),
822 NULL_TREE, rtl_exp, $3);
823 /* Remove the block from the tree at this point.
824 It gets put back at the proper place
825 when the BIND_EXPR is expanded. */
831 | primary '(' exprlist ')' %prec '.'
832 { $$ = build_function_call ($1, $3); }
833 | primary '[' expr ']' %prec '.'
834 { $$ = build_array_ref ($1, $3); }
835 | primary '.' identifier
838 if (doing_objc_thang)
840 if (is_public ($1, $3))
841 $$ = build_component_ref ($1, $3);
843 $$ = error_mark_node;
847 $$ = build_component_ref ($1, $3);
849 | primary POINTSAT identifier
851 tree expr = build_indirect_ref ($1, "->");
854 if (doing_objc_thang)
856 if (is_public (expr, $3))
857 $$ = build_component_ref (expr, $3);
859 $$ = error_mark_node;
863 $$ = build_component_ref (expr, $3);
866 { $$ = build_unary_op (POSTINCREMENT_EXPR, $1, 0); }
868 { $$ = build_unary_op (POSTDECREMENT_EXPR, $1, 0); }
871 { $$ = build_message_expr ($1); }
873 { $$ = build_selector_expr ($1); }
875 { $$ = build_protocol_expr ($1); }
877 { $$ = build_encode_expr ($1); }
879 { $$ = build_objc_string_object ($1); }
883 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
887 { $$ = chainon ($1, $2); }
891 /* Produces an OBJC_STRING_CST with perhaps more OBJC_STRING_CSTs chained
895 | objc_string OBJC_STRING
896 { $$ = chainon ($1, $2); }
900 old_style_parm_decls:
904 /* ... is used here to indicate a varargs function. */
907 pedwarn ("ANSI C does not permit use of `varargs.h'"); }
910 /* The following are analogous to lineno_decl, decls and decl
911 except that they do not allow nested functions.
912 They are used for old-style parm decls. */
914 save_filename save_lineno datadecl
921 | datadecls lineno_datadecl
922 | lineno_datadecl errstmt
925 /* We don't allow prefix attributes here because they cause reduce/reduce
926 conflicts: we can't know whether we're parsing a function decl with
927 attribute suffix, or function defn with attribute prefix on first old
930 typed_declspecs_no_prefix_attr setspecs initdecls ';'
931 { current_declspecs = TREE_VALUE (declspec_stack);
932 prefix_attributes = TREE_PURPOSE (declspec_stack);
933 declspec_stack = TREE_CHAIN (declspec_stack);
934 resume_momentary ($2); }
935 | declmods_no_prefix_attr setspecs notype_initdecls ';'
936 { current_declspecs = TREE_VALUE (declspec_stack);
937 prefix_attributes = TREE_PURPOSE (declspec_stack);
938 declspec_stack = TREE_CHAIN (declspec_stack);
939 resume_momentary ($2); }
940 | typed_declspecs_no_prefix_attr ';'
941 { shadow_tag_warned ($1, 1);
942 pedwarn ("empty declaration"); }
943 | declmods_no_prefix_attr ';'
944 { pedwarn ("empty declaration"); }
947 /* This combination which saves a lineno before a decl
948 is the normal thing to use, rather than decl itself.
949 This is to avoid shift/reduce conflicts in contexts
950 where statement labels are allowed. */
952 save_filename save_lineno decl
960 | lineno_decl errstmt
963 /* records the type and storage class specs to use for processing
964 the declarators that follow.
965 Maintains a stack of outer-level values of current_declspecs,
966 for the sake of parm declarations nested in function declarators. */
967 setspecs: /* empty */
968 { $$ = suspend_momentary ();
969 pending_xref_error ();
970 declspec_stack = tree_cons (prefix_attributes,
973 split_specs_attrs ($<ttype>0,
974 ¤t_declspecs, &prefix_attributes); }
977 /* ??? Yuck. See after_type_declarator. */
978 setattrs: /* empty */
979 { prefix_attributes = chainon (prefix_attributes, $<ttype>0); }
983 typed_declspecs setspecs initdecls ';'
984 { current_declspecs = TREE_VALUE (declspec_stack);
985 prefix_attributes = TREE_PURPOSE (declspec_stack);
986 declspec_stack = TREE_CHAIN (declspec_stack);
987 resume_momentary ($2); }
988 | declmods setspecs notype_initdecls ';'
989 { current_declspecs = TREE_VALUE (declspec_stack);
990 prefix_attributes = TREE_PURPOSE (declspec_stack);
991 declspec_stack = TREE_CHAIN (declspec_stack);
992 resume_momentary ($2); }
993 | typed_declspecs setspecs nested_function
994 { current_declspecs = TREE_VALUE (declspec_stack);
995 prefix_attributes = TREE_PURPOSE (declspec_stack);
996 declspec_stack = TREE_CHAIN (declspec_stack);
997 resume_momentary ($2); }
998 | declmods setspecs notype_nested_function
999 { current_declspecs = TREE_VALUE (declspec_stack);
1000 prefix_attributes = TREE_PURPOSE (declspec_stack);
1001 declspec_stack = TREE_CHAIN (declspec_stack);
1002 resume_momentary ($2); }
1003 | typed_declspecs ';'
1004 { shadow_tag ($1); }
1006 { pedwarn ("empty declaration"); }
1008 { pedantic = $<itype>1; }
1011 /* Declspecs which contain at least one type specifier or typedef name.
1012 (Just `const' or `volatile' is not enough.)
1013 A typedef'd name following these is taken as a name to be declared.
1014 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
1017 typespec reserved_declspecs
1018 { $$ = tree_cons (NULL_TREE, $1, $2); }
1019 | declmods typespec reserved_declspecs
1020 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
1023 reserved_declspecs: /* empty */
1025 | reserved_declspecs typespecqual_reserved
1026 { $$ = tree_cons (NULL_TREE, $2, $1); }
1027 | reserved_declspecs SCSPEC
1028 { if (extra_warnings)
1029 warning ("`%s' is not at beginning of declaration",
1030 IDENTIFIER_POINTER ($2));
1031 $$ = tree_cons (NULL_TREE, $2, $1); }
1032 | reserved_declspecs attributes
1033 { $$ = tree_cons ($2, NULL_TREE, $1); }
1036 typed_declspecs_no_prefix_attr:
1037 typespec reserved_declspecs_no_prefix_attr
1038 { $$ = tree_cons (NULL_TREE, $1, $2); }
1039 | declmods_no_prefix_attr typespec reserved_declspecs_no_prefix_attr
1040 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
1043 reserved_declspecs_no_prefix_attr:
1046 | reserved_declspecs_no_prefix_attr typespecqual_reserved
1047 { $$ = tree_cons (NULL_TREE, $2, $1); }
1048 | reserved_declspecs_no_prefix_attr SCSPEC
1049 { if (extra_warnings)
1050 warning ("`%s' is not at beginning of declaration",
1051 IDENTIFIER_POINTER ($2));
1052 $$ = tree_cons (NULL_TREE, $2, $1); }
1055 /* List of just storage classes, type modifiers, and prefix attributes.
1056 A declaration can start with just this, but then it cannot be used
1057 to redeclare a typedef-name.
1058 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
1061 declmods_no_prefix_attr
1064 { $$ = tree_cons ($1, NULL_TREE, NULL_TREE); }
1065 | declmods declmods_no_prefix_attr
1066 { $$ = chainon ($2, $1); }
1067 | declmods attributes
1068 { $$ = tree_cons ($2, NULL_TREE, $1); }
1071 declmods_no_prefix_attr:
1073 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
1074 TREE_STATIC ($$) = 1; }
1076 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
1077 | declmods_no_prefix_attr TYPE_QUAL
1078 { $$ = tree_cons (NULL_TREE, $2, $1);
1079 TREE_STATIC ($$) = 1; }
1080 | declmods_no_prefix_attr SCSPEC
1081 { if (extra_warnings && TREE_STATIC ($1))
1082 warning ("`%s' is not at beginning of declaration",
1083 IDENTIFIER_POINTER ($2));
1084 $$ = tree_cons (NULL_TREE, $2, $1);
1085 TREE_STATIC ($$) = TREE_STATIC ($1); }
1089 /* Used instead of declspecs where storage classes are not allowed
1090 (that is, for typenames and structure components).
1091 Don't accept a typedef-name if anything but a modifier precedes it. */
1094 typespec reserved_typespecquals
1095 { $$ = tree_cons (NULL_TREE, $1, $2); }
1096 | nonempty_type_quals typespec reserved_typespecquals
1097 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
1100 reserved_typespecquals: /* empty */
1102 | reserved_typespecquals typespecqual_reserved
1103 { $$ = tree_cons (NULL_TREE, $2, $1); }
1106 /* A typespec (but not a type qualifier).
1107 Once we have seen one of these in a declaration,
1108 if a typedef name appears then it is being redeclared. */
1113 { /* For a typedef name, record the meaning, not the name.
1114 In case of `foo foo, bar;'. */
1115 $$ = lookup_name ($1); }
1117 | CLASSNAME protocolrefs
1118 { $$ = get_static_reference ($1, $2); }
1119 | OBJECTNAME protocolrefs
1120 { $$ = get_object_reference ($2); }
1122 /* Make "<SomeProtocol>" equivalent to "id <SomeProtocol>"
1123 - nisse@lysator.liu.se */
1124 | non_empty_protocolrefs
1125 { $$ = get_object_reference ($1); }
1127 | TYPEOF '(' expr ')'
1128 { $$ = TREE_TYPE ($3); }
1129 | TYPEOF '(' typename ')'
1130 { $$ = groktypename ($3); }
1133 /* A typespec that is a reserved word, or a type qualifier. */
1135 typespecqual_reserved: TYPESPEC
1142 | initdecls ',' initdcl
1147 | notype_initdecls ',' initdcl
1153 | ASM_KEYWORD '(' string ')'
1154 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
1160 declarator maybeasm maybe_attribute '='
1161 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1162 $3, prefix_attributes);
1163 start_init ($<ttype>$, $2, global_bindings_p ()); }
1165 /* Note how the declaration of the variable is in effect while its init is parsed! */
1167 finish_decl ($<ttype>5, $6, $2); }
1168 | declarator maybeasm maybe_attribute
1169 { tree d = start_decl ($1, current_declspecs, 0,
1170 $3, prefix_attributes);
1171 finish_decl (d, NULL_TREE, $2);
1176 notype_declarator maybeasm maybe_attribute '='
1177 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1178 $3, prefix_attributes);
1179 start_init ($<ttype>$, $2, global_bindings_p ()); }
1181 /* Note how the declaration of the variable is in effect while its init is parsed! */
1183 decl_attributes ($<ttype>5, $3, prefix_attributes);
1184 finish_decl ($<ttype>5, $6, $2); }
1185 | notype_declarator maybeasm maybe_attribute
1186 { tree d = start_decl ($1, current_declspecs, 0,
1187 $3, prefix_attributes);
1188 finish_decl (d, NULL_TREE, $2); }
1190 /* the * rules are dummies to accept the Apollo extended syntax
1191 so that the header files compile. */
1202 | attributes attribute
1203 { $$ = chainon ($1, $2); }
1207 ATTRIBUTE '(' '(' attribute_list ')' ')'
1214 | attribute_list ',' attrib
1215 { $$ = chainon ($1, $3); }
1222 { $$ = build_tree_list ($1, NULL_TREE); }
1223 | any_word '(' IDENTIFIER ')'
1224 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1225 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1226 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1227 | any_word '(' exprlist ')'
1228 { $$ = build_tree_list ($1, $3); }
1231 /* This still leaves out most reserved keywords,
1232 shouldn't we include them? */
1241 /* Initializers. `init' is the entry point. */
1246 { really_start_incremental_init (NULL_TREE);
1247 /* Note that the call to clear_momentary
1248 is in process_init_element. */
1249 push_momentary (); }
1250 initlist_maybe_comma '}'
1251 { $$ = pop_init_level (0);
1252 if ($$ == error_mark_node
1253 && ! (yychar == STRING || yychar == CONSTANT))
1256 pop_momentary_nofree (); }
1259 { $$ = error_mark_node; }
1262 /* `initlist_maybe_comma' is the guts of an initializer in braces. */
1263 initlist_maybe_comma:
1266 pedwarn ("ANSI C forbids empty initializer braces"); }
1267 | initlist1 maybecomma
1272 | initlist1 ',' initelt
1275 /* `initelt' is a single element of an initializer.
1276 It may use braces. */
1278 designator_list '=' initval
1279 | designator initval
1281 { set_init_label ($1); }
1288 { push_init_level (0); }
1289 initlist_maybe_comma '}'
1290 { process_init_element (pop_init_level (0)); }
1292 { process_init_element ($1); }
1298 | designator_list designator
1303 { set_init_label ($2); }
1304 /* These are for labeled elements. The syntax for an array element
1305 initializer conflicts with the syntax for an Objective-C message,
1306 so don't include these productions in the Objective-C grammar. */
1308 | '[' expr_no_commas ELLIPSIS expr_no_commas ']'
1309 { set_init_index ($2, $4); }
1310 | '[' expr_no_commas ']'
1311 { set_init_index ($2, NULL_TREE); }
1317 { push_c_function_context ();
1318 if (! start_function (current_declspecs, $1,
1319 prefix_attributes, NULL_TREE, 1))
1321 pop_c_function_context ();
1324 reinit_parse_for_function (); }
1325 old_style_parm_decls
1326 { store_parm_decls (); }
1327 /* This used to use compstmt_or_error.
1328 That caused a bug with input `f(g) int g {}',
1329 where the use of YYERROR1 above caused an error
1330 which then was handled by compstmt_or_error.
1331 There followed a repeated execution of that same rule,
1332 which called YYERROR1 again, and so on. */
1334 { finish_function (1);
1335 pop_c_function_context (); }
1338 notype_nested_function:
1340 { push_c_function_context ();
1341 if (! start_function (current_declspecs, $1,
1342 prefix_attributes, NULL_TREE, 1))
1344 pop_c_function_context ();
1347 reinit_parse_for_function (); }
1348 old_style_parm_decls
1349 { store_parm_decls (); }
1350 /* This used to use compstmt_or_error.
1351 That caused a bug with input `f(g) int g {}',
1352 where the use of YYERROR1 above caused an error
1353 which then was handled by compstmt_or_error.
1354 There followed a repeated execution of that same rule,
1355 which called YYERROR1 again, and so on. */
1357 { finish_function (1);
1358 pop_c_function_context (); }
1361 /* Any kind of declarator (thus, all declarators allowed
1362 after an explicit typespec). */
1365 after_type_declarator
1369 /* A declarator that is allowed only after an explicit typespec. */
1371 after_type_declarator:
1372 '(' after_type_declarator ')'
1374 | after_type_declarator '(' parmlist_or_identifiers %prec '.'
1375 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1376 /* | after_type_declarator '(' error ')' %prec '.'
1377 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1378 poplevel (0, 0, 0); } */
1379 | after_type_declarator '[' expr ']' %prec '.'
1380 { $$ = build_nt (ARRAY_REF, $1, $3); }
1381 | after_type_declarator '[' ']' %prec '.'
1382 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1383 | '*' type_quals after_type_declarator %prec UNARY
1384 { $$ = make_pointer_declarator ($2, $3); }
1385 /* ??? Yuck. setattrs is a quick hack. We can't use
1386 prefix_attributes because $1 only applies to this
1387 declarator. We assume setspecs has already been done.
1388 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1389 attributes could be recognized here or in `attributes'). */
1390 | attributes setattrs after_type_declarator
1398 /* Kinds of declarator that can appear in a parameter list
1399 in addition to notype_declarator. This is like after_type_declarator
1400 but does not allow a typedef name in parentheses as an identifier
1401 (because it would conflict with a function with that typedef as arg). */
1404 parm_declarator '(' parmlist_or_identifiers %prec '.'
1405 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1406 /* | parm_declarator '(' error ')' %prec '.'
1407 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1408 poplevel (0, 0, 0); } */
1410 | parm_declarator '[' '*' ']' %prec '.'
1411 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE);
1413 error ("`[*]' in parameter declaration only allowed in ISO C 9x");
1416 | parm_declarator '[' expr ']' %prec '.'
1417 { $$ = build_nt (ARRAY_REF, $1, $3); }
1418 | parm_declarator '[' ']' %prec '.'
1419 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1420 | '*' type_quals parm_declarator %prec UNARY
1421 { $$ = make_pointer_declarator ($2, $3); }
1422 /* ??? Yuck. setattrs is a quick hack. We can't use
1423 prefix_attributes because $1 only applies to this
1424 declarator. We assume setspecs has already been done.
1425 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1426 attributes could be recognized here or in `attributes'). */
1427 | attributes setattrs parm_declarator
1432 /* A declarator allowed whether or not there has been
1433 an explicit typespec. These cannot redeclare a typedef-name. */
1436 notype_declarator '(' parmlist_or_identifiers %prec '.'
1437 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1438 /* | notype_declarator '(' error ')' %prec '.'
1439 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1440 poplevel (0, 0, 0); } */
1441 | '(' notype_declarator ')'
1443 | '*' type_quals notype_declarator %prec UNARY
1444 { $$ = make_pointer_declarator ($2, $3); }
1446 | notype_declarator '[' '*' ']' %prec '.'
1447 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE);
1449 error ("`[*]' in parameter declaration only allowed in ISO C 9x");
1452 | notype_declarator '[' expr ']' %prec '.'
1453 { $$ = build_nt (ARRAY_REF, $1, $3); }
1454 | notype_declarator '[' ']' %prec '.'
1455 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1456 /* ??? Yuck. setattrs is a quick hack. We can't use
1457 prefix_attributes because $1 only applies to this
1458 declarator. We assume setspecs has already been done.
1459 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1460 attributes could be recognized here or in `attributes'). */
1461 | attributes setattrs notype_declarator
1488 struct_head identifier '{'
1489 { $$ = start_struct (RECORD_TYPE, $2);
1490 /* Start scope of tag before parsing components. */
1492 component_decl_list '}' maybe_attribute
1493 { $$ = finish_struct ($<ttype>4, $5, chainon ($1, $7)); }
1494 | struct_head '{' component_decl_list '}' maybe_attribute
1495 { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
1496 $3, chainon ($1, $5));
1498 | struct_head identifier
1499 { $$ = xref_tag (RECORD_TYPE, $2); }
1500 | union_head identifier '{'
1501 { $$ = start_struct (UNION_TYPE, $2); }
1502 component_decl_list '}' maybe_attribute
1503 { $$ = finish_struct ($<ttype>4, $5, chainon ($1, $7)); }
1504 | union_head '{' component_decl_list '}' maybe_attribute
1505 { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
1506 $3, chainon ($1, $5));
1508 | union_head identifier
1509 { $$ = xref_tag (UNION_TYPE, $2); }
1510 | enum_head identifier '{'
1511 { $<itype>3 = suspend_momentary ();
1512 $$ = start_enum ($2); }
1513 enumlist maybecomma_warn '}' maybe_attribute
1514 { $$= finish_enum ($<ttype>4, nreverse ($5), chainon ($1, $8));
1515 resume_momentary ($<itype>3); }
1517 { $<itype>2 = suspend_momentary ();
1518 $$ = start_enum (NULL_TREE); }
1519 enumlist maybecomma_warn '}' maybe_attribute
1520 { $$= finish_enum ($<ttype>3, nreverse ($4), chainon ($1, $7));
1521 resume_momentary ($<itype>2); }
1522 | enum_head identifier
1523 { $$ = xref_tag (ENUMERAL_TYPE, $2); }
1534 { if (pedantic && ! flag_isoc9x)
1535 pedwarn ("comma at end of enumerator list"); }
1538 component_decl_list:
1539 component_decl_list2
1541 | component_decl_list2 component_decl
1542 { $$ = chainon ($1, $2);
1543 pedwarn ("no semicolon at end of struct or union"); }
1546 component_decl_list2: /* empty */
1548 | component_decl_list2 component_decl ';'
1549 { $$ = chainon ($1, $2); }
1550 | component_decl_list2 ';'
1552 pedwarn ("extra semicolon in struct or union specified"); }
1554 /* foo(sizeof(struct{ @defs(ClassName)})); */
1555 | DEFS '(' CLASSNAME ')'
1557 tree interface = lookup_interface ($3);
1560 $$ = get_class_ivars (interface);
1563 error ("Cannot find interface declaration for `%s'",
1564 IDENTIFIER_POINTER ($3));
1571 /* There is a shift-reduce conflict here, because `components' may
1572 start with a `typename'. It happens that shifting (the default resolution)
1573 does the right thing, because it treats the `typename' as part of
1574 a `typed_typespecs'.
1576 It is possible that this same technique would allow the distinction
1577 between `notype_initdecls' and `initdecls' to be eliminated.
1578 But I am being cautious and not trying it. */
1581 typed_typespecs setspecs components
1583 current_declspecs = TREE_VALUE (declspec_stack);
1584 prefix_attributes = TREE_PURPOSE (declspec_stack);
1585 declspec_stack = TREE_CHAIN (declspec_stack);
1586 resume_momentary ($2); }
1589 pedwarn ("ANSI C forbids member declarations with no members");
1592 | nonempty_type_quals setspecs components
1594 current_declspecs = TREE_VALUE (declspec_stack);
1595 prefix_attributes = TREE_PURPOSE (declspec_stack);
1596 declspec_stack = TREE_CHAIN (declspec_stack);
1597 resume_momentary ($2); }
1598 | nonempty_type_quals
1600 pedwarn ("ANSI C forbids member declarations with no members");
1605 | extension component_decl
1607 pedantic = $<itype>1; }
1611 component_declarator
1612 | components ',' component_declarator
1613 { $$ = chainon ($1, $3); }
1616 component_declarator:
1617 save_filename save_lineno declarator maybe_attribute
1618 { $$ = grokfield ($1, $2, $3, current_declspecs, NULL_TREE);
1619 decl_attributes ($$, $4, prefix_attributes); }
1620 | save_filename save_lineno
1621 declarator ':' expr_no_commas maybe_attribute
1622 { $$ = grokfield ($1, $2, $3, current_declspecs, $5);
1623 decl_attributes ($$, $6, prefix_attributes); }
1624 | save_filename save_lineno ':' expr_no_commas maybe_attribute
1625 { $$ = grokfield ($1, $2, NULL_TREE, current_declspecs, $4);
1626 decl_attributes ($$, $5, prefix_attributes); }
1629 /* We chain the enumerators in reverse order.
1630 They are put in forward order where enumlist is used.
1631 (The order used to be significant, but no longer is so.
1632 However, we still maintain the order, just to be clean.) */
1636 | enumlist ',' enumerator
1637 { if ($1 == error_mark_node)
1640 $$ = chainon ($3, $1); }
1642 { $$ = error_mark_node; }
1648 { $$ = build_enumerator ($1, NULL_TREE); }
1649 | identifier '=' expr_no_commas
1650 { $$ = build_enumerator ($1, $3); }
1654 typed_typespecs absdcl
1655 { $$ = build_tree_list ($1, $2); }
1656 | nonempty_type_quals absdcl
1657 { $$ = build_tree_list ($1, $2); }
1660 absdcl: /* an absolute declarator */
1666 nonempty_type_quals:
1668 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
1669 | nonempty_type_quals TYPE_QUAL
1670 { $$ = tree_cons (NULL_TREE, $2, $1); }
1676 | type_quals TYPE_QUAL
1677 { $$ = tree_cons (NULL_TREE, $2, $1); }
1680 absdcl1: /* a nonempty absolute declarator */
1683 /* `(typedef)1' is `int'. */
1684 | '*' type_quals absdcl1 %prec UNARY
1685 { $$ = make_pointer_declarator ($2, $3); }
1686 | '*' type_quals %prec UNARY
1687 { $$ = make_pointer_declarator ($2, NULL_TREE); }
1688 | absdcl1 '(' parmlist %prec '.'
1689 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1690 | absdcl1 '[' expr ']' %prec '.'
1691 { $$ = build_nt (ARRAY_REF, $1, $3); }
1692 | absdcl1 '[' ']' %prec '.'
1693 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1694 | '(' parmlist %prec '.'
1695 { $$ = build_nt (CALL_EXPR, NULL_TREE, $2, NULL_TREE); }
1696 | '[' expr ']' %prec '.'
1697 { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
1699 { $$ = build_nt (ARRAY_REF, NULL_TREE, NULL_TREE); }
1700 /* ??? It appears we have to support attributes here, however
1701 using prefix_attributes is wrong. */
1704 /* at least one statement, the first of which parses without error. */
1705 /* stmts is used only after decls, so an invalid first statement
1706 is actually regarded as an invalid decl and part of the decls. */
1709 lineno_stmt_or_labels
1712 pedwarn ("ANSI C forbids label at end of compound statement");
1716 lineno_stmt_or_labels:
1717 lineno_stmt_or_label
1718 | lineno_stmt_or_labels lineno_stmt_or_label
1720 | lineno_stmt_or_labels errstmt
1732 pushlevel: /* empty */
1733 { emit_line_note (input_filename, lineno);
1737 expand_start_bindings (0);
1739 if (objc_method_context)
1745 /* Read zero or more forward-declarations for labels
1746 that nested functions can jump to. */
1751 pedwarn ("ANSI C forbids label declarations"); }
1756 | label_decls label_decl
1760 LABEL identifiers_or_typenames ';'
1762 for (link = $2; link; link = TREE_CHAIN (link))
1764 tree label = shadow_label (TREE_VALUE (link));
1765 C_DECLARED_LABEL_FLAG (label) = 1;
1766 declare_nonlocal_label (label);
1771 /* This is the body of a function definition.
1772 It causes syntax errors to ignore to the next openbrace. */
1779 compstmt_start: '{' { compstmt_count++; }
1781 compstmt: compstmt_start '}'
1782 { $$ = convert (void_type_node, integer_zero_node); }
1783 | compstmt_start pushlevel maybe_label_decls decls xstmts '}'
1784 { emit_line_note (input_filename, lineno);
1785 expand_end_bindings (getdecls (), 1, 0);
1786 $$ = poplevel (1, 1, 0);
1787 if (yychar == CONSTANT || yychar == STRING)
1788 pop_momentary_nofree ();
1791 | compstmt_start pushlevel maybe_label_decls error '}'
1792 { emit_line_note (input_filename, lineno);
1793 expand_end_bindings (getdecls (), kept_level_p (), 0);
1794 $$ = poplevel (kept_level_p (), 0, 0);
1795 if (yychar == CONSTANT || yychar == STRING)
1796 pop_momentary_nofree ();
1799 | compstmt_start pushlevel maybe_label_decls stmts '}'
1800 { emit_line_note (input_filename, lineno);
1801 expand_end_bindings (getdecls (), kept_level_p (), 0);
1802 $$ = poplevel (kept_level_p (), 0, 0);
1803 if (yychar == CONSTANT || yychar == STRING)
1804 pop_momentary_nofree ();
1809 /* Value is number of statements counted as of the closeparen. */
1811 if_prefix lineno_labeled_stmt
1812 /* Make sure c_expand_end_cond is run once
1813 for each call to c_expand_start_cond.
1814 Otherwise a crash is likely. */
1820 { emit_line_note ($<filename>-1, $<lineno>0);
1821 c_expand_start_cond (truthvalue_conversion ($3), 0,
1823 $<itype>$ = stmt_count;
1824 if_stmt_file = $<filename>-1;
1825 if_stmt_line = $<lineno>0;
1826 position_after_white_space (); }
1829 /* This is a subroutine of stmt.
1830 It is used twice, once for valid DO statements
1831 and once for catching errors in parsing the end test. */
1836 emit_line_note ($<filename>-1, $<lineno>0);
1837 /* See comment in `while' alternative, above. */
1839 expand_start_loop_continue_elsewhere (1);
1840 position_after_white_space (); }
1841 lineno_labeled_stmt WHILE
1842 { expand_loop_continue_here (); }
1846 { $$ = input_filename; }
1853 lineno_labeled_stmt:
1854 save_filename save_lineno stmt
1856 /* | save_filename save_lineno error
1859 | save_filename save_lineno label lineno_labeled_stmt
1863 lineno_stmt_or_label:
1864 save_filename save_lineno stmt_or_label
1875 /* Parse a single real statement, not including any labels. */
1882 emit_line_note ($<filename>-1, $<lineno>0);
1883 /* It appears that this should not be done--that a non-lvalue array
1884 shouldn't get an error if the value isn't used.
1885 Section 3.2.2.1 says that an array lvalue gets converted to a pointer
1886 if it appears as a top-level expression,
1887 but says nothing about non-lvalue arrays. */
1889 /* Call default_conversion to get an error
1890 on referring to a register array if pedantic. */
1891 if (TREE_CODE (TREE_TYPE ($1)) == ARRAY_TYPE
1892 || TREE_CODE (TREE_TYPE ($1)) == FUNCTION_TYPE)
1893 $1 = default_conversion ($1);
1895 iterator_expand ($1);
1896 clear_momentary (); }
1898 { c_expand_start_else ();
1899 $<itype>1 = stmt_count;
1900 position_after_white_space (); }
1902 { c_expand_end_cond ();
1903 if (extra_warnings && stmt_count == $<itype>1)
1904 warning ("empty body in an else-statement"); }
1905 | simple_if %prec IF
1906 { c_expand_end_cond ();
1907 /* This warning is here instead of in simple_if, because we
1908 do not want a warning if an empty if is followed by an
1909 else statement. Increment stmt_count so we don't
1910 give a second error if this is a nested `if'. */
1911 if (extra_warnings && stmt_count++ == $<itype>1)
1912 warning_with_file_and_line (if_stmt_file, if_stmt_line,
1913 "empty body in an if-statement"); }
1914 /* Make sure c_expand_end_cond is run once
1915 for each call to c_expand_start_cond.
1916 Otherwise a crash is likely. */
1917 | simple_if ELSE error
1918 { c_expand_end_cond (); }
1921 emit_line_note ($<filename>-1, $<lineno>0);
1922 /* The emit_nop used to come before emit_line_note,
1923 but that made the nop seem like part of the preceding line.
1924 And that was confusing when the preceding line was
1925 inside of an if statement and was not really executed.
1926 I think it ought to work to put the nop after the line number.
1927 We will see. --rms, July 15, 1991. */
1930 { /* Don't start the loop till we have succeeded
1931 in parsing the end test. This is to make sure
1932 that we end every loop we start. */
1933 expand_start_loop (1);
1934 emit_line_note (input_filename, lineno);
1935 expand_exit_loop_if_false (NULL_PTR,
1936 truthvalue_conversion ($4));
1937 position_after_white_space (); }
1939 { expand_end_loop (); }
1942 { emit_line_note (input_filename, lineno);
1943 expand_exit_loop_if_false (NULL_PTR,
1944 truthvalue_conversion ($3));
1946 clear_momentary (); }
1947 /* This rule is needed to make sure we end every loop we start. */
1948 | do_stmt_start error
1949 { expand_end_loop ();
1950 clear_momentary (); }
1954 emit_line_note ($<filename>-1, $<lineno>0);
1955 /* See comment in `while' alternative, above. */
1957 if ($3) c_expand_expr_stmt ($3);
1958 /* Next step is to call expand_start_loop_continue_elsewhere,
1959 but wait till after we parse the entire for (...).
1960 Otherwise, invalid input might cause us to call that
1961 fn without calling expand_end_loop. */
1964 /* Can't emit now; wait till after expand_start_loop... */
1965 { $<lineno>7 = lineno;
1966 $<filename>$ = input_filename; }
1969 /* Start the loop. Doing this after parsing
1970 all the expressions ensures we will end the loop. */
1971 expand_start_loop_continue_elsewhere (1);
1972 /* Emit the end-test, with a line number. */
1973 emit_line_note ($<filename>8, $<lineno>7);
1975 expand_exit_loop_if_false (NULL_PTR,
1976 truthvalue_conversion ($6));
1977 /* Don't let the tree nodes for $9 be discarded by
1978 clear_momentary during the parsing of the next stmt. */
1980 $<lineno>7 = lineno;
1981 $<filename>8 = input_filename;
1982 position_after_white_space (); }
1984 { /* Emit the increment expression, with a line number. */
1985 emit_line_note ($<filename>8, $<lineno>7);
1986 expand_loop_continue_here ();
1988 c_expand_expr_stmt ($9);
1989 if (yychar == CONSTANT || yychar == STRING)
1990 pop_momentary_nofree ();
1993 expand_end_loop (); }
1994 | SWITCH '(' expr ')'
1996 emit_line_note ($<filename>-1, $<lineno>0);
1997 c_expand_start_case ($3);
1998 /* Don't let the tree nodes for $3 be discarded by
1999 clear_momentary during the parsing of the next stmt. */
2001 position_after_white_space (); }
2003 { expand_end_case ($3);
2004 if (yychar == CONSTANT || yychar == STRING)
2005 pop_momentary_nofree ();
2010 emit_line_note ($<filename>-1, $<lineno>0);
2011 if ( ! expand_exit_something ())
2012 error ("break statement not within loop or switch"); }
2015 emit_line_note ($<filename>-1, $<lineno>0);
2016 if (! expand_continue_loop (NULL_PTR))
2017 error ("continue statement not within a loop"); }
2020 emit_line_note ($<filename>-1, $<lineno>0);
2021 c_expand_return (NULL_TREE); }
2024 emit_line_note ($<filename>-1, $<lineno>0);
2025 c_expand_return ($2); }
2026 | ASM_KEYWORD maybe_type_qual '(' expr ')' ';'
2028 emit_line_note ($<filename>-1, $<lineno>0);
2030 if ((TREE_CODE ($4) == ADDR_EXPR
2031 && TREE_CODE (TREE_OPERAND ($4, 0)) == STRING_CST)
2032 || TREE_CODE ($4) == STRING_CST)
2035 error ("argument of `asm' is not a constant string"); }
2036 /* This is the case with just output operands. */
2037 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ')' ';'
2039 emit_line_note ($<filename>-1, $<lineno>0);
2040 c_expand_asm_operands ($4, $6, NULL_TREE, NULL_TREE,
2041 $2 == ridpointers[(int)RID_VOLATILE],
2042 input_filename, lineno); }
2043 /* This is the case with input operands as well. */
2044 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':' asm_operands ')' ';'
2046 emit_line_note ($<filename>-1, $<lineno>0);
2047 c_expand_asm_operands ($4, $6, $8, NULL_TREE,
2048 $2 == ridpointers[(int)RID_VOLATILE],
2049 input_filename, lineno); }
2050 /* This is the case with clobbered registers as well. */
2051 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':'
2052 asm_operands ':' asm_clobbers ')' ';'
2054 emit_line_note ($<filename>-1, $<lineno>0);
2055 c_expand_asm_operands ($4, $6, $8, $10,
2056 $2 == ridpointers[(int)RID_VOLATILE],
2057 input_filename, lineno); }
2058 | GOTO identifier ';'
2061 emit_line_note ($<filename>-1, $<lineno>0);
2062 decl = lookup_label ($2);
2065 TREE_USED (decl) = 1;
2071 pedwarn ("ANSI C forbids `goto *expr;'");
2073 emit_line_note ($<filename>-1, $<lineno>0);
2074 expand_computed_goto (convert (ptr_type_node, $3)); }
2079 all_iter_stmt_simple
2080 /* | all_iter_stmt_with_decl */
2083 all_iter_stmt_simple:
2086 /* The value returned by this action is */
2087 /* 1 if everything is OK */
2088 /* 0 in case of error or already bound iterator */
2091 if (TREE_CODE ($3) != VAR_DECL)
2092 error ("invalid `for (ITERATOR)' syntax");
2093 else if (! ITERATOR_P ($3))
2094 error ("`%s' is not an iterator",
2095 IDENTIFIER_POINTER (DECL_NAME ($3)));
2096 else if (ITERATOR_BOUND_P ($3))
2097 error ("`for (%s)' inside expansion of same iterator",
2098 IDENTIFIER_POINTER (DECL_NAME ($3)));
2102 iterator_for_loop_start ($3);
2108 iterator_for_loop_end ($3);
2111 /* This really should allow any kind of declaration,
2112 for generality. Fix it before turning it back on.
2114 all_iter_stmt_with_decl:
2115 FOR '(' ITERATOR pushlevel setspecs iterator_spec ')'
2117 */ /* The value returned by this action is */
2118 /* 1 if everything is OK */
2119 /* 0 in case of error or already bound iterator */
2121 iterator_for_loop_start ($6);
2125 iterator_for_loop_end ($6);
2126 emit_line_note (input_filename, lineno);
2127 expand_end_bindings (getdecls (), 1, 0);
2128 $<ttype>$ = poplevel (1, 1, 0);
2129 if (yychar == CONSTANT || yychar == STRING)
2130 pop_momentary_nofree ();
2136 /* Any kind of label, including jump labels and case labels.
2137 ANSI C accepts labels only before statements, but we allow them
2138 also at the end of a compound statement. */
2140 label: CASE expr_no_commas ':'
2141 { register tree value = check_case_value ($2);
2143 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
2147 if (value != error_mark_node)
2152 if (pedantic && ! INTEGRAL_TYPE_P (TREE_TYPE (value)))
2153 pedwarn ("label must have integral type in ANSI C");
2155 success = pushcase (value, convert_and_check,
2159 error ("case label not within a switch statement");
2160 else if (success == 2)
2162 error ("duplicate case value");
2163 error_with_decl (duplicate, "this is the first entry for that value");
2165 else if (success == 3)
2166 warning ("case value out of range");
2167 else if (success == 5)
2168 error ("case label within scope of cleanup or variable array");
2170 position_after_white_space (); }
2171 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
2172 { register tree value1 = check_case_value ($2);
2173 register tree value2 = check_case_value ($4);
2175 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
2178 pedwarn ("ANSI C forbids case ranges");
2181 if (value1 != error_mark_node && value2 != error_mark_node)
2184 int success = pushcase_range (value1, value2,
2185 convert_and_check, label,
2188 error ("case label not within a switch statement");
2189 else if (success == 2)
2191 error ("duplicate case value");
2192 error_with_decl (duplicate, "this is the first entry for that value");
2194 else if (success == 3)
2195 warning ("case value out of range");
2196 else if (success == 4)
2197 warning ("empty case range");
2198 else if (success == 5)
2199 error ("case label within scope of cleanup or variable array");
2201 position_after_white_space (); }
2206 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
2207 int success = pushcase (NULL_TREE, 0, label, &duplicate);
2210 error ("default label not within a switch statement");
2211 else if (success == 2)
2213 error ("multiple default labels in one switch");
2214 error_with_decl (duplicate, "this is the first default label");
2216 position_after_white_space (); }
2218 { tree label = define_label (input_filename, lineno, $1);
2222 expand_label (label);
2223 position_after_white_space (); }
2226 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
2230 { emit_line_note (input_filename, lineno);
2233 { emit_line_note (input_filename, lineno); }
2242 /* These are the operands other than the first string and colon
2243 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
2244 asm_operands: /* empty */
2246 | nonnull_asm_operands
2249 nonnull_asm_operands:
2251 | nonnull_asm_operands ',' asm_operand
2252 { $$ = chainon ($1, $3); }
2257 { $$ = build_tree_list ($1, $3); }
2262 { $$ = tree_cons (NULL_TREE, combine_strings ($1), NULL_TREE); }
2263 | asm_clobbers ',' string
2264 { $$ = tree_cons (NULL_TREE, combine_strings ($3), $1); }
2267 /* This is what appears inside the parens in a function declarator.
2268 Its value is a list of ..._TYPE nodes. */
2271 clear_parm_order ();
2272 declare_parm_level (0); }
2275 parmlist_tags_warning ();
2276 poplevel (0, 0, 0); }
2284 pedwarn ("ANSI C forbids forward parameter declarations");
2285 /* Mark the forward decls as such. */
2286 for (parm = getdecls (); parm; parm = TREE_CHAIN (parm))
2287 TREE_ASM_WRITTEN (parm) = 1;
2288 clear_parm_order (); }
2292 { $$ = tree_cons (NULL_TREE, NULL_TREE, NULL_TREE); }
2295 /* This is what appears inside the parens in a function declarator.
2296 Is value is represented in the format that grokdeclarator expects. */
2297 parmlist_2: /* empty */
2298 { $$ = get_parm_info (0); }
2300 { $$ = get_parm_info (0);
2301 /* Gcc used to allow this as an extension. However, it does
2302 not work for all targets, and thus has been disabled.
2303 Also, since func (...) and func () are indistinguishable,
2304 it caused problems with the code in expand_builtin which
2305 tries to verify that BUILT_IN_NEXT_ARG is being used
2307 error ("ANSI C requires a named argument before `...'");
2310 { $$ = get_parm_info (1); }
2311 | parms ',' ELLIPSIS
2312 { $$ = get_parm_info (0); }
2317 { push_parm_decl ($1); }
2319 { push_parm_decl ($3); }
2322 /* A single parameter declaration or parameter type name,
2323 as found in a parmlist. */
2325 typed_declspecs setspecs parm_declarator maybe_attribute
2326 { $$ = build_tree_list (build_tree_list (current_declspecs,
2328 build_tree_list (prefix_attributes,
2330 current_declspecs = TREE_VALUE (declspec_stack);
2331 prefix_attributes = TREE_PURPOSE (declspec_stack);
2332 declspec_stack = TREE_CHAIN (declspec_stack);
2333 resume_momentary ($2); }
2334 | typed_declspecs setspecs notype_declarator maybe_attribute
2335 { $$ = build_tree_list (build_tree_list (current_declspecs,
2337 build_tree_list (prefix_attributes,
2339 current_declspecs = TREE_VALUE (declspec_stack);
2340 prefix_attributes = TREE_PURPOSE (declspec_stack);
2341 declspec_stack = TREE_CHAIN (declspec_stack);
2342 resume_momentary ($2); }
2343 | typed_declspecs setspecs absdcl maybe_attribute
2344 { $$ = build_tree_list (build_tree_list (current_declspecs,
2346 build_tree_list (prefix_attributes,
2348 current_declspecs = TREE_VALUE (declspec_stack);
2349 prefix_attributes = TREE_PURPOSE (declspec_stack);
2350 declspec_stack = TREE_CHAIN (declspec_stack);
2351 resume_momentary ($2); }
2352 | declmods setspecs notype_declarator maybe_attribute
2353 { $$ = build_tree_list (build_tree_list (current_declspecs,
2355 build_tree_list (prefix_attributes,
2357 current_declspecs = TREE_VALUE (declspec_stack);
2358 prefix_attributes = TREE_PURPOSE (declspec_stack);
2359 declspec_stack = TREE_CHAIN (declspec_stack);
2360 resume_momentary ($2); }
2362 | declmods setspecs absdcl maybe_attribute
2363 { $$ = build_tree_list (build_tree_list (current_declspecs,
2365 build_tree_list (prefix_attributes,
2367 current_declspecs = TREE_VALUE (declspec_stack);
2368 prefix_attributes = TREE_PURPOSE (declspec_stack);
2369 declspec_stack = TREE_CHAIN (declspec_stack);
2370 resume_momentary ($2); }
2373 /* This is used in a function definition
2374 where either a parmlist or an identifier list is ok.
2375 Its value is a list of ..._TYPE nodes or a list of identifiers. */
2376 parmlist_or_identifiers:
2378 clear_parm_order ();
2379 declare_parm_level (1); }
2380 parmlist_or_identifiers_1
2382 parmlist_tags_warning ();
2383 poplevel (0, 0, 0); }
2386 parmlist_or_identifiers_1:
2390 for (t = $1; t; t = TREE_CHAIN (t))
2391 if (TREE_VALUE (t) == NULL_TREE)
2392 error ("`...' in old-style identifier list");
2393 $$ = tree_cons (NULL_TREE, NULL_TREE, $1); }
2396 /* A nonempty list of identifiers. */
2399 { $$ = build_tree_list (NULL_TREE, $1); }
2400 | identifiers ',' IDENTIFIER
2401 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2404 /* A nonempty list of identifiers, including typenames. */
2405 identifiers_or_typenames:
2407 { $$ = build_tree_list (NULL_TREE, $1); }
2408 | identifiers_or_typenames ',' identifier
2409 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2414 { $<itype>$ = pedantic;
2419 /* Objective-C productions. */
2429 if (objc_implementation_context)
2431 finish_class (objc_implementation_context);
2432 objc_ivar_chain = NULL_TREE;
2433 objc_implementation_context = NULL_TREE;
2436 warning ("`@end' must appear in an implementation context");
2440 /* A nonempty list of identifiers. */
2443 { $$ = build_tree_list (NULL_TREE, $1); }
2444 | identifier_list ',' identifier
2445 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2449 CLASS identifier_list ';'
2451 objc_declare_class ($2);
2455 ALIAS identifier identifier ';'
2457 objc_declare_alias ($2, $3);
2461 INTERFACE identifier protocolrefs '{'
2463 objc_interface_context = objc_ivar_context
2464 = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, $3);
2465 objc_public_flag = 0;
2469 continue_class (objc_interface_context);
2474 finish_class (objc_interface_context);
2475 objc_interface_context = NULL_TREE;
2478 | INTERFACE identifier protocolrefs
2480 objc_interface_context
2481 = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, $3);
2482 continue_class (objc_interface_context);
2487 finish_class (objc_interface_context);
2488 objc_interface_context = NULL_TREE;
2491 | INTERFACE identifier ':' identifier protocolrefs '{'
2493 objc_interface_context = objc_ivar_context
2494 = start_class (CLASS_INTERFACE_TYPE, $2, $4, $5);
2495 objc_public_flag = 0;
2499 continue_class (objc_interface_context);
2504 finish_class (objc_interface_context);
2505 objc_interface_context = NULL_TREE;
2508 | INTERFACE identifier ':' identifier protocolrefs
2510 objc_interface_context
2511 = start_class (CLASS_INTERFACE_TYPE, $2, $4, $5);
2512 continue_class (objc_interface_context);
2517 finish_class (objc_interface_context);
2518 objc_interface_context = NULL_TREE;
2521 | IMPLEMENTATION identifier '{'
2523 objc_implementation_context = objc_ivar_context
2524 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, NULL_TREE, NULL_TREE);
2525 objc_public_flag = 0;
2530 = continue_class (objc_implementation_context);
2533 | IMPLEMENTATION identifier
2535 objc_implementation_context
2536 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, NULL_TREE, NULL_TREE);
2538 = continue_class (objc_implementation_context);
2541 | IMPLEMENTATION identifier ':' identifier '{'
2543 objc_implementation_context = objc_ivar_context
2544 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2545 objc_public_flag = 0;
2550 = continue_class (objc_implementation_context);
2553 | IMPLEMENTATION identifier ':' identifier
2555 objc_implementation_context
2556 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2558 = continue_class (objc_implementation_context);
2561 | INTERFACE identifier '(' identifier ')' protocolrefs
2563 objc_interface_context
2564 = start_class (CATEGORY_INTERFACE_TYPE, $2, $4, $6);
2565 continue_class (objc_interface_context);
2570 finish_class (objc_interface_context);
2571 objc_interface_context = NULL_TREE;
2574 | IMPLEMENTATION identifier '(' identifier ')'
2576 objc_implementation_context
2577 = start_class (CATEGORY_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2579 = continue_class (objc_implementation_context);
2584 PROTOCOL identifier protocolrefs
2586 remember_protocol_qualifiers ();
2587 objc_interface_context
2588 = start_protocol(PROTOCOL_INTERFACE_TYPE, $2, $3);
2592 forget_protocol_qualifiers();
2593 finish_protocol(objc_interface_context);
2594 objc_interface_context = NULL_TREE;
2603 | non_empty_protocolrefs
2606 non_empty_protocolrefs:
2607 ARITHCOMPARE identifier_list ARITHCOMPARE
2609 if ($1 == LT_EXPR && $3 == GT_EXPR)
2617 ivar_decl_list visibility_spec ivar_decls
2622 PRIVATE { objc_public_flag = 2; }
2623 | PROTECTED { objc_public_flag = 0; }
2624 | PUBLIC { objc_public_flag = 1; }
2632 | ivar_decls ivar_decl ';'
2636 pedwarn ("extra semicolon in struct or union specified");
2641 /* There is a shift-reduce conflict here, because `components' may
2642 start with a `typename'. It happens that shifting (the default resolution)
2643 does the right thing, because it treats the `typename' as part of
2644 a `typed_typespecs'.
2646 It is possible that this same technique would allow the distinction
2647 between `notype_initdecls' and `initdecls' to be eliminated.
2648 But I am being cautious and not trying it. */
2651 typed_typespecs setspecs ivars
2653 current_declspecs = TREE_VALUE (declspec_stack);
2654 prefix_attributes = TREE_PURPOSE (declspec_stack);
2655 declspec_stack = TREE_CHAIN (declspec_stack);
2656 resume_momentary ($2); }
2657 | nonempty_type_quals setspecs ivars
2659 current_declspecs = TREE_VALUE (declspec_stack);
2660 prefix_attributes = TREE_PURPOSE (declspec_stack);
2661 declspec_stack = TREE_CHAIN (declspec_stack);
2662 resume_momentary ($2); }
2671 | ivars ',' ivar_declarator
2677 $$ = add_instance_variable (objc_ivar_context,
2679 $1, current_declspecs,
2682 | declarator ':' expr_no_commas
2684 $$ = add_instance_variable (objc_ivar_context,
2686 $1, current_declspecs, $3);
2688 | ':' expr_no_commas
2690 $$ = add_instance_variable (objc_ivar_context,
2693 current_declspecs, $2);
2700 remember_protocol_qualifiers ();
2701 if (objc_implementation_context)
2702 objc_inherit_code = CLASS_METHOD_DECL;
2704 fatal ("method definition not in class context");
2708 forget_protocol_qualifiers ();
2709 add_class_method (objc_implementation_context, $3);
2710 start_method_def ($3);
2711 objc_method_context = $3;
2715 continue_method_def ();
2719 finish_method_def ();
2720 objc_method_context = NULL_TREE;
2725 remember_protocol_qualifiers ();
2726 if (objc_implementation_context)
2727 objc_inherit_code = INSTANCE_METHOD_DECL;
2729 fatal ("method definition not in class context");
2733 forget_protocol_qualifiers ();
2734 add_instance_method (objc_implementation_context, $3);
2735 start_method_def ($3);
2736 objc_method_context = $3;
2740 continue_method_def ();
2744 finish_method_def ();
2745 objc_method_context = NULL_TREE;
2749 /* the reason for the strange actions in this rule
2750 is so that notype_initdecls when reached via datadef
2751 can find a valid list of type and sc specs in $0. */
2755 | {$<ttype>$ = NULL_TREE; } methodprotolist2
2758 methodprotolist2: /* eliminates a shift/reduce conflict */
2761 | methodprotolist2 methodproto
2762 | methodprotolist2 {$<ttype>$ = NULL_TREE; } datadef
2773 /* Remember protocol qualifiers in prototypes. */
2774 remember_protocol_qualifiers ();
2775 objc_inherit_code = CLASS_METHOD_DECL;
2779 /* Forget protocol qualifiers here. */
2780 forget_protocol_qualifiers ();
2781 add_class_method (objc_interface_context, $3);
2787 /* Remember protocol qualifiers in prototypes. */
2788 remember_protocol_qualifiers ();
2789 objc_inherit_code = INSTANCE_METHOD_DECL;
2793 /* Forget protocol qualifiers here. */
2794 forget_protocol_qualifiers ();
2795 add_instance_method (objc_interface_context, $3);
2801 '(' typename ')' unaryselector
2803 $$ = build_method_decl (objc_inherit_code, $2, $4, NULL_TREE);
2808 $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, NULL_TREE);
2811 | '(' typename ')' keywordselector optparmlist
2813 $$ = build_method_decl (objc_inherit_code, $2, $4, $5);
2816 | keywordselector optparmlist
2818 $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, $2);
2822 /* "optarglist" assumes that start_method_def has already been called...
2823 if it is not, the "xdecls" will not be placed in the proper scope */
2830 /* to get around the following situation: "int foo (int a) int b; {}" that
2831 is synthesized when parsing "- a:a b:b; id c; id d; { ... }" */
2846 typed_declspecs setspecs myparms ';'
2847 { current_declspecs = TREE_VALUE (declspec_stack);
2848 prefix_attributes = TREE_PURPOSE (declspec_stack);
2849 declspec_stack = TREE_CHAIN (declspec_stack);
2850 resume_momentary ($2); }
2851 | typed_declspecs ';'
2852 { shadow_tag ($1); }
2854 { pedwarn ("empty declaration"); }
2859 { push_parm_decl ($1); }
2860 | myparms ',' myparm
2861 { push_parm_decl ($3); }
2864 /* A single parameter declaration or parameter type name,
2865 as found in a parmlist. DOES NOT ALLOW AN INITIALIZER OR ASMSPEC */
2868 parm_declarator maybe_attribute
2869 { $$ = build_tree_list (build_tree_list (current_declspecs,
2871 build_tree_list (prefix_attributes,
2873 | notype_declarator maybe_attribute
2874 { $$ = build_tree_list (build_tree_list (current_declspecs,
2876 build_tree_list (prefix_attributes,
2878 | absdcl maybe_attribute
2879 { $$ = build_tree_list (build_tree_list (current_declspecs,
2881 build_tree_list (prefix_attributes,
2892 /* oh what a kludge! */
2901 /* returns a tree list node generated by get_parm_info */
2914 | keywordselector keyworddecl
2916 $$ = chainon ($1, $2);
2928 ENUM { $$ = get_identifier (token_buffer); }
2929 | STRUCT { $$ = get_identifier (token_buffer); }
2930 | UNION { $$ = get_identifier (token_buffer); }
2931 | IF { $$ = get_identifier (token_buffer); }
2932 | ELSE { $$ = get_identifier (token_buffer); }
2933 | WHILE { $$ = get_identifier (token_buffer); }
2934 | DO { $$ = get_identifier (token_buffer); }
2935 | FOR { $$ = get_identifier (token_buffer); }
2936 | SWITCH { $$ = get_identifier (token_buffer); }
2937 | CASE { $$ = get_identifier (token_buffer); }
2938 | DEFAULT { $$ = get_identifier (token_buffer); }
2939 | BREAK { $$ = get_identifier (token_buffer); }
2940 | CONTINUE { $$ = get_identifier (token_buffer); }
2941 | RETURN { $$ = get_identifier (token_buffer); }
2942 | GOTO { $$ = get_identifier (token_buffer); }
2943 | ASM_KEYWORD { $$ = get_identifier (token_buffer); }
2944 | SIZEOF { $$ = get_identifier (token_buffer); }
2945 | TYPEOF { $$ = get_identifier (token_buffer); }
2946 | ALIGNOF { $$ = get_identifier (token_buffer); }
2947 | TYPESPEC | TYPE_QUAL
2951 selector ':' '(' typename ')' identifier
2953 $$ = build_keyword_decl ($1, $4, $6);
2956 | selector ':' identifier
2958 $$ = build_keyword_decl ($1, NULL_TREE, $3);
2961 | ':' '(' typename ')' identifier
2963 $$ = build_keyword_decl (NULL_TREE, $3, $5);
2968 $$ = build_keyword_decl (NULL_TREE, NULL_TREE, $2);
2979 | keywordarglist keywordarg
2981 $$ = chainon ($1, $2);
2989 if (TREE_CHAIN ($1) == NULL_TREE)
2990 /* just return the expr., remove a level of indirection */
2991 $$ = TREE_VALUE ($1);
2993 /* we have a comma expr., we will collapse later */
2999 selector ':' keywordexpr
3001 $$ = build_tree_list ($1, $3);
3005 $$ = build_tree_list (NULL_TREE, $2);
3013 $$ = get_class_reference ($1);
3019 { objc_receiver_context = 1; }
3021 { objc_receiver_context = 0; }
3024 $$ = build_tree_list ($3, $5);
3035 | keywordnamelist keywordname
3037 $$ = chainon ($1, $2);
3044 $$ = build_tree_list ($1, NULL_TREE);
3048 $$ = build_tree_list (NULL_TREE, NULL_TREE);
3053 SELECTOR '(' selectorarg ')'
3060 PROTOCOL '(' identifier ')'
3066 /* extension to support C-structures in the archiver */
3069 ENCODE '(' typename ')'
3071 $$ = groktypename ($3);