1 /*WARNING: This file is automatically generated!*/
2 /* YACC parser for C syntax and for Objective C. -*-c-*-
3 Copyright (C) 1987, 88, 89, 92-98, 1999 Free Software Foundation, Inc.
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
22 /* This file defines the grammar of C and that of Objective C.
23 ifobjc ... end ifobjc conditionals contain code for Objective C only.
24 ifc ... end ifc conditionals contain code for C only.
25 Sed commands in Makefile.in are used to convert this file into
26 c-parse.y and into objc-parse.y. */
28 /* To whomever it may concern: I have heard that such a thing was once
29 written by AT&T, but I have never seen it. */
45 #ifdef MULTIBYTE_CHARS
51 /* Since parsers are distinct for each language, put the language string
53 const char * const language_string = "GNU Obj-C";
55 /* Like YYERROR but do call yyerror. */
56 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
58 /* Cause the `yydebug' variable to be defined. */
64 %union {long itype; tree ttype; enum tree_code code;
65 char *filename; int lineno; int ends_in_label; }
67 /* All identifiers that are not reserved words
68 and are not declared typedefs in the current block */
71 /* All identifiers that are declared typedefs in the current block.
72 In some contexts, they are treated just like IDENTIFIER,
73 but they can also serve as typespecs in declarations. */
76 /* Reserved words that specify storage class.
77 yylval contains an IDENTIFIER_NODE which indicates which one. */
80 /* Reserved words that specify type.
81 yylval contains an IDENTIFIER_NODE which indicates which one. */
84 /* Reserved words that qualify type: "const", "volatile", or "restrict".
85 yylval contains an IDENTIFIER_NODE which indicates which one. */
88 /* Character or numeric constants.
89 yylval is the node for the constant. */
92 /* String constants in raw form.
93 yylval is a STRING_CST node. */
96 /* "...", used for functions with variable arglists. */
99 /* the reserved words */
100 /* SCO include files test "ASM", so use something else. */
101 %token SIZEOF ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
102 %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD TYPEOF ALIGNOF
103 %token ATTRIBUTE EXTENSION LABEL
104 %token REALPART IMAGPART VA_ARG
106 /* Used in c-lex.c for parsing pragmas. */
109 /* Add precedence rules to solve dangling else s/r conflict */
113 /* Define the operator tokens and their precedences.
114 The value is an integer because, if used, it is the tree code
115 to use in the expression made from the operator. */
117 %right <code> ASSIGN '='
118 %right <code> '?' ':'
124 %left <code> EQCOMPARE
125 %left <code> ARITHCOMPARE
126 %left <code> LSHIFT RSHIFT
128 %left <code> '*' '/' '%'
129 %right <code> UNARY PLUSPLUS MINUSMINUS
131 %left <code> POINTSAT '.' '(' '['
133 /* The Objective-C keywords. These are included in C and in
134 Objective C, so that the token codes are the same in both. */
135 %token INTERFACE IMPLEMENTATION END SELECTOR DEFS ENCODE
136 %token CLASSNAME PUBLIC PRIVATE PROTECTED PROTOCOL OBJECTNAME CLASS ALIAS
138 /* Objective-C string constants in raw form.
139 yylval is an OBJC_STRING_CST node. */
145 %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist exprlist
146 %type <ttype> expr_no_commas cast_expr unary_expr primary string STRING
147 %type <ttype> typed_declspecs reserved_declspecs
148 %type <ttype> typed_typespecs reserved_typespecquals
149 %type <ttype> declmods typespec typespecqual_reserved
150 %type <ttype> typed_declspecs_no_prefix_attr reserved_declspecs_no_prefix_attr
151 %type <ttype> declmods_no_prefix_attr
152 %type <ttype> SCSPEC TYPESPEC TYPE_QUAL nonempty_type_quals maybe_type_qual
153 %type <ttype> initdecls notype_initdecls initdcl notype_initdcl
154 %type <ttype> init maybeasm
155 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
156 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
157 %type <ttype> any_word
159 %type <ttype> compstmt compstmt_nostart compstmt_primary_start
161 %type <ttype> declarator
162 %type <ttype> notype_declarator after_type_declarator
163 %type <ttype> parm_declarator
165 %type <ttype> structsp component_decl_list component_decl_list2
166 %type <ttype> component_decl components component_declarator
167 %type <ttype> enumlist enumerator
168 %type <ttype> struct_head union_head enum_head
169 %type <ttype> typename absdcl absdcl1 type_quals
170 %type <ttype> xexpr parms parm identifiers
172 %type <ttype> parmlist parmlist_1 parmlist_2
173 %type <ttype> parmlist_or_identifiers parmlist_or_identifiers_1
174 %type <ttype> identifiers_or_typenames
176 %type <itype> setspecs
178 %type <ends_in_label> lineno_stmt_or_label lineno_stmt_or_labels stmt_or_label
180 %type <filename> save_filename
181 %type <lineno> save_lineno
183 /* the Objective-C nonterminals */
185 %type <ttype> ivar_decl_list ivar_decls ivar_decl ivars ivar_declarator
186 %type <ttype> methoddecl unaryselector keywordselector selector
187 %type <ttype> keyworddecl receiver objcmessageexpr messageargs
188 %type <ttype> keywordexpr keywordarglist keywordarg
189 %type <ttype> myparms myparm optparmlist reservedwords objcselectorexpr
190 %type <ttype> selectorarg keywordnamelist keywordname objcencodeexpr
191 %type <ttype> objc_string non_empty_protocolrefs protocolrefs identifier_list objcprotocolexpr
193 %type <ttype> CLASSNAME OBJC_STRING OBJECTNAME
196 /* Number of statements (loosely speaking) and compound statements
198 static int stmt_count;
199 static int compstmt_count;
201 /* Input file and line number of the end of the body of last simple_if;
202 used by the stmt-rule immediately after simple_if returns. */
203 static char *if_stmt_file;
204 static int if_stmt_line;
206 /* List of types and structure classes of the current declaration. */
207 static tree current_declspecs = NULL_TREE;
208 static tree prefix_attributes = NULL_TREE;
210 /* Stack of saved values of current_declspecs and prefix_attributes. */
211 static tree declspec_stack;
213 /* 1 if we explained undeclared var errors. */
214 static int undeclared_variable_notice;
216 /* Objective-C specific information */
218 tree objc_interface_context;
219 tree objc_implementation_context;
220 tree objc_method_context;
221 tree objc_ivar_chain;
222 tree objc_ivar_context;
223 enum tree_code objc_inherit_code;
224 int objc_receiver_context;
225 int objc_public_flag;
228 /* Tell yyparse how to print a token's value, if yydebug is set. */
230 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
231 extern void yyprint PROTO ((FILE *, int, YYSTYPE));
237 pedwarn ("ANSI C forbids an empty source file");
242 /* In case there were missing closebraces,
243 get us back to the global binding level. */
244 while (! global_bindings_p ())
250 /* the reason for the strange actions in this rule
251 is so that notype_initdecls when reached via datadef
252 can find a valid list of type and sc specs in $0. */
255 {$<ttype>$ = NULL_TREE; } extdef
256 | extdefs {$<ttype>$ = NULL_TREE; } extdef
263 | ASM_KEYWORD '(' expr ')' ';'
265 if ((TREE_CODE ($3) == ADDR_EXPR
266 && TREE_CODE (TREE_OPERAND ($3, 0)) == STRING_CST)
267 || TREE_CODE ($3) == STRING_CST)
270 error ("argument of `asm' is not a constant string"); }
272 { pedantic = $<itype>1; }
276 setspecs notype_initdecls ';'
278 error ("ANSI C forbids data definition with no type or storage class");
279 else if (!flag_traditional)
280 warning ("data definition has no type or storage class");
282 current_declspecs = TREE_VALUE (declspec_stack);
283 prefix_attributes = TREE_PURPOSE (declspec_stack);
284 declspec_stack = TREE_CHAIN (declspec_stack);
285 resume_momentary ($1); }
286 | declmods setspecs notype_initdecls ';'
287 { current_declspecs = TREE_VALUE (declspec_stack);
288 prefix_attributes = TREE_PURPOSE (declspec_stack);
289 declspec_stack = TREE_CHAIN (declspec_stack);
290 resume_momentary ($2); }
291 | typed_declspecs setspecs initdecls ';'
292 { current_declspecs = TREE_VALUE (declspec_stack);
293 prefix_attributes = TREE_PURPOSE (declspec_stack);
294 declspec_stack = TREE_CHAIN (declspec_stack);
295 resume_momentary ($2); }
297 { pedwarn ("empty declaration"); }
298 | typed_declspecs ';'
304 pedwarn ("ANSI C does not allow extra `;' outside of a function"); }
308 typed_declspecs setspecs declarator
309 { if (! start_function (current_declspecs, $3,
310 prefix_attributes, NULL_TREE, 0))
312 reinit_parse_for_function (); }
314 { store_parm_decls (); }
316 { finish_function (0);
317 current_declspecs = TREE_VALUE (declspec_stack);
318 prefix_attributes = TREE_PURPOSE (declspec_stack);
319 declspec_stack = TREE_CHAIN (declspec_stack);
320 resume_momentary ($2); }
321 | typed_declspecs setspecs declarator error
322 { current_declspecs = TREE_VALUE (declspec_stack);
323 prefix_attributes = TREE_PURPOSE (declspec_stack);
324 declspec_stack = TREE_CHAIN (declspec_stack);
325 resume_momentary ($2); }
326 | declmods setspecs notype_declarator
327 { if (! start_function (current_declspecs, $3,
328 prefix_attributes, NULL_TREE, 0))
330 reinit_parse_for_function (); }
332 { store_parm_decls (); }
334 { finish_function (0);
335 current_declspecs = TREE_VALUE (declspec_stack);
336 prefix_attributes = TREE_PURPOSE (declspec_stack);
337 declspec_stack = TREE_CHAIN (declspec_stack);
338 resume_momentary ($2); }
339 | declmods setspecs notype_declarator error
340 { current_declspecs = TREE_VALUE (declspec_stack);
341 prefix_attributes = TREE_PURPOSE (declspec_stack);
342 declspec_stack = TREE_CHAIN (declspec_stack);
343 resume_momentary ($2); }
344 | setspecs notype_declarator
345 { if (! start_function (NULL_TREE, $2,
346 prefix_attributes, NULL_TREE, 0))
348 reinit_parse_for_function (); }
350 { store_parm_decls (); }
352 { finish_function (0);
353 current_declspecs = TREE_VALUE (declspec_stack);
354 prefix_attributes = TREE_PURPOSE (declspec_stack);
355 declspec_stack = TREE_CHAIN (declspec_stack);
356 resume_momentary ($1); }
357 | setspecs notype_declarator error
358 { current_declspecs = TREE_VALUE (declspec_stack);
359 prefix_attributes = TREE_PURPOSE (declspec_stack);
360 declspec_stack = TREE_CHAIN (declspec_stack);
361 resume_momentary ($1); }
374 { $$ = NEGATE_EXPR; }
376 { $$ = CONVERT_EXPR; }
378 { $$ = PREINCREMENT_EXPR; }
380 { $$ = PREDECREMENT_EXPR; }
382 { $$ = BIT_NOT_EXPR; }
384 { $$ = TRUTH_NOT_EXPR; }
387 expr: nonnull_exprlist
388 { $$ = build_compound_expr ($1); }
399 { $$ = build_tree_list (NULL_TREE, $1); }
400 | nonnull_exprlist ',' expr_no_commas
401 { chainon ($1, build_tree_list (NULL_TREE, $3)); }
406 | '*' cast_expr %prec UNARY
407 { $$ = build_indirect_ref ($2, "unary *"); }
408 /* __extension__ turns off -pedantic for following primary. */
409 | extension cast_expr %prec UNARY
411 pedantic = $<itype>1; }
412 | unop cast_expr %prec UNARY
413 { $$ = build_unary_op ($1, $2, 0);
414 overflow_warning ($$); }
415 /* Refer to the address of a label as a pointer. */
417 { tree label = lookup_label ($2);
419 pedwarn ("ANSI C forbids `&&'");
421 $$ = null_pointer_node;
424 TREE_USED (label) = 1;
425 $$ = build1 (ADDR_EXPR, ptr_type_node, label);
426 TREE_CONSTANT ($$) = 1;
429 /* This seems to be impossible on some machines, so let's turn it off.
430 You can use __builtin_next_arg to find the anonymous stack args.
432 { tree types = TYPE_ARG_TYPES (TREE_TYPE (current_function_decl));
433 $$ = error_mark_node;
434 if (TREE_VALUE (tree_last (types)) == void_type_node)
435 error ("`&...' used in function with fixed number of arguments");
439 pedwarn ("ANSI C forbids `&...'");
440 $$ = tree_last (DECL_ARGUMENTS (current_function_decl));
441 $$ = build_unary_op (ADDR_EXPR, $$, 0);
444 | sizeof unary_expr %prec UNARY
446 if (TREE_CODE ($2) == COMPONENT_REF
447 && DECL_C_BIT_FIELD (TREE_OPERAND ($2, 1)))
448 error ("`sizeof' applied to a bit-field");
449 $$ = c_sizeof (TREE_TYPE ($2)); }
450 | sizeof '(' typename ')' %prec HYPERUNARY
452 $$ = c_sizeof (groktypename ($3)); }
453 | alignof unary_expr %prec UNARY
455 $$ = c_alignof_expr ($2); }
456 | alignof '(' typename ')' %prec HYPERUNARY
458 $$ = c_alignof (groktypename ($3)); }
459 | REALPART cast_expr %prec UNARY
460 { $$ = build_unary_op (REALPART_EXPR, $2, 0); }
461 | IMAGPART cast_expr %prec UNARY
462 { $$ = build_unary_op (IMAGPART_EXPR, $2, 0); }
463 | VA_ARG '(' expr_no_commas ',' typename ')'
464 { $$ = build_va_arg ($3, groktypename ($5)); }
468 SIZEOF { skip_evaluation++; }
472 ALIGNOF { skip_evaluation++; }
477 | '(' typename ')' cast_expr %prec UNARY
478 { tree type = groktypename ($2);
479 $$ = build_c_cast (type, $4); }
480 | '(' typename ')' '{'
481 { start_init (NULL_TREE, NULL, 0);
482 $2 = groktypename ($2);
483 really_start_incremental_init ($2); }
484 initlist_maybe_comma '}' %prec UNARY
486 tree result = pop_init_level (0);
490 if (pedantic && ! flag_isoc9x)
491 pedwarn ("ANSI C forbids constructor expressions");
492 if (TYPE_NAME (type) != 0)
494 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
495 name = IDENTIFIER_POINTER (TYPE_NAME (type));
497 name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
502 if (TREE_CODE (type) == ARRAY_TYPE && TYPE_SIZE (type) == 0)
504 int failure = complete_array_type (type, $$, 1);
513 | expr_no_commas '+' expr_no_commas
514 { $$ = parser_build_binary_op ($2, $1, $3); }
515 | expr_no_commas '-' expr_no_commas
516 { $$ = parser_build_binary_op ($2, $1, $3); }
517 | expr_no_commas '*' expr_no_commas
518 { $$ = parser_build_binary_op ($2, $1, $3); }
519 | expr_no_commas '/' expr_no_commas
520 { $$ = parser_build_binary_op ($2, $1, $3); }
521 | expr_no_commas '%' expr_no_commas
522 { $$ = parser_build_binary_op ($2, $1, $3); }
523 | expr_no_commas LSHIFT expr_no_commas
524 { $$ = parser_build_binary_op ($2, $1, $3); }
525 | expr_no_commas RSHIFT expr_no_commas
526 { $$ = parser_build_binary_op ($2, $1, $3); }
527 | expr_no_commas ARITHCOMPARE expr_no_commas
528 { $$ = parser_build_binary_op ($2, $1, $3); }
529 | expr_no_commas EQCOMPARE expr_no_commas
530 { $$ = parser_build_binary_op ($2, $1, $3); }
531 | expr_no_commas '&' expr_no_commas
532 { $$ = parser_build_binary_op ($2, $1, $3); }
533 | expr_no_commas '|' expr_no_commas
534 { $$ = parser_build_binary_op ($2, $1, $3); }
535 | expr_no_commas '^' expr_no_commas
536 { $$ = parser_build_binary_op ($2, $1, $3); }
537 | expr_no_commas ANDAND
538 { $1 = truthvalue_conversion (default_conversion ($1));
539 skip_evaluation += $1 == boolean_false_node; }
541 { skip_evaluation -= $1 == boolean_false_node;
542 $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $4); }
543 | expr_no_commas OROR
544 { $1 = truthvalue_conversion (default_conversion ($1));
545 skip_evaluation += $1 == boolean_true_node; }
547 { skip_evaluation -= $1 == boolean_true_node;
548 $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $4); }
550 { $1 = truthvalue_conversion (default_conversion ($1));
551 skip_evaluation += $1 == boolean_false_node; }
553 { skip_evaluation += (($1 == boolean_true_node)
554 - ($1 == boolean_false_node)); }
556 { skip_evaluation -= $1 == boolean_true_node;
557 $$ = build_conditional_expr ($1, $4, $7); }
560 pedwarn ("ANSI C forbids omitting the middle term of a ?: expression");
561 /* Make sure first operand is calculated only once. */
562 $<ttype>2 = save_expr ($1);
563 $1 = truthvalue_conversion (default_conversion ($<ttype>2));
564 skip_evaluation += $1 == boolean_true_node; }
566 { skip_evaluation -= $1 == boolean_true_node;
567 $$ = build_conditional_expr ($1, $<ttype>2, $5); }
568 | expr_no_commas '=' expr_no_commas
570 $$ = build_modify_expr ($1, NOP_EXPR, $3);
571 class = TREE_CODE_CLASS (TREE_CODE ($$));
572 if (class == 'e' || class == '1'
573 || class == '2' || class == '<')
574 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR);
576 | expr_no_commas ASSIGN expr_no_commas
578 $$ = build_modify_expr ($1, $2, $3);
579 /* This inhibits warnings in truthvalue_conversion. */
580 class = TREE_CODE_CLASS (TREE_CODE ($$));
581 if (class == 'e' || class == '1'
582 || class == '2' || class == '<')
583 C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK);
591 if (!$$ || $$ == error_mark_node)
593 if (yychar == YYEMPTY)
599 if (objc_receiver_context
600 && ! (objc_receiver_context
601 && strcmp (IDENTIFIER_POINTER ($1), "super")))
602 /* we have a message to super */
603 $$ = get_super_receiver ();
604 else if (objc_method_context
605 && (decl = is_ivar (objc_ivar_chain, $1)))
607 if (is_private (decl))
608 $$ = error_mark_node;
610 $$ = build_ivar_reference ($1);
614 /* Ordinary implicit function declaration. */
615 $$ = implicitly_declare ($1);
616 assemble_external ($$);
620 else if (current_function_decl == 0)
622 error ("`%s' undeclared here (not in a function)",
623 IDENTIFIER_POINTER ($1));
624 $$ = error_mark_node;
630 if (objc_receiver_context
631 && ! strcmp (IDENTIFIER_POINTER ($1), "super"))
632 /* we have a message to super */
633 $$ = get_super_receiver ();
634 else if (objc_method_context
635 && (decl = is_ivar (objc_ivar_chain, $1)))
637 if (is_private (decl))
638 $$ = error_mark_node;
640 $$ = build_ivar_reference ($1);
644 if (IDENTIFIER_GLOBAL_VALUE ($1) != error_mark_node
645 || IDENTIFIER_ERROR_LOCUS ($1) != current_function_decl)
647 error ("`%s' undeclared (first use in this function)",
648 IDENTIFIER_POINTER ($1));
650 if (! undeclared_variable_notice)
652 error ("(Each undeclared identifier is reported only once");
653 error ("for each function it appears in.)");
654 undeclared_variable_notice = 1;
657 $$ = error_mark_node;
658 /* Prevent repeated error messages. */
659 IDENTIFIER_GLOBAL_VALUE ($1) = error_mark_node;
660 IDENTIFIER_ERROR_LOCUS ($1) = current_function_decl;
664 else if (TREE_TYPE ($$) == error_mark_node)
665 $$ = error_mark_node;
666 else if (C_DECL_ANTICIPATED ($$))
668 /* The first time we see a build-in function used,
669 if it has not been declared. */
670 C_DECL_ANTICIPATED ($$) = 0;
671 if (yychar == YYEMPTY)
675 /* Omit the implicit declaration we
676 would ordinarily do, so we don't lose
677 the actual built in type.
678 But print a diagnostic for the mismatch. */
679 if (objc_method_context
680 && is_ivar (objc_ivar_chain, $1))
681 error ("Instance variable `%s' implicitly declared as function",
682 IDENTIFIER_POINTER (DECL_NAME ($$)));
684 if (TREE_CODE ($$) != FUNCTION_DECL)
685 error ("`%s' implicitly declared as function",
686 IDENTIFIER_POINTER (DECL_NAME ($$)));
687 else if ((TYPE_MODE (TREE_TYPE (TREE_TYPE ($$)))
688 != TYPE_MODE (integer_type_node))
689 && (TREE_TYPE (TREE_TYPE ($$))
691 pedwarn ("type mismatch in implicit declaration for built-in function `%s'",
692 IDENTIFIER_POINTER (DECL_NAME ($$)));
693 /* If it really returns void, change that to int. */
694 if (TREE_TYPE (TREE_TYPE ($$)) == void_type_node)
696 = build_function_type (integer_type_node,
697 TYPE_ARG_TYPES (TREE_TYPE ($$)));
700 pedwarn ("built-in function `%s' used without declaration",
701 IDENTIFIER_POINTER (DECL_NAME ($$)));
703 /* Do what we would ordinarily do when a fn is used. */
704 assemble_external ($$);
709 assemble_external ($$);
711 /* we have a definition - still check if iVariable */
713 if (!objc_receiver_context
714 || (objc_receiver_context
715 && strcmp (IDENTIFIER_POINTER ($1), "super")))
719 if (objc_method_context
720 && (decl = is_ivar (objc_ivar_chain, $1)))
722 if (IDENTIFIER_LOCAL_VALUE ($1))
723 warning ("local declaration of `%s' hides instance variable",
724 IDENTIFIER_POINTER ($1));
727 if (is_private (decl))
728 $$ = error_mark_node;
730 $$ = build_ivar_reference ($1);
734 else /* we have a message to super */
735 $$ = get_super_receiver ();
738 if (TREE_CODE ($$) == CONST_DECL)
740 $$ = DECL_INITIAL ($$);
741 /* This is to prevent an enum whose value is 0
742 from being considered a null pointer constant. */
743 $$ = build1 (NOP_EXPR, TREE_TYPE ($$), $$);
744 TREE_CONSTANT ($$) = 1;
749 { $$ = combine_strings ($1); }
751 { char class = TREE_CODE_CLASS (TREE_CODE ($2));
752 if (class == 'e' || class == '1'
753 || class == '2' || class == '<')
754 C_SET_EXP_ORIGINAL_CODE ($2, ERROR_MARK);
757 { $$ = error_mark_node; }
758 | compstmt_primary_start compstmt_nostart ')'
761 pedwarn ("ANSI C forbids braced-groups within expressions");
762 pop_iterator_stack ();
764 rtl_exp = expand_end_stmt_expr ($1);
765 /* The statements have side effects, so the group does. */
766 TREE_SIDE_EFFECTS (rtl_exp) = 1;
768 if (TREE_CODE ($2) == BLOCK)
770 /* Make a BIND_EXPR for the BLOCK already made. */
771 $$ = build (BIND_EXPR, TREE_TYPE (rtl_exp),
772 NULL_TREE, rtl_exp, $2);
773 /* Remove the block from the tree at this point.
774 It gets put back at the proper place
775 when the BIND_EXPR is expanded. */
781 | compstmt_primary_start error ')'
783 /* Make sure we call expand_end_stmt_expr. Otherwise
784 we are likely to lose sequences and crash later. */
785 pop_iterator_stack ();
787 expand_end_stmt_expr ($1);
788 $$ = error_mark_node;
790 | primary '(' exprlist ')' %prec '.'
791 { $$ = build_function_call ($1, $3); }
792 | primary '[' expr ']' %prec '.'
793 { $$ = build_array_ref ($1, $3); }
794 | primary '.' identifier
796 if (doing_objc_thang)
798 if (is_public ($1, $3))
799 $$ = build_component_ref ($1, $3);
801 $$ = error_mark_node;
804 $$ = build_component_ref ($1, $3);
806 | primary POINTSAT identifier
808 tree expr = build_indirect_ref ($1, "->");
810 if (doing_objc_thang)
812 if (is_public (expr, $3))
813 $$ = build_component_ref (expr, $3);
815 $$ = error_mark_node;
818 $$ = build_component_ref (expr, $3);
821 { $$ = build_unary_op (POSTINCREMENT_EXPR, $1, 0); }
823 { $$ = build_unary_op (POSTDECREMENT_EXPR, $1, 0); }
825 { $$ = build_message_expr ($1); }
827 { $$ = build_selector_expr ($1); }
829 { $$ = build_protocol_expr ($1); }
831 { $$ = build_encode_expr ($1); }
833 { $$ = build_objc_string_object ($1); }
836 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
840 { $$ = chainon ($1, $2); }
843 /* Produces an OBJC_STRING_CST with perhaps more OBJC_STRING_CSTs chained
847 | objc_string OBJC_STRING
848 { $$ = chainon ($1, $2); }
851 old_style_parm_decls:
855 /* ... is used here to indicate a varargs function. */
858 pedwarn ("ANSI C does not permit use of `varargs.h'"); }
861 /* The following are analogous to lineno_decl, decls and decl
862 except that they do not allow nested functions.
863 They are used for old-style parm decls. */
865 save_filename save_lineno datadecl
872 | datadecls lineno_datadecl
873 | lineno_datadecl errstmt
876 /* We don't allow prefix attributes here because they cause reduce/reduce
877 conflicts: we can't know whether we're parsing a function decl with
878 attribute suffix, or function defn with attribute prefix on first old
881 typed_declspecs_no_prefix_attr setspecs initdecls ';'
882 { current_declspecs = TREE_VALUE (declspec_stack);
883 prefix_attributes = TREE_PURPOSE (declspec_stack);
884 declspec_stack = TREE_CHAIN (declspec_stack);
885 resume_momentary ($2); }
886 | declmods_no_prefix_attr setspecs notype_initdecls ';'
887 { current_declspecs = TREE_VALUE (declspec_stack);
888 prefix_attributes = TREE_PURPOSE (declspec_stack);
889 declspec_stack = TREE_CHAIN (declspec_stack);
890 resume_momentary ($2); }
891 | typed_declspecs_no_prefix_attr ';'
892 { shadow_tag_warned ($1, 1);
893 pedwarn ("empty declaration"); }
894 | declmods_no_prefix_attr ';'
895 { pedwarn ("empty declaration"); }
898 /* This combination which saves a lineno before a decl
899 is the normal thing to use, rather than decl itself.
900 This is to avoid shift/reduce conflicts in contexts
901 where statement labels are allowed. */
903 save_filename save_lineno decl
911 | lineno_decl errstmt
914 /* records the type and storage class specs to use for processing
915 the declarators that follow.
916 Maintains a stack of outer-level values of current_declspecs,
917 for the sake of parm declarations nested in function declarators. */
918 setspecs: /* empty */
919 { $$ = suspend_momentary ();
920 pending_xref_error ();
921 declspec_stack = tree_cons (prefix_attributes,
924 split_specs_attrs ($<ttype>0,
925 ¤t_declspecs, &prefix_attributes); }
928 /* ??? Yuck. See after_type_declarator. */
929 setattrs: /* empty */
930 { prefix_attributes = chainon (prefix_attributes, $<ttype>0); }
934 typed_declspecs setspecs initdecls ';'
935 { current_declspecs = TREE_VALUE (declspec_stack);
936 prefix_attributes = TREE_PURPOSE (declspec_stack);
937 declspec_stack = TREE_CHAIN (declspec_stack);
938 resume_momentary ($2); }
939 | declmods setspecs notype_initdecls ';'
940 { current_declspecs = TREE_VALUE (declspec_stack);
941 prefix_attributes = TREE_PURPOSE (declspec_stack);
942 declspec_stack = TREE_CHAIN (declspec_stack);
943 resume_momentary ($2); }
944 | typed_declspecs setspecs nested_function
945 { current_declspecs = TREE_VALUE (declspec_stack);
946 prefix_attributes = TREE_PURPOSE (declspec_stack);
947 declspec_stack = TREE_CHAIN (declspec_stack);
948 resume_momentary ($2); }
949 | declmods setspecs notype_nested_function
950 { current_declspecs = TREE_VALUE (declspec_stack);
951 prefix_attributes = TREE_PURPOSE (declspec_stack);
952 declspec_stack = TREE_CHAIN (declspec_stack);
953 resume_momentary ($2); }
954 | typed_declspecs ';'
957 { pedwarn ("empty declaration"); }
959 { pedantic = $<itype>1; }
962 /* Declspecs which contain at least one type specifier or typedef name.
963 (Just `const' or `volatile' is not enough.)
964 A typedef'd name following these is taken as a name to be declared.
965 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
968 typespec reserved_declspecs
969 { $$ = tree_cons (NULL_TREE, $1, $2); }
970 | declmods typespec reserved_declspecs
971 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
974 reserved_declspecs: /* empty */
976 | reserved_declspecs typespecqual_reserved
977 { $$ = tree_cons (NULL_TREE, $2, $1); }
978 | reserved_declspecs SCSPEC
979 { if (extra_warnings)
980 warning ("`%s' is not at beginning of declaration",
981 IDENTIFIER_POINTER ($2));
982 $$ = tree_cons (NULL_TREE, $2, $1); }
983 | reserved_declspecs attributes
984 { $$ = tree_cons ($2, NULL_TREE, $1); }
987 typed_declspecs_no_prefix_attr:
988 typespec reserved_declspecs_no_prefix_attr
989 { $$ = tree_cons (NULL_TREE, $1, $2); }
990 | declmods_no_prefix_attr typespec reserved_declspecs_no_prefix_attr
991 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
994 reserved_declspecs_no_prefix_attr:
997 | reserved_declspecs_no_prefix_attr typespecqual_reserved
998 { $$ = tree_cons (NULL_TREE, $2, $1); }
999 | reserved_declspecs_no_prefix_attr SCSPEC
1000 { if (extra_warnings)
1001 warning ("`%s' is not at beginning of declaration",
1002 IDENTIFIER_POINTER ($2));
1003 $$ = tree_cons (NULL_TREE, $2, $1); }
1006 /* List of just storage classes, type modifiers, and prefix attributes.
1007 A declaration can start with just this, but then it cannot be used
1008 to redeclare a typedef-name.
1009 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
1012 declmods_no_prefix_attr
1015 { $$ = tree_cons ($1, NULL_TREE, NULL_TREE); }
1016 | declmods declmods_no_prefix_attr
1017 { $$ = chainon ($2, $1); }
1018 | declmods attributes
1019 { $$ = tree_cons ($2, NULL_TREE, $1); }
1022 declmods_no_prefix_attr:
1024 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
1025 TREE_STATIC ($$) = 1; }
1027 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
1028 | declmods_no_prefix_attr TYPE_QUAL
1029 { $$ = tree_cons (NULL_TREE, $2, $1);
1030 TREE_STATIC ($$) = 1; }
1031 | declmods_no_prefix_attr SCSPEC
1032 { if (extra_warnings && TREE_STATIC ($1))
1033 warning ("`%s' is not at beginning of declaration",
1034 IDENTIFIER_POINTER ($2));
1035 $$ = tree_cons (NULL_TREE, $2, $1);
1036 TREE_STATIC ($$) = TREE_STATIC ($1); }
1040 /* Used instead of declspecs where storage classes are not allowed
1041 (that is, for typenames and structure components).
1042 Don't accept a typedef-name if anything but a modifier precedes it. */
1045 typespec reserved_typespecquals
1046 { $$ = tree_cons (NULL_TREE, $1, $2); }
1047 | nonempty_type_quals typespec reserved_typespecquals
1048 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
1051 reserved_typespecquals: /* empty */
1053 | reserved_typespecquals typespecqual_reserved
1054 { $$ = tree_cons (NULL_TREE, $2, $1); }
1057 /* A typespec (but not a type qualifier).
1058 Once we have seen one of these in a declaration,
1059 if a typedef name appears then it is being redeclared. */
1064 { /* For a typedef name, record the meaning, not the name.
1065 In case of `foo foo, bar;'. */
1066 $$ = lookup_name ($1); }
1067 | CLASSNAME protocolrefs
1068 { $$ = get_static_reference ($1, $2); }
1069 | OBJECTNAME protocolrefs
1070 { $$ = get_object_reference ($2); }
1072 /* Make "<SomeProtocol>" equivalent to "id <SomeProtocol>"
1073 - nisse@lysator.liu.se */
1074 | non_empty_protocolrefs
1075 { $$ = get_object_reference ($1); }
1076 | TYPEOF '(' expr ')'
1077 { $$ = TREE_TYPE ($3); }
1078 | TYPEOF '(' typename ')'
1079 { $$ = groktypename ($3); }
1082 /* A typespec that is a reserved word, or a type qualifier. */
1084 typespecqual_reserved: TYPESPEC
1091 | initdecls ',' initdcl
1096 | notype_initdecls ',' initdcl
1102 | ASM_KEYWORD '(' string ')'
1103 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
1109 declarator maybeasm maybe_attribute '='
1110 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1111 $3, prefix_attributes);
1112 start_init ($<ttype>$, $2, global_bindings_p ()); }
1114 /* Note how the declaration of the variable is in effect while its init is parsed! */
1116 finish_decl ($<ttype>5, $6, $2); }
1117 | declarator maybeasm maybe_attribute
1118 { tree d = start_decl ($1, current_declspecs, 0,
1119 $3, prefix_attributes);
1120 finish_decl (d, NULL_TREE, $2);
1125 notype_declarator maybeasm maybe_attribute '='
1126 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1127 $3, prefix_attributes);
1128 start_init ($<ttype>$, $2, global_bindings_p ()); }
1130 /* Note how the declaration of the variable is in effect while its init is parsed! */
1132 decl_attributes ($<ttype>5, $3, prefix_attributes);
1133 finish_decl ($<ttype>5, $6, $2); }
1134 | notype_declarator maybeasm maybe_attribute
1135 { tree d = start_decl ($1, current_declspecs, 0,
1136 $3, prefix_attributes);
1137 finish_decl (d, NULL_TREE, $2); }
1139 /* the * rules are dummies to accept the Apollo extended syntax
1140 so that the header files compile. */
1151 | attributes attribute
1152 { $$ = chainon ($1, $2); }
1156 ATTRIBUTE '(' '(' attribute_list ')' ')'
1163 | attribute_list ',' attrib
1164 { $$ = chainon ($1, $3); }
1171 { $$ = build_tree_list ($1, NULL_TREE); }
1172 | any_word '(' IDENTIFIER ')'
1173 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1174 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1175 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1176 | any_word '(' exprlist ')'
1177 { $$ = build_tree_list ($1, $3); }
1180 /* This still leaves out most reserved keywords,
1181 shouldn't we include them? */
1190 /* Initializers. `init' is the entry point. */
1195 { really_start_incremental_init (NULL_TREE);
1196 /* Note that the call to clear_momentary
1197 is in process_init_element. */
1198 push_momentary (); }
1199 initlist_maybe_comma '}'
1200 { $$ = pop_init_level (0);
1201 if ($$ == error_mark_node
1202 && ! (yychar == STRING || yychar == CONSTANT))
1205 pop_momentary_nofree (); }
1208 { $$ = error_mark_node; }
1211 /* `initlist_maybe_comma' is the guts of an initializer in braces. */
1212 initlist_maybe_comma:
1215 pedwarn ("ANSI C forbids empty initializer braces"); }
1216 | initlist1 maybecomma
1221 | initlist1 ',' initelt
1224 /* `initelt' is a single element of an initializer.
1225 It may use braces. */
1227 designator_list '=' initval
1228 | designator initval
1230 { set_init_label ($1); }
1237 { push_init_level (0); }
1238 initlist_maybe_comma '}'
1239 { process_init_element (pop_init_level (0)); }
1241 { process_init_element ($1); }
1247 | designator_list designator
1252 { set_init_label ($2); }
1253 /* These are for labeled elements. The syntax for an array element
1254 initializer conflicts with the syntax for an Objective-C message,
1255 so don't include these productions in the Objective-C grammar. */
1261 pedwarn ("ANSI C forbids nested functions");
1263 push_function_context ();
1264 if (! start_function (current_declspecs, $1,
1265 prefix_attributes, NULL_TREE, 1))
1267 pop_function_context ();
1270 reinit_parse_for_function (); }
1271 old_style_parm_decls
1272 { store_parm_decls (); }
1273 /* This used to use compstmt_or_error.
1274 That caused a bug with input `f(g) int g {}',
1275 where the use of YYERROR1 above caused an error
1276 which then was handled by compstmt_or_error.
1277 There followed a repeated execution of that same rule,
1278 which called YYERROR1 again, and so on. */
1280 { finish_function (1);
1281 pop_function_context (); }
1284 notype_nested_function:
1287 pedwarn ("ANSI C forbids nested functions");
1289 push_function_context ();
1290 if (! start_function (current_declspecs, $1,
1291 prefix_attributes, NULL_TREE, 1))
1293 pop_function_context ();
1296 reinit_parse_for_function (); }
1297 old_style_parm_decls
1298 { store_parm_decls (); }
1299 /* This used to use compstmt_or_error.
1300 That caused a bug with input `f(g) int g {}',
1301 where the use of YYERROR1 above caused an error
1302 which then was handled by compstmt_or_error.
1303 There followed a repeated execution of that same rule,
1304 which called YYERROR1 again, and so on. */
1306 { finish_function (1);
1307 pop_function_context (); }
1310 /* Any kind of declarator (thus, all declarators allowed
1311 after an explicit typespec). */
1314 after_type_declarator
1318 /* A declarator that is allowed only after an explicit typespec. */
1320 after_type_declarator:
1321 '(' after_type_declarator ')'
1323 | after_type_declarator '(' parmlist_or_identifiers %prec '.'
1324 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1325 /* | after_type_declarator '(' error ')' %prec '.'
1326 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1327 poplevel (0, 0, 0); } */
1328 | after_type_declarator '[' expr ']' %prec '.'
1329 { $$ = build_nt (ARRAY_REF, $1, $3); }
1330 | after_type_declarator '[' ']' %prec '.'
1331 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1332 | '*' type_quals after_type_declarator %prec UNARY
1333 { $$ = make_pointer_declarator ($2, $3); }
1334 /* ??? Yuck. setattrs is a quick hack. We can't use
1335 prefix_attributes because $1 only applies to this
1336 declarator. We assume setspecs has already been done.
1337 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1338 attributes could be recognized here or in `attributes'). */
1339 | attributes setattrs after_type_declarator
1345 /* Kinds of declarator that can appear in a parameter list
1346 in addition to notype_declarator. This is like after_type_declarator
1347 but does not allow a typedef name in parentheses as an identifier
1348 (because it would conflict with a function with that typedef as arg). */
1351 parm_declarator '(' parmlist_or_identifiers %prec '.'
1352 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1353 /* | parm_declarator '(' error ')' %prec '.'
1354 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1355 poplevel (0, 0, 0); } */
1356 | parm_declarator '[' expr ']' %prec '.'
1357 { $$ = build_nt (ARRAY_REF, $1, $3); }
1358 | parm_declarator '[' ']' %prec '.'
1359 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1360 | '*' type_quals parm_declarator %prec UNARY
1361 { $$ = make_pointer_declarator ($2, $3); }
1362 /* ??? Yuck. setattrs is a quick hack. We can't use
1363 prefix_attributes because $1 only applies to this
1364 declarator. We assume setspecs has already been done.
1365 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1366 attributes could be recognized here or in `attributes'). */
1367 | attributes setattrs parm_declarator
1372 /* A declarator allowed whether or not there has been
1373 an explicit typespec. These cannot redeclare a typedef-name. */
1376 notype_declarator '(' parmlist_or_identifiers %prec '.'
1377 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1378 /* | notype_declarator '(' error ')' %prec '.'
1379 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1380 poplevel (0, 0, 0); } */
1381 | '(' notype_declarator ')'
1383 | '*' type_quals notype_declarator %prec UNARY
1384 { $$ = make_pointer_declarator ($2, $3); }
1385 | notype_declarator '[' expr ']' %prec '.'
1386 { $$ = build_nt (ARRAY_REF, $1, $3); }
1387 | notype_declarator '[' ']' %prec '.'
1388 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1389 /* ??? Yuck. setattrs is a quick hack. We can't use
1390 prefix_attributes because $1 only applies to this
1391 declarator. We assume setspecs has already been done.
1392 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1393 attributes could be recognized here or in `attributes'). */
1394 | attributes setattrs notype_declarator
1421 struct_head identifier '{'
1422 { $$ = start_struct (RECORD_TYPE, $2);
1423 /* Start scope of tag before parsing components. */
1425 component_decl_list '}' maybe_attribute
1426 { $$ = finish_struct ($<ttype>4, $5, chainon ($1, $7)); }
1427 | struct_head '{' component_decl_list '}' maybe_attribute
1428 { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
1429 $3, chainon ($1, $5));
1431 | struct_head identifier
1432 { $$ = xref_tag (RECORD_TYPE, $2); }
1433 | union_head identifier '{'
1434 { $$ = start_struct (UNION_TYPE, $2); }
1435 component_decl_list '}' maybe_attribute
1436 { $$ = finish_struct ($<ttype>4, $5, chainon ($1, $7)); }
1437 | union_head '{' component_decl_list '}' maybe_attribute
1438 { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
1439 $3, chainon ($1, $5));
1441 | union_head identifier
1442 { $$ = xref_tag (UNION_TYPE, $2); }
1443 | enum_head identifier '{'
1444 { $<itype>3 = suspend_momentary ();
1445 $$ = start_enum ($2); }
1446 enumlist maybecomma_warn '}' maybe_attribute
1447 { $$= finish_enum ($<ttype>4, nreverse ($5), chainon ($1, $8));
1448 resume_momentary ($<itype>3); }
1450 { $<itype>2 = suspend_momentary ();
1451 $$ = start_enum (NULL_TREE); }
1452 enumlist maybecomma_warn '}' maybe_attribute
1453 { $$= finish_enum ($<ttype>3, nreverse ($4), chainon ($1, $7));
1454 resume_momentary ($<itype>2); }
1455 | enum_head identifier
1456 { $$ = xref_tag (ENUMERAL_TYPE, $2); }
1467 { if (pedantic && ! flag_isoc9x)
1468 pedwarn ("comma at end of enumerator list"); }
1471 component_decl_list:
1472 component_decl_list2
1474 | component_decl_list2 component_decl
1475 { $$ = chainon ($1, $2);
1476 pedwarn ("no semicolon at end of struct or union"); }
1479 component_decl_list2: /* empty */
1481 | component_decl_list2 component_decl ';'
1482 { $$ = chainon ($1, $2); }
1483 | component_decl_list2 ';'
1485 pedwarn ("extra semicolon in struct or union specified"); }
1486 /* foo(sizeof(struct{ @defs(ClassName)})); */
1487 | DEFS '(' CLASSNAME ')'
1489 tree interface = lookup_interface ($3);
1492 $$ = get_class_ivars (interface);
1495 error ("Cannot find interface declaration for `%s'",
1496 IDENTIFIER_POINTER ($3));
1502 /* There is a shift-reduce conflict here, because `components' may
1503 start with a `typename'. It happens that shifting (the default resolution)
1504 does the right thing, because it treats the `typename' as part of
1505 a `typed_typespecs'.
1507 It is possible that this same technique would allow the distinction
1508 between `notype_initdecls' and `initdecls' to be eliminated.
1509 But I am being cautious and not trying it. */
1512 typed_typespecs setspecs components
1514 current_declspecs = TREE_VALUE (declspec_stack);
1515 prefix_attributes = TREE_PURPOSE (declspec_stack);
1516 declspec_stack = TREE_CHAIN (declspec_stack);
1517 resume_momentary ($2); }
1520 pedwarn ("ANSI C forbids member declarations with no members");
1523 | nonempty_type_quals setspecs components
1525 current_declspecs = TREE_VALUE (declspec_stack);
1526 prefix_attributes = TREE_PURPOSE (declspec_stack);
1527 declspec_stack = TREE_CHAIN (declspec_stack);
1528 resume_momentary ($2); }
1529 | nonempty_type_quals
1531 pedwarn ("ANSI C forbids member declarations with no members");
1536 | extension component_decl
1538 pedantic = $<itype>1; }
1542 component_declarator
1543 | components ',' component_declarator
1544 { $$ = chainon ($1, $3); }
1547 component_declarator:
1548 save_filename save_lineno declarator maybe_attribute
1549 { $$ = grokfield ($1, $2, $3, current_declspecs, NULL_TREE);
1550 decl_attributes ($$, $4, prefix_attributes); }
1551 | save_filename save_lineno
1552 declarator ':' expr_no_commas maybe_attribute
1553 { $$ = grokfield ($1, $2, $3, current_declspecs, $5);
1554 decl_attributes ($$, $6, prefix_attributes); }
1555 | save_filename save_lineno ':' expr_no_commas maybe_attribute
1556 { $$ = grokfield ($1, $2, NULL_TREE, current_declspecs, $4);
1557 decl_attributes ($$, $5, prefix_attributes); }
1560 /* We chain the enumerators in reverse order.
1561 They are put in forward order where enumlist is used.
1562 (The order used to be significant, but no longer is so.
1563 However, we still maintain the order, just to be clean.) */
1567 | enumlist ',' enumerator
1568 { if ($1 == error_mark_node)
1571 $$ = chainon ($3, $1); }
1573 { $$ = error_mark_node; }
1579 { $$ = build_enumerator ($1, NULL_TREE); }
1580 | identifier '=' expr_no_commas
1581 { $$ = build_enumerator ($1, $3); }
1585 typed_typespecs absdcl
1586 { $$ = build_tree_list ($1, $2); }
1587 | nonempty_type_quals absdcl
1588 { $$ = build_tree_list ($1, $2); }
1591 absdcl: /* an absolute declarator */
1597 nonempty_type_quals:
1599 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
1600 | nonempty_type_quals TYPE_QUAL
1601 { $$ = tree_cons (NULL_TREE, $2, $1); }
1607 | type_quals TYPE_QUAL
1608 { $$ = tree_cons (NULL_TREE, $2, $1); }
1611 absdcl1: /* a nonempty absolute declarator */
1614 /* `(typedef)1' is `int'. */
1615 | '*' type_quals absdcl1 %prec UNARY
1616 { $$ = make_pointer_declarator ($2, $3); }
1617 | '*' type_quals %prec UNARY
1618 { $$ = make_pointer_declarator ($2, NULL_TREE); }
1619 | absdcl1 '(' parmlist %prec '.'
1620 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1621 | absdcl1 '[' expr ']' %prec '.'
1622 { $$ = build_nt (ARRAY_REF, $1, $3); }
1623 | absdcl1 '[' ']' %prec '.'
1624 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1625 | '(' parmlist %prec '.'
1626 { $$ = build_nt (CALL_EXPR, NULL_TREE, $2, NULL_TREE); }
1627 | '[' expr ']' %prec '.'
1628 { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
1630 { $$ = build_nt (ARRAY_REF, NULL_TREE, NULL_TREE); }
1631 /* ??? It appears we have to support attributes here, however
1632 using prefix_attributes is wrong. */
1633 | attributes setattrs absdcl1
1637 /* at least one statement, the first of which parses without error. */
1638 /* stmts is used only after decls, so an invalid first statement
1639 is actually regarded as an invalid decl and part of the decls. */
1642 lineno_stmt_or_labels
1645 pedwarn ("ANSI C forbids label at end of compound statement");
1649 lineno_stmt_or_labels:
1650 lineno_stmt_or_label
1651 | lineno_stmt_or_labels lineno_stmt_or_label
1653 | lineno_stmt_or_labels errstmt
1665 pushlevel: /* empty */
1666 { emit_line_note (input_filename, lineno);
1670 expand_start_bindings (0);
1671 if (objc_method_context)
1676 /* Read zero or more forward-declarations for labels
1677 that nested functions can jump to. */
1682 pedwarn ("ANSI C forbids label declarations"); }
1687 | label_decls label_decl
1691 LABEL identifiers_or_typenames ';'
1693 for (link = $2; link; link = TREE_CHAIN (link))
1695 tree label = shadow_label (TREE_VALUE (link));
1696 C_DECLARED_LABEL_FLAG (label) = 1;
1697 declare_nonlocal_label (label);
1702 /* This is the body of a function definition.
1703 It causes syntax errors to ignore to the next openbrace. */
1710 compstmt_start: '{' { compstmt_count++; }
1712 compstmt_nostart: '}'
1713 { $$ = convert (void_type_node, integer_zero_node); }
1714 | pushlevel maybe_label_decls decls xstmts '}'
1715 { emit_line_note (input_filename, lineno);
1716 expand_end_bindings (getdecls (), 1, 0);
1717 $$ = poplevel (1, 1, 0);
1718 if (yychar == CONSTANT || yychar == STRING)
1719 pop_momentary_nofree ();
1722 | pushlevel maybe_label_decls error '}'
1723 { emit_line_note (input_filename, lineno);
1724 expand_end_bindings (getdecls (), kept_level_p (), 0);
1725 $$ = poplevel (kept_level_p (), 0, 0);
1726 if (yychar == CONSTANT || yychar == STRING)
1727 pop_momentary_nofree ();
1730 | pushlevel maybe_label_decls stmts '}'
1731 { emit_line_note (input_filename, lineno);
1732 expand_end_bindings (getdecls (), kept_level_p (), 0);
1733 $$ = poplevel (kept_level_p (), 0, 0);
1734 if (yychar == CONSTANT || yychar == STRING)
1735 pop_momentary_nofree ();
1740 compstmt_primary_start:
1742 { if (current_function_decl == 0)
1744 error ("braced-group within expression allowed only inside a function");
1747 /* We must force a BLOCK for this level
1748 so that, if it is not expanded later,
1749 there is a way to turn off the entire subtree of blocks
1750 that are contained in it. */
1752 push_iterator_stack ();
1753 push_label_level ();
1754 $$ = expand_start_stmt_expr ();
1758 compstmt: compstmt_start compstmt_nostart
1762 /* Value is number of statements counted as of the closeparen. */
1764 if_prefix lineno_labeled_stmt
1765 /* Make sure c_expand_end_cond is run once
1766 for each call to c_expand_start_cond.
1767 Otherwise a crash is likely. */
1773 { emit_line_note ($<filename>-1, $<lineno>0);
1774 c_expand_start_cond (truthvalue_conversion ($3), 0,
1776 $<itype>$ = stmt_count;
1777 if_stmt_file = $<filename>-1;
1778 if_stmt_line = $<lineno>0;
1779 position_after_white_space (); }
1782 /* This is a subroutine of stmt.
1783 It is used twice, once for valid DO statements
1784 and once for catching errors in parsing the end test. */
1789 emit_line_note ($<filename>-1, $<lineno>0);
1790 /* See comment in `while' alternative, above. */
1792 expand_start_loop_continue_elsewhere (1);
1793 position_after_white_space (); }
1794 lineno_labeled_stmt WHILE
1795 { expand_loop_continue_here (); }
1799 { $$ = input_filename; }
1806 lineno_labeled_stmt:
1807 save_filename save_lineno stmt
1809 /* | save_filename save_lineno error
1812 | save_filename save_lineno label lineno_labeled_stmt
1816 lineno_stmt_or_label:
1817 save_filename save_lineno stmt_or_label
1828 /* Parse a single real statement, not including any labels. */
1835 emit_line_note ($<filename>-1, $<lineno>0);
1836 /* It appears that this should not be done--that a non-lvalue array
1837 shouldn't get an error if the value isn't used.
1838 Section 3.2.2.1 says that an array lvalue gets converted to a pointer
1839 if it appears as a top-level expression,
1840 but says nothing about non-lvalue arrays. */
1842 /* Call default_conversion to get an error
1843 on referring to a register array if pedantic. */
1844 if (TREE_CODE (TREE_TYPE ($1)) == ARRAY_TYPE
1845 || TREE_CODE (TREE_TYPE ($1)) == FUNCTION_TYPE)
1846 $1 = default_conversion ($1);
1848 iterator_expand ($1);
1849 clear_momentary (); }
1851 { c_expand_start_else ();
1852 $<itype>1 = stmt_count;
1853 position_after_white_space (); }
1855 { c_expand_end_cond ();
1856 if (extra_warnings && stmt_count == $<itype>1)
1857 warning ("empty body in an else-statement"); }
1858 | simple_if %prec IF
1859 { c_expand_end_cond ();
1860 /* This warning is here instead of in simple_if, because we
1861 do not want a warning if an empty if is followed by an
1862 else statement. Increment stmt_count so we don't
1863 give a second error if this is a nested `if'. */
1864 if (extra_warnings && stmt_count++ == $<itype>1)
1865 warning_with_file_and_line (if_stmt_file, if_stmt_line,
1866 "empty body in an if-statement"); }
1867 /* Make sure c_expand_end_cond is run once
1868 for each call to c_expand_start_cond.
1869 Otherwise a crash is likely. */
1870 | simple_if ELSE error
1871 { c_expand_end_cond (); }
1874 emit_line_note ($<filename>-1, $<lineno>0);
1875 /* The emit_nop used to come before emit_line_note,
1876 but that made the nop seem like part of the preceding line.
1877 And that was confusing when the preceding line was
1878 inside of an if statement and was not really executed.
1879 I think it ought to work to put the nop after the line number.
1880 We will see. --rms, July 15, 1991. */
1883 { /* Don't start the loop till we have succeeded
1884 in parsing the end test. This is to make sure
1885 that we end every loop we start. */
1886 expand_start_loop (1);
1887 emit_line_note (input_filename, lineno);
1888 expand_exit_loop_if_false (NULL_PTR,
1889 truthvalue_conversion ($4));
1890 position_after_white_space (); }
1892 { expand_end_loop (); }
1895 { emit_line_note (input_filename, lineno);
1896 expand_exit_loop_if_false (NULL_PTR,
1897 truthvalue_conversion ($3));
1899 clear_momentary (); }
1900 /* This rule is needed to make sure we end every loop we start. */
1901 | do_stmt_start error
1902 { expand_end_loop ();
1903 clear_momentary (); }
1907 emit_line_note ($<filename>-1, $<lineno>0);
1908 /* See comment in `while' alternative, above. */
1910 if ($3) c_expand_expr_stmt ($3);
1911 /* Next step is to call expand_start_loop_continue_elsewhere,
1912 but wait till after we parse the entire for (...).
1913 Otherwise, invalid input might cause us to call that
1914 fn without calling expand_end_loop. */
1917 /* Can't emit now; wait till after expand_start_loop... */
1918 { $<lineno>7 = lineno;
1919 $<filename>$ = input_filename; }
1922 /* Start the loop. Doing this after parsing
1923 all the expressions ensures we will end the loop. */
1924 expand_start_loop_continue_elsewhere (1);
1925 /* Emit the end-test, with a line number. */
1926 emit_line_note ($<filename>8, $<lineno>7);
1928 expand_exit_loop_if_false (NULL_PTR,
1929 truthvalue_conversion ($6));
1930 /* Don't let the tree nodes for $9 be discarded by
1931 clear_momentary during the parsing of the next stmt. */
1933 $<lineno>7 = lineno;
1934 $<filename>8 = input_filename;
1935 position_after_white_space (); }
1937 { /* Emit the increment expression, with a line number. */
1938 emit_line_note ($<filename>8, $<lineno>7);
1939 expand_loop_continue_here ();
1941 c_expand_expr_stmt ($9);
1942 if (yychar == CONSTANT || yychar == STRING)
1943 pop_momentary_nofree ();
1946 expand_end_loop (); }
1947 | SWITCH '(' expr ')'
1949 emit_line_note ($<filename>-1, $<lineno>0);
1950 c_expand_start_case ($3);
1951 /* Don't let the tree nodes for $3 be discarded by
1952 clear_momentary during the parsing of the next stmt. */
1954 position_after_white_space (); }
1956 { expand_end_case ($3);
1957 if (yychar == CONSTANT || yychar == STRING)
1958 pop_momentary_nofree ();
1963 emit_line_note ($<filename>-1, $<lineno>0);
1964 if ( ! expand_exit_something ())
1965 error ("break statement not within loop or switch"); }
1968 emit_line_note ($<filename>-1, $<lineno>0);
1969 if (! expand_continue_loop (NULL_PTR))
1970 error ("continue statement not within a loop"); }
1973 emit_line_note ($<filename>-1, $<lineno>0);
1974 c_expand_return (NULL_TREE); }
1977 emit_line_note ($<filename>-1, $<lineno>0);
1978 c_expand_return ($2); }
1979 | ASM_KEYWORD maybe_type_qual '(' expr ')' ';'
1981 emit_line_note ($<filename>-1, $<lineno>0);
1983 if ((TREE_CODE ($4) == ADDR_EXPR
1984 && TREE_CODE (TREE_OPERAND ($4, 0)) == STRING_CST)
1985 || TREE_CODE ($4) == STRING_CST)
1988 error ("argument of `asm' is not a constant string"); }
1989 /* This is the case with just output operands. */
1990 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ')' ';'
1992 emit_line_note ($<filename>-1, $<lineno>0);
1993 c_expand_asm_operands ($4, $6, NULL_TREE, NULL_TREE,
1994 $2 == ridpointers[(int)RID_VOLATILE],
1995 input_filename, lineno); }
1996 /* This is the case with input operands as well. */
1997 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':' asm_operands ')' ';'
1999 emit_line_note ($<filename>-1, $<lineno>0);
2000 c_expand_asm_operands ($4, $6, $8, NULL_TREE,
2001 $2 == ridpointers[(int)RID_VOLATILE],
2002 input_filename, lineno); }
2003 /* This is the case with clobbered registers as well. */
2004 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':'
2005 asm_operands ':' asm_clobbers ')' ';'
2007 emit_line_note ($<filename>-1, $<lineno>0);
2008 c_expand_asm_operands ($4, $6, $8, $10,
2009 $2 == ridpointers[(int)RID_VOLATILE],
2010 input_filename, lineno); }
2011 | GOTO identifier ';'
2014 emit_line_note ($<filename>-1, $<lineno>0);
2015 decl = lookup_label ($2);
2018 TREE_USED (decl) = 1;
2024 pedwarn ("ANSI C forbids `goto *expr;'");
2026 emit_line_note ($<filename>-1, $<lineno>0);
2027 expand_computed_goto (convert (ptr_type_node, $3)); }
2032 all_iter_stmt_simple
2033 /* | all_iter_stmt_with_decl */
2036 all_iter_stmt_simple:
2039 /* The value returned by this action is */
2040 /* 1 if everything is OK */
2041 /* 0 in case of error or already bound iterator */
2044 if (TREE_CODE ($3) != VAR_DECL)
2045 error ("invalid `for (ITERATOR)' syntax");
2046 else if (! ITERATOR_P ($3))
2047 error ("`%s' is not an iterator",
2048 IDENTIFIER_POINTER (DECL_NAME ($3)));
2049 else if (ITERATOR_BOUND_P ($3))
2050 error ("`for (%s)' inside expansion of same iterator",
2051 IDENTIFIER_POINTER (DECL_NAME ($3)));
2055 iterator_for_loop_start ($3);
2061 iterator_for_loop_end ($3);
2064 /* This really should allow any kind of declaration,
2065 for generality. Fix it before turning it back on.
2067 all_iter_stmt_with_decl:
2068 FOR '(' ITERATOR pushlevel setspecs iterator_spec ')'
2070 */ /* The value returned by this action is */
2071 /* 1 if everything is OK */
2072 /* 0 in case of error or already bound iterator */
2074 iterator_for_loop_start ($6);
2078 iterator_for_loop_end ($6);
2079 emit_line_note (input_filename, lineno);
2080 expand_end_bindings (getdecls (), 1, 0);
2081 $<ttype>$ = poplevel (1, 1, 0);
2082 if (yychar == CONSTANT || yychar == STRING)
2083 pop_momentary_nofree ();
2089 /* Any kind of label, including jump labels and case labels.
2090 ANSI C accepts labels only before statements, but we allow them
2091 also at the end of a compound statement. */
2093 label: CASE expr_no_commas ':'
2094 { register tree value = check_case_value ($2);
2096 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
2100 if (value != error_mark_node)
2105 if (pedantic && ! INTEGRAL_TYPE_P (TREE_TYPE (value)))
2106 pedwarn ("label must have integral type in ANSI C");
2108 success = pushcase (value, convert_and_check,
2112 error ("case label not within a switch statement");
2113 else if (success == 2)
2115 error ("duplicate case value");
2116 error_with_decl (duplicate, "this is the first entry for that value");
2118 else if (success == 3)
2119 warning ("case value out of range");
2120 else if (success == 5)
2121 error ("case label within scope of cleanup or variable array");
2123 position_after_white_space (); }
2124 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
2125 { register tree value1 = check_case_value ($2);
2126 register tree value2 = check_case_value ($4);
2128 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
2131 pedwarn ("ANSI C forbids case ranges");
2134 if (value1 != error_mark_node && value2 != error_mark_node)
2137 int success = pushcase_range (value1, value2,
2138 convert_and_check, label,
2141 error ("case label not within a switch statement");
2142 else if (success == 2)
2144 error ("duplicate case value");
2145 error_with_decl (duplicate, "this is the first entry for that value");
2147 else if (success == 3)
2148 warning ("case value out of range");
2149 else if (success == 4)
2150 warning ("empty case range");
2151 else if (success == 5)
2152 error ("case label within scope of cleanup or variable array");
2154 position_after_white_space (); }
2159 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
2160 int success = pushcase (NULL_TREE, 0, label, &duplicate);
2163 error ("default label not within a switch statement");
2164 else if (success == 2)
2166 error ("multiple default labels in one switch");
2167 error_with_decl (duplicate, "this is the first default label");
2169 position_after_white_space (); }
2170 | identifier ':' maybe_attribute
2171 { tree label = define_label (input_filename, lineno, $1);
2176 expand_label (label);
2177 decl_attributes (label, $3, NULL_TREE);
2179 position_after_white_space (); }
2182 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
2186 { emit_line_note (input_filename, lineno);
2189 { emit_line_note (input_filename, lineno); }
2198 /* These are the operands other than the first string and colon
2199 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
2200 asm_operands: /* empty */
2202 | nonnull_asm_operands
2205 nonnull_asm_operands:
2207 | nonnull_asm_operands ',' asm_operand
2208 { $$ = chainon ($1, $3); }
2213 { $$ = build_tree_list ($1, $3); }
2218 { $$ = tree_cons (NULL_TREE, combine_strings ($1), NULL_TREE); }
2219 | asm_clobbers ',' string
2220 { $$ = tree_cons (NULL_TREE, combine_strings ($3), $1); }
2223 /* This is what appears inside the parens in a function declarator.
2224 Its value is a list of ..._TYPE nodes. */
2227 clear_parm_order ();
2228 declare_parm_level (0); }
2231 parmlist_tags_warning ();
2232 poplevel (0, 0, 0); }
2240 pedwarn ("ANSI C forbids forward parameter declarations");
2241 /* Mark the forward decls as such. */
2242 for (parm = getdecls (); parm; parm = TREE_CHAIN (parm))
2243 TREE_ASM_WRITTEN (parm) = 1;
2244 clear_parm_order (); }
2248 { $$ = tree_cons (NULL_TREE, NULL_TREE, NULL_TREE); }
2251 /* This is what appears inside the parens in a function declarator.
2252 Is value is represented in the format that grokdeclarator expects. */
2253 parmlist_2: /* empty */
2254 { $$ = get_parm_info (0); }
2256 { $$ = get_parm_info (0);
2257 /* Gcc used to allow this as an extension. However, it does
2258 not work for all targets, and thus has been disabled.
2259 Also, since func (...) and func () are indistinguishable,
2260 it caused problems with the code in expand_builtin which
2261 tries to verify that BUILT_IN_NEXT_ARG is being used
2263 error ("ANSI C requires a named argument before `...'");
2266 { $$ = get_parm_info (1); }
2267 | parms ',' ELLIPSIS
2268 { $$ = get_parm_info (0); }
2273 { push_parm_decl ($1); }
2275 { push_parm_decl ($3); }
2278 /* A single parameter declaration or parameter type name,
2279 as found in a parmlist. */
2281 typed_declspecs setspecs parm_declarator maybe_attribute
2282 { $$ = build_tree_list (build_tree_list (current_declspecs,
2284 build_tree_list (prefix_attributes,
2286 current_declspecs = TREE_VALUE (declspec_stack);
2287 prefix_attributes = TREE_PURPOSE (declspec_stack);
2288 declspec_stack = TREE_CHAIN (declspec_stack);
2289 resume_momentary ($2); }
2290 | typed_declspecs setspecs notype_declarator maybe_attribute
2291 { $$ = build_tree_list (build_tree_list (current_declspecs,
2293 build_tree_list (prefix_attributes,
2295 current_declspecs = TREE_VALUE (declspec_stack);
2296 prefix_attributes = TREE_PURPOSE (declspec_stack);
2297 declspec_stack = TREE_CHAIN (declspec_stack);
2298 resume_momentary ($2); }
2299 | typed_declspecs setspecs absdcl maybe_attribute
2300 { $$ = build_tree_list (build_tree_list (current_declspecs,
2302 build_tree_list (prefix_attributes,
2304 current_declspecs = TREE_VALUE (declspec_stack);
2305 prefix_attributes = TREE_PURPOSE (declspec_stack);
2306 declspec_stack = TREE_CHAIN (declspec_stack);
2307 resume_momentary ($2); }
2308 | declmods setspecs notype_declarator maybe_attribute
2309 { $$ = build_tree_list (build_tree_list (current_declspecs,
2311 build_tree_list (prefix_attributes,
2313 current_declspecs = TREE_VALUE (declspec_stack);
2314 prefix_attributes = TREE_PURPOSE (declspec_stack);
2315 declspec_stack = TREE_CHAIN (declspec_stack);
2316 resume_momentary ($2); }
2318 | declmods setspecs absdcl maybe_attribute
2319 { $$ = build_tree_list (build_tree_list (current_declspecs,
2321 build_tree_list (prefix_attributes,
2323 current_declspecs = TREE_VALUE (declspec_stack);
2324 prefix_attributes = TREE_PURPOSE (declspec_stack);
2325 declspec_stack = TREE_CHAIN (declspec_stack);
2326 resume_momentary ($2); }
2329 /* This is used in a function definition
2330 where either a parmlist or an identifier list is ok.
2331 Its value is a list of ..._TYPE nodes or a list of identifiers. */
2332 parmlist_or_identifiers:
2334 clear_parm_order ();
2335 declare_parm_level (1); }
2336 parmlist_or_identifiers_1
2338 parmlist_tags_warning ();
2339 poplevel (0, 0, 0); }
2342 parmlist_or_identifiers_1:
2346 for (t = $1; t; t = TREE_CHAIN (t))
2347 if (TREE_VALUE (t) == NULL_TREE)
2348 error ("`...' in old-style identifier list");
2349 $$ = tree_cons (NULL_TREE, NULL_TREE, $1); }
2352 /* A nonempty list of identifiers. */
2355 { $$ = build_tree_list (NULL_TREE, $1); }
2356 | identifiers ',' IDENTIFIER
2357 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2360 /* A nonempty list of identifiers, including typenames. */
2361 identifiers_or_typenames:
2363 { $$ = build_tree_list (NULL_TREE, $1); }
2364 | identifiers_or_typenames ',' identifier
2365 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2370 { $<itype>$ = pedantic;
2374 /* Objective-C productions. */
2384 if (objc_implementation_context)
2386 finish_class (objc_implementation_context);
2387 objc_ivar_chain = NULL_TREE;
2388 objc_implementation_context = NULL_TREE;
2391 warning ("`@end' must appear in an implementation context");
2395 /* A nonempty list of identifiers. */
2398 { $$ = build_tree_list (NULL_TREE, $1); }
2399 | identifier_list ',' identifier
2400 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2404 CLASS identifier_list ';'
2406 objc_declare_class ($2);
2410 ALIAS identifier identifier ';'
2412 objc_declare_alias ($2, $3);
2416 INTERFACE identifier protocolrefs '{'
2418 objc_interface_context = objc_ivar_context
2419 = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, $3);
2420 objc_public_flag = 0;
2424 continue_class (objc_interface_context);
2429 finish_class (objc_interface_context);
2430 objc_interface_context = NULL_TREE;
2433 | INTERFACE identifier protocolrefs
2435 objc_interface_context
2436 = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, $3);
2437 continue_class (objc_interface_context);
2442 finish_class (objc_interface_context);
2443 objc_interface_context = NULL_TREE;
2446 | INTERFACE identifier ':' identifier protocolrefs '{'
2448 objc_interface_context = objc_ivar_context
2449 = start_class (CLASS_INTERFACE_TYPE, $2, $4, $5);
2450 objc_public_flag = 0;
2454 continue_class (objc_interface_context);
2459 finish_class (objc_interface_context);
2460 objc_interface_context = NULL_TREE;
2463 | INTERFACE identifier ':' identifier protocolrefs
2465 objc_interface_context
2466 = start_class (CLASS_INTERFACE_TYPE, $2, $4, $5);
2467 continue_class (objc_interface_context);
2472 finish_class (objc_interface_context);
2473 objc_interface_context = NULL_TREE;
2476 | IMPLEMENTATION identifier '{'
2478 objc_implementation_context = objc_ivar_context
2479 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, NULL_TREE, NULL_TREE);
2480 objc_public_flag = 0;
2485 = continue_class (objc_implementation_context);
2488 | IMPLEMENTATION identifier
2490 objc_implementation_context
2491 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, NULL_TREE, NULL_TREE);
2493 = continue_class (objc_implementation_context);
2496 | IMPLEMENTATION identifier ':' identifier '{'
2498 objc_implementation_context = objc_ivar_context
2499 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2500 objc_public_flag = 0;
2505 = continue_class (objc_implementation_context);
2508 | IMPLEMENTATION identifier ':' identifier
2510 objc_implementation_context
2511 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2513 = continue_class (objc_implementation_context);
2516 | INTERFACE identifier '(' identifier ')' protocolrefs
2518 objc_interface_context
2519 = start_class (CATEGORY_INTERFACE_TYPE, $2, $4, $6);
2520 continue_class (objc_interface_context);
2525 finish_class (objc_interface_context);
2526 objc_interface_context = NULL_TREE;
2529 | IMPLEMENTATION identifier '(' identifier ')'
2531 objc_implementation_context
2532 = start_class (CATEGORY_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2534 = continue_class (objc_implementation_context);
2539 PROTOCOL identifier protocolrefs
2541 remember_protocol_qualifiers ();
2542 objc_interface_context
2543 = start_protocol(PROTOCOL_INTERFACE_TYPE, $2, $3);
2547 forget_protocol_qualifiers();
2548 finish_protocol(objc_interface_context);
2549 objc_interface_context = NULL_TREE;
2558 | non_empty_protocolrefs
2561 non_empty_protocolrefs:
2562 ARITHCOMPARE identifier_list ARITHCOMPARE
2564 if ($1 == LT_EXPR && $3 == GT_EXPR)
2572 ivar_decl_list visibility_spec ivar_decls
2577 PRIVATE { objc_public_flag = 2; }
2578 | PROTECTED { objc_public_flag = 0; }
2579 | PUBLIC { objc_public_flag = 1; }
2587 | ivar_decls ivar_decl ';'
2591 pedwarn ("extra semicolon in struct or union specified");
2596 /* There is a shift-reduce conflict here, because `components' may
2597 start with a `typename'. It happens that shifting (the default resolution)
2598 does the right thing, because it treats the `typename' as part of
2599 a `typed_typespecs'.
2601 It is possible that this same technique would allow the distinction
2602 between `notype_initdecls' and `initdecls' to be eliminated.
2603 But I am being cautious and not trying it. */
2606 typed_typespecs setspecs ivars
2608 current_declspecs = TREE_VALUE (declspec_stack);
2609 prefix_attributes = TREE_PURPOSE (declspec_stack);
2610 declspec_stack = TREE_CHAIN (declspec_stack);
2611 resume_momentary ($2); }
2612 | nonempty_type_quals setspecs ivars
2614 current_declspecs = TREE_VALUE (declspec_stack);
2615 prefix_attributes = TREE_PURPOSE (declspec_stack);
2616 declspec_stack = TREE_CHAIN (declspec_stack);
2617 resume_momentary ($2); }
2626 | ivars ',' ivar_declarator
2632 $$ = add_instance_variable (objc_ivar_context,
2634 $1, current_declspecs,
2637 | declarator ':' expr_no_commas
2639 $$ = add_instance_variable (objc_ivar_context,
2641 $1, current_declspecs, $3);
2643 | ':' expr_no_commas
2645 $$ = add_instance_variable (objc_ivar_context,
2648 current_declspecs, $2);
2655 remember_protocol_qualifiers ();
2656 if (objc_implementation_context)
2657 objc_inherit_code = CLASS_METHOD_DECL;
2659 fatal ("method definition not in class context");
2663 forget_protocol_qualifiers ();
2664 add_class_method (objc_implementation_context, $3);
2665 start_method_def ($3);
2666 objc_method_context = $3;
2670 continue_method_def ();
2674 finish_method_def ();
2675 objc_method_context = NULL_TREE;
2680 remember_protocol_qualifiers ();
2681 if (objc_implementation_context)
2682 objc_inherit_code = INSTANCE_METHOD_DECL;
2684 fatal ("method definition not in class context");
2688 forget_protocol_qualifiers ();
2689 add_instance_method (objc_implementation_context, $3);
2690 start_method_def ($3);
2691 objc_method_context = $3;
2695 continue_method_def ();
2699 finish_method_def ();
2700 objc_method_context = NULL_TREE;
2704 /* the reason for the strange actions in this rule
2705 is so that notype_initdecls when reached via datadef
2706 can find a valid list of type and sc specs in $0. */
2710 | {$<ttype>$ = NULL_TREE; } methodprotolist2
2713 methodprotolist2: /* eliminates a shift/reduce conflict */
2716 | methodprotolist2 methodproto
2717 | methodprotolist2 {$<ttype>$ = NULL_TREE; } datadef
2728 /* Remember protocol qualifiers in prototypes. */
2729 remember_protocol_qualifiers ();
2730 objc_inherit_code = CLASS_METHOD_DECL;
2734 /* Forget protocol qualifiers here. */
2735 forget_protocol_qualifiers ();
2736 add_class_method (objc_interface_context, $3);
2742 /* Remember protocol qualifiers in prototypes. */
2743 remember_protocol_qualifiers ();
2744 objc_inherit_code = INSTANCE_METHOD_DECL;
2748 /* Forget protocol qualifiers here. */
2749 forget_protocol_qualifiers ();
2750 add_instance_method (objc_interface_context, $3);
2756 '(' typename ')' unaryselector
2758 $$ = build_method_decl (objc_inherit_code, $2, $4, NULL_TREE);
2763 $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, NULL_TREE);
2766 | '(' typename ')' keywordselector optparmlist
2768 $$ = build_method_decl (objc_inherit_code, $2, $4, $5);
2771 | keywordselector optparmlist
2773 $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, $2);
2777 /* "optarglist" assumes that start_method_def has already been called...
2778 if it is not, the "xdecls" will not be placed in the proper scope */
2785 /* to get around the following situation: "int foo (int a) int b; {}" that
2786 is synthesized when parsing "- a:a b:b; id c; id d; { ... }" */
2801 typed_declspecs setspecs myparms ';'
2802 { current_declspecs = TREE_VALUE (declspec_stack);
2803 prefix_attributes = TREE_PURPOSE (declspec_stack);
2804 declspec_stack = TREE_CHAIN (declspec_stack);
2805 resume_momentary ($2); }
2806 | typed_declspecs ';'
2807 { shadow_tag ($1); }
2809 { pedwarn ("empty declaration"); }
2814 { push_parm_decl ($1); }
2815 | myparms ',' myparm
2816 { push_parm_decl ($3); }
2819 /* A single parameter declaration or parameter type name,
2820 as found in a parmlist. DOES NOT ALLOW AN INITIALIZER OR ASMSPEC */
2823 parm_declarator maybe_attribute
2824 { $$ = build_tree_list (build_tree_list (current_declspecs,
2826 build_tree_list (prefix_attributes,
2828 | notype_declarator maybe_attribute
2829 { $$ = build_tree_list (build_tree_list (current_declspecs,
2831 build_tree_list (prefix_attributes,
2833 | absdcl maybe_attribute
2834 { $$ = build_tree_list (build_tree_list (current_declspecs,
2836 build_tree_list (prefix_attributes,
2847 /* oh what a kludge! */
2856 /* returns a tree list node generated by get_parm_info */
2869 | keywordselector keyworddecl
2871 $$ = chainon ($1, $2);
2883 ENUM { $$ = get_identifier (token_buffer); }
2884 | STRUCT { $$ = get_identifier (token_buffer); }
2885 | UNION { $$ = get_identifier (token_buffer); }
2886 | IF { $$ = get_identifier (token_buffer); }
2887 | ELSE { $$ = get_identifier (token_buffer); }
2888 | WHILE { $$ = get_identifier (token_buffer); }
2889 | DO { $$ = get_identifier (token_buffer); }
2890 | FOR { $$ = get_identifier (token_buffer); }
2891 | SWITCH { $$ = get_identifier (token_buffer); }
2892 | CASE { $$ = get_identifier (token_buffer); }
2893 | DEFAULT { $$ = get_identifier (token_buffer); }
2894 | BREAK { $$ = get_identifier (token_buffer); }
2895 | CONTINUE { $$ = get_identifier (token_buffer); }
2896 | RETURN { $$ = get_identifier (token_buffer); }
2897 | GOTO { $$ = get_identifier (token_buffer); }
2898 | ASM_KEYWORD { $$ = get_identifier (token_buffer); }
2899 | SIZEOF { $$ = get_identifier (token_buffer); }
2900 | TYPEOF { $$ = get_identifier (token_buffer); }
2901 | ALIGNOF { $$ = get_identifier (token_buffer); }
2902 | TYPESPEC | TYPE_QUAL
2906 selector ':' '(' typename ')' identifier
2908 $$ = build_keyword_decl ($1, $4, $6);
2911 | selector ':' identifier
2913 $$ = build_keyword_decl ($1, NULL_TREE, $3);
2916 | ':' '(' typename ')' identifier
2918 $$ = build_keyword_decl (NULL_TREE, $3, $5);
2923 $$ = build_keyword_decl (NULL_TREE, NULL_TREE, $2);
2934 | keywordarglist keywordarg
2936 $$ = chainon ($1, $2);
2944 if (TREE_CHAIN ($1) == NULL_TREE)
2945 /* just return the expr., remove a level of indirection */
2946 $$ = TREE_VALUE ($1);
2948 /* we have a comma expr., we will collapse later */
2954 selector ':' keywordexpr
2956 $$ = build_tree_list ($1, $3);
2960 $$ = build_tree_list (NULL_TREE, $2);
2968 $$ = get_class_reference ($1);
2974 { objc_receiver_context = 1; }
2976 { objc_receiver_context = 0; }
2979 $$ = build_tree_list ($3, $5);
2990 | keywordnamelist keywordname
2992 $$ = chainon ($1, $2);
2999 $$ = build_tree_list ($1, NULL_TREE);
3003 $$ = build_tree_list (NULL_TREE, NULL_TREE);
3008 SELECTOR '(' selectorarg ')'
3015 PROTOCOL '(' identifier ')'
3021 /* extension to support C-structures in the archiver */
3024 ENCODE '(' typename ')'
3026 $$ = groktypename ($3);