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-99, 2000 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. */
46 #ifdef MULTIBYTE_CHARS
52 /* Since parsers are distinct for each language, put the language string
54 const char * const language_string = "GNU Obj-C";
56 /* Like YYERROR but do call yyerror. */
57 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
59 /* Cause the `yydebug' variable to be defined. */
65 %union {long itype; tree ttype; enum tree_code code;
66 char *filename; int lineno; int ends_in_label; }
68 /* All identifiers that are not reserved words
69 and are not declared typedefs in the current block */
72 /* All identifiers that are declared typedefs in the current block.
73 In some contexts, they are treated just like IDENTIFIER,
74 but they can also serve as typespecs in declarations. */
77 /* Reserved words that specify storage class.
78 yylval contains an IDENTIFIER_NODE which indicates which one. */
81 /* Reserved words that specify type.
82 yylval contains an IDENTIFIER_NODE which indicates which one. */
85 /* Reserved words that qualify type: "const", "volatile", or "restrict".
86 yylval contains an IDENTIFIER_NODE which indicates which one. */
89 /* Character or numeric constants.
90 yylval is the node for the constant. */
93 /* String constants in raw form.
94 yylval is a STRING_CST node. */
97 /* "...", used for functions with variable arglists. */
100 /* the reserved words */
101 /* SCO include files test "ASM", so use something else. */
102 %token SIZEOF ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
103 %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD TYPEOF ALIGNOF
104 %token ATTRIBUTE EXTENSION LABEL
105 %token REALPART IMAGPART VA_ARG
107 /* Used in c-lex.c for parsing pragmas. */
110 /* Add precedence rules to solve dangling else s/r conflict */
114 /* Define the operator tokens and their precedences.
115 The value is an integer because, if used, it is the tree code
116 to use in the expression made from the operator. */
118 %right <code> ASSIGN '='
119 %right <code> '?' ':'
125 %left <code> EQCOMPARE
126 %left <code> ARITHCOMPARE
127 %left <code> LSHIFT RSHIFT
129 %left <code> '*' '/' '%'
130 %right <code> UNARY PLUSPLUS MINUSMINUS
132 %left <code> POINTSAT '.' '(' '['
134 /* The Objective-C keywords. These are included in C and in
135 Objective C, so that the token codes are the same in both. */
136 %token INTERFACE IMPLEMENTATION END SELECTOR DEFS ENCODE
137 %token CLASSNAME PUBLIC PRIVATE PROTECTED PROTOCOL OBJECTNAME CLASS ALIAS
139 /* Objective-C string constants in raw form.
140 yylval is an OBJC_STRING_CST node. */
146 %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist exprlist
147 %type <ttype> expr_no_commas cast_expr unary_expr primary string STRING
148 %type <ttype> typed_declspecs reserved_declspecs
149 %type <ttype> typed_typespecs reserved_typespecquals
150 %type <ttype> declmods typespec typespecqual_reserved
151 %type <ttype> typed_declspecs_no_prefix_attr reserved_declspecs_no_prefix_attr
152 %type <ttype> declmods_no_prefix_attr
153 %type <ttype> SCSPEC TYPESPEC TYPE_QUAL nonempty_type_quals maybe_type_qual
154 %type <ttype> initdecls notype_initdecls initdcl notype_initdcl
155 %type <ttype> init maybeasm
156 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
157 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
158 %type <ttype> any_word extension
160 %type <ttype> compstmt compstmt_nostart compstmt_primary_start
162 %type <ttype> declarator
163 %type <ttype> notype_declarator after_type_declarator
164 %type <ttype> parm_declarator
166 %type <ttype> structsp component_decl_list component_decl_list2
167 %type <ttype> component_decl components component_declarator
168 %type <ttype> enumlist enumerator
169 %type <ttype> struct_head union_head enum_head
170 %type <ttype> typename absdcl absdcl1 type_quals
171 %type <ttype> xexpr parms parm identifiers
173 %type <ttype> parmlist parmlist_1 parmlist_2
174 %type <ttype> parmlist_or_identifiers parmlist_or_identifiers_1
175 %type <ttype> identifiers_or_typenames
177 %type <itype> setspecs
179 %type <ends_in_label> lineno_stmt_or_label lineno_stmt_or_labels stmt_or_label
181 %type <filename> save_filename
182 %type <lineno> save_lineno
184 /* the Objective-C nonterminals */
186 %type <ttype> ivar_decl_list ivar_decls ivar_decl ivars ivar_declarator
187 %type <ttype> methoddecl unaryselector keywordselector selector
188 %type <ttype> keyworddecl receiver objcmessageexpr messageargs
189 %type <ttype> keywordexpr keywordarglist keywordarg
190 %type <ttype> myparms myparm optparmlist reservedwords objcselectorexpr
191 %type <ttype> selectorarg keywordnamelist keywordname objcencodeexpr
192 %type <ttype> objc_string non_empty_protocolrefs protocolrefs identifier_list objcprotocolexpr
194 %type <ttype> CLASSNAME OBJC_STRING OBJECTNAME
197 /* Number of statements (loosely speaking) and compound statements
199 static int stmt_count;
200 static int compstmt_count;
202 /* Input file and line number of the end of the body of last simple_if;
203 used by the stmt-rule immediately after simple_if returns. */
204 static char *if_stmt_file;
205 static int if_stmt_line;
207 /* List of types and structure classes of the current declaration. */
208 static tree current_declspecs = NULL_TREE;
209 static tree prefix_attributes = NULL_TREE;
211 /* Stack of saved values of current_declspecs and prefix_attributes. */
212 static tree declspec_stack;
214 /* 1 if we explained undeclared var errors. */
215 static int undeclared_variable_notice;
217 /* For __extension__, save/restore the warning flags which are
218 controlled by __extension__. */
219 #define SAVE_WARN_FLAGS() \
220 build_int_2 (pedantic | (warn_pointer_arith << 1), 0)
221 #define RESTORE_WARN_FLAGS(tval) \
223 int val = TREE_INT_CST_LOW (tval); \
224 pedantic = val & 1; \
225 warn_pointer_arith = (val >> 1) & 1; \
228 /* Objective-C specific information */
230 tree objc_interface_context;
231 tree objc_implementation_context;
232 tree objc_method_context;
233 tree objc_ivar_chain;
234 tree objc_ivar_context;
235 enum tree_code objc_inherit_code;
236 int objc_receiver_context;
237 int objc_public_flag;
240 /* Tell yyparse how to print a token's value, if yydebug is set. */
242 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
243 extern void yyprint PARAMS ((FILE *, int, YYSTYPE));
245 /* Add GC roots for variables local to this file. */
249 ggc_add_tree_root (&declspec_stack, 1);
250 ggc_add_tree_root (¤t_declspecs, 1);
251 ggc_add_tree_root (&prefix_attributes, 1);
259 pedwarn ("ANSI C forbids an empty source file");
264 /* In case there were missing closebraces,
265 get us back to the global binding level. */
266 while (! global_bindings_p ())
272 /* the reason for the strange actions in this rule
273 is so that notype_initdecls when reached via datadef
274 can find a valid list of type and sc specs in $0. */
277 {$<ttype>$ = NULL_TREE; } extdef
278 | extdefs {$<ttype>$ = NULL_TREE; } extdef
285 | ASM_KEYWORD '(' expr ')' ';'
287 if ((TREE_CODE ($3) == ADDR_EXPR
288 && TREE_CODE (TREE_OPERAND ($3, 0)) == STRING_CST)
289 || TREE_CODE ($3) == STRING_CST)
292 error ("argument of `asm' is not a constant string"); }
294 { RESTORE_WARN_FLAGS ($1); }
298 setspecs notype_initdecls ';'
300 error ("ANSI C forbids data definition with no type or storage class");
301 else if (!flag_traditional)
302 warning ("data definition has no type or storage class");
304 current_declspecs = TREE_VALUE (declspec_stack);
305 prefix_attributes = TREE_PURPOSE (declspec_stack);
306 declspec_stack = TREE_CHAIN (declspec_stack); }
307 | declmods setspecs notype_initdecls ';'
308 { current_declspecs = TREE_VALUE (declspec_stack);
309 prefix_attributes = TREE_PURPOSE (declspec_stack);
310 declspec_stack = TREE_CHAIN (declspec_stack); }
311 | typed_declspecs setspecs initdecls ';'
312 { current_declspecs = TREE_VALUE (declspec_stack);
313 prefix_attributes = TREE_PURPOSE (declspec_stack);
314 declspec_stack = TREE_CHAIN (declspec_stack); }
316 { pedwarn ("empty declaration"); }
317 | typed_declspecs ';'
323 pedwarn ("ANSI C does not allow extra `;' outside of a function"); }
327 typed_declspecs setspecs declarator
328 { if (! start_function (current_declspecs, $3,
329 prefix_attributes, NULL_TREE))
331 reinit_parse_for_function (); }
333 { store_parm_decls (); }
335 { finish_function (0);
336 current_declspecs = TREE_VALUE (declspec_stack);
337 prefix_attributes = TREE_PURPOSE (declspec_stack);
338 declspec_stack = TREE_CHAIN (declspec_stack); }
339 | typed_declspecs setspecs declarator error
340 { current_declspecs = TREE_VALUE (declspec_stack);
341 prefix_attributes = TREE_PURPOSE (declspec_stack);
342 declspec_stack = TREE_CHAIN (declspec_stack); }
343 | declmods setspecs notype_declarator
344 { if (! start_function (current_declspecs, $3,
345 prefix_attributes, NULL_TREE))
347 reinit_parse_for_function (); }
349 { store_parm_decls (); }
351 { finish_function (0);
352 current_declspecs = TREE_VALUE (declspec_stack);
353 prefix_attributes = TREE_PURPOSE (declspec_stack);
354 declspec_stack = TREE_CHAIN (declspec_stack); }
355 | declmods setspecs notype_declarator error
356 { current_declspecs = TREE_VALUE (declspec_stack);
357 prefix_attributes = TREE_PURPOSE (declspec_stack);
358 declspec_stack = TREE_CHAIN (declspec_stack); }
359 | setspecs notype_declarator
360 { if (! start_function (NULL_TREE, $2,
361 prefix_attributes, NULL_TREE))
363 reinit_parse_for_function (); }
365 { store_parm_decls (); }
367 { finish_function (0);
368 current_declspecs = TREE_VALUE (declspec_stack);
369 prefix_attributes = TREE_PURPOSE (declspec_stack);
370 declspec_stack = TREE_CHAIN (declspec_stack); }
371 | setspecs notype_declarator error
372 { current_declspecs = TREE_VALUE (declspec_stack);
373 prefix_attributes = TREE_PURPOSE (declspec_stack);
374 declspec_stack = TREE_CHAIN (declspec_stack); }
387 { $$ = NEGATE_EXPR; }
389 { $$ = CONVERT_EXPR; }
391 { $$ = PREINCREMENT_EXPR; }
393 { $$ = PREDECREMENT_EXPR; }
395 { $$ = BIT_NOT_EXPR; }
397 { $$ = TRUTH_NOT_EXPR; }
400 expr: nonnull_exprlist
401 { $$ = build_compound_expr ($1); }
412 { $$ = build_tree_list (NULL_TREE, $1); }
413 | nonnull_exprlist ',' expr_no_commas
414 { chainon ($1, build_tree_list (NULL_TREE, $3)); }
419 | '*' cast_expr %prec UNARY
420 { $$ = build_indirect_ref ($2, "unary *"); }
421 /* __extension__ turns off -pedantic for following primary. */
422 | extension cast_expr %prec UNARY
424 RESTORE_WARN_FLAGS ($1); }
425 | unop cast_expr %prec UNARY
426 { $$ = build_unary_op ($1, $2, 0);
427 overflow_warning ($$); }
428 /* Refer to the address of a label as a pointer. */
430 { tree label = lookup_label ($2);
432 pedwarn ("ANSI C forbids `&&'");
434 $$ = null_pointer_node;
437 TREE_USED (label) = 1;
438 $$ = build1 (ADDR_EXPR, ptr_type_node, label);
439 TREE_CONSTANT ($$) = 1;
442 /* This seems to be impossible on some machines, so let's turn it off.
443 You can use __builtin_next_arg to find the anonymous stack args.
445 { tree types = TYPE_ARG_TYPES (TREE_TYPE (current_function_decl));
446 $$ = error_mark_node;
447 if (TREE_VALUE (tree_last (types)) == void_type_node)
448 error ("`&...' used in function with fixed number of arguments");
452 pedwarn ("ANSI C forbids `&...'");
453 $$ = tree_last (DECL_ARGUMENTS (current_function_decl));
454 $$ = build_unary_op (ADDR_EXPR, $$, 0);
457 | sizeof unary_expr %prec UNARY
459 if (TREE_CODE ($2) == COMPONENT_REF
460 && DECL_C_BIT_FIELD (TREE_OPERAND ($2, 1)))
461 error ("`sizeof' applied to a bit-field");
462 $$ = c_sizeof (TREE_TYPE ($2)); }
463 | sizeof '(' typename ')' %prec HYPERUNARY
465 $$ = c_sizeof (groktypename ($3)); }
466 | alignof unary_expr %prec UNARY
468 $$ = c_alignof_expr ($2); }
469 | alignof '(' typename ')' %prec HYPERUNARY
471 $$ = c_alignof (groktypename ($3)); }
472 | REALPART cast_expr %prec UNARY
473 { $$ = build_unary_op (REALPART_EXPR, $2, 0); }
474 | IMAGPART cast_expr %prec UNARY
475 { $$ = build_unary_op (IMAGPART_EXPR, $2, 0); }
476 | VA_ARG '(' expr_no_commas ',' typename ')'
477 { $$ = build_va_arg ($3, groktypename ($5)); }
481 SIZEOF { skip_evaluation++; }
485 ALIGNOF { skip_evaluation++; }
490 | '(' typename ')' cast_expr %prec UNARY
491 { tree type = groktypename ($2);
492 $$ = build_c_cast (type, $4); }
493 | '(' typename ')' '{'
494 { start_init (NULL_TREE, NULL, 0);
495 $2 = groktypename ($2);
496 really_start_incremental_init ($2); }
497 initlist_maybe_comma '}' %prec UNARY
499 tree result = pop_init_level (0);
503 if (pedantic && ! flag_isoc99)
504 pedwarn ("ANSI C forbids constructor expressions");
505 if (TYPE_NAME (type) != 0)
507 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
508 name = IDENTIFIER_POINTER (TYPE_NAME (type));
510 name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
515 if (TREE_CODE (type) == ARRAY_TYPE && TYPE_SIZE (type) == 0)
517 int failure = complete_array_type (type, $$, 1);
526 | expr_no_commas '+' expr_no_commas
527 { $$ = parser_build_binary_op ($2, $1, $3); }
528 | expr_no_commas '-' expr_no_commas
529 { $$ = parser_build_binary_op ($2, $1, $3); }
530 | expr_no_commas '*' expr_no_commas
531 { $$ = parser_build_binary_op ($2, $1, $3); }
532 | expr_no_commas '/' expr_no_commas
533 { $$ = parser_build_binary_op ($2, $1, $3); }
534 | expr_no_commas '%' expr_no_commas
535 { $$ = parser_build_binary_op ($2, $1, $3); }
536 | expr_no_commas LSHIFT expr_no_commas
537 { $$ = parser_build_binary_op ($2, $1, $3); }
538 | expr_no_commas RSHIFT expr_no_commas
539 { $$ = parser_build_binary_op ($2, $1, $3); }
540 | expr_no_commas ARITHCOMPARE expr_no_commas
541 { $$ = parser_build_binary_op ($2, $1, $3); }
542 | expr_no_commas EQCOMPARE expr_no_commas
543 { $$ = parser_build_binary_op ($2, $1, $3); }
544 | expr_no_commas '&' expr_no_commas
545 { $$ = parser_build_binary_op ($2, $1, $3); }
546 | expr_no_commas '|' expr_no_commas
547 { $$ = parser_build_binary_op ($2, $1, $3); }
548 | expr_no_commas '^' expr_no_commas
549 { $$ = parser_build_binary_op ($2, $1, $3); }
550 | expr_no_commas ANDAND
551 { $1 = truthvalue_conversion (default_conversion ($1));
552 skip_evaluation += $1 == boolean_false_node; }
554 { skip_evaluation -= $1 == boolean_false_node;
555 $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $4); }
556 | expr_no_commas OROR
557 { $1 = truthvalue_conversion (default_conversion ($1));
558 skip_evaluation += $1 == boolean_true_node; }
560 { skip_evaluation -= $1 == boolean_true_node;
561 $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $4); }
563 { $1 = truthvalue_conversion (default_conversion ($1));
564 skip_evaluation += $1 == boolean_false_node; }
566 { skip_evaluation += (($1 == boolean_true_node)
567 - ($1 == boolean_false_node)); }
569 { skip_evaluation -= $1 == boolean_true_node;
570 $$ = build_conditional_expr ($1, $4, $7); }
573 pedwarn ("ANSI C forbids omitting the middle term of a ?: expression");
574 /* Make sure first operand is calculated only once. */
575 $<ttype>2 = save_expr ($1);
576 $1 = truthvalue_conversion (default_conversion ($<ttype>2));
577 skip_evaluation += $1 == boolean_true_node; }
579 { skip_evaluation -= $1 == boolean_true_node;
580 $$ = build_conditional_expr ($1, $<ttype>2, $5); }
581 | expr_no_commas '=' expr_no_commas
583 $$ = build_modify_expr ($1, NOP_EXPR, $3);
584 class = TREE_CODE_CLASS (TREE_CODE ($$));
585 if (class == 'e' || class == '1'
586 || class == '2' || class == '<')
587 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR);
589 | expr_no_commas ASSIGN expr_no_commas
591 $$ = build_modify_expr ($1, $2, $3);
592 /* This inhibits warnings in truthvalue_conversion. */
593 class = TREE_CODE_CLASS (TREE_CODE ($$));
594 if (class == 'e' || class == '1'
595 || class == '2' || class == '<')
596 C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK);
604 if (!$$ || $$ == error_mark_node)
606 if (yychar == YYEMPTY)
612 if (objc_receiver_context
613 && ! (objc_receiver_context
614 && strcmp (IDENTIFIER_POINTER ($1), "super")))
615 /* we have a message to super */
616 $$ = get_super_receiver ();
617 else if (objc_method_context
618 && (decl = is_ivar (objc_ivar_chain, $1)))
620 if (is_private (decl))
621 $$ = error_mark_node;
623 $$ = build_ivar_reference ($1);
627 /* Ordinary implicit function declaration. */
628 $$ = implicitly_declare ($1);
629 assemble_external ($$);
633 else if (current_function_decl == 0)
635 error ("`%s' undeclared here (not in a function)",
636 IDENTIFIER_POINTER ($1));
637 $$ = error_mark_node;
643 if (objc_receiver_context
644 && ! strcmp (IDENTIFIER_POINTER ($1), "super"))
645 /* we have a message to super */
646 $$ = get_super_receiver ();
647 else if (objc_method_context
648 && (decl = is_ivar (objc_ivar_chain, $1)))
650 if (is_private (decl))
651 $$ = error_mark_node;
653 $$ = build_ivar_reference ($1);
657 if (IDENTIFIER_GLOBAL_VALUE ($1) != error_mark_node
658 || IDENTIFIER_ERROR_LOCUS ($1) != current_function_decl)
660 error ("`%s' undeclared (first use in this function)",
661 IDENTIFIER_POINTER ($1));
663 if (! undeclared_variable_notice)
665 error ("(Each undeclared identifier is reported only once");
666 error ("for each function it appears in.)");
667 undeclared_variable_notice = 1;
670 $$ = error_mark_node;
671 /* Prevent repeated error messages. */
672 IDENTIFIER_GLOBAL_VALUE ($1) = error_mark_node;
673 IDENTIFIER_ERROR_LOCUS ($1) = current_function_decl;
677 else if (TREE_TYPE ($$) == error_mark_node)
678 $$ = error_mark_node;
679 else if (C_DECL_ANTICIPATED ($$))
681 /* The first time we see a build-in function used,
682 if it has not been declared. */
683 C_DECL_ANTICIPATED ($$) = 0;
684 if (yychar == YYEMPTY)
688 /* Omit the implicit declaration we
689 would ordinarily do, so we don't lose
690 the actual built in type.
691 But print a diagnostic for the mismatch. */
692 if (objc_method_context
693 && is_ivar (objc_ivar_chain, $1))
694 error ("Instance variable `%s' implicitly declared as function",
695 IDENTIFIER_POINTER (DECL_NAME ($$)));
697 if (TREE_CODE ($$) != FUNCTION_DECL)
698 error ("`%s' implicitly declared as function",
699 IDENTIFIER_POINTER (DECL_NAME ($$)));
700 else if ((TYPE_MODE (TREE_TYPE (TREE_TYPE ($$)))
701 != TYPE_MODE (integer_type_node))
702 && (TREE_TYPE (TREE_TYPE ($$))
704 pedwarn ("type mismatch in implicit declaration for built-in function `%s'",
705 IDENTIFIER_POINTER (DECL_NAME ($$)));
706 /* If it really returns void, change that to int. */
707 if (TREE_TYPE (TREE_TYPE ($$)) == void_type_node)
709 = build_function_type (integer_type_node,
710 TYPE_ARG_TYPES (TREE_TYPE ($$)));
713 pedwarn ("built-in function `%s' used without declaration",
714 IDENTIFIER_POINTER (DECL_NAME ($$)));
716 /* Do what we would ordinarily do when a fn is used. */
717 assemble_external ($$);
722 assemble_external ($$);
724 /* we have a definition - still check if iVariable */
726 if (!objc_receiver_context
727 || (objc_receiver_context
728 && strcmp (IDENTIFIER_POINTER ($1), "super")))
732 if (objc_method_context
733 && (decl = is_ivar (objc_ivar_chain, $1)))
735 if (IDENTIFIER_LOCAL_VALUE ($1))
736 warning ("local declaration of `%s' hides instance variable",
737 IDENTIFIER_POINTER ($1));
740 if (is_private (decl))
741 $$ = error_mark_node;
743 $$ = build_ivar_reference ($1);
747 else /* we have a message to super */
748 $$ = get_super_receiver ();
751 if (TREE_CODE ($$) == CONST_DECL)
753 $$ = DECL_INITIAL ($$);
754 /* This is to prevent an enum whose value is 0
755 from being considered a null pointer constant. */
756 $$ = build1 (NOP_EXPR, TREE_TYPE ($$), $$);
757 TREE_CONSTANT ($$) = 1;
762 { $$ = combine_strings ($1); }
764 { char class = TREE_CODE_CLASS (TREE_CODE ($2));
765 if (class == 'e' || class == '1'
766 || class == '2' || class == '<')
767 C_SET_EXP_ORIGINAL_CODE ($2, ERROR_MARK);
770 { $$ = error_mark_node; }
771 | compstmt_primary_start compstmt_nostart ')'
774 pedwarn ("ANSI C forbids braced-groups within expressions");
775 pop_iterator_stack ();
777 rtl_exp = expand_end_stmt_expr ($1);
778 /* The statements have side effects, so the group does. */
779 TREE_SIDE_EFFECTS (rtl_exp) = 1;
781 if (TREE_CODE ($2) == BLOCK)
783 /* Make a BIND_EXPR for the BLOCK already made. */
784 $$ = build (BIND_EXPR, TREE_TYPE (rtl_exp),
785 NULL_TREE, rtl_exp, $2);
786 /* Remove the block from the tree at this point.
787 It gets put back at the proper place
788 when the BIND_EXPR is expanded. */
794 | compstmt_primary_start error ')'
796 /* Make sure we call expand_end_stmt_expr. Otherwise
797 we are likely to lose sequences and crash later. */
798 pop_iterator_stack ();
800 expand_end_stmt_expr ($1);
801 $$ = error_mark_node;
803 | primary '(' exprlist ')' %prec '.'
804 { $$ = build_function_call ($1, $3); }
805 | primary '[' expr ']' %prec '.'
806 { $$ = build_array_ref ($1, $3); }
807 | primary '.' identifier
809 if (doing_objc_thang)
811 if (is_public ($1, $3))
812 $$ = build_component_ref ($1, $3);
814 $$ = error_mark_node;
817 $$ = build_component_ref ($1, $3);
819 | primary POINTSAT identifier
821 tree expr = build_indirect_ref ($1, "->");
823 if (doing_objc_thang)
825 if (is_public (expr, $3))
826 $$ = build_component_ref (expr, $3);
828 $$ = error_mark_node;
831 $$ = build_component_ref (expr, $3);
834 { $$ = build_unary_op (POSTINCREMENT_EXPR, $1, 0); }
836 { $$ = build_unary_op (POSTDECREMENT_EXPR, $1, 0); }
838 { $$ = build_message_expr ($1); }
840 { $$ = build_selector_expr ($1); }
842 { $$ = build_protocol_expr ($1); }
844 { $$ = build_encode_expr ($1); }
846 { $$ = build_objc_string_object ($1); }
849 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
853 { $$ = chainon ($1, $2);
857 /* Produces an OBJC_STRING_CST with perhaps more OBJC_STRING_CSTs chained
861 | objc_string OBJC_STRING
862 { $$ = chainon ($1, $2); }
865 old_style_parm_decls:
869 /* ... is used here to indicate a varargs function. */
872 pedwarn ("ANSI C does not permit use of `varargs.h'"); }
875 /* The following are analogous to lineno_decl, decls and decl
876 except that they do not allow nested functions.
877 They are used for old-style parm decls. */
879 save_filename save_lineno datadecl
886 | datadecls lineno_datadecl
887 | lineno_datadecl errstmt
890 /* We don't allow prefix attributes here because they cause reduce/reduce
891 conflicts: we can't know whether we're parsing a function decl with
892 attribute suffix, or function defn with attribute prefix on first old
895 typed_declspecs_no_prefix_attr setspecs initdecls ';'
896 { current_declspecs = TREE_VALUE (declspec_stack);
897 prefix_attributes = TREE_PURPOSE (declspec_stack);
898 declspec_stack = TREE_CHAIN (declspec_stack); }
899 | declmods_no_prefix_attr setspecs notype_initdecls ';'
900 { current_declspecs = TREE_VALUE (declspec_stack);
901 prefix_attributes = TREE_PURPOSE (declspec_stack);
902 declspec_stack = TREE_CHAIN (declspec_stack); }
903 | typed_declspecs_no_prefix_attr ';'
904 { shadow_tag_warned ($1, 1);
905 pedwarn ("empty declaration"); }
906 | declmods_no_prefix_attr ';'
907 { pedwarn ("empty declaration"); }
910 /* This combination which saves a lineno before a decl
911 is the normal thing to use, rather than decl itself.
912 This is to avoid shift/reduce conflicts in contexts
913 where statement labels are allowed. */
915 save_filename save_lineno decl
923 | lineno_decl errstmt
926 /* records the type and storage class specs to use for processing
927 the declarators that follow.
928 Maintains a stack of outer-level values of current_declspecs,
929 for the sake of parm declarations nested in function declarators. */
930 setspecs: /* empty */
931 { pending_xref_error ();
932 declspec_stack = tree_cons (prefix_attributes,
935 split_specs_attrs ($<ttype>0,
936 ¤t_declspecs, &prefix_attributes); }
939 /* ??? Yuck. See after_type_declarator. */
940 setattrs: /* empty */
941 { prefix_attributes = chainon (prefix_attributes, $<ttype>0); }
945 typed_declspecs setspecs initdecls ';'
946 { current_declspecs = TREE_VALUE (declspec_stack);
947 prefix_attributes = TREE_PURPOSE (declspec_stack);
948 declspec_stack = TREE_CHAIN (declspec_stack); }
949 | declmods setspecs notype_initdecls ';'
950 { current_declspecs = TREE_VALUE (declspec_stack);
951 prefix_attributes = TREE_PURPOSE (declspec_stack);
952 declspec_stack = TREE_CHAIN (declspec_stack); }
953 | typed_declspecs setspecs nested_function
954 { current_declspecs = TREE_VALUE (declspec_stack);
955 prefix_attributes = TREE_PURPOSE (declspec_stack);
956 declspec_stack = TREE_CHAIN (declspec_stack); }
957 | declmods setspecs notype_nested_function
958 { current_declspecs = TREE_VALUE (declspec_stack);
959 prefix_attributes = TREE_PURPOSE (declspec_stack);
960 declspec_stack = TREE_CHAIN (declspec_stack); }
961 | typed_declspecs ';'
964 { pedwarn ("empty declaration"); }
966 { RESTORE_WARN_FLAGS ($1); }
969 /* Declspecs which contain at least one type specifier or typedef name.
970 (Just `const' or `volatile' is not enough.)
971 A typedef'd name following these is taken as a name to be declared.
972 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
975 typespec reserved_declspecs
976 { $$ = tree_cons (NULL_TREE, $1, $2); }
977 | declmods typespec reserved_declspecs
978 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
981 reserved_declspecs: /* empty */
983 | reserved_declspecs typespecqual_reserved
984 { $$ = tree_cons (NULL_TREE, $2, $1); }
985 | reserved_declspecs SCSPEC
986 { if (extra_warnings)
987 warning ("`%s' is not at beginning of declaration",
988 IDENTIFIER_POINTER ($2));
989 $$ = tree_cons (NULL_TREE, $2, $1); }
990 | reserved_declspecs attributes
991 { $$ = tree_cons ($2, NULL_TREE, $1); }
994 typed_declspecs_no_prefix_attr:
995 typespec reserved_declspecs_no_prefix_attr
996 { $$ = tree_cons (NULL_TREE, $1, $2); }
997 | declmods_no_prefix_attr typespec reserved_declspecs_no_prefix_attr
998 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
1001 reserved_declspecs_no_prefix_attr:
1004 | reserved_declspecs_no_prefix_attr typespecqual_reserved
1005 { $$ = tree_cons (NULL_TREE, $2, $1); }
1006 | reserved_declspecs_no_prefix_attr SCSPEC
1007 { if (extra_warnings)
1008 warning ("`%s' is not at beginning of declaration",
1009 IDENTIFIER_POINTER ($2));
1010 $$ = tree_cons (NULL_TREE, $2, $1); }
1013 /* List of just storage classes, type modifiers, and prefix attributes.
1014 A declaration can start with just this, but then it cannot be used
1015 to redeclare a typedef-name.
1016 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
1019 declmods_no_prefix_attr
1022 { $$ = tree_cons ($1, NULL_TREE, NULL_TREE); }
1023 | declmods declmods_no_prefix_attr
1024 { $$ = chainon ($2, $1); }
1025 | declmods attributes
1026 { $$ = tree_cons ($2, NULL_TREE, $1); }
1029 declmods_no_prefix_attr:
1031 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
1032 TREE_STATIC ($$) = 1; }
1034 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
1035 | declmods_no_prefix_attr TYPE_QUAL
1036 { $$ = tree_cons (NULL_TREE, $2, $1);
1037 TREE_STATIC ($$) = 1; }
1038 | declmods_no_prefix_attr SCSPEC
1039 { if (extra_warnings && TREE_STATIC ($1))
1040 warning ("`%s' is not at beginning of declaration",
1041 IDENTIFIER_POINTER ($2));
1042 $$ = tree_cons (NULL_TREE, $2, $1);
1043 TREE_STATIC ($$) = TREE_STATIC ($1); }
1047 /* Used instead of declspecs where storage classes are not allowed
1048 (that is, for typenames and structure components).
1049 Don't accept a typedef-name if anything but a modifier precedes it. */
1052 typespec reserved_typespecquals
1053 { $$ = tree_cons (NULL_TREE, $1, $2); }
1054 | nonempty_type_quals typespec reserved_typespecquals
1055 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
1058 reserved_typespecquals: /* empty */
1060 | reserved_typespecquals typespecqual_reserved
1061 { $$ = tree_cons (NULL_TREE, $2, $1); }
1064 /* A typespec (but not a type qualifier).
1065 Once we have seen one of these in a declaration,
1066 if a typedef name appears then it is being redeclared. */
1071 { /* For a typedef name, record the meaning, not the name.
1072 In case of `foo foo, bar;'. */
1073 $$ = lookup_name ($1); }
1074 | CLASSNAME protocolrefs
1075 { $$ = get_static_reference ($1, $2); }
1076 | OBJECTNAME protocolrefs
1077 { $$ = get_object_reference ($2); }
1079 /* Make "<SomeProtocol>" equivalent to "id <SomeProtocol>"
1080 - nisse@lysator.liu.se */
1081 | non_empty_protocolrefs
1082 { $$ = get_object_reference ($1); }
1083 | TYPEOF '(' expr ')'
1084 { $$ = TREE_TYPE ($3); }
1085 | TYPEOF '(' typename ')'
1086 { $$ = groktypename ($3); }
1089 /* A typespec that is a reserved word, or a type qualifier. */
1091 typespecqual_reserved: TYPESPEC
1098 | initdecls ',' initdcl
1103 | notype_initdecls ',' initdcl
1109 | ASM_KEYWORD '(' string ')'
1110 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
1116 declarator maybeasm maybe_attribute '='
1117 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1118 $3, prefix_attributes);
1119 start_init ($<ttype>$, $2, global_bindings_p ()); }
1121 /* Note how the declaration of the variable is in effect while its init is parsed! */
1123 finish_decl ($<ttype>5, $6, $2); }
1124 | declarator maybeasm maybe_attribute
1125 { tree d = start_decl ($1, current_declspecs, 0,
1126 $3, prefix_attributes);
1127 finish_decl (d, NULL_TREE, $2);
1132 notype_declarator maybeasm maybe_attribute '='
1133 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1134 $3, prefix_attributes);
1135 start_init ($<ttype>$, $2, global_bindings_p ()); }
1137 /* Note how the declaration of the variable is in effect while its init is parsed! */
1139 decl_attributes ($<ttype>5, $3, prefix_attributes);
1140 finish_decl ($<ttype>5, $6, $2); }
1141 | notype_declarator maybeasm maybe_attribute
1142 { tree d = start_decl ($1, current_declspecs, 0,
1143 $3, prefix_attributes);
1144 finish_decl (d, NULL_TREE, $2); }
1146 /* the * rules are dummies to accept the Apollo extended syntax
1147 so that the header files compile. */
1158 | attributes attribute
1159 { $$ = chainon ($1, $2); }
1163 ATTRIBUTE '(' '(' attribute_list ')' ')'
1170 | attribute_list ',' attrib
1171 { $$ = chainon ($1, $3); }
1178 { $$ = build_tree_list ($1, NULL_TREE); }
1179 | any_word '(' IDENTIFIER ')'
1180 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1181 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1182 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1183 | any_word '(' exprlist ')'
1184 { $$ = build_tree_list ($1, $3); }
1187 /* This still leaves out most reserved keywords,
1188 shouldn't we include them? */
1197 /* Initializers. `init' is the entry point. */
1202 { really_start_incremental_init (NULL_TREE); }
1203 initlist_maybe_comma '}'
1204 { $$ = pop_init_level (0); }
1206 { $$ = error_mark_node; }
1209 /* `initlist_maybe_comma' is the guts of an initializer in braces. */
1210 initlist_maybe_comma:
1213 pedwarn ("ANSI C forbids empty initializer braces"); }
1214 | initlist1 maybecomma
1219 | initlist1 ',' initelt
1222 /* `initelt' is a single element of an initializer.
1223 It may use braces. */
1225 designator_list '=' initval
1226 | designator initval
1228 { set_init_label ($1); }
1235 { push_init_level (0); }
1236 initlist_maybe_comma '}'
1237 { process_init_element (pop_init_level (0)); }
1239 { process_init_element ($1); }
1245 | designator_list designator
1250 { set_init_label ($2); }
1251 /* These are for labeled elements. The syntax for an array element
1252 initializer conflicts with the syntax for an Objective-C message,
1253 so don't include these productions in the Objective-C grammar. */
1259 pedwarn ("ANSI C forbids nested functions");
1261 push_function_context ();
1262 if (! start_function (current_declspecs, $1,
1263 prefix_attributes, NULL_TREE))
1265 pop_function_context ();
1268 reinit_parse_for_function (); }
1269 old_style_parm_decls
1270 { store_parm_decls (); }
1271 /* This used to use compstmt_or_error.
1272 That caused a bug with input `f(g) int g {}',
1273 where the use of YYERROR1 above caused an error
1274 which then was handled by compstmt_or_error.
1275 There followed a repeated execution of that same rule,
1276 which called YYERROR1 again, and so on. */
1278 { finish_function (1);
1279 pop_function_context (); }
1282 notype_nested_function:
1285 pedwarn ("ANSI C forbids nested functions");
1287 push_function_context ();
1288 if (! start_function (current_declspecs, $1,
1289 prefix_attributes, NULL_TREE))
1291 pop_function_context ();
1294 reinit_parse_for_function (); }
1295 old_style_parm_decls
1296 { store_parm_decls (); }
1297 /* This used to use compstmt_or_error.
1298 That caused a bug with input `f(g) int g {}',
1299 where the use of YYERROR1 above caused an error
1300 which then was handled by compstmt_or_error.
1301 There followed a repeated execution of that same rule,
1302 which called YYERROR1 again, and so on. */
1304 { finish_function (1);
1305 pop_function_context (); }
1308 /* Any kind of declarator (thus, all declarators allowed
1309 after an explicit typespec). */
1312 after_type_declarator
1316 /* A declarator that is allowed only after an explicit typespec. */
1318 after_type_declarator:
1319 '(' after_type_declarator ')'
1321 | after_type_declarator '(' parmlist_or_identifiers %prec '.'
1322 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1323 /* | after_type_declarator '(' error ')' %prec '.'
1324 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1325 poplevel (0, 0, 0); } */
1326 | after_type_declarator '[' expr ']' %prec '.'
1327 { $$ = build_nt (ARRAY_REF, $1, $3); }
1328 | after_type_declarator '[' ']' %prec '.'
1329 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1330 | '*' type_quals after_type_declarator %prec UNARY
1331 { $$ = make_pointer_declarator ($2, $3); }
1332 /* ??? Yuck. setattrs is a quick hack. We can't use
1333 prefix_attributes because $1 only applies to this
1334 declarator. We assume setspecs has already been done.
1335 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1336 attributes could be recognized here or in `attributes'). */
1337 | attributes setattrs after_type_declarator
1343 /* Kinds of declarator that can appear in a parameter list
1344 in addition to notype_declarator. This is like after_type_declarator
1345 but does not allow a typedef name in parentheses as an identifier
1346 (because it would conflict with a function with that typedef as arg). */
1349 parm_declarator '(' parmlist_or_identifiers %prec '.'
1350 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1351 /* | parm_declarator '(' error ')' %prec '.'
1352 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1353 poplevel (0, 0, 0); } */
1354 | parm_declarator '[' expr ']' %prec '.'
1355 { $$ = build_nt (ARRAY_REF, $1, $3); }
1356 | parm_declarator '[' ']' %prec '.'
1357 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1358 | '*' type_quals parm_declarator %prec UNARY
1359 { $$ = make_pointer_declarator ($2, $3); }
1360 /* ??? Yuck. setattrs is a quick hack. We can't use
1361 prefix_attributes because $1 only applies to this
1362 declarator. We assume setspecs has already been done.
1363 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1364 attributes could be recognized here or in `attributes'). */
1365 | attributes setattrs parm_declarator
1370 /* A declarator allowed whether or not there has been
1371 an explicit typespec. These cannot redeclare a typedef-name. */
1374 notype_declarator '(' parmlist_or_identifiers %prec '.'
1375 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1376 /* | notype_declarator '(' error ')' %prec '.'
1377 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1378 poplevel (0, 0, 0); } */
1379 | '(' notype_declarator ')'
1381 | '*' type_quals notype_declarator %prec UNARY
1382 { $$ = make_pointer_declarator ($2, $3); }
1383 | notype_declarator '[' expr ']' %prec '.'
1384 { $$ = build_nt (ARRAY_REF, $1, $3); }
1385 | notype_declarator '[' ']' %prec '.'
1386 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1387 /* ??? Yuck. setattrs is a quick hack. We can't use
1388 prefix_attributes because $1 only applies to this
1389 declarator. We assume setspecs has already been done.
1390 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1391 attributes could be recognized here or in `attributes'). */
1392 | attributes setattrs notype_declarator
1419 struct_head identifier '{'
1420 { $$ = start_struct (RECORD_TYPE, $2);
1421 /* Start scope of tag before parsing components. */
1423 component_decl_list '}' maybe_attribute
1424 { $$ = finish_struct ($<ttype>4, $5, chainon ($1, $7)); }
1425 | struct_head '{' component_decl_list '}' maybe_attribute
1426 { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
1427 $3, chainon ($1, $5));
1429 | struct_head identifier
1430 { $$ = xref_tag (RECORD_TYPE, $2); }
1431 | union_head identifier '{'
1432 { $$ = start_struct (UNION_TYPE, $2); }
1433 component_decl_list '}' maybe_attribute
1434 { $$ = finish_struct ($<ttype>4, $5, chainon ($1, $7)); }
1435 | union_head '{' component_decl_list '}' maybe_attribute
1436 { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
1437 $3, chainon ($1, $5));
1439 | union_head identifier
1440 { $$ = xref_tag (UNION_TYPE, $2); }
1441 | enum_head identifier '{'
1442 { $$ = start_enum ($2); }
1443 enumlist maybecomma_warn '}' maybe_attribute
1444 { $$ = finish_enum ($<ttype>4, nreverse ($5),
1445 chainon ($1, $8)); }
1447 { $$ = start_enum (NULL_TREE); }
1448 enumlist maybecomma_warn '}' maybe_attribute
1449 { $$ = finish_enum ($<ttype>3, nreverse ($4),
1450 chainon ($1, $7)); }
1451 | enum_head identifier
1452 { $$ = xref_tag (ENUMERAL_TYPE, $2); }
1463 { if (pedantic && ! flag_isoc99)
1464 pedwarn ("comma at end of enumerator list"); }
1467 component_decl_list:
1468 component_decl_list2
1470 | component_decl_list2 component_decl
1471 { $$ = chainon ($1, $2);
1472 pedwarn ("no semicolon at end of struct or union"); }
1475 component_decl_list2: /* empty */
1477 | component_decl_list2 component_decl ';'
1478 { $$ = chainon ($1, $2); }
1479 | component_decl_list2 ';'
1481 pedwarn ("extra semicolon in struct or union specified"); }
1482 /* foo(sizeof(struct{ @defs(ClassName)})); */
1483 | DEFS '(' CLASSNAME ')'
1485 tree interface = lookup_interface ($3);
1488 $$ = get_class_ivars (interface);
1491 error ("Cannot find interface declaration for `%s'",
1492 IDENTIFIER_POINTER ($3));
1498 /* There is a shift-reduce conflict here, because `components' may
1499 start with a `typename'. It happens that shifting (the default resolution)
1500 does the right thing, because it treats the `typename' as part of
1501 a `typed_typespecs'.
1503 It is possible that this same technique would allow the distinction
1504 between `notype_initdecls' and `initdecls' to be eliminated.
1505 But I am being cautious and not trying it. */
1508 typed_typespecs setspecs components
1510 current_declspecs = TREE_VALUE (declspec_stack);
1511 prefix_attributes = TREE_PURPOSE (declspec_stack);
1512 declspec_stack = TREE_CHAIN (declspec_stack); }
1513 | typed_typespecs setspecs save_filename save_lineno maybe_attribute
1515 /* Support for unnamed structs or unions as members of
1516 structs or unions (which is [a] useful and [b] supports
1519 pedwarn ("ANSI C doesn't support unnamed structs/unions");
1521 $$ = grokfield($3, $4, NULL, current_declspecs, NULL_TREE);
1522 current_declspecs = TREE_VALUE (declspec_stack);
1523 prefix_attributes = TREE_PURPOSE (declspec_stack);
1524 declspec_stack = TREE_CHAIN (declspec_stack);
1526 | nonempty_type_quals setspecs components
1528 current_declspecs = TREE_VALUE (declspec_stack);
1529 prefix_attributes = TREE_PURPOSE (declspec_stack);
1530 declspec_stack = TREE_CHAIN (declspec_stack); }
1531 | nonempty_type_quals
1533 pedwarn ("ANSI C forbids member declarations with no members");
1538 | extension component_decl
1540 RESTORE_WARN_FLAGS ($1); }
1544 component_declarator
1545 | components ',' component_declarator
1546 { $$ = chainon ($1, $3); }
1549 component_declarator:
1550 save_filename save_lineno declarator maybe_attribute
1551 { $$ = grokfield ($1, $2, $3, current_declspecs, NULL_TREE);
1552 decl_attributes ($$, $4, prefix_attributes); }
1553 | save_filename save_lineno
1554 declarator ':' expr_no_commas maybe_attribute
1555 { $$ = grokfield ($1, $2, $3, current_declspecs, $5);
1556 decl_attributes ($$, $6, prefix_attributes); }
1557 | save_filename save_lineno ':' expr_no_commas maybe_attribute
1558 { $$ = grokfield ($1, $2, NULL_TREE, current_declspecs, $4);
1559 decl_attributes ($$, $5, prefix_attributes); }
1562 /* We chain the enumerators in reverse order.
1563 They are put in forward order where enumlist is used.
1564 (The order used to be significant, but no longer is so.
1565 However, we still maintain the order, just to be clean.) */
1569 | enumlist ',' enumerator
1570 { if ($1 == error_mark_node)
1573 $$ = chainon ($3, $1); }
1575 { $$ = error_mark_node; }
1581 { $$ = build_enumerator ($1, NULL_TREE); }
1582 | identifier '=' expr_no_commas
1583 { $$ = build_enumerator ($1, $3); }
1587 typed_typespecs absdcl
1588 { $$ = build_tree_list ($1, $2); }
1589 | nonempty_type_quals absdcl
1590 { $$ = build_tree_list ($1, $2); }
1593 absdcl: /* an absolute declarator */
1599 nonempty_type_quals:
1601 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
1602 | nonempty_type_quals TYPE_QUAL
1603 { $$ = tree_cons (NULL_TREE, $2, $1); }
1609 | type_quals TYPE_QUAL
1610 { $$ = tree_cons (NULL_TREE, $2, $1); }
1613 absdcl1: /* a nonempty absolute declarator */
1616 /* `(typedef)1' is `int'. */
1617 | '*' type_quals absdcl1 %prec UNARY
1618 { $$ = make_pointer_declarator ($2, $3); }
1619 | '*' type_quals %prec UNARY
1620 { $$ = make_pointer_declarator ($2, NULL_TREE); }
1621 | absdcl1 '(' parmlist %prec '.'
1622 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1623 | absdcl1 '[' expr ']' %prec '.'
1624 { $$ = build_nt (ARRAY_REF, $1, $3); }
1625 | absdcl1 '[' ']' %prec '.'
1626 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1627 | '(' parmlist %prec '.'
1628 { $$ = build_nt (CALL_EXPR, NULL_TREE, $2, NULL_TREE); }
1629 | '[' expr ']' %prec '.'
1630 { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
1632 { $$ = build_nt (ARRAY_REF, NULL_TREE, NULL_TREE); }
1633 /* ??? It appears we have to support attributes here, however
1634 using prefix_attributes is wrong. */
1635 | attributes setattrs absdcl1
1639 /* at least one statement, the first of which parses without error. */
1640 /* stmts is used only after decls, so an invalid first statement
1641 is actually regarded as an invalid decl and part of the decls. */
1644 lineno_stmt_or_labels
1647 pedwarn ("ANSI C forbids label at end of compound statement");
1651 lineno_stmt_or_labels:
1652 lineno_stmt_or_label
1653 | lineno_stmt_or_labels lineno_stmt_or_label
1655 | lineno_stmt_or_labels errstmt
1667 pushlevel: /* empty */
1668 { emit_line_note (input_filename, lineno);
1671 expand_start_bindings (0);
1672 if (objc_method_context)
1677 /* Read zero or more forward-declarations for labels
1678 that nested functions can jump to. */
1683 pedwarn ("ANSI C forbids label declarations"); }
1688 | label_decls label_decl
1692 LABEL identifiers_or_typenames ';'
1694 for (link = $2; link; link = TREE_CHAIN (link))
1696 tree label = shadow_label (TREE_VALUE (link));
1697 C_DECLARED_LABEL_FLAG (label) = 1;
1698 declare_nonlocal_label (label);
1703 /* This is the body of a function definition.
1704 It causes syntax errors to ignore to the next openbrace. */
1711 compstmt_start: '{' { compstmt_count++; }
1713 compstmt_nostart: '}'
1714 { $$ = convert (void_type_node, integer_zero_node); }
1715 | pushlevel maybe_label_decls decls xstmts '}'
1716 { emit_line_note (input_filename, lineno);
1717 expand_end_bindings (getdecls (), 1, 0);
1718 $$ = poplevel (1, 1, 0); }
1719 | pushlevel maybe_label_decls error '}'
1720 { emit_line_note (input_filename, lineno);
1721 expand_end_bindings (getdecls (), kept_level_p (), 0);
1722 $$ = poplevel (kept_level_p (), 0, 0); }
1723 | pushlevel maybe_label_decls stmts '}'
1724 { emit_line_note (input_filename, lineno);
1725 expand_end_bindings (getdecls (), kept_level_p (), 0);
1726 $$ = poplevel (kept_level_p (), 0, 0); }
1729 compstmt_primary_start:
1731 { if (current_function_decl == 0)
1733 error ("braced-group within expression allowed only inside a function");
1736 /* We must force a BLOCK for this level
1737 so that, if it is not expanded later,
1738 there is a way to turn off the entire subtree of blocks
1739 that are contained in it. */
1741 push_iterator_stack ();
1742 push_label_level ();
1743 $$ = expand_start_stmt_expr ();
1747 compstmt: compstmt_start compstmt_nostart
1751 /* Value is number of statements counted as of the closeparen. */
1753 if_prefix lineno_labeled_stmt
1754 /* Make sure c_expand_end_cond is run once
1755 for each call to c_expand_start_cond.
1756 Otherwise a crash is likely. */
1762 { emit_line_note ($<filename>-1, $<lineno>0);
1763 c_expand_start_cond (truthvalue_conversion ($3), 0,
1765 $<itype>$ = stmt_count;
1766 if_stmt_file = $<filename>-1;
1767 if_stmt_line = $<lineno>0;
1768 position_after_white_space (); }
1771 /* This is a subroutine of stmt.
1772 It is used twice, once for valid DO statements
1773 and once for catching errors in parsing the end test. */
1778 emit_line_note ($<filename>-1, $<lineno>0);
1779 /* See comment in `while' alternative, above. */
1781 expand_start_loop_continue_elsewhere (1);
1782 position_after_white_space (); }
1783 lineno_labeled_stmt WHILE
1784 { expand_loop_continue_here (); }
1788 { $$ = input_filename; }
1795 lineno_labeled_stmt:
1796 save_filename save_lineno stmt
1798 /* | save_filename save_lineno error
1801 | save_filename save_lineno label lineno_labeled_stmt
1805 lineno_stmt_or_label:
1806 save_filename save_lineno stmt_or_label
1817 /* Parse a single real statement, not including any labels. */
1824 emit_line_note ($<filename>-1, $<lineno>0);
1825 /* It appears that this should not be done--that a non-lvalue array
1826 shouldn't get an error if the value isn't used.
1827 Section 3.2.2.1 says that an array lvalue gets converted to a pointer
1828 if it appears as a top-level expression,
1829 but says nothing about non-lvalue arrays. */
1831 /* Call default_conversion to get an error
1832 on referring to a register array if pedantic. */
1833 if (TREE_CODE (TREE_TYPE ($1)) == ARRAY_TYPE
1834 || TREE_CODE (TREE_TYPE ($1)) == FUNCTION_TYPE)
1835 $1 = default_conversion ($1);
1837 iterator_expand ($1); }
1839 { c_expand_start_else ();
1840 $<itype>1 = stmt_count;
1841 position_after_white_space (); }
1843 { c_expand_end_cond ();
1844 if (extra_warnings && stmt_count == $<itype>1)
1845 warning ("empty body in an else-statement"); }
1846 | simple_if %prec IF
1847 { c_expand_end_cond ();
1848 /* This warning is here instead of in simple_if, because we
1849 do not want a warning if an empty if is followed by an
1850 else statement. Increment stmt_count so we don't
1851 give a second error if this is a nested `if'. */
1852 if (extra_warnings && stmt_count++ == $<itype>1)
1853 warning_with_file_and_line (if_stmt_file, if_stmt_line,
1854 "empty body in an if-statement"); }
1855 /* Make sure c_expand_end_cond is run once
1856 for each call to c_expand_start_cond.
1857 Otherwise a crash is likely. */
1858 | simple_if ELSE error
1859 { c_expand_end_cond (); }
1862 emit_line_note ($<filename>-1, $<lineno>0);
1863 /* The emit_nop used to come before emit_line_note,
1864 but that made the nop seem like part of the preceding line.
1865 And that was confusing when the preceding line was
1866 inside of an if statement and was not really executed.
1867 I think it ought to work to put the nop after the line number.
1868 We will see. --rms, July 15, 1991. */
1871 { /* Don't start the loop till we have succeeded
1872 in parsing the end test. This is to make sure
1873 that we end every loop we start. */
1874 expand_start_loop (1);
1875 emit_line_note (input_filename, lineno);
1876 expand_exit_loop_if_false (NULL_PTR,
1877 truthvalue_conversion ($4));
1878 position_after_white_space (); }
1880 { expand_end_loop (); }
1883 { emit_line_note (input_filename, lineno);
1884 expand_exit_loop_if_false (NULL_PTR,
1885 truthvalue_conversion ($3));
1886 expand_end_loop (); }
1887 /* This rule is needed to make sure we end every loop we start. */
1888 | do_stmt_start error
1889 { expand_end_loop (); }
1893 emit_line_note ($<filename>-1, $<lineno>0);
1894 /* See comment in `while' alternative, above. */
1896 if ($3) c_expand_expr_stmt ($3);
1897 /* Next step is to call expand_start_loop_continue_elsewhere,
1898 but wait till after we parse the entire for (...).
1899 Otherwise, invalid input might cause us to call that
1900 fn without calling expand_end_loop. */
1903 /* Can't emit now; wait till after expand_start_loop... */
1904 { $<lineno>7 = lineno;
1905 $<filename>$ = input_filename; }
1908 /* Start the loop. Doing this after parsing
1909 all the expressions ensures we will end the loop. */
1910 expand_start_loop_continue_elsewhere (1);
1911 /* Emit the end-test, with a line number. */
1912 emit_line_note ($<filename>8, $<lineno>7);
1914 expand_exit_loop_if_false (NULL_PTR,
1915 truthvalue_conversion ($6));
1916 $<lineno>7 = lineno;
1917 $<filename>8 = input_filename;
1918 position_after_white_space (); }
1920 { /* Emit the increment expression, with a line number. */
1921 emit_line_note ($<filename>8, $<lineno>7);
1922 expand_loop_continue_here ();
1924 c_expand_expr_stmt ($9);
1925 expand_end_loop (); }
1926 | SWITCH '(' expr ')'
1928 emit_line_note ($<filename>-1, $<lineno>0);
1929 c_expand_start_case ($3);
1930 position_after_white_space (); }
1932 { expand_end_case ($3); }
1935 emit_line_note ($<filename>-1, $<lineno>0);
1936 if ( ! expand_exit_something ())
1937 error ("break statement not within loop or switch"); }
1940 emit_line_note ($<filename>-1, $<lineno>0);
1941 if (! expand_continue_loop (NULL_PTR))
1942 error ("continue statement not within a loop"); }
1945 emit_line_note ($<filename>-1, $<lineno>0);
1946 c_expand_return (NULL_TREE); }
1949 emit_line_note ($<filename>-1, $<lineno>0);
1950 c_expand_return ($2); }
1951 | ASM_KEYWORD maybe_type_qual '(' expr ')' ';'
1953 emit_line_note ($<filename>-1, $<lineno>0);
1955 if ((TREE_CODE ($4) == ADDR_EXPR
1956 && TREE_CODE (TREE_OPERAND ($4, 0)) == STRING_CST)
1957 || TREE_CODE ($4) == STRING_CST)
1960 error ("argument of `asm' is not a constant string"); }
1961 /* This is the case with just output operands. */
1962 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ')' ';'
1964 emit_line_note ($<filename>-1, $<lineno>0);
1965 c_expand_asm_operands ($4, $6, NULL_TREE, NULL_TREE,
1966 $2 == ridpointers[(int)RID_VOLATILE],
1967 input_filename, lineno); }
1968 /* This is the case with input operands as well. */
1969 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':' asm_operands ')' ';'
1971 emit_line_note ($<filename>-1, $<lineno>0);
1972 c_expand_asm_operands ($4, $6, $8, NULL_TREE,
1973 $2 == ridpointers[(int)RID_VOLATILE],
1974 input_filename, lineno); }
1975 /* This is the case with clobbered registers as well. */
1976 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':'
1977 asm_operands ':' asm_clobbers ')' ';'
1979 emit_line_note ($<filename>-1, $<lineno>0);
1980 c_expand_asm_operands ($4, $6, $8, $10,
1981 $2 == ridpointers[(int)RID_VOLATILE],
1982 input_filename, lineno); }
1983 | GOTO identifier ';'
1986 emit_line_note ($<filename>-1, $<lineno>0);
1987 decl = lookup_label ($2);
1990 TREE_USED (decl) = 1;
1996 pedwarn ("ANSI C forbids `goto *expr;'");
1998 emit_line_note ($<filename>-1, $<lineno>0);
1999 expand_computed_goto (convert (ptr_type_node, $3)); }
2004 all_iter_stmt_simple
2005 /* | all_iter_stmt_with_decl */
2008 all_iter_stmt_simple:
2011 /* The value returned by this action is */
2012 /* 1 if everything is OK */
2013 /* 0 in case of error or already bound iterator */
2016 if (TREE_CODE ($3) != VAR_DECL)
2017 error ("invalid `for (ITERATOR)' syntax");
2018 else if (! ITERATOR_P ($3))
2019 error ("`%s' is not an iterator",
2020 IDENTIFIER_POINTER (DECL_NAME ($3)));
2021 else if (ITERATOR_BOUND_P ($3))
2022 error ("`for (%s)' inside expansion of same iterator",
2023 IDENTIFIER_POINTER (DECL_NAME ($3)));
2027 iterator_for_loop_start ($3);
2033 iterator_for_loop_end ($3);
2036 /* This really should allow any kind of declaration,
2037 for generality. Fix it before turning it back on.
2039 all_iter_stmt_with_decl:
2040 FOR '(' ITERATOR pushlevel setspecs iterator_spec ')'
2042 */ /* The value returned by this action is */
2043 /* 1 if everything is OK */
2044 /* 0 in case of error or already bound iterator */
2046 iterator_for_loop_start ($6);
2050 iterator_for_loop_end ($6);
2051 emit_line_note (input_filename, lineno);
2052 expand_end_bindings (getdecls (), 1, 0);
2053 $<ttype>$ = poplevel (1, 1, 0);
2057 /* Any kind of label, including jump labels and case labels.
2058 ANSI C accepts labels only before statements, but we allow them
2059 also at the end of a compound statement. */
2061 label: CASE expr_no_commas ':'
2062 { register tree value = check_case_value ($2);
2064 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
2068 if (value != error_mark_node)
2073 if (pedantic && ! INTEGRAL_TYPE_P (TREE_TYPE (value)))
2074 pedwarn ("label must have integral type in ANSI C");
2076 success = pushcase (value, convert_and_check,
2080 error ("case label not within a switch statement");
2081 else if (success == 2)
2083 error ("duplicate case value");
2084 error_with_decl (duplicate, "this is the first entry for that value");
2086 else if (success == 3)
2087 warning ("case value out of range");
2088 else if (success == 5)
2089 error ("case label within scope of cleanup or variable array");
2091 position_after_white_space (); }
2092 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
2093 { register tree value1 = check_case_value ($2);
2094 register tree value2 = check_case_value ($4);
2096 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
2099 pedwarn ("ANSI C forbids case ranges");
2102 if (value1 != error_mark_node && value2 != error_mark_node)
2105 int success = pushcase_range (value1, value2,
2106 convert_and_check, label,
2109 error ("case label not within a switch statement");
2110 else if (success == 2)
2112 error ("duplicate case value");
2113 error_with_decl (duplicate, "this is the first entry for that value");
2115 else if (success == 3)
2116 warning ("case value out of range");
2117 else if (success == 4)
2118 warning ("empty case range");
2119 else if (success == 5)
2120 error ("case label within scope of cleanup or variable array");
2122 position_after_white_space (); }
2127 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
2128 int success = pushcase (NULL_TREE, 0, label, &duplicate);
2131 error ("default label not within a switch statement");
2132 else if (success == 2)
2134 error ("multiple default labels in one switch");
2135 error_with_decl (duplicate, "this is the first default label");
2137 position_after_white_space (); }
2138 | identifier ':' maybe_attribute
2139 { tree label = define_label (input_filename, lineno, $1);
2144 expand_label (label);
2145 decl_attributes (label, $3, NULL_TREE);
2147 position_after_white_space (); }
2150 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
2154 { emit_line_note (input_filename, lineno);
2157 { emit_line_note (input_filename, lineno); }
2166 /* These are the operands other than the first string and colon
2167 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
2168 asm_operands: /* empty */
2170 | nonnull_asm_operands
2173 nonnull_asm_operands:
2175 | nonnull_asm_operands ',' asm_operand
2176 { $$ = chainon ($1, $3); }
2181 { $$ = build_tree_list ($1, $3); }
2186 { $$ = tree_cons (NULL_TREE, combine_strings ($1), NULL_TREE); }
2187 | asm_clobbers ',' string
2188 { $$ = tree_cons (NULL_TREE, combine_strings ($3), $1); }
2191 /* This is what appears inside the parens in a function declarator.
2192 Its value is a list of ..._TYPE nodes. */
2195 clear_parm_order ();
2196 declare_parm_level (0); }
2199 parmlist_tags_warning ();
2200 poplevel (0, 0, 0); }
2208 pedwarn ("ANSI C forbids forward parameter declarations");
2209 /* Mark the forward decls as such. */
2210 for (parm = getdecls (); parm; parm = TREE_CHAIN (parm))
2211 TREE_ASM_WRITTEN (parm) = 1;
2212 clear_parm_order (); }
2216 { $$ = tree_cons (NULL_TREE, NULL_TREE, NULL_TREE); }
2219 /* This is what appears inside the parens in a function declarator.
2220 Is value is represented in the format that grokdeclarator expects. */
2221 parmlist_2: /* empty */
2222 { $$ = get_parm_info (0); }
2224 { $$ = get_parm_info (0);
2225 /* Gcc used to allow this as an extension. However, it does
2226 not work for all targets, and thus has been disabled.
2227 Also, since func (...) and func () are indistinguishable,
2228 it caused problems with the code in expand_builtin which
2229 tries to verify that BUILT_IN_NEXT_ARG is being used
2231 error ("ANSI C requires a named argument before `...'");
2234 { $$ = get_parm_info (1); }
2235 | parms ',' ELLIPSIS
2236 { $$ = get_parm_info (0); }
2241 { push_parm_decl ($1); }
2243 { push_parm_decl ($3); }
2246 /* A single parameter declaration or parameter type name,
2247 as found in a parmlist. */
2249 typed_declspecs setspecs parm_declarator maybe_attribute
2250 { $$ = build_tree_list (build_tree_list (current_declspecs,
2252 build_tree_list (prefix_attributes,
2254 current_declspecs = TREE_VALUE (declspec_stack);
2255 prefix_attributes = TREE_PURPOSE (declspec_stack);
2256 declspec_stack = TREE_CHAIN (declspec_stack); }
2257 | typed_declspecs setspecs notype_declarator maybe_attribute
2258 { $$ = build_tree_list (build_tree_list (current_declspecs,
2260 build_tree_list (prefix_attributes,
2262 current_declspecs = TREE_VALUE (declspec_stack);
2263 prefix_attributes = TREE_PURPOSE (declspec_stack);
2264 declspec_stack = TREE_CHAIN (declspec_stack); }
2265 | typed_declspecs setspecs absdcl maybe_attribute
2266 { $$ = build_tree_list (build_tree_list (current_declspecs,
2268 build_tree_list (prefix_attributes,
2270 current_declspecs = TREE_VALUE (declspec_stack);
2271 prefix_attributes = TREE_PURPOSE (declspec_stack);
2272 declspec_stack = TREE_CHAIN (declspec_stack); }
2273 | declmods setspecs notype_declarator maybe_attribute
2274 { $$ = build_tree_list (build_tree_list (current_declspecs,
2276 build_tree_list (prefix_attributes,
2278 current_declspecs = TREE_VALUE (declspec_stack);
2279 prefix_attributes = TREE_PURPOSE (declspec_stack);
2280 declspec_stack = TREE_CHAIN (declspec_stack); }
2282 | declmods setspecs absdcl maybe_attribute
2283 { $$ = build_tree_list (build_tree_list (current_declspecs,
2285 build_tree_list (prefix_attributes,
2287 current_declspecs = TREE_VALUE (declspec_stack);
2288 prefix_attributes = TREE_PURPOSE (declspec_stack);
2289 declspec_stack = TREE_CHAIN (declspec_stack); }
2292 /* This is used in a function definition
2293 where either a parmlist or an identifier list is ok.
2294 Its value is a list of ..._TYPE nodes or a list of identifiers. */
2295 parmlist_or_identifiers:
2297 clear_parm_order ();
2298 declare_parm_level (1); }
2299 parmlist_or_identifiers_1
2301 parmlist_tags_warning ();
2302 poplevel (0, 0, 0); }
2305 parmlist_or_identifiers_1:
2309 for (t = $1; t; t = TREE_CHAIN (t))
2310 if (TREE_VALUE (t) == NULL_TREE)
2311 error ("`...' in old-style identifier list");
2312 $$ = tree_cons (NULL_TREE, NULL_TREE, $1); }
2315 /* A nonempty list of identifiers. */
2318 { $$ = build_tree_list (NULL_TREE, $1); }
2319 | identifiers ',' IDENTIFIER
2320 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2323 /* A nonempty list of identifiers, including typenames. */
2324 identifiers_or_typenames:
2326 { $$ = build_tree_list (NULL_TREE, $1); }
2327 | identifiers_or_typenames ',' identifier
2328 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2333 { $$ = SAVE_WARN_FLAGS();
2335 warn_pointer_arith = 0; }
2338 /* Objective-C productions. */
2348 if (objc_implementation_context)
2350 finish_class (objc_implementation_context);
2351 objc_ivar_chain = NULL_TREE;
2352 objc_implementation_context = NULL_TREE;
2355 warning ("`@end' must appear in an implementation context");
2359 /* A nonempty list of identifiers. */
2362 { $$ = build_tree_list (NULL_TREE, $1); }
2363 | identifier_list ',' identifier
2364 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2368 CLASS identifier_list ';'
2370 objc_declare_class ($2);
2374 ALIAS identifier identifier ';'
2376 objc_declare_alias ($2, $3);
2380 INTERFACE identifier protocolrefs '{'
2382 objc_interface_context = objc_ivar_context
2383 = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, $3);
2384 objc_public_flag = 0;
2388 continue_class (objc_interface_context);
2393 finish_class (objc_interface_context);
2394 objc_interface_context = NULL_TREE;
2397 | INTERFACE identifier protocolrefs
2399 objc_interface_context
2400 = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, $3);
2401 continue_class (objc_interface_context);
2406 finish_class (objc_interface_context);
2407 objc_interface_context = NULL_TREE;
2410 | INTERFACE identifier ':' identifier protocolrefs '{'
2412 objc_interface_context = objc_ivar_context
2413 = start_class (CLASS_INTERFACE_TYPE, $2, $4, $5);
2414 objc_public_flag = 0;
2418 continue_class (objc_interface_context);
2423 finish_class (objc_interface_context);
2424 objc_interface_context = NULL_TREE;
2427 | INTERFACE identifier ':' identifier protocolrefs
2429 objc_interface_context
2430 = start_class (CLASS_INTERFACE_TYPE, $2, $4, $5);
2431 continue_class (objc_interface_context);
2436 finish_class (objc_interface_context);
2437 objc_interface_context = NULL_TREE;
2440 | IMPLEMENTATION identifier '{'
2442 objc_implementation_context = objc_ivar_context
2443 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, NULL_TREE, NULL_TREE);
2444 objc_public_flag = 0;
2449 = continue_class (objc_implementation_context);
2452 | IMPLEMENTATION identifier
2454 objc_implementation_context
2455 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, NULL_TREE, NULL_TREE);
2457 = continue_class (objc_implementation_context);
2460 | IMPLEMENTATION identifier ':' identifier '{'
2462 objc_implementation_context = objc_ivar_context
2463 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2464 objc_public_flag = 0;
2469 = continue_class (objc_implementation_context);
2472 | IMPLEMENTATION identifier ':' identifier
2474 objc_implementation_context
2475 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2477 = continue_class (objc_implementation_context);
2480 | INTERFACE identifier '(' identifier ')' protocolrefs
2482 objc_interface_context
2483 = start_class (CATEGORY_INTERFACE_TYPE, $2, $4, $6);
2484 continue_class (objc_interface_context);
2489 finish_class (objc_interface_context);
2490 objc_interface_context = NULL_TREE;
2493 | IMPLEMENTATION identifier '(' identifier ')'
2495 objc_implementation_context
2496 = start_class (CATEGORY_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2498 = continue_class (objc_implementation_context);
2503 PROTOCOL identifier protocolrefs
2505 remember_protocol_qualifiers ();
2506 objc_interface_context
2507 = start_protocol(PROTOCOL_INTERFACE_TYPE, $2, $3);
2511 forget_protocol_qualifiers();
2512 finish_protocol(objc_interface_context);
2513 objc_interface_context = NULL_TREE;
2522 | non_empty_protocolrefs
2525 non_empty_protocolrefs:
2526 ARITHCOMPARE identifier_list ARITHCOMPARE
2528 if ($1 == LT_EXPR && $3 == GT_EXPR)
2536 ivar_decl_list visibility_spec ivar_decls
2541 PRIVATE { objc_public_flag = 2; }
2542 | PROTECTED { objc_public_flag = 0; }
2543 | PUBLIC { objc_public_flag = 1; }
2551 | ivar_decls ivar_decl ';'
2555 pedwarn ("extra semicolon in struct or union specified");
2560 /* There is a shift-reduce conflict here, because `components' may
2561 start with a `typename'. It happens that shifting (the default resolution)
2562 does the right thing, because it treats the `typename' as part of
2563 a `typed_typespecs'.
2565 It is possible that this same technique would allow the distinction
2566 between `notype_initdecls' and `initdecls' to be eliminated.
2567 But I am being cautious and not trying it. */
2570 typed_typespecs setspecs ivars
2572 current_declspecs = TREE_VALUE (declspec_stack);
2573 prefix_attributes = TREE_PURPOSE (declspec_stack);
2574 declspec_stack = TREE_CHAIN (declspec_stack); }
2575 | nonempty_type_quals setspecs ivars
2577 current_declspecs = TREE_VALUE (declspec_stack);
2578 prefix_attributes = TREE_PURPOSE (declspec_stack);
2579 declspec_stack = TREE_CHAIN (declspec_stack); }
2588 | ivars ',' ivar_declarator
2594 $$ = add_instance_variable (objc_ivar_context,
2596 $1, current_declspecs,
2599 | declarator ':' expr_no_commas
2601 $$ = add_instance_variable (objc_ivar_context,
2603 $1, current_declspecs, $3);
2605 | ':' expr_no_commas
2607 $$ = add_instance_variable (objc_ivar_context,
2610 current_declspecs, $2);
2617 remember_protocol_qualifiers ();
2618 if (objc_implementation_context)
2619 objc_inherit_code = CLASS_METHOD_DECL;
2621 fatal ("method definition not in class context");
2625 forget_protocol_qualifiers ();
2626 add_class_method (objc_implementation_context, $3);
2627 start_method_def ($3);
2628 objc_method_context = $3;
2632 continue_method_def ();
2636 finish_method_def ();
2637 objc_method_context = NULL_TREE;
2642 remember_protocol_qualifiers ();
2643 if (objc_implementation_context)
2644 objc_inherit_code = INSTANCE_METHOD_DECL;
2646 fatal ("method definition not in class context");
2650 forget_protocol_qualifiers ();
2651 add_instance_method (objc_implementation_context, $3);
2652 start_method_def ($3);
2653 objc_method_context = $3;
2657 continue_method_def ();
2661 finish_method_def ();
2662 objc_method_context = NULL_TREE;
2666 /* the reason for the strange actions in this rule
2667 is so that notype_initdecls when reached via datadef
2668 can find a valid list of type and sc specs in $0. */
2672 | {$<ttype>$ = NULL_TREE; } methodprotolist2
2675 methodprotolist2: /* eliminates a shift/reduce conflict */
2678 | methodprotolist2 methodproto
2679 | methodprotolist2 {$<ttype>$ = NULL_TREE; } datadef
2690 /* Remember protocol qualifiers in prototypes. */
2691 remember_protocol_qualifiers ();
2692 objc_inherit_code = CLASS_METHOD_DECL;
2696 /* Forget protocol qualifiers here. */
2697 forget_protocol_qualifiers ();
2698 add_class_method (objc_interface_context, $3);
2704 /* Remember protocol qualifiers in prototypes. */
2705 remember_protocol_qualifiers ();
2706 objc_inherit_code = INSTANCE_METHOD_DECL;
2710 /* Forget protocol qualifiers here. */
2711 forget_protocol_qualifiers ();
2712 add_instance_method (objc_interface_context, $3);
2718 '(' typename ')' unaryselector
2720 $$ = build_method_decl (objc_inherit_code, $2, $4, NULL_TREE);
2725 $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, NULL_TREE);
2728 | '(' typename ')' keywordselector optparmlist
2730 $$ = build_method_decl (objc_inherit_code, $2, $4, $5);
2733 | keywordselector optparmlist
2735 $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, $2);
2739 /* "optarglist" assumes that start_method_def has already been called...
2740 if it is not, the "xdecls" will not be placed in the proper scope */
2747 /* to get around the following situation: "int foo (int a) int b; {}" that
2748 is synthesized when parsing "- a:a b:b; id c; id d; { ... }" */
2763 typed_declspecs setspecs myparms ';'
2764 { current_declspecs = TREE_VALUE (declspec_stack);
2765 prefix_attributes = TREE_PURPOSE (declspec_stack);
2766 declspec_stack = TREE_CHAIN (declspec_stack); }
2767 | typed_declspecs ';'
2768 { shadow_tag ($1); }
2770 { pedwarn ("empty declaration"); }
2775 { push_parm_decl ($1); }
2776 | myparms ',' myparm
2777 { push_parm_decl ($3); }
2780 /* A single parameter declaration or parameter type name,
2781 as found in a parmlist. DOES NOT ALLOW AN INITIALIZER OR ASMSPEC */
2784 parm_declarator maybe_attribute
2785 { $$ = build_tree_list (build_tree_list (current_declspecs,
2787 build_tree_list (prefix_attributes,
2789 | notype_declarator maybe_attribute
2790 { $$ = build_tree_list (build_tree_list (current_declspecs,
2792 build_tree_list (prefix_attributes,
2794 | absdcl maybe_attribute
2795 { $$ = build_tree_list (build_tree_list (current_declspecs,
2797 build_tree_list (prefix_attributes,
2808 /* oh what a kludge! */
2817 /* returns a tree list node generated by get_parm_info */
2830 | keywordselector keyworddecl
2832 $$ = chainon ($1, $2);
2844 ENUM { $$ = get_identifier (token_buffer); }
2845 | STRUCT { $$ = get_identifier (token_buffer); }
2846 | UNION { $$ = get_identifier (token_buffer); }
2847 | IF { $$ = get_identifier (token_buffer); }
2848 | ELSE { $$ = get_identifier (token_buffer); }
2849 | WHILE { $$ = get_identifier (token_buffer); }
2850 | DO { $$ = get_identifier (token_buffer); }
2851 | FOR { $$ = get_identifier (token_buffer); }
2852 | SWITCH { $$ = get_identifier (token_buffer); }
2853 | CASE { $$ = get_identifier (token_buffer); }
2854 | DEFAULT { $$ = get_identifier (token_buffer); }
2855 | BREAK { $$ = get_identifier (token_buffer); }
2856 | CONTINUE { $$ = get_identifier (token_buffer); }
2857 | RETURN { $$ = get_identifier (token_buffer); }
2858 | GOTO { $$ = get_identifier (token_buffer); }
2859 | ASM_KEYWORD { $$ = get_identifier (token_buffer); }
2860 | SIZEOF { $$ = get_identifier (token_buffer); }
2861 | TYPEOF { $$ = get_identifier (token_buffer); }
2862 | ALIGNOF { $$ = get_identifier (token_buffer); }
2863 | TYPESPEC | TYPE_QUAL
2867 selector ':' '(' typename ')' identifier
2869 $$ = build_keyword_decl ($1, $4, $6);
2872 | selector ':' identifier
2874 $$ = build_keyword_decl ($1, NULL_TREE, $3);
2877 | ':' '(' typename ')' identifier
2879 $$ = build_keyword_decl (NULL_TREE, $3, $5);
2884 $$ = build_keyword_decl (NULL_TREE, NULL_TREE, $2);
2895 | keywordarglist keywordarg
2897 $$ = chainon ($1, $2);
2905 if (TREE_CHAIN ($1) == NULL_TREE)
2906 /* just return the expr., remove a level of indirection */
2907 $$ = TREE_VALUE ($1);
2909 /* we have a comma expr., we will collapse later */
2915 selector ':' keywordexpr
2917 $$ = build_tree_list ($1, $3);
2921 $$ = build_tree_list (NULL_TREE, $2);
2929 $$ = get_class_reference ($1);
2935 { objc_receiver_context = 1; }
2937 { objc_receiver_context = 0; }
2940 $$ = build_tree_list ($3, $5);
2951 | keywordnamelist keywordname
2953 $$ = chainon ($1, $2);
2960 $$ = build_tree_list ($1, NULL_TREE);
2964 $$ = build_tree_list (NULL_TREE, NULL_TREE);
2969 SELECTOR '(' selectorarg ')'
2976 PROTOCOL '(' identifier ')'
2982 /* extension to support C-structures in the archiver */
2985 ENCODE '(' typename ')'
2987 $$ = groktypename ($3);