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; struct c_expr exprtype; enum tree_code code;
103 location_t location; }
105 /* All identifiers that are not reserved words
106 and are not declared typedefs in the current block */
109 /* All identifiers that are declared typedefs in the current block.
110 In some contexts, they are treated just like IDENTIFIER,
111 but they can also serve as typespecs in declarations. */
114 /* Reserved words that specify storage class.
115 yylval contains an IDENTIFIER_NODE which indicates which one. */
116 %token SCSPEC /* Storage class other than static. */
117 %token STATIC /* Static storage class. */
119 /* Reserved words that specify type.
120 yylval contains an IDENTIFIER_NODE which indicates which one. */
123 /* Reserved words that qualify type: "const", "volatile", or "restrict".
124 yylval contains an IDENTIFIER_NODE which indicates which one. */
127 /* Objective-C protocol qualifiers. These acquire their magic powers
128 only in certain contexts. */
129 %token OBJC_TYPE_QUAL
131 /* Character or numeric constants.
132 yylval is the node for the constant. */
135 /* String constants in raw form.
136 yylval is a STRING_CST node. */
140 /* "...", used for functions with variable arglists. */
143 /* the reserved words */
144 /* SCO include files test "ASM", so use something else. */
145 %token SIZEOF ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
146 %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD TYPEOF ALIGNOF
147 %token ATTRIBUTE EXTENSION LABEL
148 %token REALPART IMAGPART VA_ARG CHOOSE_EXPR TYPES_COMPATIBLE_P
149 %token PTR_VALUE PTR_BASE PTR_EXTENT
150 %token FUNC_NAME OFFSETOF
152 /* Add precedence rules to solve dangling else s/r conflict */
156 /* Define the operator tokens and their precedences.
157 The value is an integer because, if used, it is the tree code
158 to use in the expression made from the operator. */
160 %right <code> ASSIGN '='
161 %right <code> '?' ':'
167 %left <code> EQCOMPARE
168 %left <code> ARITHCOMPARE
169 %left <code> LSHIFT RSHIFT
171 %left <code> '*' '/' '%'
172 %right <code> UNARY PLUSPLUS MINUSMINUS
174 %left <code> POINTSAT '.' '(' '['
176 /* The Objective-C keywords. These are included in C and in
177 Objective C, so that the token codes are the same in both. */
178 %token AT_INTERFACE AT_IMPLEMENTATION AT_END AT_SELECTOR AT_DEFS AT_ENCODE
179 %token CLASSNAME AT_PUBLIC AT_PRIVATE AT_PROTECTED AT_PROTOCOL
180 %token OBJECTNAME AT_CLASS AT_ALIAS
181 %token AT_THROW AT_TRY AT_CATCH AT_FINALLY AT_SYNCHRONIZED
185 %type <ttype> ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
186 %type <ttype> BREAK CONTINUE RETURN GOTO ASM_KEYWORD SIZEOF TYPEOF ALIGNOF
188 %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT STRING FUNC_NAME
189 %type <ttype> nonnull_exprlist exprlist
190 %type <exprtype> expr expr_no_commas cast_expr unary_expr primary
191 %type <ttype> declspecs_nosc_nots_nosa_noea declspecs_nosc_nots_nosa_ea
192 %type <ttype> declspecs_nosc_nots_sa_noea declspecs_nosc_nots_sa_ea
193 %type <ttype> declspecs_nosc_ts_nosa_noea declspecs_nosc_ts_nosa_ea
194 %type <ttype> declspecs_nosc_ts_sa_noea declspecs_nosc_ts_sa_ea
195 %type <ttype> declspecs_sc_nots_nosa_noea declspecs_sc_nots_nosa_ea
196 %type <ttype> declspecs_sc_nots_sa_noea declspecs_sc_nots_sa_ea
197 %type <ttype> declspecs_sc_ts_nosa_noea declspecs_sc_ts_nosa_ea
198 %type <ttype> declspecs_sc_ts_sa_noea declspecs_sc_ts_sa_ea
199 %type <ttype> declspecs_ts declspecs_nots
200 %type <ttype> declspecs_ts_nosa declspecs_nots_nosa
201 %type <ttype> declspecs_nosc_ts declspecs_nosc_nots declspecs_nosc declspecs
202 %type <ttype> maybe_type_quals_attrs typespec_nonattr typespec_attr
203 %type <ttype> typespec_reserved_nonattr typespec_reserved_attr
204 %type <ttype> typespec_nonreserved_nonattr
205 %type <ttype> offsetof_member_designator
207 %type <ttype> scspec SCSPEC STATIC TYPESPEC TYPE_QUAL maybe_volatile
208 %type <ttype> initdecls notype_initdecls initdcl notype_initdcl
209 %type <exprtype> init
210 %type <ttype> simple_asm_expr maybeasm asm_stmt asm_argument
211 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
212 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
213 %type <ttype> any_word
215 %type <ttype> compstmt compstmt_start compstmt_primary_start
216 %type <ttype> stmt label stmt_nocomp start_break start_continue
218 %type <ttype> c99_block_start c99_block_lineno_labeled_stmt
219 %type <ttype> if_statement_1 if_statement_2
220 %type <ttype> declarator
221 %type <ttype> notype_declarator after_type_declarator
222 %type <ttype> parm_declarator
223 %type <ttype> parm_declarator_starttypename parm_declarator_nostarttypename
224 %type <ttype> array_declarator
226 %type <ttype> structsp_attr structsp_nonattr
227 %type <ttype> component_decl_list component_decl_list2
228 %type <ttype> component_decl components components_notype component_declarator
229 %type <ttype> component_notype_declarator
230 %type <ttype> enumlist enumerator
231 %type <ttype> struct_head union_head enum_head
232 %type <ttype> typename absdcl absdcl1 absdcl1_ea absdcl1_noea
233 %type <ttype> direct_absdcl1 absdcl_maybe_attribute
234 %type <ttype> condition xexpr for_cond_expr for_incr_expr
235 %type <ttype> parms parm firstparm identifiers
237 %type <ttype> parmlist parmlist_1 parmlist_2
238 %type <ttype> parmlist_or_identifiers parmlist_or_identifiers_1
239 %type <ttype> identifiers_or_typenames
241 %type <itype> setspecs setspecs_fp extension
243 %type <location> save_location
246 /* the Objective-C nonterminals */
248 %type <ttype> methoddecl unaryselector keywordselector selector
249 %type <code> methodtype
250 %type <ttype> keyworddecl receiver objcmessageexpr messageargs
251 %type <ttype> keywordexpr keywordarglist keywordarg
252 %type <ttype> optparmlist optparms reservedwords objcselectorexpr
253 %type <ttype> selectorarg keywordnamelist keywordname objcencodeexpr
254 %type <ttype> non_empty_protocolrefs protocolrefs identifier_list objcprotocolexpr
256 %type <ttype> CLASSNAME OBJECTNAME OBJC_STRING OBJC_TYPE_QUAL
258 %type <ttype> superclass objc_quals objc_qual objc_typename
259 %type <itype> objc_try_catch_stmt optellipsis
263 /* List of types and structure classes of the current declaration. */
264 static GTY(()) tree current_declspecs;
265 static GTY(()) tree prefix_attributes;
267 /* List of all the attributes applying to the identifier currently being
268 declared; includes prefix_attributes and possibly some more attributes
269 just after a comma. */
270 static GTY(()) tree all_prefix_attributes;
272 /* Stack of saved values of current_declspecs, prefix_attributes and
273 all_prefix_attributes. */
274 static GTY(()) tree declspec_stack;
276 /* INDIRECT_REF with a TREE_TYPE of the type being queried for offsetof. */
277 static tree offsetof_base;
279 /* PUSH_DECLSPEC_STACK is called from setspecs; POP_DECLSPEC_STACK
280 should be called from the productions making use of setspecs. */
281 #define PUSH_DECLSPEC_STACK \
283 declspec_stack = tree_cons (build_tree_list (prefix_attributes, \
284 all_prefix_attributes), \
289 #define POP_DECLSPEC_STACK \
291 current_declspecs = TREE_VALUE (declspec_stack); \
292 prefix_attributes = TREE_PURPOSE (TREE_PURPOSE (declspec_stack)); \
293 all_prefix_attributes = TREE_VALUE (TREE_PURPOSE (declspec_stack)); \
294 declspec_stack = TREE_CHAIN (declspec_stack); \
297 /* For __extension__, save/restore the warning flags which are
298 controlled by __extension__. */
299 #define SAVE_EXT_FLAGS() \
301 | (warn_pointer_arith << 1) \
302 | (warn_traditional << 2) \
305 #define RESTORE_EXT_FLAGS(val) \
307 pedantic = val & 1; \
308 warn_pointer_arith = (val >> 1) & 1; \
309 warn_traditional = (val >> 2) & 1; \
310 flag_iso = (val >> 3) & 1; \
314 /* Objective-C specific parser/lexer information */
316 static int objc_pq_context = 0;
318 /* The following flag is needed to contextualize ObjC lexical analysis.
319 In some cases (e.g., 'int NSObject;'), it is undesirable to bind
320 an identifier to an ObjC class, even if a class with that name
322 static int objc_need_raw_identifier;
323 #define OBJC_NEED_RAW_IDENTIFIER(VAL) objc_need_raw_identifier = VAL
327 #define OBJC_NEED_RAW_IDENTIFIER(VAL) /* nothing */
330 /* Tell yyparse how to print a token's value, if yydebug is set. */
332 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
334 static void yyprint (FILE *, int, YYSTYPE);
335 static void yyerror (const char *);
336 static int yylexname (void);
337 static inline int _yylex (void);
338 static int yylex (void);
339 static void init_reswords (void);
341 /* Initialisation routine for this file. */
353 pedwarn ("ISO C forbids an empty source file");
358 /* the reason for the strange actions in this rule
359 is so that notype_initdecls when reached via datadef
360 can find a valid list of type and sc specs in $0. */
363 {$<ttype>$ = NULL_TREE; } extdef
364 | extdefs {$<ttype>$ = NULL_TREE; ggc_collect(); } extdef
372 { RESTORE_EXT_FLAGS ($1); }
379 setspecs notype_initdecls ';'
381 error ("ISO C forbids data definition with no type or storage class");
383 warning ("data definition has no type or storage class");
385 POP_DECLSPEC_STACK; }
386 | declspecs_nots setspecs notype_initdecls ';'
387 { POP_DECLSPEC_STACK; }
388 | declspecs_ts setspecs initdecls ';'
389 { POP_DECLSPEC_STACK; }
396 pedwarn ("ISO C does not allow extra `;' outside of a function"); }
400 declspecs_ts setspecs declarator
401 { if (! start_function (current_declspecs, $3,
402 all_prefix_attributes))
405 old_style_parm_decls save_location
406 { DECL_SOURCE_LOCATION (current_function_decl) = $6;
407 store_parm_decls (); }
409 { finish_function ();
410 POP_DECLSPEC_STACK; }
411 | declspecs_ts setspecs declarator error
412 { POP_DECLSPEC_STACK; }
413 | declspecs_nots setspecs notype_declarator
414 { if (! start_function (current_declspecs, $3,
415 all_prefix_attributes))
418 old_style_parm_decls save_location
419 { DECL_SOURCE_LOCATION (current_function_decl) = $6;
420 store_parm_decls (); }
422 { finish_function ();
423 POP_DECLSPEC_STACK; }
424 | declspecs_nots setspecs notype_declarator error
425 { POP_DECLSPEC_STACK; }
426 | setspecs notype_declarator
427 { if (! start_function (NULL_TREE, $2,
428 all_prefix_attributes))
431 old_style_parm_decls save_location
432 { DECL_SOURCE_LOCATION (current_function_decl) = $5;
433 store_parm_decls (); }
435 { finish_function ();
436 POP_DECLSPEC_STACK; }
437 | setspecs notype_declarator error
438 { POP_DECLSPEC_STACK; }
453 { $$ = NEGATE_EXPR; }
457 if (warn_traditional && !in_system_header)
458 warning ("traditional C rejects the unary plus operator");
462 { $$ = PREINCREMENT_EXPR; }
464 { $$ = PREDECREMENT_EXPR; }
466 { $$ = BIT_NOT_EXPR; }
468 { $$ = TRUTH_NOT_EXPR; }
472 | expr ',' expr_no_commas
473 { $$.value = build_compound_expr ($1.value, $3.value);
474 $$.original_code = COMPOUND_EXPR; }
485 { $$ = build_tree_list (NULL_TREE, $1.value); }
486 | nonnull_exprlist ',' expr_no_commas
487 { chainon ($1, build_tree_list (NULL_TREE, $3.value)); }
492 | '*' cast_expr %prec UNARY
493 { $$.value = build_indirect_ref ($2.value, "unary *");
494 $$.original_code = ERROR_MARK; }
495 /* __extension__ turns off -pedantic for following primary. */
496 | extension cast_expr %prec UNARY
498 RESTORE_EXT_FLAGS ($1); }
499 | unop cast_expr %prec UNARY
500 { $$.value = build_unary_op ($1, $2.value, 0);
501 overflow_warning ($$.value);
502 $$.original_code = ERROR_MARK; }
503 /* Refer to the address of a label as a pointer. */
505 { $$.value = finish_label_address_expr ($2);
506 $$.original_code = ERROR_MARK; }
507 | sizeof unary_expr %prec UNARY
509 if (TREE_CODE ($2.value) == COMPONENT_REF
510 && DECL_C_BIT_FIELD (TREE_OPERAND ($2.value, 1)))
511 error ("`sizeof' applied to a bit-field");
512 $$.value = c_sizeof (TREE_TYPE ($2.value));
513 $$.original_code = ERROR_MARK; }
514 | sizeof '(' typename ')' %prec HYPERUNARY
516 $$.value = c_sizeof (groktypename ($3));
517 $$.original_code = ERROR_MARK; }
518 | alignof unary_expr %prec UNARY
520 $$.value = c_alignof_expr ($2.value);
521 $$.original_code = ERROR_MARK; }
522 | alignof '(' typename ')' %prec HYPERUNARY
524 $$.value = c_alignof (groktypename ($3));
525 $$.original_code = ERROR_MARK; }
526 | REALPART cast_expr %prec UNARY
527 { $$.value = build_unary_op (REALPART_EXPR, $2.value, 0);
528 $$.original_code = ERROR_MARK; }
529 | IMAGPART cast_expr %prec UNARY
530 { $$.value = build_unary_op (IMAGPART_EXPR, $2.value, 0);
531 $$.original_code = ERROR_MARK; }
535 SIZEOF { skip_evaluation++; }
539 ALIGNOF { skip_evaluation++; }
543 TYPEOF { skip_evaluation++; }
548 | '(' typename ')' cast_expr %prec UNARY
549 { $$.value = c_cast_expr ($2, $4.value);
550 $$.original_code = ERROR_MARK; }
555 | expr_no_commas '+' expr_no_commas
556 { $$ = parser_build_binary_op ($2, $1, $3); }
557 | expr_no_commas '-' expr_no_commas
558 { $$ = parser_build_binary_op ($2, $1, $3); }
559 | expr_no_commas '*' expr_no_commas
560 { $$ = parser_build_binary_op ($2, $1, $3); }
561 | expr_no_commas '/' expr_no_commas
562 { $$ = parser_build_binary_op ($2, $1, $3); }
563 | expr_no_commas '%' expr_no_commas
564 { $$ = parser_build_binary_op ($2, $1, $3); }
565 | expr_no_commas LSHIFT expr_no_commas
566 { $$ = parser_build_binary_op ($2, $1, $3); }
567 | expr_no_commas RSHIFT expr_no_commas
568 { $$ = parser_build_binary_op ($2, $1, $3); }
569 | expr_no_commas ARITHCOMPARE expr_no_commas
570 { $$ = parser_build_binary_op ($2, $1, $3); }
571 | expr_no_commas EQCOMPARE expr_no_commas
572 { $$ = parser_build_binary_op ($2, $1, $3); }
573 | expr_no_commas '&' expr_no_commas
574 { $$ = parser_build_binary_op ($2, $1, $3); }
575 | expr_no_commas '|' expr_no_commas
576 { $$ = parser_build_binary_op ($2, $1, $3); }
577 | expr_no_commas '^' expr_no_commas
578 { $$ = parser_build_binary_op ($2, $1, $3); }
579 | expr_no_commas ANDAND
580 { $1.value = lang_hooks.truthvalue_conversion
581 (default_conversion ($1.value));
582 skip_evaluation += $1.value == truthvalue_false_node; }
584 { skip_evaluation -= $1.value == truthvalue_false_node;
585 $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $4); }
586 | expr_no_commas OROR
587 { $1.value = lang_hooks.truthvalue_conversion
588 (default_conversion ($1.value));
589 skip_evaluation += $1.value == truthvalue_true_node; }
591 { skip_evaluation -= $1.value == truthvalue_true_node;
592 $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $4); }
594 { $1.value = lang_hooks.truthvalue_conversion
595 (default_conversion ($1.value));
596 skip_evaluation += $1.value == truthvalue_false_node; }
598 { skip_evaluation += (($1.value == truthvalue_true_node)
599 - ($1.value == truthvalue_false_node)); }
601 { skip_evaluation -= $1.value == truthvalue_true_node;
602 $$.value = build_conditional_expr ($1.value, $4.value,
604 $$.original_code = ERROR_MARK; }
607 pedwarn ("ISO C forbids omitting the middle term of a ?: expression");
608 /* Make sure first operand is calculated only once. */
609 $<ttype>2 = save_expr (default_conversion ($1.value));
610 $1.value = lang_hooks.truthvalue_conversion ($<ttype>2);
611 skip_evaluation += $1.value == truthvalue_true_node; }
613 { skip_evaluation -= $1.value == truthvalue_true_node;
614 $$.value = build_conditional_expr ($1.value, $<ttype>2,
616 $$.original_code = ERROR_MARK; }
617 | expr_no_commas '=' expr_no_commas
618 { $$.value = build_modify_expr ($1.value, NOP_EXPR, $3.value);
619 $$.original_code = MODIFY_EXPR;
621 | expr_no_commas ASSIGN expr_no_commas
622 { $$.value = build_modify_expr ($1.value, $2, $3.value);
623 TREE_NO_WARNING ($$.value) = 1;
624 $$.original_code = ERROR_MARK;
631 if (yychar == YYEMPTY)
633 $$.value = build_external_ref ($1, yychar == '(');
634 $$.original_code = ERROR_MARK;
637 { $$.value = $1; $$.original_code = ERROR_MARK; }
639 { $$.value = $1; $$.original_code = STRING_CST; }
641 { $$.value = fname_decl (C_RID_CODE ($1), $1);
642 $$.original_code = ERROR_MARK; }
643 | '(' typename ')' '{'
644 { start_init (NULL_TREE, NULL, 0);
645 $2 = groktypename ($2);
646 really_start_incremental_init ($2); }
647 initlist_maybe_comma '}' %prec UNARY
648 { struct c_expr init = pop_init_level (0);
649 tree constructor = init.value;
652 maybe_warn_string_init (type, init);
654 if (pedantic && ! flag_isoc99)
655 pedwarn ("ISO C90 forbids compound literals");
656 $$.value = build_compound_literal (type, constructor);
657 $$.original_code = ERROR_MARK;
660 { $$.value = $2.value;
661 if (TREE_CODE ($$.value) == MODIFY_EXPR)
662 TREE_NO_WARNING ($$.value) = 1;
663 $$.original_code = ERROR_MARK; }
665 { $$.value = error_mark_node; $$.original_code = ERROR_MARK; }
666 | compstmt_primary_start compstmt_nostart ')'
668 pedwarn ("ISO C forbids braced-groups within expressions");
669 $$.value = c_finish_stmt_expr ($1);
670 $$.original_code = ERROR_MARK;
672 | compstmt_primary_start error ')'
673 { c_finish_stmt_expr ($1);
674 $$.value = error_mark_node;
675 $$.original_code = ERROR_MARK;
677 | primary '(' exprlist ')' %prec '.'
678 { $$.value = build_function_call ($1.value, $3);
679 $$.original_code = ERROR_MARK; }
680 | VA_ARG '(' expr_no_commas ',' typename ')'
681 { $$.value = build_va_arg ($3.value, groktypename ($5));
682 $$.original_code = ERROR_MARK; }
684 | OFFSETOF '(' typename ','
685 { tree type = groktypename ($3);
686 if (type == error_mark_node)
687 offsetof_base = error_mark_node;
689 offsetof_base = build1 (INDIRECT_REF, type, NULL);
691 offsetof_member_designator ')'
692 { $$.value = fold_offsetof ($6);
693 $$.original_code = ERROR_MARK; }
694 | OFFSETOF '(' error ')'
695 { $$.value = error_mark_node; $$.original_code = ERROR_MARK; }
696 | CHOOSE_EXPR '(' expr_no_commas ',' expr_no_commas ','
703 if (TREE_CODE (c) != INTEGER_CST)
704 error ("first argument to __builtin_choose_expr not"
706 $$ = integer_zerop (c) ? $7 : $5;
708 | CHOOSE_EXPR '(' error ')'
709 { $$.value = error_mark_node; $$.original_code = ERROR_MARK; }
710 | TYPES_COMPATIBLE_P '(' typename ',' typename ')'
714 e1 = TYPE_MAIN_VARIANT (groktypename ($3));
715 e2 = TYPE_MAIN_VARIANT (groktypename ($5));
717 $$.value = comptypes (e1, e2)
718 ? build_int_cst (NULL_TREE, 1)
719 : build_int_cst (NULL_TREE, 0);
720 $$.original_code = ERROR_MARK;
722 | TYPES_COMPATIBLE_P '(' error ')'
723 { $$.value = error_mark_node; $$.original_code = ERROR_MARK; }
724 | primary '[' expr ']' %prec '.'
725 { $$.value = build_array_ref ($1.value, $3.value);
726 $$.original_code = ERROR_MARK; }
727 | primary '.' identifier
728 { $$.value = build_component_ref ($1.value, $3);
729 $$.original_code = ERROR_MARK; }
730 | primary POINTSAT identifier
732 tree expr = build_indirect_ref ($1.value, "->");
733 $$.value = build_component_ref (expr, $3);
734 $$.original_code = ERROR_MARK;
737 { $$.value = build_unary_op (POSTINCREMENT_EXPR, $1.value, 0);
738 $$.original_code = ERROR_MARK; }
740 { $$.value = build_unary_op (POSTDECREMENT_EXPR, $1.value, 0);
741 $$.original_code = ERROR_MARK; }
744 { $$.value = objc_build_message_expr ($1);
745 $$.original_code = ERROR_MARK; }
747 { $$.value = objc_build_selector_expr ($1);
748 $$.original_code = ERROR_MARK; }
750 { $$.value = objc_build_protocol_expr ($1);
751 $$.original_code = ERROR_MARK; }
753 { $$.value = objc_build_encode_expr ($1);
754 $$.original_code = ERROR_MARK; }
756 { $$.value = objc_build_string_object ($1);
757 $$.original_code = ERROR_MARK; }
761 /* This is the second argument to __builtin_offsetof. We must have one
762 identifier, and beyond that we want to accept sub structure and sub
765 offsetof_member_designator:
767 { $$ = build_component_ref (offsetof_base, $1); }
768 | offsetof_member_designator '.' identifier
769 { $$ = build_component_ref ($1, $3); }
770 | offsetof_member_designator '[' expr ']'
771 { $$ = build_array_ref ($1, $3.value); }
774 old_style_parm_decls:
779 /* The following are analogous to lineno_decl, decls and decl
780 except that they do not allow nested functions.
781 They are used for old-style parm decls. */
783 save_location datadecl
790 | datadecls lineno_datadecl
791 | lineno_datadecl errstmt
794 /* We don't allow prefix attributes here because they cause reduce/reduce
795 conflicts: we can't know whether we're parsing a function decl with
796 attribute suffix, or function defn with attribute prefix on first old
799 declspecs_ts_nosa setspecs initdecls ';'
800 { POP_DECLSPEC_STACK; }
801 | declspecs_nots_nosa setspecs notype_initdecls ';'
802 { POP_DECLSPEC_STACK; }
803 | declspecs_ts_nosa ';'
804 { shadow_tag_warned ($1, 1);
805 pedwarn ("empty declaration"); }
806 | declspecs_nots_nosa ';'
807 { pedwarn ("empty declaration"); }
810 /* This combination which saves a lineno before a decl
811 is the normal thing to use, rather than decl itself.
812 This is to avoid shift/reduce conflicts in contexts
813 where statement labels are allowed. */
819 /* records the type and storage class specs to use for processing
820 the declarators that follow.
821 Maintains a stack of outer-level values of current_declspecs,
822 for the sake of parm declarations nested in function declarators. */
823 setspecs: /* empty */
824 { pending_xref_error ();
826 split_specs_attrs ($<ttype>0,
827 ¤t_declspecs, &prefix_attributes);
828 all_prefix_attributes = prefix_attributes; }
831 /* Possibly attributes after a comma, which should reset all_prefix_attributes
832 to prefix_attributes with these ones chained on the front. */
835 { all_prefix_attributes = chainon ($1, prefix_attributes); }
839 declspecs_ts setspecs initdecls ';'
840 { POP_DECLSPEC_STACK; }
841 | declspecs_nots setspecs notype_initdecls ';'
842 { POP_DECLSPEC_STACK; }
843 | declspecs_ts setspecs nested_function
844 { POP_DECLSPEC_STACK; }
845 | declspecs_nots setspecs notype_nested_function
846 { POP_DECLSPEC_STACK; }
850 { RESTORE_EXT_FLAGS ($1); }
853 /* A list of declaration specifiers. These are:
855 - Storage class specifiers (scspec), which for GCC currently includes
856 function specifiers ("inline").
858 - Type specifiers (typespec_*).
860 - Type qualifiers (TYPE_QUAL).
862 - Attribute specifier lists (attributes).
864 These are stored as a TREE_LIST; the head of the list is the last
865 item in the specifier list. Each entry in the list has either a
866 TREE_PURPOSE that is an attribute specifier list, or a TREE_VALUE that
867 is a single other specifier or qualifier; and a TREE_CHAIN that is the
868 rest of the list. TREE_STATIC is set on the list if something other
869 than a storage class specifier or attribute has been seen; this is used
870 to warn for the obsolescent usage of storage class specifiers other than
871 at the start of the list. (Doing this properly would require function
872 specifiers to be handled separately from storage class specifiers.)
874 The various cases below are classified according to:
876 (a) Whether a storage class specifier is included or not; some
877 places in the grammar disallow storage class specifiers (_sc or _nosc).
879 (b) Whether a type specifier has been seen; after a type specifier,
880 a typedef name is an identifier to redeclare (_ts or _nots).
882 (c) Whether the list starts with an attribute; in certain places,
883 the grammar requires specifiers that don't start with an attribute
886 (d) Whether the list ends with an attribute (or a specifier such that
887 any following attribute would have been parsed as part of that specifier);
888 this avoids shift-reduce conflicts in the parsing of attributes
893 (i) Distinguish between function specifiers and storage class specifiers,
894 at least for the purpose of warnings about obsolescent usage.
896 (ii) Halve the number of productions here by eliminating the _sc/_nosc
897 distinction and instead checking where required that storage class
898 specifiers aren't present. */
900 /* Declspecs which contain at least one type specifier or typedef name.
901 (Just `const' or `volatile' is not enough.)
902 A typedef'd name following these is taken as a name to be declared.
903 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
905 declspecs_nosc_nots_nosa_noea:
907 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
908 TREE_STATIC ($$) = 1; }
909 | declspecs_nosc_nots_nosa_noea TYPE_QUAL
910 { $$ = tree_cons (NULL_TREE, $2, $1);
911 TREE_STATIC ($$) = 1; }
912 | declspecs_nosc_nots_nosa_ea TYPE_QUAL
913 { $$ = tree_cons (NULL_TREE, $2, $1);
914 TREE_STATIC ($$) = 1; }
917 declspecs_nosc_nots_nosa_ea:
918 declspecs_nosc_nots_nosa_noea attributes
919 { $$ = tree_cons ($2, NULL_TREE, $1);
920 TREE_STATIC ($$) = TREE_STATIC ($1); }
923 declspecs_nosc_nots_sa_noea:
924 declspecs_nosc_nots_sa_noea TYPE_QUAL
925 { $$ = tree_cons (NULL_TREE, $2, $1);
926 TREE_STATIC ($$) = 1; }
927 | declspecs_nosc_nots_sa_ea TYPE_QUAL
928 { $$ = tree_cons (NULL_TREE, $2, $1);
929 TREE_STATIC ($$) = 1; }
932 declspecs_nosc_nots_sa_ea:
934 { $$ = tree_cons ($1, NULL_TREE, NULL_TREE);
935 TREE_STATIC ($$) = 0; }
936 | declspecs_nosc_nots_sa_noea attributes
937 { $$ = tree_cons ($2, NULL_TREE, $1);
938 TREE_STATIC ($$) = TREE_STATIC ($1); }
941 declspecs_nosc_ts_nosa_noea:
943 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
944 TREE_STATIC ($$) = 1; }
945 | declspecs_nosc_ts_nosa_noea TYPE_QUAL
946 { $$ = tree_cons (NULL_TREE, $2, $1);
947 TREE_STATIC ($$) = 1; }
948 | declspecs_nosc_ts_nosa_ea TYPE_QUAL
949 { $$ = tree_cons (NULL_TREE, $2, $1);
950 TREE_STATIC ($$) = 1; }
951 | declspecs_nosc_ts_nosa_noea typespec_reserved_nonattr
952 { $$ = tree_cons (NULL_TREE, $2, $1);
953 TREE_STATIC ($$) = 1; }
954 | declspecs_nosc_ts_nosa_ea typespec_reserved_nonattr
955 { $$ = tree_cons (NULL_TREE, $2, $1);
956 TREE_STATIC ($$) = 1; }
957 | declspecs_nosc_nots_nosa_noea typespec_nonattr
958 { $$ = tree_cons (NULL_TREE, $2, $1);
959 TREE_STATIC ($$) = 1; }
960 | declspecs_nosc_nots_nosa_ea typespec_nonattr
961 { $$ = tree_cons (NULL_TREE, $2, $1);
962 TREE_STATIC ($$) = 1; }
965 declspecs_nosc_ts_nosa_ea:
967 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
968 TREE_STATIC ($$) = 1; }
969 | declspecs_nosc_ts_nosa_noea attributes
970 { $$ = tree_cons ($2, NULL_TREE, $1);
971 TREE_STATIC ($$) = TREE_STATIC ($1); }
972 | declspecs_nosc_ts_nosa_noea typespec_reserved_attr
973 { $$ = tree_cons (NULL_TREE, $2, $1);
974 TREE_STATIC ($$) = 1; }
975 | declspecs_nosc_ts_nosa_ea typespec_reserved_attr
976 { $$ = tree_cons (NULL_TREE, $2, $1);
977 TREE_STATIC ($$) = 1; }
978 | declspecs_nosc_nots_nosa_noea typespec_attr
979 { $$ = tree_cons (NULL_TREE, $2, $1);
980 TREE_STATIC ($$) = 1; }
981 | declspecs_nosc_nots_nosa_ea typespec_attr
982 { $$ = tree_cons (NULL_TREE, $2, $1);
983 TREE_STATIC ($$) = 1; }
986 declspecs_nosc_ts_sa_noea:
987 declspecs_nosc_ts_sa_noea TYPE_QUAL
988 { $$ = tree_cons (NULL_TREE, $2, $1);
989 TREE_STATIC ($$) = 1; }
990 | declspecs_nosc_ts_sa_ea TYPE_QUAL
991 { $$ = tree_cons (NULL_TREE, $2, $1);
992 TREE_STATIC ($$) = 1; }
993 | declspecs_nosc_ts_sa_noea typespec_reserved_nonattr
994 { $$ = tree_cons (NULL_TREE, $2, $1);
995 TREE_STATIC ($$) = 1; }
996 | declspecs_nosc_ts_sa_ea typespec_reserved_nonattr
997 { $$ = tree_cons (NULL_TREE, $2, $1);
998 TREE_STATIC ($$) = 1; }
999 | declspecs_nosc_nots_sa_noea typespec_nonattr
1000 { $$ = tree_cons (NULL_TREE, $2, $1);
1001 TREE_STATIC ($$) = 1; }
1002 | declspecs_nosc_nots_sa_ea typespec_nonattr
1003 { $$ = tree_cons (NULL_TREE, $2, $1);
1004 TREE_STATIC ($$) = 1; }
1007 declspecs_nosc_ts_sa_ea:
1008 declspecs_nosc_ts_sa_noea attributes
1009 { $$ = tree_cons ($2, NULL_TREE, $1);
1010 TREE_STATIC ($$) = TREE_STATIC ($1); }
1011 | declspecs_nosc_ts_sa_noea typespec_reserved_attr
1012 { $$ = tree_cons (NULL_TREE, $2, $1);
1013 TREE_STATIC ($$) = 1; }
1014 | declspecs_nosc_ts_sa_ea typespec_reserved_attr
1015 { $$ = tree_cons (NULL_TREE, $2, $1);
1016 TREE_STATIC ($$) = 1; }
1017 | declspecs_nosc_nots_sa_noea typespec_attr
1018 { $$ = tree_cons (NULL_TREE, $2, $1);
1019 TREE_STATIC ($$) = 1; }
1020 | declspecs_nosc_nots_sa_ea typespec_attr
1021 { $$ = tree_cons (NULL_TREE, $2, $1);
1022 TREE_STATIC ($$) = 1; }
1025 declspecs_sc_nots_nosa_noea:
1027 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
1028 TREE_STATIC ($$) = 0; }
1029 | declspecs_sc_nots_nosa_noea TYPE_QUAL
1030 { $$ = tree_cons (NULL_TREE, $2, $1);
1031 TREE_STATIC ($$) = 1; }
1032 | declspecs_sc_nots_nosa_ea TYPE_QUAL
1033 { $$ = tree_cons (NULL_TREE, $2, $1);
1034 TREE_STATIC ($$) = 1; }
1035 | declspecs_nosc_nots_nosa_noea scspec
1036 { if (extra_warnings && TREE_STATIC ($1))
1037 warning ("`%s' is not at beginning of declaration",
1038 IDENTIFIER_POINTER ($2));
1039 $$ = tree_cons (NULL_TREE, $2, $1);
1040 TREE_STATIC ($$) = TREE_STATIC ($1); }
1041 | declspecs_nosc_nots_nosa_ea scspec
1042 { if (extra_warnings && TREE_STATIC ($1))
1043 warning ("`%s' is not at beginning of declaration",
1044 IDENTIFIER_POINTER ($2));
1045 $$ = tree_cons (NULL_TREE, $2, $1);
1046 TREE_STATIC ($$) = TREE_STATIC ($1); }
1047 | declspecs_sc_nots_nosa_noea scspec
1048 { if (extra_warnings && TREE_STATIC ($1))
1049 warning ("`%s' is not at beginning of declaration",
1050 IDENTIFIER_POINTER ($2));
1051 $$ = tree_cons (NULL_TREE, $2, $1);
1052 TREE_STATIC ($$) = TREE_STATIC ($1); }
1053 | declspecs_sc_nots_nosa_ea scspec
1054 { if (extra_warnings && TREE_STATIC ($1))
1055 warning ("`%s' is not at beginning of declaration",
1056 IDENTIFIER_POINTER ($2));
1057 $$ = tree_cons (NULL_TREE, $2, $1);
1058 TREE_STATIC ($$) = TREE_STATIC ($1); }
1061 declspecs_sc_nots_nosa_ea:
1062 declspecs_sc_nots_nosa_noea attributes
1063 { $$ = tree_cons ($2, NULL_TREE, $1);
1064 TREE_STATIC ($$) = TREE_STATIC ($1); }
1067 declspecs_sc_nots_sa_noea:
1068 declspecs_sc_nots_sa_noea TYPE_QUAL
1069 { $$ = tree_cons (NULL_TREE, $2, $1);
1070 TREE_STATIC ($$) = 1; }
1071 | declspecs_sc_nots_sa_ea TYPE_QUAL
1072 { $$ = tree_cons (NULL_TREE, $2, $1);
1073 TREE_STATIC ($$) = 1; }
1074 | declspecs_nosc_nots_sa_noea scspec
1075 { if (extra_warnings && TREE_STATIC ($1))
1076 warning ("`%s' is not at beginning of declaration",
1077 IDENTIFIER_POINTER ($2));
1078 $$ = tree_cons (NULL_TREE, $2, $1);
1079 TREE_STATIC ($$) = TREE_STATIC ($1); }
1080 | declspecs_nosc_nots_sa_ea scspec
1081 { if (extra_warnings && TREE_STATIC ($1))
1082 warning ("`%s' is not at beginning of declaration",
1083 IDENTIFIER_POINTER ($2));
1084 $$ = tree_cons (NULL_TREE, $2, $1);
1085 TREE_STATIC ($$) = TREE_STATIC ($1); }
1086 | declspecs_sc_nots_sa_noea scspec
1087 { if (extra_warnings && TREE_STATIC ($1))
1088 warning ("`%s' is not at beginning of declaration",
1089 IDENTIFIER_POINTER ($2));
1090 $$ = tree_cons (NULL_TREE, $2, $1);
1091 TREE_STATIC ($$) = TREE_STATIC ($1); }
1092 | declspecs_sc_nots_sa_ea scspec
1093 { if (extra_warnings && TREE_STATIC ($1))
1094 warning ("`%s' is not at beginning of declaration",
1095 IDENTIFIER_POINTER ($2));
1096 $$ = tree_cons (NULL_TREE, $2, $1);
1097 TREE_STATIC ($$) = TREE_STATIC ($1); }
1100 declspecs_sc_nots_sa_ea:
1101 declspecs_sc_nots_sa_noea attributes
1102 { $$ = tree_cons ($2, NULL_TREE, $1);
1103 TREE_STATIC ($$) = TREE_STATIC ($1); }
1106 declspecs_sc_ts_nosa_noea:
1107 declspecs_sc_ts_nosa_noea TYPE_QUAL
1108 { $$ = tree_cons (NULL_TREE, $2, $1);
1109 TREE_STATIC ($$) = 1; }
1110 | declspecs_sc_ts_nosa_ea TYPE_QUAL
1111 { $$ = tree_cons (NULL_TREE, $2, $1);
1112 TREE_STATIC ($$) = 1; }
1113 | declspecs_sc_ts_nosa_noea typespec_reserved_nonattr
1114 { $$ = tree_cons (NULL_TREE, $2, $1);
1115 TREE_STATIC ($$) = 1; }
1116 | declspecs_sc_ts_nosa_ea typespec_reserved_nonattr
1117 { $$ = tree_cons (NULL_TREE, $2, $1);
1118 TREE_STATIC ($$) = 1; }
1119 | declspecs_sc_nots_nosa_noea typespec_nonattr
1120 { $$ = tree_cons (NULL_TREE, $2, $1);
1121 TREE_STATIC ($$) = 1; }
1122 | declspecs_sc_nots_nosa_ea typespec_nonattr
1123 { $$ = tree_cons (NULL_TREE, $2, $1);
1124 TREE_STATIC ($$) = 1; }
1125 | declspecs_nosc_ts_nosa_noea scspec
1126 { if (extra_warnings && TREE_STATIC ($1))
1127 warning ("`%s' is not at beginning of declaration",
1128 IDENTIFIER_POINTER ($2));
1129 $$ = tree_cons (NULL_TREE, $2, $1);
1130 TREE_STATIC ($$) = TREE_STATIC ($1); }
1131 | declspecs_nosc_ts_nosa_ea scspec
1132 { if (extra_warnings && TREE_STATIC ($1))
1133 warning ("`%s' is not at beginning of declaration",
1134 IDENTIFIER_POINTER ($2));
1135 $$ = tree_cons (NULL_TREE, $2, $1);
1136 TREE_STATIC ($$) = TREE_STATIC ($1); }
1137 | declspecs_sc_ts_nosa_noea scspec
1138 { if (extra_warnings && TREE_STATIC ($1))
1139 warning ("`%s' is not at beginning of declaration",
1140 IDENTIFIER_POINTER ($2));
1141 $$ = tree_cons (NULL_TREE, $2, $1);
1142 TREE_STATIC ($$) = TREE_STATIC ($1); }
1143 | declspecs_sc_ts_nosa_ea scspec
1144 { if (extra_warnings && TREE_STATIC ($1))
1145 warning ("`%s' is not at beginning of declaration",
1146 IDENTIFIER_POINTER ($2));
1147 $$ = tree_cons (NULL_TREE, $2, $1);
1148 TREE_STATIC ($$) = TREE_STATIC ($1); }
1151 declspecs_sc_ts_nosa_ea:
1152 declspecs_sc_ts_nosa_noea attributes
1153 { $$ = tree_cons ($2, NULL_TREE, $1);
1154 TREE_STATIC ($$) = TREE_STATIC ($1); }
1155 | declspecs_sc_ts_nosa_noea typespec_reserved_attr
1156 { $$ = tree_cons (NULL_TREE, $2, $1);
1157 TREE_STATIC ($$) = 1; }
1158 | declspecs_sc_ts_nosa_ea typespec_reserved_attr
1159 { $$ = tree_cons (NULL_TREE, $2, $1);
1160 TREE_STATIC ($$) = 1; }
1161 | declspecs_sc_nots_nosa_noea typespec_attr
1162 { $$ = tree_cons (NULL_TREE, $2, $1);
1163 TREE_STATIC ($$) = 1; }
1164 | declspecs_sc_nots_nosa_ea typespec_attr
1165 { $$ = tree_cons (NULL_TREE, $2, $1);
1166 TREE_STATIC ($$) = 1; }
1169 declspecs_sc_ts_sa_noea:
1170 declspecs_sc_ts_sa_noea TYPE_QUAL
1171 { $$ = tree_cons (NULL_TREE, $2, $1);
1172 TREE_STATIC ($$) = 1; }
1173 | declspecs_sc_ts_sa_ea TYPE_QUAL
1174 { $$ = tree_cons (NULL_TREE, $2, $1);
1175 TREE_STATIC ($$) = 1; }
1176 | declspecs_sc_ts_sa_noea typespec_reserved_nonattr
1177 { $$ = tree_cons (NULL_TREE, $2, $1);
1178 TREE_STATIC ($$) = 1; }
1179 | declspecs_sc_ts_sa_ea typespec_reserved_nonattr
1180 { $$ = tree_cons (NULL_TREE, $2, $1);
1181 TREE_STATIC ($$) = 1; }
1182 | declspecs_sc_nots_sa_noea typespec_nonattr
1183 { $$ = tree_cons (NULL_TREE, $2, $1);
1184 TREE_STATIC ($$) = 1; }
1185 | declspecs_sc_nots_sa_ea typespec_nonattr
1186 { $$ = tree_cons (NULL_TREE, $2, $1);
1187 TREE_STATIC ($$) = 1; }
1188 | declspecs_nosc_ts_sa_noea scspec
1189 { if (extra_warnings && TREE_STATIC ($1))
1190 warning ("`%s' is not at beginning of declaration",
1191 IDENTIFIER_POINTER ($2));
1192 $$ = tree_cons (NULL_TREE, $2, $1);
1193 TREE_STATIC ($$) = TREE_STATIC ($1); }
1194 | declspecs_nosc_ts_sa_ea scspec
1195 { if (extra_warnings && TREE_STATIC ($1))
1196 warning ("`%s' is not at beginning of declaration",
1197 IDENTIFIER_POINTER ($2));
1198 $$ = tree_cons (NULL_TREE, $2, $1);
1199 TREE_STATIC ($$) = TREE_STATIC ($1); }
1200 | declspecs_sc_ts_sa_noea scspec
1201 { if (extra_warnings && TREE_STATIC ($1))
1202 warning ("`%s' is not at beginning of declaration",
1203 IDENTIFIER_POINTER ($2));
1204 $$ = tree_cons (NULL_TREE, $2, $1);
1205 TREE_STATIC ($$) = TREE_STATIC ($1); }
1206 | declspecs_sc_ts_sa_ea scspec
1207 { if (extra_warnings && TREE_STATIC ($1))
1208 warning ("`%s' is not at beginning of declaration",
1209 IDENTIFIER_POINTER ($2));
1210 $$ = tree_cons (NULL_TREE, $2, $1);
1211 TREE_STATIC ($$) = TREE_STATIC ($1); }
1214 declspecs_sc_ts_sa_ea:
1215 declspecs_sc_ts_sa_noea attributes
1216 { $$ = tree_cons ($2, NULL_TREE, $1);
1217 TREE_STATIC ($$) = TREE_STATIC ($1); }
1218 | declspecs_sc_ts_sa_noea typespec_reserved_attr
1219 { $$ = tree_cons (NULL_TREE, $2, $1);
1220 TREE_STATIC ($$) = 1; }
1221 | declspecs_sc_ts_sa_ea typespec_reserved_attr
1222 { $$ = tree_cons (NULL_TREE, $2, $1);
1223 TREE_STATIC ($$) = 1; }
1224 | declspecs_sc_nots_sa_noea typespec_attr
1225 { $$ = tree_cons (NULL_TREE, $2, $1);
1226 TREE_STATIC ($$) = 1; }
1227 | declspecs_sc_nots_sa_ea typespec_attr
1228 { $$ = tree_cons (NULL_TREE, $2, $1);
1229 TREE_STATIC ($$) = 1; }
1232 /* Particular useful classes of declspecs. */
1234 declspecs_nosc_ts_nosa_noea
1235 | declspecs_nosc_ts_nosa_ea
1236 | declspecs_nosc_ts_sa_noea
1237 | declspecs_nosc_ts_sa_ea
1238 | declspecs_sc_ts_nosa_noea
1239 | declspecs_sc_ts_nosa_ea
1240 | declspecs_sc_ts_sa_noea
1241 | declspecs_sc_ts_sa_ea
1245 declspecs_nosc_nots_nosa_noea
1246 | declspecs_nosc_nots_nosa_ea
1247 | declspecs_nosc_nots_sa_noea
1248 | declspecs_nosc_nots_sa_ea
1249 | declspecs_sc_nots_nosa_noea
1250 | declspecs_sc_nots_nosa_ea
1251 | declspecs_sc_nots_sa_noea
1252 | declspecs_sc_nots_sa_ea
1256 declspecs_nosc_ts_nosa_noea
1257 | declspecs_nosc_ts_nosa_ea
1258 | declspecs_sc_ts_nosa_noea
1259 | declspecs_sc_ts_nosa_ea
1262 declspecs_nots_nosa:
1263 declspecs_nosc_nots_nosa_noea
1264 | declspecs_nosc_nots_nosa_ea
1265 | declspecs_sc_nots_nosa_noea
1266 | declspecs_sc_nots_nosa_ea
1270 declspecs_nosc_ts_nosa_noea
1271 | declspecs_nosc_ts_nosa_ea
1272 | declspecs_nosc_ts_sa_noea
1273 | declspecs_nosc_ts_sa_ea
1276 declspecs_nosc_nots:
1277 declspecs_nosc_nots_nosa_noea
1278 | declspecs_nosc_nots_nosa_ea
1279 | declspecs_nosc_nots_sa_noea
1280 | declspecs_nosc_nots_sa_ea
1284 declspecs_nosc_ts_nosa_noea
1285 | declspecs_nosc_ts_nosa_ea
1286 | declspecs_nosc_ts_sa_noea
1287 | declspecs_nosc_ts_sa_ea
1288 | declspecs_nosc_nots_nosa_noea
1289 | declspecs_nosc_nots_nosa_ea
1290 | declspecs_nosc_nots_sa_noea
1291 | declspecs_nosc_nots_sa_ea
1295 declspecs_nosc_nots_nosa_noea
1296 | declspecs_nosc_nots_nosa_ea
1297 | declspecs_nosc_nots_sa_noea
1298 | declspecs_nosc_nots_sa_ea
1299 | declspecs_nosc_ts_nosa_noea
1300 | declspecs_nosc_ts_nosa_ea
1301 | declspecs_nosc_ts_sa_noea
1302 | declspecs_nosc_ts_sa_ea
1303 | declspecs_sc_nots_nosa_noea
1304 | declspecs_sc_nots_nosa_ea
1305 | declspecs_sc_nots_sa_noea
1306 | declspecs_sc_nots_sa_ea
1307 | declspecs_sc_ts_nosa_noea
1308 | declspecs_sc_ts_nosa_ea
1309 | declspecs_sc_ts_sa_noea
1310 | declspecs_sc_ts_sa_ea
1313 /* A (possibly empty) sequence of type qualifiers and attributes. */
1314 maybe_type_quals_attrs:
1317 | declspecs_nosc_nots
1321 /* A type specifier (but not a type qualifier).
1322 Once we have seen one of these in a declaration,
1323 if a typedef name appears then it is being redeclared.
1325 The _reserved versions start with a reserved word and may appear anywhere
1326 in the declaration specifiers; the _nonreserved versions may only
1327 appear before any other type specifiers, and after that are (if names)
1330 FIXME: should the _nonreserved version be restricted to names being
1331 redeclared only? The other entries there relate only the GNU extensions
1332 and Objective C, and are historically parsed thus, and don't make sense
1333 after other type specifiers, but it might be cleaner to count them as
1336 _attr means: specifiers that either end with attributes,
1337 or are such that any following attributes would
1338 be parsed as part of the specifier.
1340 _nonattr: specifiers. */
1343 typespec_reserved_nonattr
1344 | typespec_nonreserved_nonattr
1348 typespec_reserved_attr
1351 typespec_reserved_nonattr:
1353 { OBJC_NEED_RAW_IDENTIFIER (1); }
1357 typespec_reserved_attr:
1361 typespec_nonreserved_nonattr:
1363 { /* For a typedef name, record the meaning, not the name.
1364 In case of `foo foo, bar;'. */
1365 $$ = lookup_name ($1); }
1367 | CLASSNAME protocolrefs
1368 { $$ = objc_get_protocol_qualified_type ($1, $2); }
1369 | OBJECTNAME protocolrefs
1370 { $$ = objc_get_protocol_qualified_type ($1, $2); }
1372 /* Make "<SomeProtocol>" equivalent to "id <SomeProtocol>"
1373 - nisse@lysator.liu.se */
1374 | non_empty_protocolrefs
1375 { $$ = objc_get_protocol_qualified_type (NULL_TREE, $1); }
1377 | typeof '(' expr ')'
1378 { skip_evaluation--;
1379 if (TREE_CODE ($3.value) == COMPONENT_REF
1380 && DECL_C_BIT_FIELD (TREE_OPERAND ($3.value, 1)))
1381 error ("`typeof' applied to a bit-field");
1382 $$ = TREE_TYPE ($3.value); }
1383 | typeof '(' typename ')'
1384 { skip_evaluation--; $$ = groktypename ($3); }
1387 /* typespec_nonreserved_attr does not exist. */
1391 | initdecls ',' maybe_resetattrs initdcl
1396 | notype_initdecls ',' maybe_resetattrs notype_initdcl
1400 declarator maybeasm maybe_attribute '='
1401 { $<ttype>$ = start_decl ($1, current_declspecs, true,
1402 chainon ($3, all_prefix_attributes));
1403 start_init ($<ttype>$, $2, global_bindings_p ()); }
1405 /* Note how the declaration of the variable is in effect while its init is parsed! */
1407 maybe_warn_string_init (TREE_TYPE ($<ttype>5), $6);
1408 finish_decl ($<ttype>5, $6.value, $2); }
1409 | declarator maybeasm maybe_attribute
1410 { tree d = start_decl ($1, current_declspecs, false,
1411 chainon ($3, all_prefix_attributes));
1412 finish_decl (d, NULL_TREE, $2);
1417 notype_declarator maybeasm maybe_attribute '='
1418 { $<ttype>$ = start_decl ($1, current_declspecs, true,
1419 chainon ($3, all_prefix_attributes));
1420 start_init ($<ttype>$, $2, global_bindings_p ()); }
1422 /* Note how the declaration of the variable is in effect while its init is parsed! */
1424 maybe_warn_string_init (TREE_TYPE ($<ttype>5), $6);
1425 finish_decl ($<ttype>5, $6.value, $2); }
1426 | notype_declarator maybeasm maybe_attribute
1427 { tree d = start_decl ($1, current_declspecs, false,
1428 chainon ($3, all_prefix_attributes));
1429 finish_decl (d, NULL_TREE, $2); }
1431 /* the * rules are dummies to accept the Apollo extended syntax
1432 so that the header files compile. */
1443 | attributes attribute
1444 { $$ = chainon ($1, $2); }
1448 ATTRIBUTE stop_string_translation
1449 '(' '(' attribute_list ')' ')' start_string_translation
1451 | ATTRIBUTE error start_string_translation
1458 | attribute_list ',' attrib
1459 { $$ = chainon ($1, $3); }
1466 { $$ = build_tree_list ($1, NULL_TREE); }
1467 | any_word '(' IDENTIFIER ')'
1468 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1469 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1470 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1471 | any_word '(' exprlist ')'
1472 { $$ = build_tree_list ($1, $3); }
1475 /* This still leaves out most reserved keywords,
1476 shouldn't we include them? */
1490 /* Initializers. `init' is the entry point. */
1496 { really_start_incremental_init (NULL_TREE); }
1497 initlist_maybe_comma '}'
1498 { $$ = pop_init_level (0); }
1500 { $$.value = error_mark_node; $$.original_code = ERROR_MARK; }
1503 /* `initlist_maybe_comma' is the guts of an initializer in braces. */
1504 initlist_maybe_comma:
1507 pedwarn ("ISO C forbids empty initializer braces"); }
1508 | initlist1 maybecomma
1513 | initlist1 ',' initelt
1516 /* `initelt' is a single element of an initializer.
1517 It may use braces. */
1519 designator_list '=' initval
1520 { if (pedantic && ! flag_isoc99)
1521 pedwarn ("ISO C90 forbids specifying subobject to initialize"); }
1522 | designator initval
1524 pedwarn ("obsolete use of designated initializer without `='"); }
1526 { set_init_label ($1);
1528 pedwarn ("obsolete use of designated initializer with `:'"); }
1536 { push_init_level (0); }
1537 initlist_maybe_comma '}'
1538 { process_init_element (pop_init_level (0)); }
1540 { process_init_element ($1); }
1546 | designator_list designator
1551 { set_init_label ($2); }
1552 | '[' expr_no_commas ELLIPSIS expr_no_commas ']'
1553 { set_init_index ($2.value, $4.value);
1555 pedwarn ("ISO C forbids specifying range of elements to initialize"); }
1556 | '[' expr_no_commas ']'
1557 { set_init_index ($2.value, NULL_TREE); }
1563 pedwarn ("ISO C forbids nested functions");
1565 push_function_context ();
1566 if (! start_function (current_declspecs, $1,
1567 all_prefix_attributes))
1569 pop_function_context ();
1573 old_style_parm_decls save_location
1574 { tree decl = current_function_decl;
1575 DECL_SOURCE_LOCATION (decl) = $4;
1576 store_parm_decls (); }
1577 /* This used to use compstmt_or_error. That caused a bug with
1578 input `f(g) int g {}', where the use of YYERROR1 above caused
1579 an error which then was handled by compstmt_or_error. There
1580 followed a repeated execution of that same rule, which called
1581 YYERROR1 again, and so on. */
1583 { tree decl = current_function_decl;
1586 pop_function_context ();
1587 add_stmt (build_stmt (DECL_EXPR, decl)); }
1590 notype_nested_function:
1593 pedwarn ("ISO C forbids nested functions");
1595 push_function_context ();
1596 if (! start_function (current_declspecs, $1,
1597 all_prefix_attributes))
1599 pop_function_context ();
1603 old_style_parm_decls save_location
1604 { tree decl = current_function_decl;
1605 DECL_SOURCE_LOCATION (decl) = $4;
1606 store_parm_decls (); }
1607 /* This used to use compstmt_or_error. That caused a bug with
1608 input `f(g) int g {}', where the use of YYERROR1 above caused
1609 an error which then was handled by compstmt_or_error. There
1610 followed a repeated execution of that same rule, which called
1611 YYERROR1 again, and so on. */
1613 { tree decl = current_function_decl;
1616 pop_function_context ();
1617 add_stmt (build_stmt (DECL_EXPR, decl)); }
1620 /* Any kind of declarator (thus, all declarators allowed
1621 after an explicit typespec). */
1624 after_type_declarator
1628 /* A declarator that is allowed only after an explicit typespec. */
1630 after_type_declarator:
1631 '(' maybe_attribute after_type_declarator ')'
1632 { $$ = $2 ? build_attrs_declarator ($2, $3) : $3; }
1633 | after_type_declarator '(' parmlist_or_identifiers %prec '.'
1634 { $$ = build_function_declarator ($3, $1); }
1635 | after_type_declarator array_declarator %prec '.'
1636 { $$ = set_array_declarator_inner ($2, $1, false); }
1637 | '*' maybe_type_quals_attrs after_type_declarator %prec UNARY
1638 { $$ = make_pointer_declarator ($2, $3); }
1645 /* Kinds of declarator that can appear in a parameter list
1646 in addition to notype_declarator. This is like after_type_declarator
1647 but does not allow a typedef name in parentheses as an identifier
1648 (because it would conflict with a function with that typedef as arg). */
1650 parm_declarator_starttypename
1651 | parm_declarator_nostarttypename
1654 parm_declarator_starttypename:
1655 parm_declarator_starttypename '(' parmlist_or_identifiers %prec '.'
1656 { $$ = build_function_declarator ($3, $1); }
1657 | parm_declarator_starttypename array_declarator %prec '.'
1658 { $$ = set_array_declarator_inner ($2, $1, false); }
1665 parm_declarator_nostarttypename:
1666 parm_declarator_nostarttypename '(' parmlist_or_identifiers %prec '.'
1667 { $$ = build_function_declarator ($3, $1); }
1668 | parm_declarator_nostarttypename array_declarator %prec '.'
1669 { $$ = set_array_declarator_inner ($2, $1, false); }
1670 | '*' maybe_type_quals_attrs parm_declarator_starttypename %prec UNARY
1671 { $$ = make_pointer_declarator ($2, $3); }
1672 | '*' maybe_type_quals_attrs parm_declarator_nostarttypename %prec UNARY
1673 { $$ = make_pointer_declarator ($2, $3); }
1674 | '(' maybe_attribute parm_declarator_nostarttypename ')'
1675 { $$ = $2 ? build_attrs_declarator ($2, $3) : $3; }
1678 /* A declarator allowed whether or not there has been
1679 an explicit typespec. These cannot redeclare a typedef-name. */
1682 notype_declarator '(' parmlist_or_identifiers %prec '.'
1683 { $$ = build_function_declarator ($3, $1); }
1684 | '(' maybe_attribute notype_declarator ')'
1685 { $$ = $2 ? build_attrs_declarator ($2, $3) : $3; }
1686 | '*' maybe_type_quals_attrs notype_declarator %prec UNARY
1687 { $$ = make_pointer_declarator ($2, $3); }
1688 | notype_declarator array_declarator %prec '.'
1689 { $$ = set_array_declarator_inner ($2, $1, false); }
1714 /* structsp_attr: struct/union/enum specifiers that either
1715 end with attributes, or are such that any following attributes would
1716 be parsed as part of the struct/union/enum specifier.
1718 structsp_nonattr: other struct/union/enum specifiers. */
1721 struct_head identifier '{'
1722 { $$ = start_struct (RECORD_TYPE, $2);
1723 /* Start scope of tag before parsing components. */
1725 component_decl_list '}' maybe_attribute
1726 { $$ = finish_struct ($<ttype>4, nreverse ($5),
1727 chainon ($1, $7)); }
1728 | struct_head '{' component_decl_list '}' maybe_attribute
1729 { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
1730 nreverse ($3), chainon ($1, $5));
1732 | union_head identifier '{'
1733 { $$ = start_struct (UNION_TYPE, $2); }
1734 component_decl_list '}' maybe_attribute
1735 { $$ = finish_struct ($<ttype>4, nreverse ($5),
1736 chainon ($1, $7)); }
1737 | union_head '{' component_decl_list '}' maybe_attribute
1738 { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
1739 nreverse ($3), chainon ($1, $5));
1741 | enum_head identifier '{'
1742 { $$ = start_enum ($2); }
1743 enumlist maybecomma_warn '}' maybe_attribute
1744 { $$ = finish_enum ($<ttype>4, nreverse ($5),
1745 chainon ($1, $8)); }
1747 { $$ = start_enum (NULL_TREE); }
1748 enumlist maybecomma_warn '}' maybe_attribute
1749 { $$ = finish_enum ($<ttype>3, nreverse ($4),
1750 chainon ($1, $7)); }
1754 struct_head identifier
1755 { $$ = xref_tag (RECORD_TYPE, $2); }
1756 | union_head identifier
1757 { $$ = xref_tag (UNION_TYPE, $2); }
1758 | enum_head identifier
1759 { $$ = xref_tag (ENUMERAL_TYPE, $2);
1760 /* In ISO C, enumerated types can be referred to
1761 only if already defined. */
1762 if (pedantic && !COMPLETE_TYPE_P ($$))
1763 pedwarn ("ISO C forbids forward references to `enum' types"); }
1774 { if (pedantic && ! flag_isoc99)
1775 pedwarn ("comma at end of enumerator list"); }
1778 /* We chain the components in reverse order. They are put in forward
1779 order in structsp_attr.
1781 Note that component_declarator returns single decls, so components
1782 and components_notype can use TREE_CHAIN directly, wheras components
1783 and components_notype return lists (of comma separated decls), so
1784 component_decl_list and component_decl_list2 must use chainon.
1786 The theory behind all this is that there will be more semicolon
1787 separated fields than comma separated fields, and so we'll be
1788 minimizing the number of node traversals required by chainon. */
1790 component_decl_list:
1791 component_decl_list2
1793 | component_decl_list2 component_decl
1794 { $$ = chainon ($2, $1);
1795 pedwarn ("no semicolon at end of struct or union"); }
1798 component_decl_list2: /* empty */
1800 | component_decl_list2 component_decl ';'
1801 { $$ = chainon ($2, $1); }
1802 | component_decl_list2 ';'
1804 pedwarn ("extra semicolon in struct or union specified"); }
1806 /* foo(sizeof(struct{ @defs(ClassName)})); */
1807 | AT_DEFS '(' CLASSNAME ')'
1808 { $$ = nreverse (objc_get_class_ivars ($3)); }
1813 declspecs_nosc_ts setspecs components
1815 POP_DECLSPEC_STACK; }
1816 | declspecs_nosc_ts setspecs
1818 /* Support for unnamed structs or unions as members of
1819 structs or unions (which is [a] useful and [b] supports
1822 pedwarn ("ISO C doesn't support unnamed structs/unions");
1824 $$ = grokfield(NULL, current_declspecs, NULL_TREE);
1825 POP_DECLSPEC_STACK; }
1826 | declspecs_nosc_nots setspecs components_notype
1828 POP_DECLSPEC_STACK; }
1829 | declspecs_nosc_nots
1831 pedwarn ("ISO C forbids member declarations with no members");
1832 shadow_tag_warned ($1, pedantic);
1836 | extension component_decl
1838 RESTORE_EXT_FLAGS ($1); }
1842 component_declarator
1843 | components ',' maybe_resetattrs component_declarator
1844 { TREE_CHAIN ($4) = $1; $$ = $4; }
1848 component_notype_declarator
1849 | components_notype ',' maybe_resetattrs component_notype_declarator
1850 { TREE_CHAIN ($4) = $1; $$ = $4; }
1853 component_declarator:
1854 declarator maybe_attribute
1855 { $$ = grokfield ($1, current_declspecs, NULL_TREE);
1856 decl_attributes (&$$,
1857 chainon ($2, all_prefix_attributes), 0); }
1858 | declarator ':' expr_no_commas maybe_attribute
1859 { $$ = grokfield ($1, current_declspecs, $3.value);
1860 decl_attributes (&$$,
1861 chainon ($4, all_prefix_attributes), 0); }
1862 | ':' expr_no_commas maybe_attribute
1863 { $$ = grokfield (NULL_TREE, current_declspecs, $2.value);
1864 decl_attributes (&$$,
1865 chainon ($3, all_prefix_attributes), 0); }
1868 component_notype_declarator:
1869 notype_declarator maybe_attribute
1870 { $$ = grokfield ($1, current_declspecs, NULL_TREE);
1871 decl_attributes (&$$,
1872 chainon ($2, all_prefix_attributes), 0); }
1873 | notype_declarator ':' expr_no_commas maybe_attribute
1874 { $$ = grokfield ($1, current_declspecs, $3.value);
1875 decl_attributes (&$$,
1876 chainon ($4, all_prefix_attributes), 0); }
1877 | ':' expr_no_commas maybe_attribute
1878 { $$ = grokfield (NULL_TREE, current_declspecs, $2.value);
1879 decl_attributes (&$$,
1880 chainon ($3, all_prefix_attributes), 0); }
1883 /* We chain the enumerators in reverse order.
1884 They are put in forward order in structsp_attr. */
1888 | enumlist ',' enumerator
1889 { if ($1 == error_mark_node)
1892 TREE_CHAIN ($3) = $1, $$ = $3; }
1894 { $$ = error_mark_node; }
1900 { $$ = build_enumerator ($1, NULL_TREE); }
1901 | identifier '=' expr_no_commas
1902 { $$ = build_enumerator ($1, $3.value); }
1907 { pending_xref_error ();
1910 { $$ = build_tree_list ($<ttype>2, $3); }
1913 absdcl: /* an absolute declarator */
1919 absdcl_maybe_attribute: /* absdcl maybe_attribute, but not just attributes */
1921 { $$ = build_c_parm (current_declspecs, all_prefix_attributes,
1924 { $$ = build_c_parm (current_declspecs, all_prefix_attributes,
1926 | absdcl1_noea attributes
1927 { $$ = build_c_parm (current_declspecs,
1928 chainon ($2, all_prefix_attributes),
1932 absdcl1: /* a nonempty absolute declarator */
1939 | '*' maybe_type_quals_attrs absdcl1_noea
1940 { $$ = make_pointer_declarator ($2, $3); }
1944 '*' maybe_type_quals_attrs
1945 { $$ = make_pointer_declarator ($2, NULL_TREE); }
1946 | '*' maybe_type_quals_attrs absdcl1_ea
1947 { $$ = make_pointer_declarator ($2, $3); }
1951 '(' maybe_attribute absdcl1 ')'
1952 { $$ = $2 ? build_attrs_declarator ($2, $3) : $3; }
1953 | direct_absdcl1 '(' parmlist
1954 { $$ = build_function_declarator ($3, $1); }
1955 | direct_absdcl1 array_declarator
1956 { $$ = set_array_declarator_inner ($2, $1, true); }
1958 { $$ = build_function_declarator ($2, NULL_TREE); }
1960 { $$ = set_array_declarator_inner ($1, NULL_TREE, true); }
1963 /* The [...] part of a declarator for an array type. */
1966 '[' maybe_type_quals_attrs expr_no_commas ']'
1967 { $$ = build_array_declarator ($3.value, $2, false, false); }
1968 | '[' maybe_type_quals_attrs ']'
1969 { $$ = build_array_declarator (NULL_TREE, $2, false, false); }
1970 | '[' maybe_type_quals_attrs '*' ']'
1971 { $$ = build_array_declarator (NULL_TREE, $2, false, true); }
1972 | '[' STATIC maybe_type_quals_attrs expr_no_commas ']'
1973 { $$ = build_array_declarator ($4.value, $3, true, false); }
1974 /* declspecs_nosc_nots is a synonym for type_quals_attrs. */
1975 | '[' declspecs_nosc_nots STATIC expr_no_commas ']'
1976 { $$ = build_array_declarator ($4.value, $2, true, false); }
1979 /* A nonempty series of declarations and statements (possibly followed by
1980 some labels) that can form the body of a compound statement.
1981 NOTE: we don't allow labels on declarations; this might seem like a
1982 natural extension, but there would be a conflict between attributes
1983 on the label and prefix attributes on the declaration. */
1986 lineno_stmt_decl_or_labels_ending_stmt
1987 | lineno_stmt_decl_or_labels_ending_decl
1988 | lineno_stmt_decl_or_labels_ending_label
1990 error ("label at end of compound statement");
1992 | lineno_stmt_decl_or_labels_ending_error
1995 lineno_stmt_decl_or_labels_ending_stmt:
1997 | lineno_stmt_decl_or_labels_ending_stmt lineno_stmt
1998 | lineno_stmt_decl_or_labels_ending_decl lineno_stmt
1999 | lineno_stmt_decl_or_labels_ending_label lineno_stmt
2000 | lineno_stmt_decl_or_labels_ending_error lineno_stmt
2003 lineno_stmt_decl_or_labels_ending_decl:
2005 | lineno_stmt_decl_or_labels_ending_stmt lineno_decl
2007 if ((pedantic && !flag_isoc99)
2008 || warn_declaration_after_statement)
2009 pedwarn_c90 ("ISO C90 forbids mixed declarations and code");
2011 | lineno_stmt_decl_or_labels_ending_decl lineno_decl
2012 | lineno_stmt_decl_or_labels_ending_error lineno_decl
2015 lineno_stmt_decl_or_labels_ending_label:
2017 | lineno_stmt_decl_or_labels_ending_stmt lineno_label
2018 | lineno_stmt_decl_or_labels_ending_decl lineno_label
2019 | lineno_stmt_decl_or_labels_ending_label lineno_label
2020 | lineno_stmt_decl_or_labels_ending_error lineno_label
2023 lineno_stmt_decl_or_labels_ending_error:
2025 | lineno_stmt_decl_or_labels errstmt
2028 lineno_stmt_decl_or_labels:
2029 lineno_stmt_decl_or_labels_ending_stmt
2030 | lineno_stmt_decl_or_labels_ending_decl
2031 | lineno_stmt_decl_or_labels_ending_label
2032 | lineno_stmt_decl_or_labels_ending_error
2038 /* Start and end blocks created for the new scopes of C99. */
2039 c99_block_start: /* empty */
2040 { $$ = c_begin_compound_stmt (flag_isoc99); }
2043 /* Read zero or more forward-declarations for labels
2044 that nested functions can jump to. */
2049 pedwarn ("ISO C forbids label declarations"); }
2054 | label_decls label_decl
2058 LABEL identifiers_or_typenames ';'
2060 for (link = $2; link; link = TREE_CHAIN (link))
2062 tree label = declare_label (TREE_VALUE (link));
2063 C_DECLARED_LABEL_FLAG (label) = 1;
2064 add_stmt (build_stmt (DECL_EXPR, label));
2069 /* This is the body of a function definition.
2070 It causes syntax errors to ignore to the next openbrace. */
2077 compstmt_start: '{' { $$ = c_begin_compound_stmt (true); }
2080 compstmt_nostart: '}'
2081 | maybe_label_decls compstmt_contents_nonempty '}'
2084 compstmt_contents_nonempty:
2089 compstmt_primary_start:
2091 { if (current_function_decl == 0)
2093 error ("braced-group within expression allowed "
2094 "only inside a function");
2097 $$ = c_begin_stmt_expr ();
2101 compstmt: compstmt_start compstmt_nostart
2102 { $$ = c_end_compound_stmt ($1, true); }
2105 /* The forced readahead in here is because we might be at the end of a
2106 line, and the line and file won't be bumped until yylex absorbs the
2107 first token on the next line. */
2110 { if (yychar == YYEMPTY)
2112 $$ = input_location; }
2117 | lineno_labels lineno_label
2120 /* A labeled statement. In C99 it also generates an implicit block. */
2121 c99_block_lineno_labeled_stmt:
2122 c99_block_start lineno_labels lineno_stmt
2123 { $$ = c_end_compound_stmt ($1, flag_isoc99); }
2129 /* Two cases cannot and do not have line numbers associated:
2130 If stmt is degenerate, such as "2;", then stmt is an
2131 INTEGER_CST, which cannot hold line numbers. But that's
2132 ok because the statement will either be changed to a
2133 MODIFY_EXPR during gimplification of the statement expr,
2134 or discarded. If stmt was compound, but without new
2135 variables, we will have skipped the creation of a BIND
2136 and will have a bare STATEMENT_LIST. But that's ok
2137 because (recursively) all of the component statments
2138 should already have line numbers assigned. */
2139 if ($2 && EXPR_P ($2))
2140 SET_EXPR_LOCATION ($2, $1);
2146 { if ($2) SET_EXPR_LOCATION ($2, $1); }
2149 condition: save_location expr
2150 { $$ = lang_hooks.truthvalue_conversion ($2.value);
2152 SET_EXPR_LOCATION ($$, $1); }
2155 /* Implement -Wparenthesis by special casing IF statement directly nested
2156 within IF statement. This requires some amount of duplication of the
2157 productions under c99_block_lineno_labeled_stmt in order to work out.
2158 But it's still likely more maintainable than lots of state outside the
2162 c99_block_start lineno_labels if_statement
2163 { $$ = c_end_compound_stmt ($1, flag_isoc99); }
2167 c99_block_start lineno_labels ';'
2168 { if (extra_warnings)
2169 add_stmt (build (NOP_EXPR, NULL_TREE, NULL_TREE));
2170 $$ = c_end_compound_stmt ($1, flag_isoc99); }
2171 | c99_block_lineno_labeled_stmt
2175 IF c99_block_start save_location '(' condition ')'
2176 if_statement_1 ELSE if_statement_2
2177 { c_finish_if_stmt ($3, $5, $7, $9, true);
2178 add_stmt (c_end_compound_stmt ($2, flag_isoc99)); }
2179 | IF c99_block_start save_location '(' condition ')'
2180 if_statement_2 ELSE if_statement_2
2181 { c_finish_if_stmt ($3, $5, $7, $9, false);
2182 add_stmt (c_end_compound_stmt ($2, flag_isoc99)); }
2183 | IF c99_block_start save_location '(' condition ')'
2184 if_statement_1 %prec IF
2185 { c_finish_if_stmt ($3, $5, $7, NULL, true);
2186 add_stmt (c_end_compound_stmt ($2, flag_isoc99)); }
2187 | IF c99_block_start save_location '(' condition ')'
2188 if_statement_2 %prec IF
2189 { c_finish_if_stmt ($3, $5, $7, NULL, false);
2190 add_stmt (c_end_compound_stmt ($2, flag_isoc99)); }
2193 start_break: /* empty */
2194 { $$ = c_break_label; c_break_label = NULL; }
2197 start_continue: /* empty */
2198 { $$ = c_cont_label; c_cont_label = NULL; }
2202 WHILE c99_block_start save_location '(' condition ')'
2203 start_break start_continue c99_block_lineno_labeled_stmt
2204 { c_finish_loop ($3, $5, NULL, $9, c_break_label,
2205 c_cont_label, true);
2206 add_stmt (c_end_compound_stmt ($2, flag_isoc99));
2207 c_break_label = $7; c_cont_label = $8; }
2211 DO c99_block_start save_location start_break start_continue
2212 c99_block_lineno_labeled_stmt WHILE
2213 { $<ttype>$ = c_break_label; c_break_label = $4; }
2214 { $<ttype>$ = c_cont_label; c_cont_label = $5; }
2215 '(' condition ')' ';'
2216 { c_finish_loop ($3, $11, NULL, $6, $<ttype>8,
2218 add_stmt (c_end_compound_stmt ($2, flag_isoc99)); }
2230 { c_finish_expr_stmt ($1); }
2232 { check_for_loop_decls (); }
2235 for_cond_expr: save_location xexpr
2238 $$ = lang_hooks.truthvalue_conversion ($2);
2240 SET_EXPR_LOCATION ($$, $1);
2247 for_incr_expr: xexpr
2248 { $$ = c_process_expr_stmt ($1); }
2252 FOR c99_block_start '(' for_init_stmt
2253 save_location for_cond_expr ';' for_incr_expr ')'
2254 start_break start_continue c99_block_lineno_labeled_stmt
2255 { c_finish_loop ($5, $6, $8, $12, c_break_label,
2256 c_cont_label, true);
2257 add_stmt (c_end_compound_stmt ($2, flag_isoc99));
2258 c_break_label = $10; c_cont_label = $11; }
2262 SWITCH c99_block_start '(' expr ')'
2263 { $<ttype>$ = c_start_case ($4.value); }
2264 start_break c99_block_lineno_labeled_stmt
2265 { c_finish_case ($8);
2267 add_stmt (build (LABEL_EXPR, void_type_node,
2270 add_stmt (c_end_compound_stmt ($2, flag_isoc99)); }
2273 /* Parse a single real statement, not including any labels or compounds. */
2276 { $$ = c_finish_expr_stmt ($1.value); }
2288 { $$ = c_finish_bc_stmt (&c_break_label, true); }
2290 { $$ = c_finish_bc_stmt (&c_cont_label, false); }
2292 { $$ = c_finish_return (NULL_TREE); }
2294 { $$ = c_finish_return ($2.value); }
2296 | GOTO identifier ';'
2297 { $$ = c_finish_goto_label ($2); }
2299 { $$ = c_finish_goto_ptr ($3.value); }
2304 { $$ = objc_build_throw_stmt ($2.value); }
2306 { $$ = objc_build_throw_stmt (NULL_TREE); }
2307 | objc_try_catch_stmt
2309 | AT_SYNCHRONIZED save_location '(' expr ')' compstmt
2310 { objc_build_synchronized ($2, $4.value, $6); $$ = NULL_TREE; }
2314 AT_CATCH '(' parm ')'
2315 { objc_begin_catch_clause (grokparm ($3)); }
2319 objc_catch_prefix '{' compstmt_nostart
2320 { objc_finish_catch_clause (); }
2321 | objc_catch_prefix '{' error '}'
2322 { objc_finish_catch_clause (); }
2325 objc_opt_catch_list:
2327 | objc_opt_catch_list objc_catch_clause
2330 objc_try_catch_clause:
2331 AT_TRY save_location compstmt
2332 { objc_begin_try_stmt ($2, $3); }
2336 objc_finally_clause:
2337 AT_FINALLY save_location compstmt
2338 { objc_build_finally_clause ($2, $3); }
2341 objc_try_catch_stmt:
2342 objc_try_catch_clause
2343 { objc_finish_try_stmt (); }
2344 | objc_try_catch_clause objc_finally_clause
2345 { objc_finish_try_stmt (); }
2349 /* Parse a single or compound real statement, not including any labels. */
2352 { add_stmt ($1); $$ = NULL_TREE; }
2356 /* Any kind of label, including jump labels and case labels.
2357 ANSI C accepts labels only before statements, but we allow them
2358 also at the end of a compound statement. */
2360 label: CASE expr_no_commas ':'
2361 { $$ = do_case ($2.value, NULL_TREE); }
2362 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
2363 { $$ = do_case ($2.value, $4.value); }
2365 { $$ = do_case (NULL_TREE, NULL_TREE); }
2366 | identifier save_location ':' maybe_attribute
2367 { tree label = define_label ($2, $1);
2370 decl_attributes (&label, $4, 0);
2371 $$ = add_stmt (build_stmt (LABEL_EXPR, label));
2378 /* Asm expressions and statements */
2380 /* simple_asm_expr is used in restricted contexts, where a full
2381 expression with inputs and outputs does not make sense. */
2383 ASM_KEYWORD stop_string_translation
2384 '(' STRING ')' start_string_translation
2388 /* maybeasm: used for assembly names for declarations */
2395 /* asmdef: asm() outside a function body. */
2398 { assemble_asm ($1); }
2399 | ASM_KEYWORD error start_string_translation ';'
2403 /* Full-blown asm statement with inputs, outputs, clobbers, and
2404 volatile tag allowed. */
2406 ASM_KEYWORD maybe_volatile stop_string_translation
2407 '(' asm_argument ')' start_string_translation ';'
2408 { $$ = build_asm_stmt ($2, $5); }
2414 { $$ = build_asm_expr ($1, 0, 0, 0, true); }
2415 /* output operands */
2416 | STRING ':' asm_operands
2417 { $$ = build_asm_expr ($1, $3, 0, 0, false); }
2418 /* output and input operands */
2419 | STRING ':' asm_operands ':' asm_operands
2420 { $$ = build_asm_expr ($1, $3, $5, 0, false); }
2421 /* output and input operands and clobbers */
2422 | STRING ':' asm_operands ':' asm_operands ':' asm_clobbers
2423 { $$ = build_asm_expr ($1, $3, $5, $7, false); }
2426 /* Either 'volatile' or nothing. First thing in an `asm' statement. */
2432 { if ($1 != ridpointers[RID_VOLATILE])
2434 warning ("%E qualifier ignored on asm", $1);
2442 /* These are the operands other than the first string and colon
2443 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
2444 asm_operands: /* empty */
2446 | nonnull_asm_operands
2449 nonnull_asm_operands:
2451 | nonnull_asm_operands ',' asm_operand
2452 { $$ = chainon ($1, $3); }
2456 STRING start_string_translation '(' expr ')' stop_string_translation
2457 { $$ = build_tree_list (build_tree_list (NULL_TREE, $1),
2459 | '[' identifier ']' STRING start_string_translation
2460 '(' expr ')' stop_string_translation
2461 { $2 = build_string (IDENTIFIER_LENGTH ($2),
2462 IDENTIFIER_POINTER ($2));
2463 $$ = build_tree_list (build_tree_list ($2, $4), $7.value); }
2468 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
2469 | asm_clobbers ',' STRING
2470 { $$ = tree_cons (NULL_TREE, $3, $1); }
2473 stop_string_translation:
2474 { c_lex_string_translate = 0; }
2477 start_string_translation:
2478 { c_lex_string_translate = 1; }
2482 /* This is what appears inside the parens in a function declarator.
2483 Its value is a list of ..._TYPE nodes. Attributes must appear here
2484 to avoid a conflict with their appearance after an open parenthesis
2485 in an abstract declarator, as in
2486 "void bar (int (__attribute__((__mode__(SI))) int foo));". */
2490 declare_parm_level (); }
2499 { mark_forward_parm_decls (); }
2501 { /* Dummy action so attributes are in known place
2502 on parser stack. */ }
2506 { $$ = make_node (TREE_LIST); }
2509 /* This is what appears inside the parens in a function declarator.
2510 Is value is represented in the format that grokdeclarator expects. */
2511 parmlist_2: /* empty */
2512 { $$ = make_node (TREE_LIST); }
2514 { $$ = make_node (TREE_LIST);
2515 /* Suppress -Wold-style-definition for this case. */
2516 TREE_CHAIN ($$) = error_mark_node;
2517 error ("ISO C requires a named argument before `...'");
2520 { $$ = get_parm_info (/*ellipsis=*/false); }
2521 | parms ',' ELLIPSIS
2522 { $$ = get_parm_info (/*ellipsis=*/true); }
2527 { push_parm_decl ($1); }
2529 { push_parm_decl ($3); }
2532 /* A single parameter declaration or parameter type name,
2533 as found in a parmlist. */
2535 declspecs_ts setspecs parm_declarator maybe_attribute
2536 { $$ = build_c_parm (current_declspecs,
2537 chainon ($4, all_prefix_attributes), $3);
2538 POP_DECLSPEC_STACK; }
2539 | declspecs_ts setspecs notype_declarator maybe_attribute
2540 { $$ = build_c_parm (current_declspecs,
2541 chainon ($4, all_prefix_attributes), $3);
2542 POP_DECLSPEC_STACK; }
2543 | declspecs_ts setspecs absdcl_maybe_attribute
2545 POP_DECLSPEC_STACK; }
2546 | declspecs_nots setspecs notype_declarator maybe_attribute
2547 { $$ = build_c_parm (current_declspecs,
2548 chainon ($4, all_prefix_attributes), $3);
2549 POP_DECLSPEC_STACK; }
2551 | declspecs_nots setspecs absdcl_maybe_attribute
2553 POP_DECLSPEC_STACK; }
2556 /* The first parm, which must suck attributes from off the top of the parser
2559 declspecs_ts_nosa setspecs_fp parm_declarator maybe_attribute
2560 { $$ = build_c_parm (current_declspecs,
2561 chainon ($4, all_prefix_attributes), $3);
2562 POP_DECLSPEC_STACK; }
2563 | declspecs_ts_nosa setspecs_fp notype_declarator maybe_attribute
2564 { $$ = build_c_parm (current_declspecs,
2565 chainon ($4, all_prefix_attributes), $3);
2566 POP_DECLSPEC_STACK; }
2567 | declspecs_ts_nosa setspecs_fp absdcl_maybe_attribute
2569 POP_DECLSPEC_STACK; }
2570 | declspecs_nots_nosa setspecs_fp notype_declarator maybe_attribute
2571 { $$ = build_c_parm (current_declspecs,
2572 chainon ($4, all_prefix_attributes), $3);
2573 POP_DECLSPEC_STACK; }
2575 | declspecs_nots_nosa setspecs_fp absdcl_maybe_attribute
2577 POP_DECLSPEC_STACK; }
2582 { prefix_attributes = chainon (prefix_attributes, $<ttype>-2);
2583 all_prefix_attributes = prefix_attributes; }
2586 /* This is used in a function definition
2587 where either a parmlist or an identifier list is ok.
2588 Its value is a list of ..._TYPE nodes or a list of identifiers. */
2589 parmlist_or_identifiers:
2592 declare_parm_level (); }
2593 parmlist_or_identifiers_1
2598 parmlist_or_identifiers_1:
2601 { $$ = tree_cons (NULL_TREE, NULL_TREE, $1);
2603 /* Make sure we have a parmlist after attributes. */
2604 if ($<ttype>-1 != 0)
2609 /* A nonempty list of identifiers. */
2612 { $$ = build_tree_list (NULL_TREE, $1); }
2613 | identifiers ',' IDENTIFIER
2614 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2617 /* A nonempty list of identifiers, including typenames. */
2618 identifiers_or_typenames:
2620 { $$ = build_tree_list (NULL_TREE, $1); }
2621 | identifiers_or_typenames ',' identifier
2622 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2627 { $$ = SAVE_EXT_FLAGS();
2629 warn_pointer_arith = 0;
2630 warn_traditional = 0;
2635 /* Objective-C productions. */
2645 objc_finish_implementation ();
2649 /* A nonempty list of identifiers. */
2652 { $$ = build_tree_list (NULL_TREE, $1); }
2653 | identifier_list ',' identifier
2654 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2658 AT_CLASS identifier_list ';'
2660 objc_declare_class ($2);
2665 AT_ALIAS identifier identifier ';'
2667 objc_declare_alias ($2, $3);
2672 ':' identifier { $$ = $2; }
2673 | /* NULL */ %prec HYPERUNARY { $$ = NULL_TREE; }
2677 '{' ivar_decl_list '}'
2682 AT_INTERFACE identifier superclass protocolrefs
2684 objc_start_class_interface ($2, $3, $4);
2688 objc_continue_interface ();
2690 methodprotolist AT_END
2692 objc_finish_interface ();
2695 | AT_IMPLEMENTATION identifier superclass
2697 objc_start_class_implementation ($2, $3);
2701 objc_continue_implementation ();
2704 | AT_INTERFACE identifier '(' identifier ')' protocolrefs
2706 objc_start_category_interface ($2, $4, $6);
2708 methodprotolist AT_END
2710 objc_finish_interface ();
2713 | AT_IMPLEMENTATION identifier '(' identifier ')'
2715 objc_start_category_implementation ($2, $4);
2720 AT_PROTOCOL identifier protocolrefs
2722 objc_pq_context = 1;
2723 objc_start_protocol ($2, $3);
2725 methodprotolist AT_END
2727 objc_pq_context = 0;
2728 objc_finish_interface ();
2730 /* The @protocol forward-declaration production introduces a
2731 reduce/reduce conflict on ';', which should be resolved in
2732 favor of the production 'identifier_list -> identifier'. */
2733 | AT_PROTOCOL identifier_list ';'
2735 objc_declare_protocols ($2);
2744 | non_empty_protocolrefs
2747 non_empty_protocolrefs:
2748 ARITHCOMPARE identifier_list ARITHCOMPARE
2750 if ($1 == LT_EXPR && $3 == GT_EXPR)
2759 | ivar_decl_list visibility_spec ivar_decls
2764 | AT_PRIVATE { objc_set_visibility (2); }
2765 | AT_PROTECTED { objc_set_visibility (0); }
2766 | AT_PUBLIC { objc_set_visibility (1); }
2771 | ivar_decls ivar_decl ';'
2775 pedwarn ("extra semicolon in struct or union specified");
2782 /* Comma-separated ivars are chained together in
2783 reverse order; add them one by one. */
2784 tree ivar = nreverse ($1);
2786 for (; ivar; ivar = TREE_CHAIN (ivar))
2787 objc_add_instance_variable (copy_node (ivar));
2796 pedwarn ("extra semicolon in method definition specified");
2808 objc_set_method_type ($1);
2809 objc_pq_context = 1;
2813 objc_pq_context = 0;
2814 objc_start_method_definition ($3);
2818 objc_finish_method_definition (current_function_decl);
2822 /* the reason for the strange actions in this rule
2823 is so that notype_initdecls when reached via datadef
2824 can find a valid list of type and sc specs in $0. */
2828 | methodprotolist methodproto
2829 | methodprotolist { $<ttype>$ = NULL_TREE; } datadef
2840 objc_set_method_type ($1);
2841 /* Remember protocol qualifiers in prototypes. */
2842 objc_pq_context = 1;
2846 /* Forget protocol qualifiers here. */
2847 objc_pq_context = 0;
2848 objc_add_method_declaration ($3);
2854 '(' objc_typename ')' unaryselector
2856 $$ = objc_build_method_signature ($2, $4, NULL_TREE);
2861 $$ = objc_build_method_signature (NULL_TREE, $1, NULL_TREE);
2864 | '(' objc_typename ')' keywordselector optparmlist
2866 $$ = objc_build_method_signature ($2, $4, $5);
2869 | keywordselector optparmlist
2871 $$ = objc_build_method_signature (NULL_TREE, $1, $2);
2875 /* Optional ObjC method parameters follow the C syntax, and may include '...'
2876 to denote a variable number of arguments. */
2879 optparms optellipsis
2881 TREE_OVERFLOW ($$) = $2;
2888 $$ = make_node (TREE_LIST);
2892 $$ = chainon ($1, build_tree_list (NULL_TREE,
2915 | keywordselector keyworddecl
2917 $$ = chainon ($1, $2);
2930 ENUM | STRUCT | UNION | IF | ELSE | WHILE | DO | FOR
2931 | SWITCH | CASE | DEFAULT | BREAK | CONTINUE | RETURN
2932 | GOTO | ASM_KEYWORD | SIZEOF | TYPEOF | ALIGNOF
2933 | TYPESPEC | TYPE_QUAL
2941 objc_quals objc_qual
2943 $$ = chainon ($1, build_tree_list (NULL_TREE, $2));
2954 $$ = build_tree_list ($1, groktypename ($2));
2958 $$ = build_tree_list ($1, NULL_TREE);
2963 selector ':' '(' objc_typename ')' identifier
2965 $$ = objc_build_keyword_decl ($1, $4, $6);
2968 | selector ':' identifier
2970 $$ = objc_build_keyword_decl ($1, NULL_TREE, $3);
2973 | ':' '(' objc_typename ')' identifier
2975 $$ = objc_build_keyword_decl (NULL_TREE, $3, $5);
2980 $$ = objc_build_keyword_decl (NULL_TREE, NULL_TREE, $2);
2991 | keywordarglist keywordarg
2993 $$ = chainon ($1, $2);
3001 if (TREE_CHAIN ($1) == NULL_TREE)
3002 /* just return the expr., remove a level of indirection */
3003 $$ = TREE_VALUE ($1);
3005 /* we have a comma expr., we will collapse later */
3011 selector ':' keywordexpr
3013 $$ = build_tree_list ($1, $3);
3017 $$ = build_tree_list (NULL_TREE, $2);
3026 $$ = objc_get_class_reference ($1);
3030 $$ = objc_get_class_reference ($1);
3035 '[' receiver messageargs ']'
3036 { $$ = build_tree_list ($2, $3); }
3046 | keywordnamelist keywordname
3048 $$ = chainon ($1, $2);
3055 $$ = build_tree_list ($1, NULL_TREE);
3059 $$ = build_tree_list (NULL_TREE, NULL_TREE);
3064 AT_SELECTOR '(' selectorarg ')'
3071 AT_PROTOCOL '(' identifier ')'
3077 /* extension to support C-structures in the archiver */
3080 AT_ENCODE '(' typename ')'
3082 $$ = groktypename ($3);
3089 /* yylex() is a thin wrapper around c_lex(), all it does is translate
3090 cpplib.h's token codes into yacc's token codes. */
3092 static enum cpp_ttype last_token;
3094 /* The reserved keyword table. */
3098 ENUM_BITFIELD(rid) rid : 16;
3099 unsigned int disable : 16;
3102 /* Disable mask. Keywords are disabled if (reswords[i].disable & mask) is
3104 #define D_C89 0x01 /* not in C89 */
3105 #define D_EXT 0x02 /* GCC extension */
3106 #define D_EXT89 0x04 /* GCC extension incorporated in C99 */
3107 #define D_OBJC 0x08 /* Objective C only */
3109 static const struct resword reswords[] =
3111 { "_Bool", RID_BOOL, 0 },
3112 { "_Complex", RID_COMPLEX, 0 },
3113 { "__FUNCTION__", RID_FUNCTION_NAME, 0 },
3114 { "__PRETTY_FUNCTION__", RID_PRETTY_FUNCTION_NAME, 0 },
3115 { "__alignof", RID_ALIGNOF, 0 },
3116 { "__alignof__", RID_ALIGNOF, 0 },
3117 { "__asm", RID_ASM, 0 },
3118 { "__asm__", RID_ASM, 0 },
3119 { "__attribute", RID_ATTRIBUTE, 0 },
3120 { "__attribute__", RID_ATTRIBUTE, 0 },
3121 { "__builtin_choose_expr", RID_CHOOSE_EXPR, 0 },
3122 { "__builtin_offsetof", RID_OFFSETOF, 0 },
3123 { "__builtin_types_compatible_p", RID_TYPES_COMPATIBLE_P, 0 },
3124 { "__builtin_va_arg", RID_VA_ARG, 0 },
3125 { "__complex", RID_COMPLEX, 0 },
3126 { "__complex__", RID_COMPLEX, 0 },
3127 { "__const", RID_CONST, 0 },
3128 { "__const__", RID_CONST, 0 },
3129 { "__extension__", RID_EXTENSION, 0 },
3130 { "__func__", RID_C99_FUNCTION_NAME, 0 },
3131 { "__imag", RID_IMAGPART, 0 },
3132 { "__imag__", RID_IMAGPART, 0 },
3133 { "__inline", RID_INLINE, 0 },
3134 { "__inline__", RID_INLINE, 0 },
3135 { "__label__", RID_LABEL, 0 },
3136 { "__ptrbase", RID_PTRBASE, 0 },
3137 { "__ptrbase__", RID_PTRBASE, 0 },
3138 { "__ptrextent", RID_PTREXTENT, 0 },
3139 { "__ptrextent__", RID_PTREXTENT, 0 },
3140 { "__ptrvalue", RID_PTRVALUE, 0 },
3141 { "__ptrvalue__", RID_PTRVALUE, 0 },
3142 { "__real", RID_REALPART, 0 },
3143 { "__real__", RID_REALPART, 0 },
3144 { "__restrict", RID_RESTRICT, 0 },
3145 { "__restrict__", RID_RESTRICT, 0 },
3146 { "__signed", RID_SIGNED, 0 },
3147 { "__signed__", RID_SIGNED, 0 },
3148 { "__thread", RID_THREAD, 0 },
3149 { "__typeof", RID_TYPEOF, 0 },
3150 { "__typeof__", RID_TYPEOF, 0 },
3151 { "__volatile", RID_VOLATILE, 0 },
3152 { "__volatile__", RID_VOLATILE, 0 },
3153 { "asm", RID_ASM, D_EXT },
3154 { "auto", RID_AUTO, 0 },
3155 { "break", RID_BREAK, 0 },
3156 { "case", RID_CASE, 0 },
3157 { "char", RID_CHAR, 0 },
3158 { "const", RID_CONST, 0 },
3159 { "continue", RID_CONTINUE, 0 },
3160 { "default", RID_DEFAULT, 0 },
3161 { "do", RID_DO, 0 },
3162 { "double", RID_DOUBLE, 0 },
3163 { "else", RID_ELSE, 0 },
3164 { "enum", RID_ENUM, 0 },
3165 { "extern", RID_EXTERN, 0 },
3166 { "float", RID_FLOAT, 0 },
3167 { "for", RID_FOR, 0 },
3168 { "goto", RID_GOTO, 0 },
3169 { "if", RID_IF, 0 },
3170 { "inline", RID_INLINE, D_EXT89 },
3171 { "int", RID_INT, 0 },
3172 { "long", RID_LONG, 0 },
3173 { "register", RID_REGISTER, 0 },
3174 { "restrict", RID_RESTRICT, D_C89 },
3175 { "return", RID_RETURN, 0 },
3176 { "short", RID_SHORT, 0 },
3177 { "signed", RID_SIGNED, 0 },
3178 { "sizeof", RID_SIZEOF, 0 },
3179 { "static", RID_STATIC, 0 },
3180 { "struct", RID_STRUCT, 0 },
3181 { "switch", RID_SWITCH, 0 },
3182 { "typedef", RID_TYPEDEF, 0 },
3183 { "typeof", RID_TYPEOF, D_EXT },
3184 { "union", RID_UNION, 0 },
3185 { "unsigned", RID_UNSIGNED, 0 },
3186 { "void", RID_VOID, 0 },
3187 { "volatile", RID_VOLATILE, 0 },
3188 { "while", RID_WHILE, 0 },
3191 { "id", RID_ID, D_OBJC },
3193 /* These objc keywords are recognized only immediately after
3195 { "class", RID_AT_CLASS, D_OBJC },
3196 { "compatibility_alias", RID_AT_ALIAS, D_OBJC },
3197 { "defs", RID_AT_DEFS, D_OBJC },
3198 { "encode", RID_AT_ENCODE, D_OBJC },
3199 { "end", RID_AT_END, D_OBJC },
3200 { "implementation", RID_AT_IMPLEMENTATION, D_OBJC },
3201 { "interface", RID_AT_INTERFACE, D_OBJC },
3202 { "private", RID_AT_PRIVATE, D_OBJC },
3203 { "protected", RID_AT_PROTECTED, D_OBJC },
3204 { "protocol", RID_AT_PROTOCOL, D_OBJC },
3205 { "public", RID_AT_PUBLIC, D_OBJC },
3206 { "selector", RID_AT_SELECTOR, D_OBJC },
3207 { "throw", RID_AT_THROW, D_OBJC },
3208 { "try", RID_AT_TRY, D_OBJC },
3209 { "catch", RID_AT_CATCH, D_OBJC },
3210 { "finally", RID_AT_FINALLY, D_OBJC },
3211 { "synchronized", RID_AT_SYNCHRONIZED, D_OBJC },
3212 /* These are recognized only in protocol-qualifier context
3214 { "bycopy", RID_BYCOPY, D_OBJC },
3215 { "byref", RID_BYREF, D_OBJC },
3216 { "in", RID_IN, D_OBJC },
3217 { "inout", RID_INOUT, D_OBJC },
3218 { "oneway", RID_ONEWAY, D_OBJC },
3219 { "out", RID_OUT, D_OBJC },
3222 #define N_reswords (sizeof reswords / sizeof (struct resword))
3224 /* Table mapping from RID_* constants to yacc token numbers.
3225 Unfortunately we have to have entries for all the keywords in all
3227 static const short rid_to_yy[RID_MAX] =
3229 /* RID_STATIC */ STATIC,
3230 /* RID_UNSIGNED */ TYPESPEC,
3231 /* RID_LONG */ TYPESPEC,
3232 /* RID_CONST */ TYPE_QUAL,
3233 /* RID_EXTERN */ SCSPEC,
3234 /* RID_REGISTER */ SCSPEC,
3235 /* RID_TYPEDEF */ SCSPEC,
3236 /* RID_SHORT */ TYPESPEC,
3237 /* RID_INLINE */ SCSPEC,
3238 /* RID_VOLATILE */ TYPE_QUAL,
3239 /* RID_SIGNED */ TYPESPEC,
3240 /* RID_AUTO */ SCSPEC,
3241 /* RID_RESTRICT */ TYPE_QUAL,
3244 /* RID_COMPLEX */ TYPESPEC,
3245 /* RID_THREAD */ SCSPEC,
3249 /* RID_VIRTUAL */ 0,
3250 /* RID_EXPLICIT */ 0,
3252 /* RID_MUTABLE */ 0,
3255 /* RID_IN */ OBJC_TYPE_QUAL,
3256 /* RID_OUT */ OBJC_TYPE_QUAL,
3257 /* RID_INOUT */ OBJC_TYPE_QUAL,
3258 /* RID_BYCOPY */ OBJC_TYPE_QUAL,
3259 /* RID_BYREF */ OBJC_TYPE_QUAL,
3260 /* RID_ONEWAY */ OBJC_TYPE_QUAL,
3263 /* RID_INT */ TYPESPEC,
3264 /* RID_CHAR */ TYPESPEC,
3265 /* RID_FLOAT */ TYPESPEC,
3266 /* RID_DOUBLE */ TYPESPEC,
3267 /* RID_VOID */ TYPESPEC,
3268 /* RID_ENUM */ ENUM,
3269 /* RID_STRUCT */ STRUCT,
3270 /* RID_UNION */ UNION,
3272 /* RID_ELSE */ ELSE,
3273 /* RID_WHILE */ WHILE,
3276 /* RID_SWITCH */ SWITCH,
3277 /* RID_CASE */ CASE,
3278 /* RID_DEFAULT */ DEFAULT,
3279 /* RID_BREAK */ BREAK,
3280 /* RID_CONTINUE */ CONTINUE,
3281 /* RID_RETURN */ RETURN,
3282 /* RID_GOTO */ GOTO,
3283 /* RID_SIZEOF */ SIZEOF,
3286 /* RID_ASM */ ASM_KEYWORD,
3287 /* RID_TYPEOF */ TYPEOF,
3288 /* RID_ALIGNOF */ ALIGNOF,
3289 /* RID_ATTRIBUTE */ ATTRIBUTE,
3290 /* RID_VA_ARG */ VA_ARG,
3291 /* RID_EXTENSION */ EXTENSION,
3292 /* RID_IMAGPART */ IMAGPART,
3293 /* RID_REALPART */ REALPART,
3294 /* RID_LABEL */ LABEL,
3295 /* RID_PTRBASE */ PTR_BASE,
3296 /* RID_PTREXTENT */ PTR_EXTENT,
3297 /* RID_PTRVALUE */ PTR_VALUE,
3299 /* RID_CHOOSE_EXPR */ CHOOSE_EXPR,
3300 /* RID_TYPES_COMPATIBLE_P */ TYPES_COMPATIBLE_P,
3302 /* RID_FUNCTION_NAME */ FUNC_NAME,
3303 /* RID_PRETTY_FUNCTION_NAME */ FUNC_NAME,
3304 /* RID_C99_FUNCTION_NAME */ FUNC_NAME,
3307 /* RID_BOOL */ TYPESPEC,
3311 /* RID_PRIVATE */ 0,
3312 /* RID_PROTECTED */ 0,
3313 /* RID_TEMPLATE */ 0,
3318 /* RID_NAMESPACE */ 0,
3320 /* RID_OFFSETOF */ OFFSETOF,
3321 /* RID_OPERATOR */ 0,
3326 /* RID_TYPENAME */ 0,
3331 /* RID_CONSTCAST */ 0,
3332 /* RID_DYNCAST */ 0,
3333 /* RID_REINTCAST */ 0,
3334 /* RID_STATCAST */ 0,
3337 /* RID_ID */ OBJECTNAME,
3338 /* RID_AT_ENCODE */ AT_ENCODE,
3339 /* RID_AT_END */ AT_END,
3340 /* RID_AT_CLASS */ AT_CLASS,
3341 /* RID_AT_ALIAS */ AT_ALIAS,
3342 /* RID_AT_DEFS */ AT_DEFS,
3343 /* RID_AT_PRIVATE */ AT_PRIVATE,
3344 /* RID_AT_PROTECTED */ AT_PROTECTED,
3345 /* RID_AT_PUBLIC */ AT_PUBLIC,
3346 /* RID_AT_PROTOCOL */ AT_PROTOCOL,
3347 /* RID_AT_SELECTOR */ AT_SELECTOR,
3348 /* RID_AT_THROW */ AT_THROW,
3349 /* RID_AT_TRY */ AT_TRY,
3350 /* RID_AT_CATCH */ AT_CATCH,
3351 /* RID_AT_FINALLY */ AT_FINALLY,
3352 /* RID_AT_SYNCHRONIZED */ AT_SYNCHRONIZED,
3353 /* RID_AT_INTERFACE */ AT_INTERFACE,
3354 /* RID_AT_IMPLEMENTATION */ AT_IMPLEMENTATION
3358 init_reswords (void)
3362 int mask = (flag_isoc99 ? 0 : D_C89)
3363 | (flag_no_asm ? (flag_isoc99 ? D_EXT : D_EXT|D_EXT89) : 0);
3365 if (!c_dialect_objc ())
3368 ridpointers = GGC_CNEWVEC (tree, (int) RID_MAX);
3369 for (i = 0; i < N_reswords; i++)
3371 /* If a keyword is disabled, do not enter it into the table
3372 and so create a canonical spelling that isn't a keyword. */
3373 if (reswords[i].disable & mask)
3376 id = get_identifier (reswords[i].word);
3377 C_RID_CODE (id) = reswords[i].rid;
3378 C_IS_RESERVED_WORD (id) = 1;
3379 ridpointers [(int) reswords[i].rid] = id;
3383 #define NAME(type) cpp_type2name (type)
3386 yyerror (const char *msgid)
3388 c_parse_error (msgid, last_token, yylval.ttype);
3397 int objc_force_identifier = objc_need_raw_identifier;
3398 OBJC_NEED_RAW_IDENTIFIER (0);
3401 if (C_IS_RESERVED_WORD (yylval.ttype))
3403 enum rid rid_code = C_RID_CODE (yylval.ttype);
3406 /* Turn non-typedefed refs to "id" into plain identifiers; this
3407 allows constructs like "void foo(id id);" to work. */
3408 if (rid_code == RID_ID)
3410 decl = lookup_name (yylval.ttype);
3411 if (decl == NULL_TREE || TREE_CODE (decl) != TYPE_DECL)
3415 if (!OBJC_IS_AT_KEYWORD (rid_code)
3416 && (!OBJC_IS_PQ_KEYWORD (rid_code) || objc_pq_context))
3419 /* Return the canonical spelling for this keyword. */
3420 yylval.ttype = ridpointers[(int) rid_code];
3421 return rid_to_yy[(int) rid_code];
3425 decl = lookup_name (yylval.ttype);
3428 if (TREE_CODE (decl) == TYPE_DECL)
3434 tree objc_interface_decl = objc_is_class_name (yylval.ttype);
3435 /* ObjC class names are in the same namespace as variables and
3436 typedefs, and hence are shadowed by local declarations. */
3437 if (objc_interface_decl
3438 && (global_bindings_p ()
3439 || (!objc_force_identifier && !decl)))
3441 yylval.ttype = objc_interface_decl;
3454 last_token = c_lex (&yylval.ttype);
3457 case CPP_EQ: return '=';
3458 case CPP_NOT: return '!';
3459 case CPP_GREATER: yylval.code = GT_EXPR; return ARITHCOMPARE;
3460 case CPP_LESS: yylval.code = LT_EXPR; return ARITHCOMPARE;
3461 case CPP_PLUS: yylval.code = PLUS_EXPR; return '+';
3462 case CPP_MINUS: yylval.code = MINUS_EXPR; return '-';
3463 case CPP_MULT: yylval.code = MULT_EXPR; return '*';
3464 case CPP_DIV: yylval.code = TRUNC_DIV_EXPR; return '/';
3465 case CPP_MOD: yylval.code = TRUNC_MOD_EXPR; return '%';
3466 case CPP_AND: yylval.code = BIT_AND_EXPR; return '&';
3467 case CPP_OR: yylval.code = BIT_IOR_EXPR; return '|';
3468 case CPP_XOR: yylval.code = BIT_XOR_EXPR; return '^';
3469 case CPP_RSHIFT: yylval.code = RSHIFT_EXPR; return RSHIFT;
3470 case CPP_LSHIFT: yylval.code = LSHIFT_EXPR; return LSHIFT;
3472 case CPP_COMPL: return '~';
3473 case CPP_AND_AND: return ANDAND;
3474 case CPP_OR_OR: return OROR;
3475 case CPP_QUERY: return '?';
3476 case CPP_OPEN_PAREN: return '(';
3477 case CPP_EQ_EQ: yylval.code = EQ_EXPR; return EQCOMPARE;
3478 case CPP_NOT_EQ: yylval.code = NE_EXPR; return EQCOMPARE;
3479 case CPP_GREATER_EQ:yylval.code = GE_EXPR; return ARITHCOMPARE;
3480 case CPP_LESS_EQ: yylval.code = LE_EXPR; return ARITHCOMPARE;
3482 case CPP_PLUS_EQ: yylval.code = PLUS_EXPR; return ASSIGN;
3483 case CPP_MINUS_EQ: yylval.code = MINUS_EXPR; return ASSIGN;
3484 case CPP_MULT_EQ: yylval.code = MULT_EXPR; return ASSIGN;
3485 case CPP_DIV_EQ: yylval.code = TRUNC_DIV_EXPR; return ASSIGN;
3486 case CPP_MOD_EQ: yylval.code = TRUNC_MOD_EXPR; return ASSIGN;
3487 case CPP_AND_EQ: yylval.code = BIT_AND_EXPR; return ASSIGN;
3488 case CPP_OR_EQ: yylval.code = BIT_IOR_EXPR; return ASSIGN;
3489 case CPP_XOR_EQ: yylval.code = BIT_XOR_EXPR; return ASSIGN;
3490 case CPP_RSHIFT_EQ: yylval.code = RSHIFT_EXPR; return ASSIGN;
3491 case CPP_LSHIFT_EQ: yylval.code = LSHIFT_EXPR; return ASSIGN;
3493 case CPP_OPEN_SQUARE: return '[';
3494 case CPP_CLOSE_SQUARE: return ']';
3495 case CPP_OPEN_BRACE: return '{';
3496 case CPP_CLOSE_BRACE: return '}';
3497 case CPP_ELLIPSIS: return ELLIPSIS;
3499 case CPP_PLUS_PLUS: return PLUSPLUS;
3500 case CPP_MINUS_MINUS: return MINUSMINUS;
3501 case CPP_DEREF: return POINTSAT;
3502 case CPP_DOT: return '.';
3504 /* The following tokens may affect the interpretation of any
3505 identifiers following, if doing Objective-C. */
3506 case CPP_COLON: OBJC_NEED_RAW_IDENTIFIER (0); return ':';
3507 case CPP_COMMA: OBJC_NEED_RAW_IDENTIFIER (0); return ',';
3508 case CPP_CLOSE_PAREN: OBJC_NEED_RAW_IDENTIFIER (0); return ')';
3509 case CPP_SEMICOLON: OBJC_NEED_RAW_IDENTIFIER (0); return ';';
3515 return yylexname ();
3518 /* This only happens in Objective-C; it must be a keyword. */
3519 return rid_to_yy [(int) C_RID_CODE (yylval.ttype)];
3530 case CPP_OBJC_STRING:
3533 /* These tokens are C++ specific (and will not be generated
3534 in C mode, but let's be cautious). */
3536 case CPP_DEREF_STAR:
3542 /* These tokens should not survive translation phase 4. */
3545 error ("syntax error at '%s' token", NAME(last_token));
3558 timevar_push (TV_LEX);
3560 timevar_pop (TV_LEX);
3564 /* Function used when yydebug is set, to print a token in more detail. */
3567 yyprint (FILE *file, int yychar, YYSTYPE yyl)
3571 fprintf (file, " [%s]", NAME(last_token));
3582 if (IDENTIFIER_POINTER (t))
3583 fprintf (file, " `%s'", IDENTIFIER_POINTER (t));
3587 fprintf (file, " %s", GET_MODE_NAME (TYPE_MODE (TREE_TYPE (t))));
3588 if (TREE_CODE (t) == INTEGER_CST)
3591 fprintf (file, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
3592 TREE_INT_CST_HIGH (t), TREE_INT_CST_LOW (t));
3598 /* This is not the ideal place to put this, but we have to get it out
3599 of c-lex.c because cp/lex.c has its own version. */
3601 /* Parse the file. */
3609 free (malloced_yyss);
3610 free (malloced_yyvs);
3615 #include "gt-c-parse.h"