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. */
58 /* Like YYERROR but do call yyerror. */
59 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
61 /* Like the default stack expander, except (1) use realloc when possible,
62 (2) impose no hard maxiumum on stack size, (3) REALLY do not use alloca.
64 Irritatingly, YYSTYPE is defined after this %{ %} block, so we cannot
65 give malloced_yyvs its proper type. This is ok since all we need from
66 it is to be able to free it. */
68 static short *malloced_yyss;
69 static void *malloced_yyvs;
71 #define yyoverflow(MSG, SS, SSSIZE, VS, VSSIZE, YYSSZ) \
76 newsize = *(YYSSZ) *= 2; \
79 newss = really_call_realloc (*(SS), newsize * sizeof (short)); \
80 newvs = really_call_realloc (*(VS), newsize * sizeof (YYSTYPE)); \
84 newss = really_call_malloc (newsize * sizeof (short)); \
85 newvs = really_call_malloc (newsize * sizeof (YYSTYPE)); \
87 memcpy (newss, *(SS), (SSSIZE)); \
89 memcpy (newvs, *(VS), (VSSIZE)); \
91 if (!newss || !newvs) \
98 malloced_yyss = newss; \
99 malloced_yyvs = (void *) newvs; \
105 %union {long itype; tree ttype; struct c_expr exprtype; 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 /* Character or numeric constants.
131 yylval is the node for the constant. */
134 /* String constants in raw form.
135 yylval is a STRING_CST node. */
139 /* "...", used for functions with variable arglists. */
142 /* the reserved words */
143 /* SCO include files test "ASM", so use something else. */
144 %token SIZEOF ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
145 %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD TYPEOF ALIGNOF
146 %token ATTRIBUTE EXTENSION LABEL
147 %token REALPART IMAGPART VA_ARG CHOOSE_EXPR TYPES_COMPATIBLE_P
148 %token PTR_VALUE PTR_BASE PTR_EXTENT
149 %token FUNC_NAME OFFSETOF
151 /* Add precedence rules to solve dangling else s/r conflict */
155 /* Define the operator tokens and their precedences.
156 The value is an integer because, if used, it is the tree code
157 to use in the expression made from the operator. */
159 %right <code> ASSIGN '='
160 %right <code> '?' ':'
166 %left <code> EQCOMPARE
167 %left <code> ARITHCOMPARE
168 %left <code> LSHIFT RSHIFT
170 %left <code> '*' '/' '%'
171 %right <code> UNARY PLUSPLUS MINUSMINUS
173 %left <code> POINTSAT '.' '(' '['
175 /* The Objective-C keywords. These are included in C and in
176 Objective C, so that the token codes are the same in both. */
177 %token AT_INTERFACE AT_IMPLEMENTATION AT_END AT_SELECTOR AT_DEFS AT_ENCODE
178 %token CLASSNAME AT_PUBLIC AT_PRIVATE AT_PROTECTED AT_PROTOCOL
179 %token OBJECTNAME AT_CLASS AT_ALIAS
180 %token AT_THROW AT_TRY AT_CATCH AT_FINALLY AT_SYNCHRONIZED
184 %type <ttype> ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
185 %type <ttype> BREAK CONTINUE RETURN GOTO ASM_KEYWORD SIZEOF TYPEOF ALIGNOF
187 %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT STRING FUNC_NAME
188 %type <ttype> nonnull_exprlist exprlist
189 %type <exprtype> expr expr_no_commas cast_expr unary_expr primary
190 %type <ttype> declspecs_nosc_nots_nosa_noea declspecs_nosc_nots_nosa_ea
191 %type <ttype> declspecs_nosc_nots_sa_noea declspecs_nosc_nots_sa_ea
192 %type <ttype> declspecs_nosc_ts_nosa_noea declspecs_nosc_ts_nosa_ea
193 %type <ttype> declspecs_nosc_ts_sa_noea declspecs_nosc_ts_sa_ea
194 %type <ttype> declspecs_sc_nots_nosa_noea declspecs_sc_nots_nosa_ea
195 %type <ttype> declspecs_sc_nots_sa_noea declspecs_sc_nots_sa_ea
196 %type <ttype> declspecs_sc_ts_nosa_noea declspecs_sc_ts_nosa_ea
197 %type <ttype> declspecs_sc_ts_sa_noea declspecs_sc_ts_sa_ea
198 %type <ttype> declspecs_ts declspecs_nots
199 %type <ttype> declspecs_ts_nosa declspecs_nots_nosa
200 %type <ttype> declspecs_nosc_ts declspecs_nosc_nots declspecs_nosc declspecs
201 %type <ttype> maybe_type_quals_attrs typespec_nonattr typespec_attr
202 %type <ttype> typespec_reserved_nonattr typespec_reserved_attr
203 %type <ttype> typespec_nonreserved_nonattr
204 %type <ttype> offsetof_member_designator
206 %type <ttype> scspec SCSPEC STATIC TYPESPEC TYPE_QUAL maybe_volatile
207 %type <ttype> initdecls notype_initdecls initdcl notype_initdcl
208 %type <exprtype> init
209 %type <ttype> simple_asm_expr maybeasm asm_stmt asm_argument
210 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
211 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
212 %type <ttype> any_word
214 %type <ttype> compstmt compstmt_start compstmt_primary_start
215 %type <ttype> stmt label stmt_nocomp start_break start_continue
217 %type <ttype> c99_block_start c99_block_lineno_labeled_stmt
218 %type <ttype> if_statement_1 if_statement_2
219 %type <ttype> declarator
220 %type <ttype> notype_declarator after_type_declarator
221 %type <ttype> parm_declarator
222 %type <ttype> parm_declarator_starttypename parm_declarator_nostarttypename
223 %type <ttype> array_declarator
225 %type <ttype> structsp_attr structsp_nonattr
226 %type <ttype> component_decl_list component_decl_list2
227 %type <ttype> component_decl components components_notype component_declarator
228 %type <ttype> component_notype_declarator
229 %type <ttype> enumlist enumerator
230 %type <ttype> struct_head union_head enum_head
231 %type <ttype> typename absdcl absdcl1 absdcl1_ea absdcl1_noea
232 %type <ttype> direct_absdcl1 absdcl_maybe_attribute
233 %type <ttype> condition xexpr for_cond_expr for_incr_expr
234 %type <ttype> parms parm firstparm identifiers
236 %type <ttype> parmlist parmlist_1 parmlist_2
237 %type <ttype> parmlist_or_identifiers parmlist_or_identifiers_1
238 %type <ttype> identifiers_or_typenames
240 %type <itype> setspecs setspecs_fp extension
242 %type <location> save_location
245 /* the Objective-C nonterminals */
247 %type <ttype> ivar_decl_list ivar_decls ivar_decl ivars ivar_declarator
248 %type <ttype> methoddecl unaryselector keywordselector selector
249 %type <ttype> keyworddecl receiver objcmessageexpr messageargs
250 %type <ttype> keywordexpr keywordarglist keywordarg
251 %type <ttype> myparms myparm optparmlist reservedwords objcselectorexpr
252 %type <ttype> selectorarg keywordnamelist keywordname objcencodeexpr
253 %type <ttype> non_empty_protocolrefs protocolrefs identifier_list objcprotocolexpr
255 %type <ttype> CLASSNAME OBJECTNAME OBJC_STRING
257 %type <ttype> superclass
261 /* List of types and structure classes of the current declaration. */
262 static GTY(()) tree current_declspecs;
263 static GTY(()) tree prefix_attributes;
265 /* List of all the attributes applying to the identifier currently being
266 declared; includes prefix_attributes and possibly some more attributes
267 just after a comma. */
268 static GTY(()) tree all_prefix_attributes;
270 /* Stack of saved values of current_declspecs, prefix_attributes and
271 all_prefix_attributes. */
272 static GTY(()) tree declspec_stack;
274 /* PUSH_DECLSPEC_STACK is called from setspecs; POP_DECLSPEC_STACK
275 should be called from the productions making use of setspecs. */
276 #define PUSH_DECLSPEC_STACK \
278 declspec_stack = tree_cons (build_tree_list (prefix_attributes, \
279 all_prefix_attributes), \
284 #define POP_DECLSPEC_STACK \
286 current_declspecs = TREE_VALUE (declspec_stack); \
287 prefix_attributes = TREE_PURPOSE (TREE_PURPOSE (declspec_stack)); \
288 all_prefix_attributes = TREE_VALUE (TREE_PURPOSE (declspec_stack)); \
289 declspec_stack = TREE_CHAIN (declspec_stack); \
292 /* For __extension__, save/restore the warning flags which are
293 controlled by __extension__. */
294 #define SAVE_EXT_FLAGS() \
296 | (warn_pointer_arith << 1) \
297 | (warn_traditional << 2) \
300 #define RESTORE_EXT_FLAGS(val) \
302 pedantic = val & 1; \
303 warn_pointer_arith = (val >> 1) & 1; \
304 warn_traditional = (val >> 2) & 1; \
305 flag_iso = (val >> 3) & 1; \
309 /* Objective-C specific parser/lexer information */
311 static enum tree_code objc_inherit_code;
312 static int objc_pq_context = 0, objc_public_flag = 0;
314 /* The following flag is needed to contextualize ObjC lexical analysis.
315 In some cases (e.g., 'int NSObject;'), it is undesirable to bind
316 an identifier to an ObjC class, even if a class with that name
318 static int objc_need_raw_identifier;
319 #define OBJC_NEED_RAW_IDENTIFIER(VAL) objc_need_raw_identifier = VAL
323 #define OBJC_NEED_RAW_IDENTIFIER(VAL) /* nothing */
326 /* Tell yyparse how to print a token's value, if yydebug is set. */
328 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
330 static void yyprint (FILE *, int, YYSTYPE);
331 static void yyerror (const char *);
332 static int yylexname (void);
333 static inline int _yylex (void);
334 static int yylex (void);
335 static void init_reswords (void);
337 /* Initialisation routine for this file. */
349 pedwarn ("ISO C forbids an empty source file");
354 /* the reason for the strange actions in this rule
355 is so that notype_initdecls when reached via datadef
356 can find a valid list of type and sc specs in $0. */
359 {$<ttype>$ = NULL_TREE; } extdef
360 | extdefs {$<ttype>$ = NULL_TREE; ggc_collect(); } extdef
368 { RESTORE_EXT_FLAGS ($1); }
375 setspecs notype_initdecls ';'
377 error ("ISO C forbids data definition with no type or storage class");
379 warning ("data definition has no type or storage class");
381 POP_DECLSPEC_STACK; }
382 | declspecs_nots setspecs notype_initdecls ';'
383 { POP_DECLSPEC_STACK; }
384 | declspecs_ts setspecs initdecls ';'
385 { POP_DECLSPEC_STACK; }
392 pedwarn ("ISO C does not allow extra `;' outside of a function"); }
396 declspecs_ts setspecs declarator
397 { if (! start_function (current_declspecs, $3,
398 all_prefix_attributes))
401 old_style_parm_decls save_location
402 { DECL_SOURCE_LOCATION (current_function_decl) = $6;
403 store_parm_decls (); }
405 { finish_function ();
406 POP_DECLSPEC_STACK; }
407 | declspecs_ts setspecs declarator error
408 { POP_DECLSPEC_STACK; }
409 | declspecs_nots setspecs notype_declarator
410 { if (! start_function (current_declspecs, $3,
411 all_prefix_attributes))
414 old_style_parm_decls save_location
415 { DECL_SOURCE_LOCATION (current_function_decl) = $6;
416 store_parm_decls (); }
418 { finish_function ();
419 POP_DECLSPEC_STACK; }
420 | declspecs_nots setspecs notype_declarator error
421 { POP_DECLSPEC_STACK; }
422 | setspecs notype_declarator
423 { if (! start_function (NULL_TREE, $2,
424 all_prefix_attributes))
427 old_style_parm_decls save_location
428 { DECL_SOURCE_LOCATION (current_function_decl) = $5;
429 store_parm_decls (); }
431 { finish_function ();
432 POP_DECLSPEC_STACK; }
433 | setspecs notype_declarator error
434 { POP_DECLSPEC_STACK; }
449 { $$ = NEGATE_EXPR; }
453 if (warn_traditional && !in_system_header)
454 warning ("traditional C rejects the unary plus operator");
458 { $$ = PREINCREMENT_EXPR; }
460 { $$ = PREDECREMENT_EXPR; }
462 { $$ = BIT_NOT_EXPR; }
464 { $$ = TRUTH_NOT_EXPR; }
468 | expr ',' expr_no_commas
469 { $$.value = build_compound_expr ($1.value, $3.value);
470 $$.original_code = COMPOUND_EXPR; }
481 { $$ = build_tree_list (NULL_TREE, $1.value); }
482 | nonnull_exprlist ',' expr_no_commas
483 { chainon ($1, build_tree_list (NULL_TREE, $3.value)); }
488 | '*' cast_expr %prec UNARY
489 { $$.value = build_indirect_ref ($2.value, "unary *");
490 $$.original_code = ERROR_MARK; }
491 /* __extension__ turns off -pedantic for following primary. */
492 | extension cast_expr %prec UNARY
494 RESTORE_EXT_FLAGS ($1); }
495 | unop cast_expr %prec UNARY
496 { $$.value = build_unary_op ($1, $2.value, 0);
497 overflow_warning ($$.value);
498 $$.original_code = ERROR_MARK; }
499 /* Refer to the address of a label as a pointer. */
501 { $$.value = finish_label_address_expr ($2);
502 $$.original_code = ERROR_MARK; }
503 | sizeof unary_expr %prec UNARY
505 if (TREE_CODE ($2.value) == COMPONENT_REF
506 && DECL_C_BIT_FIELD (TREE_OPERAND ($2.value, 1)))
507 error ("`sizeof' applied to a bit-field");
508 $$.value = c_sizeof (TREE_TYPE ($2.value));
509 $$.original_code = ERROR_MARK; }
510 | sizeof '(' typename ')' %prec HYPERUNARY
512 $$.value = c_sizeof (groktypename ($3));
513 $$.original_code = ERROR_MARK; }
514 | alignof unary_expr %prec UNARY
516 $$.value = c_alignof_expr ($2.value);
517 $$.original_code = ERROR_MARK; }
518 | alignof '(' typename ')' %prec HYPERUNARY
520 $$.value = c_alignof (groktypename ($3));
521 $$.original_code = ERROR_MARK; }
522 | REALPART cast_expr %prec UNARY
523 { $$.value = build_unary_op (REALPART_EXPR, $2.value, 0);
524 $$.original_code = ERROR_MARK; }
525 | IMAGPART cast_expr %prec UNARY
526 { $$.value = build_unary_op (IMAGPART_EXPR, $2.value, 0);
527 $$.original_code = ERROR_MARK; }
531 SIZEOF { skip_evaluation++; }
535 ALIGNOF { skip_evaluation++; }
539 TYPEOF { skip_evaluation++; }
544 | '(' typename ')' cast_expr %prec UNARY
545 { $$.value = c_cast_expr ($2, $4.value);
546 $$.original_code = ERROR_MARK; }
551 | expr_no_commas '+' expr_no_commas
552 { $$ = parser_build_binary_op ($2, $1, $3); }
553 | expr_no_commas '-' expr_no_commas
554 { $$ = parser_build_binary_op ($2, $1, $3); }
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 LSHIFT expr_no_commas
562 { $$ = parser_build_binary_op ($2, $1, $3); }
563 | expr_no_commas RSHIFT expr_no_commas
564 { $$ = parser_build_binary_op ($2, $1, $3); }
565 | expr_no_commas ARITHCOMPARE expr_no_commas
566 { $$ = parser_build_binary_op ($2, $1, $3); }
567 | expr_no_commas EQCOMPARE expr_no_commas
568 { $$ = parser_build_binary_op ($2, $1, $3); }
569 | expr_no_commas '&' expr_no_commas
570 { $$ = parser_build_binary_op ($2, $1, $3); }
571 | expr_no_commas '|' 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 ANDAND
576 { $1.value = lang_hooks.truthvalue_conversion
577 (default_conversion ($1.value));
578 skip_evaluation += $1.value == truthvalue_false_node; }
580 { skip_evaluation -= $1.value == truthvalue_false_node;
581 $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $4); }
582 | expr_no_commas OROR
583 { $1.value = lang_hooks.truthvalue_conversion
584 (default_conversion ($1.value));
585 skip_evaluation += $1.value == truthvalue_true_node; }
587 { skip_evaluation -= $1.value == truthvalue_true_node;
588 $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $4); }
590 { $1.value = lang_hooks.truthvalue_conversion
591 (default_conversion ($1.value));
592 skip_evaluation += $1.value == truthvalue_false_node; }
594 { skip_evaluation += (($1.value == truthvalue_true_node)
595 - ($1.value == truthvalue_false_node)); }
597 { skip_evaluation -= $1.value == truthvalue_true_node;
598 $$.value = build_conditional_expr ($1.value, $4.value,
600 $$.original_code = ERROR_MARK; }
603 pedwarn ("ISO C forbids omitting the middle term of a ?: expression");
604 /* Make sure first operand is calculated only once. */
605 $<ttype>2 = save_expr (default_conversion ($1.value));
606 $1.value = lang_hooks.truthvalue_conversion ($<ttype>2);
607 skip_evaluation += $1.value == truthvalue_true_node; }
609 { skip_evaluation -= $1.value == truthvalue_true_node;
610 $$.value = build_conditional_expr ($1.value, $<ttype>2,
612 $$.original_code = ERROR_MARK; }
613 | expr_no_commas '=' expr_no_commas
614 { $$.value = build_modify_expr ($1.value, NOP_EXPR, $3.value);
615 $$.original_code = MODIFY_EXPR;
617 | expr_no_commas ASSIGN expr_no_commas
618 { $$.value = build_modify_expr ($1.value, $2, $3.value);
619 TREE_NO_WARNING ($$.value) = 1;
620 $$.original_code = ERROR_MARK;
627 if (yychar == YYEMPTY)
629 $$.value = build_external_ref ($1, yychar == '(');
630 $$.original_code = ERROR_MARK;
633 { $$.value = $1; $$.original_code = ERROR_MARK; }
635 { $$.value = $1; $$.original_code = STRING_CST; }
637 { $$.value = fname_decl (C_RID_CODE ($1), $1);
638 $$.original_code = ERROR_MARK; }
639 | '(' typename ')' '{'
640 { start_init (NULL_TREE, NULL, 0);
641 $2 = groktypename ($2);
642 really_start_incremental_init ($2); }
643 initlist_maybe_comma '}' %prec UNARY
644 { struct c_expr init = pop_init_level (0);
645 tree constructor = init.value;
648 maybe_warn_string_init (type, init);
650 if (pedantic && ! flag_isoc99)
651 pedwarn ("ISO C90 forbids compound literals");
652 $$.value = build_compound_literal (type, constructor);
653 $$.original_code = ERROR_MARK;
656 { $$.value = $2.value;
657 if (TREE_CODE ($$.value) == MODIFY_EXPR)
658 TREE_NO_WARNING ($$.value) = 1;
659 $$.original_code = ERROR_MARK; }
661 { $$.value = error_mark_node; $$.original_code = ERROR_MARK; }
662 | compstmt_primary_start compstmt_nostart ')'
664 pedwarn ("ISO C forbids braced-groups within expressions");
665 $$.value = c_finish_stmt_expr ($1);
666 $$.original_code = ERROR_MARK;
668 | compstmt_primary_start error ')'
669 { c_finish_stmt_expr ($1);
670 $$.value = error_mark_node;
671 $$.original_code = ERROR_MARK;
673 | primary '(' exprlist ')' %prec '.'
674 { $$.value = build_function_call ($1.value, $3);
675 $$.original_code = ERROR_MARK; }
676 | VA_ARG '(' expr_no_commas ',' typename ')'
677 { $$.value = build_va_arg ($3.value, groktypename ($5));
678 $$.original_code = ERROR_MARK; }
680 | OFFSETOF '(' typename ',' offsetof_member_designator ')'
681 { $$.value = build_offsetof (groktypename ($3), $5);
682 $$.original_code = ERROR_MARK; }
683 | OFFSETOF '(' error ')'
684 { $$.value = error_mark_node; $$.original_code = ERROR_MARK; }
685 | CHOOSE_EXPR '(' expr_no_commas ',' expr_no_commas ','
692 if (TREE_CODE (c) != INTEGER_CST)
693 error ("first argument to __builtin_choose_expr not"
695 $$ = integer_zerop (c) ? $7 : $5;
697 | CHOOSE_EXPR '(' error ')'
698 { $$.value = error_mark_node; $$.original_code = ERROR_MARK; }
699 | TYPES_COMPATIBLE_P '(' typename ',' typename ')'
703 e1 = TYPE_MAIN_VARIANT (groktypename ($3));
704 e2 = TYPE_MAIN_VARIANT (groktypename ($5));
706 $$.value = comptypes (e1, e2)
707 ? build_int_2 (1, 0) : build_int_2 (0, 0);
708 $$.original_code = ERROR_MARK;
710 | TYPES_COMPATIBLE_P '(' error ')'
711 { $$.value = error_mark_node; $$.original_code = ERROR_MARK; }
712 | primary '[' expr ']' %prec '.'
713 { $$.value = build_array_ref ($1.value, $3.value);
714 $$.original_code = ERROR_MARK; }
715 | primary '.' identifier
716 { $$.value = build_component_ref ($1.value, $3);
717 $$.original_code = ERROR_MARK; }
718 | primary POINTSAT identifier
720 tree expr = build_indirect_ref ($1.value, "->");
721 $$.value = build_component_ref (expr, $3);
722 $$.original_code = ERROR_MARK;
725 { $$.value = build_unary_op (POSTINCREMENT_EXPR, $1.value, 0);
726 $$.original_code = ERROR_MARK; }
728 { $$.value = build_unary_op (POSTDECREMENT_EXPR, $1.value, 0);
729 $$.original_code = ERROR_MARK; }
732 { $$.value = build_message_expr ($1);
733 $$.original_code = ERROR_MARK; }
735 { $$.value = build_selector_expr ($1);
736 $$.original_code = ERROR_MARK; }
738 { $$.value = build_protocol_expr ($1);
739 $$.original_code = ERROR_MARK; }
741 { $$.value = build_encode_expr ($1);
742 $$.original_code = ERROR_MARK; }
744 { $$.value = build_objc_string_object ($1);
745 $$.original_code = ERROR_MARK; }
749 /* This is the second argument to __builtin_offsetof. We must have one
750 identifier, and beyond that we want to accept sub structure and sub
751 array references. We return tree list where each element has
752 PURPOSE set for component refs or VALUE set for array refs. We'll
753 turn this into something real inside build_offsetof. */
755 offsetof_member_designator:
757 { $$ = tree_cons ($1, NULL_TREE, NULL_TREE); }
758 | offsetof_member_designator '.' identifier
759 { $$ = tree_cons ($3, NULL_TREE, $1); }
760 | offsetof_member_designator '[' expr ']'
761 { $$ = tree_cons (NULL_TREE, $3.value, $1); }
764 old_style_parm_decls:
769 /* The following are analogous to lineno_decl, decls and decl
770 except that they do not allow nested functions.
771 They are used for old-style parm decls. */
773 save_location datadecl
780 | datadecls lineno_datadecl
781 | lineno_datadecl errstmt
784 /* We don't allow prefix attributes here because they cause reduce/reduce
785 conflicts: we can't know whether we're parsing a function decl with
786 attribute suffix, or function defn with attribute prefix on first old
789 declspecs_ts_nosa setspecs initdecls ';'
790 { POP_DECLSPEC_STACK; }
791 | declspecs_nots_nosa setspecs notype_initdecls ';'
792 { POP_DECLSPEC_STACK; }
793 | declspecs_ts_nosa ';'
794 { shadow_tag_warned ($1, 1);
795 pedwarn ("empty declaration"); }
796 | declspecs_nots_nosa ';'
797 { pedwarn ("empty declaration"); }
800 /* This combination which saves a lineno before a decl
801 is the normal thing to use, rather than decl itself.
802 This is to avoid shift/reduce conflicts in contexts
803 where statement labels are allowed. */
809 /* records the type and storage class specs to use for processing
810 the declarators that follow.
811 Maintains a stack of outer-level values of current_declspecs,
812 for the sake of parm declarations nested in function declarators. */
813 setspecs: /* empty */
814 { pending_xref_error ();
816 split_specs_attrs ($<ttype>0,
817 ¤t_declspecs, &prefix_attributes);
818 all_prefix_attributes = prefix_attributes; }
821 /* Possibly attributes after a comma, which should reset all_prefix_attributes
822 to prefix_attributes with these ones chained on the front. */
825 { all_prefix_attributes = chainon ($1, prefix_attributes); }
829 declspecs_ts setspecs initdecls ';'
830 { POP_DECLSPEC_STACK; }
831 | declspecs_nots setspecs notype_initdecls ';'
832 { POP_DECLSPEC_STACK; }
833 | declspecs_ts setspecs nested_function
834 { POP_DECLSPEC_STACK; }
835 | declspecs_nots setspecs notype_nested_function
836 { POP_DECLSPEC_STACK; }
840 { RESTORE_EXT_FLAGS ($1); }
843 /* A list of declaration specifiers. These are:
845 - Storage class specifiers (scspec), which for GCC currently includes
846 function specifiers ("inline").
848 - Type specifiers (typespec_*).
850 - Type qualifiers (TYPE_QUAL).
852 - Attribute specifier lists (attributes).
854 These are stored as a TREE_LIST; the head of the list is the last
855 item in the specifier list. Each entry in the list has either a
856 TREE_PURPOSE that is an attribute specifier list, or a TREE_VALUE that
857 is a single other specifier or qualifier; and a TREE_CHAIN that is the
858 rest of the list. TREE_STATIC is set on the list if something other
859 than a storage class specifier or attribute has been seen; this is used
860 to warn for the obsolescent usage of storage class specifiers other than
861 at the start of the list. (Doing this properly would require function
862 specifiers to be handled separately from storage class specifiers.)
864 The various cases below are classified according to:
866 (a) Whether a storage class specifier is included or not; some
867 places in the grammar disallow storage class specifiers (_sc or _nosc).
869 (b) Whether a type specifier has been seen; after a type specifier,
870 a typedef name is an identifier to redeclare (_ts or _nots).
872 (c) Whether the list starts with an attribute; in certain places,
873 the grammar requires specifiers that don't start with an attribute
876 (d) Whether the list ends with an attribute (or a specifier such that
877 any following attribute would have been parsed as part of that specifier);
878 this avoids shift-reduce conflicts in the parsing of attributes
883 (i) Distinguish between function specifiers and storage class specifiers,
884 at least for the purpose of warnings about obsolescent usage.
886 (ii) Halve the number of productions here by eliminating the _sc/_nosc
887 distinction and instead checking where required that storage class
888 specifiers aren't present. */
890 /* Declspecs which contain at least one type specifier or typedef name.
891 (Just `const' or `volatile' is not enough.)
892 A typedef'd name following these is taken as a name to be declared.
893 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
895 declspecs_nosc_nots_nosa_noea:
897 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
898 TREE_STATIC ($$) = 1; }
899 | declspecs_nosc_nots_nosa_noea TYPE_QUAL
900 { $$ = tree_cons (NULL_TREE, $2, $1);
901 TREE_STATIC ($$) = 1; }
902 | declspecs_nosc_nots_nosa_ea TYPE_QUAL
903 { $$ = tree_cons (NULL_TREE, $2, $1);
904 TREE_STATIC ($$) = 1; }
907 declspecs_nosc_nots_nosa_ea:
908 declspecs_nosc_nots_nosa_noea attributes
909 { $$ = tree_cons ($2, NULL_TREE, $1);
910 TREE_STATIC ($$) = TREE_STATIC ($1); }
913 declspecs_nosc_nots_sa_noea:
914 declspecs_nosc_nots_sa_noea TYPE_QUAL
915 { $$ = tree_cons (NULL_TREE, $2, $1);
916 TREE_STATIC ($$) = 1; }
917 | declspecs_nosc_nots_sa_ea TYPE_QUAL
918 { $$ = tree_cons (NULL_TREE, $2, $1);
919 TREE_STATIC ($$) = 1; }
922 declspecs_nosc_nots_sa_ea:
924 { $$ = tree_cons ($1, NULL_TREE, NULL_TREE);
925 TREE_STATIC ($$) = 0; }
926 | declspecs_nosc_nots_sa_noea attributes
927 { $$ = tree_cons ($2, NULL_TREE, $1);
928 TREE_STATIC ($$) = TREE_STATIC ($1); }
931 declspecs_nosc_ts_nosa_noea:
933 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
934 TREE_STATIC ($$) = 1; }
935 | declspecs_nosc_ts_nosa_noea TYPE_QUAL
936 { $$ = tree_cons (NULL_TREE, $2, $1);
937 TREE_STATIC ($$) = 1; }
938 | declspecs_nosc_ts_nosa_ea TYPE_QUAL
939 { $$ = tree_cons (NULL_TREE, $2, $1);
940 TREE_STATIC ($$) = 1; }
941 | declspecs_nosc_ts_nosa_noea typespec_reserved_nonattr
942 { $$ = tree_cons (NULL_TREE, $2, $1);
943 TREE_STATIC ($$) = 1; }
944 | declspecs_nosc_ts_nosa_ea typespec_reserved_nonattr
945 { $$ = tree_cons (NULL_TREE, $2, $1);
946 TREE_STATIC ($$) = 1; }
947 | declspecs_nosc_nots_nosa_noea typespec_nonattr
948 { $$ = tree_cons (NULL_TREE, $2, $1);
949 TREE_STATIC ($$) = 1; }
950 | declspecs_nosc_nots_nosa_ea typespec_nonattr
951 { $$ = tree_cons (NULL_TREE, $2, $1);
952 TREE_STATIC ($$) = 1; }
955 declspecs_nosc_ts_nosa_ea:
957 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
958 TREE_STATIC ($$) = 1; }
959 | declspecs_nosc_ts_nosa_noea attributes
960 { $$ = tree_cons ($2, NULL_TREE, $1);
961 TREE_STATIC ($$) = TREE_STATIC ($1); }
962 | declspecs_nosc_ts_nosa_noea typespec_reserved_attr
963 { $$ = tree_cons (NULL_TREE, $2, $1);
964 TREE_STATIC ($$) = 1; }
965 | declspecs_nosc_ts_nosa_ea typespec_reserved_attr
966 { $$ = tree_cons (NULL_TREE, $2, $1);
967 TREE_STATIC ($$) = 1; }
968 | declspecs_nosc_nots_nosa_noea typespec_attr
969 { $$ = tree_cons (NULL_TREE, $2, $1);
970 TREE_STATIC ($$) = 1; }
971 | declspecs_nosc_nots_nosa_ea typespec_attr
972 { $$ = tree_cons (NULL_TREE, $2, $1);
973 TREE_STATIC ($$) = 1; }
976 declspecs_nosc_ts_sa_noea:
977 declspecs_nosc_ts_sa_noea TYPE_QUAL
978 { $$ = tree_cons (NULL_TREE, $2, $1);
979 TREE_STATIC ($$) = 1; }
980 | declspecs_nosc_ts_sa_ea TYPE_QUAL
981 { $$ = tree_cons (NULL_TREE, $2, $1);
982 TREE_STATIC ($$) = 1; }
983 | declspecs_nosc_ts_sa_noea typespec_reserved_nonattr
984 { $$ = tree_cons (NULL_TREE, $2, $1);
985 TREE_STATIC ($$) = 1; }
986 | declspecs_nosc_ts_sa_ea typespec_reserved_nonattr
987 { $$ = tree_cons (NULL_TREE, $2, $1);
988 TREE_STATIC ($$) = 1; }
989 | declspecs_nosc_nots_sa_noea typespec_nonattr
990 { $$ = tree_cons (NULL_TREE, $2, $1);
991 TREE_STATIC ($$) = 1; }
992 | declspecs_nosc_nots_sa_ea typespec_nonattr
993 { $$ = tree_cons (NULL_TREE, $2, $1);
994 TREE_STATIC ($$) = 1; }
997 declspecs_nosc_ts_sa_ea:
998 declspecs_nosc_ts_sa_noea attributes
999 { $$ = tree_cons ($2, NULL_TREE, $1);
1000 TREE_STATIC ($$) = TREE_STATIC ($1); }
1001 | declspecs_nosc_ts_sa_noea typespec_reserved_attr
1002 { $$ = tree_cons (NULL_TREE, $2, $1);
1003 TREE_STATIC ($$) = 1; }
1004 | declspecs_nosc_ts_sa_ea typespec_reserved_attr
1005 { $$ = tree_cons (NULL_TREE, $2, $1);
1006 TREE_STATIC ($$) = 1; }
1007 | declspecs_nosc_nots_sa_noea typespec_attr
1008 { $$ = tree_cons (NULL_TREE, $2, $1);
1009 TREE_STATIC ($$) = 1; }
1010 | declspecs_nosc_nots_sa_ea typespec_attr
1011 { $$ = tree_cons (NULL_TREE, $2, $1);
1012 TREE_STATIC ($$) = 1; }
1015 declspecs_sc_nots_nosa_noea:
1017 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
1018 TREE_STATIC ($$) = 0; }
1019 | declspecs_sc_nots_nosa_noea TYPE_QUAL
1020 { $$ = tree_cons (NULL_TREE, $2, $1);
1021 TREE_STATIC ($$) = 1; }
1022 | declspecs_sc_nots_nosa_ea TYPE_QUAL
1023 { $$ = tree_cons (NULL_TREE, $2, $1);
1024 TREE_STATIC ($$) = 1; }
1025 | declspecs_nosc_nots_nosa_noea scspec
1026 { if (extra_warnings && TREE_STATIC ($1))
1027 warning ("`%s' is not at beginning of declaration",
1028 IDENTIFIER_POINTER ($2));
1029 $$ = tree_cons (NULL_TREE, $2, $1);
1030 TREE_STATIC ($$) = TREE_STATIC ($1); }
1031 | declspecs_nosc_nots_nosa_ea scspec
1032 { if (extra_warnings && TREE_STATIC ($1))
1033 warning ("`%s' is not at beginning of declaration",
1034 IDENTIFIER_POINTER ($2));
1035 $$ = tree_cons (NULL_TREE, $2, $1);
1036 TREE_STATIC ($$) = TREE_STATIC ($1); }
1037 | declspecs_sc_nots_nosa_noea scspec
1038 { if (extra_warnings && TREE_STATIC ($1))
1039 warning ("`%s' is not at beginning of declaration",
1040 IDENTIFIER_POINTER ($2));
1041 $$ = tree_cons (NULL_TREE, $2, $1);
1042 TREE_STATIC ($$) = TREE_STATIC ($1); }
1043 | declspecs_sc_nots_nosa_ea scspec
1044 { if (extra_warnings && TREE_STATIC ($1))
1045 warning ("`%s' is not at beginning of declaration",
1046 IDENTIFIER_POINTER ($2));
1047 $$ = tree_cons (NULL_TREE, $2, $1);
1048 TREE_STATIC ($$) = TREE_STATIC ($1); }
1051 declspecs_sc_nots_nosa_ea:
1052 declspecs_sc_nots_nosa_noea attributes
1053 { $$ = tree_cons ($2, NULL_TREE, $1);
1054 TREE_STATIC ($$) = TREE_STATIC ($1); }
1057 declspecs_sc_nots_sa_noea:
1058 declspecs_sc_nots_sa_noea TYPE_QUAL
1059 { $$ = tree_cons (NULL_TREE, $2, $1);
1060 TREE_STATIC ($$) = 1; }
1061 | declspecs_sc_nots_sa_ea TYPE_QUAL
1062 { $$ = tree_cons (NULL_TREE, $2, $1);
1063 TREE_STATIC ($$) = 1; }
1064 | declspecs_nosc_nots_sa_noea scspec
1065 { if (extra_warnings && TREE_STATIC ($1))
1066 warning ("`%s' is not at beginning of declaration",
1067 IDENTIFIER_POINTER ($2));
1068 $$ = tree_cons (NULL_TREE, $2, $1);
1069 TREE_STATIC ($$) = TREE_STATIC ($1); }
1070 | declspecs_nosc_nots_sa_ea scspec
1071 { if (extra_warnings && TREE_STATIC ($1))
1072 warning ("`%s' is not at beginning of declaration",
1073 IDENTIFIER_POINTER ($2));
1074 $$ = tree_cons (NULL_TREE, $2, $1);
1075 TREE_STATIC ($$) = TREE_STATIC ($1); }
1076 | declspecs_sc_nots_sa_noea scspec
1077 { if (extra_warnings && TREE_STATIC ($1))
1078 warning ("`%s' is not at beginning of declaration",
1079 IDENTIFIER_POINTER ($2));
1080 $$ = tree_cons (NULL_TREE, $2, $1);
1081 TREE_STATIC ($$) = TREE_STATIC ($1); }
1082 | declspecs_sc_nots_sa_ea scspec
1083 { if (extra_warnings && TREE_STATIC ($1))
1084 warning ("`%s' is not at beginning of declaration",
1085 IDENTIFIER_POINTER ($2));
1086 $$ = tree_cons (NULL_TREE, $2, $1);
1087 TREE_STATIC ($$) = TREE_STATIC ($1); }
1090 declspecs_sc_nots_sa_ea:
1091 declspecs_sc_nots_sa_noea attributes
1092 { $$ = tree_cons ($2, NULL_TREE, $1);
1093 TREE_STATIC ($$) = TREE_STATIC ($1); }
1096 declspecs_sc_ts_nosa_noea:
1097 declspecs_sc_ts_nosa_noea TYPE_QUAL
1098 { $$ = tree_cons (NULL_TREE, $2, $1);
1099 TREE_STATIC ($$) = 1; }
1100 | declspecs_sc_ts_nosa_ea TYPE_QUAL
1101 { $$ = tree_cons (NULL_TREE, $2, $1);
1102 TREE_STATIC ($$) = 1; }
1103 | declspecs_sc_ts_nosa_noea typespec_reserved_nonattr
1104 { $$ = tree_cons (NULL_TREE, $2, $1);
1105 TREE_STATIC ($$) = 1; }
1106 | declspecs_sc_ts_nosa_ea typespec_reserved_nonattr
1107 { $$ = tree_cons (NULL_TREE, $2, $1);
1108 TREE_STATIC ($$) = 1; }
1109 | declspecs_sc_nots_nosa_noea typespec_nonattr
1110 { $$ = tree_cons (NULL_TREE, $2, $1);
1111 TREE_STATIC ($$) = 1; }
1112 | declspecs_sc_nots_nosa_ea typespec_nonattr
1113 { $$ = tree_cons (NULL_TREE, $2, $1);
1114 TREE_STATIC ($$) = 1; }
1115 | declspecs_nosc_ts_nosa_noea scspec
1116 { if (extra_warnings && TREE_STATIC ($1))
1117 warning ("`%s' is not at beginning of declaration",
1118 IDENTIFIER_POINTER ($2));
1119 $$ = tree_cons (NULL_TREE, $2, $1);
1120 TREE_STATIC ($$) = TREE_STATIC ($1); }
1121 | declspecs_nosc_ts_nosa_ea scspec
1122 { if (extra_warnings && TREE_STATIC ($1))
1123 warning ("`%s' is not at beginning of declaration",
1124 IDENTIFIER_POINTER ($2));
1125 $$ = tree_cons (NULL_TREE, $2, $1);
1126 TREE_STATIC ($$) = TREE_STATIC ($1); }
1127 | declspecs_sc_ts_nosa_noea scspec
1128 { if (extra_warnings && TREE_STATIC ($1))
1129 warning ("`%s' is not at beginning of declaration",
1130 IDENTIFIER_POINTER ($2));
1131 $$ = tree_cons (NULL_TREE, $2, $1);
1132 TREE_STATIC ($$) = TREE_STATIC ($1); }
1133 | declspecs_sc_ts_nosa_ea scspec
1134 { if (extra_warnings && TREE_STATIC ($1))
1135 warning ("`%s' is not at beginning of declaration",
1136 IDENTIFIER_POINTER ($2));
1137 $$ = tree_cons (NULL_TREE, $2, $1);
1138 TREE_STATIC ($$) = TREE_STATIC ($1); }
1141 declspecs_sc_ts_nosa_ea:
1142 declspecs_sc_ts_nosa_noea attributes
1143 { $$ = tree_cons ($2, NULL_TREE, $1);
1144 TREE_STATIC ($$) = TREE_STATIC ($1); }
1145 | declspecs_sc_ts_nosa_noea typespec_reserved_attr
1146 { $$ = tree_cons (NULL_TREE, $2, $1);
1147 TREE_STATIC ($$) = 1; }
1148 | declspecs_sc_ts_nosa_ea typespec_reserved_attr
1149 { $$ = tree_cons (NULL_TREE, $2, $1);
1150 TREE_STATIC ($$) = 1; }
1151 | declspecs_sc_nots_nosa_noea typespec_attr
1152 { $$ = tree_cons (NULL_TREE, $2, $1);
1153 TREE_STATIC ($$) = 1; }
1154 | declspecs_sc_nots_nosa_ea typespec_attr
1155 { $$ = tree_cons (NULL_TREE, $2, $1);
1156 TREE_STATIC ($$) = 1; }
1159 declspecs_sc_ts_sa_noea:
1160 declspecs_sc_ts_sa_noea TYPE_QUAL
1161 { $$ = tree_cons (NULL_TREE, $2, $1);
1162 TREE_STATIC ($$) = 1; }
1163 | declspecs_sc_ts_sa_ea TYPE_QUAL
1164 { $$ = tree_cons (NULL_TREE, $2, $1);
1165 TREE_STATIC ($$) = 1; }
1166 | declspecs_sc_ts_sa_noea typespec_reserved_nonattr
1167 { $$ = tree_cons (NULL_TREE, $2, $1);
1168 TREE_STATIC ($$) = 1; }
1169 | declspecs_sc_ts_sa_ea typespec_reserved_nonattr
1170 { $$ = tree_cons (NULL_TREE, $2, $1);
1171 TREE_STATIC ($$) = 1; }
1172 | declspecs_sc_nots_sa_noea typespec_nonattr
1173 { $$ = tree_cons (NULL_TREE, $2, $1);
1174 TREE_STATIC ($$) = 1; }
1175 | declspecs_sc_nots_sa_ea typespec_nonattr
1176 { $$ = tree_cons (NULL_TREE, $2, $1);
1177 TREE_STATIC ($$) = 1; }
1178 | declspecs_nosc_ts_sa_noea scspec
1179 { if (extra_warnings && TREE_STATIC ($1))
1180 warning ("`%s' is not at beginning of declaration",
1181 IDENTIFIER_POINTER ($2));
1182 $$ = tree_cons (NULL_TREE, $2, $1);
1183 TREE_STATIC ($$) = TREE_STATIC ($1); }
1184 | declspecs_nosc_ts_sa_ea scspec
1185 { if (extra_warnings && TREE_STATIC ($1))
1186 warning ("`%s' is not at beginning of declaration",
1187 IDENTIFIER_POINTER ($2));
1188 $$ = tree_cons (NULL_TREE, $2, $1);
1189 TREE_STATIC ($$) = TREE_STATIC ($1); }
1190 | declspecs_sc_ts_sa_noea scspec
1191 { if (extra_warnings && TREE_STATIC ($1))
1192 warning ("`%s' is not at beginning of declaration",
1193 IDENTIFIER_POINTER ($2));
1194 $$ = tree_cons (NULL_TREE, $2, $1);
1195 TREE_STATIC ($$) = TREE_STATIC ($1); }
1196 | declspecs_sc_ts_sa_ea scspec
1197 { if (extra_warnings && TREE_STATIC ($1))
1198 warning ("`%s' is not at beginning of declaration",
1199 IDENTIFIER_POINTER ($2));
1200 $$ = tree_cons (NULL_TREE, $2, $1);
1201 TREE_STATIC ($$) = TREE_STATIC ($1); }
1204 declspecs_sc_ts_sa_ea:
1205 declspecs_sc_ts_sa_noea attributes
1206 { $$ = tree_cons ($2, NULL_TREE, $1);
1207 TREE_STATIC ($$) = TREE_STATIC ($1); }
1208 | declspecs_sc_ts_sa_noea typespec_reserved_attr
1209 { $$ = tree_cons (NULL_TREE, $2, $1);
1210 TREE_STATIC ($$) = 1; }
1211 | declspecs_sc_ts_sa_ea typespec_reserved_attr
1212 { $$ = tree_cons (NULL_TREE, $2, $1);
1213 TREE_STATIC ($$) = 1; }
1214 | declspecs_sc_nots_sa_noea typespec_attr
1215 { $$ = tree_cons (NULL_TREE, $2, $1);
1216 TREE_STATIC ($$) = 1; }
1217 | declspecs_sc_nots_sa_ea typespec_attr
1218 { $$ = tree_cons (NULL_TREE, $2, $1);
1219 TREE_STATIC ($$) = 1; }
1222 /* Particular useful classes of declspecs. */
1224 declspecs_nosc_ts_nosa_noea
1225 | declspecs_nosc_ts_nosa_ea
1226 | declspecs_nosc_ts_sa_noea
1227 | declspecs_nosc_ts_sa_ea
1228 | declspecs_sc_ts_nosa_noea
1229 | declspecs_sc_ts_nosa_ea
1230 | declspecs_sc_ts_sa_noea
1231 | declspecs_sc_ts_sa_ea
1235 declspecs_nosc_nots_nosa_noea
1236 | declspecs_nosc_nots_nosa_ea
1237 | declspecs_nosc_nots_sa_noea
1238 | declspecs_nosc_nots_sa_ea
1239 | declspecs_sc_nots_nosa_noea
1240 | declspecs_sc_nots_nosa_ea
1241 | declspecs_sc_nots_sa_noea
1242 | declspecs_sc_nots_sa_ea
1246 declspecs_nosc_ts_nosa_noea
1247 | declspecs_nosc_ts_nosa_ea
1248 | declspecs_sc_ts_nosa_noea
1249 | declspecs_sc_ts_nosa_ea
1252 declspecs_nots_nosa:
1253 declspecs_nosc_nots_nosa_noea
1254 | declspecs_nosc_nots_nosa_ea
1255 | declspecs_sc_nots_nosa_noea
1256 | declspecs_sc_nots_nosa_ea
1260 declspecs_nosc_ts_nosa_noea
1261 | declspecs_nosc_ts_nosa_ea
1262 | declspecs_nosc_ts_sa_noea
1263 | declspecs_nosc_ts_sa_ea
1266 declspecs_nosc_nots:
1267 declspecs_nosc_nots_nosa_noea
1268 | declspecs_nosc_nots_nosa_ea
1269 | declspecs_nosc_nots_sa_noea
1270 | declspecs_nosc_nots_sa_ea
1274 declspecs_nosc_ts_nosa_noea
1275 | declspecs_nosc_ts_nosa_ea
1276 | declspecs_nosc_ts_sa_noea
1277 | declspecs_nosc_ts_sa_ea
1278 | declspecs_nosc_nots_nosa_noea
1279 | declspecs_nosc_nots_nosa_ea
1280 | declspecs_nosc_nots_sa_noea
1281 | declspecs_nosc_nots_sa_ea
1285 declspecs_nosc_nots_nosa_noea
1286 | declspecs_nosc_nots_nosa_ea
1287 | declspecs_nosc_nots_sa_noea
1288 | declspecs_nosc_nots_sa_ea
1289 | declspecs_nosc_ts_nosa_noea
1290 | declspecs_nosc_ts_nosa_ea
1291 | declspecs_nosc_ts_sa_noea
1292 | declspecs_nosc_ts_sa_ea
1293 | declspecs_sc_nots_nosa_noea
1294 | declspecs_sc_nots_nosa_ea
1295 | declspecs_sc_nots_sa_noea
1296 | declspecs_sc_nots_sa_ea
1297 | declspecs_sc_ts_nosa_noea
1298 | declspecs_sc_ts_nosa_ea
1299 | declspecs_sc_ts_sa_noea
1300 | declspecs_sc_ts_sa_ea
1303 /* A (possibly empty) sequence of type qualifiers and attributes. */
1304 maybe_type_quals_attrs:
1307 | declspecs_nosc_nots
1311 /* A type specifier (but not a type qualifier).
1312 Once we have seen one of these in a declaration,
1313 if a typedef name appears then it is being redeclared.
1315 The _reserved versions start with a reserved word and may appear anywhere
1316 in the declaration specifiers; the _nonreserved versions may only
1317 appear before any other type specifiers, and after that are (if names)
1320 FIXME: should the _nonreserved version be restricted to names being
1321 redeclared only? The other entries there relate only the GNU extensions
1322 and Objective C, and are historically parsed thus, and don't make sense
1323 after other type specifiers, but it might be cleaner to count them as
1326 _attr means: specifiers that either end with attributes,
1327 or are such that any following attributes would
1328 be parsed as part of the specifier.
1330 _nonattr: specifiers. */
1333 typespec_reserved_nonattr
1334 | typespec_nonreserved_nonattr
1338 typespec_reserved_attr
1341 typespec_reserved_nonattr:
1343 { OBJC_NEED_RAW_IDENTIFIER (1); }
1347 typespec_reserved_attr:
1351 typespec_nonreserved_nonattr:
1353 { /* For a typedef name, record the meaning, not the name.
1354 In case of `foo foo, bar;'. */
1355 $$ = lookup_name ($1); }
1357 | CLASSNAME protocolrefs
1358 { $$ = get_static_reference ($1, $2); }
1359 | OBJECTNAME protocolrefs
1360 { $$ = get_protocol_reference ($2); }
1362 /* Make "<SomeProtocol>" equivalent to "id <SomeProtocol>"
1363 - nisse@lysator.liu.se */
1364 | non_empty_protocolrefs
1365 { $$ = get_protocol_reference ($1); }
1367 | typeof '(' expr ')'
1368 { skip_evaluation--;
1369 if (TREE_CODE ($3.value) == COMPONENT_REF
1370 && DECL_C_BIT_FIELD (TREE_OPERAND ($3.value, 1)))
1371 error ("`typeof' applied to a bit-field");
1372 $$ = TREE_TYPE ($3.value); }
1373 | typeof '(' typename ')'
1374 { skip_evaluation--; $$ = groktypename ($3); }
1377 /* typespec_nonreserved_attr does not exist. */
1381 | initdecls ',' maybe_resetattrs initdcl
1386 | notype_initdecls ',' maybe_resetattrs notype_initdcl
1390 declarator maybeasm maybe_attribute '='
1391 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1392 chainon ($3, all_prefix_attributes));
1393 start_init ($<ttype>$, $2, global_bindings_p ()); }
1395 /* Note how the declaration of the variable is in effect while its init is parsed! */
1397 maybe_warn_string_init (TREE_TYPE ($<ttype>5), $6);
1398 finish_decl ($<ttype>5, $6.value, $2); }
1399 | declarator maybeasm maybe_attribute
1400 { tree d = start_decl ($1, current_declspecs, 0,
1401 chainon ($3, all_prefix_attributes));
1402 finish_decl (d, NULL_TREE, $2);
1407 notype_declarator maybeasm maybe_attribute '='
1408 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1409 chainon ($3, all_prefix_attributes));
1410 start_init ($<ttype>$, $2, global_bindings_p ()); }
1412 /* Note how the declaration of the variable is in effect while its init is parsed! */
1414 maybe_warn_string_init (TREE_TYPE ($<ttype>5), $6);
1415 finish_decl ($<ttype>5, $6.value, $2); }
1416 | notype_declarator maybeasm maybe_attribute
1417 { tree d = start_decl ($1, current_declspecs, 0,
1418 chainon ($3, all_prefix_attributes));
1419 finish_decl (d, NULL_TREE, $2); }
1421 /* the * rules are dummies to accept the Apollo extended syntax
1422 so that the header files compile. */
1433 | attributes attribute
1434 { $$ = chainon ($1, $2); }
1438 ATTRIBUTE stop_string_translation
1439 '(' '(' attribute_list ')' ')' start_string_translation
1441 | ATTRIBUTE error start_string_translation
1448 | attribute_list ',' attrib
1449 { $$ = chainon ($1, $3); }
1456 { $$ = build_tree_list ($1, NULL_TREE); }
1457 | any_word '(' IDENTIFIER ')'
1458 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1459 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1460 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1461 | any_word '(' exprlist ')'
1462 { $$ = build_tree_list ($1, $3); }
1465 /* This still leaves out most reserved keywords,
1466 shouldn't we include them? */
1480 /* Initializers. `init' is the entry point. */
1486 { really_start_incremental_init (NULL_TREE); }
1487 initlist_maybe_comma '}'
1488 { $$ = pop_init_level (0); }
1490 { $$.value = error_mark_node; $$.original_code = ERROR_MARK; }
1493 /* `initlist_maybe_comma' is the guts of an initializer in braces. */
1494 initlist_maybe_comma:
1497 pedwarn ("ISO C forbids empty initializer braces"); }
1498 | initlist1 maybecomma
1503 | initlist1 ',' initelt
1506 /* `initelt' is a single element of an initializer.
1507 It may use braces. */
1509 designator_list '=' initval
1510 { if (pedantic && ! flag_isoc99)
1511 pedwarn ("ISO C90 forbids specifying subobject to initialize"); }
1512 | designator initval
1514 pedwarn ("obsolete use of designated initializer without `='"); }
1516 { set_init_label ($1);
1518 pedwarn ("obsolete use of designated initializer with `:'"); }
1526 { push_init_level (0); }
1527 initlist_maybe_comma '}'
1528 { process_init_element (pop_init_level (0)); }
1530 { process_init_element ($1); }
1536 | designator_list designator
1541 { set_init_label ($2); }
1542 | '[' expr_no_commas ELLIPSIS expr_no_commas ']'
1543 { set_init_index ($2.value, $4.value);
1545 pedwarn ("ISO C forbids specifying range of elements to initialize"); }
1546 | '[' expr_no_commas ']'
1547 { set_init_index ($2.value, NULL_TREE); }
1553 pedwarn ("ISO C forbids nested functions");
1555 push_function_context ();
1556 if (! start_function (current_declspecs, $1,
1557 all_prefix_attributes))
1559 pop_function_context ();
1563 old_style_parm_decls save_location
1564 { tree decl = current_function_decl;
1565 DECL_SOURCE_LOCATION (decl) = $4;
1566 store_parm_decls (); }
1567 /* This used to use compstmt_or_error. That caused a bug with
1568 input `f(g) int g {}', where the use of YYERROR1 above caused
1569 an error which then was handled by compstmt_or_error. There
1570 followed a repeated execution of that same rule, which called
1571 YYERROR1 again, and so on. */
1573 { tree decl = current_function_decl;
1576 pop_function_context ();
1577 add_stmt (build_stmt (DECL_EXPR, decl)); }
1580 notype_nested_function:
1583 pedwarn ("ISO C forbids nested functions");
1585 push_function_context ();
1586 if (! start_function (current_declspecs, $1,
1587 all_prefix_attributes))
1589 pop_function_context ();
1593 old_style_parm_decls save_location
1594 { tree decl = current_function_decl;
1595 DECL_SOURCE_LOCATION (decl) = $4;
1596 store_parm_decls (); }
1597 /* This used to use compstmt_or_error. That caused a bug with
1598 input `f(g) int g {}', where the use of YYERROR1 above caused
1599 an error which then was handled by compstmt_or_error. There
1600 followed a repeated execution of that same rule, which called
1601 YYERROR1 again, and so on. */
1603 { tree decl = current_function_decl;
1606 pop_function_context ();
1607 add_stmt (build_stmt (DECL_EXPR, decl)); }
1610 /* Any kind of declarator (thus, all declarators allowed
1611 after an explicit typespec). */
1614 after_type_declarator
1618 /* A declarator that is allowed only after an explicit typespec. */
1620 after_type_declarator:
1621 '(' maybe_attribute after_type_declarator ')'
1622 { $$ = $2 ? tree_cons ($2, $3, NULL_TREE) : $3; }
1623 | after_type_declarator '(' parmlist_or_identifiers %prec '.'
1624 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1625 | after_type_declarator array_declarator %prec '.'
1626 { $$ = set_array_declarator_type ($2, $1, 0); }
1627 | '*' maybe_type_quals_attrs after_type_declarator %prec UNARY
1628 { $$ = make_pointer_declarator ($2, $3); }
1635 /* Kinds of declarator that can appear in a parameter list
1636 in addition to notype_declarator. This is like after_type_declarator
1637 but does not allow a typedef name in parentheses as an identifier
1638 (because it would conflict with a function with that typedef as arg). */
1640 parm_declarator_starttypename
1641 | parm_declarator_nostarttypename
1644 parm_declarator_starttypename:
1645 parm_declarator_starttypename '(' parmlist_or_identifiers %prec '.'
1646 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1647 | parm_declarator_starttypename array_declarator %prec '.'
1648 { $$ = set_array_declarator_type ($2, $1, 0); }
1655 parm_declarator_nostarttypename:
1656 parm_declarator_nostarttypename '(' parmlist_or_identifiers %prec '.'
1657 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1658 | parm_declarator_nostarttypename array_declarator %prec '.'
1659 { $$ = set_array_declarator_type ($2, $1, 0); }
1660 | '*' maybe_type_quals_attrs parm_declarator_starttypename %prec UNARY
1661 { $$ = make_pointer_declarator ($2, $3); }
1662 | '*' maybe_type_quals_attrs parm_declarator_nostarttypename %prec UNARY
1663 { $$ = make_pointer_declarator ($2, $3); }
1664 | '(' maybe_attribute parm_declarator_nostarttypename ')'
1665 { $$ = $2 ? tree_cons ($2, $3, NULL_TREE) : $3; }
1668 /* A declarator allowed whether or not there has been
1669 an explicit typespec. These cannot redeclare a typedef-name. */
1672 notype_declarator '(' parmlist_or_identifiers %prec '.'
1673 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1674 | '(' maybe_attribute notype_declarator ')'
1675 { $$ = $2 ? tree_cons ($2, $3, NULL_TREE) : $3; }
1676 | '*' maybe_type_quals_attrs notype_declarator %prec UNARY
1677 { $$ = make_pointer_declarator ($2, $3); }
1678 | notype_declarator array_declarator %prec '.'
1679 { $$ = set_array_declarator_type ($2, $1, 0); }
1704 /* structsp_attr: struct/union/enum specifiers that either
1705 end with attributes, or are such that any following attributes would
1706 be parsed as part of the struct/union/enum specifier.
1708 structsp_nonattr: other struct/union/enum specifiers. */
1711 struct_head identifier '{'
1712 { $$ = start_struct (RECORD_TYPE, $2);
1713 /* Start scope of tag before parsing components. */
1715 component_decl_list '}' maybe_attribute
1716 { $$ = finish_struct ($<ttype>4, nreverse ($5),
1717 chainon ($1, $7)); }
1718 | struct_head '{' component_decl_list '}' maybe_attribute
1719 { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
1720 nreverse ($3), chainon ($1, $5));
1722 | union_head identifier '{'
1723 { $$ = start_struct (UNION_TYPE, $2); }
1724 component_decl_list '}' maybe_attribute
1725 { $$ = finish_struct ($<ttype>4, nreverse ($5),
1726 chainon ($1, $7)); }
1727 | union_head '{' component_decl_list '}' maybe_attribute
1728 { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
1729 nreverse ($3), chainon ($1, $5));
1731 | enum_head identifier '{'
1732 { $$ = start_enum ($2); }
1733 enumlist maybecomma_warn '}' maybe_attribute
1734 { $$ = finish_enum ($<ttype>4, nreverse ($5),
1735 chainon ($1, $8)); }
1737 { $$ = start_enum (NULL_TREE); }
1738 enumlist maybecomma_warn '}' maybe_attribute
1739 { $$ = finish_enum ($<ttype>3, nreverse ($4),
1740 chainon ($1, $7)); }
1744 struct_head identifier
1745 { $$ = xref_tag (RECORD_TYPE, $2); }
1746 | union_head identifier
1747 { $$ = xref_tag (UNION_TYPE, $2); }
1748 | enum_head identifier
1749 { $$ = xref_tag (ENUMERAL_TYPE, $2);
1750 /* In ISO C, enumerated types can be referred to
1751 only if already defined. */
1752 if (pedantic && !COMPLETE_TYPE_P ($$))
1753 pedwarn ("ISO C forbids forward references to `enum' types"); }
1764 { if (pedantic && ! flag_isoc99)
1765 pedwarn ("comma at end of enumerator list"); }
1768 /* We chain the components in reverse order. They are put in forward
1769 order in structsp_attr.
1771 Note that component_declarator returns single decls, so components
1772 and components_notype can use TREE_CHAIN directly, wheras components
1773 and components_notype return lists (of comma separated decls), so
1774 component_decl_list and component_decl_list2 must use chainon.
1776 The theory behind all this is that there will be more semicolon
1777 separated fields than comma separated fields, and so we'll be
1778 minimizing the number of node traversals required by chainon. */
1780 component_decl_list:
1781 component_decl_list2
1783 | component_decl_list2 component_decl
1784 { $$ = chainon ($2, $1);
1785 pedwarn ("no semicolon at end of struct or union"); }
1788 component_decl_list2: /* empty */
1790 | component_decl_list2 component_decl ';'
1791 { $$ = chainon ($2, $1); }
1792 | component_decl_list2 ';'
1794 pedwarn ("extra semicolon in struct or union specified"); }
1796 /* foo(sizeof(struct{ @defs(ClassName)})); */
1797 | AT_DEFS '(' CLASSNAME ')'
1798 { $$ = nreverse (get_class_ivars_from_name ($3)); }
1803 declspecs_nosc_ts setspecs components
1805 POP_DECLSPEC_STACK; }
1806 | declspecs_nosc_ts setspecs
1808 /* Support for unnamed structs or unions as members of
1809 structs or unions (which is [a] useful and [b] supports
1812 pedwarn ("ISO C doesn't support unnamed structs/unions");
1814 $$ = grokfield(NULL, current_declspecs, NULL_TREE);
1815 POP_DECLSPEC_STACK; }
1816 | declspecs_nosc_nots setspecs components_notype
1818 POP_DECLSPEC_STACK; }
1819 | declspecs_nosc_nots
1821 pedwarn ("ISO C forbids member declarations with no members");
1822 shadow_tag_warned ($1, pedantic);
1826 | extension component_decl
1828 RESTORE_EXT_FLAGS ($1); }
1832 component_declarator
1833 | components ',' maybe_resetattrs component_declarator
1834 { TREE_CHAIN ($4) = $1; $$ = $4; }
1838 component_notype_declarator
1839 | components_notype ',' maybe_resetattrs component_notype_declarator
1840 { TREE_CHAIN ($4) = $1; $$ = $4; }
1843 component_declarator:
1844 declarator maybe_attribute
1845 { $$ = grokfield ($1, current_declspecs, NULL_TREE);
1846 decl_attributes (&$$,
1847 chainon ($2, all_prefix_attributes), 0); }
1848 | declarator ':' expr_no_commas maybe_attribute
1849 { $$ = grokfield ($1, current_declspecs, $3.value);
1850 decl_attributes (&$$,
1851 chainon ($4, all_prefix_attributes), 0); }
1852 | ':' expr_no_commas maybe_attribute
1853 { $$ = grokfield (NULL_TREE, current_declspecs, $2.value);
1854 decl_attributes (&$$,
1855 chainon ($3, all_prefix_attributes), 0); }
1858 component_notype_declarator:
1859 notype_declarator maybe_attribute
1860 { $$ = grokfield ($1, current_declspecs, NULL_TREE);
1861 decl_attributes (&$$,
1862 chainon ($2, all_prefix_attributes), 0); }
1863 | notype_declarator ':' expr_no_commas maybe_attribute
1864 { $$ = grokfield ($1, current_declspecs, $3.value);
1865 decl_attributes (&$$,
1866 chainon ($4, all_prefix_attributes), 0); }
1867 | ':' expr_no_commas maybe_attribute
1868 { $$ = grokfield (NULL_TREE, current_declspecs, $2.value);
1869 decl_attributes (&$$,
1870 chainon ($3, all_prefix_attributes), 0); }
1873 /* We chain the enumerators in reverse order.
1874 They are put in forward order in structsp_attr. */
1878 | enumlist ',' enumerator
1879 { if ($1 == error_mark_node)
1882 TREE_CHAIN ($3) = $1, $$ = $3; }
1884 { $$ = error_mark_node; }
1890 { $$ = build_enumerator ($1, NULL_TREE); }
1891 | identifier '=' expr_no_commas
1892 { $$ = build_enumerator ($1, $3.value); }
1897 { pending_xref_error ();
1900 { $$ = build_tree_list ($<ttype>2, $3); }
1903 absdcl: /* an absolute declarator */
1909 absdcl_maybe_attribute: /* absdcl maybe_attribute, but not just attributes */
1911 { $$ = build_tree_list (build_tree_list (current_declspecs,
1913 all_prefix_attributes); }
1915 { $$ = build_tree_list (build_tree_list (current_declspecs,
1917 all_prefix_attributes); }
1918 | absdcl1_noea attributes
1919 { $$ = build_tree_list (build_tree_list (current_declspecs,
1921 chainon ($2, all_prefix_attributes)); }
1924 absdcl1: /* a nonempty absolute declarator */
1931 | '*' maybe_type_quals_attrs absdcl1_noea
1932 { $$ = make_pointer_declarator ($2, $3); }
1936 '*' maybe_type_quals_attrs
1937 { $$ = make_pointer_declarator ($2, NULL_TREE); }
1938 | '*' maybe_type_quals_attrs absdcl1_ea
1939 { $$ = make_pointer_declarator ($2, $3); }
1943 '(' maybe_attribute absdcl1 ')'
1944 { $$ = $2 ? tree_cons ($2, $3, NULL_TREE) : $3; }
1945 | direct_absdcl1 '(' parmlist
1946 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1947 | direct_absdcl1 array_declarator
1948 { $$ = set_array_declarator_type ($2, $1, 1); }
1950 { $$ = build_nt (CALL_EXPR, NULL_TREE, $2, NULL_TREE); }
1952 { $$ = set_array_declarator_type ($1, NULL_TREE, 1); }
1955 /* The [...] part of a declarator for an array type. */
1958 '[' maybe_type_quals_attrs expr_no_commas ']'
1959 { $$ = build_array_declarator ($3.value, $2, 0, 0); }
1960 | '[' maybe_type_quals_attrs ']'
1961 { $$ = build_array_declarator (NULL_TREE, $2, 0, 0); }
1962 | '[' maybe_type_quals_attrs '*' ']'
1963 { $$ = build_array_declarator (NULL_TREE, $2, 0, 1); }
1964 | '[' STATIC maybe_type_quals_attrs expr_no_commas ']'
1965 { $$ = build_array_declarator ($4.value, $3, 1, 0); }
1966 /* declspecs_nosc_nots is a synonym for type_quals_attrs. */
1967 | '[' declspecs_nosc_nots STATIC expr_no_commas ']'
1968 { $$ = build_array_declarator ($4.value, $2, 1, 0); }
1971 /* A nonempty series of declarations and statements (possibly followed by
1972 some labels) that can form the body of a compound statement.
1973 NOTE: we don't allow labels on declarations; this might seem like a
1974 natural extension, but there would be a conflict between attributes
1975 on the label and prefix attributes on the declaration. */
1978 lineno_stmt_decl_or_labels_ending_stmt
1979 | lineno_stmt_decl_or_labels_ending_decl
1980 | lineno_stmt_decl_or_labels_ending_label
1982 error ("label at end of compound statement");
1984 | lineno_stmt_decl_or_labels_ending_error
1987 lineno_stmt_decl_or_labels_ending_stmt:
1989 | lineno_stmt_decl_or_labels_ending_stmt lineno_stmt
1990 | lineno_stmt_decl_or_labels_ending_decl lineno_stmt
1991 | lineno_stmt_decl_or_labels_ending_label lineno_stmt
1992 | lineno_stmt_decl_or_labels_ending_error lineno_stmt
1995 lineno_stmt_decl_or_labels_ending_decl:
1997 | lineno_stmt_decl_or_labels_ending_stmt lineno_decl
1999 if ((pedantic && !flag_isoc99)
2000 || warn_declaration_after_statement)
2001 pedwarn_c90 ("ISO C90 forbids mixed declarations and code");
2003 | lineno_stmt_decl_or_labels_ending_decl lineno_decl
2004 | lineno_stmt_decl_or_labels_ending_error lineno_decl
2007 lineno_stmt_decl_or_labels_ending_label:
2009 | lineno_stmt_decl_or_labels_ending_stmt lineno_label
2010 | lineno_stmt_decl_or_labels_ending_decl lineno_label
2011 | lineno_stmt_decl_or_labels_ending_label lineno_label
2012 | lineno_stmt_decl_or_labels_ending_error lineno_label
2015 lineno_stmt_decl_or_labels_ending_error:
2017 | lineno_stmt_decl_or_labels errstmt
2020 lineno_stmt_decl_or_labels:
2021 lineno_stmt_decl_or_labels_ending_stmt
2022 | lineno_stmt_decl_or_labels_ending_decl
2023 | lineno_stmt_decl_or_labels_ending_label
2024 | lineno_stmt_decl_or_labels_ending_error
2030 /* Start and end blocks created for the new scopes of C99. */
2031 c99_block_start: /* empty */
2032 { $$ = c_begin_compound_stmt (flag_isoc99); }
2035 /* Read zero or more forward-declarations for labels
2036 that nested functions can jump to. */
2041 pedwarn ("ISO C forbids label declarations"); }
2046 | label_decls label_decl
2050 LABEL identifiers_or_typenames ';'
2052 for (link = $2; link; link = TREE_CHAIN (link))
2054 tree label = declare_label (TREE_VALUE (link));
2055 C_DECLARED_LABEL_FLAG (label) = 1;
2056 add_stmt (build_stmt (DECL_EXPR, label));
2061 /* This is the body of a function definition.
2062 It causes syntax errors to ignore to the next openbrace. */
2069 compstmt_start: '{' { $$ = c_begin_compound_stmt (true); }
2072 compstmt_nostart: '}'
2073 | maybe_label_decls compstmt_contents_nonempty '}'
2076 compstmt_contents_nonempty:
2081 compstmt_primary_start:
2083 { if (current_function_decl == 0)
2085 error ("braced-group within expression allowed "
2086 "only inside a function");
2089 $$ = c_begin_stmt_expr ();
2093 compstmt: compstmt_start compstmt_nostart
2094 { $$ = c_end_compound_stmt ($1, true); }
2097 /* The forced readahead in here is because we might be at the end of a
2098 line, and the line and file won't be bumped until yylex absorbs the
2099 first token on the next line. */
2102 { if (yychar == YYEMPTY)
2104 $$ = input_location; }
2109 | lineno_labels lineno_label
2112 /* A labeled statement. In C99 it also generates an implicit block. */
2113 c99_block_lineno_labeled_stmt:
2114 c99_block_start lineno_labels lineno_stmt
2115 { $$ = c_end_compound_stmt ($1, flag_isoc99); }
2121 /* Two cases cannot and do not have line numbers associated:
2122 If stmt is degenerate, such as "2;", then stmt is an
2123 INTEGER_CST, which cannot hold line numbers. But that's
2124 ok because the statement will either be changed to a
2125 MODIFY_EXPR during gimplification of the statement expr,
2126 or discarded. If stmt was compound, but without new
2127 variables, we will have skipped the creation of a BIND
2128 and will have a bare STATEMENT_LIST. But that's ok
2129 because (recursively) all of the component statments
2130 should already have line numbers assigned. */
2131 if ($2 && EXPR_P ($2))
2132 SET_EXPR_LOCATION ($2, $1);
2138 { if ($2) SET_EXPR_LOCATION ($2, $1); }
2141 condition: save_location expr
2142 { $$ = lang_hooks.truthvalue_conversion ($2.value);
2144 SET_EXPR_LOCATION ($$, $1); }
2147 /* Implement -Wparenthesis by special casing IF statement directly nested
2148 within IF statement. This requires some amount of duplication of the
2149 productions under c99_block_lineno_labeled_stmt in order to work out.
2150 But it's still likely more maintainable than lots of state outside the
2154 c99_block_start lineno_labels if_statement
2155 { $$ = c_end_compound_stmt ($1, flag_isoc99); }
2159 c99_block_start lineno_labels ';'
2160 { if (extra_warnings)
2161 add_stmt (build (NOP_EXPR, NULL_TREE, NULL_TREE));
2162 $$ = c_end_compound_stmt ($1, flag_isoc99); }
2163 | c99_block_lineno_labeled_stmt
2167 IF c99_block_start save_location '(' condition ')'
2168 if_statement_1 ELSE if_statement_2
2169 { c_finish_if_stmt ($3, $5, $7, $9, true);
2170 add_stmt (c_end_compound_stmt ($2, flag_isoc99)); }
2171 | IF c99_block_start save_location '(' condition ')'
2172 if_statement_2 ELSE if_statement_2
2173 { c_finish_if_stmt ($3, $5, $7, $9, false);
2174 add_stmt (c_end_compound_stmt ($2, flag_isoc99)); }
2175 | IF c99_block_start save_location '(' condition ')'
2176 if_statement_1 %prec IF
2177 { c_finish_if_stmt ($3, $5, $7, NULL, true);
2178 add_stmt (c_end_compound_stmt ($2, flag_isoc99)); }
2179 | IF c99_block_start save_location '(' condition ')'
2180 if_statement_2 %prec IF
2181 { c_finish_if_stmt ($3, $5, $7, NULL, false);
2182 add_stmt (c_end_compound_stmt ($2, flag_isoc99)); }
2185 start_break: /* empty */
2186 { $$ = c_break_label; c_break_label = NULL; }
2189 start_continue: /* empty */
2190 { $$ = c_cont_label; c_cont_label = NULL; }
2194 WHILE c99_block_start save_location '(' condition ')'
2195 start_break start_continue c99_block_lineno_labeled_stmt
2196 { c_finish_loop ($3, $5, NULL, $9, c_break_label,
2197 c_cont_label, true);
2198 add_stmt (c_end_compound_stmt ($2, flag_isoc99));
2199 c_break_label = $7; c_cont_label = $8; }
2203 DO c99_block_start save_location start_break start_continue
2204 c99_block_lineno_labeled_stmt WHILE
2205 { $<ttype>$ = c_break_label; c_break_label = $4; }
2206 { $<ttype>$ = c_cont_label; c_cont_label = $5; }
2207 '(' condition ')' ';'
2208 { c_finish_loop ($3, $11, NULL, $6, $<ttype>8,
2210 add_stmt (c_end_compound_stmt ($2, flag_isoc99)); }
2222 { c_finish_expr_stmt ($1); }
2224 { check_for_loop_decls (); }
2227 for_cond_expr: save_location xexpr
2230 $$ = lang_hooks.truthvalue_conversion ($2);
2232 SET_EXPR_LOCATION ($$, $1);
2239 for_incr_expr: xexpr
2240 { $$ = c_process_expr_stmt ($1); }
2244 FOR c99_block_start '(' for_init_stmt
2245 save_location for_cond_expr ';' for_incr_expr ')'
2246 start_break start_continue c99_block_lineno_labeled_stmt
2247 { c_finish_loop ($5, $6, $8, $12, c_break_label,
2248 c_cont_label, true);
2249 add_stmt (c_end_compound_stmt ($2, flag_isoc99));
2250 c_break_label = $10; c_cont_label = $11; }
2254 SWITCH c99_block_start '(' expr ')'
2255 { $<ttype>$ = c_start_case ($4.value); }
2256 start_break c99_block_lineno_labeled_stmt
2257 { c_finish_case ($8);
2259 add_stmt (build (LABEL_EXPR, void_type_node,
2262 add_stmt (c_end_compound_stmt ($2, flag_isoc99)); }
2265 /* Parse a single real statement, not including any labels or compounds. */
2268 { $$ = c_finish_expr_stmt ($1.value); }
2280 { $$ = c_finish_bc_stmt (&c_break_label, true); }
2282 { $$ = c_finish_bc_stmt (&c_cont_label, false); }
2284 { $$ = c_finish_return (NULL_TREE); }
2286 { $$ = c_finish_return ($2.value); }
2288 | GOTO identifier ';'
2289 { $$ = c_finish_goto_label ($2); }
2291 { $$ = c_finish_goto_ptr ($3.value); }
2296 { $$ = objc_build_throw_stmt ($2.value); }
2298 { $$ = objc_build_throw_stmt (NULL_TREE); }
2299 | objc_try_catch_stmt
2301 | AT_SYNCHRONIZED save_location '(' expr ')' compstmt
2302 { objc_build_synchronized ($2, $4.value, $6); $$ = NULL_TREE; }
2306 AT_CATCH '(' parm ')'
2307 { objc_begin_catch_clause ($3); }
2311 objc_catch_prefix '{' compstmt_nostart
2312 { objc_finish_catch_clause (); }
2313 | objc_catch_prefix '{' error '}'
2314 { objc_finish_catch_clause (); }
2317 objc_opt_catch_list:
2319 | objc_opt_catch_list objc_catch_clause
2322 objc_try_catch_clause:
2323 AT_TRY save_location compstmt
2324 { objc_begin_try_stmt ($2, $3); }
2328 objc_finally_clause:
2329 AT_FINALLY save_location compstmt
2330 { objc_build_finally_clause ($2, $3); }
2333 objc_try_catch_stmt:
2334 objc_try_catch_clause
2335 { objc_finish_try_stmt (); }
2336 | objc_try_catch_clause objc_finally_clause
2337 { objc_finish_try_stmt (); }
2341 /* Parse a single or compound real statement, not including any labels. */
2344 { add_stmt ($1); $$ = NULL_TREE; }
2348 /* Any kind of label, including jump labels and case labels.
2349 ANSI C accepts labels only before statements, but we allow them
2350 also at the end of a compound statement. */
2352 label: CASE expr_no_commas ':'
2353 { $$ = do_case ($2.value, NULL_TREE); }
2354 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
2355 { $$ = do_case ($2.value, $4.value); }
2357 { $$ = do_case (NULL_TREE, NULL_TREE); }
2358 | identifier save_location ':' maybe_attribute
2359 { tree label = define_label ($2, $1);
2362 decl_attributes (&label, $4, 0);
2363 $$ = add_stmt (build_stmt (LABEL_EXPR, label));
2370 /* Asm expressions and statements */
2372 /* simple_asm_expr is used in restricted contexts, where a full
2373 expression with inputs and outputs does not make sense. */
2375 ASM_KEYWORD stop_string_translation
2376 '(' STRING ')' start_string_translation
2380 /* maybeasm: used for assembly names for declarations */
2387 /* asmdef: asm() outside a function body. */
2390 { assemble_asm ($1); }
2391 | ASM_KEYWORD error start_string_translation ';'
2395 /* Full-blown asm statement with inputs, outputs, clobbers, and
2396 volatile tag allowed. */
2398 ASM_KEYWORD maybe_volatile stop_string_translation
2399 '(' asm_argument ')' start_string_translation ';'
2400 { $$ = build_asm_stmt ($2, $5); }
2406 { $$ = build_asm_expr ($1, 0, 0, 0, true); }
2407 /* output operands */
2408 | STRING ':' asm_operands
2409 { $$ = build_asm_expr ($1, $3, 0, 0, false); }
2410 /* output and input operands */
2411 | STRING ':' asm_operands ':' asm_operands
2412 { $$ = build_asm_expr ($1, $3, $5, 0, false); }
2413 /* output and input operands and clobbers */
2414 | STRING ':' asm_operands ':' asm_operands ':' asm_clobbers
2415 { $$ = build_asm_expr ($1, $3, $5, $7, false); }
2418 /* Either 'volatile' or nothing. First thing in an `asm' statement. */
2424 { if ($1 != ridpointers[RID_VOLATILE])
2426 warning ("%E qualifier ignored on asm", $1);
2434 /* These are the operands other than the first string and colon
2435 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
2436 asm_operands: /* empty */
2438 | nonnull_asm_operands
2441 nonnull_asm_operands:
2443 | nonnull_asm_operands ',' asm_operand
2444 { $$ = chainon ($1, $3); }
2448 STRING start_string_translation '(' expr ')' stop_string_translation
2449 { $$ = build_tree_list (build_tree_list (NULL_TREE, $1),
2451 | '[' identifier ']' STRING start_string_translation
2452 '(' expr ')' stop_string_translation
2453 { $2 = build_string (IDENTIFIER_LENGTH ($2),
2454 IDENTIFIER_POINTER ($2));
2455 $$ = build_tree_list (build_tree_list ($2, $4), $7.value); }
2460 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
2461 | asm_clobbers ',' STRING
2462 { $$ = tree_cons (NULL_TREE, $3, $1); }
2465 stop_string_translation:
2466 { c_lex_string_translate = 0; }
2469 start_string_translation:
2470 { c_lex_string_translate = 1; }
2474 /* This is what appears inside the parens in a function declarator.
2475 Its value is a list of ..._TYPE nodes. Attributes must appear here
2476 to avoid a conflict with their appearance after an open parenthesis
2477 in an abstract declarator, as in
2478 "void bar (int (__attribute__((__mode__(SI))) int foo));". */
2482 declare_parm_level (); }
2491 { mark_forward_parm_decls (); }
2493 { /* Dummy action so attributes are in known place
2494 on parser stack. */ }
2498 { $$ = make_node (TREE_LIST); }
2501 /* This is what appears inside the parens in a function declarator.
2502 Is value is represented in the format that grokdeclarator expects. */
2503 parmlist_2: /* empty */
2504 { $$ = make_node (TREE_LIST); }
2506 { $$ = make_node (TREE_LIST);
2507 /* Suppress -Wold-style-definition for this case. */
2508 TREE_CHAIN ($$) = error_mark_node;
2509 error ("ISO C requires a named argument before `...'");
2512 { $$ = get_parm_info (/*ellipsis=*/false); }
2513 | parms ',' ELLIPSIS
2514 { $$ = get_parm_info (/*ellipsis=*/true); }
2519 { push_parm_decl ($1); }
2521 { push_parm_decl ($3); }
2524 /* A single parameter declaration or parameter type name,
2525 as found in a parmlist. */
2527 declspecs_ts setspecs parm_declarator maybe_attribute
2528 { $$ = build_tree_list (build_tree_list (current_declspecs,
2530 chainon ($4, all_prefix_attributes));
2531 POP_DECLSPEC_STACK; }
2532 | declspecs_ts setspecs notype_declarator maybe_attribute
2533 { $$ = build_tree_list (build_tree_list (current_declspecs,
2535 chainon ($4, all_prefix_attributes));
2536 POP_DECLSPEC_STACK; }
2537 | declspecs_ts setspecs absdcl_maybe_attribute
2539 POP_DECLSPEC_STACK; }
2540 | declspecs_nots setspecs notype_declarator maybe_attribute
2541 { $$ = build_tree_list (build_tree_list (current_declspecs,
2543 chainon ($4, all_prefix_attributes));
2544 POP_DECLSPEC_STACK; }
2546 | declspecs_nots setspecs absdcl_maybe_attribute
2548 POP_DECLSPEC_STACK; }
2551 /* The first parm, which must suck attributes from off the top of the parser
2554 declspecs_ts_nosa setspecs_fp parm_declarator maybe_attribute
2555 { $$ = build_tree_list (build_tree_list (current_declspecs,
2557 chainon ($4, all_prefix_attributes));
2558 POP_DECLSPEC_STACK; }
2559 | declspecs_ts_nosa setspecs_fp notype_declarator maybe_attribute
2560 { $$ = build_tree_list (build_tree_list (current_declspecs,
2562 chainon ($4, all_prefix_attributes));
2563 POP_DECLSPEC_STACK; }
2564 | declspecs_ts_nosa setspecs_fp absdcl_maybe_attribute
2566 POP_DECLSPEC_STACK; }
2567 | declspecs_nots_nosa setspecs_fp notype_declarator maybe_attribute
2568 { $$ = build_tree_list (build_tree_list (current_declspecs,
2570 chainon ($4, all_prefix_attributes));
2571 POP_DECLSPEC_STACK; }
2573 | declspecs_nots_nosa setspecs_fp absdcl_maybe_attribute
2575 POP_DECLSPEC_STACK; }
2580 { prefix_attributes = chainon (prefix_attributes, $<ttype>-2);
2581 all_prefix_attributes = prefix_attributes; }
2584 /* This is used in a function definition
2585 where either a parmlist or an identifier list is ok.
2586 Its value is a list of ..._TYPE nodes or a list of identifiers. */
2587 parmlist_or_identifiers:
2590 declare_parm_level (); }
2591 parmlist_or_identifiers_1
2596 parmlist_or_identifiers_1:
2600 for (t = $1; t; t = TREE_CHAIN (t))
2601 if (TREE_VALUE (t) == NULL_TREE)
2602 error ("`...' in old-style identifier list");
2603 $$ = tree_cons (NULL_TREE, NULL_TREE, $1);
2605 /* Make sure we have a parmlist after attributes. */
2607 && (TREE_CODE ($$) != TREE_LIST
2608 || TREE_PURPOSE ($$) == 0
2609 || TREE_CODE (TREE_PURPOSE ($$)) != PARM_DECL))
2614 /* A nonempty list of identifiers. */
2617 { $$ = build_tree_list (NULL_TREE, $1); }
2618 | identifiers ',' IDENTIFIER
2619 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2622 /* A nonempty list of identifiers, including typenames. */
2623 identifiers_or_typenames:
2625 { $$ = build_tree_list (NULL_TREE, $1); }
2626 | identifiers_or_typenames ',' identifier
2627 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2632 { $$ = SAVE_EXT_FLAGS();
2634 warn_pointer_arith = 0;
2635 warn_traditional = 0;
2640 /* Objective-C productions. */
2650 if (objc_implementation_context)
2652 finish_class (objc_implementation_context);
2653 objc_ivar_chain = NULL_TREE;
2654 objc_implementation_context = NULL_TREE;
2657 warning ("`@end' must appear in an implementation context");
2661 /* A nonempty list of identifiers. */
2664 { $$ = build_tree_list (NULL_TREE, $1); }
2665 | identifier_list ',' identifier
2666 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2670 AT_CLASS identifier_list ';'
2672 objc_declare_class ($2);
2677 AT_ALIAS identifier identifier ';'
2679 objc_declare_alias ($2, $3);
2684 ':' identifier { $$ = $2; }
2685 | /* NULL */ %prec HYPERUNARY { $$ = NULL_TREE; }
2689 '{' ivar_decl_list '}'
2694 AT_INTERFACE identifier superclass protocolrefs
2696 objc_interface_context = objc_ivar_context
2697 = start_class (CLASS_INTERFACE_TYPE, $2, $3, $4);
2698 objc_public_flag = 0;
2702 continue_class (objc_interface_context);
2704 methodprotolist AT_END
2706 finish_class (objc_interface_context);
2707 objc_interface_context = NULL_TREE;
2710 | AT_IMPLEMENTATION identifier superclass
2712 objc_implementation_context = objc_ivar_context
2713 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $3, NULL_TREE);
2714 objc_public_flag = 0;
2719 = continue_class (objc_implementation_context);
2722 | AT_INTERFACE identifier '(' identifier ')' protocolrefs
2724 objc_interface_context
2725 = start_class (CATEGORY_INTERFACE_TYPE, $2, $4, $6);
2726 continue_class (objc_interface_context);
2728 methodprotolist AT_END
2730 finish_class (objc_interface_context);
2731 objc_interface_context = NULL_TREE;
2734 | AT_IMPLEMENTATION identifier '(' identifier ')'
2736 objc_implementation_context
2737 = start_class (CATEGORY_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2739 = continue_class (objc_implementation_context);
2744 AT_PROTOCOL identifier protocolrefs
2746 objc_pq_context = 1;
2747 objc_interface_context
2748 = start_protocol(PROTOCOL_INTERFACE_TYPE, $2, $3);
2750 methodprotolist AT_END
2752 objc_pq_context = 0;
2753 finish_protocol(objc_interface_context);
2754 objc_interface_context = NULL_TREE;
2756 /* The @protocol forward-declaration production introduces a
2757 reduce/reduce conflict on ';', which should be resolved in
2758 favor of the production 'identifier_list -> identifier'. */
2759 | AT_PROTOCOL identifier_list ';'
2761 objc_declare_protocols ($2);
2770 | non_empty_protocolrefs
2773 non_empty_protocolrefs:
2774 ARITHCOMPARE identifier_list ARITHCOMPARE
2776 if ($1 == LT_EXPR && $3 == GT_EXPR)
2784 ivar_decl_list visibility_spec ivar_decls
2789 AT_PRIVATE { objc_public_flag = 2; }
2790 | AT_PROTECTED { objc_public_flag = 0; }
2791 | AT_PUBLIC { objc_public_flag = 1; }
2799 | ivar_decls ivar_decl ';'
2803 pedwarn ("extra semicolon in struct or union specified");
2808 /* There is a shift-reduce conflict here, because `components' may
2809 start with a `typename'. It happens that shifting (the default resolution)
2810 does the right thing, because it treats the `typename' as part of
2811 a `typed_typespecs'.
2813 It is possible that this same technique would allow the distinction
2814 between `notype_initdecls' and `initdecls' to be eliminated.
2815 But I am being cautious and not trying it. */
2818 declspecs_nosc_ts setspecs ivars
2820 POP_DECLSPEC_STACK; }
2821 | declspecs_nosc_nots setspecs ivars
2823 POP_DECLSPEC_STACK; }
2832 | ivars ',' maybe_resetattrs ivar_declarator
2838 $$ = add_instance_variable (objc_ivar_context,
2840 $1, current_declspecs,
2843 | declarator ':' expr_no_commas
2845 $$ = add_instance_variable (objc_ivar_context,
2847 $1, current_declspecs, $3.value);
2849 | ':' expr_no_commas
2851 $$ = add_instance_variable (objc_ivar_context,
2854 current_declspecs, $2.value);
2860 { objc_inherit_code = CLASS_METHOD_DECL; }
2862 { objc_inherit_code = INSTANCE_METHOD_DECL; }
2868 objc_pq_context = 1;
2869 if (!objc_implementation_context)
2870 fatal_error ("method definition not in class context");
2874 objc_pq_context = 0;
2875 objc_add_method (objc_implementation_context,
2877 objc_inherit_code == CLASS_METHOD_DECL);
2878 start_method_def ($3);
2882 continue_method_def ();
2886 finish_method_def ();
2890 /* the reason for the strange actions in this rule
2891 is so that notype_initdecls when reached via datadef
2892 can find a valid list of type and sc specs in $0. */
2896 | methodprotolist methodproto
2897 | methodprotolist { $<ttype>$ = NULL_TREE; } datadef
2908 /* Remember protocol qualifiers in prototypes. */
2909 objc_pq_context = 1;
2913 /* Forget protocol qualifiers here. */
2914 objc_pq_context = 0;
2915 objc_add_method (objc_interface_context,
2917 objc_inherit_code == CLASS_METHOD_DECL);
2923 '(' typename ')' unaryselector
2925 $$ = build_method_decl (objc_inherit_code, $2, $4, NULL_TREE);
2930 $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, NULL_TREE);
2933 | '(' typename ')' keywordselector optparmlist
2935 $$ = build_method_decl (objc_inherit_code, $2, $4, $5);
2938 | keywordselector optparmlist
2940 $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, $2);
2944 /* "optarglist" assumes that start_method_def has already been called...
2945 if it is not, the "xdecls" will not be placed in the proper scope */
2952 /* to get around the following situation: "int foo (int a) int b; {}" that
2953 is synthesized when parsing "- a:a b:b; id c; id d; { ... }" */
2968 declspecs_ts setspecs myparms ';'
2969 { POP_DECLSPEC_STACK; }
2971 { shadow_tag ($1); }
2972 | declspecs_nots ';'
2973 { pedwarn ("empty declaration"); }
2978 { push_parm_decl ($1); }
2979 | myparms ',' myparm
2980 { push_parm_decl ($3); }
2983 /* A single parameter declaration or parameter type name,
2984 as found in a parmlist. DOES NOT ALLOW AN INITIALIZER OR ASMSPEC */
2987 parm_declarator maybe_attribute
2988 { $$ = build_tree_list (build_tree_list (current_declspecs,
2990 chainon ($2, all_prefix_attributes)); }
2991 | notype_declarator maybe_attribute
2992 { $$ = build_tree_list (build_tree_list (current_declspecs,
2994 chainon ($2, all_prefix_attributes)); }
2995 | absdcl_maybe_attribute
3006 /* oh what a kludge! */
3007 $$ = objc_ellipsis_node;
3015 /* returns a tree list node generated by get_parm_info */
3028 | keywordselector keyworddecl
3030 $$ = chainon ($1, $2);
3043 ENUM | STRUCT | UNION | IF | ELSE | WHILE | DO | FOR
3044 | SWITCH | CASE | DEFAULT | BREAK | CONTINUE | RETURN
3045 | GOTO | ASM_KEYWORD | SIZEOF | TYPEOF | ALIGNOF
3046 | TYPESPEC | TYPE_QUAL
3050 selector ':' '(' typename ')' identifier
3052 $$ = build_keyword_decl ($1, $4, $6);
3055 | selector ':' identifier
3057 $$ = build_keyword_decl ($1, NULL_TREE, $3);
3060 | ':' '(' typename ')' identifier
3062 $$ = build_keyword_decl (NULL_TREE, $3, $5);
3067 $$ = build_keyword_decl (NULL_TREE, NULL_TREE, $2);
3078 | keywordarglist keywordarg
3080 $$ = chainon ($1, $2);
3088 if (TREE_CHAIN ($1) == NULL_TREE)
3089 /* just return the expr., remove a level of indirection */
3090 $$ = TREE_VALUE ($1);
3092 /* we have a comma expr., we will collapse later */
3098 selector ':' keywordexpr
3100 $$ = build_tree_list ($1, $3);
3104 $$ = build_tree_list (NULL_TREE, $2);
3113 $$ = get_class_reference ($1);
3117 $$ = get_class_reference ($1);
3122 '[' receiver messageargs ']'
3123 { $$ = build_tree_list ($2, $3); }
3133 | keywordnamelist keywordname
3135 $$ = chainon ($1, $2);
3142 $$ = build_tree_list ($1, NULL_TREE);
3146 $$ = build_tree_list (NULL_TREE, NULL_TREE);
3151 AT_SELECTOR '(' selectorarg ')'
3158 AT_PROTOCOL '(' identifier ')'
3164 /* extension to support C-structures in the archiver */
3167 AT_ENCODE '(' typename ')'
3169 $$ = groktypename ($3);
3176 /* yylex() is a thin wrapper around c_lex(), all it does is translate
3177 cpplib.h's token codes into yacc's token codes. */
3179 static enum cpp_ttype last_token;
3181 /* The reserved keyword table. */
3185 ENUM_BITFIELD(rid) rid : 16;
3186 unsigned int disable : 16;
3189 /* Disable mask. Keywords are disabled if (reswords[i].disable & mask) is
3191 #define D_C89 0x01 /* not in C89 */
3192 #define D_EXT 0x02 /* GCC extension */
3193 #define D_EXT89 0x04 /* GCC extension incorporated in C99 */
3194 #define D_OBJC 0x08 /* Objective C only */
3196 static const struct resword reswords[] =
3198 { "_Bool", RID_BOOL, 0 },
3199 { "_Complex", RID_COMPLEX, 0 },
3200 { "__FUNCTION__", RID_FUNCTION_NAME, 0 },
3201 { "__PRETTY_FUNCTION__", RID_PRETTY_FUNCTION_NAME, 0 },
3202 { "__alignof", RID_ALIGNOF, 0 },
3203 { "__alignof__", RID_ALIGNOF, 0 },
3204 { "__asm", RID_ASM, 0 },
3205 { "__asm__", RID_ASM, 0 },
3206 { "__attribute", RID_ATTRIBUTE, 0 },
3207 { "__attribute__", RID_ATTRIBUTE, 0 },
3208 { "__builtin_choose_expr", RID_CHOOSE_EXPR, 0 },
3209 { "__builtin_offsetof", RID_OFFSETOF, 0 },
3210 { "__builtin_types_compatible_p", RID_TYPES_COMPATIBLE_P, 0 },
3211 { "__builtin_va_arg", RID_VA_ARG, 0 },
3212 { "__complex", RID_COMPLEX, 0 },
3213 { "__complex__", RID_COMPLEX, 0 },
3214 { "__const", RID_CONST, 0 },
3215 { "__const__", RID_CONST, 0 },
3216 { "__extension__", RID_EXTENSION, 0 },
3217 { "__func__", RID_C99_FUNCTION_NAME, 0 },
3218 { "__imag", RID_IMAGPART, 0 },
3219 { "__imag__", RID_IMAGPART, 0 },
3220 { "__inline", RID_INLINE, 0 },
3221 { "__inline__", RID_INLINE, 0 },
3222 { "__label__", RID_LABEL, 0 },
3223 { "__ptrbase", RID_PTRBASE, 0 },
3224 { "__ptrbase__", RID_PTRBASE, 0 },
3225 { "__ptrextent", RID_PTREXTENT, 0 },
3226 { "__ptrextent__", RID_PTREXTENT, 0 },
3227 { "__ptrvalue", RID_PTRVALUE, 0 },
3228 { "__ptrvalue__", RID_PTRVALUE, 0 },
3229 { "__real", RID_REALPART, 0 },
3230 { "__real__", RID_REALPART, 0 },
3231 { "__restrict", RID_RESTRICT, 0 },
3232 { "__restrict__", RID_RESTRICT, 0 },
3233 { "__signed", RID_SIGNED, 0 },
3234 { "__signed__", RID_SIGNED, 0 },
3235 { "__thread", RID_THREAD, 0 },
3236 { "__typeof", RID_TYPEOF, 0 },
3237 { "__typeof__", RID_TYPEOF, 0 },
3238 { "__volatile", RID_VOLATILE, 0 },
3239 { "__volatile__", RID_VOLATILE, 0 },
3240 { "asm", RID_ASM, D_EXT },
3241 { "auto", RID_AUTO, 0 },
3242 { "break", RID_BREAK, 0 },
3243 { "case", RID_CASE, 0 },
3244 { "char", RID_CHAR, 0 },
3245 { "const", RID_CONST, 0 },
3246 { "continue", RID_CONTINUE, 0 },
3247 { "default", RID_DEFAULT, 0 },
3248 { "do", RID_DO, 0 },
3249 { "double", RID_DOUBLE, 0 },
3250 { "else", RID_ELSE, 0 },
3251 { "enum", RID_ENUM, 0 },
3252 { "extern", RID_EXTERN, 0 },
3253 { "float", RID_FLOAT, 0 },
3254 { "for", RID_FOR, 0 },
3255 { "goto", RID_GOTO, 0 },
3256 { "if", RID_IF, 0 },
3257 { "inline", RID_INLINE, D_EXT89 },
3258 { "int", RID_INT, 0 },
3259 { "long", RID_LONG, 0 },
3260 { "register", RID_REGISTER, 0 },
3261 { "restrict", RID_RESTRICT, D_C89 },
3262 { "return", RID_RETURN, 0 },
3263 { "short", RID_SHORT, 0 },
3264 { "signed", RID_SIGNED, 0 },
3265 { "sizeof", RID_SIZEOF, 0 },
3266 { "static", RID_STATIC, 0 },
3267 { "struct", RID_STRUCT, 0 },
3268 { "switch", RID_SWITCH, 0 },
3269 { "typedef", RID_TYPEDEF, 0 },
3270 { "typeof", RID_TYPEOF, D_EXT },
3271 { "union", RID_UNION, 0 },
3272 { "unsigned", RID_UNSIGNED, 0 },
3273 { "void", RID_VOID, 0 },
3274 { "volatile", RID_VOLATILE, 0 },
3275 { "while", RID_WHILE, 0 },
3277 { "id", RID_ID, D_OBJC },
3279 /* These objc keywords are recognized only immediately after
3281 { "class", RID_AT_CLASS, D_OBJC },
3282 { "compatibility_alias", RID_AT_ALIAS, D_OBJC },
3283 { "defs", RID_AT_DEFS, D_OBJC },
3284 { "encode", RID_AT_ENCODE, D_OBJC },
3285 { "end", RID_AT_END, D_OBJC },
3286 { "implementation", RID_AT_IMPLEMENTATION, D_OBJC },
3287 { "interface", RID_AT_INTERFACE, D_OBJC },
3288 { "private", RID_AT_PRIVATE, D_OBJC },
3289 { "protected", RID_AT_PROTECTED, D_OBJC },
3290 { "protocol", RID_AT_PROTOCOL, D_OBJC },
3291 { "public", RID_AT_PUBLIC, D_OBJC },
3292 { "selector", RID_AT_SELECTOR, D_OBJC },
3293 { "throw", RID_AT_THROW, D_OBJC },
3294 { "try", RID_AT_TRY, D_OBJC },
3295 { "catch", RID_AT_CATCH, D_OBJC },
3296 { "finally", RID_AT_FINALLY, D_OBJC },
3297 { "synchronized", RID_AT_SYNCHRONIZED, D_OBJC },
3298 /* These are recognized only in protocol-qualifier context
3300 { "bycopy", RID_BYCOPY, D_OBJC },
3301 { "byref", RID_BYREF, D_OBJC },
3302 { "in", RID_IN, D_OBJC },
3303 { "inout", RID_INOUT, D_OBJC },
3304 { "oneway", RID_ONEWAY, D_OBJC },
3305 { "out", RID_OUT, D_OBJC },
3308 #define N_reswords (sizeof reswords / sizeof (struct resword))
3310 /* Table mapping from RID_* constants to yacc token numbers.
3311 Unfortunately we have to have entries for all the keywords in all
3313 static const short rid_to_yy[RID_MAX] =
3315 /* RID_STATIC */ STATIC,
3316 /* RID_UNSIGNED */ TYPESPEC,
3317 /* RID_LONG */ TYPESPEC,
3318 /* RID_CONST */ TYPE_QUAL,
3319 /* RID_EXTERN */ SCSPEC,
3320 /* RID_REGISTER */ SCSPEC,
3321 /* RID_TYPEDEF */ SCSPEC,
3322 /* RID_SHORT */ TYPESPEC,
3323 /* RID_INLINE */ SCSPEC,
3324 /* RID_VOLATILE */ TYPE_QUAL,
3325 /* RID_SIGNED */ TYPESPEC,
3326 /* RID_AUTO */ SCSPEC,
3327 /* RID_RESTRICT */ TYPE_QUAL,
3330 /* RID_COMPLEX */ TYPESPEC,
3331 /* RID_THREAD */ SCSPEC,
3335 /* RID_VIRTUAL */ 0,
3336 /* RID_EXPLICIT */ 0,
3338 /* RID_MUTABLE */ 0,
3341 /* RID_IN */ TYPE_QUAL,
3342 /* RID_OUT */ TYPE_QUAL,
3343 /* RID_INOUT */ TYPE_QUAL,
3344 /* RID_BYCOPY */ TYPE_QUAL,
3345 /* RID_BYREF */ TYPE_QUAL,
3346 /* RID_ONEWAY */ TYPE_QUAL,
3349 /* RID_INT */ TYPESPEC,
3350 /* RID_CHAR */ TYPESPEC,
3351 /* RID_FLOAT */ TYPESPEC,
3352 /* RID_DOUBLE */ TYPESPEC,
3353 /* RID_VOID */ TYPESPEC,
3354 /* RID_ENUM */ ENUM,
3355 /* RID_STRUCT */ STRUCT,
3356 /* RID_UNION */ UNION,
3358 /* RID_ELSE */ ELSE,
3359 /* RID_WHILE */ WHILE,
3362 /* RID_SWITCH */ SWITCH,
3363 /* RID_CASE */ CASE,
3364 /* RID_DEFAULT */ DEFAULT,
3365 /* RID_BREAK */ BREAK,
3366 /* RID_CONTINUE */ CONTINUE,
3367 /* RID_RETURN */ RETURN,
3368 /* RID_GOTO */ GOTO,
3369 /* RID_SIZEOF */ SIZEOF,
3372 /* RID_ASM */ ASM_KEYWORD,
3373 /* RID_TYPEOF */ TYPEOF,
3374 /* RID_ALIGNOF */ ALIGNOF,
3375 /* RID_ATTRIBUTE */ ATTRIBUTE,
3376 /* RID_VA_ARG */ VA_ARG,
3377 /* RID_EXTENSION */ EXTENSION,
3378 /* RID_IMAGPART */ IMAGPART,
3379 /* RID_REALPART */ REALPART,
3380 /* RID_LABEL */ LABEL,
3381 /* RID_PTRBASE */ PTR_BASE,
3382 /* RID_PTREXTENT */ PTR_EXTENT,
3383 /* RID_PTRVALUE */ PTR_VALUE,
3385 /* RID_CHOOSE_EXPR */ CHOOSE_EXPR,
3386 /* RID_TYPES_COMPATIBLE_P */ TYPES_COMPATIBLE_P,
3388 /* RID_FUNCTION_NAME */ FUNC_NAME,
3389 /* RID_PRETTY_FUNCTION_NAME */ FUNC_NAME,
3390 /* RID_C99_FUNCTION_NAME */ FUNC_NAME,
3393 /* RID_BOOL */ TYPESPEC,
3397 /* RID_PRIVATE */ 0,
3398 /* RID_PROTECTED */ 0,
3399 /* RID_TEMPLATE */ 0,
3404 /* RID_NAMESPACE */ 0,
3406 /* RID_OFFSETOF */ OFFSETOF,
3407 /* RID_OPERATOR */ 0,
3412 /* RID_TYPENAME */ 0,
3417 /* RID_CONSTCAST */ 0,
3418 /* RID_DYNCAST */ 0,
3419 /* RID_REINTCAST */ 0,
3420 /* RID_STATCAST */ 0,
3423 /* RID_ID */ OBJECTNAME,
3424 /* RID_AT_ENCODE */ AT_ENCODE,
3425 /* RID_AT_END */ AT_END,
3426 /* RID_AT_CLASS */ AT_CLASS,
3427 /* RID_AT_ALIAS */ AT_ALIAS,
3428 /* RID_AT_DEFS */ AT_DEFS,
3429 /* RID_AT_PRIVATE */ AT_PRIVATE,
3430 /* RID_AT_PROTECTED */ AT_PROTECTED,
3431 /* RID_AT_PUBLIC */ AT_PUBLIC,
3432 /* RID_AT_PROTOCOL */ AT_PROTOCOL,
3433 /* RID_AT_SELECTOR */ AT_SELECTOR,
3434 /* RID_AT_THROW */ AT_THROW,
3435 /* RID_AT_TRY */ AT_TRY,
3436 /* RID_AT_CATCH */ AT_CATCH,
3437 /* RID_AT_FINALLY */ AT_FINALLY,
3438 /* RID_AT_SYNCHRONIZED */ AT_SYNCHRONIZED,
3439 /* RID_AT_INTERFACE */ AT_INTERFACE,
3440 /* RID_AT_IMPLEMENTATION */ AT_IMPLEMENTATION
3444 init_reswords (void)
3448 int mask = (flag_isoc99 ? 0 : D_C89)
3449 | (flag_no_asm ? (flag_isoc99 ? D_EXT : D_EXT|D_EXT89) : 0);
3451 if (!c_dialect_objc ())
3454 ridpointers = ggc_calloc ((int) RID_MAX, sizeof (tree));
3455 for (i = 0; i < N_reswords; i++)
3457 /* If a keyword is disabled, do not enter it into the table
3458 and so create a canonical spelling that isn't a keyword. */
3459 if (reswords[i].disable & mask)
3462 id = get_identifier (reswords[i].word);
3463 C_RID_CODE (id) = reswords[i].rid;
3464 C_IS_RESERVED_WORD (id) = 1;
3465 ridpointers [(int) reswords[i].rid] = id;
3469 #define NAME(type) cpp_type2name (type)
3472 yyerror (const char *msgid)
3474 c_parse_error (msgid, last_token, yylval.ttype);
3483 int objc_force_identifier = objc_need_raw_identifier;
3484 OBJC_NEED_RAW_IDENTIFIER (0);
3487 if (C_IS_RESERVED_WORD (yylval.ttype))
3489 enum rid rid_code = C_RID_CODE (yylval.ttype);
3492 /* Turn non-typedefed refs to "id" into plain identifiers; this
3493 allows constructs like "void foo(id id);" to work. */
3494 if (rid_code == RID_ID)
3496 decl = lookup_name (yylval.ttype);
3497 if (decl == NULL_TREE || TREE_CODE (decl) != TYPE_DECL)
3501 if (!OBJC_IS_AT_KEYWORD (rid_code)
3502 && (!OBJC_IS_PQ_KEYWORD (rid_code) || objc_pq_context))
3505 /* Return the canonical spelling for this keyword. */
3506 yylval.ttype = ridpointers[(int) rid_code];
3507 return rid_to_yy[(int) rid_code];
3511 decl = lookup_name (yylval.ttype);
3514 if (TREE_CODE (decl) == TYPE_DECL)
3520 tree objc_interface_decl = is_class_name (yylval.ttype);
3521 /* ObjC class names are in the same namespace as variables and
3522 typedefs, and hence are shadowed by local declarations. */
3523 if (objc_interface_decl
3524 && (global_bindings_p ()
3525 || (!objc_force_identifier && !decl)))
3527 yylval.ttype = objc_interface_decl;
3540 last_token = c_lex (&yylval.ttype);
3543 case CPP_EQ: return '=';
3544 case CPP_NOT: return '!';
3545 case CPP_GREATER: yylval.code = GT_EXPR; return ARITHCOMPARE;
3546 case CPP_LESS: yylval.code = LT_EXPR; return ARITHCOMPARE;
3547 case CPP_PLUS: yylval.code = PLUS_EXPR; return '+';
3548 case CPP_MINUS: yylval.code = MINUS_EXPR; return '-';
3549 case CPP_MULT: yylval.code = MULT_EXPR; return '*';
3550 case CPP_DIV: yylval.code = TRUNC_DIV_EXPR; return '/';
3551 case CPP_MOD: yylval.code = TRUNC_MOD_EXPR; return '%';
3552 case CPP_AND: yylval.code = BIT_AND_EXPR; return '&';
3553 case CPP_OR: yylval.code = BIT_IOR_EXPR; return '|';
3554 case CPP_XOR: yylval.code = BIT_XOR_EXPR; return '^';
3555 case CPP_RSHIFT: yylval.code = RSHIFT_EXPR; return RSHIFT;
3556 case CPP_LSHIFT: yylval.code = LSHIFT_EXPR; return LSHIFT;
3558 case CPP_COMPL: return '~';
3559 case CPP_AND_AND: return ANDAND;
3560 case CPP_OR_OR: return OROR;
3561 case CPP_QUERY: return '?';
3562 case CPP_OPEN_PAREN: return '(';
3563 case CPP_EQ_EQ: yylval.code = EQ_EXPR; return EQCOMPARE;
3564 case CPP_NOT_EQ: yylval.code = NE_EXPR; return EQCOMPARE;
3565 case CPP_GREATER_EQ:yylval.code = GE_EXPR; return ARITHCOMPARE;
3566 case CPP_LESS_EQ: yylval.code = LE_EXPR; return ARITHCOMPARE;
3568 case CPP_PLUS_EQ: yylval.code = PLUS_EXPR; return ASSIGN;
3569 case CPP_MINUS_EQ: yylval.code = MINUS_EXPR; return ASSIGN;
3570 case CPP_MULT_EQ: yylval.code = MULT_EXPR; return ASSIGN;
3571 case CPP_DIV_EQ: yylval.code = TRUNC_DIV_EXPR; return ASSIGN;
3572 case CPP_MOD_EQ: yylval.code = TRUNC_MOD_EXPR; return ASSIGN;
3573 case CPP_AND_EQ: yylval.code = BIT_AND_EXPR; return ASSIGN;
3574 case CPP_OR_EQ: yylval.code = BIT_IOR_EXPR; return ASSIGN;
3575 case CPP_XOR_EQ: yylval.code = BIT_XOR_EXPR; return ASSIGN;
3576 case CPP_RSHIFT_EQ: yylval.code = RSHIFT_EXPR; return ASSIGN;
3577 case CPP_LSHIFT_EQ: yylval.code = LSHIFT_EXPR; return ASSIGN;
3579 case CPP_OPEN_SQUARE: return '[';
3580 case CPP_CLOSE_SQUARE: return ']';
3581 case CPP_OPEN_BRACE: return '{';
3582 case CPP_CLOSE_BRACE: return '}';
3583 case CPP_ELLIPSIS: return ELLIPSIS;
3585 case CPP_PLUS_PLUS: return PLUSPLUS;
3586 case CPP_MINUS_MINUS: return MINUSMINUS;
3587 case CPP_DEREF: return POINTSAT;
3588 case CPP_DOT: return '.';
3590 /* The following tokens may affect the interpretation of any
3591 identifiers following, if doing Objective-C. */
3592 case CPP_COLON: OBJC_NEED_RAW_IDENTIFIER (0); return ':';
3593 case CPP_COMMA: OBJC_NEED_RAW_IDENTIFIER (0); return ',';
3594 case CPP_CLOSE_PAREN: OBJC_NEED_RAW_IDENTIFIER (0); return ')';
3595 case CPP_SEMICOLON: OBJC_NEED_RAW_IDENTIFIER (0); return ';';
3601 return yylexname ();
3604 /* This only happens in Objective-C; it must be a keyword. */
3605 return rid_to_yy [(int) C_RID_CODE (yylval.ttype)];
3616 case CPP_OBJC_STRING:
3619 /* These tokens are C++ specific (and will not be generated
3620 in C mode, but let's be cautious). */
3622 case CPP_DEREF_STAR:
3628 /* These tokens should not survive translation phase 4. */
3631 error ("syntax error at '%s' token", NAME(last_token));
3644 timevar_push (TV_LEX);
3646 timevar_pop (TV_LEX);
3650 /* Function used when yydebug is set, to print a token in more detail. */
3653 yyprint (FILE *file, int yychar, YYSTYPE yyl)
3657 fprintf (file, " [%s]", NAME(last_token));
3668 if (IDENTIFIER_POINTER (t))
3669 fprintf (file, " `%s'", IDENTIFIER_POINTER (t));
3673 fprintf (file, " %s", GET_MODE_NAME (TYPE_MODE (TREE_TYPE (t))));
3674 if (TREE_CODE (t) == INTEGER_CST)
3677 fprintf (file, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
3678 TREE_INT_CST_HIGH (t), TREE_INT_CST_LOW (t));
3684 /* This is not the ideal place to put this, but we have to get it out
3685 of c-lex.c because cp/lex.c has its own version. */
3687 /* Parse the file. */
3695 free (malloced_yyss);
3696 free (malloced_yyvs);
3701 #include "gt-c-parse.h"