OSDN Git Service

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