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 /* Initialisation 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; }
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 really_start_incremental_init ($<ttype>$); }
681 initlist_maybe_comma '}' %prec UNARY
682 { struct c_expr init = pop_init_level (0);
683 tree constructor = init.value;
684 tree type = $<ttype>5;
686 maybe_warn_string_init (type, init);
688 if (pedantic && ! flag_isoc99)
689 pedwarn ("ISO C90 forbids compound literals");
690 $$.value = build_compound_literal (type, constructor);
691 $$.original_code = ERROR_MARK;
694 { $$.value = $2.value;
695 if (TREE_CODE ($$.value) == MODIFY_EXPR)
696 TREE_NO_WARNING ($$.value) = 1;
697 $$.original_code = ERROR_MARK; }
699 { $$.value = error_mark_node; $$.original_code = ERROR_MARK; }
700 | compstmt_primary_start compstmt_nostart ')'
702 pedwarn ("ISO C forbids braced-groups within expressions");
703 $$.value = c_finish_stmt_expr ($1);
704 $$.original_code = ERROR_MARK;
706 | compstmt_primary_start error ')'
707 { c_finish_stmt_expr ($1);
708 $$.value = error_mark_node;
709 $$.original_code = ERROR_MARK;
711 | primary '(' exprlist ')' %prec '.'
712 { $$.value = build_function_call ($1.value, $3);
713 $$.original_code = ERROR_MARK; }
714 | VA_ARG '(' expr_no_commas ',' typename ')'
715 { $$.value = build_va_arg ($3.value, groktypename ($5));
716 $$.original_code = ERROR_MARK; }
718 | OFFSETOF '(' typename ','
719 { tree type = groktypename ($3);
720 if (type == error_mark_node)
721 offsetof_base = error_mark_node;
723 offsetof_base = build1 (INDIRECT_REF, type, NULL);
725 offsetof_member_designator ')'
726 { $$.value = fold_offsetof ($6);
727 $$.original_code = ERROR_MARK; }
728 | OFFSETOF '(' error ')'
729 { $$.value = error_mark_node; $$.original_code = ERROR_MARK; }
730 | CHOOSE_EXPR '(' expr_no_commas ',' expr_no_commas ','
737 if (TREE_CODE (c) != INTEGER_CST)
738 error ("first argument to __builtin_choose_expr not"
740 $$ = integer_zerop (c) ? $7 : $5;
742 | CHOOSE_EXPR '(' error ')'
743 { $$.value = error_mark_node; $$.original_code = ERROR_MARK; }
744 | TYPES_COMPATIBLE_P '(' typename ',' typename ')'
748 e1 = TYPE_MAIN_VARIANT (groktypename ($3));
749 e2 = TYPE_MAIN_VARIANT (groktypename ($5));
751 $$.value = comptypes (e1, e2)
752 ? build_int_cst (NULL_TREE, 1)
753 : build_int_cst (NULL_TREE, 0);
754 $$.original_code = ERROR_MARK;
756 | TYPES_COMPATIBLE_P '(' error ')'
757 { $$.value = error_mark_node; $$.original_code = ERROR_MARK; }
758 | primary '[' expr ']' %prec '.'
759 { $$.value = build_array_ref ($1.value, $3.value);
760 $$.original_code = ERROR_MARK; }
761 | primary '.' identifier
762 { $$.value = build_component_ref ($1.value, $3);
763 $$.original_code = ERROR_MARK; }
764 | primary POINTSAT identifier
766 tree expr = build_indirect_ref ($1.value, "->");
767 $$.value = build_component_ref (expr, $3);
768 $$.original_code = ERROR_MARK;
771 { $$.value = build_unary_op (POSTINCREMENT_EXPR, $1.value, 0);
772 $$.original_code = ERROR_MARK; }
774 { $$.value = build_unary_op (POSTDECREMENT_EXPR, $1.value, 0);
775 $$.original_code = ERROR_MARK; }
778 { $$.value = objc_build_message_expr ($1);
779 $$.original_code = ERROR_MARK; }
781 { $$.value = objc_build_selector_expr ($1);
782 $$.original_code = ERROR_MARK; }
784 { $$.value = objc_build_protocol_expr ($1);
785 $$.original_code = ERROR_MARK; }
787 { $$.value = objc_build_encode_expr ($1);
788 $$.original_code = ERROR_MARK; }
790 { $$.value = objc_build_string_object ($1);
791 $$.original_code = ERROR_MARK; }
795 /* This is the second argument to __builtin_offsetof. We must have one
796 identifier, and beyond that we want to accept sub structure and sub
799 offsetof_member_designator:
801 { $$ = build_component_ref (offsetof_base, $1); }
802 | offsetof_member_designator '.' identifier
803 { $$ = build_component_ref ($1, $3); }
804 | offsetof_member_designator '[' expr ']'
805 { $$ = build_array_ref ($1, $3.value); }
808 old_style_parm_decls:
813 /* The following are analogous to lineno_decl, decls and decl
814 except that they do not allow nested functions.
815 They are used for old-style parm decls. */
817 save_location datadecl
824 | datadecls lineno_datadecl
825 | lineno_datadecl errstmt
828 /* We don't allow prefix attributes here because they cause reduce/reduce
829 conflicts: we can't know whether we're parsing a function decl with
830 attribute suffix, or function defn with attribute prefix on first old
833 declspecs_ts_nosa setspecs initdecls ';'
834 { POP_DECLSPEC_STACK; }
835 | declspecs_nots_nosa setspecs notype_initdecls ';'
836 { POP_DECLSPEC_STACK; }
837 | declspecs_ts_nosa ';'
838 { shadow_tag_warned ($1, 1);
839 pedwarn ("empty declaration"); }
840 | declspecs_nots_nosa ';'
841 { pedwarn ("empty declaration"); }
844 /* This combination which saves a lineno before a decl
845 is the normal thing to use, rather than decl itself.
846 This is to avoid shift/reduce conflicts in contexts
847 where statement labels are allowed. */
853 /* records the type and storage class specs to use for processing
854 the declarators that follow.
855 Maintains a stack of outer-level values of current_declspecs,
856 for the sake of parm declarations nested in function declarators. */
857 setspecs: /* empty */
858 { pending_xref_error ();
862 prefix_attributes = $<dsptype>0->attrs;
863 $<dsptype>0->attrs = NULL_TREE;
864 current_declspecs = $<dsptype>0;
868 prefix_attributes = NULL_TREE;
869 current_declspecs = build_null_declspecs ();
871 all_prefix_attributes = prefix_attributes; }
874 /* Possibly attributes after a comma, which should reset all_prefix_attributes
875 to prefix_attributes with these ones chained on the front. */
878 { all_prefix_attributes = chainon ($1, prefix_attributes); }
882 declspecs_ts setspecs initdecls ';'
883 { POP_DECLSPEC_STACK; }
884 | declspecs_nots setspecs notype_initdecls ';'
885 { POP_DECLSPEC_STACK; }
886 | declspecs_ts setspecs nested_function
887 { POP_DECLSPEC_STACK; }
888 | declspecs_nots setspecs notype_nested_function
889 { POP_DECLSPEC_STACK; }
893 { RESTORE_EXT_FLAGS ($1); }
896 /* A list of declaration specifiers. These are:
898 - Storage class specifiers (scspec), which for GCC currently includes
899 function specifiers ("inline").
901 - Type specifiers (typespec_*).
903 - Type qualifiers (TYPE_QUAL).
905 - Attribute specifier lists (attributes).
907 The various cases below are classified according to:
909 (a) Whether a storage class specifier is included or not; some
910 places in the grammar disallow storage class specifiers (_sc or _nosc).
912 (b) Whether a type specifier has been seen; after a type specifier,
913 a typedef name is an identifier to redeclare (_ts or _nots).
915 (c) Whether the list starts with an attribute; in certain places,
916 the grammar requires specifiers that don't start with an attribute
919 (d) Whether the list ends with an attribute (or a specifier such that
920 any following attribute would have been parsed as part of that specifier);
921 this avoids shift-reduce conflicts in the parsing of attributes
926 (i) Distinguish between function specifiers and storage class specifiers,
927 at least for the purpose of warnings about obsolescent usage.
929 (ii) Halve the number of productions here by eliminating the _sc/_nosc
930 distinction and instead checking where required that storage class
931 specifiers aren't present. */
933 /* Declspecs which contain at least one type specifier or typedef name.
934 (Just `const' or `volatile' is not enough.)
935 A typedef'd name following these is taken as a name to be declared. */
937 declspecs_nosc_nots_nosa_noea:
939 { $$ = declspecs_add_qual (build_null_declspecs (), $1); }
940 | declspecs_nosc_nots_nosa_noea TYPE_QUAL
941 { $$ = declspecs_add_qual ($1, $2); }
942 | declspecs_nosc_nots_nosa_ea TYPE_QUAL
943 { $$ = declspecs_add_qual ($1, $2); }
946 declspecs_nosc_nots_nosa_ea:
947 declspecs_nosc_nots_nosa_noea attributes
948 { $$ = declspecs_add_attrs ($1, $2); }
951 declspecs_nosc_nots_sa_noea:
952 declspecs_nosc_nots_sa_noea TYPE_QUAL
953 { $$ = declspecs_add_qual ($1, $2); }
954 | declspecs_nosc_nots_sa_ea TYPE_QUAL
955 { $$ = declspecs_add_qual ($1, $2); }
958 declspecs_nosc_nots_sa_ea:
960 { $$ = declspecs_add_attrs (build_null_declspecs (), $1); }
961 | declspecs_nosc_nots_sa_noea attributes
962 { $$ = declspecs_add_attrs ($1, $2); }
965 declspecs_nosc_ts_nosa_noea:
967 { $$ = declspecs_add_type (build_null_declspecs (), $1); }
968 | declspecs_nosc_ts_nosa_noea TYPE_QUAL
969 { $$ = declspecs_add_qual ($1, $2); }
970 | declspecs_nosc_ts_nosa_ea TYPE_QUAL
971 { $$ = declspecs_add_qual ($1, $2); }
972 | declspecs_nosc_ts_nosa_noea typespec_reserved_nonattr
973 { $$ = declspecs_add_type ($1, $2); }
974 | declspecs_nosc_ts_nosa_ea typespec_reserved_nonattr
975 { $$ = declspecs_add_type ($1, $2); }
976 | declspecs_nosc_nots_nosa_noea typespec_nonattr
977 { $$ = declspecs_add_type ($1, $2); }
978 | declspecs_nosc_nots_nosa_ea typespec_nonattr
979 { $$ = declspecs_add_type ($1, $2); }
982 declspecs_nosc_ts_nosa_ea:
984 { $$ = declspecs_add_type (build_null_declspecs (), $1); }
985 | declspecs_nosc_ts_nosa_noea attributes
986 { $$ = declspecs_add_attrs ($1, $2); }
987 | declspecs_nosc_ts_nosa_noea typespec_reserved_attr
988 { $$ = declspecs_add_type ($1, $2); }
989 | declspecs_nosc_ts_nosa_ea typespec_reserved_attr
990 { $$ = declspecs_add_type ($1, $2); }
991 | declspecs_nosc_nots_nosa_noea typespec_attr
992 { $$ = declspecs_add_type ($1, $2); }
993 | declspecs_nosc_nots_nosa_ea typespec_attr
994 { $$ = declspecs_add_type ($1, $2); }
997 declspecs_nosc_ts_sa_noea:
998 declspecs_nosc_ts_sa_noea TYPE_QUAL
999 { $$ = declspecs_add_qual ($1, $2); }
1000 | declspecs_nosc_ts_sa_ea TYPE_QUAL
1001 { $$ = declspecs_add_qual ($1, $2); }
1002 | declspecs_nosc_ts_sa_noea typespec_reserved_nonattr
1003 { $$ = declspecs_add_type ($1, $2); }
1004 | declspecs_nosc_ts_sa_ea typespec_reserved_nonattr
1005 { $$ = declspecs_add_type ($1, $2); }
1006 | declspecs_nosc_nots_sa_noea typespec_nonattr
1007 { $$ = declspecs_add_type ($1, $2); }
1008 | declspecs_nosc_nots_sa_ea typespec_nonattr
1009 { $$ = declspecs_add_type ($1, $2); }
1012 declspecs_nosc_ts_sa_ea:
1013 declspecs_nosc_ts_sa_noea attributes
1014 { $$ = declspecs_add_attrs ($1, $2); }
1015 | declspecs_nosc_ts_sa_noea typespec_reserved_attr
1016 { $$ = declspecs_add_type ($1, $2); }
1017 | declspecs_nosc_ts_sa_ea typespec_reserved_attr
1018 { $$ = declspecs_add_type ($1, $2); }
1019 | declspecs_nosc_nots_sa_noea typespec_attr
1020 { $$ = declspecs_add_type ($1, $2); }
1021 | declspecs_nosc_nots_sa_ea typespec_attr
1022 { $$ = declspecs_add_type ($1, $2); }
1025 declspecs_sc_nots_nosa_noea:
1027 { $$ = declspecs_add_scspec (build_null_declspecs (), $1); }
1028 | declspecs_sc_nots_nosa_noea TYPE_QUAL
1029 { $$ = declspecs_add_qual ($1, $2); }
1030 | declspecs_sc_nots_nosa_ea TYPE_QUAL
1031 { $$ = declspecs_add_qual ($1, $2); }
1032 | declspecs_nosc_nots_nosa_noea scspec
1033 { $$ = declspecs_add_scspec ($1, $2); }
1034 | declspecs_nosc_nots_nosa_ea scspec
1035 { $$ = declspecs_add_scspec ($1, $2); }
1036 | declspecs_sc_nots_nosa_noea scspec
1037 { $$ = declspecs_add_scspec ($1, $2); }
1038 | declspecs_sc_nots_nosa_ea scspec
1039 { $$ = declspecs_add_scspec ($1, $2); }
1042 declspecs_sc_nots_nosa_ea:
1043 declspecs_sc_nots_nosa_noea attributes
1044 { $$ = declspecs_add_attrs ($1, $2); }
1047 declspecs_sc_nots_sa_noea:
1048 declspecs_sc_nots_sa_noea TYPE_QUAL
1049 { $$ = declspecs_add_qual ($1, $2); }
1050 | declspecs_sc_nots_sa_ea TYPE_QUAL
1051 { $$ = declspecs_add_qual ($1, $2); }
1052 | declspecs_nosc_nots_sa_noea scspec
1053 { $$ = declspecs_add_scspec ($1, $2); }
1054 | declspecs_nosc_nots_sa_ea scspec
1055 { $$ = declspecs_add_scspec ($1, $2); }
1056 | declspecs_sc_nots_sa_noea scspec
1057 { $$ = declspecs_add_scspec ($1, $2); }
1058 | declspecs_sc_nots_sa_ea scspec
1059 { $$ = declspecs_add_scspec ($1, $2); }
1062 declspecs_sc_nots_sa_ea:
1063 declspecs_sc_nots_sa_noea attributes
1064 { $$ = declspecs_add_attrs ($1, $2); }
1067 declspecs_sc_ts_nosa_noea:
1068 declspecs_sc_ts_nosa_noea TYPE_QUAL
1069 { $$ = declspecs_add_qual ($1, $2); }
1070 | declspecs_sc_ts_nosa_ea TYPE_QUAL
1071 { $$ = declspecs_add_qual ($1, $2); }
1072 | declspecs_sc_ts_nosa_noea typespec_reserved_nonattr
1073 { $$ = declspecs_add_type ($1, $2); }
1074 | declspecs_sc_ts_nosa_ea typespec_reserved_nonattr
1075 { $$ = declspecs_add_type ($1, $2); }
1076 | declspecs_sc_nots_nosa_noea typespec_nonattr
1077 { $$ = declspecs_add_type ($1, $2); }
1078 | declspecs_sc_nots_nosa_ea typespec_nonattr
1079 { $$ = declspecs_add_type ($1, $2); }
1080 | declspecs_nosc_ts_nosa_noea scspec
1081 { $$ = declspecs_add_scspec ($1, $2); }
1082 | declspecs_nosc_ts_nosa_ea scspec
1083 { $$ = declspecs_add_scspec ($1, $2); }
1084 | declspecs_sc_ts_nosa_noea scspec
1085 { $$ = declspecs_add_scspec ($1, $2); }
1086 | declspecs_sc_ts_nosa_ea scspec
1087 { $$ = declspecs_add_scspec ($1, $2); }
1090 declspecs_sc_ts_nosa_ea:
1091 declspecs_sc_ts_nosa_noea attributes
1092 { $$ = declspecs_add_attrs ($1, $2); }
1093 | declspecs_sc_ts_nosa_noea typespec_reserved_attr
1094 { $$ = declspecs_add_type ($1, $2); }
1095 | declspecs_sc_ts_nosa_ea typespec_reserved_attr
1096 { $$ = declspecs_add_type ($1, $2); }
1097 | declspecs_sc_nots_nosa_noea typespec_attr
1098 { $$ = declspecs_add_type ($1, $2); }
1099 | declspecs_sc_nots_nosa_ea typespec_attr
1100 { $$ = declspecs_add_type ($1, $2); }
1103 declspecs_sc_ts_sa_noea:
1104 declspecs_sc_ts_sa_noea TYPE_QUAL
1105 { $$ = declspecs_add_qual ($1, $2); }
1106 | declspecs_sc_ts_sa_ea TYPE_QUAL
1107 { $$ = declspecs_add_qual ($1, $2); }
1108 | declspecs_sc_ts_sa_noea typespec_reserved_nonattr
1109 { $$ = declspecs_add_type ($1, $2); }
1110 | declspecs_sc_ts_sa_ea typespec_reserved_nonattr
1111 { $$ = declspecs_add_type ($1, $2); }
1112 | declspecs_sc_nots_sa_noea typespec_nonattr
1113 { $$ = declspecs_add_type ($1, $2); }
1114 | declspecs_sc_nots_sa_ea typespec_nonattr
1115 { $$ = declspecs_add_type ($1, $2); }
1116 | declspecs_nosc_ts_sa_noea scspec
1117 { $$ = declspecs_add_scspec ($1, $2); }
1118 | declspecs_nosc_ts_sa_ea scspec
1119 { $$ = declspecs_add_scspec ($1, $2); }
1120 | declspecs_sc_ts_sa_noea scspec
1121 { $$ = declspecs_add_scspec ($1, $2); }
1122 | declspecs_sc_ts_sa_ea scspec
1123 { $$ = declspecs_add_scspec ($1, $2); }
1126 declspecs_sc_ts_sa_ea:
1127 declspecs_sc_ts_sa_noea attributes
1128 { $$ = declspecs_add_attrs ($1, $2); }
1129 | declspecs_sc_ts_sa_noea typespec_reserved_attr
1130 { $$ = declspecs_add_type ($1, $2); }
1131 | declspecs_sc_ts_sa_ea typespec_reserved_attr
1132 { $$ = declspecs_add_type ($1, $2); }
1133 | declspecs_sc_nots_sa_noea typespec_attr
1134 { $$ = declspecs_add_type ($1, $2); }
1135 | declspecs_sc_nots_sa_ea typespec_attr
1136 { $$ = declspecs_add_type ($1, $2); }
1139 /* Particular useful classes of declspecs. */
1141 declspecs_nosc_ts_nosa_noea
1142 | declspecs_nosc_ts_nosa_ea
1143 | declspecs_nosc_ts_sa_noea
1144 | declspecs_nosc_ts_sa_ea
1145 | declspecs_sc_ts_nosa_noea
1146 | declspecs_sc_ts_nosa_ea
1147 | declspecs_sc_ts_sa_noea
1148 | declspecs_sc_ts_sa_ea
1152 declspecs_nosc_nots_nosa_noea
1153 | declspecs_nosc_nots_nosa_ea
1154 | declspecs_nosc_nots_sa_noea
1155 | declspecs_nosc_nots_sa_ea
1156 | declspecs_sc_nots_nosa_noea
1157 | declspecs_sc_nots_nosa_ea
1158 | declspecs_sc_nots_sa_noea
1159 | declspecs_sc_nots_sa_ea
1163 declspecs_nosc_ts_nosa_noea
1164 | declspecs_nosc_ts_nosa_ea
1165 | declspecs_sc_ts_nosa_noea
1166 | declspecs_sc_ts_nosa_ea
1169 declspecs_nots_nosa:
1170 declspecs_nosc_nots_nosa_noea
1171 | declspecs_nosc_nots_nosa_ea
1172 | declspecs_sc_nots_nosa_noea
1173 | declspecs_sc_nots_nosa_ea
1177 declspecs_nosc_ts_nosa_noea
1178 | declspecs_nosc_ts_nosa_ea
1179 | declspecs_nosc_ts_sa_noea
1180 | declspecs_nosc_ts_sa_ea
1183 declspecs_nosc_nots:
1184 declspecs_nosc_nots_nosa_noea
1185 | declspecs_nosc_nots_nosa_ea
1186 | declspecs_nosc_nots_sa_noea
1187 | declspecs_nosc_nots_sa_ea
1191 declspecs_nosc_ts_nosa_noea
1192 | declspecs_nosc_ts_nosa_ea
1193 | declspecs_nosc_ts_sa_noea
1194 | declspecs_nosc_ts_sa_ea
1195 | declspecs_nosc_nots_nosa_noea
1196 | declspecs_nosc_nots_nosa_ea
1197 | declspecs_nosc_nots_sa_noea
1198 | declspecs_nosc_nots_sa_ea
1202 declspecs_nosc_nots_nosa_noea
1203 | declspecs_nosc_nots_nosa_ea
1204 | declspecs_nosc_nots_sa_noea
1205 | declspecs_nosc_nots_sa_ea
1206 | declspecs_nosc_ts_nosa_noea
1207 | declspecs_nosc_ts_nosa_ea
1208 | declspecs_nosc_ts_sa_noea
1209 | declspecs_nosc_ts_sa_ea
1210 | declspecs_sc_nots_nosa_noea
1211 | declspecs_sc_nots_nosa_ea
1212 | declspecs_sc_nots_sa_noea
1213 | declspecs_sc_nots_sa_ea
1214 | declspecs_sc_ts_nosa_noea
1215 | declspecs_sc_ts_nosa_ea
1216 | declspecs_sc_ts_sa_noea
1217 | declspecs_sc_ts_sa_ea
1220 /* A (possibly empty) sequence of type qualifiers and attributes. */
1221 maybe_type_quals_attrs:
1224 | declspecs_nosc_nots
1228 /* A type specifier (but not a type qualifier).
1229 Once we have seen one of these in a declaration,
1230 if a typedef name appears then it is being redeclared.
1232 The _reserved versions start with a reserved word and may appear anywhere
1233 in the declaration specifiers; the _nonreserved versions may only
1234 appear before any other type specifiers, and after that are (if names)
1237 FIXME: should the _nonreserved version be restricted to names being
1238 redeclared only? The other entries there relate only the GNU extensions
1239 and Objective C, and are historically parsed thus, and don't make sense
1240 after other type specifiers, but it might be cleaner to count them as
1243 _attr means: specifiers that either end with attributes,
1244 or are such that any following attributes would
1245 be parsed as part of the specifier.
1247 _nonattr: other specifiers not ending with attributes. */
1250 typespec_reserved_nonattr
1251 | typespec_nonreserved_nonattr
1255 typespec_reserved_attr
1258 typespec_reserved_nonattr:
1260 { OBJC_NEED_RAW_IDENTIFIER (1); }
1264 typespec_reserved_attr:
1268 typespec_nonreserved_nonattr:
1270 { /* For a typedef name, record the meaning, not the name.
1271 In case of `foo foo, bar;'. */
1272 $$ = lookup_name ($1); }
1274 | CLASSNAME protocolrefs
1275 { $$ = objc_get_protocol_qualified_type ($1, $2); }
1276 | OBJECTNAME protocolrefs
1277 { $$ = objc_get_protocol_qualified_type ($1, $2); }
1279 /* Make "<SomeProtocol>" equivalent to "id <SomeProtocol>"
1280 - nisse@lysator.liu.se */
1281 | non_empty_protocolrefs
1282 { $$ = objc_get_protocol_qualified_type (NULL_TREE, $1); }
1284 | typeof '(' expr ')'
1285 { skip_evaluation--;
1287 if (TREE_CODE ($3.value) == COMPONENT_REF
1288 && DECL_C_BIT_FIELD (TREE_OPERAND ($3.value, 1)))
1289 error ("%<typeof%> applied to a bit-field");
1290 $$ = TREE_TYPE ($3.value);
1291 pop_maybe_used (variably_modified_type_p ($$, NULL_TREE)); }
1292 | typeof '(' typename ')'
1293 { skip_evaluation--; in_typeof--; $$ = groktypename ($3);
1294 pop_maybe_used (variably_modified_type_p ($$, NULL_TREE)); }
1297 /* typespec_nonreserved_attr does not exist. */
1301 | initdecls ',' maybe_resetattrs initdcl
1306 | notype_initdecls ',' maybe_resetattrs notype_initdcl
1310 declarator maybeasm maybe_attribute '='
1311 { $<ttype>$ = start_decl ($1, current_declspecs, true,
1312 chainon ($3, all_prefix_attributes));
1313 start_init ($<ttype>$, $2, global_bindings_p ()); }
1315 /* Note how the declaration of the variable is in effect while its init is parsed! */
1317 maybe_warn_string_init (TREE_TYPE ($<ttype>5), $6);
1318 finish_decl ($<ttype>5, $6.value, $2); }
1319 | declarator maybeasm maybe_attribute
1320 { tree d = start_decl ($1, current_declspecs, false,
1321 chainon ($3, all_prefix_attributes));
1322 finish_decl (d, NULL_TREE, $2);
1327 notype_declarator maybeasm maybe_attribute '='
1328 { $<ttype>$ = start_decl ($1, current_declspecs, true,
1329 chainon ($3, all_prefix_attributes));
1330 start_init ($<ttype>$, $2, global_bindings_p ()); }
1332 /* Note how the declaration of the variable is in effect while its init is parsed! */
1334 maybe_warn_string_init (TREE_TYPE ($<ttype>5), $6);
1335 finish_decl ($<ttype>5, $6.value, $2); }
1336 | notype_declarator maybeasm maybe_attribute
1337 { tree d = start_decl ($1, current_declspecs, false,
1338 chainon ($3, all_prefix_attributes));
1339 finish_decl (d, NULL_TREE, $2); }
1341 /* the * rules are dummies to accept the Apollo extended syntax
1342 so that the header files compile. */
1353 | attributes attribute
1354 { $$ = chainon ($1, $2); }
1358 ATTRIBUTE stop_string_translation
1359 '(' '(' attribute_list ')' ')' start_string_translation
1361 | ATTRIBUTE error start_string_translation
1368 | attribute_list ',' attrib
1369 { $$ = chainon ($1, $3); }
1376 { $$ = build_tree_list ($1, NULL_TREE); }
1377 | any_word '(' IDENTIFIER ')'
1378 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1379 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1380 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1381 | any_word '(' exprlist ')'
1382 { $$ = build_tree_list ($1, $3); }
1385 /* This still leaves out most reserved keywords,
1386 shouldn't we include them? */
1400 /* Initializers. `init' is the entry point. */
1406 { really_start_incremental_init (NULL_TREE); }
1407 initlist_maybe_comma '}'
1408 { $$ = pop_init_level (0); }
1410 { $$.value = error_mark_node; $$.original_code = ERROR_MARK; }
1413 /* `initlist_maybe_comma' is the guts of an initializer in braces. */
1414 initlist_maybe_comma:
1417 pedwarn ("ISO C forbids empty initializer braces"); }
1418 | initlist1 maybecomma
1423 | initlist1 ',' initelt
1426 /* `initelt' is a single element of an initializer.
1427 It may use braces. */
1429 designator_list '=' initval
1430 { if (pedantic && ! flag_isoc99)
1431 pedwarn ("ISO C90 forbids specifying subobject to initialize"); }
1432 | designator initval
1434 pedwarn ("obsolete use of designated initializer without %<=%>"); }
1436 { set_init_label ($1);
1438 pedwarn ("obsolete use of designated initializer with %<:%>"); }
1446 { push_init_level (0); }
1447 initlist_maybe_comma '}'
1448 { process_init_element (pop_init_level (0)); }
1450 { process_init_element ($1); }
1456 | designator_list designator
1461 { set_init_label ($2); }
1462 | '[' expr_no_commas ELLIPSIS expr_no_commas ']'
1463 { set_init_index ($2.value, $4.value);
1465 pedwarn ("ISO C forbids specifying range of elements to initialize"); }
1466 | '[' expr_no_commas ']'
1467 { set_init_index ($2.value, NULL_TREE); }
1473 pedwarn ("ISO C forbids nested functions");
1475 push_function_context ();
1476 if (! start_function (current_declspecs, $1,
1477 all_prefix_attributes))
1479 pop_function_context ();
1483 old_style_parm_decls save_location
1484 { tree decl = current_function_decl;
1485 DECL_SOURCE_LOCATION (decl) = $4;
1486 store_parm_decls (); }
1487 /* This used to use compstmt_or_error. That caused a bug with
1488 input `f(g) int g {}', where the use of YYERROR1 above caused
1489 an error which then was handled by compstmt_or_error. There
1490 followed a repeated execution of that same rule, which called
1491 YYERROR1 again, and so on. */
1493 { tree decl = current_function_decl;
1496 pop_function_context ();
1497 add_stmt (build_stmt (DECL_EXPR, decl)); }
1500 notype_nested_function:
1503 pedwarn ("ISO C forbids nested functions");
1505 push_function_context ();
1506 if (! start_function (current_declspecs, $1,
1507 all_prefix_attributes))
1509 pop_function_context ();
1513 old_style_parm_decls save_location
1514 { tree decl = current_function_decl;
1515 DECL_SOURCE_LOCATION (decl) = $4;
1516 store_parm_decls (); }
1517 /* This used to use compstmt_or_error. That caused a bug with
1518 input `f(g) int g {}', where the use of YYERROR1 above caused
1519 an error which then was handled by compstmt_or_error. There
1520 followed a repeated execution of that same rule, which called
1521 YYERROR1 again, and so on. */
1523 { tree decl = current_function_decl;
1526 pop_function_context ();
1527 add_stmt (build_stmt (DECL_EXPR, decl)); }
1530 /* Any kind of declarator (thus, all declarators allowed
1531 after an explicit typespec). */
1534 after_type_declarator
1538 /* A declarator that is allowed only after an explicit typespec. */
1540 after_type_declarator:
1541 '(' maybe_attribute after_type_declarator ')'
1542 { $$ = $2 ? build_attrs_declarator ($2, $3) : $3; }
1543 | after_type_declarator '(' parmlist_or_identifiers %prec '.'
1544 { $$ = build_function_declarator ($3, $1); }
1545 | after_type_declarator array_declarator %prec '.'
1546 { $$ = set_array_declarator_inner ($2, $1, false); }
1547 | '*' maybe_type_quals_attrs after_type_declarator %prec UNARY
1548 { $$ = make_pointer_declarator ($2, $3); }
1550 { $$ = build_id_declarator ($1); }
1553 { $$ = build_id_declarator ($1); }
1557 /* Kinds of declarator that can appear in a parameter list
1558 in addition to notype_declarator. This is like after_type_declarator
1559 but does not allow a typedef name in parentheses as an identifier
1560 (because it would conflict with a function with that typedef as arg). */
1562 parm_declarator_starttypename
1563 | parm_declarator_nostarttypename
1566 parm_declarator_starttypename:
1567 parm_declarator_starttypename '(' parmlist_or_identifiers %prec '.'
1568 { $$ = build_function_declarator ($3, $1); }
1569 | parm_declarator_starttypename array_declarator %prec '.'
1570 { $$ = set_array_declarator_inner ($2, $1, false); }
1572 { $$ = build_id_declarator ($1); }
1575 { $$ = build_id_declarator ($1); }
1579 parm_declarator_nostarttypename:
1580 parm_declarator_nostarttypename '(' parmlist_or_identifiers %prec '.'
1581 { $$ = build_function_declarator ($3, $1); }
1582 | parm_declarator_nostarttypename array_declarator %prec '.'
1583 { $$ = set_array_declarator_inner ($2, $1, false); }
1584 | '*' maybe_type_quals_attrs parm_declarator_starttypename %prec UNARY
1585 { $$ = make_pointer_declarator ($2, $3); }
1586 | '*' maybe_type_quals_attrs parm_declarator_nostarttypename %prec UNARY
1587 { $$ = make_pointer_declarator ($2, $3); }
1588 | '(' maybe_attribute parm_declarator_nostarttypename ')'
1589 { $$ = $2 ? build_attrs_declarator ($2, $3) : $3; }
1592 /* A declarator allowed whether or not there has been
1593 an explicit typespec. These cannot redeclare a typedef-name. */
1596 notype_declarator '(' parmlist_or_identifiers %prec '.'
1597 { $$ = build_function_declarator ($3, $1); }
1598 | '(' maybe_attribute notype_declarator ')'
1599 { $$ = $2 ? build_attrs_declarator ($2, $3) : $3; }
1600 | '*' maybe_type_quals_attrs notype_declarator %prec UNARY
1601 { $$ = make_pointer_declarator ($2, $3); }
1602 | notype_declarator array_declarator %prec '.'
1603 { $$ = set_array_declarator_inner ($2, $1, false); }
1605 { $$ = build_id_declarator ($1); }
1629 /* structsp_attr: struct/union/enum specifiers that either
1630 end with attributes, or are such that any following attributes would
1631 be parsed as part of the struct/union/enum specifier.
1633 structsp_nonattr: other struct/union/enum specifiers. */
1636 struct_head identifier '{'
1637 { $$ = start_struct (RECORD_TYPE, $2);
1638 /* Start scope of tag before parsing components. */
1640 component_decl_list '}' maybe_attribute
1641 { $$ = finish_struct ($<ttype>4, nreverse ($5),
1642 chainon ($1, $7)); }
1643 | struct_head '{' component_decl_list '}' maybe_attribute
1644 { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
1645 nreverse ($3), chainon ($1, $5));
1647 | union_head identifier '{'
1648 { $$ = start_struct (UNION_TYPE, $2); }
1649 component_decl_list '}' maybe_attribute
1650 { $$ = finish_struct ($<ttype>4, nreverse ($5),
1651 chainon ($1, $7)); }
1652 | union_head '{' component_decl_list '}' maybe_attribute
1653 { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
1654 nreverse ($3), chainon ($1, $5));
1656 | enum_head identifier '{'
1657 { $$ = start_enum ($2); }
1658 enumlist maybecomma_warn '}' maybe_attribute
1659 { $$ = finish_enum ($<ttype>4, nreverse ($5),
1660 chainon ($1, $8)); }
1662 { $$ = start_enum (NULL_TREE); }
1663 enumlist maybecomma_warn '}' maybe_attribute
1664 { $$ = finish_enum ($<ttype>3, nreverse ($4),
1665 chainon ($1, $7)); }
1669 struct_head identifier
1670 { $$ = xref_tag (RECORD_TYPE, $2); }
1671 | union_head identifier
1672 { $$ = xref_tag (UNION_TYPE, $2); }
1673 | enum_head identifier
1674 { $$ = xref_tag (ENUMERAL_TYPE, $2);
1675 /* In ISO C, enumerated types can be referred to
1676 only if already defined. */
1677 if (pedantic && !COMPLETE_TYPE_P ($$))
1678 pedwarn ("ISO C forbids forward references to %<enum%> types"); }
1689 { if (pedantic && ! flag_isoc99)
1690 pedwarn ("comma at end of enumerator list"); }
1693 /* We chain the components in reverse order. They are put in forward
1694 order in structsp_attr.
1696 Note that component_declarator returns single decls, so components
1697 and components_notype can use TREE_CHAIN directly, wheras components
1698 and components_notype return lists (of comma separated decls), so
1699 component_decl_list and component_decl_list2 must use chainon.
1701 The theory behind all this is that there will be more semicolon
1702 separated fields than comma separated fields, and so we'll be
1703 minimizing the number of node traversals required by chainon. */
1705 component_decl_list:
1706 component_decl_list2
1708 | component_decl_list2 component_decl
1709 { $$ = chainon ($2, $1);
1710 pedwarn ("no semicolon at end of struct or union"); }
1713 component_decl_list2: /* empty */
1715 | component_decl_list2 component_decl ';'
1716 { $$ = chainon ($2, $1); }
1717 | component_decl_list2 ';'
1719 pedwarn ("extra semicolon in struct or union specified"); }
1721 /* foo(sizeof(struct{ @defs(ClassName)})); */
1722 | AT_DEFS '(' CLASSNAME ')'
1723 { $$ = nreverse (objc_get_class_ivars ($3)); }
1728 declspecs_nosc_ts setspecs components
1730 POP_DECLSPEC_STACK; }
1731 | declspecs_nosc_ts setspecs
1733 /* Support for unnamed structs or unions as members of
1734 structs or unions (which is [a] useful and [b] supports
1737 pedwarn ("ISO C doesn't support unnamed structs/unions");
1739 $$ = grokfield (build_id_declarator (NULL_TREE),
1740 current_declspecs, NULL_TREE);
1741 POP_DECLSPEC_STACK; }
1742 | declspecs_nosc_nots setspecs components_notype
1744 POP_DECLSPEC_STACK; }
1745 | declspecs_nosc_nots
1747 pedwarn ("ISO C forbids member declarations with no members");
1748 shadow_tag_warned ($1, pedantic);
1752 | extension component_decl
1754 RESTORE_EXT_FLAGS ($1); }
1758 component_declarator
1759 | components ',' maybe_resetattrs component_declarator
1760 { TREE_CHAIN ($4) = $1; $$ = $4; }
1764 component_notype_declarator
1765 | components_notype ',' maybe_resetattrs component_notype_declarator
1766 { TREE_CHAIN ($4) = $1; $$ = $4; }
1769 component_declarator:
1770 declarator maybe_attribute
1771 { $$ = grokfield ($1, current_declspecs, NULL_TREE);
1772 decl_attributes (&$$,
1773 chainon ($2, all_prefix_attributes), 0); }
1774 | declarator ':' expr_no_commas maybe_attribute
1775 { $$ = grokfield ($1, current_declspecs, $3.value);
1776 decl_attributes (&$$,
1777 chainon ($4, all_prefix_attributes), 0); }
1778 | ':' expr_no_commas maybe_attribute
1779 { $$ = grokfield (build_id_declarator (NULL_TREE),
1780 current_declspecs, $2.value);
1781 decl_attributes (&$$,
1782 chainon ($3, all_prefix_attributes), 0); }
1785 component_notype_declarator:
1786 notype_declarator maybe_attribute
1787 { $$ = grokfield ($1, current_declspecs, NULL_TREE);
1788 decl_attributes (&$$,
1789 chainon ($2, all_prefix_attributes), 0); }
1790 | notype_declarator ':' expr_no_commas maybe_attribute
1791 { $$ = grokfield ($1, current_declspecs, $3.value);
1792 decl_attributes (&$$,
1793 chainon ($4, all_prefix_attributes), 0); }
1794 | ':' expr_no_commas maybe_attribute
1795 { $$ = grokfield (build_id_declarator (NULL_TREE),
1796 current_declspecs, $2.value);
1797 decl_attributes (&$$,
1798 chainon ($3, all_prefix_attributes), 0); }
1801 /* We chain the enumerators in reverse order.
1802 They are put in forward order in structsp_attr. */
1806 | enumlist ',' enumerator
1807 { if ($1 == error_mark_node)
1810 TREE_CHAIN ($3) = $1, $$ = $3; }
1812 { $$ = error_mark_node; }
1818 { $$ = build_enumerator ($1, NULL_TREE); }
1819 | identifier '=' expr_no_commas
1820 { $$ = build_enumerator ($1, $3.value); }
1825 { pending_xref_error ();
1828 { $$ = XOBNEW (&parser_obstack, struct c_type_name);
1829 $$->specs = $<dsptype>2;
1830 $$->declarator = $3; }
1833 absdcl: /* an absolute declarator */
1835 { $$ = build_id_declarator (NULL_TREE); }
1839 absdcl_maybe_attribute: /* absdcl maybe_attribute, but not just attributes */
1841 { $$ = build_c_parm (current_declspecs, all_prefix_attributes,
1842 build_id_declarator (NULL_TREE)); }
1844 { $$ = build_c_parm (current_declspecs, all_prefix_attributes,
1846 | absdcl1_noea attributes
1847 { $$ = build_c_parm (current_declspecs,
1848 chainon ($2, all_prefix_attributes),
1852 absdcl1: /* a nonempty absolute declarator */
1859 | '*' maybe_type_quals_attrs absdcl1_noea
1860 { $$ = make_pointer_declarator ($2, $3); }
1864 '*' maybe_type_quals_attrs
1865 { $$ = make_pointer_declarator
1866 ($2, build_id_declarator (NULL_TREE)); }
1867 | '*' maybe_type_quals_attrs absdcl1_ea
1868 { $$ = make_pointer_declarator ($2, $3); }
1872 '(' maybe_attribute absdcl1 ')'
1873 { $$ = $2 ? build_attrs_declarator ($2, $3) : $3; }
1874 | direct_absdcl1 '(' parmlist
1875 { $$ = build_function_declarator ($3, $1); }
1876 | direct_absdcl1 array_declarator
1877 { $$ = set_array_declarator_inner ($2, $1, true); }
1879 { $$ = build_function_declarator
1880 ($2, build_id_declarator (NULL_TREE)); }
1882 { $$ = set_array_declarator_inner
1883 ($1, build_id_declarator (NULL_TREE), true); }
1886 /* The [...] part of a declarator for an array type. */
1889 '[' maybe_type_quals_attrs expr_no_commas ']'
1890 { $$ = build_array_declarator ($3.value, $2, false, false); }
1891 | '[' maybe_type_quals_attrs ']'
1892 { $$ = build_array_declarator (NULL_TREE, $2, false, false); }
1893 | '[' maybe_type_quals_attrs '*' ']'
1894 { $$ = build_array_declarator (NULL_TREE, $2, false, true); }
1895 | '[' STATIC maybe_type_quals_attrs expr_no_commas ']'
1896 { $$ = build_array_declarator ($4.value, $3, true, false); }
1897 /* declspecs_nosc_nots is a synonym for type_quals_attrs. */
1898 | '[' declspecs_nosc_nots STATIC expr_no_commas ']'
1899 { $$ = build_array_declarator ($4.value, $2, true, false); }
1902 /* A nonempty series of declarations and statements (possibly followed by
1903 some labels) that can form the body of a compound statement.
1904 NOTE: we don't allow labels on declarations; this might seem like a
1905 natural extension, but there would be a conflict between attributes
1906 on the label and prefix attributes on the declaration. */
1909 lineno_stmt_decl_or_labels_ending_stmt
1910 | lineno_stmt_decl_or_labels_ending_decl
1911 | lineno_stmt_decl_or_labels_ending_label
1913 error ("label at end of compound statement");
1915 | lineno_stmt_decl_or_labels_ending_error
1918 lineno_stmt_decl_or_labels_ending_stmt:
1920 | lineno_stmt_decl_or_labels_ending_stmt lineno_stmt
1921 | lineno_stmt_decl_or_labels_ending_decl lineno_stmt
1922 | lineno_stmt_decl_or_labels_ending_label lineno_stmt
1923 | lineno_stmt_decl_or_labels_ending_error lineno_stmt
1926 lineno_stmt_decl_or_labels_ending_decl:
1928 | lineno_stmt_decl_or_labels_ending_stmt lineno_decl
1930 if ((pedantic && !flag_isoc99)
1931 || warn_declaration_after_statement)
1932 pedwarn_c90 ("ISO C90 forbids mixed declarations and code");
1934 | lineno_stmt_decl_or_labels_ending_decl lineno_decl
1935 | lineno_stmt_decl_or_labels_ending_error lineno_decl
1938 lineno_stmt_decl_or_labels_ending_label:
1940 | lineno_stmt_decl_or_labels_ending_stmt lineno_label
1941 | lineno_stmt_decl_or_labels_ending_decl lineno_label
1942 | lineno_stmt_decl_or_labels_ending_label lineno_label
1943 | lineno_stmt_decl_or_labels_ending_error lineno_label
1946 lineno_stmt_decl_or_labels_ending_error:
1948 | lineno_stmt_decl_or_labels errstmt
1951 lineno_stmt_decl_or_labels:
1952 lineno_stmt_decl_or_labels_ending_stmt
1953 | lineno_stmt_decl_or_labels_ending_decl
1954 | lineno_stmt_decl_or_labels_ending_label
1955 | lineno_stmt_decl_or_labels_ending_error
1961 /* Start and end blocks created for the new scopes of C99. */
1962 c99_block_start: /* empty */
1963 { $$ = c_begin_compound_stmt (flag_isoc99); }
1966 /* Read zero or more forward-declarations for labels
1967 that nested functions can jump to. */
1972 pedwarn ("ISO C forbids label declarations"); }
1977 | label_decls label_decl
1981 LABEL identifiers_or_typenames ';'
1983 for (link = $2; link; link = TREE_CHAIN (link))
1985 tree label = declare_label (TREE_VALUE (link));
1986 C_DECLARED_LABEL_FLAG (label) = 1;
1987 add_stmt (build_stmt (DECL_EXPR, label));
1992 /* This is the body of a function definition.
1993 It causes syntax errors to ignore to the next openbrace. */
2000 compstmt_start: '{' { $$ = c_begin_compound_stmt (true); }
2003 compstmt_nostart: '}'
2004 | maybe_label_decls compstmt_contents_nonempty '}'
2007 compstmt_contents_nonempty:
2012 compstmt_primary_start:
2014 { if (current_function_decl == 0)
2016 error ("braced-group within expression allowed "
2017 "only inside a function");
2020 $$ = c_begin_stmt_expr ();
2024 compstmt: compstmt_start compstmt_nostart
2025 { $$ = c_end_compound_stmt ($1, true); }
2028 /* The forced readahead in here is because we might be at the end of a
2029 line, and the line and file won't be bumped until yylex absorbs the
2030 first token on the next line. */
2033 { if (yychar == YYEMPTY)
2035 $$ = input_location; }
2040 | lineno_labels lineno_label
2043 /* A labeled statement. In C99 it also generates an implicit block. */
2044 c99_block_lineno_labeled_stmt:
2045 c99_block_start lineno_labels lineno_stmt
2046 { $$ = c_end_compound_stmt ($1, flag_isoc99); }
2052 /* Two cases cannot and do not have line numbers associated:
2053 If stmt is degenerate, such as "2;", then stmt is an
2054 INTEGER_CST, which cannot hold line numbers. But that's
2055 ok because the statement will either be changed to a
2056 MODIFY_EXPR during gimplification of the statement expr,
2057 or discarded. If stmt was compound, but without new
2058 variables, we will have skipped the creation of a BIND
2059 and will have a bare STATEMENT_LIST. But that's ok
2060 because (recursively) all of the component statments
2061 should already have line numbers assigned. */
2062 if ($2 && EXPR_P ($2))
2063 SET_EXPR_LOCATION ($2, $1);
2069 { if ($2) SET_EXPR_LOCATION ($2, $1); }
2072 condition: save_location expr
2073 { $$ = lang_hooks.truthvalue_conversion ($2.value);
2075 SET_EXPR_LOCATION ($$, $1); }
2078 /* Implement -Wparenthesis by special casing IF statement directly nested
2079 within IF statement. This requires some amount of duplication of the
2080 productions under c99_block_lineno_labeled_stmt in order to work out.
2081 But it's still likely more maintainable than lots of state outside the
2085 c99_block_start lineno_labels if_statement
2086 { $$ = c_end_compound_stmt ($1, flag_isoc99); }
2090 c99_block_start lineno_labels ';'
2091 { if (extra_warnings)
2092 add_stmt (build (NOP_EXPR, NULL_TREE, NULL_TREE));
2093 $$ = c_end_compound_stmt ($1, flag_isoc99); }
2094 | c99_block_lineno_labeled_stmt
2098 IF c99_block_start save_location '(' condition ')'
2099 if_statement_1 ELSE if_statement_2
2100 { c_finish_if_stmt ($3, $5, $7, $9, true);
2101 add_stmt (c_end_compound_stmt ($2, flag_isoc99)); }
2102 | IF c99_block_start save_location '(' condition ')'
2103 if_statement_2 ELSE if_statement_2
2104 { c_finish_if_stmt ($3, $5, $7, $9, false);
2105 add_stmt (c_end_compound_stmt ($2, flag_isoc99)); }
2106 | IF c99_block_start save_location '(' condition ')'
2107 if_statement_1 %prec IF
2108 { c_finish_if_stmt ($3, $5, $7, NULL, true);
2109 add_stmt (c_end_compound_stmt ($2, flag_isoc99)); }
2110 | IF c99_block_start save_location '(' condition ')'
2111 if_statement_2 %prec IF
2112 { c_finish_if_stmt ($3, $5, $7, NULL, false);
2113 add_stmt (c_end_compound_stmt ($2, flag_isoc99)); }
2116 start_break: /* empty */
2117 { $$ = c_break_label; c_break_label = NULL; }
2120 start_continue: /* empty */
2121 { $$ = c_cont_label; c_cont_label = NULL; }
2125 WHILE c99_block_start save_location '(' condition ')'
2126 start_break start_continue c99_block_lineno_labeled_stmt
2127 { c_finish_loop ($3, $5, NULL, $9, c_break_label,
2128 c_cont_label, true);
2129 add_stmt (c_end_compound_stmt ($2, flag_isoc99));
2130 c_break_label = $7; c_cont_label = $8; }
2134 DO c99_block_start save_location start_break start_continue
2135 c99_block_lineno_labeled_stmt WHILE
2136 { $<ttype>$ = c_break_label; c_break_label = $4; }
2137 { $<ttype>$ = c_cont_label; c_cont_label = $5; }
2138 '(' condition ')' ';'
2139 { c_finish_loop ($3, $11, NULL, $6, $<ttype>8,
2141 add_stmt (c_end_compound_stmt ($2, flag_isoc99)); }
2153 { c_finish_expr_stmt ($1); }
2155 { check_for_loop_decls (); }
2158 for_cond_expr: save_location xexpr
2161 $$ = lang_hooks.truthvalue_conversion ($2);
2163 SET_EXPR_LOCATION ($$, $1);
2170 for_incr_expr: xexpr
2171 { $$ = c_process_expr_stmt ($1); }
2175 FOR c99_block_start '(' for_init_stmt
2176 save_location for_cond_expr ';' for_incr_expr ')'
2177 start_break start_continue c99_block_lineno_labeled_stmt
2178 { c_finish_loop ($5, $6, $8, $12, c_break_label,
2179 c_cont_label, true);
2180 add_stmt (c_end_compound_stmt ($2, flag_isoc99));
2181 c_break_label = $10; c_cont_label = $11; }
2185 SWITCH c99_block_start '(' expr ')'
2186 { $<ttype>$ = c_start_case ($4.value); }
2187 start_break c99_block_lineno_labeled_stmt
2188 { c_finish_case ($8);
2190 add_stmt (build (LABEL_EXPR, void_type_node,
2193 add_stmt (c_end_compound_stmt ($2, flag_isoc99)); }
2196 /* Parse a single real statement, not including any labels or compounds. */
2199 { $$ = c_finish_expr_stmt ($1.value); }
2211 { $$ = c_finish_bc_stmt (&c_break_label, true); }
2213 { $$ = c_finish_bc_stmt (&c_cont_label, false); }
2215 { $$ = c_finish_return (NULL_TREE); }
2217 { $$ = c_finish_return ($2.value); }
2219 | GOTO identifier ';'
2220 { $$ = c_finish_goto_label ($2); }
2222 { $$ = c_finish_goto_ptr ($3.value); }
2227 { $$ = objc_build_throw_stmt ($2.value); }
2229 { $$ = objc_build_throw_stmt (NULL_TREE); }
2230 | objc_try_catch_stmt
2232 | AT_SYNCHRONIZED save_location '(' expr ')' compstmt
2233 { objc_build_synchronized ($2, $4.value, $6); $$ = NULL_TREE; }
2237 AT_CATCH '(' parm ')'
2238 { objc_begin_catch_clause (grokparm ($3)); }
2242 objc_catch_prefix '{' compstmt_nostart
2243 { objc_finish_catch_clause (); }
2244 | objc_catch_prefix '{' error '}'
2245 { objc_finish_catch_clause (); }
2248 objc_opt_catch_list:
2250 | objc_opt_catch_list objc_catch_clause
2253 objc_try_catch_clause:
2254 AT_TRY save_location compstmt
2255 { objc_begin_try_stmt ($2, $3); }
2259 objc_finally_clause:
2260 AT_FINALLY save_location compstmt
2261 { objc_build_finally_clause ($2, $3); }
2264 objc_try_catch_stmt:
2265 objc_try_catch_clause
2266 { objc_finish_try_stmt (); }
2267 | objc_try_catch_clause objc_finally_clause
2268 { objc_finish_try_stmt (); }
2272 /* Parse a single or compound real statement, not including any labels. */
2275 { add_stmt ($1); $$ = NULL_TREE; }
2279 /* Any kind of label, including jump labels and case labels.
2280 ANSI C accepts labels only before statements, but we allow them
2281 also at the end of a compound statement. */
2283 label: CASE expr_no_commas ':'
2284 { $$ = do_case ($2.value, NULL_TREE); }
2285 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
2286 { $$ = do_case ($2.value, $4.value); }
2288 { $$ = do_case (NULL_TREE, NULL_TREE); }
2289 | identifier save_location ':' maybe_attribute
2290 { tree label = define_label ($2, $1);
2293 decl_attributes (&label, $4, 0);
2294 $$ = add_stmt (build_stmt (LABEL_EXPR, label));
2301 /* Asm expressions and statements */
2303 /* simple_asm_expr is used in restricted contexts, where a full
2304 expression with inputs and outputs does not make sense. */
2306 ASM_KEYWORD stop_string_translation
2307 '(' STRING ')' start_string_translation
2311 /* maybeasm: used for assembly names for declarations */
2318 /* asmdef: asm() outside a function body. */
2321 { assemble_asm ($1); }
2322 | ASM_KEYWORD error start_string_translation ';'
2326 /* Full-blown asm statement with inputs, outputs, clobbers, and
2327 volatile tag allowed. */
2329 ASM_KEYWORD maybe_volatile stop_string_translation
2330 '(' asm_argument ')' start_string_translation ';'
2331 { $$ = build_asm_stmt ($2, $5); }
2337 { $$ = build_asm_expr ($1, 0, 0, 0, true); }
2338 /* output operands */
2339 | STRING ':' asm_operands
2340 { $$ = build_asm_expr ($1, $3, 0, 0, false); }
2341 /* output and input operands */
2342 | STRING ':' asm_operands ':' asm_operands
2343 { $$ = build_asm_expr ($1, $3, $5, 0, false); }
2344 /* output and input operands and clobbers */
2345 | STRING ':' asm_operands ':' asm_operands ':' asm_clobbers
2346 { $$ = build_asm_expr ($1, $3, $5, $7, false); }
2349 /* Either 'volatile' or nothing. First thing in an `asm' statement. */
2355 { if ($1 != ridpointers[RID_VOLATILE])
2357 warning ("%E qualifier ignored on asm", $1);
2365 /* These are the operands other than the first string and colon
2366 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
2367 asm_operands: /* empty */
2369 | nonnull_asm_operands
2372 nonnull_asm_operands:
2374 | nonnull_asm_operands ',' asm_operand
2375 { $$ = chainon ($1, $3); }
2379 STRING start_string_translation '(' expr ')' stop_string_translation
2380 { $$ = build_tree_list (build_tree_list (NULL_TREE, $1),
2382 | '[' identifier ']' STRING start_string_translation
2383 '(' expr ')' stop_string_translation
2384 { $2 = build_string (IDENTIFIER_LENGTH ($2),
2385 IDENTIFIER_POINTER ($2));
2386 $$ = build_tree_list (build_tree_list ($2, $4), $7.value); }
2391 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
2392 | asm_clobbers ',' STRING
2393 { $$ = tree_cons (NULL_TREE, $3, $1); }
2396 stop_string_translation:
2397 { c_lex_string_translate = 0; }
2400 start_string_translation:
2401 { c_lex_string_translate = 1; }
2405 /* This is what appears inside the parens in a function declarator.
2406 Its value is a list of ..._TYPE nodes. Attributes must appear here
2407 to avoid a conflict with their appearance after an open parenthesis
2408 in an abstract declarator, as in
2409 "void bar (int (__attribute__((__mode__(SI))) int foo));". */
2413 declare_parm_level (); }
2422 { mark_forward_parm_decls (); }
2424 { /* Dummy action so attributes are in known place
2425 on parser stack. */ }
2429 { $$ = XOBNEW (&parser_obstack, struct c_arg_info);
2436 /* This is what appears inside the parens in a function declarator.
2437 Its value is represented in the format that grokdeclarator expects. */
2438 parmlist_2: /* empty */
2439 { $$ = XOBNEW (&parser_obstack, struct c_arg_info);
2445 { $$ = XOBNEW (&parser_obstack, struct c_arg_info);
2449 /* Suppress -Wold-style-definition for this case. */
2450 $$->types = error_mark_node;
2451 error ("ISO C requires a named argument before %<...%>");
2454 { $$ = get_parm_info (/*ellipsis=*/false); }
2455 | parms ',' ELLIPSIS
2456 { $$ = get_parm_info (/*ellipsis=*/true); }
2461 { push_parm_decl ($1); }
2463 { push_parm_decl ($3); }
2466 /* A single parameter declaration or parameter type name,
2467 as found in a parmlist. */
2469 declspecs_ts setspecs parm_declarator maybe_attribute
2470 { $$ = build_c_parm (current_declspecs,
2471 chainon ($4, all_prefix_attributes), $3);
2472 POP_DECLSPEC_STACK; }
2473 | declspecs_ts setspecs notype_declarator maybe_attribute
2474 { $$ = build_c_parm (current_declspecs,
2475 chainon ($4, all_prefix_attributes), $3);
2476 POP_DECLSPEC_STACK; }
2477 | declspecs_ts setspecs absdcl_maybe_attribute
2479 POP_DECLSPEC_STACK; }
2480 | declspecs_nots setspecs notype_declarator maybe_attribute
2481 { $$ = build_c_parm (current_declspecs,
2482 chainon ($4, all_prefix_attributes), $3);
2483 POP_DECLSPEC_STACK; }
2485 | declspecs_nots setspecs absdcl_maybe_attribute
2487 POP_DECLSPEC_STACK; }
2490 /* The first parm, which must suck attributes from off the top of the parser
2493 declspecs_ts_nosa setspecs_fp parm_declarator maybe_attribute
2494 { $$ = build_c_parm (current_declspecs,
2495 chainon ($4, all_prefix_attributes), $3);
2496 POP_DECLSPEC_STACK; }
2497 | declspecs_ts_nosa setspecs_fp notype_declarator maybe_attribute
2498 { $$ = build_c_parm (current_declspecs,
2499 chainon ($4, all_prefix_attributes), $3);
2500 POP_DECLSPEC_STACK; }
2501 | declspecs_ts_nosa setspecs_fp absdcl_maybe_attribute
2503 POP_DECLSPEC_STACK; }
2504 | declspecs_nots_nosa setspecs_fp notype_declarator maybe_attribute
2505 { $$ = build_c_parm (current_declspecs,
2506 chainon ($4, all_prefix_attributes), $3);
2507 POP_DECLSPEC_STACK; }
2509 | declspecs_nots_nosa setspecs_fp absdcl_maybe_attribute
2511 POP_DECLSPEC_STACK; }
2516 { prefix_attributes = chainon (prefix_attributes, $<ttype>-2);
2517 all_prefix_attributes = prefix_attributes; }
2520 /* This is used in a function definition
2521 where either a parmlist or an identifier list is ok.
2522 Its value is a list of ..._TYPE nodes or a list of identifiers. */
2523 parmlist_or_identifiers:
2526 declare_parm_level (); }
2527 parmlist_or_identifiers_1
2532 parmlist_or_identifiers_1:
2535 { $$ = XOBNEW (&parser_obstack, struct c_arg_info);
2541 /* Make sure we have a parmlist after attributes. */
2542 if ($<ttype>-1 != 0)
2547 /* A nonempty list of identifiers. */
2550 { $$ = build_tree_list (NULL_TREE, $1); }
2551 | identifiers ',' IDENTIFIER
2552 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2555 /* A nonempty list of identifiers, including typenames. */
2556 identifiers_or_typenames:
2558 { $$ = build_tree_list (NULL_TREE, $1); }
2559 | identifiers_or_typenames ',' identifier
2560 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2565 { $$ = SAVE_EXT_FLAGS();
2567 warn_pointer_arith = 0;
2568 warn_traditional = 0;
2573 /* Objective-C productions. */
2583 objc_finish_implementation ();
2587 /* A nonempty list of identifiers. */
2590 { $$ = build_tree_list (NULL_TREE, $1); }
2591 | identifier_list ',' identifier
2592 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2596 AT_CLASS identifier_list ';'
2598 objc_declare_class ($2);
2603 AT_ALIAS identifier identifier ';'
2605 objc_declare_alias ($2, $3);
2610 ':' identifier { $$ = $2; }
2611 | /* NULL */ %prec HYPERUNARY { $$ = NULL_TREE; }
2615 '{' ivar_decl_list '}'
2620 AT_INTERFACE identifier superclass protocolrefs
2622 objc_start_class_interface ($2, $3, $4);
2626 objc_continue_interface ();
2628 methodprotolist AT_END
2630 objc_finish_interface ();
2633 | AT_IMPLEMENTATION identifier superclass
2635 objc_start_class_implementation ($2, $3);
2639 objc_continue_implementation ();
2642 | AT_INTERFACE identifier '(' identifier ')' protocolrefs
2644 objc_start_category_interface ($2, $4, $6);
2646 methodprotolist AT_END
2648 objc_finish_interface ();
2651 | AT_IMPLEMENTATION identifier '(' identifier ')'
2653 objc_start_category_implementation ($2, $4);
2658 AT_PROTOCOL identifier protocolrefs
2660 objc_pq_context = 1;
2661 objc_start_protocol ($2, $3);
2663 methodprotolist AT_END
2665 objc_pq_context = 0;
2666 objc_finish_interface ();
2668 /* The @protocol forward-declaration production introduces a
2669 reduce/reduce conflict on ';', which should be resolved in
2670 favor of the production 'identifier_list -> identifier'. */
2671 | AT_PROTOCOL identifier_list ';'
2673 objc_declare_protocols ($2);
2682 | non_empty_protocolrefs
2685 non_empty_protocolrefs:
2686 ARITHCOMPARE identifier_list ARITHCOMPARE
2688 if ($1 == LT_EXPR && $3 == GT_EXPR)
2697 | ivar_decl_list visibility_spec ivar_decls
2702 | AT_PRIVATE { objc_set_visibility (2); }
2703 | AT_PROTECTED { objc_set_visibility (0); }
2704 | AT_PUBLIC { objc_set_visibility (1); }
2709 | ivar_decls ivar_decl ';'
2713 pedwarn ("extra semicolon in struct or union specified");
2720 /* Comma-separated ivars are chained together in
2721 reverse order; add them one by one. */
2722 tree ivar = nreverse ($1);
2724 for (; ivar; ivar = TREE_CHAIN (ivar))
2725 objc_add_instance_variable (copy_node (ivar));
2734 pedwarn ("extra semicolon in method definition specified");
2746 objc_set_method_type ($1);
2747 objc_pq_context = 1;
2751 objc_pq_context = 0;
2752 objc_start_method_definition ($3);
2756 objc_finish_method_definition (current_function_decl);
2760 /* the reason for the strange actions in this rule
2761 is so that notype_initdecls when reached via datadef
2762 can find a valid list of type and sc specs in $0. */
2766 | methodprotolist methodproto
2767 | methodprotolist { $<ttype>$ = NULL_TREE; } datadef
2778 objc_set_method_type ($1);
2779 /* Remember protocol qualifiers in prototypes. */
2780 objc_pq_context = 1;
2784 /* Forget protocol qualifiers here. */
2785 objc_pq_context = 0;
2786 objc_add_method_declaration ($3);
2792 '(' objc_typename ')' unaryselector
2794 $$ = objc_build_method_signature ($2, $4, NULL_TREE);
2799 $$ = objc_build_method_signature (NULL_TREE, $1, NULL_TREE);
2802 | '(' objc_typename ')' keywordselector optparmlist
2804 $$ = objc_build_method_signature ($2, $4, $5);
2807 | keywordselector optparmlist
2809 $$ = objc_build_method_signature (NULL_TREE, $1, $2);
2813 /* Optional ObjC method parameters follow the C syntax, and may include '...'
2814 to denote a variable number of arguments. */
2817 optparms optellipsis
2819 TREE_OVERFLOW ($$) = $2;
2826 $$ = make_node (TREE_LIST);
2830 $$ = chainon ($1, build_tree_list (NULL_TREE,
2853 | keywordselector keyworddecl
2855 $$ = chainon ($1, $2);
2868 ENUM | STRUCT | UNION | IF | ELSE | WHILE | DO | FOR
2869 | SWITCH | CASE | DEFAULT | BREAK | CONTINUE | RETURN
2870 | GOTO | ASM_KEYWORD | SIZEOF | TYPEOF | ALIGNOF
2871 | TYPESPEC | TYPE_QUAL
2879 objc_quals objc_qual
2881 $$ = chainon ($1, build_tree_list (NULL_TREE, $2));
2892 $$ = build_tree_list ($1, groktypename ($2));
2896 $$ = build_tree_list ($1, NULL_TREE);
2901 selector ':' '(' objc_typename ')' identifier
2903 $$ = objc_build_keyword_decl ($1, $4, $6);
2906 | selector ':' identifier
2908 $$ = objc_build_keyword_decl ($1, NULL_TREE, $3);
2911 | ':' '(' objc_typename ')' identifier
2913 $$ = objc_build_keyword_decl (NULL_TREE, $3, $5);
2918 $$ = objc_build_keyword_decl (NULL_TREE, NULL_TREE, $2);
2929 | keywordarglist keywordarg
2931 $$ = chainon ($1, $2);
2939 if (TREE_CHAIN ($1) == NULL_TREE)
2940 /* just return the expr., remove a level of indirection */
2941 $$ = TREE_VALUE ($1);
2943 /* we have a comma expr., we will collapse later */
2949 selector ':' keywordexpr
2951 $$ = build_tree_list ($1, $3);
2955 $$ = build_tree_list (NULL_TREE, $2);
2964 $$ = objc_get_class_reference ($1);
2968 $$ = objc_get_class_reference ($1);
2973 '[' receiver messageargs ']'
2974 { $$ = build_tree_list ($2, $3); }
2984 | keywordnamelist keywordname
2986 $$ = chainon ($1, $2);
2993 $$ = build_tree_list ($1, NULL_TREE);
2997 $$ = build_tree_list (NULL_TREE, NULL_TREE);
3002 AT_SELECTOR '(' selectorarg ')'
3009 AT_PROTOCOL '(' identifier ')'
3015 /* extension to support C-structures in the archiver */
3018 AT_ENCODE '(' typename ')'
3020 $$ = groktypename ($3);
3027 /* yylex() is a thin wrapper around c_lex(), all it does is translate
3028 cpplib.h's token codes into yacc's token codes. */
3030 static enum cpp_ttype last_token;
3032 /* The reserved keyword table. */
3036 ENUM_BITFIELD(rid) rid : 16;
3037 unsigned int disable : 16;
3040 /* Disable mask. Keywords are disabled if (reswords[i].disable & mask) is
3042 #define D_C89 0x01 /* not in C89 */
3043 #define D_EXT 0x02 /* GCC extension */
3044 #define D_EXT89 0x04 /* GCC extension incorporated in C99 */
3045 #define D_OBJC 0x08 /* Objective C only */
3047 static const struct resword reswords[] =
3049 { "_Bool", RID_BOOL, 0 },
3050 { "_Complex", RID_COMPLEX, 0 },
3051 { "__FUNCTION__", RID_FUNCTION_NAME, 0 },
3052 { "__PRETTY_FUNCTION__", RID_PRETTY_FUNCTION_NAME, 0 },
3053 { "__alignof", RID_ALIGNOF, 0 },
3054 { "__alignof__", RID_ALIGNOF, 0 },
3055 { "__asm", RID_ASM, 0 },
3056 { "__asm__", RID_ASM, 0 },
3057 { "__attribute", RID_ATTRIBUTE, 0 },
3058 { "__attribute__", RID_ATTRIBUTE, 0 },
3059 { "__builtin_choose_expr", RID_CHOOSE_EXPR, 0 },
3060 { "__builtin_offsetof", RID_OFFSETOF, 0 },
3061 { "__builtin_types_compatible_p", RID_TYPES_COMPATIBLE_P, 0 },
3062 { "__builtin_va_arg", RID_VA_ARG, 0 },
3063 { "__complex", RID_COMPLEX, 0 },
3064 { "__complex__", RID_COMPLEX, 0 },
3065 { "__const", RID_CONST, 0 },
3066 { "__const__", RID_CONST, 0 },
3067 { "__extension__", RID_EXTENSION, 0 },
3068 { "__func__", RID_C99_FUNCTION_NAME, 0 },
3069 { "__imag", RID_IMAGPART, 0 },
3070 { "__imag__", RID_IMAGPART, 0 },
3071 { "__inline", RID_INLINE, 0 },
3072 { "__inline__", RID_INLINE, 0 },
3073 { "__label__", RID_LABEL, 0 },
3074 { "__ptrbase", RID_PTRBASE, 0 },
3075 { "__ptrbase__", RID_PTRBASE, 0 },
3076 { "__ptrextent", RID_PTREXTENT, 0 },
3077 { "__ptrextent__", RID_PTREXTENT, 0 },
3078 { "__ptrvalue", RID_PTRVALUE, 0 },
3079 { "__ptrvalue__", RID_PTRVALUE, 0 },
3080 { "__real", RID_REALPART, 0 },
3081 { "__real__", RID_REALPART, 0 },
3082 { "__restrict", RID_RESTRICT, 0 },
3083 { "__restrict__", RID_RESTRICT, 0 },
3084 { "__signed", RID_SIGNED, 0 },
3085 { "__signed__", RID_SIGNED, 0 },
3086 { "__thread", RID_THREAD, 0 },
3087 { "__typeof", RID_TYPEOF, 0 },
3088 { "__typeof__", RID_TYPEOF, 0 },
3089 { "__volatile", RID_VOLATILE, 0 },
3090 { "__volatile__", RID_VOLATILE, 0 },
3091 { "asm", RID_ASM, D_EXT },
3092 { "auto", RID_AUTO, 0 },
3093 { "break", RID_BREAK, 0 },
3094 { "case", RID_CASE, 0 },
3095 { "char", RID_CHAR, 0 },
3096 { "const", RID_CONST, 0 },
3097 { "continue", RID_CONTINUE, 0 },
3098 { "default", RID_DEFAULT, 0 },
3099 { "do", RID_DO, 0 },
3100 { "double", RID_DOUBLE, 0 },
3101 { "else", RID_ELSE, 0 },
3102 { "enum", RID_ENUM, 0 },
3103 { "extern", RID_EXTERN, 0 },
3104 { "float", RID_FLOAT, 0 },
3105 { "for", RID_FOR, 0 },
3106 { "goto", RID_GOTO, 0 },
3107 { "if", RID_IF, 0 },
3108 { "inline", RID_INLINE, D_EXT89 },
3109 { "int", RID_INT, 0 },
3110 { "long", RID_LONG, 0 },
3111 { "register", RID_REGISTER, 0 },
3112 { "restrict", RID_RESTRICT, D_C89 },
3113 { "return", RID_RETURN, 0 },
3114 { "short", RID_SHORT, 0 },
3115 { "signed", RID_SIGNED, 0 },
3116 { "sizeof", RID_SIZEOF, 0 },
3117 { "static", RID_STATIC, 0 },
3118 { "struct", RID_STRUCT, 0 },
3119 { "switch", RID_SWITCH, 0 },
3120 { "typedef", RID_TYPEDEF, 0 },
3121 { "typeof", RID_TYPEOF, D_EXT },
3122 { "union", RID_UNION, 0 },
3123 { "unsigned", RID_UNSIGNED, 0 },
3124 { "void", RID_VOID, 0 },
3125 { "volatile", RID_VOLATILE, 0 },
3126 { "while", RID_WHILE, 0 },
3129 { "id", RID_ID, D_OBJC },
3131 /* These objc keywords are recognized only immediately after
3133 { "class", RID_AT_CLASS, D_OBJC },
3134 { "compatibility_alias", RID_AT_ALIAS, D_OBJC },
3135 { "defs", RID_AT_DEFS, D_OBJC },
3136 { "encode", RID_AT_ENCODE, D_OBJC },
3137 { "end", RID_AT_END, D_OBJC },
3138 { "implementation", RID_AT_IMPLEMENTATION, D_OBJC },
3139 { "interface", RID_AT_INTERFACE, D_OBJC },
3140 { "private", RID_AT_PRIVATE, D_OBJC },
3141 { "protected", RID_AT_PROTECTED, D_OBJC },
3142 { "protocol", RID_AT_PROTOCOL, D_OBJC },
3143 { "public", RID_AT_PUBLIC, D_OBJC },
3144 { "selector", RID_AT_SELECTOR, D_OBJC },
3145 { "throw", RID_AT_THROW, D_OBJC },
3146 { "try", RID_AT_TRY, D_OBJC },
3147 { "catch", RID_AT_CATCH, D_OBJC },
3148 { "finally", RID_AT_FINALLY, D_OBJC },
3149 { "synchronized", RID_AT_SYNCHRONIZED, D_OBJC },
3150 /* These are recognized only in protocol-qualifier context
3152 { "bycopy", RID_BYCOPY, D_OBJC },
3153 { "byref", RID_BYREF, D_OBJC },
3154 { "in", RID_IN, D_OBJC },
3155 { "inout", RID_INOUT, D_OBJC },
3156 { "oneway", RID_ONEWAY, D_OBJC },
3157 { "out", RID_OUT, D_OBJC },
3160 #define N_reswords (sizeof reswords / sizeof (struct resword))
3162 /* Table mapping from RID_* constants to yacc token numbers.
3163 Unfortunately we have to have entries for all the keywords in all
3165 static const short rid_to_yy[RID_MAX] =
3167 /* RID_STATIC */ STATIC,
3168 /* RID_UNSIGNED */ TYPESPEC,
3169 /* RID_LONG */ TYPESPEC,
3170 /* RID_CONST */ TYPE_QUAL,
3171 /* RID_EXTERN */ SCSPEC,
3172 /* RID_REGISTER */ SCSPEC,
3173 /* RID_TYPEDEF */ SCSPEC,
3174 /* RID_SHORT */ TYPESPEC,
3175 /* RID_INLINE */ SCSPEC,
3176 /* RID_VOLATILE */ TYPE_QUAL,
3177 /* RID_SIGNED */ TYPESPEC,
3178 /* RID_AUTO */ SCSPEC,
3179 /* RID_RESTRICT */ TYPE_QUAL,
3182 /* RID_COMPLEX */ TYPESPEC,
3183 /* RID_THREAD */ SCSPEC,
3187 /* RID_VIRTUAL */ 0,
3188 /* RID_EXPLICIT */ 0,
3190 /* RID_MUTABLE */ 0,
3193 /* RID_IN */ OBJC_TYPE_QUAL,
3194 /* RID_OUT */ OBJC_TYPE_QUAL,
3195 /* RID_INOUT */ OBJC_TYPE_QUAL,
3196 /* RID_BYCOPY */ OBJC_TYPE_QUAL,
3197 /* RID_BYREF */ OBJC_TYPE_QUAL,
3198 /* RID_ONEWAY */ OBJC_TYPE_QUAL,
3201 /* RID_INT */ TYPESPEC,
3202 /* RID_CHAR */ TYPESPEC,
3203 /* RID_FLOAT */ TYPESPEC,
3204 /* RID_DOUBLE */ TYPESPEC,
3205 /* RID_VOID */ TYPESPEC,
3206 /* RID_ENUM */ ENUM,
3207 /* RID_STRUCT */ STRUCT,
3208 /* RID_UNION */ UNION,
3210 /* RID_ELSE */ ELSE,
3211 /* RID_WHILE */ WHILE,
3214 /* RID_SWITCH */ SWITCH,
3215 /* RID_CASE */ CASE,
3216 /* RID_DEFAULT */ DEFAULT,
3217 /* RID_BREAK */ BREAK,
3218 /* RID_CONTINUE */ CONTINUE,
3219 /* RID_RETURN */ RETURN,
3220 /* RID_GOTO */ GOTO,
3221 /* RID_SIZEOF */ SIZEOF,
3224 /* RID_ASM */ ASM_KEYWORD,
3225 /* RID_TYPEOF */ TYPEOF,
3226 /* RID_ALIGNOF */ ALIGNOF,
3227 /* RID_ATTRIBUTE */ ATTRIBUTE,
3228 /* RID_VA_ARG */ VA_ARG,
3229 /* RID_EXTENSION */ EXTENSION,
3230 /* RID_IMAGPART */ IMAGPART,
3231 /* RID_REALPART */ REALPART,
3232 /* RID_LABEL */ LABEL,
3233 /* RID_PTRBASE */ PTR_BASE,
3234 /* RID_PTREXTENT */ PTR_EXTENT,
3235 /* RID_PTRVALUE */ PTR_VALUE,
3237 /* RID_CHOOSE_EXPR */ CHOOSE_EXPR,
3238 /* RID_TYPES_COMPATIBLE_P */ TYPES_COMPATIBLE_P,
3240 /* RID_FUNCTION_NAME */ FUNC_NAME,
3241 /* RID_PRETTY_FUNCTION_NAME */ FUNC_NAME,
3242 /* RID_C99_FUNCTION_NAME */ FUNC_NAME,
3245 /* RID_BOOL */ TYPESPEC,
3249 /* RID_PRIVATE */ 0,
3250 /* RID_PROTECTED */ 0,
3251 /* RID_TEMPLATE */ 0,
3256 /* RID_NAMESPACE */ 0,
3258 /* RID_OFFSETOF */ OFFSETOF,
3259 /* RID_OPERATOR */ 0,
3264 /* RID_TYPENAME */ 0,
3269 /* RID_CONSTCAST */ 0,
3270 /* RID_DYNCAST */ 0,
3271 /* RID_REINTCAST */ 0,
3272 /* RID_STATCAST */ 0,
3275 /* RID_ID */ OBJECTNAME,
3276 /* RID_AT_ENCODE */ AT_ENCODE,
3277 /* RID_AT_END */ AT_END,
3278 /* RID_AT_CLASS */ AT_CLASS,
3279 /* RID_AT_ALIAS */ AT_ALIAS,
3280 /* RID_AT_DEFS */ AT_DEFS,
3281 /* RID_AT_PRIVATE */ AT_PRIVATE,
3282 /* RID_AT_PROTECTED */ AT_PROTECTED,
3283 /* RID_AT_PUBLIC */ AT_PUBLIC,
3284 /* RID_AT_PROTOCOL */ AT_PROTOCOL,
3285 /* RID_AT_SELECTOR */ AT_SELECTOR,
3286 /* RID_AT_THROW */ AT_THROW,
3287 /* RID_AT_TRY */ AT_TRY,
3288 /* RID_AT_CATCH */ AT_CATCH,
3289 /* RID_AT_FINALLY */ AT_FINALLY,
3290 /* RID_AT_SYNCHRONIZED */ AT_SYNCHRONIZED,
3291 /* RID_AT_INTERFACE */ AT_INTERFACE,
3292 /* RID_AT_IMPLEMENTATION */ AT_IMPLEMENTATION
3296 init_reswords (void)
3300 int mask = (flag_isoc99 ? 0 : D_C89)
3301 | (flag_no_asm ? (flag_isoc99 ? D_EXT : D_EXT|D_EXT89) : 0);
3303 if (!c_dialect_objc ())
3306 ridpointers = GGC_CNEWVEC (tree, (int) RID_MAX);
3307 for (i = 0; i < N_reswords; i++)
3309 /* If a keyword is disabled, do not enter it into the table
3310 and so create a canonical spelling that isn't a keyword. */
3311 if (reswords[i].disable & mask)
3314 id = get_identifier (reswords[i].word);
3315 C_RID_CODE (id) = reswords[i].rid;
3316 C_IS_RESERVED_WORD (id) = 1;
3317 ridpointers [(int) reswords[i].rid] = id;
3321 #define NAME(type) cpp_type2name (type)
3324 yyerror (const char *msgid)
3326 c_parse_error (msgid, last_token, yylval.ttype);
3335 int objc_force_identifier = objc_need_raw_identifier;
3336 OBJC_NEED_RAW_IDENTIFIER (0);
3339 if (C_IS_RESERVED_WORD (yylval.ttype))
3341 enum rid rid_code = C_RID_CODE (yylval.ttype);
3344 /* Turn non-typedefed refs to "id" into plain identifiers; this
3345 allows constructs like "void foo(id id);" to work. */
3346 if (rid_code == RID_ID)
3348 decl = lookup_name (yylval.ttype);
3349 if (decl == NULL_TREE || TREE_CODE (decl) != TYPE_DECL)
3353 if (!OBJC_IS_AT_KEYWORD (rid_code)
3354 && (!OBJC_IS_PQ_KEYWORD (rid_code) || objc_pq_context))
3357 /* Return the canonical spelling for this keyword. */
3358 yylval.ttype = ridpointers[(int) rid_code];
3359 return rid_to_yy[(int) rid_code];
3363 decl = lookup_name (yylval.ttype);
3366 if (TREE_CODE (decl) == TYPE_DECL)
3372 tree objc_interface_decl = objc_is_class_name (yylval.ttype);
3373 /* ObjC class names are in the same namespace as variables and
3374 typedefs, and hence are shadowed by local declarations. */
3375 if (objc_interface_decl
3376 && (global_bindings_p ()
3377 || (!objc_force_identifier && !decl)))
3379 yylval.ttype = objc_interface_decl;
3392 last_token = c_lex (&yylval.ttype);
3395 case CPP_EQ: return '=';
3396 case CPP_NOT: return '!';
3397 case CPP_GREATER: yylval.code = GT_EXPR; return ARITHCOMPARE;
3398 case CPP_LESS: yylval.code = LT_EXPR; return ARITHCOMPARE;
3399 case CPP_PLUS: yylval.code = PLUS_EXPR; return '+';
3400 case CPP_MINUS: yylval.code = MINUS_EXPR; return '-';
3401 case CPP_MULT: yylval.code = MULT_EXPR; return '*';
3402 case CPP_DIV: yylval.code = TRUNC_DIV_EXPR; return '/';
3403 case CPP_MOD: yylval.code = TRUNC_MOD_EXPR; return '%';
3404 case CPP_AND: yylval.code = BIT_AND_EXPR; return '&';
3405 case CPP_OR: yylval.code = BIT_IOR_EXPR; return '|';
3406 case CPP_XOR: yylval.code = BIT_XOR_EXPR; return '^';
3407 case CPP_RSHIFT: yylval.code = RSHIFT_EXPR; return RSHIFT;
3408 case CPP_LSHIFT: yylval.code = LSHIFT_EXPR; return LSHIFT;
3410 case CPP_COMPL: return '~';
3411 case CPP_AND_AND: return ANDAND;
3412 case CPP_OR_OR: return OROR;
3413 case CPP_QUERY: return '?';
3414 case CPP_OPEN_PAREN: return '(';
3415 case CPP_EQ_EQ: yylval.code = EQ_EXPR; return EQCOMPARE;
3416 case CPP_NOT_EQ: yylval.code = NE_EXPR; return EQCOMPARE;
3417 case CPP_GREATER_EQ:yylval.code = GE_EXPR; return ARITHCOMPARE;
3418 case CPP_LESS_EQ: yylval.code = LE_EXPR; return ARITHCOMPARE;
3420 case CPP_PLUS_EQ: yylval.code = PLUS_EXPR; return ASSIGN;
3421 case CPP_MINUS_EQ: yylval.code = MINUS_EXPR; return ASSIGN;
3422 case CPP_MULT_EQ: yylval.code = MULT_EXPR; return ASSIGN;
3423 case CPP_DIV_EQ: yylval.code = TRUNC_DIV_EXPR; return ASSIGN;
3424 case CPP_MOD_EQ: yylval.code = TRUNC_MOD_EXPR; return ASSIGN;
3425 case CPP_AND_EQ: yylval.code = BIT_AND_EXPR; return ASSIGN;
3426 case CPP_OR_EQ: yylval.code = BIT_IOR_EXPR; return ASSIGN;
3427 case CPP_XOR_EQ: yylval.code = BIT_XOR_EXPR; return ASSIGN;
3428 case CPP_RSHIFT_EQ: yylval.code = RSHIFT_EXPR; return ASSIGN;
3429 case CPP_LSHIFT_EQ: yylval.code = LSHIFT_EXPR; return ASSIGN;
3431 case CPP_OPEN_SQUARE: return '[';
3432 case CPP_CLOSE_SQUARE: return ']';
3433 case CPP_OPEN_BRACE: return '{';
3434 case CPP_CLOSE_BRACE: return '}';
3435 case CPP_ELLIPSIS: return ELLIPSIS;
3437 case CPP_PLUS_PLUS: return PLUSPLUS;
3438 case CPP_MINUS_MINUS: return MINUSMINUS;
3439 case CPP_DEREF: return POINTSAT;
3440 case CPP_DOT: return '.';
3442 /* The following tokens may affect the interpretation of any
3443 identifiers following, if doing Objective-C. */
3444 case CPP_COLON: OBJC_NEED_RAW_IDENTIFIER (0); return ':';
3445 case CPP_COMMA: OBJC_NEED_RAW_IDENTIFIER (0); return ',';
3446 case CPP_CLOSE_PAREN: OBJC_NEED_RAW_IDENTIFIER (0); return ')';
3447 case CPP_SEMICOLON: OBJC_NEED_RAW_IDENTIFIER (0); return ';';
3453 return yylexname ();
3456 /* This only happens in Objective-C; it must be a keyword. */
3457 return rid_to_yy [(int) C_RID_CODE (yylval.ttype)];
3468 case CPP_OBJC_STRING:
3471 /* These tokens are C++ specific (and will not be generated
3472 in C mode, but let's be cautious). */
3474 case CPP_DEREF_STAR:
3480 /* These tokens should not survive translation phase 4. */
3483 error ("syntax error at %qs token", NAME(last_token));
3496 timevar_push (TV_LEX);
3498 timevar_pop (TV_LEX);
3502 /* Function used when yydebug is set, to print a token in more detail. */
3505 yyprint (FILE *file, int yychar, YYSTYPE yyl)
3509 fprintf (file, " [%s]", NAME(last_token));
3520 if (IDENTIFIER_POINTER (t))
3521 fprintf (file, " '%s'", IDENTIFIER_POINTER (t));
3525 fprintf (file, " %s", GET_MODE_NAME (TYPE_MODE (TREE_TYPE (t))));
3526 if (TREE_CODE (t) == INTEGER_CST)
3529 fprintf (file, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
3530 TREE_INT_CST_HIGH (t), TREE_INT_CST_LOW (t));
3536 /* This is not the ideal place to put this, but we have to get it out
3537 of c-lex.c because cp/lex.c has its own version. */
3539 /* Parse the file. */
3547 free (malloced_yyss);
3548 free (malloced_yyvs);
3553 #include "gt-c-parse.h"