OSDN Git Service

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