OSDN Git Service

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