OSDN Git Service

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