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.
5 This file is part of GCC.
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
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
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
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. */
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. */
32 %expect 13 /* shift/reduce conflicts, and no reduce/reduce conflicts. */
38 #include "coretypes.h"
41 #include "langhooks.h"
46 #include "c-pragma.h" /* For YYDEBUG definition, and parse_in. */
55 /* Like YYERROR but do call yyerror. */
56 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
58 /* Like the default stack expander, except (1) use realloc when possible,
59 (2) impose no hard maxiumum on stack size, (3) REALLY do not use alloca.
61 Irritatingly, YYSTYPE is defined after this %{ %} block, so we cannot
62 give malloced_yyvs its proper type. This is ok since all we need from
63 it is to be able to free it. */
65 static short *malloced_yyss;
66 static void *malloced_yyvs;
68 #define yyoverflow(MSG, SS, SSSIZE, VS, VSSIZE, YYSSZ) \
73 newsize = *(YYSSZ) *= 2; \
76 newss = really_call_realloc (*(SS), newsize * sizeof (short)); \
77 newvs = really_call_realloc (*(VS), newsize * sizeof (YYSTYPE)); \
81 newss = really_call_malloc (newsize * sizeof (short)); \
82 newvs = really_call_malloc (newsize * sizeof (YYSTYPE)); \
84 memcpy (newss, *(SS), (SSSIZE)); \
86 memcpy (newvs, *(VS), (VSSIZE)); \
88 if (!newss || !newvs) \
95 malloced_yyss = newss; \
96 malloced_yyvs = (void *) newvs; \
102 %union {long itype; tree ttype; void *otype; struct c_expr exprtype;
103 struct c_arg_info *arginfotype; struct c_declarator *dtrtype;
104 struct c_type_name *typenametype; struct c_parm *parmtype;
105 struct c_declspecs *dsptype; enum tree_code code;
106 location_t location; }
108 /* All identifiers that are not reserved words
109 and are not declared typedefs in the current block */
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. */
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. */
122 /* Reserved words that specify type.
123 yylval contains an IDENTIFIER_NODE which indicates which one. */
126 /* Reserved words that qualify type: "const", "volatile", or "restrict".
127 yylval contains an IDENTIFIER_NODE which indicates which one. */
130 /* Objective-C protocol qualifiers. These acquire their magic powers
131 only in certain contexts. */
132 %token OBJC_TYPE_QUAL
134 /* Character or numeric constants.
135 yylval is the node for the constant. */
138 /* String constants in raw form.
139 yylval is a STRING_CST node. */
143 /* "...", used for functions with variable arglists. */
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
155 /* Add precedence rules to solve dangling else s/r conflict */
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. */
163 %right <code> ASSIGN '='
164 %right <code> '?' ':'
170 %left <code> EQCOMPARE
171 %left <code> ARITHCOMPARE
172 %left <code> LSHIFT RSHIFT
174 %left <code> '*' '/' '%'
175 %right <code> UNARY PLUSPLUS MINUSMINUS
177 %left <code> POINTSAT '.' '(' '['
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
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
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 <dsptype> declspecs_nosc_nots_nosa_noea declspecs_nosc_nots_nosa_ea
195 %type <dsptype> declspecs_nosc_nots_sa_noea declspecs_nosc_nots_sa_ea
196 %type <dsptype> declspecs_nosc_ts_nosa_noea declspecs_nosc_ts_nosa_ea
197 %type <dsptype> declspecs_nosc_ts_sa_noea declspecs_nosc_ts_sa_ea
198 %type <dsptype> declspecs_sc_nots_nosa_noea declspecs_sc_nots_nosa_ea
199 %type <dsptype> declspecs_sc_nots_sa_noea declspecs_sc_nots_sa_ea
200 %type <dsptype> declspecs_sc_ts_nosa_noea declspecs_sc_ts_nosa_ea
201 %type <dsptype> declspecs_sc_ts_sa_noea declspecs_sc_ts_sa_ea
202 %type <dsptype> declspecs_ts declspecs_nots
203 %type <dsptype> declspecs_ts_nosa declspecs_nots_nosa
204 %type <dsptype> declspecs_nosc_ts declspecs_nosc_nots declspecs_nosc declspecs
205 %type <dsptype> maybe_type_quals_attrs
206 %type <ttype> typespec_nonattr typespec_attr
207 %type <ttype> typespec_reserved_nonattr typespec_reserved_attr
208 %type <ttype> typespec_nonreserved_nonattr
209 %type <ttype> offsetof_member_designator
211 %type <ttype> scspec SCSPEC STATIC TYPESPEC TYPE_QUAL maybe_volatile
212 %type <ttype> initdecls notype_initdecls initdcl notype_initdcl
213 %type <exprtype> init
214 %type <ttype> simple_asm_expr maybeasm asm_stmt asm_argument
215 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
216 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
217 %type <ttype> any_word
219 %type <ttype> compstmt compstmt_start compstmt_primary_start
220 %type <ttype> stmt label stmt_nocomp start_break start_continue
222 %type <ttype> c99_block_start c99_block_lineno_labeled_stmt
223 %type <ttype> if_statement_1 if_statement_2
224 %type <dtrtype> declarator
225 %type <dtrtype> notype_declarator after_type_declarator
226 %type <dtrtype> parm_declarator
227 %type <dtrtype> parm_declarator_starttypename parm_declarator_nostarttypename
228 %type <dtrtype> array_declarator
230 %type <ttype> structsp_attr structsp_nonattr
231 %type <ttype> component_decl_list component_decl_list2
232 %type <ttype> component_decl components components_notype component_declarator
233 %type <ttype> component_notype_declarator
234 %type <ttype> enumlist enumerator
235 %type <ttype> struct_head union_head enum_head
236 %type <typenametype> typename
237 %type <dtrtype> absdcl absdcl1 absdcl1_ea absdcl1_noea direct_absdcl1
238 %type <parmtype> absdcl_maybe_attribute
239 %type <ttype> condition xexpr for_cond_expr for_incr_expr
240 %type <parmtype> parm firstparm
241 %type <ttype> identifiers
243 %type <arginfotype> parms parmlist parmlist_1 parmlist_2
244 %type <arginfotype> parmlist_or_identifiers parmlist_or_identifiers_1
245 %type <ttype> identifiers_or_typenames
247 %type <itype> setspecs setspecs_fp extension
249 %type <location> save_location
251 %type <otype> save_obstack_position
254 /* the Objective-C nonterminals */
256 %type <ttype> methoddecl unaryselector keywordselector selector
257 %type <code> methodtype
258 %type <ttype> keyworddecl receiver objcmessageexpr messageargs
259 %type <ttype> keywordexpr keywordarglist keywordarg
260 %type <ttype> optparmlist optparms reservedwords objcselectorexpr
261 %type <ttype> selectorarg keywordnamelist keywordname objcencodeexpr
262 %type <ttype> non_empty_protocolrefs protocolrefs identifier_list objcprotocolexpr
264 %type <ttype> CLASSNAME OBJECTNAME OBJC_STRING OBJC_TYPE_QUAL
266 %type <ttype> superclass objc_quals objc_qual objc_typename
267 %type <itype> objc_try_catch_stmt optellipsis
271 /* Declaration specifiers of the current declaration. */
272 static struct c_declspecs *current_declspecs;
273 static GTY(()) tree prefix_attributes;
275 /* List of all the attributes applying to the identifier currently being
276 declared; includes prefix_attributes and possibly some more attributes
277 just after a comma. */
278 static GTY(()) tree all_prefix_attributes;
280 /* Structure to save declaration specifiers. */
281 struct c_declspec_stack {
282 /* Saved value of current_declspecs. */
283 struct c_declspecs *current_declspecs;
284 /* Saved value of prefix_attributes. */
285 tree prefix_attributes;
286 /* Saved value of all_prefix_attributes. */
287 tree all_prefix_attributes;
288 /* Next level of stack. */
289 struct c_declspec_stack *next;
292 /* Stack of saved values of current_declspecs, prefix_attributes and
293 all_prefix_attributes. */
294 static struct c_declspec_stack *declspec_stack;
296 /* INDIRECT_REF with a TREE_TYPE of the type being queried for offsetof. */
297 static tree offsetof_base;
299 /* PUSH_DECLSPEC_STACK is called from setspecs; POP_DECLSPEC_STACK
300 should be called from the productions making use of setspecs. */
301 #define PUSH_DECLSPEC_STACK \
303 struct c_declspec_stack *t = XOBNEW (&parser_obstack, \
304 struct c_declspec_stack); \
305 t->current_declspecs = current_declspecs; \
306 t->prefix_attributes = prefix_attributes; \
307 t->all_prefix_attributes = all_prefix_attributes; \
308 t->next = declspec_stack; \
309 declspec_stack = t; \
312 #define POP_DECLSPEC_STACK \
314 current_declspecs = declspec_stack->current_declspecs; \
315 prefix_attributes = declspec_stack->prefix_attributes; \
316 all_prefix_attributes = declspec_stack->all_prefix_attributes; \
317 declspec_stack = declspec_stack->next; \
320 /* For __extension__, save/restore the warning flags which are
321 controlled by __extension__. */
322 #define SAVE_EXT_FLAGS() \
324 | (warn_pointer_arith << 1) \
325 | (warn_traditional << 2) \
328 #define RESTORE_EXT_FLAGS(val) \
330 pedantic = val & 1; \
331 warn_pointer_arith = (val >> 1) & 1; \
332 warn_traditional = (val >> 2) & 1; \
333 flag_iso = (val >> 3) & 1; \
337 /* Objective-C specific parser/lexer information */
339 static int objc_pq_context = 0;
341 /* The following flag is needed to contextualize ObjC lexical analysis.
342 In some cases (e.g., 'int NSObject;'), it is undesirable to bind
343 an identifier to an ObjC class, even if a class with that name
345 static int objc_need_raw_identifier;
346 #define OBJC_NEED_RAW_IDENTIFIER(VAL) objc_need_raw_identifier = VAL
350 #define OBJC_NEED_RAW_IDENTIFIER(VAL) /* nothing */
353 /* Tell yyparse how to print a token's value, if yydebug is set. */
355 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
357 static void yyprint (FILE *, int, YYSTYPE);
358 static void yyerror (const char *);
359 static int yylexname (void);
360 static inline int _yylex (void);
361 static int yylex (void);
362 static void init_reswords (void);
364 /* Initialization routine for this file. */
376 pedwarn ("ISO C forbids an empty source file");
381 /* the reason for the strange actions in this rule
382 is so that notype_initdecls when reached via datadef
383 can find valid declaration specifiers in $0. */
386 save_obstack_position { $<dsptype>$ = NULL; } extdef
387 { obstack_free (&parser_obstack, $1); }
388 | extdefs save_obstack_position
389 { $<dsptype>$ = NULL; ggc_collect (); } extdef
390 { obstack_free (&parser_obstack, $2); }
398 { RESTORE_EXT_FLAGS ($1); }
404 /* Record the current position of parser_obstack before a
405 declaration to restore it afterwards. */
406 save_obstack_position:
407 { $$ = obstack_alloc (&parser_obstack, 0); }
411 setspecs notype_initdecls ';'
413 error ("ISO C forbids data definition with no type or storage class");
415 warning ("data definition has no type or storage class");
417 POP_DECLSPEC_STACK; }
418 | declspecs_nots setspecs notype_initdecls ';'
419 { POP_DECLSPEC_STACK; }
420 | declspecs_ts setspecs initdecls ';'
421 { POP_DECLSPEC_STACK; }
423 { shadow_tag (finish_declspecs ($1)); }
428 pedwarn ("ISO C does not allow extra %<;%> outside of a function"); }
432 declspecs_ts setspecs declarator
433 { if (!start_function (current_declspecs, $3,
434 all_prefix_attributes))
437 old_style_parm_decls save_location
438 { DECL_SOURCE_LOCATION (current_function_decl) = $6;
439 store_parm_decls (); }
441 { finish_function ();
442 POP_DECLSPEC_STACK; }
443 | declspecs_ts setspecs declarator error
444 { POP_DECLSPEC_STACK; }
445 | declspecs_nots setspecs notype_declarator
446 { if (!start_function (current_declspecs, $3,
447 all_prefix_attributes))
450 old_style_parm_decls save_location
451 { DECL_SOURCE_LOCATION (current_function_decl) = $6;
452 store_parm_decls (); }
454 { finish_function ();
455 POP_DECLSPEC_STACK; }
456 | declspecs_nots setspecs notype_declarator error
457 { POP_DECLSPEC_STACK; }
458 | setspecs notype_declarator
459 { if (!start_function (current_declspecs, $2,
460 all_prefix_attributes))
463 old_style_parm_decls save_location
464 { DECL_SOURCE_LOCATION (current_function_decl) = $5;
465 store_parm_decls (); }
467 { finish_function ();
468 POP_DECLSPEC_STACK; }
469 | setspecs notype_declarator error
470 { POP_DECLSPEC_STACK; }
485 { $$ = NEGATE_EXPR; }
489 if (warn_traditional && !in_system_header)
490 warning ("traditional C rejects the unary plus operator");
494 { $$ = PREINCREMENT_EXPR; }
496 { $$ = PREDECREMENT_EXPR; }
498 { $$ = BIT_NOT_EXPR; }
500 { $$ = TRUTH_NOT_EXPR; }
504 | expr ',' expr_no_commas
505 { $$.value = build_compound_expr ($1.value, $3.value);
506 $$.original_code = COMPOUND_EXPR; }
517 { $$ = build_tree_list (NULL_TREE, $1.value); }
518 | nonnull_exprlist ',' expr_no_commas
519 { chainon ($1, build_tree_list (NULL_TREE, $3.value)); }
524 | '*' cast_expr %prec UNARY
525 { $$.value = build_indirect_ref ($2.value, "unary *");
526 $$.original_code = ERROR_MARK; }
527 /* __extension__ turns off -pedantic for following primary. */
528 | extension cast_expr %prec UNARY
530 RESTORE_EXT_FLAGS ($1); }
531 | unop cast_expr %prec UNARY
532 { $$.value = build_unary_op ($1, $2.value, 0);
533 overflow_warning ($$.value);
534 $$.original_code = ERROR_MARK; }
535 /* Refer to the address of a label as a pointer. */
537 { $$.value = finish_label_address_expr ($2);
538 $$.original_code = ERROR_MARK; }
539 | sizeof unary_expr %prec UNARY
542 if (TREE_CODE ($2.value) == COMPONENT_REF
543 && DECL_C_BIT_FIELD (TREE_OPERAND ($2.value, 1)))
544 error ("%<sizeof%> applied to a bit-field");
545 $$ = c_expr_sizeof_expr ($2); }
546 | sizeof '(' typename ')' %prec HYPERUNARY
549 $$ = c_expr_sizeof_type ($3); }
550 | alignof unary_expr %prec UNARY
553 $$.value = c_alignof_expr ($2.value);
554 $$.original_code = ERROR_MARK; }
555 | alignof '(' typename ')' %prec HYPERUNARY
558 $$.value = c_alignof (groktypename ($3));
559 $$.original_code = ERROR_MARK; }
560 | REALPART cast_expr %prec UNARY
561 { $$.value = build_unary_op (REALPART_EXPR, $2.value, 0);
562 $$.original_code = ERROR_MARK; }
563 | IMAGPART cast_expr %prec UNARY
564 { $$.value = build_unary_op (IMAGPART_EXPR, $2.value, 0);
565 $$.original_code = ERROR_MARK; }
569 SIZEOF { skip_evaluation++; in_sizeof++; }
573 ALIGNOF { skip_evaluation++; in_alignof++; }
577 TYPEOF { skip_evaluation++; in_typeof++; }
582 | '(' typename ')' cast_expr %prec UNARY
583 { $$.value = c_cast_expr ($2, $4.value);
584 $$.original_code = ERROR_MARK; }
589 | expr_no_commas '+' expr_no_commas
590 { $$ = parser_build_binary_op ($2, $1, $3); }
591 | expr_no_commas '-' expr_no_commas
592 { $$ = parser_build_binary_op ($2, $1, $3); }
593 | expr_no_commas '*' expr_no_commas
594 { $$ = parser_build_binary_op ($2, $1, $3); }
595 | expr_no_commas '/' expr_no_commas
596 { $$ = parser_build_binary_op ($2, $1, $3); }
597 | expr_no_commas '%' expr_no_commas
598 { $$ = parser_build_binary_op ($2, $1, $3); }
599 | expr_no_commas LSHIFT expr_no_commas
600 { $$ = parser_build_binary_op ($2, $1, $3); }
601 | expr_no_commas RSHIFT expr_no_commas
602 { $$ = parser_build_binary_op ($2, $1, $3); }
603 | expr_no_commas ARITHCOMPARE expr_no_commas
604 { $$ = parser_build_binary_op ($2, $1, $3); }
605 | expr_no_commas EQCOMPARE expr_no_commas
606 { $$ = parser_build_binary_op ($2, $1, $3); }
607 | expr_no_commas '&' expr_no_commas
608 { $$ = parser_build_binary_op ($2, $1, $3); }
609 | expr_no_commas '|' expr_no_commas
610 { $$ = parser_build_binary_op ($2, $1, $3); }
611 | expr_no_commas '^' expr_no_commas
612 { $$ = parser_build_binary_op ($2, $1, $3); }
613 | expr_no_commas ANDAND
614 { $1.value = lang_hooks.truthvalue_conversion
615 (default_conversion ($1.value));
616 skip_evaluation += $1.value == truthvalue_false_node; }
618 { skip_evaluation -= $1.value == truthvalue_false_node;
619 $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $4); }
620 | expr_no_commas OROR
621 { $1.value = lang_hooks.truthvalue_conversion
622 (default_conversion ($1.value));
623 skip_evaluation += $1.value == truthvalue_true_node; }
625 { skip_evaluation -= $1.value == truthvalue_true_node;
626 $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $4); }
628 { $1.value = lang_hooks.truthvalue_conversion
629 (default_conversion ($1.value));
630 skip_evaluation += $1.value == truthvalue_false_node; }
632 { skip_evaluation += (($1.value == truthvalue_true_node)
633 - ($1.value == truthvalue_false_node)); }
635 { skip_evaluation -= $1.value == truthvalue_true_node;
636 $$.value = build_conditional_expr ($1.value, $4.value,
638 $$.original_code = ERROR_MARK; }
641 pedwarn ("ISO C forbids omitting the middle term of a ?: expression");
642 /* Make sure first operand is calculated only once. */
643 $<ttype>2 = save_expr (default_conversion ($1.value));
644 $1.value = lang_hooks.truthvalue_conversion ($<ttype>2);
645 skip_evaluation += $1.value == truthvalue_true_node; }
647 { skip_evaluation -= $1.value == truthvalue_true_node;
648 $$.value = build_conditional_expr ($1.value, $<ttype>2,
650 $$.original_code = ERROR_MARK; }
651 | expr_no_commas '=' expr_no_commas
652 { $$.value = build_modify_expr ($1.value, NOP_EXPR, $3.value);
653 $$.original_code = MODIFY_EXPR;
655 | expr_no_commas ASSIGN expr_no_commas
656 { $$.value = build_modify_expr ($1.value, $2, $3.value);
657 TREE_NO_WARNING ($$.value) = 1;
658 $$.original_code = ERROR_MARK;
665 if (yychar == YYEMPTY)
667 $$.value = build_external_ref ($1, yychar == '(');
668 $$.original_code = ERROR_MARK;
671 { $$.value = $1; $$.original_code = ERROR_MARK; }
673 { $$.value = $1; $$.original_code = STRING_CST; }
675 { $$.value = fname_decl (C_RID_CODE ($1), $1);
676 $$.original_code = ERROR_MARK; }
677 | '(' typename ')' '{'
678 { start_init (NULL_TREE, NULL, 0);
679 $<ttype>$ = groktypename ($2);
680 if (C_TYPE_VARIABLE_SIZE ($<ttype>$))
682 error ("compound literal has variable size");
683 $<ttype>$ = error_mark_node;
685 really_start_incremental_init ($<ttype>$); }
686 initlist_maybe_comma '}' %prec UNARY
687 { struct c_expr init = pop_init_level (0);
688 tree constructor = init.value;
689 tree type = $<ttype>5;
691 maybe_warn_string_init (type, init);
693 if (pedantic && !flag_isoc99)
694 pedwarn ("ISO C90 forbids compound literals");
695 $$.value = build_compound_literal (type, constructor);
696 $$.original_code = ERROR_MARK;
699 { $$.value = $2.value;
700 if (TREE_CODE ($$.value) == MODIFY_EXPR)
701 TREE_NO_WARNING ($$.value) = 1;
702 $$.original_code = ERROR_MARK; }
704 { $$.value = error_mark_node; $$.original_code = ERROR_MARK; }
705 | compstmt_primary_start compstmt_nostart ')'
707 pedwarn ("ISO C forbids braced-groups within expressions");
708 $$.value = c_finish_stmt_expr ($1);
709 $$.original_code = ERROR_MARK;
711 | compstmt_primary_start error ')'
712 { c_finish_stmt_expr ($1);
713 $$.value = error_mark_node;
714 $$.original_code = ERROR_MARK;
716 | primary '(' exprlist ')' %prec '.'
717 { $$.value = build_function_call ($1.value, $3);
718 $$.original_code = ERROR_MARK; }
719 | VA_ARG '(' expr_no_commas ',' typename ')'
720 { $$.value = build_va_arg ($3.value, groktypename ($5));
721 $$.original_code = ERROR_MARK; }
723 | OFFSETOF '(' typename ','
724 { tree type = groktypename ($3);
725 if (type == error_mark_node)
726 offsetof_base = error_mark_node;
728 offsetof_base = build1 (INDIRECT_REF, type, NULL);
730 offsetof_member_designator ')'
731 { $$.value = fold_offsetof ($6);
732 $$.original_code = ERROR_MARK; }
733 | OFFSETOF '(' error ')'
734 { $$.value = error_mark_node; $$.original_code = ERROR_MARK; }
735 | CHOOSE_EXPR '(' expr_no_commas ',' expr_no_commas ','
742 if (TREE_CODE (c) != INTEGER_CST)
743 error ("first argument to __builtin_choose_expr not"
745 $$ = integer_zerop (c) ? $7 : $5;
747 | CHOOSE_EXPR '(' error ')'
748 { $$.value = error_mark_node; $$.original_code = ERROR_MARK; }
749 | TYPES_COMPATIBLE_P '(' typename ',' typename ')'
753 e1 = TYPE_MAIN_VARIANT (groktypename ($3));
754 e2 = TYPE_MAIN_VARIANT (groktypename ($5));
756 $$.value = comptypes (e1, e2)
757 ? build_int_cst (NULL_TREE, 1)
758 : build_int_cst (NULL_TREE, 0);
759 $$.original_code = ERROR_MARK;
761 | TYPES_COMPATIBLE_P '(' error ')'
762 { $$.value = error_mark_node; $$.original_code = ERROR_MARK; }
763 | primary '[' expr ']' %prec '.'
764 { $$.value = build_array_ref ($1.value, $3.value);
765 $$.original_code = ERROR_MARK; }
766 | primary '.' identifier
767 { $$.value = build_component_ref ($1.value, $3);
768 $$.original_code = ERROR_MARK; }
769 | primary POINTSAT identifier
771 tree expr = build_indirect_ref ($1.value, "->");
772 $$.value = build_component_ref (expr, $3);
773 $$.original_code = ERROR_MARK;
776 { $$.value = build_unary_op (POSTINCREMENT_EXPR, $1.value, 0);
777 $$.original_code = ERROR_MARK; }
779 { $$.value = build_unary_op (POSTDECREMENT_EXPR, $1.value, 0);
780 $$.original_code = ERROR_MARK; }
783 { $$.value = objc_build_message_expr ($1);
784 $$.original_code = ERROR_MARK; }
786 { $$.value = objc_build_selector_expr ($1);
787 $$.original_code = ERROR_MARK; }
789 { $$.value = objc_build_protocol_expr ($1);
790 $$.original_code = ERROR_MARK; }
792 { $$.value = objc_build_encode_expr ($1);
793 $$.original_code = ERROR_MARK; }
795 { $$.value = objc_build_string_object ($1);
796 $$.original_code = ERROR_MARK; }
800 /* This is the second argument to __builtin_offsetof. We must have one
801 identifier, and beyond that we want to accept sub structure and sub
804 offsetof_member_designator:
806 { $$ = build_component_ref (offsetof_base, $1); }
807 | offsetof_member_designator '.' identifier
808 { $$ = build_component_ref ($1, $3); }
809 | offsetof_member_designator '[' expr ']'
810 { $$ = build_array_ref ($1, $3.value); }
813 old_style_parm_decls:
818 /* The following are analogous to lineno_decl, decls and decl
819 except that they do not allow nested functions.
820 They are used for old-style parm decls. */
822 save_location datadecl
829 | datadecls lineno_datadecl
830 | lineno_datadecl errstmt
833 /* We don't allow prefix attributes here because they cause reduce/reduce
834 conflicts: we can't know whether we're parsing a function decl with
835 attribute suffix, or function defn with attribute prefix on first old
838 declspecs_ts_nosa setspecs initdecls ';'
839 { POP_DECLSPEC_STACK; }
840 | declspecs_nots_nosa setspecs notype_initdecls ';'
841 { POP_DECLSPEC_STACK; }
842 | declspecs_ts_nosa ';'
843 { shadow_tag_warned (finish_declspecs ($1), 1);
844 pedwarn ("empty declaration"); }
845 | declspecs_nots_nosa ';'
846 { pedwarn ("empty declaration"); }
849 /* This combination which saves a lineno before a decl
850 is the normal thing to use, rather than decl itself.
851 This is to avoid shift/reduce conflicts in contexts
852 where statement labels are allowed. */
858 /* records the type and storage class specs to use for processing
859 the declarators that follow.
860 Maintains a stack of outer-level values of current_declspecs,
861 for the sake of parm declarations nested in function declarators. */
862 setspecs: /* empty */
863 { pending_xref_error ();
867 prefix_attributes = $<dsptype>0->attrs;
868 $<dsptype>0->attrs = NULL_TREE;
869 current_declspecs = $<dsptype>0;
873 prefix_attributes = NULL_TREE;
874 current_declspecs = build_null_declspecs ();
876 current_declspecs = finish_declspecs (current_declspecs);
877 all_prefix_attributes = prefix_attributes; }
880 /* Possibly attributes after a comma, which should reset all_prefix_attributes
881 to prefix_attributes with these ones chained on the front. */
884 { all_prefix_attributes = chainon ($1, prefix_attributes); }
888 declspecs_ts setspecs initdecls ';'
889 { POP_DECLSPEC_STACK; }
890 | declspecs_nots setspecs notype_initdecls ';'
891 { POP_DECLSPEC_STACK; }
892 | declspecs_ts setspecs nested_function
893 { POP_DECLSPEC_STACK; }
894 | declspecs_nots setspecs notype_nested_function
895 { POP_DECLSPEC_STACK; }
897 { shadow_tag (finish_declspecs ($1)); }
899 { RESTORE_EXT_FLAGS ($1); }
902 /* A list of declaration specifiers. These are:
904 - Storage class specifiers (scspec), which for GCC currently includes
905 function specifiers ("inline").
907 - Type specifiers (typespec_*).
909 - Type qualifiers (TYPE_QUAL).
911 - Attribute specifier lists (attributes).
913 The various cases below are classified according to:
915 (a) Whether a storage class specifier is included or not; some
916 places in the grammar disallow storage class specifiers (_sc or _nosc).
918 (b) Whether a type specifier has been seen; after a type specifier,
919 a typedef name is an identifier to redeclare (_ts or _nots).
921 (c) Whether the list starts with an attribute; in certain places,
922 the grammar requires specifiers that don't start with an attribute
925 (d) Whether the list ends with an attribute (or a specifier such that
926 any following attribute would have been parsed as part of that specifier);
927 this avoids shift-reduce conflicts in the parsing of attributes
932 (i) Distinguish between function specifiers and storage class specifiers,
933 at least for the purpose of warnings about obsolescent usage.
935 (ii) Halve the number of productions here by eliminating the _sc/_nosc
936 distinction and instead checking where required that storage class
937 specifiers aren't present. */
939 /* Declspecs which contain at least one type specifier or typedef name.
940 (Just `const' or `volatile' is not enough.)
941 A typedef'd name following these is taken as a name to be declared. */
943 declspecs_nosc_nots_nosa_noea:
945 { $$ = declspecs_add_qual (build_null_declspecs (), $1); }
946 | declspecs_nosc_nots_nosa_noea TYPE_QUAL
947 { $$ = declspecs_add_qual ($1, $2); }
948 | declspecs_nosc_nots_nosa_ea TYPE_QUAL
949 { $$ = declspecs_add_qual ($1, $2); }
952 declspecs_nosc_nots_nosa_ea:
953 declspecs_nosc_nots_nosa_noea attributes
954 { $$ = declspecs_add_attrs ($1, $2); }
957 declspecs_nosc_nots_sa_noea:
958 declspecs_nosc_nots_sa_noea TYPE_QUAL
959 { $$ = declspecs_add_qual ($1, $2); }
960 | declspecs_nosc_nots_sa_ea TYPE_QUAL
961 { $$ = declspecs_add_qual ($1, $2); }
964 declspecs_nosc_nots_sa_ea:
966 { $$ = declspecs_add_attrs (build_null_declspecs (), $1); }
967 | declspecs_nosc_nots_sa_noea attributes
968 { $$ = declspecs_add_attrs ($1, $2); }
971 declspecs_nosc_ts_nosa_noea:
973 { $$ = declspecs_add_type (build_null_declspecs (), $1); }
974 | declspecs_nosc_ts_nosa_noea TYPE_QUAL
975 { $$ = declspecs_add_qual ($1, $2); }
976 | declspecs_nosc_ts_nosa_ea TYPE_QUAL
977 { $$ = declspecs_add_qual ($1, $2); }
978 | declspecs_nosc_ts_nosa_noea typespec_reserved_nonattr
979 { $$ = declspecs_add_type ($1, $2); }
980 | declspecs_nosc_ts_nosa_ea typespec_reserved_nonattr
981 { $$ = declspecs_add_type ($1, $2); }
982 | declspecs_nosc_nots_nosa_noea typespec_nonattr
983 { $$ = declspecs_add_type ($1, $2); }
984 | declspecs_nosc_nots_nosa_ea typespec_nonattr
985 { $$ = declspecs_add_type ($1, $2); }
988 declspecs_nosc_ts_nosa_ea:
990 { $$ = declspecs_add_type (build_null_declspecs (), $1); }
991 | declspecs_nosc_ts_nosa_noea attributes
992 { $$ = declspecs_add_attrs ($1, $2); }
993 | declspecs_nosc_ts_nosa_noea typespec_reserved_attr
994 { $$ = declspecs_add_type ($1, $2); }
995 | declspecs_nosc_ts_nosa_ea typespec_reserved_attr
996 { $$ = declspecs_add_type ($1, $2); }
997 | declspecs_nosc_nots_nosa_noea typespec_attr
998 { $$ = declspecs_add_type ($1, $2); }
999 | declspecs_nosc_nots_nosa_ea typespec_attr
1000 { $$ = declspecs_add_type ($1, $2); }
1003 declspecs_nosc_ts_sa_noea:
1004 declspecs_nosc_ts_sa_noea TYPE_QUAL
1005 { $$ = declspecs_add_qual ($1, $2); }
1006 | declspecs_nosc_ts_sa_ea TYPE_QUAL
1007 { $$ = declspecs_add_qual ($1, $2); }
1008 | declspecs_nosc_ts_sa_noea typespec_reserved_nonattr
1009 { $$ = declspecs_add_type ($1, $2); }
1010 | declspecs_nosc_ts_sa_ea typespec_reserved_nonattr
1011 { $$ = declspecs_add_type ($1, $2); }
1012 | declspecs_nosc_nots_sa_noea typespec_nonattr
1013 { $$ = declspecs_add_type ($1, $2); }
1014 | declspecs_nosc_nots_sa_ea typespec_nonattr
1015 { $$ = declspecs_add_type ($1, $2); }
1018 declspecs_nosc_ts_sa_ea:
1019 declspecs_nosc_ts_sa_noea attributes
1020 { $$ = declspecs_add_attrs ($1, $2); }
1021 | declspecs_nosc_ts_sa_noea typespec_reserved_attr
1022 { $$ = declspecs_add_type ($1, $2); }
1023 | declspecs_nosc_ts_sa_ea typespec_reserved_attr
1024 { $$ = declspecs_add_type ($1, $2); }
1025 | declspecs_nosc_nots_sa_noea typespec_attr
1026 { $$ = declspecs_add_type ($1, $2); }
1027 | declspecs_nosc_nots_sa_ea typespec_attr
1028 { $$ = declspecs_add_type ($1, $2); }
1031 declspecs_sc_nots_nosa_noea:
1033 { $$ = declspecs_add_scspec (build_null_declspecs (), $1); }
1034 | declspecs_sc_nots_nosa_noea TYPE_QUAL
1035 { $$ = declspecs_add_qual ($1, $2); }
1036 | declspecs_sc_nots_nosa_ea TYPE_QUAL
1037 { $$ = declspecs_add_qual ($1, $2); }
1038 | declspecs_nosc_nots_nosa_noea scspec
1039 { $$ = declspecs_add_scspec ($1, $2); }
1040 | declspecs_nosc_nots_nosa_ea scspec
1041 { $$ = declspecs_add_scspec ($1, $2); }
1042 | declspecs_sc_nots_nosa_noea scspec
1043 { $$ = declspecs_add_scspec ($1, $2); }
1044 | declspecs_sc_nots_nosa_ea scspec
1045 { $$ = declspecs_add_scspec ($1, $2); }
1048 declspecs_sc_nots_nosa_ea:
1049 declspecs_sc_nots_nosa_noea attributes
1050 { $$ = declspecs_add_attrs ($1, $2); }
1053 declspecs_sc_nots_sa_noea:
1054 declspecs_sc_nots_sa_noea TYPE_QUAL
1055 { $$ = declspecs_add_qual ($1, $2); }
1056 | declspecs_sc_nots_sa_ea TYPE_QUAL
1057 { $$ = declspecs_add_qual ($1, $2); }
1058 | declspecs_nosc_nots_sa_noea scspec
1059 { $$ = declspecs_add_scspec ($1, $2); }
1060 | declspecs_nosc_nots_sa_ea scspec
1061 { $$ = declspecs_add_scspec ($1, $2); }
1062 | declspecs_sc_nots_sa_noea scspec
1063 { $$ = declspecs_add_scspec ($1, $2); }
1064 | declspecs_sc_nots_sa_ea scspec
1065 { $$ = declspecs_add_scspec ($1, $2); }
1068 declspecs_sc_nots_sa_ea:
1069 declspecs_sc_nots_sa_noea attributes
1070 { $$ = declspecs_add_attrs ($1, $2); }
1073 declspecs_sc_ts_nosa_noea:
1074 declspecs_sc_ts_nosa_noea TYPE_QUAL
1075 { $$ = declspecs_add_qual ($1, $2); }
1076 | declspecs_sc_ts_nosa_ea TYPE_QUAL
1077 { $$ = declspecs_add_qual ($1, $2); }
1078 | declspecs_sc_ts_nosa_noea typespec_reserved_nonattr
1079 { $$ = declspecs_add_type ($1, $2); }
1080 | declspecs_sc_ts_nosa_ea typespec_reserved_nonattr
1081 { $$ = declspecs_add_type ($1, $2); }
1082 | declspecs_sc_nots_nosa_noea typespec_nonattr
1083 { $$ = declspecs_add_type ($1, $2); }
1084 | declspecs_sc_nots_nosa_ea typespec_nonattr
1085 { $$ = declspecs_add_type ($1, $2); }
1086 | declspecs_nosc_ts_nosa_noea scspec
1087 { $$ = declspecs_add_scspec ($1, $2); }
1088 | declspecs_nosc_ts_nosa_ea scspec
1089 { $$ = declspecs_add_scspec ($1, $2); }
1090 | declspecs_sc_ts_nosa_noea scspec
1091 { $$ = declspecs_add_scspec ($1, $2); }
1092 | declspecs_sc_ts_nosa_ea scspec
1093 { $$ = declspecs_add_scspec ($1, $2); }
1096 declspecs_sc_ts_nosa_ea:
1097 declspecs_sc_ts_nosa_noea attributes
1098 { $$ = declspecs_add_attrs ($1, $2); }
1099 | declspecs_sc_ts_nosa_noea typespec_reserved_attr
1100 { $$ = declspecs_add_type ($1, $2); }
1101 | declspecs_sc_ts_nosa_ea typespec_reserved_attr
1102 { $$ = declspecs_add_type ($1, $2); }
1103 | declspecs_sc_nots_nosa_noea typespec_attr
1104 { $$ = declspecs_add_type ($1, $2); }
1105 | declspecs_sc_nots_nosa_ea typespec_attr
1106 { $$ = declspecs_add_type ($1, $2); }
1109 declspecs_sc_ts_sa_noea:
1110 declspecs_sc_ts_sa_noea TYPE_QUAL
1111 { $$ = declspecs_add_qual ($1, $2); }
1112 | declspecs_sc_ts_sa_ea TYPE_QUAL
1113 { $$ = declspecs_add_qual ($1, $2); }
1114 | declspecs_sc_ts_sa_noea typespec_reserved_nonattr
1115 { $$ = declspecs_add_type ($1, $2); }
1116 | declspecs_sc_ts_sa_ea typespec_reserved_nonattr
1117 { $$ = declspecs_add_type ($1, $2); }
1118 | declspecs_sc_nots_sa_noea typespec_nonattr
1119 { $$ = declspecs_add_type ($1, $2); }
1120 | declspecs_sc_nots_sa_ea typespec_nonattr
1121 { $$ = declspecs_add_type ($1, $2); }
1122 | declspecs_nosc_ts_sa_noea scspec
1123 { $$ = declspecs_add_scspec ($1, $2); }
1124 | declspecs_nosc_ts_sa_ea scspec
1125 { $$ = declspecs_add_scspec ($1, $2); }
1126 | declspecs_sc_ts_sa_noea scspec
1127 { $$ = declspecs_add_scspec ($1, $2); }
1128 | declspecs_sc_ts_sa_ea scspec
1129 { $$ = declspecs_add_scspec ($1, $2); }
1132 declspecs_sc_ts_sa_ea:
1133 declspecs_sc_ts_sa_noea attributes
1134 { $$ = declspecs_add_attrs ($1, $2); }
1135 | declspecs_sc_ts_sa_noea typespec_reserved_attr
1136 { $$ = declspecs_add_type ($1, $2); }
1137 | declspecs_sc_ts_sa_ea typespec_reserved_attr
1138 { $$ = declspecs_add_type ($1, $2); }
1139 | declspecs_sc_nots_sa_noea typespec_attr
1140 { $$ = declspecs_add_type ($1, $2); }
1141 | declspecs_sc_nots_sa_ea typespec_attr
1142 { $$ = declspecs_add_type ($1, $2); }
1145 /* Particular useful classes of declspecs. */
1147 declspecs_nosc_ts_nosa_noea
1148 | declspecs_nosc_ts_nosa_ea
1149 | declspecs_nosc_ts_sa_noea
1150 | declspecs_nosc_ts_sa_ea
1151 | declspecs_sc_ts_nosa_noea
1152 | declspecs_sc_ts_nosa_ea
1153 | declspecs_sc_ts_sa_noea
1154 | declspecs_sc_ts_sa_ea
1158 declspecs_nosc_nots_nosa_noea
1159 | declspecs_nosc_nots_nosa_ea
1160 | declspecs_nosc_nots_sa_noea
1161 | declspecs_nosc_nots_sa_ea
1162 | declspecs_sc_nots_nosa_noea
1163 | declspecs_sc_nots_nosa_ea
1164 | declspecs_sc_nots_sa_noea
1165 | declspecs_sc_nots_sa_ea
1169 declspecs_nosc_ts_nosa_noea
1170 | declspecs_nosc_ts_nosa_ea
1171 | declspecs_sc_ts_nosa_noea
1172 | declspecs_sc_ts_nosa_ea
1175 declspecs_nots_nosa:
1176 declspecs_nosc_nots_nosa_noea
1177 | declspecs_nosc_nots_nosa_ea
1178 | declspecs_sc_nots_nosa_noea
1179 | declspecs_sc_nots_nosa_ea
1183 declspecs_nosc_ts_nosa_noea
1184 | declspecs_nosc_ts_nosa_ea
1185 | declspecs_nosc_ts_sa_noea
1186 | declspecs_nosc_ts_sa_ea
1189 declspecs_nosc_nots:
1190 declspecs_nosc_nots_nosa_noea
1191 | declspecs_nosc_nots_nosa_ea
1192 | declspecs_nosc_nots_sa_noea
1193 | declspecs_nosc_nots_sa_ea
1197 declspecs_nosc_ts_nosa_noea
1198 | declspecs_nosc_ts_nosa_ea
1199 | declspecs_nosc_ts_sa_noea
1200 | declspecs_nosc_ts_sa_ea
1201 | declspecs_nosc_nots_nosa_noea
1202 | declspecs_nosc_nots_nosa_ea
1203 | declspecs_nosc_nots_sa_noea
1204 | declspecs_nosc_nots_sa_ea
1208 declspecs_nosc_nots_nosa_noea
1209 | declspecs_nosc_nots_nosa_ea
1210 | declspecs_nosc_nots_sa_noea
1211 | declspecs_nosc_nots_sa_ea
1212 | declspecs_nosc_ts_nosa_noea
1213 | declspecs_nosc_ts_nosa_ea
1214 | declspecs_nosc_ts_sa_noea
1215 | declspecs_nosc_ts_sa_ea
1216 | declspecs_sc_nots_nosa_noea
1217 | declspecs_sc_nots_nosa_ea
1218 | declspecs_sc_nots_sa_noea
1219 | declspecs_sc_nots_sa_ea
1220 | declspecs_sc_ts_nosa_noea
1221 | declspecs_sc_ts_nosa_ea
1222 | declspecs_sc_ts_sa_noea
1223 | declspecs_sc_ts_sa_ea
1226 /* A (possibly empty) sequence of type qualifiers and attributes. */
1227 maybe_type_quals_attrs:
1230 | declspecs_nosc_nots
1234 /* A type specifier (but not a type qualifier).
1235 Once we have seen one of these in a declaration,
1236 if a typedef name appears then it is being redeclared.
1238 The _reserved versions start with a reserved word and may appear anywhere
1239 in the declaration specifiers; the _nonreserved versions may only
1240 appear before any other type specifiers, and after that are (if names)
1243 FIXME: should the _nonreserved version be restricted to names being
1244 redeclared only? The other entries there relate only the GNU extensions
1245 and Objective C, and are historically parsed thus, and don't make sense
1246 after other type specifiers, but it might be cleaner to count them as
1249 _attr means: specifiers that either end with attributes,
1250 or are such that any following attributes would
1251 be parsed as part of the specifier.
1253 _nonattr: other specifiers not ending with attributes. */
1256 typespec_reserved_nonattr
1257 | typespec_nonreserved_nonattr
1261 typespec_reserved_attr
1264 typespec_reserved_nonattr:
1266 { OBJC_NEED_RAW_IDENTIFIER (1); }
1270 typespec_reserved_attr:
1274 typespec_nonreserved_nonattr:
1276 { /* For a typedef name, record the meaning, not the name.
1277 In case of `foo foo, bar;'. */
1278 $$ = lookup_name ($1); }
1280 | CLASSNAME protocolrefs
1281 { $$ = objc_get_protocol_qualified_type ($1, $2); }
1282 | OBJECTNAME protocolrefs
1283 { $$ = objc_get_protocol_qualified_type ($1, $2); }
1285 /* Make "<SomeProtocol>" equivalent to "id <SomeProtocol>"
1286 - nisse@lysator.liu.se */
1287 | non_empty_protocolrefs
1288 { $$ = objc_get_protocol_qualified_type (NULL_TREE, $1); }
1290 | typeof '(' expr ')'
1291 { skip_evaluation--;
1293 if (TREE_CODE ($3.value) == COMPONENT_REF
1294 && DECL_C_BIT_FIELD (TREE_OPERAND ($3.value, 1)))
1295 error ("%<typeof%> applied to a bit-field");
1296 $$ = TREE_TYPE ($3.value);
1297 pop_maybe_used (variably_modified_type_p ($$, NULL_TREE)); }
1298 | typeof '(' typename ')'
1299 { skip_evaluation--; in_typeof--; $$ = groktypename ($3);
1300 pop_maybe_used (variably_modified_type_p ($$, NULL_TREE)); }
1303 /* typespec_nonreserved_attr does not exist. */
1307 | initdecls ',' maybe_resetattrs initdcl
1312 | notype_initdecls ',' maybe_resetattrs notype_initdcl
1316 declarator maybeasm maybe_attribute '='
1317 { $<ttype>$ = start_decl ($1, current_declspecs, true,
1318 chainon ($3, all_prefix_attributes));
1319 start_init ($<ttype>$, $2, global_bindings_p ()); }
1321 /* Note how the declaration of the variable is in effect while its init is parsed! */
1323 maybe_warn_string_init (TREE_TYPE ($<ttype>5), $6);
1324 finish_decl ($<ttype>5, $6.value, $2); }
1325 | declarator maybeasm maybe_attribute
1326 { tree d = start_decl ($1, current_declspecs, false,
1327 chainon ($3, all_prefix_attributes));
1328 finish_decl (d, NULL_TREE, $2);
1333 notype_declarator maybeasm maybe_attribute '='
1334 { $<ttype>$ = start_decl ($1, current_declspecs, true,
1335 chainon ($3, all_prefix_attributes));
1336 start_init ($<ttype>$, $2, global_bindings_p ()); }
1338 /* Note how the declaration of the variable is in effect while its init is parsed! */
1340 maybe_warn_string_init (TREE_TYPE ($<ttype>5), $6);
1341 finish_decl ($<ttype>5, $6.value, $2); }
1342 | notype_declarator maybeasm maybe_attribute
1343 { tree d = start_decl ($1, current_declspecs, false,
1344 chainon ($3, all_prefix_attributes));
1345 finish_decl (d, NULL_TREE, $2); }
1347 /* the * rules are dummies to accept the Apollo extended syntax
1348 so that the header files compile. */
1359 | attributes attribute
1360 { $$ = chainon ($1, $2); }
1364 ATTRIBUTE stop_string_translation
1365 '(' '(' attribute_list ')' ')' start_string_translation
1367 | ATTRIBUTE error start_string_translation
1374 | attribute_list ',' attrib
1375 { $$ = chainon ($1, $3); }
1382 { $$ = build_tree_list ($1, NULL_TREE); }
1383 | any_word '(' IDENTIFIER ')'
1384 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1385 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1386 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1387 | any_word '(' exprlist ')'
1388 { $$ = build_tree_list ($1, $3); }
1391 /* This still leaves out most reserved keywords,
1392 shouldn't we include them? */
1406 /* Initializers. `init' is the entry point. */
1412 { really_start_incremental_init (NULL_TREE); }
1413 initlist_maybe_comma '}'
1414 { $$ = pop_init_level (0); }
1416 { $$.value = error_mark_node; $$.original_code = ERROR_MARK; }
1419 /* `initlist_maybe_comma' is the guts of an initializer in braces. */
1420 initlist_maybe_comma:
1423 pedwarn ("ISO C forbids empty initializer braces"); }
1424 | initlist1 maybecomma
1429 | initlist1 ',' initelt
1432 /* `initelt' is a single element of an initializer.
1433 It may use braces. */
1435 designator_list '=' initval
1436 { if (pedantic && !flag_isoc99)
1437 pedwarn ("ISO C90 forbids specifying subobject to initialize"); }
1438 | designator initval
1440 pedwarn ("obsolete use of designated initializer without %<=%>"); }
1442 { set_init_label ($1);
1444 pedwarn ("obsolete use of designated initializer with %<:%>"); }
1452 { push_init_level (0); }
1453 initlist_maybe_comma '}'
1454 { process_init_element (pop_init_level (0)); }
1456 { process_init_element ($1); }
1462 | designator_list designator
1467 { set_init_label ($2); }
1468 | '[' expr_no_commas ELLIPSIS expr_no_commas ']'
1469 { set_init_index ($2.value, $4.value);
1471 pedwarn ("ISO C forbids specifying range of elements to initialize"); }
1472 | '[' expr_no_commas ']'
1473 { set_init_index ($2.value, NULL_TREE); }
1479 pedwarn ("ISO C forbids nested functions");
1481 push_function_context ();
1482 if (!start_function (current_declspecs, $1,
1483 all_prefix_attributes))
1485 pop_function_context ();
1489 old_style_parm_decls save_location
1490 { tree decl = current_function_decl;
1491 DECL_SOURCE_LOCATION (decl) = $4;
1492 store_parm_decls (); }
1493 /* This used to use compstmt_or_error. That caused a bug with
1494 input `f(g) int g {}', where the use of YYERROR1 above caused
1495 an error which then was handled by compstmt_or_error. There
1496 followed a repeated execution of that same rule, which called
1497 YYERROR1 again, and so on. */
1499 { tree decl = current_function_decl;
1502 pop_function_context ();
1503 add_stmt (build_stmt (DECL_EXPR, decl)); }
1506 notype_nested_function:
1509 pedwarn ("ISO C forbids nested functions");
1511 push_function_context ();
1512 if (!start_function (current_declspecs, $1,
1513 all_prefix_attributes))
1515 pop_function_context ();
1519 old_style_parm_decls save_location
1520 { tree decl = current_function_decl;
1521 DECL_SOURCE_LOCATION (decl) = $4;
1522 store_parm_decls (); }
1523 /* This used to use compstmt_or_error. That caused a bug with
1524 input `f(g) int g {}', where the use of YYERROR1 above caused
1525 an error which then was handled by compstmt_or_error. There
1526 followed a repeated execution of that same rule, which called
1527 YYERROR1 again, and so on. */
1529 { tree decl = current_function_decl;
1532 pop_function_context ();
1533 add_stmt (build_stmt (DECL_EXPR, decl)); }
1536 /* Any kind of declarator (thus, all declarators allowed
1537 after an explicit typespec). */
1540 after_type_declarator
1544 /* A declarator that is allowed only after an explicit typespec. */
1546 after_type_declarator:
1547 '(' maybe_attribute after_type_declarator ')'
1548 { $$ = $2 ? build_attrs_declarator ($2, $3) : $3; }
1549 | after_type_declarator '(' parmlist_or_identifiers %prec '.'
1550 { $$ = build_function_declarator ($3, $1); }
1551 | after_type_declarator array_declarator %prec '.'
1552 { $$ = set_array_declarator_inner ($2, $1, false); }
1553 | '*' maybe_type_quals_attrs after_type_declarator %prec UNARY
1554 { $$ = make_pointer_declarator ($2, $3); }
1556 { $$ = build_id_declarator ($1); }
1559 { $$ = build_id_declarator ($1); }
1563 /* Kinds of declarator that can appear in a parameter list
1564 in addition to notype_declarator. This is like after_type_declarator
1565 but does not allow a typedef name in parentheses as an identifier
1566 (because it would conflict with a function with that typedef as arg). */
1568 parm_declarator_starttypename
1569 | parm_declarator_nostarttypename
1572 parm_declarator_starttypename:
1573 parm_declarator_starttypename '(' parmlist_or_identifiers %prec '.'
1574 { $$ = build_function_declarator ($3, $1); }
1575 | parm_declarator_starttypename array_declarator %prec '.'
1576 { $$ = set_array_declarator_inner ($2, $1, false); }
1578 { $$ = build_id_declarator ($1); }
1581 { $$ = build_id_declarator ($1); }
1585 parm_declarator_nostarttypename:
1586 parm_declarator_nostarttypename '(' parmlist_or_identifiers %prec '.'
1587 { $$ = build_function_declarator ($3, $1); }
1588 | parm_declarator_nostarttypename array_declarator %prec '.'
1589 { $$ = set_array_declarator_inner ($2, $1, false); }
1590 | '*' maybe_type_quals_attrs parm_declarator_starttypename %prec UNARY
1591 { $$ = make_pointer_declarator ($2, $3); }
1592 | '*' maybe_type_quals_attrs parm_declarator_nostarttypename %prec UNARY
1593 { $$ = make_pointer_declarator ($2, $3); }
1594 | '(' maybe_attribute parm_declarator_nostarttypename ')'
1595 { $$ = $2 ? build_attrs_declarator ($2, $3) : $3; }
1598 /* A declarator allowed whether or not there has been
1599 an explicit typespec. These cannot redeclare a typedef-name. */
1602 notype_declarator '(' parmlist_or_identifiers %prec '.'
1603 { $$ = build_function_declarator ($3, $1); }
1604 | '(' maybe_attribute notype_declarator ')'
1605 { $$ = $2 ? build_attrs_declarator ($2, $3) : $3; }
1606 | '*' maybe_type_quals_attrs notype_declarator %prec UNARY
1607 { $$ = make_pointer_declarator ($2, $3); }
1608 | notype_declarator array_declarator %prec '.'
1609 { $$ = set_array_declarator_inner ($2, $1, false); }
1611 { $$ = build_id_declarator ($1); }
1635 /* structsp_attr: struct/union/enum specifiers that either
1636 end with attributes, or are such that any following attributes would
1637 be parsed as part of the struct/union/enum specifier.
1639 structsp_nonattr: other struct/union/enum specifiers. */
1642 struct_head identifier '{'
1643 { $$ = start_struct (RECORD_TYPE, $2);
1644 /* Start scope of tag before parsing components. */
1646 component_decl_list '}' maybe_attribute
1647 { $$ = finish_struct ($<ttype>4, nreverse ($5),
1648 chainon ($1, $7)); }
1649 | struct_head '{' component_decl_list '}' maybe_attribute
1650 { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
1651 nreverse ($3), chainon ($1, $5));
1653 | union_head identifier '{'
1654 { $$ = start_struct (UNION_TYPE, $2); }
1655 component_decl_list '}' maybe_attribute
1656 { $$ = finish_struct ($<ttype>4, nreverse ($5),
1657 chainon ($1, $7)); }
1658 | union_head '{' component_decl_list '}' maybe_attribute
1659 { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
1660 nreverse ($3), chainon ($1, $5));
1662 | enum_head identifier '{'
1663 { $$ = start_enum ($2); }
1664 enumlist maybecomma_warn '}' maybe_attribute
1665 { $$ = finish_enum ($<ttype>4, nreverse ($5),
1666 chainon ($1, $8)); }
1668 { $$ = start_enum (NULL_TREE); }
1669 enumlist maybecomma_warn '}' maybe_attribute
1670 { $$ = finish_enum ($<ttype>3, nreverse ($4),
1671 chainon ($1, $7)); }
1675 struct_head identifier
1676 { $$ = xref_tag (RECORD_TYPE, $2); }
1677 | union_head identifier
1678 { $$ = xref_tag (UNION_TYPE, $2); }
1679 | enum_head identifier
1680 { $$ = xref_tag (ENUMERAL_TYPE, $2);
1681 /* In ISO C, enumerated types can be referred to
1682 only if already defined. */
1683 if (pedantic && !COMPLETE_TYPE_P ($$))
1684 pedwarn ("ISO C forbids forward references to %<enum%> types"); }
1695 { if (pedantic && !flag_isoc99)
1696 pedwarn ("comma at end of enumerator list"); }
1699 /* We chain the components in reverse order. They are put in forward
1700 order in structsp_attr.
1702 Note that component_declarator returns single decls, so components
1703 and components_notype can use TREE_CHAIN directly, wheras components
1704 and components_notype return lists (of comma separated decls), so
1705 component_decl_list and component_decl_list2 must use chainon.
1707 The theory behind all this is that there will be more semicolon
1708 separated fields than comma separated fields, and so we'll be
1709 minimizing the number of node traversals required by chainon. */
1711 component_decl_list:
1712 component_decl_list2
1714 | component_decl_list2 component_decl
1715 { $$ = chainon ($2, $1);
1716 pedwarn ("no semicolon at end of struct or union"); }
1719 component_decl_list2: /* empty */
1721 | component_decl_list2 component_decl ';'
1722 { $$ = chainon ($2, $1); }
1723 | component_decl_list2 ';'
1725 pedwarn ("extra semicolon in struct or union specified"); }
1727 /* foo(sizeof(struct{ @defs(ClassName)})); */
1728 | AT_DEFS '(' CLASSNAME ')'
1729 { $$ = nreverse (objc_get_class_ivars ($3)); }
1734 declspecs_nosc_ts setspecs components
1736 POP_DECLSPEC_STACK; }
1737 | declspecs_nosc_ts setspecs
1739 /* Support for unnamed structs or unions as members of
1740 structs or unions (which is [a] useful and [b] supports
1743 pedwarn ("ISO C doesn't support unnamed structs/unions");
1745 $$ = grokfield (build_id_declarator (NULL_TREE),
1746 current_declspecs, NULL_TREE);
1747 POP_DECLSPEC_STACK; }
1748 | declspecs_nosc_nots setspecs components_notype
1750 POP_DECLSPEC_STACK; }
1751 | declspecs_nosc_nots
1753 pedwarn ("ISO C forbids member declarations with no members");
1754 shadow_tag_warned (finish_declspecs ($1), pedantic);
1758 | extension component_decl
1760 RESTORE_EXT_FLAGS ($1); }
1764 component_declarator
1765 | components ',' maybe_resetattrs component_declarator
1766 { TREE_CHAIN ($4) = $1; $$ = $4; }
1770 component_notype_declarator
1771 | components_notype ',' maybe_resetattrs component_notype_declarator
1772 { TREE_CHAIN ($4) = $1; $$ = $4; }
1775 component_declarator:
1776 declarator maybe_attribute
1777 { $$ = grokfield ($1, current_declspecs, NULL_TREE);
1778 decl_attributes (&$$,
1779 chainon ($2, all_prefix_attributes), 0); }
1780 | declarator ':' expr_no_commas maybe_attribute
1781 { $$ = grokfield ($1, current_declspecs, $3.value);
1782 decl_attributes (&$$,
1783 chainon ($4, all_prefix_attributes), 0); }
1784 | ':' expr_no_commas maybe_attribute
1785 { $$ = grokfield (build_id_declarator (NULL_TREE),
1786 current_declspecs, $2.value);
1787 decl_attributes (&$$,
1788 chainon ($3, all_prefix_attributes), 0); }
1791 component_notype_declarator:
1792 notype_declarator maybe_attribute
1793 { $$ = grokfield ($1, current_declspecs, NULL_TREE);
1794 decl_attributes (&$$,
1795 chainon ($2, all_prefix_attributes), 0); }
1796 | notype_declarator ':' expr_no_commas maybe_attribute
1797 { $$ = grokfield ($1, current_declspecs, $3.value);
1798 decl_attributes (&$$,
1799 chainon ($4, all_prefix_attributes), 0); }
1800 | ':' expr_no_commas maybe_attribute
1801 { $$ = grokfield (build_id_declarator (NULL_TREE),
1802 current_declspecs, $2.value);
1803 decl_attributes (&$$,
1804 chainon ($3, all_prefix_attributes), 0); }
1807 /* We chain the enumerators in reverse order.
1808 They are put in forward order in structsp_attr. */
1812 | enumlist ',' enumerator
1813 { if ($1 == error_mark_node)
1816 TREE_CHAIN ($3) = $1, $$ = $3; }
1818 { $$ = error_mark_node; }
1824 { $$ = build_enumerator ($1, NULL_TREE); }
1825 | identifier '=' expr_no_commas
1826 { $$ = build_enumerator ($1, $3.value); }
1831 { pending_xref_error ();
1832 $<dsptype>$ = finish_declspecs ($1); }
1834 { $$ = XOBNEW (&parser_obstack, struct c_type_name);
1835 $$->specs = $<dsptype>2;
1836 $$->declarator = $3; }
1839 absdcl: /* an absolute declarator */
1841 { $$ = build_id_declarator (NULL_TREE); }
1845 absdcl_maybe_attribute: /* absdcl maybe_attribute, but not just attributes */
1847 { $$ = build_c_parm (current_declspecs, all_prefix_attributes,
1848 build_id_declarator (NULL_TREE)); }
1850 { $$ = build_c_parm (current_declspecs, all_prefix_attributes,
1852 | absdcl1_noea attributes
1853 { $$ = build_c_parm (current_declspecs,
1854 chainon ($2, all_prefix_attributes),
1858 absdcl1: /* a nonempty absolute declarator */
1865 | '*' maybe_type_quals_attrs absdcl1_noea
1866 { $$ = make_pointer_declarator ($2, $3); }
1870 '*' maybe_type_quals_attrs
1871 { $$ = make_pointer_declarator
1872 ($2, build_id_declarator (NULL_TREE)); }
1873 | '*' maybe_type_quals_attrs absdcl1_ea
1874 { $$ = make_pointer_declarator ($2, $3); }
1878 '(' maybe_attribute absdcl1 ')'
1879 { $$ = $2 ? build_attrs_declarator ($2, $3) : $3; }
1880 | direct_absdcl1 '(' parmlist
1881 { $$ = build_function_declarator ($3, $1); }
1882 | direct_absdcl1 array_declarator
1883 { $$ = set_array_declarator_inner ($2, $1, true); }
1885 { $$ = build_function_declarator
1886 ($2, build_id_declarator (NULL_TREE)); }
1888 { $$ = set_array_declarator_inner
1889 ($1, build_id_declarator (NULL_TREE), true); }
1892 /* The [...] part of a declarator for an array type. */
1895 '[' maybe_type_quals_attrs expr_no_commas ']'
1896 { $$ = build_array_declarator ($3.value, $2, false, false); }
1897 | '[' maybe_type_quals_attrs ']'
1898 { $$ = build_array_declarator (NULL_TREE, $2, false, false); }
1899 | '[' maybe_type_quals_attrs '*' ']'
1900 { $$ = build_array_declarator (NULL_TREE, $2, false, true); }
1901 | '[' STATIC maybe_type_quals_attrs expr_no_commas ']'
1902 { $$ = build_array_declarator ($4.value, $3, true, false); }
1903 /* declspecs_nosc_nots is a synonym for type_quals_attrs. */
1904 | '[' declspecs_nosc_nots STATIC expr_no_commas ']'
1905 { $$ = build_array_declarator ($4.value, $2, true, false); }
1908 /* A nonempty series of declarations and statements (possibly followed by
1909 some labels) that can form the body of a compound statement.
1910 NOTE: we don't allow labels on declarations; this might seem like a
1911 natural extension, but there would be a conflict between attributes
1912 on the label and prefix attributes on the declaration. */
1915 lineno_stmt_decl_or_labels_ending_stmt
1916 | lineno_stmt_decl_or_labels_ending_decl
1917 | lineno_stmt_decl_or_labels_ending_label
1919 error ("label at end of compound statement");
1921 | lineno_stmt_decl_or_labels_ending_error
1924 lineno_stmt_decl_or_labels_ending_stmt:
1926 | lineno_stmt_decl_or_labels_ending_stmt lineno_stmt
1927 | lineno_stmt_decl_or_labels_ending_decl lineno_stmt
1928 | lineno_stmt_decl_or_labels_ending_label lineno_stmt
1929 | lineno_stmt_decl_or_labels_ending_error lineno_stmt
1932 lineno_stmt_decl_or_labels_ending_decl:
1934 | lineno_stmt_decl_or_labels_ending_stmt lineno_decl
1936 if ((pedantic && !flag_isoc99)
1937 || warn_declaration_after_statement)
1938 pedwarn_c90 ("ISO C90 forbids mixed declarations and code");
1940 | lineno_stmt_decl_or_labels_ending_decl lineno_decl
1941 | lineno_stmt_decl_or_labels_ending_error lineno_decl
1944 lineno_stmt_decl_or_labels_ending_label:
1946 | lineno_stmt_decl_or_labels_ending_stmt lineno_label
1947 | lineno_stmt_decl_or_labels_ending_decl lineno_label
1948 | lineno_stmt_decl_or_labels_ending_label lineno_label
1949 | lineno_stmt_decl_or_labels_ending_error lineno_label
1952 lineno_stmt_decl_or_labels_ending_error:
1954 | lineno_stmt_decl_or_labels errstmt
1957 lineno_stmt_decl_or_labels:
1958 lineno_stmt_decl_or_labels_ending_stmt
1959 | lineno_stmt_decl_or_labels_ending_decl
1960 | lineno_stmt_decl_or_labels_ending_label
1961 | lineno_stmt_decl_or_labels_ending_error
1967 /* Start and end blocks created for the new scopes of C99. */
1968 c99_block_start: /* empty */
1969 { $$ = c_begin_compound_stmt (flag_isoc99); }
1972 /* Read zero or more forward-declarations for labels
1973 that nested functions can jump to. */
1978 pedwarn ("ISO C forbids label declarations"); }
1983 | label_decls label_decl
1987 LABEL identifiers_or_typenames ';'
1989 for (link = $2; link; link = TREE_CHAIN (link))
1991 tree label = declare_label (TREE_VALUE (link));
1992 C_DECLARED_LABEL_FLAG (label) = 1;
1993 add_stmt (build_stmt (DECL_EXPR, label));
1998 /* This is the body of a function definition.
1999 It causes syntax errors to ignore to the next openbrace. */
2006 compstmt_start: '{' { $$ = c_begin_compound_stmt (true); }
2009 compstmt_nostart: '}'
2010 | maybe_label_decls compstmt_contents_nonempty '}'
2013 compstmt_contents_nonempty:
2018 compstmt_primary_start:
2020 { if (current_function_decl == 0)
2022 error ("braced-group within expression allowed "
2023 "only inside a function");
2026 $$ = c_begin_stmt_expr ();
2030 compstmt: compstmt_start compstmt_nostart
2031 { $$ = c_end_compound_stmt ($1, true); }
2034 /* The forced readahead in here is because we might be at the end of a
2035 line, and the line and file won't be bumped until yylex absorbs the
2036 first token on the next line. */
2039 { if (yychar == YYEMPTY)
2041 $$ = input_location; }
2046 | lineno_labels lineno_label
2049 /* A labeled statement. In C99 it also generates an implicit block. */
2050 c99_block_lineno_labeled_stmt:
2051 c99_block_start lineno_labels lineno_stmt
2052 { $$ = c_end_compound_stmt ($1, flag_isoc99); }
2058 /* Two cases cannot and do not have line numbers associated:
2059 If stmt is degenerate, such as "2;", then stmt is an
2060 INTEGER_CST, which cannot hold line numbers. But that's
2061 ok because the statement will either be changed to a
2062 MODIFY_EXPR during gimplification of the statement expr,
2063 or discarded. If stmt was compound, but without new
2064 variables, we will have skipped the creation of a BIND
2065 and will have a bare STATEMENT_LIST. But that's ok
2066 because (recursively) all of the component statments
2067 should already have line numbers assigned. */
2068 if ($2 && EXPR_P ($2))
2069 SET_EXPR_LOCATION ($2, $1);
2075 { if ($2) SET_EXPR_LOCATION ($2, $1); }
2078 condition: save_location expr
2079 { $$ = lang_hooks.truthvalue_conversion ($2.value);
2081 SET_EXPR_LOCATION ($$, $1); }
2084 /* Implement -Wparenthesis by special casing IF statement directly nested
2085 within IF statement. This requires some amount of duplication of the
2086 productions under c99_block_lineno_labeled_stmt in order to work out.
2087 But it's still likely more maintainable than lots of state outside the
2091 c99_block_start lineno_labels if_statement
2092 { $$ = c_end_compound_stmt ($1, flag_isoc99); }
2096 c99_block_start lineno_labels ';'
2097 { if (extra_warnings)
2098 add_stmt (build (NOP_EXPR, NULL_TREE, NULL_TREE));
2099 $$ = c_end_compound_stmt ($1, flag_isoc99); }
2100 | c99_block_lineno_labeled_stmt
2104 IF c99_block_start save_location '(' condition ')'
2105 if_statement_1 ELSE if_statement_2
2106 { c_finish_if_stmt ($3, $5, $7, $9, true);
2107 add_stmt (c_end_compound_stmt ($2, flag_isoc99)); }
2108 | IF c99_block_start save_location '(' condition ')'
2109 if_statement_2 ELSE if_statement_2
2110 { c_finish_if_stmt ($3, $5, $7, $9, false);
2111 add_stmt (c_end_compound_stmt ($2, flag_isoc99)); }
2112 | IF c99_block_start save_location '(' condition ')'
2113 if_statement_1 %prec IF
2114 { c_finish_if_stmt ($3, $5, $7, NULL, true);
2115 add_stmt (c_end_compound_stmt ($2, flag_isoc99)); }
2116 | IF c99_block_start save_location '(' condition ')'
2117 if_statement_2 %prec IF
2118 { c_finish_if_stmt ($3, $5, $7, NULL, false);
2119 add_stmt (c_end_compound_stmt ($2, flag_isoc99)); }
2122 start_break: /* empty */
2123 { $$ = c_break_label; c_break_label = NULL; }
2126 start_continue: /* empty */
2127 { $$ = c_cont_label; c_cont_label = NULL; }
2131 WHILE c99_block_start save_location '(' condition ')'
2132 start_break start_continue c99_block_lineno_labeled_stmt
2133 { c_finish_loop ($3, $5, NULL, $9, c_break_label,
2134 c_cont_label, true);
2135 add_stmt (c_end_compound_stmt ($2, flag_isoc99));
2136 c_break_label = $7; c_cont_label = $8; }
2140 DO c99_block_start save_location start_break start_continue
2141 c99_block_lineno_labeled_stmt WHILE
2142 { $<ttype>$ = c_break_label; c_break_label = $4; }
2143 { $<ttype>$ = c_cont_label; c_cont_label = $5; }
2144 '(' condition ')' ';'
2145 { c_finish_loop ($3, $11, NULL, $6, $<ttype>8,
2147 add_stmt (c_end_compound_stmt ($2, flag_isoc99)); }
2159 { c_finish_expr_stmt ($1); }
2161 { check_for_loop_decls (); }
2164 for_cond_expr: save_location xexpr
2167 $$ = lang_hooks.truthvalue_conversion ($2);
2169 SET_EXPR_LOCATION ($$, $1);
2176 for_incr_expr: xexpr
2177 { $$ = c_process_expr_stmt ($1); }
2181 FOR c99_block_start '(' for_init_stmt
2182 save_location for_cond_expr ';' for_incr_expr ')'
2183 start_break start_continue c99_block_lineno_labeled_stmt
2184 { c_finish_loop ($5, $6, $8, $12, c_break_label,
2185 c_cont_label, true);
2186 add_stmt (c_end_compound_stmt ($2, flag_isoc99));
2187 c_break_label = $10; c_cont_label = $11; }
2191 SWITCH c99_block_start '(' expr ')'
2192 { $<ttype>$ = c_start_case ($4.value); }
2193 start_break c99_block_lineno_labeled_stmt
2194 { c_finish_case ($8);
2196 add_stmt (build (LABEL_EXPR, void_type_node,
2199 add_stmt (c_end_compound_stmt ($2, flag_isoc99)); }
2202 /* Parse a single real statement, not including any labels or compounds. */
2205 { $$ = c_finish_expr_stmt ($1.value); }
2217 { $$ = c_finish_bc_stmt (&c_break_label, true); }
2219 { $$ = c_finish_bc_stmt (&c_cont_label, false); }
2221 { $$ = c_finish_return (NULL_TREE); }
2223 { $$ = c_finish_return ($2.value); }
2225 | GOTO identifier ';'
2226 { $$ = c_finish_goto_label ($2); }
2228 { $$ = c_finish_goto_ptr ($3.value); }
2233 { $$ = objc_build_throw_stmt ($2.value); }
2235 { $$ = objc_build_throw_stmt (NULL_TREE); }
2236 | objc_try_catch_stmt
2238 | AT_SYNCHRONIZED save_location '(' expr ')' compstmt
2239 { objc_build_synchronized ($2, $4.value, $6); $$ = NULL_TREE; }
2243 AT_CATCH '(' parm ')'
2244 { objc_begin_catch_clause (grokparm ($3)); }
2248 objc_catch_prefix '{' compstmt_nostart
2249 { objc_finish_catch_clause (); }
2250 | objc_catch_prefix '{' error '}'
2251 { objc_finish_catch_clause (); }
2254 objc_opt_catch_list:
2256 | objc_opt_catch_list objc_catch_clause
2259 objc_try_catch_clause:
2260 AT_TRY save_location compstmt
2261 { objc_begin_try_stmt ($2, $3); }
2265 objc_finally_clause:
2266 AT_FINALLY save_location compstmt
2267 { objc_build_finally_clause ($2, $3); }
2270 objc_try_catch_stmt:
2271 objc_try_catch_clause
2272 { objc_finish_try_stmt (); }
2273 | objc_try_catch_clause objc_finally_clause
2274 { objc_finish_try_stmt (); }
2278 /* Parse a single or compound real statement, not including any labels. */
2281 { add_stmt ($1); $$ = NULL_TREE; }
2285 /* Any kind of label, including jump labels and case labels.
2286 ANSI C accepts labels only before statements, but we allow them
2287 also at the end of a compound statement. */
2289 label: CASE expr_no_commas ':'
2290 { $$ = do_case ($2.value, NULL_TREE); }
2291 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
2292 { $$ = do_case ($2.value, $4.value); }
2294 { $$ = do_case (NULL_TREE, NULL_TREE); }
2295 | identifier save_location ':' maybe_attribute
2296 { tree label = define_label ($2, $1);
2299 decl_attributes (&label, $4, 0);
2300 $$ = add_stmt (build_stmt (LABEL_EXPR, label));
2307 /* Asm expressions and statements */
2309 /* simple_asm_expr is used in restricted contexts, where a full
2310 expression with inputs and outputs does not make sense. */
2312 ASM_KEYWORD stop_string_translation
2313 '(' STRING ')' start_string_translation
2317 /* maybeasm: used for assembly names for declarations */
2324 /* asmdef: asm() outside a function body. */
2327 { assemble_asm ($1); }
2328 | ASM_KEYWORD error start_string_translation ';'
2332 /* Full-blown asm statement with inputs, outputs, clobbers, and
2333 volatile tag allowed. */
2335 ASM_KEYWORD maybe_volatile stop_string_translation
2336 '(' asm_argument ')' start_string_translation ';'
2337 { $$ = build_asm_stmt ($2, $5); }
2343 { $$ = build_asm_expr ($1, 0, 0, 0, true); }
2344 /* output operands */
2345 | STRING ':' asm_operands
2346 { $$ = build_asm_expr ($1, $3, 0, 0, false); }
2347 /* output and input operands */
2348 | STRING ':' asm_operands ':' asm_operands
2349 { $$ = build_asm_expr ($1, $3, $5, 0, false); }
2350 /* output and input operands and clobbers */
2351 | STRING ':' asm_operands ':' asm_operands ':' asm_clobbers
2352 { $$ = build_asm_expr ($1, $3, $5, $7, false); }
2355 /* Either 'volatile' or nothing. First thing in an `asm' statement. */
2361 { if ($1 != ridpointers[RID_VOLATILE])
2363 warning ("%E qualifier ignored on asm", $1);
2371 /* These are the operands other than the first string and colon
2372 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
2373 asm_operands: /* empty */
2375 | nonnull_asm_operands
2378 nonnull_asm_operands:
2380 | nonnull_asm_operands ',' asm_operand
2381 { $$ = chainon ($1, $3); }
2385 STRING start_string_translation '(' expr ')' stop_string_translation
2386 { $$ = build_tree_list (build_tree_list (NULL_TREE, $1),
2388 | '[' identifier ']' STRING start_string_translation
2389 '(' expr ')' stop_string_translation
2390 { $2 = build_string (IDENTIFIER_LENGTH ($2),
2391 IDENTIFIER_POINTER ($2));
2392 $$ = build_tree_list (build_tree_list ($2, $4), $7.value); }
2397 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
2398 | asm_clobbers ',' STRING
2399 { $$ = tree_cons (NULL_TREE, $3, $1); }
2402 stop_string_translation:
2403 { c_lex_string_translate = 0; }
2406 start_string_translation:
2407 { c_lex_string_translate = 1; }
2411 /* This is what appears inside the parens in a function declarator.
2412 Its value is a list of ..._TYPE nodes. Attributes must appear here
2413 to avoid a conflict with their appearance after an open parenthesis
2414 in an abstract declarator, as in
2415 "void bar (int (__attribute__((__mode__(SI))) int foo));". */
2419 declare_parm_level (); }
2428 { mark_forward_parm_decls (); }
2430 { /* Dummy action so attributes are in known place
2431 on parser stack. */ }
2435 { $$ = XOBNEW (&parser_obstack, struct c_arg_info);
2442 /* This is what appears inside the parens in a function declarator.
2443 Its value is represented in the format that grokdeclarator expects. */
2444 parmlist_2: /* empty */
2445 { $$ = XOBNEW (&parser_obstack, struct c_arg_info);
2451 { $$ = XOBNEW (&parser_obstack, struct c_arg_info);
2455 /* Suppress -Wold-style-definition for this case. */
2456 $$->types = error_mark_node;
2457 error ("ISO C requires a named argument before %<...%>");
2460 { $$ = get_parm_info (/*ellipsis=*/false); }
2461 | parms ',' ELLIPSIS
2462 { $$ = get_parm_info (/*ellipsis=*/true); }
2467 { push_parm_decl ($1); }
2469 { push_parm_decl ($3); }
2472 /* A single parameter declaration or parameter type name,
2473 as found in a parmlist. */
2475 declspecs_ts setspecs parm_declarator maybe_attribute
2476 { $$ = build_c_parm (current_declspecs,
2477 chainon ($4, all_prefix_attributes), $3);
2478 POP_DECLSPEC_STACK; }
2479 | declspecs_ts setspecs notype_declarator maybe_attribute
2480 { $$ = build_c_parm (current_declspecs,
2481 chainon ($4, all_prefix_attributes), $3);
2482 POP_DECLSPEC_STACK; }
2483 | declspecs_ts setspecs absdcl_maybe_attribute
2485 POP_DECLSPEC_STACK; }
2486 | declspecs_nots setspecs notype_declarator maybe_attribute
2487 { $$ = build_c_parm (current_declspecs,
2488 chainon ($4, all_prefix_attributes), $3);
2489 POP_DECLSPEC_STACK; }
2491 | declspecs_nots setspecs absdcl_maybe_attribute
2493 POP_DECLSPEC_STACK; }
2496 /* The first parm, which must suck attributes from off the top of the parser
2499 declspecs_ts_nosa setspecs_fp parm_declarator maybe_attribute
2500 { $$ = build_c_parm (current_declspecs,
2501 chainon ($4, all_prefix_attributes), $3);
2502 POP_DECLSPEC_STACK; }
2503 | declspecs_ts_nosa setspecs_fp notype_declarator maybe_attribute
2504 { $$ = build_c_parm (current_declspecs,
2505 chainon ($4, all_prefix_attributes), $3);
2506 POP_DECLSPEC_STACK; }
2507 | declspecs_ts_nosa setspecs_fp absdcl_maybe_attribute
2509 POP_DECLSPEC_STACK; }
2510 | declspecs_nots_nosa setspecs_fp notype_declarator maybe_attribute
2511 { $$ = build_c_parm (current_declspecs,
2512 chainon ($4, all_prefix_attributes), $3);
2513 POP_DECLSPEC_STACK; }
2515 | declspecs_nots_nosa setspecs_fp absdcl_maybe_attribute
2517 POP_DECLSPEC_STACK; }
2522 { prefix_attributes = chainon (prefix_attributes, $<ttype>-2);
2523 all_prefix_attributes = prefix_attributes; }
2526 /* This is used in a function definition
2527 where either a parmlist or an identifier list is ok.
2528 Its value is a list of ..._TYPE nodes or a list of identifiers. */
2529 parmlist_or_identifiers:
2532 declare_parm_level (); }
2533 parmlist_or_identifiers_1
2538 parmlist_or_identifiers_1:
2541 { $$ = XOBNEW (&parser_obstack, struct c_arg_info);
2547 /* Make sure we have a parmlist after attributes. */
2548 if ($<ttype>-1 != 0)
2553 /* A nonempty list of identifiers. */
2556 { $$ = build_tree_list (NULL_TREE, $1); }
2557 | identifiers ',' IDENTIFIER
2558 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2561 /* A nonempty list of identifiers, including typenames. */
2562 identifiers_or_typenames:
2564 { $$ = build_tree_list (NULL_TREE, $1); }
2565 | identifiers_or_typenames ',' identifier
2566 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2571 { $$ = SAVE_EXT_FLAGS ();
2573 warn_pointer_arith = 0;
2574 warn_traditional = 0;
2579 /* Objective-C productions. */
2589 objc_finish_implementation ();
2593 /* A nonempty list of identifiers. */
2596 { $$ = build_tree_list (NULL_TREE, $1); }
2597 | identifier_list ',' identifier
2598 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2602 AT_CLASS identifier_list ';'
2604 objc_declare_class ($2);
2609 AT_ALIAS identifier identifier ';'
2611 objc_declare_alias ($2, $3);
2616 ':' identifier { $$ = $2; }
2617 | /* NULL */ %prec HYPERUNARY { $$ = NULL_TREE; }
2621 '{' ivar_decl_list '}'
2626 AT_INTERFACE identifier superclass protocolrefs
2628 objc_start_class_interface ($2, $3, $4);
2632 objc_continue_interface ();
2634 methodprotolist AT_END
2636 objc_finish_interface ();
2639 | AT_IMPLEMENTATION identifier superclass
2641 objc_start_class_implementation ($2, $3);
2645 objc_continue_implementation ();
2648 | AT_INTERFACE identifier '(' identifier ')' protocolrefs
2650 objc_start_category_interface ($2, $4, $6);
2652 methodprotolist AT_END
2654 objc_finish_interface ();
2657 | AT_IMPLEMENTATION identifier '(' identifier ')'
2659 objc_start_category_implementation ($2, $4);
2664 AT_PROTOCOL identifier protocolrefs
2666 objc_pq_context = 1;
2667 objc_start_protocol ($2, $3);
2669 methodprotolist AT_END
2671 objc_pq_context = 0;
2672 objc_finish_interface ();
2674 /* The @protocol forward-declaration production introduces a
2675 reduce/reduce conflict on ';', which should be resolved in
2676 favor of the production 'identifier_list -> identifier'. */
2677 | AT_PROTOCOL identifier_list ';'
2679 objc_declare_protocols ($2);
2688 | non_empty_protocolrefs
2691 non_empty_protocolrefs:
2692 ARITHCOMPARE identifier_list ARITHCOMPARE
2694 if ($1 == LT_EXPR && $3 == GT_EXPR)
2703 | ivar_decl_list visibility_spec ivar_decls
2708 | AT_PRIVATE { objc_set_visibility (2); }
2709 | AT_PROTECTED { objc_set_visibility (0); }
2710 | AT_PUBLIC { objc_set_visibility (1); }
2715 | ivar_decls ivar_decl ';'
2719 pedwarn ("extra semicolon in struct or union specified");
2726 /* Comma-separated ivars are chained together in
2727 reverse order; add them one by one. */
2728 tree ivar = nreverse ($1);
2730 for (; ivar; ivar = TREE_CHAIN (ivar))
2731 objc_add_instance_variable (copy_node (ivar));
2740 pedwarn ("extra semicolon in method definition specified");
2752 objc_set_method_type ($1);
2753 objc_pq_context = 1;
2757 objc_pq_context = 0;
2758 objc_start_method_definition ($3);
2762 objc_finish_method_definition (current_function_decl);
2766 /* the reason for the strange actions in this rule
2767 is so that notype_initdecls when reached via datadef
2768 can find a valid list of type and sc specs in $0. */
2772 | methodprotolist methodproto
2773 | methodprotolist { $<ttype>$ = NULL_TREE; } datadef
2784 objc_set_method_type ($1);
2785 /* Remember protocol qualifiers in prototypes. */
2786 objc_pq_context = 1;
2790 /* Forget protocol qualifiers here. */
2791 objc_pq_context = 0;
2792 objc_add_method_declaration ($3);
2798 '(' objc_typename ')' unaryselector
2800 $$ = objc_build_method_signature ($2, $4, NULL_TREE);
2805 $$ = objc_build_method_signature (NULL_TREE, $1, NULL_TREE);
2808 | '(' objc_typename ')' keywordselector optparmlist
2810 $$ = objc_build_method_signature ($2, $4, $5);
2813 | keywordselector optparmlist
2815 $$ = objc_build_method_signature (NULL_TREE, $1, $2);
2819 /* Optional ObjC method parameters follow the C syntax, and may include '...'
2820 to denote a variable number of arguments. */
2823 optparms optellipsis
2825 TREE_OVERFLOW ($$) = $2;
2832 $$ = make_node (TREE_LIST);
2836 $$ = chainon ($1, build_tree_list (NULL_TREE,
2859 | keywordselector keyworddecl
2861 $$ = chainon ($1, $2);
2874 ENUM | STRUCT | UNION | IF | ELSE | WHILE | DO | FOR
2875 | SWITCH | CASE | DEFAULT | BREAK | CONTINUE | RETURN
2876 | GOTO | ASM_KEYWORD | SIZEOF | TYPEOF | ALIGNOF
2877 | TYPESPEC | TYPE_QUAL
2885 objc_quals objc_qual
2887 $$ = chainon ($1, build_tree_list (NULL_TREE, $2));
2898 $$ = build_tree_list ($1, groktypename ($2));
2902 $$ = build_tree_list ($1, NULL_TREE);
2907 selector ':' '(' objc_typename ')' identifier
2909 $$ = objc_build_keyword_decl ($1, $4, $6);
2912 | selector ':' identifier
2914 $$ = objc_build_keyword_decl ($1, NULL_TREE, $3);
2917 | ':' '(' objc_typename ')' identifier
2919 $$ = objc_build_keyword_decl (NULL_TREE, $3, $5);
2924 $$ = objc_build_keyword_decl (NULL_TREE, NULL_TREE, $2);
2935 | keywordarglist keywordarg
2937 $$ = chainon ($1, $2);
2945 if (TREE_CHAIN ($1) == NULL_TREE)
2946 /* just return the expr., remove a level of indirection */
2947 $$ = TREE_VALUE ($1);
2949 /* we have a comma expr., we will collapse later */
2955 selector ':' keywordexpr
2957 $$ = build_tree_list ($1, $3);
2961 $$ = build_tree_list (NULL_TREE, $2);
2970 $$ = objc_get_class_reference ($1);
2974 $$ = objc_get_class_reference ($1);
2979 '[' receiver messageargs ']'
2980 { $$ = build_tree_list ($2, $3); }
2990 | keywordnamelist keywordname
2992 $$ = chainon ($1, $2);
2999 $$ = build_tree_list ($1, NULL_TREE);
3003 $$ = build_tree_list (NULL_TREE, NULL_TREE);
3008 AT_SELECTOR '(' selectorarg ')'
3015 AT_PROTOCOL '(' identifier ')'
3021 /* extension to support C-structures in the archiver */
3024 AT_ENCODE '(' typename ')'
3026 $$ = groktypename ($3);
3033 /* yylex() is a thin wrapper around c_lex(), all it does is translate
3034 cpplib.h's token codes into yacc's token codes. */
3036 static enum cpp_ttype last_token;
3038 /* The reserved keyword table. */
3042 ENUM_BITFIELD(rid) rid : 16;
3043 unsigned int disable : 16;
3046 /* Disable mask. Keywords are disabled if (reswords[i].disable & mask) is
3048 #define D_C89 0x01 /* not in C89 */
3049 #define D_EXT 0x02 /* GCC extension */
3050 #define D_EXT89 0x04 /* GCC extension incorporated in C99 */
3051 #define D_OBJC 0x08 /* Objective C only */
3053 static const struct resword reswords[] =
3055 { "_Bool", RID_BOOL, 0 },
3056 { "_Complex", RID_COMPLEX, 0 },
3057 { "__FUNCTION__", RID_FUNCTION_NAME, 0 },
3058 { "__PRETTY_FUNCTION__", RID_PRETTY_FUNCTION_NAME, 0 },
3059 { "__alignof", RID_ALIGNOF, 0 },
3060 { "__alignof__", RID_ALIGNOF, 0 },
3061 { "__asm", RID_ASM, 0 },
3062 { "__asm__", RID_ASM, 0 },
3063 { "__attribute", RID_ATTRIBUTE, 0 },
3064 { "__attribute__", RID_ATTRIBUTE, 0 },
3065 { "__builtin_choose_expr", RID_CHOOSE_EXPR, 0 },
3066 { "__builtin_offsetof", RID_OFFSETOF, 0 },
3067 { "__builtin_types_compatible_p", RID_TYPES_COMPATIBLE_P, 0 },
3068 { "__builtin_va_arg", RID_VA_ARG, 0 },
3069 { "__complex", RID_COMPLEX, 0 },
3070 { "__complex__", RID_COMPLEX, 0 },
3071 { "__const", RID_CONST, 0 },
3072 { "__const__", RID_CONST, 0 },
3073 { "__extension__", RID_EXTENSION, 0 },
3074 { "__func__", RID_C99_FUNCTION_NAME, 0 },
3075 { "__imag", RID_IMAGPART, 0 },
3076 { "__imag__", RID_IMAGPART, 0 },
3077 { "__inline", RID_INLINE, 0 },
3078 { "__inline__", RID_INLINE, 0 },
3079 { "__label__", RID_LABEL, 0 },
3080 { "__ptrbase", RID_PTRBASE, 0 },
3081 { "__ptrbase__", RID_PTRBASE, 0 },
3082 { "__ptrextent", RID_PTREXTENT, 0 },
3083 { "__ptrextent__", RID_PTREXTENT, 0 },
3084 { "__ptrvalue", RID_PTRVALUE, 0 },
3085 { "__ptrvalue__", RID_PTRVALUE, 0 },
3086 { "__real", RID_REALPART, 0 },
3087 { "__real__", RID_REALPART, 0 },
3088 { "__restrict", RID_RESTRICT, 0 },
3089 { "__restrict__", RID_RESTRICT, 0 },
3090 { "__signed", RID_SIGNED, 0 },
3091 { "__signed__", RID_SIGNED, 0 },
3092 { "__thread", RID_THREAD, 0 },
3093 { "__typeof", RID_TYPEOF, 0 },
3094 { "__typeof__", RID_TYPEOF, 0 },
3095 { "__volatile", RID_VOLATILE, 0 },
3096 { "__volatile__", RID_VOLATILE, 0 },
3097 { "asm", RID_ASM, D_EXT },
3098 { "auto", RID_AUTO, 0 },
3099 { "break", RID_BREAK, 0 },
3100 { "case", RID_CASE, 0 },
3101 { "char", RID_CHAR, 0 },
3102 { "const", RID_CONST, 0 },
3103 { "continue", RID_CONTINUE, 0 },
3104 { "default", RID_DEFAULT, 0 },
3105 { "do", RID_DO, 0 },
3106 { "double", RID_DOUBLE, 0 },
3107 { "else", RID_ELSE, 0 },
3108 { "enum", RID_ENUM, 0 },
3109 { "extern", RID_EXTERN, 0 },
3110 { "float", RID_FLOAT, 0 },
3111 { "for", RID_FOR, 0 },
3112 { "goto", RID_GOTO, 0 },
3113 { "if", RID_IF, 0 },
3114 { "inline", RID_INLINE, D_EXT89 },
3115 { "int", RID_INT, 0 },
3116 { "long", RID_LONG, 0 },
3117 { "register", RID_REGISTER, 0 },
3118 { "restrict", RID_RESTRICT, D_C89 },
3119 { "return", RID_RETURN, 0 },
3120 { "short", RID_SHORT, 0 },
3121 { "signed", RID_SIGNED, 0 },
3122 { "sizeof", RID_SIZEOF, 0 },
3123 { "static", RID_STATIC, 0 },
3124 { "struct", RID_STRUCT, 0 },
3125 { "switch", RID_SWITCH, 0 },
3126 { "typedef", RID_TYPEDEF, 0 },
3127 { "typeof", RID_TYPEOF, D_EXT },
3128 { "union", RID_UNION, 0 },
3129 { "unsigned", RID_UNSIGNED, 0 },
3130 { "void", RID_VOID, 0 },
3131 { "volatile", RID_VOLATILE, 0 },
3132 { "while", RID_WHILE, 0 },
3135 { "id", RID_ID, D_OBJC },
3137 /* These objc keywords are recognized only immediately after
3139 { "class", RID_AT_CLASS, D_OBJC },
3140 { "compatibility_alias", RID_AT_ALIAS, D_OBJC },
3141 { "defs", RID_AT_DEFS, D_OBJC },
3142 { "encode", RID_AT_ENCODE, D_OBJC },
3143 { "end", RID_AT_END, D_OBJC },
3144 { "implementation", RID_AT_IMPLEMENTATION, D_OBJC },
3145 { "interface", RID_AT_INTERFACE, D_OBJC },
3146 { "private", RID_AT_PRIVATE, D_OBJC },
3147 { "protected", RID_AT_PROTECTED, D_OBJC },
3148 { "protocol", RID_AT_PROTOCOL, D_OBJC },
3149 { "public", RID_AT_PUBLIC, D_OBJC },
3150 { "selector", RID_AT_SELECTOR, D_OBJC },
3151 { "throw", RID_AT_THROW, D_OBJC },
3152 { "try", RID_AT_TRY, D_OBJC },
3153 { "catch", RID_AT_CATCH, D_OBJC },
3154 { "finally", RID_AT_FINALLY, D_OBJC },
3155 { "synchronized", RID_AT_SYNCHRONIZED, D_OBJC },
3156 /* These are recognized only in protocol-qualifier context
3158 { "bycopy", RID_BYCOPY, D_OBJC },
3159 { "byref", RID_BYREF, D_OBJC },
3160 { "in", RID_IN, D_OBJC },
3161 { "inout", RID_INOUT, D_OBJC },
3162 { "oneway", RID_ONEWAY, D_OBJC },
3163 { "out", RID_OUT, D_OBJC },
3166 #define N_reswords (sizeof reswords / sizeof (struct resword))
3168 /* Table mapping from RID_* constants to yacc token numbers.
3169 Unfortunately we have to have entries for all the keywords in all
3171 static const short rid_to_yy[RID_MAX] =
3173 /* RID_STATIC */ STATIC,
3174 /* RID_UNSIGNED */ TYPESPEC,
3175 /* RID_LONG */ TYPESPEC,
3176 /* RID_CONST */ TYPE_QUAL,
3177 /* RID_EXTERN */ SCSPEC,
3178 /* RID_REGISTER */ SCSPEC,
3179 /* RID_TYPEDEF */ SCSPEC,
3180 /* RID_SHORT */ TYPESPEC,
3181 /* RID_INLINE */ SCSPEC,
3182 /* RID_VOLATILE */ TYPE_QUAL,
3183 /* RID_SIGNED */ TYPESPEC,
3184 /* RID_AUTO */ SCSPEC,
3185 /* RID_RESTRICT */ TYPE_QUAL,
3188 /* RID_COMPLEX */ TYPESPEC,
3189 /* RID_THREAD */ SCSPEC,
3193 /* RID_VIRTUAL */ 0,
3194 /* RID_EXPLICIT */ 0,
3196 /* RID_MUTABLE */ 0,
3199 /* RID_IN */ OBJC_TYPE_QUAL,
3200 /* RID_OUT */ OBJC_TYPE_QUAL,
3201 /* RID_INOUT */ OBJC_TYPE_QUAL,
3202 /* RID_BYCOPY */ OBJC_TYPE_QUAL,
3203 /* RID_BYREF */ OBJC_TYPE_QUAL,
3204 /* RID_ONEWAY */ OBJC_TYPE_QUAL,
3207 /* RID_INT */ TYPESPEC,
3208 /* RID_CHAR */ TYPESPEC,
3209 /* RID_FLOAT */ TYPESPEC,
3210 /* RID_DOUBLE */ TYPESPEC,
3211 /* RID_VOID */ TYPESPEC,
3212 /* RID_ENUM */ ENUM,
3213 /* RID_STRUCT */ STRUCT,
3214 /* RID_UNION */ UNION,
3216 /* RID_ELSE */ ELSE,
3217 /* RID_WHILE */ WHILE,
3220 /* RID_SWITCH */ SWITCH,
3221 /* RID_CASE */ CASE,
3222 /* RID_DEFAULT */ DEFAULT,
3223 /* RID_BREAK */ BREAK,
3224 /* RID_CONTINUE */ CONTINUE,
3225 /* RID_RETURN */ RETURN,
3226 /* RID_GOTO */ GOTO,
3227 /* RID_SIZEOF */ SIZEOF,
3230 /* RID_ASM */ ASM_KEYWORD,
3231 /* RID_TYPEOF */ TYPEOF,
3232 /* RID_ALIGNOF */ ALIGNOF,
3233 /* RID_ATTRIBUTE */ ATTRIBUTE,
3234 /* RID_VA_ARG */ VA_ARG,
3235 /* RID_EXTENSION */ EXTENSION,
3236 /* RID_IMAGPART */ IMAGPART,
3237 /* RID_REALPART */ REALPART,
3238 /* RID_LABEL */ LABEL,
3239 /* RID_PTRBASE */ PTR_BASE,
3240 /* RID_PTREXTENT */ PTR_EXTENT,
3241 /* RID_PTRVALUE */ PTR_VALUE,
3243 /* RID_CHOOSE_EXPR */ CHOOSE_EXPR,
3244 /* RID_TYPES_COMPATIBLE_P */ TYPES_COMPATIBLE_P,
3246 /* RID_FUNCTION_NAME */ FUNC_NAME,
3247 /* RID_PRETTY_FUNCTION_NAME */ FUNC_NAME,
3248 /* RID_C99_FUNCTION_NAME */ FUNC_NAME,
3251 /* RID_BOOL */ TYPESPEC,
3255 /* RID_PRIVATE */ 0,
3256 /* RID_PROTECTED */ 0,
3257 /* RID_TEMPLATE */ 0,
3262 /* RID_NAMESPACE */ 0,
3264 /* RID_OFFSETOF */ OFFSETOF,
3265 /* RID_OPERATOR */ 0,
3270 /* RID_TYPENAME */ 0,
3275 /* RID_CONSTCAST */ 0,
3276 /* RID_DYNCAST */ 0,
3277 /* RID_REINTCAST */ 0,
3278 /* RID_STATCAST */ 0,
3281 /* RID_ID */ OBJECTNAME,
3282 /* RID_AT_ENCODE */ AT_ENCODE,
3283 /* RID_AT_END */ AT_END,
3284 /* RID_AT_CLASS */ AT_CLASS,
3285 /* RID_AT_ALIAS */ AT_ALIAS,
3286 /* RID_AT_DEFS */ AT_DEFS,
3287 /* RID_AT_PRIVATE */ AT_PRIVATE,
3288 /* RID_AT_PROTECTED */ AT_PROTECTED,
3289 /* RID_AT_PUBLIC */ AT_PUBLIC,
3290 /* RID_AT_PROTOCOL */ AT_PROTOCOL,
3291 /* RID_AT_SELECTOR */ AT_SELECTOR,
3292 /* RID_AT_THROW */ AT_THROW,
3293 /* RID_AT_TRY */ AT_TRY,
3294 /* RID_AT_CATCH */ AT_CATCH,
3295 /* RID_AT_FINALLY */ AT_FINALLY,
3296 /* RID_AT_SYNCHRONIZED */ AT_SYNCHRONIZED,
3297 /* RID_AT_INTERFACE */ AT_INTERFACE,
3298 /* RID_AT_IMPLEMENTATION */ AT_IMPLEMENTATION
3302 init_reswords (void)
3306 int mask = (flag_isoc99 ? 0 : D_C89)
3307 | (flag_no_asm ? (flag_isoc99 ? D_EXT : D_EXT|D_EXT89) : 0);
3309 if (!c_dialect_objc ())
3312 ridpointers = GGC_CNEWVEC (tree, (int) RID_MAX);
3313 for (i = 0; i < N_reswords; i++)
3315 /* If a keyword is disabled, do not enter it into the table
3316 and so create a canonical spelling that isn't a keyword. */
3317 if (reswords[i].disable & mask)
3320 id = get_identifier (reswords[i].word);
3321 C_RID_CODE (id) = reswords[i].rid;
3322 C_IS_RESERVED_WORD (id) = 1;
3323 ridpointers [(int) reswords[i].rid] = id;
3327 #define NAME(type) cpp_type2name (type)
3330 yyerror (const char *msgid)
3332 c_parse_error (msgid, last_token, yylval.ttype);
3341 int objc_force_identifier = objc_need_raw_identifier;
3342 OBJC_NEED_RAW_IDENTIFIER (0);
3345 if (C_IS_RESERVED_WORD (yylval.ttype))
3347 enum rid rid_code = C_RID_CODE (yylval.ttype);
3350 /* Turn non-typedefed refs to "id" into plain identifiers; this
3351 allows constructs like "void foo(id id);" to work. */
3352 if (rid_code == RID_ID)
3354 decl = lookup_name (yylval.ttype);
3355 if (decl == NULL_TREE || TREE_CODE (decl) != TYPE_DECL)
3359 if (!OBJC_IS_AT_KEYWORD (rid_code)
3360 && (!OBJC_IS_PQ_KEYWORD (rid_code) || objc_pq_context))
3363 /* Return the canonical spelling for this keyword. */
3364 yylval.ttype = ridpointers[(int) rid_code];
3365 return rid_to_yy[(int) rid_code];
3369 decl = lookup_name (yylval.ttype);
3372 if (TREE_CODE (decl) == TYPE_DECL)
3378 tree objc_interface_decl = objc_is_class_name (yylval.ttype);
3379 /* ObjC class names are in the same namespace as variables and
3380 typedefs, and hence are shadowed by local declarations. */
3381 if (objc_interface_decl
3382 && (global_bindings_p ()
3383 || (!objc_force_identifier && !decl)))
3385 yylval.ttype = objc_interface_decl;
3398 last_token = c_lex (&yylval.ttype);
3401 case CPP_EQ: return '=';
3402 case CPP_NOT: return '!';
3403 case CPP_GREATER: yylval.code = GT_EXPR; return ARITHCOMPARE;
3404 case CPP_LESS: yylval.code = LT_EXPR; return ARITHCOMPARE;
3405 case CPP_PLUS: yylval.code = PLUS_EXPR; return '+';
3406 case CPP_MINUS: yylval.code = MINUS_EXPR; return '-';
3407 case CPP_MULT: yylval.code = MULT_EXPR; return '*';
3408 case CPP_DIV: yylval.code = TRUNC_DIV_EXPR; return '/';
3409 case CPP_MOD: yylval.code = TRUNC_MOD_EXPR; return '%';
3410 case CPP_AND: yylval.code = BIT_AND_EXPR; return '&';
3411 case CPP_OR: yylval.code = BIT_IOR_EXPR; return '|';
3412 case CPP_XOR: yylval.code = BIT_XOR_EXPR; return '^';
3413 case CPP_RSHIFT: yylval.code = RSHIFT_EXPR; return RSHIFT;
3414 case CPP_LSHIFT: yylval.code = LSHIFT_EXPR; return LSHIFT;
3416 case CPP_COMPL: return '~';
3417 case CPP_AND_AND: return ANDAND;
3418 case CPP_OR_OR: return OROR;
3419 case CPP_QUERY: return '?';
3420 case CPP_OPEN_PAREN: return '(';
3421 case CPP_EQ_EQ: yylval.code = EQ_EXPR; return EQCOMPARE;
3422 case CPP_NOT_EQ: yylval.code = NE_EXPR; return EQCOMPARE;
3423 case CPP_GREATER_EQ:yylval.code = GE_EXPR; return ARITHCOMPARE;
3424 case CPP_LESS_EQ: yylval.code = LE_EXPR; return ARITHCOMPARE;
3426 case CPP_PLUS_EQ: yylval.code = PLUS_EXPR; return ASSIGN;
3427 case CPP_MINUS_EQ: yylval.code = MINUS_EXPR; return ASSIGN;
3428 case CPP_MULT_EQ: yylval.code = MULT_EXPR; return ASSIGN;
3429 case CPP_DIV_EQ: yylval.code = TRUNC_DIV_EXPR; return ASSIGN;
3430 case CPP_MOD_EQ: yylval.code = TRUNC_MOD_EXPR; return ASSIGN;
3431 case CPP_AND_EQ: yylval.code = BIT_AND_EXPR; return ASSIGN;
3432 case CPP_OR_EQ: yylval.code = BIT_IOR_EXPR; return ASSIGN;
3433 case CPP_XOR_EQ: yylval.code = BIT_XOR_EXPR; return ASSIGN;
3434 case CPP_RSHIFT_EQ: yylval.code = RSHIFT_EXPR; return ASSIGN;
3435 case CPP_LSHIFT_EQ: yylval.code = LSHIFT_EXPR; return ASSIGN;
3437 case CPP_OPEN_SQUARE: return '[';
3438 case CPP_CLOSE_SQUARE: return ']';
3439 case CPP_OPEN_BRACE: return '{';
3440 case CPP_CLOSE_BRACE: return '}';
3441 case CPP_ELLIPSIS: return ELLIPSIS;
3443 case CPP_PLUS_PLUS: return PLUSPLUS;
3444 case CPP_MINUS_MINUS: return MINUSMINUS;
3445 case CPP_DEREF: return POINTSAT;
3446 case CPP_DOT: return '.';
3448 /* The following tokens may affect the interpretation of any
3449 identifiers following, if doing Objective-C. */
3450 case CPP_COLON: OBJC_NEED_RAW_IDENTIFIER (0); return ':';
3451 case CPP_COMMA: OBJC_NEED_RAW_IDENTIFIER (0); return ',';
3452 case CPP_CLOSE_PAREN: OBJC_NEED_RAW_IDENTIFIER (0); return ')';
3453 case CPP_SEMICOLON: OBJC_NEED_RAW_IDENTIFIER (0); return ';';
3459 return yylexname ();
3462 /* This only happens in Objective-C; it must be a keyword. */
3463 return rid_to_yy [(int) C_RID_CODE (yylval.ttype)];
3474 case CPP_OBJC_STRING:
3477 /* These tokens are C++ specific (and will not be generated
3478 in C mode, but let's be cautious). */
3480 case CPP_DEREF_STAR:
3486 /* These tokens should not survive translation phase 4. */
3489 error ("syntax error at %qs token", NAME(last_token));
3502 timevar_push (TV_LEX);
3504 timevar_pop (TV_LEX);
3508 /* Function used when yydebug is set, to print a token in more detail. */
3511 yyprint (FILE *file, int yychar, YYSTYPE yyl)
3515 fprintf (file, " [%s]", NAME(last_token));
3526 if (IDENTIFIER_POINTER (t))
3527 fprintf (file, " '%s'", IDENTIFIER_POINTER (t));
3531 fprintf (file, " %s", GET_MODE_NAME (TYPE_MODE (TREE_TYPE (t))));
3532 if (TREE_CODE (t) == INTEGER_CST)
3535 fprintf (file, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
3536 TREE_INT_CST_HIGH (t), TREE_INT_CST_LOW (t));
3542 /* This is not the ideal place to put this, but we have to get it out
3543 of c-lex.c because cp/lex.c has its own version. */
3545 /* Parse the file. */
3553 free (malloced_yyss);
3554 free (malloced_yyvs);
3559 #include "gt-c-parse.h"