1 /* YACC parser for C syntax and for Objective C. -*-c-*-
2 Copyright (C) 1987, 88, 89, 92-98, 1999 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 /* This file defines the grammar of C and that of Objective C.
22 ifobjc ... end ifobjc conditionals contain code for Objective C only.
23 ifc ... end ifc conditionals contain code for C only.
24 Sed commands in Makefile.in are used to convert this file into
25 c-parse.y and into objc-parse.y. */
27 /* To whomever it may concern: I have heard that such a thing was once
28 written by AT&T, but I have never seen it. */
36 /* These are the 23 conflicts you should get in parse.output;
37 the state numbers may vary if minor changes in the grammar are made.
39 State 42 contains 1 shift/reduce conflict. (Two ways to parse ATTRIBUTE.)
40 State 44 contains 1 shift/reduce conflict. (Two ways to recover from error.)
41 State 103 contains 1 shift/reduce conflict. (Two ways to recover from error.)
42 State 110 contains 1 shift/reduce conflict. (Two ways to parse ATTRIBUTE.)
43 State 111 contains 1 shift/reduce conflict. (Two ways to recover from error.)
44 State 115 contains 1 shift/reduce conflict. (Two ways to recover from error.)
45 State 132 contains 1 shift/reduce conflict. (See comment at component_decl.)
46 State 180 contains 1 shift/reduce conflict. (Two ways to parse ATTRIBUTE.)
47 State 194 contains 2 shift/reduce conflict. (Four ways to parse this.)
48 State 202 contains 1 shift/reduce conflict. (Two ways to recover from error.)
49 State 214 contains 1 shift/reduce conflict. (Two ways to recover from error.)
50 State 220 contains 1 shift/reduce conflict. (Two ways to recover from error.)
51 State 304 contains 2 shift/reduce conflicts. (Four ways to parse this.)
52 State 335 contains 2 shift/reduce conflicts. (Four ways to parse this.)
53 State 347 contains 1 shift/reduce conflict. (Two ways to parse ATTRIBUTES.)
54 State 352 contains 1 shift/reduce conflict. (Two ways to parse ATTRIBUTES.)
55 State 383 contains 2 shift/reduce conflicts. (Four ways to parse this.)
56 State 434 contains 2 shift/reduce conflicts. (Four ways to parse this.) */
73 #ifdef MULTIBYTE_CHARS
81 /* Since parsers are distinct for each language, put the language string
84 const char * const language_string = "GNU Obj-C";
87 const char * const language_string = "GNU C";
90 /* Like YYERROR but do call yyerror. */
91 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
93 /* Cause the `yydebug' variable to be defined. */
99 %union {long itype; tree ttype; enum tree_code code;
100 char *filename; int lineno; int ends_in_label; }
102 /* All identifiers that are not reserved words
103 and are not declared typedefs in the current block */
106 /* All identifiers that are declared typedefs in the current block.
107 In some contexts, they are treated just like IDENTIFIER,
108 but they can also serve as typespecs in declarations. */
111 /* Reserved words that specify storage class.
112 yylval contains an IDENTIFIER_NODE which indicates which one. */
115 /* Reserved words that specify type.
116 yylval contains an IDENTIFIER_NODE which indicates which one. */
119 /* Reserved words that qualify type: "const", "volatile", or "restrict".
120 yylval contains an IDENTIFIER_NODE which indicates which one. */
123 /* Character or numeric constants.
124 yylval is the node for the constant. */
127 /* String constants in raw form.
128 yylval is a STRING_CST node. */
131 /* "...", used for functions with variable arglists. */
134 /* the reserved words */
135 /* SCO include files test "ASM", so use something else. */
136 %token SIZEOF ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
137 %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD TYPEOF ALIGNOF
138 %token ATTRIBUTE EXTENSION LABEL
139 %token REALPART IMAGPART VA_ARG
141 /* Used in c-lex.c for parsing pragmas. */
144 /* Add precedence rules to solve dangling else s/r conflict */
148 /* Define the operator tokens and their precedences.
149 The value is an integer because, if used, it is the tree code
150 to use in the expression made from the operator. */
152 %right <code> ASSIGN '='
153 %right <code> '?' ':'
159 %left <code> EQCOMPARE
160 %left <code> ARITHCOMPARE
161 %left <code> LSHIFT RSHIFT
163 %left <code> '*' '/' '%'
164 %right <code> UNARY PLUSPLUS MINUSMINUS
166 %left <code> POINTSAT '.' '(' '['
168 /* The Objective-C keywords. These are included in C and in
169 Objective C, so that the token codes are the same in both. */
170 %token INTERFACE IMPLEMENTATION END SELECTOR DEFS ENCODE
171 %token CLASSNAME PUBLIC PRIVATE PROTECTED PROTOCOL OBJECTNAME CLASS ALIAS
173 /* Objective-C string constants in raw form.
174 yylval is an OBJC_STRING_CST node. */
180 %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist exprlist
181 %type <ttype> expr_no_commas cast_expr unary_expr primary string STRING
182 %type <ttype> typed_declspecs reserved_declspecs
183 %type <ttype> typed_typespecs reserved_typespecquals
184 %type <ttype> declmods typespec typespecqual_reserved
185 %type <ttype> typed_declspecs_no_prefix_attr reserved_declspecs_no_prefix_attr
186 %type <ttype> declmods_no_prefix_attr
187 %type <ttype> SCSPEC TYPESPEC TYPE_QUAL nonempty_type_quals maybe_type_qual
188 %type <ttype> initdecls notype_initdecls initdcl notype_initdcl
189 %type <ttype> init maybeasm
190 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
191 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
192 %type <ttype> any_word
194 %type <ttype> compstmt
196 %type <ttype> declarator
197 %type <ttype> notype_declarator after_type_declarator
198 %type <ttype> parm_declarator
200 %type <ttype> structsp component_decl_list component_decl_list2
201 %type <ttype> component_decl components component_declarator
202 %type <ttype> enumlist enumerator
203 %type <ttype> struct_head union_head enum_head
204 %type <ttype> typename absdcl absdcl1 type_quals
205 %type <ttype> xexpr parms parm identifiers
207 %type <ttype> parmlist parmlist_1 parmlist_2
208 %type <ttype> parmlist_or_identifiers parmlist_or_identifiers_1
209 %type <ttype> identifiers_or_typenames
211 %type <itype> setspecs
213 %type <ends_in_label> lineno_stmt_or_label lineno_stmt_or_labels stmt_or_label
215 %type <filename> save_filename
216 %type <lineno> save_lineno
219 /* the Objective-C nonterminals */
221 %type <ttype> ivar_decl_list ivar_decls ivar_decl ivars ivar_declarator
222 %type <ttype> methoddecl unaryselector keywordselector selector
223 %type <ttype> keyworddecl receiver objcmessageexpr messageargs
224 %type <ttype> keywordexpr keywordarglist keywordarg
225 %type <ttype> myparms myparm optparmlist reservedwords objcselectorexpr
226 %type <ttype> selectorarg keywordnamelist keywordname objcencodeexpr
227 %type <ttype> objc_string non_empty_protocolrefs protocolrefs identifier_list objcprotocolexpr
229 %type <ttype> CLASSNAME OBJC_STRING OBJECTNAME
233 /* Number of statements (loosely speaking) and compound statements
235 static int stmt_count;
236 static int compstmt_count;
238 /* Input file and line number of the end of the body of last simple_if;
239 used by the stmt-rule immediately after simple_if returns. */
240 static char *if_stmt_file;
241 static int if_stmt_line;
243 /* List of types and structure classes of the current declaration. */
244 static tree current_declspecs = NULL_TREE;
245 static tree prefix_attributes = NULL_TREE;
247 /* Stack of saved values of current_declspecs and prefix_attributes. */
248 static tree declspec_stack;
250 /* 1 if we explained undeclared var errors. */
251 static int undeclared_variable_notice;
254 /* Objective-C specific information */
256 tree objc_interface_context;
257 tree objc_implementation_context;
258 tree objc_method_context;
259 tree objc_ivar_chain;
260 tree objc_ivar_context;
261 enum tree_code objc_inherit_code;
262 int objc_receiver_context;
263 int objc_public_flag;
267 /* Tell yyparse how to print a token's value, if yydebug is set. */
269 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
270 extern void yyprint PROTO ((FILE *, int, YYSTYPE));
276 pedwarn ("ANSI C forbids an empty source file");
281 /* In case there were missing closebraces,
282 get us back to the global binding level. */
283 while (! global_bindings_p ())
289 /* the reason for the strange actions in this rule
290 is so that notype_initdecls when reached via datadef
291 can find a valid list of type and sc specs in $0. */
294 {$<ttype>$ = NULL_TREE; } extdef
295 | extdefs {$<ttype>$ = NULL_TREE; } extdef
304 | ASM_KEYWORD '(' expr ')' ';'
306 if ((TREE_CODE ($3) == ADDR_EXPR
307 && TREE_CODE (TREE_OPERAND ($3, 0)) == STRING_CST)
308 || TREE_CODE ($3) == STRING_CST)
311 error ("argument of `asm' is not a constant string"); }
313 { pedantic = $<itype>1; }
317 setspecs notype_initdecls ';'
319 error ("ANSI C forbids data definition with no type or storage class");
320 else if (!flag_traditional)
321 warning ("data definition has no type or storage class");
323 current_declspecs = TREE_VALUE (declspec_stack);
324 prefix_attributes = TREE_PURPOSE (declspec_stack);
325 declspec_stack = TREE_CHAIN (declspec_stack);
326 resume_momentary ($1); }
327 | declmods setspecs notype_initdecls ';'
328 { current_declspecs = TREE_VALUE (declspec_stack);
329 prefix_attributes = TREE_PURPOSE (declspec_stack);
330 declspec_stack = TREE_CHAIN (declspec_stack);
331 resume_momentary ($2); }
332 | typed_declspecs setspecs initdecls ';'
333 { current_declspecs = TREE_VALUE (declspec_stack);
334 prefix_attributes = TREE_PURPOSE (declspec_stack);
335 declspec_stack = TREE_CHAIN (declspec_stack);
336 resume_momentary ($2); }
338 { pedwarn ("empty declaration"); }
339 | typed_declspecs ';'
345 pedwarn ("ANSI C does not allow extra `;' outside of a function"); }
349 typed_declspecs setspecs declarator
350 { if (! start_function (current_declspecs, $3,
351 prefix_attributes, NULL_TREE, 0))
353 reinit_parse_for_function (); }
355 { store_parm_decls (); }
357 { finish_function (0);
358 current_declspecs = TREE_VALUE (declspec_stack);
359 prefix_attributes = TREE_PURPOSE (declspec_stack);
360 declspec_stack = TREE_CHAIN (declspec_stack);
361 resume_momentary ($2); }
362 | typed_declspecs setspecs declarator error
363 { current_declspecs = TREE_VALUE (declspec_stack);
364 prefix_attributes = TREE_PURPOSE (declspec_stack);
365 declspec_stack = TREE_CHAIN (declspec_stack);
366 resume_momentary ($2); }
367 | declmods setspecs notype_declarator
368 { if (! start_function (current_declspecs, $3,
369 prefix_attributes, NULL_TREE, 0))
371 reinit_parse_for_function (); }
373 { store_parm_decls (); }
375 { finish_function (0);
376 current_declspecs = TREE_VALUE (declspec_stack);
377 prefix_attributes = TREE_PURPOSE (declspec_stack);
378 declspec_stack = TREE_CHAIN (declspec_stack);
379 resume_momentary ($2); }
380 | declmods setspecs notype_declarator error
381 { current_declspecs = TREE_VALUE (declspec_stack);
382 prefix_attributes = TREE_PURPOSE (declspec_stack);
383 declspec_stack = TREE_CHAIN (declspec_stack);
384 resume_momentary ($2); }
385 | setspecs notype_declarator
386 { if (! start_function (NULL_TREE, $2,
387 prefix_attributes, NULL_TREE, 0))
389 reinit_parse_for_function (); }
391 { store_parm_decls (); }
393 { finish_function (0);
394 current_declspecs = TREE_VALUE (declspec_stack);
395 prefix_attributes = TREE_PURPOSE (declspec_stack);
396 declspec_stack = TREE_CHAIN (declspec_stack);
397 resume_momentary ($1); }
398 | setspecs notype_declarator error
399 { current_declspecs = TREE_VALUE (declspec_stack);
400 prefix_attributes = TREE_PURPOSE (declspec_stack);
401 declspec_stack = TREE_CHAIN (declspec_stack);
402 resume_momentary ($1); }
417 { $$ = NEGATE_EXPR; }
419 { $$ = CONVERT_EXPR; }
421 { $$ = PREINCREMENT_EXPR; }
423 { $$ = PREDECREMENT_EXPR; }
425 { $$ = BIT_NOT_EXPR; }
427 { $$ = TRUTH_NOT_EXPR; }
430 expr: nonnull_exprlist
431 { $$ = build_compound_expr ($1); }
442 { $$ = build_tree_list (NULL_TREE, $1); }
443 | nonnull_exprlist ',' expr_no_commas
444 { chainon ($1, build_tree_list (NULL_TREE, $3)); }
449 | '*' cast_expr %prec UNARY
450 { $$ = build_indirect_ref ($2, "unary *"); }
451 /* __extension__ turns off -pedantic for following primary. */
452 | extension cast_expr %prec UNARY
454 pedantic = $<itype>1; }
455 | unop cast_expr %prec UNARY
456 { $$ = build_unary_op ($1, $2, 0);
457 overflow_warning ($$); }
458 /* Refer to the address of a label as a pointer. */
460 { tree label = lookup_label ($2);
462 pedwarn ("ANSI C forbids `&&'");
464 $$ = null_pointer_node;
467 TREE_USED (label) = 1;
468 $$ = build1 (ADDR_EXPR, ptr_type_node, label);
469 TREE_CONSTANT ($$) = 1;
472 /* This seems to be impossible on some machines, so let's turn it off.
473 You can use __builtin_next_arg to find the anonymous stack args.
475 { tree types = TYPE_ARG_TYPES (TREE_TYPE (current_function_decl));
476 $$ = error_mark_node;
477 if (TREE_VALUE (tree_last (types)) == void_type_node)
478 error ("`&...' used in function with fixed number of arguments");
482 pedwarn ("ANSI C forbids `&...'");
483 $$ = tree_last (DECL_ARGUMENTS (current_function_decl));
484 $$ = build_unary_op (ADDR_EXPR, $$, 0);
487 | sizeof unary_expr %prec UNARY
489 if (TREE_CODE ($2) == COMPONENT_REF
490 && DECL_C_BIT_FIELD (TREE_OPERAND ($2, 1)))
491 error ("`sizeof' applied to a bit-field");
492 $$ = c_sizeof (TREE_TYPE ($2)); }
493 | sizeof '(' typename ')' %prec HYPERUNARY
495 $$ = c_sizeof (groktypename ($3)); }
496 | alignof unary_expr %prec UNARY
498 $$ = c_alignof_expr ($2); }
499 | alignof '(' typename ')' %prec HYPERUNARY
501 $$ = c_alignof (groktypename ($3)); }
502 | REALPART cast_expr %prec UNARY
503 { $$ = build_unary_op (REALPART_EXPR, $2, 0); }
504 | IMAGPART cast_expr %prec UNARY
505 { $$ = build_unary_op (IMAGPART_EXPR, $2, 0); }
506 | VA_ARG '(' expr_no_commas ',' typename ')'
507 { $$ = build_va_arg ($3, groktypename ($5)); }
511 SIZEOF { skip_evaluation++; }
515 ALIGNOF { skip_evaluation++; }
520 | '(' typename ')' cast_expr %prec UNARY
521 { tree type = groktypename ($2);
522 $$ = build_c_cast (type, $4); }
523 | '(' typename ')' '{'
524 { start_init (NULL_TREE, NULL, 0);
525 $2 = groktypename ($2);
526 really_start_incremental_init ($2); }
527 initlist_maybe_comma '}' %prec UNARY
529 tree result = pop_init_level (0);
533 if (pedantic && ! flag_isoc9x)
534 pedwarn ("ANSI C forbids constructor expressions");
535 if (TYPE_NAME (type) != 0)
537 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
538 name = IDENTIFIER_POINTER (TYPE_NAME (type));
540 name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
545 if (TREE_CODE (type) == ARRAY_TYPE && TYPE_SIZE (type) == 0)
547 int failure = complete_array_type (type, $$, 1);
556 | expr_no_commas '+' expr_no_commas
557 { $$ = parser_build_binary_op ($2, $1, $3); }
558 | expr_no_commas '-' expr_no_commas
559 { $$ = parser_build_binary_op ($2, $1, $3); }
560 | expr_no_commas '*' expr_no_commas
561 { $$ = parser_build_binary_op ($2, $1, $3); }
562 | expr_no_commas '/' expr_no_commas
563 { $$ = parser_build_binary_op ($2, $1, $3); }
564 | expr_no_commas '%' expr_no_commas
565 { $$ = parser_build_binary_op ($2, $1, $3); }
566 | expr_no_commas LSHIFT expr_no_commas
567 { $$ = parser_build_binary_op ($2, $1, $3); }
568 | expr_no_commas RSHIFT expr_no_commas
569 { $$ = parser_build_binary_op ($2, $1, $3); }
570 | expr_no_commas ARITHCOMPARE expr_no_commas
571 { $$ = parser_build_binary_op ($2, $1, $3); }
572 | expr_no_commas EQCOMPARE expr_no_commas
573 { $$ = parser_build_binary_op ($2, $1, $3); }
574 | expr_no_commas '&' expr_no_commas
575 { $$ = parser_build_binary_op ($2, $1, $3); }
576 | expr_no_commas '|' expr_no_commas
577 { $$ = parser_build_binary_op ($2, $1, $3); }
578 | expr_no_commas '^' expr_no_commas
579 { $$ = parser_build_binary_op ($2, $1, $3); }
580 | expr_no_commas ANDAND
581 { $1 = truthvalue_conversion (default_conversion ($1));
582 skip_evaluation += $1 == boolean_false_node; }
584 { skip_evaluation -= $1 == boolean_false_node;
585 $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $4); }
586 | expr_no_commas OROR
587 { $1 = truthvalue_conversion (default_conversion ($1));
588 skip_evaluation += $1 == boolean_true_node; }
590 { skip_evaluation -= $1 == boolean_true_node;
591 $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $4); }
593 { $1 = truthvalue_conversion (default_conversion ($1));
594 skip_evaluation += $1 == boolean_false_node; }
596 { skip_evaluation += (($1 == boolean_true_node)
597 - ($1 == boolean_false_node)); }
599 { skip_evaluation -= $1 == boolean_true_node;
600 $$ = build_conditional_expr ($1, $4, $7); }
603 pedwarn ("ANSI C forbids omitting the middle term of a ?: expression");
604 /* Make sure first operand is calculated only once. */
605 $<ttype>2 = save_expr ($1);
606 $1 = truthvalue_conversion (default_conversion ($<ttype>2));
607 skip_evaluation += $1 == boolean_true_node; }
609 { skip_evaluation -= $1 == boolean_true_node;
610 $$ = build_conditional_expr ($1, $<ttype>2, $5); }
611 | expr_no_commas '=' expr_no_commas
613 $$ = build_modify_expr ($1, NOP_EXPR, $3);
614 class = TREE_CODE_CLASS (TREE_CODE ($$));
615 if (class == 'e' || class == '1'
616 || class == '2' || class == '<')
617 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR);
619 | expr_no_commas ASSIGN expr_no_commas
621 $$ = build_modify_expr ($1, $2, $3);
622 /* This inhibits warnings in truthvalue_conversion. */
623 class = TREE_CODE_CLASS (TREE_CODE ($$));
624 if (class == 'e' || class == '1'
625 || class == '2' || class == '<')
626 C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK);
634 if (!$$ || $$ == error_mark_node)
636 if (yychar == YYEMPTY)
643 if (objc_receiver_context
644 && ! (objc_receiver_context
645 && strcmp (IDENTIFIER_POINTER ($1), "super")))
646 /* we have a message to super */
647 $$ = get_super_receiver ();
648 else if (objc_method_context
649 && (decl = is_ivar (objc_ivar_chain, $1)))
651 if (is_private (decl))
652 $$ = error_mark_node;
654 $$ = build_ivar_reference ($1);
659 /* Ordinary implicit function declaration. */
660 $$ = implicitly_declare ($1);
661 assemble_external ($$);
665 else if (current_function_decl == 0)
667 error ("`%s' undeclared here (not in a function)",
668 IDENTIFIER_POINTER ($1));
669 $$ = error_mark_node;
676 if (objc_receiver_context
677 && ! strcmp (IDENTIFIER_POINTER ($1), "super"))
678 /* we have a message to super */
679 $$ = get_super_receiver ();
680 else if (objc_method_context
681 && (decl = is_ivar (objc_ivar_chain, $1)))
683 if (is_private (decl))
684 $$ = error_mark_node;
686 $$ = build_ivar_reference ($1);
691 if (IDENTIFIER_GLOBAL_VALUE ($1) != error_mark_node
692 || IDENTIFIER_ERROR_LOCUS ($1) != current_function_decl)
694 error ("`%s' undeclared (first use in this function)",
695 IDENTIFIER_POINTER ($1));
697 if (! undeclared_variable_notice)
699 error ("(Each undeclared identifier is reported only once");
700 error ("for each function it appears in.)");
701 undeclared_variable_notice = 1;
704 $$ = error_mark_node;
705 /* Prevent repeated error messages. */
706 IDENTIFIER_GLOBAL_VALUE ($1) = error_mark_node;
707 IDENTIFIER_ERROR_LOCUS ($1) = current_function_decl;
711 else if (TREE_TYPE ($$) == error_mark_node)
712 $$ = error_mark_node;
713 else if (C_DECL_ANTICIPATED ($$))
715 /* The first time we see a build-in function used,
716 if it has not been declared. */
717 C_DECL_ANTICIPATED ($$) = 0;
718 if (yychar == YYEMPTY)
722 /* Omit the implicit declaration we
723 would ordinarily do, so we don't lose
724 the actual built in type.
725 But print a diagnostic for the mismatch. */
727 if (objc_method_context
728 && is_ivar (objc_ivar_chain, $1))
729 error ("Instance variable `%s' implicitly declared as function",
730 IDENTIFIER_POINTER (DECL_NAME ($$)));
733 if (TREE_CODE ($$) != FUNCTION_DECL)
734 error ("`%s' implicitly declared as function",
735 IDENTIFIER_POINTER (DECL_NAME ($$)));
736 else if ((TYPE_MODE (TREE_TYPE (TREE_TYPE ($$)))
737 != TYPE_MODE (integer_type_node))
738 && (TREE_TYPE (TREE_TYPE ($$))
740 pedwarn ("type mismatch in implicit declaration for built-in function `%s'",
741 IDENTIFIER_POINTER (DECL_NAME ($$)));
742 /* If it really returns void, change that to int. */
743 if (TREE_TYPE (TREE_TYPE ($$)) == void_type_node)
745 = build_function_type (integer_type_node,
746 TYPE_ARG_TYPES (TREE_TYPE ($$)));
749 pedwarn ("built-in function `%s' used without declaration",
750 IDENTIFIER_POINTER (DECL_NAME ($$)));
752 /* Do what we would ordinarily do when a fn is used. */
753 assemble_external ($$);
758 assemble_external ($$);
761 /* we have a definition - still check if iVariable */
763 if (!objc_receiver_context
764 || (objc_receiver_context
765 && strcmp (IDENTIFIER_POINTER ($1), "super")))
769 if (objc_method_context
770 && (decl = is_ivar (objc_ivar_chain, $1)))
772 if (IDENTIFIER_LOCAL_VALUE ($1))
773 warning ("local declaration of `%s' hides instance variable",
774 IDENTIFIER_POINTER ($1));
777 if (is_private (decl))
778 $$ = error_mark_node;
780 $$ = build_ivar_reference ($1);
784 else /* we have a message to super */
785 $$ = get_super_receiver ();
789 if (TREE_CODE ($$) == CONST_DECL)
791 $$ = DECL_INITIAL ($$);
792 /* This is to prevent an enum whose value is 0
793 from being considered a null pointer constant. */
794 $$ = build1 (NOP_EXPR, TREE_TYPE ($$), $$);
795 TREE_CONSTANT ($$) = 1;
800 { $$ = combine_strings ($1); }
802 { char class = TREE_CODE_CLASS (TREE_CODE ($2));
803 if (class == 'e' || class == '1'
804 || class == '2' || class == '<')
805 C_SET_EXP_ORIGINAL_CODE ($2, ERROR_MARK);
808 { $$ = error_mark_node; }
810 { if (current_function_decl == 0)
812 error ("braced-group within expression allowed only inside a function");
815 /* We must force a BLOCK for this level
816 so that, if it is not expanded later,
817 there is a way to turn off the entire subtree of blocks
818 that are contained in it. */
820 push_iterator_stack ();
822 $<ttype>$ = expand_start_stmt_expr (); }
826 pedwarn ("ANSI C forbids braced-groups within expressions");
827 pop_iterator_stack ();
829 rtl_exp = expand_end_stmt_expr ($<ttype>2);
830 /* The statements have side effects, so the group does. */
831 TREE_SIDE_EFFECTS (rtl_exp) = 1;
833 if (TREE_CODE ($3) == BLOCK)
835 /* Make a BIND_EXPR for the BLOCK already made. */
836 $$ = build (BIND_EXPR, TREE_TYPE (rtl_exp),
837 NULL_TREE, rtl_exp, $3);
838 /* Remove the block from the tree at this point.
839 It gets put back at the proper place
840 when the BIND_EXPR is expanded. */
846 | primary '(' exprlist ')' %prec '.'
847 { $$ = build_function_call ($1, $3); }
848 | primary '[' expr ']' %prec '.'
849 { $$ = build_array_ref ($1, $3); }
850 | primary '.' identifier
853 if (doing_objc_thang)
855 if (is_public ($1, $3))
856 $$ = build_component_ref ($1, $3);
858 $$ = error_mark_node;
862 $$ = build_component_ref ($1, $3);
864 | primary POINTSAT identifier
866 tree expr = build_indirect_ref ($1, "->");
869 if (doing_objc_thang)
871 if (is_public (expr, $3))
872 $$ = build_component_ref (expr, $3);
874 $$ = error_mark_node;
878 $$ = build_component_ref (expr, $3);
881 { $$ = build_unary_op (POSTINCREMENT_EXPR, $1, 0); }
883 { $$ = build_unary_op (POSTDECREMENT_EXPR, $1, 0); }
886 { $$ = build_message_expr ($1); }
888 { $$ = build_selector_expr ($1); }
890 { $$ = build_protocol_expr ($1); }
892 { $$ = build_encode_expr ($1); }
894 { $$ = build_objc_string_object ($1); }
898 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
902 { $$ = chainon ($1, $2); }
906 /* Produces an OBJC_STRING_CST with perhaps more OBJC_STRING_CSTs chained
910 | objc_string OBJC_STRING
911 { $$ = chainon ($1, $2); }
915 old_style_parm_decls:
919 /* ... is used here to indicate a varargs function. */
922 pedwarn ("ANSI C does not permit use of `varargs.h'"); }
925 /* The following are analogous to lineno_decl, decls and decl
926 except that they do not allow nested functions.
927 They are used for old-style parm decls. */
929 save_filename save_lineno datadecl
936 | datadecls lineno_datadecl
937 | lineno_datadecl errstmt
940 /* We don't allow prefix attributes here because they cause reduce/reduce
941 conflicts: we can't know whether we're parsing a function decl with
942 attribute suffix, or function defn with attribute prefix on first old
945 typed_declspecs_no_prefix_attr setspecs initdecls ';'
946 { current_declspecs = TREE_VALUE (declspec_stack);
947 prefix_attributes = TREE_PURPOSE (declspec_stack);
948 declspec_stack = TREE_CHAIN (declspec_stack);
949 resume_momentary ($2); }
950 | declmods_no_prefix_attr setspecs notype_initdecls ';'
951 { current_declspecs = TREE_VALUE (declspec_stack);
952 prefix_attributes = TREE_PURPOSE (declspec_stack);
953 declspec_stack = TREE_CHAIN (declspec_stack);
954 resume_momentary ($2); }
955 | typed_declspecs_no_prefix_attr ';'
956 { shadow_tag_warned ($1, 1);
957 pedwarn ("empty declaration"); }
958 | declmods_no_prefix_attr ';'
959 { pedwarn ("empty declaration"); }
962 /* This combination which saves a lineno before a decl
963 is the normal thing to use, rather than decl itself.
964 This is to avoid shift/reduce conflicts in contexts
965 where statement labels are allowed. */
967 save_filename save_lineno decl
975 | lineno_decl errstmt
978 /* records the type and storage class specs to use for processing
979 the declarators that follow.
980 Maintains a stack of outer-level values of current_declspecs,
981 for the sake of parm declarations nested in function declarators. */
982 setspecs: /* empty */
983 { $$ = suspend_momentary ();
984 pending_xref_error ();
985 declspec_stack = tree_cons (prefix_attributes,
988 split_specs_attrs ($<ttype>0,
989 ¤t_declspecs, &prefix_attributes); }
992 /* ??? Yuck. See after_type_declarator. */
993 setattrs: /* empty */
994 { prefix_attributes = chainon (prefix_attributes, $<ttype>0); }
998 typed_declspecs setspecs initdecls ';'
999 { current_declspecs = TREE_VALUE (declspec_stack);
1000 prefix_attributes = TREE_PURPOSE (declspec_stack);
1001 declspec_stack = TREE_CHAIN (declspec_stack);
1002 resume_momentary ($2); }
1003 | declmods setspecs notype_initdecls ';'
1004 { current_declspecs = TREE_VALUE (declspec_stack);
1005 prefix_attributes = TREE_PURPOSE (declspec_stack);
1006 declspec_stack = TREE_CHAIN (declspec_stack);
1007 resume_momentary ($2); }
1008 | typed_declspecs setspecs nested_function
1009 { current_declspecs = TREE_VALUE (declspec_stack);
1010 prefix_attributes = TREE_PURPOSE (declspec_stack);
1011 declspec_stack = TREE_CHAIN (declspec_stack);
1012 resume_momentary ($2); }
1013 | declmods setspecs notype_nested_function
1014 { current_declspecs = TREE_VALUE (declspec_stack);
1015 prefix_attributes = TREE_PURPOSE (declspec_stack);
1016 declspec_stack = TREE_CHAIN (declspec_stack);
1017 resume_momentary ($2); }
1018 | typed_declspecs ';'
1019 { shadow_tag ($1); }
1021 { pedwarn ("empty declaration"); }
1023 { pedantic = $<itype>1; }
1026 /* Declspecs which contain at least one type specifier or typedef name.
1027 (Just `const' or `volatile' is not enough.)
1028 A typedef'd name following these is taken as a name to be declared.
1029 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
1032 typespec reserved_declspecs
1033 { $$ = tree_cons (NULL_TREE, $1, $2); }
1034 | declmods typespec reserved_declspecs
1035 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
1038 reserved_declspecs: /* empty */
1040 | reserved_declspecs typespecqual_reserved
1041 { $$ = tree_cons (NULL_TREE, $2, $1); }
1042 | reserved_declspecs SCSPEC
1043 { if (extra_warnings)
1044 warning ("`%s' is not at beginning of declaration",
1045 IDENTIFIER_POINTER ($2));
1046 $$ = tree_cons (NULL_TREE, $2, $1); }
1047 | reserved_declspecs attributes
1048 { $$ = tree_cons ($2, NULL_TREE, $1); }
1051 typed_declspecs_no_prefix_attr:
1052 typespec reserved_declspecs_no_prefix_attr
1053 { $$ = tree_cons (NULL_TREE, $1, $2); }
1054 | declmods_no_prefix_attr typespec reserved_declspecs_no_prefix_attr
1055 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
1058 reserved_declspecs_no_prefix_attr:
1061 | reserved_declspecs_no_prefix_attr typespecqual_reserved
1062 { $$ = tree_cons (NULL_TREE, $2, $1); }
1063 | reserved_declspecs_no_prefix_attr SCSPEC
1064 { if (extra_warnings)
1065 warning ("`%s' is not at beginning of declaration",
1066 IDENTIFIER_POINTER ($2));
1067 $$ = tree_cons (NULL_TREE, $2, $1); }
1070 /* List of just storage classes, type modifiers, and prefix attributes.
1071 A declaration can start with just this, but then it cannot be used
1072 to redeclare a typedef-name.
1073 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
1076 declmods_no_prefix_attr
1079 { $$ = tree_cons ($1, NULL_TREE, NULL_TREE); }
1080 | declmods declmods_no_prefix_attr
1081 { $$ = chainon ($2, $1); }
1082 | declmods attributes
1083 { $$ = tree_cons ($2, NULL_TREE, $1); }
1086 declmods_no_prefix_attr:
1088 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
1089 TREE_STATIC ($$) = 1; }
1091 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
1092 | declmods_no_prefix_attr TYPE_QUAL
1093 { $$ = tree_cons (NULL_TREE, $2, $1);
1094 TREE_STATIC ($$) = 1; }
1095 | declmods_no_prefix_attr SCSPEC
1096 { if (extra_warnings && TREE_STATIC ($1))
1097 warning ("`%s' is not at beginning of declaration",
1098 IDENTIFIER_POINTER ($2));
1099 $$ = tree_cons (NULL_TREE, $2, $1);
1100 TREE_STATIC ($$) = TREE_STATIC ($1); }
1104 /* Used instead of declspecs where storage classes are not allowed
1105 (that is, for typenames and structure components).
1106 Don't accept a typedef-name if anything but a modifier precedes it. */
1109 typespec reserved_typespecquals
1110 { $$ = tree_cons (NULL_TREE, $1, $2); }
1111 | nonempty_type_quals typespec reserved_typespecquals
1112 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
1115 reserved_typespecquals: /* empty */
1117 | reserved_typespecquals typespecqual_reserved
1118 { $$ = tree_cons (NULL_TREE, $2, $1); }
1121 /* A typespec (but not a type qualifier).
1122 Once we have seen one of these in a declaration,
1123 if a typedef name appears then it is being redeclared. */
1128 { /* For a typedef name, record the meaning, not the name.
1129 In case of `foo foo, bar;'. */
1130 $$ = lookup_name ($1); }
1132 | CLASSNAME protocolrefs
1133 { $$ = get_static_reference ($1, $2); }
1134 | OBJECTNAME protocolrefs
1135 { $$ = get_object_reference ($2); }
1137 /* Make "<SomeProtocol>" equivalent to "id <SomeProtocol>"
1138 - nisse@lysator.liu.se */
1139 | non_empty_protocolrefs
1140 { $$ = get_object_reference ($1); }
1142 | TYPEOF '(' expr ')'
1143 { $$ = TREE_TYPE ($3); }
1144 | TYPEOF '(' typename ')'
1145 { $$ = groktypename ($3); }
1148 /* A typespec that is a reserved word, or a type qualifier. */
1150 typespecqual_reserved: TYPESPEC
1157 | initdecls ',' initdcl
1162 | notype_initdecls ',' initdcl
1168 | ASM_KEYWORD '(' string ')'
1169 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
1175 declarator maybeasm maybe_attribute '='
1176 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1177 $3, prefix_attributes);
1178 start_init ($<ttype>$, $2, global_bindings_p ()); }
1180 /* Note how the declaration of the variable is in effect while its init is parsed! */
1182 finish_decl ($<ttype>5, $6, $2); }
1183 | declarator maybeasm maybe_attribute
1184 { tree d = start_decl ($1, current_declspecs, 0,
1185 $3, prefix_attributes);
1186 finish_decl (d, NULL_TREE, $2);
1191 notype_declarator maybeasm maybe_attribute '='
1192 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1193 $3, prefix_attributes);
1194 start_init ($<ttype>$, $2, global_bindings_p ()); }
1196 /* Note how the declaration of the variable is in effect while its init is parsed! */
1198 decl_attributes ($<ttype>5, $3, prefix_attributes);
1199 finish_decl ($<ttype>5, $6, $2); }
1200 | notype_declarator maybeasm maybe_attribute
1201 { tree d = start_decl ($1, current_declspecs, 0,
1202 $3, prefix_attributes);
1203 finish_decl (d, NULL_TREE, $2); }
1205 /* the * rules are dummies to accept the Apollo extended syntax
1206 so that the header files compile. */
1217 | attributes attribute
1218 { $$ = chainon ($1, $2); }
1222 ATTRIBUTE '(' '(' attribute_list ')' ')'
1229 | attribute_list ',' attrib
1230 { $$ = chainon ($1, $3); }
1237 { $$ = build_tree_list ($1, NULL_TREE); }
1238 | any_word '(' IDENTIFIER ')'
1239 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1240 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1241 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1242 | any_word '(' exprlist ')'
1243 { $$ = build_tree_list ($1, $3); }
1246 /* This still leaves out most reserved keywords,
1247 shouldn't we include them? */
1256 /* Initializers. `init' is the entry point. */
1261 { really_start_incremental_init (NULL_TREE);
1262 /* Note that the call to clear_momentary
1263 is in process_init_element. */
1264 push_momentary (); }
1265 initlist_maybe_comma '}'
1266 { $$ = pop_init_level (0);
1267 if ($$ == error_mark_node
1268 && ! (yychar == STRING || yychar == CONSTANT))
1271 pop_momentary_nofree (); }
1274 { $$ = error_mark_node; }
1277 /* `initlist_maybe_comma' is the guts of an initializer in braces. */
1278 initlist_maybe_comma:
1281 pedwarn ("ANSI C forbids empty initializer braces"); }
1282 | initlist1 maybecomma
1287 | initlist1 ',' initelt
1290 /* `initelt' is a single element of an initializer.
1291 It may use braces. */
1293 designator_list '=' initval
1294 | designator initval
1296 { set_init_label ($1); }
1303 { push_init_level (0); }
1304 initlist_maybe_comma '}'
1305 { process_init_element (pop_init_level (0)); }
1307 { process_init_element ($1); }
1313 | designator_list designator
1318 { set_init_label ($2); }
1319 /* These are for labeled elements. The syntax for an array element
1320 initializer conflicts with the syntax for an Objective-C message,
1321 so don't include these productions in the Objective-C grammar. */
1323 | '[' expr_no_commas ELLIPSIS expr_no_commas ']'
1324 { set_init_index ($2, $4); }
1325 | '[' expr_no_commas ']'
1326 { set_init_index ($2, NULL_TREE); }
1332 { push_c_function_context ();
1333 if (! start_function (current_declspecs, $1,
1334 prefix_attributes, NULL_TREE, 1))
1336 pop_c_function_context ();
1339 reinit_parse_for_function (); }
1340 old_style_parm_decls
1341 { store_parm_decls (); }
1342 /* This used to use compstmt_or_error.
1343 That caused a bug with input `f(g) int g {}',
1344 where the use of YYERROR1 above caused an error
1345 which then was handled by compstmt_or_error.
1346 There followed a repeated execution of that same rule,
1347 which called YYERROR1 again, and so on. */
1349 { finish_function (1);
1350 pop_c_function_context (); }
1353 notype_nested_function:
1355 { push_c_function_context ();
1356 if (! start_function (current_declspecs, $1,
1357 prefix_attributes, NULL_TREE, 1))
1359 pop_c_function_context ();
1362 reinit_parse_for_function (); }
1363 old_style_parm_decls
1364 { store_parm_decls (); }
1365 /* This used to use compstmt_or_error.
1366 That caused a bug with input `f(g) int g {}',
1367 where the use of YYERROR1 above caused an error
1368 which then was handled by compstmt_or_error.
1369 There followed a repeated execution of that same rule,
1370 which called YYERROR1 again, and so on. */
1372 { finish_function (1);
1373 pop_c_function_context (); }
1376 /* Any kind of declarator (thus, all declarators allowed
1377 after an explicit typespec). */
1380 after_type_declarator
1384 /* A declarator that is allowed only after an explicit typespec. */
1386 after_type_declarator:
1387 '(' after_type_declarator ')'
1389 | after_type_declarator '(' parmlist_or_identifiers %prec '.'
1390 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1391 /* | after_type_declarator '(' error ')' %prec '.'
1392 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1393 poplevel (0, 0, 0); } */
1394 | after_type_declarator '[' expr ']' %prec '.'
1395 { $$ = build_nt (ARRAY_REF, $1, $3); }
1396 | after_type_declarator '[' ']' %prec '.'
1397 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1398 | '*' type_quals after_type_declarator %prec UNARY
1399 { $$ = make_pointer_declarator ($2, $3); }
1400 /* ??? Yuck. setattrs is a quick hack. We can't use
1401 prefix_attributes because $1 only applies to this
1402 declarator. We assume setspecs has already been done.
1403 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1404 attributes could be recognized here or in `attributes'). */
1405 | attributes setattrs after_type_declarator
1413 /* Kinds of declarator that can appear in a parameter list
1414 in addition to notype_declarator. This is like after_type_declarator
1415 but does not allow a typedef name in parentheses as an identifier
1416 (because it would conflict with a function with that typedef as arg). */
1419 parm_declarator '(' parmlist_or_identifiers %prec '.'
1420 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1421 /* | parm_declarator '(' error ')' %prec '.'
1422 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1423 poplevel (0, 0, 0); } */
1425 | parm_declarator '[' '*' ']' %prec '.'
1426 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE);
1428 error ("`[*]' in parameter declaration only allowed in ISO C 9x");
1431 | parm_declarator '[' expr ']' %prec '.'
1432 { $$ = build_nt (ARRAY_REF, $1, $3); }
1433 | parm_declarator '[' ']' %prec '.'
1434 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1435 | '*' type_quals parm_declarator %prec UNARY
1436 { $$ = make_pointer_declarator ($2, $3); }
1437 /* ??? Yuck. setattrs is a quick hack. We can't use
1438 prefix_attributes because $1 only applies to this
1439 declarator. We assume setspecs has already been done.
1440 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1441 attributes could be recognized here or in `attributes'). */
1442 | attributes setattrs parm_declarator
1447 /* A declarator allowed whether or not there has been
1448 an explicit typespec. These cannot redeclare a typedef-name. */
1451 notype_declarator '(' parmlist_or_identifiers %prec '.'
1452 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1453 /* | notype_declarator '(' error ')' %prec '.'
1454 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1455 poplevel (0, 0, 0); } */
1456 | '(' notype_declarator ')'
1458 | '*' type_quals notype_declarator %prec UNARY
1459 { $$ = make_pointer_declarator ($2, $3); }
1461 | notype_declarator '[' '*' ']' %prec '.'
1462 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE);
1464 error ("`[*]' in parameter declaration only allowed in ISO C 9x");
1467 | notype_declarator '[' expr ']' %prec '.'
1468 { $$ = build_nt (ARRAY_REF, $1, $3); }
1469 | notype_declarator '[' ']' %prec '.'
1470 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1471 /* ??? Yuck. setattrs is a quick hack. We can't use
1472 prefix_attributes because $1 only applies to this
1473 declarator. We assume setspecs has already been done.
1474 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1475 attributes could be recognized here or in `attributes'). */
1476 | attributes setattrs notype_declarator
1503 struct_head identifier '{'
1504 { $$ = start_struct (RECORD_TYPE, $2);
1505 /* Start scope of tag before parsing components. */
1507 component_decl_list '}' maybe_attribute
1508 { $$ = finish_struct ($<ttype>4, $5, chainon ($1, $7)); }
1509 | struct_head '{' component_decl_list '}' maybe_attribute
1510 { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
1511 $3, chainon ($1, $5));
1513 | struct_head identifier
1514 { $$ = xref_tag (RECORD_TYPE, $2); }
1515 | union_head identifier '{'
1516 { $$ = start_struct (UNION_TYPE, $2); }
1517 component_decl_list '}' maybe_attribute
1518 { $$ = finish_struct ($<ttype>4, $5, chainon ($1, $7)); }
1519 | union_head '{' component_decl_list '}' maybe_attribute
1520 { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
1521 $3, chainon ($1, $5));
1523 | union_head identifier
1524 { $$ = xref_tag (UNION_TYPE, $2); }
1525 | enum_head identifier '{'
1526 { $<itype>3 = suspend_momentary ();
1527 $$ = start_enum ($2); }
1528 enumlist maybecomma_warn '}' maybe_attribute
1529 { $$= finish_enum ($<ttype>4, nreverse ($5), chainon ($1, $8));
1530 resume_momentary ($<itype>3); }
1532 { $<itype>2 = suspend_momentary ();
1533 $$ = start_enum (NULL_TREE); }
1534 enumlist maybecomma_warn '}' maybe_attribute
1535 { $$= finish_enum ($<ttype>3, nreverse ($4), chainon ($1, $7));
1536 resume_momentary ($<itype>2); }
1537 | enum_head identifier
1538 { $$ = xref_tag (ENUMERAL_TYPE, $2); }
1549 { if (pedantic && ! flag_isoc9x)
1550 pedwarn ("comma at end of enumerator list"); }
1553 component_decl_list:
1554 component_decl_list2
1556 | component_decl_list2 component_decl
1557 { $$ = chainon ($1, $2);
1558 pedwarn ("no semicolon at end of struct or union"); }
1561 component_decl_list2: /* empty */
1563 | component_decl_list2 component_decl ';'
1564 { $$ = chainon ($1, $2); }
1565 | component_decl_list2 ';'
1567 pedwarn ("extra semicolon in struct or union specified"); }
1569 /* foo(sizeof(struct{ @defs(ClassName)})); */
1570 | DEFS '(' CLASSNAME ')'
1572 tree interface = lookup_interface ($3);
1575 $$ = get_class_ivars (interface);
1578 error ("Cannot find interface declaration for `%s'",
1579 IDENTIFIER_POINTER ($3));
1586 /* There is a shift-reduce conflict here, because `components' may
1587 start with a `typename'. It happens that shifting (the default resolution)
1588 does the right thing, because it treats the `typename' as part of
1589 a `typed_typespecs'.
1591 It is possible that this same technique would allow the distinction
1592 between `notype_initdecls' and `initdecls' to be eliminated.
1593 But I am being cautious and not trying it. */
1596 typed_typespecs setspecs components
1598 current_declspecs = TREE_VALUE (declspec_stack);
1599 prefix_attributes = TREE_PURPOSE (declspec_stack);
1600 declspec_stack = TREE_CHAIN (declspec_stack);
1601 resume_momentary ($2); }
1604 pedwarn ("ANSI C forbids member declarations with no members");
1607 | nonempty_type_quals setspecs components
1609 current_declspecs = TREE_VALUE (declspec_stack);
1610 prefix_attributes = TREE_PURPOSE (declspec_stack);
1611 declspec_stack = TREE_CHAIN (declspec_stack);
1612 resume_momentary ($2); }
1613 | nonempty_type_quals
1615 pedwarn ("ANSI C forbids member declarations with no members");
1620 | extension component_decl
1622 pedantic = $<itype>1; }
1626 component_declarator
1627 | components ',' component_declarator
1628 { $$ = chainon ($1, $3); }
1631 component_declarator:
1632 save_filename save_lineno declarator maybe_attribute
1633 { $$ = grokfield ($1, $2, $3, current_declspecs, NULL_TREE);
1634 decl_attributes ($$, $4, prefix_attributes); }
1635 | save_filename save_lineno
1636 declarator ':' expr_no_commas maybe_attribute
1637 { $$ = grokfield ($1, $2, $3, current_declspecs, $5);
1638 decl_attributes ($$, $6, prefix_attributes); }
1639 | save_filename save_lineno ':' expr_no_commas maybe_attribute
1640 { $$ = grokfield ($1, $2, NULL_TREE, current_declspecs, $4);
1641 decl_attributes ($$, $5, prefix_attributes); }
1644 /* We chain the enumerators in reverse order.
1645 They are put in forward order where enumlist is used.
1646 (The order used to be significant, but no longer is so.
1647 However, we still maintain the order, just to be clean.) */
1651 | enumlist ',' enumerator
1652 { if ($1 == error_mark_node)
1655 $$ = chainon ($3, $1); }
1657 { $$ = error_mark_node; }
1663 { $$ = build_enumerator ($1, NULL_TREE); }
1664 | identifier '=' expr_no_commas
1665 { $$ = build_enumerator ($1, $3); }
1669 typed_typespecs absdcl
1670 { $$ = build_tree_list ($1, $2); }
1671 | nonempty_type_quals absdcl
1672 { $$ = build_tree_list ($1, $2); }
1675 absdcl: /* an absolute declarator */
1681 nonempty_type_quals:
1683 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
1684 | nonempty_type_quals TYPE_QUAL
1685 { $$ = tree_cons (NULL_TREE, $2, $1); }
1691 | type_quals TYPE_QUAL
1692 { $$ = tree_cons (NULL_TREE, $2, $1); }
1695 absdcl1: /* a nonempty absolute declarator */
1698 /* `(typedef)1' is `int'. */
1699 | '*' type_quals absdcl1 %prec UNARY
1700 { $$ = make_pointer_declarator ($2, $3); }
1701 | '*' type_quals %prec UNARY
1702 { $$ = make_pointer_declarator ($2, NULL_TREE); }
1703 | absdcl1 '(' parmlist %prec '.'
1704 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1705 | absdcl1 '[' expr ']' %prec '.'
1706 { $$ = build_nt (ARRAY_REF, $1, $3); }
1707 | absdcl1 '[' ']' %prec '.'
1708 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1709 | '(' parmlist %prec '.'
1710 { $$ = build_nt (CALL_EXPR, NULL_TREE, $2, NULL_TREE); }
1711 | '[' expr ']' %prec '.'
1712 { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
1714 { $$ = build_nt (ARRAY_REF, NULL_TREE, NULL_TREE); }
1715 /* ??? It appears we have to support attributes here, however
1716 using prefix_attributes is wrong. */
1717 | attributes setattrs absdcl1
1721 /* at least one statement, the first of which parses without error. */
1722 /* stmts is used only after decls, so an invalid first statement
1723 is actually regarded as an invalid decl and part of the decls. */
1726 lineno_stmt_or_labels
1729 pedwarn ("ANSI C forbids label at end of compound statement");
1733 lineno_stmt_or_labels:
1734 lineno_stmt_or_label
1735 | lineno_stmt_or_labels lineno_stmt_or_label
1737 | lineno_stmt_or_labels errstmt
1749 pushlevel: /* empty */
1750 { emit_line_note (input_filename, lineno);
1754 expand_start_bindings (0);
1756 if (objc_method_context)
1762 /* Read zero or more forward-declarations for labels
1763 that nested functions can jump to. */
1768 pedwarn ("ANSI C forbids label declarations"); }
1773 | label_decls label_decl
1777 LABEL identifiers_or_typenames ';'
1779 for (link = $2; link; link = TREE_CHAIN (link))
1781 tree label = shadow_label (TREE_VALUE (link));
1782 C_DECLARED_LABEL_FLAG (label) = 1;
1783 declare_nonlocal_label (label);
1788 /* This is the body of a function definition.
1789 It causes syntax errors to ignore to the next openbrace. */
1796 compstmt_start: '{' { compstmt_count++; }
1798 compstmt: compstmt_start '}'
1799 { $$ = convert (void_type_node, integer_zero_node); }
1800 | compstmt_start pushlevel maybe_label_decls decls xstmts '}'
1801 { emit_line_note (input_filename, lineno);
1802 expand_end_bindings (getdecls (), 1, 0);
1803 $$ = poplevel (1, 1, 0);
1804 if (yychar == CONSTANT || yychar == STRING)
1805 pop_momentary_nofree ();
1808 | compstmt_start pushlevel maybe_label_decls error '}'
1809 { emit_line_note (input_filename, lineno);
1810 expand_end_bindings (getdecls (), kept_level_p (), 0);
1811 $$ = poplevel (kept_level_p (), 0, 0);
1812 if (yychar == CONSTANT || yychar == STRING)
1813 pop_momentary_nofree ();
1816 | compstmt_start pushlevel maybe_label_decls stmts '}'
1817 { emit_line_note (input_filename, lineno);
1818 expand_end_bindings (getdecls (), kept_level_p (), 0);
1819 $$ = poplevel (kept_level_p (), 0, 0);
1820 if (yychar == CONSTANT || yychar == STRING)
1821 pop_momentary_nofree ();
1826 /* Value is number of statements counted as of the closeparen. */
1828 if_prefix lineno_labeled_stmt
1829 /* Make sure c_expand_end_cond is run once
1830 for each call to c_expand_start_cond.
1831 Otherwise a crash is likely. */
1837 { emit_line_note ($<filename>-1, $<lineno>0);
1838 c_expand_start_cond (truthvalue_conversion ($3), 0,
1840 $<itype>$ = stmt_count;
1841 if_stmt_file = $<filename>-1;
1842 if_stmt_line = $<lineno>0;
1843 position_after_white_space (); }
1846 /* This is a subroutine of stmt.
1847 It is used twice, once for valid DO statements
1848 and once for catching errors in parsing the end test. */
1853 emit_line_note ($<filename>-1, $<lineno>0);
1854 /* See comment in `while' alternative, above. */
1856 expand_start_loop_continue_elsewhere (1);
1857 position_after_white_space (); }
1858 lineno_labeled_stmt WHILE
1859 { expand_loop_continue_here (); }
1863 { $$ = input_filename; }
1870 lineno_labeled_stmt:
1871 save_filename save_lineno stmt
1873 /* | save_filename save_lineno error
1876 | save_filename save_lineno label lineno_labeled_stmt
1880 lineno_stmt_or_label:
1881 save_filename save_lineno stmt_or_label
1892 /* Parse a single real statement, not including any labels. */
1899 emit_line_note ($<filename>-1, $<lineno>0);
1900 /* It appears that this should not be done--that a non-lvalue array
1901 shouldn't get an error if the value isn't used.
1902 Section 3.2.2.1 says that an array lvalue gets converted to a pointer
1903 if it appears as a top-level expression,
1904 but says nothing about non-lvalue arrays. */
1906 /* Call default_conversion to get an error
1907 on referring to a register array if pedantic. */
1908 if (TREE_CODE (TREE_TYPE ($1)) == ARRAY_TYPE
1909 || TREE_CODE (TREE_TYPE ($1)) == FUNCTION_TYPE)
1910 $1 = default_conversion ($1);
1912 iterator_expand ($1);
1913 clear_momentary (); }
1915 { c_expand_start_else ();
1916 $<itype>1 = stmt_count;
1917 position_after_white_space (); }
1919 { c_expand_end_cond ();
1920 if (extra_warnings && stmt_count == $<itype>1)
1921 warning ("empty body in an else-statement"); }
1922 | simple_if %prec IF
1923 { c_expand_end_cond ();
1924 /* This warning is here instead of in simple_if, because we
1925 do not want a warning if an empty if is followed by an
1926 else statement. Increment stmt_count so we don't
1927 give a second error if this is a nested `if'. */
1928 if (extra_warnings && stmt_count++ == $<itype>1)
1929 warning_with_file_and_line (if_stmt_file, if_stmt_line,
1930 "empty body in an if-statement"); }
1931 /* Make sure c_expand_end_cond is run once
1932 for each call to c_expand_start_cond.
1933 Otherwise a crash is likely. */
1934 | simple_if ELSE error
1935 { c_expand_end_cond (); }
1938 emit_line_note ($<filename>-1, $<lineno>0);
1939 /* The emit_nop used to come before emit_line_note,
1940 but that made the nop seem like part of the preceding line.
1941 And that was confusing when the preceding line was
1942 inside of an if statement and was not really executed.
1943 I think it ought to work to put the nop after the line number.
1944 We will see. --rms, July 15, 1991. */
1947 { /* Don't start the loop till we have succeeded
1948 in parsing the end test. This is to make sure
1949 that we end every loop we start. */
1950 expand_start_loop (1);
1951 emit_line_note (input_filename, lineno);
1952 expand_exit_loop_if_false (NULL_PTR,
1953 truthvalue_conversion ($4));
1954 position_after_white_space (); }
1956 { expand_end_loop (); }
1959 { emit_line_note (input_filename, lineno);
1960 expand_exit_loop_if_false (NULL_PTR,
1961 truthvalue_conversion ($3));
1963 clear_momentary (); }
1964 /* This rule is needed to make sure we end every loop we start. */
1965 | do_stmt_start error
1966 { expand_end_loop ();
1967 clear_momentary (); }
1971 emit_line_note ($<filename>-1, $<lineno>0);
1972 /* See comment in `while' alternative, above. */
1974 if ($3) c_expand_expr_stmt ($3);
1975 /* Next step is to call expand_start_loop_continue_elsewhere,
1976 but wait till after we parse the entire for (...).
1977 Otherwise, invalid input might cause us to call that
1978 fn without calling expand_end_loop. */
1981 /* Can't emit now; wait till after expand_start_loop... */
1982 { $<lineno>7 = lineno;
1983 $<filename>$ = input_filename; }
1986 /* Start the loop. Doing this after parsing
1987 all the expressions ensures we will end the loop. */
1988 expand_start_loop_continue_elsewhere (1);
1989 /* Emit the end-test, with a line number. */
1990 emit_line_note ($<filename>8, $<lineno>7);
1992 expand_exit_loop_if_false (NULL_PTR,
1993 truthvalue_conversion ($6));
1994 /* Don't let the tree nodes for $9 be discarded by
1995 clear_momentary during the parsing of the next stmt. */
1997 $<lineno>7 = lineno;
1998 $<filename>8 = input_filename;
1999 position_after_white_space (); }
2001 { /* Emit the increment expression, with a line number. */
2002 emit_line_note ($<filename>8, $<lineno>7);
2003 expand_loop_continue_here ();
2005 c_expand_expr_stmt ($9);
2006 if (yychar == CONSTANT || yychar == STRING)
2007 pop_momentary_nofree ();
2010 expand_end_loop (); }
2011 | SWITCH '(' expr ')'
2013 emit_line_note ($<filename>-1, $<lineno>0);
2014 c_expand_start_case ($3);
2015 /* Don't let the tree nodes for $3 be discarded by
2016 clear_momentary during the parsing of the next stmt. */
2018 position_after_white_space (); }
2020 { expand_end_case ($3);
2021 if (yychar == CONSTANT || yychar == STRING)
2022 pop_momentary_nofree ();
2027 emit_line_note ($<filename>-1, $<lineno>0);
2028 if ( ! expand_exit_something ())
2029 error ("break statement not within loop or switch"); }
2032 emit_line_note ($<filename>-1, $<lineno>0);
2033 if (! expand_continue_loop (NULL_PTR))
2034 error ("continue statement not within a loop"); }
2037 emit_line_note ($<filename>-1, $<lineno>0);
2038 c_expand_return (NULL_TREE); }
2041 emit_line_note ($<filename>-1, $<lineno>0);
2042 c_expand_return ($2); }
2043 | ASM_KEYWORD maybe_type_qual '(' expr ')' ';'
2045 emit_line_note ($<filename>-1, $<lineno>0);
2047 if ((TREE_CODE ($4) == ADDR_EXPR
2048 && TREE_CODE (TREE_OPERAND ($4, 0)) == STRING_CST)
2049 || TREE_CODE ($4) == STRING_CST)
2052 error ("argument of `asm' is not a constant string"); }
2053 /* This is the case with just output operands. */
2054 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ')' ';'
2056 emit_line_note ($<filename>-1, $<lineno>0);
2057 c_expand_asm_operands ($4, $6, NULL_TREE, NULL_TREE,
2058 $2 == ridpointers[(int)RID_VOLATILE],
2059 input_filename, lineno); }
2060 /* This is the case with input operands as well. */
2061 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':' asm_operands ')' ';'
2063 emit_line_note ($<filename>-1, $<lineno>0);
2064 c_expand_asm_operands ($4, $6, $8, NULL_TREE,
2065 $2 == ridpointers[(int)RID_VOLATILE],
2066 input_filename, lineno); }
2067 /* This is the case with clobbered registers as well. */
2068 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':'
2069 asm_operands ':' asm_clobbers ')' ';'
2071 emit_line_note ($<filename>-1, $<lineno>0);
2072 c_expand_asm_operands ($4, $6, $8, $10,
2073 $2 == ridpointers[(int)RID_VOLATILE],
2074 input_filename, lineno); }
2075 | GOTO identifier ';'
2078 emit_line_note ($<filename>-1, $<lineno>0);
2079 decl = lookup_label ($2);
2082 TREE_USED (decl) = 1;
2088 pedwarn ("ANSI C forbids `goto *expr;'");
2090 emit_line_note ($<filename>-1, $<lineno>0);
2091 expand_computed_goto (convert (ptr_type_node, $3)); }
2096 all_iter_stmt_simple
2097 /* | all_iter_stmt_with_decl */
2100 all_iter_stmt_simple:
2103 /* The value returned by this action is */
2104 /* 1 if everything is OK */
2105 /* 0 in case of error or already bound iterator */
2108 if (TREE_CODE ($3) != VAR_DECL)
2109 error ("invalid `for (ITERATOR)' syntax");
2110 else if (! ITERATOR_P ($3))
2111 error ("`%s' is not an iterator",
2112 IDENTIFIER_POINTER (DECL_NAME ($3)));
2113 else if (ITERATOR_BOUND_P ($3))
2114 error ("`for (%s)' inside expansion of same iterator",
2115 IDENTIFIER_POINTER (DECL_NAME ($3)));
2119 iterator_for_loop_start ($3);
2125 iterator_for_loop_end ($3);
2128 /* This really should allow any kind of declaration,
2129 for generality. Fix it before turning it back on.
2131 all_iter_stmt_with_decl:
2132 FOR '(' ITERATOR pushlevel setspecs iterator_spec ')'
2134 */ /* The value returned by this action is */
2135 /* 1 if everything is OK */
2136 /* 0 in case of error or already bound iterator */
2138 iterator_for_loop_start ($6);
2142 iterator_for_loop_end ($6);
2143 emit_line_note (input_filename, lineno);
2144 expand_end_bindings (getdecls (), 1, 0);
2145 $<ttype>$ = poplevel (1, 1, 0);
2146 if (yychar == CONSTANT || yychar == STRING)
2147 pop_momentary_nofree ();
2153 /* Any kind of label, including jump labels and case labels.
2154 ANSI C accepts labels only before statements, but we allow them
2155 also at the end of a compound statement. */
2157 label: CASE expr_no_commas ':'
2158 { register tree value = check_case_value ($2);
2160 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
2164 if (value != error_mark_node)
2169 if (pedantic && ! INTEGRAL_TYPE_P (TREE_TYPE (value)))
2170 pedwarn ("label must have integral type in ANSI C");
2172 success = pushcase (value, convert_and_check,
2176 error ("case label not within a switch statement");
2177 else if (success == 2)
2179 error ("duplicate case value");
2180 error_with_decl (duplicate, "this is the first entry for that value");
2182 else if (success == 3)
2183 warning ("case value out of range");
2184 else if (success == 5)
2185 error ("case label within scope of cleanup or variable array");
2187 position_after_white_space (); }
2188 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
2189 { register tree value1 = check_case_value ($2);
2190 register tree value2 = check_case_value ($4);
2192 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
2195 pedwarn ("ANSI C forbids case ranges");
2198 if (value1 != error_mark_node && value2 != error_mark_node)
2201 int success = pushcase_range (value1, value2,
2202 convert_and_check, label,
2205 error ("case label not within a switch statement");
2206 else if (success == 2)
2208 error ("duplicate case value");
2209 error_with_decl (duplicate, "this is the first entry for that value");
2211 else if (success == 3)
2212 warning ("case value out of range");
2213 else if (success == 4)
2214 warning ("empty case range");
2215 else if (success == 5)
2216 error ("case label within scope of cleanup or variable array");
2218 position_after_white_space (); }
2223 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
2224 int success = pushcase (NULL_TREE, 0, label, &duplicate);
2227 error ("default label not within a switch statement");
2228 else if (success == 2)
2230 error ("multiple default labels in one switch");
2231 error_with_decl (duplicate, "this is the first default label");
2233 position_after_white_space (); }
2234 | identifier ':' maybe_attribute
2235 { tree label = define_label (input_filename, lineno, $1);
2240 expand_label (label);
2241 decl_attributes (label, $3, NULL_TREE);
2243 position_after_white_space (); }
2246 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
2250 { emit_line_note (input_filename, lineno);
2253 { emit_line_note (input_filename, lineno); }
2262 /* These are the operands other than the first string and colon
2263 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
2264 asm_operands: /* empty */
2266 | nonnull_asm_operands
2269 nonnull_asm_operands:
2271 | nonnull_asm_operands ',' asm_operand
2272 { $$ = chainon ($1, $3); }
2277 { $$ = build_tree_list ($1, $3); }
2282 { $$ = tree_cons (NULL_TREE, combine_strings ($1), NULL_TREE); }
2283 | asm_clobbers ',' string
2284 { $$ = tree_cons (NULL_TREE, combine_strings ($3), $1); }
2287 /* This is what appears inside the parens in a function declarator.
2288 Its value is a list of ..._TYPE nodes. */
2291 clear_parm_order ();
2292 declare_parm_level (0); }
2295 parmlist_tags_warning ();
2296 poplevel (0, 0, 0); }
2304 pedwarn ("ANSI C forbids forward parameter declarations");
2305 /* Mark the forward decls as such. */
2306 for (parm = getdecls (); parm; parm = TREE_CHAIN (parm))
2307 TREE_ASM_WRITTEN (parm) = 1;
2308 clear_parm_order (); }
2312 { $$ = tree_cons (NULL_TREE, NULL_TREE, NULL_TREE); }
2315 /* This is what appears inside the parens in a function declarator.
2316 Is value is represented in the format that grokdeclarator expects. */
2317 parmlist_2: /* empty */
2318 { $$ = get_parm_info (0); }
2320 { $$ = get_parm_info (0);
2321 /* Gcc used to allow this as an extension. However, it does
2322 not work for all targets, and thus has been disabled.
2323 Also, since func (...) and func () are indistinguishable,
2324 it caused problems with the code in expand_builtin which
2325 tries to verify that BUILT_IN_NEXT_ARG is being used
2327 error ("ANSI C requires a named argument before `...'");
2330 { $$ = get_parm_info (1); }
2331 | parms ',' ELLIPSIS
2332 { $$ = get_parm_info (0); }
2337 { push_parm_decl ($1); }
2339 { push_parm_decl ($3); }
2342 /* A single parameter declaration or parameter type name,
2343 as found in a parmlist. */
2345 typed_declspecs setspecs parm_declarator maybe_attribute
2346 { $$ = build_tree_list (build_tree_list (current_declspecs,
2348 build_tree_list (prefix_attributes,
2350 current_declspecs = TREE_VALUE (declspec_stack);
2351 prefix_attributes = TREE_PURPOSE (declspec_stack);
2352 declspec_stack = TREE_CHAIN (declspec_stack);
2353 resume_momentary ($2); }
2354 | typed_declspecs setspecs notype_declarator maybe_attribute
2355 { $$ = build_tree_list (build_tree_list (current_declspecs,
2357 build_tree_list (prefix_attributes,
2359 current_declspecs = TREE_VALUE (declspec_stack);
2360 prefix_attributes = TREE_PURPOSE (declspec_stack);
2361 declspec_stack = TREE_CHAIN (declspec_stack);
2362 resume_momentary ($2); }
2363 | typed_declspecs setspecs absdcl maybe_attribute
2364 { $$ = build_tree_list (build_tree_list (current_declspecs,
2366 build_tree_list (prefix_attributes,
2368 current_declspecs = TREE_VALUE (declspec_stack);
2369 prefix_attributes = TREE_PURPOSE (declspec_stack);
2370 declspec_stack = TREE_CHAIN (declspec_stack);
2371 resume_momentary ($2); }
2372 | declmods setspecs notype_declarator maybe_attribute
2373 { $$ = build_tree_list (build_tree_list (current_declspecs,
2375 build_tree_list (prefix_attributes,
2377 current_declspecs = TREE_VALUE (declspec_stack);
2378 prefix_attributes = TREE_PURPOSE (declspec_stack);
2379 declspec_stack = TREE_CHAIN (declspec_stack);
2380 resume_momentary ($2); }
2382 | declmods setspecs absdcl maybe_attribute
2383 { $$ = build_tree_list (build_tree_list (current_declspecs,
2385 build_tree_list (prefix_attributes,
2387 current_declspecs = TREE_VALUE (declspec_stack);
2388 prefix_attributes = TREE_PURPOSE (declspec_stack);
2389 declspec_stack = TREE_CHAIN (declspec_stack);
2390 resume_momentary ($2); }
2393 /* This is used in a function definition
2394 where either a parmlist or an identifier list is ok.
2395 Its value is a list of ..._TYPE nodes or a list of identifiers. */
2396 parmlist_or_identifiers:
2398 clear_parm_order ();
2399 declare_parm_level (1); }
2400 parmlist_or_identifiers_1
2402 parmlist_tags_warning ();
2403 poplevel (0, 0, 0); }
2406 parmlist_or_identifiers_1:
2410 for (t = $1; t; t = TREE_CHAIN (t))
2411 if (TREE_VALUE (t) == NULL_TREE)
2412 error ("`...' in old-style identifier list");
2413 $$ = tree_cons (NULL_TREE, NULL_TREE, $1); }
2416 /* A nonempty list of identifiers. */
2419 { $$ = build_tree_list (NULL_TREE, $1); }
2420 | identifiers ',' IDENTIFIER
2421 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2424 /* A nonempty list of identifiers, including typenames. */
2425 identifiers_or_typenames:
2427 { $$ = build_tree_list (NULL_TREE, $1); }
2428 | identifiers_or_typenames ',' identifier
2429 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2434 { $<itype>$ = pedantic;
2439 /* Objective-C productions. */
2449 if (objc_implementation_context)
2451 finish_class (objc_implementation_context);
2452 objc_ivar_chain = NULL_TREE;
2453 objc_implementation_context = NULL_TREE;
2456 warning ("`@end' must appear in an implementation context");
2460 /* A nonempty list of identifiers. */
2463 { $$ = build_tree_list (NULL_TREE, $1); }
2464 | identifier_list ',' identifier
2465 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2469 CLASS identifier_list ';'
2471 objc_declare_class ($2);
2475 ALIAS identifier identifier ';'
2477 objc_declare_alias ($2, $3);
2481 INTERFACE identifier protocolrefs '{'
2483 objc_interface_context = objc_ivar_context
2484 = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, $3);
2485 objc_public_flag = 0;
2489 continue_class (objc_interface_context);
2494 finish_class (objc_interface_context);
2495 objc_interface_context = NULL_TREE;
2498 | INTERFACE identifier protocolrefs
2500 objc_interface_context
2501 = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, $3);
2502 continue_class (objc_interface_context);
2507 finish_class (objc_interface_context);
2508 objc_interface_context = NULL_TREE;
2511 | INTERFACE identifier ':' identifier protocolrefs '{'
2513 objc_interface_context = objc_ivar_context
2514 = start_class (CLASS_INTERFACE_TYPE, $2, $4, $5);
2515 objc_public_flag = 0;
2519 continue_class (objc_interface_context);
2524 finish_class (objc_interface_context);
2525 objc_interface_context = NULL_TREE;
2528 | INTERFACE identifier ':' identifier protocolrefs
2530 objc_interface_context
2531 = start_class (CLASS_INTERFACE_TYPE, $2, $4, $5);
2532 continue_class (objc_interface_context);
2537 finish_class (objc_interface_context);
2538 objc_interface_context = NULL_TREE;
2541 | IMPLEMENTATION identifier '{'
2543 objc_implementation_context = objc_ivar_context
2544 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, NULL_TREE, NULL_TREE);
2545 objc_public_flag = 0;
2550 = continue_class (objc_implementation_context);
2553 | IMPLEMENTATION identifier
2555 objc_implementation_context
2556 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, NULL_TREE, NULL_TREE);
2558 = continue_class (objc_implementation_context);
2561 | IMPLEMENTATION identifier ':' identifier '{'
2563 objc_implementation_context = objc_ivar_context
2564 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2565 objc_public_flag = 0;
2570 = continue_class (objc_implementation_context);
2573 | IMPLEMENTATION identifier ':' identifier
2575 objc_implementation_context
2576 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2578 = continue_class (objc_implementation_context);
2581 | INTERFACE identifier '(' identifier ')' protocolrefs
2583 objc_interface_context
2584 = start_class (CATEGORY_INTERFACE_TYPE, $2, $4, $6);
2585 continue_class (objc_interface_context);
2590 finish_class (objc_interface_context);
2591 objc_interface_context = NULL_TREE;
2594 | IMPLEMENTATION identifier '(' identifier ')'
2596 objc_implementation_context
2597 = start_class (CATEGORY_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2599 = continue_class (objc_implementation_context);
2604 PROTOCOL identifier protocolrefs
2606 remember_protocol_qualifiers ();
2607 objc_interface_context
2608 = start_protocol(PROTOCOL_INTERFACE_TYPE, $2, $3);
2612 forget_protocol_qualifiers();
2613 finish_protocol(objc_interface_context);
2614 objc_interface_context = NULL_TREE;
2623 | non_empty_protocolrefs
2626 non_empty_protocolrefs:
2627 ARITHCOMPARE identifier_list ARITHCOMPARE
2629 if ($1 == LT_EXPR && $3 == GT_EXPR)
2637 ivar_decl_list visibility_spec ivar_decls
2642 PRIVATE { objc_public_flag = 2; }
2643 | PROTECTED { objc_public_flag = 0; }
2644 | PUBLIC { objc_public_flag = 1; }
2652 | ivar_decls ivar_decl ';'
2656 pedwarn ("extra semicolon in struct or union specified");
2661 /* There is a shift-reduce conflict here, because `components' may
2662 start with a `typename'. It happens that shifting (the default resolution)
2663 does the right thing, because it treats the `typename' as part of
2664 a `typed_typespecs'.
2666 It is possible that this same technique would allow the distinction
2667 between `notype_initdecls' and `initdecls' to be eliminated.
2668 But I am being cautious and not trying it. */
2671 typed_typespecs setspecs ivars
2673 current_declspecs = TREE_VALUE (declspec_stack);
2674 prefix_attributes = TREE_PURPOSE (declspec_stack);
2675 declspec_stack = TREE_CHAIN (declspec_stack);
2676 resume_momentary ($2); }
2677 | nonempty_type_quals setspecs ivars
2679 current_declspecs = TREE_VALUE (declspec_stack);
2680 prefix_attributes = TREE_PURPOSE (declspec_stack);
2681 declspec_stack = TREE_CHAIN (declspec_stack);
2682 resume_momentary ($2); }
2691 | ivars ',' ivar_declarator
2697 $$ = add_instance_variable (objc_ivar_context,
2699 $1, current_declspecs,
2702 | declarator ':' expr_no_commas
2704 $$ = add_instance_variable (objc_ivar_context,
2706 $1, current_declspecs, $3);
2708 | ':' expr_no_commas
2710 $$ = add_instance_variable (objc_ivar_context,
2713 current_declspecs, $2);
2720 remember_protocol_qualifiers ();
2721 if (objc_implementation_context)
2722 objc_inherit_code = CLASS_METHOD_DECL;
2724 fatal ("method definition not in class context");
2728 forget_protocol_qualifiers ();
2729 add_class_method (objc_implementation_context, $3);
2730 start_method_def ($3);
2731 objc_method_context = $3;
2735 continue_method_def ();
2739 finish_method_def ();
2740 objc_method_context = NULL_TREE;
2745 remember_protocol_qualifiers ();
2746 if (objc_implementation_context)
2747 objc_inherit_code = INSTANCE_METHOD_DECL;
2749 fatal ("method definition not in class context");
2753 forget_protocol_qualifiers ();
2754 add_instance_method (objc_implementation_context, $3);
2755 start_method_def ($3);
2756 objc_method_context = $3;
2760 continue_method_def ();
2764 finish_method_def ();
2765 objc_method_context = NULL_TREE;
2769 /* the reason for the strange actions in this rule
2770 is so that notype_initdecls when reached via datadef
2771 can find a valid list of type and sc specs in $0. */
2775 | {$<ttype>$ = NULL_TREE; } methodprotolist2
2778 methodprotolist2: /* eliminates a shift/reduce conflict */
2781 | methodprotolist2 methodproto
2782 | methodprotolist2 {$<ttype>$ = NULL_TREE; } datadef
2793 /* Remember protocol qualifiers in prototypes. */
2794 remember_protocol_qualifiers ();
2795 objc_inherit_code = CLASS_METHOD_DECL;
2799 /* Forget protocol qualifiers here. */
2800 forget_protocol_qualifiers ();
2801 add_class_method (objc_interface_context, $3);
2807 /* Remember protocol qualifiers in prototypes. */
2808 remember_protocol_qualifiers ();
2809 objc_inherit_code = INSTANCE_METHOD_DECL;
2813 /* Forget protocol qualifiers here. */
2814 forget_protocol_qualifiers ();
2815 add_instance_method (objc_interface_context, $3);
2821 '(' typename ')' unaryselector
2823 $$ = build_method_decl (objc_inherit_code, $2, $4, NULL_TREE);
2828 $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, NULL_TREE);
2831 | '(' typename ')' keywordselector optparmlist
2833 $$ = build_method_decl (objc_inherit_code, $2, $4, $5);
2836 | keywordselector optparmlist
2838 $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, $2);
2842 /* "optarglist" assumes that start_method_def has already been called...
2843 if it is not, the "xdecls" will not be placed in the proper scope */
2850 /* to get around the following situation: "int foo (int a) int b; {}" that
2851 is synthesized when parsing "- a:a b:b; id c; id d; { ... }" */
2866 typed_declspecs setspecs myparms ';'
2867 { current_declspecs = TREE_VALUE (declspec_stack);
2868 prefix_attributes = TREE_PURPOSE (declspec_stack);
2869 declspec_stack = TREE_CHAIN (declspec_stack);
2870 resume_momentary ($2); }
2871 | typed_declspecs ';'
2872 { shadow_tag ($1); }
2874 { pedwarn ("empty declaration"); }
2879 { push_parm_decl ($1); }
2880 | myparms ',' myparm
2881 { push_parm_decl ($3); }
2884 /* A single parameter declaration or parameter type name,
2885 as found in a parmlist. DOES NOT ALLOW AN INITIALIZER OR ASMSPEC */
2888 parm_declarator maybe_attribute
2889 { $$ = build_tree_list (build_tree_list (current_declspecs,
2891 build_tree_list (prefix_attributes,
2893 | notype_declarator maybe_attribute
2894 { $$ = build_tree_list (build_tree_list (current_declspecs,
2896 build_tree_list (prefix_attributes,
2898 | absdcl maybe_attribute
2899 { $$ = build_tree_list (build_tree_list (current_declspecs,
2901 build_tree_list (prefix_attributes,
2912 /* oh what a kludge! */
2921 /* returns a tree list node generated by get_parm_info */
2934 | keywordselector keyworddecl
2936 $$ = chainon ($1, $2);
2948 ENUM { $$ = get_identifier (token_buffer); }
2949 | STRUCT { $$ = get_identifier (token_buffer); }
2950 | UNION { $$ = get_identifier (token_buffer); }
2951 | IF { $$ = get_identifier (token_buffer); }
2952 | ELSE { $$ = get_identifier (token_buffer); }
2953 | WHILE { $$ = get_identifier (token_buffer); }
2954 | DO { $$ = get_identifier (token_buffer); }
2955 | FOR { $$ = get_identifier (token_buffer); }
2956 | SWITCH { $$ = get_identifier (token_buffer); }
2957 | CASE { $$ = get_identifier (token_buffer); }
2958 | DEFAULT { $$ = get_identifier (token_buffer); }
2959 | BREAK { $$ = get_identifier (token_buffer); }
2960 | CONTINUE { $$ = get_identifier (token_buffer); }
2961 | RETURN { $$ = get_identifier (token_buffer); }
2962 | GOTO { $$ = get_identifier (token_buffer); }
2963 | ASM_KEYWORD { $$ = get_identifier (token_buffer); }
2964 | SIZEOF { $$ = get_identifier (token_buffer); }
2965 | TYPEOF { $$ = get_identifier (token_buffer); }
2966 | ALIGNOF { $$ = get_identifier (token_buffer); }
2967 | TYPESPEC | TYPE_QUAL
2971 selector ':' '(' typename ')' identifier
2973 $$ = build_keyword_decl ($1, $4, $6);
2976 | selector ':' identifier
2978 $$ = build_keyword_decl ($1, NULL_TREE, $3);
2981 | ':' '(' typename ')' identifier
2983 $$ = build_keyword_decl (NULL_TREE, $3, $5);
2988 $$ = build_keyword_decl (NULL_TREE, NULL_TREE, $2);
2999 | keywordarglist keywordarg
3001 $$ = chainon ($1, $2);
3009 if (TREE_CHAIN ($1) == NULL_TREE)
3010 /* just return the expr., remove a level of indirection */
3011 $$ = TREE_VALUE ($1);
3013 /* we have a comma expr., we will collapse later */
3019 selector ':' keywordexpr
3021 $$ = build_tree_list ($1, $3);
3025 $$ = build_tree_list (NULL_TREE, $2);
3033 $$ = get_class_reference ($1);
3039 { objc_receiver_context = 1; }
3041 { objc_receiver_context = 0; }
3044 $$ = build_tree_list ($3, $5);
3055 | keywordnamelist keywordname
3057 $$ = chainon ($1, $2);
3064 $$ = build_tree_list ($1, NULL_TREE);
3068 $$ = build_tree_list (NULL_TREE, NULL_TREE);
3073 SELECTOR '(' selectorarg ')'
3080 PROTOCOL '(' identifier ')'
3086 /* extension to support C-structures in the archiver */
3089 ENCODE '(' typename ')'
3091 $$ = groktypename ($3);