1 /* YACC parser for C syntax and for Objective C. -*-c-*-
2 Copyright (C) 1987, 88, 89, 92-98, 1999 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 extension
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;
250 /* For __extension__, save/restore the warning flags which are
251 controlled by __extension__. */
252 #define SAVE_WARN_FLAGS() \
253 build_int_2 (pedantic | (warn_pointer_arith << 1), 0)
254 #define RESTORE_WARN_FLAGS(tval) \
256 int val = TREE_INT_CST_LOW (tval); \
257 pedantic = val & 1; \
258 warn_pointer_arith = (val >> 1) & 1; \
262 /* Objective-C specific information */
264 tree objc_interface_context;
265 tree objc_implementation_context;
266 tree objc_method_context;
267 tree objc_ivar_chain;
268 tree objc_ivar_context;
269 enum tree_code objc_inherit_code;
270 int objc_receiver_context;
271 int objc_public_flag;
275 /* Tell yyparse how to print a token's value, if yydebug is set. */
277 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
278 extern void yyprint PROTO ((FILE *, int, YYSTYPE));
284 pedwarn ("ANSI C forbids an empty source file");
289 /* In case there were missing closebraces,
290 get us back to the global binding level. */
291 while (! global_bindings_p ())
297 /* the reason for the strange actions in this rule
298 is so that notype_initdecls when reached via datadef
299 can find a valid list of type and sc specs in $0. */
302 {$<ttype>$ = NULL_TREE; } extdef
303 | extdefs {$<ttype>$ = NULL_TREE; } extdef
312 | ASM_KEYWORD '(' expr ')' ';'
314 if ((TREE_CODE ($3) == ADDR_EXPR
315 && TREE_CODE (TREE_OPERAND ($3, 0)) == STRING_CST)
316 || TREE_CODE ($3) == STRING_CST)
319 error ("argument of `asm' is not a constant string"); }
321 { RESTORE_WARN_FLAGS ($1); }
325 setspecs notype_initdecls ';'
327 error ("ANSI C forbids data definition with no type or storage class");
328 else if (!flag_traditional)
329 warning ("data definition has no type or storage class");
331 current_declspecs = TREE_VALUE (declspec_stack);
332 prefix_attributes = TREE_PURPOSE (declspec_stack);
333 declspec_stack = TREE_CHAIN (declspec_stack);
334 resume_momentary ($1); }
335 | declmods setspecs notype_initdecls ';'
336 { current_declspecs = TREE_VALUE (declspec_stack);
337 prefix_attributes = TREE_PURPOSE (declspec_stack);
338 declspec_stack = TREE_CHAIN (declspec_stack);
339 resume_momentary ($2); }
340 | typed_declspecs setspecs initdecls ';'
341 { current_declspecs = TREE_VALUE (declspec_stack);
342 prefix_attributes = TREE_PURPOSE (declspec_stack);
343 declspec_stack = TREE_CHAIN (declspec_stack);
344 resume_momentary ($2); }
346 { pedwarn ("empty declaration"); }
347 | typed_declspecs ';'
353 pedwarn ("ANSI C does not allow extra `;' outside of a function"); }
357 typed_declspecs setspecs declarator
358 { if (! start_function (current_declspecs, $3,
359 prefix_attributes, NULL_TREE, 0))
361 reinit_parse_for_function (); }
363 { store_parm_decls (); }
365 { finish_function (0);
366 current_declspecs = TREE_VALUE (declspec_stack);
367 prefix_attributes = TREE_PURPOSE (declspec_stack);
368 declspec_stack = TREE_CHAIN (declspec_stack);
369 resume_momentary ($2); }
370 | typed_declspecs setspecs declarator error
371 { current_declspecs = TREE_VALUE (declspec_stack);
372 prefix_attributes = TREE_PURPOSE (declspec_stack);
373 declspec_stack = TREE_CHAIN (declspec_stack);
374 resume_momentary ($2); }
375 | declmods setspecs notype_declarator
376 { if (! start_function (current_declspecs, $3,
377 prefix_attributes, NULL_TREE, 0))
379 reinit_parse_for_function (); }
381 { store_parm_decls (); }
383 { finish_function (0);
384 current_declspecs = TREE_VALUE (declspec_stack);
385 prefix_attributes = TREE_PURPOSE (declspec_stack);
386 declspec_stack = TREE_CHAIN (declspec_stack);
387 resume_momentary ($2); }
388 | declmods setspecs notype_declarator error
389 { current_declspecs = TREE_VALUE (declspec_stack);
390 prefix_attributes = TREE_PURPOSE (declspec_stack);
391 declspec_stack = TREE_CHAIN (declspec_stack);
392 resume_momentary ($2); }
393 | setspecs notype_declarator
394 { if (! start_function (NULL_TREE, $2,
395 prefix_attributes, NULL_TREE, 0))
397 reinit_parse_for_function (); }
399 { store_parm_decls (); }
401 { finish_function (0);
402 current_declspecs = TREE_VALUE (declspec_stack);
403 prefix_attributes = TREE_PURPOSE (declspec_stack);
404 declspec_stack = TREE_CHAIN (declspec_stack);
405 resume_momentary ($1); }
406 | setspecs notype_declarator error
407 { current_declspecs = TREE_VALUE (declspec_stack);
408 prefix_attributes = TREE_PURPOSE (declspec_stack);
409 declspec_stack = TREE_CHAIN (declspec_stack);
410 resume_momentary ($1); }
425 { $$ = NEGATE_EXPR; }
427 { $$ = CONVERT_EXPR; }
429 { $$ = PREINCREMENT_EXPR; }
431 { $$ = PREDECREMENT_EXPR; }
433 { $$ = BIT_NOT_EXPR; }
435 { $$ = TRUTH_NOT_EXPR; }
438 expr: nonnull_exprlist
439 { $$ = build_compound_expr ($1); }
450 { $$ = build_tree_list (NULL_TREE, $1); }
451 | nonnull_exprlist ',' expr_no_commas
452 { chainon ($1, build_tree_list (NULL_TREE, $3)); }
457 | '*' cast_expr %prec UNARY
458 { $$ = build_indirect_ref ($2, "unary *"); }
459 /* __extension__ turns off -pedantic for following primary. */
460 | extension cast_expr %prec UNARY
462 RESTORE_WARN_FLAGS ($1); }
463 | unop cast_expr %prec UNARY
464 { $$ = build_unary_op ($1, $2, 0);
465 overflow_warning ($$); }
466 /* Refer to the address of a label as a pointer. */
468 { tree label = lookup_label ($2);
470 pedwarn ("ANSI C forbids `&&'");
472 $$ = null_pointer_node;
475 TREE_USED (label) = 1;
476 $$ = build1 (ADDR_EXPR, ptr_type_node, label);
477 TREE_CONSTANT ($$) = 1;
480 /* This seems to be impossible on some machines, so let's turn it off.
481 You can use __builtin_next_arg to find the anonymous stack args.
483 { tree types = TYPE_ARG_TYPES (TREE_TYPE (current_function_decl));
484 $$ = error_mark_node;
485 if (TREE_VALUE (tree_last (types)) == void_type_node)
486 error ("`&...' used in function with fixed number of arguments");
490 pedwarn ("ANSI C forbids `&...'");
491 $$ = tree_last (DECL_ARGUMENTS (current_function_decl));
492 $$ = build_unary_op (ADDR_EXPR, $$, 0);
495 | sizeof unary_expr %prec UNARY
497 if (TREE_CODE ($2) == COMPONENT_REF
498 && DECL_C_BIT_FIELD (TREE_OPERAND ($2, 1)))
499 error ("`sizeof' applied to a bit-field");
500 $$ = c_sizeof (TREE_TYPE ($2)); }
501 | sizeof '(' typename ')' %prec HYPERUNARY
503 $$ = c_sizeof (groktypename ($3)); }
504 | alignof unary_expr %prec UNARY
506 $$ = c_alignof_expr ($2); }
507 | alignof '(' typename ')' %prec HYPERUNARY
509 $$ = c_alignof (groktypename ($3)); }
510 | REALPART cast_expr %prec UNARY
511 { $$ = build_unary_op (REALPART_EXPR, $2, 0); }
512 | IMAGPART cast_expr %prec UNARY
513 { $$ = build_unary_op (IMAGPART_EXPR, $2, 0); }
517 SIZEOF { skip_evaluation++; }
521 ALIGNOF { skip_evaluation++; }
526 | '(' typename ')' cast_expr %prec UNARY
527 { tree type = groktypename ($2);
528 $$ = build_c_cast (type, $4); }
529 | '(' typename ')' '{'
530 { start_init (NULL_TREE, NULL, 0);
531 $2 = groktypename ($2);
532 really_start_incremental_init ($2); }
533 initlist_maybe_comma '}' %prec UNARY
535 tree result = pop_init_level (0);
539 if (pedantic && ! flag_isoc9x)
540 pedwarn ("ANSI C forbids constructor expressions");
541 if (TYPE_NAME (type) != 0)
543 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
544 name = IDENTIFIER_POINTER (TYPE_NAME (type));
546 name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
551 if (TREE_CODE (type) == ARRAY_TYPE && TYPE_SIZE (type) == 0)
553 int failure = complete_array_type (type, $$, 1);
562 | expr_no_commas '+' expr_no_commas
563 { $$ = parser_build_binary_op ($2, $1, $3); }
564 | expr_no_commas '-' expr_no_commas
565 { $$ = parser_build_binary_op ($2, $1, $3); }
566 | expr_no_commas '*' expr_no_commas
567 { $$ = parser_build_binary_op ($2, $1, $3); }
568 | expr_no_commas '/' expr_no_commas
569 { $$ = parser_build_binary_op ($2, $1, $3); }
570 | expr_no_commas '%' expr_no_commas
571 { $$ = parser_build_binary_op ($2, $1, $3); }
572 | expr_no_commas LSHIFT expr_no_commas
573 { $$ = parser_build_binary_op ($2, $1, $3); }
574 | expr_no_commas RSHIFT expr_no_commas
575 { $$ = parser_build_binary_op ($2, $1, $3); }
576 | expr_no_commas ARITHCOMPARE expr_no_commas
577 { $$ = parser_build_binary_op ($2, $1, $3); }
578 | expr_no_commas EQCOMPARE expr_no_commas
579 { $$ = parser_build_binary_op ($2, $1, $3); }
580 | expr_no_commas '&' expr_no_commas
581 { $$ = parser_build_binary_op ($2, $1, $3); }
582 | expr_no_commas '|' expr_no_commas
583 { $$ = parser_build_binary_op ($2, $1, $3); }
584 | expr_no_commas '^' expr_no_commas
585 { $$ = parser_build_binary_op ($2, $1, $3); }
586 | expr_no_commas ANDAND
587 { $1 = truthvalue_conversion (default_conversion ($1));
588 skip_evaluation += $1 == boolean_false_node; }
590 { skip_evaluation -= $1 == boolean_false_node;
591 $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $4); }
592 | expr_no_commas OROR
593 { $1 = truthvalue_conversion (default_conversion ($1));
594 skip_evaluation += $1 == boolean_true_node; }
596 { skip_evaluation -= $1 == boolean_true_node;
597 $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $4); }
599 { $1 = truthvalue_conversion (default_conversion ($1));
600 skip_evaluation += $1 == boolean_false_node; }
602 { skip_evaluation += (($1 == boolean_true_node)
603 - ($1 == boolean_false_node)); }
605 { skip_evaluation -= $1 == boolean_true_node;
606 $$ = build_conditional_expr ($1, $4, $7); }
609 pedwarn ("ANSI C forbids omitting the middle term of a ?: expression");
610 /* Make sure first operand is calculated only once. */
611 $<ttype>2 = save_expr ($1);
612 $1 = truthvalue_conversion (default_conversion ($<ttype>2));
613 skip_evaluation += $1 == boolean_true_node; }
615 { skip_evaluation -= $1 == boolean_true_node;
616 $$ = build_conditional_expr ($1, $<ttype>2, $5); }
617 | expr_no_commas '=' expr_no_commas
619 $$ = build_modify_expr ($1, NOP_EXPR, $3);
620 class = TREE_CODE_CLASS (TREE_CODE ($$));
621 if (class == 'e' || class == '1'
622 || class == '2' || class == '<')
623 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR);
625 | expr_no_commas ASSIGN expr_no_commas
627 $$ = build_modify_expr ($1, $2, $3);
628 /* This inhibits warnings in truthvalue_conversion. */
629 class = TREE_CODE_CLASS (TREE_CODE ($$));
630 if (class == 'e' || class == '1'
631 || class == '2' || class == '<')
632 C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK);
640 if (!$$ || $$ == error_mark_node)
642 if (yychar == YYEMPTY)
649 if (objc_receiver_context
650 && ! (objc_receiver_context
651 && strcmp (IDENTIFIER_POINTER ($1), "super")))
652 /* we have a message to super */
653 $$ = get_super_receiver ();
654 else if (objc_method_context
655 && (decl = is_ivar (objc_ivar_chain, $1)))
657 if (is_private (decl))
658 $$ = error_mark_node;
660 $$ = build_ivar_reference ($1);
665 /* Ordinary implicit function declaration. */
666 $$ = implicitly_declare ($1);
667 assemble_external ($$);
671 else if (current_function_decl == 0)
673 error ("`%s' undeclared here (not in a function)",
674 IDENTIFIER_POINTER ($1));
675 $$ = error_mark_node;
682 if (objc_receiver_context
683 && ! strcmp (IDENTIFIER_POINTER ($1), "super"))
684 /* we have a message to super */
685 $$ = get_super_receiver ();
686 else if (objc_method_context
687 && (decl = is_ivar (objc_ivar_chain, $1)))
689 if (is_private (decl))
690 $$ = error_mark_node;
692 $$ = build_ivar_reference ($1);
697 if (IDENTIFIER_GLOBAL_VALUE ($1) != error_mark_node
698 || IDENTIFIER_ERROR_LOCUS ($1) != current_function_decl)
700 error ("`%s' undeclared (first use in this function)",
701 IDENTIFIER_POINTER ($1));
703 if (! undeclared_variable_notice)
705 error ("(Each undeclared identifier is reported only once");
706 error ("for each function it appears in.)");
707 undeclared_variable_notice = 1;
710 $$ = error_mark_node;
711 /* Prevent repeated error messages. */
712 IDENTIFIER_GLOBAL_VALUE ($1) = error_mark_node;
713 IDENTIFIER_ERROR_LOCUS ($1) = current_function_decl;
717 else if (TREE_TYPE ($$) == error_mark_node)
718 $$ = error_mark_node;
719 else if (C_DECL_ANTICIPATED ($$))
721 /* The first time we see a build-in function used,
722 if it has not been declared. */
723 C_DECL_ANTICIPATED ($$) = 0;
724 if (yychar == YYEMPTY)
728 /* Omit the implicit declaration we
729 would ordinarily do, so we don't lose
730 the actual built in type.
731 But print a diagnostic for the mismatch. */
733 if (objc_method_context
734 && is_ivar (objc_ivar_chain, $1))
735 error ("Instance variable `%s' implicitly declared as function",
736 IDENTIFIER_POINTER (DECL_NAME ($$)));
739 if (TREE_CODE ($$) != FUNCTION_DECL)
740 error ("`%s' implicitly declared as function",
741 IDENTIFIER_POINTER (DECL_NAME ($$)));
742 else if ((TYPE_MODE (TREE_TYPE (TREE_TYPE ($$)))
743 != TYPE_MODE (integer_type_node))
744 && (TREE_TYPE (TREE_TYPE ($$))
746 pedwarn ("type mismatch in implicit declaration for built-in function `%s'",
747 IDENTIFIER_POINTER (DECL_NAME ($$)));
748 /* If it really returns void, change that to int. */
749 if (TREE_TYPE (TREE_TYPE ($$)) == void_type_node)
751 = build_function_type (integer_type_node,
752 TYPE_ARG_TYPES (TREE_TYPE ($$)));
755 pedwarn ("built-in function `%s' used without declaration",
756 IDENTIFIER_POINTER (DECL_NAME ($$)));
758 /* Do what we would ordinarily do when a fn is used. */
759 assemble_external ($$);
764 assemble_external ($$);
767 /* we have a definition - still check if iVariable */
769 if (!objc_receiver_context
770 || (objc_receiver_context
771 && strcmp (IDENTIFIER_POINTER ($1), "super")))
775 if (objc_method_context
776 && (decl = is_ivar (objc_ivar_chain, $1)))
778 if (IDENTIFIER_LOCAL_VALUE ($1))
779 warning ("local declaration of `%s' hides instance variable",
780 IDENTIFIER_POINTER ($1));
783 if (is_private (decl))
784 $$ = error_mark_node;
786 $$ = build_ivar_reference ($1);
790 else /* we have a message to super */
791 $$ = get_super_receiver ();
795 if (TREE_CODE ($$) == CONST_DECL)
797 $$ = DECL_INITIAL ($$);
798 /* This is to prevent an enum whose value is 0
799 from being considered a null pointer constant. */
800 $$ = build1 (NOP_EXPR, TREE_TYPE ($$), $$);
801 TREE_CONSTANT ($$) = 1;
806 { $$ = combine_strings ($1); }
808 { char class = TREE_CODE_CLASS (TREE_CODE ($2));
809 if (class == 'e' || class == '1'
810 || class == '2' || class == '<')
811 C_SET_EXP_ORIGINAL_CODE ($2, ERROR_MARK);
814 { $$ = error_mark_node; }
816 { if (current_function_decl == 0)
818 error ("braced-group within expression allowed only inside a function");
821 /* We must force a BLOCK for this level
822 so that, if it is not expanded later,
823 there is a way to turn off the entire subtree of blocks
824 that are contained in it. */
826 push_iterator_stack ();
828 $<ttype>$ = expand_start_stmt_expr (); }
832 pedwarn ("ANSI C forbids braced-groups within expressions");
833 pop_iterator_stack ();
835 rtl_exp = expand_end_stmt_expr ($<ttype>2);
836 /* The statements have side effects, so the group does. */
837 TREE_SIDE_EFFECTS (rtl_exp) = 1;
839 if (TREE_CODE ($3) == BLOCK)
841 /* Make a BIND_EXPR for the BLOCK already made. */
842 $$ = build (BIND_EXPR, TREE_TYPE (rtl_exp),
843 NULL_TREE, rtl_exp, $3);
844 /* Remove the block from the tree at this point.
845 It gets put back at the proper place
846 when the BIND_EXPR is expanded. */
852 | primary '(' exprlist ')' %prec '.'
853 { $$ = build_function_call ($1, $3); }
854 | primary '[' expr ']' %prec '.'
855 { $$ = build_array_ref ($1, $3); }
856 | primary '.' identifier
859 if (doing_objc_thang)
861 if (is_public ($1, $3))
862 $$ = build_component_ref ($1, $3);
864 $$ = error_mark_node;
868 $$ = build_component_ref ($1, $3);
870 | primary POINTSAT identifier
872 tree expr = build_indirect_ref ($1, "->");
875 if (doing_objc_thang)
877 if (is_public (expr, $3))
878 $$ = build_component_ref (expr, $3);
880 $$ = error_mark_node;
884 $$ = build_component_ref (expr, $3);
887 { $$ = build_unary_op (POSTINCREMENT_EXPR, $1, 0); }
889 { $$ = build_unary_op (POSTDECREMENT_EXPR, $1, 0); }
892 { $$ = build_message_expr ($1); }
894 { $$ = build_selector_expr ($1); }
896 { $$ = build_protocol_expr ($1); }
898 { $$ = build_encode_expr ($1); }
900 { $$ = build_objc_string_object ($1); }
904 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
908 { $$ = chainon ($1, $2); }
912 /* Produces an OBJC_STRING_CST with perhaps more OBJC_STRING_CSTs chained
916 | objc_string OBJC_STRING
917 { $$ = chainon ($1, $2); }
921 old_style_parm_decls:
925 /* ... is used here to indicate a varargs function. */
928 pedwarn ("ANSI C does not permit use of `varargs.h'"); }
931 /* The following are analogous to lineno_decl, decls and decl
932 except that they do not allow nested functions.
933 They are used for old-style parm decls. */
935 save_filename save_lineno datadecl
942 | datadecls lineno_datadecl
943 | lineno_datadecl errstmt
946 /* We don't allow prefix attributes here because they cause reduce/reduce
947 conflicts: we can't know whether we're parsing a function decl with
948 attribute suffix, or function defn with attribute prefix on first old
951 typed_declspecs_no_prefix_attr setspecs initdecls ';'
952 { current_declspecs = TREE_VALUE (declspec_stack);
953 prefix_attributes = TREE_PURPOSE (declspec_stack);
954 declspec_stack = TREE_CHAIN (declspec_stack);
955 resume_momentary ($2); }
956 | declmods_no_prefix_attr setspecs notype_initdecls ';'
957 { current_declspecs = TREE_VALUE (declspec_stack);
958 prefix_attributes = TREE_PURPOSE (declspec_stack);
959 declspec_stack = TREE_CHAIN (declspec_stack);
960 resume_momentary ($2); }
961 | typed_declspecs_no_prefix_attr ';'
962 { shadow_tag_warned ($1, 1);
963 pedwarn ("empty declaration"); }
964 | declmods_no_prefix_attr ';'
965 { pedwarn ("empty declaration"); }
968 /* This combination which saves a lineno before a decl
969 is the normal thing to use, rather than decl itself.
970 This is to avoid shift/reduce conflicts in contexts
971 where statement labels are allowed. */
973 save_filename save_lineno decl
981 | lineno_decl errstmt
984 /* records the type and storage class specs to use for processing
985 the declarators that follow.
986 Maintains a stack of outer-level values of current_declspecs,
987 for the sake of parm declarations nested in function declarators. */
988 setspecs: /* empty */
989 { $$ = suspend_momentary ();
990 pending_xref_error ();
991 declspec_stack = tree_cons (prefix_attributes,
994 split_specs_attrs ($<ttype>0,
995 ¤t_declspecs, &prefix_attributes); }
998 /* ??? Yuck. See after_type_declarator. */
999 setattrs: /* empty */
1000 { prefix_attributes = chainon (prefix_attributes, $<ttype>0); }
1004 typed_declspecs setspecs initdecls ';'
1005 { current_declspecs = TREE_VALUE (declspec_stack);
1006 prefix_attributes = TREE_PURPOSE (declspec_stack);
1007 declspec_stack = TREE_CHAIN (declspec_stack);
1008 resume_momentary ($2); }
1009 | declmods setspecs notype_initdecls ';'
1010 { current_declspecs = TREE_VALUE (declspec_stack);
1011 prefix_attributes = TREE_PURPOSE (declspec_stack);
1012 declspec_stack = TREE_CHAIN (declspec_stack);
1013 resume_momentary ($2); }
1014 | typed_declspecs setspecs nested_function
1015 { current_declspecs = TREE_VALUE (declspec_stack);
1016 prefix_attributes = TREE_PURPOSE (declspec_stack);
1017 declspec_stack = TREE_CHAIN (declspec_stack);
1018 resume_momentary ($2); }
1019 | declmods setspecs notype_nested_function
1020 { current_declspecs = TREE_VALUE (declspec_stack);
1021 prefix_attributes = TREE_PURPOSE (declspec_stack);
1022 declspec_stack = TREE_CHAIN (declspec_stack);
1023 resume_momentary ($2); }
1024 | typed_declspecs ';'
1025 { shadow_tag ($1); }
1027 { pedwarn ("empty declaration"); }
1029 { RESTORE_WARN_FLAGS ($1); }
1032 /* Declspecs which contain at least one type specifier or typedef name.
1033 (Just `const' or `volatile' is not enough.)
1034 A typedef'd name following these is taken as a name to be declared.
1035 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
1038 typespec reserved_declspecs
1039 { $$ = tree_cons (NULL_TREE, $1, $2); }
1040 | declmods typespec reserved_declspecs
1041 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
1044 reserved_declspecs: /* empty */
1046 | reserved_declspecs typespecqual_reserved
1047 { $$ = tree_cons (NULL_TREE, $2, $1); }
1048 | reserved_declspecs 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); }
1053 | reserved_declspecs attributes
1054 { $$ = tree_cons ($2, NULL_TREE, $1); }
1057 typed_declspecs_no_prefix_attr:
1058 typespec reserved_declspecs_no_prefix_attr
1059 { $$ = tree_cons (NULL_TREE, $1, $2); }
1060 | declmods_no_prefix_attr typespec reserved_declspecs_no_prefix_attr
1061 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
1064 reserved_declspecs_no_prefix_attr:
1067 | reserved_declspecs_no_prefix_attr typespecqual_reserved
1068 { $$ = tree_cons (NULL_TREE, $2, $1); }
1069 | reserved_declspecs_no_prefix_attr SCSPEC
1070 { if (extra_warnings)
1071 warning ("`%s' is not at beginning of declaration",
1072 IDENTIFIER_POINTER ($2));
1073 $$ = tree_cons (NULL_TREE, $2, $1); }
1076 /* List of just storage classes, type modifiers, and prefix attributes.
1077 A declaration can start with just this, but then it cannot be used
1078 to redeclare a typedef-name.
1079 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
1082 declmods_no_prefix_attr
1085 { $$ = tree_cons ($1, NULL_TREE, NULL_TREE); }
1086 | declmods declmods_no_prefix_attr
1087 { $$ = chainon ($2, $1); }
1088 | declmods attributes
1089 { $$ = tree_cons ($2, NULL_TREE, $1); }
1092 declmods_no_prefix_attr:
1094 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
1095 TREE_STATIC ($$) = 1; }
1097 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
1098 | declmods_no_prefix_attr TYPE_QUAL
1099 { $$ = tree_cons (NULL_TREE, $2, $1);
1100 TREE_STATIC ($$) = 1; }
1101 | declmods_no_prefix_attr SCSPEC
1102 { if (extra_warnings && TREE_STATIC ($1))
1103 warning ("`%s' is not at beginning of declaration",
1104 IDENTIFIER_POINTER ($2));
1105 $$ = tree_cons (NULL_TREE, $2, $1);
1106 TREE_STATIC ($$) = TREE_STATIC ($1); }
1110 /* Used instead of declspecs where storage classes are not allowed
1111 (that is, for typenames and structure components).
1112 Don't accept a typedef-name if anything but a modifier precedes it. */
1115 typespec reserved_typespecquals
1116 { $$ = tree_cons (NULL_TREE, $1, $2); }
1117 | nonempty_type_quals typespec reserved_typespecquals
1118 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
1121 reserved_typespecquals: /* empty */
1123 | reserved_typespecquals typespecqual_reserved
1124 { $$ = tree_cons (NULL_TREE, $2, $1); }
1127 /* A typespec (but not a type qualifier).
1128 Once we have seen one of these in a declaration,
1129 if a typedef name appears then it is being redeclared. */
1134 { /* For a typedef name, record the meaning, not the name.
1135 In case of `foo foo, bar;'. */
1136 $$ = lookup_name ($1); }
1138 | CLASSNAME protocolrefs
1139 { $$ = get_static_reference ($1, $2); }
1140 | OBJECTNAME protocolrefs
1141 { $$ = get_object_reference ($2); }
1143 /* Make "<SomeProtocol>" equivalent to "id <SomeProtocol>"
1144 - nisse@lysator.liu.se */
1145 | non_empty_protocolrefs
1146 { $$ = get_object_reference ($1); }
1148 | TYPEOF '(' expr ')'
1149 { $$ = TREE_TYPE ($3); }
1150 | TYPEOF '(' typename ')'
1151 { $$ = groktypename ($3); }
1154 /* A typespec that is a reserved word, or a type qualifier. */
1156 typespecqual_reserved: TYPESPEC
1163 | initdecls ',' initdcl
1168 | notype_initdecls ',' initdcl
1174 | ASM_KEYWORD '(' string ')'
1175 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
1181 declarator maybeasm maybe_attribute '='
1182 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1183 $3, prefix_attributes);
1184 start_init ($<ttype>$, $2, global_bindings_p ()); }
1186 /* Note how the declaration of the variable is in effect while its init is parsed! */
1188 finish_decl ($<ttype>5, $6, $2); }
1189 | declarator maybeasm maybe_attribute
1190 { tree d = start_decl ($1, current_declspecs, 0,
1191 $3, prefix_attributes);
1192 finish_decl (d, NULL_TREE, $2);
1197 notype_declarator maybeasm maybe_attribute '='
1198 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1199 $3, prefix_attributes);
1200 start_init ($<ttype>$, $2, global_bindings_p ()); }
1202 /* Note how the declaration of the variable is in effect while its init is parsed! */
1204 decl_attributes ($<ttype>5, $3, prefix_attributes);
1205 finish_decl ($<ttype>5, $6, $2); }
1206 | notype_declarator maybeasm maybe_attribute
1207 { tree d = start_decl ($1, current_declspecs, 0,
1208 $3, prefix_attributes);
1209 finish_decl (d, NULL_TREE, $2); }
1211 /* the * rules are dummies to accept the Apollo extended syntax
1212 so that the header files compile. */
1223 | attributes attribute
1224 { $$ = chainon ($1, $2); }
1228 ATTRIBUTE '(' '(' attribute_list ')' ')'
1235 | attribute_list ',' attrib
1236 { $$ = chainon ($1, $3); }
1243 { $$ = build_tree_list ($1, NULL_TREE); }
1244 | any_word '(' IDENTIFIER ')'
1245 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1246 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1247 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1248 | any_word '(' exprlist ')'
1249 { $$ = build_tree_list ($1, $3); }
1252 /* This still leaves out most reserved keywords,
1253 shouldn't we include them? */
1262 /* Initializers. `init' is the entry point. */
1267 { really_start_incremental_init (NULL_TREE);
1268 /* Note that the call to clear_momentary
1269 is in process_init_element. */
1270 push_momentary (); }
1271 initlist_maybe_comma '}'
1272 { $$ = pop_init_level (0);
1273 if ($$ == error_mark_node
1274 && ! (yychar == STRING || yychar == CONSTANT))
1277 pop_momentary_nofree (); }
1280 { $$ = error_mark_node; }
1283 /* `initlist_maybe_comma' is the guts of an initializer in braces. */
1284 initlist_maybe_comma:
1287 pedwarn ("ANSI C forbids empty initializer braces"); }
1288 | initlist1 maybecomma
1293 | initlist1 ',' initelt
1296 /* `initelt' is a single element of an initializer.
1297 It may use braces. */
1299 designator_list '=' initval
1300 | designator initval
1302 { set_init_label ($1); }
1309 { push_init_level (0); }
1310 initlist_maybe_comma '}'
1311 { process_init_element (pop_init_level (0)); }
1313 { process_init_element ($1); }
1319 | designator_list designator
1324 { set_init_label ($2); }
1325 /* These are for labeled elements. The syntax for an array element
1326 initializer conflicts with the syntax for an Objective-C message,
1327 so don't include these productions in the Objective-C grammar. */
1329 | '[' expr_no_commas ELLIPSIS expr_no_commas ']'
1330 { set_init_index ($2, $4); }
1331 | '[' expr_no_commas ']'
1332 { set_init_index ($2, NULL_TREE); }
1338 { push_c_function_context ();
1339 if (! start_function (current_declspecs, $1,
1340 prefix_attributes, NULL_TREE, 1))
1342 pop_c_function_context ();
1345 reinit_parse_for_function (); }
1346 old_style_parm_decls
1347 { store_parm_decls (); }
1348 /* This used to use compstmt_or_error.
1349 That caused a bug with input `f(g) int g {}',
1350 where the use of YYERROR1 above caused an error
1351 which then was handled by compstmt_or_error.
1352 There followed a repeated execution of that same rule,
1353 which called YYERROR1 again, and so on. */
1355 { finish_function (1);
1356 pop_c_function_context (); }
1359 notype_nested_function:
1361 { push_c_function_context ();
1362 if (! start_function (current_declspecs, $1,
1363 prefix_attributes, NULL_TREE, 1))
1365 pop_c_function_context ();
1368 reinit_parse_for_function (); }
1369 old_style_parm_decls
1370 { store_parm_decls (); }
1371 /* This used to use compstmt_or_error.
1372 That caused a bug with input `f(g) int g {}',
1373 where the use of YYERROR1 above caused an error
1374 which then was handled by compstmt_or_error.
1375 There followed a repeated execution of that same rule,
1376 which called YYERROR1 again, and so on. */
1378 { finish_function (1);
1379 pop_c_function_context (); }
1382 /* Any kind of declarator (thus, all declarators allowed
1383 after an explicit typespec). */
1386 after_type_declarator
1390 /* A declarator that is allowed only after an explicit typespec. */
1392 after_type_declarator:
1393 '(' after_type_declarator ')'
1395 | after_type_declarator '(' parmlist_or_identifiers %prec '.'
1396 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1397 /* | after_type_declarator '(' error ')' %prec '.'
1398 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1399 poplevel (0, 0, 0); } */
1400 | after_type_declarator '[' expr ']' %prec '.'
1401 { $$ = build_nt (ARRAY_REF, $1, $3); }
1402 | after_type_declarator '[' ']' %prec '.'
1403 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1404 | '*' type_quals after_type_declarator %prec UNARY
1405 { $$ = make_pointer_declarator ($2, $3); }
1406 /* ??? Yuck. setattrs is a quick hack. We can't use
1407 prefix_attributes because $1 only applies to this
1408 declarator. We assume setspecs has already been done.
1409 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1410 attributes could be recognized here or in `attributes'). */
1411 | attributes setattrs after_type_declarator
1419 /* Kinds of declarator that can appear in a parameter list
1420 in addition to notype_declarator. This is like after_type_declarator
1421 but does not allow a typedef name in parentheses as an identifier
1422 (because it would conflict with a function with that typedef as arg). */
1425 parm_declarator '(' parmlist_or_identifiers %prec '.'
1426 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1427 /* | parm_declarator '(' error ')' %prec '.'
1428 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1429 poplevel (0, 0, 0); } */
1431 | parm_declarator '[' '*' ']' %prec '.'
1432 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE);
1434 error ("`[*]' in parameter declaration only allowed in ISO C 9x");
1437 | parm_declarator '[' expr ']' %prec '.'
1438 { $$ = build_nt (ARRAY_REF, $1, $3); }
1439 | parm_declarator '[' ']' %prec '.'
1440 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1441 | '*' type_quals parm_declarator %prec UNARY
1442 { $$ = make_pointer_declarator ($2, $3); }
1443 /* ??? Yuck. setattrs is a quick hack. We can't use
1444 prefix_attributes because $1 only applies to this
1445 declarator. We assume setspecs has already been done.
1446 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1447 attributes could be recognized here or in `attributes'). */
1448 | attributes setattrs parm_declarator
1453 /* A declarator allowed whether or not there has been
1454 an explicit typespec. These cannot redeclare a typedef-name. */
1457 notype_declarator '(' parmlist_or_identifiers %prec '.'
1458 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1459 /* | notype_declarator '(' error ')' %prec '.'
1460 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1461 poplevel (0, 0, 0); } */
1462 | '(' notype_declarator ')'
1464 | '*' type_quals notype_declarator %prec UNARY
1465 { $$ = make_pointer_declarator ($2, $3); }
1467 | notype_declarator '[' '*' ']' %prec '.'
1468 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE);
1470 error ("`[*]' in parameter declaration only allowed in ISO C 9x");
1473 | notype_declarator '[' expr ']' %prec '.'
1474 { $$ = build_nt (ARRAY_REF, $1, $3); }
1475 | notype_declarator '[' ']' %prec '.'
1476 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1477 /* ??? Yuck. setattrs is a quick hack. We can't use
1478 prefix_attributes because $1 only applies to this
1479 declarator. We assume setspecs has already been done.
1480 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1481 attributes could be recognized here or in `attributes'). */
1482 | attributes setattrs notype_declarator
1509 struct_head identifier '{'
1510 { $$ = start_struct (RECORD_TYPE, $2);
1511 /* Start scope of tag before parsing components. */
1513 component_decl_list '}' maybe_attribute
1514 { $$ = finish_struct ($<ttype>4, $5, chainon ($1, $7)); }
1515 | struct_head '{' component_decl_list '}' maybe_attribute
1516 { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
1517 $3, chainon ($1, $5));
1519 | struct_head identifier
1520 { $$ = xref_tag (RECORD_TYPE, $2); }
1521 | union_head identifier '{'
1522 { $$ = start_struct (UNION_TYPE, $2); }
1523 component_decl_list '}' maybe_attribute
1524 { $$ = finish_struct ($<ttype>4, $5, chainon ($1, $7)); }
1525 | union_head '{' component_decl_list '}' maybe_attribute
1526 { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
1527 $3, chainon ($1, $5));
1529 | union_head identifier
1530 { $$ = xref_tag (UNION_TYPE, $2); }
1531 | enum_head identifier '{'
1532 { $<itype>3 = suspend_momentary ();
1533 $$ = start_enum ($2); }
1534 enumlist maybecomma_warn '}' maybe_attribute
1535 { $$= finish_enum ($<ttype>4, nreverse ($5), chainon ($1, $8));
1536 resume_momentary ($<itype>3); }
1538 { $<itype>2 = suspend_momentary ();
1539 $$ = start_enum (NULL_TREE); }
1540 enumlist maybecomma_warn '}' maybe_attribute
1541 { $$= finish_enum ($<ttype>3, nreverse ($4), chainon ($1, $7));
1542 resume_momentary ($<itype>2); }
1543 | enum_head identifier
1544 { $$ = xref_tag (ENUMERAL_TYPE, $2); }
1555 { if (pedantic && ! flag_isoc9x)
1556 pedwarn ("comma at end of enumerator list"); }
1559 component_decl_list:
1560 component_decl_list2
1562 | component_decl_list2 component_decl
1563 { $$ = chainon ($1, $2);
1564 pedwarn ("no semicolon at end of struct or union"); }
1567 component_decl_list2: /* empty */
1569 | component_decl_list2 component_decl ';'
1570 { $$ = chainon ($1, $2); }
1571 | component_decl_list2 ';'
1573 pedwarn ("extra semicolon in struct or union specified"); }
1575 /* foo(sizeof(struct{ @defs(ClassName)})); */
1576 | DEFS '(' CLASSNAME ')'
1578 tree interface = lookup_interface ($3);
1581 $$ = get_class_ivars (interface);
1584 error ("Cannot find interface declaration for `%s'",
1585 IDENTIFIER_POINTER ($3));
1592 /* There is a shift-reduce conflict here, because `components' may
1593 start with a `typename'. It happens that shifting (the default resolution)
1594 does the right thing, because it treats the `typename' as part of
1595 a `typed_typespecs'.
1597 It is possible that this same technique would allow the distinction
1598 between `notype_initdecls' and `initdecls' to be eliminated.
1599 But I am being cautious and not trying it. */
1602 typed_typespecs setspecs components
1604 current_declspecs = TREE_VALUE (declspec_stack);
1605 prefix_attributes = TREE_PURPOSE (declspec_stack);
1606 declspec_stack = TREE_CHAIN (declspec_stack);
1607 resume_momentary ($2); }
1610 pedwarn ("ANSI C forbids member declarations with no members");
1613 | nonempty_type_quals setspecs components
1615 current_declspecs = TREE_VALUE (declspec_stack);
1616 prefix_attributes = TREE_PURPOSE (declspec_stack);
1617 declspec_stack = TREE_CHAIN (declspec_stack);
1618 resume_momentary ($2); }
1619 | nonempty_type_quals
1621 pedwarn ("ANSI C forbids member declarations with no members");
1626 | extension component_decl
1628 RESTORE_WARN_FLAGS ($1); }
1632 component_declarator
1633 | components ',' component_declarator
1634 { $$ = chainon ($1, $3); }
1637 component_declarator:
1638 save_filename save_lineno declarator maybe_attribute
1639 { $$ = grokfield ($1, $2, $3, current_declspecs, NULL_TREE);
1640 decl_attributes ($$, $4, prefix_attributes); }
1641 | save_filename save_lineno
1642 declarator ':' expr_no_commas maybe_attribute
1643 { $$ = grokfield ($1, $2, $3, current_declspecs, $5);
1644 decl_attributes ($$, $6, prefix_attributes); }
1645 | save_filename save_lineno ':' expr_no_commas maybe_attribute
1646 { $$ = grokfield ($1, $2, NULL_TREE, current_declspecs, $4);
1647 decl_attributes ($$, $5, prefix_attributes); }
1650 /* We chain the enumerators in reverse order.
1651 They are put in forward order where enumlist is used.
1652 (The order used to be significant, but no longer is so.
1653 However, we still maintain the order, just to be clean.) */
1657 | enumlist ',' enumerator
1658 { if ($1 == error_mark_node)
1661 $$ = chainon ($3, $1); }
1663 { $$ = error_mark_node; }
1669 { $$ = build_enumerator ($1, NULL_TREE); }
1670 | identifier '=' expr_no_commas
1671 { $$ = build_enumerator ($1, $3); }
1675 typed_typespecs absdcl
1676 { $$ = build_tree_list ($1, $2); }
1677 | nonempty_type_quals absdcl
1678 { $$ = build_tree_list ($1, $2); }
1681 absdcl: /* an absolute declarator */
1687 nonempty_type_quals:
1689 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
1690 | nonempty_type_quals TYPE_QUAL
1691 { $$ = tree_cons (NULL_TREE, $2, $1); }
1697 | type_quals TYPE_QUAL
1698 { $$ = tree_cons (NULL_TREE, $2, $1); }
1701 absdcl1: /* a nonempty absolute declarator */
1704 /* `(typedef)1' is `int'. */
1705 | '*' type_quals absdcl1 %prec UNARY
1706 { $$ = make_pointer_declarator ($2, $3); }
1707 | '*' type_quals %prec UNARY
1708 { $$ = make_pointer_declarator ($2, NULL_TREE); }
1709 | absdcl1 '(' parmlist %prec '.'
1710 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1711 | absdcl1 '[' expr ']' %prec '.'
1712 { $$ = build_nt (ARRAY_REF, $1, $3); }
1713 | absdcl1 '[' ']' %prec '.'
1714 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1715 | '(' parmlist %prec '.'
1716 { $$ = build_nt (CALL_EXPR, NULL_TREE, $2, NULL_TREE); }
1717 | '[' expr ']' %prec '.'
1718 { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
1720 { $$ = build_nt (ARRAY_REF, NULL_TREE, NULL_TREE); }
1721 /* ??? It appears we have to support attributes here, however
1722 using prefix_attributes is wrong. */
1723 | attributes setattrs absdcl1
1727 /* at least one statement, the first of which parses without error. */
1728 /* stmts is used only after decls, so an invalid first statement
1729 is actually regarded as an invalid decl and part of the decls. */
1732 lineno_stmt_or_labels
1735 pedwarn ("ANSI C forbids label at end of compound statement");
1739 lineno_stmt_or_labels:
1740 lineno_stmt_or_label
1741 | lineno_stmt_or_labels lineno_stmt_or_label
1743 | lineno_stmt_or_labels errstmt
1755 pushlevel: /* empty */
1756 { emit_line_note (input_filename, lineno);
1760 expand_start_bindings (0);
1762 if (objc_method_context)
1768 /* Read zero or more forward-declarations for labels
1769 that nested functions can jump to. */
1774 pedwarn ("ANSI C forbids label declarations"); }
1779 | label_decls label_decl
1783 LABEL identifiers_or_typenames ';'
1785 for (link = $2; link; link = TREE_CHAIN (link))
1787 tree label = shadow_label (TREE_VALUE (link));
1788 C_DECLARED_LABEL_FLAG (label) = 1;
1789 declare_nonlocal_label (label);
1794 /* This is the body of a function definition.
1795 It causes syntax errors to ignore to the next openbrace. */
1802 compstmt_start: '{' { compstmt_count++; }
1804 compstmt: compstmt_start '}'
1805 { $$ = convert (void_type_node, integer_zero_node); }
1806 | compstmt_start pushlevel maybe_label_decls decls xstmts '}'
1807 { emit_line_note (input_filename, lineno);
1808 expand_end_bindings (getdecls (), 1, 0);
1809 $$ = poplevel (1, 1, 0);
1810 if (yychar == CONSTANT || yychar == STRING)
1811 pop_momentary_nofree ();
1814 | compstmt_start pushlevel maybe_label_decls error '}'
1815 { emit_line_note (input_filename, lineno);
1816 expand_end_bindings (getdecls (), kept_level_p (), 0);
1817 $$ = poplevel (kept_level_p (), 0, 0);
1818 if (yychar == CONSTANT || yychar == STRING)
1819 pop_momentary_nofree ();
1822 | compstmt_start pushlevel maybe_label_decls stmts '}'
1823 { emit_line_note (input_filename, lineno);
1824 expand_end_bindings (getdecls (), kept_level_p (), 0);
1825 $$ = poplevel (kept_level_p (), 0, 0);
1826 if (yychar == CONSTANT || yychar == STRING)
1827 pop_momentary_nofree ();
1832 /* Value is number of statements counted as of the closeparen. */
1834 if_prefix lineno_labeled_stmt
1835 /* Make sure c_expand_end_cond is run once
1836 for each call to c_expand_start_cond.
1837 Otherwise a crash is likely. */
1843 { emit_line_note ($<filename>-1, $<lineno>0);
1844 c_expand_start_cond (truthvalue_conversion ($3), 0,
1846 $<itype>$ = stmt_count;
1847 if_stmt_file = $<filename>-1;
1848 if_stmt_line = $<lineno>0;
1849 position_after_white_space (); }
1852 /* This is a subroutine of stmt.
1853 It is used twice, once for valid DO statements
1854 and once for catching errors in parsing the end test. */
1859 emit_line_note ($<filename>-1, $<lineno>0);
1860 /* See comment in `while' alternative, above. */
1862 expand_start_loop_continue_elsewhere (1);
1863 position_after_white_space (); }
1864 lineno_labeled_stmt WHILE
1865 { expand_loop_continue_here (); }
1869 { $$ = input_filename; }
1876 lineno_labeled_stmt:
1877 save_filename save_lineno stmt
1879 /* | save_filename save_lineno error
1882 | save_filename save_lineno label lineno_labeled_stmt
1886 lineno_stmt_or_label:
1887 save_filename save_lineno stmt_or_label
1898 /* Parse a single real statement, not including any labels. */
1905 emit_line_note ($<filename>-1, $<lineno>0);
1906 /* It appears that this should not be done--that a non-lvalue array
1907 shouldn't get an error if the value isn't used.
1908 Section 3.2.2.1 says that an array lvalue gets converted to a pointer
1909 if it appears as a top-level expression,
1910 but says nothing about non-lvalue arrays. */
1912 /* Call default_conversion to get an error
1913 on referring to a register array if pedantic. */
1914 if (TREE_CODE (TREE_TYPE ($1)) == ARRAY_TYPE
1915 || TREE_CODE (TREE_TYPE ($1)) == FUNCTION_TYPE)
1916 $1 = default_conversion ($1);
1918 iterator_expand ($1);
1919 clear_momentary (); }
1921 { c_expand_start_else ();
1922 $<itype>1 = stmt_count;
1923 position_after_white_space (); }
1925 { c_expand_end_cond ();
1926 if (extra_warnings && stmt_count == $<itype>1)
1927 warning ("empty body in an else-statement"); }
1928 | simple_if %prec IF
1929 { c_expand_end_cond ();
1930 /* This warning is here instead of in simple_if, because we
1931 do not want a warning if an empty if is followed by an
1932 else statement. Increment stmt_count so we don't
1933 give a second error if this is a nested `if'. */
1934 if (extra_warnings && stmt_count++ == $<itype>1)
1935 warning_with_file_and_line (if_stmt_file, if_stmt_line,
1936 "empty body in an if-statement"); }
1937 /* Make sure c_expand_end_cond is run once
1938 for each call to c_expand_start_cond.
1939 Otherwise a crash is likely. */
1940 | simple_if ELSE error
1941 { c_expand_end_cond (); }
1944 emit_line_note ($<filename>-1, $<lineno>0);
1945 /* The emit_nop used to come before emit_line_note,
1946 but that made the nop seem like part of the preceding line.
1947 And that was confusing when the preceding line was
1948 inside of an if statement and was not really executed.
1949 I think it ought to work to put the nop after the line number.
1950 We will see. --rms, July 15, 1991. */
1953 { /* Don't start the loop till we have succeeded
1954 in parsing the end test. This is to make sure
1955 that we end every loop we start. */
1956 expand_start_loop (1);
1957 emit_line_note (input_filename, lineno);
1958 expand_exit_loop_if_false (NULL_PTR,
1959 truthvalue_conversion ($4));
1960 position_after_white_space (); }
1962 { expand_end_loop (); }
1965 { emit_line_note (input_filename, lineno);
1966 expand_exit_loop_if_false (NULL_PTR,
1967 truthvalue_conversion ($3));
1969 clear_momentary (); }
1970 /* This rule is needed to make sure we end every loop we start. */
1971 | do_stmt_start error
1972 { expand_end_loop ();
1973 clear_momentary (); }
1977 emit_line_note ($<filename>-1, $<lineno>0);
1978 /* See comment in `while' alternative, above. */
1980 if ($3) c_expand_expr_stmt ($3);
1981 /* Next step is to call expand_start_loop_continue_elsewhere,
1982 but wait till after we parse the entire for (...).
1983 Otherwise, invalid input might cause us to call that
1984 fn without calling expand_end_loop. */
1987 /* Can't emit now; wait till after expand_start_loop... */
1988 { $<lineno>7 = lineno;
1989 $<filename>$ = input_filename; }
1992 /* Start the loop. Doing this after parsing
1993 all the expressions ensures we will end the loop. */
1994 expand_start_loop_continue_elsewhere (1);
1995 /* Emit the end-test, with a line number. */
1996 emit_line_note ($<filename>8, $<lineno>7);
1998 expand_exit_loop_if_false (NULL_PTR,
1999 truthvalue_conversion ($6));
2000 /* Don't let the tree nodes for $9 be discarded by
2001 clear_momentary during the parsing of the next stmt. */
2003 $<lineno>7 = lineno;
2004 $<filename>8 = input_filename;
2005 position_after_white_space (); }
2007 { /* Emit the increment expression, with a line number. */
2008 emit_line_note ($<filename>8, $<lineno>7);
2009 expand_loop_continue_here ();
2011 c_expand_expr_stmt ($9);
2012 if (yychar == CONSTANT || yychar == STRING)
2013 pop_momentary_nofree ();
2016 expand_end_loop (); }
2017 | SWITCH '(' expr ')'
2019 emit_line_note ($<filename>-1, $<lineno>0);
2020 c_expand_start_case ($3);
2021 /* Don't let the tree nodes for $3 be discarded by
2022 clear_momentary during the parsing of the next stmt. */
2024 position_after_white_space (); }
2026 { expand_end_case ($3);
2027 if (yychar == CONSTANT || yychar == STRING)
2028 pop_momentary_nofree ();
2033 emit_line_note ($<filename>-1, $<lineno>0);
2034 if ( ! expand_exit_something ())
2035 error ("break statement not within loop or switch"); }
2038 emit_line_note ($<filename>-1, $<lineno>0);
2039 if (! expand_continue_loop (NULL_PTR))
2040 error ("continue statement not within a loop"); }
2043 emit_line_note ($<filename>-1, $<lineno>0);
2044 c_expand_return (NULL_TREE); }
2047 emit_line_note ($<filename>-1, $<lineno>0);
2048 c_expand_return ($2); }
2049 | ASM_KEYWORD maybe_type_qual '(' expr ')' ';'
2051 emit_line_note ($<filename>-1, $<lineno>0);
2053 if ((TREE_CODE ($4) == ADDR_EXPR
2054 && TREE_CODE (TREE_OPERAND ($4, 0)) == STRING_CST)
2055 || TREE_CODE ($4) == STRING_CST)
2058 error ("argument of `asm' is not a constant string"); }
2059 /* This is the case with just output operands. */
2060 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ')' ';'
2062 emit_line_note ($<filename>-1, $<lineno>0);
2063 c_expand_asm_operands ($4, $6, NULL_TREE, NULL_TREE,
2064 $2 == ridpointers[(int)RID_VOLATILE],
2065 input_filename, lineno); }
2066 /* This is the case with input operands as well. */
2067 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':' asm_operands ')' ';'
2069 emit_line_note ($<filename>-1, $<lineno>0);
2070 c_expand_asm_operands ($4, $6, $8, NULL_TREE,
2071 $2 == ridpointers[(int)RID_VOLATILE],
2072 input_filename, lineno); }
2073 /* This is the case with clobbered registers as well. */
2074 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':'
2075 asm_operands ':' asm_clobbers ')' ';'
2077 emit_line_note ($<filename>-1, $<lineno>0);
2078 c_expand_asm_operands ($4, $6, $8, $10,
2079 $2 == ridpointers[(int)RID_VOLATILE],
2080 input_filename, lineno); }
2081 | GOTO identifier ';'
2084 emit_line_note ($<filename>-1, $<lineno>0);
2085 decl = lookup_label ($2);
2088 TREE_USED (decl) = 1;
2094 pedwarn ("ANSI C forbids `goto *expr;'");
2096 emit_line_note ($<filename>-1, $<lineno>0);
2097 expand_computed_goto (convert (ptr_type_node, $3)); }
2102 all_iter_stmt_simple
2103 /* | all_iter_stmt_with_decl */
2106 all_iter_stmt_simple:
2109 /* The value returned by this action is */
2110 /* 1 if everything is OK */
2111 /* 0 in case of error or already bound iterator */
2114 if (TREE_CODE ($3) != VAR_DECL)
2115 error ("invalid `for (ITERATOR)' syntax");
2116 else if (! ITERATOR_P ($3))
2117 error ("`%s' is not an iterator",
2118 IDENTIFIER_POINTER (DECL_NAME ($3)));
2119 else if (ITERATOR_BOUND_P ($3))
2120 error ("`for (%s)' inside expansion of same iterator",
2121 IDENTIFIER_POINTER (DECL_NAME ($3)));
2125 iterator_for_loop_start ($3);
2131 iterator_for_loop_end ($3);
2134 /* This really should allow any kind of declaration,
2135 for generality. Fix it before turning it back on.
2137 all_iter_stmt_with_decl:
2138 FOR '(' ITERATOR pushlevel setspecs iterator_spec ')'
2140 */ /* The value returned by this action is */
2141 /* 1 if everything is OK */
2142 /* 0 in case of error or already bound iterator */
2144 iterator_for_loop_start ($6);
2148 iterator_for_loop_end ($6);
2149 emit_line_note (input_filename, lineno);
2150 expand_end_bindings (getdecls (), 1, 0);
2151 $<ttype>$ = poplevel (1, 1, 0);
2152 if (yychar == CONSTANT || yychar == STRING)
2153 pop_momentary_nofree ();
2159 /* Any kind of label, including jump labels and case labels.
2160 ANSI C accepts labels only before statements, but we allow them
2161 also at the end of a compound statement. */
2163 label: CASE expr_no_commas ':'
2164 { register tree value = check_case_value ($2);
2166 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
2170 if (value != error_mark_node)
2175 if (pedantic && ! INTEGRAL_TYPE_P (TREE_TYPE (value)))
2176 pedwarn ("label must have integral type in ANSI C");
2178 success = pushcase (value, convert_and_check,
2182 error ("case label not within a switch statement");
2183 else if (success == 2)
2185 error ("duplicate case value");
2186 error_with_decl (duplicate, "this is the first entry for that value");
2188 else if (success == 3)
2189 warning ("case value out of range");
2190 else if (success == 5)
2191 error ("case label within scope of cleanup or variable array");
2193 position_after_white_space (); }
2194 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
2195 { register tree value1 = check_case_value ($2);
2196 register tree value2 = check_case_value ($4);
2198 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
2201 pedwarn ("ANSI C forbids case ranges");
2204 if (value1 != error_mark_node && value2 != error_mark_node)
2207 int success = pushcase_range (value1, value2,
2208 convert_and_check, label,
2211 error ("case label not within a switch statement");
2212 else if (success == 2)
2214 error ("duplicate case value");
2215 error_with_decl (duplicate, "this is the first entry for that value");
2217 else if (success == 3)
2218 warning ("case value out of range");
2219 else if (success == 4)
2220 warning ("empty case range");
2221 else if (success == 5)
2222 error ("case label within scope of cleanup or variable array");
2224 position_after_white_space (); }
2229 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
2230 int success = pushcase (NULL_TREE, 0, label, &duplicate);
2233 error ("default label not within a switch statement");
2234 else if (success == 2)
2236 error ("multiple default labels in one switch");
2237 error_with_decl (duplicate, "this is the first default label");
2239 position_after_white_space (); }
2240 | identifier ':' maybe_attribute
2241 { tree label = define_label (input_filename, lineno, $1);
2246 expand_label (label);
2247 decl_attributes (label, $3, NULL_TREE);
2249 position_after_white_space (); }
2252 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
2256 { emit_line_note (input_filename, lineno);
2259 { emit_line_note (input_filename, lineno); }
2268 /* These are the operands other than the first string and colon
2269 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
2270 asm_operands: /* empty */
2272 | nonnull_asm_operands
2275 nonnull_asm_operands:
2277 | nonnull_asm_operands ',' asm_operand
2278 { $$ = chainon ($1, $3); }
2283 { $$ = build_tree_list ($1, $3); }
2288 { $$ = tree_cons (NULL_TREE, combine_strings ($1), NULL_TREE); }
2289 | asm_clobbers ',' string
2290 { $$ = tree_cons (NULL_TREE, combine_strings ($3), $1); }
2293 /* This is what appears inside the parens in a function declarator.
2294 Its value is a list of ..._TYPE nodes. */
2297 clear_parm_order ();
2298 declare_parm_level (0); }
2301 parmlist_tags_warning ();
2302 poplevel (0, 0, 0); }
2310 pedwarn ("ANSI C forbids forward parameter declarations");
2311 /* Mark the forward decls as such. */
2312 for (parm = getdecls (); parm; parm = TREE_CHAIN (parm))
2313 TREE_ASM_WRITTEN (parm) = 1;
2314 clear_parm_order (); }
2318 { $$ = tree_cons (NULL_TREE, NULL_TREE, NULL_TREE); }
2321 /* This is what appears inside the parens in a function declarator.
2322 Is value is represented in the format that grokdeclarator expects. */
2323 parmlist_2: /* empty */
2324 { $$ = get_parm_info (0); }
2326 { $$ = get_parm_info (0);
2327 /* Gcc used to allow this as an extension. However, it does
2328 not work for all targets, and thus has been disabled.
2329 Also, since func (...) and func () are indistinguishable,
2330 it caused problems with the code in expand_builtin which
2331 tries to verify that BUILT_IN_NEXT_ARG is being used
2333 error ("ANSI C requires a named argument before `...'");
2336 { $$ = get_parm_info (1); }
2337 | parms ',' ELLIPSIS
2338 { $$ = get_parm_info (0); }
2343 { push_parm_decl ($1); }
2345 { push_parm_decl ($3); }
2348 /* A single parameter declaration or parameter type name,
2349 as found in a parmlist. */
2351 typed_declspecs setspecs parm_declarator maybe_attribute
2352 { $$ = build_tree_list (build_tree_list (current_declspecs,
2354 build_tree_list (prefix_attributes,
2356 current_declspecs = TREE_VALUE (declspec_stack);
2357 prefix_attributes = TREE_PURPOSE (declspec_stack);
2358 declspec_stack = TREE_CHAIN (declspec_stack);
2359 resume_momentary ($2); }
2360 | typed_declspecs setspecs notype_declarator maybe_attribute
2361 { $$ = build_tree_list (build_tree_list (current_declspecs,
2363 build_tree_list (prefix_attributes,
2365 current_declspecs = TREE_VALUE (declspec_stack);
2366 prefix_attributes = TREE_PURPOSE (declspec_stack);
2367 declspec_stack = TREE_CHAIN (declspec_stack);
2368 resume_momentary ($2); }
2369 | typed_declspecs setspecs absdcl maybe_attribute
2370 { $$ = build_tree_list (build_tree_list (current_declspecs,
2372 build_tree_list (prefix_attributes,
2374 current_declspecs = TREE_VALUE (declspec_stack);
2375 prefix_attributes = TREE_PURPOSE (declspec_stack);
2376 declspec_stack = TREE_CHAIN (declspec_stack);
2377 resume_momentary ($2); }
2378 | declmods setspecs notype_declarator maybe_attribute
2379 { $$ = build_tree_list (build_tree_list (current_declspecs,
2381 build_tree_list (prefix_attributes,
2383 current_declspecs = TREE_VALUE (declspec_stack);
2384 prefix_attributes = TREE_PURPOSE (declspec_stack);
2385 declspec_stack = TREE_CHAIN (declspec_stack);
2386 resume_momentary ($2); }
2388 | declmods setspecs absdcl maybe_attribute
2389 { $$ = build_tree_list (build_tree_list (current_declspecs,
2391 build_tree_list (prefix_attributes,
2393 current_declspecs = TREE_VALUE (declspec_stack);
2394 prefix_attributes = TREE_PURPOSE (declspec_stack);
2395 declspec_stack = TREE_CHAIN (declspec_stack);
2396 resume_momentary ($2); }
2399 /* This is used in a function definition
2400 where either a parmlist or an identifier list is ok.
2401 Its value is a list of ..._TYPE nodes or a list of identifiers. */
2402 parmlist_or_identifiers:
2404 clear_parm_order ();
2405 declare_parm_level (1); }
2406 parmlist_or_identifiers_1
2408 parmlist_tags_warning ();
2409 poplevel (0, 0, 0); }
2412 parmlist_or_identifiers_1:
2416 for (t = $1; t; t = TREE_CHAIN (t))
2417 if (TREE_VALUE (t) == NULL_TREE)
2418 error ("`...' in old-style identifier list");
2419 $$ = tree_cons (NULL_TREE, NULL_TREE, $1); }
2422 /* A nonempty list of identifiers. */
2425 { $$ = build_tree_list (NULL_TREE, $1); }
2426 | identifiers ',' IDENTIFIER
2427 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2430 /* A nonempty list of identifiers, including typenames. */
2431 identifiers_or_typenames:
2433 { $$ = build_tree_list (NULL_TREE, $1); }
2434 | identifiers_or_typenames ',' identifier
2435 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2440 { $$ = SAVE_WARN_FLAGS();
2442 warn_pointer_arith = 0; }
2446 /* Objective-C productions. */
2456 if (objc_implementation_context)
2458 finish_class (objc_implementation_context);
2459 objc_ivar_chain = NULL_TREE;
2460 objc_implementation_context = NULL_TREE;
2463 warning ("`@end' must appear in an implementation context");
2467 /* A nonempty list of identifiers. */
2470 { $$ = build_tree_list (NULL_TREE, $1); }
2471 | identifier_list ',' identifier
2472 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2476 CLASS identifier_list ';'
2478 objc_declare_class ($2);
2482 ALIAS identifier identifier ';'
2484 objc_declare_alias ($2, $3);
2488 INTERFACE identifier protocolrefs '{'
2490 objc_interface_context = objc_ivar_context
2491 = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, $3);
2492 objc_public_flag = 0;
2496 continue_class (objc_interface_context);
2501 finish_class (objc_interface_context);
2502 objc_interface_context = NULL_TREE;
2505 | INTERFACE identifier protocolrefs
2507 objc_interface_context
2508 = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, $3);
2509 continue_class (objc_interface_context);
2514 finish_class (objc_interface_context);
2515 objc_interface_context = NULL_TREE;
2518 | INTERFACE identifier ':' identifier protocolrefs '{'
2520 objc_interface_context = objc_ivar_context
2521 = start_class (CLASS_INTERFACE_TYPE, $2, $4, $5);
2522 objc_public_flag = 0;
2526 continue_class (objc_interface_context);
2531 finish_class (objc_interface_context);
2532 objc_interface_context = NULL_TREE;
2535 | INTERFACE identifier ':' identifier protocolrefs
2537 objc_interface_context
2538 = start_class (CLASS_INTERFACE_TYPE, $2, $4, $5);
2539 continue_class (objc_interface_context);
2544 finish_class (objc_interface_context);
2545 objc_interface_context = NULL_TREE;
2548 | IMPLEMENTATION identifier '{'
2550 objc_implementation_context = objc_ivar_context
2551 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, NULL_TREE, NULL_TREE);
2552 objc_public_flag = 0;
2557 = continue_class (objc_implementation_context);
2560 | IMPLEMENTATION identifier
2562 objc_implementation_context
2563 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, NULL_TREE, NULL_TREE);
2565 = continue_class (objc_implementation_context);
2568 | IMPLEMENTATION identifier ':' identifier '{'
2570 objc_implementation_context = objc_ivar_context
2571 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2572 objc_public_flag = 0;
2577 = continue_class (objc_implementation_context);
2580 | IMPLEMENTATION identifier ':' identifier
2582 objc_implementation_context
2583 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2585 = continue_class (objc_implementation_context);
2588 | INTERFACE identifier '(' identifier ')' protocolrefs
2590 objc_interface_context
2591 = start_class (CATEGORY_INTERFACE_TYPE, $2, $4, $6);
2592 continue_class (objc_interface_context);
2597 finish_class (objc_interface_context);
2598 objc_interface_context = NULL_TREE;
2601 | IMPLEMENTATION identifier '(' identifier ')'
2603 objc_implementation_context
2604 = start_class (CATEGORY_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2606 = continue_class (objc_implementation_context);
2611 PROTOCOL identifier protocolrefs
2613 remember_protocol_qualifiers ();
2614 objc_interface_context
2615 = start_protocol(PROTOCOL_INTERFACE_TYPE, $2, $3);
2619 forget_protocol_qualifiers();
2620 finish_protocol(objc_interface_context);
2621 objc_interface_context = NULL_TREE;
2630 | non_empty_protocolrefs
2633 non_empty_protocolrefs:
2634 ARITHCOMPARE identifier_list ARITHCOMPARE
2636 if ($1 == LT_EXPR && $3 == GT_EXPR)
2644 ivar_decl_list visibility_spec ivar_decls
2649 PRIVATE { objc_public_flag = 2; }
2650 | PROTECTED { objc_public_flag = 0; }
2651 | PUBLIC { objc_public_flag = 1; }
2659 | ivar_decls ivar_decl ';'
2663 pedwarn ("extra semicolon in struct or union specified");
2668 /* There is a shift-reduce conflict here, because `components' may
2669 start with a `typename'. It happens that shifting (the default resolution)
2670 does the right thing, because it treats the `typename' as part of
2671 a `typed_typespecs'.
2673 It is possible that this same technique would allow the distinction
2674 between `notype_initdecls' and `initdecls' to be eliminated.
2675 But I am being cautious and not trying it. */
2678 typed_typespecs setspecs ivars
2680 current_declspecs = TREE_VALUE (declspec_stack);
2681 prefix_attributes = TREE_PURPOSE (declspec_stack);
2682 declspec_stack = TREE_CHAIN (declspec_stack);
2683 resume_momentary ($2); }
2684 | nonempty_type_quals setspecs ivars
2686 current_declspecs = TREE_VALUE (declspec_stack);
2687 prefix_attributes = TREE_PURPOSE (declspec_stack);
2688 declspec_stack = TREE_CHAIN (declspec_stack);
2689 resume_momentary ($2); }
2698 | ivars ',' ivar_declarator
2704 $$ = add_instance_variable (objc_ivar_context,
2706 $1, current_declspecs,
2709 | declarator ':' expr_no_commas
2711 $$ = add_instance_variable (objc_ivar_context,
2713 $1, current_declspecs, $3);
2715 | ':' expr_no_commas
2717 $$ = add_instance_variable (objc_ivar_context,
2720 current_declspecs, $2);
2727 remember_protocol_qualifiers ();
2728 if (objc_implementation_context)
2729 objc_inherit_code = CLASS_METHOD_DECL;
2731 fatal ("method definition not in class context");
2735 forget_protocol_qualifiers ();
2736 add_class_method (objc_implementation_context, $3);
2737 start_method_def ($3);
2738 objc_method_context = $3;
2742 continue_method_def ();
2746 finish_method_def ();
2747 objc_method_context = NULL_TREE;
2752 remember_protocol_qualifiers ();
2753 if (objc_implementation_context)
2754 objc_inherit_code = INSTANCE_METHOD_DECL;
2756 fatal ("method definition not in class context");
2760 forget_protocol_qualifiers ();
2761 add_instance_method (objc_implementation_context, $3);
2762 start_method_def ($3);
2763 objc_method_context = $3;
2767 continue_method_def ();
2771 finish_method_def ();
2772 objc_method_context = NULL_TREE;
2776 /* the reason for the strange actions in this rule
2777 is so that notype_initdecls when reached via datadef
2778 can find a valid list of type and sc specs in $0. */
2782 | {$<ttype>$ = NULL_TREE; } methodprotolist2
2785 methodprotolist2: /* eliminates a shift/reduce conflict */
2788 | methodprotolist2 methodproto
2789 | methodprotolist2 {$<ttype>$ = NULL_TREE; } datadef
2800 /* Remember protocol qualifiers in prototypes. */
2801 remember_protocol_qualifiers ();
2802 objc_inherit_code = CLASS_METHOD_DECL;
2806 /* Forget protocol qualifiers here. */
2807 forget_protocol_qualifiers ();
2808 add_class_method (objc_interface_context, $3);
2814 /* Remember protocol qualifiers in prototypes. */
2815 remember_protocol_qualifiers ();
2816 objc_inherit_code = INSTANCE_METHOD_DECL;
2820 /* Forget protocol qualifiers here. */
2821 forget_protocol_qualifiers ();
2822 add_instance_method (objc_interface_context, $3);
2828 '(' typename ')' unaryselector
2830 $$ = build_method_decl (objc_inherit_code, $2, $4, NULL_TREE);
2835 $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, NULL_TREE);
2838 | '(' typename ')' keywordselector optparmlist
2840 $$ = build_method_decl (objc_inherit_code, $2, $4, $5);
2843 | keywordselector optparmlist
2845 $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, $2);
2849 /* "optarglist" assumes that start_method_def has already been called...
2850 if it is not, the "xdecls" will not be placed in the proper scope */
2857 /* to get around the following situation: "int foo (int a) int b; {}" that
2858 is synthesized when parsing "- a:a b:b; id c; id d; { ... }" */
2873 typed_declspecs setspecs myparms ';'
2874 { current_declspecs = TREE_VALUE (declspec_stack);
2875 prefix_attributes = TREE_PURPOSE (declspec_stack);
2876 declspec_stack = TREE_CHAIN (declspec_stack);
2877 resume_momentary ($2); }
2878 | typed_declspecs ';'
2879 { shadow_tag ($1); }
2881 { pedwarn ("empty declaration"); }
2886 { push_parm_decl ($1); }
2887 | myparms ',' myparm
2888 { push_parm_decl ($3); }
2891 /* A single parameter declaration or parameter type name,
2892 as found in a parmlist. DOES NOT ALLOW AN INITIALIZER OR ASMSPEC */
2895 parm_declarator maybe_attribute
2896 { $$ = build_tree_list (build_tree_list (current_declspecs,
2898 build_tree_list (prefix_attributes,
2900 | notype_declarator maybe_attribute
2901 { $$ = build_tree_list (build_tree_list (current_declspecs,
2903 build_tree_list (prefix_attributes,
2905 | absdcl maybe_attribute
2906 { $$ = build_tree_list (build_tree_list (current_declspecs,
2908 build_tree_list (prefix_attributes,
2919 /* oh what a kludge! */
2928 /* returns a tree list node generated by get_parm_info */
2941 | keywordselector keyworddecl
2943 $$ = chainon ($1, $2);
2955 ENUM { $$ = get_identifier (token_buffer); }
2956 | STRUCT { $$ = get_identifier (token_buffer); }
2957 | UNION { $$ = get_identifier (token_buffer); }
2958 | IF { $$ = get_identifier (token_buffer); }
2959 | ELSE { $$ = get_identifier (token_buffer); }
2960 | WHILE { $$ = get_identifier (token_buffer); }
2961 | DO { $$ = get_identifier (token_buffer); }
2962 | FOR { $$ = get_identifier (token_buffer); }
2963 | SWITCH { $$ = get_identifier (token_buffer); }
2964 | CASE { $$ = get_identifier (token_buffer); }
2965 | DEFAULT { $$ = get_identifier (token_buffer); }
2966 | BREAK { $$ = get_identifier (token_buffer); }
2967 | CONTINUE { $$ = get_identifier (token_buffer); }
2968 | RETURN { $$ = get_identifier (token_buffer); }
2969 | GOTO { $$ = get_identifier (token_buffer); }
2970 | ASM_KEYWORD { $$ = get_identifier (token_buffer); }
2971 | SIZEOF { $$ = get_identifier (token_buffer); }
2972 | TYPEOF { $$ = get_identifier (token_buffer); }
2973 | ALIGNOF { $$ = get_identifier (token_buffer); }
2974 | TYPESPEC | TYPE_QUAL
2978 selector ':' '(' typename ')' identifier
2980 $$ = build_keyword_decl ($1, $4, $6);
2983 | selector ':' identifier
2985 $$ = build_keyword_decl ($1, NULL_TREE, $3);
2988 | ':' '(' typename ')' identifier
2990 $$ = build_keyword_decl (NULL_TREE, $3, $5);
2995 $$ = build_keyword_decl (NULL_TREE, NULL_TREE, $2);
3006 | keywordarglist keywordarg
3008 $$ = chainon ($1, $2);
3016 if (TREE_CHAIN ($1) == NULL_TREE)
3017 /* just return the expr., remove a level of indirection */
3018 $$ = TREE_VALUE ($1);
3020 /* we have a comma expr., we will collapse later */
3026 selector ':' keywordexpr
3028 $$ = build_tree_list ($1, $3);
3032 $$ = build_tree_list (NULL_TREE, $2);
3040 $$ = get_class_reference ($1);
3046 { objc_receiver_context = 1; }
3048 { objc_receiver_context = 0; }
3051 $$ = build_tree_list ($3, $5);
3062 | keywordnamelist keywordname
3064 $$ = chainon ($1, $2);
3071 $$ = build_tree_list ($1, NULL_TREE);
3075 $$ = build_tree_list (NULL_TREE, NULL_TREE);
3080 SELECTOR '(' selectorarg ')'
3087 PROTOCOL '(' identifier ')'
3093 /* extension to support C-structures in the archiver */
3096 ENCODE '(' typename ')'
3098 $$ = groktypename ($3);