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