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; 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 expr nonnull_exprlist exprlist
188 %type <ttype> expr_no_commas cast_expr unary_expr primary STRING
189 %type <ttype> declspecs_nosc_nots_nosa_noea declspecs_nosc_nots_nosa_ea
190 %type <ttype> declspecs_nosc_nots_sa_noea declspecs_nosc_nots_sa_ea
191 %type <ttype> declspecs_nosc_ts_nosa_noea declspecs_nosc_ts_nosa_ea
192 %type <ttype> declspecs_nosc_ts_sa_noea declspecs_nosc_ts_sa_ea
193 %type <ttype> declspecs_sc_nots_nosa_noea declspecs_sc_nots_nosa_ea
194 %type <ttype> declspecs_sc_nots_sa_noea declspecs_sc_nots_sa_ea
195 %type <ttype> declspecs_sc_ts_nosa_noea declspecs_sc_ts_nosa_ea
196 %type <ttype> declspecs_sc_ts_sa_noea declspecs_sc_ts_sa_ea
197 %type <ttype> declspecs_ts declspecs_nots
198 %type <ttype> declspecs_ts_nosa declspecs_nots_nosa
199 %type <ttype> declspecs_nosc_ts declspecs_nosc_nots declspecs_nosc declspecs
200 %type <ttype> maybe_type_quals_attrs typespec_nonattr typespec_attr
201 %type <ttype> typespec_reserved_nonattr typespec_reserved_attr
202 %type <ttype> typespec_nonreserved_nonattr
203 %type <ttype> offsetof_member_designator
205 %type <ttype> scspec SCSPEC STATIC TYPESPEC TYPE_QUAL maybe_volatile
206 %type <ttype> initdecls notype_initdecls initdcl notype_initdcl init
207 %type <ttype> simple_asm_expr maybeasm asm_stmt asm_argument
208 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
209 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
210 %type <ttype> any_word
212 %type <ttype> compstmt compstmt_start compstmt_primary_start
213 %type <ttype> stmt label stmt_nocomp start_break start_continue
215 %type <ttype> c99_block_start c99_block_lineno_labeled_stmt
216 %type <ttype> if_statement_1 if_statement_2
217 %type <ttype> declarator
218 %type <ttype> notype_declarator after_type_declarator
219 %type <ttype> parm_declarator
220 %type <ttype> parm_declarator_starttypename parm_declarator_nostarttypename
221 %type <ttype> array_declarator
223 %type <ttype> structsp_attr structsp_nonattr
224 %type <ttype> component_decl_list component_decl_list2
225 %type <ttype> component_decl components components_notype component_declarator
226 %type <ttype> component_notype_declarator
227 %type <ttype> enumlist enumerator
228 %type <ttype> struct_head union_head enum_head
229 %type <ttype> typename absdcl absdcl1 absdcl1_ea absdcl1_noea
230 %type <ttype> direct_absdcl1 absdcl_maybe_attribute
231 %type <ttype> condition xexpr for_cond_expr for_incr_expr
232 %type <ttype> parms parm firstparm identifiers
234 %type <ttype> parmlist parmlist_1 parmlist_2
235 %type <ttype> parmlist_or_identifiers parmlist_or_identifiers_1
236 %type <ttype> identifiers_or_typenames
238 %type <itype> setspecs setspecs_fp extension
240 %type <location> save_location
243 /* the Objective-C nonterminals */
245 %type <ttype> ivar_decl_list ivar_decls ivar_decl ivars ivar_declarator
246 %type <ttype> methoddecl unaryselector keywordselector selector
247 %type <ttype> keyworddecl receiver objcmessageexpr messageargs
248 %type <ttype> keywordexpr keywordarglist keywordarg
249 %type <ttype> myparms myparm optparmlist reservedwords objcselectorexpr
250 %type <ttype> selectorarg keywordnamelist keywordname objcencodeexpr
251 %type <ttype> non_empty_protocolrefs protocolrefs identifier_list objcprotocolexpr
253 %type <ttype> CLASSNAME OBJECTNAME OBJC_STRING
255 %type <ttype> superclass
259 /* List of types and structure classes of the current declaration. */
260 static GTY(()) tree current_declspecs;
261 static GTY(()) tree prefix_attributes;
263 /* List of all the attributes applying to the identifier currently being
264 declared; includes prefix_attributes and possibly some more attributes
265 just after a comma. */
266 static GTY(()) tree all_prefix_attributes;
268 /* Stack of saved values of current_declspecs, prefix_attributes and
269 all_prefix_attributes. */
270 static GTY(()) tree declspec_stack;
272 /* PUSH_DECLSPEC_STACK is called from setspecs; POP_DECLSPEC_STACK
273 should be called from the productions making use of setspecs. */
274 #define PUSH_DECLSPEC_STACK \
276 declspec_stack = tree_cons (build_tree_list (prefix_attributes, \
277 all_prefix_attributes), \
282 #define POP_DECLSPEC_STACK \
284 current_declspecs = TREE_VALUE (declspec_stack); \
285 prefix_attributes = TREE_PURPOSE (TREE_PURPOSE (declspec_stack)); \
286 all_prefix_attributes = TREE_VALUE (TREE_PURPOSE (declspec_stack)); \
287 declspec_stack = TREE_CHAIN (declspec_stack); \
290 /* For __extension__, save/restore the warning flags which are
291 controlled by __extension__. */
292 #define SAVE_EXT_FLAGS() \
294 | (warn_pointer_arith << 1) \
295 | (warn_traditional << 2) \
298 #define RESTORE_EXT_FLAGS(val) \
300 pedantic = val & 1; \
301 warn_pointer_arith = (val >> 1) & 1; \
302 warn_traditional = (val >> 2) & 1; \
303 flag_iso = (val >> 3) & 1; \
307 /* Objective-C specific parser/lexer information */
309 static enum tree_code objc_inherit_code;
310 static int objc_pq_context = 0, objc_public_flag = 0;
312 /* The following flag is needed to contextualize ObjC lexical analysis.
313 In some cases (e.g., 'int NSObject;'), it is undesirable to bind
314 an identifier to an ObjC class, even if a class with that name
316 static int objc_need_raw_identifier;
317 #define OBJC_NEED_RAW_IDENTIFIER(VAL) objc_need_raw_identifier = VAL
321 #define OBJC_NEED_RAW_IDENTIFIER(VAL) /* nothing */
324 /* Tell yyparse how to print a token's value, if yydebug is set. */
326 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
328 static void yyprint (FILE *, int, YYSTYPE);
329 static void yyerror (const char *);
330 static int yylexname (void);
331 static inline int _yylex (void);
332 static int yylex (void);
333 static void init_reswords (void);
335 /* Initialisation routine for this file. */
347 pedwarn ("ISO C forbids an empty source file");
352 /* the reason for the strange actions in this rule
353 is so that notype_initdecls when reached via datadef
354 can find a valid list of type and sc specs in $0. */
357 {$<ttype>$ = NULL_TREE; } extdef
358 | extdefs {$<ttype>$ = NULL_TREE; ggc_collect(); } extdef
366 { RESTORE_EXT_FLAGS ($1); }
373 setspecs notype_initdecls ';'
375 error ("ISO C forbids data definition with no type or storage class");
377 warning ("data definition has no type or storage class");
379 POP_DECLSPEC_STACK; }
380 | declspecs_nots setspecs notype_initdecls ';'
381 { POP_DECLSPEC_STACK; }
382 | declspecs_ts setspecs initdecls ';'
383 { POP_DECLSPEC_STACK; }
390 pedwarn ("ISO C does not allow extra `;' outside of a function"); }
394 declspecs_ts setspecs declarator
395 { if (! start_function (current_declspecs, $3,
396 all_prefix_attributes))
399 old_style_parm_decls save_location
400 { DECL_SOURCE_LOCATION (current_function_decl) = $6;
401 store_parm_decls (); }
403 { finish_function ();
404 POP_DECLSPEC_STACK; }
405 | declspecs_ts setspecs declarator error
406 { POP_DECLSPEC_STACK; }
407 | declspecs_nots setspecs notype_declarator
408 { if (! start_function (current_declspecs, $3,
409 all_prefix_attributes))
412 old_style_parm_decls save_location
413 { DECL_SOURCE_LOCATION (current_function_decl) = $6;
414 store_parm_decls (); }
416 { finish_function ();
417 POP_DECLSPEC_STACK; }
418 | declspecs_nots setspecs notype_declarator error
419 { POP_DECLSPEC_STACK; }
420 | setspecs notype_declarator
421 { if (! start_function (NULL_TREE, $2,
422 all_prefix_attributes))
425 old_style_parm_decls save_location
426 { DECL_SOURCE_LOCATION (current_function_decl) = $5;
427 store_parm_decls (); }
429 { finish_function ();
430 POP_DECLSPEC_STACK; }
431 | setspecs notype_declarator error
432 { POP_DECLSPEC_STACK; }
447 { $$ = NEGATE_EXPR; }
451 if (warn_traditional && !in_system_header)
452 warning ("traditional C rejects the unary plus operator");
456 { $$ = PREINCREMENT_EXPR; }
458 { $$ = PREDECREMENT_EXPR; }
460 { $$ = BIT_NOT_EXPR; }
462 { $$ = TRUTH_NOT_EXPR; }
465 expr: nonnull_exprlist
466 { $$ = build_compound_expr ($1); }
477 { $$ = build_tree_list (NULL_TREE, $1); }
478 | nonnull_exprlist ',' expr_no_commas
479 { chainon ($1, build_tree_list (NULL_TREE, $3)); }
484 | '*' cast_expr %prec UNARY
485 { $$ = build_indirect_ref ($2, "unary *"); }
486 /* __extension__ turns off -pedantic for following primary. */
487 | extension cast_expr %prec UNARY
489 RESTORE_EXT_FLAGS ($1); }
490 | unop cast_expr %prec UNARY
491 { $$ = build_unary_op ($1, $2, 0);
492 overflow_warning ($$); }
493 /* Refer to the address of a label as a pointer. */
495 { $$ = finish_label_address_expr ($2); }
496 | sizeof unary_expr %prec UNARY
498 if (TREE_CODE ($2) == COMPONENT_REF
499 && DECL_C_BIT_FIELD (TREE_OPERAND ($2, 1)))
500 error ("`sizeof' applied to a bit-field");
501 $$ = c_sizeof (TREE_TYPE ($2)); }
502 | sizeof '(' typename ')' %prec HYPERUNARY
504 $$ = c_sizeof (groktypename ($3)); }
505 | alignof unary_expr %prec UNARY
507 $$ = c_alignof_expr ($2); }
508 | alignof '(' typename ')' %prec HYPERUNARY
510 $$ = c_alignof (groktypename ($3)); }
511 | REALPART cast_expr %prec UNARY
512 { $$ = build_unary_op (REALPART_EXPR, $2, 0); }
513 | IMAGPART cast_expr %prec UNARY
514 { $$ = build_unary_op (IMAGPART_EXPR, $2, 0); }
518 SIZEOF { skip_evaluation++; }
522 ALIGNOF { skip_evaluation++; }
526 TYPEOF { skip_evaluation++; }
531 | '(' typename ')' cast_expr %prec UNARY
532 { $$ = c_cast_expr ($2, $4); }
537 | expr_no_commas '+' expr_no_commas
538 { $$ = parser_build_binary_op ($2, $1, $3); }
539 | expr_no_commas '-' expr_no_commas
540 { $$ = parser_build_binary_op ($2, $1, $3); }
541 | expr_no_commas '*' expr_no_commas
542 { $$ = parser_build_binary_op ($2, $1, $3); }
543 | expr_no_commas '/' expr_no_commas
544 { $$ = parser_build_binary_op ($2, $1, $3); }
545 | expr_no_commas '%' expr_no_commas
546 { $$ = parser_build_binary_op ($2, $1, $3); }
547 | expr_no_commas LSHIFT expr_no_commas
548 { $$ = parser_build_binary_op ($2, $1, $3); }
549 | expr_no_commas RSHIFT expr_no_commas
550 { $$ = parser_build_binary_op ($2, $1, $3); }
551 | expr_no_commas ARITHCOMPARE expr_no_commas
552 { $$ = parser_build_binary_op ($2, $1, $3); }
553 | expr_no_commas EQCOMPARE 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 ANDAND
562 { $1 = lang_hooks.truthvalue_conversion
563 (default_conversion ($1));
564 skip_evaluation += $1 == truthvalue_false_node; }
566 { skip_evaluation -= $1 == truthvalue_false_node;
567 $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $4); }
568 | expr_no_commas OROR
569 { $1 = lang_hooks.truthvalue_conversion
570 (default_conversion ($1));
571 skip_evaluation += $1 == truthvalue_true_node; }
573 { skip_evaluation -= $1 == truthvalue_true_node;
574 $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $4); }
576 { $1 = lang_hooks.truthvalue_conversion
577 (default_conversion ($1));
578 skip_evaluation += $1 == truthvalue_false_node; }
580 { skip_evaluation += (($1 == truthvalue_true_node)
581 - ($1 == truthvalue_false_node)); }
583 { skip_evaluation -= $1 == truthvalue_true_node;
584 $$ = build_conditional_expr ($1, $4, $7); }
587 pedwarn ("ISO C forbids omitting the middle term of a ?: expression");
588 /* Make sure first operand is calculated only once. */
589 $<ttype>2 = save_expr (default_conversion ($1));
590 $1 = lang_hooks.truthvalue_conversion ($<ttype>2);
591 skip_evaluation += $1 == truthvalue_true_node; }
593 { skip_evaluation -= $1 == truthvalue_true_node;
594 $$ = build_conditional_expr ($1, $<ttype>2, $5); }
595 | expr_no_commas '=' expr_no_commas
597 $$ = build_modify_expr ($1, NOP_EXPR, $3);
598 class = TREE_CODE_CLASS (TREE_CODE ($$));
599 if (IS_EXPR_CODE_CLASS (class))
600 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR);
602 | expr_no_commas ASSIGN expr_no_commas
604 $$ = build_modify_expr ($1, $2, $3);
605 /* This inhibits warnings in
606 c_common_truthvalue_conversion. */
607 class = TREE_CODE_CLASS (TREE_CODE ($$));
608 if (IS_EXPR_CODE_CLASS (class))
609 C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK);
616 if (yychar == YYEMPTY)
618 $$ = build_external_ref ($1, yychar == '(');
623 { $$ = fname_decl (C_RID_CODE ($$), $$); }
624 | '(' typename ')' '{'
625 { start_init (NULL_TREE, NULL, 0);
626 $2 = groktypename ($2);
627 really_start_incremental_init ($2); }
628 initlist_maybe_comma '}' %prec UNARY
629 { tree constructor = pop_init_level (0);
633 if (pedantic && ! flag_isoc99)
634 pedwarn ("ISO C90 forbids compound literals");
635 $$ = build_compound_literal (type, constructor);
638 { char class = TREE_CODE_CLASS (TREE_CODE ($2));
639 if (IS_EXPR_CODE_CLASS (class))
640 C_SET_EXP_ORIGINAL_CODE ($2, ERROR_MARK);
643 { $$ = error_mark_node; }
644 | compstmt_primary_start compstmt_nostart ')'
646 pedwarn ("ISO C forbids braced-groups within expressions");
647 $$ = c_finish_stmt_expr ($1);
649 | compstmt_primary_start error ')'
650 { c_finish_stmt_expr ($1);
651 $$ = error_mark_node;
653 | primary '(' exprlist ')' %prec '.'
654 { $$ = build_function_call ($1, $3); }
655 | VA_ARG '(' expr_no_commas ',' typename ')'
656 { $$ = build_va_arg ($3, groktypename ($5)); }
658 | OFFSETOF '(' typename ',' offsetof_member_designator ')'
659 { $$ = build_offsetof (groktypename ($3), $5); }
660 | OFFSETOF '(' error ')'
661 { $$ = error_mark_node; }
662 | CHOOSE_EXPR '(' expr_no_commas ',' expr_no_commas ','
669 if (TREE_CODE (c) != INTEGER_CST)
670 error ("first argument to __builtin_choose_expr not"
672 $$ = integer_zerop (c) ? $7 : $5;
674 | CHOOSE_EXPR '(' error ')'
675 { $$ = error_mark_node; }
676 | TYPES_COMPATIBLE_P '(' typename ',' typename ')'
680 e1 = TYPE_MAIN_VARIANT (groktypename ($3));
681 e2 = TYPE_MAIN_VARIANT (groktypename ($5));
683 $$ = comptypes (e1, e2)
684 ? build_int_2 (1, 0) : build_int_2 (0, 0);
686 | TYPES_COMPATIBLE_P '(' error ')'
687 { $$ = error_mark_node; }
688 | primary '[' expr ']' %prec '.'
689 { $$ = build_array_ref ($1, $3); }
690 | primary '.' identifier
691 { $$ = build_component_ref ($1, $3); }
692 | primary POINTSAT identifier
694 tree expr = build_indirect_ref ($1, "->");
695 $$ = build_component_ref (expr, $3);
698 { $$ = build_unary_op (POSTINCREMENT_EXPR, $1, 0); }
700 { $$ = build_unary_op (POSTDECREMENT_EXPR, $1, 0); }
703 { $$ = build_message_expr ($1); }
705 { $$ = build_selector_expr ($1); }
707 { $$ = build_protocol_expr ($1); }
709 { $$ = build_encode_expr ($1); }
711 { $$ = build_objc_string_object ($1); }
715 /* This is the second argument to __builtin_offsetof. We must have one
716 identifier, and beyond that we want to accept sub structure and sub
717 array references. We return tree list where each element has
718 PURPOSE set for component refs or VALUE set for array refs. We'll
719 turn this into something real inside build_offsetof. */
721 offsetof_member_designator:
723 { $$ = tree_cons ($1, NULL_TREE, NULL_TREE); }
724 | offsetof_member_designator '.' identifier
725 { $$ = tree_cons ($3, NULL_TREE, $1); }
726 | offsetof_member_designator '[' expr ']'
727 { $$ = tree_cons (NULL_TREE, $3, $1); }
730 old_style_parm_decls:
735 /* The following are analogous to lineno_decl, decls and decl
736 except that they do not allow nested functions.
737 They are used for old-style parm decls. */
739 save_location datadecl
746 | datadecls lineno_datadecl
747 | lineno_datadecl errstmt
750 /* We don't allow prefix attributes here because they cause reduce/reduce
751 conflicts: we can't know whether we're parsing a function decl with
752 attribute suffix, or function defn with attribute prefix on first old
755 declspecs_ts_nosa setspecs initdecls ';'
756 { POP_DECLSPEC_STACK; }
757 | declspecs_nots_nosa setspecs notype_initdecls ';'
758 { POP_DECLSPEC_STACK; }
759 | declspecs_ts_nosa ';'
760 { shadow_tag_warned ($1, 1);
761 pedwarn ("empty declaration"); }
762 | declspecs_nots_nosa ';'
763 { pedwarn ("empty declaration"); }
766 /* This combination which saves a lineno before a decl
767 is the normal thing to use, rather than decl itself.
768 This is to avoid shift/reduce conflicts in contexts
769 where statement labels are allowed. */
775 /* records the type and storage class specs to use for processing
776 the declarators that follow.
777 Maintains a stack of outer-level values of current_declspecs,
778 for the sake of parm declarations nested in function declarators. */
779 setspecs: /* empty */
780 { pending_xref_error ();
782 split_specs_attrs ($<ttype>0,
783 ¤t_declspecs, &prefix_attributes);
784 all_prefix_attributes = prefix_attributes; }
787 /* Possibly attributes after a comma, which should reset all_prefix_attributes
788 to prefix_attributes with these ones chained on the front. */
791 { all_prefix_attributes = chainon ($1, prefix_attributes); }
795 declspecs_ts setspecs initdecls ';'
796 { POP_DECLSPEC_STACK; }
797 | declspecs_nots setspecs notype_initdecls ';'
798 { POP_DECLSPEC_STACK; }
799 | declspecs_ts setspecs nested_function
800 { POP_DECLSPEC_STACK; }
801 | declspecs_nots setspecs notype_nested_function
802 { POP_DECLSPEC_STACK; }
806 { RESTORE_EXT_FLAGS ($1); }
809 /* A list of declaration specifiers. These are:
811 - Storage class specifiers (scspec), which for GCC currently includes
812 function specifiers ("inline").
814 - Type specifiers (typespec_*).
816 - Type qualifiers (TYPE_QUAL).
818 - Attribute specifier lists (attributes).
820 These are stored as a TREE_LIST; the head of the list is the last
821 item in the specifier list. Each entry in the list has either a
822 TREE_PURPOSE that is an attribute specifier list, or a TREE_VALUE that
823 is a single other specifier or qualifier; and a TREE_CHAIN that is the
824 rest of the list. TREE_STATIC is set on the list if something other
825 than a storage class specifier or attribute has been seen; this is used
826 to warn for the obsolescent usage of storage class specifiers other than
827 at the start of the list. (Doing this properly would require function
828 specifiers to be handled separately from storage class specifiers.)
830 The various cases below are classified according to:
832 (a) Whether a storage class specifier is included or not; some
833 places in the grammar disallow storage class specifiers (_sc or _nosc).
835 (b) Whether a type specifier has been seen; after a type specifier,
836 a typedef name is an identifier to redeclare (_ts or _nots).
838 (c) Whether the list starts with an attribute; in certain places,
839 the grammar requires specifiers that don't start with an attribute
842 (d) Whether the list ends with an attribute (or a specifier such that
843 any following attribute would have been parsed as part of that specifier);
844 this avoids shift-reduce conflicts in the parsing of attributes
849 (i) Distinguish between function specifiers and storage class specifiers,
850 at least for the purpose of warnings about obsolescent usage.
852 (ii) Halve the number of productions here by eliminating the _sc/_nosc
853 distinction and instead checking where required that storage class
854 specifiers aren't present. */
856 /* Declspecs which contain at least one type specifier or typedef name.
857 (Just `const' or `volatile' is not enough.)
858 A typedef'd name following these is taken as a name to be declared.
859 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
861 declspecs_nosc_nots_nosa_noea:
863 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
864 TREE_STATIC ($$) = 1; }
865 | declspecs_nosc_nots_nosa_noea TYPE_QUAL
866 { $$ = tree_cons (NULL_TREE, $2, $1);
867 TREE_STATIC ($$) = 1; }
868 | declspecs_nosc_nots_nosa_ea TYPE_QUAL
869 { $$ = tree_cons (NULL_TREE, $2, $1);
870 TREE_STATIC ($$) = 1; }
873 declspecs_nosc_nots_nosa_ea:
874 declspecs_nosc_nots_nosa_noea attributes
875 { $$ = tree_cons ($2, NULL_TREE, $1);
876 TREE_STATIC ($$) = TREE_STATIC ($1); }
879 declspecs_nosc_nots_sa_noea:
880 declspecs_nosc_nots_sa_noea TYPE_QUAL
881 { $$ = tree_cons (NULL_TREE, $2, $1);
882 TREE_STATIC ($$) = 1; }
883 | declspecs_nosc_nots_sa_ea TYPE_QUAL
884 { $$ = tree_cons (NULL_TREE, $2, $1);
885 TREE_STATIC ($$) = 1; }
888 declspecs_nosc_nots_sa_ea:
890 { $$ = tree_cons ($1, NULL_TREE, NULL_TREE);
891 TREE_STATIC ($$) = 0; }
892 | declspecs_nosc_nots_sa_noea attributes
893 { $$ = tree_cons ($2, NULL_TREE, $1);
894 TREE_STATIC ($$) = TREE_STATIC ($1); }
897 declspecs_nosc_ts_nosa_noea:
899 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
900 TREE_STATIC ($$) = 1; }
901 | declspecs_nosc_ts_nosa_noea TYPE_QUAL
902 { $$ = tree_cons (NULL_TREE, $2, $1);
903 TREE_STATIC ($$) = 1; }
904 | declspecs_nosc_ts_nosa_ea TYPE_QUAL
905 { $$ = tree_cons (NULL_TREE, $2, $1);
906 TREE_STATIC ($$) = 1; }
907 | declspecs_nosc_ts_nosa_noea typespec_reserved_nonattr
908 { $$ = tree_cons (NULL_TREE, $2, $1);
909 TREE_STATIC ($$) = 1; }
910 | declspecs_nosc_ts_nosa_ea typespec_reserved_nonattr
911 { $$ = tree_cons (NULL_TREE, $2, $1);
912 TREE_STATIC ($$) = 1; }
913 | declspecs_nosc_nots_nosa_noea typespec_nonattr
914 { $$ = tree_cons (NULL_TREE, $2, $1);
915 TREE_STATIC ($$) = 1; }
916 | declspecs_nosc_nots_nosa_ea typespec_nonattr
917 { $$ = tree_cons (NULL_TREE, $2, $1);
918 TREE_STATIC ($$) = 1; }
921 declspecs_nosc_ts_nosa_ea:
923 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
924 TREE_STATIC ($$) = 1; }
925 | declspecs_nosc_ts_nosa_noea attributes
926 { $$ = tree_cons ($2, NULL_TREE, $1);
927 TREE_STATIC ($$) = TREE_STATIC ($1); }
928 | declspecs_nosc_ts_nosa_noea typespec_reserved_attr
929 { $$ = tree_cons (NULL_TREE, $2, $1);
930 TREE_STATIC ($$) = 1; }
931 | declspecs_nosc_ts_nosa_ea typespec_reserved_attr
932 { $$ = tree_cons (NULL_TREE, $2, $1);
933 TREE_STATIC ($$) = 1; }
934 | declspecs_nosc_nots_nosa_noea typespec_attr
935 { $$ = tree_cons (NULL_TREE, $2, $1);
936 TREE_STATIC ($$) = 1; }
937 | declspecs_nosc_nots_nosa_ea typespec_attr
938 { $$ = tree_cons (NULL_TREE, $2, $1);
939 TREE_STATIC ($$) = 1; }
942 declspecs_nosc_ts_sa_noea:
943 declspecs_nosc_ts_sa_noea TYPE_QUAL
944 { $$ = tree_cons (NULL_TREE, $2, $1);
945 TREE_STATIC ($$) = 1; }
946 | declspecs_nosc_ts_sa_ea TYPE_QUAL
947 { $$ = tree_cons (NULL_TREE, $2, $1);
948 TREE_STATIC ($$) = 1; }
949 | declspecs_nosc_ts_sa_noea typespec_reserved_nonattr
950 { $$ = tree_cons (NULL_TREE, $2, $1);
951 TREE_STATIC ($$) = 1; }
952 | declspecs_nosc_ts_sa_ea typespec_reserved_nonattr
953 { $$ = tree_cons (NULL_TREE, $2, $1);
954 TREE_STATIC ($$) = 1; }
955 | declspecs_nosc_nots_sa_noea typespec_nonattr
956 { $$ = tree_cons (NULL_TREE, $2, $1);
957 TREE_STATIC ($$) = 1; }
958 | declspecs_nosc_nots_sa_ea typespec_nonattr
959 { $$ = tree_cons (NULL_TREE, $2, $1);
960 TREE_STATIC ($$) = 1; }
963 declspecs_nosc_ts_sa_ea:
964 declspecs_nosc_ts_sa_noea attributes
965 { $$ = tree_cons ($2, NULL_TREE, $1);
966 TREE_STATIC ($$) = TREE_STATIC ($1); }
967 | declspecs_nosc_ts_sa_noea typespec_reserved_attr
968 { $$ = tree_cons (NULL_TREE, $2, $1);
969 TREE_STATIC ($$) = 1; }
970 | declspecs_nosc_ts_sa_ea typespec_reserved_attr
971 { $$ = tree_cons (NULL_TREE, $2, $1);
972 TREE_STATIC ($$) = 1; }
973 | declspecs_nosc_nots_sa_noea typespec_attr
974 { $$ = tree_cons (NULL_TREE, $2, $1);
975 TREE_STATIC ($$) = 1; }
976 | declspecs_nosc_nots_sa_ea typespec_attr
977 { $$ = tree_cons (NULL_TREE, $2, $1);
978 TREE_STATIC ($$) = 1; }
981 declspecs_sc_nots_nosa_noea:
983 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
984 TREE_STATIC ($$) = 0; }
985 | declspecs_sc_nots_nosa_noea TYPE_QUAL
986 { $$ = tree_cons (NULL_TREE, $2, $1);
987 TREE_STATIC ($$) = 1; }
988 | declspecs_sc_nots_nosa_ea TYPE_QUAL
989 { $$ = tree_cons (NULL_TREE, $2, $1);
990 TREE_STATIC ($$) = 1; }
991 | declspecs_nosc_nots_nosa_noea scspec
992 { if (extra_warnings && TREE_STATIC ($1))
993 warning ("`%s' is not at beginning of declaration",
994 IDENTIFIER_POINTER ($2));
995 $$ = tree_cons (NULL_TREE, $2, $1);
996 TREE_STATIC ($$) = TREE_STATIC ($1); }
997 | declspecs_nosc_nots_nosa_ea scspec
998 { if (extra_warnings && TREE_STATIC ($1))
999 warning ("`%s' is not at beginning of declaration",
1000 IDENTIFIER_POINTER ($2));
1001 $$ = tree_cons (NULL_TREE, $2, $1);
1002 TREE_STATIC ($$) = TREE_STATIC ($1); }
1003 | declspecs_sc_nots_nosa_noea scspec
1004 { if (extra_warnings && TREE_STATIC ($1))
1005 warning ("`%s' is not at beginning of declaration",
1006 IDENTIFIER_POINTER ($2));
1007 $$ = tree_cons (NULL_TREE, $2, $1);
1008 TREE_STATIC ($$) = TREE_STATIC ($1); }
1009 | declspecs_sc_nots_nosa_ea scspec
1010 { if (extra_warnings && TREE_STATIC ($1))
1011 warning ("`%s' is not at beginning of declaration",
1012 IDENTIFIER_POINTER ($2));
1013 $$ = tree_cons (NULL_TREE, $2, $1);
1014 TREE_STATIC ($$) = TREE_STATIC ($1); }
1017 declspecs_sc_nots_nosa_ea:
1018 declspecs_sc_nots_nosa_noea attributes
1019 { $$ = tree_cons ($2, NULL_TREE, $1);
1020 TREE_STATIC ($$) = TREE_STATIC ($1); }
1023 declspecs_sc_nots_sa_noea:
1024 declspecs_sc_nots_sa_noea TYPE_QUAL
1025 { $$ = tree_cons (NULL_TREE, $2, $1);
1026 TREE_STATIC ($$) = 1; }
1027 | declspecs_sc_nots_sa_ea TYPE_QUAL
1028 { $$ = tree_cons (NULL_TREE, $2, $1);
1029 TREE_STATIC ($$) = 1; }
1030 | declspecs_nosc_nots_sa_noea scspec
1031 { if (extra_warnings && TREE_STATIC ($1))
1032 warning ("`%s' is not at beginning of declaration",
1033 IDENTIFIER_POINTER ($2));
1034 $$ = tree_cons (NULL_TREE, $2, $1);
1035 TREE_STATIC ($$) = TREE_STATIC ($1); }
1036 | declspecs_nosc_nots_sa_ea scspec
1037 { if (extra_warnings && TREE_STATIC ($1))
1038 warning ("`%s' is not at beginning of declaration",
1039 IDENTIFIER_POINTER ($2));
1040 $$ = tree_cons (NULL_TREE, $2, $1);
1041 TREE_STATIC ($$) = TREE_STATIC ($1); }
1042 | declspecs_sc_nots_sa_noea scspec
1043 { if (extra_warnings && TREE_STATIC ($1))
1044 warning ("`%s' is not at beginning of declaration",
1045 IDENTIFIER_POINTER ($2));
1046 $$ = tree_cons (NULL_TREE, $2, $1);
1047 TREE_STATIC ($$) = TREE_STATIC ($1); }
1048 | declspecs_sc_nots_sa_ea scspec
1049 { if (extra_warnings && TREE_STATIC ($1))
1050 warning ("`%s' is not at beginning of declaration",
1051 IDENTIFIER_POINTER ($2));
1052 $$ = tree_cons (NULL_TREE, $2, $1);
1053 TREE_STATIC ($$) = TREE_STATIC ($1); }
1056 declspecs_sc_nots_sa_ea:
1057 declspecs_sc_nots_sa_noea attributes
1058 { $$ = tree_cons ($2, NULL_TREE, $1);
1059 TREE_STATIC ($$) = TREE_STATIC ($1); }
1062 declspecs_sc_ts_nosa_noea:
1063 declspecs_sc_ts_nosa_noea TYPE_QUAL
1064 { $$ = tree_cons (NULL_TREE, $2, $1);
1065 TREE_STATIC ($$) = 1; }
1066 | declspecs_sc_ts_nosa_ea TYPE_QUAL
1067 { $$ = tree_cons (NULL_TREE, $2, $1);
1068 TREE_STATIC ($$) = 1; }
1069 | declspecs_sc_ts_nosa_noea typespec_reserved_nonattr
1070 { $$ = tree_cons (NULL_TREE, $2, $1);
1071 TREE_STATIC ($$) = 1; }
1072 | declspecs_sc_ts_nosa_ea typespec_reserved_nonattr
1073 { $$ = tree_cons (NULL_TREE, $2, $1);
1074 TREE_STATIC ($$) = 1; }
1075 | declspecs_sc_nots_nosa_noea typespec_nonattr
1076 { $$ = tree_cons (NULL_TREE, $2, $1);
1077 TREE_STATIC ($$) = 1; }
1078 | declspecs_sc_nots_nosa_ea typespec_nonattr
1079 { $$ = tree_cons (NULL_TREE, $2, $1);
1080 TREE_STATIC ($$) = 1; }
1081 | declspecs_nosc_ts_nosa_noea scspec
1082 { if (extra_warnings && TREE_STATIC ($1))
1083 warning ("`%s' is not at beginning of declaration",
1084 IDENTIFIER_POINTER ($2));
1085 $$ = tree_cons (NULL_TREE, $2, $1);
1086 TREE_STATIC ($$) = TREE_STATIC ($1); }
1087 | declspecs_nosc_ts_nosa_ea scspec
1088 { if (extra_warnings && TREE_STATIC ($1))
1089 warning ("`%s' is not at beginning of declaration",
1090 IDENTIFIER_POINTER ($2));
1091 $$ = tree_cons (NULL_TREE, $2, $1);
1092 TREE_STATIC ($$) = TREE_STATIC ($1); }
1093 | declspecs_sc_ts_nosa_noea scspec
1094 { if (extra_warnings && TREE_STATIC ($1))
1095 warning ("`%s' is not at beginning of declaration",
1096 IDENTIFIER_POINTER ($2));
1097 $$ = tree_cons (NULL_TREE, $2, $1);
1098 TREE_STATIC ($$) = TREE_STATIC ($1); }
1099 | declspecs_sc_ts_nosa_ea scspec
1100 { if (extra_warnings && TREE_STATIC ($1))
1101 warning ("`%s' is not at beginning of declaration",
1102 IDENTIFIER_POINTER ($2));
1103 $$ = tree_cons (NULL_TREE, $2, $1);
1104 TREE_STATIC ($$) = TREE_STATIC ($1); }
1107 declspecs_sc_ts_nosa_ea:
1108 declspecs_sc_ts_nosa_noea attributes
1109 { $$ = tree_cons ($2, NULL_TREE, $1);
1110 TREE_STATIC ($$) = TREE_STATIC ($1); }
1111 | declspecs_sc_ts_nosa_noea typespec_reserved_attr
1112 { $$ = tree_cons (NULL_TREE, $2, $1);
1113 TREE_STATIC ($$) = 1; }
1114 | declspecs_sc_ts_nosa_ea typespec_reserved_attr
1115 { $$ = tree_cons (NULL_TREE, $2, $1);
1116 TREE_STATIC ($$) = 1; }
1117 | declspecs_sc_nots_nosa_noea typespec_attr
1118 { $$ = tree_cons (NULL_TREE, $2, $1);
1119 TREE_STATIC ($$) = 1; }
1120 | declspecs_sc_nots_nosa_ea typespec_attr
1121 { $$ = tree_cons (NULL_TREE, $2, $1);
1122 TREE_STATIC ($$) = 1; }
1125 declspecs_sc_ts_sa_noea:
1126 declspecs_sc_ts_sa_noea TYPE_QUAL
1127 { $$ = tree_cons (NULL_TREE, $2, $1);
1128 TREE_STATIC ($$) = 1; }
1129 | declspecs_sc_ts_sa_ea TYPE_QUAL
1130 { $$ = tree_cons (NULL_TREE, $2, $1);
1131 TREE_STATIC ($$) = 1; }
1132 | declspecs_sc_ts_sa_noea typespec_reserved_nonattr
1133 { $$ = tree_cons (NULL_TREE, $2, $1);
1134 TREE_STATIC ($$) = 1; }
1135 | declspecs_sc_ts_sa_ea typespec_reserved_nonattr
1136 { $$ = tree_cons (NULL_TREE, $2, $1);
1137 TREE_STATIC ($$) = 1; }
1138 | declspecs_sc_nots_sa_noea typespec_nonattr
1139 { $$ = tree_cons (NULL_TREE, $2, $1);
1140 TREE_STATIC ($$) = 1; }
1141 | declspecs_sc_nots_sa_ea typespec_nonattr
1142 { $$ = tree_cons (NULL_TREE, $2, $1);
1143 TREE_STATIC ($$) = 1; }
1144 | declspecs_nosc_ts_sa_noea scspec
1145 { if (extra_warnings && TREE_STATIC ($1))
1146 warning ("`%s' is not at beginning of declaration",
1147 IDENTIFIER_POINTER ($2));
1148 $$ = tree_cons (NULL_TREE, $2, $1);
1149 TREE_STATIC ($$) = TREE_STATIC ($1); }
1150 | declspecs_nosc_ts_sa_ea scspec
1151 { if (extra_warnings && TREE_STATIC ($1))
1152 warning ("`%s' is not at beginning of declaration",
1153 IDENTIFIER_POINTER ($2));
1154 $$ = tree_cons (NULL_TREE, $2, $1);
1155 TREE_STATIC ($$) = TREE_STATIC ($1); }
1156 | declspecs_sc_ts_sa_noea scspec
1157 { if (extra_warnings && TREE_STATIC ($1))
1158 warning ("`%s' is not at beginning of declaration",
1159 IDENTIFIER_POINTER ($2));
1160 $$ = tree_cons (NULL_TREE, $2, $1);
1161 TREE_STATIC ($$) = TREE_STATIC ($1); }
1162 | declspecs_sc_ts_sa_ea scspec
1163 { if (extra_warnings && TREE_STATIC ($1))
1164 warning ("`%s' is not at beginning of declaration",
1165 IDENTIFIER_POINTER ($2));
1166 $$ = tree_cons (NULL_TREE, $2, $1);
1167 TREE_STATIC ($$) = TREE_STATIC ($1); }
1170 declspecs_sc_ts_sa_ea:
1171 declspecs_sc_ts_sa_noea attributes
1172 { $$ = tree_cons ($2, NULL_TREE, $1);
1173 TREE_STATIC ($$) = TREE_STATIC ($1); }
1174 | declspecs_sc_ts_sa_noea typespec_reserved_attr
1175 { $$ = tree_cons (NULL_TREE, $2, $1);
1176 TREE_STATIC ($$) = 1; }
1177 | declspecs_sc_ts_sa_ea typespec_reserved_attr
1178 { $$ = tree_cons (NULL_TREE, $2, $1);
1179 TREE_STATIC ($$) = 1; }
1180 | declspecs_sc_nots_sa_noea typespec_attr
1181 { $$ = tree_cons (NULL_TREE, $2, $1);
1182 TREE_STATIC ($$) = 1; }
1183 | declspecs_sc_nots_sa_ea typespec_attr
1184 { $$ = tree_cons (NULL_TREE, $2, $1);
1185 TREE_STATIC ($$) = 1; }
1188 /* Particular useful classes of declspecs. */
1190 declspecs_nosc_ts_nosa_noea
1191 | declspecs_nosc_ts_nosa_ea
1192 | declspecs_nosc_ts_sa_noea
1193 | declspecs_nosc_ts_sa_ea
1194 | declspecs_sc_ts_nosa_noea
1195 | declspecs_sc_ts_nosa_ea
1196 | declspecs_sc_ts_sa_noea
1197 | declspecs_sc_ts_sa_ea
1201 declspecs_nosc_nots_nosa_noea
1202 | declspecs_nosc_nots_nosa_ea
1203 | declspecs_nosc_nots_sa_noea
1204 | declspecs_nosc_nots_sa_ea
1205 | declspecs_sc_nots_nosa_noea
1206 | declspecs_sc_nots_nosa_ea
1207 | declspecs_sc_nots_sa_noea
1208 | declspecs_sc_nots_sa_ea
1212 declspecs_nosc_ts_nosa_noea
1213 | declspecs_nosc_ts_nosa_ea
1214 | declspecs_sc_ts_nosa_noea
1215 | declspecs_sc_ts_nosa_ea
1218 declspecs_nots_nosa:
1219 declspecs_nosc_nots_nosa_noea
1220 | declspecs_nosc_nots_nosa_ea
1221 | declspecs_sc_nots_nosa_noea
1222 | declspecs_sc_nots_nosa_ea
1226 declspecs_nosc_ts_nosa_noea
1227 | declspecs_nosc_ts_nosa_ea
1228 | declspecs_nosc_ts_sa_noea
1229 | declspecs_nosc_ts_sa_ea
1232 declspecs_nosc_nots:
1233 declspecs_nosc_nots_nosa_noea
1234 | declspecs_nosc_nots_nosa_ea
1235 | declspecs_nosc_nots_sa_noea
1236 | declspecs_nosc_nots_sa_ea
1240 declspecs_nosc_ts_nosa_noea
1241 | declspecs_nosc_ts_nosa_ea
1242 | declspecs_nosc_ts_sa_noea
1243 | declspecs_nosc_ts_sa_ea
1244 | declspecs_nosc_nots_nosa_noea
1245 | declspecs_nosc_nots_nosa_ea
1246 | declspecs_nosc_nots_sa_noea
1247 | declspecs_nosc_nots_sa_ea
1251 declspecs_nosc_nots_nosa_noea
1252 | declspecs_nosc_nots_nosa_ea
1253 | declspecs_nosc_nots_sa_noea
1254 | declspecs_nosc_nots_sa_ea
1255 | declspecs_nosc_ts_nosa_noea
1256 | declspecs_nosc_ts_nosa_ea
1257 | declspecs_nosc_ts_sa_noea
1258 | declspecs_nosc_ts_sa_ea
1259 | declspecs_sc_nots_nosa_noea
1260 | declspecs_sc_nots_nosa_ea
1261 | declspecs_sc_nots_sa_noea
1262 | declspecs_sc_nots_sa_ea
1263 | declspecs_sc_ts_nosa_noea
1264 | declspecs_sc_ts_nosa_ea
1265 | declspecs_sc_ts_sa_noea
1266 | declspecs_sc_ts_sa_ea
1269 /* A (possibly empty) sequence of type qualifiers and attributes. */
1270 maybe_type_quals_attrs:
1273 | declspecs_nosc_nots
1277 /* A type specifier (but not a type qualifier).
1278 Once we have seen one of these in a declaration,
1279 if a typedef name appears then it is being redeclared.
1281 The _reserved versions start with a reserved word and may appear anywhere
1282 in the declaration specifiers; the _nonreserved versions may only
1283 appear before any other type specifiers, and after that are (if names)
1286 FIXME: should the _nonreserved version be restricted to names being
1287 redeclared only? The other entries there relate only the GNU extensions
1288 and Objective C, and are historically parsed thus, and don't make sense
1289 after other type specifiers, but it might be cleaner to count them as
1292 _attr means: specifiers that either end with attributes,
1293 or are such that any following attributes would
1294 be parsed as part of the specifier.
1296 _nonattr: specifiers. */
1299 typespec_reserved_nonattr
1300 | typespec_nonreserved_nonattr
1304 typespec_reserved_attr
1307 typespec_reserved_nonattr:
1309 { OBJC_NEED_RAW_IDENTIFIER (1); }
1313 typespec_reserved_attr:
1317 typespec_nonreserved_nonattr:
1319 { /* For a typedef name, record the meaning, not the name.
1320 In case of `foo foo, bar;'. */
1321 $$ = lookup_name ($1); }
1323 | CLASSNAME protocolrefs
1324 { $$ = get_static_reference ($1, $2); }
1325 | OBJECTNAME protocolrefs
1326 { $$ = get_protocol_reference ($2); }
1328 /* Make "<SomeProtocol>" equivalent to "id <SomeProtocol>"
1329 - nisse@lysator.liu.se */
1330 | non_empty_protocolrefs
1331 { $$ = get_protocol_reference ($1); }
1333 | typeof '(' expr ')'
1334 { skip_evaluation--;
1335 if (TREE_CODE ($3) == COMPONENT_REF
1336 && DECL_C_BIT_FIELD (TREE_OPERAND ($3, 1)))
1337 error ("`typeof' applied to a bit-field");
1338 $$ = TREE_TYPE ($3); }
1339 | typeof '(' typename ')'
1340 { skip_evaluation--; $$ = groktypename ($3); }
1343 /* typespec_nonreserved_attr does not exist. */
1347 | initdecls ',' maybe_resetattrs initdcl
1352 | notype_initdecls ',' maybe_resetattrs notype_initdcl
1356 declarator maybeasm maybe_attribute '='
1357 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1358 chainon ($3, all_prefix_attributes));
1359 start_init ($<ttype>$, $2, global_bindings_p ()); }
1361 /* Note how the declaration of the variable is in effect while its init is parsed! */
1363 finish_decl ($<ttype>5, $6, $2); }
1364 | declarator maybeasm maybe_attribute
1365 { tree d = start_decl ($1, current_declspecs, 0,
1366 chainon ($3, all_prefix_attributes));
1367 finish_decl (d, NULL_TREE, $2);
1372 notype_declarator maybeasm maybe_attribute '='
1373 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1374 chainon ($3, all_prefix_attributes));
1375 start_init ($<ttype>$, $2, global_bindings_p ()); }
1377 /* Note how the declaration of the variable is in effect while its init is parsed! */
1379 finish_decl ($<ttype>5, $6, $2); }
1380 | notype_declarator maybeasm maybe_attribute
1381 { tree d = start_decl ($1, current_declspecs, 0,
1382 chainon ($3, all_prefix_attributes));
1383 finish_decl (d, NULL_TREE, $2); }
1385 /* the * rules are dummies to accept the Apollo extended syntax
1386 so that the header files compile. */
1397 | attributes attribute
1398 { $$ = chainon ($1, $2); }
1402 ATTRIBUTE stop_string_translation
1403 '(' '(' attribute_list ')' ')' start_string_translation
1405 | ATTRIBUTE error start_string_translation
1412 | attribute_list ',' attrib
1413 { $$ = chainon ($1, $3); }
1420 { $$ = build_tree_list ($1, NULL_TREE); }
1421 | any_word '(' IDENTIFIER ')'
1422 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1423 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1424 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1425 | any_word '(' exprlist ')'
1426 { $$ = build_tree_list ($1, $3); }
1429 /* This still leaves out most reserved keywords,
1430 shouldn't we include them? */
1444 /* Initializers. `init' is the entry point. */
1449 { really_start_incremental_init (NULL_TREE); }
1450 initlist_maybe_comma '}'
1451 { $$ = pop_init_level (0); }
1453 { $$ = error_mark_node; }
1456 /* `initlist_maybe_comma' is the guts of an initializer in braces. */
1457 initlist_maybe_comma:
1460 pedwarn ("ISO C forbids empty initializer braces"); }
1461 | initlist1 maybecomma
1466 | initlist1 ',' initelt
1469 /* `initelt' is a single element of an initializer.
1470 It may use braces. */
1472 designator_list '=' initval
1473 { if (pedantic && ! flag_isoc99)
1474 pedwarn ("ISO C90 forbids specifying subobject to initialize"); }
1475 | designator initval
1477 pedwarn ("obsolete use of designated initializer without `='"); }
1479 { set_init_label ($1);
1481 pedwarn ("obsolete use of designated initializer with `:'"); }
1489 { push_init_level (0); }
1490 initlist_maybe_comma '}'
1491 { process_init_element (pop_init_level (0)); }
1493 { process_init_element ($1); }
1499 | designator_list designator
1504 { set_init_label ($2); }
1505 | '[' expr_no_commas ELLIPSIS expr_no_commas ']'
1506 { set_init_index ($2, $4);
1508 pedwarn ("ISO C forbids specifying range of elements to initialize"); }
1509 | '[' expr_no_commas ']'
1510 { set_init_index ($2, NULL_TREE); }
1516 pedwarn ("ISO C forbids nested functions");
1518 push_function_context ();
1519 if (! start_function (current_declspecs, $1,
1520 all_prefix_attributes))
1522 pop_function_context ();
1526 old_style_parm_decls save_location
1527 { tree decl = current_function_decl;
1528 DECL_SOURCE_LOCATION (decl) = $4;
1529 store_parm_decls (); }
1530 /* This used to use compstmt_or_error. That caused a bug with
1531 input `f(g) int g {}', where the use of YYERROR1 above caused
1532 an error which then was handled by compstmt_or_error. There
1533 followed a repeated execution of that same rule, which called
1534 YYERROR1 again, and so on. */
1536 { tree decl = current_function_decl;
1539 pop_function_context ();
1540 add_stmt (build_stmt (DECL_EXPR, decl)); }
1543 notype_nested_function:
1546 pedwarn ("ISO C forbids nested functions");
1548 push_function_context ();
1549 if (! start_function (current_declspecs, $1,
1550 all_prefix_attributes))
1552 pop_function_context ();
1556 old_style_parm_decls save_location
1557 { tree decl = current_function_decl;
1558 DECL_SOURCE_LOCATION (decl) = $4;
1559 store_parm_decls (); }
1560 /* This used to use compstmt_or_error. That caused a bug with
1561 input `f(g) int g {}', where the use of YYERROR1 above caused
1562 an error which then was handled by compstmt_or_error. There
1563 followed a repeated execution of that same rule, which called
1564 YYERROR1 again, and so on. */
1566 { tree decl = current_function_decl;
1569 pop_function_context ();
1570 add_stmt (build_stmt (DECL_EXPR, decl)); }
1573 /* Any kind of declarator (thus, all declarators allowed
1574 after an explicit typespec). */
1577 after_type_declarator
1581 /* A declarator that is allowed only after an explicit typespec. */
1583 after_type_declarator:
1584 '(' maybe_attribute after_type_declarator ')'
1585 { $$ = $2 ? tree_cons ($2, $3, NULL_TREE) : $3; }
1586 | after_type_declarator '(' parmlist_or_identifiers %prec '.'
1587 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1588 | after_type_declarator array_declarator %prec '.'
1589 { $$ = set_array_declarator_type ($2, $1, 0); }
1590 | '*' maybe_type_quals_attrs after_type_declarator %prec UNARY
1591 { $$ = make_pointer_declarator ($2, $3); }
1598 /* Kinds of declarator that can appear in a parameter list
1599 in addition to notype_declarator. This is like after_type_declarator
1600 but does not allow a typedef name in parentheses as an identifier
1601 (because it would conflict with a function with that typedef as arg). */
1603 parm_declarator_starttypename
1604 | parm_declarator_nostarttypename
1607 parm_declarator_starttypename:
1608 parm_declarator_starttypename '(' parmlist_or_identifiers %prec '.'
1609 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1610 | parm_declarator_starttypename array_declarator %prec '.'
1611 { $$ = set_array_declarator_type ($2, $1, 0); }
1618 parm_declarator_nostarttypename:
1619 parm_declarator_nostarttypename '(' parmlist_or_identifiers %prec '.'
1620 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1621 | parm_declarator_nostarttypename array_declarator %prec '.'
1622 { $$ = set_array_declarator_type ($2, $1, 0); }
1623 | '*' maybe_type_quals_attrs parm_declarator_starttypename %prec UNARY
1624 { $$ = make_pointer_declarator ($2, $3); }
1625 | '*' maybe_type_quals_attrs parm_declarator_nostarttypename %prec UNARY
1626 { $$ = make_pointer_declarator ($2, $3); }
1627 | '(' maybe_attribute parm_declarator_nostarttypename ')'
1628 { $$ = $2 ? tree_cons ($2, $3, NULL_TREE) : $3; }
1631 /* A declarator allowed whether or not there has been
1632 an explicit typespec. These cannot redeclare a typedef-name. */
1635 notype_declarator '(' parmlist_or_identifiers %prec '.'
1636 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1637 | '(' maybe_attribute notype_declarator ')'
1638 { $$ = $2 ? tree_cons ($2, $3, NULL_TREE) : $3; }
1639 | '*' maybe_type_quals_attrs notype_declarator %prec UNARY
1640 { $$ = make_pointer_declarator ($2, $3); }
1641 | notype_declarator array_declarator %prec '.'
1642 { $$ = set_array_declarator_type ($2, $1, 0); }
1667 /* structsp_attr: struct/union/enum specifiers that either
1668 end with attributes, or are such that any following attributes would
1669 be parsed as part of the struct/union/enum specifier.
1671 structsp_nonattr: other struct/union/enum specifiers. */
1674 struct_head identifier '{'
1675 { $$ = start_struct (RECORD_TYPE, $2);
1676 /* Start scope of tag before parsing components. */
1678 component_decl_list '}' maybe_attribute
1679 { $$ = finish_struct ($<ttype>4, nreverse ($5),
1680 chainon ($1, $7)); }
1681 | struct_head '{' component_decl_list '}' maybe_attribute
1682 { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
1683 nreverse ($3), chainon ($1, $5));
1685 | union_head identifier '{'
1686 { $$ = start_struct (UNION_TYPE, $2); }
1687 component_decl_list '}' maybe_attribute
1688 { $$ = finish_struct ($<ttype>4, nreverse ($5),
1689 chainon ($1, $7)); }
1690 | union_head '{' component_decl_list '}' maybe_attribute
1691 { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
1692 nreverse ($3), chainon ($1, $5));
1694 | enum_head identifier '{'
1695 { $$ = start_enum ($2); }
1696 enumlist maybecomma_warn '}' maybe_attribute
1697 { $$ = finish_enum ($<ttype>4, nreverse ($5),
1698 chainon ($1, $8)); }
1700 { $$ = start_enum (NULL_TREE); }
1701 enumlist maybecomma_warn '}' maybe_attribute
1702 { $$ = finish_enum ($<ttype>3, nreverse ($4),
1703 chainon ($1, $7)); }
1707 struct_head identifier
1708 { $$ = xref_tag (RECORD_TYPE, $2); }
1709 | union_head identifier
1710 { $$ = xref_tag (UNION_TYPE, $2); }
1711 | enum_head identifier
1712 { $$ = xref_tag (ENUMERAL_TYPE, $2);
1713 /* In ISO C, enumerated types can be referred to
1714 only if already defined. */
1715 if (pedantic && !COMPLETE_TYPE_P ($$))
1716 pedwarn ("ISO C forbids forward references to `enum' types"); }
1727 { if (pedantic && ! flag_isoc99)
1728 pedwarn ("comma at end of enumerator list"); }
1731 /* We chain the components in reverse order. They are put in forward
1732 order in structsp_attr.
1734 Note that component_declarator returns single decls, so components
1735 and components_notype can use TREE_CHAIN directly, wheras components
1736 and components_notype return lists (of comma separated decls), so
1737 component_decl_list and component_decl_list2 must use chainon.
1739 The theory behind all this is that there will be more semicolon
1740 separated fields than comma separated fields, and so we'll be
1741 minimizing the number of node traversals required by chainon. */
1743 component_decl_list:
1744 component_decl_list2
1746 | component_decl_list2 component_decl
1747 { $$ = chainon ($2, $1);
1748 pedwarn ("no semicolon at end of struct or union"); }
1751 component_decl_list2: /* empty */
1753 | component_decl_list2 component_decl ';'
1754 { $$ = chainon ($2, $1); }
1755 | component_decl_list2 ';'
1757 pedwarn ("extra semicolon in struct or union specified"); }
1759 /* foo(sizeof(struct{ @defs(ClassName)})); */
1760 | AT_DEFS '(' CLASSNAME ')'
1761 { $$ = nreverse (get_class_ivars_from_name ($3)); }
1766 declspecs_nosc_ts setspecs components
1768 POP_DECLSPEC_STACK; }
1769 | declspecs_nosc_ts setspecs
1771 /* Support for unnamed structs or unions as members of
1772 structs or unions (which is [a] useful and [b] supports
1775 pedwarn ("ISO C doesn't support unnamed structs/unions");
1777 $$ = grokfield(NULL, current_declspecs, NULL_TREE);
1778 POP_DECLSPEC_STACK; }
1779 | declspecs_nosc_nots setspecs components_notype
1781 POP_DECLSPEC_STACK; }
1782 | declspecs_nosc_nots
1784 pedwarn ("ISO C forbids member declarations with no members");
1785 shadow_tag_warned ($1, pedantic);
1789 | extension component_decl
1791 RESTORE_EXT_FLAGS ($1); }
1795 component_declarator
1796 | components ',' maybe_resetattrs component_declarator
1797 { TREE_CHAIN ($4) = $1; $$ = $4; }
1801 component_notype_declarator
1802 | components_notype ',' maybe_resetattrs component_notype_declarator
1803 { TREE_CHAIN ($4) = $1; $$ = $4; }
1806 component_declarator:
1807 declarator maybe_attribute
1808 { $$ = grokfield ($1, current_declspecs, NULL_TREE);
1809 decl_attributes (&$$,
1810 chainon ($2, all_prefix_attributes), 0); }
1811 | declarator ':' expr_no_commas maybe_attribute
1812 { $$ = grokfield ($1, current_declspecs, $3);
1813 decl_attributes (&$$,
1814 chainon ($4, all_prefix_attributes), 0); }
1815 | ':' expr_no_commas maybe_attribute
1816 { $$ = grokfield (NULL_TREE, current_declspecs, $2);
1817 decl_attributes (&$$,
1818 chainon ($3, all_prefix_attributes), 0); }
1821 component_notype_declarator:
1822 notype_declarator maybe_attribute
1823 { $$ = grokfield ($1, current_declspecs, NULL_TREE);
1824 decl_attributes (&$$,
1825 chainon ($2, all_prefix_attributes), 0); }
1826 | notype_declarator ':' expr_no_commas maybe_attribute
1827 { $$ = grokfield ($1, current_declspecs, $3);
1828 decl_attributes (&$$,
1829 chainon ($4, all_prefix_attributes), 0); }
1830 | ':' expr_no_commas maybe_attribute
1831 { $$ = grokfield (NULL_TREE, current_declspecs, $2);
1832 decl_attributes (&$$,
1833 chainon ($3, all_prefix_attributes), 0); }
1836 /* We chain the enumerators in reverse order.
1837 They are put in forward order in structsp_attr. */
1841 | enumlist ',' enumerator
1842 { if ($1 == error_mark_node)
1845 TREE_CHAIN ($3) = $1, $$ = $3; }
1847 { $$ = error_mark_node; }
1853 { $$ = build_enumerator ($1, NULL_TREE); }
1854 | identifier '=' expr_no_commas
1855 { $$ = build_enumerator ($1, $3); }
1860 { pending_xref_error ();
1863 { $$ = build_tree_list ($<ttype>2, $3); }
1866 absdcl: /* an absolute declarator */
1872 absdcl_maybe_attribute: /* absdcl maybe_attribute, but not just attributes */
1874 { $$ = build_tree_list (build_tree_list (current_declspecs,
1876 all_prefix_attributes); }
1878 { $$ = build_tree_list (build_tree_list (current_declspecs,
1880 all_prefix_attributes); }
1881 | absdcl1_noea attributes
1882 { $$ = build_tree_list (build_tree_list (current_declspecs,
1884 chainon ($2, all_prefix_attributes)); }
1887 absdcl1: /* a nonempty absolute declarator */
1894 | '*' maybe_type_quals_attrs absdcl1_noea
1895 { $$ = make_pointer_declarator ($2, $3); }
1899 '*' maybe_type_quals_attrs
1900 { $$ = make_pointer_declarator ($2, NULL_TREE); }
1901 | '*' maybe_type_quals_attrs absdcl1_ea
1902 { $$ = make_pointer_declarator ($2, $3); }
1906 '(' maybe_attribute absdcl1 ')'
1907 { $$ = $2 ? tree_cons ($2, $3, NULL_TREE) : $3; }
1908 | direct_absdcl1 '(' parmlist
1909 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1910 | direct_absdcl1 array_declarator
1911 { $$ = set_array_declarator_type ($2, $1, 1); }
1913 { $$ = build_nt (CALL_EXPR, NULL_TREE, $2, NULL_TREE); }
1915 { $$ = set_array_declarator_type ($1, NULL_TREE, 1); }
1918 /* The [...] part of a declarator for an array type. */
1921 '[' maybe_type_quals_attrs expr_no_commas ']'
1922 { $$ = build_array_declarator ($3, $2, 0, 0); }
1923 | '[' maybe_type_quals_attrs ']'
1924 { $$ = build_array_declarator (NULL_TREE, $2, 0, 0); }
1925 | '[' maybe_type_quals_attrs '*' ']'
1926 { $$ = build_array_declarator (NULL_TREE, $2, 0, 1); }
1927 | '[' STATIC maybe_type_quals_attrs expr_no_commas ']'
1928 { $$ = build_array_declarator ($4, $3, 1, 0); }
1929 /* declspecs_nosc_nots is a synonym for type_quals_attrs. */
1930 | '[' declspecs_nosc_nots STATIC expr_no_commas ']'
1931 { $$ = build_array_declarator ($4, $2, 1, 0); }
1934 /* A nonempty series of declarations and statements (possibly followed by
1935 some labels) that can form the body of a compound statement.
1936 NOTE: we don't allow labels on declarations; this might seem like a
1937 natural extension, but there would be a conflict between attributes
1938 on the label and prefix attributes on the declaration. */
1941 lineno_stmt_decl_or_labels_ending_stmt
1942 | lineno_stmt_decl_or_labels_ending_decl
1943 | lineno_stmt_decl_or_labels_ending_label
1945 error ("label at end of compound statement");
1947 | lineno_stmt_decl_or_labels_ending_error
1950 lineno_stmt_decl_or_labels_ending_stmt:
1952 | lineno_stmt_decl_or_labels_ending_stmt lineno_stmt
1953 | lineno_stmt_decl_or_labels_ending_decl lineno_stmt
1954 | lineno_stmt_decl_or_labels_ending_label lineno_stmt
1955 | lineno_stmt_decl_or_labels_ending_error lineno_stmt
1958 lineno_stmt_decl_or_labels_ending_decl:
1960 | lineno_stmt_decl_or_labels_ending_stmt lineno_decl
1962 if ((pedantic && !flag_isoc99)
1963 || warn_declaration_after_statement)
1964 pedwarn_c90 ("ISO C90 forbids mixed declarations and code");
1966 | lineno_stmt_decl_or_labels_ending_decl lineno_decl
1967 | lineno_stmt_decl_or_labels_ending_error lineno_decl
1970 lineno_stmt_decl_or_labels_ending_label:
1972 | lineno_stmt_decl_or_labels_ending_stmt lineno_label
1973 | lineno_stmt_decl_or_labels_ending_decl lineno_label
1974 | lineno_stmt_decl_or_labels_ending_label lineno_label
1975 | lineno_stmt_decl_or_labels_ending_error lineno_label
1978 lineno_stmt_decl_or_labels_ending_error:
1980 | lineno_stmt_decl_or_labels errstmt
1983 lineno_stmt_decl_or_labels:
1984 lineno_stmt_decl_or_labels_ending_stmt
1985 | lineno_stmt_decl_or_labels_ending_decl
1986 | lineno_stmt_decl_or_labels_ending_label
1987 | lineno_stmt_decl_or_labels_ending_error
1993 /* Start and end blocks created for the new scopes of C99. */
1994 c99_block_start: /* empty */
1995 { $$ = c_begin_compound_stmt (flag_isoc99); }
1998 /* Read zero or more forward-declarations for labels
1999 that nested functions can jump to. */
2004 pedwarn ("ISO C forbids label declarations"); }
2009 | label_decls label_decl
2013 LABEL identifiers_or_typenames ';'
2015 for (link = $2; link; link = TREE_CHAIN (link))
2017 tree label = declare_label (TREE_VALUE (link));
2018 C_DECLARED_LABEL_FLAG (label) = 1;
2019 add_stmt (build_stmt (DECL_EXPR, label));
2024 /* This is the body of a function definition.
2025 It causes syntax errors to ignore to the next openbrace. */
2032 compstmt_start: '{' { $$ = c_begin_compound_stmt (true); }
2035 compstmt_nostart: '}'
2036 | maybe_label_decls compstmt_contents_nonempty '}'
2039 compstmt_contents_nonempty:
2044 compstmt_primary_start:
2046 { if (current_function_decl == 0)
2048 error ("braced-group within expression allowed "
2049 "only inside a function");
2052 $$ = c_begin_stmt_expr ();
2056 compstmt: compstmt_start compstmt_nostart
2057 { $$ = c_end_compound_stmt ($1, true); }
2060 /* The forced readahead in here is because we might be at the end of a
2061 line, and the line and file won't be bumped until yylex absorbs the
2062 first token on the next line. */
2065 { if (yychar == YYEMPTY)
2067 $$ = input_location; }
2072 | lineno_labels lineno_label
2075 /* A labeled statement. In C99 it also generates an implicit block. */
2076 c99_block_lineno_labeled_stmt:
2077 c99_block_start lineno_labels lineno_stmt
2078 { $$ = c_end_compound_stmt ($1, flag_isoc99); }
2084 /* Two cases cannot and do not have line numbers associated:
2085 If stmt is degenerate, such as "2;", then stmt is an
2086 INTEGER_CST, which cannot hold line numbers. But that's
2087 ok because the statement will either be changed to a
2088 MODIFY_EXPR during gimplification of the statement expr,
2089 or discarded. If stmt was compound, but without new
2090 variables, we will have skipped the creation of a BIND
2091 and will have a bare STATEMENT_LIST. But that's ok
2092 because (recursively) all of the component statments
2093 should already have line numbers assigned. */
2094 if ($2 && EXPR_P ($2))
2095 annotate_with_locus ($2, $1);
2101 { if ($2) annotate_with_locus ($2, $1); }
2104 condition: save_location expr
2105 { $$ = lang_hooks.truthvalue_conversion ($2);
2107 annotate_with_locus ($$, $1); }
2110 /* Implement -Wparenthesis by special casing IF statement directly nested
2111 within IF statement. This requires some amount of duplication of the
2112 productions under c99_block_lineno_labeled_stmt in order to work out.
2113 But it's still likely more maintainable than lots of state outside the
2117 c99_block_start lineno_labels if_statement
2118 { $$ = c_end_compound_stmt ($1, flag_isoc99); }
2122 c99_block_start lineno_labels ';'
2123 { if (extra_warnings)
2124 add_stmt (build (NOP_EXPR, NULL_TREE, NULL_TREE));
2125 $$ = c_end_compound_stmt ($1, flag_isoc99); }
2126 | c99_block_lineno_labeled_stmt
2130 IF c99_block_start save_location '(' condition ')'
2131 if_statement_1 ELSE if_statement_2
2132 { c_finish_if_stmt ($3, $5, $7, $9, true);
2133 add_stmt (c_end_compound_stmt ($2, flag_isoc99)); }
2134 | IF c99_block_start save_location '(' condition ')'
2135 if_statement_2 ELSE if_statement_2
2136 { c_finish_if_stmt ($3, $5, $7, $9, false);
2137 add_stmt (c_end_compound_stmt ($2, flag_isoc99)); }
2138 | IF c99_block_start save_location '(' condition ')'
2139 if_statement_1 %prec IF
2140 { c_finish_if_stmt ($3, $5, $7, NULL, true);
2141 add_stmt (c_end_compound_stmt ($2, flag_isoc99)); }
2142 | IF c99_block_start save_location '(' condition ')'
2143 if_statement_2 %prec IF
2144 { c_finish_if_stmt ($3, $5, $7, NULL, false);
2145 add_stmt (c_end_compound_stmt ($2, flag_isoc99)); }
2148 start_break: /* empty */
2149 { $$ = c_break_label; c_break_label = NULL; }
2152 start_continue: /* empty */
2153 { $$ = c_cont_label; c_cont_label = NULL; }
2157 WHILE c99_block_start save_location '(' condition ')'
2158 start_break start_continue c99_block_lineno_labeled_stmt
2159 { c_finish_loop ($3, $5, NULL, $9, c_break_label,
2160 c_cont_label, true);
2161 add_stmt (c_end_compound_stmt ($2, flag_isoc99));
2162 c_break_label = $7; c_cont_label = $8; }
2166 DO c99_block_start save_location start_break start_continue
2167 c99_block_lineno_labeled_stmt WHILE
2168 { $<ttype>$ = c_break_label; c_break_label = $4; }
2169 { $<ttype>$ = c_cont_label; c_cont_label = $5; }
2170 '(' condition ')' ';'
2171 { c_finish_loop ($3, $11, NULL, $6, $<ttype>8,
2173 add_stmt (c_end_compound_stmt ($2, flag_isoc99)); }
2184 { c_finish_expr_stmt ($1); }
2186 { check_for_loop_decls (); }
2189 for_cond_expr: save_location xexpr
2192 $$ = lang_hooks.truthvalue_conversion ($2);
2194 annotate_with_locus ($$, $1);
2201 for_incr_expr: xexpr
2202 { $$ = c_process_expr_stmt ($1); }
2206 FOR c99_block_start '(' for_init_stmt
2207 save_location for_cond_expr ';' for_incr_expr ')'
2208 start_break start_continue c99_block_lineno_labeled_stmt
2209 { c_finish_loop ($5, $6, $8, $12, c_break_label,
2210 c_cont_label, true);
2211 add_stmt (c_end_compound_stmt ($2, flag_isoc99));
2212 c_break_label = $10; c_cont_label = $11; }
2216 SWITCH c99_block_start '(' expr ')'
2217 { $<ttype>$ = c_start_case ($4); }
2218 start_break c99_block_lineno_labeled_stmt
2219 { c_finish_case ($8);
2221 add_stmt (build (LABEL_EXPR, void_type_node,
2224 add_stmt (c_end_compound_stmt ($2, flag_isoc99)); }
2227 /* Parse a single real statement, not including any labels or compounds. */
2230 { $$ = c_finish_expr_stmt ($1); }
2242 { $$ = c_finish_bc_stmt (&c_break_label, true); }
2244 { $$ = c_finish_bc_stmt (&c_cont_label, false); }
2246 { $$ = c_finish_return (NULL_TREE); }
2248 { $$ = c_finish_return ($2); }
2250 | GOTO identifier ';'
2251 { $$ = c_finish_goto_label ($2); }
2253 { $$ = c_finish_goto_ptr ($3); }
2258 { $$ = objc_build_throw_stmt ($2); }
2260 { $$ = objc_build_throw_stmt (NULL_TREE); }
2261 | objc_try_catch_stmt
2263 | AT_SYNCHRONIZED save_location '(' expr ')' compstmt
2264 { objc_build_synchronized ($2, $4, $6); $$ = NULL_TREE; }
2268 AT_CATCH '(' parm ')'
2269 { objc_begin_catch_clause ($3); }
2273 objc_catch_prefix '{' compstmt_nostart
2274 { objc_finish_catch_clause (); }
2275 | objc_catch_prefix '{' error '}'
2276 { objc_finish_catch_clause (); }
2279 objc_opt_catch_list:
2281 | objc_opt_catch_list objc_catch_clause
2284 objc_try_catch_clause:
2285 AT_TRY save_location compstmt
2286 { objc_begin_try_stmt ($2, $3); }
2290 objc_finally_clause:
2291 AT_FINALLY save_location compstmt
2292 { objc_build_finally_clause ($2, $3); }
2295 objc_try_catch_stmt:
2296 objc_try_catch_clause
2297 { objc_finish_try_stmt (); }
2298 | objc_try_catch_clause objc_finally_clause
2299 { objc_finish_try_stmt (); }
2303 /* Parse a single or compound real statement, not including any labels. */
2306 { add_stmt ($1); $$ = NULL_TREE; }
2310 /* Any kind of label, including jump labels and case labels.
2311 ANSI C accepts labels only before statements, but we allow them
2312 also at the end of a compound statement. */
2314 label: CASE expr_no_commas ':'
2315 { $$ = do_case ($2, NULL_TREE); }
2316 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
2317 { $$ = do_case ($2, $4); }
2319 { $$ = do_case (NULL_TREE, NULL_TREE); }
2320 | identifier save_location ':' maybe_attribute
2321 { tree label = define_label ($2, $1);
2324 decl_attributes (&label, $4, 0);
2325 $$ = add_stmt (build_stmt (LABEL_EXPR, label));
2332 /* Asm expressions and statements */
2334 /* simple_asm_expr is used in restricted contexts, where a full
2335 expression with inputs and outputs does not make sense. */
2337 ASM_KEYWORD stop_string_translation
2338 '(' STRING ')' start_string_translation
2342 /* maybeasm: used for assembly names for declarations */
2349 /* asmdef: asm() outside a function body. */
2352 { assemble_asm ($1); }
2353 | ASM_KEYWORD error start_string_translation ';'
2357 /* Full-blown asm statement with inputs, outputs, clobbers, and
2358 volatile tag allowed. */
2360 ASM_KEYWORD maybe_volatile stop_string_translation
2361 '(' asm_argument ')' start_string_translation ';'
2362 { $$ = build_asm_stmt ($2, $5); }
2368 { $$ = build_asm_expr ($1, 0, 0, 0, true); }
2369 /* output operands */
2370 | STRING ':' asm_operands
2371 { $$ = build_asm_expr ($1, $3, 0, 0, false); }
2372 /* output and input operands */
2373 | STRING ':' asm_operands ':' asm_operands
2374 { $$ = build_asm_expr ($1, $3, $5, 0, false); }
2375 /* output and input operands and clobbers */
2376 | STRING ':' asm_operands ':' asm_operands ':' asm_clobbers
2377 { $$ = build_asm_expr ($1, $3, $5, $7, false); }
2380 /* Either 'volatile' or nothing. First thing in an `asm' statement. */
2386 { if ($1 != ridpointers[RID_VOLATILE])
2388 warning ("%E qualifier ignored on asm", $1);
2396 /* These are the operands other than the first string and colon
2397 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
2398 asm_operands: /* empty */
2400 | nonnull_asm_operands
2403 nonnull_asm_operands:
2405 | nonnull_asm_operands ',' asm_operand
2406 { $$ = chainon ($1, $3); }
2410 STRING start_string_translation '(' expr ')' stop_string_translation
2411 { $$ = build_tree_list (build_tree_list (NULL_TREE, $1), $4); }
2412 | '[' identifier ']' STRING start_string_translation
2413 '(' expr ')' stop_string_translation
2414 { $2 = build_string (IDENTIFIER_LENGTH ($2),
2415 IDENTIFIER_POINTER ($2));
2416 $$ = build_tree_list (build_tree_list ($2, $4), $7); }
2421 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
2422 | asm_clobbers ',' STRING
2423 { $$ = tree_cons (NULL_TREE, $3, $1); }
2426 stop_string_translation:
2427 { c_lex_string_translate = 0; }
2430 start_string_translation:
2431 { c_lex_string_translate = 1; }
2435 /* This is what appears inside the parens in a function declarator.
2436 Its value is a list of ..._TYPE nodes. Attributes must appear here
2437 to avoid a conflict with their appearance after an open parenthesis
2438 in an abstract declarator, as in
2439 "void bar (int (__attribute__((__mode__(SI))) int foo));". */
2443 declare_parm_level (); }
2452 { mark_forward_parm_decls (); }
2454 { /* Dummy action so attributes are in known place
2455 on parser stack. */ }
2459 { $$ = make_node (TREE_LIST); }
2462 /* This is what appears inside the parens in a function declarator.
2463 Is value is represented in the format that grokdeclarator expects. */
2464 parmlist_2: /* empty */
2465 { $$ = make_node (TREE_LIST); }
2467 { $$ = make_node (TREE_LIST);
2468 /* Suppress -Wold-style-definition for this case. */
2469 TREE_CHAIN ($$) = error_mark_node;
2470 error ("ISO C requires a named argument before `...'");
2473 { $$ = get_parm_info (/*ellipsis=*/false); }
2474 | parms ',' ELLIPSIS
2475 { $$ = get_parm_info (/*ellipsis=*/true); }
2480 { push_parm_decl ($1); }
2482 { push_parm_decl ($3); }
2485 /* A single parameter declaration or parameter type name,
2486 as found in a parmlist. */
2488 declspecs_ts setspecs parm_declarator maybe_attribute
2489 { $$ = build_tree_list (build_tree_list (current_declspecs,
2491 chainon ($4, all_prefix_attributes));
2492 POP_DECLSPEC_STACK; }
2493 | declspecs_ts setspecs notype_declarator maybe_attribute
2494 { $$ = build_tree_list (build_tree_list (current_declspecs,
2496 chainon ($4, all_prefix_attributes));
2497 POP_DECLSPEC_STACK; }
2498 | declspecs_ts setspecs absdcl_maybe_attribute
2500 POP_DECLSPEC_STACK; }
2501 | declspecs_nots setspecs notype_declarator maybe_attribute
2502 { $$ = build_tree_list (build_tree_list (current_declspecs,
2504 chainon ($4, all_prefix_attributes));
2505 POP_DECLSPEC_STACK; }
2507 | declspecs_nots setspecs absdcl_maybe_attribute
2509 POP_DECLSPEC_STACK; }
2512 /* The first parm, which must suck attributes from off the top of the parser
2515 declspecs_ts_nosa setspecs_fp parm_declarator maybe_attribute
2516 { $$ = build_tree_list (build_tree_list (current_declspecs,
2518 chainon ($4, all_prefix_attributes));
2519 POP_DECLSPEC_STACK; }
2520 | declspecs_ts_nosa setspecs_fp notype_declarator maybe_attribute
2521 { $$ = build_tree_list (build_tree_list (current_declspecs,
2523 chainon ($4, all_prefix_attributes));
2524 POP_DECLSPEC_STACK; }
2525 | declspecs_ts_nosa setspecs_fp absdcl_maybe_attribute
2527 POP_DECLSPEC_STACK; }
2528 | declspecs_nots_nosa setspecs_fp notype_declarator maybe_attribute
2529 { $$ = build_tree_list (build_tree_list (current_declspecs,
2531 chainon ($4, all_prefix_attributes));
2532 POP_DECLSPEC_STACK; }
2534 | declspecs_nots_nosa setspecs_fp absdcl_maybe_attribute
2536 POP_DECLSPEC_STACK; }
2541 { prefix_attributes = chainon (prefix_attributes, $<ttype>-2);
2542 all_prefix_attributes = prefix_attributes; }
2545 /* This is used in a function definition
2546 where either a parmlist or an identifier list is ok.
2547 Its value is a list of ..._TYPE nodes or a list of identifiers. */
2548 parmlist_or_identifiers:
2551 declare_parm_level (); }
2552 parmlist_or_identifiers_1
2557 parmlist_or_identifiers_1:
2561 for (t = $1; t; t = TREE_CHAIN (t))
2562 if (TREE_VALUE (t) == NULL_TREE)
2563 error ("`...' in old-style identifier list");
2564 $$ = tree_cons (NULL_TREE, NULL_TREE, $1);
2566 /* Make sure we have a parmlist after attributes. */
2568 && (TREE_CODE ($$) != TREE_LIST
2569 || TREE_PURPOSE ($$) == 0
2570 || TREE_CODE (TREE_PURPOSE ($$)) != PARM_DECL))
2575 /* A nonempty list of identifiers. */
2578 { $$ = build_tree_list (NULL_TREE, $1); }
2579 | identifiers ',' IDENTIFIER
2580 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2583 /* A nonempty list of identifiers, including typenames. */
2584 identifiers_or_typenames:
2586 { $$ = build_tree_list (NULL_TREE, $1); }
2587 | identifiers_or_typenames ',' identifier
2588 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2593 { $$ = SAVE_EXT_FLAGS();
2595 warn_pointer_arith = 0;
2596 warn_traditional = 0;
2601 /* Objective-C productions. */
2611 if (objc_implementation_context)
2613 finish_class (objc_implementation_context);
2614 objc_ivar_chain = NULL_TREE;
2615 objc_implementation_context = NULL_TREE;
2618 warning ("`@end' must appear in an implementation context");
2622 /* A nonempty list of identifiers. */
2625 { $$ = build_tree_list (NULL_TREE, $1); }
2626 | identifier_list ',' identifier
2627 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2631 AT_CLASS identifier_list ';'
2633 objc_declare_class ($2);
2638 AT_ALIAS identifier identifier ';'
2640 objc_declare_alias ($2, $3);
2645 ':' identifier { $$ = $2; }
2646 | /* NULL */ %prec HYPERUNARY { $$ = NULL_TREE; }
2650 '{' ivar_decl_list '}'
2655 AT_INTERFACE identifier superclass protocolrefs
2657 objc_interface_context = objc_ivar_context
2658 = start_class (CLASS_INTERFACE_TYPE, $2, $3, $4);
2659 objc_public_flag = 0;
2663 continue_class (objc_interface_context);
2665 methodprotolist AT_END
2667 finish_class (objc_interface_context);
2668 objc_interface_context = NULL_TREE;
2671 | AT_IMPLEMENTATION identifier superclass
2673 objc_implementation_context = objc_ivar_context
2674 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $3, NULL_TREE);
2675 objc_public_flag = 0;
2680 = continue_class (objc_implementation_context);
2683 | AT_INTERFACE identifier '(' identifier ')' protocolrefs
2685 objc_interface_context
2686 = start_class (CATEGORY_INTERFACE_TYPE, $2, $4, $6);
2687 continue_class (objc_interface_context);
2689 methodprotolist AT_END
2691 finish_class (objc_interface_context);
2692 objc_interface_context = NULL_TREE;
2695 | AT_IMPLEMENTATION identifier '(' identifier ')'
2697 objc_implementation_context
2698 = start_class (CATEGORY_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2700 = continue_class (objc_implementation_context);
2705 AT_PROTOCOL identifier protocolrefs
2707 objc_pq_context = 1;
2708 objc_interface_context
2709 = start_protocol(PROTOCOL_INTERFACE_TYPE, $2, $3);
2711 methodprotolist AT_END
2713 objc_pq_context = 0;
2714 finish_protocol(objc_interface_context);
2715 objc_interface_context = NULL_TREE;
2717 /* The @protocol forward-declaration production introduces a
2718 reduce/reduce conflict on ';', which should be resolved in
2719 favor of the production 'identifier_list -> identifier'. */
2720 | AT_PROTOCOL identifier_list ';'
2722 objc_declare_protocols ($2);
2731 | non_empty_protocolrefs
2734 non_empty_protocolrefs:
2735 ARITHCOMPARE identifier_list ARITHCOMPARE
2737 if ($1 == LT_EXPR && $3 == GT_EXPR)
2745 ivar_decl_list visibility_spec ivar_decls
2750 AT_PRIVATE { objc_public_flag = 2; }
2751 | AT_PROTECTED { objc_public_flag = 0; }
2752 | AT_PUBLIC { objc_public_flag = 1; }
2760 | ivar_decls ivar_decl ';'
2764 pedwarn ("extra semicolon in struct or union specified");
2769 /* There is a shift-reduce conflict here, because `components' may
2770 start with a `typename'. It happens that shifting (the default resolution)
2771 does the right thing, because it treats the `typename' as part of
2772 a `typed_typespecs'.
2774 It is possible that this same technique would allow the distinction
2775 between `notype_initdecls' and `initdecls' to be eliminated.
2776 But I am being cautious and not trying it. */
2779 declspecs_nosc_ts setspecs ivars
2781 POP_DECLSPEC_STACK; }
2782 | declspecs_nosc_nots setspecs ivars
2784 POP_DECLSPEC_STACK; }
2793 | ivars ',' maybe_resetattrs ivar_declarator
2799 $$ = add_instance_variable (objc_ivar_context,
2801 $1, current_declspecs,
2804 | declarator ':' expr_no_commas
2806 $$ = add_instance_variable (objc_ivar_context,
2808 $1, current_declspecs, $3);
2810 | ':' expr_no_commas
2812 $$ = add_instance_variable (objc_ivar_context,
2815 current_declspecs, $2);
2821 { objc_inherit_code = CLASS_METHOD_DECL; }
2823 { objc_inherit_code = INSTANCE_METHOD_DECL; }
2829 objc_pq_context = 1;
2830 if (!objc_implementation_context)
2831 fatal_error ("method definition not in class context");
2835 objc_pq_context = 0;
2836 objc_add_method (objc_implementation_context,
2838 objc_inherit_code == CLASS_METHOD_DECL);
2839 start_method_def ($3);
2843 continue_method_def ();
2847 finish_method_def ();
2851 /* the reason for the strange actions in this rule
2852 is so that notype_initdecls when reached via datadef
2853 can find a valid list of type and sc specs in $0. */
2857 | methodprotolist methodproto
2858 | methodprotolist { $<ttype>$ = NULL_TREE; } datadef
2869 /* Remember protocol qualifiers in prototypes. */
2870 objc_pq_context = 1;
2874 /* Forget protocol qualifiers here. */
2875 objc_pq_context = 0;
2876 objc_add_method (objc_interface_context,
2878 objc_inherit_code == CLASS_METHOD_DECL);
2884 '(' typename ')' unaryselector
2886 $$ = build_method_decl (objc_inherit_code, $2, $4, NULL_TREE);
2891 $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, NULL_TREE);
2894 | '(' typename ')' keywordselector optparmlist
2896 $$ = build_method_decl (objc_inherit_code, $2, $4, $5);
2899 | keywordselector optparmlist
2901 $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, $2);
2905 /* "optarglist" assumes that start_method_def has already been called...
2906 if it is not, the "xdecls" will not be placed in the proper scope */
2913 /* to get around the following situation: "int foo (int a) int b; {}" that
2914 is synthesized when parsing "- a:a b:b; id c; id d; { ... }" */
2929 declspecs_ts setspecs myparms ';'
2930 { POP_DECLSPEC_STACK; }
2932 { shadow_tag ($1); }
2933 | declspecs_nots ';'
2934 { pedwarn ("empty declaration"); }
2939 { push_parm_decl ($1); }
2940 | myparms ',' myparm
2941 { push_parm_decl ($3); }
2944 /* A single parameter declaration or parameter type name,
2945 as found in a parmlist. DOES NOT ALLOW AN INITIALIZER OR ASMSPEC */
2948 parm_declarator maybe_attribute
2949 { $$ = build_tree_list (build_tree_list (current_declspecs,
2951 chainon ($2, all_prefix_attributes)); }
2952 | notype_declarator maybe_attribute
2953 { $$ = build_tree_list (build_tree_list (current_declspecs,
2955 chainon ($2, all_prefix_attributes)); }
2956 | absdcl_maybe_attribute
2967 /* oh what a kludge! */
2968 $$ = objc_ellipsis_node;
2976 /* returns a tree list node generated by get_parm_info */
2989 | keywordselector keyworddecl
2991 $$ = chainon ($1, $2);
3004 ENUM | STRUCT | UNION | IF | ELSE | WHILE | DO | FOR
3005 | SWITCH | CASE | DEFAULT | BREAK | CONTINUE | RETURN
3006 | GOTO | ASM_KEYWORD | SIZEOF | TYPEOF | ALIGNOF
3007 | TYPESPEC | TYPE_QUAL
3011 selector ':' '(' typename ')' identifier
3013 $$ = build_keyword_decl ($1, $4, $6);
3016 | selector ':' identifier
3018 $$ = build_keyword_decl ($1, NULL_TREE, $3);
3021 | ':' '(' typename ')' identifier
3023 $$ = build_keyword_decl (NULL_TREE, $3, $5);
3028 $$ = build_keyword_decl (NULL_TREE, NULL_TREE, $2);
3039 | keywordarglist keywordarg
3041 $$ = chainon ($1, $2);
3049 if (TREE_CHAIN ($1) == NULL_TREE)
3050 /* just return the expr., remove a level of indirection */
3051 $$ = TREE_VALUE ($1);
3053 /* we have a comma expr., we will collapse later */
3059 selector ':' keywordexpr
3061 $$ = build_tree_list ($1, $3);
3065 $$ = build_tree_list (NULL_TREE, $2);
3073 $$ = get_class_reference ($1);
3077 $$ = get_class_reference ($1);
3082 '[' receiver messageargs ']'
3083 { $$ = build_tree_list ($2, $3); }
3093 | keywordnamelist keywordname
3095 $$ = chainon ($1, $2);
3102 $$ = build_tree_list ($1, NULL_TREE);
3106 $$ = build_tree_list (NULL_TREE, NULL_TREE);
3111 AT_SELECTOR '(' selectorarg ')'
3118 AT_PROTOCOL '(' identifier ')'
3124 /* extension to support C-structures in the archiver */
3127 AT_ENCODE '(' typename ')'
3129 $$ = groktypename ($3);
3136 /* yylex() is a thin wrapper around c_lex(), all it does is translate
3137 cpplib.h's token codes into yacc's token codes. */
3139 static enum cpp_ttype last_token;
3141 /* The reserved keyword table. */
3145 ENUM_BITFIELD(rid) rid : 16;
3146 unsigned int disable : 16;
3149 /* Disable mask. Keywords are disabled if (reswords[i].disable & mask) is
3151 #define D_C89 0x01 /* not in C89 */
3152 #define D_EXT 0x02 /* GCC extension */
3153 #define D_EXT89 0x04 /* GCC extension incorporated in C99 */
3154 #define D_OBJC 0x08 /* Objective C only */
3156 static const struct resword reswords[] =
3158 { "_Bool", RID_BOOL, 0 },
3159 { "_Complex", RID_COMPLEX, 0 },
3160 { "__FUNCTION__", RID_FUNCTION_NAME, 0 },
3161 { "__PRETTY_FUNCTION__", RID_PRETTY_FUNCTION_NAME, 0 },
3162 { "__alignof", RID_ALIGNOF, 0 },
3163 { "__alignof__", RID_ALIGNOF, 0 },
3164 { "__asm", RID_ASM, 0 },
3165 { "__asm__", RID_ASM, 0 },
3166 { "__attribute", RID_ATTRIBUTE, 0 },
3167 { "__attribute__", RID_ATTRIBUTE, 0 },
3168 { "__builtin_choose_expr", RID_CHOOSE_EXPR, 0 },
3169 { "__builtin_offsetof", RID_OFFSETOF, 0 },
3170 { "__builtin_types_compatible_p", RID_TYPES_COMPATIBLE_P, 0 },
3171 { "__builtin_va_arg", RID_VA_ARG, 0 },
3172 { "__complex", RID_COMPLEX, 0 },
3173 { "__complex__", RID_COMPLEX, 0 },
3174 { "__const", RID_CONST, 0 },
3175 { "__const__", RID_CONST, 0 },
3176 { "__extension__", RID_EXTENSION, 0 },
3177 { "__func__", RID_C99_FUNCTION_NAME, 0 },
3178 { "__imag", RID_IMAGPART, 0 },
3179 { "__imag__", RID_IMAGPART, 0 },
3180 { "__inline", RID_INLINE, 0 },
3181 { "__inline__", RID_INLINE, 0 },
3182 { "__label__", RID_LABEL, 0 },
3183 { "__ptrbase", RID_PTRBASE, 0 },
3184 { "__ptrbase__", RID_PTRBASE, 0 },
3185 { "__ptrextent", RID_PTREXTENT, 0 },
3186 { "__ptrextent__", RID_PTREXTENT, 0 },
3187 { "__ptrvalue", RID_PTRVALUE, 0 },
3188 { "__ptrvalue__", RID_PTRVALUE, 0 },
3189 { "__real", RID_REALPART, 0 },
3190 { "__real__", RID_REALPART, 0 },
3191 { "__restrict", RID_RESTRICT, 0 },
3192 { "__restrict__", RID_RESTRICT, 0 },
3193 { "__signed", RID_SIGNED, 0 },
3194 { "__signed__", RID_SIGNED, 0 },
3195 { "__thread", RID_THREAD, 0 },
3196 { "__typeof", RID_TYPEOF, 0 },
3197 { "__typeof__", RID_TYPEOF, 0 },
3198 { "__volatile", RID_VOLATILE, 0 },
3199 { "__volatile__", RID_VOLATILE, 0 },
3200 { "asm", RID_ASM, D_EXT },
3201 { "auto", RID_AUTO, 0 },
3202 { "break", RID_BREAK, 0 },
3203 { "case", RID_CASE, 0 },
3204 { "char", RID_CHAR, 0 },
3205 { "const", RID_CONST, 0 },
3206 { "continue", RID_CONTINUE, 0 },
3207 { "default", RID_DEFAULT, 0 },
3208 { "do", RID_DO, 0 },
3209 { "double", RID_DOUBLE, 0 },
3210 { "else", RID_ELSE, 0 },
3211 { "enum", RID_ENUM, 0 },
3212 { "extern", RID_EXTERN, 0 },
3213 { "float", RID_FLOAT, 0 },
3214 { "for", RID_FOR, 0 },
3215 { "goto", RID_GOTO, 0 },
3216 { "if", RID_IF, 0 },
3217 { "inline", RID_INLINE, D_EXT89 },
3218 { "int", RID_INT, 0 },
3219 { "long", RID_LONG, 0 },
3220 { "register", RID_REGISTER, 0 },
3221 { "restrict", RID_RESTRICT, D_C89 },
3222 { "return", RID_RETURN, 0 },
3223 { "short", RID_SHORT, 0 },
3224 { "signed", RID_SIGNED, 0 },
3225 { "sizeof", RID_SIZEOF, 0 },
3226 { "static", RID_STATIC, 0 },
3227 { "struct", RID_STRUCT, 0 },
3228 { "switch", RID_SWITCH, 0 },
3229 { "typedef", RID_TYPEDEF, 0 },
3230 { "typeof", RID_TYPEOF, D_EXT },
3231 { "union", RID_UNION, 0 },
3232 { "unsigned", RID_UNSIGNED, 0 },
3233 { "void", RID_VOID, 0 },
3234 { "volatile", RID_VOLATILE, 0 },
3235 { "while", RID_WHILE, 0 },
3237 { "id", RID_ID, D_OBJC },
3239 /* These objc keywords are recognized only immediately after
3241 { "class", RID_AT_CLASS, D_OBJC },
3242 { "compatibility_alias", RID_AT_ALIAS, D_OBJC },
3243 { "defs", RID_AT_DEFS, D_OBJC },
3244 { "encode", RID_AT_ENCODE, D_OBJC },
3245 { "end", RID_AT_END, D_OBJC },
3246 { "implementation", RID_AT_IMPLEMENTATION, D_OBJC },
3247 { "interface", RID_AT_INTERFACE, D_OBJC },
3248 { "private", RID_AT_PRIVATE, D_OBJC },
3249 { "protected", RID_AT_PROTECTED, D_OBJC },
3250 { "protocol", RID_AT_PROTOCOL, D_OBJC },
3251 { "public", RID_AT_PUBLIC, D_OBJC },
3252 { "selector", RID_AT_SELECTOR, D_OBJC },
3253 { "throw", RID_AT_THROW, D_OBJC },
3254 { "try", RID_AT_TRY, D_OBJC },
3255 { "catch", RID_AT_CATCH, D_OBJC },
3256 { "finally", RID_AT_FINALLY, D_OBJC },
3257 { "synchronized", RID_AT_SYNCHRONIZED, D_OBJC },
3258 /* These are recognized only in protocol-qualifier context
3260 { "bycopy", RID_BYCOPY, D_OBJC },
3261 { "byref", RID_BYREF, D_OBJC },
3262 { "in", RID_IN, D_OBJC },
3263 { "inout", RID_INOUT, D_OBJC },
3264 { "oneway", RID_ONEWAY, D_OBJC },
3265 { "out", RID_OUT, D_OBJC },
3268 #define N_reswords (sizeof reswords / sizeof (struct resword))
3270 /* Table mapping from RID_* constants to yacc token numbers.
3271 Unfortunately we have to have entries for all the keywords in all
3273 static const short rid_to_yy[RID_MAX] =
3275 /* RID_STATIC */ STATIC,
3276 /* RID_UNSIGNED */ TYPESPEC,
3277 /* RID_LONG */ TYPESPEC,
3278 /* RID_CONST */ TYPE_QUAL,
3279 /* RID_EXTERN */ SCSPEC,
3280 /* RID_REGISTER */ SCSPEC,
3281 /* RID_TYPEDEF */ SCSPEC,
3282 /* RID_SHORT */ TYPESPEC,
3283 /* RID_INLINE */ SCSPEC,
3284 /* RID_VOLATILE */ TYPE_QUAL,
3285 /* RID_SIGNED */ TYPESPEC,
3286 /* RID_AUTO */ SCSPEC,
3287 /* RID_RESTRICT */ TYPE_QUAL,
3290 /* RID_COMPLEX */ TYPESPEC,
3291 /* RID_THREAD */ SCSPEC,
3295 /* RID_VIRTUAL */ 0,
3296 /* RID_EXPLICIT */ 0,
3298 /* RID_MUTABLE */ 0,
3301 /* RID_IN */ TYPE_QUAL,
3302 /* RID_OUT */ TYPE_QUAL,
3303 /* RID_INOUT */ TYPE_QUAL,
3304 /* RID_BYCOPY */ TYPE_QUAL,
3305 /* RID_BYREF */ TYPE_QUAL,
3306 /* RID_ONEWAY */ TYPE_QUAL,
3309 /* RID_INT */ TYPESPEC,
3310 /* RID_CHAR */ TYPESPEC,
3311 /* RID_FLOAT */ TYPESPEC,
3312 /* RID_DOUBLE */ TYPESPEC,
3313 /* RID_VOID */ TYPESPEC,
3314 /* RID_ENUM */ ENUM,
3315 /* RID_STRUCT */ STRUCT,
3316 /* RID_UNION */ UNION,
3318 /* RID_ELSE */ ELSE,
3319 /* RID_WHILE */ WHILE,
3322 /* RID_SWITCH */ SWITCH,
3323 /* RID_CASE */ CASE,
3324 /* RID_DEFAULT */ DEFAULT,
3325 /* RID_BREAK */ BREAK,
3326 /* RID_CONTINUE */ CONTINUE,
3327 /* RID_RETURN */ RETURN,
3328 /* RID_GOTO */ GOTO,
3329 /* RID_SIZEOF */ SIZEOF,
3332 /* RID_ASM */ ASM_KEYWORD,
3333 /* RID_TYPEOF */ TYPEOF,
3334 /* RID_ALIGNOF */ ALIGNOF,
3335 /* RID_ATTRIBUTE */ ATTRIBUTE,
3336 /* RID_VA_ARG */ VA_ARG,
3337 /* RID_EXTENSION */ EXTENSION,
3338 /* RID_IMAGPART */ IMAGPART,
3339 /* RID_REALPART */ REALPART,
3340 /* RID_LABEL */ LABEL,
3341 /* RID_PTRBASE */ PTR_BASE,
3342 /* RID_PTREXTENT */ PTR_EXTENT,
3343 /* RID_PTRVALUE */ PTR_VALUE,
3345 /* RID_CHOOSE_EXPR */ CHOOSE_EXPR,
3346 /* RID_TYPES_COMPATIBLE_P */ TYPES_COMPATIBLE_P,
3348 /* RID_FUNCTION_NAME */ FUNC_NAME,
3349 /* RID_PRETTY_FUNCTION_NAME */ FUNC_NAME,
3350 /* RID_C99_FUNCTION_NAME */ FUNC_NAME,
3353 /* RID_BOOL */ TYPESPEC,
3357 /* RID_PRIVATE */ 0,
3358 /* RID_PROTECTED */ 0,
3359 /* RID_TEMPLATE */ 0,
3364 /* RID_NAMESPACE */ 0,
3366 /* RID_OFFSETOF */ OFFSETOF,
3367 /* RID_OPERATOR */ 0,
3372 /* RID_TYPENAME */ 0,
3377 /* RID_CONSTCAST */ 0,
3378 /* RID_DYNCAST */ 0,
3379 /* RID_REINTCAST */ 0,
3380 /* RID_STATCAST */ 0,
3383 /* RID_ID */ OBJECTNAME,
3384 /* RID_AT_ENCODE */ AT_ENCODE,
3385 /* RID_AT_END */ AT_END,
3386 /* RID_AT_CLASS */ AT_CLASS,
3387 /* RID_AT_ALIAS */ AT_ALIAS,
3388 /* RID_AT_DEFS */ AT_DEFS,
3389 /* RID_AT_PRIVATE */ AT_PRIVATE,
3390 /* RID_AT_PROTECTED */ AT_PROTECTED,
3391 /* RID_AT_PUBLIC */ AT_PUBLIC,
3392 /* RID_AT_PROTOCOL */ AT_PROTOCOL,
3393 /* RID_AT_SELECTOR */ AT_SELECTOR,
3394 /* RID_AT_THROW */ AT_THROW,
3395 /* RID_AT_TRY */ AT_TRY,
3396 /* RID_AT_CATCH */ AT_CATCH,
3397 /* RID_AT_FINALLY */ AT_FINALLY,
3398 /* RID_AT_SYNCHRONIZED */ AT_SYNCHRONIZED,
3399 /* RID_AT_INTERFACE */ AT_INTERFACE,
3400 /* RID_AT_IMPLEMENTATION */ AT_IMPLEMENTATION
3404 init_reswords (void)
3408 int mask = (flag_isoc99 ? 0 : D_C89)
3409 | (flag_no_asm ? (flag_isoc99 ? D_EXT : D_EXT|D_EXT89) : 0);
3411 if (!c_dialect_objc ())
3414 ridpointers = ggc_calloc ((int) RID_MAX, sizeof (tree));
3415 for (i = 0; i < N_reswords; i++)
3417 /* If a keyword is disabled, do not enter it into the table
3418 and so create a canonical spelling that isn't a keyword. */
3419 if (reswords[i].disable & mask)
3422 id = get_identifier (reswords[i].word);
3423 C_RID_CODE (id) = reswords[i].rid;
3424 C_IS_RESERVED_WORD (id) = 1;
3425 ridpointers [(int) reswords[i].rid] = id;
3429 #define NAME(type) cpp_type2name (type)
3432 yyerror (const char *msgid)
3434 c_parse_error (msgid, last_token, yylval.ttype);
3443 int objc_force_identifier = objc_need_raw_identifier;
3444 OBJC_NEED_RAW_IDENTIFIER (0);
3447 if (C_IS_RESERVED_WORD (yylval.ttype))
3449 enum rid rid_code = C_RID_CODE (yylval.ttype);
3452 /* Turn non-typedefed refs to "id" into plain identifiers; this
3453 allows constructs like "void foo(id id);" to work. */
3454 if (rid_code == RID_ID)
3456 decl = lookup_name (yylval.ttype);
3457 if (decl == NULL_TREE || TREE_CODE (decl) != TYPE_DECL)
3461 if (!OBJC_IS_AT_KEYWORD (rid_code)
3462 && (!OBJC_IS_PQ_KEYWORD (rid_code) || objc_pq_context))
3465 /* Return the canonical spelling for this keyword. */
3466 yylval.ttype = ridpointers[(int) rid_code];
3467 return rid_to_yy[(int) rid_code];
3471 decl = lookup_name (yylval.ttype);
3474 if (TREE_CODE (decl) == TYPE_DECL)
3480 tree objc_interface_decl = is_class_name (yylval.ttype);
3481 /* ObjC class names are in the same namespace as variables and
3482 typedefs, and hence are shadowed by local declarations. */
3483 if (objc_interface_decl
3484 && (global_bindings_p ()
3485 || (!objc_force_identifier && !decl)))
3487 yylval.ttype = objc_interface_decl;
3500 last_token = c_lex (&yylval.ttype);
3503 case CPP_EQ: return '=';
3504 case CPP_NOT: return '!';
3505 case CPP_GREATER: yylval.code = GT_EXPR; return ARITHCOMPARE;
3506 case CPP_LESS: yylval.code = LT_EXPR; return ARITHCOMPARE;
3507 case CPP_PLUS: yylval.code = PLUS_EXPR; return '+';
3508 case CPP_MINUS: yylval.code = MINUS_EXPR; return '-';
3509 case CPP_MULT: yylval.code = MULT_EXPR; return '*';
3510 case CPP_DIV: yylval.code = TRUNC_DIV_EXPR; return '/';
3511 case CPP_MOD: yylval.code = TRUNC_MOD_EXPR; return '%';
3512 case CPP_AND: yylval.code = BIT_AND_EXPR; return '&';
3513 case CPP_OR: yylval.code = BIT_IOR_EXPR; return '|';
3514 case CPP_XOR: yylval.code = BIT_XOR_EXPR; return '^';
3515 case CPP_RSHIFT: yylval.code = RSHIFT_EXPR; return RSHIFT;
3516 case CPP_LSHIFT: yylval.code = LSHIFT_EXPR; return LSHIFT;
3518 case CPP_COMPL: return '~';
3519 case CPP_AND_AND: return ANDAND;
3520 case CPP_OR_OR: return OROR;
3521 case CPP_QUERY: return '?';
3522 case CPP_OPEN_PAREN: return '(';
3523 case CPP_EQ_EQ: yylval.code = EQ_EXPR; return EQCOMPARE;
3524 case CPP_NOT_EQ: yylval.code = NE_EXPR; return EQCOMPARE;
3525 case CPP_GREATER_EQ:yylval.code = GE_EXPR; return ARITHCOMPARE;
3526 case CPP_LESS_EQ: yylval.code = LE_EXPR; return ARITHCOMPARE;
3528 case CPP_PLUS_EQ: yylval.code = PLUS_EXPR; return ASSIGN;
3529 case CPP_MINUS_EQ: yylval.code = MINUS_EXPR; return ASSIGN;
3530 case CPP_MULT_EQ: yylval.code = MULT_EXPR; return ASSIGN;
3531 case CPP_DIV_EQ: yylval.code = TRUNC_DIV_EXPR; return ASSIGN;
3532 case CPP_MOD_EQ: yylval.code = TRUNC_MOD_EXPR; return ASSIGN;
3533 case CPP_AND_EQ: yylval.code = BIT_AND_EXPR; return ASSIGN;
3534 case CPP_OR_EQ: yylval.code = BIT_IOR_EXPR; return ASSIGN;
3535 case CPP_XOR_EQ: yylval.code = BIT_XOR_EXPR; return ASSIGN;
3536 case CPP_RSHIFT_EQ: yylval.code = RSHIFT_EXPR; return ASSIGN;
3537 case CPP_LSHIFT_EQ: yylval.code = LSHIFT_EXPR; return ASSIGN;
3539 case CPP_OPEN_SQUARE: return '[';
3540 case CPP_CLOSE_SQUARE: return ']';
3541 case CPP_OPEN_BRACE: return '{';
3542 case CPP_CLOSE_BRACE: return '}';
3543 case CPP_ELLIPSIS: return ELLIPSIS;
3545 case CPP_PLUS_PLUS: return PLUSPLUS;
3546 case CPP_MINUS_MINUS: return MINUSMINUS;
3547 case CPP_DEREF: return POINTSAT;
3548 case CPP_DOT: return '.';
3550 /* The following tokens may affect the interpretation of any
3551 identifiers following, if doing Objective-C. */
3552 case CPP_COLON: OBJC_NEED_RAW_IDENTIFIER (0); return ':';
3553 case CPP_COMMA: OBJC_NEED_RAW_IDENTIFIER (0); return ',';
3554 case CPP_CLOSE_PAREN: OBJC_NEED_RAW_IDENTIFIER (0); return ')';
3555 case CPP_SEMICOLON: OBJC_NEED_RAW_IDENTIFIER (0); return ';';
3561 return yylexname ();
3564 /* This only happens in Objective-C; it must be a keyword. */
3565 return rid_to_yy [(int) C_RID_CODE (yylval.ttype)];
3576 case CPP_OBJC_STRING:
3579 /* These tokens are C++ specific (and will not be generated
3580 in C mode, but let's be cautious). */
3582 case CPP_DEREF_STAR:
3588 /* These tokens should not survive translation phase 4. */
3591 error ("syntax error at '%s' token", NAME(last_token));
3604 timevar_push (TV_LEX);
3606 timevar_pop (TV_LEX);
3610 /* Function used when yydebug is set, to print a token in more detail. */
3613 yyprint (FILE *file, int yychar, YYSTYPE yyl)
3617 fprintf (file, " [%s]", NAME(last_token));
3628 if (IDENTIFIER_POINTER (t))
3629 fprintf (file, " `%s'", IDENTIFIER_POINTER (t));
3633 fprintf (file, " %s", GET_MODE_NAME (TYPE_MODE (TREE_TYPE (t))));
3634 if (TREE_CODE (t) == INTEGER_CST)
3637 fprintf (file, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
3638 TREE_INT_CST_HIGH (t), TREE_INT_CST_LOW (t));
3644 /* This is not the ideal place to put this, but we have to get it out
3645 of c-lex.c because cp/lex.c has its own version. */
3647 /* Parse the file. */
3655 free (malloced_yyss);
3656 free (malloced_yyvs);
3661 #include "gt-c-parse.h"