OSDN Git Service

9774bcf461d4655c73446db58b3b927904c89928
[pf3gnuchains/gcc-fork.git] / gcc / c-parse.in
1 /* YACC parser for C syntax and for Objective C.  -*-c-*-
2    Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997,
3    1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
4
5 This file is part of GCC.
6
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
10 version.
11
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING.  If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20 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 @@ifc
32 %expect 13 /* shift/reduce conflicts, and no reduce/reduce conflicts.  */
33 @@end_ifc
34
35 %{
36 #include "config.h"
37 #include "system.h"
38 #include "coretypes.h"
39 #include "tm.h"
40 #include "tree.h"
41 #include "langhooks.h"
42 #include "input.h"
43 #include "cpplib.h"
44 #include "intl.h"
45 #include "timevar.h"
46 #include "c-pragma.h"           /* For YYDEBUG definition, and parse_in.  */
47 #include "c-tree.h"
48 #include "flags.h"
49 #include "varray.h"
50 #include "output.h"
51 #include "toplev.h"
52 #include "ggc.h"
53 #include "c-common.h"
54
55 /* Like YYERROR but do call yyerror.  */
56 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
57
58 /* Like the default stack expander, except (1) use realloc when possible,
59    (2) impose no hard maxiumum on stack size, (3) REALLY do not use alloca.
60
61    Irritatingly, YYSTYPE is defined after this %{ %} block, so we cannot
62    give malloced_yyvs its proper type.  This is ok since all we need from
63    it is to be able to free it.  */
64
65 static short *malloced_yyss;
66 static void *malloced_yyvs;
67
68 #define yyoverflow(MSG, SS, SSSIZE, VS, VSSIZE, YYSSZ)                  \
69 do {                                                                    \
70   size_t newsize;                                                       \
71   short *newss;                                                         \
72   YYSTYPE *newvs;                                                       \
73   newsize = *(YYSSZ) *= 2;                                              \
74   if (malloced_yyss)                                                    \
75     {                                                                   \
76       newss = really_call_realloc (*(SS), newsize * sizeof (short));    \
77       newvs = really_call_realloc (*(VS), newsize * sizeof (YYSTYPE));  \
78     }                                                                   \
79   else                                                                  \
80     {                                                                   \
81       newss = really_call_malloc (newsize * sizeof (short));            \
82       newvs = really_call_malloc (newsize * sizeof (YYSTYPE));          \
83       if (newss)                                                        \
84         memcpy (newss, *(SS), (SSSIZE));                                \
85       if (newvs)                                                        \
86         memcpy (newvs, *(VS), (VSSIZE));                                \
87     }                                                                   \
88   if (!newss || !newvs)                                                 \
89     {                                                                   \
90       yyerror (MSG);                                                    \
91       return 2;                                                         \
92     }                                                                   \
93   *(SS) = newss;                                                        \
94   *(VS) = newvs;                                                        \
95   malloced_yyss = newss;                                                \
96   malloced_yyvs = (void *) newvs;                                       \
97 } while (0)
98 %}
99
100 %start program
101
102 %union {long itype; tree ttype; struct c_expr exprtype; enum tree_code code;
103         location_t location; }
104
105 /* All identifiers that are not reserved words
106    and are not declared typedefs in the current block */
107 %token IDENTIFIER
108
109 /* All identifiers that are declared typedefs in the current block.
110    In some contexts, they are treated just like IDENTIFIER,
111    but they can also serve as typespecs in declarations.  */
112 %token TYPENAME
113
114 /* Reserved words that specify storage class.
115    yylval contains an IDENTIFIER_NODE which indicates which one.  */
116 %token SCSPEC                   /* Storage class other than static.  */
117 %token STATIC                   /* Static storage class.  */
118
119 /* Reserved words that specify type.
120    yylval contains an IDENTIFIER_NODE which indicates which one.  */
121 %token TYPESPEC
122
123 /* Reserved words that qualify type: "const", "volatile", or "restrict".
124    yylval contains an IDENTIFIER_NODE which indicates which one.  */
125 %token TYPE_QUAL
126
127 /* Objective-C protocol qualifiers.  These acquire their magic powers
128    only in certain contexts.  */
129 %token OBJC_TYPE_QUAL
130
131 /* Character or numeric constants.
132    yylval is the node for the constant.  */
133 %token CONSTANT
134
135 /* String constants in raw form.
136    yylval is a STRING_CST node.  */
137
138 %token STRING
139
140 /* "...", used for functions with variable arglists.  */
141 %token ELLIPSIS
142
143 /* the reserved words */
144 /* SCO include files test "ASM", so use something else. */
145 %token SIZEOF ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
146 %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD TYPEOF ALIGNOF
147 %token ATTRIBUTE EXTENSION LABEL
148 %token REALPART IMAGPART VA_ARG CHOOSE_EXPR TYPES_COMPATIBLE_P
149 %token PTR_VALUE PTR_BASE PTR_EXTENT
150 %token FUNC_NAME OFFSETOF
151
152 /* Add precedence rules to solve dangling else s/r conflict */
153 %nonassoc IF
154 %nonassoc ELSE
155
156 /* Define the operator tokens and their precedences.
157    The value is an integer because, if used, it is the tree code
158    to use in the expression made from the operator.  */
159
160 %right <code> ASSIGN '='
161 %right <code> '?' ':'
162 %left <code> OROR
163 %left <code> ANDAND
164 %left <code> '|'
165 %left <code> '^'
166 %left <code> '&'
167 %left <code> EQCOMPARE
168 %left <code> ARITHCOMPARE
169 %left <code> LSHIFT RSHIFT
170 %left <code> '+' '-'
171 %left <code> '*' '/' '%'
172 %right <code> UNARY PLUSPLUS MINUSMINUS
173 %left HYPERUNARY
174 %left <code> POINTSAT '.' '(' '['
175
176 /* The Objective-C keywords.  These are included in C and in
177    Objective C, so that the token codes are the same in both.  */
178 %token AT_INTERFACE AT_IMPLEMENTATION AT_END AT_SELECTOR AT_DEFS AT_ENCODE
179 %token CLASSNAME AT_PUBLIC AT_PRIVATE AT_PROTECTED AT_PROTOCOL
180 %token OBJECTNAME AT_CLASS AT_ALIAS
181 %token AT_THROW AT_TRY AT_CATCH AT_FINALLY AT_SYNCHRONIZED
182 %token OBJC_STRING
183
184 %type <code> unop
185 %type <ttype> ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
186 %type <ttype> BREAK CONTINUE RETURN GOTO ASM_KEYWORD SIZEOF TYPEOF ALIGNOF
187
188 %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT STRING FUNC_NAME
189 %type <ttype> nonnull_exprlist exprlist
190 %type <exprtype> expr expr_no_commas cast_expr unary_expr primary
191 %type <ttype> declspecs_nosc_nots_nosa_noea declspecs_nosc_nots_nosa_ea
192 %type <ttype> declspecs_nosc_nots_sa_noea declspecs_nosc_nots_sa_ea
193 %type <ttype> declspecs_nosc_ts_nosa_noea declspecs_nosc_ts_nosa_ea
194 %type <ttype> declspecs_nosc_ts_sa_noea declspecs_nosc_ts_sa_ea
195 %type <ttype> declspecs_sc_nots_nosa_noea declspecs_sc_nots_nosa_ea
196 %type <ttype> declspecs_sc_nots_sa_noea declspecs_sc_nots_sa_ea
197 %type <ttype> declspecs_sc_ts_nosa_noea declspecs_sc_ts_nosa_ea
198 %type <ttype> declspecs_sc_ts_sa_noea declspecs_sc_ts_sa_ea
199 %type <ttype> declspecs_ts declspecs_nots
200 %type <ttype> declspecs_ts_nosa declspecs_nots_nosa
201 %type <ttype> declspecs_nosc_ts declspecs_nosc_nots declspecs_nosc declspecs
202 %type <ttype> maybe_type_quals_attrs typespec_nonattr typespec_attr
203 %type <ttype> typespec_reserved_nonattr typespec_reserved_attr
204 %type <ttype> typespec_nonreserved_nonattr
205 %type <ttype> offsetof_member_designator
206
207 %type <ttype> scspec SCSPEC STATIC TYPESPEC TYPE_QUAL maybe_volatile
208 %type <ttype> initdecls notype_initdecls initdcl notype_initdcl
209 %type <exprtype> init
210 %type <ttype> simple_asm_expr maybeasm asm_stmt asm_argument
211 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
212 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
213 %type <ttype> any_word
214
215 %type <ttype> compstmt compstmt_start compstmt_primary_start
216 %type <ttype> stmt label stmt_nocomp start_break start_continue
217
218 %type <ttype> c99_block_start c99_block_lineno_labeled_stmt
219 %type <ttype> if_statement_1 if_statement_2
220 %type <ttype> declarator
221 %type <ttype> notype_declarator after_type_declarator
222 %type <ttype> parm_declarator
223 %type <ttype> parm_declarator_starttypename parm_declarator_nostarttypename
224 %type <ttype> array_declarator
225
226 %type <ttype> structsp_attr structsp_nonattr
227 %type <ttype> component_decl_list component_decl_list2
228 %type <ttype> component_decl components components_notype component_declarator
229 %type <ttype> component_notype_declarator
230 %type <ttype> enumlist enumerator
231 %type <ttype> struct_head union_head enum_head
232 %type <ttype> typename absdcl absdcl1 absdcl1_ea absdcl1_noea
233 %type <ttype> direct_absdcl1 absdcl_maybe_attribute
234 %type <ttype> condition xexpr for_cond_expr for_incr_expr
235 %type <ttype> parms parm firstparm identifiers
236
237 %type <ttype> parmlist parmlist_1 parmlist_2
238 %type <ttype> parmlist_or_identifiers parmlist_or_identifiers_1
239 %type <ttype> identifiers_or_typenames
240
241 %type <itype> setspecs setspecs_fp extension
242
243 %type <location> save_location
244 \f
245 @@ifobjc
246 /* the Objective-C nonterminals */
247
248 %type <ttype> methoddecl unaryselector keywordselector selector
249 %type <code> methodtype
250 %type <ttype> keyworddecl receiver objcmessageexpr messageargs
251 %type <ttype> keywordexpr keywordarglist keywordarg
252 %type <ttype> optparmlist optparms reservedwords objcselectorexpr
253 %type <ttype> selectorarg keywordnamelist keywordname objcencodeexpr
254 %type <ttype> non_empty_protocolrefs protocolrefs identifier_list objcprotocolexpr
255
256 %type <ttype> CLASSNAME OBJECTNAME OBJC_STRING OBJC_TYPE_QUAL
257
258 %type <ttype> superclass objc_quals objc_qual objc_typename
259 %type <itype> objc_try_catch_stmt optellipsis
260 @@end_ifobjc
261 \f
262 %{
263 /* List of types and structure classes of the current declaration.  */
264 static GTY(()) tree current_declspecs;
265 static GTY(()) tree prefix_attributes;
266
267 /* List of all the attributes applying to the identifier currently being
268    declared; includes prefix_attributes and possibly some more attributes
269    just after a comma.  */
270 static GTY(()) tree all_prefix_attributes;
271
272 /* Stack of saved values of current_declspecs, prefix_attributes and
273    all_prefix_attributes.  */
274 static GTY(()) tree declspec_stack;
275
276 /* INDIRECT_REF with a TREE_TYPE of the type being queried for offsetof.  */
277 static tree offsetof_base;
278
279 /* PUSH_DECLSPEC_STACK is called from setspecs; POP_DECLSPEC_STACK
280    should be called from the productions making use of setspecs.  */
281 #define PUSH_DECLSPEC_STACK                                              \
282   do {                                                                   \
283     declspec_stack = tree_cons (build_tree_list (prefix_attributes,      \
284                                                  all_prefix_attributes), \
285                                 current_declspecs,                       \
286                                 declspec_stack);                         \
287   } while (0)
288
289 #define POP_DECLSPEC_STACK                                              \
290   do {                                                                  \
291     current_declspecs = TREE_VALUE (declspec_stack);                    \
292     prefix_attributes = TREE_PURPOSE (TREE_PURPOSE (declspec_stack));   \
293     all_prefix_attributes = TREE_VALUE (TREE_PURPOSE (declspec_stack)); \
294     declspec_stack = TREE_CHAIN (declspec_stack);                       \
295   } while (0)
296
297 /* For __extension__, save/restore the warning flags which are
298    controlled by __extension__.  */
299 #define SAVE_EXT_FLAGS()                \
300         (pedantic                       \
301          | (warn_pointer_arith << 1)    \
302          | (warn_traditional << 2)      \
303          | (flag_iso << 3))
304
305 #define RESTORE_EXT_FLAGS(val)                  \
306   do {                                          \
307     pedantic = val & 1;                         \
308     warn_pointer_arith = (val >> 1) & 1;        \
309     warn_traditional = (val >> 2) & 1;          \
310     flag_iso = (val >> 3) & 1;                  \
311   } while (0)
312
313 @@ifobjc
314 /* Objective-C specific parser/lexer information */
315
316 static int objc_pq_context = 0;
317
318 /* The following flag is needed to contextualize ObjC lexical analysis.
319    In some cases (e.g., 'int NSObject;'), it is undesirable to bind
320    an identifier to an ObjC class, even if a class with that name
321    exists.  */
322 static int objc_need_raw_identifier;
323 #define OBJC_NEED_RAW_IDENTIFIER(VAL)   objc_need_raw_identifier = VAL
324 @@end_ifobjc
325
326 @@ifc
327 #define OBJC_NEED_RAW_IDENTIFIER(VAL)   /* nothing */
328 @@end_ifc
329
330 /* Tell yyparse how to print a token's value, if yydebug is set.  */
331
332 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
333
334 static void yyprint (FILE *, int, YYSTYPE);
335 static void yyerror (const char *);
336 static int yylexname (void);
337 static inline int _yylex (void);
338 static int  yylex (void);
339 static void init_reswords (void);
340
341   /* Initialisation routine for this file.  */
342 void
343 c_parse_init (void)
344 {
345   init_reswords ();
346 }
347
348 %}
349 \f
350 %%
351 program: /* empty */
352                 { if (pedantic)
353                     pedwarn ("ISO C forbids an empty source file");
354                 }
355         | extdefs
356         ;
357
358 /* the reason for the strange actions in this rule
359  is so that notype_initdecls when reached via datadef
360  can find a valid list of type and sc specs in $0. */
361
362 extdefs:
363         {$<ttype>$ = NULL_TREE; } extdef
364         | extdefs {$<ttype>$ = NULL_TREE; ggc_collect(); } extdef
365         ;
366
367 extdef:
368         fndef
369         | datadef
370         | asmdef
371         | extension extdef
372                 { RESTORE_EXT_FLAGS ($1); }
373 @@ifobjc
374         | objcdef
375 @@end_ifobjc
376         ;
377
378 datadef:
379           setspecs notype_initdecls ';'
380                 { if (pedantic)
381                     error ("ISO C forbids data definition with no type or storage class");
382                   else
383                     warning ("data definition has no type or storage class");
384
385                   POP_DECLSPEC_STACK; }
386         | declspecs_nots setspecs notype_initdecls ';'
387                 { POP_DECLSPEC_STACK; }
388         | declspecs_ts setspecs initdecls ';'
389                 { POP_DECLSPEC_STACK; }
390         | declspecs ';'
391           { shadow_tag ($1); }
392         | error ';'
393         | error '}'
394         | ';'
395                 { if (pedantic)
396                     pedwarn ("ISO C does not allow extra `;' outside of a function"); }
397         ;
398 \f
399 fndef:
400           declspecs_ts setspecs declarator
401                 { if (! start_function (current_declspecs, $3,
402                                         all_prefix_attributes))
403                     YYERROR1;
404                 }
405           old_style_parm_decls save_location
406                 { DECL_SOURCE_LOCATION (current_function_decl) = $6;
407                   store_parm_decls (); }
408           compstmt_or_error
409                 { finish_function ();
410                   POP_DECLSPEC_STACK; }
411         | declspecs_ts setspecs declarator error
412                 { POP_DECLSPEC_STACK; }
413         | declspecs_nots setspecs notype_declarator
414                 { if (! start_function (current_declspecs, $3,
415                                         all_prefix_attributes))
416                     YYERROR1;
417                 }
418           old_style_parm_decls save_location
419                 { DECL_SOURCE_LOCATION (current_function_decl) = $6;
420                   store_parm_decls (); }
421           compstmt_or_error
422                 { finish_function ();
423                   POP_DECLSPEC_STACK; }
424         | declspecs_nots setspecs notype_declarator error
425                 { POP_DECLSPEC_STACK; }
426         | setspecs notype_declarator
427                 { if (! start_function (NULL_TREE, $2,
428                                         all_prefix_attributes))
429                     YYERROR1;
430                 }
431           old_style_parm_decls save_location
432                 { DECL_SOURCE_LOCATION (current_function_decl) = $5;
433                   store_parm_decls (); }
434           compstmt_or_error
435                 { finish_function ();
436                   POP_DECLSPEC_STACK; }
437         | setspecs notype_declarator error
438                 { POP_DECLSPEC_STACK; }
439         ;
440
441 identifier:
442         IDENTIFIER
443         | TYPENAME
444 @@ifobjc
445         | OBJECTNAME
446         | CLASSNAME
447 @@end_ifobjc
448         ;
449
450 unop:     '&'
451                 { $$ = ADDR_EXPR; }
452         | '-'
453                 { $$ = NEGATE_EXPR; }
454         | '+'
455                 { $$ = CONVERT_EXPR;
456 @@ifc
457   if (warn_traditional && !in_system_header)
458     warning ("traditional C rejects the unary plus operator");
459 @@end_ifc
460                 }
461         | PLUSPLUS
462                 { $$ = PREINCREMENT_EXPR; }
463         | MINUSMINUS
464                 { $$ = PREDECREMENT_EXPR; }
465         | '~'
466                 { $$ = BIT_NOT_EXPR; }
467         | '!'
468                 { $$ = TRUTH_NOT_EXPR; }
469         ;
470
471 expr:   expr_no_commas
472         | expr ',' expr_no_commas
473                 { $$.value = build_compound_expr ($1.value, $3.value);
474                   $$.original_code = COMPOUND_EXPR; }
475         ;
476
477 exprlist:
478           /* empty */
479                 { $$ = NULL_TREE; }
480         | nonnull_exprlist
481         ;
482
483 nonnull_exprlist:
484         expr_no_commas
485                 { $$ = build_tree_list (NULL_TREE, $1.value); }
486         | nonnull_exprlist ',' expr_no_commas
487                 { chainon ($1, build_tree_list (NULL_TREE, $3.value)); }
488         ;
489
490 unary_expr:
491         primary
492         | '*' cast_expr   %prec UNARY
493                 { $$.value = build_indirect_ref ($2.value, "unary *");
494                   $$.original_code = ERROR_MARK; }
495         /* __extension__ turns off -pedantic for following primary.  */
496         | extension cast_expr     %prec UNARY
497                 { $$ = $2;
498                   RESTORE_EXT_FLAGS ($1); }
499         | unop cast_expr  %prec UNARY
500                 { $$.value = build_unary_op ($1, $2.value, 0);
501                   overflow_warning ($$.value);
502                   $$.original_code = ERROR_MARK; }
503         /* Refer to the address of a label as a pointer.  */
504         | ANDAND identifier
505                 { $$.value = finish_label_address_expr ($2);
506                   $$.original_code = ERROR_MARK; }
507         | sizeof unary_expr  %prec UNARY
508                 { skip_evaluation--;
509                   if (TREE_CODE ($2.value) == COMPONENT_REF
510                       && DECL_C_BIT_FIELD (TREE_OPERAND ($2.value, 1)))
511                     error ("`sizeof' applied to a bit-field");
512                   $$.value = c_sizeof (TREE_TYPE ($2.value));
513                   $$.original_code = ERROR_MARK; }
514         | sizeof '(' typename ')'  %prec HYPERUNARY
515                 { skip_evaluation--;
516                   $$.value = c_sizeof (groktypename ($3));
517                   $$.original_code = ERROR_MARK; }
518         | alignof unary_expr  %prec UNARY
519                 { skip_evaluation--;
520                   $$.value = c_alignof_expr ($2.value);
521                   $$.original_code = ERROR_MARK; }
522         | alignof '(' typename ')'  %prec HYPERUNARY
523                 { skip_evaluation--;
524                   $$.value = c_alignof (groktypename ($3));
525                   $$.original_code = ERROR_MARK; }
526         | REALPART cast_expr %prec UNARY
527                 { $$.value = build_unary_op (REALPART_EXPR, $2.value, 0);
528                   $$.original_code = ERROR_MARK; }
529         | IMAGPART cast_expr %prec UNARY
530                 { $$.value = build_unary_op (IMAGPART_EXPR, $2.value, 0);
531                   $$.original_code = ERROR_MARK; }
532         ;
533
534 sizeof:
535         SIZEOF { skip_evaluation++; }
536         ;
537
538 alignof:
539         ALIGNOF { skip_evaluation++; }
540         ;
541
542 typeof:
543         TYPEOF { skip_evaluation++; }
544         ;
545
546 cast_expr:
547         unary_expr
548         | '(' typename ')' cast_expr  %prec UNARY
549                 { $$.value = c_cast_expr ($2, $4.value);
550                   $$.original_code = ERROR_MARK; }
551         ;
552
553 expr_no_commas:
554           cast_expr
555         | expr_no_commas '+' expr_no_commas
556                 { $$ = parser_build_binary_op ($2, $1, $3); }
557         | expr_no_commas '-' expr_no_commas
558                 { $$ = parser_build_binary_op ($2, $1, $3); }
559         | expr_no_commas '*' expr_no_commas
560                 { $$ = parser_build_binary_op ($2, $1, $3); }
561         | expr_no_commas '/' expr_no_commas
562                 { $$ = parser_build_binary_op ($2, $1, $3); }
563         | expr_no_commas '%' expr_no_commas
564                 { $$ = parser_build_binary_op ($2, $1, $3); }
565         | expr_no_commas LSHIFT expr_no_commas
566                 { $$ = parser_build_binary_op ($2, $1, $3); }
567         | expr_no_commas RSHIFT expr_no_commas
568                 { $$ = parser_build_binary_op ($2, $1, $3); }
569         | expr_no_commas ARITHCOMPARE expr_no_commas
570                 { $$ = parser_build_binary_op ($2, $1, $3); }
571         | expr_no_commas EQCOMPARE expr_no_commas
572                 { $$ = parser_build_binary_op ($2, $1, $3); }
573         | expr_no_commas '&' expr_no_commas
574                 { $$ = parser_build_binary_op ($2, $1, $3); }
575         | expr_no_commas '|' expr_no_commas
576                 { $$ = parser_build_binary_op ($2, $1, $3); }
577         | expr_no_commas '^' expr_no_commas
578                 { $$ = parser_build_binary_op ($2, $1, $3); }
579         | expr_no_commas ANDAND
580                 { $1.value = lang_hooks.truthvalue_conversion
581                     (default_conversion ($1.value));
582                   skip_evaluation += $1.value == truthvalue_false_node; }
583           expr_no_commas
584                 { skip_evaluation -= $1.value == truthvalue_false_node;
585                   $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $4); }
586         | expr_no_commas OROR
587                 { $1.value = lang_hooks.truthvalue_conversion
588                     (default_conversion ($1.value));
589                   skip_evaluation += $1.value == truthvalue_true_node; }
590           expr_no_commas
591                 { skip_evaluation -= $1.value == truthvalue_true_node;
592                   $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $4); }
593         | expr_no_commas '?'
594                 { $1.value = lang_hooks.truthvalue_conversion
595                     (default_conversion ($1.value));
596                   skip_evaluation += $1.value == truthvalue_false_node; }
597           expr ':'
598                 { skip_evaluation += (($1.value == truthvalue_true_node)
599                                       - ($1.value == truthvalue_false_node)); }
600           expr_no_commas
601                 { skip_evaluation -= $1.value == truthvalue_true_node;
602                   $$.value = build_conditional_expr ($1.value, $4.value,
603                                                      $7.value);
604                   $$.original_code = ERROR_MARK; }
605         | expr_no_commas '?'
606                 { if (pedantic)
607                     pedwarn ("ISO C forbids omitting the middle term of a ?: expression");
608                   /* Make sure first operand is calculated only once.  */
609                   $<ttype>2 = save_expr (default_conversion ($1.value));
610                   $1.value = lang_hooks.truthvalue_conversion ($<ttype>2);
611                   skip_evaluation += $1.value == truthvalue_true_node; }
612           ':' expr_no_commas
613                 { skip_evaluation -= $1.value == truthvalue_true_node;
614                   $$.value = build_conditional_expr ($1.value, $<ttype>2,
615                                                      $5.value);
616                   $$.original_code = ERROR_MARK; }
617         | expr_no_commas '=' expr_no_commas
618                 { $$.value = build_modify_expr ($1.value, NOP_EXPR, $3.value);
619                   $$.original_code = MODIFY_EXPR;
620                 }
621         | expr_no_commas ASSIGN expr_no_commas
622                 { $$.value = build_modify_expr ($1.value, $2, $3.value);
623                   TREE_NO_WARNING ($$.value) = 1;
624                   $$.original_code = ERROR_MARK;
625                 }
626         ;
627
628 primary:
629         IDENTIFIER
630                 {
631                   if (yychar == YYEMPTY)
632                     yychar = YYLEX;
633                   $$.value = build_external_ref ($1, yychar == '(');
634                   $$.original_code = ERROR_MARK;
635                 }
636         | CONSTANT
637                 { $$.value = $1; $$.original_code = ERROR_MARK; }
638         | STRING
639                 { $$.value = $1; $$.original_code = STRING_CST; }
640         | FUNC_NAME
641                 { $$.value = fname_decl (C_RID_CODE ($1), $1);
642                   $$.original_code = ERROR_MARK; }
643         | '(' typename ')' '{'
644                 { start_init (NULL_TREE, NULL, 0);
645                   $2 = groktypename ($2);
646                   really_start_incremental_init ($2); }
647           initlist_maybe_comma '}'  %prec UNARY
648                 { struct c_expr init = pop_init_level (0);
649                   tree constructor = init.value;
650                   tree type = $2;
651                   finish_init ();
652                   maybe_warn_string_init (type, init);
653
654                   if (pedantic && ! flag_isoc99)
655                     pedwarn ("ISO C90 forbids compound literals");
656                   $$.value = build_compound_literal (type, constructor);
657                   $$.original_code = ERROR_MARK;
658                 }
659         | '(' expr ')'
660                 { $$.value = $2.value;
661                   if (TREE_CODE ($$.value) == MODIFY_EXPR)
662                     TREE_NO_WARNING ($$.value) = 1;
663                   $$.original_code = ERROR_MARK; }
664         | '(' error ')'
665                 { $$.value = error_mark_node; $$.original_code = ERROR_MARK; }
666         | compstmt_primary_start compstmt_nostart ')'
667                 { if (pedantic)
668                     pedwarn ("ISO C forbids braced-groups within expressions");
669                   $$.value = c_finish_stmt_expr ($1);
670                   $$.original_code = ERROR_MARK;
671                 }
672         | compstmt_primary_start error ')'
673                 { c_finish_stmt_expr ($1);
674                   $$.value = error_mark_node;
675                   $$.original_code = ERROR_MARK;
676                 }
677         | primary '(' exprlist ')'   %prec '.'
678                 { $$.value = build_function_call ($1.value, $3);
679                   $$.original_code = ERROR_MARK; }
680         | VA_ARG '(' expr_no_commas ',' typename ')'
681                 { $$.value = build_va_arg ($3.value, groktypename ($5));
682                   $$.original_code = ERROR_MARK; }
683
684         | OFFSETOF '(' typename ','
685                 { tree type = groktypename ($3);
686                   if (type == error_mark_node)
687                     offsetof_base = error_mark_node;
688                   else
689                     offsetof_base = build1 (INDIRECT_REF, type, NULL);
690                 }
691           offsetof_member_designator ')'
692                 { $$.value = fold_offsetof ($6);
693                   $$.original_code = ERROR_MARK; }
694         | OFFSETOF '(' error ')'
695                 { $$.value = error_mark_node; $$.original_code = ERROR_MARK; }
696         | CHOOSE_EXPR '(' expr_no_commas ',' expr_no_commas ','
697                           expr_no_commas ')'
698                 {
699                   tree c;
700
701                   c = fold ($3.value);
702                   STRIP_NOPS (c);
703                   if (TREE_CODE (c) != INTEGER_CST)
704                     error ("first argument to __builtin_choose_expr not"
705                            " a constant");
706                   $$ = integer_zerop (c) ? $7 : $5;
707                 }
708         | CHOOSE_EXPR '(' error ')'
709                 { $$.value = error_mark_node; $$.original_code = ERROR_MARK; }
710         | TYPES_COMPATIBLE_P '(' typename ',' typename ')'
711                 {
712                   tree e1, e2;
713
714                   e1 = TYPE_MAIN_VARIANT (groktypename ($3));
715                   e2 = TYPE_MAIN_VARIANT (groktypename ($5));
716
717                   $$.value = comptypes (e1, e2)
718                     ? build_int_cst (NULL_TREE, 1)
719                     : build_int_cst (NULL_TREE, 0);
720                   $$.original_code = ERROR_MARK;
721                 }
722         | TYPES_COMPATIBLE_P '(' error ')'
723                 { $$.value = error_mark_node; $$.original_code = ERROR_MARK; }
724         | primary '[' expr ']'   %prec '.'
725                 { $$.value = build_array_ref ($1.value, $3.value);
726                   $$.original_code = ERROR_MARK; }
727         | primary '.' identifier
728                 { $$.value = build_component_ref ($1.value, $3);
729                   $$.original_code = ERROR_MARK; }
730         | primary POINTSAT identifier
731                 {
732                   tree expr = build_indirect_ref ($1.value, "->");
733                   $$.value = build_component_ref (expr, $3);
734                   $$.original_code = ERROR_MARK;
735                 }
736         | primary PLUSPLUS
737                 { $$.value = build_unary_op (POSTINCREMENT_EXPR, $1.value, 0);
738                   $$.original_code = ERROR_MARK; }
739         | primary MINUSMINUS
740                 { $$.value = build_unary_op (POSTDECREMENT_EXPR, $1.value, 0);
741                   $$.original_code = ERROR_MARK; }
742 @@ifobjc
743         | objcmessageexpr
744                 { $$.value = objc_build_message_expr ($1);
745                   $$.original_code = ERROR_MARK; }
746         | objcselectorexpr
747                 { $$.value = objc_build_selector_expr ($1);
748                   $$.original_code = ERROR_MARK; }
749         | objcprotocolexpr
750                 { $$.value = objc_build_protocol_expr ($1);
751                   $$.original_code = ERROR_MARK; }
752         | objcencodeexpr
753                 { $$.value = objc_build_encode_expr ($1);
754                   $$.original_code = ERROR_MARK; }
755         | OBJC_STRING
756                 { $$.value = objc_build_string_object ($1);
757                   $$.original_code = ERROR_MARK; }
758 @@end_ifobjc
759         ;
760
761 /* This is the second argument to __builtin_offsetof.  We must have one
762    identifier, and beyond that we want to accept sub structure and sub
763    array references.  */
764
765 offsetof_member_designator:
766           identifier
767                 { $$ = build_component_ref (offsetof_base, $1); }
768         | offsetof_member_designator '.' identifier
769                 { $$ = build_component_ref ($1, $3); }
770         | offsetof_member_designator '[' expr ']'
771                 { $$ = build_array_ref ($1, $3.value); }
772         ;
773
774 old_style_parm_decls:
775         /* empty */
776         | datadecls
777         ;
778
779 /* The following are analogous to lineno_decl, decls and decl
780    except that they do not allow nested functions.
781    They are used for old-style parm decls.  */
782 lineno_datadecl:
783           save_location datadecl
784                 { }
785         ;
786
787 datadecls:
788         lineno_datadecl
789         | errstmt
790         | datadecls lineno_datadecl
791         | lineno_datadecl errstmt
792         ;
793
794 /* We don't allow prefix attributes here because they cause reduce/reduce
795    conflicts: we can't know whether we're parsing a function decl with
796    attribute suffix, or function defn with attribute prefix on first old
797    style parm.  */
798 datadecl:
799         declspecs_ts_nosa setspecs initdecls ';'
800                 { POP_DECLSPEC_STACK; }
801         | declspecs_nots_nosa setspecs notype_initdecls ';'
802                 { POP_DECLSPEC_STACK; }
803         | declspecs_ts_nosa ';'
804                 { shadow_tag_warned ($1, 1);
805                   pedwarn ("empty declaration"); }
806         | declspecs_nots_nosa ';'
807                 { pedwarn ("empty declaration"); }
808         ;
809
810 /* This combination which saves a lineno before a decl
811    is the normal thing to use, rather than decl itself.
812    This is to avoid shift/reduce conflicts in contexts
813    where statement labels are allowed.  */
814 lineno_decl:
815           save_location decl
816                 { }
817         ;
818
819 /* records the type and storage class specs to use for processing
820    the declarators that follow.
821    Maintains a stack of outer-level values of current_declspecs,
822    for the sake of parm declarations nested in function declarators.  */
823 setspecs: /* empty */
824                 { pending_xref_error ();
825                   PUSH_DECLSPEC_STACK;
826                   split_specs_attrs ($<ttype>0,
827                                      &current_declspecs, &prefix_attributes);
828                   all_prefix_attributes = prefix_attributes; }
829         ;
830
831 /* Possibly attributes after a comma, which should reset all_prefix_attributes
832    to prefix_attributes with these ones chained on the front.  */
833 maybe_resetattrs:
834           maybe_attribute
835                 { all_prefix_attributes = chainon ($1, prefix_attributes); }
836         ;
837
838 decl:
839         declspecs_ts setspecs initdecls ';'
840                 { POP_DECLSPEC_STACK; }
841         | declspecs_nots setspecs notype_initdecls ';'
842                 { POP_DECLSPEC_STACK; }
843         | declspecs_ts setspecs nested_function
844                 { POP_DECLSPEC_STACK; }
845         | declspecs_nots setspecs notype_nested_function
846                 { POP_DECLSPEC_STACK; }
847         | declspecs ';'
848                 { shadow_tag ($1); }
849         | extension decl
850                 { RESTORE_EXT_FLAGS ($1); }
851         ;
852
853 /* A list of declaration specifiers.  These are:
854
855    - Storage class specifiers (scspec), which for GCC currently includes
856    function specifiers ("inline").
857
858    - Type specifiers (typespec_*).
859
860    - Type qualifiers (TYPE_QUAL).
861
862    - Attribute specifier lists (attributes).
863
864    These are stored as a TREE_LIST; the head of the list is the last
865    item in the specifier list.  Each entry in the list has either a
866    TREE_PURPOSE that is an attribute specifier list, or a TREE_VALUE that
867    is a single other specifier or qualifier; and a TREE_CHAIN that is the
868    rest of the list.  TREE_STATIC is set on the list if something other
869    than a storage class specifier or attribute has been seen; this is used
870    to warn for the obsolescent usage of storage class specifiers other than
871    at the start of the list.  (Doing this properly would require function
872    specifiers to be handled separately from storage class specifiers.)
873
874    The various cases below are classified according to:
875
876    (a) Whether a storage class specifier is included or not; some
877    places in the grammar disallow storage class specifiers (_sc or _nosc).
878
879    (b) Whether a type specifier has been seen; after a type specifier,
880    a typedef name is an identifier to redeclare (_ts or _nots).
881
882    (c) Whether the list starts with an attribute; in certain places,
883    the grammar requires specifiers that don't start with an attribute
884    (_sa or _nosa).
885
886    (d) Whether the list ends with an attribute (or a specifier such that
887    any following attribute would have been parsed as part of that specifier);
888    this avoids shift-reduce conflicts in the parsing of attributes
889    (_ea or _noea).
890
891    TODO:
892
893    (i) Distinguish between function specifiers and storage class specifiers,
894    at least for the purpose of warnings about obsolescent usage.
895
896    (ii) Halve the number of productions here by eliminating the _sc/_nosc
897    distinction and instead checking where required that storage class
898    specifiers aren't present.  */
899
900 /* Declspecs which contain at least one type specifier or typedef name.
901    (Just `const' or `volatile' is not enough.)
902    A typedef'd name following these is taken as a name to be declared.
903    Declspecs have a non-NULL TREE_VALUE, attributes do not.  */
904
905 declspecs_nosc_nots_nosa_noea:
906           TYPE_QUAL
907                 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
908                   TREE_STATIC ($$) = 1; }
909         | declspecs_nosc_nots_nosa_noea TYPE_QUAL
910                 { $$ = tree_cons (NULL_TREE, $2, $1);
911                   TREE_STATIC ($$) = 1; }
912         | declspecs_nosc_nots_nosa_ea TYPE_QUAL
913                 { $$ = tree_cons (NULL_TREE, $2, $1);
914                   TREE_STATIC ($$) = 1; }
915         ;
916
917 declspecs_nosc_nots_nosa_ea:
918           declspecs_nosc_nots_nosa_noea attributes
919                 { $$ = tree_cons ($2, NULL_TREE, $1);
920                   TREE_STATIC ($$) = TREE_STATIC ($1); }
921         ;
922
923 declspecs_nosc_nots_sa_noea:
924           declspecs_nosc_nots_sa_noea TYPE_QUAL
925                 { $$ = tree_cons (NULL_TREE, $2, $1);
926                   TREE_STATIC ($$) = 1; }
927         | declspecs_nosc_nots_sa_ea TYPE_QUAL
928                 { $$ = tree_cons (NULL_TREE, $2, $1);
929                   TREE_STATIC ($$) = 1; }
930         ;
931
932 declspecs_nosc_nots_sa_ea:
933           attributes
934                 { $$ = tree_cons ($1, NULL_TREE, NULL_TREE);
935                   TREE_STATIC ($$) = 0; }
936         | declspecs_nosc_nots_sa_noea attributes
937                 { $$ = tree_cons ($2, NULL_TREE, $1);
938                   TREE_STATIC ($$) = TREE_STATIC ($1); }
939         ;
940
941 declspecs_nosc_ts_nosa_noea:
942           typespec_nonattr
943                 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
944                   TREE_STATIC ($$) = 1; }
945         | declspecs_nosc_ts_nosa_noea TYPE_QUAL
946                 { $$ = tree_cons (NULL_TREE, $2, $1);
947                   TREE_STATIC ($$) = 1; }
948         | declspecs_nosc_ts_nosa_ea TYPE_QUAL
949                 { $$ = tree_cons (NULL_TREE, $2, $1);
950                   TREE_STATIC ($$) = 1; }
951         | declspecs_nosc_ts_nosa_noea typespec_reserved_nonattr
952                 { $$ = tree_cons (NULL_TREE, $2, $1);
953                   TREE_STATIC ($$) = 1; }
954         | declspecs_nosc_ts_nosa_ea typespec_reserved_nonattr
955                 { $$ = tree_cons (NULL_TREE, $2, $1);
956                   TREE_STATIC ($$) = 1; }
957         | declspecs_nosc_nots_nosa_noea typespec_nonattr
958                 { $$ = tree_cons (NULL_TREE, $2, $1);
959                   TREE_STATIC ($$) = 1; }
960         | declspecs_nosc_nots_nosa_ea typespec_nonattr
961                 { $$ = tree_cons (NULL_TREE, $2, $1);
962                   TREE_STATIC ($$) = 1; }
963         ;
964
965 declspecs_nosc_ts_nosa_ea:
966           typespec_attr
967                 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
968                   TREE_STATIC ($$) = 1; }
969         | declspecs_nosc_ts_nosa_noea attributes
970                 { $$ = tree_cons ($2, NULL_TREE, $1);
971                   TREE_STATIC ($$) = TREE_STATIC ($1); }
972         | declspecs_nosc_ts_nosa_noea typespec_reserved_attr
973                 { $$ = tree_cons (NULL_TREE, $2, $1);
974                   TREE_STATIC ($$) = 1; }
975         | declspecs_nosc_ts_nosa_ea typespec_reserved_attr
976                 { $$ = tree_cons (NULL_TREE, $2, $1);
977                   TREE_STATIC ($$) = 1; }
978         | declspecs_nosc_nots_nosa_noea typespec_attr
979                 { $$ = tree_cons (NULL_TREE, $2, $1);
980                   TREE_STATIC ($$) = 1; }
981         | declspecs_nosc_nots_nosa_ea typespec_attr
982                 { $$ = tree_cons (NULL_TREE, $2, $1);
983                   TREE_STATIC ($$) = 1; }
984         ;
985
986 declspecs_nosc_ts_sa_noea:
987           declspecs_nosc_ts_sa_noea TYPE_QUAL
988                 { $$ = tree_cons (NULL_TREE, $2, $1);
989                   TREE_STATIC ($$) = 1; }
990         | declspecs_nosc_ts_sa_ea TYPE_QUAL
991                 { $$ = tree_cons (NULL_TREE, $2, $1);
992                   TREE_STATIC ($$) = 1; }
993         | declspecs_nosc_ts_sa_noea typespec_reserved_nonattr
994                 { $$ = tree_cons (NULL_TREE, $2, $1);
995                   TREE_STATIC ($$) = 1; }
996         | declspecs_nosc_ts_sa_ea typespec_reserved_nonattr
997                 { $$ = tree_cons (NULL_TREE, $2, $1);
998                   TREE_STATIC ($$) = 1; }
999         | declspecs_nosc_nots_sa_noea typespec_nonattr
1000                 { $$ = tree_cons (NULL_TREE, $2, $1);
1001                   TREE_STATIC ($$) = 1; }
1002         | declspecs_nosc_nots_sa_ea typespec_nonattr
1003                 { $$ = tree_cons (NULL_TREE, $2, $1);
1004                   TREE_STATIC ($$) = 1; }
1005         ;
1006
1007 declspecs_nosc_ts_sa_ea:
1008           declspecs_nosc_ts_sa_noea attributes
1009                 { $$ = tree_cons ($2, NULL_TREE, $1);
1010                   TREE_STATIC ($$) = TREE_STATIC ($1); }
1011         | declspecs_nosc_ts_sa_noea typespec_reserved_attr
1012                 { $$ = tree_cons (NULL_TREE, $2, $1);
1013                   TREE_STATIC ($$) = 1; }
1014         | declspecs_nosc_ts_sa_ea typespec_reserved_attr
1015                 { $$ = tree_cons (NULL_TREE, $2, $1);
1016                   TREE_STATIC ($$) = 1; }
1017         | declspecs_nosc_nots_sa_noea typespec_attr
1018                 { $$ = tree_cons (NULL_TREE, $2, $1);
1019                   TREE_STATIC ($$) = 1; }
1020         | declspecs_nosc_nots_sa_ea typespec_attr
1021                 { $$ = tree_cons (NULL_TREE, $2, $1);
1022                   TREE_STATIC ($$) = 1; }
1023         ;
1024
1025 declspecs_sc_nots_nosa_noea:
1026           scspec
1027                 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
1028                   TREE_STATIC ($$) = 0; }
1029         | declspecs_sc_nots_nosa_noea TYPE_QUAL
1030                 { $$ = tree_cons (NULL_TREE, $2, $1);
1031                   TREE_STATIC ($$) = 1; }
1032         | declspecs_sc_nots_nosa_ea TYPE_QUAL
1033                 { $$ = tree_cons (NULL_TREE, $2, $1);
1034                   TREE_STATIC ($$) = 1; }
1035         | declspecs_nosc_nots_nosa_noea scspec
1036                 { if (extra_warnings && TREE_STATIC ($1))
1037                     warning ("`%s' is not at beginning of declaration",
1038                              IDENTIFIER_POINTER ($2));
1039                   $$ = tree_cons (NULL_TREE, $2, $1);
1040                   TREE_STATIC ($$) = TREE_STATIC ($1); }
1041         | declspecs_nosc_nots_nosa_ea scspec
1042                 { if (extra_warnings && TREE_STATIC ($1))
1043                     warning ("`%s' is not at beginning of declaration",
1044                              IDENTIFIER_POINTER ($2));
1045                   $$ = tree_cons (NULL_TREE, $2, $1);
1046                   TREE_STATIC ($$) = TREE_STATIC ($1); }
1047         | declspecs_sc_nots_nosa_noea scspec
1048                 { if (extra_warnings && TREE_STATIC ($1))
1049                     warning ("`%s' is not at beginning of declaration",
1050                              IDENTIFIER_POINTER ($2));
1051                   $$ = tree_cons (NULL_TREE, $2, $1);
1052                   TREE_STATIC ($$) = TREE_STATIC ($1); }
1053         | declspecs_sc_nots_nosa_ea scspec
1054                 { if (extra_warnings && TREE_STATIC ($1))
1055                     warning ("`%s' is not at beginning of declaration",
1056                              IDENTIFIER_POINTER ($2));
1057                   $$ = tree_cons (NULL_TREE, $2, $1);
1058                   TREE_STATIC ($$) = TREE_STATIC ($1); }
1059         ;
1060
1061 declspecs_sc_nots_nosa_ea:
1062           declspecs_sc_nots_nosa_noea attributes
1063                 { $$ = tree_cons ($2, NULL_TREE, $1);
1064                   TREE_STATIC ($$) = TREE_STATIC ($1); }
1065         ;
1066
1067 declspecs_sc_nots_sa_noea:
1068           declspecs_sc_nots_sa_noea TYPE_QUAL
1069                 { $$ = tree_cons (NULL_TREE, $2, $1);
1070                   TREE_STATIC ($$) = 1; }
1071         | declspecs_sc_nots_sa_ea TYPE_QUAL
1072                 { $$ = tree_cons (NULL_TREE, $2, $1);
1073                   TREE_STATIC ($$) = 1; }
1074         | declspecs_nosc_nots_sa_noea scspec
1075                 { if (extra_warnings && TREE_STATIC ($1))
1076                     warning ("`%s' is not at beginning of declaration",
1077                              IDENTIFIER_POINTER ($2));
1078                   $$ = tree_cons (NULL_TREE, $2, $1);
1079                   TREE_STATIC ($$) = TREE_STATIC ($1); }
1080         | declspecs_nosc_nots_sa_ea scspec
1081                 { if (extra_warnings && TREE_STATIC ($1))
1082                     warning ("`%s' is not at beginning of declaration",
1083                              IDENTIFIER_POINTER ($2));
1084                   $$ = tree_cons (NULL_TREE, $2, $1);
1085                   TREE_STATIC ($$) = TREE_STATIC ($1); }
1086         | declspecs_sc_nots_sa_noea scspec
1087                 { if (extra_warnings && TREE_STATIC ($1))
1088                     warning ("`%s' is not at beginning of declaration",
1089                              IDENTIFIER_POINTER ($2));
1090                   $$ = tree_cons (NULL_TREE, $2, $1);
1091                   TREE_STATIC ($$) = TREE_STATIC ($1); }
1092         | declspecs_sc_nots_sa_ea scspec
1093                 { if (extra_warnings && TREE_STATIC ($1))
1094                     warning ("`%s' is not at beginning of declaration",
1095                              IDENTIFIER_POINTER ($2));
1096                   $$ = tree_cons (NULL_TREE, $2, $1);
1097                   TREE_STATIC ($$) = TREE_STATIC ($1); }
1098         ;
1099
1100 declspecs_sc_nots_sa_ea:
1101           declspecs_sc_nots_sa_noea attributes
1102                 { $$ = tree_cons ($2, NULL_TREE, $1);
1103                   TREE_STATIC ($$) = TREE_STATIC ($1); }
1104         ;
1105
1106 declspecs_sc_ts_nosa_noea:
1107           declspecs_sc_ts_nosa_noea TYPE_QUAL
1108                 { $$ = tree_cons (NULL_TREE, $2, $1);
1109                   TREE_STATIC ($$) = 1; }
1110         | declspecs_sc_ts_nosa_ea TYPE_QUAL
1111                 { $$ = tree_cons (NULL_TREE, $2, $1);
1112                   TREE_STATIC ($$) = 1; }
1113         | declspecs_sc_ts_nosa_noea typespec_reserved_nonattr
1114                 { $$ = tree_cons (NULL_TREE, $2, $1);
1115                   TREE_STATIC ($$) = 1; }
1116         | declspecs_sc_ts_nosa_ea typespec_reserved_nonattr
1117                 { $$ = tree_cons (NULL_TREE, $2, $1);
1118                   TREE_STATIC ($$) = 1; }
1119         | declspecs_sc_nots_nosa_noea typespec_nonattr
1120                 { $$ = tree_cons (NULL_TREE, $2, $1);
1121                   TREE_STATIC ($$) = 1; }
1122         | declspecs_sc_nots_nosa_ea typespec_nonattr
1123                 { $$ = tree_cons (NULL_TREE, $2, $1);
1124                   TREE_STATIC ($$) = 1; }
1125         | declspecs_nosc_ts_nosa_noea scspec
1126                 { if (extra_warnings && TREE_STATIC ($1))
1127                     warning ("`%s' is not at beginning of declaration",
1128                              IDENTIFIER_POINTER ($2));
1129                   $$ = tree_cons (NULL_TREE, $2, $1);
1130                   TREE_STATIC ($$) = TREE_STATIC ($1); }
1131         | declspecs_nosc_ts_nosa_ea scspec
1132                 { if (extra_warnings && TREE_STATIC ($1))
1133                     warning ("`%s' is not at beginning of declaration",
1134                              IDENTIFIER_POINTER ($2));
1135                   $$ = tree_cons (NULL_TREE, $2, $1);
1136                   TREE_STATIC ($$) = TREE_STATIC ($1); }
1137         | declspecs_sc_ts_nosa_noea scspec
1138                 { if (extra_warnings && TREE_STATIC ($1))
1139                     warning ("`%s' is not at beginning of declaration",
1140                              IDENTIFIER_POINTER ($2));
1141                   $$ = tree_cons (NULL_TREE, $2, $1);
1142                   TREE_STATIC ($$) = TREE_STATIC ($1); }
1143         | declspecs_sc_ts_nosa_ea scspec
1144                 { if (extra_warnings && TREE_STATIC ($1))
1145                     warning ("`%s' is not at beginning of declaration",
1146                              IDENTIFIER_POINTER ($2));
1147                   $$ = tree_cons (NULL_TREE, $2, $1);
1148                   TREE_STATIC ($$) = TREE_STATIC ($1); }
1149         ;
1150
1151 declspecs_sc_ts_nosa_ea:
1152           declspecs_sc_ts_nosa_noea attributes
1153                 { $$ = tree_cons ($2, NULL_TREE, $1);
1154                   TREE_STATIC ($$) = TREE_STATIC ($1); }
1155         | declspecs_sc_ts_nosa_noea typespec_reserved_attr
1156                 { $$ = tree_cons (NULL_TREE, $2, $1);
1157                   TREE_STATIC ($$) = 1; }
1158         | declspecs_sc_ts_nosa_ea typespec_reserved_attr
1159                 { $$ = tree_cons (NULL_TREE, $2, $1);
1160                   TREE_STATIC ($$) = 1; }
1161         | declspecs_sc_nots_nosa_noea typespec_attr
1162                 { $$ = tree_cons (NULL_TREE, $2, $1);
1163                   TREE_STATIC ($$) = 1; }
1164         | declspecs_sc_nots_nosa_ea typespec_attr
1165                 { $$ = tree_cons (NULL_TREE, $2, $1);
1166                   TREE_STATIC ($$) = 1; }
1167         ;
1168
1169 declspecs_sc_ts_sa_noea:
1170           declspecs_sc_ts_sa_noea TYPE_QUAL
1171                 { $$ = tree_cons (NULL_TREE, $2, $1);
1172                   TREE_STATIC ($$) = 1; }
1173         | declspecs_sc_ts_sa_ea TYPE_QUAL
1174                 { $$ = tree_cons (NULL_TREE, $2, $1);
1175                   TREE_STATIC ($$) = 1; }
1176         | declspecs_sc_ts_sa_noea typespec_reserved_nonattr
1177                 { $$ = tree_cons (NULL_TREE, $2, $1);
1178                   TREE_STATIC ($$) = 1; }
1179         | declspecs_sc_ts_sa_ea typespec_reserved_nonattr
1180                 { $$ = tree_cons (NULL_TREE, $2, $1);
1181                   TREE_STATIC ($$) = 1; }
1182         | declspecs_sc_nots_sa_noea typespec_nonattr
1183                 { $$ = tree_cons (NULL_TREE, $2, $1);
1184                   TREE_STATIC ($$) = 1; }
1185         | declspecs_sc_nots_sa_ea typespec_nonattr
1186                 { $$ = tree_cons (NULL_TREE, $2, $1);
1187                   TREE_STATIC ($$) = 1; }
1188         | declspecs_nosc_ts_sa_noea scspec
1189                 { if (extra_warnings && TREE_STATIC ($1))
1190                     warning ("`%s' is not at beginning of declaration",
1191                              IDENTIFIER_POINTER ($2));
1192                   $$ = tree_cons (NULL_TREE, $2, $1);
1193                   TREE_STATIC ($$) = TREE_STATIC ($1); }
1194         | declspecs_nosc_ts_sa_ea scspec
1195                 { if (extra_warnings && TREE_STATIC ($1))
1196                     warning ("`%s' is not at beginning of declaration",
1197                              IDENTIFIER_POINTER ($2));
1198                   $$ = tree_cons (NULL_TREE, $2, $1);
1199                   TREE_STATIC ($$) = TREE_STATIC ($1); }
1200         | declspecs_sc_ts_sa_noea scspec
1201                 { if (extra_warnings && TREE_STATIC ($1))
1202                     warning ("`%s' is not at beginning of declaration",
1203                              IDENTIFIER_POINTER ($2));
1204                   $$ = tree_cons (NULL_TREE, $2, $1);
1205                   TREE_STATIC ($$) = TREE_STATIC ($1); }
1206         | declspecs_sc_ts_sa_ea scspec
1207                 { if (extra_warnings && TREE_STATIC ($1))
1208                     warning ("`%s' is not at beginning of declaration",
1209                              IDENTIFIER_POINTER ($2));
1210                   $$ = tree_cons (NULL_TREE, $2, $1);
1211                   TREE_STATIC ($$) = TREE_STATIC ($1); }
1212         ;
1213
1214 declspecs_sc_ts_sa_ea:
1215           declspecs_sc_ts_sa_noea attributes
1216                 { $$ = tree_cons ($2, NULL_TREE, $1);
1217                   TREE_STATIC ($$) = TREE_STATIC ($1); }
1218         | declspecs_sc_ts_sa_noea typespec_reserved_attr
1219                 { $$ = tree_cons (NULL_TREE, $2, $1);
1220                   TREE_STATIC ($$) = 1; }
1221         | declspecs_sc_ts_sa_ea typespec_reserved_attr
1222                 { $$ = tree_cons (NULL_TREE, $2, $1);
1223                   TREE_STATIC ($$) = 1; }
1224         | declspecs_sc_nots_sa_noea typespec_attr
1225                 { $$ = tree_cons (NULL_TREE, $2, $1);
1226                   TREE_STATIC ($$) = 1; }
1227         | declspecs_sc_nots_sa_ea typespec_attr
1228                 { $$ = tree_cons (NULL_TREE, $2, $1);
1229                   TREE_STATIC ($$) = 1; }
1230         ;
1231
1232 /* Particular useful classes of declspecs.  */
1233 declspecs_ts:
1234           declspecs_nosc_ts_nosa_noea
1235         | declspecs_nosc_ts_nosa_ea
1236         | declspecs_nosc_ts_sa_noea
1237         | declspecs_nosc_ts_sa_ea
1238         | declspecs_sc_ts_nosa_noea
1239         | declspecs_sc_ts_nosa_ea
1240         | declspecs_sc_ts_sa_noea
1241         | declspecs_sc_ts_sa_ea
1242         ;
1243
1244 declspecs_nots:
1245           declspecs_nosc_nots_nosa_noea
1246         | declspecs_nosc_nots_nosa_ea
1247         | declspecs_nosc_nots_sa_noea
1248         | declspecs_nosc_nots_sa_ea
1249         | declspecs_sc_nots_nosa_noea
1250         | declspecs_sc_nots_nosa_ea
1251         | declspecs_sc_nots_sa_noea
1252         | declspecs_sc_nots_sa_ea
1253         ;
1254
1255 declspecs_ts_nosa:
1256           declspecs_nosc_ts_nosa_noea
1257         | declspecs_nosc_ts_nosa_ea
1258         | declspecs_sc_ts_nosa_noea
1259         | declspecs_sc_ts_nosa_ea
1260         ;
1261
1262 declspecs_nots_nosa:
1263           declspecs_nosc_nots_nosa_noea
1264         | declspecs_nosc_nots_nosa_ea
1265         | declspecs_sc_nots_nosa_noea
1266         | declspecs_sc_nots_nosa_ea
1267         ;
1268
1269 declspecs_nosc_ts:
1270           declspecs_nosc_ts_nosa_noea
1271         | declspecs_nosc_ts_nosa_ea
1272         | declspecs_nosc_ts_sa_noea
1273         | declspecs_nosc_ts_sa_ea
1274         ;
1275
1276 declspecs_nosc_nots:
1277           declspecs_nosc_nots_nosa_noea
1278         | declspecs_nosc_nots_nosa_ea
1279         | declspecs_nosc_nots_sa_noea
1280         | declspecs_nosc_nots_sa_ea
1281         ;
1282
1283 declspecs_nosc:
1284           declspecs_nosc_ts_nosa_noea
1285         | declspecs_nosc_ts_nosa_ea
1286         | declspecs_nosc_ts_sa_noea
1287         | declspecs_nosc_ts_sa_ea
1288         | declspecs_nosc_nots_nosa_noea
1289         | declspecs_nosc_nots_nosa_ea
1290         | declspecs_nosc_nots_sa_noea
1291         | declspecs_nosc_nots_sa_ea
1292         ;
1293
1294 declspecs:
1295           declspecs_nosc_nots_nosa_noea
1296         | declspecs_nosc_nots_nosa_ea
1297         | declspecs_nosc_nots_sa_noea
1298         | declspecs_nosc_nots_sa_ea
1299         | declspecs_nosc_ts_nosa_noea
1300         | declspecs_nosc_ts_nosa_ea
1301         | declspecs_nosc_ts_sa_noea
1302         | declspecs_nosc_ts_sa_ea
1303         | declspecs_sc_nots_nosa_noea
1304         | declspecs_sc_nots_nosa_ea
1305         | declspecs_sc_nots_sa_noea
1306         | declspecs_sc_nots_sa_ea
1307         | declspecs_sc_ts_nosa_noea
1308         | declspecs_sc_ts_nosa_ea
1309         | declspecs_sc_ts_sa_noea
1310         | declspecs_sc_ts_sa_ea
1311         ;
1312
1313 /* A (possibly empty) sequence of type qualifiers and attributes.  */
1314 maybe_type_quals_attrs:
1315           /* empty */
1316                 { $$ = NULL_TREE; }
1317         | declspecs_nosc_nots
1318                 { $$ = $1; }
1319         ;
1320
1321 /* A type specifier (but not a type qualifier).
1322    Once we have seen one of these in a declaration,
1323    if a typedef name appears then it is being redeclared.
1324
1325    The _reserved versions start with a reserved word and may appear anywhere
1326    in the declaration specifiers; the _nonreserved versions may only
1327    appear before any other type specifiers, and after that are (if names)
1328    being redeclared.
1329
1330    FIXME: should the _nonreserved version be restricted to names being
1331    redeclared only?  The other entries there relate only the GNU extensions
1332    and Objective C, and are historically parsed thus, and don't make sense
1333    after other type specifiers, but it might be cleaner to count them as
1334    _reserved.
1335
1336    _attr means: specifiers that either end with attributes,
1337    or are such that any following attributes would
1338    be parsed as part of the specifier.
1339
1340    _nonattr: specifiers.  */
1341
1342 typespec_nonattr:
1343           typespec_reserved_nonattr
1344         | typespec_nonreserved_nonattr
1345         ;
1346
1347 typespec_attr:
1348           typespec_reserved_attr
1349         ;
1350
1351 typespec_reserved_nonattr:
1352           TYPESPEC
1353                 { OBJC_NEED_RAW_IDENTIFIER (1); }
1354         | structsp_nonattr
1355         ;
1356
1357 typespec_reserved_attr:
1358           structsp_attr
1359         ;
1360
1361 typespec_nonreserved_nonattr:
1362           TYPENAME
1363                 { /* For a typedef name, record the meaning, not the name.
1364                      In case of `foo foo, bar;'.  */
1365                   $$ = lookup_name ($1); }
1366 @@ifobjc
1367         | CLASSNAME protocolrefs
1368                 { $$ = objc_get_protocol_qualified_type ($1, $2); }
1369         | OBJECTNAME protocolrefs
1370                 { $$ = objc_get_protocol_qualified_type ($1, $2); }
1371
1372 /* Make "<SomeProtocol>" equivalent to "id <SomeProtocol>"
1373    - nisse@lysator.liu.se */
1374         | non_empty_protocolrefs
1375                 { $$ = objc_get_protocol_qualified_type (NULL_TREE, $1); }
1376 @@end_ifobjc
1377         | typeof '(' expr ')'
1378                 { skip_evaluation--;
1379                   if (TREE_CODE ($3.value) == COMPONENT_REF
1380                       && DECL_C_BIT_FIELD (TREE_OPERAND ($3.value, 1)))
1381                     error ("`typeof' applied to a bit-field");
1382                   $$ = TREE_TYPE ($3.value); }
1383         | typeof '(' typename ')'
1384                 { skip_evaluation--; $$ = groktypename ($3); }
1385         ;
1386
1387 /* typespec_nonreserved_attr does not exist.  */
1388
1389 initdecls:
1390         initdcl
1391         | initdecls ',' maybe_resetattrs initdcl
1392         ;
1393
1394 notype_initdecls:
1395         notype_initdcl
1396         | notype_initdecls ',' maybe_resetattrs notype_initdcl
1397         ;
1398
1399 initdcl:
1400           declarator maybeasm maybe_attribute '='
1401                 { $<ttype>$ = start_decl ($1, current_declspecs, true,
1402                                           chainon ($3, all_prefix_attributes));
1403                   start_init ($<ttype>$, $2, global_bindings_p ()); }
1404           init
1405 /* Note how the declaration of the variable is in effect while its init is parsed! */
1406                 { finish_init ();
1407                   maybe_warn_string_init (TREE_TYPE ($<ttype>5), $6);
1408                   finish_decl ($<ttype>5, $6.value, $2); }
1409         | declarator maybeasm maybe_attribute
1410                 { tree d = start_decl ($1, current_declspecs, false,
1411                                        chainon ($3, all_prefix_attributes));
1412                   finish_decl (d, NULL_TREE, $2);
1413                 }
1414         ;
1415
1416 notype_initdcl:
1417           notype_declarator maybeasm maybe_attribute '='
1418                 { $<ttype>$ = start_decl ($1, current_declspecs, true,
1419                                           chainon ($3, all_prefix_attributes));
1420                   start_init ($<ttype>$, $2, global_bindings_p ()); }
1421           init
1422 /* Note how the declaration of the variable is in effect while its init is parsed! */
1423                 { finish_init ();
1424                   maybe_warn_string_init (TREE_TYPE ($<ttype>5), $6);
1425                   finish_decl ($<ttype>5, $6.value, $2); }
1426         | notype_declarator maybeasm maybe_attribute
1427                 { tree d = start_decl ($1, current_declspecs, false,
1428                                        chainon ($3, all_prefix_attributes));
1429                   finish_decl (d, NULL_TREE, $2); }
1430         ;
1431 /* the * rules are dummies to accept the Apollo extended syntax
1432    so that the header files compile. */
1433 maybe_attribute:
1434       /* empty */
1435                 { $$ = NULL_TREE; }
1436         | attributes
1437                 { $$ = $1; }
1438         ;
1439
1440 attributes:
1441       attribute
1442                 { $$ = $1; }
1443         | attributes attribute
1444                 { $$ = chainon ($1, $2); }
1445         ;
1446
1447 attribute:
1448       ATTRIBUTE stop_string_translation
1449                 '(' '(' attribute_list ')' ')' start_string_translation
1450                 { $$ = $5; }
1451       | ATTRIBUTE error start_string_translation
1452                 {}
1453         ;
1454
1455 attribute_list:
1456       attrib
1457                 { $$ = $1; }
1458         | attribute_list ',' attrib
1459                 { $$ = chainon ($1, $3); }
1460         ;
1461
1462 attrib:
1463     /* empty */
1464                 { $$ = NULL_TREE; }
1465         | any_word
1466                 { $$ = build_tree_list ($1, NULL_TREE); }
1467         | any_word '(' IDENTIFIER ')'
1468                 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1469         | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1470                 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1471         | any_word '(' exprlist ')'
1472                 { $$ = build_tree_list ($1, $3); }
1473         ;
1474
1475 /* This still leaves out most reserved keywords,
1476    shouldn't we include them?  */
1477
1478 any_word:
1479           identifier
1480         | scspec
1481         | TYPESPEC
1482         | TYPE_QUAL
1483         ;
1484
1485 scspec:
1486           STATIC
1487         | SCSPEC
1488         ;
1489 \f
1490 /* Initializers.  `init' is the entry point.  */
1491
1492 init:
1493         expr_no_commas
1494                 { $$ = $1; }
1495         | '{'
1496                 { really_start_incremental_init (NULL_TREE); }
1497           initlist_maybe_comma '}'
1498                 { $$ = pop_init_level (0); }
1499         | error
1500                 { $$.value = error_mark_node; $$.original_code = ERROR_MARK; }
1501         ;
1502
1503 /* `initlist_maybe_comma' is the guts of an initializer in braces.  */
1504 initlist_maybe_comma:
1505           /* empty */
1506                 { if (pedantic)
1507                     pedwarn ("ISO C forbids empty initializer braces"); }
1508         | initlist1 maybecomma
1509         ;
1510
1511 initlist1:
1512           initelt
1513         | initlist1 ',' initelt
1514         ;
1515
1516 /* `initelt' is a single element of an initializer.
1517    It may use braces.  */
1518 initelt:
1519           designator_list '=' initval
1520                 { if (pedantic && ! flag_isoc99)
1521                     pedwarn ("ISO C90 forbids specifying subobject to initialize"); }
1522         | designator initval
1523                 { if (pedantic)
1524                     pedwarn ("obsolete use of designated initializer without `='"); }
1525         | identifier ':'
1526                 { set_init_label ($1);
1527                   if (pedantic)
1528                     pedwarn ("obsolete use of designated initializer with `:'"); }
1529           initval
1530                 {}
1531         | initval
1532         ;
1533
1534 initval:
1535           '{'
1536                 { push_init_level (0); }
1537           initlist_maybe_comma '}'
1538                 { process_init_element (pop_init_level (0)); }
1539         | expr_no_commas
1540                 { process_init_element ($1); }
1541         | error
1542         ;
1543
1544 designator_list:
1545           designator
1546         | designator_list designator
1547         ;
1548
1549 designator:
1550           '.' identifier
1551                 { set_init_label ($2); }
1552         | '[' expr_no_commas ELLIPSIS expr_no_commas ']'
1553                 { set_init_index ($2.value, $4.value);
1554                   if (pedantic)
1555                     pedwarn ("ISO C forbids specifying range of elements to initialize"); }
1556         | '[' expr_no_commas ']'
1557                 { set_init_index ($2.value, NULL_TREE); }
1558         ;
1559 \f
1560 nested_function:
1561         declarator
1562                 { if (pedantic)
1563                     pedwarn ("ISO C forbids nested functions");
1564
1565                   push_function_context ();
1566                   if (! start_function (current_declspecs, $1,
1567                                         all_prefix_attributes))
1568                     {
1569                       pop_function_context ();
1570                       YYERROR1;
1571                     }
1572                 }
1573         old_style_parm_decls save_location
1574                 { tree decl = current_function_decl;
1575                   DECL_SOURCE_LOCATION (decl) = $4;
1576                   store_parm_decls (); }
1577         /* This used to use compstmt_or_error.  That caused a bug with
1578            input `f(g) int g {}', where the use of YYERROR1 above caused
1579            an error which then was handled by compstmt_or_error.  There
1580            followed a repeated execution of that same rule, which called
1581            YYERROR1 again, and so on.  */
1582         compstmt
1583                 { tree decl = current_function_decl;
1584                   add_stmt ($6);
1585                   finish_function ();
1586                   pop_function_context ();
1587                   add_stmt (build_stmt (DECL_EXPR, decl)); }
1588         ;
1589
1590 notype_nested_function:
1591         notype_declarator
1592                 { if (pedantic)
1593                     pedwarn ("ISO C forbids nested functions");
1594
1595                   push_function_context ();
1596                   if (! start_function (current_declspecs, $1,
1597                                         all_prefix_attributes))
1598                     {
1599                       pop_function_context ();
1600                       YYERROR1;
1601                     }
1602                 }
1603         old_style_parm_decls save_location
1604                 { tree decl = current_function_decl;
1605                   DECL_SOURCE_LOCATION (decl) = $4;
1606                   store_parm_decls (); }
1607         /* This used to use compstmt_or_error.  That caused a bug with
1608            input `f(g) int g {}', where the use of YYERROR1 above caused
1609            an error which then was handled by compstmt_or_error.  There
1610            followed a repeated execution of that same rule, which called
1611            YYERROR1 again, and so on.  */
1612         compstmt
1613                 { tree decl = current_function_decl;
1614                   add_stmt ($6);
1615                   finish_function ();
1616                   pop_function_context ();
1617                   add_stmt (build_stmt (DECL_EXPR, decl)); }
1618         ;
1619
1620 /* Any kind of declarator (thus, all declarators allowed
1621    after an explicit typespec).  */
1622
1623 declarator:
1624           after_type_declarator
1625         | notype_declarator
1626         ;
1627
1628 /* A declarator that is allowed only after an explicit typespec.  */
1629
1630 after_type_declarator:
1631           '(' maybe_attribute after_type_declarator ')'
1632                 { $$ = $2 ? build_attrs_declarator ($2, $3) : $3; }
1633         | after_type_declarator '(' parmlist_or_identifiers  %prec '.'
1634                 { $$ = build_function_declarator ($3, $1); }
1635         | after_type_declarator array_declarator  %prec '.'
1636                 { $$ = set_array_declarator_inner ($2, $1, false); }
1637         | '*' maybe_type_quals_attrs after_type_declarator  %prec UNARY
1638                 { $$ = make_pointer_declarator ($2, $3); }
1639         | TYPENAME
1640 @@ifobjc
1641         | OBJECTNAME
1642 @@end_ifobjc
1643         ;
1644
1645 /* Kinds of declarator that can appear in a parameter list
1646    in addition to notype_declarator.  This is like after_type_declarator
1647    but does not allow a typedef name in parentheses as an identifier
1648    (because it would conflict with a function with that typedef as arg).  */
1649 parm_declarator:
1650           parm_declarator_starttypename
1651         | parm_declarator_nostarttypename
1652         ;
1653
1654 parm_declarator_starttypename:
1655           parm_declarator_starttypename '(' parmlist_or_identifiers  %prec '.'
1656                 { $$ = build_function_declarator ($3, $1); }
1657         | parm_declarator_starttypename array_declarator  %prec '.'
1658                 { $$ = set_array_declarator_inner ($2, $1, false); }
1659         | TYPENAME
1660 @@ifobjc
1661         | OBJECTNAME
1662 @@end_ifobjc
1663         ;
1664
1665 parm_declarator_nostarttypename:
1666           parm_declarator_nostarttypename '(' parmlist_or_identifiers  %prec '.'
1667                 { $$ = build_function_declarator ($3, $1); }
1668         | parm_declarator_nostarttypename array_declarator  %prec '.'
1669                 { $$ = set_array_declarator_inner ($2, $1, false); }
1670         | '*' maybe_type_quals_attrs parm_declarator_starttypename  %prec UNARY
1671                 { $$ = make_pointer_declarator ($2, $3); }
1672         | '*' maybe_type_quals_attrs parm_declarator_nostarttypename  %prec UNARY
1673                 { $$ = make_pointer_declarator ($2, $3); }
1674         | '(' maybe_attribute parm_declarator_nostarttypename ')'
1675                 { $$ = $2 ? build_attrs_declarator ($2, $3) : $3; }
1676         ;
1677
1678 /* A declarator allowed whether or not there has been
1679    an explicit typespec.  These cannot redeclare a typedef-name.  */
1680
1681 notype_declarator:
1682           notype_declarator '(' parmlist_or_identifiers  %prec '.'
1683                 { $$ = build_function_declarator ($3, $1); }
1684         | '(' maybe_attribute notype_declarator ')'
1685                 { $$ = $2 ? build_attrs_declarator ($2, $3) : $3; }
1686         | '*' maybe_type_quals_attrs notype_declarator  %prec UNARY
1687                 { $$ = make_pointer_declarator ($2, $3); }
1688         | notype_declarator array_declarator  %prec '.'
1689                 { $$ = set_array_declarator_inner ($2, $1, false); }
1690         | IDENTIFIER
1691         ;
1692
1693 struct_head:
1694           STRUCT
1695                 { $$ = NULL_TREE; }
1696         | STRUCT attributes
1697                 { $$ = $2; }
1698         ;
1699
1700 union_head:
1701           UNION
1702                 { $$ = NULL_TREE; }
1703         | UNION attributes
1704                 { $$ = $2; }
1705         ;
1706
1707 enum_head:
1708           ENUM
1709                 { $$ = NULL_TREE; }
1710         | ENUM attributes
1711                 { $$ = $2; }
1712         ;
1713
1714 /* structsp_attr: struct/union/enum specifiers that either
1715    end with attributes, or are such that any following attributes would
1716    be parsed as part of the struct/union/enum specifier.
1717
1718    structsp_nonattr: other struct/union/enum specifiers.  */
1719
1720 structsp_attr:
1721           struct_head identifier '{'
1722                 { $$ = start_struct (RECORD_TYPE, $2);
1723                   /* Start scope of tag before parsing components.  */
1724                 }
1725           component_decl_list '}' maybe_attribute
1726                 { $$ = finish_struct ($<ttype>4, nreverse ($5),
1727                                       chainon ($1, $7)); }
1728         | struct_head '{' component_decl_list '}' maybe_attribute
1729                 { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
1730                                       nreverse ($3), chainon ($1, $5));
1731                 }
1732         | union_head identifier '{'
1733                 { $$ = start_struct (UNION_TYPE, $2); }
1734           component_decl_list '}' maybe_attribute
1735                 { $$ = finish_struct ($<ttype>4, nreverse ($5),
1736                                       chainon ($1, $7)); }
1737         | union_head '{' component_decl_list '}' maybe_attribute
1738                 { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
1739                                       nreverse ($3), chainon ($1, $5));
1740                 }
1741         | enum_head identifier '{'
1742                 { $$ = start_enum ($2); }
1743           enumlist maybecomma_warn '}' maybe_attribute
1744                 { $$ = finish_enum ($<ttype>4, nreverse ($5),
1745                                     chainon ($1, $8)); }
1746         | enum_head '{'
1747                 { $$ = start_enum (NULL_TREE); }
1748           enumlist maybecomma_warn '}' maybe_attribute
1749                 { $$ = finish_enum ($<ttype>3, nreverse ($4),
1750                                     chainon ($1, $7)); }
1751         ;
1752
1753 structsp_nonattr:
1754           struct_head identifier
1755                 { $$ = xref_tag (RECORD_TYPE, $2); }
1756         | union_head identifier
1757                 { $$ = xref_tag (UNION_TYPE, $2); }
1758         | enum_head identifier
1759                 { $$ = xref_tag (ENUMERAL_TYPE, $2);
1760                   /* In ISO C, enumerated types can be referred to
1761                      only if already defined.  */
1762                   if (pedantic && !COMPLETE_TYPE_P ($$))
1763                     pedwarn ("ISO C forbids forward references to `enum' types"); }
1764         ;
1765
1766 maybecomma:
1767           /* empty */
1768         | ','
1769         ;
1770
1771 maybecomma_warn:
1772           /* empty */
1773         | ','
1774                 { if (pedantic && ! flag_isoc99)
1775                     pedwarn ("comma at end of enumerator list"); }
1776         ;
1777
1778 /* We chain the components in reverse order.  They are put in forward
1779    order in structsp_attr.
1780
1781    Note that component_declarator returns single decls, so components
1782    and components_notype can use TREE_CHAIN directly, wheras components
1783    and components_notype return lists (of comma separated decls), so
1784    component_decl_list and component_decl_list2 must use chainon.
1785
1786    The theory behind all this is that there will be more semicolon
1787    separated fields than comma separated fields, and so we'll be
1788    minimizing the number of node traversals required by chainon.  */
1789
1790 component_decl_list:
1791           component_decl_list2
1792                 { $$ = $1; }
1793         | component_decl_list2 component_decl
1794                 { $$ = chainon ($2, $1);
1795                   pedwarn ("no semicolon at end of struct or union"); }
1796         ;
1797
1798 component_decl_list2:   /* empty */
1799                 { $$ = NULL_TREE; }
1800         | component_decl_list2 component_decl ';'
1801                 { $$ = chainon ($2, $1); }
1802         | component_decl_list2 ';'
1803                 { if (pedantic)
1804                     pedwarn ("extra semicolon in struct or union specified"); }
1805 @@ifobjc
1806         /* foo(sizeof(struct{ @defs(ClassName)})); */
1807         | AT_DEFS '(' CLASSNAME ')'
1808                 { $$ = nreverse (objc_get_class_ivars ($3)); }
1809 @@end_ifobjc
1810         ;
1811
1812 component_decl:
1813           declspecs_nosc_ts setspecs components
1814                 { $$ = $3;
1815                   POP_DECLSPEC_STACK; }
1816         | declspecs_nosc_ts setspecs
1817                 {
1818                   /* Support for unnamed structs or unions as members of
1819                      structs or unions (which is [a] useful and [b] supports
1820                      MS P-SDK).  */
1821                   if (pedantic)
1822                     pedwarn ("ISO C doesn't support unnamed structs/unions");
1823
1824                   $$ = grokfield(NULL, current_declspecs, NULL_TREE);
1825                   POP_DECLSPEC_STACK; }
1826         | declspecs_nosc_nots setspecs components_notype
1827                 { $$ = $3;
1828                   POP_DECLSPEC_STACK; }
1829         | declspecs_nosc_nots
1830                 { if (pedantic)
1831                     pedwarn ("ISO C forbids member declarations with no members");
1832                   shadow_tag_warned ($1, pedantic);
1833                   $$ = NULL_TREE; }
1834         | error
1835                 { $$ = NULL_TREE; }
1836         | extension component_decl
1837                 { $$ = $2;
1838                   RESTORE_EXT_FLAGS ($1); }
1839         ;
1840
1841 components:
1842           component_declarator
1843         | components ',' maybe_resetattrs component_declarator
1844                 { TREE_CHAIN ($4) = $1; $$ = $4; }
1845         ;
1846
1847 components_notype:
1848           component_notype_declarator
1849         | components_notype ',' maybe_resetattrs component_notype_declarator
1850                 { TREE_CHAIN ($4) = $1; $$ = $4; }
1851         ;
1852
1853 component_declarator:
1854           declarator maybe_attribute
1855                 { $$ = grokfield ($1, current_declspecs, NULL_TREE);
1856                   decl_attributes (&$$,
1857                                    chainon ($2, all_prefix_attributes), 0); }
1858         | declarator ':' expr_no_commas maybe_attribute
1859                 { $$ = grokfield ($1, current_declspecs, $3.value);
1860                   decl_attributes (&$$,
1861                                    chainon ($4, all_prefix_attributes), 0); }
1862         | ':' expr_no_commas maybe_attribute
1863                 { $$ = grokfield (NULL_TREE, current_declspecs, $2.value);
1864                   decl_attributes (&$$,
1865                                    chainon ($3, all_prefix_attributes), 0); }
1866         ;
1867
1868 component_notype_declarator:
1869           notype_declarator maybe_attribute
1870                 { $$ = grokfield ($1, current_declspecs, NULL_TREE);
1871                   decl_attributes (&$$,
1872                                    chainon ($2, all_prefix_attributes), 0); }
1873         | notype_declarator ':' expr_no_commas maybe_attribute
1874                 { $$ = grokfield ($1, current_declspecs, $3.value);
1875                   decl_attributes (&$$,
1876                                    chainon ($4, all_prefix_attributes), 0); }
1877         | ':' expr_no_commas maybe_attribute
1878                 { $$ = grokfield (NULL_TREE, current_declspecs, $2.value);
1879                   decl_attributes (&$$,
1880                                    chainon ($3, all_prefix_attributes), 0); }
1881         ;
1882
1883 /* We chain the enumerators in reverse order.
1884    They are put in forward order in structsp_attr.  */
1885
1886 enumlist:
1887           enumerator
1888         | enumlist ',' enumerator
1889                 { if ($1 == error_mark_node)
1890                     $$ = $1;
1891                   else
1892                     TREE_CHAIN ($3) = $1, $$ = $3; }
1893         | error
1894                 { $$ = error_mark_node; }
1895         ;
1896
1897
1898 enumerator:
1899           identifier
1900                 { $$ = build_enumerator ($1, NULL_TREE); }
1901         | identifier '=' expr_no_commas
1902                 { $$ = build_enumerator ($1, $3.value); }
1903         ;
1904
1905 typename:
1906           declspecs_nosc
1907                 { pending_xref_error ();
1908                   $<ttype>$ = $1; }
1909           absdcl
1910                 { $$ = build_tree_list ($<ttype>2, $3); }
1911         ;
1912
1913 absdcl:   /* an absolute declarator */
1914         /* empty */
1915                 { $$ = NULL_TREE; }
1916         | absdcl1
1917         ;
1918
1919 absdcl_maybe_attribute:   /* absdcl maybe_attribute, but not just attributes */
1920         /* empty */
1921                 { $$ = build_c_parm (current_declspecs, all_prefix_attributes,
1922                                      NULL_TREE); }
1923         | absdcl1
1924                 { $$ = build_c_parm (current_declspecs, all_prefix_attributes,
1925                                      $1); }
1926         | absdcl1_noea attributes
1927                 { $$ = build_c_parm (current_declspecs,
1928                                      chainon ($2, all_prefix_attributes),
1929                                      $1); }
1930         ;
1931
1932 absdcl1:  /* a nonempty absolute declarator */
1933           absdcl1_ea
1934         | absdcl1_noea
1935         ;
1936
1937 absdcl1_noea:
1938           direct_absdcl1
1939         | '*' maybe_type_quals_attrs absdcl1_noea
1940                 { $$ = make_pointer_declarator ($2, $3); }
1941         ;
1942
1943 absdcl1_ea:
1944           '*' maybe_type_quals_attrs
1945                 { $$ = make_pointer_declarator ($2, NULL_TREE); }
1946         | '*' maybe_type_quals_attrs absdcl1_ea
1947                 { $$ = make_pointer_declarator ($2, $3); }
1948         ;
1949
1950 direct_absdcl1:
1951           '(' maybe_attribute absdcl1 ')'
1952                 { $$ = $2 ? build_attrs_declarator ($2, $3) : $3; }
1953         | direct_absdcl1 '(' parmlist
1954                 { $$ = build_function_declarator ($3, $1); }
1955         | direct_absdcl1 array_declarator
1956                 { $$ = set_array_declarator_inner ($2, $1, true); }
1957         | '(' parmlist
1958                 { $$ = build_function_declarator ($2, NULL_TREE); }
1959         | array_declarator
1960                 { $$ = set_array_declarator_inner ($1, NULL_TREE, true); }
1961         ;
1962
1963 /* The [...] part of a declarator for an array type.  */
1964
1965 array_declarator:
1966         '[' maybe_type_quals_attrs expr_no_commas ']'
1967                 { $$ = build_array_declarator ($3.value, $2, false, false); }
1968         | '[' maybe_type_quals_attrs ']'
1969                 { $$ = build_array_declarator (NULL_TREE, $2, false, false); }
1970         | '[' maybe_type_quals_attrs '*' ']'
1971                 { $$ = build_array_declarator (NULL_TREE, $2, false, true); }
1972         | '[' STATIC maybe_type_quals_attrs expr_no_commas ']'
1973                 { $$ = build_array_declarator ($4.value, $3, true, false); }
1974         /* declspecs_nosc_nots is a synonym for type_quals_attrs.  */
1975         | '[' declspecs_nosc_nots STATIC expr_no_commas ']'
1976                 { $$ = build_array_declarator ($4.value, $2, true, false); }
1977         ;
1978
1979 /* A nonempty series of declarations and statements (possibly followed by
1980    some labels) that can form the body of a compound statement.
1981    NOTE: we don't allow labels on declarations; this might seem like a
1982    natural extension, but there would be a conflict between attributes
1983    on the label and prefix attributes on the declaration.  */
1984
1985 stmts_and_decls:
1986           lineno_stmt_decl_or_labels_ending_stmt
1987         | lineno_stmt_decl_or_labels_ending_decl
1988         | lineno_stmt_decl_or_labels_ending_label
1989                 {
1990                   error ("label at end of compound statement");
1991                 }
1992         | lineno_stmt_decl_or_labels_ending_error
1993         ;
1994
1995 lineno_stmt_decl_or_labels_ending_stmt:
1996           lineno_stmt
1997         | lineno_stmt_decl_or_labels_ending_stmt lineno_stmt
1998         | lineno_stmt_decl_or_labels_ending_decl lineno_stmt
1999         | lineno_stmt_decl_or_labels_ending_label lineno_stmt
2000         | lineno_stmt_decl_or_labels_ending_error lineno_stmt
2001         ;
2002
2003 lineno_stmt_decl_or_labels_ending_decl:
2004           lineno_decl
2005         | lineno_stmt_decl_or_labels_ending_stmt lineno_decl
2006                 {
2007                   if ((pedantic && !flag_isoc99)
2008                       || warn_declaration_after_statement)
2009                     pedwarn_c90 ("ISO C90 forbids mixed declarations and code");
2010                 }
2011         | lineno_stmt_decl_or_labels_ending_decl lineno_decl
2012         | lineno_stmt_decl_or_labels_ending_error lineno_decl
2013         ;
2014
2015 lineno_stmt_decl_or_labels_ending_label:
2016           lineno_label
2017         | lineno_stmt_decl_or_labels_ending_stmt lineno_label
2018         | lineno_stmt_decl_or_labels_ending_decl lineno_label
2019         | lineno_stmt_decl_or_labels_ending_label lineno_label
2020         | lineno_stmt_decl_or_labels_ending_error lineno_label
2021         ;
2022
2023 lineno_stmt_decl_or_labels_ending_error:
2024         errstmt
2025         | lineno_stmt_decl_or_labels errstmt
2026         ;
2027
2028 lineno_stmt_decl_or_labels:
2029           lineno_stmt_decl_or_labels_ending_stmt
2030         | lineno_stmt_decl_or_labels_ending_decl
2031         | lineno_stmt_decl_or_labels_ending_label
2032         | lineno_stmt_decl_or_labels_ending_error
2033         ;
2034
2035 errstmt:  error ';'
2036         ;
2037
2038 /* Start and end blocks created for the new scopes of C99.  */
2039 c99_block_start: /* empty */
2040                 { $$ = c_begin_compound_stmt (flag_isoc99); }
2041         ;
2042
2043 /* Read zero or more forward-declarations for labels
2044    that nested functions can jump to.  */
2045 maybe_label_decls:
2046           /* empty */
2047         | label_decls
2048                 { if (pedantic)
2049                     pedwarn ("ISO C forbids label declarations"); }
2050         ;
2051
2052 label_decls:
2053           label_decl
2054         | label_decls label_decl
2055         ;
2056
2057 label_decl:
2058           LABEL identifiers_or_typenames ';'
2059                 { tree link;
2060                   for (link = $2; link; link = TREE_CHAIN (link))
2061                     {
2062                       tree label = declare_label (TREE_VALUE (link));
2063                       C_DECLARED_LABEL_FLAG (label) = 1;
2064                       add_stmt (build_stmt (DECL_EXPR, label));
2065                     }
2066                 }
2067         ;
2068
2069 /* This is the body of a function definition.
2070    It causes syntax errors to ignore to the next openbrace.  */
2071 compstmt_or_error:
2072           compstmt
2073                 { add_stmt ($1); }
2074         | error compstmt
2075         ;
2076
2077 compstmt_start: '{' { $$ = c_begin_compound_stmt (true); }
2078         ;
2079
2080 compstmt_nostart: '}'
2081         | maybe_label_decls compstmt_contents_nonempty '}'
2082         ;
2083
2084 compstmt_contents_nonempty:
2085           stmts_and_decls
2086         | error
2087         ;
2088
2089 compstmt_primary_start:
2090         '(' '{'
2091                 { if (current_function_decl == 0)
2092                     {
2093                       error ("braced-group within expression allowed "
2094                              "only inside a function");
2095                       YYERROR;
2096                     }
2097                   $$ = c_begin_stmt_expr ();
2098                 }
2099         ;
2100
2101 compstmt: compstmt_start compstmt_nostart
2102                 { $$ = c_end_compound_stmt ($1, true); }
2103         ;
2104
2105 /* The forced readahead in here is because we might be at the end of a
2106    line, and the line and file won't be bumped until yylex absorbs the
2107    first token on the next line.  */
2108
2109 save_location:
2110                 { if (yychar == YYEMPTY)
2111                     yychar = YYLEX;
2112                   $$ = input_location; }
2113         ;
2114
2115 lineno_labels:
2116           /* empty */
2117         | lineno_labels lineno_label
2118         ;
2119
2120 /* A labeled statement.  In C99 it also generates an implicit block.  */
2121 c99_block_lineno_labeled_stmt:
2122           c99_block_start lineno_labels lineno_stmt
2123                 { $$ = c_end_compound_stmt ($1, flag_isoc99); }
2124         ;
2125
2126 lineno_stmt:
2127           save_location stmt
2128                 { 
2129                   /* Two cases cannot and do not have line numbers associated:
2130                      If stmt is degenerate, such as "2;", then stmt is an 
2131                      INTEGER_CST, which cannot hold line numbers.  But that's
2132                      ok because the statement will either be changed to a
2133                      MODIFY_EXPR during gimplification of the statement expr,
2134                      or discarded.  If stmt was compound, but without new
2135                      variables, we will have skipped the creation of a BIND
2136                      and will have a bare STATEMENT_LIST.  But that's ok
2137                      because (recursively) all of the component statments
2138                      should already have line numbers assigned.  */
2139                   if ($2 && EXPR_P ($2))
2140                     SET_EXPR_LOCATION ($2, $1);
2141                 }
2142         ;
2143
2144 lineno_label:
2145           save_location label
2146                 { if ($2) SET_EXPR_LOCATION ($2, $1); }
2147         ;
2148
2149 condition: save_location expr
2150                 { $$ = lang_hooks.truthvalue_conversion ($2.value);
2151                   if (EXPR_P ($$))
2152                     SET_EXPR_LOCATION ($$, $1); }
2153         ;
2154
2155 /* Implement -Wparenthesis by special casing IF statement directly nested
2156    within IF statement.  This requires some amount of duplication of the
2157    productions under c99_block_lineno_labeled_stmt in order to work out.
2158    But it's still likely more maintainable than lots of state outside the
2159    parser...  */
2160
2161 if_statement_1:
2162         c99_block_start lineno_labels if_statement
2163                 { $$ = c_end_compound_stmt ($1, flag_isoc99); }
2164         ;
2165
2166 if_statement_2:
2167           c99_block_start lineno_labels ';'
2168                 { if (extra_warnings)
2169                     add_stmt (build (NOP_EXPR, NULL_TREE, NULL_TREE));
2170                   $$ = c_end_compound_stmt ($1, flag_isoc99); }
2171         | c99_block_lineno_labeled_stmt
2172         ;
2173
2174 if_statement:
2175           IF c99_block_start save_location '(' condition ')'
2176             if_statement_1 ELSE if_statement_2
2177                 { c_finish_if_stmt ($3, $5, $7, $9, true);
2178                   add_stmt (c_end_compound_stmt ($2, flag_isoc99)); }
2179         | IF c99_block_start save_location '(' condition ')'
2180             if_statement_2 ELSE if_statement_2
2181                 { c_finish_if_stmt ($3, $5, $7, $9, false);
2182                   add_stmt (c_end_compound_stmt ($2, flag_isoc99)); }
2183         | IF c99_block_start save_location '(' condition ')'
2184             if_statement_1                              %prec IF
2185                 { c_finish_if_stmt ($3, $5, $7, NULL, true);
2186                   add_stmt (c_end_compound_stmt ($2, flag_isoc99)); }
2187         | IF c99_block_start save_location '(' condition ')'
2188             if_statement_2                              %prec IF
2189                 { c_finish_if_stmt ($3, $5, $7, NULL, false);
2190                   add_stmt (c_end_compound_stmt ($2, flag_isoc99)); }
2191         ;
2192
2193 start_break: /* empty */
2194                 { $$ = c_break_label; c_break_label = NULL; }
2195         ;
2196
2197 start_continue: /* empty */
2198                 { $$ = c_cont_label; c_cont_label = NULL; }
2199         ;
2200
2201 while_statement:
2202         WHILE c99_block_start save_location '(' condition ')'
2203         start_break start_continue c99_block_lineno_labeled_stmt
2204                 { c_finish_loop ($3, $5, NULL, $9, c_break_label,
2205                                  c_cont_label, true);
2206                   add_stmt (c_end_compound_stmt ($2, flag_isoc99));
2207                   c_break_label = $7; c_cont_label = $8; }
2208         ;
2209
2210 do_statement:
2211         DO c99_block_start save_location start_break start_continue
2212         c99_block_lineno_labeled_stmt WHILE
2213                 { $<ttype>$ = c_break_label; c_break_label = $4; }
2214                 { $<ttype>$ = c_cont_label; c_cont_label = $5; }
2215         '(' condition ')' ';'
2216                 { c_finish_loop ($3, $11, NULL, $6, $<ttype>8,
2217                                  $<ttype>9, false);
2218                   add_stmt (c_end_compound_stmt ($2, flag_isoc99)); }
2219         ;
2220
2221 xexpr:
2222         /* empty */
2223                 { $$ = NULL_TREE; }
2224         | expr
2225                 { $$ = $1.value; }
2226         ;
2227
2228 for_init_stmt:
2229           xexpr ';'
2230                 { c_finish_expr_stmt ($1); }
2231         | decl
2232                 { check_for_loop_decls (); }
2233         ;
2234
2235 for_cond_expr: save_location xexpr
2236                 { if ($2)
2237                     {
2238                       $$ = lang_hooks.truthvalue_conversion ($2);
2239                       if (EXPR_P ($$))
2240                         SET_EXPR_LOCATION ($$, $1);
2241                     }
2242                   else
2243                     $$ = NULL;
2244                 }
2245         ;
2246
2247 for_incr_expr: xexpr
2248                 { $$ = c_process_expr_stmt ($1); }
2249         ;
2250
2251 for_statement:
2252         FOR c99_block_start '(' for_init_stmt
2253         save_location for_cond_expr ';' for_incr_expr ')'
2254         start_break start_continue c99_block_lineno_labeled_stmt
2255                 { c_finish_loop ($5, $6, $8, $12, c_break_label,
2256                                  c_cont_label, true);
2257                   add_stmt (c_end_compound_stmt ($2, flag_isoc99));
2258                   c_break_label = $10; c_cont_label = $11; }
2259         ;
2260
2261 switch_statement:
2262         SWITCH c99_block_start '(' expr ')'
2263                 { $<ttype>$ = c_start_case ($4.value); }
2264         start_break c99_block_lineno_labeled_stmt
2265                 { c_finish_case ($8);
2266                   if (c_break_label)
2267                     add_stmt (build (LABEL_EXPR, void_type_node,
2268                                      c_break_label));
2269                   c_break_label = $7;
2270                   add_stmt (c_end_compound_stmt ($2, flag_isoc99)); }
2271         ;
2272
2273 /* Parse a single real statement, not including any labels or compounds.  */
2274 stmt_nocomp:
2275           expr ';'
2276                 { $$ = c_finish_expr_stmt ($1.value); }
2277         | if_statement
2278                 { $$ = NULL_TREE; }
2279         | while_statement
2280                 { $$ = NULL_TREE; }
2281         | do_statement
2282                 { $$ = NULL_TREE; }
2283         | for_statement
2284                 { $$ = NULL_TREE; }
2285         | switch_statement
2286                 { $$ = NULL_TREE; }
2287         | BREAK ';'
2288                 { $$ = c_finish_bc_stmt (&c_break_label, true); }
2289         | CONTINUE ';'
2290                 { $$ = c_finish_bc_stmt (&c_cont_label, false); }
2291         | RETURN ';'
2292                 { $$ = c_finish_return (NULL_TREE); }
2293         | RETURN expr ';'
2294                 { $$ = c_finish_return ($2.value); }
2295         | asm_stmt
2296         | GOTO identifier ';'
2297                 { $$ = c_finish_goto_label ($2); }
2298         | GOTO '*' expr ';'
2299                 { $$ = c_finish_goto_ptr ($3.value); }
2300         | ';'
2301                 { $$ = NULL_TREE; }
2302 @@ifobjc
2303         | AT_THROW expr ';'
2304                 { $$ = objc_build_throw_stmt ($2.value); }
2305         | AT_THROW ';'
2306                 { $$ = objc_build_throw_stmt (NULL_TREE); }
2307         | objc_try_catch_stmt
2308                 { $$ = NULL_TREE; }
2309         | AT_SYNCHRONIZED save_location '(' expr ')' compstmt
2310                 { objc_build_synchronized ($2, $4.value, $6); $$ = NULL_TREE; }
2311         ;
2312
2313 objc_catch_prefix:
2314         AT_CATCH '(' parm ')'
2315                 { objc_begin_catch_clause (grokparm ($3)); }
2316         ;
2317
2318 objc_catch_clause:
2319           objc_catch_prefix '{' compstmt_nostart
2320                 { objc_finish_catch_clause (); }
2321         | objc_catch_prefix '{' error '}'
2322                 { objc_finish_catch_clause (); }
2323         ;
2324
2325 objc_opt_catch_list:
2326           /* empty */
2327         | objc_opt_catch_list objc_catch_clause
2328         ;
2329
2330 objc_try_catch_clause:
2331         AT_TRY save_location compstmt
2332                 { objc_begin_try_stmt ($2, $3); }
2333         objc_opt_catch_list
2334         ;
2335
2336 objc_finally_clause:
2337         AT_FINALLY save_location compstmt
2338                 { objc_build_finally_clause ($2, $3); }
2339         ;
2340
2341 objc_try_catch_stmt:
2342           objc_try_catch_clause
2343                 { objc_finish_try_stmt (); }
2344         | objc_try_catch_clause objc_finally_clause
2345                 { objc_finish_try_stmt (); }
2346 @@end_ifobjc
2347         ;
2348
2349 /* Parse a single or compound real statement, not including any labels.  */
2350 stmt:
2351           compstmt
2352                 { add_stmt ($1); $$ = NULL_TREE; }
2353         | stmt_nocomp
2354         ;
2355
2356 /* Any kind of label, including jump labels and case labels.
2357    ANSI C accepts labels only before statements, but we allow them
2358    also at the end of a compound statement.  */
2359
2360 label:    CASE expr_no_commas ':'
2361                 { $$ = do_case ($2.value, NULL_TREE); }
2362         | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
2363                 { $$ = do_case ($2.value, $4.value); }
2364         | DEFAULT ':'
2365                 { $$ = do_case (NULL_TREE, NULL_TREE); }
2366         | identifier save_location ':' maybe_attribute
2367                 { tree label = define_label ($2, $1);
2368                   if (label)
2369                     {
2370                       decl_attributes (&label, $4, 0);
2371                       $$ = add_stmt (build_stmt (LABEL_EXPR, label));
2372                     }
2373                   else
2374                     $$ = NULL_TREE;
2375                 }
2376         ;
2377
2378 /* Asm expressions and statements */
2379
2380 /* simple_asm_expr is used in restricted contexts, where a full
2381    expression with inputs and outputs does not make sense.  */
2382 simple_asm_expr:
2383         ASM_KEYWORD stop_string_translation
2384               '(' STRING ')' start_string_translation
2385                 { $$ = $4; }
2386         ;
2387
2388 /* maybeasm: used for assembly names for declarations */
2389 maybeasm:
2390           /* empty */
2391                 { $$ = NULL_TREE; }
2392         | simple_asm_expr
2393         ;
2394
2395 /* asmdef: asm() outside a function body.  */
2396 asmdef:
2397         simple_asm_expr ';'
2398                 { assemble_asm ($1); }
2399         | ASM_KEYWORD error start_string_translation ';'
2400                 {}
2401         ;
2402
2403 /* Full-blown asm statement with inputs, outputs, clobbers, and
2404    volatile tag allowed.  */
2405 asm_stmt:
2406         ASM_KEYWORD maybe_volatile stop_string_translation
2407                 '(' asm_argument ')' start_string_translation ';'
2408                 { $$ = build_asm_stmt ($2, $5); }
2409         ;
2410
2411 asm_argument:
2412         /* no operands */
2413         STRING
2414                 { $$ = build_asm_expr ($1, 0, 0, 0, true); }
2415         /* output operands */
2416         | STRING ':' asm_operands
2417                 { $$ = build_asm_expr ($1, $3, 0, 0, false); }
2418         /* output and input operands */
2419         | STRING ':' asm_operands ':' asm_operands
2420                 { $$ = build_asm_expr ($1, $3, $5, 0, false); }
2421         /* output and input operands and clobbers */
2422         | STRING ':' asm_operands ':' asm_operands ':' asm_clobbers
2423                 { $$ = build_asm_expr ($1, $3, $5, $7, false); }
2424         ;
2425
2426 /* Either 'volatile' or nothing.  First thing in an `asm' statement.  */
2427
2428 maybe_volatile:
2429         /* empty */
2430                 { $$ = 0; }
2431         | TYPE_QUAL
2432                 { if ($1 != ridpointers[RID_VOLATILE])
2433                     {
2434                       warning ("%E qualifier ignored on asm", $1);
2435                       $$ = 0;
2436                     }
2437                   else
2438                     $$ = $1;
2439                 }
2440         ;
2441
2442 /* These are the operands other than the first string and colon
2443    in  asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x))  */
2444 asm_operands: /* empty */
2445                 { $$ = NULL_TREE; }
2446         | nonnull_asm_operands
2447         ;
2448
2449 nonnull_asm_operands:
2450           asm_operand
2451         | nonnull_asm_operands ',' asm_operand
2452                 { $$ = chainon ($1, $3); }
2453         ;
2454
2455 asm_operand:
2456           STRING start_string_translation '(' expr ')' stop_string_translation
2457                 { $$ = build_tree_list (build_tree_list (NULL_TREE, $1),
2458                                         $4.value); }
2459         | '[' identifier ']' STRING start_string_translation
2460           '(' expr ')' stop_string_translation
2461                 { $2 = build_string (IDENTIFIER_LENGTH ($2),
2462                                      IDENTIFIER_POINTER ($2));
2463                   $$ = build_tree_list (build_tree_list ($2, $4), $7.value); }
2464         ;
2465
2466 asm_clobbers:
2467           STRING
2468                 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
2469         | asm_clobbers ',' STRING
2470                 { $$ = tree_cons (NULL_TREE, $3, $1); }
2471         ;
2472
2473 stop_string_translation:
2474         { c_lex_string_translate = 0; }
2475         ;
2476
2477 start_string_translation:
2478         { c_lex_string_translate = 1; }
2479         ;
2480
2481 \f
2482 /* This is what appears inside the parens in a function declarator.
2483    Its value is a list of ..._TYPE nodes.  Attributes must appear here
2484    to avoid a conflict with their appearance after an open parenthesis
2485    in an abstract declarator, as in
2486    "void bar (int (__attribute__((__mode__(SI))) int foo));".  */
2487 parmlist:
2488           maybe_attribute
2489                 { push_scope ();
2490                   declare_parm_level (); }
2491           parmlist_1
2492                 { $$ = $3;
2493                   pop_scope (); }
2494         ;
2495
2496 parmlist_1:
2497           parmlist_2 ')'
2498         | parms ';'
2499                 { mark_forward_parm_decls (); }
2500           maybe_attribute
2501                 { /* Dummy action so attributes are in known place
2502                      on parser stack.  */ }
2503           parmlist_1
2504                 { $$ = $6; }
2505         | error ')'
2506                 { $$ = make_node (TREE_LIST); }
2507         ;
2508
2509 /* This is what appears inside the parens in a function declarator.
2510    Is value is represented in the format that grokdeclarator expects.  */
2511 parmlist_2:  /* empty */
2512                 { $$ = make_node (TREE_LIST); }
2513         | ELLIPSIS
2514                 { $$ = make_node (TREE_LIST); 
2515                   /* Suppress -Wold-style-definition for this case.  */
2516                   TREE_CHAIN ($$) = error_mark_node;
2517                   error ("ISO C requires a named argument before `...'");
2518                 }
2519         | parms
2520                 { $$ = get_parm_info (/*ellipsis=*/false); }
2521         | parms ',' ELLIPSIS
2522                 { $$ = get_parm_info (/*ellipsis=*/true); }
2523         ;
2524
2525 parms:
2526         firstparm
2527                 { push_parm_decl ($1); }
2528         | parms ',' parm
2529                 { push_parm_decl ($3); }
2530         ;
2531
2532 /* A single parameter declaration or parameter type name,
2533    as found in a parmlist.  */
2534 parm:
2535           declspecs_ts setspecs parm_declarator maybe_attribute
2536                 { $$ = build_c_parm (current_declspecs,
2537                                      chainon ($4, all_prefix_attributes), $3);
2538                   POP_DECLSPEC_STACK; }
2539         | declspecs_ts setspecs notype_declarator maybe_attribute
2540                 { $$ = build_c_parm (current_declspecs,
2541                                      chainon ($4, all_prefix_attributes), $3);
2542                   POP_DECLSPEC_STACK; }
2543         | declspecs_ts setspecs absdcl_maybe_attribute
2544                 { $$ = $3;
2545                   POP_DECLSPEC_STACK; }
2546         | declspecs_nots setspecs notype_declarator maybe_attribute
2547                 { $$ = build_c_parm (current_declspecs,
2548                                      chainon ($4, all_prefix_attributes), $3);
2549                   POP_DECLSPEC_STACK; }
2550
2551         | declspecs_nots setspecs absdcl_maybe_attribute
2552                 { $$ = $3;
2553                   POP_DECLSPEC_STACK; }
2554         ;
2555
2556 /* The first parm, which must suck attributes from off the top of the parser
2557    stack.  */
2558 firstparm:
2559           declspecs_ts_nosa setspecs_fp parm_declarator maybe_attribute
2560                 { $$ = build_c_parm (current_declspecs,
2561                                      chainon ($4, all_prefix_attributes), $3);
2562                   POP_DECLSPEC_STACK; }
2563         | declspecs_ts_nosa setspecs_fp notype_declarator maybe_attribute
2564                 { $$ = build_c_parm (current_declspecs,
2565                                      chainon ($4, all_prefix_attributes), $3);
2566                   POP_DECLSPEC_STACK; }
2567         | declspecs_ts_nosa setspecs_fp absdcl_maybe_attribute
2568                 { $$ = $3;
2569                   POP_DECLSPEC_STACK; }
2570         | declspecs_nots_nosa setspecs_fp notype_declarator maybe_attribute
2571                 { $$ = build_c_parm (current_declspecs,
2572                                      chainon ($4, all_prefix_attributes), $3);
2573                   POP_DECLSPEC_STACK; }
2574
2575         | declspecs_nots_nosa setspecs_fp absdcl_maybe_attribute
2576                 { $$ = $3;
2577                   POP_DECLSPEC_STACK; }
2578         ;
2579
2580 setspecs_fp:
2581           setspecs
2582                 { prefix_attributes = chainon (prefix_attributes, $<ttype>-2);
2583                   all_prefix_attributes = prefix_attributes; }
2584         ;
2585
2586 /* This is used in a function definition
2587    where either a parmlist or an identifier list is ok.
2588    Its value is a list of ..._TYPE nodes or a list of identifiers.  */
2589 parmlist_or_identifiers:
2590           maybe_attribute
2591                 { push_scope ();
2592                   declare_parm_level (); }
2593           parmlist_or_identifiers_1
2594                 { $$ = $3;
2595                   pop_scope (); }
2596         ;
2597
2598 parmlist_or_identifiers_1:
2599           parmlist_1
2600         | identifiers ')'
2601                 { $$ = tree_cons (NULL_TREE, NULL_TREE, $1);
2602
2603                   /* Make sure we have a parmlist after attributes.  */
2604                   if ($<ttype>-1 != 0)
2605                     YYERROR1;
2606                 }
2607         ;
2608
2609 /* A nonempty list of identifiers.  */
2610 identifiers:
2611         IDENTIFIER
2612                 { $$ = build_tree_list (NULL_TREE, $1); }
2613         | identifiers ',' IDENTIFIER
2614                 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2615         ;
2616
2617 /* A nonempty list of identifiers, including typenames.  */
2618 identifiers_or_typenames:
2619         identifier
2620                 { $$ = build_tree_list (NULL_TREE, $1); }
2621         | identifiers_or_typenames ',' identifier
2622                 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2623         ;
2624
2625 extension:
2626         EXTENSION
2627                 { $$ = SAVE_EXT_FLAGS();
2628                   pedantic = 0;
2629                   warn_pointer_arith = 0;
2630                   warn_traditional = 0;
2631                   flag_iso = 0; }
2632         ;
2633 \f
2634 @@ifobjc
2635 /* Objective-C productions.  */
2636
2637 objcdef:
2638           classdef
2639         | classdecl
2640         | aliasdecl
2641         | protocoldef
2642         | methoddef
2643         | AT_END
2644                 {
2645                   objc_finish_implementation ();
2646                 }
2647         ;
2648
2649 /* A nonempty list of identifiers.  */
2650 identifier_list:
2651         identifier
2652                 { $$ = build_tree_list (NULL_TREE, $1); }
2653         | identifier_list ',' identifier
2654                 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2655         ;
2656
2657 classdecl:
2658           AT_CLASS identifier_list ';'
2659                 {
2660                   objc_declare_class ($2);
2661                 }
2662         ;
2663
2664 aliasdecl:
2665           AT_ALIAS identifier identifier ';'
2666                 {
2667                   objc_declare_alias ($2, $3);
2668                 }
2669         ;
2670
2671 superclass:
2672           ':' identifier { $$ = $2; }
2673         | /* NULL */ %prec HYPERUNARY    { $$ = NULL_TREE; }
2674         ;
2675
2676 class_ivars:
2677           '{' ivar_decl_list '}'
2678         | /* NULL */
2679         ;
2680
2681 classdef:
2682           AT_INTERFACE identifier superclass protocolrefs
2683                 {
2684                   objc_start_class_interface ($2, $3, $4);
2685                 }
2686           class_ivars
2687                 {
2688                   objc_continue_interface ();
2689                 }
2690           methodprotolist AT_END
2691                 {
2692                   objc_finish_interface ();
2693                 }
2694
2695         | AT_IMPLEMENTATION identifier superclass
2696                 {
2697                   objc_start_class_implementation ($2, $3);
2698                 }
2699           class_ivars
2700                 {
2701                   objc_continue_implementation ();
2702                 }
2703
2704         | AT_INTERFACE identifier '(' identifier ')' protocolrefs
2705                 {
2706                   objc_start_category_interface ($2, $4, $6);
2707                 }
2708           methodprotolist AT_END
2709                 {
2710                   objc_finish_interface ();
2711                 }
2712
2713         | AT_IMPLEMENTATION identifier '(' identifier ')'
2714                 {
2715                   objc_start_category_implementation ($2, $4);
2716                 }
2717         ;
2718
2719 protocoldef:
2720           AT_PROTOCOL identifier protocolrefs
2721                 {
2722                   objc_pq_context = 1;
2723                   objc_start_protocol ($2, $3);
2724                 }
2725           methodprotolist AT_END
2726                 {
2727                   objc_pq_context = 0;
2728                   objc_finish_interface ();
2729                 }
2730         /* The @protocol forward-declaration production introduces a
2731            reduce/reduce conflict on ';', which should be resolved in
2732            favor of the production 'identifier_list -> identifier'.  */
2733         | AT_PROTOCOL identifier_list ';'
2734                 {
2735                   objc_declare_protocols ($2);
2736                 }
2737         ;
2738
2739 protocolrefs:
2740           /* empty */
2741                 {
2742                   $$ = NULL_TREE;
2743                 }
2744         | non_empty_protocolrefs
2745         ;
2746
2747 non_empty_protocolrefs:
2748           ARITHCOMPARE identifier_list ARITHCOMPARE
2749                 {
2750                   if ($1 == LT_EXPR && $3 == GT_EXPR)
2751                     $$ = $2;
2752                   else
2753                     YYERROR1;
2754                 }
2755         ;
2756
2757 ivar_decl_list:
2758           /* empty */
2759         | ivar_decl_list visibility_spec ivar_decls
2760         ;
2761
2762 visibility_spec:
2763           /* empty */
2764         | AT_PRIVATE { objc_set_visibility (2); }
2765         | AT_PROTECTED { objc_set_visibility (0); }
2766         | AT_PUBLIC { objc_set_visibility (1); }
2767         ;
2768
2769 ivar_decls:
2770           /* empty */
2771         | ivar_decls ivar_decl ';'
2772         | ivar_decls ';'
2773                 {
2774                   if (pedantic)
2775                     pedwarn ("extra semicolon in struct or union specified");
2776                 }
2777         ;
2778
2779 ivar_decl:
2780         component_decl
2781                 {
2782                   /* Comma-separated ivars are chained together in
2783                      reverse order; add them one by one.  */
2784                   tree ivar = nreverse ($1);
2785
2786                   for (; ivar; ivar = TREE_CHAIN (ivar))
2787                     objc_add_instance_variable (copy_node (ivar));
2788                 }
2789         ;
2790
2791 opt_semi:
2792           /* NULL */
2793         | ';'
2794                 {
2795                   if (pedantic)
2796                     pedwarn ("extra semicolon in method definition specified");
2797                 }
2798         ;
2799
2800 methodtype:
2801           '+'
2802         | '-'
2803         ;
2804
2805 methoddef:
2806           methodtype
2807                 {
2808                   objc_set_method_type ($1);
2809                   objc_pq_context = 1;
2810                 }
2811           methoddecl opt_semi
2812                 {
2813                   objc_pq_context = 0;
2814                   objc_start_method_definition ($3);
2815                 }
2816           compstmt_or_error
2817                 {
2818                   objc_finish_method_definition (current_function_decl);
2819                 }
2820         ;
2821
2822 /* the reason for the strange actions in this rule
2823  is so that notype_initdecls when reached via datadef
2824  can find a valid list of type and sc specs in $0. */
2825
2826 methodprotolist:
2827           /* empty  */
2828         | methodprotolist methodproto
2829         | methodprotolist { $<ttype>$ = NULL_TREE; } datadef
2830         ;
2831
2832 semi_or_error:
2833           ';'
2834         | error
2835         ;
2836
2837 methodproto:
2838           methodtype
2839                 {
2840                   objc_set_method_type ($1);
2841                   /* Remember protocol qualifiers in prototypes.  */
2842                   objc_pq_context = 1;
2843                 }
2844           methoddecl
2845                 {
2846                   /* Forget protocol qualifiers here.  */
2847                   objc_pq_context = 0;
2848                   objc_add_method_declaration ($3);
2849                 }
2850           semi_or_error
2851         ;
2852
2853 methoddecl:
2854           '(' objc_typename ')' unaryselector
2855                 {
2856                   $$ = objc_build_method_signature ($2, $4, NULL_TREE);
2857                 }
2858
2859         | unaryselector
2860                 {
2861                   $$ = objc_build_method_signature (NULL_TREE, $1, NULL_TREE);
2862                 }
2863
2864         | '(' objc_typename ')' keywordselector optparmlist
2865                 {
2866                   $$ = objc_build_method_signature ($2, $4, $5);
2867                 }
2868
2869         | keywordselector optparmlist
2870                 {
2871                   $$ = objc_build_method_signature (NULL_TREE, $1, $2);
2872                 }
2873         ;
2874
2875 /* Optional ObjC method parameters follow the C syntax, and may include '...'
2876    to denote a variable number of arguments.  */
2877
2878 optparmlist:
2879           optparms optellipsis
2880                 {
2881                   TREE_OVERFLOW ($$) = $2;
2882                 }
2883         ;
2884
2885 optparms:
2886           /* NULL */
2887                 {
2888                   $$ = make_node (TREE_LIST);
2889                 }
2890         | optparms ',' parm
2891                 {
2892                   $$ = chainon ($1, build_tree_list (NULL_TREE,
2893                                                      grokparm ($3)));
2894                 }
2895         ;
2896         
2897 optellipsis:
2898           /* NULL */
2899                 {
2900                   $$ = 0;
2901                 }
2902         | ',' ELLIPSIS
2903                 {
2904                   $$ = 1;
2905                 }
2906         ;
2907
2908 unaryselector:
2909           selector
2910         ;
2911
2912 keywordselector:
2913           keyworddecl
2914
2915         | keywordselector keyworddecl
2916                 {
2917                   $$ = chainon ($1, $2);
2918                 }
2919         ;
2920
2921 selector:
2922           IDENTIFIER
2923         | TYPENAME
2924         | CLASSNAME
2925         | OBJECTNAME
2926         | reservedwords
2927         ;
2928
2929 reservedwords:
2930           ENUM | STRUCT | UNION | IF | ELSE | WHILE | DO | FOR
2931         | SWITCH | CASE | DEFAULT | BREAK | CONTINUE | RETURN
2932         | GOTO | ASM_KEYWORD | SIZEOF | TYPEOF | ALIGNOF
2933         | TYPESPEC | TYPE_QUAL
2934         ;
2935
2936 objc_qual:
2937           OBJC_TYPE_QUAL
2938         ;
2939
2940 objc_quals:
2941           objc_quals objc_qual
2942                 {
2943                   $$ = chainon ($1, build_tree_list (NULL_TREE, $2));
2944                 }
2945         | /* NULL */
2946                 {
2947                   $$ = NULL_TREE;
2948                 }
2949         ;
2950
2951 objc_typename:
2952           objc_quals typename
2953                 {
2954                   $$ = build_tree_list ($1, groktypename ($2));
2955                 }
2956         | objc_quals
2957                 {
2958                   $$ = build_tree_list ($1, NULL_TREE);
2959                 }
2960         ;
2961
2962 keyworddecl:
2963           selector ':' '(' objc_typename ')' identifier
2964                 {
2965                   $$ = objc_build_keyword_decl ($1, $4, $6);
2966                 }
2967
2968         | selector ':' identifier
2969                 {
2970                   $$ = objc_build_keyword_decl ($1, NULL_TREE, $3);
2971                 }
2972
2973         | ':' '(' objc_typename ')' identifier
2974                 {
2975                   $$ = objc_build_keyword_decl (NULL_TREE, $3, $5);
2976                 }
2977
2978         | ':' identifier
2979                 {
2980                   $$ = objc_build_keyword_decl (NULL_TREE, NULL_TREE, $2);
2981                 }
2982         ;
2983
2984 messageargs:
2985           selector
2986         | keywordarglist
2987         ;
2988
2989 keywordarglist:
2990           keywordarg
2991         | keywordarglist keywordarg
2992                 {
2993                   $$ = chainon ($1, $2);
2994                 }
2995         ;
2996
2997
2998 keywordexpr:
2999           nonnull_exprlist
3000                 {
3001                   if (TREE_CHAIN ($1) == NULL_TREE)
3002                     /* just return the expr., remove a level of indirection */
3003                     $$ = TREE_VALUE ($1);
3004                   else
3005                     /* we have a comma expr., we will collapse later */
3006                     $$ = $1;
3007                 }
3008         ;
3009
3010 keywordarg:
3011           selector ':' keywordexpr
3012                 {
3013                   $$ = build_tree_list ($1, $3);
3014                 }
3015         | ':' keywordexpr
3016                 {
3017                   $$ = build_tree_list (NULL_TREE, $2);
3018                 }
3019         ;
3020
3021 receiver:
3022           expr
3023                 { $$ = $1.value; }
3024         | CLASSNAME
3025                 {
3026                   $$ = objc_get_class_reference ($1);
3027                 }
3028         | TYPENAME
3029                 {
3030                   $$ = objc_get_class_reference ($1);
3031                 }
3032         ;
3033
3034 objcmessageexpr:
3035           '[' receiver messageargs ']'
3036                 { $$ = build_tree_list ($2, $3); }
3037         ;
3038
3039 selectorarg:
3040           selector
3041         | keywordnamelist
3042         ;
3043
3044 keywordnamelist:
3045           keywordname
3046         | keywordnamelist keywordname
3047                 {
3048                   $$ = chainon ($1, $2);
3049                 }
3050         ;
3051
3052 keywordname:
3053           selector ':'
3054                 {
3055                   $$ = build_tree_list ($1, NULL_TREE);
3056                 }
3057         | ':'
3058                 {
3059                   $$ = build_tree_list (NULL_TREE, NULL_TREE);
3060                 }
3061         ;
3062
3063 objcselectorexpr:
3064           AT_SELECTOR '(' selectorarg ')'
3065                 {
3066                   $$ = $3;
3067                 }
3068         ;
3069
3070 objcprotocolexpr:
3071           AT_PROTOCOL '(' identifier ')'
3072                 {
3073                   $$ = $3;
3074                 }
3075         ;
3076
3077 /* extension to support C-structures in the archiver */
3078
3079 objcencodeexpr:
3080           AT_ENCODE '(' typename ')'
3081                 {
3082                   $$ = groktypename ($3);
3083                 }
3084         ;
3085
3086 @@end_ifobjc
3087 %%
3088
3089 /* yylex() is a thin wrapper around c_lex(), all it does is translate
3090    cpplib.h's token codes into yacc's token codes.  */
3091
3092 static enum cpp_ttype last_token;
3093
3094 /* The reserved keyword table.  */
3095 struct resword
3096 {
3097   const char *word;
3098   ENUM_BITFIELD(rid) rid : 16;
3099   unsigned int disable   : 16;
3100 };
3101
3102 /* Disable mask.  Keywords are disabled if (reswords[i].disable & mask) is
3103    _true_.  */
3104 #define D_C89   0x01    /* not in C89 */
3105 #define D_EXT   0x02    /* GCC extension */
3106 #define D_EXT89 0x04    /* GCC extension incorporated in C99 */
3107 #define D_OBJC  0x08    /* Objective C only */
3108
3109 static const struct resword reswords[] =
3110 {
3111   { "_Bool",            RID_BOOL,       0 },
3112   { "_Complex",         RID_COMPLEX,    0 },
3113   { "__FUNCTION__",     RID_FUNCTION_NAME, 0 },
3114   { "__PRETTY_FUNCTION__", RID_PRETTY_FUNCTION_NAME, 0 },
3115   { "__alignof",        RID_ALIGNOF,    0 },
3116   { "__alignof__",      RID_ALIGNOF,    0 },
3117   { "__asm",            RID_ASM,        0 },
3118   { "__asm__",          RID_ASM,        0 },
3119   { "__attribute",      RID_ATTRIBUTE,  0 },
3120   { "__attribute__",    RID_ATTRIBUTE,  0 },
3121   { "__builtin_choose_expr", RID_CHOOSE_EXPR, 0 },
3122   { "__builtin_offsetof", RID_OFFSETOF, 0 },
3123   { "__builtin_types_compatible_p", RID_TYPES_COMPATIBLE_P, 0 },
3124   { "__builtin_va_arg", RID_VA_ARG,     0 },
3125   { "__complex",        RID_COMPLEX,    0 },
3126   { "__complex__",      RID_COMPLEX,    0 },
3127   { "__const",          RID_CONST,      0 },
3128   { "__const__",        RID_CONST,      0 },
3129   { "__extension__",    RID_EXTENSION,  0 },
3130   { "__func__",         RID_C99_FUNCTION_NAME, 0 },
3131   { "__imag",           RID_IMAGPART,   0 },
3132   { "__imag__",         RID_IMAGPART,   0 },
3133   { "__inline",         RID_INLINE,     0 },
3134   { "__inline__",       RID_INLINE,     0 },
3135   { "__label__",        RID_LABEL,      0 },
3136   { "__ptrbase",        RID_PTRBASE,    0 },
3137   { "__ptrbase__",      RID_PTRBASE,    0 },
3138   { "__ptrextent",      RID_PTREXTENT,  0 },
3139   { "__ptrextent__",    RID_PTREXTENT,  0 },
3140   { "__ptrvalue",       RID_PTRVALUE,   0 },
3141   { "__ptrvalue__",     RID_PTRVALUE,   0 },
3142   { "__real",           RID_REALPART,   0 },
3143   { "__real__",         RID_REALPART,   0 },
3144   { "__restrict",       RID_RESTRICT,   0 },
3145   { "__restrict__",     RID_RESTRICT,   0 },
3146   { "__signed",         RID_SIGNED,     0 },
3147   { "__signed__",       RID_SIGNED,     0 },
3148   { "__thread",         RID_THREAD,     0 },
3149   { "__typeof",         RID_TYPEOF,     0 },
3150   { "__typeof__",       RID_TYPEOF,     0 },
3151   { "__volatile",       RID_VOLATILE,   0 },
3152   { "__volatile__",     RID_VOLATILE,   0 },
3153   { "asm",              RID_ASM,        D_EXT },
3154   { "auto",             RID_AUTO,       0 },
3155   { "break",            RID_BREAK,      0 },
3156   { "case",             RID_CASE,       0 },
3157   { "char",             RID_CHAR,       0 },
3158   { "const",            RID_CONST,      0 },
3159   { "continue",         RID_CONTINUE,   0 },
3160   { "default",          RID_DEFAULT,    0 },
3161   { "do",               RID_DO,         0 },
3162   { "double",           RID_DOUBLE,     0 },
3163   { "else",             RID_ELSE,       0 },
3164   { "enum",             RID_ENUM,       0 },
3165   { "extern",           RID_EXTERN,     0 },
3166   { "float",            RID_FLOAT,      0 },
3167   { "for",              RID_FOR,        0 },
3168   { "goto",             RID_GOTO,       0 },
3169   { "if",               RID_IF,         0 },
3170   { "inline",           RID_INLINE,     D_EXT89 },
3171   { "int",              RID_INT,        0 },
3172   { "long",             RID_LONG,       0 },
3173   { "register",         RID_REGISTER,   0 },
3174   { "restrict",         RID_RESTRICT,   D_C89 },
3175   { "return",           RID_RETURN,     0 },
3176   { "short",            RID_SHORT,      0 },
3177   { "signed",           RID_SIGNED,     0 },
3178   { "sizeof",           RID_SIZEOF,     0 },
3179   { "static",           RID_STATIC,     0 },
3180   { "struct",           RID_STRUCT,     0 },
3181   { "switch",           RID_SWITCH,     0 },
3182   { "typedef",          RID_TYPEDEF,    0 },
3183   { "typeof",           RID_TYPEOF,     D_EXT },
3184   { "union",            RID_UNION,      0 },
3185   { "unsigned",         RID_UNSIGNED,   0 },
3186   { "void",             RID_VOID,       0 },
3187   { "volatile",         RID_VOLATILE,   0 },
3188   { "while",            RID_WHILE,      0 },
3189
3190 @@ifobjc
3191   { "id",               RID_ID,                 D_OBJC },
3192
3193   /* These objc keywords are recognized only immediately after
3194      an '@'.  */
3195   { "class",            RID_AT_CLASS,           D_OBJC },
3196   { "compatibility_alias", RID_AT_ALIAS,        D_OBJC },
3197   { "defs",             RID_AT_DEFS,            D_OBJC },
3198   { "encode",           RID_AT_ENCODE,          D_OBJC },
3199   { "end",              RID_AT_END,             D_OBJC },
3200   { "implementation",   RID_AT_IMPLEMENTATION,  D_OBJC },
3201   { "interface",        RID_AT_INTERFACE,       D_OBJC },
3202   { "private",          RID_AT_PRIVATE,         D_OBJC },
3203   { "protected",        RID_AT_PROTECTED,       D_OBJC },
3204   { "protocol",         RID_AT_PROTOCOL,        D_OBJC },
3205   { "public",           RID_AT_PUBLIC,          D_OBJC },
3206   { "selector",         RID_AT_SELECTOR,        D_OBJC },
3207   { "throw",            RID_AT_THROW,           D_OBJC },
3208   { "try",              RID_AT_TRY,             D_OBJC },
3209   { "catch",            RID_AT_CATCH,           D_OBJC },
3210   { "finally",          RID_AT_FINALLY,         D_OBJC },
3211   { "synchronized",     RID_AT_SYNCHRONIZED,    D_OBJC },
3212   /* These are recognized only in protocol-qualifier context
3213      (see above) */
3214   { "bycopy",           RID_BYCOPY,             D_OBJC },
3215   { "byref",            RID_BYREF,              D_OBJC },
3216   { "in",               RID_IN,                 D_OBJC },
3217   { "inout",            RID_INOUT,              D_OBJC },
3218   { "oneway",           RID_ONEWAY,             D_OBJC },
3219   { "out",              RID_OUT,                D_OBJC },
3220 @@end_ifobjc
3221 };
3222 #define N_reswords (sizeof reswords / sizeof (struct resword))
3223
3224 /* Table mapping from RID_* constants to yacc token numbers.
3225    Unfortunately we have to have entries for all the keywords in all
3226    three languages.  */
3227 static const short rid_to_yy[RID_MAX] =
3228 {
3229   /* RID_STATIC */      STATIC,
3230   /* RID_UNSIGNED */    TYPESPEC,
3231   /* RID_LONG */        TYPESPEC,
3232   /* RID_CONST */       TYPE_QUAL,
3233   /* RID_EXTERN */      SCSPEC,
3234   /* RID_REGISTER */    SCSPEC,
3235   /* RID_TYPEDEF */     SCSPEC,
3236   /* RID_SHORT */       TYPESPEC,
3237   /* RID_INLINE */      SCSPEC,
3238   /* RID_VOLATILE */    TYPE_QUAL,
3239   /* RID_SIGNED */      TYPESPEC,
3240   /* RID_AUTO */        SCSPEC,
3241   /* RID_RESTRICT */    TYPE_QUAL,
3242
3243   /* C extensions */
3244   /* RID_COMPLEX */     TYPESPEC,
3245   /* RID_THREAD */      SCSPEC,
3246
3247   /* C++ */
3248   /* RID_FRIEND */      0,
3249   /* RID_VIRTUAL */     0,
3250   /* RID_EXPLICIT */    0,
3251   /* RID_EXPORT */      0,
3252   /* RID_MUTABLE */     0,
3253
3254   /* ObjC */
3255   /* RID_IN */          OBJC_TYPE_QUAL,
3256   /* RID_OUT */         OBJC_TYPE_QUAL,
3257   /* RID_INOUT */       OBJC_TYPE_QUAL,
3258   /* RID_BYCOPY */      OBJC_TYPE_QUAL,
3259   /* RID_BYREF */       OBJC_TYPE_QUAL,
3260   /* RID_ONEWAY */      OBJC_TYPE_QUAL,
3261
3262   /* C */
3263   /* RID_INT */         TYPESPEC,
3264   /* RID_CHAR */        TYPESPEC,
3265   /* RID_FLOAT */       TYPESPEC,
3266   /* RID_DOUBLE */      TYPESPEC,
3267   /* RID_VOID */        TYPESPEC,
3268   /* RID_ENUM */        ENUM,
3269   /* RID_STRUCT */      STRUCT,
3270   /* RID_UNION */       UNION,
3271   /* RID_IF */          IF,
3272   /* RID_ELSE */        ELSE,
3273   /* RID_WHILE */       WHILE,
3274   /* RID_DO */          DO,
3275   /* RID_FOR */         FOR,
3276   /* RID_SWITCH */      SWITCH,
3277   /* RID_CASE */        CASE,
3278   /* RID_DEFAULT */     DEFAULT,
3279   /* RID_BREAK */       BREAK,
3280   /* RID_CONTINUE */    CONTINUE,
3281   /* RID_RETURN */      RETURN,
3282   /* RID_GOTO */        GOTO,
3283   /* RID_SIZEOF */      SIZEOF,
3284
3285   /* C extensions */
3286   /* RID_ASM */         ASM_KEYWORD,
3287   /* RID_TYPEOF */      TYPEOF,
3288   /* RID_ALIGNOF */     ALIGNOF,
3289   /* RID_ATTRIBUTE */   ATTRIBUTE,
3290   /* RID_VA_ARG */      VA_ARG,
3291   /* RID_EXTENSION */   EXTENSION,
3292   /* RID_IMAGPART */    IMAGPART,
3293   /* RID_REALPART */    REALPART,
3294   /* RID_LABEL */       LABEL,
3295   /* RID_PTRBASE */     PTR_BASE,
3296   /* RID_PTREXTENT */   PTR_EXTENT,
3297   /* RID_PTRVALUE */    PTR_VALUE,
3298
3299   /* RID_CHOOSE_EXPR */                 CHOOSE_EXPR,
3300   /* RID_TYPES_COMPATIBLE_P */          TYPES_COMPATIBLE_P,
3301
3302   /* RID_FUNCTION_NAME */               FUNC_NAME,
3303   /* RID_PRETTY_FUNCTION_NAME */        FUNC_NAME,
3304   /* RID_C99_FUNCTION_NAME */           FUNC_NAME,
3305
3306   /* C++ */
3307   /* RID_BOOL */        TYPESPEC,
3308   /* RID_WCHAR */       0,
3309   /* RID_CLASS */       0,
3310   /* RID_PUBLIC */      0,
3311   /* RID_PRIVATE */     0,
3312   /* RID_PROTECTED */   0,
3313   /* RID_TEMPLATE */    0,
3314   /* RID_NULL */        0,
3315   /* RID_CATCH */       0,
3316   /* RID_DELETE */      0,
3317   /* RID_FALSE */       0,
3318   /* RID_NAMESPACE */   0,
3319   /* RID_NEW */         0,
3320   /* RID_OFFSETOF */    OFFSETOF,
3321   /* RID_OPERATOR */    0,
3322   /* RID_THIS */        0,
3323   /* RID_THROW */       0,
3324   /* RID_TRUE */        0,
3325   /* RID_TRY */         0,
3326   /* RID_TYPENAME */    0,
3327   /* RID_TYPEID */      0,
3328   /* RID_USING */       0,
3329
3330   /* casts */
3331   /* RID_CONSTCAST */   0,
3332   /* RID_DYNCAST */     0,
3333   /* RID_REINTCAST */   0,
3334   /* RID_STATCAST */    0,
3335
3336   /* Objective C */
3337   /* RID_ID */                  OBJECTNAME,
3338   /* RID_AT_ENCODE */           AT_ENCODE,
3339   /* RID_AT_END */              AT_END,
3340   /* RID_AT_CLASS */            AT_CLASS,
3341   /* RID_AT_ALIAS */            AT_ALIAS,
3342   /* RID_AT_DEFS */             AT_DEFS,
3343   /* RID_AT_PRIVATE */          AT_PRIVATE,
3344   /* RID_AT_PROTECTED */        AT_PROTECTED,
3345   /* RID_AT_PUBLIC */           AT_PUBLIC,
3346   /* RID_AT_PROTOCOL */         AT_PROTOCOL,
3347   /* RID_AT_SELECTOR */         AT_SELECTOR,
3348   /* RID_AT_THROW */            AT_THROW,
3349   /* RID_AT_TRY */              AT_TRY,
3350   /* RID_AT_CATCH */            AT_CATCH,
3351   /* RID_AT_FINALLY */          AT_FINALLY,
3352   /* RID_AT_SYNCHRONIZED */     AT_SYNCHRONIZED,
3353   /* RID_AT_INTERFACE */        AT_INTERFACE,
3354   /* RID_AT_IMPLEMENTATION */   AT_IMPLEMENTATION
3355 };
3356
3357 static void
3358 init_reswords (void)
3359 {
3360   unsigned int i;
3361   tree id;
3362   int mask = (flag_isoc99 ? 0 : D_C89)
3363               | (flag_no_asm ? (flag_isoc99 ? D_EXT : D_EXT|D_EXT89) : 0);
3364
3365   if (!c_dialect_objc ())
3366      mask |= D_OBJC;
3367
3368   ridpointers = GGC_CNEWVEC (tree, (int) RID_MAX);
3369   for (i = 0; i < N_reswords; i++)
3370     {
3371       /* If a keyword is disabled, do not enter it into the table
3372          and so create a canonical spelling that isn't a keyword.  */
3373       if (reswords[i].disable & mask)
3374         continue;
3375
3376       id = get_identifier (reswords[i].word);
3377       C_RID_CODE (id) = reswords[i].rid;
3378       C_IS_RESERVED_WORD (id) = 1;
3379       ridpointers [(int) reswords[i].rid] = id;
3380     }
3381 }
3382
3383 #define NAME(type) cpp_type2name (type)
3384
3385 static void
3386 yyerror (const char *msgid)
3387 {
3388   c_parse_error (msgid, last_token, yylval.ttype);
3389 }
3390
3391 static int
3392 yylexname (void)
3393 {
3394   tree decl;
3395
3396 @@ifobjc
3397   int objc_force_identifier = objc_need_raw_identifier;
3398   OBJC_NEED_RAW_IDENTIFIER (0);
3399 @@end_ifobjc
3400
3401   if (C_IS_RESERVED_WORD (yylval.ttype))
3402     {
3403       enum rid rid_code = C_RID_CODE (yylval.ttype);
3404
3405 @@ifobjc
3406       /* Turn non-typedefed refs to "id" into plain identifiers; this
3407          allows constructs like "void foo(id id);" to work.  */
3408       if (rid_code == RID_ID)
3409       {
3410         decl = lookup_name (yylval.ttype);
3411         if (decl == NULL_TREE || TREE_CODE (decl) != TYPE_DECL)
3412           return IDENTIFIER;
3413       }
3414
3415       if (!OBJC_IS_AT_KEYWORD (rid_code)
3416           && (!OBJC_IS_PQ_KEYWORD (rid_code) || objc_pq_context))
3417 @@end_ifobjc
3418       {
3419         /* Return the canonical spelling for this keyword.  */
3420         yylval.ttype = ridpointers[(int) rid_code];
3421         return rid_to_yy[(int) rid_code];
3422       }
3423     }
3424
3425   decl = lookup_name (yylval.ttype);
3426   if (decl)
3427     {
3428       if (TREE_CODE (decl) == TYPE_DECL)
3429         return TYPENAME;
3430     }
3431 @@ifobjc
3432   else
3433     {
3434       tree objc_interface_decl = objc_is_class_name (yylval.ttype);
3435       /* ObjC class names are in the same namespace as variables and
3436          typedefs, and hence are shadowed by local declarations.  */
3437       if (objc_interface_decl
3438           && (global_bindings_p ()
3439               || (!objc_force_identifier && !decl)))
3440         {
3441           yylval.ttype = objc_interface_decl;
3442           return CLASSNAME;
3443         }
3444     }
3445 @@end_ifobjc
3446
3447   return IDENTIFIER;
3448 }
3449
3450 static inline int
3451 _yylex (void)
3452 {
3453  get_next:
3454   last_token = c_lex (&yylval.ttype);
3455   switch (last_token)
3456     {
3457     case CPP_EQ:                                        return '=';
3458     case CPP_NOT:                                       return '!';
3459     case CPP_GREATER:   yylval.code = GT_EXPR;          return ARITHCOMPARE;
3460     case CPP_LESS:      yylval.code = LT_EXPR;          return ARITHCOMPARE;
3461     case CPP_PLUS:      yylval.code = PLUS_EXPR;        return '+';
3462     case CPP_MINUS:     yylval.code = MINUS_EXPR;       return '-';
3463     case CPP_MULT:      yylval.code = MULT_EXPR;        return '*';
3464     case CPP_DIV:       yylval.code = TRUNC_DIV_EXPR;   return '/';
3465     case CPP_MOD:       yylval.code = TRUNC_MOD_EXPR;   return '%';
3466     case CPP_AND:       yylval.code = BIT_AND_EXPR;     return '&';
3467     case CPP_OR:        yylval.code = BIT_IOR_EXPR;     return '|';
3468     case CPP_XOR:       yylval.code = BIT_XOR_EXPR;     return '^';
3469     case CPP_RSHIFT:    yylval.code = RSHIFT_EXPR;      return RSHIFT;
3470     case CPP_LSHIFT:    yylval.code = LSHIFT_EXPR;      return LSHIFT;
3471
3472     case CPP_COMPL:                                     return '~';
3473     case CPP_AND_AND:                                   return ANDAND;
3474     case CPP_OR_OR:                                     return OROR;
3475     case CPP_QUERY:                                     return '?';
3476     case CPP_OPEN_PAREN:                                return '(';
3477     case CPP_EQ_EQ:     yylval.code = EQ_EXPR;          return EQCOMPARE;
3478     case CPP_NOT_EQ:    yylval.code = NE_EXPR;          return EQCOMPARE;
3479     case CPP_GREATER_EQ:yylval.code = GE_EXPR;          return ARITHCOMPARE;
3480     case CPP_LESS_EQ:   yylval.code = LE_EXPR;          return ARITHCOMPARE;
3481
3482     case CPP_PLUS_EQ:   yylval.code = PLUS_EXPR;        return ASSIGN;
3483     case CPP_MINUS_EQ:  yylval.code = MINUS_EXPR;       return ASSIGN;
3484     case CPP_MULT_EQ:   yylval.code = MULT_EXPR;        return ASSIGN;
3485     case CPP_DIV_EQ:    yylval.code = TRUNC_DIV_EXPR;   return ASSIGN;
3486     case CPP_MOD_EQ:    yylval.code = TRUNC_MOD_EXPR;   return ASSIGN;
3487     case CPP_AND_EQ:    yylval.code = BIT_AND_EXPR;     return ASSIGN;
3488     case CPP_OR_EQ:     yylval.code = BIT_IOR_EXPR;     return ASSIGN;
3489     case CPP_XOR_EQ:    yylval.code = BIT_XOR_EXPR;     return ASSIGN;
3490     case CPP_RSHIFT_EQ: yylval.code = RSHIFT_EXPR;      return ASSIGN;
3491     case CPP_LSHIFT_EQ: yylval.code = LSHIFT_EXPR;      return ASSIGN;
3492
3493     case CPP_OPEN_SQUARE:                               return '[';
3494     case CPP_CLOSE_SQUARE:                              return ']';
3495     case CPP_OPEN_BRACE:                                return '{';
3496     case CPP_CLOSE_BRACE:                               return '}';
3497     case CPP_ELLIPSIS:                                  return ELLIPSIS;
3498
3499     case CPP_PLUS_PLUS:                                 return PLUSPLUS;
3500     case CPP_MINUS_MINUS:                               return MINUSMINUS;
3501     case CPP_DEREF:                                     return POINTSAT;
3502     case CPP_DOT:                                       return '.';
3503
3504       /* The following tokens may affect the interpretation of any
3505          identifiers following, if doing Objective-C.  */
3506     case CPP_COLON:             OBJC_NEED_RAW_IDENTIFIER (0);   return ':';
3507     case CPP_COMMA:             OBJC_NEED_RAW_IDENTIFIER (0);   return ',';
3508     case CPP_CLOSE_PAREN:       OBJC_NEED_RAW_IDENTIFIER (0);   return ')';
3509     case CPP_SEMICOLON:         OBJC_NEED_RAW_IDENTIFIER (0);   return ';';
3510
3511     case CPP_EOF:
3512       return 0;
3513
3514     case CPP_NAME:
3515       return yylexname ();
3516
3517     case CPP_AT_NAME:
3518       /* This only happens in Objective-C; it must be a keyword.  */
3519       return rid_to_yy [(int) C_RID_CODE (yylval.ttype)];
3520
3521     case CPP_NUMBER:
3522     case CPP_CHAR:
3523     case CPP_WCHAR:
3524       return CONSTANT;
3525
3526     case CPP_STRING:
3527     case CPP_WSTRING:
3528       return STRING;
3529
3530     case CPP_OBJC_STRING:
3531       return OBJC_STRING;
3532
3533       /* These tokens are C++ specific (and will not be generated
3534          in C mode, but let's be cautious).  */
3535     case CPP_SCOPE:
3536     case CPP_DEREF_STAR:
3537     case CPP_DOT_STAR:
3538     case CPP_MIN_EQ:
3539     case CPP_MAX_EQ:
3540     case CPP_MIN:
3541     case CPP_MAX:
3542       /* These tokens should not survive translation phase 4.  */
3543     case CPP_HASH:
3544     case CPP_PASTE:
3545       error ("syntax error at '%s' token", NAME(last_token));
3546       goto get_next;
3547
3548     default:
3549       abort ();
3550     }
3551   /* NOTREACHED */
3552 }
3553
3554 static int
3555 yylex (void)
3556 {
3557   int r;
3558   timevar_push (TV_LEX);
3559   r = _yylex();
3560   timevar_pop (TV_LEX);
3561   return r;
3562 }
3563
3564 /* Function used when yydebug is set, to print a token in more detail.  */
3565
3566 static void
3567 yyprint (FILE *file, int yychar, YYSTYPE yyl)
3568 {
3569   tree t = yyl.ttype;
3570
3571   fprintf (file, " [%s]", NAME(last_token));
3572
3573   switch (yychar)
3574     {
3575     case IDENTIFIER:
3576     case TYPENAME:
3577     case OBJECTNAME:
3578     case TYPESPEC:
3579     case TYPE_QUAL:
3580     case SCSPEC:
3581     case STATIC:
3582       if (IDENTIFIER_POINTER (t))
3583         fprintf (file, " `%s'", IDENTIFIER_POINTER (t));
3584       break;
3585
3586     case CONSTANT:
3587       fprintf (file, " %s", GET_MODE_NAME (TYPE_MODE (TREE_TYPE (t))));
3588       if (TREE_CODE (t) == INTEGER_CST)
3589         {
3590           fputs (" ", file);
3591           fprintf (file, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
3592                    TREE_INT_CST_HIGH (t), TREE_INT_CST_LOW (t));
3593         }
3594       break;
3595     }
3596 }
3597 \f
3598 /* This is not the ideal place to put this, but we have to get it out
3599    of c-lex.c because cp/lex.c has its own version.  */
3600
3601 /* Parse the file.  */
3602 void
3603 c_parse_file (void)
3604 {
3605   yyparse ();
3606
3607   if (malloced_yyss)
3608     {
3609       free (malloced_yyss);
3610       free (malloced_yyvs);
3611       malloced_yyss = 0;
3612     }
3613 }
3614
3615 #include "gt-c-parse.h"