At the suggestion of Richard Earnshaw I have changed GO_IF_LEGITIMATE_ADDRESS
[official-gcc.git] / gcc / objc / objc-parse.y
blobc216d438ae1782bbb40adb7ac716ec260bb61292
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-97, 1998 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)
10 any later version.
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. */
31 %expect 66
34 #include "config.h"
35 #include "system.h"
36 #include <setjmp.h>
38 #include "tree.h"
39 #include "input.h"
40 #include "c-lex.h"
41 #include "c-tree.h"
42 #include "flags.h"
43 #include "output.h"
45 #ifdef MULTIBYTE_CHARS
46 #include <locale.h>
47 #endif
49 #include "objc-act.h"
51 /* Since parsers are distinct for each language, put the language string
52 definition here. */
53 char *language_string = "GNU Obj-C";
55 /* Like YYERROR but do call yyerror. */
56 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
58 /* Cause the `yydebug' variable to be defined. */
59 #define YYDEBUG 1
62 %start program
64 %union {long itype; tree ttype; enum tree_code code;
65 char *filename; int lineno; int ends_in_label; }
67 /* All identifiers that are not reserved words
68 and are not declared typedefs in the current block */
69 %token IDENTIFIER
71 /* All identifiers that are declared typedefs in the current block.
72 In some contexts, they are treated just like IDENTIFIER,
73 but they can also serve as typespecs in declarations. */
74 %token TYPENAME
76 /* Reserved words that specify storage class.
77 yylval contains an IDENTIFIER_NODE which indicates which one. */
78 %token SCSPEC
80 /* Reserved words that specify type.
81 yylval contains an IDENTIFIER_NODE which indicates which one. */
82 %token TYPESPEC
84 /* Reserved words that qualify type: "const" or "volatile".
85 yylval contains an IDENTIFIER_NODE which indicates which one. */
86 %token TYPE_QUAL
88 /* Character or numeric constants.
89 yylval is the node for the constant. */
90 %token CONSTANT
92 /* String constants in raw form.
93 yylval is a STRING_CST node. */
94 %token STRING
96 /* "...", used for functions with variable arglists. */
97 %token ELLIPSIS
99 /* the reserved words */
100 /* SCO include files test "ASM", so use something else. */
101 %token SIZEOF ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
102 %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD TYPEOF ALIGNOF
103 %token ATTRIBUTE EXTENSION LABEL
104 %token REALPART IMAGPART
106 /* Add precedence rules to solve dangling else s/r conflict */
107 %nonassoc IF
108 %nonassoc ELSE
110 /* Define the operator tokens and their precedences.
111 The value is an integer because, if used, it is the tree code
112 to use in the expression made from the operator. */
114 %right <code> ASSIGN '='
115 %right <code> '?' ':'
116 %left <code> OROR
117 %left <code> ANDAND
118 %left <code> '|'
119 %left <code> '^'
120 %left <code> '&'
121 %left <code> EQCOMPARE
122 %left <code> ARITHCOMPARE
123 %left <code> LSHIFT RSHIFT
124 %left <code> '+' '-'
125 %left <code> '*' '/' '%'
126 %right <code> UNARY PLUSPLUS MINUSMINUS
127 %left HYPERUNARY
128 %left <code> POINTSAT '.' '(' '['
130 /* The Objective-C keywords. These are included in C and in
131 Objective C, so that the token codes are the same in both. */
132 %token INTERFACE IMPLEMENTATION END SELECTOR DEFS ENCODE
133 %token CLASSNAME PUBLIC PRIVATE PROTECTED PROTOCOL OBJECTNAME CLASS ALIAS
135 /* Objective-C string constants in raw form.
136 yylval is an OBJC_STRING_CST node. */
137 %token OBJC_STRING
140 %type <code> unop
142 %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist exprlist
143 %type <ttype> expr_no_commas cast_expr unary_expr primary string STRING
144 %type <ttype> typed_declspecs reserved_declspecs
145 %type <ttype> typed_typespecs reserved_typespecquals
146 %type <ttype> declmods typespec typespecqual_reserved
147 %type <ttype> typed_declspecs_no_prefix_attr reserved_declspecs_no_prefix_attr
148 %type <ttype> declmods_no_prefix_attr
149 %type <ttype> SCSPEC TYPESPEC TYPE_QUAL nonempty_type_quals maybe_type_qual
150 %type <ttype> initdecls notype_initdecls initdcl notype_initdcl
151 %type <ttype> init maybeasm
152 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
153 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
154 %type <ttype> any_word
156 %type <ttype> compstmt
158 %type <ttype> declarator
159 %type <ttype> notype_declarator after_type_declarator
160 %type <ttype> parm_declarator
162 %type <ttype> structsp component_decl_list component_decl_list2
163 %type <ttype> component_decl components component_declarator
164 %type <ttype> enumlist enumerator
165 %type <ttype> typename absdcl absdcl1 type_quals
166 %type <ttype> xexpr parms parm identifiers
168 %type <ttype> parmlist parmlist_1 parmlist_2
169 %type <ttype> parmlist_or_identifiers parmlist_or_identifiers_1
170 %type <ttype> identifiers_or_typenames
172 %type <itype> setspecs
174 %type <ends_in_label> lineno_stmt_or_label lineno_stmt_or_labels stmt_or_label
176 %type <filename> save_filename
177 %type <lineno> save_lineno
179 /* the Objective-C nonterminals */
181 %type <ttype> ivar_decl_list ivar_decls ivar_decl ivars ivar_declarator
182 %type <ttype> methoddecl unaryselector keywordselector selector
183 %type <ttype> keyworddecl receiver objcmessageexpr messageargs
184 %type <ttype> keywordexpr keywordarglist keywordarg
185 %type <ttype> myparms myparm optparmlist reservedwords objcselectorexpr
186 %type <ttype> selectorarg keywordnamelist keywordname objcencodeexpr
187 %type <ttype> objc_string non_empty_protocolrefs protocolrefs identifier_list objcprotocolexpr
189 %type <ttype> CLASSNAME OBJC_STRING OBJECTNAME
192 /* Number of statements (loosely speaking) and compound statements
193 seen so far. */
194 static int stmt_count;
195 static int compstmt_count;
197 /* Input file and line number of the end of the body of last simple_if;
198 used by the stmt-rule immediately after simple_if returns. */
199 static char *if_stmt_file;
200 static int if_stmt_line;
202 /* List of types and structure classes of the current declaration. */
203 static tree current_declspecs = NULL_TREE;
204 static tree prefix_attributes = NULL_TREE;
206 /* Stack of saved values of current_declspecs and prefix_attributes. */
207 static tree declspec_stack;
209 /* 1 if we explained undeclared var errors. */
210 static int undeclared_variable_notice;
212 /* Objective-C specific information */
214 tree objc_interface_context;
215 tree objc_implementation_context;
216 tree objc_method_context;
217 tree objc_ivar_chain;
218 tree objc_ivar_context;
219 enum tree_code objc_inherit_code;
220 int objc_receiver_context;
221 int objc_public_flag;
224 /* Tell yyparse how to print a token's value, if yydebug is set. */
226 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
227 extern void yyprint PROTO ((FILE *, int, YYSTYPE));
231 program: /* empty */
232 { if (pedantic)
233 pedwarn ("ANSI C forbids an empty source file");
234 finish_file ();
236 | extdefs
238 /* In case there were missing closebraces,
239 get us back to the global binding level. */
240 while (! global_bindings_p ())
241 poplevel (0, 0, 0);
242 finish_file ();
246 /* the reason for the strange actions in this rule
247 is so that notype_initdecls when reached via datadef
248 can find a valid list of type and sc specs in $0. */
250 extdefs:
251 {$<ttype>$ = NULL_TREE; } extdef
252 | extdefs {$<ttype>$ = NULL_TREE; } extdef
255 extdef:
256 fndef
257 | datadef
258 | objcdef
259 | ASM_KEYWORD '(' expr ')' ';'
260 { STRIP_NOPS ($3);
261 if ((TREE_CODE ($3) == ADDR_EXPR
262 && TREE_CODE (TREE_OPERAND ($3, 0)) == STRING_CST)
263 || TREE_CODE ($3) == STRING_CST)
264 assemble_asm ($3);
265 else
266 error ("argument of `asm' is not a constant string"); }
267 | extension extdef
268 { pedantic = $<itype>1; }
271 datadef:
272 setspecs notype_initdecls ';'
273 { if (pedantic)
274 error ("ANSI C forbids data definition with no type or storage class");
275 else if (!flag_traditional)
276 warning ("data definition has no type or storage class");
278 current_declspecs = TREE_VALUE (declspec_stack);
279 prefix_attributes = TREE_PURPOSE (declspec_stack);
280 declspec_stack = TREE_CHAIN (declspec_stack);
281 resume_momentary ($1); }
282 | declmods setspecs notype_initdecls ';'
283 { current_declspecs = TREE_VALUE (declspec_stack);
284 prefix_attributes = TREE_PURPOSE (declspec_stack);
285 declspec_stack = TREE_CHAIN (declspec_stack);
286 resume_momentary ($2); }
287 | typed_declspecs setspecs initdecls ';'
288 { current_declspecs = TREE_VALUE (declspec_stack);
289 prefix_attributes = TREE_PURPOSE (declspec_stack);
290 declspec_stack = TREE_CHAIN (declspec_stack);
291 resume_momentary ($2); }
292 | declmods ';'
293 { pedwarn ("empty declaration"); }
294 | typed_declspecs ';'
295 { shadow_tag ($1); }
296 | error ';'
297 | error '}'
298 | ';'
299 { if (pedantic)
300 pedwarn ("ANSI C does not allow extra `;' outside of a function"); }
303 fndef:
304 typed_declspecs setspecs declarator
305 { if (! start_function (current_declspecs, $3,
306 prefix_attributes, NULL_TREE, 0))
307 YYERROR1;
308 reinit_parse_for_function (); }
309 old_style_parm_decls
310 { store_parm_decls (); }
311 compstmt_or_error
312 { finish_function (0);
313 current_declspecs = TREE_VALUE (declspec_stack);
314 prefix_attributes = TREE_PURPOSE (declspec_stack);
315 declspec_stack = TREE_CHAIN (declspec_stack);
316 resume_momentary ($2); }
317 | typed_declspecs setspecs declarator error
318 { current_declspecs = TREE_VALUE (declspec_stack);
319 prefix_attributes = TREE_PURPOSE (declspec_stack);
320 declspec_stack = TREE_CHAIN (declspec_stack);
321 resume_momentary ($2); }
322 | declmods setspecs notype_declarator
323 { if (! start_function (current_declspecs, $3,
324 prefix_attributes, NULL_TREE, 0))
325 YYERROR1;
326 reinit_parse_for_function (); }
327 old_style_parm_decls
328 { store_parm_decls (); }
329 compstmt_or_error
330 { finish_function (0);
331 current_declspecs = TREE_VALUE (declspec_stack);
332 prefix_attributes = TREE_PURPOSE (declspec_stack);
333 declspec_stack = TREE_CHAIN (declspec_stack);
334 resume_momentary ($2); }
335 | declmods setspecs notype_declarator error
336 { current_declspecs = TREE_VALUE (declspec_stack);
337 prefix_attributes = TREE_PURPOSE (declspec_stack);
338 declspec_stack = TREE_CHAIN (declspec_stack);
339 resume_momentary ($2); }
340 | setspecs notype_declarator
341 { if (! start_function (NULL_TREE, $2,
342 prefix_attributes, NULL_TREE, 0))
343 YYERROR1;
344 reinit_parse_for_function (); }
345 old_style_parm_decls
346 { store_parm_decls (); }
347 compstmt_or_error
348 { finish_function (0);
349 current_declspecs = TREE_VALUE (declspec_stack);
350 prefix_attributes = TREE_PURPOSE (declspec_stack);
351 declspec_stack = TREE_CHAIN (declspec_stack);
352 resume_momentary ($1); }
353 | setspecs notype_declarator error
354 { current_declspecs = TREE_VALUE (declspec_stack);
355 prefix_attributes = TREE_PURPOSE (declspec_stack);
356 declspec_stack = TREE_CHAIN (declspec_stack);
357 resume_momentary ($1); }
360 identifier:
361 IDENTIFIER
362 | TYPENAME
363 | OBJECTNAME
364 | CLASSNAME
367 unop: '&'
368 { $$ = ADDR_EXPR; }
369 | '-'
370 { $$ = NEGATE_EXPR; }
371 | '+'
372 { $$ = CONVERT_EXPR; }
373 | PLUSPLUS
374 { $$ = PREINCREMENT_EXPR; }
375 | MINUSMINUS
376 { $$ = PREDECREMENT_EXPR; }
377 | '~'
378 { $$ = BIT_NOT_EXPR; }
379 | '!'
380 { $$ = TRUTH_NOT_EXPR; }
383 expr: nonnull_exprlist
384 { $$ = build_compound_expr ($1); }
387 exprlist:
388 /* empty */
389 { $$ = NULL_TREE; }
390 | nonnull_exprlist
393 nonnull_exprlist:
394 expr_no_commas
395 { $$ = build_tree_list (NULL_TREE, $1); }
396 | nonnull_exprlist ',' expr_no_commas
397 { chainon ($1, build_tree_list (NULL_TREE, $3)); }
400 unary_expr:
401 primary
402 | '*' cast_expr %prec UNARY
403 { $$ = build_indirect_ref ($2, "unary *"); }
404 /* __extension__ turns off -pedantic for following primary. */
405 | extension cast_expr %prec UNARY
406 { $$ = $2;
407 pedantic = $<itype>1; }
408 | unop cast_expr %prec UNARY
409 { $$ = build_unary_op ($1, $2, 0);
410 overflow_warning ($$); }
411 /* Refer to the address of a label as a pointer. */
412 | ANDAND identifier
413 { tree label = lookup_label ($2);
414 if (pedantic)
415 pedwarn ("ANSI C forbids `&&'");
416 if (label == 0)
417 $$ = null_pointer_node;
418 else
420 TREE_USED (label) = 1;
421 $$ = build1 (ADDR_EXPR, ptr_type_node, label);
422 TREE_CONSTANT ($$) = 1;
425 /* This seems to be impossible on some machines, so let's turn it off.
426 You can use __builtin_next_arg to find the anonymous stack args.
427 | '&' ELLIPSIS
428 { tree types = TYPE_ARG_TYPES (TREE_TYPE (current_function_decl));
429 $$ = error_mark_node;
430 if (TREE_VALUE (tree_last (types)) == void_type_node)
431 error ("`&...' used in function with fixed number of arguments");
432 else
434 if (pedantic)
435 pedwarn ("ANSI C forbids `&...'");
436 $$ = tree_last (DECL_ARGUMENTS (current_function_decl));
437 $$ = build_unary_op (ADDR_EXPR, $$, 0);
440 | sizeof unary_expr %prec UNARY
441 { skip_evaluation--;
442 if (TREE_CODE ($2) == COMPONENT_REF
443 && DECL_C_BIT_FIELD (TREE_OPERAND ($2, 1)))
444 error ("`sizeof' applied to a bit-field");
445 $$ = c_sizeof (TREE_TYPE ($2)); }
446 | sizeof '(' typename ')' %prec HYPERUNARY
447 { skip_evaluation--;
448 $$ = c_sizeof (groktypename ($3)); }
449 | alignof unary_expr %prec UNARY
450 { skip_evaluation--;
451 $$ = c_alignof_expr ($2); }
452 | alignof '(' typename ')' %prec HYPERUNARY
453 { skip_evaluation--;
454 $$ = c_alignof (groktypename ($3)); }
455 | REALPART cast_expr %prec UNARY
456 { $$ = build_unary_op (REALPART_EXPR, $2, 0); }
457 | IMAGPART cast_expr %prec UNARY
458 { $$ = build_unary_op (IMAGPART_EXPR, $2, 0); }
461 sizeof:
462 SIZEOF { skip_evaluation++; }
465 alignof:
466 ALIGNOF { skip_evaluation++; }
469 cast_expr:
470 unary_expr
471 | '(' typename ')' cast_expr %prec UNARY
472 { tree type = groktypename ($2);
473 $$ = build_c_cast (type, $4); }
474 | '(' typename ')' '{'
475 { start_init (NULL_TREE, NULL, 0);
476 $2 = groktypename ($2);
477 really_start_incremental_init ($2); }
478 initlist_maybe_comma '}' %prec UNARY
479 { char *name;
480 tree result = pop_init_level (0);
481 tree type = $2;
482 finish_init ();
484 if (pedantic)
485 pedwarn ("ANSI C forbids constructor expressions");
486 if (TYPE_NAME (type) != 0)
488 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
489 name = IDENTIFIER_POINTER (TYPE_NAME (type));
490 else
491 name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
493 else
494 name = "";
495 $$ = result;
496 if (TREE_CODE (type) == ARRAY_TYPE && TYPE_SIZE (type) == 0)
498 int failure = complete_array_type (type, $$, 1);
499 if (failure)
500 abort ();
505 expr_no_commas:
506 cast_expr
507 | expr_no_commas '+' expr_no_commas
508 { $$ = parser_build_binary_op ($2, $1, $3); }
509 | expr_no_commas '-' expr_no_commas
510 { $$ = parser_build_binary_op ($2, $1, $3); }
511 | expr_no_commas '*' expr_no_commas
512 { $$ = parser_build_binary_op ($2, $1, $3); }
513 | expr_no_commas '/' expr_no_commas
514 { $$ = parser_build_binary_op ($2, $1, $3); }
515 | expr_no_commas '%' expr_no_commas
516 { $$ = parser_build_binary_op ($2, $1, $3); }
517 | expr_no_commas LSHIFT expr_no_commas
518 { $$ = parser_build_binary_op ($2, $1, $3); }
519 | expr_no_commas RSHIFT expr_no_commas
520 { $$ = parser_build_binary_op ($2, $1, $3); }
521 | expr_no_commas ARITHCOMPARE expr_no_commas
522 { $$ = parser_build_binary_op ($2, $1, $3); }
523 | expr_no_commas EQCOMPARE expr_no_commas
524 { $$ = parser_build_binary_op ($2, $1, $3); }
525 | expr_no_commas '&' expr_no_commas
526 { $$ = parser_build_binary_op ($2, $1, $3); }
527 | expr_no_commas '|' expr_no_commas
528 { $$ = parser_build_binary_op ($2, $1, $3); }
529 | expr_no_commas '^' expr_no_commas
530 { $$ = parser_build_binary_op ($2, $1, $3); }
531 | expr_no_commas ANDAND
532 { $1 = truthvalue_conversion (default_conversion ($1));
533 skip_evaluation += $1 == boolean_false_node; }
534 expr_no_commas
535 { skip_evaluation -= $1 == boolean_false_node;
536 $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $4); }
537 | expr_no_commas OROR
538 { $1 = truthvalue_conversion (default_conversion ($1));
539 skip_evaluation += $1 == boolean_true_node; }
540 expr_no_commas
541 { skip_evaluation -= $1 == boolean_true_node;
542 $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $4); }
543 | expr_no_commas '?'
544 { $1 = truthvalue_conversion (default_conversion ($1));
545 skip_evaluation += $1 == boolean_false_node; }
546 expr ':'
547 { skip_evaluation += (($1 == boolean_true_node)
548 - ($1 == boolean_false_node)); }
549 expr_no_commas
550 { skip_evaluation -= $1 == boolean_true_node;
551 $$ = build_conditional_expr ($1, $4, $7); }
552 | expr_no_commas '?'
553 { if (pedantic)
554 pedwarn ("ANSI C forbids omitting the middle term of a ?: expression");
555 /* Make sure first operand is calculated only once. */
556 $<ttype>2 = save_expr ($1);
557 $1 = truthvalue_conversion (default_conversion ($<ttype>2));
558 skip_evaluation += $1 == boolean_true_node; }
559 ':' expr_no_commas
560 { skip_evaluation -= $1 == boolean_true_node;
561 $$ = build_conditional_expr ($1, $<ttype>2, $5); }
562 | expr_no_commas '=' expr_no_commas
563 { $$ = build_modify_expr ($1, NOP_EXPR, $3);
564 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
565 | expr_no_commas ASSIGN expr_no_commas
566 { $$ = build_modify_expr ($1, $2, $3);
567 /* This inhibits warnings in truthvalue_conversion. */
568 C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK); }
571 primary:
572 IDENTIFIER
574 $$ = lastiddecl;
575 if (!$$ || $$ == error_mark_node)
577 if (yychar == YYEMPTY)
578 yychar = YYLEX;
579 if (yychar == '(')
581 tree decl;
583 if (objc_receiver_context
584 && ! (objc_receiver_context
585 && strcmp (IDENTIFIER_POINTER ($1), "super")))
586 /* we have a message to super */
587 $$ = get_super_receiver ();
588 else if (objc_method_context
589 && (decl = is_ivar (objc_ivar_chain, $1)))
591 if (is_private (decl))
592 $$ = error_mark_node;
593 else
594 $$ = build_ivar_reference ($1);
596 else
598 /* Ordinary implicit function declaration. */
599 $$ = implicitly_declare ($1);
600 assemble_external ($$);
601 TREE_USED ($$) = 1;
604 else if (current_function_decl == 0)
606 error ("`%s' undeclared here (not in a function)",
607 IDENTIFIER_POINTER ($1));
608 $$ = error_mark_node;
610 else
612 tree decl;
614 if (objc_receiver_context
615 && ! strcmp (IDENTIFIER_POINTER ($1), "super"))
616 /* we have a message to super */
617 $$ = get_super_receiver ();
618 else if (objc_method_context
619 && (decl = is_ivar (objc_ivar_chain, $1)))
621 if (is_private (decl))
622 $$ = error_mark_node;
623 else
624 $$ = build_ivar_reference ($1);
626 else
628 if (IDENTIFIER_GLOBAL_VALUE ($1) != error_mark_node
629 || IDENTIFIER_ERROR_LOCUS ($1) != current_function_decl)
631 error ("`%s' undeclared (first use in this function)",
632 IDENTIFIER_POINTER ($1));
634 if (! undeclared_variable_notice)
636 error ("(Each undeclared identifier is reported only once");
637 error ("for each function it appears in.)");
638 undeclared_variable_notice = 1;
641 $$ = error_mark_node;
642 /* Prevent repeated error messages. */
643 IDENTIFIER_GLOBAL_VALUE ($1) = error_mark_node;
644 IDENTIFIER_ERROR_LOCUS ($1) = current_function_decl;
648 else if (TREE_TYPE ($$) == error_mark_node)
649 $$ = error_mark_node;
650 else if (C_DECL_ANTICIPATED ($$))
652 /* The first time we see a build-in function used,
653 if it has not been declared. */
654 C_DECL_ANTICIPATED ($$) = 0;
655 if (yychar == YYEMPTY)
656 yychar = YYLEX;
657 if (yychar == '(')
659 /* Omit the implicit declaration we
660 would ordinarily do, so we don't lose
661 the actual built in type.
662 But print a diagnostic for the mismatch. */
663 if (objc_method_context
664 && is_ivar (objc_ivar_chain, $1))
665 error ("Instance variable `%s' implicitly declared as function",
666 IDENTIFIER_POINTER (DECL_NAME ($$)));
667 else
668 if (TREE_CODE ($$) != FUNCTION_DECL)
669 error ("`%s' implicitly declared as function",
670 IDENTIFIER_POINTER (DECL_NAME ($$)));
671 else if ((TYPE_MODE (TREE_TYPE (TREE_TYPE ($$)))
672 != TYPE_MODE (integer_type_node))
673 && (TREE_TYPE (TREE_TYPE ($$))
674 != void_type_node))
675 pedwarn ("type mismatch in implicit declaration for built-in function `%s'",
676 IDENTIFIER_POINTER (DECL_NAME ($$)));
677 /* If it really returns void, change that to int. */
678 if (TREE_TYPE (TREE_TYPE ($$)) == void_type_node)
679 TREE_TYPE ($$)
680 = build_function_type (integer_type_node,
681 TYPE_ARG_TYPES (TREE_TYPE ($$)));
683 else
684 pedwarn ("built-in function `%s' used without declaration",
685 IDENTIFIER_POINTER (DECL_NAME ($$)));
687 /* Do what we would ordinarily do when a fn is used. */
688 assemble_external ($$);
689 TREE_USED ($$) = 1;
691 else
693 assemble_external ($$);
694 TREE_USED ($$) = 1;
695 /* we have a definition - still check if iVariable */
697 if (!objc_receiver_context
698 || (objc_receiver_context
699 && strcmp (IDENTIFIER_POINTER ($1), "super")))
701 tree decl;
703 if (objc_method_context
704 && (decl = is_ivar (objc_ivar_chain, $1)))
706 if (IDENTIFIER_LOCAL_VALUE ($1))
707 warning ("local declaration of `%s' hides instance variable",
708 IDENTIFIER_POINTER ($1));
709 else
711 if (is_private (decl))
712 $$ = error_mark_node;
713 else
714 $$ = build_ivar_reference ($1);
718 else /* we have a message to super */
719 $$ = get_super_receiver ();
722 if (TREE_CODE ($$) == CONST_DECL)
724 $$ = DECL_INITIAL ($$);
725 /* This is to prevent an enum whose value is 0
726 from being considered a null pointer constant. */
727 $$ = build1 (NOP_EXPR, TREE_TYPE ($$), $$);
728 TREE_CONSTANT ($$) = 1;
731 | CONSTANT
732 | string
733 { $$ = combine_strings ($1); }
734 | '(' expr ')'
735 { char class = TREE_CODE_CLASS (TREE_CODE ($2));
736 if (class == 'e' || class == '1'
737 || class == '2' || class == '<')
738 C_SET_EXP_ORIGINAL_CODE ($2, ERROR_MARK);
739 $$ = $2; }
740 | '(' error ')'
741 { $$ = error_mark_node; }
742 | '('
743 { if (current_function_decl == 0)
745 error ("braced-group within expression allowed only inside a function");
746 YYERROR;
748 /* We must force a BLOCK for this level
749 so that, if it is not expanded later,
750 there is a way to turn off the entire subtree of blocks
751 that are contained in it. */
752 keep_next_level ();
753 push_iterator_stack ();
754 push_label_level ();
755 $<ttype>$ = expand_start_stmt_expr (); }
756 compstmt ')'
757 { tree rtl_exp;
758 if (pedantic)
759 pedwarn ("ANSI C forbids braced-groups within expressions");
760 pop_iterator_stack ();
761 pop_label_level ();
762 rtl_exp = expand_end_stmt_expr ($<ttype>2);
763 /* The statements have side effects, so the group does. */
764 TREE_SIDE_EFFECTS (rtl_exp) = 1;
766 if (TREE_CODE ($3) == BLOCK)
768 /* Make a BIND_EXPR for the BLOCK already made. */
769 $$ = build (BIND_EXPR, TREE_TYPE (rtl_exp),
770 NULL_TREE, rtl_exp, $3);
771 /* Remove the block from the tree at this point.
772 It gets put back at the proper place
773 when the BIND_EXPR is expanded. */
774 delete_block ($3);
776 else
777 $$ = $3;
779 | primary '(' exprlist ')' %prec '.'
780 { $$ = build_function_call ($1, $3); }
781 | primary '[' expr ']' %prec '.'
782 { $$ = build_array_ref ($1, $3); }
783 | primary '.' identifier
785 if (doing_objc_thang)
787 if (is_public ($1, $3))
788 $$ = build_component_ref ($1, $3);
789 else
790 $$ = error_mark_node;
792 else
793 $$ = build_component_ref ($1, $3);
795 | primary POINTSAT identifier
797 tree expr = build_indirect_ref ($1, "->");
799 if (doing_objc_thang)
801 if (is_public (expr, $3))
802 $$ = build_component_ref (expr, $3);
803 else
804 $$ = error_mark_node;
806 else
807 $$ = build_component_ref (expr, $3);
809 | primary PLUSPLUS
810 { $$ = build_unary_op (POSTINCREMENT_EXPR, $1, 0); }
811 | primary MINUSMINUS
812 { $$ = build_unary_op (POSTDECREMENT_EXPR, $1, 0); }
813 | objcmessageexpr
814 { $$ = build_message_expr ($1); }
815 | objcselectorexpr
816 { $$ = build_selector_expr ($1); }
817 | objcprotocolexpr
818 { $$ = build_protocol_expr ($1); }
819 | objcencodeexpr
820 { $$ = build_encode_expr ($1); }
821 | objc_string
822 { $$ = build_objc_string_object ($1); }
825 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
826 string:
827 STRING
828 | string STRING
829 { $$ = chainon ($1, $2); }
832 /* Produces an OBJC_STRING_CST with perhaps more OBJC_STRING_CSTs chained
833 onto it. */
834 objc_string:
835 OBJC_STRING
836 | objc_string OBJC_STRING
837 { $$ = chainon ($1, $2); }
840 old_style_parm_decls:
841 /* empty */
842 | datadecls
843 | datadecls ELLIPSIS
844 /* ... is used here to indicate a varargs function. */
845 { c_mark_varargs ();
846 if (pedantic)
847 pedwarn ("ANSI C does not permit use of `varargs.h'"); }
850 /* The following are analogous to lineno_decl, decls and decl
851 except that they do not allow nested functions.
852 They are used for old-style parm decls. */
853 lineno_datadecl:
854 save_filename save_lineno datadecl
858 datadecls:
859 lineno_datadecl
860 | errstmt
861 | datadecls lineno_datadecl
862 | lineno_datadecl errstmt
865 /* We don't allow prefix attributes here because they cause reduce/reduce
866 conflicts: we can't know whether we're parsing a function decl with
867 attribute suffix, or function defn with attribute prefix on first old
868 style parm. */
869 datadecl:
870 typed_declspecs_no_prefix_attr setspecs initdecls ';'
871 { current_declspecs = TREE_VALUE (declspec_stack);
872 prefix_attributes = TREE_PURPOSE (declspec_stack);
873 declspec_stack = TREE_CHAIN (declspec_stack);
874 resume_momentary ($2); }
875 | declmods_no_prefix_attr setspecs notype_initdecls ';'
876 { current_declspecs = TREE_VALUE (declspec_stack);
877 prefix_attributes = TREE_PURPOSE (declspec_stack);
878 declspec_stack = TREE_CHAIN (declspec_stack);
879 resume_momentary ($2); }
880 | typed_declspecs_no_prefix_attr ';'
881 { shadow_tag_warned ($1, 1);
882 pedwarn ("empty declaration"); }
883 | declmods_no_prefix_attr ';'
884 { pedwarn ("empty declaration"); }
887 /* This combination which saves a lineno before a decl
888 is the normal thing to use, rather than decl itself.
889 This is to avoid shift/reduce conflicts in contexts
890 where statement labels are allowed. */
891 lineno_decl:
892 save_filename save_lineno decl
896 decls:
897 lineno_decl
898 | errstmt
899 | decls lineno_decl
900 | lineno_decl errstmt
903 /* records the type and storage class specs to use for processing
904 the declarators that follow.
905 Maintains a stack of outer-level values of current_declspecs,
906 for the sake of parm declarations nested in function declarators. */
907 setspecs: /* empty */
908 { $$ = suspend_momentary ();
909 pending_xref_error ();
910 declspec_stack = tree_cons (prefix_attributes,
911 current_declspecs,
912 declspec_stack);
913 split_specs_attrs ($<ttype>0,
914 &current_declspecs, &prefix_attributes); }
917 /* ??? Yuck. See after_type_declarator. */
918 setattrs: /* empty */
919 { prefix_attributes = chainon (prefix_attributes, $<ttype>0); }
922 decl:
923 typed_declspecs setspecs initdecls ';'
924 { current_declspecs = TREE_VALUE (declspec_stack);
925 prefix_attributes = TREE_PURPOSE (declspec_stack);
926 declspec_stack = TREE_CHAIN (declspec_stack);
927 resume_momentary ($2); }
928 | declmods setspecs notype_initdecls ';'
929 { current_declspecs = TREE_VALUE (declspec_stack);
930 prefix_attributes = TREE_PURPOSE (declspec_stack);
931 declspec_stack = TREE_CHAIN (declspec_stack);
932 resume_momentary ($2); }
933 | typed_declspecs setspecs nested_function
934 { current_declspecs = TREE_VALUE (declspec_stack);
935 prefix_attributes = TREE_PURPOSE (declspec_stack);
936 declspec_stack = TREE_CHAIN (declspec_stack);
937 resume_momentary ($2); }
938 | declmods setspecs notype_nested_function
939 { current_declspecs = TREE_VALUE (declspec_stack);
940 prefix_attributes = TREE_PURPOSE (declspec_stack);
941 declspec_stack = TREE_CHAIN (declspec_stack);
942 resume_momentary ($2); }
943 | typed_declspecs ';'
944 { shadow_tag ($1); }
945 | declmods ';'
946 { pedwarn ("empty declaration"); }
947 | extension decl
948 { pedantic = $<itype>1; }
951 /* Declspecs which contain at least one type specifier or typedef name.
952 (Just `const' or `volatile' is not enough.)
953 A typedef'd name following these is taken as a name to be declared.
954 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
956 typed_declspecs:
957 typespec reserved_declspecs
958 { $$ = tree_cons (NULL_TREE, $1, $2); }
959 | declmods typespec reserved_declspecs
960 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
963 reserved_declspecs: /* empty */
964 { $$ = NULL_TREE; }
965 | reserved_declspecs typespecqual_reserved
966 { $$ = tree_cons (NULL_TREE, $2, $1); }
967 | reserved_declspecs SCSPEC
968 { if (extra_warnings)
969 warning ("`%s' is not at beginning of declaration",
970 IDENTIFIER_POINTER ($2));
971 $$ = tree_cons (NULL_TREE, $2, $1); }
972 | reserved_declspecs attributes
973 { $$ = tree_cons ($2, NULL_TREE, $1); }
976 typed_declspecs_no_prefix_attr:
977 typespec reserved_declspecs_no_prefix_attr
978 { $$ = tree_cons (NULL_TREE, $1, $2); }
979 | declmods_no_prefix_attr typespec reserved_declspecs_no_prefix_attr
980 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
983 reserved_declspecs_no_prefix_attr:
984 /* empty */
985 { $$ = NULL_TREE; }
986 | reserved_declspecs_no_prefix_attr typespecqual_reserved
987 { $$ = tree_cons (NULL_TREE, $2, $1); }
988 | reserved_declspecs_no_prefix_attr SCSPEC
989 { if (extra_warnings)
990 warning ("`%s' is not at beginning of declaration",
991 IDENTIFIER_POINTER ($2));
992 $$ = tree_cons (NULL_TREE, $2, $1); }
995 /* List of just storage classes, type modifiers, and prefix attributes.
996 A declaration can start with just this, but then it cannot be used
997 to redeclare a typedef-name.
998 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
1000 declmods:
1001 declmods_no_prefix_attr
1002 { $$ = $1; }
1003 | attributes
1004 { $$ = tree_cons ($1, NULL_TREE, NULL_TREE); }
1005 | declmods declmods_no_prefix_attr
1006 { $$ = chainon ($2, $1); }
1007 | declmods attributes
1008 { $$ = tree_cons ($2, NULL_TREE, $1); }
1011 declmods_no_prefix_attr:
1012 TYPE_QUAL
1013 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
1014 TREE_STATIC ($$) = 1; }
1015 | SCSPEC
1016 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
1017 | declmods_no_prefix_attr TYPE_QUAL
1018 { $$ = tree_cons (NULL_TREE, $2, $1);
1019 TREE_STATIC ($$) = 1; }
1020 | declmods_no_prefix_attr SCSPEC
1021 { if (extra_warnings && TREE_STATIC ($1))
1022 warning ("`%s' is not at beginning of declaration",
1023 IDENTIFIER_POINTER ($2));
1024 $$ = tree_cons (NULL_TREE, $2, $1);
1025 TREE_STATIC ($$) = TREE_STATIC ($1); }
1029 /* Used instead of declspecs where storage classes are not allowed
1030 (that is, for typenames and structure components).
1031 Don't accept a typedef-name if anything but a modifier precedes it. */
1033 typed_typespecs:
1034 typespec reserved_typespecquals
1035 { $$ = tree_cons (NULL_TREE, $1, $2); }
1036 | nonempty_type_quals typespec reserved_typespecquals
1037 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
1040 reserved_typespecquals: /* empty */
1041 { $$ = NULL_TREE; }
1042 | reserved_typespecquals typespecqual_reserved
1043 { $$ = tree_cons (NULL_TREE, $2, $1); }
1046 /* A typespec (but not a type qualifier).
1047 Once we have seen one of these in a declaration,
1048 if a typedef name appears then it is being redeclared. */
1050 typespec: TYPESPEC
1051 | structsp
1052 | TYPENAME
1053 { /* For a typedef name, record the meaning, not the name.
1054 In case of `foo foo, bar;'. */
1055 $$ = lookup_name ($1); }
1056 | CLASSNAME protocolrefs
1057 { $$ = get_static_reference ($1, $2); }
1058 | OBJECTNAME protocolrefs
1059 { $$ = get_object_reference ($2); }
1061 /* Make "<SomeProtocol>" equivalent to "id <SomeProtocol>"
1062 - nisse@lysator.liu.se */
1063 | non_empty_protocolrefs
1064 { $$ = get_object_reference ($1); }
1065 | TYPEOF '(' expr ')'
1066 { $$ = TREE_TYPE ($3); }
1067 | TYPEOF '(' typename ')'
1068 { $$ = groktypename ($3); }
1071 /* A typespec that is a reserved word, or a type qualifier. */
1073 typespecqual_reserved: TYPESPEC
1074 | TYPE_QUAL
1075 | structsp
1078 initdecls:
1079 initdcl
1080 | initdecls ',' initdcl
1083 notype_initdecls:
1084 notype_initdcl
1085 | notype_initdecls ',' initdcl
1088 maybeasm:
1089 /* empty */
1090 { $$ = NULL_TREE; }
1091 | ASM_KEYWORD '(' string ')'
1092 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
1093 $$ = $3;
1097 initdcl:
1098 declarator maybeasm maybe_attribute '='
1099 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1100 $3, prefix_attributes);
1101 start_init ($<ttype>$, $2, global_bindings_p ()); }
1102 init
1103 /* Note how the declaration of the variable is in effect while its init is parsed! */
1104 { finish_init ();
1105 finish_decl ($<ttype>5, $6, $2); }
1106 | declarator maybeasm maybe_attribute
1107 { tree d = start_decl ($1, current_declspecs, 0,
1108 $3, prefix_attributes);
1109 finish_decl (d, NULL_TREE, $2);
1113 notype_initdcl:
1114 notype_declarator maybeasm maybe_attribute '='
1115 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1116 $3, prefix_attributes);
1117 start_init ($<ttype>$, $2, global_bindings_p ()); }
1118 init
1119 /* Note how the declaration of the variable is in effect while its init is parsed! */
1120 { finish_init ();
1121 decl_attributes ($<ttype>5, $3, prefix_attributes);
1122 finish_decl ($<ttype>5, $6, $2); }
1123 | notype_declarator maybeasm maybe_attribute
1124 { tree d = start_decl ($1, current_declspecs, 0,
1125 $3, prefix_attributes);
1126 finish_decl (d, NULL_TREE, $2); }
1128 /* the * rules are dummies to accept the Apollo extended syntax
1129 so that the header files compile. */
1130 maybe_attribute:
1131 /* empty */
1132 { $$ = NULL_TREE; }
1133 | attributes
1134 { $$ = $1; }
1137 attributes:
1138 attribute
1139 { $$ = $1; }
1140 | attributes attribute
1141 { $$ = chainon ($1, $2); }
1144 attribute:
1145 ATTRIBUTE '(' '(' attribute_list ')' ')'
1146 { $$ = $4; }
1149 attribute_list:
1150 attrib
1151 { $$ = $1; }
1152 | attribute_list ',' attrib
1153 { $$ = chainon ($1, $3); }
1156 attrib:
1157 /* empty */
1158 { $$ = NULL_TREE; }
1159 | any_word
1160 { $$ = build_tree_list ($1, NULL_TREE); }
1161 | any_word '(' IDENTIFIER ')'
1162 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1163 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1164 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1165 | any_word '(' exprlist ')'
1166 { $$ = build_tree_list ($1, $3); }
1169 /* This still leaves out most reserved keywords,
1170 shouldn't we include them? */
1172 any_word:
1173 identifier
1174 | SCSPEC
1175 | TYPESPEC
1176 | TYPE_QUAL
1179 /* Initializers. `init' is the entry point. */
1181 init:
1182 expr_no_commas
1183 | '{'
1184 { really_start_incremental_init (NULL_TREE);
1185 /* Note that the call to clear_momentary
1186 is in process_init_element. */
1187 push_momentary (); }
1188 initlist_maybe_comma '}'
1189 { $$ = pop_init_level (0);
1190 if ($$ == error_mark_node
1191 && ! (yychar == STRING || yychar == CONSTANT))
1192 pop_momentary ();
1193 else
1194 pop_momentary_nofree (); }
1196 | error
1197 { $$ = error_mark_node; }
1200 /* `initlist_maybe_comma' is the guts of an initializer in braces. */
1201 initlist_maybe_comma:
1202 /* empty */
1203 { if (pedantic)
1204 pedwarn ("ANSI C forbids empty initializer braces"); }
1205 | initlist1 maybecomma
1208 initlist1:
1209 initelt
1210 | initlist1 ',' initelt
1213 /* `initelt' is a single element of an initializer.
1214 It may use braces. */
1215 initelt:
1216 expr_no_commas
1217 { process_init_element ($1); }
1218 | '{'
1219 { push_init_level (0); }
1220 initlist_maybe_comma '}'
1221 { process_init_element (pop_init_level (0)); }
1222 | error
1223 /* These are for labeled elements. The syntax for an array element
1224 initializer conflicts with the syntax for an Objective-C message,
1225 so don't include these productions in the Objective-C grammar. */
1226 | identifier ':'
1227 { set_init_label ($1); }
1228 initelt
1229 | '.' identifier '='
1230 { set_init_label ($2); }
1231 initelt
1234 nested_function:
1235 declarator
1236 { push_c_function_context ();
1237 if (! start_function (current_declspecs, $1,
1238 prefix_attributes, NULL_TREE, 1))
1240 pop_c_function_context ();
1241 YYERROR1;
1243 reinit_parse_for_function (); }
1244 old_style_parm_decls
1245 { store_parm_decls (); }
1246 /* This used to use compstmt_or_error.
1247 That caused a bug with input `f(g) int g {}',
1248 where the use of YYERROR1 above caused an error
1249 which then was handled by compstmt_or_error.
1250 There followed a repeated execution of that same rule,
1251 which called YYERROR1 again, and so on. */
1252 compstmt
1253 { finish_function (1);
1254 pop_c_function_context (); }
1257 notype_nested_function:
1258 notype_declarator
1259 { push_c_function_context ();
1260 if (! start_function (current_declspecs, $1,
1261 prefix_attributes, NULL_TREE, 1))
1263 pop_c_function_context ();
1264 YYERROR1;
1266 reinit_parse_for_function (); }
1267 old_style_parm_decls
1268 { store_parm_decls (); }
1269 /* This used to use compstmt_or_error.
1270 That caused a bug with input `f(g) int g {}',
1271 where the use of YYERROR1 above caused an error
1272 which then was handled by compstmt_or_error.
1273 There followed a repeated execution of that same rule,
1274 which called YYERROR1 again, and so on. */
1275 compstmt
1276 { finish_function (1);
1277 pop_c_function_context (); }
1280 /* Any kind of declarator (thus, all declarators allowed
1281 after an explicit typespec). */
1283 declarator:
1284 after_type_declarator
1285 | notype_declarator
1288 /* A declarator that is allowed only after an explicit typespec. */
1290 after_type_declarator:
1291 '(' after_type_declarator ')'
1292 { $$ = $2; }
1293 | after_type_declarator '(' parmlist_or_identifiers %prec '.'
1294 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1295 /* | after_type_declarator '(' error ')' %prec '.'
1296 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1297 poplevel (0, 0, 0); } */
1298 | after_type_declarator '[' expr ']' %prec '.'
1299 { $$ = build_nt (ARRAY_REF, $1, $3); }
1300 | after_type_declarator '[' ']' %prec '.'
1301 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1302 | '*' type_quals after_type_declarator %prec UNARY
1303 { $$ = make_pointer_declarator ($2, $3); }
1304 /* ??? Yuck. setattrs is a quick hack. We can't use
1305 prefix_attributes because $1 only applies to this
1306 declarator. We assume setspecs has already been done.
1307 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1308 attributes could be recognized here or in `attributes'). */
1309 | attributes setattrs after_type_declarator
1310 { $$ = $3; }
1311 | TYPENAME
1312 | OBJECTNAME
1315 /* Kinds of declarator that can appear in a parameter list
1316 in addition to notype_declarator. This is like after_type_declarator
1317 but does not allow a typedef name in parentheses as an identifier
1318 (because it would conflict with a function with that typedef as arg). */
1320 parm_declarator:
1321 parm_declarator '(' parmlist_or_identifiers %prec '.'
1322 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1323 /* | parm_declarator '(' error ')' %prec '.'
1324 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1325 poplevel (0, 0, 0); } */
1326 | parm_declarator '[' expr ']' %prec '.'
1327 { $$ = build_nt (ARRAY_REF, $1, $3); }
1328 | parm_declarator '[' ']' %prec '.'
1329 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1330 | '*' type_quals parm_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 parm_declarator
1338 { $$ = $3; }
1339 | TYPENAME
1342 /* A declarator allowed whether or not there has been
1343 an explicit typespec. These cannot redeclare a typedef-name. */
1345 notype_declarator:
1346 notype_declarator '(' parmlist_or_identifiers %prec '.'
1347 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1348 /* | notype_declarator '(' error ')' %prec '.'
1349 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1350 poplevel (0, 0, 0); } */
1351 | '(' notype_declarator ')'
1352 { $$ = $2; }
1353 | '*' type_quals notype_declarator %prec UNARY
1354 { $$ = make_pointer_declarator ($2, $3); }
1355 | notype_declarator '[' expr ']' %prec '.'
1356 { $$ = build_nt (ARRAY_REF, $1, $3); }
1357 | notype_declarator '[' ']' %prec '.'
1358 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1359 /* ??? Yuck. setattrs is a quick hack. We can't use
1360 prefix_attributes because $1 only applies to this
1361 declarator. We assume setspecs has already been done.
1362 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1363 attributes could be recognized here or in `attributes'). */
1364 | attributes setattrs notype_declarator
1365 { $$ = $3; }
1366 | IDENTIFIER
1369 structsp:
1370 STRUCT identifier '{'
1371 { $$ = start_struct (RECORD_TYPE, $2);
1372 /* Start scope of tag before parsing components. */
1374 component_decl_list '}' maybe_attribute
1375 { $$ = finish_struct ($<ttype>4, $5, $7); }
1376 | STRUCT '{' component_decl_list '}' maybe_attribute
1377 { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
1378 $3, $5);
1380 | STRUCT identifier
1381 { $$ = xref_tag (RECORD_TYPE, $2); }
1382 | UNION identifier '{'
1383 { $$ = start_struct (UNION_TYPE, $2); }
1384 component_decl_list '}' maybe_attribute
1385 { $$ = finish_struct ($<ttype>4, $5, $7); }
1386 | UNION '{' component_decl_list '}' maybe_attribute
1387 { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
1388 $3, $5);
1390 | UNION identifier
1391 { $$ = xref_tag (UNION_TYPE, $2); }
1392 | ENUM identifier '{'
1393 { $<itype>3 = suspend_momentary ();
1394 $$ = start_enum ($2); }
1395 enumlist maybecomma_warn '}' maybe_attribute
1396 { $$ = finish_enum ($<ttype>4, nreverse ($5), $8);
1397 resume_momentary ($<itype>3); }
1398 | ENUM '{'
1399 { $<itype>2 = suspend_momentary ();
1400 $$ = start_enum (NULL_TREE); }
1401 enumlist maybecomma_warn '}' maybe_attribute
1402 { $$ = finish_enum ($<ttype>3, nreverse ($4), $7);
1403 resume_momentary ($<itype>2); }
1404 | ENUM identifier
1405 { $$ = xref_tag (ENUMERAL_TYPE, $2); }
1408 maybecomma:
1409 /* empty */
1410 | ','
1413 maybecomma_warn:
1414 /* empty */
1415 | ','
1416 { if (pedantic) pedwarn ("comma at end of enumerator list"); }
1419 component_decl_list:
1420 component_decl_list2
1421 { $$ = $1; }
1422 | component_decl_list2 component_decl
1423 { $$ = chainon ($1, $2);
1424 pedwarn ("no semicolon at end of struct or union"); }
1427 component_decl_list2: /* empty */
1428 { $$ = NULL_TREE; }
1429 | component_decl_list2 component_decl ';'
1430 { $$ = chainon ($1, $2); }
1431 | component_decl_list2 ';'
1432 { if (pedantic)
1433 pedwarn ("extra semicolon in struct or union specified"); }
1434 /* foo(sizeof(struct{ @defs(ClassName)})); */
1435 | DEFS '(' CLASSNAME ')'
1437 tree interface = lookup_interface ($3);
1439 if (interface)
1440 $$ = get_class_ivars (interface);
1441 else
1443 error ("Cannot find interface declaration for `%s'",
1444 IDENTIFIER_POINTER ($3));
1445 $$ = NULL_TREE;
1450 /* There is a shift-reduce conflict here, because `components' may
1451 start with a `typename'. It happens that shifting (the default resolution)
1452 does the right thing, because it treats the `typename' as part of
1453 a `typed_typespecs'.
1455 It is possible that this same technique would allow the distinction
1456 between `notype_initdecls' and `initdecls' to be eliminated.
1457 But I am being cautious and not trying it. */
1459 component_decl:
1460 typed_typespecs setspecs components
1461 { $$ = $3;
1462 current_declspecs = TREE_VALUE (declspec_stack);
1463 prefix_attributes = TREE_PURPOSE (declspec_stack);
1464 declspec_stack = TREE_CHAIN (declspec_stack);
1465 resume_momentary ($2); }
1466 | typed_typespecs
1467 { if (pedantic)
1468 pedwarn ("ANSI C forbids member declarations with no members");
1469 shadow_tag($1);
1470 $$ = NULL_TREE; }
1471 | nonempty_type_quals setspecs components
1472 { $$ = $3;
1473 current_declspecs = TREE_VALUE (declspec_stack);
1474 prefix_attributes = TREE_PURPOSE (declspec_stack);
1475 declspec_stack = TREE_CHAIN (declspec_stack);
1476 resume_momentary ($2); }
1477 | nonempty_type_quals
1478 { if (pedantic)
1479 pedwarn ("ANSI C forbids member declarations with no members");
1480 shadow_tag($1);
1481 $$ = NULL_TREE; }
1482 | error
1483 { $$ = NULL_TREE; }
1484 | extension component_decl
1485 { $$ = $2;
1486 pedantic = $<itype>1; }
1489 components:
1490 component_declarator
1491 | components ',' component_declarator
1492 { $$ = chainon ($1, $3); }
1495 component_declarator:
1496 save_filename save_lineno declarator maybe_attribute
1497 { $$ = grokfield ($1, $2, $3, current_declspecs, NULL_TREE);
1498 decl_attributes ($$, $4, prefix_attributes); }
1499 | save_filename save_lineno
1500 declarator ':' expr_no_commas maybe_attribute
1501 { $$ = grokfield ($1, $2, $3, current_declspecs, $5);
1502 decl_attributes ($$, $6, prefix_attributes); }
1503 | save_filename save_lineno ':' expr_no_commas maybe_attribute
1504 { $$ = grokfield ($1, $2, NULL_TREE, current_declspecs, $4);
1505 decl_attributes ($$, $5, prefix_attributes); }
1508 /* We chain the enumerators in reverse order.
1509 They are put in forward order where enumlist is used.
1510 (The order used to be significant, but no longer is so.
1511 However, we still maintain the order, just to be clean.) */
1513 enumlist:
1514 enumerator
1515 | enumlist ',' enumerator
1516 { if ($1 == error_mark_node)
1517 $$ = $1;
1518 else
1519 $$ = chainon ($3, $1); }
1520 | error
1521 { $$ = error_mark_node; }
1525 enumerator:
1526 identifier
1527 { $$ = build_enumerator ($1, NULL_TREE); }
1528 | identifier '=' expr_no_commas
1529 { $$ = build_enumerator ($1, $3); }
1532 typename:
1533 typed_typespecs absdcl
1534 { $$ = build_tree_list ($1, $2); }
1535 | nonempty_type_quals absdcl
1536 { $$ = build_tree_list ($1, $2); }
1539 absdcl: /* an absolute declarator */
1540 /* empty */
1541 { $$ = NULL_TREE; }
1542 | absdcl1
1545 nonempty_type_quals:
1546 TYPE_QUAL
1547 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
1548 | nonempty_type_quals TYPE_QUAL
1549 { $$ = tree_cons (NULL_TREE, $2, $1); }
1552 type_quals:
1553 /* empty */
1554 { $$ = NULL_TREE; }
1555 | type_quals TYPE_QUAL
1556 { $$ = tree_cons (NULL_TREE, $2, $1); }
1559 absdcl1: /* a nonempty absolute declarator */
1560 '(' absdcl1 ')'
1561 { $$ = $2; }
1562 /* `(typedef)1' is `int'. */
1563 | '*' type_quals absdcl1 %prec UNARY
1564 { $$ = make_pointer_declarator ($2, $3); }
1565 | '*' type_quals %prec UNARY
1566 { $$ = make_pointer_declarator ($2, NULL_TREE); }
1567 | absdcl1 '(' parmlist %prec '.'
1568 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1569 | absdcl1 '[' expr ']' %prec '.'
1570 { $$ = build_nt (ARRAY_REF, $1, $3); }
1571 | absdcl1 '[' ']' %prec '.'
1572 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1573 | '(' parmlist %prec '.'
1574 { $$ = build_nt (CALL_EXPR, NULL_TREE, $2, NULL_TREE); }
1575 | '[' expr ']' %prec '.'
1576 { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
1577 | '[' ']' %prec '.'
1578 { $$ = build_nt (ARRAY_REF, NULL_TREE, NULL_TREE); }
1579 /* ??? It appears we have to support attributes here, however
1580 using prefix_attributes is wrong. */
1583 /* at least one statement, the first of which parses without error. */
1584 /* stmts is used only after decls, so an invalid first statement
1585 is actually regarded as an invalid decl and part of the decls. */
1587 stmts:
1588 lineno_stmt_or_labels
1590 if (pedantic && $1)
1591 pedwarn ("ANSI C forbids label at end of compound statement");
1595 lineno_stmt_or_labels:
1596 lineno_stmt_or_label
1597 | lineno_stmt_or_labels lineno_stmt_or_label
1598 { $$ = $2; }
1599 | lineno_stmt_or_labels errstmt
1600 { $$ = 0; }
1603 xstmts:
1604 /* empty */
1605 | stmts
1608 errstmt: error ';'
1611 pushlevel: /* empty */
1612 { emit_line_note (input_filename, lineno);
1613 pushlevel (0);
1614 clear_last_expr ();
1615 push_momentary ();
1616 expand_start_bindings (0);
1617 if (objc_method_context)
1618 add_objc_decls ();
1622 /* Read zero or more forward-declarations for labels
1623 that nested functions can jump to. */
1624 maybe_label_decls:
1625 /* empty */
1626 | label_decls
1627 { if (pedantic)
1628 pedwarn ("ANSI C forbids label declarations"); }
1631 label_decls:
1632 label_decl
1633 | label_decls label_decl
1636 label_decl:
1637 LABEL identifiers_or_typenames ';'
1638 { tree link;
1639 for (link = $2; link; link = TREE_CHAIN (link))
1641 tree label = shadow_label (TREE_VALUE (link));
1642 C_DECLARED_LABEL_FLAG (label) = 1;
1643 declare_nonlocal_label (label);
1648 /* This is the body of a function definition.
1649 It causes syntax errors to ignore to the next openbrace. */
1650 compstmt_or_error:
1651 compstmt
1653 | error compstmt
1656 compstmt_start: '{' { compstmt_count++; }
1658 compstmt: compstmt_start '}'
1659 { $$ = convert (void_type_node, integer_zero_node); }
1660 | compstmt_start pushlevel maybe_label_decls decls xstmts '}'
1661 { emit_line_note (input_filename, lineno);
1662 expand_end_bindings (getdecls (), 1, 0);
1663 $$ = poplevel (1, 1, 0);
1664 if (yychar == CONSTANT || yychar == STRING)
1665 pop_momentary_nofree ();
1666 else
1667 pop_momentary (); }
1668 | compstmt_start pushlevel maybe_label_decls error '}'
1669 { emit_line_note (input_filename, lineno);
1670 expand_end_bindings (getdecls (), kept_level_p (), 0);
1671 $$ = poplevel (kept_level_p (), 0, 0);
1672 if (yychar == CONSTANT || yychar == STRING)
1673 pop_momentary_nofree ();
1674 else
1675 pop_momentary (); }
1676 | compstmt_start pushlevel maybe_label_decls stmts '}'
1677 { emit_line_note (input_filename, lineno);
1678 expand_end_bindings (getdecls (), kept_level_p (), 0);
1679 $$ = poplevel (kept_level_p (), 0, 0);
1680 if (yychar == CONSTANT || yychar == STRING)
1681 pop_momentary_nofree ();
1682 else
1683 pop_momentary (); }
1686 /* Value is number of statements counted as of the closeparen. */
1687 simple_if:
1688 if_prefix lineno_labeled_stmt
1689 /* Make sure c_expand_end_cond is run once
1690 for each call to c_expand_start_cond.
1691 Otherwise a crash is likely. */
1692 | if_prefix error
1695 if_prefix:
1696 IF '(' expr ')'
1697 { emit_line_note ($<filename>-1, $<lineno>0);
1698 c_expand_start_cond (truthvalue_conversion ($3), 0,
1699 compstmt_count);
1700 $<itype>$ = stmt_count;
1701 if_stmt_file = $<filename>-1;
1702 if_stmt_line = $<lineno>0;
1703 position_after_white_space (); }
1706 /* This is a subroutine of stmt.
1707 It is used twice, once for valid DO statements
1708 and once for catching errors in parsing the end test. */
1709 do_stmt_start:
1711 { stmt_count++;
1712 compstmt_count++;
1713 emit_line_note ($<filename>-1, $<lineno>0);
1714 /* See comment in `while' alternative, above. */
1715 emit_nop ();
1716 expand_start_loop_continue_elsewhere (1);
1717 position_after_white_space (); }
1718 lineno_labeled_stmt WHILE
1719 { expand_loop_continue_here (); }
1722 save_filename:
1723 { $$ = input_filename; }
1726 save_lineno:
1727 { $$ = lineno; }
1730 lineno_labeled_stmt:
1731 save_filename save_lineno stmt
1733 /* | save_filename save_lineno error
1736 | save_filename save_lineno label lineno_labeled_stmt
1740 lineno_stmt_or_label:
1741 save_filename save_lineno stmt_or_label
1742 { $$ = $3; }
1745 stmt_or_label:
1746 stmt
1747 { $$ = 0; }
1748 | label
1749 { $$ = 1; }
1752 /* Parse a single real statement, not including any labels. */
1753 stmt:
1754 compstmt
1755 { stmt_count++; }
1756 | all_iter_stmt
1757 | expr ';'
1758 { stmt_count++;
1759 emit_line_note ($<filename>-1, $<lineno>0);
1760 /* It appears that this should not be done--that a non-lvalue array
1761 shouldn't get an error if the value isn't used.
1762 Section 3.2.2.1 says that an array lvalue gets converted to a pointer
1763 if it appears as a top-level expression,
1764 but says nothing about non-lvalue arrays. */
1765 #if 0
1766 /* Call default_conversion to get an error
1767 on referring to a register array if pedantic. */
1768 if (TREE_CODE (TREE_TYPE ($1)) == ARRAY_TYPE
1769 || TREE_CODE (TREE_TYPE ($1)) == FUNCTION_TYPE)
1770 $1 = default_conversion ($1);
1771 #endif
1772 iterator_expand ($1);
1773 clear_momentary (); }
1774 | simple_if ELSE
1775 { c_expand_start_else ();
1776 $<itype>1 = stmt_count;
1777 position_after_white_space (); }
1778 lineno_labeled_stmt
1779 { c_expand_end_cond ();
1780 if (extra_warnings && stmt_count == $<itype>1)
1781 warning ("empty body in an else-statement"); }
1782 | simple_if %prec IF
1783 { c_expand_end_cond ();
1784 /* This warning is here instead of in simple_if, because we
1785 do not want a warning if an empty if is followed by an
1786 else statement. Increment stmt_count so we don't
1787 give a second error if this is a nested `if'. */
1788 if (extra_warnings && stmt_count++ == $<itype>1)
1789 warning_with_file_and_line (if_stmt_file, if_stmt_line,
1790 "empty body in an if-statement"); }
1791 /* Make sure c_expand_end_cond is run once
1792 for each call to c_expand_start_cond.
1793 Otherwise a crash is likely. */
1794 | simple_if ELSE error
1795 { c_expand_end_cond (); }
1796 | WHILE
1797 { stmt_count++;
1798 emit_line_note ($<filename>-1, $<lineno>0);
1799 /* The emit_nop used to come before emit_line_note,
1800 but that made the nop seem like part of the preceding line.
1801 And that was confusing when the preceding line was
1802 inside of an if statement and was not really executed.
1803 I think it ought to work to put the nop after the line number.
1804 We will see. --rms, July 15, 1991. */
1805 emit_nop (); }
1806 '(' expr ')'
1807 { /* Don't start the loop till we have succeeded
1808 in parsing the end test. This is to make sure
1809 that we end every loop we start. */
1810 expand_start_loop (1);
1811 emit_line_note (input_filename, lineno);
1812 expand_exit_loop_if_false (NULL_PTR,
1813 truthvalue_conversion ($4));
1814 position_after_white_space (); }
1815 lineno_labeled_stmt
1816 { expand_end_loop (); }
1817 | do_stmt_start
1818 '(' expr ')' ';'
1819 { emit_line_note (input_filename, lineno);
1820 expand_exit_loop_if_false (NULL_PTR,
1821 truthvalue_conversion ($3));
1822 expand_end_loop ();
1823 clear_momentary (); }
1824 /* This rule is needed to make sure we end every loop we start. */
1825 | do_stmt_start error
1826 { expand_end_loop ();
1827 clear_momentary (); }
1828 | FOR
1829 '(' xexpr ';'
1830 { stmt_count++;
1831 emit_line_note ($<filename>-1, $<lineno>0);
1832 /* See comment in `while' alternative, above. */
1833 emit_nop ();
1834 if ($3) c_expand_expr_stmt ($3);
1835 /* Next step is to call expand_start_loop_continue_elsewhere,
1836 but wait till after we parse the entire for (...).
1837 Otherwise, invalid input might cause us to call that
1838 fn without calling expand_end_loop. */
1840 xexpr ';'
1841 /* Can't emit now; wait till after expand_start_loop... */
1842 { $<lineno>7 = lineno;
1843 $<filename>$ = input_filename; }
1844 xexpr ')'
1846 /* Start the loop. Doing this after parsing
1847 all the expressions ensures we will end the loop. */
1848 expand_start_loop_continue_elsewhere (1);
1849 /* Emit the end-test, with a line number. */
1850 emit_line_note ($<filename>8, $<lineno>7);
1851 if ($6)
1852 expand_exit_loop_if_false (NULL_PTR,
1853 truthvalue_conversion ($6));
1854 /* Don't let the tree nodes for $9 be discarded by
1855 clear_momentary during the parsing of the next stmt. */
1856 push_momentary ();
1857 $<lineno>7 = lineno;
1858 $<filename>8 = input_filename;
1859 position_after_white_space (); }
1860 lineno_labeled_stmt
1861 { /* Emit the increment expression, with a line number. */
1862 emit_line_note ($<filename>8, $<lineno>7);
1863 expand_loop_continue_here ();
1864 if ($9)
1865 c_expand_expr_stmt ($9);
1866 if (yychar == CONSTANT || yychar == STRING)
1867 pop_momentary_nofree ();
1868 else
1869 pop_momentary ();
1870 expand_end_loop (); }
1871 | SWITCH '(' expr ')'
1872 { stmt_count++;
1873 emit_line_note ($<filename>-1, $<lineno>0);
1874 c_expand_start_case ($3);
1875 /* Don't let the tree nodes for $3 be discarded by
1876 clear_momentary during the parsing of the next stmt. */
1877 push_momentary ();
1878 position_after_white_space (); }
1879 lineno_labeled_stmt
1880 { expand_end_case ($3);
1881 if (yychar == CONSTANT || yychar == STRING)
1882 pop_momentary_nofree ();
1883 else
1884 pop_momentary (); }
1885 | BREAK ';'
1886 { stmt_count++;
1887 emit_line_note ($<filename>-1, $<lineno>0);
1888 if ( ! expand_exit_something ())
1889 error ("break statement not within loop or switch"); }
1890 | CONTINUE ';'
1891 { stmt_count++;
1892 emit_line_note ($<filename>-1, $<lineno>0);
1893 if (! expand_continue_loop (NULL_PTR))
1894 error ("continue statement not within a loop"); }
1895 | RETURN ';'
1896 { stmt_count++;
1897 emit_line_note ($<filename>-1, $<lineno>0);
1898 c_expand_return (NULL_TREE); }
1899 | RETURN expr ';'
1900 { stmt_count++;
1901 emit_line_note ($<filename>-1, $<lineno>0);
1902 c_expand_return ($2); }
1903 | ASM_KEYWORD maybe_type_qual '(' expr ')' ';'
1904 { stmt_count++;
1905 emit_line_note ($<filename>-1, $<lineno>0);
1906 STRIP_NOPS ($4);
1907 if ((TREE_CODE ($4) == ADDR_EXPR
1908 && TREE_CODE (TREE_OPERAND ($4, 0)) == STRING_CST)
1909 || TREE_CODE ($4) == STRING_CST)
1910 expand_asm ($4);
1911 else
1912 error ("argument of `asm' is not a constant string"); }
1913 /* This is the case with just output operands. */
1914 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ')' ';'
1915 { stmt_count++;
1916 emit_line_note ($<filename>-1, $<lineno>0);
1917 c_expand_asm_operands ($4, $6, NULL_TREE, NULL_TREE,
1918 $2 == ridpointers[(int)RID_VOLATILE],
1919 input_filename, lineno); }
1920 /* This is the case with input operands as well. */
1921 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':' asm_operands ')' ';'
1922 { stmt_count++;
1923 emit_line_note ($<filename>-1, $<lineno>0);
1924 c_expand_asm_operands ($4, $6, $8, NULL_TREE,
1925 $2 == ridpointers[(int)RID_VOLATILE],
1926 input_filename, lineno); }
1927 /* This is the case with clobbered registers as well. */
1928 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':'
1929 asm_operands ':' asm_clobbers ')' ';'
1930 { stmt_count++;
1931 emit_line_note ($<filename>-1, $<lineno>0);
1932 c_expand_asm_operands ($4, $6, $8, $10,
1933 $2 == ridpointers[(int)RID_VOLATILE],
1934 input_filename, lineno); }
1935 | GOTO identifier ';'
1936 { tree decl;
1937 stmt_count++;
1938 emit_line_note ($<filename>-1, $<lineno>0);
1939 decl = lookup_label ($2);
1940 if (decl != 0)
1942 TREE_USED (decl) = 1;
1943 expand_goto (decl);
1946 | GOTO '*' expr ';'
1947 { if (pedantic)
1948 pedwarn ("ANSI C forbids `goto *expr;'");
1949 stmt_count++;
1950 emit_line_note ($<filename>-1, $<lineno>0);
1951 expand_computed_goto (convert (ptr_type_node, $3)); }
1952 | ';'
1955 all_iter_stmt:
1956 all_iter_stmt_simple
1957 /* | all_iter_stmt_with_decl */
1960 all_iter_stmt_simple:
1961 FOR '(' primary ')'
1963 /* The value returned by this action is */
1964 /* 1 if everything is OK */
1965 /* 0 in case of error or already bound iterator */
1967 $<itype>$ = 0;
1968 if (TREE_CODE ($3) != VAR_DECL)
1969 error ("invalid `for (ITERATOR)' syntax");
1970 else if (! ITERATOR_P ($3))
1971 error ("`%s' is not an iterator",
1972 IDENTIFIER_POINTER (DECL_NAME ($3)));
1973 else if (ITERATOR_BOUND_P ($3))
1974 error ("`for (%s)' inside expansion of same iterator",
1975 IDENTIFIER_POINTER (DECL_NAME ($3)));
1976 else
1978 $<itype>$ = 1;
1979 iterator_for_loop_start ($3);
1982 lineno_labeled_stmt
1984 if ($<itype>5)
1985 iterator_for_loop_end ($3);
1988 /* This really should allow any kind of declaration,
1989 for generality. Fix it before turning it back on.
1991 all_iter_stmt_with_decl:
1992 FOR '(' ITERATOR pushlevel setspecs iterator_spec ')'
1994 */ /* The value returned by this action is */
1995 /* 1 if everything is OK */
1996 /* 0 in case of error or already bound iterator */
1998 iterator_for_loop_start ($6);
2000 lineno_labeled_stmt
2002 iterator_for_loop_end ($6);
2003 emit_line_note (input_filename, lineno);
2004 expand_end_bindings (getdecls (), 1, 0);
2005 $<ttype>$ = poplevel (1, 1, 0);
2006 if (yychar == CONSTANT || yychar == STRING)
2007 pop_momentary_nofree ();
2008 else
2009 pop_momentary ();
2013 /* Any kind of label, including jump labels and case labels.
2014 ANSI C accepts labels only before statements, but we allow them
2015 also at the end of a compound statement. */
2017 label: CASE expr_no_commas ':'
2018 { register tree value = check_case_value ($2);
2019 register tree label
2020 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
2022 stmt_count++;
2024 if (value != error_mark_node)
2026 tree duplicate;
2027 int success = pushcase (value, convert_and_check,
2028 label, &duplicate);
2029 if (success == 1)
2030 error ("case label not within a switch statement");
2031 else if (success == 2)
2033 error ("duplicate case value");
2034 error_with_decl (duplicate, "this is the first entry for that value");
2036 else if (success == 3)
2037 warning ("case value out of range");
2038 else if (success == 5)
2039 error ("case label within scope of cleanup or variable array");
2041 position_after_white_space (); }
2042 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
2043 { register tree value1 = check_case_value ($2);
2044 register tree value2 = check_case_value ($4);
2045 register tree label
2046 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
2048 if (pedantic)
2049 pedwarn ("ANSI C forbids case ranges");
2050 stmt_count++;
2052 if (value1 != error_mark_node && value2 != error_mark_node)
2054 tree duplicate;
2055 int success = pushcase_range (value1, value2,
2056 convert_and_check, label,
2057 &duplicate);
2058 if (success == 1)
2059 error ("case label not within a switch statement");
2060 else if (success == 2)
2062 error ("duplicate case value");
2063 error_with_decl (duplicate, "this is the first entry for that value");
2065 else if (success == 3)
2066 warning ("case value out of range");
2067 else if (success == 4)
2068 warning ("empty case range");
2069 else if (success == 5)
2070 error ("case label within scope of cleanup or variable array");
2072 position_after_white_space (); }
2073 | DEFAULT ':'
2075 tree duplicate;
2076 register tree label
2077 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
2078 int success = pushcase (NULL_TREE, 0, label, &duplicate);
2079 stmt_count++;
2080 if (success == 1)
2081 error ("default label not within a switch statement");
2082 else if (success == 2)
2084 error ("multiple default labels in one switch");
2085 error_with_decl (duplicate, "this is the first default label");
2087 position_after_white_space (); }
2088 | identifier ':'
2089 { tree label = define_label (input_filename, lineno, $1);
2090 stmt_count++;
2091 emit_nop ();
2092 if (label)
2093 expand_label (label);
2094 position_after_white_space (); }
2097 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
2099 maybe_type_qual:
2100 /* empty */
2101 { emit_line_note (input_filename, lineno);
2102 $$ = NULL_TREE; }
2103 | TYPE_QUAL
2104 { emit_line_note (input_filename, lineno); }
2107 xexpr:
2108 /* empty */
2109 { $$ = NULL_TREE; }
2110 | expr
2113 /* These are the operands other than the first string and colon
2114 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
2115 asm_operands: /* empty */
2116 { $$ = NULL_TREE; }
2117 | nonnull_asm_operands
2120 nonnull_asm_operands:
2121 asm_operand
2122 | nonnull_asm_operands ',' asm_operand
2123 { $$ = chainon ($1, $3); }
2126 asm_operand:
2127 STRING '(' expr ')'
2128 { $$ = build_tree_list ($1, $3); }
2131 asm_clobbers:
2132 string
2133 { $$ = tree_cons (NULL_TREE, combine_strings ($1), NULL_TREE); }
2134 | asm_clobbers ',' string
2135 { $$ = tree_cons (NULL_TREE, combine_strings ($3), $1); }
2138 /* This is what appears inside the parens in a function declarator.
2139 Its value is a list of ..._TYPE nodes. */
2140 parmlist:
2141 { pushlevel (0);
2142 clear_parm_order ();
2143 declare_parm_level (0); }
2144 parmlist_1
2145 { $$ = $2;
2146 parmlist_tags_warning ();
2147 poplevel (0, 0, 0); }
2150 parmlist_1:
2151 parmlist_2 ')'
2152 | parms ';'
2153 { tree parm;
2154 if (pedantic)
2155 pedwarn ("ANSI C forbids forward parameter declarations");
2156 /* Mark the forward decls as such. */
2157 for (parm = getdecls (); parm; parm = TREE_CHAIN (parm))
2158 TREE_ASM_WRITTEN (parm) = 1;
2159 clear_parm_order (); }
2160 parmlist_1
2161 { $$ = $4; }
2162 | error ')'
2163 { $$ = tree_cons (NULL_TREE, NULL_TREE, NULL_TREE); }
2166 /* This is what appears inside the parens in a function declarator.
2167 Is value is represented in the format that grokdeclarator expects. */
2168 parmlist_2: /* empty */
2169 { $$ = get_parm_info (0); }
2170 | ELLIPSIS
2171 { $$ = get_parm_info (0);
2172 /* Gcc used to allow this as an extension. However, it does
2173 not work for all targets, and thus has been disabled.
2174 Also, since func (...) and func () are indistinguishable,
2175 it caused problems with the code in expand_builtin which
2176 tries to verify that BUILT_IN_NEXT_ARG is being used
2177 correctly. */
2178 error ("ANSI C requires a named argument before `...'");
2180 | parms
2181 { $$ = get_parm_info (1); }
2182 | parms ',' ELLIPSIS
2183 { $$ = get_parm_info (0); }
2186 parms:
2187 parm
2188 { push_parm_decl ($1); }
2189 | parms ',' parm
2190 { push_parm_decl ($3); }
2193 /* A single parameter declaration or parameter type name,
2194 as found in a parmlist. */
2195 parm:
2196 typed_declspecs setspecs parm_declarator maybe_attribute
2197 { $$ = build_tree_list (build_tree_list (current_declspecs,
2198 $3),
2199 build_tree_list (prefix_attributes,
2200 $4));
2201 current_declspecs = TREE_VALUE (declspec_stack);
2202 prefix_attributes = TREE_PURPOSE (declspec_stack);
2203 declspec_stack = TREE_CHAIN (declspec_stack);
2204 resume_momentary ($2); }
2205 | typed_declspecs setspecs notype_declarator maybe_attribute
2206 { $$ = build_tree_list (build_tree_list (current_declspecs,
2207 $3),
2208 build_tree_list (prefix_attributes,
2209 $4));
2210 current_declspecs = TREE_VALUE (declspec_stack);
2211 prefix_attributes = TREE_PURPOSE (declspec_stack);
2212 declspec_stack = TREE_CHAIN (declspec_stack);
2213 resume_momentary ($2); }
2214 | typed_declspecs setspecs absdcl maybe_attribute
2215 { $$ = build_tree_list (build_tree_list (current_declspecs,
2216 $3),
2217 build_tree_list (prefix_attributes,
2218 $4));
2219 current_declspecs = TREE_VALUE (declspec_stack);
2220 prefix_attributes = TREE_PURPOSE (declspec_stack);
2221 declspec_stack = TREE_CHAIN (declspec_stack);
2222 resume_momentary ($2); }
2223 | declmods setspecs notype_declarator maybe_attribute
2224 { $$ = build_tree_list (build_tree_list (current_declspecs,
2225 $3),
2226 build_tree_list (prefix_attributes,
2227 $4));
2228 current_declspecs = TREE_VALUE (declspec_stack);
2229 prefix_attributes = TREE_PURPOSE (declspec_stack);
2230 declspec_stack = TREE_CHAIN (declspec_stack);
2231 resume_momentary ($2); }
2233 | declmods setspecs absdcl maybe_attribute
2234 { $$ = build_tree_list (build_tree_list (current_declspecs,
2235 $3),
2236 build_tree_list (prefix_attributes,
2237 $4));
2238 current_declspecs = TREE_VALUE (declspec_stack);
2239 prefix_attributes = TREE_PURPOSE (declspec_stack);
2240 declspec_stack = TREE_CHAIN (declspec_stack);
2241 resume_momentary ($2); }
2244 /* This is used in a function definition
2245 where either a parmlist or an identifier list is ok.
2246 Its value is a list of ..._TYPE nodes or a list of identifiers. */
2247 parmlist_or_identifiers:
2248 { pushlevel (0);
2249 clear_parm_order ();
2250 declare_parm_level (1); }
2251 parmlist_or_identifiers_1
2252 { $$ = $2;
2253 parmlist_tags_warning ();
2254 poplevel (0, 0, 0); }
2257 parmlist_or_identifiers_1:
2258 parmlist_1
2259 | identifiers ')'
2260 { tree t;
2261 for (t = $1; t; t = TREE_CHAIN (t))
2262 if (TREE_VALUE (t) == NULL_TREE)
2263 error ("`...' in old-style identifier list");
2264 $$ = tree_cons (NULL_TREE, NULL_TREE, $1); }
2267 /* A nonempty list of identifiers. */
2268 identifiers:
2269 IDENTIFIER
2270 { $$ = build_tree_list (NULL_TREE, $1); }
2271 | identifiers ',' IDENTIFIER
2272 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2275 /* A nonempty list of identifiers, including typenames. */
2276 identifiers_or_typenames:
2277 identifier
2278 { $$ = build_tree_list (NULL_TREE, $1); }
2279 | identifiers_or_typenames ',' identifier
2280 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2283 extension:
2284 EXTENSION
2285 { $<itype>$ = pedantic;
2286 pedantic = 0; }
2289 /* Objective-C productions. */
2291 objcdef:
2292 classdef
2293 | classdecl
2294 | aliasdecl
2295 | protocoldef
2296 | methoddef
2297 | END
2299 if (objc_implementation_context)
2301 finish_class (objc_implementation_context);
2302 objc_ivar_chain = NULL_TREE;
2303 objc_implementation_context = NULL_TREE;
2305 else
2306 warning ("`@end' must appear in an implementation context");
2310 /* A nonempty list of identifiers. */
2311 identifier_list:
2312 identifier
2313 { $$ = build_tree_list (NULL_TREE, $1); }
2314 | identifier_list ',' identifier
2315 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2318 classdecl:
2319 CLASS identifier_list ';'
2321 objc_declare_class ($2);
2324 aliasdecl:
2325 ALIAS identifier identifier ';'
2327 objc_declare_alias ($2, $3);
2330 classdef:
2331 INTERFACE identifier protocolrefs '{'
2333 objc_interface_context = objc_ivar_context
2334 = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, $3);
2335 objc_public_flag = 0;
2337 ivar_decl_list '}'
2339 continue_class (objc_interface_context);
2341 methodprotolist
2344 finish_class (objc_interface_context);
2345 objc_interface_context = NULL_TREE;
2348 | INTERFACE identifier protocolrefs
2350 objc_interface_context
2351 = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, $3);
2352 continue_class (objc_interface_context);
2354 methodprotolist
2357 finish_class (objc_interface_context);
2358 objc_interface_context = NULL_TREE;
2361 | INTERFACE identifier ':' identifier protocolrefs '{'
2363 objc_interface_context = objc_ivar_context
2364 = start_class (CLASS_INTERFACE_TYPE, $2, $4, $5);
2365 objc_public_flag = 0;
2367 ivar_decl_list '}'
2369 continue_class (objc_interface_context);
2371 methodprotolist
2374 finish_class (objc_interface_context);
2375 objc_interface_context = NULL_TREE;
2378 | INTERFACE identifier ':' identifier protocolrefs
2380 objc_interface_context
2381 = start_class (CLASS_INTERFACE_TYPE, $2, $4, $5);
2382 continue_class (objc_interface_context);
2384 methodprotolist
2387 finish_class (objc_interface_context);
2388 objc_interface_context = NULL_TREE;
2391 | IMPLEMENTATION identifier '{'
2393 objc_implementation_context = objc_ivar_context
2394 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, NULL_TREE, NULL_TREE);
2395 objc_public_flag = 0;
2397 ivar_decl_list '}'
2399 objc_ivar_chain
2400 = continue_class (objc_implementation_context);
2403 | IMPLEMENTATION identifier
2405 objc_implementation_context
2406 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, NULL_TREE, NULL_TREE);
2407 objc_ivar_chain
2408 = continue_class (objc_implementation_context);
2411 | IMPLEMENTATION identifier ':' identifier '{'
2413 objc_implementation_context = objc_ivar_context
2414 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2415 objc_public_flag = 0;
2417 ivar_decl_list '}'
2419 objc_ivar_chain
2420 = continue_class (objc_implementation_context);
2423 | IMPLEMENTATION identifier ':' identifier
2425 objc_implementation_context
2426 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2427 objc_ivar_chain
2428 = continue_class (objc_implementation_context);
2431 | INTERFACE identifier '(' identifier ')' protocolrefs
2433 objc_interface_context
2434 = start_class (CATEGORY_INTERFACE_TYPE, $2, $4, $6);
2435 continue_class (objc_interface_context);
2437 methodprotolist
2440 finish_class (objc_interface_context);
2441 objc_interface_context = NULL_TREE;
2444 | IMPLEMENTATION identifier '(' identifier ')'
2446 objc_implementation_context
2447 = start_class (CATEGORY_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2448 objc_ivar_chain
2449 = continue_class (objc_implementation_context);
2453 protocoldef:
2454 PROTOCOL identifier protocolrefs
2456 remember_protocol_qualifiers ();
2457 objc_interface_context
2458 = start_protocol(PROTOCOL_INTERFACE_TYPE, $2, $3);
2460 methodprotolist END
2462 forget_protocol_qualifiers();
2463 finish_protocol(objc_interface_context);
2464 objc_interface_context = NULL_TREE;
2468 protocolrefs:
2469 /* empty */
2471 $$ = NULL_TREE;
2473 | non_empty_protocolrefs
2476 non_empty_protocolrefs:
2477 ARITHCOMPARE identifier_list ARITHCOMPARE
2479 if ($1 == LT_EXPR && $3 == GT_EXPR)
2480 $$ = $2;
2481 else
2482 YYERROR1;
2486 ivar_decl_list:
2487 ivar_decl_list visibility_spec ivar_decls
2488 | ivar_decls
2491 visibility_spec:
2492 PRIVATE { objc_public_flag = 2; }
2493 | PROTECTED { objc_public_flag = 0; }
2494 | PUBLIC { objc_public_flag = 1; }
2497 ivar_decls:
2498 /* empty */
2500 $$ = NULL_TREE;
2502 | ivar_decls ivar_decl ';'
2503 | ivar_decls ';'
2505 if (pedantic)
2506 pedwarn ("extra semicolon in struct or union specified");
2511 /* There is a shift-reduce conflict here, because `components' may
2512 start with a `typename'. It happens that shifting (the default resolution)
2513 does the right thing, because it treats the `typename' as part of
2514 a `typed_typespecs'.
2516 It is possible that this same technique would allow the distinction
2517 between `notype_initdecls' and `initdecls' to be eliminated.
2518 But I am being cautious and not trying it. */
2520 ivar_decl:
2521 typed_typespecs setspecs ivars
2522 { $$ = $3;
2523 current_declspecs = TREE_VALUE (declspec_stack);
2524 prefix_attributes = TREE_PURPOSE (declspec_stack);
2525 declspec_stack = TREE_CHAIN (declspec_stack);
2526 resume_momentary ($2); }
2527 | nonempty_type_quals setspecs ivars
2528 { $$ = $3;
2529 current_declspecs = TREE_VALUE (declspec_stack);
2530 prefix_attributes = TREE_PURPOSE (declspec_stack);
2531 declspec_stack = TREE_CHAIN (declspec_stack);
2532 resume_momentary ($2); }
2533 | error
2534 { $$ = NULL_TREE; }
2537 ivars:
2538 /* empty */
2539 { $$ = NULL_TREE; }
2540 | ivar_declarator
2541 | ivars ',' ivar_declarator
2544 ivar_declarator:
2545 declarator
2547 $$ = add_instance_variable (objc_ivar_context,
2548 objc_public_flag,
2549 $1, current_declspecs,
2550 NULL_TREE);
2552 | declarator ':' expr_no_commas
2554 $$ = add_instance_variable (objc_ivar_context,
2555 objc_public_flag,
2556 $1, current_declspecs, $3);
2558 | ':' expr_no_commas
2560 $$ = add_instance_variable (objc_ivar_context,
2561 objc_public_flag,
2562 NULL_TREE,
2563 current_declspecs, $2);
2567 methoddef:
2570 remember_protocol_qualifiers ();
2571 if (objc_implementation_context)
2572 objc_inherit_code = CLASS_METHOD_DECL;
2573 else
2574 fatal ("method definition not in class context");
2576 methoddecl
2578 forget_protocol_qualifiers ();
2579 add_class_method (objc_implementation_context, $3);
2580 start_method_def ($3);
2581 objc_method_context = $3;
2583 optarglist
2585 continue_method_def ();
2587 compstmt_or_error
2589 finish_method_def ();
2590 objc_method_context = NULL_TREE;
2593 | '-'
2595 remember_protocol_qualifiers ();
2596 if (objc_implementation_context)
2597 objc_inherit_code = INSTANCE_METHOD_DECL;
2598 else
2599 fatal ("method definition not in class context");
2601 methoddecl
2603 forget_protocol_qualifiers ();
2604 add_instance_method (objc_implementation_context, $3);
2605 start_method_def ($3);
2606 objc_method_context = $3;
2608 optarglist
2610 continue_method_def ();
2612 compstmt_or_error
2614 finish_method_def ();
2615 objc_method_context = NULL_TREE;
2619 /* the reason for the strange actions in this rule
2620 is so that notype_initdecls when reached via datadef
2621 can find a valid list of type and sc specs in $0. */
2623 methodprotolist:
2624 /* empty */
2625 | {$<ttype>$ = NULL_TREE; } methodprotolist2
2628 methodprotolist2: /* eliminates a shift/reduce conflict */
2629 methodproto
2630 | datadef
2631 | methodprotolist2 methodproto
2632 | methodprotolist2 {$<ttype>$ = NULL_TREE; } datadef
2635 semi_or_error:
2637 | error
2640 methodproto:
2643 /* Remember protocol qualifiers in prototypes. */
2644 remember_protocol_qualifiers ();
2645 objc_inherit_code = CLASS_METHOD_DECL;
2647 methoddecl
2649 /* Forget protocol qualifiers here. */
2650 forget_protocol_qualifiers ();
2651 add_class_method (objc_interface_context, $3);
2653 semi_or_error
2655 | '-'
2657 /* Remember protocol qualifiers in prototypes. */
2658 remember_protocol_qualifiers ();
2659 objc_inherit_code = INSTANCE_METHOD_DECL;
2661 methoddecl
2663 /* Forget protocol qualifiers here. */
2664 forget_protocol_qualifiers ();
2665 add_instance_method (objc_interface_context, $3);
2667 semi_or_error
2670 methoddecl:
2671 '(' typename ')' unaryselector
2673 $$ = build_method_decl (objc_inherit_code, $2, $4, NULL_TREE);
2676 | unaryselector
2678 $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, NULL_TREE);
2681 | '(' typename ')' keywordselector optparmlist
2683 $$ = build_method_decl (objc_inherit_code, $2, $4, $5);
2686 | keywordselector optparmlist
2688 $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, $2);
2692 /* "optarglist" assumes that start_method_def has already been called...
2693 if it is not, the "xdecls" will not be placed in the proper scope */
2695 optarglist:
2696 /* empty */
2697 | ';' myxdecls
2700 /* to get around the following situation: "int foo (int a) int b; {}" that
2701 is synthesized when parsing "- a:a b:b; id c; id d; { ... }" */
2703 myxdecls:
2704 /* empty */
2705 | mydecls
2708 mydecls:
2709 mydecl
2710 | errstmt
2711 | mydecls mydecl
2712 | mydecl errstmt
2715 mydecl:
2716 typed_declspecs setspecs myparms ';'
2717 { current_declspecs = TREE_VALUE (declspec_stack);
2718 prefix_attributes = TREE_PURPOSE (declspec_stack);
2719 declspec_stack = TREE_CHAIN (declspec_stack);
2720 resume_momentary ($2); }
2721 | typed_declspecs ';'
2722 { shadow_tag ($1); }
2723 | declmods ';'
2724 { pedwarn ("empty declaration"); }
2727 myparms:
2728 myparm
2729 { push_parm_decl ($1); }
2730 | myparms ',' myparm
2731 { push_parm_decl ($3); }
2734 /* A single parameter declaration or parameter type name,
2735 as found in a parmlist. DOES NOT ALLOW AN INITIALIZER OR ASMSPEC */
2737 myparm:
2738 parm_declarator maybe_attribute
2739 { $$ = build_tree_list (build_tree_list (current_declspecs,
2740 $1),
2741 build_tree_list (prefix_attributes,
2742 $2)); }
2743 | notype_declarator maybe_attribute
2744 { $$ = build_tree_list (build_tree_list (current_declspecs,
2745 $1),
2746 build_tree_list (prefix_attributes,
2747 $2)); }
2748 | absdcl maybe_attribute
2749 { $$ = build_tree_list (build_tree_list (current_declspecs,
2750 $1),
2751 build_tree_list (prefix_attributes,
2752 $2)); }
2755 optparmlist:
2756 /* empty */
2758 $$ = NULL_TREE;
2760 | ',' ELLIPSIS
2762 /* oh what a kludge! */
2763 $$ = (tree)1;
2765 | ','
2767 pushlevel (0);
2769 parmlist_2
2771 /* returns a tree list node generated by get_parm_info */
2772 $$ = $3;
2773 poplevel (0, 0, 0);
2777 unaryselector:
2778 selector
2781 keywordselector:
2782 keyworddecl
2784 | keywordselector keyworddecl
2786 $$ = chainon ($1, $2);
2790 selector:
2791 IDENTIFIER
2792 | TYPENAME
2793 | OBJECTNAME
2794 | reservedwords
2797 reservedwords:
2798 ENUM { $$ = get_identifier (token_buffer); }
2799 | STRUCT { $$ = get_identifier (token_buffer); }
2800 | UNION { $$ = get_identifier (token_buffer); }
2801 | IF { $$ = get_identifier (token_buffer); }
2802 | ELSE { $$ = get_identifier (token_buffer); }
2803 | WHILE { $$ = get_identifier (token_buffer); }
2804 | DO { $$ = get_identifier (token_buffer); }
2805 | FOR { $$ = get_identifier (token_buffer); }
2806 | SWITCH { $$ = get_identifier (token_buffer); }
2807 | CASE { $$ = get_identifier (token_buffer); }
2808 | DEFAULT { $$ = get_identifier (token_buffer); }
2809 | BREAK { $$ = get_identifier (token_buffer); }
2810 | CONTINUE { $$ = get_identifier (token_buffer); }
2811 | RETURN { $$ = get_identifier (token_buffer); }
2812 | GOTO { $$ = get_identifier (token_buffer); }
2813 | ASM_KEYWORD { $$ = get_identifier (token_buffer); }
2814 | SIZEOF { $$ = get_identifier (token_buffer); }
2815 | TYPEOF { $$ = get_identifier (token_buffer); }
2816 | ALIGNOF { $$ = get_identifier (token_buffer); }
2817 | TYPESPEC | TYPE_QUAL
2820 keyworddecl:
2821 selector ':' '(' typename ')' identifier
2823 $$ = build_keyword_decl ($1, $4, $6);
2826 | selector ':' identifier
2828 $$ = build_keyword_decl ($1, NULL_TREE, $3);
2831 | ':' '(' typename ')' identifier
2833 $$ = build_keyword_decl (NULL_TREE, $3, $5);
2836 | ':' identifier
2838 $$ = build_keyword_decl (NULL_TREE, NULL_TREE, $2);
2842 messageargs:
2843 selector
2844 | keywordarglist
2847 keywordarglist:
2848 keywordarg
2849 | keywordarglist keywordarg
2851 $$ = chainon ($1, $2);
2856 keywordexpr:
2857 nonnull_exprlist
2859 if (TREE_CHAIN ($1) == NULL_TREE)
2860 /* just return the expr., remove a level of indirection */
2861 $$ = TREE_VALUE ($1);
2862 else
2863 /* we have a comma expr., we will collapse later */
2864 $$ = $1;
2868 keywordarg:
2869 selector ':' keywordexpr
2871 $$ = build_tree_list ($1, $3);
2873 | ':' keywordexpr
2875 $$ = build_tree_list (NULL_TREE, $2);
2879 receiver:
2880 expr
2881 | CLASSNAME
2883 $$ = get_class_reference ($1);
2887 objcmessageexpr:
2889 { objc_receiver_context = 1; }
2890 receiver
2891 { objc_receiver_context = 0; }
2892 messageargs ']'
2894 $$ = build_tree_list ($3, $5);
2898 selectorarg:
2899 selector
2900 | keywordnamelist
2903 keywordnamelist:
2904 keywordname
2905 | keywordnamelist keywordname
2907 $$ = chainon ($1, $2);
2911 keywordname:
2912 selector ':'
2914 $$ = build_tree_list ($1, NULL_TREE);
2916 | ':'
2918 $$ = build_tree_list (NULL_TREE, NULL_TREE);
2922 objcselectorexpr:
2923 SELECTOR '(' selectorarg ')'
2925 $$ = $3;
2929 objcprotocolexpr:
2930 PROTOCOL '(' identifier ')'
2932 $$ = $3;
2936 /* extension to support C-structures in the archiver */
2938 objcencodeexpr:
2939 ENCODE '(' typename ')'
2941 $$ = groktypename ($3);