1 /* YACC parser for C syntax and for Objective C. -*-c-*-
2 Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996,
3 1997, 1998, 1999, 2000, 2001, 2002, 2003 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 10 /* shift/reduce conflicts, and no reduce/reduce conflicts. */
38 #include "coretypes.h"
45 #include "c-pragma.h" /* For YYDEBUG definition, and parse_in. */
53 #ifdef MULTIBYTE_CHARS
61 /* Like YYERROR but do call yyerror. */
62 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
64 /* Like the default stack expander, except (1) use realloc when possible,
65 (2) impose no hard maxiumum on stack size, (3) REALLY do not use alloca.
67 Irritatingly, YYSTYPE is defined after this %{ %} block, so we cannot
68 give malloced_yyvs its proper type. This is ok since all we need from
69 it is to be able to free it. */
71 static short *malloced_yyss;
72 static void *malloced_yyvs;
74 #define yyoverflow(MSG, SS, SSSIZE, VS, VSSIZE, YYSSZ) \
79 newsize = *(YYSSZ) *= 2; \
83 really_call_realloc (*(SS), newsize * sizeof (short)); \
85 really_call_realloc (*(VS), newsize * sizeof (YYSTYPE)); \
89 newss = (short *) really_call_malloc (newsize * sizeof (short)); \
90 newvs = (YYSTYPE *) really_call_malloc (newsize * sizeof (YYSTYPE)); \
92 memcpy (newss, *(SS), (SSSIZE)); \
94 memcpy (newvs, *(VS), (VSSIZE)); \
96 if (!newss || !newvs) \
103 malloced_yyss = newss; \
104 malloced_yyvs = (void *) newvs; \
110 %union {long itype; tree ttype; enum tree_code code;
111 location_t location; }
113 /* All identifiers that are not reserved words
114 and are not declared typedefs in the current block */
117 /* All identifiers that are declared typedefs in the current block.
118 In some contexts, they are treated just like IDENTIFIER,
119 but they can also serve as typespecs in declarations. */
122 /* Reserved words that specify storage class.
123 yylval contains an IDENTIFIER_NODE which indicates which one. */
124 %token SCSPEC /* Storage class other than static. */
125 %token STATIC /* Static storage class. */
127 /* Reserved words that specify type.
128 yylval contains an IDENTIFIER_NODE which indicates which one. */
131 /* Reserved words that qualify type: "const", "volatile", or "restrict".
132 yylval contains an IDENTIFIER_NODE which indicates which one. */
135 /* Character or numeric constants.
136 yylval is the node for the constant. */
139 /* String constants in raw form.
140 yylval is a STRING_CST node. */
144 /* "...", used for functions with variable arglists. */
147 /* the reserved words */
148 /* SCO include files test "ASM", so use something else. */
149 %token SIZEOF ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
150 %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD TYPEOF ALIGNOF
151 %token ATTRIBUTE EXTENSION LABEL
152 %token REALPART IMAGPART VA_ARG CHOOSE_EXPR TYPES_COMPATIBLE_P
153 %token PTR_VALUE PTR_BASE PTR_EXTENT
156 /* Add precedence rules to solve dangling else s/r conflict */
160 /* Define the operator tokens and their precedences.
161 The value is an integer because, if used, it is the tree code
162 to use in the expression made from the operator. */
164 %right <code> ASSIGN '='
165 %right <code> '?' ':'
171 %left <code> EQCOMPARE
172 %left <code> ARITHCOMPARE
173 %left <code> LSHIFT RSHIFT
175 %left <code> '*' '/' '%'
176 %right <code> UNARY PLUSPLUS MINUSMINUS
178 %left <code> POINTSAT '.' '(' '['
180 /* The Objective-C keywords. These are included in C and in
181 Objective C, so that the token codes are the same in both. */
182 %token INTERFACE IMPLEMENTATION END SELECTOR DEFS ENCODE
183 %token CLASSNAME PUBLIC PRIVATE PROTECTED PROTOCOL OBJECTNAME CLASS ALIAS
187 %type <ttype> ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
188 %type <ttype> BREAK CONTINUE RETURN GOTO ASM_KEYWORD SIZEOF TYPEOF ALIGNOF
190 %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist exprlist
191 %type <ttype> expr_no_commas cast_expr unary_expr primary STRING
192 %type <ttype> declspecs_nosc_nots_nosa_noea declspecs_nosc_nots_nosa_ea
193 %type <ttype> declspecs_nosc_nots_sa_noea declspecs_nosc_nots_sa_ea
194 %type <ttype> declspecs_nosc_ts_nosa_noea declspecs_nosc_ts_nosa_ea
195 %type <ttype> declspecs_nosc_ts_sa_noea declspecs_nosc_ts_sa_ea
196 %type <ttype> declspecs_sc_nots_nosa_noea declspecs_sc_nots_nosa_ea
197 %type <ttype> declspecs_sc_nots_sa_noea declspecs_sc_nots_sa_ea
198 %type <ttype> declspecs_sc_ts_nosa_noea declspecs_sc_ts_nosa_ea
199 %type <ttype> declspecs_sc_ts_sa_noea declspecs_sc_ts_sa_ea
200 %type <ttype> declspecs_ts declspecs_nots
201 %type <ttype> declspecs_ts_nosa declspecs_nots_nosa
202 %type <ttype> declspecs_nosc_ts declspecs_nosc_nots declspecs_nosc declspecs
203 %type <ttype> maybe_type_quals_attrs typespec_nonattr typespec_attr
204 %type <ttype> typespec_reserved_nonattr typespec_reserved_attr
205 %type <ttype> typespec_nonreserved_nonattr
207 %type <ttype> scspec SCSPEC STATIC TYPESPEC TYPE_QUAL maybe_type_qual
208 %type <ttype> initdecls notype_initdecls initdcl notype_initdcl
209 %type <ttype> init maybeasm
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 extension
214 %type <ttype> compstmt compstmt_start compstmt_nostart compstmt_primary_start
215 %type <ttype> do_stmt_start poplevel stmt label
217 %type <ttype> c99_block_start c99_block_end
218 %type <ttype> declarator
219 %type <ttype> notype_declarator after_type_declarator
220 %type <ttype> parm_declarator
221 %type <ttype> parm_declarator_starttypename parm_declarator_nostarttypename
222 %type <ttype> array_declarator
224 %type <ttype> structsp_attr structsp_nonattr
225 %type <ttype> component_decl_list component_decl_list2
226 %type <ttype> component_decl components components_notype component_declarator
227 %type <ttype> component_notype_declarator
228 %type <ttype> enumlist enumerator
229 %type <ttype> struct_head union_head enum_head
230 %type <ttype> typename absdcl absdcl1 absdcl1_ea absdcl1_noea
231 %type <ttype> direct_absdcl1 absdcl_maybe_attribute
232 %type <ttype> xexpr 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
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
257 /* Number of statements (loosely speaking) and compound statements
259 static int stmt_count;
260 static int compstmt_count;
262 /* Input location of the end of the body of last simple_if;
263 used by the stmt-rule immediately after simple_if returns. */
264 static location_t if_stmt_locus;
267 /* List of types and structure classes of the current declaration. */
268 static GTY(()) tree current_declspecs;
269 static GTY(()) tree prefix_attributes;
271 /* List of all the attributes applying to the identifier currently being
272 declared; includes prefix_attributes and possibly some more attributes
273 just after a comma. */
274 static GTY(()) tree all_prefix_attributes;
276 /* Stack of saved values of current_declspecs, prefix_attributes and
277 all_prefix_attributes. */
278 static GTY(()) tree declspec_stack;
280 /* PUSH_DECLSPEC_STACK is called from setspecs; POP_DECLSPEC_STACK
281 should be called from the productions making use of setspecs. */
282 #define PUSH_DECLSPEC_STACK \
284 declspec_stack = tree_cons (build_tree_list (prefix_attributes, \
285 all_prefix_attributes), \
290 #define POP_DECLSPEC_STACK \
292 current_declspecs = TREE_VALUE (declspec_stack); \
293 prefix_attributes = TREE_PURPOSE (TREE_PURPOSE (declspec_stack)); \
294 all_prefix_attributes = TREE_VALUE (TREE_PURPOSE (declspec_stack)); \
295 declspec_stack = TREE_CHAIN (declspec_stack); \
298 /* For __extension__, save/restore the warning flags which are
299 controlled by __extension__. */
300 #define SAVE_EXT_FLAGS() \
302 | (warn_pointer_arith << 1) \
303 | (warn_traditional << 2) \
306 #define RESTORE_EXT_FLAGS(tval) \
308 int val = tree_low_cst (tval, 0); \
309 pedantic = val & 1; \
310 warn_pointer_arith = (val >> 1) & 1; \
311 warn_traditional = (val >> 2) & 1; \
312 flag_iso = (val >> 3) & 1; \
316 /* Objective-C specific parser/lexer information */
318 static enum tree_code objc_inherit_code;
319 static int objc_pq_context = 0, objc_public_flag = 0;
321 /* The following flag is needed to contextualize ObjC lexical analysis.
322 In some cases (e.g., 'int NSObject;'), it is undesirable to bind
323 an identifier to an ObjC class, even if a class with that name
325 static int objc_need_raw_identifier;
326 #define OBJC_NEED_RAW_IDENTIFIER(VAL) objc_need_raw_identifier = VAL
330 #define OBJC_NEED_RAW_IDENTIFIER(VAL) /* nothing */
333 static bool parsing_iso_function_signature;
335 /* Tell yyparse how to print a token's value, if yydebug is set. */
337 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
339 static void yyprint PARAMS ((FILE *, int, YYSTYPE));
340 static void yyerror PARAMS ((const char *));
341 static int yylexname PARAMS ((void));
342 static inline int _yylex PARAMS ((void));
343 static int yylex PARAMS ((void));
344 static void init_reswords PARAMS ((void));
346 /* Initialisation routine for this file. */
358 pedwarn ("ISO C forbids an empty source file");
363 /* In case there were missing closebraces,
364 get us back to the global binding level. */
365 while (! global_bindings_p ())
367 /* __FUNCTION__ is defined at file scope (""). This
368 call may not be necessary as my tests indicate it
369 still works without it. */
370 finish_fname_decls ();
375 /* the reason for the strange actions in this rule
376 is so that notype_initdecls when reached via datadef
377 can find a valid list of type and sc specs in $0. */
380 {$<ttype>$ = NULL_TREE; } extdef
381 | extdefs {$<ttype>$ = NULL_TREE; ggc_collect(); } extdef
386 { parsing_iso_function_signature = false; } /* Reset after any external definition. */
395 | ASM_KEYWORD '(' expr ')' ';'
397 if ((TREE_CODE ($3) == ADDR_EXPR
398 && TREE_CODE (TREE_OPERAND ($3, 0)) == STRING_CST)
399 || TREE_CODE ($3) == STRING_CST)
402 error ("argument of `asm' is not a constant string"); }
404 { RESTORE_EXT_FLAGS ($1); }
408 setspecs notype_initdecls ';'
410 error ("ISO C forbids data definition with no type or storage class");
412 warning ("data definition has no type or storage class");
414 POP_DECLSPEC_STACK; }
415 | declspecs_nots setspecs notype_initdecls ';'
416 { POP_DECLSPEC_STACK; }
417 | declspecs_ts setspecs initdecls ';'
418 { POP_DECLSPEC_STACK; }
425 pedwarn ("ISO C does not allow extra `;' outside of a function"); }
429 declspecs_ts setspecs declarator
430 { if (! start_function (current_declspecs, $3,
431 all_prefix_attributes))
434 old_style_parm_decls save_location
435 { DECL_SOURCE_LOCATION (current_function_decl) = $6;
436 store_parm_decls (); }
438 { finish_function (0, 1);
439 POP_DECLSPEC_STACK; }
440 | declspecs_ts setspecs declarator error
441 { POP_DECLSPEC_STACK; }
442 | declspecs_nots setspecs notype_declarator
443 { if (! start_function (current_declspecs, $3,
444 all_prefix_attributes))
447 old_style_parm_decls save_location
448 { DECL_SOURCE_LOCATION (current_function_decl) = $6;
449 store_parm_decls (); }
451 { finish_function (0, 1);
452 POP_DECLSPEC_STACK; }
453 | declspecs_nots setspecs notype_declarator error
454 { POP_DECLSPEC_STACK; }
455 | setspecs notype_declarator
456 { if (! start_function (NULL_TREE, $2,
457 all_prefix_attributes))
460 old_style_parm_decls save_location
461 { DECL_SOURCE_LOCATION (current_function_decl) = $5;
462 store_parm_decls (); }
464 { finish_function (0, 1);
465 POP_DECLSPEC_STACK; }
466 | setspecs notype_declarator error
467 { POP_DECLSPEC_STACK; }
482 { $$ = NEGATE_EXPR; }
486 if (warn_traditional && !in_system_header)
487 warning ("traditional C rejects the unary plus operator");
491 { $$ = PREINCREMENT_EXPR; }
493 { $$ = PREDECREMENT_EXPR; }
495 { $$ = BIT_NOT_EXPR; }
497 { $$ = TRUTH_NOT_EXPR; }
500 expr: nonnull_exprlist
501 { $$ = build_compound_expr ($1); }
512 { $$ = build_tree_list (NULL_TREE, $1); }
513 | nonnull_exprlist ',' expr_no_commas
514 { chainon ($1, build_tree_list (NULL_TREE, $3)); }
519 | '*' cast_expr %prec UNARY
520 { $$ = build_indirect_ref ($2, "unary *"); }
521 /* __extension__ turns off -pedantic for following primary. */
522 | extension cast_expr %prec UNARY
524 RESTORE_EXT_FLAGS ($1); }
525 | unop cast_expr %prec UNARY
526 { $$ = build_unary_op ($1, $2, 0);
527 overflow_warning ($$); }
528 /* Refer to the address of a label as a pointer. */
530 { $$ = finish_label_address_expr ($2); }
531 | sizeof unary_expr %prec UNARY
533 if (TREE_CODE ($2) == COMPONENT_REF
534 && DECL_C_BIT_FIELD (TREE_OPERAND ($2, 1)))
535 error ("`sizeof' applied to a bit-field");
536 $$ = c_sizeof (TREE_TYPE ($2)); }
537 | sizeof '(' typename ')' %prec HYPERUNARY
539 $$ = c_sizeof (groktypename ($3)); }
540 | alignof unary_expr %prec UNARY
542 $$ = c_alignof_expr ($2); }
543 | alignof '(' typename ')' %prec HYPERUNARY
545 $$ = c_alignof (groktypename ($3)); }
546 | REALPART cast_expr %prec UNARY
547 { $$ = build_unary_op (REALPART_EXPR, $2, 0); }
548 | IMAGPART cast_expr %prec UNARY
549 { $$ = build_unary_op (IMAGPART_EXPR, $2, 0); }
553 SIZEOF { skip_evaluation++; }
557 ALIGNOF { skip_evaluation++; }
561 TYPEOF { skip_evaluation++; }
566 | '(' typename ')' cast_expr %prec UNARY
567 { $$ = c_cast_expr ($2, $4); }
572 | expr_no_commas '+' expr_no_commas
573 { $$ = parser_build_binary_op ($2, $1, $3); }
574 | expr_no_commas '-' expr_no_commas
575 { $$ = parser_build_binary_op ($2, $1, $3); }
576 | expr_no_commas '*' expr_no_commas
577 { $$ = parser_build_binary_op ($2, $1, $3); }
578 | expr_no_commas '/' expr_no_commas
579 { $$ = parser_build_binary_op ($2, $1, $3); }
580 | expr_no_commas '%' expr_no_commas
581 { $$ = parser_build_binary_op ($2, $1, $3); }
582 | expr_no_commas LSHIFT expr_no_commas
583 { $$ = parser_build_binary_op ($2, $1, $3); }
584 | expr_no_commas RSHIFT expr_no_commas
585 { $$ = parser_build_binary_op ($2, $1, $3); }
586 | expr_no_commas ARITHCOMPARE expr_no_commas
587 { $$ = parser_build_binary_op ($2, $1, $3); }
588 | expr_no_commas EQCOMPARE expr_no_commas
589 { $$ = parser_build_binary_op ($2, $1, $3); }
590 | expr_no_commas '&' expr_no_commas
591 { $$ = parser_build_binary_op ($2, $1, $3); }
592 | expr_no_commas '|' expr_no_commas
593 { $$ = parser_build_binary_op ($2, $1, $3); }
594 | expr_no_commas '^' expr_no_commas
595 { $$ = parser_build_binary_op ($2, $1, $3); }
596 | expr_no_commas ANDAND
597 { $1 = c_common_truthvalue_conversion
598 (default_conversion ($1));
599 skip_evaluation += $1 == boolean_false_node; }
601 { skip_evaluation -= $1 == boolean_false_node;
602 $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $4); }
603 | expr_no_commas OROR
604 { $1 = c_common_truthvalue_conversion
605 (default_conversion ($1));
606 skip_evaluation += $1 == boolean_true_node; }
608 { skip_evaluation -= $1 == boolean_true_node;
609 $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $4); }
611 { $1 = c_common_truthvalue_conversion
612 (default_conversion ($1));
613 skip_evaluation += $1 == boolean_false_node; }
615 { skip_evaluation += (($1 == boolean_true_node)
616 - ($1 == boolean_false_node)); }
618 { skip_evaluation -= $1 == boolean_true_node;
619 $$ = build_conditional_expr ($1, $4, $7); }
622 pedwarn ("ISO C forbids omitting the middle term of a ?: expression");
623 /* Make sure first operand is calculated only once. */
624 $<ttype>2 = save_expr ($1);
625 $1 = c_common_truthvalue_conversion
626 (default_conversion ($<ttype>2));
627 skip_evaluation += $1 == boolean_true_node; }
629 { skip_evaluation -= $1 == boolean_true_node;
630 $$ = build_conditional_expr ($1, $<ttype>2, $5); }
631 | expr_no_commas '=' expr_no_commas
633 $$ = build_modify_expr ($1, NOP_EXPR, $3);
634 class = TREE_CODE_CLASS (TREE_CODE ($$));
635 if (IS_EXPR_CODE_CLASS (class))
636 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR);
638 | expr_no_commas ASSIGN expr_no_commas
640 $$ = build_modify_expr ($1, $2, $3);
641 /* This inhibits warnings in
642 c_common_truthvalue_conversion. */
643 class = TREE_CODE_CLASS (TREE_CODE ($$));
644 if (IS_EXPR_CODE_CLASS (class))
645 C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK);
652 if (yychar == YYEMPTY)
654 $$ = build_external_ref ($1, yychar == '(');
659 { $$ = fname_decl (C_RID_CODE ($$), $$); }
660 | '(' typename ')' '{'
661 { start_init (NULL_TREE, NULL, 0);
662 $2 = groktypename ($2);
663 really_start_incremental_init ($2); }
664 initlist_maybe_comma '}' %prec UNARY
665 { tree constructor = pop_init_level (0);
669 if (pedantic && ! flag_isoc99)
670 pedwarn ("ISO C89 forbids compound literals");
671 $$ = build_compound_literal (type, constructor);
674 { char class = TREE_CODE_CLASS (TREE_CODE ($2));
675 if (IS_EXPR_CODE_CLASS (class))
676 C_SET_EXP_ORIGINAL_CODE ($2, ERROR_MARK);
679 { $$ = error_mark_node; }
680 | compstmt_primary_start compstmt_nostart ')'
681 { tree saved_last_tree;
684 pedwarn ("ISO C forbids braced-groups within expressions");
687 saved_last_tree = COMPOUND_BODY ($1);
688 RECHAIN_STMTS ($1, COMPOUND_BODY ($1));
689 last_tree = saved_last_tree;
690 TREE_CHAIN (last_tree) = NULL_TREE;
692 last_expr_type = void_type_node;
693 $$ = build1 (STMT_EXPR, last_expr_type, $1);
694 TREE_SIDE_EFFECTS ($$) = 1;
696 | compstmt_primary_start error ')'
699 last_tree = COMPOUND_BODY ($1);
700 TREE_CHAIN (last_tree) = NULL_TREE;
701 $$ = error_mark_node;
703 | primary '(' exprlist ')' %prec '.'
704 { $$ = build_function_call ($1, $3); }
705 | VA_ARG '(' expr_no_commas ',' typename ')'
706 { $$ = build_va_arg ($3, groktypename ($5)); }
708 | CHOOSE_EXPR '(' expr_no_commas ',' expr_no_commas ',' expr_no_commas ')'
714 if (TREE_CODE (c) != INTEGER_CST)
715 error ("first argument to __builtin_choose_expr not a constant");
716 $$ = integer_zerop (c) ? $7 : $5;
718 | TYPES_COMPATIBLE_P '(' typename ',' typename ')'
722 e1 = TYPE_MAIN_VARIANT (groktypename ($3));
723 e2 = TYPE_MAIN_VARIANT (groktypename ($5));
725 $$ = comptypes (e1, e2)
726 ? build_int_2 (1, 0) : build_int_2 (0, 0);
728 | primary '[' expr ']' %prec '.'
729 { $$ = build_array_ref ($1, $3); }
730 | primary '.' identifier
733 if (!is_public ($1, $3))
734 $$ = error_mark_node;
737 $$ = build_component_ref ($1, $3);
739 | primary POINTSAT identifier
741 tree expr = build_indirect_ref ($1, "->");
744 if (!is_public (expr, $3))
745 $$ = error_mark_node;
748 $$ = build_component_ref (expr, $3);
751 { $$ = build_unary_op (POSTINCREMENT_EXPR, $1, 0); }
753 { $$ = build_unary_op (POSTDECREMENT_EXPR, $1, 0); }
756 { $$ = build_message_expr ($1); }
758 { $$ = build_selector_expr ($1); }
760 { $$ = build_protocol_expr ($1); }
762 { $$ = build_encode_expr ($1); }
764 { $$ = build_objc_string_object ($1); }
768 old_style_parm_decls:
769 old_style_parm_decls_1
771 parsing_iso_function_signature = false; /* Reset after decls. */
775 old_style_parm_decls_1:
778 if (warn_traditional && !in_system_header
779 && parsing_iso_function_signature)
780 warning ("traditional C rejects ISO C style function definitions");
781 parsing_iso_function_signature = false; /* Reset after warning. */
786 /* The following are analogous to lineno_decl, decls and decl
787 except that they do not allow nested functions.
788 They are used for old-style parm decls. */
790 save_location datadecl
797 | datadecls lineno_datadecl
798 | lineno_datadecl errstmt
801 /* We don't allow prefix attributes here because they cause reduce/reduce
802 conflicts: we can't know whether we're parsing a function decl with
803 attribute suffix, or function defn with attribute prefix on first old
806 declspecs_ts_nosa setspecs initdecls ';'
807 { POP_DECLSPEC_STACK; }
808 | declspecs_nots_nosa setspecs notype_initdecls ';'
809 { POP_DECLSPEC_STACK; }
810 | declspecs_ts_nosa ';'
811 { shadow_tag_warned ($1, 1);
812 pedwarn ("empty declaration"); }
813 | declspecs_nots_nosa ';'
814 { pedwarn ("empty declaration"); }
817 /* This combination which saves a lineno before a decl
818 is the normal thing to use, rather than decl itself.
819 This is to avoid shift/reduce conflicts in contexts
820 where statement labels are allowed. */
826 /* records the type and storage class specs to use for processing
827 the declarators that follow.
828 Maintains a stack of outer-level values of current_declspecs,
829 for the sake of parm declarations nested in function declarators. */
830 setspecs: /* empty */
831 { pending_xref_error ();
833 split_specs_attrs ($<ttype>0,
834 ¤t_declspecs, &prefix_attributes);
835 all_prefix_attributes = prefix_attributes; }
838 /* Possibly attributes after a comma, which should reset all_prefix_attributes
839 to prefix_attributes with these ones chained on the front. */
842 { all_prefix_attributes = chainon ($1, prefix_attributes); }
846 declspecs_ts setspecs initdecls ';'
847 { POP_DECLSPEC_STACK; }
848 | declspecs_nots setspecs notype_initdecls ';'
849 { POP_DECLSPEC_STACK; }
850 | declspecs_ts setspecs nested_function
851 { POP_DECLSPEC_STACK; }
852 | declspecs_nots setspecs notype_nested_function
853 { POP_DECLSPEC_STACK; }
857 { RESTORE_EXT_FLAGS ($1); }
860 /* A list of declaration specifiers. These are:
862 - Storage class specifiers (scspec), which for GCC currently includes
863 function specifiers ("inline").
865 - Type specifiers (typespec_*).
867 - Type qualifiers (TYPE_QUAL).
869 - Attribute specifier lists (attributes).
871 These are stored as a TREE_LIST; the head of the list is the last
872 item in the specifier list. Each entry in the list has either a
873 TREE_PURPOSE that is an attribute specifier list, or a TREE_VALUE that
874 is a single other specifier or qualifier; and a TREE_CHAIN that is the
875 rest of the list. TREE_STATIC is set on the list if something other
876 than a storage class specifier or attribute has been seen; this is used
877 to warn for the obsolescent usage of storage class specifiers other than
878 at the start of the list. (Doing this properly would require function
879 specifiers to be handled separately from storage class specifiers.)
881 The various cases below are classified according to:
883 (a) Whether a storage class specifier is included or not; some
884 places in the grammar disallow storage class specifiers (_sc or _nosc).
886 (b) Whether a type specifier has been seen; after a type specifier,
887 a typedef name is an identifier to redeclare (_ts or _nots).
889 (c) Whether the list starts with an attribute; in certain places,
890 the grammar requires specifiers that don't start with an attribute
893 (d) Whether the list ends with an attribute (or a specifier such that
894 any following attribute would have been parsed as part of that specifier);
895 this avoids shift-reduce conflicts in the parsing of attributes
900 (i) Distinguish between function specifiers and storage class specifiers,
901 at least for the purpose of warnings about obsolescent usage.
903 (ii) Halve the number of productions here by eliminating the _sc/_nosc
904 distinction and instead checking where required that storage class
905 specifiers aren't present. */
907 /* Declspecs which contain at least one type specifier or typedef name.
908 (Just `const' or `volatile' is not enough.)
909 A typedef'd name following these is taken as a name to be declared.
910 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
912 declspecs_nosc_nots_nosa_noea:
914 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
915 TREE_STATIC ($$) = 1; }
916 | declspecs_nosc_nots_nosa_noea TYPE_QUAL
917 { $$ = tree_cons (NULL_TREE, $2, $1);
918 TREE_STATIC ($$) = 1; }
919 | declspecs_nosc_nots_nosa_ea TYPE_QUAL
920 { $$ = tree_cons (NULL_TREE, $2, $1);
921 TREE_STATIC ($$) = 1; }
924 declspecs_nosc_nots_nosa_ea:
925 declspecs_nosc_nots_nosa_noea attributes
926 { $$ = tree_cons ($2, NULL_TREE, $1);
927 TREE_STATIC ($$) = TREE_STATIC ($1); }
930 declspecs_nosc_nots_sa_noea:
931 declspecs_nosc_nots_sa_noea TYPE_QUAL
932 { $$ = tree_cons (NULL_TREE, $2, $1);
933 TREE_STATIC ($$) = 1; }
934 | declspecs_nosc_nots_sa_ea TYPE_QUAL
935 { $$ = tree_cons (NULL_TREE, $2, $1);
936 TREE_STATIC ($$) = 1; }
939 declspecs_nosc_nots_sa_ea:
941 { $$ = tree_cons ($1, NULL_TREE, NULL_TREE);
942 TREE_STATIC ($$) = 0; }
943 | declspecs_nosc_nots_sa_noea attributes
944 { $$ = tree_cons ($2, NULL_TREE, $1);
945 TREE_STATIC ($$) = TREE_STATIC ($1); }
948 declspecs_nosc_ts_nosa_noea:
950 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
951 TREE_STATIC ($$) = 1; }
952 | declspecs_nosc_ts_nosa_noea TYPE_QUAL
953 { $$ = tree_cons (NULL_TREE, $2, $1);
954 TREE_STATIC ($$) = 1; }
955 | declspecs_nosc_ts_nosa_ea TYPE_QUAL
956 { $$ = tree_cons (NULL_TREE, $2, $1);
957 TREE_STATIC ($$) = 1; }
958 | declspecs_nosc_ts_nosa_noea typespec_reserved_nonattr
959 { $$ = tree_cons (NULL_TREE, $2, $1);
960 TREE_STATIC ($$) = 1; }
961 | declspecs_nosc_ts_nosa_ea typespec_reserved_nonattr
962 { $$ = tree_cons (NULL_TREE, $2, $1);
963 TREE_STATIC ($$) = 1; }
964 | declspecs_nosc_nots_nosa_noea typespec_nonattr
965 { $$ = tree_cons (NULL_TREE, $2, $1);
966 TREE_STATIC ($$) = 1; }
967 | declspecs_nosc_nots_nosa_ea typespec_nonattr
968 { $$ = tree_cons (NULL_TREE, $2, $1);
969 TREE_STATIC ($$) = 1; }
972 declspecs_nosc_ts_nosa_ea:
974 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
975 TREE_STATIC ($$) = 1; }
976 | declspecs_nosc_ts_nosa_noea attributes
977 { $$ = tree_cons ($2, NULL_TREE, $1);
978 TREE_STATIC ($$) = TREE_STATIC ($1); }
979 | declspecs_nosc_ts_nosa_noea typespec_reserved_attr
980 { $$ = tree_cons (NULL_TREE, $2, $1);
981 TREE_STATIC ($$) = 1; }
982 | declspecs_nosc_ts_nosa_ea typespec_reserved_attr
983 { $$ = tree_cons (NULL_TREE, $2, $1);
984 TREE_STATIC ($$) = 1; }
985 | declspecs_nosc_nots_nosa_noea typespec_attr
986 { $$ = tree_cons (NULL_TREE, $2, $1);
987 TREE_STATIC ($$) = 1; }
988 | declspecs_nosc_nots_nosa_ea typespec_attr
989 { $$ = tree_cons (NULL_TREE, $2, $1);
990 TREE_STATIC ($$) = 1; }
993 declspecs_nosc_ts_sa_noea:
994 declspecs_nosc_ts_sa_noea TYPE_QUAL
995 { $$ = tree_cons (NULL_TREE, $2, $1);
996 TREE_STATIC ($$) = 1; }
997 | declspecs_nosc_ts_sa_ea TYPE_QUAL
998 { $$ = tree_cons (NULL_TREE, $2, $1);
999 TREE_STATIC ($$) = 1; }
1000 | declspecs_nosc_ts_sa_noea typespec_reserved_nonattr
1001 { $$ = tree_cons (NULL_TREE, $2, $1);
1002 TREE_STATIC ($$) = 1; }
1003 | declspecs_nosc_ts_sa_ea typespec_reserved_nonattr
1004 { $$ = tree_cons (NULL_TREE, $2, $1);
1005 TREE_STATIC ($$) = 1; }
1006 | declspecs_nosc_nots_sa_noea typespec_nonattr
1007 { $$ = tree_cons (NULL_TREE, $2, $1);
1008 TREE_STATIC ($$) = 1; }
1009 | declspecs_nosc_nots_sa_ea typespec_nonattr
1010 { $$ = tree_cons (NULL_TREE, $2, $1);
1011 TREE_STATIC ($$) = 1; }
1014 declspecs_nosc_ts_sa_ea:
1015 declspecs_nosc_ts_sa_noea attributes
1016 { $$ = tree_cons ($2, NULL_TREE, $1);
1017 TREE_STATIC ($$) = TREE_STATIC ($1); }
1018 | declspecs_nosc_ts_sa_noea typespec_reserved_attr
1019 { $$ = tree_cons (NULL_TREE, $2, $1);
1020 TREE_STATIC ($$) = 1; }
1021 | declspecs_nosc_ts_sa_ea typespec_reserved_attr
1022 { $$ = tree_cons (NULL_TREE, $2, $1);
1023 TREE_STATIC ($$) = 1; }
1024 | declspecs_nosc_nots_sa_noea typespec_attr
1025 { $$ = tree_cons (NULL_TREE, $2, $1);
1026 TREE_STATIC ($$) = 1; }
1027 | declspecs_nosc_nots_sa_ea typespec_attr
1028 { $$ = tree_cons (NULL_TREE, $2, $1);
1029 TREE_STATIC ($$) = 1; }
1032 declspecs_sc_nots_nosa_noea:
1034 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
1035 TREE_STATIC ($$) = 0; }
1036 | declspecs_sc_nots_nosa_noea TYPE_QUAL
1037 { $$ = tree_cons (NULL_TREE, $2, $1);
1038 TREE_STATIC ($$) = 1; }
1039 | declspecs_sc_nots_nosa_ea TYPE_QUAL
1040 { $$ = tree_cons (NULL_TREE, $2, $1);
1041 TREE_STATIC ($$) = 1; }
1042 | declspecs_nosc_nots_nosa_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_nosc_nots_nosa_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); }
1054 | declspecs_sc_nots_nosa_noea scspec
1055 { if (extra_warnings && TREE_STATIC ($1))
1056 warning ("`%s' is not at beginning of declaration",
1057 IDENTIFIER_POINTER ($2));
1058 $$ = tree_cons (NULL_TREE, $2, $1);
1059 TREE_STATIC ($$) = TREE_STATIC ($1); }
1060 | declspecs_sc_nots_nosa_ea scspec
1061 { if (extra_warnings && TREE_STATIC ($1))
1062 warning ("`%s' is not at beginning of declaration",
1063 IDENTIFIER_POINTER ($2));
1064 $$ = tree_cons (NULL_TREE, $2, $1);
1065 TREE_STATIC ($$) = TREE_STATIC ($1); }
1068 declspecs_sc_nots_nosa_ea:
1069 declspecs_sc_nots_nosa_noea attributes
1070 { $$ = tree_cons ($2, NULL_TREE, $1);
1071 TREE_STATIC ($$) = TREE_STATIC ($1); }
1074 declspecs_sc_nots_sa_noea:
1075 declspecs_sc_nots_sa_noea TYPE_QUAL
1076 { $$ = tree_cons (NULL_TREE, $2, $1);
1077 TREE_STATIC ($$) = 1; }
1078 | declspecs_sc_nots_sa_ea TYPE_QUAL
1079 { $$ = tree_cons (NULL_TREE, $2, $1);
1080 TREE_STATIC ($$) = 1; }
1081 | declspecs_nosc_nots_sa_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_nots_sa_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_nots_sa_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_nots_sa_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_nots_sa_ea:
1108 declspecs_sc_nots_sa_noea attributes
1109 { $$ = tree_cons ($2, NULL_TREE, $1);
1110 TREE_STATIC ($$) = TREE_STATIC ($1); }
1113 declspecs_sc_ts_nosa_noea:
1114 declspecs_sc_ts_nosa_noea TYPE_QUAL
1115 { $$ = tree_cons (NULL_TREE, $2, $1);
1116 TREE_STATIC ($$) = 1; }
1117 | declspecs_sc_ts_nosa_ea TYPE_QUAL
1118 { $$ = tree_cons (NULL_TREE, $2, $1);
1119 TREE_STATIC ($$) = 1; }
1120 | declspecs_sc_ts_nosa_noea typespec_reserved_nonattr
1121 { $$ = tree_cons (NULL_TREE, $2, $1);
1122 TREE_STATIC ($$) = 1; }
1123 | declspecs_sc_ts_nosa_ea typespec_reserved_nonattr
1124 { $$ = tree_cons (NULL_TREE, $2, $1);
1125 TREE_STATIC ($$) = 1; }
1126 | declspecs_sc_nots_nosa_noea typespec_nonattr
1127 { $$ = tree_cons (NULL_TREE, $2, $1);
1128 TREE_STATIC ($$) = 1; }
1129 | declspecs_sc_nots_nosa_ea typespec_nonattr
1130 { $$ = tree_cons (NULL_TREE, $2, $1);
1131 TREE_STATIC ($$) = 1; }
1132 | declspecs_nosc_ts_nosa_noea scspec
1133 { if (extra_warnings && TREE_STATIC ($1))
1134 warning ("`%s' is not at beginning of declaration",
1135 IDENTIFIER_POINTER ($2));
1136 $$ = tree_cons (NULL_TREE, $2, $1);
1137 TREE_STATIC ($$) = TREE_STATIC ($1); }
1138 | declspecs_nosc_ts_nosa_ea scspec
1139 { if (extra_warnings && TREE_STATIC ($1))
1140 warning ("`%s' is not at beginning of declaration",
1141 IDENTIFIER_POINTER ($2));
1142 $$ = tree_cons (NULL_TREE, $2, $1);
1143 TREE_STATIC ($$) = TREE_STATIC ($1); }
1144 | declspecs_sc_ts_nosa_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_sc_ts_nosa_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); }
1158 declspecs_sc_ts_nosa_ea:
1159 declspecs_sc_ts_nosa_noea attributes
1160 { $$ = tree_cons ($2, NULL_TREE, $1);
1161 TREE_STATIC ($$) = TREE_STATIC ($1); }
1162 | declspecs_sc_ts_nosa_noea typespec_reserved_attr
1163 { $$ = tree_cons (NULL_TREE, $2, $1);
1164 TREE_STATIC ($$) = 1; }
1165 | declspecs_sc_ts_nosa_ea typespec_reserved_attr
1166 { $$ = tree_cons (NULL_TREE, $2, $1);
1167 TREE_STATIC ($$) = 1; }
1168 | declspecs_sc_nots_nosa_noea typespec_attr
1169 { $$ = tree_cons (NULL_TREE, $2, $1);
1170 TREE_STATIC ($$) = 1; }
1171 | declspecs_sc_nots_nosa_ea typespec_attr
1172 { $$ = tree_cons (NULL_TREE, $2, $1);
1173 TREE_STATIC ($$) = 1; }
1176 declspecs_sc_ts_sa_noea:
1177 declspecs_sc_ts_sa_noea TYPE_QUAL
1178 { $$ = tree_cons (NULL_TREE, $2, $1);
1179 TREE_STATIC ($$) = 1; }
1180 | declspecs_sc_ts_sa_ea TYPE_QUAL
1181 { $$ = tree_cons (NULL_TREE, $2, $1);
1182 TREE_STATIC ($$) = 1; }
1183 | declspecs_sc_ts_sa_noea typespec_reserved_nonattr
1184 { $$ = tree_cons (NULL_TREE, $2, $1);
1185 TREE_STATIC ($$) = 1; }
1186 | declspecs_sc_ts_sa_ea typespec_reserved_nonattr
1187 { $$ = tree_cons (NULL_TREE, $2, $1);
1188 TREE_STATIC ($$) = 1; }
1189 | declspecs_sc_nots_sa_noea typespec_nonattr
1190 { $$ = tree_cons (NULL_TREE, $2, $1);
1191 TREE_STATIC ($$) = 1; }
1192 | declspecs_sc_nots_sa_ea typespec_nonattr
1193 { $$ = tree_cons (NULL_TREE, $2, $1);
1194 TREE_STATIC ($$) = 1; }
1195 | declspecs_nosc_ts_sa_noea scspec
1196 { if (extra_warnings && TREE_STATIC ($1))
1197 warning ("`%s' is not at beginning of declaration",
1198 IDENTIFIER_POINTER ($2));
1199 $$ = tree_cons (NULL_TREE, $2, $1);
1200 TREE_STATIC ($$) = TREE_STATIC ($1); }
1201 | declspecs_nosc_ts_sa_ea scspec
1202 { if (extra_warnings && TREE_STATIC ($1))
1203 warning ("`%s' is not at beginning of declaration",
1204 IDENTIFIER_POINTER ($2));
1205 $$ = tree_cons (NULL_TREE, $2, $1);
1206 TREE_STATIC ($$) = TREE_STATIC ($1); }
1207 | declspecs_sc_ts_sa_noea scspec
1208 { if (extra_warnings && TREE_STATIC ($1))
1209 warning ("`%s' is not at beginning of declaration",
1210 IDENTIFIER_POINTER ($2));
1211 $$ = tree_cons (NULL_TREE, $2, $1);
1212 TREE_STATIC ($$) = TREE_STATIC ($1); }
1213 | declspecs_sc_ts_sa_ea scspec
1214 { if (extra_warnings && TREE_STATIC ($1))
1215 warning ("`%s' is not at beginning of declaration",
1216 IDENTIFIER_POINTER ($2));
1217 $$ = tree_cons (NULL_TREE, $2, $1);
1218 TREE_STATIC ($$) = TREE_STATIC ($1); }
1221 declspecs_sc_ts_sa_ea:
1222 declspecs_sc_ts_sa_noea attributes
1223 { $$ = tree_cons ($2, NULL_TREE, $1);
1224 TREE_STATIC ($$) = TREE_STATIC ($1); }
1225 | declspecs_sc_ts_sa_noea typespec_reserved_attr
1226 { $$ = tree_cons (NULL_TREE, $2, $1);
1227 TREE_STATIC ($$) = 1; }
1228 | declspecs_sc_ts_sa_ea typespec_reserved_attr
1229 { $$ = tree_cons (NULL_TREE, $2, $1);
1230 TREE_STATIC ($$) = 1; }
1231 | declspecs_sc_nots_sa_noea typespec_attr
1232 { $$ = tree_cons (NULL_TREE, $2, $1);
1233 TREE_STATIC ($$) = 1; }
1234 | declspecs_sc_nots_sa_ea typespec_attr
1235 { $$ = tree_cons (NULL_TREE, $2, $1);
1236 TREE_STATIC ($$) = 1; }
1239 /* Particular useful classes of declspecs. */
1241 declspecs_nosc_ts_nosa_noea
1242 | declspecs_nosc_ts_nosa_ea
1243 | declspecs_nosc_ts_sa_noea
1244 | declspecs_nosc_ts_sa_ea
1245 | declspecs_sc_ts_nosa_noea
1246 | declspecs_sc_ts_nosa_ea
1247 | declspecs_sc_ts_sa_noea
1248 | declspecs_sc_ts_sa_ea
1252 declspecs_nosc_nots_nosa_noea
1253 | declspecs_nosc_nots_nosa_ea
1254 | declspecs_nosc_nots_sa_noea
1255 | declspecs_nosc_nots_sa_ea
1256 | declspecs_sc_nots_nosa_noea
1257 | declspecs_sc_nots_nosa_ea
1258 | declspecs_sc_nots_sa_noea
1259 | declspecs_sc_nots_sa_ea
1263 declspecs_nosc_ts_nosa_noea
1264 | declspecs_nosc_ts_nosa_ea
1265 | declspecs_sc_ts_nosa_noea
1266 | declspecs_sc_ts_nosa_ea
1269 declspecs_nots_nosa:
1270 declspecs_nosc_nots_nosa_noea
1271 | declspecs_nosc_nots_nosa_ea
1272 | declspecs_sc_nots_nosa_noea
1273 | declspecs_sc_nots_nosa_ea
1277 declspecs_nosc_ts_nosa_noea
1278 | declspecs_nosc_ts_nosa_ea
1279 | declspecs_nosc_ts_sa_noea
1280 | declspecs_nosc_ts_sa_ea
1283 declspecs_nosc_nots:
1284 declspecs_nosc_nots_nosa_noea
1285 | declspecs_nosc_nots_nosa_ea
1286 | declspecs_nosc_nots_sa_noea
1287 | declspecs_nosc_nots_sa_ea
1291 declspecs_nosc_ts_nosa_noea
1292 | declspecs_nosc_ts_nosa_ea
1293 | declspecs_nosc_ts_sa_noea
1294 | declspecs_nosc_ts_sa_ea
1295 | declspecs_nosc_nots_nosa_noea
1296 | declspecs_nosc_nots_nosa_ea
1297 | declspecs_nosc_nots_sa_noea
1298 | declspecs_nosc_nots_sa_ea
1302 declspecs_nosc_nots_nosa_noea
1303 | declspecs_nosc_nots_nosa_ea
1304 | declspecs_nosc_nots_sa_noea
1305 | declspecs_nosc_nots_sa_ea
1306 | declspecs_nosc_ts_nosa_noea
1307 | declspecs_nosc_ts_nosa_ea
1308 | declspecs_nosc_ts_sa_noea
1309 | declspecs_nosc_ts_sa_ea
1310 | declspecs_sc_nots_nosa_noea
1311 | declspecs_sc_nots_nosa_ea
1312 | declspecs_sc_nots_sa_noea
1313 | declspecs_sc_nots_sa_ea
1314 | declspecs_sc_ts_nosa_noea
1315 | declspecs_sc_ts_nosa_ea
1316 | declspecs_sc_ts_sa_noea
1317 | declspecs_sc_ts_sa_ea
1320 /* A (possibly empty) sequence of type qualifiers and attributes. */
1321 maybe_type_quals_attrs:
1324 | declspecs_nosc_nots
1328 /* A type specifier (but not a type qualifier).
1329 Once we have seen one of these in a declaration,
1330 if a typedef name appears then it is being redeclared.
1332 The _reserved versions start with a reserved word and may appear anywhere
1333 in the declaration specifiers; the _nonreserved versions may only
1334 appear before any other type specifiers, and after that are (if names)
1337 FIXME: should the _nonreserved version be restricted to names being
1338 redeclared only? The other entries there relate only the GNU extensions
1339 and Objective C, and are historically parsed thus, and don't make sense
1340 after other type specifiers, but it might be cleaner to count them as
1343 _attr means: specifiers that either end with attributes,
1344 or are such that any following attributes would
1345 be parsed as part of the specifier.
1347 _nonattr: specifiers. */
1350 typespec_reserved_nonattr
1351 | typespec_nonreserved_nonattr
1355 typespec_reserved_attr
1358 typespec_reserved_nonattr:
1360 { OBJC_NEED_RAW_IDENTIFIER (1); }
1364 typespec_reserved_attr:
1368 typespec_nonreserved_nonattr:
1370 { /* For a typedef name, record the meaning, not the name.
1371 In case of `foo foo, bar;'. */
1372 $$ = lookup_name ($1); }
1374 | CLASSNAME protocolrefs
1375 { $$ = get_static_reference ($1, $2); }
1376 | OBJECTNAME protocolrefs
1377 { $$ = get_object_reference ($2); }
1379 /* Make "<SomeProtocol>" equivalent to "id <SomeProtocol>"
1380 - nisse@lysator.liu.se */
1381 | non_empty_protocolrefs
1382 { $$ = get_object_reference ($1); }
1384 | typeof '(' expr ')'
1385 { skip_evaluation--; $$ = TREE_TYPE ($3); }
1386 | typeof '(' typename ')'
1387 { skip_evaluation--; $$ = groktypename ($3); }
1390 /* typespec_nonreserved_attr does not exist. */
1394 | initdecls ',' maybe_resetattrs initdcl
1399 | notype_initdecls ',' maybe_resetattrs notype_initdcl
1405 | ASM_KEYWORD '(' STRING ')'
1410 declarator maybeasm maybe_attribute '='
1411 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1412 chainon ($3, all_prefix_attributes));
1413 start_init ($<ttype>$, $2, global_bindings_p ()); }
1415 /* Note how the declaration of the variable is in effect while its init is parsed! */
1417 finish_decl ($<ttype>5, $6, $2); }
1418 | declarator maybeasm maybe_attribute
1419 { tree d = start_decl ($1, current_declspecs, 0,
1420 chainon ($3, all_prefix_attributes));
1421 finish_decl (d, NULL_TREE, $2);
1426 notype_declarator maybeasm maybe_attribute '='
1427 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1428 chainon ($3, all_prefix_attributes));
1429 start_init ($<ttype>$, $2, global_bindings_p ()); }
1431 /* Note how the declaration of the variable is in effect while its init is parsed! */
1433 finish_decl ($<ttype>5, $6, $2); }
1434 | notype_declarator maybeasm maybe_attribute
1435 { tree d = start_decl ($1, current_declspecs, 0,
1436 chainon ($3, all_prefix_attributes));
1437 finish_decl (d, NULL_TREE, $2); }
1439 /* the * rules are dummies to accept the Apollo extended syntax
1440 so that the header files compile. */
1451 | attributes attribute
1452 { $$ = chainon ($1, $2); }
1456 ATTRIBUTE '(' '(' attribute_list ')' ')'
1463 | attribute_list ',' attrib
1464 { $$ = chainon ($1, $3); }
1471 { $$ = build_tree_list ($1, NULL_TREE); }
1472 | any_word '(' IDENTIFIER ')'
1473 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1474 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1475 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1476 | any_word '(' exprlist ')'
1477 { $$ = build_tree_list ($1, $3); }
1480 /* This still leaves out most reserved keywords,
1481 shouldn't we include them? */
1495 /* Initializers. `init' is the entry point. */
1500 { really_start_incremental_init (NULL_TREE); }
1501 initlist_maybe_comma '}'
1502 { $$ = pop_init_level (0); }
1504 { $$ = error_mark_node; }
1507 /* `initlist_maybe_comma' is the guts of an initializer in braces. */
1508 initlist_maybe_comma:
1511 pedwarn ("ISO C forbids empty initializer braces"); }
1512 | initlist1 maybecomma
1517 | initlist1 ',' initelt
1520 /* `initelt' is a single element of an initializer.
1521 It may use braces. */
1523 designator_list '=' initval
1524 { if (pedantic && ! flag_isoc99)
1525 pedwarn ("ISO C89 forbids specifying subobject to initialize"); }
1526 | designator initval
1528 pedwarn ("obsolete use of designated initializer without `='"); }
1530 { set_init_label ($1);
1532 pedwarn ("obsolete use of designated initializer with `:'"); }
1540 { push_init_level (0); }
1541 initlist_maybe_comma '}'
1542 { process_init_element (pop_init_level (0)); }
1544 { process_init_element ($1); }
1550 | designator_list designator
1555 { set_init_label ($2); }
1556 | '[' expr_no_commas ELLIPSIS expr_no_commas ']'
1557 { set_init_index ($2, $4);
1559 pedwarn ("ISO C forbids specifying range of elements to initialize"); }
1560 | '[' expr_no_commas ']'
1561 { set_init_index ($2, NULL_TREE); }
1567 pedwarn ("ISO C forbids nested functions");
1569 push_function_context ();
1570 if (! start_function (current_declspecs, $1,
1571 all_prefix_attributes))
1573 pop_function_context ();
1576 parsing_iso_function_signature = false; /* Don't warn about nested functions. */
1578 old_style_parm_decls save_location
1579 { tree decl = current_function_decl;
1580 DECL_SOURCE_LOCATION (decl) = $4;
1581 store_parm_decls (); }
1582 /* This used to use compstmt_or_error.
1583 That caused a bug with input `f(g) int g {}',
1584 where the use of YYERROR1 above caused an error
1585 which then was handled by compstmt_or_error.
1586 There followed a repeated execution of that same rule,
1587 which called YYERROR1 again, and so on. */
1589 { tree decl = current_function_decl;
1590 finish_function (1, 1);
1591 pop_function_context ();
1592 add_decl_stmt (decl); }
1595 notype_nested_function:
1598 pedwarn ("ISO C forbids nested functions");
1600 push_function_context ();
1601 if (! start_function (current_declspecs, $1,
1602 all_prefix_attributes))
1604 pop_function_context ();
1607 parsing_iso_function_signature = false; /* Don't warn about nested functions. */
1609 old_style_parm_decls save_location
1610 { tree decl = current_function_decl;
1611 DECL_SOURCE_LOCATION (decl) = $4;
1612 store_parm_decls (); }
1613 /* This used to use compstmt_or_error.
1614 That caused a bug with input `f(g) int g {}',
1615 where the use of YYERROR1 above caused an error
1616 which then was handled by compstmt_or_error.
1617 There followed a repeated execution of that same rule,
1618 which called YYERROR1 again, and so on. */
1620 { tree decl = current_function_decl;
1621 finish_function (1, 1);
1622 pop_function_context ();
1623 add_decl_stmt (decl); }
1626 /* Any kind of declarator (thus, all declarators allowed
1627 after an explicit typespec). */
1630 after_type_declarator
1634 /* A declarator that is allowed only after an explicit typespec. */
1636 after_type_declarator:
1637 '(' maybe_attribute after_type_declarator ')'
1638 { $$ = $2 ? tree_cons ($2, $3, NULL_TREE) : $3; }
1639 | after_type_declarator '(' parmlist_or_identifiers %prec '.'
1640 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1641 /* | after_type_declarator '(' error ')' %prec '.'
1642 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1643 poplevel (0, 0, 0); } */
1644 | after_type_declarator array_declarator %prec '.'
1645 { $$ = set_array_declarator_type ($2, $1, 0); }
1646 | '*' maybe_type_quals_attrs after_type_declarator %prec UNARY
1647 { $$ = make_pointer_declarator ($2, $3); }
1654 /* Kinds of declarator that can appear in a parameter list
1655 in addition to notype_declarator. This is like after_type_declarator
1656 but does not allow a typedef name in parentheses as an identifier
1657 (because it would conflict with a function with that typedef as arg). */
1659 parm_declarator_starttypename
1660 | parm_declarator_nostarttypename
1663 parm_declarator_starttypename:
1664 parm_declarator_starttypename '(' parmlist_or_identifiers %prec '.'
1665 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1666 /* | parm_declarator_starttypename '(' error ')' %prec '.'
1667 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1668 poplevel (0, 0, 0); } */
1669 | parm_declarator_starttypename array_declarator %prec '.'
1670 { $$ = set_array_declarator_type ($2, $1, 0); }
1677 parm_declarator_nostarttypename:
1678 parm_declarator_nostarttypename '(' parmlist_or_identifiers %prec '.'
1679 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1680 /* | parm_declarator_nostarttypename '(' error ')' %prec '.'
1681 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1682 poplevel (0, 0, 0); } */
1683 | parm_declarator_nostarttypename array_declarator %prec '.'
1684 { $$ = set_array_declarator_type ($2, $1, 0); }
1685 | '*' maybe_type_quals_attrs parm_declarator_starttypename %prec UNARY
1686 { $$ = make_pointer_declarator ($2, $3); }
1687 | '*' maybe_type_quals_attrs parm_declarator_nostarttypename %prec UNARY
1688 { $$ = make_pointer_declarator ($2, $3); }
1689 | '(' maybe_attribute parm_declarator_nostarttypename ')'
1690 { $$ = $2 ? tree_cons ($2, $3, NULL_TREE) : $3; }
1693 /* A declarator allowed whether or not there has been
1694 an explicit typespec. These cannot redeclare a typedef-name. */
1697 notype_declarator '(' parmlist_or_identifiers %prec '.'
1698 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1699 /* | notype_declarator '(' error ')' %prec '.'
1700 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1701 poplevel (0, 0, 0); } */
1702 | '(' maybe_attribute notype_declarator ')'
1703 { $$ = $2 ? tree_cons ($2, $3, NULL_TREE) : $3; }
1704 | '*' maybe_type_quals_attrs notype_declarator %prec UNARY
1705 { $$ = make_pointer_declarator ($2, $3); }
1706 | notype_declarator array_declarator %prec '.'
1707 { $$ = set_array_declarator_type ($2, $1, 0); }
1732 /* structsp_attr: struct/union/enum specifiers that either
1733 end with attributes, or are such that any following attributes would
1734 be parsed as part of the struct/union/enum specifier.
1736 structsp_nonattr: other struct/union/enum specifiers. */
1739 struct_head identifier '{'
1740 { $$ = start_struct (RECORD_TYPE, $2);
1741 /* Start scope of tag before parsing components. */
1743 component_decl_list '}' maybe_attribute
1744 { $$ = finish_struct ($<ttype>4, nreverse ($5),
1745 chainon ($1, $7)); }
1746 | struct_head '{' component_decl_list '}' maybe_attribute
1747 { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
1748 nreverse ($3), chainon ($1, $5));
1750 | union_head identifier '{'
1751 { $$ = start_struct (UNION_TYPE, $2); }
1752 component_decl_list '}' maybe_attribute
1753 { $$ = finish_struct ($<ttype>4, nreverse ($5),
1754 chainon ($1, $7)); }
1755 | union_head '{' component_decl_list '}' maybe_attribute
1756 { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
1757 nreverse ($3), chainon ($1, $5));
1759 | enum_head identifier '{'
1760 { $$ = start_enum ($2); }
1761 enumlist maybecomma_warn '}' maybe_attribute
1762 { $$ = finish_enum ($<ttype>4, nreverse ($5),
1763 chainon ($1, $8)); }
1765 { $$ = start_enum (NULL_TREE); }
1766 enumlist maybecomma_warn '}' maybe_attribute
1767 { $$ = finish_enum ($<ttype>3, nreverse ($4),
1768 chainon ($1, $7)); }
1772 struct_head identifier
1773 { $$ = xref_tag (RECORD_TYPE, $2); }
1774 | union_head identifier
1775 { $$ = xref_tag (UNION_TYPE, $2); }
1776 | enum_head identifier
1777 { $$ = xref_tag (ENUMERAL_TYPE, $2);
1778 /* In ISO C, enumerated types can be referred to
1779 only if already defined. */
1780 if (pedantic && !COMPLETE_TYPE_P ($$))
1781 pedwarn ("ISO C forbids forward references to `enum' types"); }
1792 { if (pedantic && ! flag_isoc99)
1793 pedwarn ("comma at end of enumerator list"); }
1796 /* We chain the components in reverse order. They are put in forward
1797 order in structsp_attr.
1799 Note that component_declarator returns single decls, so components
1800 and components_notype can use TREE_CHAIN directly, wheras components
1801 and components_notype return lists (of comma separated decls), so
1802 component_decl_list and component_decl_list2 must use chainon.
1804 The theory behind all this is that there will be more semicolon
1805 separated fields than comma separated fields, and so we'll be
1806 minimizing the number of node traversals required by chainon. */
1808 component_decl_list:
1809 component_decl_list2
1811 | component_decl_list2 component_decl
1812 { $$ = chainon ($2, $1);
1813 pedwarn ("no semicolon at end of struct or union"); }
1816 component_decl_list2: /* empty */
1818 | component_decl_list2 component_decl ';'
1819 { $$ = chainon ($2, $1); }
1820 | component_decl_list2 ';'
1822 pedwarn ("extra semicolon in struct or union specified"); }
1824 /* foo(sizeof(struct{ @defs(ClassName)})); */
1825 | DEFS '(' CLASSNAME ')'
1827 tree interface = lookup_interface ($3);
1830 $$ = nreverse (get_class_ivars (interface));
1833 error ("cannot find interface declaration for `%s'",
1834 IDENTIFIER_POINTER ($3));
1842 declspecs_nosc_ts setspecs components
1844 POP_DECLSPEC_STACK; }
1845 | declspecs_nosc_ts setspecs
1847 /* Support for unnamed structs or unions as members of
1848 structs or unions (which is [a] useful and [b] supports
1851 pedwarn ("ISO C doesn't support unnamed structs/unions");
1853 $$ = grokfield(NULL, current_declspecs, NULL_TREE);
1854 POP_DECLSPEC_STACK; }
1855 | declspecs_nosc_nots setspecs components_notype
1857 POP_DECLSPEC_STACK; }
1858 | declspecs_nosc_nots
1860 pedwarn ("ISO C forbids member declarations with no members");
1865 | extension component_decl
1867 RESTORE_EXT_FLAGS ($1); }
1871 component_declarator
1872 | components ',' maybe_resetattrs component_declarator
1873 { TREE_CHAIN ($4) = $1; $$ = $4; }
1877 component_notype_declarator
1878 | components_notype ',' maybe_resetattrs component_notype_declarator
1879 { TREE_CHAIN ($4) = $1; $$ = $4; }
1882 component_declarator:
1883 declarator maybe_attribute
1884 { $$ = grokfield ($1, current_declspecs, NULL_TREE);
1885 decl_attributes (&$$,
1886 chainon ($2, all_prefix_attributes), 0); }
1887 | declarator ':' expr_no_commas maybe_attribute
1888 { $$ = grokfield ($1, current_declspecs, $3);
1889 decl_attributes (&$$,
1890 chainon ($4, all_prefix_attributes), 0); }
1891 | ':' expr_no_commas maybe_attribute
1892 { $$ = grokfield (NULL_TREE, current_declspecs, $2);
1893 decl_attributes (&$$,
1894 chainon ($3, all_prefix_attributes), 0); }
1897 component_notype_declarator:
1898 notype_declarator maybe_attribute
1899 { $$ = grokfield ($1, current_declspecs, NULL_TREE);
1900 decl_attributes (&$$,
1901 chainon ($2, all_prefix_attributes), 0); }
1902 | notype_declarator ':' expr_no_commas maybe_attribute
1903 { $$ = grokfield ($1, current_declspecs, $3);
1904 decl_attributes (&$$,
1905 chainon ($4, all_prefix_attributes), 0); }
1906 | ':' expr_no_commas maybe_attribute
1907 { $$ = grokfield (NULL_TREE, current_declspecs, $2);
1908 decl_attributes (&$$,
1909 chainon ($3, all_prefix_attributes), 0); }
1912 /* We chain the enumerators in reverse order.
1913 They are put in forward order in structsp_attr. */
1917 | enumlist ',' enumerator
1918 { if ($1 == error_mark_node)
1921 TREE_CHAIN ($3) = $1, $$ = $3; }
1923 { $$ = error_mark_node; }
1929 { $$ = build_enumerator ($1, NULL_TREE); }
1930 | identifier '=' expr_no_commas
1931 { $$ = build_enumerator ($1, $3); }
1936 { pending_xref_error ();
1939 { $$ = build_tree_list ($<ttype>2, $3); }
1942 absdcl: /* an absolute declarator */
1948 absdcl_maybe_attribute: /* absdcl maybe_attribute, but not just attributes */
1950 { $$ = build_tree_list (build_tree_list (current_declspecs,
1952 all_prefix_attributes); }
1954 { $$ = build_tree_list (build_tree_list (current_declspecs,
1956 all_prefix_attributes); }
1957 | absdcl1_noea attributes
1958 { $$ = build_tree_list (build_tree_list (current_declspecs,
1960 chainon ($2, all_prefix_attributes)); }
1963 absdcl1: /* a nonempty absolute declarator */
1970 | '*' maybe_type_quals_attrs absdcl1_noea
1971 { $$ = make_pointer_declarator ($2, $3); }
1975 '*' maybe_type_quals_attrs
1976 { $$ = make_pointer_declarator ($2, NULL_TREE); }
1977 | '*' maybe_type_quals_attrs absdcl1_ea
1978 { $$ = make_pointer_declarator ($2, $3); }
1982 '(' maybe_attribute absdcl1 ')'
1983 { $$ = $2 ? tree_cons ($2, $3, NULL_TREE) : $3; }
1984 | direct_absdcl1 '(' parmlist
1985 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1986 | direct_absdcl1 array_declarator
1987 { $$ = set_array_declarator_type ($2, $1, 1); }
1989 { $$ = build_nt (CALL_EXPR, NULL_TREE, $2, NULL_TREE); }
1991 { $$ = set_array_declarator_type ($1, NULL_TREE, 1); }
1994 /* The [...] part of a declarator for an array type. */
1997 '[' maybe_type_quals_attrs expr ']'
1998 { $$ = build_array_declarator ($3, $2, 0, 0); }
1999 | '[' maybe_type_quals_attrs ']'
2000 { $$ = build_array_declarator (NULL_TREE, $2, 0, 0); }
2001 | '[' maybe_type_quals_attrs '*' ']'
2002 { $$ = build_array_declarator (NULL_TREE, $2, 0, 1); }
2003 | '[' STATIC maybe_type_quals_attrs expr ']'
2004 { $$ = build_array_declarator ($4, $3, 1, 0); }
2005 /* declspecs_nosc_nots is a synonym for type_quals_attrs. */
2006 | '[' declspecs_nosc_nots STATIC expr ']'
2007 { $$ = build_array_declarator ($4, $2, 1, 0); }
2010 /* A nonempty series of declarations and statements (possibly followed by
2011 some labels) that can form the body of a compound statement.
2012 NOTE: we don't allow labels on declarations; this might seem like a
2013 natural extension, but there would be a conflict between attributes
2014 on the label and prefix attributes on the declaration. */
2017 lineno_stmt_decl_or_labels_ending_stmt
2018 | lineno_stmt_decl_or_labels_ending_decl
2019 | lineno_stmt_decl_or_labels_ending_label
2021 pedwarn ("deprecated use of label at end of compound statement");
2023 | lineno_stmt_decl_or_labels_ending_error
2026 lineno_stmt_decl_or_labels_ending_stmt:
2028 | lineno_stmt_decl_or_labels_ending_stmt lineno_stmt
2029 | lineno_stmt_decl_or_labels_ending_decl lineno_stmt
2030 | lineno_stmt_decl_or_labels_ending_label lineno_stmt
2031 | lineno_stmt_decl_or_labels_ending_error lineno_stmt
2034 lineno_stmt_decl_or_labels_ending_decl:
2036 | lineno_stmt_decl_or_labels_ending_stmt lineno_decl
2037 { if (pedantic && !flag_isoc99)
2038 pedwarn ("ISO C89 forbids mixed declarations and code"); }
2039 | lineno_stmt_decl_or_labels_ending_decl lineno_decl
2040 | lineno_stmt_decl_or_labels_ending_error lineno_decl
2043 lineno_stmt_decl_or_labels_ending_label:
2045 | lineno_stmt_decl_or_labels_ending_stmt lineno_label
2046 | lineno_stmt_decl_or_labels_ending_decl lineno_label
2047 | lineno_stmt_decl_or_labels_ending_label lineno_label
2048 | lineno_stmt_decl_or_labels_ending_error lineno_label
2051 lineno_stmt_decl_or_labels_ending_error:
2053 | lineno_stmt_decl_or_labels errstmt
2056 lineno_stmt_decl_or_labels:
2057 lineno_stmt_decl_or_labels_ending_stmt
2058 | lineno_stmt_decl_or_labels_ending_decl
2059 | lineno_stmt_decl_or_labels_ending_label
2060 | lineno_stmt_decl_or_labels_ending_error
2066 pushlevel: /* empty */
2069 add_scope_stmt (/*begin_p=*/1, /*partial_p=*/0);
2071 if (objc_method_context)
2077 poplevel: /* empty */
2078 { $$ = add_scope_stmt (/*begin_p=*/0, /*partial_p=*/0); }
2081 /* Start and end blocks created for the new scopes of C99. */
2082 c99_block_start: /* empty */
2085 $$ = c_begin_compound_stmt ();
2088 add_scope_stmt (/*begin_p=*/1, /*partial_p=*/0);
2090 if (objc_method_context)
2099 /* Productions using c99_block_start and c99_block_end will need to do what's
2100 in compstmt: RECHAIN_STMTS ($1, COMPOUND_BODY ($1)); $$ = $2; where
2101 $1 is the value of c99_block_start and $2 of c99_block_end. */
2102 c99_block_end: /* empty */
2105 tree scope_stmt = add_scope_stmt (/*begin_p=*/0, /*partial_p=*/0);
2106 $$ = poplevel (kept_level_p (), 0, 0);
2107 SCOPE_STMT_BLOCK (TREE_PURPOSE (scope_stmt))
2108 = SCOPE_STMT_BLOCK (TREE_VALUE (scope_stmt))
2115 /* Read zero or more forward-declarations for labels
2116 that nested functions can jump to. */
2121 pedwarn ("ISO C forbids label declarations"); }
2126 | label_decls label_decl
2130 LABEL identifiers_or_typenames ';'
2132 for (link = $2; link; link = TREE_CHAIN (link))
2134 tree label = shadow_label (TREE_VALUE (link));
2135 C_DECLARED_LABEL_FLAG (label) = 1;
2136 add_decl_stmt (label);
2141 /* This is the body of a function definition.
2142 It causes syntax errors to ignore to the next openbrace. */
2149 compstmt_start: '{' { compstmt_count++;
2150 $$ = c_begin_compound_stmt (); }
2153 compstmt_nostart: '}'
2154 { $$ = convert (void_type_node, integer_zero_node); }
2155 | pushlevel maybe_label_decls compstmt_contents_nonempty '}' poplevel
2156 { $$ = poplevel (kept_level_p (), 1, 0);
2157 SCOPE_STMT_BLOCK (TREE_PURPOSE ($5))
2158 = SCOPE_STMT_BLOCK (TREE_VALUE ($5))
2162 compstmt_contents_nonempty:
2167 compstmt_primary_start:
2169 { if (current_function_decl == 0)
2171 error ("braced-group within expression allowed only inside a function");
2174 /* We must force a BLOCK for this level
2175 so that, if it is not expanded later,
2176 there is a way to turn off the entire subtree of blocks
2177 that are contained in it. */
2179 push_label_level ();
2181 $$ = add_stmt (build_stmt (COMPOUND_STMT, last_tree));
2185 compstmt: compstmt_start compstmt_nostart
2186 { RECHAIN_STMTS ($1, COMPOUND_BODY ($1));
2187 last_expr_type = NULL_TREE;
2191 /* Value is number of statements counted as of the closeparen. */
2193 if_prefix c99_block_lineno_labeled_stmt
2194 { c_finish_then (); }
2195 /* Make sure c_expand_end_cond is run once
2196 for each call to c_expand_start_cond.
2197 Otherwise a crash is likely. */
2202 /* We must build the IF_STMT node before parsing its
2203 condition so that STMT_LINENO refers to the line
2204 containing the "if", and not the line containing
2205 the close-parenthesis.
2207 c_begin_if_stmt returns the IF_STMT node, which
2208 we later pass to c_expand_start_cond to fill
2209 in the condition and other tidbits. */
2211 { $<ttype>$ = c_begin_if_stmt (); }
2213 { c_expand_start_cond (c_common_truthvalue_conversion ($4),
2214 compstmt_count,$<ttype>2);
2215 $<itype>$ = stmt_count;
2216 if_stmt_locus = $<location>-1; }
2219 /* This is a subroutine of stmt.
2220 It is used twice, once for valid DO statements
2221 and once for catching errors in parsing the end test. */
2227 = add_stmt (build_stmt (DO_STMT, NULL_TREE,
2229 /* In the event that a parse error prevents
2230 parsing the complete do-statement, set the
2231 condition now. Otherwise, we can get crashes at
2232 RTL-generation time. */
2233 DO_COND ($<ttype>$) = error_mark_node; }
2234 c99_block_lineno_labeled_stmt WHILE
2236 RECHAIN_STMTS ($$, DO_BODY ($$)); }
2239 /* The forced readahead in here is because we might be at the end of a
2240 line, and the line and file won't be bumped until yylex absorbs the
2241 first token on the next line. */
2244 { if (yychar == YYEMPTY)
2246 $$ = input_location; }
2249 lineno_labeled_stmt:
2251 | lineno_label lineno_labeled_stmt
2254 /* Like lineno_labeled_stmt, but a block in C99. */
2255 c99_block_lineno_labeled_stmt:
2256 c99_block_start lineno_labeled_stmt c99_block_end
2258 RECHAIN_STMTS ($1, COMPOUND_BODY ($1)); }
2265 STMT_LINENO ($2) = $1.line;
2266 /* ??? We currently have no way of recording
2267 the filename for a statement. This probably
2268 matters little in practice at the moment,
2269 but I suspect that problems will occur when
2270 doing inlining at the tree level. */
2279 STMT_LINENO ($2) = $1.line;
2284 select_or_iter_stmt:
2286 { c_expand_start_else ();
2287 $<itype>1 = stmt_count; }
2288 c99_block_lineno_labeled_stmt
2290 c_expand_end_cond ();
2291 if (extra_warnings && stmt_count == $<itype>1)
2292 warning ("empty body in an else-statement"); }
2293 | simple_if %prec IF
2294 { c_expand_end_cond ();
2295 /* This warning is here instead of in simple_if, because we
2296 do not want a warning if an empty if is followed by an
2297 else statement. Increment stmt_count so we don't
2298 give a second error if this is a nested `if'. */
2299 if (extra_warnings && stmt_count++ == $<itype>1)
2300 warning ("%Hempty body in an if-statement",
2302 /* Make sure c_expand_end_cond is run once
2303 for each call to c_expand_start_cond.
2304 Otherwise a crash is likely. */
2305 | simple_if ELSE error
2306 { c_expand_end_cond (); }
2307 /* We must build the WHILE_STMT node before parsing its
2308 condition so that STMT_LINENO refers to the line
2309 containing the "while", and not the line containing
2310 the close-parenthesis.
2312 c_begin_while_stmt returns the WHILE_STMT node, which
2313 we later pass to c_finish_while_stmt_cond to fill
2314 in the condition and other tidbits. */
2317 $<ttype>$ = c_begin_while_stmt (); }
2319 { $4 = c_common_truthvalue_conversion ($4);
2320 c_finish_while_stmt_cond
2321 (c_common_truthvalue_conversion ($4), $<ttype>2);
2322 $<ttype>$ = add_stmt ($<ttype>2); }
2323 c99_block_lineno_labeled_stmt
2324 { RECHAIN_STMTS ($<ttype>6, WHILE_BODY ($<ttype>6)); }
2327 { DO_COND ($1) = c_common_truthvalue_conversion ($3); }
2328 | do_stmt_start error
2331 { $<ttype>$ = build_stmt (FOR_STMT, NULL_TREE, NULL_TREE,
2332 NULL_TREE, NULL_TREE);
2333 add_stmt ($<ttype>$); }
2336 RECHAIN_STMTS ($<ttype>2, FOR_INIT_STMT ($<ttype>2)); }
2339 FOR_COND ($<ttype>2)
2340 = c_common_truthvalue_conversion ($6); }
2342 { FOR_EXPR ($<ttype>2) = $9; }
2343 c99_block_lineno_labeled_stmt
2344 { RECHAIN_STMTS ($<ttype>2, FOR_BODY ($<ttype>2)); }
2345 | SWITCH '(' expr ')'
2347 $<ttype>$ = c_start_case ($3); }
2348 c99_block_lineno_labeled_stmt
2349 { c_finish_case (); }
2354 { add_stmt (build_stmt (EXPR_STMT, $1)); }
2356 { check_for_loop_decls (); }
2359 /* Parse a single real statement, not including any labels. */
2362 { stmt_count++; $$ = $1; }
2365 $$ = c_expand_expr_stmt ($1); }
2366 | c99_block_start select_or_iter_stmt c99_block_end
2368 RECHAIN_STMTS ($1, COMPOUND_BODY ($1));
2372 $$ = add_stmt (build_break_stmt ()); }
2375 $$ = add_stmt (build_continue_stmt ()); }
2378 $$ = c_expand_return (NULL_TREE); }
2381 $$ = c_expand_return ($2); }
2382 | ASM_KEYWORD maybe_type_qual '(' expr ')' ';'
2384 $$ = simple_asm_stmt ($4); }
2385 /* This is the case with just output operands. */
2386 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ')' ';'
2388 $$ = build_asm_stmt ($2, $4, $6, NULL_TREE, NULL_TREE); }
2389 /* This is the case with input operands as well. */
2390 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':'
2391 asm_operands ')' ';'
2393 $$ = build_asm_stmt ($2, $4, $6, $8, NULL_TREE); }
2394 /* This is the case with clobbered registers as well. */
2395 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':'
2396 asm_operands ':' asm_clobbers ')' ';'
2398 $$ = build_asm_stmt ($2, $4, $6, $8, $10); }
2399 | GOTO identifier ';'
2402 decl = lookup_label ($2);
2405 TREE_USED (decl) = 1;
2406 $$ = add_stmt (build_stmt (GOTO_STMT, decl));
2413 pedwarn ("ISO C forbids `goto *expr;'");
2415 $3 = convert (ptr_type_node, $3);
2416 $$ = add_stmt (build_stmt (GOTO_STMT, $3)); }
2421 /* Any kind of label, including jump labels and case labels.
2422 ANSI C accepts labels only before statements, but we allow them
2423 also at the end of a compound statement. */
2425 label: CASE expr_no_commas ':'
2427 $$ = do_case ($2, NULL_TREE); }
2428 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
2430 $$ = do_case ($2, $4); }
2433 $$ = do_case (NULL_TREE, NULL_TREE); }
2434 | identifier save_location ':' maybe_attribute
2435 { tree label = define_label ($2, $1);
2439 decl_attributes (&label, $4, 0);
2440 $$ = add_stmt (build_stmt (LABEL_STMT, label));
2447 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
2451 { emit_line_note (input_filename, input_line);
2454 { emit_line_note (input_filename, input_line); }
2463 /* These are the operands other than the first string and colon
2464 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
2465 asm_operands: /* empty */
2467 | nonnull_asm_operands
2470 nonnull_asm_operands:
2472 | nonnull_asm_operands ',' asm_operand
2473 { $$ = chainon ($1, $3); }
2478 { $$ = build_tree_list (build_tree_list (NULL_TREE, $1), $3); }
2479 | '[' identifier ']' STRING '(' expr ')'
2480 { $2 = build_string (IDENTIFIER_LENGTH ($2),
2481 IDENTIFIER_POINTER ($2));
2482 $$ = build_tree_list (build_tree_list ($2, $4), $6); }
2487 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
2488 | asm_clobbers ',' STRING
2489 { $$ = tree_cons (NULL_TREE, $3, $1); }
2492 /* This is what appears inside the parens in a function declarator.
2493 Its value is a list of ..._TYPE nodes. Attributes must appear here
2494 to avoid a conflict with their appearance after an open parenthesis
2495 in an abstract declarator, as in
2496 "void bar (int (__attribute__((__mode__(SI))) int foo));". */
2500 clear_parm_order ();
2501 declare_parm_level (0); }
2504 parmlist_tags_warning ();
2505 poplevel (0, 0, 0); }
2513 pedwarn ("ISO C forbids forward parameter declarations");
2514 /* Mark the forward decls as such. */
2515 for (parm = getdecls (); parm; parm = TREE_CHAIN (parm))
2516 TREE_ASM_WRITTEN (parm) = 1;
2517 clear_parm_order (); }
2519 { /* Dummy action so attributes are in known place
2520 on parser stack. */ }
2524 { $$ = tree_cons (NULL_TREE, NULL_TREE, NULL_TREE); }
2527 /* This is what appears inside the parens in a function declarator.
2528 Is value is represented in the format that grokdeclarator expects. */
2529 parmlist_2: /* empty */
2530 { $$ = get_parm_info (0); }
2532 { $$ = get_parm_info (0);
2533 /* Gcc used to allow this as an extension. However, it does
2534 not work for all targets, and thus has been disabled.
2535 Also, since func (...) and func () are indistinguishable,
2536 it caused problems with the code in expand_builtin which
2537 tries to verify that BUILT_IN_NEXT_ARG is being used
2539 error ("ISO C requires a named argument before `...'");
2542 { $$ = get_parm_info (1);
2543 parsing_iso_function_signature = true;
2545 | parms ',' ELLIPSIS
2546 { $$ = get_parm_info (0); }
2551 { push_parm_decl ($1); }
2553 { push_parm_decl ($3); }
2556 /* A single parameter declaration or parameter type name,
2557 as found in a parmlist. */
2559 declspecs_ts setspecs parm_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 setspecs notype_declarator maybe_attribute
2565 { $$ = build_tree_list (build_tree_list (current_declspecs,
2567 chainon ($4, all_prefix_attributes));
2568 POP_DECLSPEC_STACK; }
2569 | declspecs_ts setspecs absdcl_maybe_attribute
2571 POP_DECLSPEC_STACK; }
2572 | declspecs_nots setspecs notype_declarator maybe_attribute
2573 { $$ = build_tree_list (build_tree_list (current_declspecs,
2575 chainon ($4, all_prefix_attributes));
2576 POP_DECLSPEC_STACK; }
2578 | declspecs_nots setspecs absdcl_maybe_attribute
2580 POP_DECLSPEC_STACK; }
2583 /* The first parm, which must suck attributes from off the top of the parser
2586 declspecs_ts_nosa setspecs_fp parm_declarator maybe_attribute
2587 { $$ = build_tree_list (build_tree_list (current_declspecs,
2589 chainon ($4, all_prefix_attributes));
2590 POP_DECLSPEC_STACK; }
2591 | declspecs_ts_nosa setspecs_fp notype_declarator maybe_attribute
2592 { $$ = build_tree_list (build_tree_list (current_declspecs,
2594 chainon ($4, all_prefix_attributes));
2595 POP_DECLSPEC_STACK; }
2596 | declspecs_ts_nosa setspecs_fp absdcl_maybe_attribute
2598 POP_DECLSPEC_STACK; }
2599 | declspecs_nots_nosa setspecs_fp notype_declarator maybe_attribute
2600 { $$ = build_tree_list (build_tree_list (current_declspecs,
2602 chainon ($4, all_prefix_attributes));
2603 POP_DECLSPEC_STACK; }
2605 | declspecs_nots_nosa setspecs_fp absdcl_maybe_attribute
2607 POP_DECLSPEC_STACK; }
2612 { prefix_attributes = chainon (prefix_attributes, $<ttype>-2);
2613 all_prefix_attributes = prefix_attributes; }
2616 /* This is used in a function definition
2617 where either a parmlist or an identifier list is ok.
2618 Its value is a list of ..._TYPE nodes or a list of identifiers. */
2619 parmlist_or_identifiers:
2622 clear_parm_order ();
2623 declare_parm_level (1); }
2624 parmlist_or_identifiers_1
2626 parmlist_tags_warning ();
2627 poplevel (0, 0, 0); }
2630 parmlist_or_identifiers_1:
2634 for (t = $1; t; t = TREE_CHAIN (t))
2635 if (TREE_VALUE (t) == NULL_TREE)
2636 error ("`...' in old-style identifier list");
2637 $$ = tree_cons (NULL_TREE, NULL_TREE, $1);
2639 /* Make sure we have a parmlist after attributes. */
2641 && (TREE_CODE ($$) != TREE_LIST
2642 || TREE_PURPOSE ($$) == 0
2643 || TREE_CODE (TREE_PURPOSE ($$)) != PARM_DECL))
2648 /* A nonempty list of identifiers. */
2651 { $$ = build_tree_list (NULL_TREE, $1); }
2652 | identifiers ',' IDENTIFIER
2653 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2656 /* A nonempty list of identifiers, including typenames. */
2657 identifiers_or_typenames:
2659 { $$ = build_tree_list (NULL_TREE, $1); }
2660 | identifiers_or_typenames ',' identifier
2661 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2666 { $$ = SAVE_EXT_FLAGS();
2668 warn_pointer_arith = 0;
2669 warn_traditional = 0;
2674 /* Objective-C productions. */
2684 if (objc_implementation_context)
2686 finish_class (objc_implementation_context);
2687 objc_ivar_chain = NULL_TREE;
2688 objc_implementation_context = NULL_TREE;
2691 warning ("`@end' must appear in an implementation context");
2695 /* A nonempty list of identifiers. */
2698 { $$ = build_tree_list (NULL_TREE, $1); }
2699 | identifier_list ',' identifier
2700 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2704 CLASS identifier_list ';'
2706 objc_declare_class ($2);
2711 ALIAS identifier identifier ';'
2713 objc_declare_alias ($2, $3);
2718 INTERFACE identifier protocolrefs '{'
2720 objc_interface_context = objc_ivar_context
2721 = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, $3);
2722 objc_public_flag = 0;
2726 continue_class (objc_interface_context);
2731 finish_class (objc_interface_context);
2732 objc_interface_context = NULL_TREE;
2735 | INTERFACE identifier protocolrefs
2737 objc_interface_context
2738 = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, $3);
2739 continue_class (objc_interface_context);
2744 finish_class (objc_interface_context);
2745 objc_interface_context = NULL_TREE;
2748 | INTERFACE identifier ':' identifier protocolrefs '{'
2750 objc_interface_context = objc_ivar_context
2751 = start_class (CLASS_INTERFACE_TYPE, $2, $4, $5);
2752 objc_public_flag = 0;
2756 continue_class (objc_interface_context);
2761 finish_class (objc_interface_context);
2762 objc_interface_context = NULL_TREE;
2765 | INTERFACE identifier ':' identifier protocolrefs
2767 objc_interface_context
2768 = start_class (CLASS_INTERFACE_TYPE, $2, $4, $5);
2769 continue_class (objc_interface_context);
2774 finish_class (objc_interface_context);
2775 objc_interface_context = NULL_TREE;
2778 | IMPLEMENTATION identifier '{'
2780 objc_implementation_context = objc_ivar_context
2781 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, NULL_TREE, NULL_TREE);
2782 objc_public_flag = 0;
2787 = continue_class (objc_implementation_context);
2790 | IMPLEMENTATION identifier
2792 objc_implementation_context
2793 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, NULL_TREE, NULL_TREE);
2795 = continue_class (objc_implementation_context);
2798 | IMPLEMENTATION identifier ':' identifier '{'
2800 objc_implementation_context = objc_ivar_context
2801 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2802 objc_public_flag = 0;
2807 = continue_class (objc_implementation_context);
2810 | IMPLEMENTATION identifier ':' identifier
2812 objc_implementation_context
2813 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2815 = continue_class (objc_implementation_context);
2818 | INTERFACE identifier '(' identifier ')' protocolrefs
2820 objc_interface_context
2821 = start_class (CATEGORY_INTERFACE_TYPE, $2, $4, $6);
2822 continue_class (objc_interface_context);
2827 finish_class (objc_interface_context);
2828 objc_interface_context = NULL_TREE;
2831 | IMPLEMENTATION identifier '(' identifier ')'
2833 objc_implementation_context
2834 = start_class (CATEGORY_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2836 = continue_class (objc_implementation_context);
2841 PROTOCOL identifier protocolrefs
2843 objc_pq_context = 1;
2844 objc_interface_context
2845 = start_protocol(PROTOCOL_INTERFACE_TYPE, $2, $3);
2849 objc_pq_context = 0;
2850 finish_protocol(objc_interface_context);
2851 objc_interface_context = NULL_TREE;
2853 /* The @protocol forward-declaration production introduces a
2854 reduce/reduce conflict on ';', which should be resolved in
2855 favor of the production 'identifier_list -> identifier'. */
2856 | PROTOCOL identifier_list ';'
2858 objc_declare_protocols ($2);
2867 | non_empty_protocolrefs
2870 non_empty_protocolrefs:
2871 ARITHCOMPARE identifier_list ARITHCOMPARE
2873 if ($1 == LT_EXPR && $3 == GT_EXPR)
2881 ivar_decl_list visibility_spec ivar_decls
2886 PRIVATE { objc_public_flag = 2; }
2887 | PROTECTED { objc_public_flag = 0; }
2888 | PUBLIC { objc_public_flag = 1; }
2896 | ivar_decls ivar_decl ';'
2900 pedwarn ("extra semicolon in struct or union specified");
2905 /* There is a shift-reduce conflict here, because `components' may
2906 start with a `typename'. It happens that shifting (the default resolution)
2907 does the right thing, because it treats the `typename' as part of
2908 a `typed_typespecs'.
2910 It is possible that this same technique would allow the distinction
2911 between `notype_initdecls' and `initdecls' to be eliminated.
2912 But I am being cautious and not trying it. */
2915 declspecs_nosc_ts setspecs ivars
2917 POP_DECLSPEC_STACK; }
2918 | declspecs_nosc_nots setspecs ivars
2920 POP_DECLSPEC_STACK; }
2929 | ivars ',' maybe_resetattrs ivar_declarator
2935 $$ = add_instance_variable (objc_ivar_context,
2937 $1, current_declspecs,
2940 | declarator ':' expr_no_commas
2942 $$ = add_instance_variable (objc_ivar_context,
2944 $1, current_declspecs, $3);
2946 | ':' expr_no_commas
2948 $$ = add_instance_variable (objc_ivar_context,
2951 current_declspecs, $2);
2957 { objc_inherit_code = CLASS_METHOD_DECL; }
2959 { objc_inherit_code = INSTANCE_METHOD_DECL; }
2965 objc_pq_context = 1;
2966 if (!objc_implementation_context)
2967 fatal_error ("method definition not in class context");
2971 objc_pq_context = 0;
2972 if (objc_inherit_code == CLASS_METHOD_DECL)
2973 add_class_method (objc_implementation_context, $3);
2975 add_instance_method (objc_implementation_context, $3);
2976 start_method_def ($3);
2980 continue_method_def ();
2984 finish_method_def ();
2988 /* the reason for the strange actions in this rule
2989 is so that notype_initdecls when reached via datadef
2990 can find a valid list of type and sc specs in $0. */
2994 | {$<ttype>$ = NULL_TREE; } methodprotolist2
2997 methodprotolist2: /* eliminates a shift/reduce conflict */
3000 | methodprotolist2 methodproto
3001 | methodprotolist2 {$<ttype>$ = NULL_TREE; } datadef
3012 /* Remember protocol qualifiers in prototypes. */
3013 objc_pq_context = 1;
3017 /* Forget protocol qualifiers here. */
3018 objc_pq_context = 0;
3019 if (objc_inherit_code == CLASS_METHOD_DECL)
3020 add_class_method (objc_interface_context, $3);
3022 add_instance_method (objc_interface_context, $3);
3028 '(' typename ')' unaryselector
3030 $$ = build_method_decl (objc_inherit_code, $2, $4, NULL_TREE);
3035 $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, NULL_TREE);
3038 | '(' typename ')' keywordselector optparmlist
3040 $$ = build_method_decl (objc_inherit_code, $2, $4, $5);
3043 | keywordselector optparmlist
3045 $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, $2);
3049 /* "optarglist" assumes that start_method_def has already been called...
3050 if it is not, the "xdecls" will not be placed in the proper scope */
3057 /* to get around the following situation: "int foo (int a) int b; {}" that
3058 is synthesized when parsing "- a:a b:b; id c; id d; { ... }" */
3073 declspecs_ts setspecs myparms ';'
3074 { POP_DECLSPEC_STACK; }
3076 { shadow_tag ($1); }
3077 | declspecs_nots ';'
3078 { pedwarn ("empty declaration"); }
3083 { push_parm_decl ($1); }
3084 | myparms ',' myparm
3085 { push_parm_decl ($3); }
3088 /* A single parameter declaration or parameter type name,
3089 as found in a parmlist. DOES NOT ALLOW AN INITIALIZER OR ASMSPEC */
3092 parm_declarator maybe_attribute
3093 { $$ = build_tree_list (build_tree_list (current_declspecs,
3095 chainon ($2, all_prefix_attributes)); }
3096 | notype_declarator maybe_attribute
3097 { $$ = build_tree_list (build_tree_list (current_declspecs,
3099 chainon ($2, all_prefix_attributes)); }
3100 | absdcl_maybe_attribute
3111 /* oh what a kludge! */
3112 $$ = objc_ellipsis_node;
3120 /* returns a tree list node generated by get_parm_info */
3133 | keywordselector keyworddecl
3135 $$ = chainon ($1, $2);
3148 ENUM | STRUCT | UNION | IF | ELSE | WHILE | DO | FOR
3149 | SWITCH | CASE | DEFAULT | BREAK | CONTINUE | RETURN
3150 | GOTO | ASM_KEYWORD | SIZEOF | TYPEOF | ALIGNOF
3151 | TYPESPEC | TYPE_QUAL
3155 selector ':' '(' typename ')' identifier
3157 $$ = build_keyword_decl ($1, $4, $6);
3160 | selector ':' identifier
3162 $$ = build_keyword_decl ($1, NULL_TREE, $3);
3165 | ':' '(' typename ')' identifier
3167 $$ = build_keyword_decl (NULL_TREE, $3, $5);
3172 $$ = build_keyword_decl (NULL_TREE, NULL_TREE, $2);
3183 | keywordarglist keywordarg
3185 $$ = chainon ($1, $2);
3193 if (TREE_CHAIN ($1) == NULL_TREE)
3194 /* just return the expr., remove a level of indirection */
3195 $$ = TREE_VALUE ($1);
3197 /* we have a comma expr., we will collapse later */
3203 selector ':' keywordexpr
3205 $$ = build_tree_list ($1, $3);
3209 $$ = build_tree_list (NULL_TREE, $2);
3217 $$ = get_class_reference ($1);
3222 '[' receiver messageargs ']'
3223 { $$ = build_tree_list ($2, $3); }
3233 | keywordnamelist keywordname
3235 $$ = chainon ($1, $2);
3242 $$ = build_tree_list ($1, NULL_TREE);
3246 $$ = build_tree_list (NULL_TREE, NULL_TREE);
3251 SELECTOR '(' selectorarg ')'
3258 PROTOCOL '(' identifier ')'
3264 /* extension to support C-structures in the archiver */
3267 ENCODE '(' typename ')'
3269 $$ = groktypename ($3);
3276 /* yylex() is a thin wrapper around c_lex(), all it does is translate
3277 cpplib.h's token codes into yacc's token codes. */
3279 static enum cpp_ttype last_token;
3281 /* The reserved keyword table. */
3285 ENUM_BITFIELD(rid) rid : 16;
3286 unsigned int disable : 16;
3289 /* Disable mask. Keywords are disabled if (reswords[i].disable & mask) is
3291 #define D_C89 0x01 /* not in C89 */
3292 #define D_EXT 0x02 /* GCC extension */
3293 #define D_EXT89 0x04 /* GCC extension incorporated in C99 */
3294 #define D_OBJC 0x08 /* Objective C only */
3296 static const struct resword reswords[] =
3298 { "_Bool", RID_BOOL, 0 },
3299 { "_Complex", RID_COMPLEX, 0 },
3300 { "__FUNCTION__", RID_FUNCTION_NAME, 0 },
3301 { "__PRETTY_FUNCTION__", RID_PRETTY_FUNCTION_NAME, 0 },
3302 { "__alignof", RID_ALIGNOF, 0 },
3303 { "__alignof__", RID_ALIGNOF, 0 },
3304 { "__asm", RID_ASM, 0 },
3305 { "__asm__", RID_ASM, 0 },
3306 { "__attribute", RID_ATTRIBUTE, 0 },
3307 { "__attribute__", RID_ATTRIBUTE, 0 },
3308 { "__builtin_choose_expr", RID_CHOOSE_EXPR, 0 },
3309 { "__builtin_types_compatible_p", RID_TYPES_COMPATIBLE_P, 0 },
3310 { "__builtin_va_arg", RID_VA_ARG, 0 },
3311 { "__complex", RID_COMPLEX, 0 },
3312 { "__complex__", RID_COMPLEX, 0 },
3313 { "__const", RID_CONST, 0 },
3314 { "__const__", RID_CONST, 0 },
3315 { "__extension__", RID_EXTENSION, 0 },
3316 { "__func__", RID_C99_FUNCTION_NAME, 0 },
3317 { "__imag", RID_IMAGPART, 0 },
3318 { "__imag__", RID_IMAGPART, 0 },
3319 { "__inline", RID_INLINE, 0 },
3320 { "__inline__", RID_INLINE, 0 },
3321 { "__label__", RID_LABEL, 0 },
3322 { "__ptrbase", RID_PTRBASE, 0 },
3323 { "__ptrbase__", RID_PTRBASE, 0 },
3324 { "__ptrextent", RID_PTREXTENT, 0 },
3325 { "__ptrextent__", RID_PTREXTENT, 0 },
3326 { "__ptrvalue", RID_PTRVALUE, 0 },
3327 { "__ptrvalue__", RID_PTRVALUE, 0 },
3328 { "__real", RID_REALPART, 0 },
3329 { "__real__", RID_REALPART, 0 },
3330 { "__restrict", RID_RESTRICT, 0 },
3331 { "__restrict__", RID_RESTRICT, 0 },
3332 { "__signed", RID_SIGNED, 0 },
3333 { "__signed__", RID_SIGNED, 0 },
3334 { "__thread", RID_THREAD, 0 },
3335 { "__typeof", RID_TYPEOF, 0 },
3336 { "__typeof__", RID_TYPEOF, 0 },
3337 { "__volatile", RID_VOLATILE, 0 },
3338 { "__volatile__", RID_VOLATILE, 0 },
3339 { "asm", RID_ASM, D_EXT },
3340 { "auto", RID_AUTO, 0 },
3341 { "break", RID_BREAK, 0 },
3342 { "case", RID_CASE, 0 },
3343 { "char", RID_CHAR, 0 },
3344 { "const", RID_CONST, 0 },
3345 { "continue", RID_CONTINUE, 0 },
3346 { "default", RID_DEFAULT, 0 },
3347 { "do", RID_DO, 0 },
3348 { "double", RID_DOUBLE, 0 },
3349 { "else", RID_ELSE, 0 },
3350 { "enum", RID_ENUM, 0 },
3351 { "extern", RID_EXTERN, 0 },
3352 { "float", RID_FLOAT, 0 },
3353 { "for", RID_FOR, 0 },
3354 { "goto", RID_GOTO, 0 },
3355 { "if", RID_IF, 0 },
3356 { "inline", RID_INLINE, D_EXT89 },
3357 { "int", RID_INT, 0 },
3358 { "long", RID_LONG, 0 },
3359 { "register", RID_REGISTER, 0 },
3360 { "restrict", RID_RESTRICT, D_C89 },
3361 { "return", RID_RETURN, 0 },
3362 { "short", RID_SHORT, 0 },
3363 { "signed", RID_SIGNED, 0 },
3364 { "sizeof", RID_SIZEOF, 0 },
3365 { "static", RID_STATIC, 0 },
3366 { "struct", RID_STRUCT, 0 },
3367 { "switch", RID_SWITCH, 0 },
3368 { "typedef", RID_TYPEDEF, 0 },
3369 { "typeof", RID_TYPEOF, D_EXT },
3370 { "union", RID_UNION, 0 },
3371 { "unsigned", RID_UNSIGNED, 0 },
3372 { "void", RID_VOID, 0 },
3373 { "volatile", RID_VOLATILE, 0 },
3374 { "while", RID_WHILE, 0 },
3376 { "id", RID_ID, D_OBJC },
3378 /* These objc keywords are recognized only immediately after
3380 { "class", RID_AT_CLASS, D_OBJC },
3381 { "compatibility_alias", RID_AT_ALIAS, D_OBJC },
3382 { "defs", RID_AT_DEFS, D_OBJC },
3383 { "encode", RID_AT_ENCODE, D_OBJC },
3384 { "end", RID_AT_END, D_OBJC },
3385 { "implementation", RID_AT_IMPLEMENTATION, D_OBJC },
3386 { "interface", RID_AT_INTERFACE, D_OBJC },
3387 { "private", RID_AT_PRIVATE, D_OBJC },
3388 { "protected", RID_AT_PROTECTED, D_OBJC },
3389 { "protocol", RID_AT_PROTOCOL, D_OBJC },
3390 { "public", RID_AT_PUBLIC, D_OBJC },
3391 { "selector", RID_AT_SELECTOR, D_OBJC },
3393 /* These are recognized only in protocol-qualifier context
3395 { "bycopy", RID_BYCOPY, D_OBJC },
3396 { "byref", RID_BYREF, D_OBJC },
3397 { "in", RID_IN, D_OBJC },
3398 { "inout", RID_INOUT, D_OBJC },
3399 { "oneway", RID_ONEWAY, D_OBJC },
3400 { "out", RID_OUT, D_OBJC },
3403 #define N_reswords (sizeof reswords / sizeof (struct resword))
3405 /* Table mapping from RID_* constants to yacc token numbers.
3406 Unfortunately we have to have entries for all the keywords in all
3408 static const short rid_to_yy[RID_MAX] =
3410 /* RID_STATIC */ STATIC,
3411 /* RID_UNSIGNED */ TYPESPEC,
3412 /* RID_LONG */ TYPESPEC,
3413 /* RID_CONST */ TYPE_QUAL,
3414 /* RID_EXTERN */ SCSPEC,
3415 /* RID_REGISTER */ SCSPEC,
3416 /* RID_TYPEDEF */ SCSPEC,
3417 /* RID_SHORT */ TYPESPEC,
3418 /* RID_INLINE */ SCSPEC,
3419 /* RID_VOLATILE */ TYPE_QUAL,
3420 /* RID_SIGNED */ TYPESPEC,
3421 /* RID_AUTO */ SCSPEC,
3422 /* RID_RESTRICT */ TYPE_QUAL,
3425 /* RID_COMPLEX */ TYPESPEC,
3426 /* RID_THREAD */ SCSPEC,
3430 /* RID_VIRTUAL */ 0,
3431 /* RID_EXPLICIT */ 0,
3433 /* RID_MUTABLE */ 0,
3436 /* RID_IN */ TYPE_QUAL,
3437 /* RID_OUT */ TYPE_QUAL,
3438 /* RID_INOUT */ TYPE_QUAL,
3439 /* RID_BYCOPY */ TYPE_QUAL,
3440 /* RID_BYREF */ TYPE_QUAL,
3441 /* RID_ONEWAY */ TYPE_QUAL,
3444 /* RID_INT */ TYPESPEC,
3445 /* RID_CHAR */ TYPESPEC,
3446 /* RID_FLOAT */ TYPESPEC,
3447 /* RID_DOUBLE */ TYPESPEC,
3448 /* RID_VOID */ TYPESPEC,
3449 /* RID_ENUM */ ENUM,
3450 /* RID_STRUCT */ STRUCT,
3451 /* RID_UNION */ UNION,
3453 /* RID_ELSE */ ELSE,
3454 /* RID_WHILE */ WHILE,
3457 /* RID_SWITCH */ SWITCH,
3458 /* RID_CASE */ CASE,
3459 /* RID_DEFAULT */ DEFAULT,
3460 /* RID_BREAK */ BREAK,
3461 /* RID_CONTINUE */ CONTINUE,
3462 /* RID_RETURN */ RETURN,
3463 /* RID_GOTO */ GOTO,
3464 /* RID_SIZEOF */ SIZEOF,
3467 /* RID_ASM */ ASM_KEYWORD,
3468 /* RID_TYPEOF */ TYPEOF,
3469 /* RID_ALIGNOF */ ALIGNOF,
3470 /* RID_ATTRIBUTE */ ATTRIBUTE,
3471 /* RID_VA_ARG */ VA_ARG,
3472 /* RID_EXTENSION */ EXTENSION,
3473 /* RID_IMAGPART */ IMAGPART,
3474 /* RID_REALPART */ REALPART,
3475 /* RID_LABEL */ LABEL,
3476 /* RID_PTRBASE */ PTR_BASE,
3477 /* RID_PTREXTENT */ PTR_EXTENT,
3478 /* RID_PTRVALUE */ PTR_VALUE,
3480 /* RID_CHOOSE_EXPR */ CHOOSE_EXPR,
3481 /* RID_TYPES_COMPATIBLE_P */ TYPES_COMPATIBLE_P,
3483 /* RID_FUNCTION_NAME */ FUNC_NAME,
3484 /* RID_PRETTY_FUNCTION_NAME */ FUNC_NAME,
3485 /* RID_C99_FUNCTION_NAME */ FUNC_NAME,
3488 /* RID_BOOL */ TYPESPEC,
3492 /* RID_PRIVATE */ 0,
3493 /* RID_PROTECTED */ 0,
3494 /* RID_TEMPLATE */ 0,
3499 /* RID_NAMESPACE */ 0,
3501 /* RID_OPERATOR */ 0,
3506 /* RID_TYPENAME */ 0,
3511 /* RID_CONSTCAST */ 0,
3512 /* RID_DYNCAST */ 0,
3513 /* RID_REINTCAST */ 0,
3514 /* RID_STATCAST */ 0,
3517 /* RID_ID */ OBJECTNAME,
3518 /* RID_AT_ENCODE */ ENCODE,
3519 /* RID_AT_END */ END,
3520 /* RID_AT_CLASS */ CLASS,
3521 /* RID_AT_ALIAS */ ALIAS,
3522 /* RID_AT_DEFS */ DEFS,
3523 /* RID_AT_PRIVATE */ PRIVATE,
3524 /* RID_AT_PROTECTED */ PROTECTED,
3525 /* RID_AT_PUBLIC */ PUBLIC,
3526 /* RID_AT_PROTOCOL */ PROTOCOL,
3527 /* RID_AT_SELECTOR */ SELECTOR,
3528 /* RID_AT_INTERFACE */ INTERFACE,
3529 /* RID_AT_IMPLEMENTATION */ IMPLEMENTATION
3537 int mask = (flag_isoc99 ? 0 : D_C89)
3538 | (flag_no_asm ? (flag_isoc99 ? D_EXT : D_EXT|D_EXT89) : 0);
3540 if (!c_dialect_objc ())
3543 ridpointers = (tree *) ggc_calloc ((int) RID_MAX, sizeof (tree));
3544 for (i = 0; i < N_reswords; i++)
3546 /* If a keyword is disabled, do not enter it into the table
3547 and so create a canonical spelling that isn't a keyword. */
3548 if (reswords[i].disable & mask)
3551 id = get_identifier (reswords[i].word);
3552 C_RID_CODE (id) = reswords[i].rid;
3553 C_IS_RESERVED_WORD (id) = 1;
3554 ridpointers [(int) reswords[i].rid] = id;
3558 #define NAME(type) cpp_type2name (type)
3564 const char *string = _(msgid);
3566 if (last_token == CPP_EOF)
3567 error ("%s at end of input", string);
3568 else if (last_token == CPP_CHAR || last_token == CPP_WCHAR)
3570 unsigned int val = TREE_INT_CST_LOW (yylval.ttype);
3571 const char *const ell = (last_token == CPP_CHAR) ? "" : "L";
3572 if (val <= UCHAR_MAX && ISGRAPH (val))
3573 error ("%s before %s'%c'", string, ell, val);
3575 error ("%s before %s'\\x%x'", string, ell, val);
3577 else if (last_token == CPP_STRING
3578 || last_token == CPP_WSTRING)
3579 error ("%s before string constant", string);
3580 else if (last_token == CPP_NUMBER)
3581 error ("%s before numeric constant", string);
3582 else if (last_token == CPP_NAME)
3583 error ("%s before \"%s\"", string, IDENTIFIER_POINTER (yylval.ttype));
3585 error ("%s before '%s' token", string, NAME(last_token));
3594 int objc_force_identifier = objc_need_raw_identifier;
3595 OBJC_NEED_RAW_IDENTIFIER (0);
3598 if (C_IS_RESERVED_WORD (yylval.ttype))
3600 enum rid rid_code = C_RID_CODE (yylval.ttype);
3603 /* Turn non-typedefed refs to "id" into plain identifiers; this
3604 allows constructs like "void foo(id id);" to work. */
3605 if (rid_code == RID_ID)
3607 decl = lookup_name (yylval.ttype);
3608 if (decl == NULL_TREE || TREE_CODE (decl) != TYPE_DECL)
3612 if (!OBJC_IS_AT_KEYWORD (rid_code)
3613 && (!OBJC_IS_PQ_KEYWORD (rid_code) || objc_pq_context))
3616 /* Return the canonical spelling for this keyword. */
3617 yylval.ttype = ridpointers[(int) rid_code];
3618 return rid_to_yy[(int) rid_code];
3622 decl = lookup_name (yylval.ttype);
3625 if (TREE_CODE (decl) == TYPE_DECL)
3631 tree objc_interface_decl = is_class_name (yylval.ttype);
3632 /* ObjC class names are in the same namespace as variables and
3633 typedefs, and hence are shadowed by local declarations. */
3634 if (objc_interface_decl
3635 && (global_bindings_p ()
3636 || (!objc_force_identifier && !decl)))
3638 yylval.ttype = objc_interface_decl;
3651 last_token = c_lex (&yylval.ttype);
3654 case CPP_EQ: return '=';
3655 case CPP_NOT: return '!';
3656 case CPP_GREATER: yylval.code = GT_EXPR; return ARITHCOMPARE;
3657 case CPP_LESS: yylval.code = LT_EXPR; return ARITHCOMPARE;
3658 case CPP_PLUS: yylval.code = PLUS_EXPR; return '+';
3659 case CPP_MINUS: yylval.code = MINUS_EXPR; return '-';
3660 case CPP_MULT: yylval.code = MULT_EXPR; return '*';
3661 case CPP_DIV: yylval.code = TRUNC_DIV_EXPR; return '/';
3662 case CPP_MOD: yylval.code = TRUNC_MOD_EXPR; return '%';
3663 case CPP_AND: yylval.code = BIT_AND_EXPR; return '&';
3664 case CPP_OR: yylval.code = BIT_IOR_EXPR; return '|';
3665 case CPP_XOR: yylval.code = BIT_XOR_EXPR; return '^';
3666 case CPP_RSHIFT: yylval.code = RSHIFT_EXPR; return RSHIFT;
3667 case CPP_LSHIFT: yylval.code = LSHIFT_EXPR; return LSHIFT;
3669 case CPP_COMPL: return '~';
3670 case CPP_AND_AND: return ANDAND;
3671 case CPP_OR_OR: return OROR;
3672 case CPP_QUERY: return '?';
3673 case CPP_OPEN_PAREN: return '(';
3674 case CPP_EQ_EQ: yylval.code = EQ_EXPR; return EQCOMPARE;
3675 case CPP_NOT_EQ: yylval.code = NE_EXPR; return EQCOMPARE;
3676 case CPP_GREATER_EQ:yylval.code = GE_EXPR; return ARITHCOMPARE;
3677 case CPP_LESS_EQ: yylval.code = LE_EXPR; return ARITHCOMPARE;
3679 case CPP_PLUS_EQ: yylval.code = PLUS_EXPR; return ASSIGN;
3680 case CPP_MINUS_EQ: yylval.code = MINUS_EXPR; return ASSIGN;
3681 case CPP_MULT_EQ: yylval.code = MULT_EXPR; return ASSIGN;
3682 case CPP_DIV_EQ: yylval.code = TRUNC_DIV_EXPR; return ASSIGN;
3683 case CPP_MOD_EQ: yylval.code = TRUNC_MOD_EXPR; return ASSIGN;
3684 case CPP_AND_EQ: yylval.code = BIT_AND_EXPR; return ASSIGN;
3685 case CPP_OR_EQ: yylval.code = BIT_IOR_EXPR; return ASSIGN;
3686 case CPP_XOR_EQ: yylval.code = BIT_XOR_EXPR; return ASSIGN;
3687 case CPP_RSHIFT_EQ: yylval.code = RSHIFT_EXPR; return ASSIGN;
3688 case CPP_LSHIFT_EQ: yylval.code = LSHIFT_EXPR; return ASSIGN;
3690 case CPP_OPEN_SQUARE: return '[';
3691 case CPP_CLOSE_SQUARE: return ']';
3692 case CPP_OPEN_BRACE: return '{';
3693 case CPP_CLOSE_BRACE: return '}';
3694 case CPP_ELLIPSIS: return ELLIPSIS;
3696 case CPP_PLUS_PLUS: return PLUSPLUS;
3697 case CPP_MINUS_MINUS: return MINUSMINUS;
3698 case CPP_DEREF: return POINTSAT;
3699 case CPP_DOT: return '.';
3701 /* The following tokens may affect the interpretation of any
3702 identifiers following, if doing Objective-C. */
3703 case CPP_COLON: OBJC_NEED_RAW_IDENTIFIER (0); return ':';
3704 case CPP_COMMA: OBJC_NEED_RAW_IDENTIFIER (0); return ',';
3705 case CPP_CLOSE_PAREN: OBJC_NEED_RAW_IDENTIFIER (0); return ')';
3706 case CPP_SEMICOLON: OBJC_NEED_RAW_IDENTIFIER (0); return ';';
3712 return yylexname ();
3715 /* This only happens in Objective-C; it must be a keyword. */
3716 return rid_to_yy [(int) C_RID_CODE (yylval.ttype)];
3727 case CPP_OBJC_STRING:
3730 /* These tokens are C++ specific (and will not be generated
3731 in C mode, but let's be cautious). */
3733 case CPP_DEREF_STAR:
3739 /* These tokens should not survive translation phase 4. */
3742 error ("syntax error at '%s' token", NAME(last_token));
3755 timevar_push (TV_LEX);
3757 timevar_pop (TV_LEX);
3761 /* Function used when yydebug is set, to print a token in more detail. */
3764 yyprint (file, yychar, yyl)
3771 fprintf (file, " [%s]", NAME(last_token));
3782 if (IDENTIFIER_POINTER (t))
3783 fprintf (file, " `%s'", IDENTIFIER_POINTER (t));
3787 fprintf (file, " %s", GET_MODE_NAME (TYPE_MODE (TREE_TYPE (t))));
3788 if (TREE_CODE (t) == INTEGER_CST)
3791 fprintf (file, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
3792 TREE_INT_CST_HIGH (t), TREE_INT_CST_LOW (t));
3798 /* This is not the ideal place to put these, but we have to get them out
3799 of c-lex.c because cp/lex.c has its own versions. */
3801 /* Free malloced parser stacks if necessary. */
3804 free_parser_stacks ()
3808 free (malloced_yyss);
3809 free (malloced_yyvs);
3813 #include "gt-c-parse.h"