OSDN Git Service

Rewrite attribute parsing; update the expected conflicts and state
[pf3gnuchains/gcc-fork.git] / gcc / c-parse.in
1 /* YACC parser for C syntax and for Objective C.  -*-c-*-
2    Copyright (C) 1987, 88, 89, 92, 93, 1994 Free Software Foundation, Inc.
3
4 This file is part of GNU CC.
5
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING.  If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
19
20 /* This file defines the grammar of C and that of Objective C.
21    ifobjc ... end ifobjc  conditionals contain code for Objective C only.
22    ifc ... end ifc  conditionals contain code for C only.
23    Sed commands in Makefile.in are used to convert this file into
24    c-parse.y and into objc-parse.y.  */
25
26 /* To whomever it may concern: I have heard that such a thing was once
27 written by AT&T, but I have never seen it.  */
28
29 ifobjc
30 %expect 22
31 end ifobjc
32 ifc
33 %expect 10
34
35 /* These are the 10 conflicts you should get in parse.output;
36    the state numbers may vary if minor changes in the grammar are made.
37
38 State 41 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
39 State 97 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
40 State 104 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
41 State 108 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
42 State 124 contains 1 shift/reduce conflict.  (See comment at component_decl.)
43 State 191 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
44 State 204 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
45 State 210 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
46 State 449 contains 2 shift/reduce conflicts.  (Four ways to parse this.)
47 */
48 end ifc
49
50 %{
51 #include <stdio.h>
52 #include <errno.h>
53 #include <setjmp.h>
54
55 #include "config.h"
56 #include "tree.h"
57 #include "input.h"
58 #include "c-lex.h"
59 #include "c-tree.h"
60 #include "flags.h"
61
62 #ifdef MULTIBYTE_CHARS
63 #include <stdlib.h>
64 #include <locale.h>
65 #endif
66
67 ifobjc
68 #include "objc-act.h"
69 end ifobjc
70
71 /* Since parsers are distinct for each language, put the language string
72    definition here.  */
73 ifobjc
74 char *language_string = "GNU Obj-C";
75 end ifobjc
76 ifc
77 char *language_string = "GNU C";
78 end ifc
79
80 #ifndef errno
81 extern int errno;
82 #endif
83
84 void yyerror ();
85
86 /* Like YYERROR but do call yyerror.  */
87 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
88
89 /* Cause the `yydebug' variable to be defined.  */
90 #define YYDEBUG 1
91 %}
92
93 %start program
94
95 %union {long itype; tree ttype; enum tree_code code;
96         char *filename; int lineno; }
97
98 /* All identifiers that are not reserved words
99    and are not declared typedefs in the current block */
100 %token IDENTIFIER
101
102 /* All identifiers that are declared typedefs in the current block.
103    In some contexts, they are treated just like IDENTIFIER,
104    but they can also serve as typespecs in declarations.  */
105 %token TYPENAME
106
107 /* Reserved words that specify storage class.
108    yylval contains an IDENTIFIER_NODE which indicates which one.  */
109 %token SCSPEC
110
111 /* Reserved words that specify type.
112    yylval contains an IDENTIFIER_NODE which indicates which one.  */
113 %token TYPESPEC
114
115 /* Reserved words that qualify type: "const" or "volatile".
116    yylval contains an IDENTIFIER_NODE which indicates which one.  */
117 %token TYPE_QUAL
118
119 /* Character or numeric constants.
120    yylval is the node for the constant.  */
121 %token CONSTANT
122
123 /* String constants in raw form.
124    yylval is a STRING_CST node.  */
125 %token STRING
126
127 /* "...", used for functions with variable arglists.  */
128 %token ELLIPSIS
129
130 /* the reserved words */
131 /* SCO include files test "ASM", so use something else. */
132 %token SIZEOF ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
133 %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD TYPEOF ALIGNOF ALIGN
134 %token ATTRIBUTE EXTENSION LABEL
135 %token REALPART IMAGPART
136
137 /* Add precedence rules to solve dangling else s/r conflict */
138 %nonassoc IF
139 %nonassoc ELSE
140
141 /* Define the operator tokens and their precedences.
142    The value is an integer because, if used, it is the tree code
143    to use in the expression made from the operator.  */
144
145 %right <code> ASSIGN '='
146 %right <code> '?' ':'
147 %left <code> OROR
148 %left <code> ANDAND
149 %left <code> '|'
150 %left <code> '^'
151 %left <code> '&'
152 %left <code> EQCOMPARE
153 %left <code> ARITHCOMPARE
154 %left <code> LSHIFT RSHIFT
155 %left <code> '+' '-'
156 %left <code> '*' '/' '%'
157 %right <code> UNARY PLUSPLUS MINUSMINUS
158 %left HYPERUNARY
159 %left <code> POINTSAT '.' '(' '['
160
161 /* The Objective-C keywords.  These are included in C and in
162    Objective C, so that the token codes are the same in both.  */
163 %token INTERFACE IMPLEMENTATION END SELECTOR DEFS ENCODE
164 %token CLASSNAME PUBLIC PRIVATE PROTECTED PROTOCOL OBJECTNAME CLASS ALIAS
165
166 /* Objective-C string constants in raw form.
167    yylval is an OBJC_STRING_CST node.  */
168 %token OBJC_STRING
169
170
171 %type <code> unop
172
173 %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist exprlist
174 %type <ttype> expr_no_commas cast_expr unary_expr primary string STRING
175 %type <ttype> typed_declspecs reserved_declspecs
176 %type <ttype> typed_typespecs reserved_typespecquals
177 %type <ttype> declmods typespec typespecqual_reserved
178 %type <ttype> SCSPEC TYPESPEC TYPE_QUAL nonempty_type_quals maybe_type_qual
179 %type <ttype> initdecls notype_initdecls initdcl notype_initdcl
180 %type <ttype> init maybeasm
181 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
182 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
183 %type <ttype> any_word
184
185 %type <ttype> compstmt
186
187 %type <ttype> declarator
188 %type <ttype> notype_declarator after_type_declarator
189 %type <ttype> parm_declarator
190
191 %type <ttype> structsp component_decl_list component_decl_list2
192 %type <ttype> component_decl components component_declarator
193 %type <ttype> enumlist enumerator
194 %type <ttype> typename absdcl absdcl1 type_quals
195 %type <ttype> xexpr parms parm identifiers
196
197 %type <ttype> parmlist parmlist_1 parmlist_2
198 %type <ttype> parmlist_or_identifiers parmlist_or_identifiers_1
199 %type <ttype> identifiers_or_typenames
200
201 %type <itype> setspecs
202
203 %type <filename> save_filename
204 %type <lineno> save_lineno
205 \f
206 ifobjc
207 /* the Objective-C nonterminals */
208
209 %type <ttype> ivar_decl_list ivar_decls ivar_decl ivars ivar_declarator
210 %type <ttype> methoddecl unaryselector keywordselector selector
211 %type <ttype> keyworddecl receiver objcmessageexpr messageargs
212 %type <ttype> keywordexpr keywordarglist keywordarg
213 %type <ttype> myparms myparm optparmlist reservedwords objcselectorexpr
214 %type <ttype> selectorarg keywordnamelist keywordname objcencodeexpr
215 %type <ttype> objc_string protocolrefs identifier_list objcprotocolexpr
216 %type <ttype> CLASSNAME OBJC_STRING OBJECTNAME
217 end ifobjc
218 \f
219 %{
220 /* Number of statements (loosely speaking) seen so far.  */
221 static int stmt_count;
222
223 /* Input file and line number of the end of the body of last simple_if;
224    used by the stmt-rule immediately after simple_if returns.  */
225 static char *if_stmt_file;
226 static int if_stmt_line;
227
228 /* List of types and structure classes of the current declaration.  */
229 static tree current_declspecs;
230
231 /* Stack of saved values of current_declspecs.  */
232 static tree declspec_stack;
233
234 /* 1 if we explained undeclared var errors.  */
235 static int undeclared_variable_notice;
236
237 ifobjc
238 /* Objective-C specific information */
239
240 tree objc_interface_context;
241 tree objc_implementation_context;
242 tree objc_method_context;
243 tree objc_ivar_chain;
244 tree objc_ivar_context;
245 enum tree_code objc_inherit_code;
246 int objc_receiver_context;
247 int objc_public_flag;
248
249 end ifobjc
250
251 /* Tell yyparse how to print a token's value, if yydebug is set.  */
252
253 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
254 extern void yyprint ();
255 %}
256 \f
257 %%
258 program: /* empty */
259                 { if (pedantic)
260                     pedwarn ("ANSI C forbids an empty source file");
261 ifobjc
262                   objc_finish ();
263 end ifobjc
264                 }
265         | extdefs
266                 {
267                   /* In case there were missing closebraces,
268                      get us back to the global binding level.  */
269                   while (! global_bindings_p ())
270                     poplevel (0, 0, 0);
271 ifobjc
272                   objc_finish ();
273 end ifobjc
274                 }
275         ;
276
277 /* the reason for the strange actions in this rule
278  is so that notype_initdecls when reached via datadef
279  can find a valid list of type and sc specs in $0. */
280
281 extdefs:
282         {$<ttype>$ = NULL_TREE; } extdef
283         | extdefs {$<ttype>$ = NULL_TREE; } extdef
284         ;
285
286 extdef:
287         fndef
288         | datadef
289 ifobjc
290         | objcdef
291 end ifobjc
292         | ASM_KEYWORD '(' expr ')' ';'
293                 { STRIP_NOPS ($3);
294                   if ((TREE_CODE ($3) == ADDR_EXPR
295                        && TREE_CODE (TREE_OPERAND ($3, 0)) == STRING_CST)
296                       || TREE_CODE ($3) == STRING_CST)
297                     assemble_asm ($3);
298                   else
299                     error ("argument of `asm' is not a constant string"); }
300         ;
301
302 datadef:
303           setspecs notype_initdecls ';'
304                 { if (pedantic)
305                     error ("ANSI C forbids data definition with no type or storage class");
306                   else if (!flag_traditional)
307                     warning ("data definition has no type or storage class"); }
308         | declmods setspecs notype_initdecls ';'
309           {}
310         | typed_declspecs setspecs initdecls ';'
311           {}
312         | declmods ';'
313           { pedwarn ("empty declaration"); }
314         | typed_declspecs ';'
315           { shadow_tag ($1); }
316         | error ';'
317         | error '}'
318         | ';'
319                 { if (pedantic)
320                     pedwarn ("ANSI C does not allow extra `;' outside of a function"); }
321         ;
322 \f
323 fndef:
324           typed_declspecs setspecs declarator
325                 { if (! start_function ($1, $3, 0))
326                     YYERROR1;
327                   reinit_parse_for_function (); }
328           xdecls
329                 { store_parm_decls (); }
330           compstmt_or_error
331                 { finish_function (0); }
332         | typed_declspecs setspecs declarator error
333                 { }
334         | declmods setspecs notype_declarator
335                 { if (! start_function ($1, $3, 0))
336                     YYERROR1;
337                   reinit_parse_for_function (); }
338           xdecls
339                 { store_parm_decls (); }
340           compstmt_or_error
341                 { finish_function (0); }
342         | declmods setspecs notype_declarator error
343                 { }
344         | setspecs notype_declarator
345                 { if (! start_function (NULL_TREE, $2, 0))
346                     YYERROR1;
347                   reinit_parse_for_function (); }
348           xdecls
349                 { store_parm_decls (); }
350           compstmt_or_error
351                 { finish_function (0); }
352         | setspecs notype_declarator error
353                 { }
354         ;
355
356 identifier:
357         IDENTIFIER
358         | TYPENAME
359 ifobjc
360         | OBJECTNAME
361         | CLASSNAME
362 end ifobjc
363         ;
364
365 unop:     '&'
366                 { $$ = ADDR_EXPR; }
367         | '-'
368                 { $$ = NEGATE_EXPR; }
369         | '+'
370                 { $$ = CONVERT_EXPR; }
371         | PLUSPLUS
372                 { $$ = PREINCREMENT_EXPR; }
373         | MINUSMINUS
374                 { $$ = PREDECREMENT_EXPR; }
375         | '~'
376                 { $$ = BIT_NOT_EXPR; }
377         | '!'
378                 { $$ = TRUTH_NOT_EXPR; }
379         ;
380
381 expr:   nonnull_exprlist
382                 { $$ = build_compound_expr ($1); }
383         ;
384
385 exprlist:
386           /* empty */
387                 { $$ = NULL_TREE; }
388         | nonnull_exprlist
389         ;
390
391 nonnull_exprlist:
392         expr_no_commas
393                 { $$ = build_tree_list (NULL_TREE, $1); }
394         | nonnull_exprlist ',' expr_no_commas
395                 { chainon ($1, build_tree_list (NULL_TREE, $3)); }
396         ;
397
398 unary_expr:
399         primary
400         | '*' cast_expr   %prec UNARY
401                 { $$ = build_indirect_ref ($2, "unary *"); }
402         /* __extension__ turns off -pedantic for following primary.  */
403         | EXTENSION
404                 { $<itype>1 = pedantic;
405                   pedantic = 0; }
406           cast_expr       %prec UNARY
407                 { $$ = $3;
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 (label == 0)
416                     $$ = null_pointer_node;
417                   else
418                     {
419                       TREE_USED (label) = 1;
420                       $$ = build1 (ADDR_EXPR, ptr_type_node, label);
421                       TREE_CONSTANT ($$) = 1;
422                     }
423                 }
424 /* This seems to be impossible on some machines, so let's turn it off.
425    You can use __builtin_next_arg to find the anonymous stack args.
426         | '&' ELLIPSIS
427                 { tree types = TYPE_ARG_TYPES (TREE_TYPE (current_function_decl));
428                   $$ = error_mark_node;
429                   if (TREE_VALUE (tree_last (types)) == void_type_node)
430                     error ("`&...' used in function with fixed number of arguments");
431                   else
432                     {
433                       if (pedantic)
434                         pedwarn ("ANSI C forbids `&...'");
435                       $$ = tree_last (DECL_ARGUMENTS (current_function_decl));
436                       $$ = build_unary_op (ADDR_EXPR, $$, 0);
437                     } }
438 */
439         | SIZEOF unary_expr  %prec UNARY
440                 { if (TREE_CODE ($2) == COMPONENT_REF
441                       && DECL_BIT_FIELD (TREE_OPERAND ($2, 1)))
442                     error ("`sizeof' applied to a bit-field");
443                   $$ = c_sizeof (TREE_TYPE ($2)); }
444         | SIZEOF '(' typename ')'  %prec HYPERUNARY
445                 { $$ = c_sizeof (groktypename ($3)); }
446         | ALIGNOF unary_expr  %prec UNARY
447                 { $$ = c_alignof_expr ($2); }
448         | ALIGNOF '(' typename ')'  %prec HYPERUNARY
449                 { $$ = c_alignof (groktypename ($3)); }
450         | REALPART cast_expr %prec UNARY
451                 { $$ = build_unary_op (REALPART_EXPR, $2, 0); }
452         | IMAGPART cast_expr %prec UNARY
453                 { $$ = build_unary_op (IMAGPART_EXPR, $2, 0); }
454         ;
455
456 cast_expr:
457         unary_expr
458         | '(' typename ')' cast_expr  %prec UNARY
459                 { tree type = groktypename ($2);
460                   $$ = build_c_cast (type, $4); }
461         | '(' typename ')' '{' 
462                 { start_init (NULL_TREE, NULL, 0);
463                   $2 = groktypename ($2);
464                   really_start_incremental_init ($2); }
465           initlist_maybe_comma '}'  %prec UNARY
466                 { char *name;
467                   tree result = pop_init_level (0);
468                   tree type = $2;
469                   finish_init ();
470
471                   if (pedantic)
472                     pedwarn ("ANSI C forbids constructor expressions");
473                   if (TYPE_NAME (type) != 0)
474                     {
475                       if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
476                         name = IDENTIFIER_POINTER (TYPE_NAME (type));
477                       else
478                         name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
479                     }
480                   else
481                     name = "";
482                   $$ = result;
483                   if (TREE_CODE (type) == ARRAY_TYPE && TYPE_SIZE (type) == 0)
484                     {
485                       int failure = complete_array_type (type, $$, 1);
486                       if (failure)
487                         abort ();
488                     }
489                 }
490         ;
491
492 expr_no_commas:
493           cast_expr
494         | expr_no_commas '+' expr_no_commas
495                 { $$ = parser_build_binary_op ($2, $1, $3); }
496         | expr_no_commas '-' expr_no_commas
497                 { $$ = parser_build_binary_op ($2, $1, $3); }
498         | expr_no_commas '*' expr_no_commas
499                 { $$ = parser_build_binary_op ($2, $1, $3); }
500         | expr_no_commas '/' expr_no_commas
501                 { $$ = parser_build_binary_op ($2, $1, $3); }
502         | expr_no_commas '%' expr_no_commas
503                 { $$ = parser_build_binary_op ($2, $1, $3); }
504         | expr_no_commas LSHIFT expr_no_commas
505                 { $$ = parser_build_binary_op ($2, $1, $3); }
506         | expr_no_commas RSHIFT expr_no_commas
507                 { $$ = parser_build_binary_op ($2, $1, $3); }
508         | expr_no_commas ARITHCOMPARE expr_no_commas
509                 { $$ = parser_build_binary_op ($2, $1, $3); }
510         | expr_no_commas EQCOMPARE 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 ANDAND expr_no_commas
519                 { $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $3); }
520         | expr_no_commas OROR expr_no_commas
521                 { $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $3); }
522         | expr_no_commas '?' xexpr ':' expr_no_commas
523                 { $$ = build_conditional_expr ($1, $3, $5); }
524         | expr_no_commas '=' expr_no_commas
525                 { $$ = build_modify_expr ($1, NOP_EXPR, $3);
526                   C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
527         | expr_no_commas ASSIGN expr_no_commas
528                 { $$ = build_modify_expr ($1, $2, $3);
529                   /* This inhibits warnings in truthvalue_conversion.  */
530                   C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK); }
531         ;
532
533 primary:
534         IDENTIFIER
535                 {
536                   $$ = lastiddecl;
537                   if (!$$ || $$ == error_mark_node)
538                     {
539                       if (yychar == YYEMPTY)
540                         yychar = YYLEX;
541                       if (yychar == '(')
542                         {
543 ifobjc
544                           tree decl;
545
546                           if (objc_receiver_context
547                               && ! (objc_receiver_context
548                                     && strcmp (IDENTIFIER_POINTER ($1), "super")))
549                             /* we have a message to super */
550                             $$ = get_super_receiver ();
551                           else if (objc_method_context
552                                    && (decl = is_ivar (objc_ivar_chain, $1)))
553                             {
554                               if (is_private (decl))
555                                 $$ = error_mark_node;
556                               else
557                                 $$ = build_ivar_reference ($1);
558                             }
559                           else
560 end ifobjc
561                             {
562                               /* Ordinary implicit function declaration.  */
563                               $$ = implicitly_declare ($1);
564                               assemble_external ($$);
565                               TREE_USED ($$) = 1;
566                             }
567                         }
568                       else if (current_function_decl == 0)
569                         {
570                           error ("`%s' undeclared here (not in a function)",
571                                  IDENTIFIER_POINTER ($1));
572                           $$ = error_mark_node;
573                         }
574                       else
575                         {
576 ifobjc
577                           tree decl;
578
579                           if (objc_receiver_context
580                               && ! strcmp (IDENTIFIER_POINTER ($1), "super"))
581                             /* we have a message to super */
582                             $$ = get_super_receiver ();
583                           else if (objc_method_context
584                                    && (decl = is_ivar (objc_ivar_chain, $1)))
585                             {
586                               if (is_private (decl))
587                                 $$ = error_mark_node;
588                               else
589                                 $$ = build_ivar_reference ($1);
590                             }
591                           else
592 end ifobjc
593                             {
594                               if (IDENTIFIER_GLOBAL_VALUE ($1) != error_mark_node
595                                   || IDENTIFIER_ERROR_LOCUS ($1) != current_function_decl)
596                                 {
597                                   error ("`%s' undeclared (first use this function)",
598                                          IDENTIFIER_POINTER ($1));
599
600                                   if (! undeclared_variable_notice)
601                                     {
602                                       error ("(Each undeclared identifier is reported only once");
603                                       error ("for each function it appears in.)");
604                                       undeclared_variable_notice = 1;
605                                     }
606                                 }
607                               $$ = error_mark_node;
608                               /* Prevent repeated error messages.  */
609                               IDENTIFIER_GLOBAL_VALUE ($1) = error_mark_node;
610                               IDENTIFIER_ERROR_LOCUS ($1) = current_function_decl;
611                             }
612                         }
613                     }
614                   else if (TREE_TYPE ($$) == error_mark_node)
615                     $$ = error_mark_node;
616                   else if (C_DECL_ANTICIPATED ($$))
617                     {
618                       /* The first time we see a build-in function used,
619                          if it has not been declared.  */
620                       C_DECL_ANTICIPATED ($$) = 0;
621                       if (yychar == YYEMPTY)
622                         yychar = YYLEX;
623                       if (yychar == '(')
624                         {
625                           /* Omit the implicit declaration we
626                              would ordinarily do, so we don't lose
627                              the actual built in type.
628                              But print a diagnostic for the mismatch.  */
629 ifobjc
630                           if (objc_method_context
631                               && is_ivar (objc_ivar_chain, $1))
632                             error ("Instance variable `%s' implicitly declared as function",
633                                    IDENTIFIER_POINTER (DECL_NAME ($$)));
634                           else
635 end ifobjc
636                             if (TREE_CODE ($$) != FUNCTION_DECL)
637                               error ("`%s' implicitly declared as function",
638                                      IDENTIFIER_POINTER (DECL_NAME ($$)));
639                           else if ((TYPE_MODE (TREE_TYPE (TREE_TYPE ($$)))
640                                     != TYPE_MODE (integer_type_node))
641                                    && (TREE_TYPE (TREE_TYPE ($$))
642                                        != void_type_node))
643                             pedwarn ("type mismatch in implicit declaration for built-in function `%s'",
644                                      IDENTIFIER_POINTER (DECL_NAME ($$)));
645                           /* If it really returns void, change that to int.  */
646                           if (TREE_TYPE (TREE_TYPE ($$)) == void_type_node)
647                             TREE_TYPE ($$)
648                               = build_function_type (integer_type_node,
649                                                      TYPE_ARG_TYPES (TREE_TYPE ($$)));
650                         }
651                       else
652                         pedwarn ("built-in function `%s' used without declaration",
653                                  IDENTIFIER_POINTER (DECL_NAME ($$)));
654
655                       /* Do what we would ordinarily do when a fn is used.  */
656                       assemble_external ($$);
657                       TREE_USED ($$) = 1;
658                     }
659                   else
660                     {
661                       assemble_external ($$);
662                       TREE_USED ($$) = 1;
663 ifobjc
664                       /* we have a definition - still check if iVariable */
665
666                       if (!objc_receiver_context
667                           || (objc_receiver_context
668                               && strcmp (IDENTIFIER_POINTER ($1), "super")))
669                         {
670                           tree decl;
671
672                           if (objc_method_context
673                               && (decl = is_ivar (objc_ivar_chain, $1)))
674                             {
675                               if (IDENTIFIER_LOCAL_VALUE ($1))
676                                 warning ("local declaration of `%s' hides instance variable",
677                                          IDENTIFIER_POINTER ($1));
678                               else
679                                 {
680                                   if (is_private (decl))
681                                     $$ = error_mark_node;
682                                   else
683                                     $$ = build_ivar_reference ($1);
684                                 }
685                             }
686                         }
687                       else /* we have a message to super */
688                         $$ = get_super_receiver ();
689 end ifobjc
690                     }
691
692                   if (TREE_CODE ($$) == CONST_DECL)
693                     {
694                       $$ = DECL_INITIAL ($$);
695                       /* This is to prevent an enum whose value is 0
696                          from being considered a null pointer constant.  */
697                       $$ = build1 (NOP_EXPR, TREE_TYPE ($$), $$);
698                       TREE_CONSTANT ($$) = 1;
699                     }
700                 }
701         | CONSTANT
702         | string
703                 { $$ = combine_strings ($1); }
704         | '(' expr ')'
705                 { char class = TREE_CODE_CLASS (TREE_CODE ($2));
706                   if (class == 'e' || class == '1'
707                       || class == '2' || class == '<')
708                     C_SET_EXP_ORIGINAL_CODE ($2, ERROR_MARK);
709                   $$ = $2; }
710         | '(' error ')'
711                 { $$ = error_mark_node; }
712         | '('
713                 { if (current_function_decl == 0)
714                     {
715                       error ("braced-group within expression allowed only inside a function");
716                       YYERROR;
717                     }
718                   /* We must force a BLOCK for this level
719                      so that, if it is not expanded later,
720                      there is a way to turn off the entire subtree of blocks
721                      that are contained in it.  */
722                   keep_next_level ();
723                   push_iterator_stack ();
724                   push_label_level ();
725                   $<ttype>$ = expand_start_stmt_expr (); }
726           compstmt ')'
727                 { tree rtl_exp;
728                   if (pedantic)
729                     pedwarn ("ANSI C forbids braced-groups within expressions");
730                   pop_iterator_stack ();
731                   pop_label_level ();
732                   rtl_exp = expand_end_stmt_expr ($<ttype>2);
733                   /* The statements have side effects, so the group does.  */
734                   TREE_SIDE_EFFECTS (rtl_exp) = 1;
735
736                   if (TREE_CODE ($3) == BLOCK)
737                     {
738                       /* Make a BIND_EXPR for the BLOCK already made.  */
739                       $$ = build (BIND_EXPR, TREE_TYPE (rtl_exp),
740                                   NULL_TREE, rtl_exp, $3);
741                       /* Remove the block from the tree at this point.
742                          It gets put back at the proper place
743                          when the BIND_EXPR is expanded.  */
744                       delete_block ($3);
745                     }
746                   else
747                     $$ = $3;
748                 }
749         | primary '(' exprlist ')'   %prec '.'
750                 { $$ = build_function_call ($1, $3); }
751         | primary '[' expr ']'   %prec '.'
752                 { $$ = build_array_ref ($1, $3); }
753         | primary '.' identifier
754                 {
755 ifobjc
756                   if (doing_objc_thang)
757                     {
758                       if (is_public ($1, $3))
759                         $$ = build_component_ref ($1, $3);
760                       else
761                         $$ = error_mark_node;
762                     }
763                   else
764 end ifobjc
765                     $$ = build_component_ref ($1, $3);
766                 }
767         | primary POINTSAT identifier
768                 {
769                   tree expr = build_indirect_ref ($1, "->");
770
771 ifobjc
772                   if (doing_objc_thang)
773                     {
774                       if (is_public (expr, $3))
775                         $$ = build_component_ref (expr, $3);
776                       else
777                         $$ = error_mark_node;
778                     }
779                   else
780 end ifobjc
781                     $$ = build_component_ref (expr, $3);
782                 }
783         | primary PLUSPLUS
784                 { $$ = build_unary_op (POSTINCREMENT_EXPR, $1, 0); }
785         | primary MINUSMINUS
786                 { $$ = build_unary_op (POSTDECREMENT_EXPR, $1, 0); }
787 ifobjc
788         | objcmessageexpr
789                 { $$ = build_message_expr ($1); }
790         | objcselectorexpr
791                 { $$ = build_selector_expr ($1); }
792         | objcprotocolexpr
793                 { $$ = build_protocol_expr ($1); }
794         | objcencodeexpr
795                 { $$ = build_encode_expr ($1); }
796         | objc_string
797                 { $$ = build_objc_string_object ($1); }
798 end ifobjc
799         ;
800
801 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it.  */
802 string:
803           STRING
804         | string STRING
805                 { $$ = chainon ($1, $2); }
806         ;
807
808 ifobjc
809 /* Produces an OBJC_STRING_CST with prehaps more OBJC_STRING_CSTs chained
810    onto it.  */
811 objc_string:
812           OBJC_STRING
813         | objc_string OBJC_STRING
814                 { $$ = chainon ($1, $2); }
815         ;
816 end ifobjc
817
818 xdecls:
819         /* empty */
820         | datadecls
821         | datadecls ELLIPSIS
822                 /* ... is used here to indicate a varargs function.  */
823                 { c_mark_varargs ();
824                   if (pedantic)
825                     pedwarn ("ANSI C does not permit use of `varargs.h'"); }
826         ;
827
828 /* The following are analogous to lineno_decl, decls and decl
829    except that they do not allow nested functions.
830    They are used for old-style parm decls.  */
831 lineno_datadecl:
832           save_filename save_lineno datadecl
833                 { }
834         ;
835
836 datadecls:
837         lineno_datadecl
838         | errstmt
839         | datadecls lineno_datadecl
840         | lineno_datadecl errstmt
841         ;
842
843 datadecl:
844         typed_declspecs setspecs initdecls ';'
845                 { current_declspecs = TREE_VALUE (declspec_stack);
846                   declspec_stack = TREE_CHAIN (declspec_stack);
847                   resume_momentary ($2); }
848         | declmods setspecs notype_initdecls ';'
849                 { current_declspecs = TREE_VALUE (declspec_stack);
850                   declspec_stack = TREE_CHAIN (declspec_stack);
851                   resume_momentary ($2); }
852         | typed_declspecs ';'
853                 { shadow_tag_warned ($1, 1);
854                   pedwarn ("empty declaration"); }
855         | declmods ';'
856                 { pedwarn ("empty declaration"); }
857         ;
858
859 /* This combination which saves a lineno before a decl
860    is the normal thing to use, rather than decl itself.
861    This is to avoid shift/reduce conflicts in contexts
862    where statement labels are allowed.  */
863 lineno_decl:
864           save_filename save_lineno decl
865                 { }
866         ;
867
868 decls:
869         lineno_decl
870         | errstmt
871         | decls lineno_decl
872         | lineno_decl errstmt
873         ;
874
875 /* records the type and storage class specs to use for processing
876    the declarators that follow.
877    Maintains a stack of outer-level values of current_declspecs,
878    for the sake of parm declarations nested in function declarators.  */
879 setspecs: /* empty */
880                 { $$ = suspend_momentary ();
881                   pending_xref_error ();
882                   declspec_stack = tree_cons (NULL_TREE, current_declspecs,
883                                               declspec_stack);
884                   current_declspecs = $<ttype>0; }
885         ;
886
887 decl:
888         typed_declspecs setspecs initdecls ';'
889                 { current_declspecs = TREE_VALUE (declspec_stack);
890                   declspec_stack = TREE_CHAIN (declspec_stack);
891                   resume_momentary ($2); }
892         | declmods setspecs notype_initdecls ';'
893                 { current_declspecs = TREE_VALUE (declspec_stack);
894                   declspec_stack = TREE_CHAIN (declspec_stack);
895                   resume_momentary ($2); }
896         | typed_declspecs setspecs nested_function
897                 { current_declspecs = TREE_VALUE (declspec_stack);
898                   declspec_stack = TREE_CHAIN (declspec_stack);
899                   resume_momentary ($2); }
900         | declmods setspecs notype_nested_function
901                 { current_declspecs = TREE_VALUE (declspec_stack);
902                   declspec_stack = TREE_CHAIN (declspec_stack);
903                   resume_momentary ($2); }
904         | typed_declspecs ';'
905                 { shadow_tag ($1); }
906         | declmods ';'
907                 { pedwarn ("empty declaration"); }
908         ;
909
910 /* Declspecs which contain at least one type specifier or typedef name.
911    (Just `const' or `volatile' is not enough.)
912    A typedef'd name following these is taken as a name to be declared.  */
913
914 typed_declspecs:
915           typespec reserved_declspecs
916                 { $$ = tree_cons (NULL_TREE, $1, $2); }
917         | declmods typespec reserved_declspecs
918                 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
919         ;
920
921 reserved_declspecs:  /* empty */
922                 { $$ = NULL_TREE; }
923         | reserved_declspecs typespecqual_reserved
924                 { $$ = tree_cons (NULL_TREE, $2, $1); }
925         | reserved_declspecs SCSPEC
926                 { if (extra_warnings)
927                     warning ("`%s' is not at beginning of declaration",
928                              IDENTIFIER_POINTER ($2));
929                   $$ = tree_cons (NULL_TREE, $2, $1); }
930         ;
931
932 /* List of just storage classes and type modifiers.
933    A declaration can start with just this, but then it cannot be used
934    to redeclare a typedef-name.  */
935
936 declmods:
937           TYPE_QUAL
938                 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
939                   TREE_STATIC ($$) = 1; }
940         | SCSPEC
941                 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
942         | declmods TYPE_QUAL
943                 { $$ = tree_cons (NULL_TREE, $2, $1);
944                   TREE_STATIC ($$) = 1; }
945         | declmods SCSPEC
946                 { if (extra_warnings && TREE_STATIC ($1))
947                     warning ("`%s' is not at beginning of declaration",
948                              IDENTIFIER_POINTER ($2));
949                   $$ = tree_cons (NULL_TREE, $2, $1);
950                   TREE_STATIC ($$) = TREE_STATIC ($1); }
951         ;
952
953
954 /* Used instead of declspecs where storage classes are not allowed
955    (that is, for typenames and structure components).
956    Don't accept a typedef-name if anything but a modifier precedes it.  */
957
958 typed_typespecs:
959           typespec reserved_typespecquals
960                 { $$ = tree_cons (NULL_TREE, $1, $2); }
961         | nonempty_type_quals typespec reserved_typespecquals
962                 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
963         ;
964
965 reserved_typespecquals:  /* empty */
966                 { $$ = NULL_TREE; }
967         | reserved_typespecquals typespecqual_reserved
968                 { $$ = tree_cons (NULL_TREE, $2, $1); }
969         ;
970
971 /* A typespec (but not a type qualifier).
972    Once we have seen one of these in a declaration,
973    if a typedef name appears then it is being redeclared.  */
974
975 typespec: TYPESPEC
976         | structsp
977         | TYPENAME
978                 { /* For a typedef name, record the meaning, not the name.
979                      In case of `foo foo, bar;'.  */
980                   $$ = lookup_name ($1); }
981 ifobjc
982         | CLASSNAME protocolrefs
983                 { $$ = get_static_reference ($1, $2); }
984         | OBJECTNAME protocolrefs
985                 { $$ = get_object_reference ($2); }
986 end ifobjc
987         | TYPEOF '(' expr ')'
988                 { $$ = TREE_TYPE ($3); }
989         | TYPEOF '(' typename ')'
990                 { $$ = groktypename ($3); }
991         ;
992
993 /* A typespec that is a reserved word, or a type qualifier.  */
994
995 typespecqual_reserved: TYPESPEC
996         | TYPE_QUAL
997         | structsp
998         ;
999
1000 initdecls:
1001         initdcl
1002         | initdecls ',' initdcl
1003         ;
1004
1005 notype_initdecls:
1006         notype_initdcl
1007         | notype_initdecls ',' initdcl
1008         ;
1009
1010 maybeasm:
1011           /* empty */
1012                 { $$ = NULL_TREE; }
1013         | ASM_KEYWORD '(' string ')'
1014                 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
1015                   $$ = $3;
1016                 }
1017         ;
1018
1019 initdcl:
1020           declarator maybeasm maybe_attribute '='
1021                 { $<ttype>$ = start_decl ($1, current_declspecs, 1);
1022                   decl_attributes ($<ttype>$, $3);
1023                   start_init ($<ttype>$, $2, global_bindings_p ()); }
1024           init
1025 /* Note how the declaration of the variable is in effect while its init is parsed! */
1026                 { finish_init ();
1027                   decl_attributes ($<ttype>5, $3);
1028                   finish_decl ($<ttype>5, $6, $2); }
1029         | declarator maybeasm maybe_attribute
1030                 { tree d = start_decl ($1, current_declspecs, 0);
1031                   decl_attributes (d, $3);
1032                   finish_decl (d, NULL_TREE, $2); }
1033         ;
1034
1035 notype_initdcl:
1036           notype_declarator maybeasm maybe_attribute '='
1037                 { $<ttype>$ = start_decl ($1, current_declspecs, 1);
1038                   decl_attributes ($<ttype>$, $3);
1039                   start_init ($<ttype>$, $2, global_bindings_p ()); }
1040           init
1041 /* Note how the declaration of the variable is in effect while its init is parsed! */
1042                 { finish_init ();
1043                   decl_attributes ($<ttype>5, $3);
1044                   finish_decl ($<ttype>5, $6, $2); }
1045         | notype_declarator maybeasm maybe_attribute
1046                 { tree d = start_decl ($1, current_declspecs, 0);
1047                   decl_attributes (d, $3);
1048                   finish_decl (d, NULL_TREE, $2); }
1049         ;
1050 /* the * rules are dummies to accept the Apollo extended syntax
1051    so that the header files compile. */
1052 maybe_attribute:
1053       /* empty */
1054                 { $$ = NULL_TREE; }
1055         | attributes
1056                 { $$ = $1; }
1057         ;
1058  
1059 attributes:
1060       attribute
1061                 { $$ = $1; }
1062         | attributes attribute
1063                 { $$ = chainon ($1, $2); }
1064         ;
1065
1066 attribute:
1067       ATTRIBUTE '(' '(' attribute_list ')' ')'
1068                 { $$ = $4; }
1069         ;
1070
1071 attribute_list:
1072       attrib
1073                 { $$ = build_tree_list (NULL_TREE, $1); }
1074         | attribute_list ',' attrib
1075                 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
1076         ;
1077  
1078 attrib:
1079     /* empty */
1080                 { $$ = NULL_TREE; }
1081         | any_word
1082                 { $$ = $1; }
1083         | any_word '(' IDENTIFIER ')'
1084                 { $$ = tree_cons ($1, NULL_TREE,
1085                                   build_tree_list (NULL_TREE, $3)); }
1086         | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1087                 { $$ = tree_cons ($1, NULL_TREE,
1088                                   tree_cons (NULL_TREE, $3, $5)); }
1089         | any_word '(' nonnull_exprlist ')'
1090                 { $$ = tree_cons ($1, NULL_TREE, $3); }
1091         ;
1092
1093 /* This still leaves out most reserved keywords,
1094    shouldn't we include them?  */
1095
1096 any_word:
1097           identifier
1098         | SCSPEC
1099         | TYPESPEC
1100         | TYPE_QUAL
1101         ;
1102 \f
1103 /* Initializers.  `init' is the entry point.  */
1104
1105 init:
1106         expr_no_commas
1107         | '{'
1108                 { really_start_incremental_init (NULL_TREE);
1109                   /* Note that the call to clear_momentary
1110                      is in process_init_element.  */
1111                   push_momentary (); }
1112           initlist_maybe_comma '}'
1113                 { $$ = pop_init_level (0);
1114                   if ($$ == error_mark_node)
1115                     pop_momentary ();
1116                   else
1117                     pop_momentary_nofree (); }
1118
1119         | error
1120                 { $$ = error_mark_node; }
1121         ;
1122
1123 /* `initlist_maybe_comma' is the guts of an initializer in braces.  */
1124 initlist_maybe_comma:
1125           /* empty */
1126                 { if (pedantic)
1127                     pedwarn ("ANSI C forbids empty initializer braces"); }
1128         | initlist1 maybecomma
1129         ;
1130
1131 initlist1:
1132           initelt
1133         | initlist1 ',' initelt
1134         ;
1135
1136 /* `initelt' is a single element of an initializer.
1137    It may use braces.  */
1138 initelt:
1139         expr_no_commas
1140                 { process_init_element ($1); }
1141         | '{' 
1142                 { push_init_level (0); }
1143           initlist_maybe_comma '}'
1144                 { process_init_element (pop_init_level (0)); }
1145         | error
1146         /* These are for labeled elements.  The syntax for an array element
1147            initializer conflicts with the syntax for an Objective-C message,
1148            so don't include these productions in the Objective-C grammer.  */
1149 ifc
1150         | '[' expr_no_commas ELLIPSIS expr_no_commas ']' '='
1151                 { set_init_index ($2, $4); }
1152           initelt
1153         | '[' expr_no_commas ']' '='
1154                 { set_init_index ($2, NULL_TREE); }
1155           initelt
1156 end ifc
1157         | identifier ':'
1158                 { set_init_label ($1); }
1159           initelt
1160         | '.' identifier '='
1161                 { set_init_label ($2); }
1162           initelt
1163         ;
1164 \f
1165 nested_function:
1166           declarator
1167                 { push_c_function_context ();
1168                   if (! start_function (current_declspecs, $1, 1))
1169                     {
1170                       pop_c_function_context ();
1171                       YYERROR1;
1172                     }
1173                   reinit_parse_for_function ();
1174                   store_parm_decls (); }
1175 /* This used to use compstmt_or_error.
1176    That caused a bug with input `f(g) int g {}',
1177    where the use of YYERROR1 above caused an error
1178    which then was handled by compstmt_or_error.
1179    There followed a repeated execution of that same rule,
1180    which called YYERROR1 again, and so on.  */
1181           compstmt
1182                 { finish_function (1);
1183                   pop_c_function_context (); }
1184         ;
1185
1186 notype_nested_function:
1187           notype_declarator
1188                 { push_c_function_context ();
1189                   if (! start_function (current_declspecs, $1, 1))
1190                     {
1191                       pop_c_function_context ();
1192                       YYERROR1;
1193                     }
1194                   reinit_parse_for_function ();
1195                   store_parm_decls (); }
1196 /* This used to use compstmt_or_error.
1197    That caused a bug with input `f(g) int g {}',
1198    where the use of YYERROR1 above caused an error
1199    which then was handled by compstmt_or_error.
1200    There followed a repeated execution of that same rule,
1201    which called YYERROR1 again, and so on.  */
1202           compstmt
1203                 { finish_function (1);
1204                   pop_c_function_context (); }
1205         ;
1206
1207 /* Any kind of declarator (thus, all declarators allowed
1208    after an explicit typespec).  */
1209
1210 declarator:
1211           after_type_declarator
1212         | notype_declarator
1213         ;
1214
1215 /* A declarator that is allowed only after an explicit typespec.  */
1216
1217 after_type_declarator:
1218           '(' after_type_declarator ')'
1219                 { $$ = $2; }
1220         | after_type_declarator '(' parmlist_or_identifiers  %prec '.'
1221                 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1222 /*      | after_type_declarator '(' error ')'  %prec '.'
1223                 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1224                   poplevel (0, 0, 0); }  */
1225         | after_type_declarator '[' expr ']'  %prec '.'
1226                 { $$ = build_nt (ARRAY_REF, $1, $3); }
1227         | after_type_declarator '[' ']'  %prec '.'
1228                 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1229         | '*' type_quals after_type_declarator  %prec UNARY
1230                 { $$ = make_pointer_declarator ($2, $3); }
1231         | TYPENAME
1232 ifobjc
1233         | OBJECTNAME
1234 end ifobjc
1235         ;
1236
1237 /* Kinds of declarator that can appear in a parameter list
1238    in addition to notype_declarator.  This is like after_type_declarator
1239    but does not allow a typedef name in parentheses as an identifier
1240    (because it would conflict with a function with that typedef as arg).  */
1241
1242 parm_declarator:
1243           parm_declarator '(' parmlist_or_identifiers  %prec '.'
1244                 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1245 /*      | parm_declarator '(' error ')'  %prec '.'
1246                 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1247                   poplevel (0, 0, 0); }  */
1248         | parm_declarator '[' expr ']'  %prec '.'
1249                 { $$ = build_nt (ARRAY_REF, $1, $3); }
1250         | parm_declarator '[' ']'  %prec '.'
1251                 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1252         | '*' type_quals parm_declarator  %prec UNARY
1253                 { $$ = make_pointer_declarator ($2, $3); }
1254         | TYPENAME
1255         ;
1256
1257 /* A declarator allowed whether or not there has been
1258    an explicit typespec.  These cannot redeclare a typedef-name.  */
1259
1260 notype_declarator:
1261           notype_declarator '(' parmlist_or_identifiers  %prec '.'
1262                 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1263 /*      | notype_declarator '(' error ')'  %prec '.'
1264                 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1265                   poplevel (0, 0, 0); }  */
1266         | '(' notype_declarator ')'
1267                 { $$ = $2; }
1268         | '*' type_quals notype_declarator  %prec UNARY
1269                 { $$ = make_pointer_declarator ($2, $3); }
1270         | notype_declarator '[' expr ']'  %prec '.'
1271                 { $$ = build_nt (ARRAY_REF, $1, $3); }
1272         | notype_declarator '[' ']'  %prec '.'
1273                 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1274         | IDENTIFIER
1275         ;
1276
1277 structsp:
1278           STRUCT identifier '{'
1279                 { $$ = start_struct (RECORD_TYPE, $2);
1280                   /* Start scope of tag before parsing components.  */
1281                 }
1282           component_decl_list '}'
1283                 { $$ = finish_struct ($<ttype>4, $5);
1284                   /* Really define the structure.  */
1285                 }
1286         | STRUCT '{' component_decl_list '}'
1287                 { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
1288                                       $3); }
1289         | STRUCT identifier
1290                 { $$ = xref_tag (RECORD_TYPE, $2); }
1291         | UNION identifier '{'
1292                 { $$ = start_struct (UNION_TYPE, $2); }
1293           component_decl_list '}'
1294                 { $$ = finish_struct ($<ttype>4, $5); }
1295         | UNION '{' component_decl_list '}'
1296                 { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
1297                                       $3); }
1298         | UNION identifier
1299                 { $$ = xref_tag (UNION_TYPE, $2); }
1300         | ENUM identifier '{'
1301                 { $<itype>3 = suspend_momentary ();
1302                   $$ = start_enum ($2); }
1303           enumlist maybecomma_warn '}'
1304                 { $$ = finish_enum ($<ttype>4, nreverse ($5));
1305                   resume_momentary ($<itype>3); }
1306         | ENUM '{'
1307                 { $<itype>2 = suspend_momentary ();
1308                   $$ = start_enum (NULL_TREE); }
1309           enumlist maybecomma_warn '}'
1310                 { $$ = finish_enum ($<ttype>3, nreverse ($4));
1311                   resume_momentary ($<itype>2); }
1312         | ENUM identifier
1313                 { $$ = xref_tag (ENUMERAL_TYPE, $2); }
1314         ;
1315
1316 maybecomma:
1317           /* empty */
1318         | ','
1319         ;
1320
1321 maybecomma_warn:
1322           /* empty */
1323         | ','
1324                 { if (pedantic) pedwarn ("comma at end of enumerator list"); }
1325         ;
1326
1327 component_decl_list:
1328           component_decl_list2
1329                 { $$ = $1; }
1330         | component_decl_list2 component_decl
1331                 { $$ = chainon ($1, $2);
1332                   pedwarn ("no semicolon at end of struct or union"); }
1333         ;
1334
1335 component_decl_list2:   /* empty */
1336                 { $$ = NULL_TREE; }
1337         | component_decl_list2 component_decl ';'
1338                 { $$ = chainon ($1, $2); }
1339         | component_decl_list2 ';'
1340                 { if (pedantic)
1341                     pedwarn ("extra semicolon in struct or union specified"); }
1342 ifobjc
1343         /* foo(sizeof(struct{ @defs(ClassName)})); */
1344         | DEFS '(' CLASSNAME ')'
1345                 {
1346                   tree interface = lookup_interface ($3);
1347
1348                   if (interface)
1349                     $$ = get_class_ivars (interface);
1350                   else
1351                     {
1352                       error ("Cannot find interface declaration for `%s'",
1353                              IDENTIFIER_POINTER ($3));
1354                       $$ = NULL_TREE;
1355                     }
1356                 }
1357 end ifobjc
1358         ;
1359
1360 /* There is a shift-reduce conflict here, because `components' may
1361    start with a `typename'.  It happens that shifting (the default resolution)
1362    does the right thing, because it treats the `typename' as part of
1363    a `typed_typespecs'.
1364
1365    It is possible that this same technique would allow the distinction
1366    between `notype_initdecls' and `initdecls' to be eliminated.
1367    But I am being cautious and not trying it.  */
1368
1369 component_decl:
1370           typed_typespecs setspecs components
1371                 { $$ = $3;
1372                   current_declspecs = TREE_VALUE (declspec_stack);
1373                   declspec_stack = TREE_CHAIN (declspec_stack);
1374                   resume_momentary ($2); }
1375         | typed_typespecs
1376                 { if (pedantic)
1377                     pedwarn ("ANSI C forbids member declarations with no members");
1378                   shadow_tag($1);
1379                   $$ = NULL_TREE; }
1380         | nonempty_type_quals setspecs components
1381                 { $$ = $3;
1382                   current_declspecs = TREE_VALUE (declspec_stack);
1383                   declspec_stack = TREE_CHAIN (declspec_stack);
1384                   resume_momentary ($2); }
1385         | nonempty_type_quals
1386                 { if (pedantic)
1387                     pedwarn ("ANSI C forbids member declarations with no members");
1388                   shadow_tag($1);
1389                   $$ = NULL_TREE; }
1390         | error
1391                 { $$ = NULL_TREE; }
1392         ;
1393
1394 components:
1395           component_declarator
1396         | components ',' component_declarator
1397                 { $$ = chainon ($1, $3); }
1398         ;
1399
1400 component_declarator:
1401           save_filename save_lineno declarator maybe_attribute
1402                 { $$ = grokfield ($1, $2, $3, current_declspecs, NULL_TREE);
1403                   decl_attributes ($$, $4); }
1404         | save_filename save_lineno
1405           declarator ':' expr_no_commas maybe_attribute
1406                 { $$ = grokfield ($1, $2, $3, current_declspecs, $5);
1407                   decl_attributes ($$, $6); }
1408         | save_filename save_lineno ':' expr_no_commas maybe_attribute
1409                 { $$ = grokfield ($1, $2, NULL_TREE, current_declspecs, $4);
1410                   decl_attributes ($$, $5); }
1411         ;
1412
1413 /* We chain the enumerators in reverse order.
1414    They are put in forward order where enumlist is used.
1415    (The order used to be significant, but no longer is so.
1416    However, we still maintain the order, just to be clean.)  */
1417
1418 enumlist:
1419           enumerator
1420         | enumlist ',' enumerator
1421                 { $$ = chainon ($3, $1); }
1422         ;
1423
1424
1425 enumerator:
1426           identifier
1427                 { $$ = build_enumerator ($1, NULL_TREE); }
1428         | identifier '=' expr_no_commas
1429                 { $$ = build_enumerator ($1, $3); }
1430         ;
1431
1432 typename:
1433         typed_typespecs absdcl
1434                 { $$ = build_tree_list ($1, $2); }
1435         | nonempty_type_quals absdcl
1436                 { $$ = build_tree_list ($1, $2); }
1437         ;
1438
1439 absdcl:   /* an absolute declarator */
1440         /* empty */
1441                 { $$ = NULL_TREE; }
1442         | absdcl1
1443         ;
1444
1445 nonempty_type_quals:
1446           TYPE_QUAL
1447                 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
1448         | nonempty_type_quals TYPE_QUAL
1449                 { $$ = tree_cons (NULL_TREE, $2, $1); }
1450         ;
1451
1452 type_quals:
1453           /* empty */
1454                 { $$ = NULL_TREE; }
1455         | type_quals TYPE_QUAL
1456                 { $$ = tree_cons (NULL_TREE, $2, $1); }
1457         ;
1458
1459 absdcl1:  /* a nonempty absolute declarator */
1460           '(' absdcl1 ')'
1461                 { $$ = $2; }
1462           /* `(typedef)1' is `int'.  */
1463         | '*' type_quals absdcl1  %prec UNARY
1464                 { $$ = make_pointer_declarator ($2, $3); }
1465         | '*' type_quals  %prec UNARY
1466                 { $$ = make_pointer_declarator ($2, NULL_TREE); }
1467         | absdcl1 '(' parmlist  %prec '.'
1468                 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1469         | absdcl1 '[' expr ']'  %prec '.'
1470                 { $$ = build_nt (ARRAY_REF, $1, $3); }
1471         | absdcl1 '[' ']'  %prec '.'
1472                 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1473         | '(' parmlist  %prec '.'
1474                 { $$ = build_nt (CALL_EXPR, NULL_TREE, $2, NULL_TREE); }
1475         | '[' expr ']'  %prec '.'
1476                 { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
1477         | '[' ']'  %prec '.'
1478                 { $$ = build_nt (ARRAY_REF, NULL_TREE, NULL_TREE); }
1479         ;
1480
1481 /* at least one statement, the first of which parses without error.  */
1482 /* stmts is used only after decls, so an invalid first statement
1483    is actually regarded as an invalid decl and part of the decls.  */
1484
1485 stmts:
1486           lineno_stmt_or_label
1487         | stmts lineno_stmt_or_label
1488         | stmts errstmt
1489         ;
1490
1491 xstmts:
1492         /* empty */
1493         | stmts
1494         ;
1495
1496 errstmt:  error ';'
1497         ;
1498
1499 pushlevel:  /* empty */
1500                 { emit_line_note (input_filename, lineno);
1501                   pushlevel (0);
1502                   clear_last_expr ();
1503                   push_momentary ();
1504                   expand_start_bindings (0);
1505 ifobjc
1506                   if (objc_method_context)
1507                     add_objc_decls ();
1508 end ifobjc
1509                 }
1510         ;
1511
1512 /* Read zero or more forward-declarations for labels
1513    that nested functions can jump to.  */
1514 maybe_label_decls:
1515           /* empty */
1516         | label_decls
1517                 { if (pedantic)
1518                     pedwarn ("ANSI C forbids label declarations"); }
1519         ;
1520
1521 label_decls:
1522           label_decl
1523         | label_decls label_decl
1524         ;
1525
1526 label_decl:
1527           LABEL identifiers_or_typenames ';'
1528                 { tree link;
1529                   for (link = $2; link; link = TREE_CHAIN (link))
1530                     {
1531                       tree label = shadow_label (TREE_VALUE (link));
1532                       C_DECLARED_LABEL_FLAG (label) = 1;
1533                       declare_nonlocal_label (label);
1534                     }
1535                 }
1536         ;
1537
1538 /* This is the body of a function definition.
1539    It causes syntax errors to ignore to the next openbrace.  */
1540 compstmt_or_error:
1541           compstmt
1542                 {}
1543         | error compstmt
1544         ;
1545
1546 compstmt: '{' '}'
1547                 { $$ = convert (void_type_node, integer_zero_node); }
1548         | '{' pushlevel maybe_label_decls decls xstmts '}'
1549                 { emit_line_note (input_filename, lineno);
1550                   expand_end_bindings (getdecls (), 1, 0);
1551                   $$ = poplevel (1, 1, 0);
1552                   pop_momentary (); }
1553         | '{' pushlevel maybe_label_decls error '}'
1554                 { emit_line_note (input_filename, lineno);
1555                   expand_end_bindings (getdecls (), kept_level_p (), 0);
1556                   $$ = poplevel (kept_level_p (), 0, 0);
1557                   pop_momentary (); }
1558         | '{' pushlevel maybe_label_decls stmts '}'
1559                 { emit_line_note (input_filename, lineno);
1560                   expand_end_bindings (getdecls (), kept_level_p (), 0);
1561                   $$ = poplevel (kept_level_p (), 0, 0);
1562                   pop_momentary (); }
1563         ;
1564
1565 /* Value is number of statements counted as of the closeparen.  */
1566 simple_if:
1567           if_prefix lineno_labeled_stmt
1568 /* Make sure expand_end_cond is run once
1569    for each call to expand_start_cond.
1570    Otherwise a crash is likely.  */
1571         | if_prefix error
1572         ;
1573
1574 if_prefix:
1575           IF '(' expr ')'
1576                 { emit_line_note ($<filename>-1, $<lineno>0);
1577                   expand_start_cond (truthvalue_conversion ($3), 0);
1578                   $<itype>$ = stmt_count;
1579                   if_stmt_file = $<filename>-1;
1580                   if_stmt_line = $<lineno>0;
1581                   position_after_white_space (); }
1582         ;
1583
1584 /* This is a subroutine of stmt.
1585    It is used twice, once for valid DO statements
1586    and once for catching errors in parsing the end test.  */
1587 do_stmt_start:
1588           DO
1589                 { stmt_count++;
1590                   emit_line_note ($<filename>-1, $<lineno>0);
1591                   /* See comment in `while' alternative, above.  */
1592                   emit_nop ();
1593                   expand_start_loop_continue_elsewhere (1);
1594                   position_after_white_space (); }
1595           lineno_labeled_stmt WHILE
1596                 { expand_loop_continue_here (); }
1597         ;
1598
1599 save_filename:
1600                 { $$ = input_filename; }
1601         ;
1602
1603 save_lineno:
1604                 { $$ = lineno; }
1605         ;
1606
1607 lineno_labeled_stmt:
1608           save_filename save_lineno stmt
1609                 { }
1610 /*      | save_filename save_lineno error
1611                 { }
1612 */
1613         | save_filename save_lineno label lineno_labeled_stmt
1614                 { }
1615         ;
1616
1617 lineno_stmt_or_label:
1618           save_filename save_lineno stmt_or_label
1619                 { }
1620         ;
1621
1622 stmt_or_label:
1623           stmt
1624         | label
1625                 { int next;
1626                   position_after_white_space ();
1627                   next = getc (finput);
1628                   ungetc (next, finput);
1629                   if (pedantic && next == '}')
1630                     pedwarn ("ANSI C forbids label at end of compound statement");
1631                 }
1632         ;
1633
1634 /* Parse a single real statement, not including any labels.  */
1635 stmt:
1636           compstmt
1637                 { stmt_count++; }
1638         | all_iter_stmt 
1639         | expr ';'
1640                 { stmt_count++;
1641                   emit_line_note ($<filename>-1, $<lineno>0);
1642 /* It appears that this should not be done--that a non-lvalue array
1643    shouldn't get an error if the value isn't used.
1644    Section 3.2.2.1 says that an array lvalue gets converted to a pointer
1645    if it appears as a top-level expression,
1646    but says nothing about non-lvalue arrays.  */
1647 #if 0
1648                   /* Call default_conversion to get an error
1649                      on referring to a register array if pedantic.  */
1650                   if (TREE_CODE (TREE_TYPE ($1)) == ARRAY_TYPE
1651                       || TREE_CODE (TREE_TYPE ($1)) == FUNCTION_TYPE)
1652                     $1 = default_conversion ($1);
1653 #endif
1654                   iterator_expand ($1);
1655                   clear_momentary (); }
1656         | simple_if ELSE
1657                 { expand_start_else ();
1658                   $<itype>1 = stmt_count;
1659                   position_after_white_space (); }
1660           lineno_labeled_stmt
1661                 { expand_end_cond ();
1662                   if (extra_warnings && stmt_count == $<itype>1)
1663                     warning ("empty body in an else-statement"); }
1664         | simple_if %prec IF
1665                 { expand_end_cond ();
1666                   /* This warning is here instead of in simple_if, because we
1667                      do not want a warning if an empty if is followed by an
1668                      else statement.  */
1669                   if (extra_warnings && stmt_count == $<itype>1)
1670                     warning_with_file_and_line (if_stmt_file, if_stmt_line,
1671                                                 "empty body in an if-statement"); }
1672 /* Make sure expand_end_cond is run once
1673    for each call to expand_start_cond.
1674    Otherwise a crash is likely.  */
1675         | simple_if ELSE error
1676                 { expand_end_cond (); }
1677         | WHILE
1678                 { stmt_count++;
1679                   emit_line_note ($<filename>-1, $<lineno>0);
1680                   /* The emit_nop used to come before emit_line_note,
1681                      but that made the nop seem like part of the preceding line.
1682                      And that was confusing when the preceding line was
1683                      inside of an if statement and was not really executed.
1684                      I think it ought to work to put the nop after the line number.
1685                      We will see.  --rms, July 15, 1991.  */
1686                   emit_nop (); }
1687           '(' expr ')'
1688                 { /* Don't start the loop till we have succeeded
1689                      in parsing the end test.  This is to make sure
1690                      that we end every loop we start.  */
1691                   expand_start_loop (1);
1692                   emit_line_note (input_filename, lineno);
1693                   expand_exit_loop_if_false (NULL_PTR,
1694                                              truthvalue_conversion ($4));
1695                   position_after_white_space (); }
1696           lineno_labeled_stmt
1697                 { expand_end_loop (); }
1698         | do_stmt_start
1699           '(' expr ')' ';'
1700                 { emit_line_note (input_filename, lineno);
1701                   expand_exit_loop_if_false (NULL_PTR,
1702                                              truthvalue_conversion ($3));
1703                   expand_end_loop ();
1704                   clear_momentary (); }
1705 /* This rule is needed to make sure we end every loop we start.  */
1706         | do_stmt_start error
1707                 { expand_end_loop ();
1708                   clear_momentary (); }
1709         | FOR
1710           '(' xexpr ';'
1711                 { stmt_count++;
1712                   emit_line_note ($<filename>-1, $<lineno>0);
1713                   /* See comment in `while' alternative, above.  */
1714                   emit_nop ();
1715                   if ($3) c_expand_expr_stmt ($3);
1716                   /* Next step is to call expand_start_loop_continue_elsewhere,
1717                      but wait till after we parse the entire for (...).
1718                      Otherwise, invalid input might cause us to call that
1719                      fn without calling expand_end_loop.  */
1720                 }
1721           xexpr ';'
1722                 /* Can't emit now; wait till after expand_start_loop...  */
1723                 { $<lineno>7 = lineno;
1724                   $<filename>$ = input_filename; }
1725           xexpr ')'
1726                 { 
1727                   /* Start the loop.  Doing this after parsing
1728                      all the expressions ensures we will end the loop.  */
1729                   expand_start_loop_continue_elsewhere (1);
1730                   /* Emit the end-test, with a line number.  */
1731                   emit_line_note ($<filename>8, $<lineno>7);
1732                   if ($6)
1733                     expand_exit_loop_if_false (NULL_PTR,
1734                                                truthvalue_conversion ($6));
1735                   /* Don't let the tree nodes for $9 be discarded by
1736                      clear_momentary during the parsing of the next stmt.  */
1737                   push_momentary ();
1738                   $<lineno>7 = lineno;
1739                   $<filename>8 = input_filename;
1740                   position_after_white_space (); }
1741           lineno_labeled_stmt
1742                 { /* Emit the increment expression, with a line number.  */
1743                   emit_line_note ($<filename>8, $<lineno>7);
1744                   expand_loop_continue_here ();
1745                   if ($9)
1746                     c_expand_expr_stmt ($9);
1747                   pop_momentary ();
1748                   expand_end_loop (); }
1749         | SWITCH '(' expr ')'
1750                 { stmt_count++;
1751                   emit_line_note ($<filename>-1, $<lineno>0);
1752                   c_expand_start_case ($3);
1753                   /* Don't let the tree nodes for $3 be discarded by
1754                      clear_momentary during the parsing of the next stmt.  */
1755                   push_momentary ();
1756                   position_after_white_space (); }
1757           lineno_labeled_stmt
1758                 { expand_end_case ($3);
1759                   pop_momentary (); }
1760         | BREAK ';'
1761                 { stmt_count++;
1762                   emit_line_note ($<filename>-1, $<lineno>0);
1763                   if ( ! expand_exit_something ())
1764                     error ("break statement not within loop or switch"); }
1765         | CONTINUE ';'
1766                 { stmt_count++;
1767                   emit_line_note ($<filename>-1, $<lineno>0);
1768                   if (! expand_continue_loop (NULL_PTR))
1769                     error ("continue statement not within a loop"); }
1770         | RETURN ';'
1771                 { stmt_count++;
1772                   emit_line_note ($<filename>-1, $<lineno>0);
1773                   c_expand_return (NULL_TREE); }
1774         | RETURN expr ';'
1775                 { stmt_count++;
1776                   emit_line_note ($<filename>-1, $<lineno>0);
1777                   c_expand_return ($2); }
1778         | ASM_KEYWORD maybe_type_qual '(' expr ')' ';'
1779                 { stmt_count++;
1780                   emit_line_note ($<filename>-1, $<lineno>0);
1781                   STRIP_NOPS ($4);
1782                   if ((TREE_CODE ($4) == ADDR_EXPR
1783                        && TREE_CODE (TREE_OPERAND ($4, 0)) == STRING_CST)
1784                       || TREE_CODE ($4) == STRING_CST)
1785                     expand_asm ($4);
1786                   else
1787                     error ("argument of `asm' is not a constant string"); }
1788         /* This is the case with just output operands.  */
1789         | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ')' ';'
1790                 { stmt_count++;
1791                   emit_line_note ($<filename>-1, $<lineno>0);
1792                   c_expand_asm_operands ($4, $6, NULL_TREE, NULL_TREE,
1793                                          $2 == ridpointers[(int)RID_VOLATILE],
1794                                          input_filename, lineno); }
1795         /* This is the case with input operands as well.  */
1796         | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':' asm_operands ')' ';'
1797                 { stmt_count++;
1798                   emit_line_note ($<filename>-1, $<lineno>0);
1799                   c_expand_asm_operands ($4, $6, $8, NULL_TREE,
1800                                          $2 == ridpointers[(int)RID_VOLATILE],
1801                                          input_filename, lineno); }
1802         /* This is the case with clobbered registers as well.  */
1803         | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':'
1804           asm_operands ':' asm_clobbers ')' ';'
1805                 { stmt_count++;
1806                   emit_line_note ($<filename>-1, $<lineno>0);
1807                   c_expand_asm_operands ($4, $6, $8, $10,
1808                                          $2 == ridpointers[(int)RID_VOLATILE],
1809                                          input_filename, lineno); }
1810         | GOTO identifier ';'
1811                 { tree decl;
1812                   stmt_count++;
1813                   emit_line_note ($<filename>-1, $<lineno>0);
1814                   decl = lookup_label ($2);
1815                   if (decl != 0)
1816                     {
1817                       TREE_USED (decl) = 1;
1818                       expand_goto (decl);
1819                     }
1820                 }
1821         | GOTO '*' expr ';'
1822                 { stmt_count++;
1823                   emit_line_note ($<filename>-1, $<lineno>0);
1824                   expand_computed_goto (convert (ptr_type_node, $3)); }
1825         | ';'
1826         ;
1827
1828 all_iter_stmt:
1829           all_iter_stmt_simple
1830 /*      | all_iter_stmt_with_decl */
1831         ;
1832
1833 all_iter_stmt_simple:
1834           FOR '(' primary ')' 
1835           {
1836             /* The value returned by this action is  */
1837             /*      1 if everything is OK */ 
1838             /*      0 in case of error or already bound iterator */
1839
1840             $<itype>$ = 0;
1841             if (TREE_CODE ($3) != VAR_DECL)
1842               error ("invalid `for (ITERATOR)' syntax");
1843             else if (! ITERATOR_P ($3))
1844               error ("`%s' is not an iterator",
1845                      IDENTIFIER_POINTER (DECL_NAME ($3)));
1846             else if (ITERATOR_BOUND_P ($3))
1847               error ("`for (%s)' inside expansion of same iterator",
1848                      IDENTIFIER_POINTER (DECL_NAME ($3)));
1849             else
1850               {
1851                 $<itype>$ = 1;
1852                 iterator_for_loop_start ($3);
1853               }
1854           }
1855           lineno_labeled_stmt
1856           {
1857             if ($<itype>5)
1858               iterator_for_loop_end ($3);
1859           }
1860
1861 /*  This really should allow any kind of declaration,
1862     for generality.  Fix it before turning it back on.
1863
1864 all_iter_stmt_with_decl:
1865           FOR '(' ITERATOR pushlevel setspecs iterator_spec ')' 
1866           {
1867 */          /* The value returned by this action is  */
1868             /*      1 if everything is OK */ 
1869             /*      0 in case of error or already bound iterator */
1870 /*
1871             iterator_for_loop_start ($6);
1872           }
1873           lineno_labeled_stmt
1874           {
1875             iterator_for_loop_end ($6);
1876             emit_line_note (input_filename, lineno);
1877             expand_end_bindings (getdecls (), 1, 0);
1878             $<ttype>$ = poplevel (1, 1, 0);
1879             pop_momentary ();       
1880           }
1881 */
1882
1883 /* Any kind of label, including jump labels and case labels.
1884    ANSI C accepts labels only before statements, but we allow them
1885    also at the end of a compound statement.  */
1886
1887 label:    CASE expr_no_commas ':'
1888                 { register tree value = check_case_value ($2);
1889                   register tree label
1890                     = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
1891
1892                   stmt_count++;
1893
1894                   if (value != error_mark_node)
1895                     {
1896                       tree duplicate;
1897                       int success = pushcase (value, convert_and_check,
1898                                               label, &duplicate);
1899                       if (success == 1)
1900                         error ("case label not within a switch statement");
1901                       else if (success == 2)
1902                         {
1903                           error ("duplicate case value");
1904                           error_with_decl (duplicate, "this is the first entry for that value");
1905                         }
1906                       else if (success == 3)
1907                         warning ("case value out of range");
1908                       else if (success == 5)
1909                         error ("case label within scope of cleanup or variable array");
1910                     }
1911                   position_after_white_space (); }
1912         | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
1913                 { register tree value1 = check_case_value ($2);
1914                   register tree value2 = check_case_value ($4);
1915                   register tree label
1916                     = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
1917
1918                   stmt_count++;
1919
1920                   if (value1 != error_mark_node && value2 != error_mark_node)
1921                     {
1922                       tree duplicate;
1923                       int success = pushcase_range (value1, value2,
1924                                                     convert_and_check, label,
1925                                                     &duplicate);
1926                       if (success == 1)
1927                         error ("case label not within a switch statement");
1928                       else if (success == 2)
1929                         {
1930                           error ("duplicate case value");
1931                           error_with_decl (duplicate, "this is the first entry for that value");
1932                         }
1933                       else if (success == 3)
1934                         warning ("case value out of range");
1935                       else if (success == 4)
1936                         warning ("empty case range");
1937                       else if (success == 5)
1938                         error ("case label within scope of cleanup or variable array");
1939                     }
1940                   position_after_white_space (); }
1941         | DEFAULT ':'
1942                 {
1943                   tree duplicate;
1944                   register tree label
1945                     = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
1946                   int success = pushcase (NULL_TREE, 0, label, &duplicate);
1947                   stmt_count++;
1948                   if (success == 1)
1949                     error ("default label not within a switch statement");
1950                   else if (success == 2)
1951                     {
1952                       error ("multiple default labels in one switch");
1953                       error_with_decl (duplicate, "this is the first default label");
1954                     }
1955                   position_after_white_space (); }
1956         | identifier ':'
1957                 { tree label = define_label (input_filename, lineno, $1);
1958                   stmt_count++;
1959                   emit_nop ();
1960                   if (label)
1961                     expand_label (label);
1962                   position_after_white_space (); }
1963         ;
1964
1965 /* Either a type-qualifier or nothing.  First thing in an `asm' statement.  */
1966
1967 maybe_type_qual:
1968         /* empty */
1969                 { emit_line_note (input_filename, lineno);
1970                   $$ = NULL_TREE; }
1971         | TYPE_QUAL
1972                 { emit_line_note (input_filename, lineno); }
1973         ;
1974
1975 xexpr:
1976         /* empty */
1977                 { $$ = NULL_TREE; }
1978         | expr
1979         ;
1980
1981 /* These are the operands other than the first string and colon
1982    in  asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x))  */
1983 asm_operands: /* empty */
1984                 { $$ = NULL_TREE; }
1985         | nonnull_asm_operands
1986         ;
1987
1988 nonnull_asm_operands:
1989           asm_operand
1990         | nonnull_asm_operands ',' asm_operand
1991                 { $$ = chainon ($1, $3); }
1992         ;
1993
1994 asm_operand:
1995           STRING '(' expr ')'
1996                 { $$ = build_tree_list ($1, $3); }
1997         ;
1998
1999 asm_clobbers:
2000           string
2001                 { $$ = tree_cons (NULL_TREE, combine_strings ($1), NULL_TREE); }
2002         | asm_clobbers ',' string
2003                 { $$ = tree_cons (NULL_TREE, combine_strings ($3), $1); }
2004         ;
2005 \f
2006 /* This is what appears inside the parens in a function declarator.
2007    Its value is a list of ..._TYPE nodes.  */
2008 parmlist:
2009                 { pushlevel (0);
2010                   clear_parm_order ();
2011                   declare_parm_level (0); }
2012           parmlist_1
2013                 { $$ = $2;
2014                   parmlist_tags_warning ();
2015                   poplevel (0, 0, 0); }
2016         ;
2017
2018 parmlist_1:
2019           parmlist_2 ')'
2020         | parms ';'
2021                 { tree parm;
2022                   if (pedantic)
2023                     pedwarn ("ANSI C forbids forward parameter declarations");
2024                   /* Mark the forward decls as such.  */
2025                   for (parm = getdecls (); parm; parm = TREE_CHAIN (parm))
2026                     TREE_ASM_WRITTEN (parm) = 1;
2027                   clear_parm_order (); }
2028           parmlist_1
2029                 { $$ = $4; }
2030         | error ')'
2031                 { $$ = tree_cons (NULL_TREE, NULL_TREE, NULL_TREE); }
2032         ;
2033
2034 /* This is what appears inside the parens in a function declarator.
2035    Is value is represented in the format that grokdeclarator expects.  */
2036 parmlist_2:  /* empty */
2037                 { $$ = get_parm_info (0); }
2038         | ELLIPSIS
2039                 { $$ = get_parm_info (0);
2040                   if (pedantic)
2041                     pedwarn ("ANSI C requires a named argument before `...'");
2042                 }
2043         | parms
2044                 { $$ = get_parm_info (1); }
2045         | parms ',' ELLIPSIS
2046                 { $$ = get_parm_info (0); }
2047         ;
2048
2049 parms:
2050         parm
2051                 { push_parm_decl ($1); }
2052         | parms ',' parm
2053                 { push_parm_decl ($3); }
2054         ;
2055
2056 /* A single parameter declaration or parameter type name,
2057    as found in a parmlist.  */
2058 parm:
2059           typed_declspecs parm_declarator
2060                 { $$ = build_tree_list ($1, $2) ; }
2061         | typed_declspecs notype_declarator
2062                 { $$ = build_tree_list ($1, $2) ; }
2063         | typed_declspecs absdcl
2064                 { $$ = build_tree_list ($1, $2); }
2065         | declmods notype_declarator
2066                 { $$ = build_tree_list ($1, $2) ; }
2067         | declmods absdcl
2068                 { $$ = build_tree_list ($1, $2); }
2069         ;
2070
2071 /* This is used in a function definition
2072    where either a parmlist or an identifier list is ok.
2073    Its value is a list of ..._TYPE nodes or a list of identifiers.  */
2074 parmlist_or_identifiers:
2075                 { pushlevel (0);
2076                   clear_parm_order ();
2077                   declare_parm_level (1); }
2078           parmlist_or_identifiers_1
2079                 { $$ = $2;
2080                   parmlist_tags_warning ();
2081                   poplevel (0, 0, 0); }
2082         ;
2083
2084 parmlist_or_identifiers_1:
2085           parmlist_1
2086         | identifiers ')'
2087                 { tree t;
2088                   for (t = $1; t; t = TREE_CHAIN (t))
2089                     if (TREE_VALUE (t) == NULL_TREE)
2090                       error ("`...' in old-style identifier list");
2091                   $$ = tree_cons (NULL_TREE, NULL_TREE, $1); }
2092         ;
2093
2094 /* A nonempty list of identifiers.  */
2095 identifiers:
2096         IDENTIFIER
2097                 { $$ = build_tree_list (NULL_TREE, $1); }
2098         | identifiers ',' IDENTIFIER
2099                 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2100         ;
2101
2102 /* A nonempty list of identifiers, including typenames.  */
2103 identifiers_or_typenames:
2104         identifier
2105                 { $$ = build_tree_list (NULL_TREE, $1); }
2106         | identifiers_or_typenames ',' identifier
2107                 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2108         ;
2109 \f
2110 ifobjc
2111 /* Objective-C productions.  */
2112
2113 objcdef:
2114           classdef
2115         | classdecl
2116         | aliasdecl
2117         | protocoldef
2118         | methoddef
2119         | END
2120                 {
2121                   if (objc_implementation_context)
2122                     {
2123                       finish_class (objc_implementation_context);
2124                       objc_ivar_chain = NULL_TREE;
2125                       objc_implementation_context = NULL_TREE;
2126                     }
2127                   else
2128                     warning ("`@end' must appear in an implementation context");
2129                 }
2130         ;
2131
2132 /* A nonempty list of identifiers.  */
2133 identifier_list:
2134         identifier
2135                 { $$ = build_tree_list (NULL_TREE, $1); }
2136         | identifier_list ',' identifier
2137                 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2138         ;
2139
2140 classdecl:
2141           CLASS identifier_list ';'
2142                 {
2143                   objc_declare_class ($2);
2144                 }
2145
2146 aliasdecl:
2147           ALIAS identifier identifier ';'
2148                 {
2149                   objc_declare_alias ($2, $3);
2150                 }
2151
2152 classdef:
2153           INTERFACE identifier protocolrefs '{'
2154                 {
2155                   objc_interface_context = objc_ivar_context
2156                     = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, $3);
2157                   objc_public_flag = 0;
2158                 }
2159           ivar_decl_list '}'
2160                 {
2161                   continue_class (objc_interface_context);
2162                 }
2163           methodprotolist
2164           END
2165                 {
2166                   finish_class (objc_interface_context);
2167                   objc_interface_context = NULL_TREE;
2168                 }
2169
2170         | INTERFACE identifier protocolrefs
2171                 {
2172                   objc_interface_context
2173                     = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, $3);
2174                   continue_class (objc_interface_context);
2175                 }
2176           methodprotolist
2177           END
2178                 {
2179                   finish_class (objc_interface_context);
2180                   objc_interface_context = NULL_TREE;
2181                 }
2182
2183         | INTERFACE identifier ':' identifier protocolrefs '{'
2184                 {
2185                   objc_interface_context = objc_ivar_context
2186                     = start_class (CLASS_INTERFACE_TYPE, $2, $4, $5);
2187                   objc_public_flag = 0;
2188                 }
2189           ivar_decl_list '}'
2190                 {
2191                   continue_class (objc_interface_context);
2192                 }
2193           methodprotolist
2194           END
2195                 {
2196                   finish_class (objc_interface_context);
2197                   objc_interface_context = NULL_TREE;
2198                 }
2199
2200         | INTERFACE identifier ':' identifier protocolrefs
2201                 {
2202                   objc_interface_context
2203                     = start_class (CLASS_INTERFACE_TYPE, $2, $4, $5);
2204                   continue_class (objc_interface_context);
2205                 }
2206           methodprotolist
2207           END
2208                 {
2209                   finish_class (objc_interface_context);
2210                   objc_interface_context = NULL_TREE;
2211                 }
2212
2213         | IMPLEMENTATION identifier '{'
2214                 {
2215                   objc_implementation_context = objc_ivar_context
2216                     = start_class (CLASS_IMPLEMENTATION_TYPE, $2, NULL_TREE, NULL_TREE);
2217                   objc_public_flag = 0;
2218                 }
2219           ivar_decl_list '}'
2220                 {
2221                   objc_ivar_chain
2222                     = continue_class (objc_implementation_context);
2223                 }
2224
2225         | IMPLEMENTATION identifier
2226                 {
2227                   objc_implementation_context
2228                     = start_class (CLASS_IMPLEMENTATION_TYPE, $2, NULL_TREE, NULL_TREE);
2229                   objc_ivar_chain
2230                     = continue_class (objc_implementation_context);
2231                 }
2232
2233         | IMPLEMENTATION identifier ':' identifier '{'
2234                 {
2235                   objc_implementation_context = objc_ivar_context
2236                     = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2237                   objc_public_flag = 0;
2238                 }
2239           ivar_decl_list '}'
2240                 {
2241                   objc_ivar_chain
2242                     = continue_class (objc_implementation_context);
2243                 }
2244
2245         | IMPLEMENTATION identifier ':' identifier
2246                 {
2247                   objc_implementation_context
2248                     = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2249                   objc_ivar_chain
2250                     = continue_class (objc_implementation_context);
2251                 }
2252
2253         | INTERFACE identifier '(' identifier ')' protocolrefs
2254                 {
2255                   objc_interface_context
2256                     = start_class (CATEGORY_INTERFACE_TYPE, $2, $4, $6);
2257                   continue_class (objc_interface_context);
2258                 }
2259           methodprotolist
2260           END
2261                 {
2262                   finish_class (objc_interface_context);
2263                   objc_interface_context = NULL_TREE;
2264                 }
2265
2266         | IMPLEMENTATION identifier '(' identifier ')'
2267                 {
2268                   objc_implementation_context
2269                     = start_class (CATEGORY_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2270                   objc_ivar_chain
2271                     = continue_class (objc_implementation_context);
2272                 }
2273         ;
2274
2275 protocoldef:
2276           PROTOCOL identifier protocolrefs
2277                 {
2278                   remember_protocol_qualifiers ();
2279                   objc_interface_context
2280                     = start_protocol(PROTOCOL_INTERFACE_TYPE, $2, $3);
2281                 }
2282           methodprotolist END
2283                 {
2284                   forget_protocol_qualifiers();
2285                   finish_protocol(objc_interface_context);
2286                   objc_interface_context = NULL_TREE;
2287                 }
2288         ;
2289
2290 protocolrefs:
2291           /* empty */
2292                 {
2293                   $$ = NULL_TREE;
2294                 }
2295         | ARITHCOMPARE identifier_list ARITHCOMPARE
2296                 {
2297                   if ($1 == LT_EXPR && $3 == GT_EXPR)
2298                     $$ = $2;
2299                   else
2300                     YYERROR1;
2301                 }
2302         ;
2303
2304 ivar_decl_list:
2305           ivar_decl_list visibility_spec ivar_decls
2306         | ivar_decls
2307         ;
2308
2309 visibility_spec:
2310           PRIVATE { objc_public_flag = 2; }
2311         | PROTECTED { objc_public_flag = 0; }
2312         | PUBLIC { objc_public_flag = 1; }
2313         ;
2314
2315 ivar_decls:
2316           /* empty */
2317                 {
2318                   $$ = NULL_TREE;
2319                 }
2320         | ivar_decls ivar_decl ';'
2321         | ivar_decls ';'
2322                 {
2323                   if (pedantic)
2324                     pedwarn ("extra semicolon in struct or union specified");
2325                 }
2326         ;
2327
2328
2329 /* There is a shift-reduce conflict here, because `components' may
2330    start with a `typename'.  It happens that shifting (the default resolution)
2331    does the right thing, because it treats the `typename' as part of
2332    a `typed_typespecs'.
2333
2334    It is possible that this same technique would allow the distinction
2335    between `notype_initdecls' and `initdecls' to be eliminated.
2336    But I am being cautious and not trying it.  */
2337
2338 ivar_decl:
2339         typed_typespecs setspecs ivars
2340                 {
2341                   $$ = $3;
2342                   resume_momentary ($2);
2343                 }
2344         | nonempty_type_quals setspecs ivars
2345                 {
2346                   $$ = $3;
2347                   resume_momentary ($2);
2348                 }
2349         | error
2350                 { $$ = NULL_TREE; }
2351         ;
2352
2353 ivars:
2354           /* empty */
2355                 { $$ = NULL_TREE; }
2356         | ivar_declarator
2357         | ivars ',' ivar_declarator
2358         ;
2359
2360 ivar_declarator:
2361           declarator
2362                 {
2363                   $$ = add_instance_variable (objc_ivar_context,
2364                                               objc_public_flag,
2365                                               $1, current_declspecs,
2366                                               NULL_TREE);
2367                 }
2368         | declarator ':' expr_no_commas
2369                 {
2370                   $$ = add_instance_variable (objc_ivar_context,
2371                                               objc_public_flag,
2372                                               $1, current_declspecs, $3);
2373                 }
2374         | ':' expr_no_commas
2375                 {
2376                   $$ = add_instance_variable (objc_ivar_context,
2377                                               objc_public_flag,
2378                                               NULL_TREE,
2379                                               current_declspecs, $2);
2380                 }
2381         ;
2382
2383 methoddef:
2384           '+'
2385                 {
2386                   remember_protocol_qualifiers ();
2387                   if (objc_implementation_context)
2388                     objc_inherit_code = CLASS_METHOD_DECL;
2389                   else
2390                     fatal ("method definition not in class context");
2391                 }
2392           methoddecl
2393                 {
2394                   forget_protocol_qualifiers ();
2395                   add_class_method (objc_implementation_context, $3);
2396                   start_method_def ($3);
2397                   objc_method_context = $3;
2398                 }
2399           optarglist
2400                 {
2401                   continue_method_def ();
2402                 }
2403           compstmt_or_error
2404                 {
2405                   finish_method_def ();
2406                   objc_method_context = NULL_TREE;
2407                 }
2408
2409         | '-'
2410                 {
2411                   remember_protocol_qualifiers ();
2412                   if (objc_implementation_context)
2413                     objc_inherit_code = INSTANCE_METHOD_DECL;
2414                   else
2415                     fatal ("method definition not in class context");
2416                 }
2417           methoddecl
2418                 {
2419                   forget_protocol_qualifiers ();
2420                   add_instance_method (objc_implementation_context, $3);
2421                   start_method_def ($3);
2422                   objc_method_context = $3;
2423                 }
2424           optarglist
2425                 {
2426                   continue_method_def ();
2427                 }
2428           compstmt_or_error
2429                 {
2430                   finish_method_def ();
2431                   objc_method_context = NULL_TREE;
2432                 }
2433         ;
2434
2435 /* the reason for the strange actions in this rule
2436  is so that notype_initdecls when reached via datadef
2437  can find a valid list of type and sc specs in $0. */
2438
2439 methodprotolist:
2440           /* empty  */
2441         | {$<ttype>$ = NULL_TREE; } methodprotolist2
2442         ;
2443
2444 methodprotolist2:                /* eliminates a shift/reduce conflict */
2445            methodproto
2446         |  datadef
2447         | methodprotolist2 methodproto
2448         | methodprotolist2 {$<ttype>$ = NULL_TREE; } datadef
2449         ;
2450
2451 semi_or_error:
2452           ';'
2453         | error
2454         ;
2455
2456 methodproto:
2457           '+'
2458                 {
2459                   objc_inherit_code = CLASS_METHOD_DECL;
2460                 }
2461           methoddecl
2462                 {
2463                   add_class_method (objc_interface_context, $3);
2464                 }
2465           semi_or_error
2466
2467         | '-'
2468                 {
2469                   objc_inherit_code = INSTANCE_METHOD_DECL;
2470                 }
2471           methoddecl
2472                 {
2473                   add_instance_method (objc_interface_context, $3);
2474                 }
2475           semi_or_error
2476         ;
2477
2478 methoddecl:
2479           '(' typename ')' unaryselector
2480                 {
2481                   $$ = build_method_decl (objc_inherit_code, $2, $4, NULL_TREE);
2482                 }
2483
2484         | unaryselector
2485                 {
2486                   $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, NULL_TREE);
2487                 }
2488
2489         | '(' typename ')' keywordselector optparmlist
2490                 {
2491                   $$ = build_method_decl (objc_inherit_code, $2, $4, $5);
2492                 }
2493
2494         | keywordselector optparmlist
2495                 {
2496                   $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, $2);
2497                 }
2498         ;
2499
2500 /* "optarglist" assumes that start_method_def has already been called...
2501    if it is not, the "xdecls" will not be placed in the proper scope */
2502
2503 optarglist:
2504           /* empty */
2505         | ';' myxdecls
2506         ;
2507
2508 /* to get around the following situation: "int foo (int a) int b; {}" that
2509    is synthesized when parsing "- a:a b:b; id c; id d; { ... }" */
2510
2511 myxdecls:
2512           /* empty */
2513         | mydecls
2514         ;
2515
2516 mydecls:
2517         mydecl
2518         | errstmt
2519         | mydecls mydecl
2520         | mydecl errstmt
2521         ;
2522
2523 mydecl:
2524         typed_declspecs setspecs myparms ';'
2525                 { resume_momentary ($2); }
2526         | typed_declspecs ';'
2527                 { shadow_tag ($1); }
2528         | declmods ';'
2529                 { pedwarn ("empty declaration"); }
2530         ;
2531
2532 myparms:
2533         myparm
2534                 { push_parm_decl ($1); }
2535         | myparms ',' myparm
2536                 { push_parm_decl ($3); }
2537         ;
2538
2539 /* A single parameter declaration or parameter type name,
2540    as found in a parmlist. DOES NOT ALLOW AN INITIALIZER OR ASMSPEC */
2541
2542 myparm:
2543           parm_declarator
2544                 { $$ = build_tree_list (current_declspecs, $1)  ; }
2545         | notype_declarator
2546                 { $$ = build_tree_list (current_declspecs, $1)  ; }
2547         | absdcl
2548                 { $$ = build_tree_list (current_declspecs, $1)  ; }
2549         ;
2550
2551 optparmlist:
2552           /* empty */
2553                 {
2554                   $$ = NULL_TREE;
2555                 }
2556         | ',' ELLIPSIS
2557                 {
2558                   /* oh what a kludge! */
2559                   $$ = (tree)1;
2560                 }
2561         | ','
2562                 {
2563                   pushlevel (0);
2564                 }
2565           parmlist_2
2566                 {
2567                   /* returns a tree list node generated by get_parm_info */
2568                   $$ = $3;
2569                   poplevel (0, 0, 0);
2570                 }
2571         ;
2572
2573 unaryselector:
2574           selector
2575         ;
2576
2577 keywordselector:
2578           keyworddecl
2579
2580         | keywordselector keyworddecl
2581                 {
2582                   $$ = chainon ($1, $2);
2583                 }
2584         ;
2585
2586 selector:
2587           IDENTIFIER
2588         | TYPENAME
2589         | OBJECTNAME
2590         | reservedwords
2591         ;
2592
2593 reservedwords:
2594           ENUM { $$ = get_identifier (token_buffer); }
2595         | STRUCT { $$ = get_identifier (token_buffer); }
2596         | UNION { $$ = get_identifier (token_buffer); }
2597         | IF { $$ = get_identifier (token_buffer); }
2598         | ELSE { $$ = get_identifier (token_buffer); }
2599         | WHILE { $$ = get_identifier (token_buffer); }
2600         | DO { $$ = get_identifier (token_buffer); }
2601         | FOR { $$ = get_identifier (token_buffer); }
2602         | SWITCH { $$ = get_identifier (token_buffer); }
2603         | CASE { $$ = get_identifier (token_buffer); }
2604         | DEFAULT { $$ = get_identifier (token_buffer); }
2605         | BREAK { $$ = get_identifier (token_buffer); }
2606         | CONTINUE { $$ = get_identifier (token_buffer); }
2607         | RETURN  { $$ = get_identifier (token_buffer); }
2608         | GOTO { $$ = get_identifier (token_buffer); }
2609         | ASM_KEYWORD { $$ = get_identifier (token_buffer); }
2610         | SIZEOF { $$ = get_identifier (token_buffer); }
2611         | TYPEOF { $$ = get_identifier (token_buffer); }
2612         | ALIGNOF { $$ = get_identifier (token_buffer); }
2613         | TYPESPEC | TYPE_QUAL
2614         ;
2615
2616 keyworddecl:
2617           selector ':' '(' typename ')' identifier
2618                 {
2619                   $$ = build_keyword_decl ($1, $4, $6);
2620                 }
2621
2622         | selector ':' identifier
2623                 {
2624                   $$ = build_keyword_decl ($1, NULL_TREE, $3);
2625                 }
2626
2627         | ':' '(' typename ')' identifier
2628                 {
2629                   $$ = build_keyword_decl (NULL_TREE, $3, $5);
2630                 }
2631
2632         | ':' identifier
2633                 {
2634                   $$ = build_keyword_decl (NULL_TREE, NULL_TREE, $2);
2635                 }
2636         ;
2637
2638 messageargs:
2639           selector
2640         | keywordarglist
2641         ;
2642
2643 keywordarglist:
2644           keywordarg
2645         | keywordarglist keywordarg
2646                 {
2647                   $$ = chainon ($1, $2);
2648                 }
2649         ;
2650
2651
2652 keywordexpr:
2653           nonnull_exprlist
2654                 {
2655                   if (TREE_CHAIN ($1) == NULL_TREE)
2656                     /* just return the expr., remove a level of indirection */
2657                     $$ = TREE_VALUE ($1);
2658                   else
2659                     /* we have a comma expr., we will collapse later */
2660                     $$ = $1;
2661                 }
2662         ;
2663
2664 keywordarg:
2665           selector ':' keywordexpr
2666                 {
2667                   $$ = build_tree_list ($1, $3);
2668                 }
2669         | ':' keywordexpr
2670                 {
2671                   $$ = build_tree_list (NULL_TREE, $2);
2672                 }
2673         ;
2674
2675 receiver:
2676           expr
2677         | CLASSNAME
2678                 {
2679                   $$ = get_class_reference ($1);
2680                 }
2681         ;
2682
2683 objcmessageexpr:
2684           '['
2685                 { objc_receiver_context = 1; }
2686           receiver
2687                 { objc_receiver_context = 0; }
2688           messageargs ']'
2689                 {
2690                   $$ = build_tree_list ($3, $5);
2691                 }
2692         ;
2693
2694 selectorarg:
2695           selector
2696         | keywordnamelist
2697         ;
2698
2699 keywordnamelist:
2700           keywordname
2701         | keywordnamelist keywordname
2702                 {
2703                   $$ = chainon ($1, $2);
2704                 }
2705         ;
2706
2707 keywordname:
2708           selector ':'
2709                 {
2710                   $$ = build_tree_list ($1, NULL_TREE);
2711                 }
2712         | ':'
2713                 {
2714                   $$ = build_tree_list (NULL_TREE, NULL_TREE);
2715                 }
2716         ;
2717
2718 objcselectorexpr:
2719           SELECTOR '(' selectorarg ')'
2720                 {
2721                   $$ = $3;
2722                 }
2723         ;
2724
2725 objcprotocolexpr:
2726           PROTOCOL '(' identifier ')'
2727                 {
2728                   $$ = $3;
2729                 }
2730         ;
2731
2732 /* extension to support C-structures in the archiver */
2733
2734 objcencodeexpr:
2735           ENCODE '(' typename ')'
2736                 {
2737                   $$ = groktypename ($3);
2738                 }
2739         ;
2740
2741 end ifobjc
2742 %%