Add bugs corresponding to PRs 16243 and 16245
[official-gcc.git] / gcc / objc / objc-parse.y
blob8f595654ce74e011893e4cc556d4834881f92e05
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"
44 #include "toplev.h"
46 #ifdef MULTIBYTE_CHARS
47 #include <locale.h>
48 #endif
50 #include "objc-act.h"
52 /* Since parsers are distinct for each language, put the language string
53 definition here. */
54 char *language_string = "GNU Obj-C";
56 /* Like YYERROR but do call yyerror. */
57 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
59 /* Cause the `yydebug' variable to be defined. */
60 #define YYDEBUG 1
63 %start program
65 %union {long itype; tree ttype; enum tree_code code;
66 char *filename; int lineno; int ends_in_label; }
68 /* All identifiers that are not reserved words
69 and are not declared typedefs in the current block */
70 %token IDENTIFIER
72 /* All identifiers that are declared typedefs in the current block.
73 In some contexts, they are treated just like IDENTIFIER,
74 but they can also serve as typespecs in declarations. */
75 %token TYPENAME
77 /* Reserved words that specify storage class.
78 yylval contains an IDENTIFIER_NODE which indicates which one. */
79 %token SCSPEC
81 /* Reserved words that specify type.
82 yylval contains an IDENTIFIER_NODE which indicates which one. */
83 %token TYPESPEC
85 /* Reserved words that qualify type: "const" or "volatile".
86 yylval contains an IDENTIFIER_NODE which indicates which one. */
87 %token TYPE_QUAL
89 /* Character or numeric constants.
90 yylval is the node for the constant. */
91 %token CONSTANT
93 /* String constants in raw form.
94 yylval is a STRING_CST node. */
95 %token STRING
97 /* "...", used for functions with variable arglists. */
98 %token ELLIPSIS
100 /* the reserved words */
101 /* SCO include files test "ASM", so use something else. */
102 %token SIZEOF ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
103 %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD TYPEOF ALIGNOF
104 %token ATTRIBUTE EXTENSION LABEL
105 %token REALPART IMAGPART
107 /* Add precedence rules to solve dangling else s/r conflict */
108 %nonassoc IF
109 %nonassoc ELSE
111 /* Define the operator tokens and their precedences.
112 The value is an integer because, if used, it is the tree code
113 to use in the expression made from the operator. */
115 %right <code> ASSIGN '='
116 %right <code> '?' ':'
117 %left <code> OROR
118 %left <code> ANDAND
119 %left <code> '|'
120 %left <code> '^'
121 %left <code> '&'
122 %left <code> EQCOMPARE
123 %left <code> ARITHCOMPARE
124 %left <code> LSHIFT RSHIFT
125 %left <code> '+' '-'
126 %left <code> '*' '/' '%'
127 %right <code> UNARY PLUSPLUS MINUSMINUS
128 %left HYPERUNARY
129 %left <code> POINTSAT '.' '(' '['
131 /* The Objective-C keywords. These are included in C and in
132 Objective C, so that the token codes are the same in both. */
133 %token INTERFACE IMPLEMENTATION END SELECTOR DEFS ENCODE
134 %token CLASSNAME PUBLIC PRIVATE PROTECTED PROTOCOL OBJECTNAME CLASS ALIAS
136 /* Objective-C string constants in raw form.
137 yylval is an OBJC_STRING_CST node. */
138 %token OBJC_STRING
141 %type <code> unop
143 %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist exprlist
144 %type <ttype> expr_no_commas cast_expr unary_expr primary string STRING
145 %type <ttype> typed_declspecs reserved_declspecs
146 %type <ttype> typed_typespecs reserved_typespecquals
147 %type <ttype> declmods typespec typespecqual_reserved
148 %type <ttype> typed_declspecs_no_prefix_attr reserved_declspecs_no_prefix_attr
149 %type <ttype> declmods_no_prefix_attr
150 %type <ttype> SCSPEC TYPESPEC TYPE_QUAL nonempty_type_quals maybe_type_qual
151 %type <ttype> initdecls notype_initdecls initdcl notype_initdcl
152 %type <ttype> init maybeasm
153 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
154 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
155 %type <ttype> any_word
157 %type <ttype> compstmt
159 %type <ttype> declarator
160 %type <ttype> notype_declarator after_type_declarator
161 %type <ttype> parm_declarator
163 %type <ttype> structsp component_decl_list component_decl_list2
164 %type <ttype> component_decl components component_declarator
165 %type <ttype> enumlist enumerator
166 %type <ttype> typename absdcl absdcl1 type_quals
167 %type <ttype> xexpr parms parm identifiers
169 %type <ttype> parmlist parmlist_1 parmlist_2
170 %type <ttype> parmlist_or_identifiers parmlist_or_identifiers_1
171 %type <ttype> identifiers_or_typenames
173 %type <itype> setspecs
175 %type <ends_in_label> lineno_stmt_or_label lineno_stmt_or_labels stmt_or_label
177 %type <filename> save_filename
178 %type <lineno> save_lineno
180 /* the Objective-C nonterminals */
182 %type <ttype> ivar_decl_list ivar_decls ivar_decl ivars ivar_declarator
183 %type <ttype> methoddecl unaryselector keywordselector selector
184 %type <ttype> keyworddecl receiver objcmessageexpr messageargs
185 %type <ttype> keywordexpr keywordarglist keywordarg
186 %type <ttype> myparms myparm optparmlist reservedwords objcselectorexpr
187 %type <ttype> selectorarg keywordnamelist keywordname objcencodeexpr
188 %type <ttype> objc_string non_empty_protocolrefs protocolrefs identifier_list objcprotocolexpr
190 %type <ttype> CLASSNAME OBJC_STRING OBJECTNAME
193 /* Number of statements (loosely speaking) and compound statements
194 seen so far. */
195 static int stmt_count;
196 static int compstmt_count;
198 /* Input file and line number of the end of the body of last simple_if;
199 used by the stmt-rule immediately after simple_if returns. */
200 static char *if_stmt_file;
201 static int if_stmt_line;
203 /* List of types and structure classes of the current declaration. */
204 static tree current_declspecs = NULL_TREE;
205 static tree prefix_attributes = NULL_TREE;
207 /* Stack of saved values of current_declspecs and prefix_attributes. */
208 static tree declspec_stack;
210 /* 1 if we explained undeclared var errors. */
211 static int undeclared_variable_notice;
213 /* Objective-C specific information */
215 tree objc_interface_context;
216 tree objc_implementation_context;
217 tree objc_method_context;
218 tree objc_ivar_chain;
219 tree objc_ivar_context;
220 enum tree_code objc_inherit_code;
221 int objc_receiver_context;
222 int objc_public_flag;
225 /* Tell yyparse how to print a token's value, if yydebug is set. */
227 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
228 extern void yyprint PROTO ((FILE *, int, YYSTYPE));
232 program: /* empty */
233 { if (pedantic)
234 pedwarn ("ANSI C forbids an empty source file");
235 finish_file ();
237 | extdefs
239 /* In case there were missing closebraces,
240 get us back to the global binding level. */
241 while (! global_bindings_p ())
242 poplevel (0, 0, 0);
243 finish_file ();
247 /* the reason for the strange actions in this rule
248 is so that notype_initdecls when reached via datadef
249 can find a valid list of type and sc specs in $0. */
251 extdefs:
252 {$<ttype>$ = NULL_TREE; } extdef
253 | extdefs {$<ttype>$ = NULL_TREE; } extdef
256 extdef:
257 fndef
258 | datadef
259 | objcdef
260 | ASM_KEYWORD '(' expr ')' ';'
261 { STRIP_NOPS ($3);
262 if ((TREE_CODE ($3) == ADDR_EXPR
263 && TREE_CODE (TREE_OPERAND ($3, 0)) == STRING_CST)
264 || TREE_CODE ($3) == STRING_CST)
265 assemble_asm ($3);
266 else
267 error ("argument of `asm' is not a constant string"); }
268 | extension extdef
269 { pedantic = $<itype>1; }
272 datadef:
273 setspecs notype_initdecls ';'
274 { if (pedantic)
275 error ("ANSI C forbids data definition with no type or storage class");
276 else if (!flag_traditional)
277 warning ("data definition has no type or storage class");
279 current_declspecs = TREE_VALUE (declspec_stack);
280 prefix_attributes = TREE_PURPOSE (declspec_stack);
281 declspec_stack = TREE_CHAIN (declspec_stack);
282 resume_momentary ($1); }
283 | declmods setspecs notype_initdecls ';'
284 { current_declspecs = TREE_VALUE (declspec_stack);
285 prefix_attributes = TREE_PURPOSE (declspec_stack);
286 declspec_stack = TREE_CHAIN (declspec_stack);
287 resume_momentary ($2); }
288 | typed_declspecs setspecs initdecls ';'
289 { current_declspecs = TREE_VALUE (declspec_stack);
290 prefix_attributes = TREE_PURPOSE (declspec_stack);
291 declspec_stack = TREE_CHAIN (declspec_stack);
292 resume_momentary ($2); }
293 | declmods ';'
294 { pedwarn ("empty declaration"); }
295 | typed_declspecs ';'
296 { shadow_tag ($1); }
297 | error ';'
298 | error '}'
299 | ';'
300 { if (pedantic)
301 pedwarn ("ANSI C does not allow extra `;' outside of a function"); }
304 fndef:
305 typed_declspecs setspecs declarator
306 { if (! start_function (current_declspecs, $3,
307 prefix_attributes, NULL_TREE, 0))
308 YYERROR1;
309 reinit_parse_for_function (); }
310 old_style_parm_decls
311 { store_parm_decls (); }
312 compstmt_or_error
313 { finish_function (0);
314 current_declspecs = TREE_VALUE (declspec_stack);
315 prefix_attributes = TREE_PURPOSE (declspec_stack);
316 declspec_stack = TREE_CHAIN (declspec_stack);
317 resume_momentary ($2); }
318 | typed_declspecs setspecs declarator error
319 { current_declspecs = TREE_VALUE (declspec_stack);
320 prefix_attributes = TREE_PURPOSE (declspec_stack);
321 declspec_stack = TREE_CHAIN (declspec_stack);
322 resume_momentary ($2); }
323 | declmods setspecs notype_declarator
324 { if (! start_function (current_declspecs, $3,
325 prefix_attributes, NULL_TREE, 0))
326 YYERROR1;
327 reinit_parse_for_function (); }
328 old_style_parm_decls
329 { store_parm_decls (); }
330 compstmt_or_error
331 { finish_function (0);
332 current_declspecs = TREE_VALUE (declspec_stack);
333 prefix_attributes = TREE_PURPOSE (declspec_stack);
334 declspec_stack = TREE_CHAIN (declspec_stack);
335 resume_momentary ($2); }
336 | declmods setspecs notype_declarator error
337 { current_declspecs = TREE_VALUE (declspec_stack);
338 prefix_attributes = TREE_PURPOSE (declspec_stack);
339 declspec_stack = TREE_CHAIN (declspec_stack);
340 resume_momentary ($2); }
341 | setspecs notype_declarator
342 { if (! start_function (NULL_TREE, $2,
343 prefix_attributes, NULL_TREE, 0))
344 YYERROR1;
345 reinit_parse_for_function (); }
346 old_style_parm_decls
347 { store_parm_decls (); }
348 compstmt_or_error
349 { finish_function (0);
350 current_declspecs = TREE_VALUE (declspec_stack);
351 prefix_attributes = TREE_PURPOSE (declspec_stack);
352 declspec_stack = TREE_CHAIN (declspec_stack);
353 resume_momentary ($1); }
354 | setspecs notype_declarator error
355 { current_declspecs = TREE_VALUE (declspec_stack);
356 prefix_attributes = TREE_PURPOSE (declspec_stack);
357 declspec_stack = TREE_CHAIN (declspec_stack);
358 resume_momentary ($1); }
361 identifier:
362 IDENTIFIER
363 | TYPENAME
364 | OBJECTNAME
365 | CLASSNAME
368 unop: '&'
369 { $$ = ADDR_EXPR; }
370 | '-'
371 { $$ = NEGATE_EXPR; }
372 | '+'
373 { $$ = CONVERT_EXPR; }
374 | PLUSPLUS
375 { $$ = PREINCREMENT_EXPR; }
376 | MINUSMINUS
377 { $$ = PREDECREMENT_EXPR; }
378 | '~'
379 { $$ = BIT_NOT_EXPR; }
380 | '!'
381 { $$ = TRUTH_NOT_EXPR; }
384 expr: nonnull_exprlist
385 { $$ = build_compound_expr ($1); }
388 exprlist:
389 /* empty */
390 { $$ = NULL_TREE; }
391 | nonnull_exprlist
394 nonnull_exprlist:
395 expr_no_commas
396 { $$ = build_tree_list (NULL_TREE, $1); }
397 | nonnull_exprlist ',' expr_no_commas
398 { chainon ($1, build_tree_list (NULL_TREE, $3)); }
401 unary_expr:
402 primary
403 | '*' cast_expr %prec UNARY
404 { $$ = build_indirect_ref ($2, "unary *"); }
405 /* __extension__ turns off -pedantic for following primary. */
406 | extension cast_expr %prec UNARY
407 { $$ = $2;
408 pedantic = $<itype>1; }
409 | unop cast_expr %prec UNARY
410 { $$ = build_unary_op ($1, $2, 0);
411 overflow_warning ($$); }
412 /* Refer to the address of a label as a pointer. */
413 | ANDAND identifier
414 { tree label = lookup_label ($2);
415 if (pedantic)
416 pedwarn ("ANSI C forbids `&&'");
417 if (label == 0)
418 $$ = null_pointer_node;
419 else
421 TREE_USED (label) = 1;
422 $$ = build1 (ADDR_EXPR, ptr_type_node, label);
423 TREE_CONSTANT ($$) = 1;
426 /* This seems to be impossible on some machines, so let's turn it off.
427 You can use __builtin_next_arg to find the anonymous stack args.
428 | '&' ELLIPSIS
429 { tree types = TYPE_ARG_TYPES (TREE_TYPE (current_function_decl));
430 $$ = error_mark_node;
431 if (TREE_VALUE (tree_last (types)) == void_type_node)
432 error ("`&...' used in function with fixed number of arguments");
433 else
435 if (pedantic)
436 pedwarn ("ANSI C forbids `&...'");
437 $$ = tree_last (DECL_ARGUMENTS (current_function_decl));
438 $$ = build_unary_op (ADDR_EXPR, $$, 0);
441 | sizeof unary_expr %prec UNARY
442 { skip_evaluation--;
443 if (TREE_CODE ($2) == COMPONENT_REF
444 && DECL_C_BIT_FIELD (TREE_OPERAND ($2, 1)))
445 error ("`sizeof' applied to a bit-field");
446 $$ = c_sizeof (TREE_TYPE ($2)); }
447 | sizeof '(' typename ')' %prec HYPERUNARY
448 { skip_evaluation--;
449 $$ = c_sizeof (groktypename ($3)); }
450 | alignof unary_expr %prec UNARY
451 { skip_evaluation--;
452 $$ = c_alignof_expr ($2); }
453 | alignof '(' typename ')' %prec HYPERUNARY
454 { skip_evaluation--;
455 $$ = c_alignof (groktypename ($3)); }
456 | REALPART cast_expr %prec UNARY
457 { $$ = build_unary_op (REALPART_EXPR, $2, 0); }
458 | IMAGPART cast_expr %prec UNARY
459 { $$ = build_unary_op (IMAGPART_EXPR, $2, 0); }
462 sizeof:
463 SIZEOF { skip_evaluation++; }
466 alignof:
467 ALIGNOF { skip_evaluation++; }
470 cast_expr:
471 unary_expr
472 | '(' typename ')' cast_expr %prec UNARY
473 { tree type = groktypename ($2);
474 $$ = build_c_cast (type, $4); }
475 | '(' typename ')' '{'
476 { start_init (NULL_TREE, NULL, 0);
477 $2 = groktypename ($2);
478 really_start_incremental_init ($2); }
479 initlist_maybe_comma '}' %prec UNARY
480 { char *name;
481 tree result = pop_init_level (0);
482 tree type = $2;
483 finish_init ();
485 if (pedantic)
486 pedwarn ("ANSI C forbids constructor expressions");
487 if (TYPE_NAME (type) != 0)
489 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
490 name = IDENTIFIER_POINTER (TYPE_NAME (type));
491 else
492 name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
494 else
495 name = "";
496 $$ = result;
497 if (TREE_CODE (type) == ARRAY_TYPE && TYPE_SIZE (type) == 0)
499 int failure = complete_array_type (type, $$, 1);
500 if (failure)
501 abort ();
506 expr_no_commas:
507 cast_expr
508 | expr_no_commas '+' expr_no_commas
509 { $$ = parser_build_binary_op ($2, $1, $3); }
510 | expr_no_commas '-' expr_no_commas
511 { $$ = parser_build_binary_op ($2, $1, $3); }
512 | expr_no_commas '*' expr_no_commas
513 { $$ = parser_build_binary_op ($2, $1, $3); }
514 | expr_no_commas '/' expr_no_commas
515 { $$ = parser_build_binary_op ($2, $1, $3); }
516 | expr_no_commas '%' expr_no_commas
517 { $$ = parser_build_binary_op ($2, $1, $3); }
518 | expr_no_commas LSHIFT expr_no_commas
519 { $$ = parser_build_binary_op ($2, $1, $3); }
520 | expr_no_commas RSHIFT expr_no_commas
521 { $$ = parser_build_binary_op ($2, $1, $3); }
522 | expr_no_commas ARITHCOMPARE expr_no_commas
523 { $$ = parser_build_binary_op ($2, $1, $3); }
524 | expr_no_commas EQCOMPARE expr_no_commas
525 { $$ = parser_build_binary_op ($2, $1, $3); }
526 | expr_no_commas '&' expr_no_commas
527 { $$ = parser_build_binary_op ($2, $1, $3); }
528 | expr_no_commas '|' expr_no_commas
529 { $$ = parser_build_binary_op ($2, $1, $3); }
530 | expr_no_commas '^' expr_no_commas
531 { $$ = parser_build_binary_op ($2, $1, $3); }
532 | expr_no_commas ANDAND
533 { $1 = truthvalue_conversion (default_conversion ($1));
534 skip_evaluation += $1 == boolean_false_node; }
535 expr_no_commas
536 { skip_evaluation -= $1 == boolean_false_node;
537 $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $4); }
538 | expr_no_commas OROR
539 { $1 = truthvalue_conversion (default_conversion ($1));
540 skip_evaluation += $1 == boolean_true_node; }
541 expr_no_commas
542 { skip_evaluation -= $1 == boolean_true_node;
543 $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $4); }
544 | expr_no_commas '?'
545 { $1 = truthvalue_conversion (default_conversion ($1));
546 skip_evaluation += $1 == boolean_false_node; }
547 expr ':'
548 { skip_evaluation += (($1 == boolean_true_node)
549 - ($1 == boolean_false_node)); }
550 expr_no_commas
551 { skip_evaluation -= $1 == boolean_true_node;
552 $$ = build_conditional_expr ($1, $4, $7); }
553 | expr_no_commas '?'
554 { if (pedantic)
555 pedwarn ("ANSI C forbids omitting the middle term of a ?: expression");
556 /* Make sure first operand is calculated only once. */
557 $<ttype>2 = save_expr ($1);
558 $1 = truthvalue_conversion (default_conversion ($<ttype>2));
559 skip_evaluation += $1 == boolean_true_node; }
560 ':' expr_no_commas
561 { skip_evaluation -= $1 == boolean_true_node;
562 $$ = build_conditional_expr ($1, $<ttype>2, $5); }
563 | expr_no_commas '=' expr_no_commas
564 { $$ = build_modify_expr ($1, NOP_EXPR, $3);
565 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
566 | expr_no_commas ASSIGN expr_no_commas
567 { $$ = build_modify_expr ($1, $2, $3);
568 /* This inhibits warnings in truthvalue_conversion. */
569 C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK); }
572 primary:
573 IDENTIFIER
575 $$ = lastiddecl;
576 if (!$$ || $$ == error_mark_node)
578 if (yychar == YYEMPTY)
579 yychar = YYLEX;
580 if (yychar == '(')
582 tree decl;
584 if (objc_receiver_context
585 && ! (objc_receiver_context
586 && strcmp (IDENTIFIER_POINTER ($1), "super")))
587 /* we have a message to super */
588 $$ = get_super_receiver ();
589 else if (objc_method_context
590 && (decl = is_ivar (objc_ivar_chain, $1)))
592 if (is_private (decl))
593 $$ = error_mark_node;
594 else
595 $$ = build_ivar_reference ($1);
597 else
599 /* Ordinary implicit function declaration. */
600 $$ = implicitly_declare ($1);
601 assemble_external ($$);
602 TREE_USED ($$) = 1;
605 else if (current_function_decl == 0)
607 error ("`%s' undeclared here (not in a function)",
608 IDENTIFIER_POINTER ($1));
609 $$ = error_mark_node;
611 else
613 tree decl;
615 if (objc_receiver_context
616 && ! strcmp (IDENTIFIER_POINTER ($1), "super"))
617 /* we have a message to super */
618 $$ = get_super_receiver ();
619 else if (objc_method_context
620 && (decl = is_ivar (objc_ivar_chain, $1)))
622 if (is_private (decl))
623 $$ = error_mark_node;
624 else
625 $$ = build_ivar_reference ($1);
627 else
629 if (IDENTIFIER_GLOBAL_VALUE ($1) != error_mark_node
630 || IDENTIFIER_ERROR_LOCUS ($1) != current_function_decl)
632 error ("`%s' undeclared (first use in this function)",
633 IDENTIFIER_POINTER ($1));
635 if (! undeclared_variable_notice)
637 error ("(Each undeclared identifier is reported only once");
638 error ("for each function it appears in.)");
639 undeclared_variable_notice = 1;
642 $$ = error_mark_node;
643 /* Prevent repeated error messages. */
644 IDENTIFIER_GLOBAL_VALUE ($1) = error_mark_node;
645 IDENTIFIER_ERROR_LOCUS ($1) = current_function_decl;
649 else if (TREE_TYPE ($$) == error_mark_node)
650 $$ = error_mark_node;
651 else if (C_DECL_ANTICIPATED ($$))
653 /* The first time we see a build-in function used,
654 if it has not been declared. */
655 C_DECL_ANTICIPATED ($$) = 0;
656 if (yychar == YYEMPTY)
657 yychar = YYLEX;
658 if (yychar == '(')
660 /* Omit the implicit declaration we
661 would ordinarily do, so we don't lose
662 the actual built in type.
663 But print a diagnostic for the mismatch. */
664 if (objc_method_context
665 && is_ivar (objc_ivar_chain, $1))
666 error ("Instance variable `%s' implicitly declared as function",
667 IDENTIFIER_POINTER (DECL_NAME ($$)));
668 else
669 if (TREE_CODE ($$) != FUNCTION_DECL)
670 error ("`%s' implicitly declared as function",
671 IDENTIFIER_POINTER (DECL_NAME ($$)));
672 else if ((TYPE_MODE (TREE_TYPE (TREE_TYPE ($$)))
673 != TYPE_MODE (integer_type_node))
674 && (TREE_TYPE (TREE_TYPE ($$))
675 != void_type_node))
676 pedwarn ("type mismatch in implicit declaration for built-in function `%s'",
677 IDENTIFIER_POINTER (DECL_NAME ($$)));
678 /* If it really returns void, change that to int. */
679 if (TREE_TYPE (TREE_TYPE ($$)) == void_type_node)
680 TREE_TYPE ($$)
681 = build_function_type (integer_type_node,
682 TYPE_ARG_TYPES (TREE_TYPE ($$)));
684 else
685 pedwarn ("built-in function `%s' used without declaration",
686 IDENTIFIER_POINTER (DECL_NAME ($$)));
688 /* Do what we would ordinarily do when a fn is used. */
689 assemble_external ($$);
690 TREE_USED ($$) = 1;
692 else
694 assemble_external ($$);
695 TREE_USED ($$) = 1;
696 /* we have a definition - still check if iVariable */
698 if (!objc_receiver_context
699 || (objc_receiver_context
700 && strcmp (IDENTIFIER_POINTER ($1), "super")))
702 tree decl;
704 if (objc_method_context
705 && (decl = is_ivar (objc_ivar_chain, $1)))
707 if (IDENTIFIER_LOCAL_VALUE ($1))
708 warning ("local declaration of `%s' hides instance variable",
709 IDENTIFIER_POINTER ($1));
710 else
712 if (is_private (decl))
713 $$ = error_mark_node;
714 else
715 $$ = build_ivar_reference ($1);
719 else /* we have a message to super */
720 $$ = get_super_receiver ();
723 if (TREE_CODE ($$) == CONST_DECL)
725 $$ = DECL_INITIAL ($$);
726 /* This is to prevent an enum whose value is 0
727 from being considered a null pointer constant. */
728 $$ = build1 (NOP_EXPR, TREE_TYPE ($$), $$);
729 TREE_CONSTANT ($$) = 1;
732 | CONSTANT
733 | string
734 { $$ = combine_strings ($1); }
735 | '(' expr ')'
736 { char class = TREE_CODE_CLASS (TREE_CODE ($2));
737 if (class == 'e' || class == '1'
738 || class == '2' || class == '<')
739 C_SET_EXP_ORIGINAL_CODE ($2, ERROR_MARK);
740 $$ = $2; }
741 | '(' error ')'
742 { $$ = error_mark_node; }
743 | '('
744 { if (current_function_decl == 0)
746 error ("braced-group within expression allowed only inside a function");
747 YYERROR;
749 /* We must force a BLOCK for this level
750 so that, if it is not expanded later,
751 there is a way to turn off the entire subtree of blocks
752 that are contained in it. */
753 keep_next_level ();
754 push_iterator_stack ();
755 push_label_level ();
756 $<ttype>$ = expand_start_stmt_expr (); }
757 compstmt ')'
758 { tree rtl_exp;
759 if (pedantic)
760 pedwarn ("ANSI C forbids braced-groups within expressions");
761 pop_iterator_stack ();
762 pop_label_level ();
763 rtl_exp = expand_end_stmt_expr ($<ttype>2);
764 /* The statements have side effects, so the group does. */
765 TREE_SIDE_EFFECTS (rtl_exp) = 1;
767 if (TREE_CODE ($3) == BLOCK)
769 /* Make a BIND_EXPR for the BLOCK already made. */
770 $$ = build (BIND_EXPR, TREE_TYPE (rtl_exp),
771 NULL_TREE, rtl_exp, $3);
772 /* Remove the block from the tree at this point.
773 It gets put back at the proper place
774 when the BIND_EXPR is expanded. */
775 delete_block ($3);
777 else
778 $$ = $3;
780 | primary '(' exprlist ')' %prec '.'
781 { $$ = build_function_call ($1, $3); }
782 | primary '[' expr ']' %prec '.'
783 { $$ = build_array_ref ($1, $3); }
784 | primary '.' identifier
786 if (doing_objc_thang)
788 if (is_public ($1, $3))
789 $$ = build_component_ref ($1, $3);
790 else
791 $$ = error_mark_node;
793 else
794 $$ = build_component_ref ($1, $3);
796 | primary POINTSAT identifier
798 tree expr = build_indirect_ref ($1, "->");
800 if (doing_objc_thang)
802 if (is_public (expr, $3))
803 $$ = build_component_ref (expr, $3);
804 else
805 $$ = error_mark_node;
807 else
808 $$ = build_component_ref (expr, $3);
810 | primary PLUSPLUS
811 { $$ = build_unary_op (POSTINCREMENT_EXPR, $1, 0); }
812 | primary MINUSMINUS
813 { $$ = build_unary_op (POSTDECREMENT_EXPR, $1, 0); }
814 | objcmessageexpr
815 { $$ = build_message_expr ($1); }
816 | objcselectorexpr
817 { $$ = build_selector_expr ($1); }
818 | objcprotocolexpr
819 { $$ = build_protocol_expr ($1); }
820 | objcencodeexpr
821 { $$ = build_encode_expr ($1); }
822 | objc_string
823 { $$ = build_objc_string_object ($1); }
826 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
827 string:
828 STRING
829 | string STRING
830 { $$ = chainon ($1, $2); }
833 /* Produces an OBJC_STRING_CST with perhaps more OBJC_STRING_CSTs chained
834 onto it. */
835 objc_string:
836 OBJC_STRING
837 | objc_string OBJC_STRING
838 { $$ = chainon ($1, $2); }
841 old_style_parm_decls:
842 /* empty */
843 | datadecls
844 | datadecls ELLIPSIS
845 /* ... is used here to indicate a varargs function. */
846 { c_mark_varargs ();
847 if (pedantic)
848 pedwarn ("ANSI C does not permit use of `varargs.h'"); }
851 /* The following are analogous to lineno_decl, decls and decl
852 except that they do not allow nested functions.
853 They are used for old-style parm decls. */
854 lineno_datadecl:
855 save_filename save_lineno datadecl
859 datadecls:
860 lineno_datadecl
861 | errstmt
862 | datadecls lineno_datadecl
863 | lineno_datadecl errstmt
866 /* We don't allow prefix attributes here because they cause reduce/reduce
867 conflicts: we can't know whether we're parsing a function decl with
868 attribute suffix, or function defn with attribute prefix on first old
869 style parm. */
870 datadecl:
871 typed_declspecs_no_prefix_attr setspecs initdecls ';'
872 { current_declspecs = TREE_VALUE (declspec_stack);
873 prefix_attributes = TREE_PURPOSE (declspec_stack);
874 declspec_stack = TREE_CHAIN (declspec_stack);
875 resume_momentary ($2); }
876 | declmods_no_prefix_attr setspecs notype_initdecls ';'
877 { current_declspecs = TREE_VALUE (declspec_stack);
878 prefix_attributes = TREE_PURPOSE (declspec_stack);
879 declspec_stack = TREE_CHAIN (declspec_stack);
880 resume_momentary ($2); }
881 | typed_declspecs_no_prefix_attr ';'
882 { shadow_tag_warned ($1, 1);
883 pedwarn ("empty declaration"); }
884 | declmods_no_prefix_attr ';'
885 { pedwarn ("empty declaration"); }
888 /* This combination which saves a lineno before a decl
889 is the normal thing to use, rather than decl itself.
890 This is to avoid shift/reduce conflicts in contexts
891 where statement labels are allowed. */
892 lineno_decl:
893 save_filename save_lineno decl
897 decls:
898 lineno_decl
899 | errstmt
900 | decls lineno_decl
901 | lineno_decl errstmt
904 /* records the type and storage class specs to use for processing
905 the declarators that follow.
906 Maintains a stack of outer-level values of current_declspecs,
907 for the sake of parm declarations nested in function declarators. */
908 setspecs: /* empty */
909 { $$ = suspend_momentary ();
910 pending_xref_error ();
911 declspec_stack = tree_cons (prefix_attributes,
912 current_declspecs,
913 declspec_stack);
914 split_specs_attrs ($<ttype>0,
915 &current_declspecs, &prefix_attributes); }
918 /* ??? Yuck. See after_type_declarator. */
919 setattrs: /* empty */
920 { prefix_attributes = chainon (prefix_attributes, $<ttype>0); }
923 decl:
924 typed_declspecs setspecs initdecls ';'
925 { current_declspecs = TREE_VALUE (declspec_stack);
926 prefix_attributes = TREE_PURPOSE (declspec_stack);
927 declspec_stack = TREE_CHAIN (declspec_stack);
928 resume_momentary ($2); }
929 | declmods setspecs notype_initdecls ';'
930 { current_declspecs = TREE_VALUE (declspec_stack);
931 prefix_attributes = TREE_PURPOSE (declspec_stack);
932 declspec_stack = TREE_CHAIN (declspec_stack);
933 resume_momentary ($2); }
934 | typed_declspecs setspecs nested_function
935 { current_declspecs = TREE_VALUE (declspec_stack);
936 prefix_attributes = TREE_PURPOSE (declspec_stack);
937 declspec_stack = TREE_CHAIN (declspec_stack);
938 resume_momentary ($2); }
939 | declmods setspecs notype_nested_function
940 { current_declspecs = TREE_VALUE (declspec_stack);
941 prefix_attributes = TREE_PURPOSE (declspec_stack);
942 declspec_stack = TREE_CHAIN (declspec_stack);
943 resume_momentary ($2); }
944 | typed_declspecs ';'
945 { shadow_tag ($1); }
946 | declmods ';'
947 { pedwarn ("empty declaration"); }
948 | extension decl
949 { pedantic = $<itype>1; }
952 /* Declspecs which contain at least one type specifier or typedef name.
953 (Just `const' or `volatile' is not enough.)
954 A typedef'd name following these is taken as a name to be declared.
955 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
957 typed_declspecs:
958 typespec reserved_declspecs
959 { $$ = tree_cons (NULL_TREE, $1, $2); }
960 | declmods typespec reserved_declspecs
961 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
964 reserved_declspecs: /* empty */
965 { $$ = NULL_TREE; }
966 | reserved_declspecs typespecqual_reserved
967 { $$ = tree_cons (NULL_TREE, $2, $1); }
968 | reserved_declspecs SCSPEC
969 { if (extra_warnings)
970 warning ("`%s' is not at beginning of declaration",
971 IDENTIFIER_POINTER ($2));
972 $$ = tree_cons (NULL_TREE, $2, $1); }
973 | reserved_declspecs attributes
974 { $$ = tree_cons ($2, NULL_TREE, $1); }
977 typed_declspecs_no_prefix_attr:
978 typespec reserved_declspecs_no_prefix_attr
979 { $$ = tree_cons (NULL_TREE, $1, $2); }
980 | declmods_no_prefix_attr typespec reserved_declspecs_no_prefix_attr
981 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
984 reserved_declspecs_no_prefix_attr:
985 /* empty */
986 { $$ = NULL_TREE; }
987 | reserved_declspecs_no_prefix_attr typespecqual_reserved
988 { $$ = tree_cons (NULL_TREE, $2, $1); }
989 | reserved_declspecs_no_prefix_attr SCSPEC
990 { if (extra_warnings)
991 warning ("`%s' is not at beginning of declaration",
992 IDENTIFIER_POINTER ($2));
993 $$ = tree_cons (NULL_TREE, $2, $1); }
996 /* List of just storage classes, type modifiers, and prefix attributes.
997 A declaration can start with just this, but then it cannot be used
998 to redeclare a typedef-name.
999 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
1001 declmods:
1002 declmods_no_prefix_attr
1003 { $$ = $1; }
1004 | attributes
1005 { $$ = tree_cons ($1, NULL_TREE, NULL_TREE); }
1006 | declmods declmods_no_prefix_attr
1007 { $$ = chainon ($2, $1); }
1008 | declmods attributes
1009 { $$ = tree_cons ($2, NULL_TREE, $1); }
1012 declmods_no_prefix_attr:
1013 TYPE_QUAL
1014 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
1015 TREE_STATIC ($$) = 1; }
1016 | SCSPEC
1017 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
1018 | declmods_no_prefix_attr TYPE_QUAL
1019 { $$ = tree_cons (NULL_TREE, $2, $1);
1020 TREE_STATIC ($$) = 1; }
1021 | declmods_no_prefix_attr SCSPEC
1022 { if (extra_warnings && TREE_STATIC ($1))
1023 warning ("`%s' is not at beginning of declaration",
1024 IDENTIFIER_POINTER ($2));
1025 $$ = tree_cons (NULL_TREE, $2, $1);
1026 TREE_STATIC ($$) = TREE_STATIC ($1); }
1030 /* Used instead of declspecs where storage classes are not allowed
1031 (that is, for typenames and structure components).
1032 Don't accept a typedef-name if anything but a modifier precedes it. */
1034 typed_typespecs:
1035 typespec reserved_typespecquals
1036 { $$ = tree_cons (NULL_TREE, $1, $2); }
1037 | nonempty_type_quals typespec reserved_typespecquals
1038 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
1041 reserved_typespecquals: /* empty */
1042 { $$ = NULL_TREE; }
1043 | reserved_typespecquals typespecqual_reserved
1044 { $$ = tree_cons (NULL_TREE, $2, $1); }
1047 /* A typespec (but not a type qualifier).
1048 Once we have seen one of these in a declaration,
1049 if a typedef name appears then it is being redeclared. */
1051 typespec: TYPESPEC
1052 | structsp
1053 | TYPENAME
1054 { /* For a typedef name, record the meaning, not the name.
1055 In case of `foo foo, bar;'. */
1056 $$ = lookup_name ($1); }
1057 | CLASSNAME protocolrefs
1058 { $$ = get_static_reference ($1, $2); }
1059 | OBJECTNAME protocolrefs
1060 { $$ = get_object_reference ($2); }
1062 /* Make "<SomeProtocol>" equivalent to "id <SomeProtocol>"
1063 - nisse@lysator.liu.se */
1064 | non_empty_protocolrefs
1065 { $$ = get_object_reference ($1); }
1066 | TYPEOF '(' expr ')'
1067 { $$ = TREE_TYPE ($3); }
1068 | TYPEOF '(' typename ')'
1069 { $$ = groktypename ($3); }
1072 /* A typespec that is a reserved word, or a type qualifier. */
1074 typespecqual_reserved: TYPESPEC
1075 | TYPE_QUAL
1076 | structsp
1079 initdecls:
1080 initdcl
1081 | initdecls ',' initdcl
1084 notype_initdecls:
1085 notype_initdcl
1086 | notype_initdecls ',' initdcl
1089 maybeasm:
1090 /* empty */
1091 { $$ = NULL_TREE; }
1092 | ASM_KEYWORD '(' string ')'
1093 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
1094 $$ = $3;
1098 initdcl:
1099 declarator maybeasm maybe_attribute '='
1100 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1101 $3, prefix_attributes);
1102 start_init ($<ttype>$, $2, global_bindings_p ()); }
1103 init
1104 /* Note how the declaration of the variable is in effect while its init is parsed! */
1105 { finish_init ();
1106 finish_decl ($<ttype>5, $6, $2); }
1107 | declarator maybeasm maybe_attribute
1108 { tree d = start_decl ($1, current_declspecs, 0,
1109 $3, prefix_attributes);
1110 finish_decl (d, NULL_TREE, $2);
1114 notype_initdcl:
1115 notype_declarator maybeasm maybe_attribute '='
1116 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1117 $3, prefix_attributes);
1118 start_init ($<ttype>$, $2, global_bindings_p ()); }
1119 init
1120 /* Note how the declaration of the variable is in effect while its init is parsed! */
1121 { finish_init ();
1122 decl_attributes ($<ttype>5, $3, prefix_attributes);
1123 finish_decl ($<ttype>5, $6, $2); }
1124 | notype_declarator maybeasm maybe_attribute
1125 { tree d = start_decl ($1, current_declspecs, 0,
1126 $3, prefix_attributes);
1127 finish_decl (d, NULL_TREE, $2); }
1129 /* the * rules are dummies to accept the Apollo extended syntax
1130 so that the header files compile. */
1131 maybe_attribute:
1132 /* empty */
1133 { $$ = NULL_TREE; }
1134 | attributes
1135 { $$ = $1; }
1138 attributes:
1139 attribute
1140 { $$ = $1; }
1141 | attributes attribute
1142 { $$ = chainon ($1, $2); }
1145 attribute:
1146 ATTRIBUTE '(' '(' attribute_list ')' ')'
1147 { $$ = $4; }
1150 attribute_list:
1151 attrib
1152 { $$ = $1; }
1153 | attribute_list ',' attrib
1154 { $$ = chainon ($1, $3); }
1157 attrib:
1158 /* empty */
1159 { $$ = NULL_TREE; }
1160 | any_word
1161 { $$ = build_tree_list ($1, NULL_TREE); }
1162 | any_word '(' IDENTIFIER ')'
1163 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1164 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1165 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1166 | any_word '(' exprlist ')'
1167 { $$ = build_tree_list ($1, $3); }
1170 /* This still leaves out most reserved keywords,
1171 shouldn't we include them? */
1173 any_word:
1174 identifier
1175 | SCSPEC
1176 | TYPESPEC
1177 | TYPE_QUAL
1180 /* Initializers. `init' is the entry point. */
1182 init:
1183 expr_no_commas
1184 | '{'
1185 { really_start_incremental_init (NULL_TREE);
1186 /* Note that the call to clear_momentary
1187 is in process_init_element. */
1188 push_momentary (); }
1189 initlist_maybe_comma '}'
1190 { $$ = pop_init_level (0);
1191 if ($$ == error_mark_node
1192 && ! (yychar == STRING || yychar == CONSTANT))
1193 pop_momentary ();
1194 else
1195 pop_momentary_nofree (); }
1197 | error
1198 { $$ = error_mark_node; }
1201 /* `initlist_maybe_comma' is the guts of an initializer in braces. */
1202 initlist_maybe_comma:
1203 /* empty */
1204 { if (pedantic)
1205 pedwarn ("ANSI C forbids empty initializer braces"); }
1206 | initlist1 maybecomma
1209 initlist1:
1210 initelt
1211 | initlist1 ',' initelt
1214 /* `initelt' is a single element of an initializer.
1215 It may use braces. */
1216 initelt:
1217 expr_no_commas
1218 { process_init_element ($1); }
1219 | '{'
1220 { push_init_level (0); }
1221 initlist_maybe_comma '}'
1222 { process_init_element (pop_init_level (0)); }
1223 | error
1224 /* These are for labeled elements. The syntax for an array element
1225 initializer conflicts with the syntax for an Objective-C message,
1226 so don't include these productions in the Objective-C grammar. */
1227 | identifier ':'
1228 { set_init_label ($1); }
1229 initelt
1230 | '.' identifier '='
1231 { set_init_label ($2); }
1232 initelt
1235 nested_function:
1236 declarator
1237 { push_c_function_context ();
1238 if (! start_function (current_declspecs, $1,
1239 prefix_attributes, NULL_TREE, 1))
1241 pop_c_function_context ();
1242 YYERROR1;
1244 reinit_parse_for_function (); }
1245 old_style_parm_decls
1246 { store_parm_decls (); }
1247 /* This used to use compstmt_or_error.
1248 That caused a bug with input `f(g) int g {}',
1249 where the use of YYERROR1 above caused an error
1250 which then was handled by compstmt_or_error.
1251 There followed a repeated execution of that same rule,
1252 which called YYERROR1 again, and so on. */
1253 compstmt
1254 { finish_function (1);
1255 pop_c_function_context (); }
1258 notype_nested_function:
1259 notype_declarator
1260 { push_c_function_context ();
1261 if (! start_function (current_declspecs, $1,
1262 prefix_attributes, NULL_TREE, 1))
1264 pop_c_function_context ();
1265 YYERROR1;
1267 reinit_parse_for_function (); }
1268 old_style_parm_decls
1269 { store_parm_decls (); }
1270 /* This used to use compstmt_or_error.
1271 That caused a bug with input `f(g) int g {}',
1272 where the use of YYERROR1 above caused an error
1273 which then was handled by compstmt_or_error.
1274 There followed a repeated execution of that same rule,
1275 which called YYERROR1 again, and so on. */
1276 compstmt
1277 { finish_function (1);
1278 pop_c_function_context (); }
1281 /* Any kind of declarator (thus, all declarators allowed
1282 after an explicit typespec). */
1284 declarator:
1285 after_type_declarator
1286 | notype_declarator
1289 /* A declarator that is allowed only after an explicit typespec. */
1291 after_type_declarator:
1292 '(' after_type_declarator ')'
1293 { $$ = $2; }
1294 | after_type_declarator '(' parmlist_or_identifiers %prec '.'
1295 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1296 /* | after_type_declarator '(' error ')' %prec '.'
1297 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1298 poplevel (0, 0, 0); } */
1299 | after_type_declarator '[' expr ']' %prec '.'
1300 { $$ = build_nt (ARRAY_REF, $1, $3); }
1301 | after_type_declarator '[' ']' %prec '.'
1302 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1303 | '*' type_quals after_type_declarator %prec UNARY
1304 { $$ = make_pointer_declarator ($2, $3); }
1305 /* ??? Yuck. setattrs is a quick hack. We can't use
1306 prefix_attributes because $1 only applies to this
1307 declarator. We assume setspecs has already been done.
1308 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1309 attributes could be recognized here or in `attributes'). */
1310 | attributes setattrs after_type_declarator
1311 { $$ = $3; }
1312 | TYPENAME
1313 | OBJECTNAME
1316 /* Kinds of declarator that can appear in a parameter list
1317 in addition to notype_declarator. This is like after_type_declarator
1318 but does not allow a typedef name in parentheses as an identifier
1319 (because it would conflict with a function with that typedef as arg). */
1321 parm_declarator:
1322 parm_declarator '(' parmlist_or_identifiers %prec '.'
1323 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1324 /* | parm_declarator '(' error ')' %prec '.'
1325 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1326 poplevel (0, 0, 0); } */
1327 | parm_declarator '[' expr ']' %prec '.'
1328 { $$ = build_nt (ARRAY_REF, $1, $3); }
1329 | parm_declarator '[' ']' %prec '.'
1330 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1331 | '*' type_quals parm_declarator %prec UNARY
1332 { $$ = make_pointer_declarator ($2, $3); }
1333 /* ??? Yuck. setattrs is a quick hack. We can't use
1334 prefix_attributes because $1 only applies to this
1335 declarator. We assume setspecs has already been done.
1336 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1337 attributes could be recognized here or in `attributes'). */
1338 | attributes setattrs parm_declarator
1339 { $$ = $3; }
1340 | TYPENAME
1343 /* A declarator allowed whether or not there has been
1344 an explicit typespec. These cannot redeclare a typedef-name. */
1346 notype_declarator:
1347 notype_declarator '(' parmlist_or_identifiers %prec '.'
1348 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1349 /* | notype_declarator '(' error ')' %prec '.'
1350 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1351 poplevel (0, 0, 0); } */
1352 | '(' notype_declarator ')'
1353 { $$ = $2; }
1354 | '*' type_quals notype_declarator %prec UNARY
1355 { $$ = make_pointer_declarator ($2, $3); }
1356 | notype_declarator '[' expr ']' %prec '.'
1357 { $$ = build_nt (ARRAY_REF, $1, $3); }
1358 | notype_declarator '[' ']' %prec '.'
1359 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1360 /* ??? Yuck. setattrs is a quick hack. We can't use
1361 prefix_attributes because $1 only applies to this
1362 declarator. We assume setspecs has already been done.
1363 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1364 attributes could be recognized here or in `attributes'). */
1365 | attributes setattrs notype_declarator
1366 { $$ = $3; }
1367 | IDENTIFIER
1370 structsp:
1371 STRUCT identifier '{'
1372 { $$ = start_struct (RECORD_TYPE, $2);
1373 /* Start scope of tag before parsing components. */
1375 component_decl_list '}' maybe_attribute
1376 { $$ = finish_struct ($<ttype>4, $5, $7); }
1377 | STRUCT '{' component_decl_list '}' maybe_attribute
1378 { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
1379 $3, $5);
1381 | STRUCT identifier
1382 { $$ = xref_tag (RECORD_TYPE, $2); }
1383 | UNION identifier '{'
1384 { $$ = start_struct (UNION_TYPE, $2); }
1385 component_decl_list '}' maybe_attribute
1386 { $$ = finish_struct ($<ttype>4, $5, $7); }
1387 | UNION '{' component_decl_list '}' maybe_attribute
1388 { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
1389 $3, $5);
1391 | UNION identifier
1392 { $$ = xref_tag (UNION_TYPE, $2); }
1393 | ENUM identifier '{'
1394 { $<itype>3 = suspend_momentary ();
1395 $$ = start_enum ($2); }
1396 enumlist maybecomma_warn '}' maybe_attribute
1397 { $$ = finish_enum ($<ttype>4, nreverse ($5), $8);
1398 resume_momentary ($<itype>3); }
1399 | ENUM '{'
1400 { $<itype>2 = suspend_momentary ();
1401 $$ = start_enum (NULL_TREE); }
1402 enumlist maybecomma_warn '}' maybe_attribute
1403 { $$ = finish_enum ($<ttype>3, nreverse ($4), $7);
1404 resume_momentary ($<itype>2); }
1405 | ENUM identifier
1406 { $$ = xref_tag (ENUMERAL_TYPE, $2); }
1409 maybecomma:
1410 /* empty */
1411 | ','
1414 maybecomma_warn:
1415 /* empty */
1416 | ','
1417 { if (pedantic) pedwarn ("comma at end of enumerator list"); }
1420 component_decl_list:
1421 component_decl_list2
1422 { $$ = $1; }
1423 | component_decl_list2 component_decl
1424 { $$ = chainon ($1, $2);
1425 pedwarn ("no semicolon at end of struct or union"); }
1428 component_decl_list2: /* empty */
1429 { $$ = NULL_TREE; }
1430 | component_decl_list2 component_decl ';'
1431 { $$ = chainon ($1, $2); }
1432 | component_decl_list2 ';'
1433 { if (pedantic)
1434 pedwarn ("extra semicolon in struct or union specified"); }
1435 /* foo(sizeof(struct{ @defs(ClassName)})); */
1436 | DEFS '(' CLASSNAME ')'
1438 tree interface = lookup_interface ($3);
1440 if (interface)
1441 $$ = get_class_ivars (interface);
1442 else
1444 error ("Cannot find interface declaration for `%s'",
1445 IDENTIFIER_POINTER ($3));
1446 $$ = NULL_TREE;
1451 /* There is a shift-reduce conflict here, because `components' may
1452 start with a `typename'. It happens that shifting (the default resolution)
1453 does the right thing, because it treats the `typename' as part of
1454 a `typed_typespecs'.
1456 It is possible that this same technique would allow the distinction
1457 between `notype_initdecls' and `initdecls' to be eliminated.
1458 But I am being cautious and not trying it. */
1460 component_decl:
1461 typed_typespecs setspecs components
1462 { $$ = $3;
1463 current_declspecs = TREE_VALUE (declspec_stack);
1464 prefix_attributes = TREE_PURPOSE (declspec_stack);
1465 declspec_stack = TREE_CHAIN (declspec_stack);
1466 resume_momentary ($2); }
1467 | typed_typespecs
1468 { if (pedantic)
1469 pedwarn ("ANSI C forbids member declarations with no members");
1470 shadow_tag($1);
1471 $$ = NULL_TREE; }
1472 | nonempty_type_quals setspecs components
1473 { $$ = $3;
1474 current_declspecs = TREE_VALUE (declspec_stack);
1475 prefix_attributes = TREE_PURPOSE (declspec_stack);
1476 declspec_stack = TREE_CHAIN (declspec_stack);
1477 resume_momentary ($2); }
1478 | nonempty_type_quals
1479 { if (pedantic)
1480 pedwarn ("ANSI C forbids member declarations with no members");
1481 shadow_tag($1);
1482 $$ = NULL_TREE; }
1483 | error
1484 { $$ = NULL_TREE; }
1485 | extension component_decl
1486 { $$ = $2;
1487 pedantic = $<itype>1; }
1490 components:
1491 component_declarator
1492 | components ',' component_declarator
1493 { $$ = chainon ($1, $3); }
1496 component_declarator:
1497 save_filename save_lineno declarator maybe_attribute
1498 { $$ = grokfield ($1, $2, $3, current_declspecs, NULL_TREE);
1499 decl_attributes ($$, $4, prefix_attributes); }
1500 | save_filename save_lineno
1501 declarator ':' expr_no_commas maybe_attribute
1502 { $$ = grokfield ($1, $2, $3, current_declspecs, $5);
1503 decl_attributes ($$, $6, prefix_attributes); }
1504 | save_filename save_lineno ':' expr_no_commas maybe_attribute
1505 { $$ = grokfield ($1, $2, NULL_TREE, current_declspecs, $4);
1506 decl_attributes ($$, $5, prefix_attributes); }
1509 /* We chain the enumerators in reverse order.
1510 They are put in forward order where enumlist is used.
1511 (The order used to be significant, but no longer is so.
1512 However, we still maintain the order, just to be clean.) */
1514 enumlist:
1515 enumerator
1516 | enumlist ',' enumerator
1517 { if ($1 == error_mark_node)
1518 $$ = $1;
1519 else
1520 $$ = chainon ($3, $1); }
1521 | error
1522 { $$ = error_mark_node; }
1526 enumerator:
1527 identifier
1528 { $$ = build_enumerator ($1, NULL_TREE); }
1529 | identifier '=' expr_no_commas
1530 { $$ = build_enumerator ($1, $3); }
1533 typename:
1534 typed_typespecs absdcl
1535 { $$ = build_tree_list ($1, $2); }
1536 | nonempty_type_quals absdcl
1537 { $$ = build_tree_list ($1, $2); }
1540 absdcl: /* an absolute declarator */
1541 /* empty */
1542 { $$ = NULL_TREE; }
1543 | absdcl1
1546 nonempty_type_quals:
1547 TYPE_QUAL
1548 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
1549 | nonempty_type_quals TYPE_QUAL
1550 { $$ = tree_cons (NULL_TREE, $2, $1); }
1553 type_quals:
1554 /* empty */
1555 { $$ = NULL_TREE; }
1556 | type_quals TYPE_QUAL
1557 { $$ = tree_cons (NULL_TREE, $2, $1); }
1560 absdcl1: /* a nonempty absolute declarator */
1561 '(' absdcl1 ')'
1562 { $$ = $2; }
1563 /* `(typedef)1' is `int'. */
1564 | '*' type_quals absdcl1 %prec UNARY
1565 { $$ = make_pointer_declarator ($2, $3); }
1566 | '*' type_quals %prec UNARY
1567 { $$ = make_pointer_declarator ($2, NULL_TREE); }
1568 | absdcl1 '(' parmlist %prec '.'
1569 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1570 | absdcl1 '[' expr ']' %prec '.'
1571 { $$ = build_nt (ARRAY_REF, $1, $3); }
1572 | absdcl1 '[' ']' %prec '.'
1573 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1574 | '(' parmlist %prec '.'
1575 { $$ = build_nt (CALL_EXPR, NULL_TREE, $2, NULL_TREE); }
1576 | '[' expr ']' %prec '.'
1577 { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
1578 | '[' ']' %prec '.'
1579 { $$ = build_nt (ARRAY_REF, NULL_TREE, NULL_TREE); }
1580 /* ??? It appears we have to support attributes here, however
1581 using prefix_attributes is wrong. */
1584 /* at least one statement, the first of which parses without error. */
1585 /* stmts is used only after decls, so an invalid first statement
1586 is actually regarded as an invalid decl and part of the decls. */
1588 stmts:
1589 lineno_stmt_or_labels
1591 if (pedantic && $1)
1592 pedwarn ("ANSI C forbids label at end of compound statement");
1596 lineno_stmt_or_labels:
1597 lineno_stmt_or_label
1598 | lineno_stmt_or_labels lineno_stmt_or_label
1599 { $$ = $2; }
1600 | lineno_stmt_or_labels errstmt
1601 { $$ = 0; }
1604 xstmts:
1605 /* empty */
1606 | stmts
1609 errstmt: error ';'
1612 pushlevel: /* empty */
1613 { emit_line_note (input_filename, lineno);
1614 pushlevel (0);
1615 clear_last_expr ();
1616 push_momentary ();
1617 expand_start_bindings (0);
1618 if (objc_method_context)
1619 add_objc_decls ();
1623 /* Read zero or more forward-declarations for labels
1624 that nested functions can jump to. */
1625 maybe_label_decls:
1626 /* empty */
1627 | label_decls
1628 { if (pedantic)
1629 pedwarn ("ANSI C forbids label declarations"); }
1632 label_decls:
1633 label_decl
1634 | label_decls label_decl
1637 label_decl:
1638 LABEL identifiers_or_typenames ';'
1639 { tree link;
1640 for (link = $2; link; link = TREE_CHAIN (link))
1642 tree label = shadow_label (TREE_VALUE (link));
1643 C_DECLARED_LABEL_FLAG (label) = 1;
1644 declare_nonlocal_label (label);
1649 /* This is the body of a function definition.
1650 It causes syntax errors to ignore to the next openbrace. */
1651 compstmt_or_error:
1652 compstmt
1654 | error compstmt
1657 compstmt_start: '{' { compstmt_count++; }
1659 compstmt: compstmt_start '}'
1660 { $$ = convert (void_type_node, integer_zero_node); }
1661 | compstmt_start pushlevel maybe_label_decls decls xstmts '}'
1662 { emit_line_note (input_filename, lineno);
1663 expand_end_bindings (getdecls (), 1, 0);
1664 $$ = poplevel (1, 1, 0);
1665 if (yychar == CONSTANT || yychar == STRING)
1666 pop_momentary_nofree ();
1667 else
1668 pop_momentary (); }
1669 | compstmt_start pushlevel maybe_label_decls error '}'
1670 { emit_line_note (input_filename, lineno);
1671 expand_end_bindings (getdecls (), kept_level_p (), 0);
1672 $$ = poplevel (kept_level_p (), 0, 0);
1673 if (yychar == CONSTANT || yychar == STRING)
1674 pop_momentary_nofree ();
1675 else
1676 pop_momentary (); }
1677 | compstmt_start pushlevel maybe_label_decls stmts '}'
1678 { emit_line_note (input_filename, lineno);
1679 expand_end_bindings (getdecls (), kept_level_p (), 0);
1680 $$ = poplevel (kept_level_p (), 0, 0);
1681 if (yychar == CONSTANT || yychar == STRING)
1682 pop_momentary_nofree ();
1683 else
1684 pop_momentary (); }
1687 /* Value is number of statements counted as of the closeparen. */
1688 simple_if:
1689 if_prefix lineno_labeled_stmt
1690 /* Make sure c_expand_end_cond is run once
1691 for each call to c_expand_start_cond.
1692 Otherwise a crash is likely. */
1693 | if_prefix error
1696 if_prefix:
1697 IF '(' expr ')'
1698 { emit_line_note ($<filename>-1, $<lineno>0);
1699 c_expand_start_cond (truthvalue_conversion ($3), 0,
1700 compstmt_count);
1701 $<itype>$ = stmt_count;
1702 if_stmt_file = $<filename>-1;
1703 if_stmt_line = $<lineno>0;
1704 position_after_white_space (); }
1707 /* This is a subroutine of stmt.
1708 It is used twice, once for valid DO statements
1709 and once for catching errors in parsing the end test. */
1710 do_stmt_start:
1712 { stmt_count++;
1713 compstmt_count++;
1714 emit_line_note ($<filename>-1, $<lineno>0);
1715 /* See comment in `while' alternative, above. */
1716 emit_nop ();
1717 expand_start_loop_continue_elsewhere (1);
1718 position_after_white_space (); }
1719 lineno_labeled_stmt WHILE
1720 { expand_loop_continue_here (); }
1723 save_filename:
1724 { $$ = input_filename; }
1727 save_lineno:
1728 { $$ = lineno; }
1731 lineno_labeled_stmt:
1732 save_filename save_lineno stmt
1734 /* | save_filename save_lineno error
1737 | save_filename save_lineno label lineno_labeled_stmt
1741 lineno_stmt_or_label:
1742 save_filename save_lineno stmt_or_label
1743 { $$ = $3; }
1746 stmt_or_label:
1747 stmt
1748 { $$ = 0; }
1749 | label
1750 { $$ = 1; }
1753 /* Parse a single real statement, not including any labels. */
1754 stmt:
1755 compstmt
1756 { stmt_count++; }
1757 | all_iter_stmt
1758 | expr ';'
1759 { stmt_count++;
1760 emit_line_note ($<filename>-1, $<lineno>0);
1761 /* It appears that this should not be done--that a non-lvalue array
1762 shouldn't get an error if the value isn't used.
1763 Section 3.2.2.1 says that an array lvalue gets converted to a pointer
1764 if it appears as a top-level expression,
1765 but says nothing about non-lvalue arrays. */
1766 #if 0
1767 /* Call default_conversion to get an error
1768 on referring to a register array if pedantic. */
1769 if (TREE_CODE (TREE_TYPE ($1)) == ARRAY_TYPE
1770 || TREE_CODE (TREE_TYPE ($1)) == FUNCTION_TYPE)
1771 $1 = default_conversion ($1);
1772 #endif
1773 iterator_expand ($1);
1774 clear_momentary (); }
1775 | simple_if ELSE
1776 { c_expand_start_else ();
1777 $<itype>1 = stmt_count;
1778 position_after_white_space (); }
1779 lineno_labeled_stmt
1780 { c_expand_end_cond ();
1781 if (extra_warnings && stmt_count == $<itype>1)
1782 warning ("empty body in an else-statement"); }
1783 | simple_if %prec IF
1784 { c_expand_end_cond ();
1785 /* This warning is here instead of in simple_if, because we
1786 do not want a warning if an empty if is followed by an
1787 else statement. Increment stmt_count so we don't
1788 give a second error if this is a nested `if'. */
1789 if (extra_warnings && stmt_count++ == $<itype>1)
1790 warning_with_file_and_line (if_stmt_file, if_stmt_line,
1791 "empty body in an if-statement"); }
1792 /* Make sure c_expand_end_cond is run once
1793 for each call to c_expand_start_cond.
1794 Otherwise a crash is likely. */
1795 | simple_if ELSE error
1796 { c_expand_end_cond (); }
1797 | WHILE
1798 { stmt_count++;
1799 emit_line_note ($<filename>-1, $<lineno>0);
1800 /* The emit_nop used to come before emit_line_note,
1801 but that made the nop seem like part of the preceding line.
1802 And that was confusing when the preceding line was
1803 inside of an if statement and was not really executed.
1804 I think it ought to work to put the nop after the line number.
1805 We will see. --rms, July 15, 1991. */
1806 emit_nop (); }
1807 '(' expr ')'
1808 { /* Don't start the loop till we have succeeded
1809 in parsing the end test. This is to make sure
1810 that we end every loop we start. */
1811 expand_start_loop (1);
1812 emit_line_note (input_filename, lineno);
1813 expand_exit_loop_if_false (NULL_PTR,
1814 truthvalue_conversion ($4));
1815 position_after_white_space (); }
1816 lineno_labeled_stmt
1817 { expand_end_loop (); }
1818 | do_stmt_start
1819 '(' expr ')' ';'
1820 { emit_line_note (input_filename, lineno);
1821 expand_exit_loop_if_false (NULL_PTR,
1822 truthvalue_conversion ($3));
1823 expand_end_loop ();
1824 clear_momentary (); }
1825 /* This rule is needed to make sure we end every loop we start. */
1826 | do_stmt_start error
1827 { expand_end_loop ();
1828 clear_momentary (); }
1829 | FOR
1830 '(' xexpr ';'
1831 { stmt_count++;
1832 emit_line_note ($<filename>-1, $<lineno>0);
1833 /* See comment in `while' alternative, above. */
1834 emit_nop ();
1835 if ($3) c_expand_expr_stmt ($3);
1836 /* Next step is to call expand_start_loop_continue_elsewhere,
1837 but wait till after we parse the entire for (...).
1838 Otherwise, invalid input might cause us to call that
1839 fn without calling expand_end_loop. */
1841 xexpr ';'
1842 /* Can't emit now; wait till after expand_start_loop... */
1843 { $<lineno>7 = lineno;
1844 $<filename>$ = input_filename; }
1845 xexpr ')'
1847 /* Start the loop. Doing this after parsing
1848 all the expressions ensures we will end the loop. */
1849 expand_start_loop_continue_elsewhere (1);
1850 /* Emit the end-test, with a line number. */
1851 emit_line_note ($<filename>8, $<lineno>7);
1852 if ($6)
1853 expand_exit_loop_if_false (NULL_PTR,
1854 truthvalue_conversion ($6));
1855 /* Don't let the tree nodes for $9 be discarded by
1856 clear_momentary during the parsing of the next stmt. */
1857 push_momentary ();
1858 $<lineno>7 = lineno;
1859 $<filename>8 = input_filename;
1860 position_after_white_space (); }
1861 lineno_labeled_stmt
1862 { /* Emit the increment expression, with a line number. */
1863 emit_line_note ($<filename>8, $<lineno>7);
1864 expand_loop_continue_here ();
1865 if ($9)
1866 c_expand_expr_stmt ($9);
1867 if (yychar == CONSTANT || yychar == STRING)
1868 pop_momentary_nofree ();
1869 else
1870 pop_momentary ();
1871 expand_end_loop (); }
1872 | SWITCH '(' expr ')'
1873 { stmt_count++;
1874 emit_line_note ($<filename>-1, $<lineno>0);
1875 c_expand_start_case ($3);
1876 /* Don't let the tree nodes for $3 be discarded by
1877 clear_momentary during the parsing of the next stmt. */
1878 push_momentary ();
1879 position_after_white_space (); }
1880 lineno_labeled_stmt
1881 { expand_end_case ($3);
1882 if (yychar == CONSTANT || yychar == STRING)
1883 pop_momentary_nofree ();
1884 else
1885 pop_momentary (); }
1886 | BREAK ';'
1887 { stmt_count++;
1888 emit_line_note ($<filename>-1, $<lineno>0);
1889 if ( ! expand_exit_something ())
1890 error ("break statement not within loop or switch"); }
1891 | CONTINUE ';'
1892 { stmt_count++;
1893 emit_line_note ($<filename>-1, $<lineno>0);
1894 if (! expand_continue_loop (NULL_PTR))
1895 error ("continue statement not within a loop"); }
1896 | RETURN ';'
1897 { stmt_count++;
1898 emit_line_note ($<filename>-1, $<lineno>0);
1899 c_expand_return (NULL_TREE); }
1900 | RETURN expr ';'
1901 { stmt_count++;
1902 emit_line_note ($<filename>-1, $<lineno>0);
1903 c_expand_return ($2); }
1904 | ASM_KEYWORD maybe_type_qual '(' expr ')' ';'
1905 { stmt_count++;
1906 emit_line_note ($<filename>-1, $<lineno>0);
1907 STRIP_NOPS ($4);
1908 if ((TREE_CODE ($4) == ADDR_EXPR
1909 && TREE_CODE (TREE_OPERAND ($4, 0)) == STRING_CST)
1910 || TREE_CODE ($4) == STRING_CST)
1911 expand_asm ($4);
1912 else
1913 error ("argument of `asm' is not a constant string"); }
1914 /* This is the case with just output operands. */
1915 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ')' ';'
1916 { stmt_count++;
1917 emit_line_note ($<filename>-1, $<lineno>0);
1918 c_expand_asm_operands ($4, $6, NULL_TREE, NULL_TREE,
1919 $2 == ridpointers[(int)RID_VOLATILE],
1920 input_filename, lineno); }
1921 /* This is the case with input operands as well. */
1922 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':' asm_operands ')' ';'
1923 { stmt_count++;
1924 emit_line_note ($<filename>-1, $<lineno>0);
1925 c_expand_asm_operands ($4, $6, $8, NULL_TREE,
1926 $2 == ridpointers[(int)RID_VOLATILE],
1927 input_filename, lineno); }
1928 /* This is the case with clobbered registers as well. */
1929 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':'
1930 asm_operands ':' asm_clobbers ')' ';'
1931 { stmt_count++;
1932 emit_line_note ($<filename>-1, $<lineno>0);
1933 c_expand_asm_operands ($4, $6, $8, $10,
1934 $2 == ridpointers[(int)RID_VOLATILE],
1935 input_filename, lineno); }
1936 | GOTO identifier ';'
1937 { tree decl;
1938 stmt_count++;
1939 emit_line_note ($<filename>-1, $<lineno>0);
1940 decl = lookup_label ($2);
1941 if (decl != 0)
1943 TREE_USED (decl) = 1;
1944 expand_goto (decl);
1947 | GOTO '*' expr ';'
1948 { if (pedantic)
1949 pedwarn ("ANSI C forbids `goto *expr;'");
1950 stmt_count++;
1951 emit_line_note ($<filename>-1, $<lineno>0);
1952 expand_computed_goto (convert (ptr_type_node, $3)); }
1953 | ';'
1956 all_iter_stmt:
1957 all_iter_stmt_simple
1958 /* | all_iter_stmt_with_decl */
1961 all_iter_stmt_simple:
1962 FOR '(' primary ')'
1964 /* The value returned by this action is */
1965 /* 1 if everything is OK */
1966 /* 0 in case of error or already bound iterator */
1968 $<itype>$ = 0;
1969 if (TREE_CODE ($3) != VAR_DECL)
1970 error ("invalid `for (ITERATOR)' syntax");
1971 else if (! ITERATOR_P ($3))
1972 error ("`%s' is not an iterator",
1973 IDENTIFIER_POINTER (DECL_NAME ($3)));
1974 else if (ITERATOR_BOUND_P ($3))
1975 error ("`for (%s)' inside expansion of same iterator",
1976 IDENTIFIER_POINTER (DECL_NAME ($3)));
1977 else
1979 $<itype>$ = 1;
1980 iterator_for_loop_start ($3);
1983 lineno_labeled_stmt
1985 if ($<itype>5)
1986 iterator_for_loop_end ($3);
1989 /* This really should allow any kind of declaration,
1990 for generality. Fix it before turning it back on.
1992 all_iter_stmt_with_decl:
1993 FOR '(' ITERATOR pushlevel setspecs iterator_spec ')'
1995 */ /* The value returned by this action is */
1996 /* 1 if everything is OK */
1997 /* 0 in case of error or already bound iterator */
1999 iterator_for_loop_start ($6);
2001 lineno_labeled_stmt
2003 iterator_for_loop_end ($6);
2004 emit_line_note (input_filename, lineno);
2005 expand_end_bindings (getdecls (), 1, 0);
2006 $<ttype>$ = poplevel (1, 1, 0);
2007 if (yychar == CONSTANT || yychar == STRING)
2008 pop_momentary_nofree ();
2009 else
2010 pop_momentary ();
2014 /* Any kind of label, including jump labels and case labels.
2015 ANSI C accepts labels only before statements, but we allow them
2016 also at the end of a compound statement. */
2018 label: CASE expr_no_commas ':'
2019 { register tree value = check_case_value ($2);
2020 register tree label
2021 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
2023 stmt_count++;
2025 if (value != error_mark_node)
2027 tree duplicate;
2028 int success;
2030 if (pedantic && ! INTEGRAL_TYPE_P (TREE_TYPE (value)))
2031 pedwarn ("label must have integral type in ANSI C");
2033 success = pushcase (value, convert_and_check,
2034 label, &duplicate);
2036 if (success == 1)
2037 error ("case label not within a switch statement");
2038 else if (success == 2)
2040 error ("duplicate case value");
2041 error_with_decl (duplicate, "this is the first entry for that value");
2043 else if (success == 3)
2044 warning ("case value out of range");
2045 else if (success == 5)
2046 error ("case label within scope of cleanup or variable array");
2048 position_after_white_space (); }
2049 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
2050 { register tree value1 = check_case_value ($2);
2051 register tree value2 = check_case_value ($4);
2052 register tree label
2053 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
2055 if (pedantic)
2056 pedwarn ("ANSI C forbids case ranges");
2057 stmt_count++;
2059 if (value1 != error_mark_node && value2 != error_mark_node)
2061 tree duplicate;
2062 int success = pushcase_range (value1, value2,
2063 convert_and_check, label,
2064 &duplicate);
2065 if (success == 1)
2066 error ("case label not within a switch statement");
2067 else if (success == 2)
2069 error ("duplicate case value");
2070 error_with_decl (duplicate, "this is the first entry for that value");
2072 else if (success == 3)
2073 warning ("case value out of range");
2074 else if (success == 4)
2075 warning ("empty case range");
2076 else if (success == 5)
2077 error ("case label within scope of cleanup or variable array");
2079 position_after_white_space (); }
2080 | DEFAULT ':'
2082 tree duplicate;
2083 register tree label
2084 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
2085 int success = pushcase (NULL_TREE, 0, label, &duplicate);
2086 stmt_count++;
2087 if (success == 1)
2088 error ("default label not within a switch statement");
2089 else if (success == 2)
2091 error ("multiple default labels in one switch");
2092 error_with_decl (duplicate, "this is the first default label");
2094 position_after_white_space (); }
2095 | identifier ':'
2096 { tree label = define_label (input_filename, lineno, $1);
2097 stmt_count++;
2098 emit_nop ();
2099 if (label)
2100 expand_label (label);
2101 position_after_white_space (); }
2104 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
2106 maybe_type_qual:
2107 /* empty */
2108 { emit_line_note (input_filename, lineno);
2109 $$ = NULL_TREE; }
2110 | TYPE_QUAL
2111 { emit_line_note (input_filename, lineno); }
2114 xexpr:
2115 /* empty */
2116 { $$ = NULL_TREE; }
2117 | expr
2120 /* These are the operands other than the first string and colon
2121 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
2122 asm_operands: /* empty */
2123 { $$ = NULL_TREE; }
2124 | nonnull_asm_operands
2127 nonnull_asm_operands:
2128 asm_operand
2129 | nonnull_asm_operands ',' asm_operand
2130 { $$ = chainon ($1, $3); }
2133 asm_operand:
2134 STRING '(' expr ')'
2135 { $$ = build_tree_list ($1, $3); }
2138 asm_clobbers:
2139 string
2140 { $$ = tree_cons (NULL_TREE, combine_strings ($1), NULL_TREE); }
2141 | asm_clobbers ',' string
2142 { $$ = tree_cons (NULL_TREE, combine_strings ($3), $1); }
2145 /* This is what appears inside the parens in a function declarator.
2146 Its value is a list of ..._TYPE nodes. */
2147 parmlist:
2148 { pushlevel (0);
2149 clear_parm_order ();
2150 declare_parm_level (0); }
2151 parmlist_1
2152 { $$ = $2;
2153 parmlist_tags_warning ();
2154 poplevel (0, 0, 0); }
2157 parmlist_1:
2158 parmlist_2 ')'
2159 | parms ';'
2160 { tree parm;
2161 if (pedantic)
2162 pedwarn ("ANSI C forbids forward parameter declarations");
2163 /* Mark the forward decls as such. */
2164 for (parm = getdecls (); parm; parm = TREE_CHAIN (parm))
2165 TREE_ASM_WRITTEN (parm) = 1;
2166 clear_parm_order (); }
2167 parmlist_1
2168 { $$ = $4; }
2169 | error ')'
2170 { $$ = tree_cons (NULL_TREE, NULL_TREE, NULL_TREE); }
2173 /* This is what appears inside the parens in a function declarator.
2174 Is value is represented in the format that grokdeclarator expects. */
2175 parmlist_2: /* empty */
2176 { $$ = get_parm_info (0); }
2177 | ELLIPSIS
2178 { $$ = get_parm_info (0);
2179 /* Gcc used to allow this as an extension. However, it does
2180 not work for all targets, and thus has been disabled.
2181 Also, since func (...) and func () are indistinguishable,
2182 it caused problems with the code in expand_builtin which
2183 tries to verify that BUILT_IN_NEXT_ARG is being used
2184 correctly. */
2185 error ("ANSI C requires a named argument before `...'");
2187 | parms
2188 { $$ = get_parm_info (1); }
2189 | parms ',' ELLIPSIS
2190 { $$ = get_parm_info (0); }
2193 parms:
2194 parm
2195 { push_parm_decl ($1); }
2196 | parms ',' parm
2197 { push_parm_decl ($3); }
2200 /* A single parameter declaration or parameter type name,
2201 as found in a parmlist. */
2202 parm:
2203 typed_declspecs setspecs parm_declarator maybe_attribute
2204 { $$ = build_tree_list (build_tree_list (current_declspecs,
2205 $3),
2206 build_tree_list (prefix_attributes,
2207 $4));
2208 current_declspecs = TREE_VALUE (declspec_stack);
2209 prefix_attributes = TREE_PURPOSE (declspec_stack);
2210 declspec_stack = TREE_CHAIN (declspec_stack);
2211 resume_momentary ($2); }
2212 | typed_declspecs setspecs notype_declarator maybe_attribute
2213 { $$ = build_tree_list (build_tree_list (current_declspecs,
2214 $3),
2215 build_tree_list (prefix_attributes,
2216 $4));
2217 current_declspecs = TREE_VALUE (declspec_stack);
2218 prefix_attributes = TREE_PURPOSE (declspec_stack);
2219 declspec_stack = TREE_CHAIN (declspec_stack);
2220 resume_momentary ($2); }
2221 | typed_declspecs setspecs absdcl maybe_attribute
2222 { $$ = build_tree_list (build_tree_list (current_declspecs,
2223 $3),
2224 build_tree_list (prefix_attributes,
2225 $4));
2226 current_declspecs = TREE_VALUE (declspec_stack);
2227 prefix_attributes = TREE_PURPOSE (declspec_stack);
2228 declspec_stack = TREE_CHAIN (declspec_stack);
2229 resume_momentary ($2); }
2230 | declmods setspecs notype_declarator maybe_attribute
2231 { $$ = build_tree_list (build_tree_list (current_declspecs,
2232 $3),
2233 build_tree_list (prefix_attributes,
2234 $4));
2235 current_declspecs = TREE_VALUE (declspec_stack);
2236 prefix_attributes = TREE_PURPOSE (declspec_stack);
2237 declspec_stack = TREE_CHAIN (declspec_stack);
2238 resume_momentary ($2); }
2240 | declmods setspecs absdcl maybe_attribute
2241 { $$ = build_tree_list (build_tree_list (current_declspecs,
2242 $3),
2243 build_tree_list (prefix_attributes,
2244 $4));
2245 current_declspecs = TREE_VALUE (declspec_stack);
2246 prefix_attributes = TREE_PURPOSE (declspec_stack);
2247 declspec_stack = TREE_CHAIN (declspec_stack);
2248 resume_momentary ($2); }
2251 /* This is used in a function definition
2252 where either a parmlist or an identifier list is ok.
2253 Its value is a list of ..._TYPE nodes or a list of identifiers. */
2254 parmlist_or_identifiers:
2255 { pushlevel (0);
2256 clear_parm_order ();
2257 declare_parm_level (1); }
2258 parmlist_or_identifiers_1
2259 { $$ = $2;
2260 parmlist_tags_warning ();
2261 poplevel (0, 0, 0); }
2264 parmlist_or_identifiers_1:
2265 parmlist_1
2266 | identifiers ')'
2267 { tree t;
2268 for (t = $1; t; t = TREE_CHAIN (t))
2269 if (TREE_VALUE (t) == NULL_TREE)
2270 error ("`...' in old-style identifier list");
2271 $$ = tree_cons (NULL_TREE, NULL_TREE, $1); }
2274 /* A nonempty list of identifiers. */
2275 identifiers:
2276 IDENTIFIER
2277 { $$ = build_tree_list (NULL_TREE, $1); }
2278 | identifiers ',' IDENTIFIER
2279 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2282 /* A nonempty list of identifiers, including typenames. */
2283 identifiers_or_typenames:
2284 identifier
2285 { $$ = build_tree_list (NULL_TREE, $1); }
2286 | identifiers_or_typenames ',' identifier
2287 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2290 extension:
2291 EXTENSION
2292 { $<itype>$ = pedantic;
2293 pedantic = 0; }
2296 /* Objective-C productions. */
2298 objcdef:
2299 classdef
2300 | classdecl
2301 | aliasdecl
2302 | protocoldef
2303 | methoddef
2304 | END
2306 if (objc_implementation_context)
2308 finish_class (objc_implementation_context);
2309 objc_ivar_chain = NULL_TREE;
2310 objc_implementation_context = NULL_TREE;
2312 else
2313 warning ("`@end' must appear in an implementation context");
2317 /* A nonempty list of identifiers. */
2318 identifier_list:
2319 identifier
2320 { $$ = build_tree_list (NULL_TREE, $1); }
2321 | identifier_list ',' identifier
2322 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2325 classdecl:
2326 CLASS identifier_list ';'
2328 objc_declare_class ($2);
2331 aliasdecl:
2332 ALIAS identifier identifier ';'
2334 objc_declare_alias ($2, $3);
2337 classdef:
2338 INTERFACE identifier protocolrefs '{'
2340 objc_interface_context = objc_ivar_context
2341 = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, $3);
2342 objc_public_flag = 0;
2344 ivar_decl_list '}'
2346 continue_class (objc_interface_context);
2348 methodprotolist
2351 finish_class (objc_interface_context);
2352 objc_interface_context = NULL_TREE;
2355 | INTERFACE identifier protocolrefs
2357 objc_interface_context
2358 = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, $3);
2359 continue_class (objc_interface_context);
2361 methodprotolist
2364 finish_class (objc_interface_context);
2365 objc_interface_context = NULL_TREE;
2368 | INTERFACE identifier ':' identifier protocolrefs '{'
2370 objc_interface_context = objc_ivar_context
2371 = start_class (CLASS_INTERFACE_TYPE, $2, $4, $5);
2372 objc_public_flag = 0;
2374 ivar_decl_list '}'
2376 continue_class (objc_interface_context);
2378 methodprotolist
2381 finish_class (objc_interface_context);
2382 objc_interface_context = NULL_TREE;
2385 | INTERFACE identifier ':' identifier protocolrefs
2387 objc_interface_context
2388 = start_class (CLASS_INTERFACE_TYPE, $2, $4, $5);
2389 continue_class (objc_interface_context);
2391 methodprotolist
2394 finish_class (objc_interface_context);
2395 objc_interface_context = NULL_TREE;
2398 | IMPLEMENTATION identifier '{'
2400 objc_implementation_context = objc_ivar_context
2401 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, NULL_TREE, NULL_TREE);
2402 objc_public_flag = 0;
2404 ivar_decl_list '}'
2406 objc_ivar_chain
2407 = continue_class (objc_implementation_context);
2410 | IMPLEMENTATION identifier
2412 objc_implementation_context
2413 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, NULL_TREE, NULL_TREE);
2414 objc_ivar_chain
2415 = continue_class (objc_implementation_context);
2418 | IMPLEMENTATION identifier ':' identifier '{'
2420 objc_implementation_context = objc_ivar_context
2421 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2422 objc_public_flag = 0;
2424 ivar_decl_list '}'
2426 objc_ivar_chain
2427 = continue_class (objc_implementation_context);
2430 | IMPLEMENTATION identifier ':' identifier
2432 objc_implementation_context
2433 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2434 objc_ivar_chain
2435 = continue_class (objc_implementation_context);
2438 | INTERFACE identifier '(' identifier ')' protocolrefs
2440 objc_interface_context
2441 = start_class (CATEGORY_INTERFACE_TYPE, $2, $4, $6);
2442 continue_class (objc_interface_context);
2444 methodprotolist
2447 finish_class (objc_interface_context);
2448 objc_interface_context = NULL_TREE;
2451 | IMPLEMENTATION identifier '(' identifier ')'
2453 objc_implementation_context
2454 = start_class (CATEGORY_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2455 objc_ivar_chain
2456 = continue_class (objc_implementation_context);
2460 protocoldef:
2461 PROTOCOL identifier protocolrefs
2463 remember_protocol_qualifiers ();
2464 objc_interface_context
2465 = start_protocol(PROTOCOL_INTERFACE_TYPE, $2, $3);
2467 methodprotolist END
2469 forget_protocol_qualifiers();
2470 finish_protocol(objc_interface_context);
2471 objc_interface_context = NULL_TREE;
2475 protocolrefs:
2476 /* empty */
2478 $$ = NULL_TREE;
2480 | non_empty_protocolrefs
2483 non_empty_protocolrefs:
2484 ARITHCOMPARE identifier_list ARITHCOMPARE
2486 if ($1 == LT_EXPR && $3 == GT_EXPR)
2487 $$ = $2;
2488 else
2489 YYERROR1;
2493 ivar_decl_list:
2494 ivar_decl_list visibility_spec ivar_decls
2495 | ivar_decls
2498 visibility_spec:
2499 PRIVATE { objc_public_flag = 2; }
2500 | PROTECTED { objc_public_flag = 0; }
2501 | PUBLIC { objc_public_flag = 1; }
2504 ivar_decls:
2505 /* empty */
2507 $$ = NULL_TREE;
2509 | ivar_decls ivar_decl ';'
2510 | ivar_decls ';'
2512 if (pedantic)
2513 pedwarn ("extra semicolon in struct or union specified");
2518 /* There is a shift-reduce conflict here, because `components' may
2519 start with a `typename'. It happens that shifting (the default resolution)
2520 does the right thing, because it treats the `typename' as part of
2521 a `typed_typespecs'.
2523 It is possible that this same technique would allow the distinction
2524 between `notype_initdecls' and `initdecls' to be eliminated.
2525 But I am being cautious and not trying it. */
2527 ivar_decl:
2528 typed_typespecs setspecs ivars
2529 { $$ = $3;
2530 current_declspecs = TREE_VALUE (declspec_stack);
2531 prefix_attributes = TREE_PURPOSE (declspec_stack);
2532 declspec_stack = TREE_CHAIN (declspec_stack);
2533 resume_momentary ($2); }
2534 | nonempty_type_quals setspecs ivars
2535 { $$ = $3;
2536 current_declspecs = TREE_VALUE (declspec_stack);
2537 prefix_attributes = TREE_PURPOSE (declspec_stack);
2538 declspec_stack = TREE_CHAIN (declspec_stack);
2539 resume_momentary ($2); }
2540 | error
2541 { $$ = NULL_TREE; }
2544 ivars:
2545 /* empty */
2546 { $$ = NULL_TREE; }
2547 | ivar_declarator
2548 | ivars ',' ivar_declarator
2551 ivar_declarator:
2552 declarator
2554 $$ = add_instance_variable (objc_ivar_context,
2555 objc_public_flag,
2556 $1, current_declspecs,
2557 NULL_TREE);
2559 | declarator ':' expr_no_commas
2561 $$ = add_instance_variable (objc_ivar_context,
2562 objc_public_flag,
2563 $1, current_declspecs, $3);
2565 | ':' expr_no_commas
2567 $$ = add_instance_variable (objc_ivar_context,
2568 objc_public_flag,
2569 NULL_TREE,
2570 current_declspecs, $2);
2574 methoddef:
2577 remember_protocol_qualifiers ();
2578 if (objc_implementation_context)
2579 objc_inherit_code = CLASS_METHOD_DECL;
2580 else
2581 fatal ("method definition not in class context");
2583 methoddecl
2585 forget_protocol_qualifiers ();
2586 add_class_method (objc_implementation_context, $3);
2587 start_method_def ($3);
2588 objc_method_context = $3;
2590 optarglist
2592 continue_method_def ();
2594 compstmt_or_error
2596 finish_method_def ();
2597 objc_method_context = NULL_TREE;
2600 | '-'
2602 remember_protocol_qualifiers ();
2603 if (objc_implementation_context)
2604 objc_inherit_code = INSTANCE_METHOD_DECL;
2605 else
2606 fatal ("method definition not in class context");
2608 methoddecl
2610 forget_protocol_qualifiers ();
2611 add_instance_method (objc_implementation_context, $3);
2612 start_method_def ($3);
2613 objc_method_context = $3;
2615 optarglist
2617 continue_method_def ();
2619 compstmt_or_error
2621 finish_method_def ();
2622 objc_method_context = NULL_TREE;
2626 /* the reason for the strange actions in this rule
2627 is so that notype_initdecls when reached via datadef
2628 can find a valid list of type and sc specs in $0. */
2630 methodprotolist:
2631 /* empty */
2632 | {$<ttype>$ = NULL_TREE; } methodprotolist2
2635 methodprotolist2: /* eliminates a shift/reduce conflict */
2636 methodproto
2637 | datadef
2638 | methodprotolist2 methodproto
2639 | methodprotolist2 {$<ttype>$ = NULL_TREE; } datadef
2642 semi_or_error:
2644 | error
2647 methodproto:
2650 /* Remember protocol qualifiers in prototypes. */
2651 remember_protocol_qualifiers ();
2652 objc_inherit_code = CLASS_METHOD_DECL;
2654 methoddecl
2656 /* Forget protocol qualifiers here. */
2657 forget_protocol_qualifiers ();
2658 add_class_method (objc_interface_context, $3);
2660 semi_or_error
2662 | '-'
2664 /* Remember protocol qualifiers in prototypes. */
2665 remember_protocol_qualifiers ();
2666 objc_inherit_code = INSTANCE_METHOD_DECL;
2668 methoddecl
2670 /* Forget protocol qualifiers here. */
2671 forget_protocol_qualifiers ();
2672 add_instance_method (objc_interface_context, $3);
2674 semi_or_error
2677 methoddecl:
2678 '(' typename ')' unaryselector
2680 $$ = build_method_decl (objc_inherit_code, $2, $4, NULL_TREE);
2683 | unaryselector
2685 $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, NULL_TREE);
2688 | '(' typename ')' keywordselector optparmlist
2690 $$ = build_method_decl (objc_inherit_code, $2, $4, $5);
2693 | keywordselector optparmlist
2695 $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, $2);
2699 /* "optarglist" assumes that start_method_def has already been called...
2700 if it is not, the "xdecls" will not be placed in the proper scope */
2702 optarglist:
2703 /* empty */
2704 | ';' myxdecls
2707 /* to get around the following situation: "int foo (int a) int b; {}" that
2708 is synthesized when parsing "- a:a b:b; id c; id d; { ... }" */
2710 myxdecls:
2711 /* empty */
2712 | mydecls
2715 mydecls:
2716 mydecl
2717 | errstmt
2718 | mydecls mydecl
2719 | mydecl errstmt
2722 mydecl:
2723 typed_declspecs setspecs myparms ';'
2724 { current_declspecs = TREE_VALUE (declspec_stack);
2725 prefix_attributes = TREE_PURPOSE (declspec_stack);
2726 declspec_stack = TREE_CHAIN (declspec_stack);
2727 resume_momentary ($2); }
2728 | typed_declspecs ';'
2729 { shadow_tag ($1); }
2730 | declmods ';'
2731 { pedwarn ("empty declaration"); }
2734 myparms:
2735 myparm
2736 { push_parm_decl ($1); }
2737 | myparms ',' myparm
2738 { push_parm_decl ($3); }
2741 /* A single parameter declaration or parameter type name,
2742 as found in a parmlist. DOES NOT ALLOW AN INITIALIZER OR ASMSPEC */
2744 myparm:
2745 parm_declarator maybe_attribute
2746 { $$ = build_tree_list (build_tree_list (current_declspecs,
2747 $1),
2748 build_tree_list (prefix_attributes,
2749 $2)); }
2750 | notype_declarator maybe_attribute
2751 { $$ = build_tree_list (build_tree_list (current_declspecs,
2752 $1),
2753 build_tree_list (prefix_attributes,
2754 $2)); }
2755 | absdcl maybe_attribute
2756 { $$ = build_tree_list (build_tree_list (current_declspecs,
2757 $1),
2758 build_tree_list (prefix_attributes,
2759 $2)); }
2762 optparmlist:
2763 /* empty */
2765 $$ = NULL_TREE;
2767 | ',' ELLIPSIS
2769 /* oh what a kludge! */
2770 $$ = (tree)1;
2772 | ','
2774 pushlevel (0);
2776 parmlist_2
2778 /* returns a tree list node generated by get_parm_info */
2779 $$ = $3;
2780 poplevel (0, 0, 0);
2784 unaryselector:
2785 selector
2788 keywordselector:
2789 keyworddecl
2791 | keywordselector keyworddecl
2793 $$ = chainon ($1, $2);
2797 selector:
2798 IDENTIFIER
2799 | TYPENAME
2800 | OBJECTNAME
2801 | reservedwords
2804 reservedwords:
2805 ENUM { $$ = get_identifier (token_buffer); }
2806 | STRUCT { $$ = get_identifier (token_buffer); }
2807 | UNION { $$ = get_identifier (token_buffer); }
2808 | IF { $$ = get_identifier (token_buffer); }
2809 | ELSE { $$ = get_identifier (token_buffer); }
2810 | WHILE { $$ = get_identifier (token_buffer); }
2811 | DO { $$ = get_identifier (token_buffer); }
2812 | FOR { $$ = get_identifier (token_buffer); }
2813 | SWITCH { $$ = get_identifier (token_buffer); }
2814 | CASE { $$ = get_identifier (token_buffer); }
2815 | DEFAULT { $$ = get_identifier (token_buffer); }
2816 | BREAK { $$ = get_identifier (token_buffer); }
2817 | CONTINUE { $$ = get_identifier (token_buffer); }
2818 | RETURN { $$ = get_identifier (token_buffer); }
2819 | GOTO { $$ = get_identifier (token_buffer); }
2820 | ASM_KEYWORD { $$ = get_identifier (token_buffer); }
2821 | SIZEOF { $$ = get_identifier (token_buffer); }
2822 | TYPEOF { $$ = get_identifier (token_buffer); }
2823 | ALIGNOF { $$ = get_identifier (token_buffer); }
2824 | TYPESPEC | TYPE_QUAL
2827 keyworddecl:
2828 selector ':' '(' typename ')' identifier
2830 $$ = build_keyword_decl ($1, $4, $6);
2833 | selector ':' identifier
2835 $$ = build_keyword_decl ($1, NULL_TREE, $3);
2838 | ':' '(' typename ')' identifier
2840 $$ = build_keyword_decl (NULL_TREE, $3, $5);
2843 | ':' identifier
2845 $$ = build_keyword_decl (NULL_TREE, NULL_TREE, $2);
2849 messageargs:
2850 selector
2851 | keywordarglist
2854 keywordarglist:
2855 keywordarg
2856 | keywordarglist keywordarg
2858 $$ = chainon ($1, $2);
2863 keywordexpr:
2864 nonnull_exprlist
2866 if (TREE_CHAIN ($1) == NULL_TREE)
2867 /* just return the expr., remove a level of indirection */
2868 $$ = TREE_VALUE ($1);
2869 else
2870 /* we have a comma expr., we will collapse later */
2871 $$ = $1;
2875 keywordarg:
2876 selector ':' keywordexpr
2878 $$ = build_tree_list ($1, $3);
2880 | ':' keywordexpr
2882 $$ = build_tree_list (NULL_TREE, $2);
2886 receiver:
2887 expr
2888 | CLASSNAME
2890 $$ = get_class_reference ($1);
2894 objcmessageexpr:
2896 { objc_receiver_context = 1; }
2897 receiver
2898 { objc_receiver_context = 0; }
2899 messageargs ']'
2901 $$ = build_tree_list ($3, $5);
2905 selectorarg:
2906 selector
2907 | keywordnamelist
2910 keywordnamelist:
2911 keywordname
2912 | keywordnamelist keywordname
2914 $$ = chainon ($1, $2);
2918 keywordname:
2919 selector ':'
2921 $$ = build_tree_list ($1, NULL_TREE);
2923 | ':'
2925 $$ = build_tree_list (NULL_TREE, NULL_TREE);
2929 objcselectorexpr:
2930 SELECTOR '(' selectorarg ')'
2932 $$ = $3;
2936 objcprotocolexpr:
2937 PROTOCOL '(' identifier ')'
2939 $$ = $3;
2943 /* extension to support C-structures in the archiver */
2945 objcencodeexpr:
2946 ENCODE '(' typename ')'
2948 $$ = groktypename ($3);