OSDN Git Service

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