source: trunk/third/gcc/c-parse.y @ 11288

Revision 11288, 65.0 KB checked in by ghudson, 26 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r11287, which included commits to RCS files with non-trunk default branches.
Line 
1/*WARNING: This file is automatically generated!*/
2/* YACC parser for C syntax and for Objective C.  -*-c-*-
3   Copyright (C) 1987, 88, 89, 92-97, 1998 Free Software Foundation, Inc.
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 46
32
33/* These are the 23 conflicts you should get in parse.output;
34   the state numbers may vary if minor changes in the grammar are made.
35
36State 42 contains 1 shift/reduce conflict.  (Two ways to parse ATTRIBUTE.)
37State 44 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
38State 103 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
39State 110 contains 1 shift/reduce conflict.  (Two ways to parse ATTRIBUTE.)
40State 111 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
41State 115 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
42State 132 contains 1 shift/reduce conflict.  (See comment at component_decl.)
43State 180 contains 1 shift/reduce conflict.  (Two ways to parse ATTRIBUTE.)
44State 194 contains 2 shift/reduce conflict.  (Four ways to parse this.)
45State 202 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
46State 214 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
47State 220 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
48State 304 contains 2 shift/reduce conflicts.  (Four ways to parse this.)
49State 335 contains 2 shift/reduce conflicts.  (Four ways to parse this.)
50State 347 contains 1 shift/reduce conflict.  (Two ways to parse ATTRIBUTES.)
51State 352 contains 1 shift/reduce conflict.  (Two ways to parse ATTRIBUTES.)
52State 383 contains 2 shift/reduce conflicts.  (Four ways to parse this.)
53State 434 contains 2 shift/reduce conflicts.  (Four ways to parse this.)  */
54
55
56%{
57#include "config.h"
58
59#include <stdio.h>
60#include <errno.h>
61#include <setjmp.h>
62
63#include "tree.h"
64#include "input.h"
65#include "c-lex.h"
66#include "c-tree.h"
67#include "flags.h"
68
69#ifdef MULTIBYTE_CHARS
70#include <stdlib.h>
71#include <locale.h>
72#endif
73
74
75/* Since parsers are distinct for each language, put the language string
76   definition here.  */
77char *language_string = "GNU C";
78
79#ifndef errno
80extern int errno;
81#endif
82
83void yyerror ();
84
85/* Like YYERROR but do call yyerror.  */
86#define YYERROR1 { yyerror ("syntax error"); YYERROR; }
87
88/* Cause the `yydebug' variable to be defined.  */
89#define YYDEBUG 1
90%}
91
92%start program
93
94%union {long itype; tree ttype; enum tree_code code;
95        char *filename; int lineno; int ends_in_label; }
96
97/* All identifiers that are not reserved words
98   and are not declared typedefs in the current block */
99%token IDENTIFIER
100
101/* All identifiers that are declared typedefs in the current block.
102   In some contexts, they are treated just like IDENTIFIER,
103   but they can also serve as typespecs in declarations.  */
104%token TYPENAME
105
106/* Reserved words that specify storage class.
107   yylval contains an IDENTIFIER_NODE which indicates which one.  */
108%token SCSPEC
109
110/* Reserved words that specify type.
111   yylval contains an IDENTIFIER_NODE which indicates which one.  */
112%token TYPESPEC
113
114/* Reserved words that qualify type: "const" or "volatile".
115   yylval contains an IDENTIFIER_NODE which indicates which one.  */
116%token TYPE_QUAL
117
118/* Character or numeric constants.
119   yylval is the node for the constant.  */
120%token CONSTANT
121
122/* String constants in raw form.
123   yylval is a STRING_CST node.  */
124%token STRING
125
126/* "...", used for functions with variable arglists.  */
127%token ELLIPSIS
128
129/* the reserved words */
130/* SCO include files test "ASM", so use something else. */
131%token SIZEOF ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
132%token BREAK CONTINUE RETURN GOTO ASM_KEYWORD TYPEOF ALIGNOF
133%token ATTRIBUTE EXTENSION LABEL
134%token REALPART IMAGPART
135
136/* Add precedence rules to solve dangling else s/r conflict */
137%nonassoc IF
138%nonassoc ELSE
139
140/* Define the operator tokens and their precedences.
141   The value is an integer because, if used, it is the tree code
142   to use in the expression made from the operator.  */
143
144%right <code> ASSIGN '='
145%right <code> '?' ':'
146%left <code> OROR
147%left <code> ANDAND
148%left <code> '|'
149%left <code> '^'
150%left <code> '&'
151%left <code> EQCOMPARE
152%left <code> ARITHCOMPARE
153%left <code> LSHIFT RSHIFT
154%left <code> '+' '-'
155%left <code> '*' '/' '%'
156%right <code> UNARY PLUSPLUS MINUSMINUS
157%left HYPERUNARY
158%left <code> POINTSAT '.' '(' '['
159
160/* The Objective-C keywords.  These are included in C and in
161   Objective C, so that the token codes are the same in both.  */
162%token INTERFACE IMPLEMENTATION END SELECTOR DEFS ENCODE
163%token CLASSNAME PUBLIC PRIVATE PROTECTED PROTOCOL OBJECTNAME CLASS ALIAS
164
165/* Objective-C string constants in raw form.
166   yylval is an OBJC_STRING_CST node.  */
167%token OBJC_STRING
168
169
170%type <code> unop
171
172%type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist exprlist
173%type <ttype> expr_no_commas cast_expr unary_expr primary string STRING
174%type <ttype> typed_declspecs reserved_declspecs
175%type <ttype> typed_typespecs reserved_typespecquals
176%type <ttype> declmods typespec typespecqual_reserved
177%type <ttype> typed_declspecs_no_prefix_attr reserved_declspecs_no_prefix_attr
178%type <ttype> declmods_no_prefix_attr
179%type <ttype> SCSPEC TYPESPEC TYPE_QUAL nonempty_type_quals maybe_type_qual
180%type <ttype> initdecls notype_initdecls initdcl notype_initdcl
181%type <ttype> init maybeasm
182%type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
183%type <ttype> maybe_attribute attributes attribute attribute_list attrib
184%type <ttype> any_word
185
186%type <ttype> compstmt
187
188%type <ttype> declarator
189%type <ttype> notype_declarator after_type_declarator
190%type <ttype> parm_declarator
191
192%type <ttype> structsp component_decl_list component_decl_list2
193%type <ttype> component_decl components component_declarator
194%type <ttype> enumlist enumerator
195%type <ttype> typename absdcl absdcl1 type_quals
196%type <ttype> xexpr parms parm identifiers
197
198%type <ttype> parmlist parmlist_1 parmlist_2
199%type <ttype> parmlist_or_identifiers parmlist_or_identifiers_1
200%type <ttype> identifiers_or_typenames
201
202%type <itype> setspecs
203
204%type <ends_in_label> lineno_stmt_or_label lineno_stmt_or_labels stmt_or_label
205
206%type <filename> save_filename
207%type <lineno> save_lineno
208
209
210%{
211/* Number of statements (loosely speaking) and compound statements
212   seen so far.  */
213static int stmt_count;
214static int compstmt_count;
215 
216/* Input file and line number of the end of the body of last simple_if;
217   used by the stmt-rule immediately after simple_if returns.  */
218static char *if_stmt_file;
219static int if_stmt_line;
220
221/* List of types and structure classes of the current declaration.  */
222static tree current_declspecs = NULL_TREE;
223static tree prefix_attributes = NULL_TREE;
224
225/* Stack of saved values of current_declspecs and prefix_attributes.  */
226static tree declspec_stack;
227
228/* 1 if we explained undeclared var errors.  */
229static int undeclared_variable_notice;
230
231
232/* Tell yyparse how to print a token's value, if yydebug is set.  */
233
234#define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
235extern void yyprint ();
236%}
237
238%%
239program: /* empty */
240                { if (pedantic)
241                    pedwarn ("ANSI C forbids an empty source file");
242                  finish_file ();
243                }
244        | extdefs
245                {
246                  /* In case there were missing closebraces,
247                     get us back to the global binding level.  */
248                  while (! global_bindings_p ())
249                    poplevel (0, 0, 0);
250                  finish_file ();
251                }
252        ;
253
254/* the reason for the strange actions in this rule
255 is so that notype_initdecls when reached via datadef
256 can find a valid list of type and sc specs in $0. */
257
258extdefs:
259        {$<ttype>$ = NULL_TREE; } extdef
260        | extdefs {$<ttype>$ = NULL_TREE; } extdef
261        ;
262
263extdef:
264        fndef
265        | datadef
266        | ASM_KEYWORD '(' expr ')' ';'
267                { STRIP_NOPS ($3);
268                  if ((TREE_CODE ($3) == ADDR_EXPR
269                       && TREE_CODE (TREE_OPERAND ($3, 0)) == STRING_CST)
270                      || TREE_CODE ($3) == STRING_CST)
271                    assemble_asm ($3);
272                  else
273                    error ("argument of `asm' is not a constant string"); }
274        | extension extdef
275                { pedantic = $<itype>1; }
276        ;
277
278datadef:
279          setspecs notype_initdecls ';'
280                { if (pedantic)
281                    error ("ANSI C forbids data definition with no type or storage class");
282                  else if (!flag_traditional)
283                    warning ("data definition has no type or storage class");
284
285                  current_declspecs = TREE_VALUE (declspec_stack);
286                  prefix_attributes = TREE_PURPOSE (declspec_stack);
287                  declspec_stack = TREE_CHAIN (declspec_stack);
288                  resume_momentary ($1); }
289        | declmods setspecs notype_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        | typed_declspecs setspecs initdecls ';'
295                { current_declspecs = TREE_VALUE (declspec_stack);
296                  prefix_attributes = TREE_PURPOSE (declspec_stack);
297                  declspec_stack = TREE_CHAIN (declspec_stack);
298                  resume_momentary ($2);  }
299        | declmods ';'
300          { pedwarn ("empty declaration"); }
301        | typed_declspecs ';'
302          { shadow_tag ($1); }
303        | error ';'
304        | error '}'
305        | ';'
306                { if (pedantic)
307                    pedwarn ("ANSI C does not allow extra `;' outside of a function"); }
308        ;
309
310fndef:
311          typed_declspecs setspecs declarator
312                { if (! start_function (current_declspecs, $3,
313                                        prefix_attributes, NULL_TREE, 0))
314                    YYERROR1;
315                  reinit_parse_for_function (); }
316          old_style_parm_decls
317                { store_parm_decls (); }
318          compstmt_or_error
319                { finish_function (0);
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        | typed_declspecs setspecs declarator error
325                { current_declspecs = TREE_VALUE (declspec_stack);
326                  prefix_attributes = TREE_PURPOSE (declspec_stack);
327                  declspec_stack = TREE_CHAIN (declspec_stack);
328                  resume_momentary ($2); }
329        | declmods setspecs notype_declarator
330                { if (! start_function (current_declspecs, $3,
331                                        prefix_attributes, NULL_TREE, 0))
332                    YYERROR1;
333                  reinit_parse_for_function (); }
334          old_style_parm_decls
335                { store_parm_decls (); }
336          compstmt_or_error
337                { finish_function (0);
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        | declmods setspecs notype_declarator error
343                { current_declspecs = TREE_VALUE (declspec_stack);
344                  prefix_attributes = TREE_PURPOSE (declspec_stack);
345                  declspec_stack = TREE_CHAIN (declspec_stack);
346                  resume_momentary ($2); }
347        | setspecs notype_declarator
348                { if (! start_function (NULL_TREE, $2,
349                                        prefix_attributes, NULL_TREE, 0))
350                    YYERROR1;
351                  reinit_parse_for_function (); }
352          old_style_parm_decls
353                { store_parm_decls (); }
354          compstmt_or_error
355                { finish_function (0);
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        | setspecs notype_declarator error
361                { current_declspecs = TREE_VALUE (declspec_stack);
362                  prefix_attributes = TREE_PURPOSE (declspec_stack);
363                  declspec_stack = TREE_CHAIN (declspec_stack);
364                  resume_momentary ($1); }
365        ;
366
367identifier:
368        IDENTIFIER
369        | TYPENAME
370        ;
371
372unop:     '&'
373                { $$ = ADDR_EXPR; }
374        | '-'
375                { $$ = NEGATE_EXPR; }
376        | '+'
377                { $$ = CONVERT_EXPR; }
378        | PLUSPLUS
379                { $$ = PREINCREMENT_EXPR; }
380        | MINUSMINUS
381                { $$ = PREDECREMENT_EXPR; }
382        | '~'
383                { $$ = BIT_NOT_EXPR; }
384        | '!'
385                { $$ = TRUTH_NOT_EXPR; }
386        ;
387
388expr:   nonnull_exprlist
389                { $$ = build_compound_expr ($1); }
390        ;
391
392exprlist:
393          /* empty */
394                { $$ = NULL_TREE; }
395        | nonnull_exprlist
396        ;
397
398nonnull_exprlist:
399        expr_no_commas
400                { $$ = build_tree_list (NULL_TREE, $1); }
401        | nonnull_exprlist ',' expr_no_commas
402                { chainon ($1, build_tree_list (NULL_TREE, $3)); }
403        ;
404
405unary_expr:
406        primary
407        | '*' cast_expr   %prec UNARY
408                { $$ = build_indirect_ref ($2, "unary *"); }
409        /* __extension__ turns off -pedantic for following primary.  */
410        | extension cast_expr     %prec UNARY
411                { $$ = $2;
412                  pedantic = $<itype>1; }
413        | unop cast_expr  %prec UNARY
414                { $$ = build_unary_op ($1, $2, 0);
415                  overflow_warning ($$); }
416        /* Refer to the address of a label as a pointer.  */
417        | ANDAND identifier
418                { tree label = lookup_label ($2);
419                  if (pedantic)
420                    pedwarn ("ANSI C forbids `&&'");
421                  if (label == 0)
422                    $$ = null_pointer_node;
423                  else
424                    {
425                      TREE_USED (label) = 1;
426                      $$ = build1 (ADDR_EXPR, ptr_type_node, label);
427                      TREE_CONSTANT ($$) = 1;
428                    }
429                }
430/* This seems to be impossible on some machines, so let's turn it off.
431   You can use __builtin_next_arg to find the anonymous stack args.
432        | '&' ELLIPSIS
433                { tree types = TYPE_ARG_TYPES (TREE_TYPE (current_function_decl));
434                  $$ = error_mark_node;
435                  if (TREE_VALUE (tree_last (types)) == void_type_node)
436                    error ("`&...' used in function with fixed number of arguments");
437                  else
438                    {
439                      if (pedantic)
440                        pedwarn ("ANSI C forbids `&...'");
441                      $$ = tree_last (DECL_ARGUMENTS (current_function_decl));
442                      $$ = build_unary_op (ADDR_EXPR, $$, 0);
443                    } }
444*/
445        | sizeof unary_expr  %prec UNARY
446                { skip_evaluation--;
447                  if (TREE_CODE ($2) == COMPONENT_REF
448                      && DECL_C_BIT_FIELD (TREE_OPERAND ($2, 1)))
449                    error ("`sizeof' applied to a bit-field");
450                  $$ = c_sizeof (TREE_TYPE ($2)); }
451        | sizeof '(' typename ')'  %prec HYPERUNARY
452                { skip_evaluation--;
453                  $$ = c_sizeof (groktypename ($3)); }
454        | alignof unary_expr  %prec UNARY
455                { skip_evaluation--;
456                  $$ = c_alignof_expr ($2); }
457        | alignof '(' typename ')'  %prec HYPERUNARY
458                { skip_evaluation--;
459                  $$ = c_alignof (groktypename ($3)); }
460        | REALPART cast_expr %prec UNARY
461                { $$ = build_unary_op (REALPART_EXPR, $2, 0); }
462        | IMAGPART cast_expr %prec UNARY
463                { $$ = build_unary_op (IMAGPART_EXPR, $2, 0); }
464        ;
465
466sizeof:
467        SIZEOF { skip_evaluation++; }
468        ;
469
470alignof:
471        ALIGNOF { skip_evaluation++; }
472        ;
473
474cast_expr:
475        unary_expr
476        | '(' typename ')' cast_expr  %prec UNARY
477                { tree type = groktypename ($2);
478                  $$ = build_c_cast (type, $4); }
479        | '(' typename ')' '{'
480                { start_init (NULL_TREE, NULL, 0);
481                  $2 = groktypename ($2);
482                  really_start_incremental_init ($2); }
483          initlist_maybe_comma '}'  %prec UNARY
484                { char *name;
485                  tree result = pop_init_level (0);
486                  tree type = $2;
487                  finish_init ();
488
489                  if (pedantic)
490                    pedwarn ("ANSI C forbids constructor expressions");
491                  if (TYPE_NAME (type) != 0)
492                    {
493                      if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
494                        name = IDENTIFIER_POINTER (TYPE_NAME (type));
495                      else
496                        name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
497                    }
498                  else
499                    name = "";
500                  $$ = result;
501                  if (TREE_CODE (type) == ARRAY_TYPE && TYPE_SIZE (type) == 0)
502                    {
503                      int failure = complete_array_type (type, $$, 1);
504                      if (failure)
505                        abort ();
506                    }
507                }
508        ;
509
510expr_no_commas:
511          cast_expr
512        | expr_no_commas '+' expr_no_commas
513                { $$ = parser_build_binary_op ($2, $1, $3); }
514        | expr_no_commas '-' expr_no_commas
515                { $$ = parser_build_binary_op ($2, $1, $3); }
516        | expr_no_commas '*' expr_no_commas
517                { $$ = parser_build_binary_op ($2, $1, $3); }
518        | expr_no_commas '/' expr_no_commas
519                { $$ = parser_build_binary_op ($2, $1, $3); }
520        | expr_no_commas '%' expr_no_commas
521                { $$ = parser_build_binary_op ($2, $1, $3); }
522        | expr_no_commas LSHIFT expr_no_commas
523                { $$ = parser_build_binary_op ($2, $1, $3); }
524        | expr_no_commas RSHIFT expr_no_commas
525                { $$ = parser_build_binary_op ($2, $1, $3); }
526        | expr_no_commas ARITHCOMPARE expr_no_commas
527                { $$ = parser_build_binary_op ($2, $1, $3); }
528        | expr_no_commas EQCOMPARE expr_no_commas
529                { $$ = parser_build_binary_op ($2, $1, $3); }
530        | expr_no_commas '&' expr_no_commas
531                { $$ = parser_build_binary_op ($2, $1, $3); }
532        | expr_no_commas '|' expr_no_commas
533                { $$ = parser_build_binary_op ($2, $1, $3); }
534        | expr_no_commas '^' expr_no_commas
535                { $$ = parser_build_binary_op ($2, $1, $3); }
536        | expr_no_commas ANDAND
537                { $1 = truthvalue_conversion (default_conversion ($1));
538                  skip_evaluation += $1 == boolean_false_node; }
539          expr_no_commas
540                { skip_evaluation -= $1 == boolean_false_node;
541                  $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $4); }
542        | expr_no_commas OROR
543                { $1 = truthvalue_conversion (default_conversion ($1));
544                  skip_evaluation += $1 == boolean_true_node; }
545          expr_no_commas
546                { skip_evaluation -= $1 == boolean_true_node;
547                  $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $4); }
548        | expr_no_commas '?'
549                { $1 = truthvalue_conversion (default_conversion ($1));
550                  skip_evaluation += $1 == boolean_false_node; }
551          expr ':'
552                { skip_evaluation += (($1 == boolean_true_node)
553                                      - ($1 == boolean_false_node)); }
554          expr_no_commas
555                { skip_evaluation -= $1 == boolean_true_node;
556                  $$ = build_conditional_expr ($1, $4, $7); }
557        | expr_no_commas '?'
558                { if (pedantic)
559                    pedwarn ("ANSI C forbids omitting the middle term of a ?: expression");
560                  /* Make sure first operand is calculated only once.  */
561                  $<ttype>2 = save_expr ($1);
562                  $1 = truthvalue_conversion (default_conversion ($<ttype>2));
563                  skip_evaluation += $1 == boolean_true_node; }
564          ':' expr_no_commas
565                { skip_evaluation -= $1 == boolean_true_node;
566                  $$ = build_conditional_expr ($1, $<ttype>2, $5); }
567        | expr_no_commas '=' expr_no_commas
568                { $$ = build_modify_expr ($1, NOP_EXPR, $3);
569                  C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
570        | expr_no_commas ASSIGN expr_no_commas
571                { $$ = build_modify_expr ($1, $2, $3);
572                  /* This inhibits warnings in truthvalue_conversion.  */
573                  C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK); }
574        ;
575
576primary:
577        IDENTIFIER
578                {
579                  $$ = lastiddecl;
580                  if (!$$ || $$ == error_mark_node)
581                    {
582                      if (yychar == YYEMPTY)
583                        yychar = YYLEX;
584                      if (yychar == '(')
585                        {
586                            {
587                              /* Ordinary implicit function declaration.  */
588                              $$ = implicitly_declare ($1);
589                              assemble_external ($$);
590                              TREE_USED ($$) = 1;
591                            }
592                        }
593                      else if (current_function_decl == 0)
594                        {
595                          error ("`%s' undeclared here (not in a function)",
596                                 IDENTIFIER_POINTER ($1));
597                          $$ = error_mark_node;
598                        }
599                      else
600                        {
601                            {
602                              if (IDENTIFIER_GLOBAL_VALUE ($1) != error_mark_node
603                                  || IDENTIFIER_ERROR_LOCUS ($1) != current_function_decl)
604                                {
605                                  error ("`%s' undeclared (first use in this function)",
606                                         IDENTIFIER_POINTER ($1));
607
608                                  if (! undeclared_variable_notice)
609                                    {
610                                      error ("(Each undeclared identifier is reported only once");
611                                      error ("for each function it appears in.)");
612                                      undeclared_variable_notice = 1;
613                                    }
614                                }
615                              $$ = error_mark_node;
616                              /* Prevent repeated error messages.  */
617                              IDENTIFIER_GLOBAL_VALUE ($1) = error_mark_node;
618                              IDENTIFIER_ERROR_LOCUS ($1) = current_function_decl;
619                            }
620                        }
621                    }
622                  else if (TREE_TYPE ($$) == error_mark_node)
623                    $$ = error_mark_node;
624                  else if (C_DECL_ANTICIPATED ($$))
625                    {
626                      /* The first time we see a build-in function used,
627                         if it has not been declared.  */
628                      C_DECL_ANTICIPATED ($$) = 0;
629                      if (yychar == YYEMPTY)
630                        yychar = YYLEX;
631                      if (yychar == '(')
632                        {
633                          /* Omit the implicit declaration we
634                             would ordinarily do, so we don't lose
635                             the actual built in type.
636                             But print a diagnostic for the mismatch.  */
637                            if (TREE_CODE ($$) != FUNCTION_DECL)
638                              error ("`%s' implicitly declared as function",
639                                     IDENTIFIER_POINTER (DECL_NAME ($$)));
640                          else if ((TYPE_MODE (TREE_TYPE (TREE_TYPE ($$)))
641                                    != TYPE_MODE (integer_type_node))
642                                   && (TREE_TYPE (TREE_TYPE ($$))
643                                       != void_type_node))
644                            pedwarn ("type mismatch in implicit declaration for built-in function `%s'",
645                                     IDENTIFIER_POINTER (DECL_NAME ($$)));
646                          /* If it really returns void, change that to int.  */
647                          if (TREE_TYPE (TREE_TYPE ($$)) == void_type_node)
648                            TREE_TYPE ($$)
649                              = build_function_type (integer_type_node,
650                                                     TYPE_ARG_TYPES (TREE_TYPE ($$)));
651                        }
652                      else
653                        pedwarn ("built-in function `%s' used without declaration",
654                                 IDENTIFIER_POINTER (DECL_NAME ($$)));
655
656                      /* Do what we would ordinarily do when a fn is used.  */
657                      assemble_external ($$);
658                      TREE_USED ($$) = 1;
659                    }
660                  else
661                    {
662                      assemble_external ($$);
663                      TREE_USED ($$) = 1;
664                    }
665
666                  if (TREE_CODE ($$) == CONST_DECL)
667                    {
668                      $$ = DECL_INITIAL ($$);
669                      /* This is to prevent an enum whose value is 0
670                         from being considered a null pointer constant.  */
671                      $$ = build1 (NOP_EXPR, TREE_TYPE ($$), $$);
672                      TREE_CONSTANT ($$) = 1;
673                    }
674                }
675        | CONSTANT
676        | string
677                { $$ = combine_strings ($1); }
678        | '(' expr ')'
679                { char class = TREE_CODE_CLASS (TREE_CODE ($2));
680                  if (class == 'e' || class == '1'
681                      || class == '2' || class == '<')
682                    C_SET_EXP_ORIGINAL_CODE ($2, ERROR_MARK);
683                  $$ = $2; }
684        | '(' error ')'
685                { $$ = error_mark_node; }
686        | '('
687                { if (current_function_decl == 0)
688                    {
689                      error ("braced-group within expression allowed only inside a function");
690                      YYERROR;
691                    }
692                  /* We must force a BLOCK for this level
693                     so that, if it is not expanded later,
694                     there is a way to turn off the entire subtree of blocks
695                     that are contained in it.  */
696                  keep_next_level ();
697                  push_iterator_stack ();
698                  push_label_level ();
699                  $<ttype>$ = expand_start_stmt_expr (); }
700          compstmt ')'
701                { tree rtl_exp;
702                  if (pedantic)
703                    pedwarn ("ANSI C forbids braced-groups within expressions");
704                  pop_iterator_stack ();
705                  pop_label_level ();
706                  rtl_exp = expand_end_stmt_expr ($<ttype>2);
707                  /* The statements have side effects, so the group does.  */
708                  TREE_SIDE_EFFECTS (rtl_exp) = 1;
709
710                  if (TREE_CODE ($3) == BLOCK)
711                    {
712                      /* Make a BIND_EXPR for the BLOCK already made.  */
713                      $$ = build (BIND_EXPR, TREE_TYPE (rtl_exp),
714                                  NULL_TREE, rtl_exp, $3);
715                      /* Remove the block from the tree at this point.
716                         It gets put back at the proper place
717                         when the BIND_EXPR is expanded.  */
718                      delete_block ($3);
719                    }
720                  else
721                    $$ = $3;
722                }
723        | primary '(' exprlist ')'   %prec '.'
724                { $$ = build_function_call ($1, $3); }
725        | primary '[' expr ']'   %prec '.'
726                { $$ = build_array_ref ($1, $3); }
727        | primary '.' identifier
728                {
729                    $$ = build_component_ref ($1, $3);
730                }
731        | primary POINTSAT identifier
732                {
733                  tree expr = build_indirect_ref ($1, "->");
734
735                    $$ = build_component_ref (expr, $3);
736                }
737        | primary PLUSPLUS
738                { $$ = build_unary_op (POSTINCREMENT_EXPR, $1, 0); }
739        | primary MINUSMINUS
740                { $$ = build_unary_op (POSTDECREMENT_EXPR, $1, 0); }
741        ;
742
743/* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it.  */
744string:
745          STRING
746        | string STRING
747                { $$ = chainon ($1, $2); }
748        ;
749
750
751old_style_parm_decls:
752        /* empty */
753        | datadecls
754        | datadecls ELLIPSIS
755                /* ... is used here to indicate a varargs function.  */
756                { c_mark_varargs ();
757                  if (pedantic)
758                    pedwarn ("ANSI C does not permit use of `varargs.h'"); }
759        ;
760
761/* The following are analogous to lineno_decl, decls and decl
762   except that they do not allow nested functions.
763   They are used for old-style parm decls.  */
764lineno_datadecl:
765          save_filename save_lineno datadecl
766                { }
767        ;
768
769datadecls:
770        lineno_datadecl
771        | errstmt
772        | datadecls lineno_datadecl
773        | lineno_datadecl errstmt
774        ;
775
776/* We don't allow prefix attributes here because they cause reduce/reduce
777   conflicts: we can't know whether we're parsing a function decl with
778   attribute suffix, or function defn with attribute prefix on first old
779   style parm.  */
780datadecl:
781        typed_declspecs_no_prefix_attr setspecs initdecls ';'
782                { current_declspecs = TREE_VALUE (declspec_stack);
783                  prefix_attributes = TREE_PURPOSE (declspec_stack);
784                  declspec_stack = TREE_CHAIN (declspec_stack);
785                  resume_momentary ($2); }
786        | declmods_no_prefix_attr setspecs notype_initdecls ';'
787                { current_declspecs = TREE_VALUE (declspec_stack);     
788                  prefix_attributes = TREE_PURPOSE (declspec_stack);
789                  declspec_stack = TREE_CHAIN (declspec_stack);
790                  resume_momentary ($2); }
791        | typed_declspecs_no_prefix_attr ';'
792                { shadow_tag_warned ($1, 1);
793                  pedwarn ("empty declaration"); }
794        | declmods_no_prefix_attr ';'
795                { pedwarn ("empty declaration"); }
796        ;
797
798/* This combination which saves a lineno before a decl
799   is the normal thing to use, rather than decl itself.
800   This is to avoid shift/reduce conflicts in contexts
801   where statement labels are allowed.  */
802lineno_decl:
803          save_filename save_lineno decl
804                { }
805        ;
806
807decls:
808        lineno_decl
809        | errstmt
810        | decls lineno_decl
811        | lineno_decl errstmt
812        ;
813
814/* records the type and storage class specs to use for processing
815   the declarators that follow.
816   Maintains a stack of outer-level values of current_declspecs,
817   for the sake of parm declarations nested in function declarators.  */
818setspecs: /* empty */
819                { $$ = suspend_momentary ();
820                  pending_xref_error ();
821                  declspec_stack = tree_cons (prefix_attributes,
822                                              current_declspecs,
823                                              declspec_stack);
824                  split_specs_attrs ($<ttype>0,
825                                     &current_declspecs, &prefix_attributes); }
826        ;
827
828/* ??? Yuck.  See after_type_declarator.  */
829setattrs: /* empty */
830                { prefix_attributes = chainon (prefix_attributes, $<ttype>0); }
831        ;
832
833decl:
834        typed_declspecs setspecs initdecls ';'
835                { current_declspecs = TREE_VALUE (declspec_stack);
836                  prefix_attributes = TREE_PURPOSE (declspec_stack);
837                  declspec_stack = TREE_CHAIN (declspec_stack);
838                  resume_momentary ($2); }
839        | declmods setspecs notype_initdecls ';'
840                { current_declspecs = TREE_VALUE (declspec_stack);
841                  prefix_attributes = TREE_PURPOSE (declspec_stack);
842                  declspec_stack = TREE_CHAIN (declspec_stack);
843                  resume_momentary ($2); }
844        | typed_declspecs setspecs nested_function
845                { current_declspecs = TREE_VALUE (declspec_stack);
846                  prefix_attributes = TREE_PURPOSE (declspec_stack);
847                  declspec_stack = TREE_CHAIN (declspec_stack);
848                  resume_momentary ($2); }
849        | declmods setspecs notype_nested_function
850                { current_declspecs = TREE_VALUE (declspec_stack);
851                  prefix_attributes = TREE_PURPOSE (declspec_stack);
852                  declspec_stack = TREE_CHAIN (declspec_stack);
853                  resume_momentary ($2); }
854        | typed_declspecs ';'
855                { shadow_tag ($1); }
856        | declmods ';'
857                { pedwarn ("empty declaration"); }
858        | extension decl
859                { pedantic = $<itype>1; }
860        ;
861
862/* Declspecs which contain at least one type specifier or typedef name.
863   (Just `const' or `volatile' is not enough.)
864   A typedef'd name following these is taken as a name to be declared.
865   Declspecs have a non-NULL TREE_VALUE, attributes do not.  */
866
867typed_declspecs:
868          typespec reserved_declspecs
869                { $$ = tree_cons (NULL_TREE, $1, $2); }
870        | declmods typespec reserved_declspecs
871                { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
872        ;
873
874reserved_declspecs:  /* empty */
875                { $$ = NULL_TREE; }
876        | reserved_declspecs typespecqual_reserved
877                { $$ = tree_cons (NULL_TREE, $2, $1); }
878        | reserved_declspecs SCSPEC
879                { if (extra_warnings)
880                    warning ("`%s' is not at beginning of declaration",
881                             IDENTIFIER_POINTER ($2));
882                  $$ = tree_cons (NULL_TREE, $2, $1); }
883        | reserved_declspecs attributes
884                { $$ = tree_cons ($2, NULL_TREE, $1); }
885        ;
886
887typed_declspecs_no_prefix_attr:
888          typespec reserved_declspecs_no_prefix_attr
889                { $$ = tree_cons (NULL_TREE, $1, $2); }
890        | declmods_no_prefix_attr typespec reserved_declspecs_no_prefix_attr
891                { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
892        ;
893
894reserved_declspecs_no_prefix_attr:
895          /* empty */
896                { $$ = NULL_TREE; }
897        | reserved_declspecs_no_prefix_attr typespecqual_reserved
898                { $$ = tree_cons (NULL_TREE, $2, $1); }
899        | reserved_declspecs_no_prefix_attr SCSPEC
900                { if (extra_warnings)
901                    warning ("`%s' is not at beginning of declaration",
902                             IDENTIFIER_POINTER ($2));
903                  $$ = tree_cons (NULL_TREE, $2, $1); }
904        ;
905
906/* List of just storage classes, type modifiers, and prefix attributes.
907   A declaration can start with just this, but then it cannot be used
908   to redeclare a typedef-name.
909   Declspecs have a non-NULL TREE_VALUE, attributes do not.  */
910
911declmods:
912          declmods_no_prefix_attr
913                { $$ = $1; }
914        | attributes
915                { $$ = tree_cons ($1, NULL_TREE, NULL_TREE); }
916        | declmods declmods_no_prefix_attr
917                { $$ = chainon ($2, $1); }
918        | declmods attributes
919                { $$ = tree_cons ($2, NULL_TREE, $1); }
920        ;
921
922declmods_no_prefix_attr:
923          TYPE_QUAL
924                { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
925                  TREE_STATIC ($$) = 1; }
926        | SCSPEC
927                { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
928        | declmods_no_prefix_attr TYPE_QUAL
929                { $$ = tree_cons (NULL_TREE, $2, $1);
930                  TREE_STATIC ($$) = 1; }
931        | declmods_no_prefix_attr SCSPEC
932                { if (extra_warnings && TREE_STATIC ($1))
933                    warning ("`%s' is not at beginning of declaration",
934                             IDENTIFIER_POINTER ($2));
935                  $$ = tree_cons (NULL_TREE, $2, $1);
936                  TREE_STATIC ($$) = TREE_STATIC ($1); }
937        ;
938
939
940/* Used instead of declspecs where storage classes are not allowed
941   (that is, for typenames and structure components).
942   Don't accept a typedef-name if anything but a modifier precedes it.  */
943
944typed_typespecs:
945          typespec reserved_typespecquals
946                { $$ = tree_cons (NULL_TREE, $1, $2); }
947        | nonempty_type_quals typespec reserved_typespecquals
948                { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
949        ;
950
951reserved_typespecquals:  /* empty */
952                { $$ = NULL_TREE; }
953        | reserved_typespecquals typespecqual_reserved
954                { $$ = tree_cons (NULL_TREE, $2, $1); }
955        ;
956
957/* A typespec (but not a type qualifier).
958   Once we have seen one of these in a declaration,
959   if a typedef name appears then it is being redeclared.  */
960
961typespec: TYPESPEC
962        | structsp
963        | TYPENAME
964                { /* For a typedef name, record the meaning, not the name.
965                     In case of `foo foo, bar;'.  */
966                  $$ = lookup_name ($1); }
967        | TYPEOF '(' expr ')'
968                { $$ = TREE_TYPE ($3); }
969        | TYPEOF '(' typename ')'
970                { $$ = groktypename ($3); }
971        ;
972
973/* A typespec that is a reserved word, or a type qualifier.  */
974
975typespecqual_reserved: TYPESPEC
976        | TYPE_QUAL
977        | structsp
978        ;
979
980initdecls:
981        initdcl
982        | initdecls ',' initdcl
983        ;
984
985notype_initdecls:
986        notype_initdcl
987        | notype_initdecls ',' initdcl
988        ;
989
990maybeasm:
991          /* empty */
992                { $$ = NULL_TREE; }
993        | ASM_KEYWORD '(' string ')'
994                { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
995                  $$ = $3;
996                }
997        ;
998
999initdcl:
1000          declarator maybeasm maybe_attribute '='
1001                { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1002                                          $3, prefix_attributes);
1003                  start_init ($<ttype>$, $2, global_bindings_p ()); }
1004          init
1005/* Note how the declaration of the variable is in effect while its init is parsed! */
1006                { finish_init ();
1007                  finish_decl ($<ttype>5, $6, $2); }
1008        | declarator maybeasm maybe_attribute
1009                { tree d = start_decl ($1, current_declspecs, 0,
1010                                       $3, prefix_attributes);
1011                  finish_decl (d, NULL_TREE, $2);
1012                }
1013        ;
1014
1015notype_initdcl:
1016          notype_declarator maybeasm maybe_attribute '='
1017                { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1018                                          $3, prefix_attributes);
1019                  start_init ($<ttype>$, $2, global_bindings_p ()); }
1020          init
1021/* Note how the declaration of the variable is in effect while its init is parsed! */
1022                { finish_init ();
1023                  decl_attributes ($<ttype>5, $3, prefix_attributes);
1024                  finish_decl ($<ttype>5, $6, $2); }
1025        | notype_declarator maybeasm maybe_attribute
1026                { tree d = start_decl ($1, current_declspecs, 0,
1027                                       $3, prefix_attributes);
1028                  finish_decl (d, NULL_TREE, $2); }
1029        ;
1030/* the * rules are dummies to accept the Apollo extended syntax
1031   so that the header files compile. */
1032maybe_attribute:
1033      /* empty */
1034                { $$ = NULL_TREE; }
1035        | attributes
1036                { $$ = $1; }
1037        ;
1038 
1039attributes:
1040      attribute
1041                { $$ = $1; }
1042        | attributes attribute
1043                { $$ = chainon ($1, $2); }
1044        ;
1045
1046attribute:
1047      ATTRIBUTE '(' '(' attribute_list ')' ')'
1048                { $$ = $4; }
1049        ;
1050
1051attribute_list:
1052      attrib
1053                { $$ = $1; }
1054        | attribute_list ',' attrib
1055                { $$ = chainon ($1, $3); }
1056        ;
1057 
1058attrib:
1059    /* empty */
1060                { $$ = NULL_TREE; }
1061        | any_word
1062                { $$ = build_tree_list ($1, NULL_TREE); }
1063        | any_word '(' IDENTIFIER ')'
1064                { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1065        | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1066                { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1067        | any_word '(' exprlist ')'
1068                { $$ = build_tree_list ($1, $3); }
1069        ;
1070
1071/* This still leaves out most reserved keywords,
1072   shouldn't we include them?  */
1073
1074any_word:
1075          identifier
1076        | SCSPEC
1077        | TYPESPEC
1078        | TYPE_QUAL
1079        ;
1080
1081/* Initializers.  `init' is the entry point.  */
1082
1083init:
1084        expr_no_commas
1085        | '{'
1086                { really_start_incremental_init (NULL_TREE);
1087                  /* Note that the call to clear_momentary
1088                     is in process_init_element.  */
1089                  push_momentary (); }
1090          initlist_maybe_comma '}'
1091                { $$ = pop_init_level (0);
1092                  if ($$ == error_mark_node
1093                      && ! (yychar == STRING || yychar == CONSTANT))
1094                    pop_momentary ();
1095                  else
1096                    pop_momentary_nofree (); }
1097
1098        | error
1099                { $$ = error_mark_node; }
1100        ;
1101
1102/* `initlist_maybe_comma' is the guts of an initializer in braces.  */
1103initlist_maybe_comma:
1104          /* empty */
1105                { if (pedantic)
1106                    pedwarn ("ANSI C forbids empty initializer braces"); }
1107        | initlist1 maybecomma
1108        ;
1109
1110initlist1:
1111          initelt
1112        | initlist1 ',' initelt
1113        ;
1114
1115/* `initelt' is a single element of an initializer.
1116   It may use braces.  */
1117initelt:
1118        expr_no_commas
1119                { process_init_element ($1); }
1120        | '{'
1121                { push_init_level (0); }
1122          initlist_maybe_comma '}'
1123                { process_init_element (pop_init_level (0)); }
1124        | error
1125        /* These are for labeled elements.  The syntax for an array element
1126           initializer conflicts with the syntax for an Objective-C message,
1127           so don't include these productions in the Objective-C grammar.  */
1128        | '[' expr_no_commas ELLIPSIS expr_no_commas ']' '='
1129                { set_init_index ($2, $4); }
1130          initelt
1131        | '[' expr_no_commas ']' '='
1132                { set_init_index ($2, NULL_TREE); }
1133          initelt
1134        | '[' expr_no_commas ']'
1135                { set_init_index ($2, NULL_TREE); }
1136          initelt
1137        | identifier ':'
1138                { set_init_label ($1); }
1139          initelt
1140        | '.' identifier '='
1141                { set_init_label ($2); }
1142          initelt
1143        ;
1144
1145nested_function:
1146          declarator
1147                { push_c_function_context ();
1148                  if (! start_function (current_declspecs, $1,
1149                                        prefix_attributes, NULL_TREE, 1))
1150                    {
1151                      pop_c_function_context ();
1152                      YYERROR1;
1153                    }
1154                  reinit_parse_for_function (); }
1155           old_style_parm_decls
1156                { store_parm_decls (); }
1157/* This used to use compstmt_or_error.
1158   That caused a bug with input `f(g) int g {}',
1159   where the use of YYERROR1 above caused an error
1160   which then was handled by compstmt_or_error.
1161   There followed a repeated execution of that same rule,
1162   which called YYERROR1 again, and so on.  */
1163          compstmt
1164                { finish_function (1);
1165                  pop_c_function_context (); }
1166        ;
1167
1168notype_nested_function:
1169          notype_declarator
1170                { push_c_function_context ();
1171                  if (! start_function (current_declspecs, $1,
1172                                        prefix_attributes, NULL_TREE, 1))
1173                    {
1174                      pop_c_function_context ();
1175                      YYERROR1;
1176                    }
1177                  reinit_parse_for_function (); }
1178          old_style_parm_decls
1179                { store_parm_decls (); }
1180/* This used to use compstmt_or_error.
1181   That caused a bug with input `f(g) int g {}',
1182   where the use of YYERROR1 above caused an error
1183   which then was handled by compstmt_or_error.
1184   There followed a repeated execution of that same rule,
1185   which called YYERROR1 again, and so on.  */
1186          compstmt
1187                { finish_function (1);
1188                  pop_c_function_context (); }
1189        ;
1190
1191/* Any kind of declarator (thus, all declarators allowed
1192   after an explicit typespec).  */
1193
1194declarator:
1195          after_type_declarator
1196        | notype_declarator
1197        ;
1198
1199/* A declarator that is allowed only after an explicit typespec.  */
1200
1201after_type_declarator:
1202          '(' after_type_declarator ')'
1203                { $$ = $2; }
1204        | after_type_declarator '(' parmlist_or_identifiers  %prec '.'
1205                { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1206/*      | after_type_declarator '(' error ')'  %prec '.'
1207                { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1208                  poplevel (0, 0, 0); }  */
1209        | after_type_declarator '[' expr ']'  %prec '.'
1210                { $$ = build_nt (ARRAY_REF, $1, $3); }
1211        | after_type_declarator '[' ']'  %prec '.'
1212                { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1213        | '*' type_quals after_type_declarator  %prec UNARY
1214                { $$ = make_pointer_declarator ($2, $3); }
1215        /* ??? Yuck.  setattrs is a quick hack.  We can't use
1216           prefix_attributes because $1 only applies to this
1217           declarator.  We assume setspecs has already been done.
1218           setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1219           attributes could be recognized here or in `attributes').  */
1220        | attributes setattrs after_type_declarator
1221                { $$ = $3; }
1222        | TYPENAME
1223        ;
1224
1225/* Kinds of declarator that can appear in a parameter list
1226   in addition to notype_declarator.  This is like after_type_declarator
1227   but does not allow a typedef name in parentheses as an identifier
1228   (because it would conflict with a function with that typedef as arg).  */
1229
1230parm_declarator:
1231          parm_declarator '(' parmlist_or_identifiers  %prec '.'
1232                { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1233/*      | parm_declarator '(' error ')'  %prec '.'
1234                { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1235                  poplevel (0, 0, 0); }  */
1236        | parm_declarator '[' expr ']'  %prec '.'
1237                { $$ = build_nt (ARRAY_REF, $1, $3); }
1238        | parm_declarator '[' ']'  %prec '.'
1239                { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1240        | '*' type_quals parm_declarator  %prec UNARY
1241                { $$ = make_pointer_declarator ($2, $3); }
1242        /* ??? Yuck.  setattrs is a quick hack.  We can't use
1243           prefix_attributes because $1 only applies to this
1244           declarator.  We assume setspecs has already been done.
1245           setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1246           attributes could be recognized here or in `attributes').  */
1247        | attributes setattrs parm_declarator
1248                { $$ = $3; }
1249        | TYPENAME
1250        ;
1251
1252/* A declarator allowed whether or not there has been
1253   an explicit typespec.  These cannot redeclare a typedef-name.  */
1254
1255notype_declarator:
1256          notype_declarator '(' parmlist_or_identifiers  %prec '.'
1257                { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1258/*      | notype_declarator '(' error ')'  %prec '.'
1259                { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1260                  poplevel (0, 0, 0); }  */
1261        | '(' notype_declarator ')'
1262                { $$ = $2; }
1263        | '*' type_quals notype_declarator  %prec UNARY
1264                { $$ = make_pointer_declarator ($2, $3); }
1265        | notype_declarator '[' expr ']'  %prec '.'
1266                { $$ = build_nt (ARRAY_REF, $1, $3); }
1267        | notype_declarator '[' ']'  %prec '.'
1268                { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1269        /* ??? Yuck.  setattrs is a quick hack.  We can't use
1270           prefix_attributes because $1 only applies to this
1271           declarator.  We assume setspecs has already been done.
1272           setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1273           attributes could be recognized here or in `attributes').  */
1274        | attributes setattrs notype_declarator
1275                { $$ = $3; }
1276        | IDENTIFIER
1277        ;
1278
1279structsp:
1280          STRUCT identifier '{'
1281                { $$ = start_struct (RECORD_TYPE, $2);
1282                  /* Start scope of tag before parsing components.  */
1283                }
1284          component_decl_list '}' maybe_attribute
1285                { $$ = finish_struct ($<ttype>4, $5, $7); }
1286        | STRUCT '{' component_decl_list '}' maybe_attribute
1287                { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
1288                                      $3, $5);
1289                }
1290        | STRUCT identifier
1291                { $$ = xref_tag (RECORD_TYPE, $2); }
1292        | UNION identifier '{'
1293                { $$ = start_struct (UNION_TYPE, $2); }
1294          component_decl_list '}' maybe_attribute
1295                { $$ = finish_struct ($<ttype>4, $5, $7); }
1296        | UNION '{' component_decl_list '}' maybe_attribute
1297                { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
1298                                      $3, $5);
1299                }
1300        | UNION identifier
1301                { $$ = xref_tag (UNION_TYPE, $2); }
1302        | ENUM identifier '{'
1303                { $<itype>3 = suspend_momentary ();
1304                  $$ = start_enum ($2); }
1305          enumlist maybecomma_warn '}' maybe_attribute
1306                { $$ = finish_enum ($<ttype>4, nreverse ($5), $8);
1307                  resume_momentary ($<itype>3); }
1308        | ENUM '{'
1309                { $<itype>2 = suspend_momentary ();
1310                  $$ = start_enum (NULL_TREE); }
1311          enumlist maybecomma_warn '}' maybe_attribute
1312                { $$ = finish_enum ($<ttype>3, nreverse ($4), $7);
1313                  resume_momentary ($<itype>2); }
1314        | ENUM identifier
1315                { $$ = xref_tag (ENUMERAL_TYPE, $2); }
1316        ;
1317
1318maybecomma:
1319          /* empty */
1320        | ','
1321        ;
1322
1323maybecomma_warn:
1324          /* empty */
1325        | ','
1326                { if (pedantic) pedwarn ("comma at end of enumerator list"); }
1327        ;
1328
1329component_decl_list:
1330          component_decl_list2
1331                { $$ = $1; }
1332        | component_decl_list2 component_decl
1333                { $$ = chainon ($1, $2);
1334                  pedwarn ("no semicolon at end of struct or union"); }
1335        ;
1336
1337component_decl_list2:   /* empty */
1338                { $$ = NULL_TREE; }
1339        | component_decl_list2 component_decl ';'
1340                { $$ = chainon ($1, $2); }
1341        | component_decl_list2 ';'
1342                { if (pedantic)
1343                    pedwarn ("extra semicolon in struct or union specified"); }
1344        ;
1345
1346/* There is a shift-reduce conflict here, because `components' may
1347   start with a `typename'.  It happens that shifting (the default resolution)
1348   does the right thing, because it treats the `typename' as part of
1349   a `typed_typespecs'.
1350
1351   It is possible that this same technique would allow the distinction
1352   between `notype_initdecls' and `initdecls' to be eliminated.
1353   But I am being cautious and not trying it.  */
1354
1355component_decl:
1356          typed_typespecs setspecs components
1357                { $$ = $3;
1358                  current_declspecs = TREE_VALUE (declspec_stack);
1359                  prefix_attributes = TREE_PURPOSE (declspec_stack);
1360                  declspec_stack = TREE_CHAIN (declspec_stack);
1361                  resume_momentary ($2); }
1362        | typed_typespecs
1363                { if (pedantic)
1364                    pedwarn ("ANSI C forbids member declarations with no members");
1365                  shadow_tag($1);
1366                  $$ = NULL_TREE; }
1367        | nonempty_type_quals setspecs components
1368                { $$ = $3;
1369                  current_declspecs = TREE_VALUE (declspec_stack);
1370                  prefix_attributes = TREE_PURPOSE (declspec_stack);
1371                  declspec_stack = TREE_CHAIN (declspec_stack);
1372                  resume_momentary ($2); }
1373        | nonempty_type_quals
1374                { if (pedantic)
1375                    pedwarn ("ANSI C forbids member declarations with no members");
1376                  shadow_tag($1);
1377                  $$ = NULL_TREE; }
1378        | error
1379                { $$ = NULL_TREE; }
1380        | extension component_decl
1381                { $$ = $2;
1382                  pedantic = $<itype>1; }
1383        ;
1384
1385components:
1386          component_declarator
1387        | components ',' component_declarator
1388                { $$ = chainon ($1, $3); }
1389        ;
1390
1391component_declarator:
1392          save_filename save_lineno declarator maybe_attribute
1393                { $$ = grokfield ($1, $2, $3, current_declspecs, NULL_TREE);
1394                  decl_attributes ($$, $4, prefix_attributes); }
1395        | save_filename save_lineno
1396          declarator ':' expr_no_commas maybe_attribute
1397                { $$ = grokfield ($1, $2, $3, current_declspecs, $5);
1398                  decl_attributes ($$, $6, prefix_attributes); }
1399        | save_filename save_lineno ':' expr_no_commas maybe_attribute
1400                { $$ = grokfield ($1, $2, NULL_TREE, current_declspecs, $4);
1401                  decl_attributes ($$, $5, prefix_attributes); }
1402        ;
1403
1404/* We chain the enumerators in reverse order.
1405   They are put in forward order where enumlist is used.
1406   (The order used to be significant, but no longer is so.
1407   However, we still maintain the order, just to be clean.)  */
1408
1409enumlist:
1410          enumerator
1411        | enumlist ',' enumerator
1412                { if ($1 == error_mark_node)
1413                    $$ = $1;
1414                  else
1415                    $$ = chainon ($3, $1); }
1416        | error
1417                { $$ = error_mark_node; }
1418        ;
1419
1420
1421enumerator:
1422          identifier
1423                { $$ = build_enumerator ($1, NULL_TREE); }
1424        | identifier '=' expr_no_commas
1425                { $$ = build_enumerator ($1, $3); }
1426        ;
1427
1428typename:
1429        typed_typespecs absdcl
1430                { $$ = build_tree_list ($1, $2); }
1431        | nonempty_type_quals absdcl
1432                { $$ = build_tree_list ($1, $2); }
1433        ;
1434
1435absdcl:   /* an absolute declarator */
1436        /* empty */
1437                { $$ = NULL_TREE; }
1438        | absdcl1
1439        ;
1440
1441nonempty_type_quals:
1442          TYPE_QUAL
1443                { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
1444        | nonempty_type_quals TYPE_QUAL
1445                { $$ = tree_cons (NULL_TREE, $2, $1); }
1446        ;
1447
1448type_quals:
1449          /* empty */
1450                { $$ = NULL_TREE; }
1451        | type_quals TYPE_QUAL
1452                { $$ = tree_cons (NULL_TREE, $2, $1); }
1453        ;
1454
1455absdcl1:  /* a nonempty absolute declarator */
1456          '(' absdcl1 ')'
1457                { $$ = $2; }
1458          /* `(typedef)1' is `int'.  */
1459        | '*' type_quals absdcl1  %prec UNARY
1460                { $$ = make_pointer_declarator ($2, $3); }
1461        | '*' type_quals  %prec UNARY
1462                { $$ = make_pointer_declarator ($2, NULL_TREE); }
1463        | absdcl1 '(' parmlist  %prec '.'
1464                { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1465        | absdcl1 '[' expr ']'  %prec '.'
1466                { $$ = build_nt (ARRAY_REF, $1, $3); }
1467        | absdcl1 '[' ']'  %prec '.'
1468                { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1469        | '(' parmlist  %prec '.'
1470                { $$ = build_nt (CALL_EXPR, NULL_TREE, $2, NULL_TREE); }
1471        | '[' expr ']'  %prec '.'
1472                { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
1473        | '[' ']'  %prec '.'
1474                { $$ = build_nt (ARRAY_REF, NULL_TREE, NULL_TREE); }
1475        /* ??? It appears we have to support attributes here, however
1476           using prefix_attributes is wrong.  */
1477        ;
1478
1479/* at least one statement, the first of which parses without error.  */
1480/* stmts is used only after decls, so an invalid first statement
1481   is actually regarded as an invalid decl and part of the decls.  */
1482
1483stmts:
1484        lineno_stmt_or_labels
1485                {
1486                  if (pedantic && $1)
1487                    pedwarn ("ANSI C forbids label at end of compound statement");
1488                }
1489        ;
1490
1491lineno_stmt_or_labels:
1492          lineno_stmt_or_label
1493        | lineno_stmt_or_labels lineno_stmt_or_label
1494                { $$ = $2; }
1495        | lineno_stmt_or_labels errstmt
1496                { $$ = 0; }
1497        ;
1498
1499xstmts:
1500        /* empty */
1501        | stmts
1502        ;
1503
1504errstmt:  error ';'
1505        ;
1506
1507pushlevel:  /* empty */
1508                { emit_line_note (input_filename, lineno);
1509                  pushlevel (0);
1510                  clear_last_expr ();
1511                  push_momentary ();
1512                  expand_start_bindings (0);
1513                }
1514        ;
1515
1516/* Read zero or more forward-declarations for labels
1517   that nested functions can jump to.  */
1518maybe_label_decls:
1519          /* empty */
1520        | label_decls
1521                { if (pedantic)
1522                    pedwarn ("ANSI C forbids label declarations"); }
1523        ;
1524
1525label_decls:
1526          label_decl
1527        | label_decls label_decl
1528        ;
1529
1530label_decl:
1531          LABEL identifiers_or_typenames ';'
1532                { tree link;
1533                  for (link = $2; link; link = TREE_CHAIN (link))
1534                    {
1535                      tree label = shadow_label (TREE_VALUE (link));
1536                      C_DECLARED_LABEL_FLAG (label) = 1;
1537                      declare_nonlocal_label (label);
1538                    }
1539                }
1540        ;
1541
1542/* This is the body of a function definition.
1543   It causes syntax errors to ignore to the next openbrace.  */
1544compstmt_or_error:
1545          compstmt
1546                {}
1547        | error compstmt
1548        ;
1549
1550compstmt_start: '{' { compstmt_count++; }
1551
1552compstmt: compstmt_start '}'
1553                { $$ = convert (void_type_node, integer_zero_node); }
1554        | compstmt_start pushlevel maybe_label_decls decls xstmts '}'
1555                { emit_line_note (input_filename, lineno);
1556                  expand_end_bindings (getdecls (), 1, 0);
1557                  $$ = poplevel (1, 1, 0);
1558                  if (yychar == CONSTANT || yychar == STRING)
1559                    pop_momentary_nofree ();
1560                  else
1561                    pop_momentary (); }
1562        | compstmt_start pushlevel maybe_label_decls error '}'
1563                { emit_line_note (input_filename, lineno);
1564                  expand_end_bindings (getdecls (), kept_level_p (), 0);
1565                  $$ = poplevel (kept_level_p (), 0, 0);
1566                  if (yychar == CONSTANT || yychar == STRING)
1567                    pop_momentary_nofree ();
1568                  else
1569                    pop_momentary (); }
1570        | compstmt_start pushlevel maybe_label_decls stmts '}'
1571                { emit_line_note (input_filename, lineno);
1572                  expand_end_bindings (getdecls (), kept_level_p (), 0);
1573                  $$ = poplevel (kept_level_p (), 0, 0);
1574                  if (yychar == CONSTANT || yychar == STRING)
1575                    pop_momentary_nofree ();
1576                  else
1577                    pop_momentary (); }
1578        ;
1579
1580/* Value is number of statements counted as of the closeparen.  */
1581simple_if:
1582          if_prefix lineno_labeled_stmt
1583/* Make sure c_expand_end_cond is run once
1584   for each call to c_expand_start_cond.
1585   Otherwise a crash is likely.  */
1586        | if_prefix error
1587        ;
1588
1589if_prefix:
1590          IF '(' expr ')'
1591                { emit_line_note ($<filename>-1, $<lineno>0);
1592                  c_expand_start_cond (truthvalue_conversion ($3), 0,
1593                                       compstmt_count);
1594                  $<itype>$ = stmt_count;
1595                  if_stmt_file = $<filename>-1;
1596                  if_stmt_line = $<lineno>0;
1597                  position_after_white_space (); }
1598        ;
1599
1600/* This is a subroutine of stmt.
1601   It is used twice, once for valid DO statements
1602   and once for catching errors in parsing the end test.  */
1603do_stmt_start:
1604          DO
1605                { stmt_count++;
1606                  compstmt_count++;
1607                  emit_line_note ($<filename>-1, $<lineno>0);
1608                  /* See comment in `while' alternative, above.  */
1609                  emit_nop ();
1610                  expand_start_loop_continue_elsewhere (1);
1611                  position_after_white_space (); }
1612          lineno_labeled_stmt WHILE
1613                { expand_loop_continue_here (); }
1614        ;
1615
1616save_filename:
1617                { $$ = input_filename; }
1618        ;
1619
1620save_lineno:
1621                { $$ = lineno; }
1622        ;
1623
1624lineno_labeled_stmt:
1625          save_filename save_lineno stmt
1626                { }
1627/*      | save_filename save_lineno error
1628                { }
1629*/
1630        | save_filename save_lineno label lineno_labeled_stmt
1631                { }
1632        ;
1633
1634lineno_stmt_or_label:
1635          save_filename save_lineno stmt_or_label
1636                { $$ = $3; }
1637        ;
1638
1639stmt_or_label:
1640          stmt
1641                { $$ = 0; }
1642        | label
1643                { $$ = 1; }
1644        ;
1645
1646/* Parse a single real statement, not including any labels.  */
1647stmt:
1648          compstmt
1649                { stmt_count++; }
1650        | all_iter_stmt
1651        | expr ';'
1652                { stmt_count++;
1653                  emit_line_note ($<filename>-1, $<lineno>0);
1654/* It appears that this should not be done--that a non-lvalue array
1655   shouldn't get an error if the value isn't used.
1656   Section 3.2.2.1 says that an array lvalue gets converted to a pointer
1657   if it appears as a top-level expression,
1658   but says nothing about non-lvalue arrays.  */
1659#if 0
1660                  /* Call default_conversion to get an error
1661                     on referring to a register array if pedantic.  */
1662                  if (TREE_CODE (TREE_TYPE ($1)) == ARRAY_TYPE
1663                      || TREE_CODE (TREE_TYPE ($1)) == FUNCTION_TYPE)
1664                    $1 = default_conversion ($1);
1665#endif
1666                  iterator_expand ($1);
1667                  clear_momentary (); }
1668        | simple_if ELSE
1669                { c_expand_start_else ();
1670                  $<itype>1 = stmt_count;
1671                  position_after_white_space (); }
1672          lineno_labeled_stmt
1673                { c_expand_end_cond ();
1674                  if (extra_warnings && stmt_count == $<itype>1)
1675                    warning ("empty body in an else-statement"); }
1676        | simple_if %prec IF
1677                { c_expand_end_cond ();
1678                  /* This warning is here instead of in simple_if, because we
1679                     do not want a warning if an empty if is followed by an
1680                     else statement.  Increment stmt_count so we don't
1681                     give a second error if this is a nested `if'.  */
1682                  if (extra_warnings && stmt_count++ == $<itype>1)
1683                    warning_with_file_and_line (if_stmt_file, if_stmt_line,
1684                                                "empty body in an if-statement"); }
1685/* Make sure c_expand_end_cond is run once
1686   for each call to c_expand_start_cond.
1687   Otherwise a crash is likely.  */
1688        | simple_if ELSE error
1689                { c_expand_end_cond (); }
1690        | WHILE
1691                { stmt_count++;
1692                  emit_line_note ($<filename>-1, $<lineno>0);
1693                  /* The emit_nop used to come before emit_line_note,
1694                     but that made the nop seem like part of the preceding line.
1695                     And that was confusing when the preceding line was
1696                     inside of an if statement and was not really executed.
1697                     I think it ought to work to put the nop after the line number.
1698                     We will see.  --rms, July 15, 1991.  */
1699                  emit_nop (); }
1700          '(' expr ')'
1701                { /* Don't start the loop till we have succeeded
1702                     in parsing the end test.  This is to make sure
1703                     that we end every loop we start.  */
1704                  expand_start_loop (1);
1705                  emit_line_note (input_filename, lineno);
1706                  expand_exit_loop_if_false (NULL_PTR,
1707                                             truthvalue_conversion ($4));
1708                  position_after_white_space (); }
1709          lineno_labeled_stmt
1710                { expand_end_loop (); }
1711        | do_stmt_start
1712          '(' expr ')' ';'
1713                { emit_line_note (input_filename, lineno);
1714                  expand_exit_loop_if_false (NULL_PTR,
1715                                             truthvalue_conversion ($3));
1716                  expand_end_loop ();
1717                  clear_momentary (); }
1718/* This rule is needed to make sure we end every loop we start.  */
1719        | do_stmt_start error
1720                { expand_end_loop ();
1721                  clear_momentary (); }
1722        | FOR
1723          '(' xexpr ';'
1724                { stmt_count++;
1725                  emit_line_note ($<filename>-1, $<lineno>0);
1726                  /* See comment in `while' alternative, above.  */
1727                  emit_nop ();
1728                  if ($3) c_expand_expr_stmt ($3);
1729                  /* Next step is to call expand_start_loop_continue_elsewhere,
1730                     but wait till after we parse the entire for (...).
1731                     Otherwise, invalid input might cause us to call that
1732                     fn without calling expand_end_loop.  */
1733                }
1734          xexpr ';'
1735                /* Can't emit now; wait till after expand_start_loop...  */
1736                { $<lineno>7 = lineno;
1737                  $<filename>$ = input_filename; }
1738          xexpr ')'
1739                {
1740                  /* Start the loop.  Doing this after parsing
1741                     all the expressions ensures we will end the loop.  */
1742                  expand_start_loop_continue_elsewhere (1);
1743                  /* Emit the end-test, with a line number.  */
1744                  emit_line_note ($<filename>8, $<lineno>7);
1745                  if ($6)
1746                    expand_exit_loop_if_false (NULL_PTR,
1747                                               truthvalue_conversion ($6));
1748                  /* Don't let the tree nodes for $9 be discarded by
1749                     clear_momentary during the parsing of the next stmt.  */
1750                  push_momentary ();
1751                  $<lineno>7 = lineno;
1752                  $<filename>8 = input_filename;
1753                  position_after_white_space (); }
1754          lineno_labeled_stmt
1755                { /* Emit the increment expression, with a line number.  */
1756                  emit_line_note ($<filename>8, $<lineno>7);
1757                  expand_loop_continue_here ();
1758                  if ($9)
1759                    c_expand_expr_stmt ($9);
1760                  if (yychar == CONSTANT || yychar == STRING)
1761                    pop_momentary_nofree ();
1762                  else
1763                    pop_momentary ();
1764                  expand_end_loop (); }
1765        | SWITCH '(' expr ')'
1766                { stmt_count++;
1767                  emit_line_note ($<filename>-1, $<lineno>0);
1768                  c_expand_start_case ($3);
1769                  /* Don't let the tree nodes for $3 be discarded by
1770                     clear_momentary during the parsing of the next stmt.  */
1771                  push_momentary ();
1772                  position_after_white_space (); }
1773          lineno_labeled_stmt
1774                { expand_end_case ($3);
1775                  if (yychar == CONSTANT || yychar == STRING)
1776                    pop_momentary_nofree ();
1777                  else
1778                    pop_momentary (); }
1779        | BREAK ';'
1780                { stmt_count++;
1781                  emit_line_note ($<filename>-1, $<lineno>0);
1782                  if ( ! expand_exit_something ())
1783                    error ("break statement not within loop or switch"); }
1784        | CONTINUE ';'
1785                { stmt_count++;
1786                  emit_line_note ($<filename>-1, $<lineno>0);
1787                  if (! expand_continue_loop (NULL_PTR))
1788                    error ("continue statement not within a loop"); }
1789        | RETURN ';'
1790                { stmt_count++;
1791                  emit_line_note ($<filename>-1, $<lineno>0);
1792                  c_expand_return (NULL_TREE); }
1793        | RETURN expr ';'
1794                { stmt_count++;
1795                  emit_line_note ($<filename>-1, $<lineno>0);
1796                  c_expand_return ($2); }
1797        | ASM_KEYWORD maybe_type_qual '(' expr ')' ';'
1798                { stmt_count++;
1799                  emit_line_note ($<filename>-1, $<lineno>0);
1800                  STRIP_NOPS ($4);
1801                  if ((TREE_CODE ($4) == ADDR_EXPR
1802                       && TREE_CODE (TREE_OPERAND ($4, 0)) == STRING_CST)
1803                      || TREE_CODE ($4) == STRING_CST)
1804                    expand_asm ($4);
1805                  else
1806                    error ("argument of `asm' is not a constant string"); }
1807        /* This is the case with just output operands.  */
1808        | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ')' ';'
1809                { stmt_count++;
1810                  emit_line_note ($<filename>-1, $<lineno>0);
1811                  c_expand_asm_operands ($4, $6, NULL_TREE, NULL_TREE,
1812                                         $2 == ridpointers[(int)RID_VOLATILE],
1813                                         input_filename, lineno); }
1814        /* This is the case with input operands as well.  */
1815        | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':' asm_operands ')' ';'
1816                { stmt_count++;
1817                  emit_line_note ($<filename>-1, $<lineno>0);
1818                  c_expand_asm_operands ($4, $6, $8, NULL_TREE,
1819                                         $2 == ridpointers[(int)RID_VOLATILE],
1820                                         input_filename, lineno); }
1821        /* This is the case with clobbered registers as well.  */
1822        | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':'
1823          asm_operands ':' asm_clobbers ')' ';'
1824                { stmt_count++;
1825                  emit_line_note ($<filename>-1, $<lineno>0);
1826                  c_expand_asm_operands ($4, $6, $8, $10,
1827                                         $2 == ridpointers[(int)RID_VOLATILE],
1828                                         input_filename, lineno); }
1829        | GOTO identifier ';'
1830                { tree decl;
1831                  stmt_count++;
1832                  emit_line_note ($<filename>-1, $<lineno>0);
1833                  decl = lookup_label ($2);
1834                  if (decl != 0)
1835                    {
1836                      TREE_USED (decl) = 1;
1837                      expand_goto (decl);
1838                    }
1839                }
1840        | GOTO '*' expr ';'
1841                { if (pedantic)
1842                    pedwarn ("ANSI C forbids `goto *expr;'");
1843                  stmt_count++;
1844                  emit_line_note ($<filename>-1, $<lineno>0);
1845                  expand_computed_goto (convert (ptr_type_node, $3)); }
1846        | ';'
1847        ;
1848
1849all_iter_stmt:
1850          all_iter_stmt_simple
1851/*      | all_iter_stmt_with_decl */
1852        ;
1853
1854all_iter_stmt_simple:
1855          FOR '(' primary ')'
1856          {
1857            /* The value returned by this action is  */
1858            /*      1 if everything is OK */
1859            /*      0 in case of error or already bound iterator */
1860
1861            $<itype>$ = 0;
1862            if (TREE_CODE ($3) != VAR_DECL)
1863              error ("invalid `for (ITERATOR)' syntax");
1864            else if (! ITERATOR_P ($3))
1865              error ("`%s' is not an iterator",
1866                     IDENTIFIER_POINTER (DECL_NAME ($3)));
1867            else if (ITERATOR_BOUND_P ($3))
1868              error ("`for (%s)' inside expansion of same iterator",
1869                     IDENTIFIER_POINTER (DECL_NAME ($3)));
1870            else
1871              {
1872                $<itype>$ = 1;
1873                iterator_for_loop_start ($3);
1874              }
1875          }
1876          lineno_labeled_stmt
1877          {
1878            if ($<itype>5)
1879              iterator_for_loop_end ($3);
1880          }
1881
1882/*  This really should allow any kind of declaration,
1883    for generality.  Fix it before turning it back on.
1884
1885all_iter_stmt_with_decl:
1886          FOR '(' ITERATOR pushlevel setspecs iterator_spec ')'
1887          {
1888*/          /* The value returned by this action is  */
1889            /*      1 if everything is OK */
1890            /*      0 in case of error or already bound iterator */
1891/*
1892            iterator_for_loop_start ($6);
1893          }
1894          lineno_labeled_stmt
1895          {
1896            iterator_for_loop_end ($6);
1897            emit_line_note (input_filename, lineno);
1898            expand_end_bindings (getdecls (), 1, 0);
1899            $<ttype>$ = poplevel (1, 1, 0);
1900            if (yychar == CONSTANT || yychar == STRING)
1901              pop_momentary_nofree ();
1902            else
1903              pop_momentary ();     
1904          }
1905*/
1906
1907/* Any kind of label, including jump labels and case labels.
1908   ANSI C accepts labels only before statements, but we allow them
1909   also at the end of a compound statement.  */
1910
1911label:    CASE expr_no_commas ':'
1912                { register tree value = check_case_value ($2);
1913                  register tree label
1914                    = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
1915
1916                  stmt_count++;
1917
1918                  if (value != error_mark_node)
1919                    {
1920                      tree duplicate;
1921                      int success = pushcase (value, convert_and_check,
1922                                              label, &duplicate);
1923                      if (success == 1)
1924                        error ("case label not within a switch statement");
1925                      else if (success == 2)
1926                        {
1927                          error ("duplicate case value");
1928                          error_with_decl (duplicate, "this is the first entry for that value");
1929                        }
1930                      else if (success == 3)
1931                        warning ("case value out of range");
1932                      else if (success == 5)
1933                        error ("case label within scope of cleanup or variable array");
1934                    }
1935                  position_after_white_space (); }
1936        | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
1937                { register tree value1 = check_case_value ($2);
1938                  register tree value2 = check_case_value ($4);
1939                  register tree label
1940                    = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
1941
1942                  if (pedantic)
1943                    pedwarn ("ANSI C forbids case ranges");
1944                  stmt_count++;
1945
1946                  if (value1 != error_mark_node && value2 != error_mark_node)
1947                    {
1948                      tree duplicate;
1949                      int success = pushcase_range (value1, value2,
1950                                                    convert_and_check, label,
1951                                                    &duplicate);
1952                      if (success == 1)
1953                        error ("case label not within a switch statement");
1954                      else if (success == 2)
1955                        {
1956                          error ("duplicate case value");
1957                          error_with_decl (duplicate, "this is the first entry for that value");
1958                        }
1959                      else if (success == 3)
1960                        warning ("case value out of range");
1961                      else if (success == 4)
1962                        warning ("empty case range");
1963                      else if (success == 5)
1964                        error ("case label within scope of cleanup or variable array");
1965                    }
1966                  position_after_white_space (); }
1967        | DEFAULT ':'
1968                {
1969                  tree duplicate;
1970                  register tree label
1971                    = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
1972                  int success = pushcase (NULL_TREE, 0, label, &duplicate);
1973                  stmt_count++;
1974                  if (success == 1)
1975                    error ("default label not within a switch statement");
1976                  else if (success == 2)
1977                    {
1978                      error ("multiple default labels in one switch");
1979                      error_with_decl (duplicate, "this is the first default label");
1980                    }
1981                  position_after_white_space (); }
1982        | identifier ':'
1983                { tree label = define_label (input_filename, lineno, $1);
1984                  stmt_count++;
1985                  emit_nop ();
1986                  if (label)
1987                    expand_label (label);
1988                  position_after_white_space (); }
1989        ;
1990
1991/* Either a type-qualifier or nothing.  First thing in an `asm' statement.  */
1992
1993maybe_type_qual:
1994        /* empty */
1995                { emit_line_note (input_filename, lineno);
1996                  $$ = NULL_TREE; }
1997        | TYPE_QUAL
1998                { emit_line_note (input_filename, lineno); }
1999        ;
2000
2001xexpr:
2002        /* empty */
2003                { $$ = NULL_TREE; }
2004        | expr
2005        ;
2006
2007/* These are the operands other than the first string and colon
2008   in  asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x))  */
2009asm_operands: /* empty */
2010                { $$ = NULL_TREE; }
2011        | nonnull_asm_operands
2012        ;
2013
2014nonnull_asm_operands:
2015          asm_operand
2016        | nonnull_asm_operands ',' asm_operand
2017                { $$ = chainon ($1, $3); }
2018        ;
2019
2020asm_operand:
2021          STRING '(' expr ')'
2022                { $$ = build_tree_list ($1, $3); }
2023        ;
2024
2025asm_clobbers:
2026          string
2027                { $$ = tree_cons (NULL_TREE, combine_strings ($1), NULL_TREE); }
2028        | asm_clobbers ',' string
2029                { $$ = tree_cons (NULL_TREE, combine_strings ($3), $1); }
2030        ;
2031
2032/* This is what appears inside the parens in a function declarator.
2033   Its value is a list of ..._TYPE nodes.  */
2034parmlist:
2035                { pushlevel (0);
2036                  clear_parm_order ();
2037                  declare_parm_level (0); }
2038          parmlist_1
2039                { $$ = $2;
2040                  parmlist_tags_warning ();
2041                  poplevel (0, 0, 0); }
2042        ;
2043
2044parmlist_1:
2045          parmlist_2 ')'
2046        | parms ';'
2047                { tree parm;
2048                  if (pedantic)
2049                    pedwarn ("ANSI C forbids forward parameter declarations");
2050                  /* Mark the forward decls as such.  */
2051                  for (parm = getdecls (); parm; parm = TREE_CHAIN (parm))
2052                    TREE_ASM_WRITTEN (parm) = 1;
2053                  clear_parm_order (); }
2054          parmlist_1
2055                { $$ = $4; }
2056        | error ')'
2057                { $$ = tree_cons (NULL_TREE, NULL_TREE, NULL_TREE); }
2058        ;
2059
2060/* This is what appears inside the parens in a function declarator.
2061   Is value is represented in the format that grokdeclarator expects.  */
2062parmlist_2:  /* empty */
2063                { $$ = get_parm_info (0); }
2064        | ELLIPSIS
2065                { $$ = get_parm_info (0);
2066                  /* Gcc used to allow this as an extension.  However, it does
2067                     not work for all targets, and thus has been disabled.
2068                     Also, since func (...) and func () are indistinguishable,
2069                     it caused problems with the code in expand_builtin which
2070                     tries to verify that BUILT_IN_NEXT_ARG is being used
2071                     correctly.  */
2072                  error ("ANSI C requires a named argument before `...'");
2073                }
2074        | parms
2075                { $$ = get_parm_info (1); }
2076        | parms ',' ELLIPSIS
2077                { $$ = get_parm_info (0); }
2078        ;
2079
2080parms:
2081        parm
2082                { push_parm_decl ($1); }
2083        | parms ',' parm
2084                { push_parm_decl ($3); }
2085        ;
2086
2087/* A single parameter declaration or parameter type name,
2088   as found in a parmlist.  */
2089parm:
2090          typed_declspecs setspecs parm_declarator maybe_attribute
2091                { $$ = build_tree_list (build_tree_list (current_declspecs,
2092                                                         $3),
2093                                        build_tree_list (prefix_attributes,
2094                                                         $4));
2095                  current_declspecs = TREE_VALUE (declspec_stack);
2096                  prefix_attributes = TREE_PURPOSE (declspec_stack);
2097                  declspec_stack = TREE_CHAIN (declspec_stack);
2098                  resume_momentary ($2); }
2099        | typed_declspecs setspecs notype_declarator maybe_attribute
2100                { $$ = build_tree_list (build_tree_list (current_declspecs,
2101                                                         $3),
2102                                        build_tree_list (prefix_attributes,
2103                                                         $4));
2104                  current_declspecs = TREE_VALUE (declspec_stack);
2105                  prefix_attributes = TREE_PURPOSE (declspec_stack);
2106                  declspec_stack = TREE_CHAIN (declspec_stack);
2107                  resume_momentary ($2); }
2108        | typed_declspecs setspecs absdcl maybe_attribute
2109                { $$ = build_tree_list (build_tree_list (current_declspecs,
2110                                                         $3),
2111                                        build_tree_list (prefix_attributes,
2112                                                         $4));
2113                  current_declspecs = TREE_VALUE (declspec_stack);
2114                  prefix_attributes = TREE_PURPOSE (declspec_stack);
2115                  declspec_stack = TREE_CHAIN (declspec_stack);
2116                  resume_momentary ($2); }
2117        | declmods setspecs notype_declarator maybe_attribute
2118                { $$ = build_tree_list (build_tree_list (current_declspecs,
2119                                                         $3),
2120                                        build_tree_list (prefix_attributes,
2121                                                         $4));
2122                  current_declspecs = TREE_VALUE (declspec_stack);
2123                  prefix_attributes = TREE_PURPOSE (declspec_stack);
2124                  declspec_stack = TREE_CHAIN (declspec_stack);
2125                  resume_momentary ($2);  }
2126
2127        | declmods setspecs absdcl maybe_attribute
2128                { $$ = build_tree_list (build_tree_list (current_declspecs,
2129                                                         $3),
2130                                        build_tree_list (prefix_attributes,
2131                                                         $4));
2132                  current_declspecs = TREE_VALUE (declspec_stack);
2133                  prefix_attributes = TREE_PURPOSE (declspec_stack);
2134                  declspec_stack = TREE_CHAIN (declspec_stack);
2135                  resume_momentary ($2);  }
2136        ;
2137
2138/* This is used in a function definition
2139   where either a parmlist or an identifier list is ok.
2140   Its value is a list of ..._TYPE nodes or a list of identifiers.  */
2141parmlist_or_identifiers:
2142                { pushlevel (0);
2143                  clear_parm_order ();
2144                  declare_parm_level (1); }
2145          parmlist_or_identifiers_1
2146                { $$ = $2;
2147                  parmlist_tags_warning ();
2148                  poplevel (0, 0, 0); }
2149        ;
2150
2151parmlist_or_identifiers_1:
2152          parmlist_1
2153        | identifiers ')'
2154                { tree t;
2155                  for (t = $1; t; t = TREE_CHAIN (t))
2156                    if (TREE_VALUE (t) == NULL_TREE)
2157                      error ("`...' in old-style identifier list");
2158                  $$ = tree_cons (NULL_TREE, NULL_TREE, $1); }
2159        ;
2160
2161/* A nonempty list of identifiers.  */
2162identifiers:
2163        IDENTIFIER
2164                { $$ = build_tree_list (NULL_TREE, $1); }
2165        | identifiers ',' IDENTIFIER
2166                { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2167        ;
2168
2169/* A nonempty list of identifiers, including typenames.  */
2170identifiers_or_typenames:
2171        identifier
2172                { $$ = build_tree_list (NULL_TREE, $1); }
2173        | identifiers_or_typenames ',' identifier
2174                { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2175        ;
2176
2177extension:
2178        EXTENSION
2179                { $<itype>$ = pedantic;
2180                  pedantic = 0; }
2181        ;
2182
2183%%
Note: See TracBrowser for help on using the repository browser.