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 Free Software Foundation, Inc.
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
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. */
54 #include "diagnostic.h"
56 #ifdef MULTIBYTE_CHARS
64 /* Since parsers are distinct for each language, put the language string
67 const char * const language_string = "GNU Objective-C";
70 const char * const language_string = "GNU C";
73 /* Like YYERROR but do call yyerror. */
74 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
76 /* Cause the "yydebug" variable to be defined. */
79 /* Rename the "yyparse" function so that we can override it elsewhere. */
80 #define yyparse yyparse_1
85 %union {long itype; tree ttype; enum tree_code code;
86 const char *filename; int lineno; }
88 /* All identifiers that are not reserved words
89 and are not declared typedefs in the current block */
92 /* All identifiers that are declared typedefs in the current block.
93 In some contexts, they are treated just like IDENTIFIER,
94 but they can also serve as typespecs in declarations. */
97 /* Reserved words that specify storage class.
98 yylval contains an IDENTIFIER_NODE which indicates which one. */
101 /* Reserved words that specify type.
102 yylval contains an IDENTIFIER_NODE which indicates which one. */
105 /* Reserved words that qualify type: "const", "volatile", or "restrict".
106 yylval contains an IDENTIFIER_NODE which indicates which one. */
109 /* Character or numeric constants.
110 yylval is the node for the constant. */
113 /* String constants in raw form.
114 yylval is a STRING_CST node. */
117 /* "...", used for functions with variable arglists. */
120 /* the reserved words */
121 /* SCO include files test "ASM", so use something else. */
122 %token SIZEOF ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
123 %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD TYPEOF ALIGNOF
124 %token ATTRIBUTE EXTENSION LABEL
125 %token REALPART IMAGPART VA_ARG
126 %token PTR_VALUE PTR_BASE PTR_EXTENT
128 /* function name can be a string const or a var decl. */
129 %token STRING_FUNC_NAME VAR_FUNC_NAME
131 /* Add precedence rules to solve dangling else s/r conflict */
135 /* Define the operator tokens and their precedences.
136 The value is an integer because, if used, it is the tree code
137 to use in the expression made from the operator. */
139 %right <code> ASSIGN '='
140 %right <code> '?' ':'
146 %left <code> EQCOMPARE
147 %left <code> ARITHCOMPARE
148 %left <code> LSHIFT RSHIFT
150 %left <code> '*' '/' '%'
151 %right <code> UNARY PLUSPLUS MINUSMINUS
153 %left <code> POINTSAT '.' '(' '['
155 /* The Objective-C keywords. These are included in C and in
156 Objective C, so that the token codes are the same in both. */
157 %token INTERFACE IMPLEMENTATION END SELECTOR DEFS ENCODE
158 %token CLASSNAME PUBLIC PRIVATE PROTECTED PROTOCOL OBJECTNAME CLASS ALIAS
161 %type <ttype> ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
162 %type <ttype> BREAK CONTINUE RETURN GOTO ASM_KEYWORD SIZEOF TYPEOF ALIGNOF
164 %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist exprlist
165 %type <ttype> expr_no_commas cast_expr unary_expr primary string STRING
166 %type <ttype> declspecs_nosc_nots_nosa_noea declspecs_nosc_nots_nosa_ea
167 %type <ttype> declspecs_nosc_nots_sa_noea declspecs_nosc_nots_sa_ea
168 %type <ttype> declspecs_nosc_ts_nosa_noea declspecs_nosc_ts_nosa_ea
169 %type <ttype> declspecs_nosc_ts_sa_noea declspecs_nosc_ts_sa_ea
170 %type <ttype> declspecs_sc_nots_nosa_noea declspecs_sc_nots_nosa_ea
171 %type <ttype> declspecs_sc_nots_sa_noea declspecs_sc_nots_sa_ea
172 %type <ttype> declspecs_sc_ts_nosa_noea declspecs_sc_ts_nosa_ea
173 %type <ttype> declspecs_sc_ts_sa_noea declspecs_sc_ts_sa_ea
174 %type <ttype> declspecs_ts declspecs_nots
175 %type <ttype> declspecs_ts_nosa declspecs_nots_nosa
176 %type <ttype> declspecs_nosc_ts declspecs_nosc_nots declspecs_nosc declspecs
177 %type <ttype> maybe_type_quals_setattrs typespec_nonattr typespec_attr
178 %type <ttype> typespec_reserved_nonattr typespec_reserved_attr
179 %type <ttype> typespec_nonreserved_nonattr
181 %type <ttype> SCSPEC TYPESPEC TYPE_QUAL maybe_type_qual
182 %type <ttype> initdecls notype_initdecls initdcl notype_initdcl
183 %type <ttype> init maybeasm
184 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
185 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
186 %type <ttype> maybe_setattrs
187 %type <ttype> any_word extension
189 %type <ttype> compstmt compstmt_start compstmt_nostart compstmt_primary_start
190 %type <ttype> do_stmt_start poplevel stmt label
192 %type <ttype> c99_block_start c99_block_end
193 %type <ttype> declarator
194 %type <ttype> notype_declarator after_type_declarator
195 %type <ttype> parm_declarator
196 %type <ttype> parm_declarator_starttypename parm_declarator_nostarttypename
197 %type <ttype> array_declarator
199 %type <ttype> structsp_attr structsp_nonattr
200 %type <ttype> component_decl_list component_decl_list2
201 %type <ttype> component_decl components components_notype component_declarator
202 %type <ttype> component_notype_declarator
203 %type <ttype> enumlist enumerator
204 %type <ttype> struct_head union_head enum_head
205 %type <ttype> typename absdcl absdcl1 absdcl1_ea absdcl1_noea
206 %type <ttype> direct_absdcl1 absdcl_maybe_attribute
207 %type <ttype> xexpr parms parm firstparm identifiers
209 %type <ttype> parmlist parmlist_1 parmlist_2
210 %type <ttype> parmlist_or_identifiers parmlist_or_identifiers_1
211 %type <ttype> identifiers_or_typenames
213 %type <itype> setspecs setspecs_fp
215 %type <filename> save_filename
216 %type <lineno> save_lineno
219 /* the Objective-C nonterminals */
221 %type <ttype> ivar_decl_list ivar_decls ivar_decl ivars ivar_declarator
222 %type <ttype> methoddecl unaryselector keywordselector selector
223 %type <ttype> keyworddecl receiver objcmessageexpr messageargs
224 %type <ttype> keywordexpr keywordarglist keywordarg
225 %type <ttype> myparms myparm optparmlist reservedwords objcselectorexpr
226 %type <ttype> selectorarg keywordnamelist keywordname objcencodeexpr
227 %type <ttype> objc_string non_empty_protocolrefs protocolrefs identifier_list objcprotocolexpr
229 %type <ttype> CLASSNAME OBJECTNAME
233 /* Number of statements (loosely speaking) and compound statements
235 static int stmt_count;
236 static int compstmt_count;
238 /* Input file and line number of the end of the body of last simple_if;
239 used by the stmt-rule immediately after simple_if returns. */
240 static const char *if_stmt_file;
241 static int if_stmt_line;
243 /* List of types and structure classes of the current declaration. */
244 static tree current_declspecs = NULL_TREE;
245 static tree prefix_attributes = NULL_TREE;
247 /* List of all the attributes applying to the identifier currently being
248 declared; includes prefix_attributes and possibly some more attributes
249 just after a comma. */
250 static tree all_prefix_attributes = NULL_TREE;
252 /* Stack of saved values of current_declspecs, prefix_attributes and
253 all_prefix_attributes. */
254 static tree declspec_stack;
256 /* PUSH_DECLSPEC_STACK is called from setspecs; POP_DECLSPEC_STACK
257 should be called from the productions making use of setspecs. */
258 #define PUSH_DECLSPEC_STACK \
260 declspec_stack = tree_cons (build_tree_list (prefix_attributes, \
261 all_prefix_attributes), \
266 #define POP_DECLSPEC_STACK \
268 current_declspecs = TREE_VALUE (declspec_stack); \
269 prefix_attributes = TREE_PURPOSE (TREE_PURPOSE (declspec_stack)); \
270 all_prefix_attributes = TREE_VALUE (TREE_PURPOSE (declspec_stack)); \
271 declspec_stack = TREE_CHAIN (declspec_stack); \
274 /* For __extension__, save/restore the warning flags which are
275 controlled by __extension__. */
276 #define SAVE_WARN_FLAGS() \
277 size_int (pedantic | (warn_pointer_arith << 1))
278 #define RESTORE_WARN_FLAGS(tval) \
280 int val = tree_low_cst (tval, 0); \
281 pedantic = val & 1; \
282 warn_pointer_arith = (val >> 1) & 1; \
286 /* Objective-C specific information */
288 tree objc_interface_context;
289 tree objc_implementation_context;
290 tree objc_method_context;
291 tree objc_ivar_chain;
292 tree objc_ivar_context;
293 enum tree_code objc_inherit_code;
294 int objc_receiver_context;
295 int objc_public_flag;
300 /* Tell yyparse how to print a token's value, if yydebug is set. */
302 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
304 static void yyprint PARAMS ((FILE *, int, YYSTYPE));
305 static void yyerror PARAMS ((const char *));
306 static int yylexname PARAMS ((void));
307 static inline int _yylex PARAMS ((void));
308 static int yylex PARAMS ((void));
309 static void init_reswords PARAMS ((void));
311 /* Add GC roots for variables local to this file. */
315 ggc_add_tree_root (&declspec_stack, 1);
316 ggc_add_tree_root (¤t_declspecs, 1);
317 ggc_add_tree_root (&prefix_attributes, 1);
318 ggc_add_tree_root (&all_prefix_attributes, 1);
320 ggc_add_tree_root (&objc_interface_context, 1);
321 ggc_add_tree_root (&objc_implementation_context, 1);
322 ggc_add_tree_root (&objc_method_context, 1);
323 ggc_add_tree_root (&objc_ivar_chain, 1);
324 ggc_add_tree_root (&objc_ivar_context, 1);
333 pedwarn ("ISO C forbids an empty source file");
338 /* In case there were missing closebraces,
339 get us back to the global binding level. */
340 while (! global_bindings_p ())
343 finish_fname_decls ();
349 /* the reason for the strange actions in this rule
350 is so that notype_initdecls when reached via datadef
351 can find a valid list of type and sc specs in $0. */
354 {$<ttype>$ = NULL_TREE; } extdef
355 | extdefs {$<ttype>$ = NULL_TREE; ggc_collect(); } extdef
364 | ASM_KEYWORD '(' expr ')' ';'
366 if ((TREE_CODE ($3) == ADDR_EXPR
367 && TREE_CODE (TREE_OPERAND ($3, 0)) == STRING_CST)
368 || TREE_CODE ($3) == STRING_CST)
371 error ("argument of `asm' is not a constant string"); }
373 { RESTORE_WARN_FLAGS ($1); }
377 setspecs notype_initdecls ';'
379 error ("ISO C forbids data definition with no type or storage class");
380 else if (!flag_traditional)
381 warning ("data definition has no type or storage class");
383 POP_DECLSPEC_STACK; }
384 | declspecs_nots setspecs notype_initdecls ';'
385 { POP_DECLSPEC_STACK; }
386 | declspecs_ts setspecs initdecls ';'
387 { POP_DECLSPEC_STACK; }
394 pedwarn ("ISO C does not allow extra `;' outside of a function"); }
398 declspecs_ts setspecs declarator
399 { if (! start_function (current_declspecs, $3,
400 all_prefix_attributes))
404 { store_parm_decls (); }
405 save_filename save_lineno compstmt_or_error
406 { DECL_SOURCE_FILE (current_function_decl) = $7;
407 DECL_SOURCE_LINE (current_function_decl) = $8;
409 POP_DECLSPEC_STACK; }
410 | declspecs_ts setspecs declarator error
411 { POP_DECLSPEC_STACK; }
412 | declspecs_nots setspecs notype_declarator
413 { if (! start_function (current_declspecs, $3,
414 all_prefix_attributes))
418 { store_parm_decls (); }
419 save_filename save_lineno compstmt_or_error
420 { DECL_SOURCE_FILE (current_function_decl) = $7;
421 DECL_SOURCE_LINE (current_function_decl) = $8;
423 POP_DECLSPEC_STACK; }
424 | declspecs_nots setspecs notype_declarator error
425 { POP_DECLSPEC_STACK; }
426 | setspecs notype_declarator
427 { if (! start_function (NULL_TREE, $2,
428 all_prefix_attributes))
432 { store_parm_decls (); }
433 save_filename save_lineno compstmt_or_error
434 { DECL_SOURCE_FILE (current_function_decl) = $6;
435 DECL_SOURCE_LINE (current_function_decl) = $7;
437 POP_DECLSPEC_STACK; }
438 | setspecs notype_declarator error
439 { POP_DECLSPEC_STACK; }
454 { $$ = NEGATE_EXPR; }
458 if (warn_traditional && !in_system_header)
459 warning ("traditional C rejects the unary plus operator");
463 { $$ = PREINCREMENT_EXPR; }
465 { $$ = PREDECREMENT_EXPR; }
467 { $$ = BIT_NOT_EXPR; }
469 { $$ = TRUTH_NOT_EXPR; }
472 expr: nonnull_exprlist
473 { $$ = build_compound_expr ($1); }
484 { $$ = build_tree_list (NULL_TREE, $1); }
485 | nonnull_exprlist ',' expr_no_commas
486 { chainon ($1, build_tree_list (NULL_TREE, $3)); }
491 | '*' cast_expr %prec UNARY
492 { $$ = build_indirect_ref ($2, "unary *"); }
493 /* __extension__ turns off -pedantic for following primary. */
494 | extension cast_expr %prec UNARY
496 RESTORE_WARN_FLAGS ($1); }
497 | unop cast_expr %prec UNARY
498 { $$ = build_unary_op ($1, $2, 0);
499 overflow_warning ($$); }
500 /* Refer to the address of a label as a pointer. */
502 { $$ = finish_label_address_expr ($2); }
503 /* This seems to be impossible on some machines, so let's turn it off.
504 You can use __builtin_next_arg to find the anonymous stack args.
506 { tree types = TYPE_ARG_TYPES (TREE_TYPE (current_function_decl));
507 $$ = error_mark_node;
508 if (TREE_VALUE (tree_last (types)) == void_type_node)
509 error ("`&...' used in function with fixed number of arguments");
513 pedwarn ("ISO C forbids `&...'");
514 $$ = tree_last (DECL_ARGUMENTS (current_function_decl));
515 $$ = build_unary_op (ADDR_EXPR, $$, 0);
518 | sizeof unary_expr %prec UNARY
520 if (TREE_CODE ($2) == COMPONENT_REF
521 && DECL_C_BIT_FIELD (TREE_OPERAND ($2, 1)))
522 error ("`sizeof' applied to a bit-field");
523 $$ = c_sizeof (TREE_TYPE ($2)); }
524 | sizeof '(' typename ')' %prec HYPERUNARY
526 $$ = c_sizeof (groktypename ($3)); }
527 | alignof unary_expr %prec UNARY
529 $$ = c_alignof_expr ($2); }
530 | alignof '(' typename ')' %prec HYPERUNARY
532 $$ = c_alignof (groktypename ($3)); }
533 | REALPART cast_expr %prec UNARY
534 { $$ = build_unary_op (REALPART_EXPR, $2, 0); }
535 | IMAGPART cast_expr %prec UNARY
536 { $$ = build_unary_op (IMAGPART_EXPR, $2, 0); }
540 SIZEOF { skip_evaluation++; }
544 ALIGNOF { skip_evaluation++; }
549 | '(' typename ')' cast_expr %prec UNARY
550 { $$ = c_cast_expr ($2, $4); }
555 | expr_no_commas '+' expr_no_commas
556 { $$ = parser_build_binary_op ($2, $1, $3); }
557 | expr_no_commas '-' expr_no_commas
558 { $$ = parser_build_binary_op ($2, $1, $3); }
559 | expr_no_commas '*' expr_no_commas
560 { $$ = parser_build_binary_op ($2, $1, $3); }
561 | expr_no_commas '/' expr_no_commas
562 { $$ = parser_build_binary_op ($2, $1, $3); }
563 | expr_no_commas '%' expr_no_commas
564 { $$ = parser_build_binary_op ($2, $1, $3); }
565 | expr_no_commas LSHIFT expr_no_commas
566 { $$ = parser_build_binary_op ($2, $1, $3); }
567 | expr_no_commas RSHIFT expr_no_commas
568 { $$ = parser_build_binary_op ($2, $1, $3); }
569 | expr_no_commas ARITHCOMPARE expr_no_commas
570 { $$ = parser_build_binary_op ($2, $1, $3); }
571 | expr_no_commas EQCOMPARE expr_no_commas
572 { $$ = parser_build_binary_op ($2, $1, $3); }
573 | expr_no_commas '&' expr_no_commas
574 { $$ = parser_build_binary_op ($2, $1, $3); }
575 | expr_no_commas '|' expr_no_commas
576 { $$ = parser_build_binary_op ($2, $1, $3); }
577 | expr_no_commas '^' expr_no_commas
578 { $$ = parser_build_binary_op ($2, $1, $3); }
579 | expr_no_commas ANDAND
580 { $1 = truthvalue_conversion (default_conversion ($1));
581 skip_evaluation += $1 == boolean_false_node; }
583 { skip_evaluation -= $1 == boolean_false_node;
584 $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $4); }
585 | expr_no_commas OROR
586 { $1 = truthvalue_conversion (default_conversion ($1));
587 skip_evaluation += $1 == boolean_true_node; }
589 { skip_evaluation -= $1 == boolean_true_node;
590 $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $4); }
592 { $1 = truthvalue_conversion (default_conversion ($1));
593 skip_evaluation += $1 == boolean_false_node; }
595 { skip_evaluation += (($1 == boolean_true_node)
596 - ($1 == boolean_false_node)); }
598 { skip_evaluation -= $1 == boolean_true_node;
599 $$ = build_conditional_expr ($1, $4, $7); }
602 pedwarn ("ISO C forbids omitting the middle term of a ?: expression");
603 /* Make sure first operand is calculated only once. */
604 $<ttype>2 = save_expr ($1);
605 $1 = truthvalue_conversion (default_conversion ($<ttype>2));
606 skip_evaluation += $1 == boolean_true_node; }
608 { skip_evaluation -= $1 == boolean_true_node;
609 $$ = build_conditional_expr ($1, $<ttype>2, $5); }
610 | expr_no_commas '=' expr_no_commas
612 $$ = build_modify_expr ($1, NOP_EXPR, $3);
613 class = TREE_CODE_CLASS (TREE_CODE ($$));
614 if (class == 'e' || class == '1'
615 || class == '2' || class == '<')
616 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR);
618 | expr_no_commas ASSIGN expr_no_commas
620 $$ = build_modify_expr ($1, $2, $3);
621 /* This inhibits warnings in truthvalue_conversion. */
622 class = TREE_CODE_CLASS (TREE_CODE ($$));
623 if (class == 'e' || class == '1'
624 || class == '2' || class == '<')
625 C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK);
632 if (yychar == YYEMPTY)
634 $$ = build_external_ref ($1, yychar == '(');
638 { $$ = combine_strings ($1); }
640 { $$ = fname_decl (C_RID_CODE ($$), $$); }
641 | '(' typename ')' '{'
642 { start_init (NULL_TREE, NULL, 0);
643 $2 = groktypename ($2);
644 really_start_incremental_init ($2); }
645 initlist_maybe_comma '}' %prec UNARY
647 tree result = pop_init_level (0);
651 if (pedantic && ! flag_isoc99)
652 pedwarn ("ISO C89 forbids compound literals");
653 if (TYPE_NAME (type) != 0)
655 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
656 name = IDENTIFIER_POINTER (TYPE_NAME (type));
658 name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
663 if (TREE_CODE (type) == ARRAY_TYPE && !COMPLETE_TYPE_P (type))
665 int failure = complete_array_type (type, $$, 1);
671 { char class = TREE_CODE_CLASS (TREE_CODE ($2));
672 if (class == 'e' || class == '1'
673 || class == '2' || class == '<')
674 C_SET_EXP_ORIGINAL_CODE ($2, ERROR_MARK);
677 { $$ = error_mark_node; }
678 | compstmt_primary_start compstmt_nostart ')'
679 { tree saved_last_tree;
682 pedwarn ("ISO C forbids braced-groups within expressions");
685 saved_last_tree = COMPOUND_BODY ($1);
686 RECHAIN_STMTS ($1, COMPOUND_BODY ($1));
687 last_tree = saved_last_tree;
688 TREE_CHAIN (last_tree) = NULL_TREE;
690 last_expr_type = void_type_node;
691 $$ = build1 (STMT_EXPR, last_expr_type, $1);
692 TREE_SIDE_EFFECTS ($$) = 1;
694 | compstmt_primary_start error ')'
697 last_tree = COMPOUND_BODY ($1);
698 TREE_CHAIN (last_tree) = NULL_TREE;
699 $$ = error_mark_node;
701 | primary '(' exprlist ')' %prec '.'
702 { $$ = build_function_call ($1, $3); }
703 | VA_ARG '(' expr_no_commas ',' typename ')'
704 { $$ = build_va_arg ($3, groktypename ($5)); }
705 | primary '[' expr ']' %prec '.'
706 { $$ = build_array_ref ($1, $3); }
707 | primary '.' identifier
710 if (!is_public ($1, $3))
711 $$ = error_mark_node;
714 $$ = build_component_ref ($1, $3);
716 | primary POINTSAT identifier
718 tree expr = build_indirect_ref ($1, "->");
721 if (!is_public (expr, $3))
722 $$ = error_mark_node;
725 $$ = build_component_ref (expr, $3);
728 { $$ = build_unary_op (POSTINCREMENT_EXPR, $1, 0); }
730 { $$ = build_unary_op (POSTDECREMENT_EXPR, $1, 0); }
733 { $$ = build_message_expr ($1); }
735 { $$ = build_selector_expr ($1); }
737 { $$ = build_protocol_expr ($1); }
739 { $$ = build_encode_expr ($1); }
741 { $$ = build_objc_string_object ($1); }
745 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
751 static int last_lineno = 0;
752 static const char *last_input_filename = 0;
754 $$ = chainon ($1, $2);
756 if (warn_traditional && !in_system_header
757 && (lineno != last_lineno || !last_input_filename ||
758 strcmp (last_input_filename, input_filename)))
760 warning ("traditional C rejects string concatenation");
761 last_lineno = lineno;
762 last_input_filename = input_filename;
769 /* Produces an STRING_CST with perhaps more STRING_CSTs chained
770 onto it, which is to be read as an ObjC string object. */
774 | objc_string '@' STRING
775 { $$ = chainon ($1, $3); }
779 old_style_parm_decls:
783 /* ... is used here to indicate a varargs function. */
786 pedwarn ("ISO C does not permit use of `varargs.h'"); }
789 /* The following are analogous to lineno_decl, decls and decl
790 except that they do not allow nested functions.
791 They are used for old-style parm decls. */
793 save_filename save_lineno datadecl
800 | datadecls lineno_datadecl
801 | lineno_datadecl errstmt
804 /* We don't allow prefix attributes here because they cause reduce/reduce
805 conflicts: we can't know whether we're parsing a function decl with
806 attribute suffix, or function defn with attribute prefix on first old
809 declspecs_ts_nosa setspecs initdecls ';'
810 { POP_DECLSPEC_STACK; }
811 | declspecs_nots_nosa setspecs notype_initdecls ';'
812 { POP_DECLSPEC_STACK; }
813 | declspecs_ts_nosa ';'
814 { shadow_tag_warned ($1, 1);
815 pedwarn ("empty declaration"); }
816 | declspecs_nots_nosa ';'
817 { pedwarn ("empty declaration"); }
820 /* This combination which saves a lineno before a decl
821 is the normal thing to use, rather than decl itself.
822 This is to avoid shift/reduce conflicts in contexts
823 where statement labels are allowed. */
825 save_filename save_lineno decl
829 /* records the type and storage class specs to use for processing
830 the declarators that follow.
831 Maintains a stack of outer-level values of current_declspecs,
832 for the sake of parm declarations nested in function declarators. */
833 setspecs: /* empty */
834 { pending_xref_error ();
836 split_specs_attrs ($<ttype>0,
837 ¤t_declspecs, &prefix_attributes);
838 all_prefix_attributes = prefix_attributes; }
841 /* ??? Yuck. See maybe_setattrs. */
842 setattrs: /* empty */
843 { all_prefix_attributes = chainon ($<ttype>0, all_prefix_attributes); }
847 /* ??? Yuck. setattrs is a quick hack. We can't use
848 prefix_attributes because $1 only applies to this
849 declarator. We assume setspecs has already been done.
850 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
851 attributes could be recognized here or in `attributes').
852 Properly attributes ought to be able to apply to any level of
853 nested declarator, but the necessary compiler support isn't
854 present, so the attributes apply to a declaration (which may be
856 maybe_attribute setattrs
859 /* Possibly attributes after a comma, which should reset all_prefix_attributes
860 to prefix_attributes with these ones chained on the front. */
862 { all_prefix_attributes = prefix_attributes; }
867 declspecs_ts setspecs initdecls ';'
868 { POP_DECLSPEC_STACK; }
869 | declspecs_nots setspecs notype_initdecls ';'
870 { POP_DECLSPEC_STACK; }
871 | declspecs_ts setspecs nested_function
872 { POP_DECLSPEC_STACK; }
873 | declspecs_nots setspecs notype_nested_function
874 { POP_DECLSPEC_STACK; }
878 { RESTORE_WARN_FLAGS ($1); }
881 /* A list of declaration specifiers. These are:
883 - Storage class specifiers (SCSPEC), which for GCC currently include
884 function specifiers ("inline").
886 - Type specifiers (typespec_*).
888 - Type qualifiers (TYPE_QUAL).
890 - Attribute specifier lists (attributes).
892 These are stored as a TREE_LIST; the head of the list is the last
893 item in the specifier list. Each entry in the list has either a
894 TREE_PURPOSE that is an attribute specifier list, or a TREE_VALUE that
895 is a single other specifier or qualifier; and a TREE_CHAIN that is the
896 rest of the list. TREE_STATIC is set on the list if something other
897 than a storage class specifier or attribute has been seen; this is used
898 to warn for the obsolescent usage of storage class specifiers other than
899 at the start of the list. (Doing this properly would require function
900 specifiers to be handled separately from storage class specifiers.)
902 The various cases below are classified according to:
904 (a) Whether a storage class specifier is included or not; some
905 places in the grammar disallow storage class specifiers (_sc or _nosc).
907 (b) Whether a type specifier has been seen; after a type specifier,
908 a typedef name is an identifier to redeclare (_ts or _nots).
910 (c) Whether the list starts with an attribute; in certain places,
911 the grammar requires specifiers that don't start with an attribute
914 (d) Whether the list ends with an attribute (or a specifier such that
915 any following attribute would have been parsed as part of that specifier);
916 this avoids shift-reduce conflicts in the parsing of attributes
921 (i) Distinguish between function specifiers and storage class specifiers,
922 at least for the purpose of warnings about obsolescent usage.
924 (ii) Halve the number of productions here by eliminating the _sc/_nosc
925 distinction and instead checking where required that storage class
926 specifiers aren't present. */
928 /* Declspecs which contain at least one type specifier or typedef name.
929 (Just `const' or `volatile' is not enough.)
930 A typedef'd name following these is taken as a name to be declared.
931 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
933 declspecs_nosc_nots_nosa_noea:
935 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
936 TREE_STATIC ($$) = 1; }
937 | declspecs_nosc_nots_nosa_noea TYPE_QUAL
938 { $$ = tree_cons (NULL_TREE, $2, $1);
939 TREE_STATIC ($$) = 1; }
940 | declspecs_nosc_nots_nosa_ea TYPE_QUAL
941 { $$ = tree_cons (NULL_TREE, $2, $1);
942 TREE_STATIC ($$) = 1; }
945 declspecs_nosc_nots_nosa_ea:
946 declspecs_nosc_nots_nosa_noea attributes
947 { $$ = tree_cons ($2, NULL_TREE, $1);
948 TREE_STATIC ($$) = TREE_STATIC ($1); }
951 declspecs_nosc_nots_sa_noea:
952 declspecs_nosc_nots_sa_noea TYPE_QUAL
953 { $$ = tree_cons (NULL_TREE, $2, $1);
954 TREE_STATIC ($$) = 1; }
955 | declspecs_nosc_nots_sa_ea TYPE_QUAL
956 { $$ = tree_cons (NULL_TREE, $2, $1);
957 TREE_STATIC ($$) = 1; }
960 declspecs_nosc_nots_sa_ea:
962 { $$ = tree_cons ($1, NULL_TREE, NULL_TREE);
963 TREE_STATIC ($$) = 0; }
964 | declspecs_nosc_nots_sa_noea attributes
965 { $$ = tree_cons ($2, NULL_TREE, $1);
966 TREE_STATIC ($$) = TREE_STATIC ($1); }
969 declspecs_nosc_ts_nosa_noea:
971 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
972 TREE_STATIC ($$) = 1; }
973 | declspecs_nosc_ts_nosa_noea TYPE_QUAL
974 { $$ = tree_cons (NULL_TREE, $2, $1);
975 TREE_STATIC ($$) = 1; }
976 | declspecs_nosc_ts_nosa_ea TYPE_QUAL
977 { $$ = tree_cons (NULL_TREE, $2, $1);
978 TREE_STATIC ($$) = 1; }
979 | declspecs_nosc_ts_nosa_noea typespec_reserved_nonattr
980 { $$ = tree_cons (NULL_TREE, $2, $1);
981 TREE_STATIC ($$) = 1; }
982 | declspecs_nosc_ts_nosa_ea typespec_reserved_nonattr
983 { $$ = tree_cons (NULL_TREE, $2, $1);
984 TREE_STATIC ($$) = 1; }
985 | declspecs_nosc_nots_nosa_noea typespec_nonattr
986 { $$ = tree_cons (NULL_TREE, $2, $1);
987 TREE_STATIC ($$) = 1; }
988 | declspecs_nosc_nots_nosa_ea typespec_nonattr
989 { $$ = tree_cons (NULL_TREE, $2, $1);
990 TREE_STATIC ($$) = 1; }
993 declspecs_nosc_ts_nosa_ea:
995 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
996 TREE_STATIC ($$) = 1; }
997 | declspecs_nosc_ts_nosa_noea attributes
998 { $$ = tree_cons ($2, NULL_TREE, $1);
999 TREE_STATIC ($$) = TREE_STATIC ($1); }
1000 | declspecs_nosc_ts_nosa_noea typespec_reserved_attr
1001 { $$ = tree_cons (NULL_TREE, $2, $1);
1002 TREE_STATIC ($$) = 1; }
1003 | declspecs_nosc_ts_nosa_ea typespec_reserved_attr
1004 { $$ = tree_cons (NULL_TREE, $2, $1);
1005 TREE_STATIC ($$) = 1; }
1006 | declspecs_nosc_nots_nosa_noea typespec_attr
1007 { $$ = tree_cons (NULL_TREE, $2, $1);
1008 TREE_STATIC ($$) = 1; }
1009 | declspecs_nosc_nots_nosa_ea typespec_attr
1010 { $$ = tree_cons (NULL_TREE, $2, $1);
1011 TREE_STATIC ($$) = 1; }
1014 declspecs_nosc_ts_sa_noea:
1015 declspecs_nosc_ts_sa_noea TYPE_QUAL
1016 { $$ = tree_cons (NULL_TREE, $2, $1);
1017 TREE_STATIC ($$) = 1; }
1018 | declspecs_nosc_ts_sa_ea TYPE_QUAL
1019 { $$ = tree_cons (NULL_TREE, $2, $1);
1020 TREE_STATIC ($$) = 1; }
1021 | declspecs_nosc_ts_sa_noea typespec_reserved_nonattr
1022 { $$ = tree_cons (NULL_TREE, $2, $1);
1023 TREE_STATIC ($$) = 1; }
1024 | declspecs_nosc_ts_sa_ea typespec_reserved_nonattr
1025 { $$ = tree_cons (NULL_TREE, $2, $1);
1026 TREE_STATIC ($$) = 1; }
1027 | declspecs_nosc_nots_sa_noea typespec_nonattr
1028 { $$ = tree_cons (NULL_TREE, $2, $1);
1029 TREE_STATIC ($$) = 1; }
1030 | declspecs_nosc_nots_sa_ea typespec_nonattr
1031 { $$ = tree_cons (NULL_TREE, $2, $1);
1032 TREE_STATIC ($$) = 1; }
1035 declspecs_nosc_ts_sa_ea:
1036 declspecs_nosc_ts_sa_noea attributes
1037 { $$ = tree_cons ($2, NULL_TREE, $1);
1038 TREE_STATIC ($$) = TREE_STATIC ($1); }
1039 | declspecs_nosc_ts_sa_noea typespec_reserved_attr
1040 { $$ = tree_cons (NULL_TREE, $2, $1);
1041 TREE_STATIC ($$) = 1; }
1042 | declspecs_nosc_ts_sa_ea typespec_reserved_attr
1043 { $$ = tree_cons (NULL_TREE, $2, $1);
1044 TREE_STATIC ($$) = 1; }
1045 | declspecs_nosc_nots_sa_noea typespec_attr
1046 { $$ = tree_cons (NULL_TREE, $2, $1);
1047 TREE_STATIC ($$) = 1; }
1048 | declspecs_nosc_nots_sa_ea typespec_attr
1049 { $$ = tree_cons (NULL_TREE, $2, $1);
1050 TREE_STATIC ($$) = 1; }
1053 declspecs_sc_nots_nosa_noea:
1055 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
1056 TREE_STATIC ($$) = 0; }
1057 | declspecs_sc_nots_nosa_noea TYPE_QUAL
1058 { $$ = tree_cons (NULL_TREE, $2, $1);
1059 TREE_STATIC ($$) = 1; }
1060 | declspecs_sc_nots_nosa_ea TYPE_QUAL
1061 { $$ = tree_cons (NULL_TREE, $2, $1);
1062 TREE_STATIC ($$) = 1; }
1063 | declspecs_nosc_nots_nosa_noea SCSPEC
1064 { if (extra_warnings && TREE_STATIC ($1))
1065 warning ("`%s' is not at beginning of declaration",
1066 IDENTIFIER_POINTER ($2));
1067 $$ = tree_cons (NULL_TREE, $2, $1);
1068 TREE_STATIC ($$) = TREE_STATIC ($1); }
1069 | declspecs_nosc_nots_nosa_ea SCSPEC
1070 { if (extra_warnings && TREE_STATIC ($1))
1071 warning ("`%s' is not at beginning of declaration",
1072 IDENTIFIER_POINTER ($2));
1073 $$ = tree_cons (NULL_TREE, $2, $1);
1074 TREE_STATIC ($$) = TREE_STATIC ($1); }
1075 | declspecs_sc_nots_nosa_noea SCSPEC
1076 { if (extra_warnings && TREE_STATIC ($1))
1077 warning ("`%s' is not at beginning of declaration",
1078 IDENTIFIER_POINTER ($2));
1079 $$ = tree_cons (NULL_TREE, $2, $1);
1080 TREE_STATIC ($$) = TREE_STATIC ($1); }
1081 | declspecs_sc_nots_nosa_ea 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); }
1089 declspecs_sc_nots_nosa_ea:
1090 declspecs_sc_nots_nosa_noea attributes
1091 { $$ = tree_cons ($2, NULL_TREE, $1);
1092 TREE_STATIC ($$) = TREE_STATIC ($1); }
1095 declspecs_sc_nots_sa_noea:
1096 declspecs_sc_nots_sa_noea TYPE_QUAL
1097 { $$ = tree_cons (NULL_TREE, $2, $1);
1098 TREE_STATIC ($$) = 1; }
1099 | declspecs_sc_nots_sa_ea TYPE_QUAL
1100 { $$ = tree_cons (NULL_TREE, $2, $1);
1101 TREE_STATIC ($$) = 1; }
1102 | declspecs_nosc_nots_sa_noea SCSPEC
1103 { if (extra_warnings && TREE_STATIC ($1))
1104 warning ("`%s' is not at beginning of declaration",
1105 IDENTIFIER_POINTER ($2));
1106 $$ = tree_cons (NULL_TREE, $2, $1);
1107 TREE_STATIC ($$) = TREE_STATIC ($1); }
1108 | declspecs_nosc_nots_sa_ea SCSPEC
1109 { if (extra_warnings && TREE_STATIC ($1))
1110 warning ("`%s' is not at beginning of declaration",
1111 IDENTIFIER_POINTER ($2));
1112 $$ = tree_cons (NULL_TREE, $2, $1);
1113 TREE_STATIC ($$) = TREE_STATIC ($1); }
1114 | declspecs_sc_nots_sa_noea SCSPEC
1115 { if (extra_warnings && TREE_STATIC ($1))
1116 warning ("`%s' is not at beginning of declaration",
1117 IDENTIFIER_POINTER ($2));
1118 $$ = tree_cons (NULL_TREE, $2, $1);
1119 TREE_STATIC ($$) = TREE_STATIC ($1); }
1120 | declspecs_sc_nots_sa_ea SCSPEC
1121 { if (extra_warnings && TREE_STATIC ($1))
1122 warning ("`%s' is not at beginning of declaration",
1123 IDENTIFIER_POINTER ($2));
1124 $$ = tree_cons (NULL_TREE, $2, $1);
1125 TREE_STATIC ($$) = TREE_STATIC ($1); }
1128 declspecs_sc_nots_sa_ea:
1129 declspecs_sc_nots_sa_noea attributes
1130 { $$ = tree_cons ($2, NULL_TREE, $1);
1131 TREE_STATIC ($$) = TREE_STATIC ($1); }
1134 declspecs_sc_ts_nosa_noea:
1135 declspecs_sc_ts_nosa_noea TYPE_QUAL
1136 { $$ = tree_cons (NULL_TREE, $2, $1);
1137 TREE_STATIC ($$) = 1; }
1138 | declspecs_sc_ts_nosa_ea TYPE_QUAL
1139 { $$ = tree_cons (NULL_TREE, $2, $1);
1140 TREE_STATIC ($$) = 1; }
1141 | declspecs_sc_ts_nosa_noea typespec_reserved_nonattr
1142 { $$ = tree_cons (NULL_TREE, $2, $1);
1143 TREE_STATIC ($$) = 1; }
1144 | declspecs_sc_ts_nosa_ea typespec_reserved_nonattr
1145 { $$ = tree_cons (NULL_TREE, $2, $1);
1146 TREE_STATIC ($$) = 1; }
1147 | declspecs_sc_nots_nosa_noea typespec_nonattr
1148 { $$ = tree_cons (NULL_TREE, $2, $1);
1149 TREE_STATIC ($$) = 1; }
1150 | declspecs_sc_nots_nosa_ea typespec_nonattr
1151 { $$ = tree_cons (NULL_TREE, $2, $1);
1152 TREE_STATIC ($$) = 1; }
1153 | declspecs_nosc_ts_nosa_noea SCSPEC
1154 { if (extra_warnings && TREE_STATIC ($1))
1155 warning ("`%s' is not at beginning of declaration",
1156 IDENTIFIER_POINTER ($2));
1157 $$ = tree_cons (NULL_TREE, $2, $1);
1158 TREE_STATIC ($$) = TREE_STATIC ($1); }
1159 | declspecs_nosc_ts_nosa_ea SCSPEC
1160 { if (extra_warnings && TREE_STATIC ($1))
1161 warning ("`%s' is not at beginning of declaration",
1162 IDENTIFIER_POINTER ($2));
1163 $$ = tree_cons (NULL_TREE, $2, $1);
1164 TREE_STATIC ($$) = TREE_STATIC ($1); }
1165 | declspecs_sc_ts_nosa_noea SCSPEC
1166 { if (extra_warnings && TREE_STATIC ($1))
1167 warning ("`%s' is not at beginning of declaration",
1168 IDENTIFIER_POINTER ($2));
1169 $$ = tree_cons (NULL_TREE, $2, $1);
1170 TREE_STATIC ($$) = TREE_STATIC ($1); }
1171 | declspecs_sc_ts_nosa_ea SCSPEC
1172 { if (extra_warnings && TREE_STATIC ($1))
1173 warning ("`%s' is not at beginning of declaration",
1174 IDENTIFIER_POINTER ($2));
1175 $$ = tree_cons (NULL_TREE, $2, $1);
1176 TREE_STATIC ($$) = TREE_STATIC ($1); }
1179 declspecs_sc_ts_nosa_ea:
1180 declspecs_sc_ts_nosa_noea attributes
1181 { $$ = tree_cons ($2, NULL_TREE, $1);
1182 TREE_STATIC ($$) = TREE_STATIC ($1); }
1183 | declspecs_sc_ts_nosa_noea typespec_reserved_attr
1184 { $$ = tree_cons (NULL_TREE, $2, $1);
1185 TREE_STATIC ($$) = 1; }
1186 | declspecs_sc_ts_nosa_ea typespec_reserved_attr
1187 { $$ = tree_cons (NULL_TREE, $2, $1);
1188 TREE_STATIC ($$) = 1; }
1189 | declspecs_sc_nots_nosa_noea typespec_attr
1190 { $$ = tree_cons (NULL_TREE, $2, $1);
1191 TREE_STATIC ($$) = 1; }
1192 | declspecs_sc_nots_nosa_ea typespec_attr
1193 { $$ = tree_cons (NULL_TREE, $2, $1);
1194 TREE_STATIC ($$) = 1; }
1197 declspecs_sc_ts_sa_noea:
1198 declspecs_sc_ts_sa_noea TYPE_QUAL
1199 { $$ = tree_cons (NULL_TREE, $2, $1);
1200 TREE_STATIC ($$) = 1; }
1201 | declspecs_sc_ts_sa_ea TYPE_QUAL
1202 { $$ = tree_cons (NULL_TREE, $2, $1);
1203 TREE_STATIC ($$) = 1; }
1204 | declspecs_sc_ts_sa_noea typespec_reserved_nonattr
1205 { $$ = tree_cons (NULL_TREE, $2, $1);
1206 TREE_STATIC ($$) = 1; }
1207 | declspecs_sc_ts_sa_ea typespec_reserved_nonattr
1208 { $$ = tree_cons (NULL_TREE, $2, $1);
1209 TREE_STATIC ($$) = 1; }
1210 | declspecs_sc_nots_sa_noea typespec_nonattr
1211 { $$ = tree_cons (NULL_TREE, $2, $1);
1212 TREE_STATIC ($$) = 1; }
1213 | declspecs_sc_nots_sa_ea typespec_nonattr
1214 { $$ = tree_cons (NULL_TREE, $2, $1);
1215 TREE_STATIC ($$) = 1; }
1216 | declspecs_nosc_ts_sa_noea SCSPEC
1217 { if (extra_warnings && TREE_STATIC ($1))
1218 warning ("`%s' is not at beginning of declaration",
1219 IDENTIFIER_POINTER ($2));
1220 $$ = tree_cons (NULL_TREE, $2, $1);
1221 TREE_STATIC ($$) = TREE_STATIC ($1); }
1222 | declspecs_nosc_ts_sa_ea SCSPEC
1223 { if (extra_warnings && TREE_STATIC ($1))
1224 warning ("`%s' is not at beginning of declaration",
1225 IDENTIFIER_POINTER ($2));
1226 $$ = tree_cons (NULL_TREE, $2, $1);
1227 TREE_STATIC ($$) = TREE_STATIC ($1); }
1228 | declspecs_sc_ts_sa_noea SCSPEC
1229 { if (extra_warnings && TREE_STATIC ($1))
1230 warning ("`%s' is not at beginning of declaration",
1231 IDENTIFIER_POINTER ($2));
1232 $$ = tree_cons (NULL_TREE, $2, $1);
1233 TREE_STATIC ($$) = TREE_STATIC ($1); }
1234 | declspecs_sc_ts_sa_ea SCSPEC
1235 { if (extra_warnings && TREE_STATIC ($1))
1236 warning ("`%s' is not at beginning of declaration",
1237 IDENTIFIER_POINTER ($2));
1238 $$ = tree_cons (NULL_TREE, $2, $1);
1239 TREE_STATIC ($$) = TREE_STATIC ($1); }
1242 declspecs_sc_ts_sa_ea:
1243 declspecs_sc_ts_sa_noea attributes
1244 { $$ = tree_cons ($2, NULL_TREE, $1);
1245 TREE_STATIC ($$) = TREE_STATIC ($1); }
1246 | declspecs_sc_ts_sa_noea typespec_reserved_attr
1247 { $$ = tree_cons (NULL_TREE, $2, $1);
1248 TREE_STATIC ($$) = 1; }
1249 | declspecs_sc_ts_sa_ea typespec_reserved_attr
1250 { $$ = tree_cons (NULL_TREE, $2, $1);
1251 TREE_STATIC ($$) = 1; }
1252 | declspecs_sc_nots_sa_noea typespec_attr
1253 { $$ = tree_cons (NULL_TREE, $2, $1);
1254 TREE_STATIC ($$) = 1; }
1255 | declspecs_sc_nots_sa_ea typespec_attr
1256 { $$ = tree_cons (NULL_TREE, $2, $1);
1257 TREE_STATIC ($$) = 1; }
1260 /* Particular useful classes of declspecs. */
1262 declspecs_nosc_ts_nosa_noea
1263 | declspecs_nosc_ts_nosa_ea
1264 | declspecs_nosc_ts_sa_noea
1265 | declspecs_nosc_ts_sa_ea
1266 | declspecs_sc_ts_nosa_noea
1267 | declspecs_sc_ts_nosa_ea
1268 | declspecs_sc_ts_sa_noea
1269 | declspecs_sc_ts_sa_ea
1273 declspecs_nosc_nots_nosa_noea
1274 | declspecs_nosc_nots_nosa_ea
1275 | declspecs_nosc_nots_sa_noea
1276 | declspecs_nosc_nots_sa_ea
1277 | declspecs_sc_nots_nosa_noea
1278 | declspecs_sc_nots_nosa_ea
1279 | declspecs_sc_nots_sa_noea
1280 | declspecs_sc_nots_sa_ea
1284 declspecs_nosc_ts_nosa_noea
1285 | declspecs_nosc_ts_nosa_ea
1286 | declspecs_sc_ts_nosa_noea
1287 | declspecs_sc_ts_nosa_ea
1290 declspecs_nots_nosa:
1291 declspecs_nosc_nots_nosa_noea
1292 | declspecs_nosc_nots_nosa_ea
1293 | declspecs_sc_nots_nosa_noea
1294 | declspecs_sc_nots_nosa_ea
1298 declspecs_nosc_ts_nosa_noea
1299 | declspecs_nosc_ts_nosa_ea
1300 | declspecs_nosc_ts_sa_noea
1301 | declspecs_nosc_ts_sa_ea
1304 declspecs_nosc_nots:
1305 declspecs_nosc_nots_nosa_noea
1306 | declspecs_nosc_nots_nosa_ea
1307 | declspecs_nosc_nots_sa_noea
1308 | declspecs_nosc_nots_sa_ea
1312 declspecs_nosc_ts_nosa_noea
1313 | declspecs_nosc_ts_nosa_ea
1314 | declspecs_nosc_ts_sa_noea
1315 | declspecs_nosc_ts_sa_ea
1316 | declspecs_nosc_nots_nosa_noea
1317 | declspecs_nosc_nots_nosa_ea
1318 | declspecs_nosc_nots_sa_noea
1319 | declspecs_nosc_nots_sa_ea
1323 declspecs_nosc_nots_nosa_noea
1324 | declspecs_nosc_nots_nosa_ea
1325 | declspecs_nosc_nots_sa_noea
1326 | declspecs_nosc_nots_sa_ea
1327 | declspecs_nosc_ts_nosa_noea
1328 | declspecs_nosc_ts_nosa_ea
1329 | declspecs_nosc_ts_sa_noea
1330 | declspecs_nosc_ts_sa_ea
1331 | declspecs_sc_nots_nosa_noea
1332 | declspecs_sc_nots_nosa_ea
1333 | declspecs_sc_nots_sa_noea
1334 | declspecs_sc_nots_sa_ea
1335 | declspecs_sc_ts_nosa_noea
1336 | declspecs_sc_ts_nosa_ea
1337 | declspecs_sc_ts_sa_noea
1338 | declspecs_sc_ts_sa_ea
1341 /* A (possibly empty) sequence of type qualifiers and attributes, to be
1342 followed by the effect of setattrs if any attributes were present. */
1343 maybe_type_quals_setattrs:
1346 | declspecs_nosc_nots
1347 { tree specs, attrs;
1348 split_specs_attrs ($1, &specs, &attrs);
1349 /* ??? Yuck. See maybe_setattrs. */
1350 if (attrs != NULL_TREE)
1351 all_prefix_attributes = chainon (attrs, all_prefix_attributes);
1355 /* A type specifier (but not a type qualifier).
1356 Once we have seen one of these in a declaration,
1357 if a typedef name appears then it is being redeclared.
1359 The _reserved versions start with a reserved word and may appear anywhere
1360 in the declaration specifiers; the _nonreserved versions may only
1361 appear before any other type specifiers, and after that are (if names)
1364 FIXME: should the _nonreserved version be restricted to names being
1365 redeclared only? The other entries there relate only the GNU extensions
1366 and Objective C, and are historically parsed thus, and don't make sense
1367 after other type specifiers, but it might be cleaner to count them as
1370 _attr means: specifiers that either end with attributes,
1371 or are such that any following attributes would
1372 be parsed as part of the specifier.
1374 _nonattr: specifiers. */
1377 typespec_reserved_nonattr
1378 | typespec_nonreserved_nonattr
1382 typespec_reserved_attr
1385 typespec_reserved_nonattr:
1390 typespec_reserved_attr:
1394 typespec_nonreserved_nonattr:
1396 { /* For a typedef name, record the meaning, not the name.
1397 In case of `foo foo, bar;'. */
1398 $$ = lookup_name ($1); }
1400 | CLASSNAME protocolrefs
1401 { $$ = get_static_reference ($1, $2); }
1402 | OBJECTNAME protocolrefs
1403 { $$ = get_object_reference ($2); }
1405 /* Make "<SomeProtocol>" equivalent to "id <SomeProtocol>"
1406 - nisse@lysator.liu.se */
1407 | non_empty_protocolrefs
1408 { $$ = get_object_reference ($1); }
1410 | TYPEOF '(' expr ')'
1411 { $$ = TREE_TYPE ($3); }
1412 | TYPEOF '(' typename ')'
1413 { $$ = groktypename ($3); }
1416 /* typespec_nonreserved_attr does not exist. */
1420 | initdecls ',' maybe_resetattrs initdcl
1425 | notype_initdecls ',' maybe_resetattrs notype_initdcl
1431 | ASM_KEYWORD '(' string ')'
1432 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
1438 declarator maybeasm maybe_attribute '='
1439 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1440 chainon ($3, all_prefix_attributes));
1441 start_init ($<ttype>$, $2, global_bindings_p ()); }
1443 /* Note how the declaration of the variable is in effect while its init is parsed! */
1445 finish_decl ($<ttype>5, $6, $2); }
1446 | declarator maybeasm maybe_attribute
1447 { tree d = start_decl ($1, current_declspecs, 0,
1448 chainon ($3, all_prefix_attributes));
1449 finish_decl (d, NULL_TREE, $2);
1454 notype_declarator maybeasm maybe_attribute '='
1455 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1456 chainon ($3, all_prefix_attributes));
1457 start_init ($<ttype>$, $2, global_bindings_p ()); }
1459 /* Note how the declaration of the variable is in effect while its init is parsed! */
1461 finish_decl ($<ttype>5, $6, $2); }
1462 | notype_declarator maybeasm maybe_attribute
1463 { tree d = start_decl ($1, current_declspecs, 0,
1464 chainon ($3, all_prefix_attributes));
1465 finish_decl (d, NULL_TREE, $2); }
1467 /* the * rules are dummies to accept the Apollo extended syntax
1468 so that the header files compile. */
1479 | attributes attribute
1480 { $$ = chainon ($1, $2); }
1484 ATTRIBUTE '(' '(' attribute_list ')' ')'
1491 | attribute_list ',' attrib
1492 { $$ = chainon ($1, $3); }
1499 { $$ = build_tree_list ($1, NULL_TREE); }
1500 | any_word '(' IDENTIFIER ')'
1501 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1502 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1503 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1504 | any_word '(' exprlist ')'
1505 { $$ = build_tree_list ($1, $3); }
1508 /* This still leaves out most reserved keywords,
1509 shouldn't we include them? */
1518 /* Initializers. `init' is the entry point. */
1523 { really_start_incremental_init (NULL_TREE); }
1524 initlist_maybe_comma '}'
1525 { $$ = pop_init_level (0); }
1527 { $$ = error_mark_node; }
1530 /* `initlist_maybe_comma' is the guts of an initializer in braces. */
1531 initlist_maybe_comma:
1534 pedwarn ("ISO C forbids empty initializer braces"); }
1535 | initlist1 maybecomma
1540 | initlist1 ',' initelt
1543 /* `initelt' is a single element of an initializer.
1544 It may use braces. */
1546 designator_list '=' initval
1547 { if (pedantic && ! flag_isoc99)
1548 pedwarn ("ISO C89 forbids specifying subobject to initialize"); }
1549 | designator initval
1551 pedwarn ("obsolete use of designated initializer without `='"); }
1553 { set_init_label ($1);
1555 pedwarn ("obsolete use of designated initializer with `:'"); }
1562 { push_init_level (0); }
1563 initlist_maybe_comma '}'
1564 { process_init_element (pop_init_level (0)); }
1566 { process_init_element ($1); }
1572 | designator_list designator
1577 { set_init_label ($2); }
1578 /* These are for labeled elements. The syntax for an array element
1579 initializer conflicts with the syntax for an Objective-C message,
1580 so don't include these productions in the Objective-C grammar. */
1582 | '[' expr_no_commas ELLIPSIS expr_no_commas ']'
1583 { set_init_index ($2, $4);
1585 pedwarn ("ISO C forbids specifying range of elements to initialize"); }
1586 | '[' expr_no_commas ']'
1587 { set_init_index ($2, NULL_TREE); }
1594 pedwarn ("ISO C forbids nested functions");
1596 push_function_context ();
1597 if (! start_function (current_declspecs, $1,
1598 all_prefix_attributes))
1600 pop_function_context ();
1604 old_style_parm_decls
1605 { store_parm_decls (); }
1606 /* This used to use compstmt_or_error.
1607 That caused a bug with input `f(g) int g {}',
1608 where the use of YYERROR1 above caused an error
1609 which then was handled by compstmt_or_error.
1610 There followed a repeated execution of that same rule,
1611 which called YYERROR1 again, and so on. */
1612 save_filename save_lineno compstmt
1613 { tree decl = current_function_decl;
1614 DECL_SOURCE_FILE (decl) = $5;
1615 DECL_SOURCE_LINE (decl) = $6;
1616 finish_function (1);
1617 pop_function_context ();
1618 add_decl_stmt (decl); }
1621 notype_nested_function:
1624 pedwarn ("ISO C forbids nested functions");
1626 push_function_context ();
1627 if (! start_function (current_declspecs, $1,
1628 all_prefix_attributes))
1630 pop_function_context ();
1634 old_style_parm_decls
1635 { store_parm_decls (); }
1636 /* This used to use compstmt_or_error.
1637 That caused a bug with input `f(g) int g {}',
1638 where the use of YYERROR1 above caused an error
1639 which then was handled by compstmt_or_error.
1640 There followed a repeated execution of that same rule,
1641 which called YYERROR1 again, and so on. */
1642 save_filename save_lineno compstmt
1643 { tree decl = current_function_decl;
1644 DECL_SOURCE_FILE (decl) = $5;
1645 DECL_SOURCE_LINE (decl) = $6;
1646 finish_function (1);
1647 pop_function_context ();
1648 add_decl_stmt (decl); }
1651 /* Any kind of declarator (thus, all declarators allowed
1652 after an explicit typespec). */
1655 after_type_declarator
1659 /* A declarator that is allowed only after an explicit typespec. */
1661 after_type_declarator:
1662 '(' maybe_setattrs after_type_declarator ')'
1664 | after_type_declarator '(' parmlist_or_identifiers %prec '.'
1665 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1666 /* | after_type_declarator '(' error ')' %prec '.'
1667 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1668 poplevel (0, 0, 0); } */
1669 | after_type_declarator array_declarator %prec '.'
1670 { $$ = set_array_declarator_type ($2, $1, 0); }
1671 | '*' maybe_type_quals_setattrs after_type_declarator %prec UNARY
1672 { $$ = make_pointer_declarator ($2, $3); }
1679 /* Kinds of declarator that can appear in a parameter list
1680 in addition to notype_declarator. This is like after_type_declarator
1681 but does not allow a typedef name in parentheses as an identifier
1682 (because it would conflict with a function with that typedef as arg). */
1684 parm_declarator_starttypename
1685 | parm_declarator_nostarttypename
1688 parm_declarator_starttypename:
1689 parm_declarator_starttypename '(' parmlist_or_identifiers %prec '.'
1690 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1691 /* | parm_declarator_starttypename '(' error ')' %prec '.'
1692 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1693 poplevel (0, 0, 0); } */
1694 | parm_declarator_starttypename array_declarator %prec '.'
1695 { $$ = set_array_declarator_type ($2, $1, 0); }
1699 parm_declarator_nostarttypename:
1700 parm_declarator_nostarttypename '(' parmlist_or_identifiers %prec '.'
1701 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1702 /* | parm_declarator_nostarttypename '(' error ')' %prec '.'
1703 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1704 poplevel (0, 0, 0); } */
1705 | parm_declarator_nostarttypename array_declarator %prec '.'
1706 { $$ = set_array_declarator_type ($2, $1, 0); }
1707 | '*' maybe_type_quals_setattrs parm_declarator_starttypename %prec UNARY
1708 { $$ = make_pointer_declarator ($2, $3); }
1709 | '*' maybe_type_quals_setattrs parm_declarator_nostarttypename %prec UNARY
1710 { $$ = make_pointer_declarator ($2, $3); }
1711 | '(' maybe_setattrs parm_declarator_nostarttypename ')'
1715 /* A declarator allowed whether or not there has been
1716 an explicit typespec. These cannot redeclare a typedef-name. */
1719 notype_declarator '(' parmlist_or_identifiers %prec '.'
1720 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1721 /* | notype_declarator '(' error ')' %prec '.'
1722 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1723 poplevel (0, 0, 0); } */
1724 | '(' maybe_setattrs notype_declarator ')'
1726 | '*' maybe_type_quals_setattrs notype_declarator %prec UNARY
1727 { $$ = make_pointer_declarator ($2, $3); }
1728 | notype_declarator array_declarator %prec '.'
1729 { $$ = set_array_declarator_type ($2, $1, 0); }
1754 /* structsp_attr: struct/union/enum specifiers that either
1755 end with attributes, or are such that any following attributes would
1756 be parsed as part of the struct/union/enum specifier.
1758 structsp_nonattr: other struct/union/enum specifiers. */
1761 struct_head identifier '{'
1762 { $$ = start_struct (RECORD_TYPE, $2);
1763 /* Start scope of tag before parsing components. */
1765 component_decl_list '}' maybe_attribute
1766 { $$ = finish_struct ($<ttype>4, $5, chainon ($1, $7)); }
1767 | struct_head '{' component_decl_list '}' maybe_attribute
1768 { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
1769 $3, chainon ($1, $5));
1771 | union_head identifier '{'
1772 { $$ = start_struct (UNION_TYPE, $2); }
1773 component_decl_list '}' maybe_attribute
1774 { $$ = finish_struct ($<ttype>4, $5, chainon ($1, $7)); }
1775 | union_head '{' component_decl_list '}' maybe_attribute
1776 { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
1777 $3, chainon ($1, $5));
1779 | enum_head identifier '{'
1780 { $$ = start_enum ($2); }
1781 enumlist maybecomma_warn '}' maybe_attribute
1782 { $$ = finish_enum ($<ttype>4, nreverse ($5),
1783 chainon ($1, $8)); }
1785 { $$ = start_enum (NULL_TREE); }
1786 enumlist maybecomma_warn '}' maybe_attribute
1787 { $$ = finish_enum ($<ttype>3, nreverse ($4),
1788 chainon ($1, $7)); }
1792 struct_head identifier
1793 { $$ = xref_tag (RECORD_TYPE, $2); }
1794 | union_head identifier
1795 { $$ = xref_tag (UNION_TYPE, $2); }
1796 | enum_head identifier
1797 { $$ = xref_tag (ENUMERAL_TYPE, $2);
1798 /* In ISO C, enumerated types can be referred to
1799 only if already defined. */
1800 if (pedantic && !COMPLETE_TYPE_P ($$))
1801 pedwarn ("ISO C forbids forward references to `enum' types"); }
1812 { if (pedantic && ! flag_isoc99)
1813 pedwarn ("comma at end of enumerator list"); }
1816 component_decl_list:
1817 component_decl_list2
1819 | component_decl_list2 component_decl
1820 { $$ = chainon ($1, $2);
1821 pedwarn ("no semicolon at end of struct or union"); }
1824 component_decl_list2: /* empty */
1826 | component_decl_list2 component_decl ';'
1827 { $$ = chainon ($1, $2); }
1828 | component_decl_list2 ';'
1830 pedwarn ("extra semicolon in struct or union specified"); }
1832 /* foo(sizeof(struct{ @defs(ClassName)})); */
1833 | DEFS '(' CLASSNAME ')'
1835 tree interface = lookup_interface ($3);
1838 $$ = get_class_ivars (interface);
1841 error ("Cannot find interface declaration for `%s'",
1842 IDENTIFIER_POINTER ($3));
1850 declspecs_nosc_ts setspecs components
1852 POP_DECLSPEC_STACK; }
1853 | declspecs_nosc_ts setspecs save_filename save_lineno
1855 /* Support for unnamed structs or unions as members of
1856 structs or unions (which is [a] useful and [b] supports
1859 pedwarn ("ISO C doesn't support unnamed structs/unions");
1861 $$ = grokfield($3, $4, NULL, current_declspecs, NULL_TREE);
1862 POP_DECLSPEC_STACK; }
1863 | declspecs_nosc_nots setspecs components_notype
1865 POP_DECLSPEC_STACK; }
1866 | declspecs_nosc_nots
1868 pedwarn ("ISO C forbids member declarations with no members");
1873 | extension component_decl
1875 RESTORE_WARN_FLAGS ($1); }
1879 component_declarator
1880 | components ',' maybe_resetattrs component_declarator
1881 { $$ = chainon ($1, $4); }
1885 component_notype_declarator
1886 | components_notype ',' maybe_resetattrs component_notype_declarator
1887 { $$ = chainon ($1, $4); }
1890 component_declarator:
1891 save_filename save_lineno declarator maybe_attribute
1892 { $$ = grokfield ($1, $2, $3, current_declspecs, NULL_TREE);
1893 decl_attributes (&$$, chainon ($4, all_prefix_attributes), 0); }
1894 | save_filename save_lineno
1895 declarator ':' expr_no_commas maybe_attribute
1896 { $$ = grokfield ($1, $2, $3, current_declspecs, $5);
1897 decl_attributes (&$$, chainon ($6, all_prefix_attributes), 0); }
1898 | save_filename save_lineno ':' expr_no_commas maybe_attribute
1899 { $$ = grokfield ($1, $2, NULL_TREE, current_declspecs, $4);
1900 decl_attributes (&$$, chainon ($5, all_prefix_attributes), 0); }
1903 component_notype_declarator:
1904 save_filename save_lineno notype_declarator maybe_attribute
1905 { $$ = grokfield ($1, $2, $3, current_declspecs, NULL_TREE);
1906 decl_attributes (&$$, chainon ($4, all_prefix_attributes), 0); }
1907 | save_filename save_lineno
1908 notype_declarator ':' expr_no_commas maybe_attribute
1909 { $$ = grokfield ($1, $2, $3, current_declspecs, $5);
1910 decl_attributes (&$$, chainon ($6, all_prefix_attributes), 0); }
1911 | save_filename save_lineno ':' expr_no_commas maybe_attribute
1912 { $$ = grokfield ($1, $2, NULL_TREE, current_declspecs, $4);
1913 decl_attributes (&$$, chainon ($5, all_prefix_attributes), 0); }
1916 /* We chain the enumerators in reverse order.
1917 They are put in forward order where enumlist is used.
1918 (The order used to be significant, but no longer is so.
1919 However, we still maintain the order, just to be clean.) */
1923 | enumlist ',' enumerator
1924 { if ($1 == error_mark_node)
1927 $$ = chainon ($3, $1); }
1929 { $$ = error_mark_node; }
1935 { $$ = build_enumerator ($1, NULL_TREE); }
1936 | identifier '=' expr_no_commas
1937 { $$ = build_enumerator ($1, $3); }
1942 { tree specs, attrs;
1943 pending_xref_error ();
1944 split_specs_attrs ($1, &specs, &attrs);
1945 /* We don't yet support attributes here. */
1946 if (attrs != NULL_TREE)
1947 warning ("attributes on type name ignored");
1948 $<ttype>$ = specs; }
1950 { $$ = build_tree_list ($<ttype>2, $3); }
1953 absdcl: /* an absolute declarator */
1959 absdcl_maybe_attribute: /* absdcl maybe_attribute, but not just attributes */
1961 { $$ = build_tree_list (build_tree_list (current_declspecs,
1963 all_prefix_attributes); }
1965 { $$ = build_tree_list (build_tree_list (current_declspecs,
1967 all_prefix_attributes); }
1968 | absdcl1_noea attributes
1969 { $$ = build_tree_list (build_tree_list (current_declspecs,
1971 chainon ($2, all_prefix_attributes)); }
1974 absdcl1: /* a nonempty absolute declarator */
1981 | '*' maybe_type_quals_setattrs absdcl1_noea
1982 { $$ = make_pointer_declarator ($2, $3); }
1986 '*' maybe_type_quals_setattrs
1987 { $$ = make_pointer_declarator ($2, NULL_TREE); }
1988 | '*' maybe_type_quals_setattrs absdcl1_ea
1989 { $$ = make_pointer_declarator ($2, $3); }
1993 '(' maybe_setattrs absdcl1 ')'
1995 | direct_absdcl1 '(' parmlist
1996 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1997 | direct_absdcl1 array_declarator
1998 { $$ = set_array_declarator_type ($2, $1, 1); }
2000 { $$ = build_nt (CALL_EXPR, NULL_TREE, $2, NULL_TREE); }
2002 { $$ = set_array_declarator_type ($1, NULL_TREE, 1); }
2005 /* The [...] part of a declarator for an array type. */
2009 { $$ = build_array_declarator ($2, NULL_TREE, 0, 0); }
2010 | '[' declspecs_nosc expr ']'
2011 { $$ = build_array_declarator ($3, $2, 0, 0); }
2013 { $$ = build_array_declarator (NULL_TREE, NULL_TREE, 0, 0); }
2014 | '[' declspecs_nosc ']'
2015 { $$ = build_array_declarator (NULL_TREE, $2, 0, 0); }
2017 { $$ = build_array_declarator (NULL_TREE, NULL_TREE, 0, 1); }
2018 | '[' declspecs_nosc '*' ']'
2019 { $$ = build_array_declarator (NULL_TREE, $2, 0, 1); }
2020 | '[' SCSPEC expr ']'
2021 { if (C_RID_CODE ($2) != RID_STATIC)
2022 error ("storage class specifier in array declarator");
2023 $$ = build_array_declarator ($3, NULL_TREE, 1, 0); }
2024 | '[' SCSPEC declspecs_nosc expr ']'
2025 { if (C_RID_CODE ($2) != RID_STATIC)
2026 error ("storage class specifier in array declarator");
2027 $$ = build_array_declarator ($4, $3, 1, 0); }
2028 | '[' declspecs_nosc SCSPEC expr ']'
2029 { if (C_RID_CODE ($3) != RID_STATIC)
2030 error ("storage class specifier in array declarator");
2031 $$ = build_array_declarator ($4, $2, 1, 0); }
2034 /* A nonempty series of declarations and statements (possibly followed by
2035 some labels) that can form the body of a compound statement.
2036 NOTE: we don't allow labels on declarations; this might seem like a
2037 natural extension, but there would be a conflict between attributes
2038 on the label and prefix attributes on the declaration. */
2041 lineno_stmt_decl_or_labels_ending_stmt
2042 | lineno_stmt_decl_or_labels_ending_decl
2043 | lineno_stmt_decl_or_labels_ending_label
2045 pedwarn ("deprecated use of label at end of compound statement");
2047 | lineno_stmt_decl_or_labels_ending_error
2050 lineno_stmt_decl_or_labels_ending_stmt:
2052 | lineno_stmt_decl_or_labels_ending_stmt lineno_stmt
2053 | lineno_stmt_decl_or_labels_ending_decl lineno_stmt
2054 | lineno_stmt_decl_or_labels_ending_label lineno_stmt
2055 | lineno_stmt_decl_or_labels_ending_error lineno_stmt
2058 lineno_stmt_decl_or_labels_ending_decl:
2060 | lineno_stmt_decl_or_labels_ending_stmt lineno_decl
2061 { if (pedantic && !flag_isoc99)
2062 pedwarn ("ISO C89 forbids mixed declarations and code"); }
2063 | lineno_stmt_decl_or_labels_ending_decl lineno_decl
2064 | lineno_stmt_decl_or_labels_ending_error lineno_decl
2067 lineno_stmt_decl_or_labels_ending_label:
2069 | lineno_stmt_decl_or_labels_ending_stmt lineno_label
2070 | lineno_stmt_decl_or_labels_ending_decl lineno_label
2071 | lineno_stmt_decl_or_labels_ending_label lineno_label
2072 | lineno_stmt_decl_or_labels_ending_error lineno_label
2075 lineno_stmt_decl_or_labels_ending_error:
2077 | lineno_stmt_decl_or_labels errstmt
2080 lineno_stmt_decl_or_labels:
2081 lineno_stmt_decl_or_labels_ending_stmt
2082 | lineno_stmt_decl_or_labels_ending_decl
2083 | lineno_stmt_decl_or_labels_ending_label
2084 | lineno_stmt_decl_or_labels_ending_error
2090 pushlevel: /* empty */
2093 add_scope_stmt (/*begin_p=*/1, /*partial_p=*/0);
2095 if (objc_method_context)
2101 poplevel: /* empty */
2102 { $$ = add_scope_stmt (/*begin_p=*/0, /*partial_p=*/0); }
2104 /* Start and end blocks created for the new scopes of C99. */
2105 c99_block_start: /* empty */
2108 $$ = c_begin_compound_stmt ();
2111 add_scope_stmt (/*begin_p=*/1, /*partial_p=*/0);
2113 if (objc_method_context)
2122 /* Productions using c99_block_start and c99_block_end will need to do what's
2123 in compstmt: RECHAIN_STMTS ($1, COMPOUND_BODY ($1)); $$ = $2; where
2124 $1 is the value of c99_block_start and $2 of c99_block_end. */
2125 c99_block_end: /* empty */
2128 tree scope_stmt = add_scope_stmt (/*begin_p=*/0, /*partial_p=*/0);
2129 $$ = poplevel (kept_level_p (), 0, 0);
2130 SCOPE_STMT_BLOCK (TREE_PURPOSE (scope_stmt))
2131 = SCOPE_STMT_BLOCK (TREE_VALUE (scope_stmt))
2138 /* Read zero or more forward-declarations for labels
2139 that nested functions can jump to. */
2144 pedwarn ("ISO C forbids label declarations"); }
2149 | label_decls label_decl
2153 LABEL identifiers_or_typenames ';'
2155 for (link = $2; link; link = TREE_CHAIN (link))
2157 tree label = shadow_label (TREE_VALUE (link));
2158 C_DECLARED_LABEL_FLAG (label) = 1;
2159 add_decl_stmt (label);
2164 /* This is the body of a function definition.
2165 It causes syntax errors to ignore to the next openbrace. */
2172 compstmt_start: '{' { compstmt_count++;
2173 $$ = c_begin_compound_stmt (); }
2175 compstmt_nostart: '}'
2176 { $$ = convert (void_type_node, integer_zero_node); }
2177 | pushlevel maybe_label_decls compstmt_contents_nonempty '}' poplevel
2178 { $$ = poplevel (kept_level_p (), 1, 0);
2179 SCOPE_STMT_BLOCK (TREE_PURPOSE ($5))
2180 = SCOPE_STMT_BLOCK (TREE_VALUE ($5))
2184 compstmt_contents_nonempty:
2189 compstmt_primary_start:
2191 { if (current_function_decl == 0)
2193 error ("braced-group within expression allowed only inside a function");
2196 /* We must force a BLOCK for this level
2197 so that, if it is not expanded later,
2198 there is a way to turn off the entire subtree of blocks
2199 that are contained in it. */
2201 push_label_level ();
2203 $$ = add_stmt (build_stmt (COMPOUND_STMT, last_tree));
2206 compstmt: compstmt_start compstmt_nostart
2207 { RECHAIN_STMTS ($1, COMPOUND_BODY ($1));
2211 /* Value is number of statements counted as of the closeparen. */
2213 if_prefix c99_block_lineno_labeled_stmt
2214 { c_finish_then (); }
2215 /* Make sure c_expand_end_cond is run once
2216 for each call to c_expand_start_cond.
2217 Otherwise a crash is likely. */
2223 { c_expand_start_cond (truthvalue_conversion ($3),
2225 $<itype>$ = stmt_count;
2226 if_stmt_file = $<filename>-2;
2227 if_stmt_line = $<lineno>-1; }
2230 /* This is a subroutine of stmt.
2231 It is used twice, once for valid DO statements
2232 and once for catching errors in parsing the end test. */
2238 = add_stmt (build_stmt (DO_STMT, NULL_TREE,
2240 /* In the event that a parse error prevents
2241 parsing the complete do-statement, set the
2242 condition now. Otherwise, we can get crashes at
2243 RTL-generation time. */
2244 DO_COND ($<ttype>$) = error_mark_node; }
2245 c99_block_lineno_labeled_stmt WHILE
2247 RECHAIN_STMTS ($$, DO_BODY ($$)); }
2250 /* The forced readahead in here is because we might be at the end of a
2251 line, and the line and file won't be bumped until yylex absorbs the
2252 first token on the next line. */
2254 { if (yychar == YYEMPTY)
2256 $$ = input_filename; }
2260 { if (yychar == YYEMPTY)
2265 lineno_labeled_stmt:
2267 | lineno_label lineno_labeled_stmt
2270 /* Like lineno_labeled_stmt, but a block in C99. */
2271 c99_block_lineno_labeled_stmt:
2272 c99_block_start lineno_labeled_stmt c99_block_end
2274 RECHAIN_STMTS ($1, COMPOUND_BODY ($1)); }
2278 save_filename save_lineno stmt
2281 STMT_LINENO ($3) = $2;
2282 /* ??? We currently have no way of recording
2283 the filename for a statement. This probably
2284 matters little in practice at the moment,
2285 but I suspect that problems will ocurr when
2286 doing inlining at the tree level. */
2292 save_filename save_lineno label
2295 STMT_LINENO ($3) = $2;
2300 select_or_iter_stmt:
2302 { c_expand_start_else ();
2303 $<itype>1 = stmt_count; }
2304 c99_block_lineno_labeled_stmt
2306 c_expand_end_cond ();
2307 if (extra_warnings && stmt_count == $<itype>1)
2308 warning ("empty body in an else-statement"); }
2309 | simple_if %prec IF
2310 { c_expand_end_cond ();
2311 /* This warning is here instead of in simple_if, because we
2312 do not want a warning if an empty if is followed by an
2313 else statement. Increment stmt_count so we don't
2314 give a second error if this is a nested `if'. */
2315 if (extra_warnings && stmt_count++ == $<itype>1)
2316 warning_with_file_and_line (if_stmt_file, if_stmt_line,
2317 "empty body in an if-statement"); }
2318 /* Make sure c_expand_end_cond is run once
2319 for each call to c_expand_start_cond.
2320 Otherwise a crash is likely. */
2321 | simple_if ELSE error
2322 { c_expand_end_cond (); }
2326 { $4 = truthvalue_conversion ($4);
2328 = add_stmt (build_stmt (WHILE_STMT, $4, NULL_TREE)); }
2329 c99_block_lineno_labeled_stmt
2330 { RECHAIN_STMTS ($<ttype>6, WHILE_BODY ($<ttype>6)); }
2333 { DO_COND ($1) = truthvalue_conversion ($3); }
2334 | do_stmt_start error
2337 { $<ttype>$ = build_stmt (FOR_STMT, NULL_TREE, NULL_TREE,
2338 NULL_TREE, NULL_TREE);
2339 add_stmt ($<ttype>$); }
2342 RECHAIN_STMTS ($<ttype>2, FOR_INIT_STMT ($<ttype>2)); }
2345 FOR_COND ($<ttype>2) = truthvalue_conversion ($6); }
2347 { FOR_EXPR ($<ttype>2) = $9; }
2348 c99_block_lineno_labeled_stmt
2349 { RECHAIN_STMTS ($<ttype>2, FOR_BODY ($<ttype>2)); }
2350 | SWITCH '(' expr ')'
2352 $<ttype>$ = c_start_case ($3); }
2353 c99_block_lineno_labeled_stmt
2354 { c_finish_case (); }
2359 { add_stmt (build_stmt (EXPR_STMT, $1)); }
2361 { check_for_loop_decls (); }
2364 /* Parse a single real statement, not including any labels. */
2367 { stmt_count++; $$ = $1; }
2370 $$ = c_expand_expr_stmt ($1); }
2371 | c99_block_start select_or_iter_stmt c99_block_end
2373 RECHAIN_STMTS ($1, COMPOUND_BODY ($1));
2377 $$ = add_stmt (build_break_stmt ()); }
2380 $$ = add_stmt (build_continue_stmt ()); }
2383 $$ = c_expand_return (NULL_TREE); }
2386 $$ = c_expand_return ($2); }
2387 | ASM_KEYWORD maybe_type_qual '(' expr ')' ';'
2389 $$ = simple_asm_stmt ($4); }
2390 /* This is the case with just output operands. */
2391 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ')' ';'
2393 $$ = build_asm_stmt ($2, $4, $6, NULL_TREE, NULL_TREE); }
2394 /* This is the case with input operands as well. */
2395 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':'
2396 asm_operands ')' ';'
2398 $$ = build_asm_stmt ($2, $4, $6, $8, NULL_TREE); }
2399 /* This is the case with clobbered registers as well. */
2400 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':'
2401 asm_operands ':' asm_clobbers ')' ';'
2403 $$ = build_asm_stmt ($2, $4, $6, $8, $10); }
2404 | GOTO identifier ';'
2407 decl = lookup_label ($2);
2410 TREE_USED (decl) = 1;
2411 $$ = add_stmt (build_stmt (GOTO_STMT, decl));
2418 pedwarn ("ISO C forbids `goto *expr;'");
2420 $3 = convert (ptr_type_node, $3);
2421 $$ = add_stmt (build_stmt (GOTO_STMT, $3)); }
2426 /* Any kind of label, including jump labels and case labels.
2427 ANSI C accepts labels only before statements, but we allow them
2428 also at the end of a compound statement. */
2430 label: CASE expr_no_commas ':'
2432 $$ = do_case ($2, NULL_TREE); }
2433 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
2435 $$ = do_case ($2, $4); }
2438 $$ = do_case (NULL_TREE, NULL_TREE); }
2439 | identifier save_filename save_lineno ':' maybe_attribute
2440 { tree label = define_label ($2, $3, $1);
2444 decl_attributes (&label, $5, 0);
2445 $$ = add_stmt (build_stmt (LABEL_STMT, label));
2452 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
2456 { emit_line_note (input_filename, lineno);
2459 { emit_line_note (input_filename, lineno); }
2468 /* These are the operands other than the first string and colon
2469 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
2470 asm_operands: /* empty */
2472 | nonnull_asm_operands
2475 nonnull_asm_operands:
2477 | nonnull_asm_operands ',' asm_operand
2478 { $$ = chainon ($1, $3); }
2483 { $$ = build_tree_list ($1, $3); }
2488 { $$ = tree_cons (NULL_TREE, combine_strings ($1), NULL_TREE); }
2489 | asm_clobbers ',' string
2490 { $$ = tree_cons (NULL_TREE, combine_strings ($3), $1); }
2493 /* This is what appears inside the parens in a function declarator.
2494 Its value is a list of ..._TYPE nodes. Attributes must appear here
2495 to avoid a conflict with their appearance after an open parenthesis
2496 in an abstract declarator, as in
2497 "void bar (int (__attribute__((__mode__(SI))) int foo));". */
2501 clear_parm_order ();
2502 declare_parm_level (0); }
2505 parmlist_tags_warning ();
2506 poplevel (0, 0, 0); }
2514 pedwarn ("ISO C forbids forward parameter declarations");
2515 /* Mark the forward decls as such. */
2516 for (parm = getdecls (); parm; parm = TREE_CHAIN (parm))
2517 TREE_ASM_WRITTEN (parm) = 1;
2518 clear_parm_order (); }
2520 { /* Dummy action so attributes are in known place
2521 on parser stack. */ }
2525 { $$ = tree_cons (NULL_TREE, NULL_TREE, NULL_TREE); }
2528 /* This is what appears inside the parens in a function declarator.
2529 Is value is represented in the format that grokdeclarator expects. */
2530 parmlist_2: /* empty */
2531 { $$ = get_parm_info (0); }
2533 { $$ = get_parm_info (0);
2534 /* Gcc used to allow this as an extension. However, it does
2535 not work for all targets, and thus has been disabled.
2536 Also, since func (...) and func () are indistinguishable,
2537 it caused problems with the code in expand_builtin which
2538 tries to verify that BUILT_IN_NEXT_ARG is being used
2540 error ("ISO C requires a named argument before `...'");
2543 { $$ = get_parm_info (1); }
2544 | parms ',' ELLIPSIS
2545 { $$ = get_parm_info (0); }
2550 { push_parm_decl ($1); }
2552 { push_parm_decl ($3); }
2555 /* A single parameter declaration or parameter type name,
2556 as found in a parmlist. */
2558 declspecs_ts setspecs parm_declarator maybe_attribute
2559 { $$ = build_tree_list (build_tree_list (current_declspecs,
2561 chainon ($4, all_prefix_attributes));
2562 POP_DECLSPEC_STACK; }
2563 | declspecs_ts setspecs notype_declarator maybe_attribute
2564 { $$ = build_tree_list (build_tree_list (current_declspecs,
2566 chainon ($4, all_prefix_attributes));
2567 POP_DECLSPEC_STACK; }
2568 | declspecs_ts setspecs absdcl_maybe_attribute
2570 POP_DECLSPEC_STACK; }
2571 | declspecs_nots setspecs notype_declarator maybe_attribute
2572 { $$ = build_tree_list (build_tree_list (current_declspecs,
2574 chainon ($4, all_prefix_attributes));
2575 POP_DECLSPEC_STACK; }
2577 | declspecs_nots setspecs absdcl_maybe_attribute
2579 POP_DECLSPEC_STACK; }
2582 /* The first parm, which must suck attributes from off the top of the parser
2585 declspecs_ts_nosa setspecs_fp parm_declarator maybe_attribute
2586 { $$ = build_tree_list (build_tree_list (current_declspecs,
2588 chainon ($4, all_prefix_attributes));
2589 POP_DECLSPEC_STACK; }
2590 | declspecs_ts_nosa setspecs_fp notype_declarator maybe_attribute
2591 { $$ = build_tree_list (build_tree_list (current_declspecs,
2593 chainon ($4, all_prefix_attributes));
2594 POP_DECLSPEC_STACK; }
2595 | declspecs_ts_nosa setspecs_fp absdcl_maybe_attribute
2597 POP_DECLSPEC_STACK; }
2598 | declspecs_nots_nosa setspecs_fp notype_declarator maybe_attribute
2599 { $$ = build_tree_list (build_tree_list (current_declspecs,
2601 chainon ($4, all_prefix_attributes));
2602 POP_DECLSPEC_STACK; }
2604 | declspecs_nots_nosa setspecs_fp absdcl_maybe_attribute
2606 POP_DECLSPEC_STACK; }
2611 { prefix_attributes = chainon (prefix_attributes, $<ttype>-2);
2612 all_prefix_attributes = prefix_attributes; }
2615 /* This is used in a function definition
2616 where either a parmlist or an identifier list is ok.
2617 Its value is a list of ..._TYPE nodes or a list of identifiers. */
2618 parmlist_or_identifiers:
2620 clear_parm_order ();
2621 declare_parm_level (1); }
2622 parmlist_or_identifiers_1
2624 parmlist_tags_warning ();
2625 poplevel (0, 0, 0); }
2628 parmlist_or_identifiers_1:
2632 for (t = $1; t; t = TREE_CHAIN (t))
2633 if (TREE_VALUE (t) == NULL_TREE)
2634 error ("`...' in old-style identifier list");
2635 $$ = tree_cons (NULL_TREE, NULL_TREE, $1); }
2638 /* A nonempty list of identifiers. */
2641 { $$ = build_tree_list (NULL_TREE, $1); }
2642 | identifiers ',' IDENTIFIER
2643 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2646 /* A nonempty list of identifiers, including typenames. */
2647 identifiers_or_typenames:
2649 { $$ = build_tree_list (NULL_TREE, $1); }
2650 | identifiers_or_typenames ',' identifier
2651 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2656 { $$ = SAVE_WARN_FLAGS();
2658 warn_pointer_arith = 0; }
2662 /* Objective-C productions. */
2672 if (objc_implementation_context)
2674 finish_class (objc_implementation_context);
2675 objc_ivar_chain = NULL_TREE;
2676 objc_implementation_context = NULL_TREE;
2679 warning ("`@end' must appear in an implementation context");
2683 /* A nonempty list of identifiers. */
2686 { $$ = build_tree_list (NULL_TREE, $1); }
2687 | identifier_list ',' identifier
2688 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2692 CLASS identifier_list ';'
2694 objc_declare_class ($2);
2698 ALIAS identifier identifier ';'
2700 objc_declare_alias ($2, $3);
2704 INTERFACE identifier protocolrefs '{'
2706 objc_interface_context = objc_ivar_context
2707 = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, $3);
2708 objc_public_flag = 0;
2712 continue_class (objc_interface_context);
2717 finish_class (objc_interface_context);
2718 objc_interface_context = NULL_TREE;
2721 | INTERFACE identifier protocolrefs
2723 objc_interface_context
2724 = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, $3);
2725 continue_class (objc_interface_context);
2730 finish_class (objc_interface_context);
2731 objc_interface_context = NULL_TREE;
2734 | INTERFACE identifier ':' identifier protocolrefs '{'
2736 objc_interface_context = objc_ivar_context
2737 = start_class (CLASS_INTERFACE_TYPE, $2, $4, $5);
2738 objc_public_flag = 0;
2742 continue_class (objc_interface_context);
2747 finish_class (objc_interface_context);
2748 objc_interface_context = NULL_TREE;
2751 | INTERFACE identifier ':' identifier protocolrefs
2753 objc_interface_context
2754 = start_class (CLASS_INTERFACE_TYPE, $2, $4, $5);
2755 continue_class (objc_interface_context);
2760 finish_class (objc_interface_context);
2761 objc_interface_context = NULL_TREE;
2764 | IMPLEMENTATION identifier '{'
2766 objc_implementation_context = objc_ivar_context
2767 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, NULL_TREE, NULL_TREE);
2768 objc_public_flag = 0;
2773 = continue_class (objc_implementation_context);
2776 | IMPLEMENTATION identifier
2778 objc_implementation_context
2779 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, NULL_TREE, NULL_TREE);
2781 = continue_class (objc_implementation_context);
2784 | IMPLEMENTATION identifier ':' identifier '{'
2786 objc_implementation_context = objc_ivar_context
2787 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2788 objc_public_flag = 0;
2793 = continue_class (objc_implementation_context);
2796 | IMPLEMENTATION identifier ':' identifier
2798 objc_implementation_context
2799 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2801 = continue_class (objc_implementation_context);
2804 | INTERFACE identifier '(' identifier ')' protocolrefs
2806 objc_interface_context
2807 = start_class (CATEGORY_INTERFACE_TYPE, $2, $4, $6);
2808 continue_class (objc_interface_context);
2813 finish_class (objc_interface_context);
2814 objc_interface_context = NULL_TREE;
2817 | IMPLEMENTATION identifier '(' identifier ')'
2819 objc_implementation_context
2820 = start_class (CATEGORY_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2822 = continue_class (objc_implementation_context);
2827 PROTOCOL identifier protocolrefs
2829 objc_pq_context = 1;
2830 objc_interface_context
2831 = start_protocol(PROTOCOL_INTERFACE_TYPE, $2, $3);
2835 objc_pq_context = 0;
2836 finish_protocol(objc_interface_context);
2837 objc_interface_context = NULL_TREE;
2846 | non_empty_protocolrefs
2849 non_empty_protocolrefs:
2850 ARITHCOMPARE identifier_list ARITHCOMPARE
2852 if ($1 == LT_EXPR && $3 == GT_EXPR)
2860 ivar_decl_list visibility_spec ivar_decls
2865 PRIVATE { objc_public_flag = 2; }
2866 | PROTECTED { objc_public_flag = 0; }
2867 | PUBLIC { objc_public_flag = 1; }
2875 | ivar_decls ivar_decl ';'
2879 pedwarn ("extra semicolon in struct or union specified");
2884 /* There is a shift-reduce conflict here, because `components' may
2885 start with a `typename'. It happens that shifting (the default resolution)
2886 does the right thing, because it treats the `typename' as part of
2887 a `typed_typespecs'.
2889 It is possible that this same technique would allow the distinction
2890 between `notype_initdecls' and `initdecls' to be eliminated.
2891 But I am being cautious and not trying it. */
2894 declspecs_nosc_ts setspecs ivars
2896 POP_DECLSPEC_STACK; }
2897 | declspecs_nosc_nots setspecs ivars
2899 POP_DECLSPEC_STACK; }
2908 | ivars ',' maybe_resetattrs ivar_declarator
2914 $$ = add_instance_variable (objc_ivar_context,
2916 $1, current_declspecs,
2919 | declarator ':' expr_no_commas
2921 $$ = add_instance_variable (objc_ivar_context,
2923 $1, current_declspecs, $3);
2925 | ':' expr_no_commas
2927 $$ = add_instance_variable (objc_ivar_context,
2930 current_declspecs, $2);
2936 { objc_inherit_code = CLASS_METHOD_DECL; }
2938 { objc_inherit_code = INSTANCE_METHOD_DECL; }
2944 objc_pq_context = 1;
2945 if (!objc_implementation_context)
2946 fatal_error ("method definition not in class context");
2950 objc_pq_context = 0;
2951 if (objc_inherit_code == CLASS_METHOD_DECL)
2952 add_class_method (objc_implementation_context, $3);
2954 add_instance_method (objc_implementation_context, $3);
2955 start_method_def ($3);
2956 objc_method_context = $3;
2960 continue_method_def ();
2964 finish_method_def ();
2965 objc_method_context = NULL_TREE;
2969 /* the reason for the strange actions in this rule
2970 is so that notype_initdecls when reached via datadef
2971 can find a valid list of type and sc specs in $0. */
2975 | {$<ttype>$ = NULL_TREE; } methodprotolist2
2978 methodprotolist2: /* eliminates a shift/reduce conflict */
2981 | methodprotolist2 methodproto
2982 | methodprotolist2 {$<ttype>$ = NULL_TREE; } datadef
2993 /* Remember protocol qualifiers in prototypes. */
2994 objc_pq_context = 1;
2998 /* Forget protocol qualifiers here. */
2999 objc_pq_context = 0;
3000 if (objc_inherit_code == CLASS_METHOD_DECL)
3001 add_class_method (objc_interface_context, $3);
3003 add_instance_method (objc_interface_context, $3);
3009 '(' typename ')' unaryselector
3011 $$ = build_method_decl (objc_inherit_code, $2, $4, NULL_TREE);
3016 $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, NULL_TREE);
3019 | '(' typename ')' keywordselector optparmlist
3021 $$ = build_method_decl (objc_inherit_code, $2, $4, $5);
3024 | keywordselector optparmlist
3026 $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, $2);
3030 /* "optarglist" assumes that start_method_def has already been called...
3031 if it is not, the "xdecls" will not be placed in the proper scope */
3038 /* to get around the following situation: "int foo (int a) int b; {}" that
3039 is synthesized when parsing "- a:a b:b; id c; id d; { ... }" */
3054 declspecs_ts setspecs myparms ';'
3055 { POP_DECLSPEC_STACK; }
3057 { shadow_tag ($1); }
3058 | declspecs_nots ';'
3059 { pedwarn ("empty declaration"); }
3064 { push_parm_decl ($1); }
3065 | myparms ',' myparm
3066 { push_parm_decl ($3); }
3069 /* A single parameter declaration or parameter type name,
3070 as found in a parmlist. DOES NOT ALLOW AN INITIALIZER OR ASMSPEC */
3073 parm_declarator maybe_attribute
3074 { $$ = build_tree_list (build_tree_list (current_declspecs,
3076 chainon ($2, all_prefix_attributes)); }
3077 | notype_declarator maybe_attribute
3078 { $$ = build_tree_list (build_tree_list (current_declspecs,
3080 chainon ($2, all_prefix_attributes)); }
3081 | absdcl_maybe_attribute
3092 /* oh what a kludge! */
3093 $$ = objc_ellipsis_node;
3101 /* returns a tree list node generated by get_parm_info */
3114 | keywordselector keyworddecl
3116 $$ = chainon ($1, $2);
3128 ENUM | STRUCT | UNION | IF | ELSE | WHILE | DO | FOR
3129 | SWITCH | CASE | DEFAULT | BREAK | CONTINUE | RETURN
3130 | GOTO | ASM_KEYWORD | SIZEOF | TYPEOF | ALIGNOF
3131 | TYPESPEC | TYPE_QUAL
3135 selector ':' '(' typename ')' identifier
3137 $$ = build_keyword_decl ($1, $4, $6);
3140 | selector ':' identifier
3142 $$ = build_keyword_decl ($1, NULL_TREE, $3);
3145 | ':' '(' typename ')' identifier
3147 $$ = build_keyword_decl (NULL_TREE, $3, $5);
3152 $$ = build_keyword_decl (NULL_TREE, NULL_TREE, $2);
3163 | keywordarglist keywordarg
3165 $$ = chainon ($1, $2);
3173 if (TREE_CHAIN ($1) == NULL_TREE)
3174 /* just return the expr., remove a level of indirection */
3175 $$ = TREE_VALUE ($1);
3177 /* we have a comma expr., we will collapse later */
3183 selector ':' keywordexpr
3185 $$ = build_tree_list ($1, $3);
3189 $$ = build_tree_list (NULL_TREE, $2);
3197 $$ = get_class_reference ($1);
3203 { objc_receiver_context = 1; }
3205 { objc_receiver_context = 0; }
3208 $$ = build_tree_list ($3, $5);
3219 | keywordnamelist keywordname
3221 $$ = chainon ($1, $2);
3228 $$ = build_tree_list ($1, NULL_TREE);
3232 $$ = build_tree_list (NULL_TREE, NULL_TREE);
3237 SELECTOR '(' selectorarg ')'
3244 PROTOCOL '(' identifier ')'
3250 /* extension to support C-structures in the archiver */
3253 ENCODE '(' typename ')'
3255 $$ = groktypename ($3);
3262 /* yylex() is a thin wrapper around c_lex(), all it does is translate
3263 cpplib.h's token codes into yacc's token codes. */
3265 static enum cpp_ttype last_token;
3267 /* The reserved keyword table. */
3271 ENUM_BITFIELD(rid) rid : 16;
3272 unsigned int disable : 16;
3275 /* Disable mask. Keywords are disabled if (reswords[i].disable & mask) is
3277 #define D_TRAD 0x01 /* not in traditional C */
3278 #define D_C89 0x02 /* not in C89 */
3279 #define D_EXT 0x04 /* GCC extension */
3280 #define D_EXT89 0x08 /* GCC extension incorporated in C99 */
3281 #define D_OBJC 0x10 /* Objective C only */
3283 static const struct resword reswords[] =
3285 { "_Bool", RID_BOOL, 0 },
3286 { "_Complex", RID_COMPLEX, 0 },
3287 { "__FUNCTION__", RID_FUNCTION_NAME, 0 },
3288 { "__PRETTY_FUNCTION__", RID_PRETTY_FUNCTION_NAME, 0 },
3289 { "__alignof", RID_ALIGNOF, 0 },
3290 { "__alignof__", RID_ALIGNOF, 0 },
3291 { "__asm", RID_ASM, 0 },
3292 { "__asm__", RID_ASM, 0 },
3293 { "__attribute", RID_ATTRIBUTE, 0 },
3294 { "__attribute__", RID_ATTRIBUTE, 0 },
3295 { "__bounded", RID_BOUNDED, 0 },
3296 { "__bounded__", RID_BOUNDED, 0 },
3297 { "__builtin_va_arg", RID_VA_ARG, 0 },
3298 { "__complex", RID_COMPLEX, 0 },
3299 { "__complex__", RID_COMPLEX, 0 },
3300 { "__const", RID_CONST, 0 },
3301 { "__const__", RID_CONST, 0 },
3302 { "__extension__", RID_EXTENSION, 0 },
3303 { "__func__", RID_C99_FUNCTION_NAME, 0 },
3304 { "__imag", RID_IMAGPART, 0 },
3305 { "__imag__", RID_IMAGPART, 0 },
3306 { "__inline", RID_INLINE, 0 },
3307 { "__inline__", RID_INLINE, 0 },
3308 { "__label__", RID_LABEL, 0 },
3309 { "__ptrbase", RID_PTRBASE, 0 },
3310 { "__ptrbase__", RID_PTRBASE, 0 },
3311 { "__ptrextent", RID_PTREXTENT, 0 },
3312 { "__ptrextent__", RID_PTREXTENT, 0 },
3313 { "__ptrvalue", RID_PTRVALUE, 0 },
3314 { "__ptrvalue__", RID_PTRVALUE, 0 },
3315 { "__real", RID_REALPART, 0 },
3316 { "__real__", RID_REALPART, 0 },
3317 { "__restrict", RID_RESTRICT, 0 },
3318 { "__restrict__", RID_RESTRICT, 0 },
3319 { "__signed", RID_SIGNED, 0 },
3320 { "__signed__", RID_SIGNED, 0 },
3321 { "__typeof", RID_TYPEOF, 0 },
3322 { "__typeof__", RID_TYPEOF, 0 },
3323 { "__unbounded", RID_UNBOUNDED, 0 },
3324 { "__unbounded__", RID_UNBOUNDED, 0 },
3325 { "__volatile", RID_VOLATILE, 0 },
3326 { "__volatile__", RID_VOLATILE, 0 },
3327 { "asm", RID_ASM, D_EXT },
3328 { "auto", RID_AUTO, 0 },
3329 { "break", RID_BREAK, 0 },
3330 { "case", RID_CASE, 0 },
3331 { "char", RID_CHAR, 0 },
3332 { "const", RID_CONST, D_TRAD },
3333 { "continue", RID_CONTINUE, 0 },
3334 { "default", RID_DEFAULT, 0 },
3335 { "do", RID_DO, 0 },
3336 { "double", RID_DOUBLE, 0 },
3337 { "else", RID_ELSE, 0 },
3338 { "enum", RID_ENUM, 0 },
3339 { "extern", RID_EXTERN, 0 },
3340 { "float", RID_FLOAT, 0 },
3341 { "for", RID_FOR, 0 },
3342 { "goto", RID_GOTO, 0 },
3343 { "if", RID_IF, 0 },
3344 { "inline", RID_INLINE, D_TRAD|D_EXT89 },
3345 { "int", RID_INT, 0 },
3346 { "long", RID_LONG, 0 },
3347 { "register", RID_REGISTER, 0 },
3348 { "restrict", RID_RESTRICT, D_TRAD|D_C89 },
3349 { "return", RID_RETURN, 0 },
3350 { "short", RID_SHORT, 0 },
3351 { "signed", RID_SIGNED, D_TRAD },
3352 { "sizeof", RID_SIZEOF, 0 },
3353 { "static", RID_STATIC, 0 },
3354 { "struct", RID_STRUCT, 0 },
3355 { "switch", RID_SWITCH, 0 },
3356 { "typedef", RID_TYPEDEF, 0 },
3357 { "typeof", RID_TYPEOF, D_TRAD|D_EXT },
3358 { "union", RID_UNION, 0 },
3359 { "unsigned", RID_UNSIGNED, 0 },
3360 { "void", RID_VOID, 0 },
3361 { "volatile", RID_VOLATILE, D_TRAD },
3362 { "while", RID_WHILE, 0 },
3364 { "id", RID_ID, D_OBJC },
3366 /* These objc keywords are recognized only immediately after
3368 { "class", RID_AT_CLASS, D_OBJC },
3369 { "compatibility_alias", RID_AT_ALIAS, D_OBJC },
3370 { "defs", RID_AT_DEFS, D_OBJC },
3371 { "encode", RID_AT_ENCODE, D_OBJC },
3372 { "end", RID_AT_END, D_OBJC },
3373 { "implementation", RID_AT_IMPLEMENTATION, D_OBJC },
3374 { "interface", RID_AT_INTERFACE, D_OBJC },
3375 { "private", RID_AT_PRIVATE, D_OBJC },
3376 { "protected", RID_AT_PROTECTED, D_OBJC },
3377 { "protocol", RID_AT_PROTOCOL, D_OBJC },
3378 { "public", RID_AT_PUBLIC, D_OBJC },
3379 { "selector", RID_AT_SELECTOR, D_OBJC },
3381 /* These are recognized only in protocol-qualifier context
3383 { "bycopy", RID_BYCOPY, D_OBJC },
3384 { "byref", RID_BYREF, D_OBJC },
3385 { "in", RID_IN, D_OBJC },
3386 { "inout", RID_INOUT, D_OBJC },
3387 { "oneway", RID_ONEWAY, D_OBJC },
3388 { "out", RID_OUT, D_OBJC },
3391 #define N_reswords (sizeof reswords / sizeof (struct resword))
3393 /* Table mapping from RID_* constants to yacc token numbers.
3394 Unfortunately we have to have entries for all the keywords in all
3396 static const short rid_to_yy[RID_MAX] =
3398 /* RID_STATIC */ SCSPEC,
3399 /* RID_UNSIGNED */ TYPESPEC,
3400 /* RID_LONG */ TYPESPEC,
3401 /* RID_CONST */ TYPE_QUAL,
3402 /* RID_EXTERN */ SCSPEC,
3403 /* RID_REGISTER */ SCSPEC,
3404 /* RID_TYPEDEF */ SCSPEC,
3405 /* RID_SHORT */ TYPESPEC,
3406 /* RID_INLINE */ SCSPEC,
3407 /* RID_VOLATILE */ TYPE_QUAL,
3408 /* RID_SIGNED */ TYPESPEC,
3409 /* RID_AUTO */ SCSPEC,
3410 /* RID_RESTRICT */ TYPE_QUAL,
3413 /* RID_BOUNDED */ TYPE_QUAL,
3414 /* RID_UNBOUNDED */ TYPE_QUAL,
3415 /* RID_COMPLEX */ TYPESPEC,
3419 /* RID_VIRTUAL */ 0,
3420 /* RID_EXPLICIT */ 0,
3422 /* RID_MUTABLE */ 0,
3425 /* RID_IN */ TYPE_QUAL,
3426 /* RID_OUT */ TYPE_QUAL,
3427 /* RID_INOUT */ TYPE_QUAL,
3428 /* RID_BYCOPY */ TYPE_QUAL,
3429 /* RID_BYREF */ TYPE_QUAL,
3430 /* RID_ONEWAY */ TYPE_QUAL,
3433 /* RID_INT */ TYPESPEC,
3434 /* RID_CHAR */ TYPESPEC,
3435 /* RID_FLOAT */ TYPESPEC,
3436 /* RID_DOUBLE */ TYPESPEC,
3437 /* RID_VOID */ TYPESPEC,
3438 /* RID_ENUM */ ENUM,
3439 /* RID_STRUCT */ STRUCT,
3440 /* RID_UNION */ UNION,
3442 /* RID_ELSE */ ELSE,
3443 /* RID_WHILE */ WHILE,
3446 /* RID_SWITCH */ SWITCH,
3447 /* RID_CASE */ CASE,
3448 /* RID_DEFAULT */ DEFAULT,
3449 /* RID_BREAK */ BREAK,
3450 /* RID_CONTINUE */ CONTINUE,
3451 /* RID_RETURN */ RETURN,
3452 /* RID_GOTO */ GOTO,
3453 /* RID_SIZEOF */ SIZEOF,
3456 /* RID_ASM */ ASM_KEYWORD,
3457 /* RID_TYPEOF */ TYPEOF,
3458 /* RID_ALIGNOF */ ALIGNOF,
3459 /* RID_ATTRIBUTE */ ATTRIBUTE,
3460 /* RID_VA_ARG */ VA_ARG,
3461 /* RID_EXTENSION */ EXTENSION,
3462 /* RID_IMAGPART */ IMAGPART,
3463 /* RID_REALPART */ REALPART,
3464 /* RID_LABEL */ LABEL,
3465 /* RID_PTRBASE */ PTR_BASE,
3466 /* RID_PTREXTENT */ PTR_EXTENT,
3467 /* RID_PTRVALUE */ PTR_VALUE,
3469 /* RID_FUNCTION_NAME */ STRING_FUNC_NAME,
3470 /* RID_PRETTY_FUNCTION_NAME */ STRING_FUNC_NAME,
3471 /* RID_C99_FUNCTION_NAME */ VAR_FUNC_NAME,
3474 /* RID_BOOL */ TYPESPEC,
3478 /* RID_PRIVATE */ 0,
3479 /* RID_PROTECTED */ 0,
3480 /* RID_TEMPLATE */ 0,
3485 /* RID_NAMESPACE */ 0,
3487 /* RID_OPERATOR */ 0,
3492 /* RID_TYPENAME */ 0,
3497 /* RID_CONSTCAST */ 0,
3498 /* RID_DYNCAST */ 0,
3499 /* RID_REINTCAST */ 0,
3500 /* RID_STATCAST */ 0,
3502 /* alternate spellings */
3516 /* RID_ID */ OBJECTNAME,
3517 /* RID_AT_ENCODE */ ENCODE,
3518 /* RID_AT_END */ END,
3519 /* RID_AT_CLASS */ CLASS,
3520 /* RID_AT_ALIAS */ ALIAS,
3521 /* RID_AT_DEFS */ DEFS,
3522 /* RID_AT_PRIVATE */ PRIVATE,
3523 /* RID_AT_PROTECTED */ PROTECTED,
3524 /* RID_AT_PUBLIC */ PUBLIC,
3525 /* RID_AT_PROTOCOL */ PROTOCOL,
3526 /* RID_AT_SELECTOR */ SELECTOR,
3527 /* RID_AT_INTERFACE */ INTERFACE,
3528 /* RID_AT_IMPLEMENTATION */ IMPLEMENTATION
3536 int mask = (flag_isoc99 ? 0 : D_C89)
3537 | (flag_traditional ? D_TRAD : 0)
3538 | (flag_no_asm ? (flag_isoc99 ? D_EXT : D_EXT|D_EXT89) : 0);
3540 if (c_language != clk_objective_c)
3543 /* It is not necessary to register ridpointers as a GC root, because
3544 all the trees it points to are permanently interned in the
3545 get_identifier hash anyway. */
3546 ridpointers = (tree *) xcalloc ((int) RID_MAX, sizeof (tree));
3547 for (i = 0; i < N_reswords; i++)
3549 /* If a keyword is disabled, do not enter it into the table
3550 and so create a canonical spelling that isn't a keyword. */
3551 if (reswords[i].disable & mask)
3554 id = get_identifier (reswords[i].word);
3555 C_RID_CODE (id) = reswords[i].rid;
3556 C_IS_RESERVED_WORD (id) = 1;
3557 ridpointers [(int) reswords[i].rid] = id;
3562 init_parse (filename)
3563 const char *filename;
3565 add_c_tree_codes ();
3567 /* Make identifier nodes long enough for the language-specific slots. */
3568 set_identifier_size (sizeof (struct lang_identifier));
3573 return init_c_lex (filename);
3579 cpp_finish (parse_in);
3580 /* Call to cpp_destroy () omitted for performance reasons. */
3581 errorcount += cpp_errors (parse_in);
3584 #define NAME(type) cpp_type2name (type)
3590 const char *string = _(msgid);
3592 if (last_token == CPP_EOF)
3593 error ("%s at end of input", string);
3594 else if (last_token == CPP_CHAR || last_token == CPP_WCHAR)
3596 unsigned int val = TREE_INT_CST_LOW (yylval.ttype);
3597 const char *ell = (last_token == CPP_CHAR) ? "" : "L";
3598 if (val <= UCHAR_MAX && ISGRAPH (val))
3599 error ("%s before %s'%c'", string, ell, val);
3601 error ("%s before %s'\\x%x'", string, ell, val);
3603 else if (last_token == CPP_STRING
3604 || last_token == CPP_WSTRING)
3605 error ("%s before string constant", string);
3606 else if (last_token == CPP_NUMBER
3607 || last_token == CPP_INT
3608 || last_token == CPP_FLOAT)
3609 error ("%s before numeric constant", string);
3610 else if (last_token == CPP_NAME)
3611 error ("%s before \"%s\"", string, IDENTIFIER_POINTER (yylval.ttype));
3613 error ("%s before '%s' token", string, NAME(last_token));
3621 if (C_IS_RESERVED_WORD (yylval.ttype))
3623 enum rid rid_code = C_RID_CODE (yylval.ttype);
3626 if (!OBJC_IS_AT_KEYWORD (rid_code)
3627 && (!OBJC_IS_PQ_KEYWORD (rid_code) || objc_pq_context))
3630 int yycode = rid_to_yy[(int) rid_code];
3631 if (yycode == STRING_FUNC_NAME)
3633 /* __FUNCTION__ and __PRETTY_FUNCTION__ get converted
3634 to string constants. */
3635 const char *name = fname_string (rid_code);
3637 yylval.ttype = build_string (strlen (name) + 1, name);
3638 last_token = CPP_STRING; /* so yyerror won't choke */
3642 /* Return the canonical spelling for this keyword. */
3643 yylval.ttype = ridpointers[(int) rid_code];
3648 decl = lookup_name (yylval.ttype);
3651 if (TREE_CODE (decl) == TYPE_DECL)
3657 tree objc_interface_decl = is_class_name (yylval.ttype);
3659 if (objc_interface_decl)
3661 yylval.ttype = objc_interface_decl;
3675 last_token = c_lex (&yylval.ttype);
3678 case CPP_EQ: return '=';
3679 case CPP_NOT: return '!';
3680 case CPP_GREATER: yylval.code = GT_EXPR; return ARITHCOMPARE;
3681 case CPP_LESS: yylval.code = LT_EXPR; return ARITHCOMPARE;
3682 case CPP_PLUS: yylval.code = PLUS_EXPR; return '+';
3683 case CPP_MINUS: yylval.code = MINUS_EXPR; return '-';
3684 case CPP_MULT: yylval.code = MULT_EXPR; return '*';
3685 case CPP_DIV: yylval.code = TRUNC_DIV_EXPR; return '/';
3686 case CPP_MOD: yylval.code = TRUNC_MOD_EXPR; return '%';
3687 case CPP_AND: yylval.code = BIT_AND_EXPR; return '&';
3688 case CPP_OR: yylval.code = BIT_IOR_EXPR; return '|';
3689 case CPP_XOR: yylval.code = BIT_XOR_EXPR; return '^';
3690 case CPP_RSHIFT: yylval.code = RSHIFT_EXPR; return RSHIFT;
3691 case CPP_LSHIFT: yylval.code = LSHIFT_EXPR; return LSHIFT;
3693 case CPP_COMPL: return '~';
3694 case CPP_AND_AND: return ANDAND;
3695 case CPP_OR_OR: return OROR;
3696 case CPP_QUERY: return '?';
3697 case CPP_COLON: return ':';
3698 case CPP_COMMA: return ',';
3699 case CPP_OPEN_PAREN: return '(';
3700 case CPP_CLOSE_PAREN: return ')';
3701 case CPP_EQ_EQ: yylval.code = EQ_EXPR; return EQCOMPARE;
3702 case CPP_NOT_EQ: yylval.code = NE_EXPR; return EQCOMPARE;
3703 case CPP_GREATER_EQ:yylval.code = GE_EXPR; return ARITHCOMPARE;
3704 case CPP_LESS_EQ: yylval.code = LE_EXPR; return ARITHCOMPARE;
3706 case CPP_PLUS_EQ: yylval.code = PLUS_EXPR; return ASSIGN;
3707 case CPP_MINUS_EQ: yylval.code = MINUS_EXPR; return ASSIGN;
3708 case CPP_MULT_EQ: yylval.code = MULT_EXPR; return ASSIGN;
3709 case CPP_DIV_EQ: yylval.code = TRUNC_DIV_EXPR; return ASSIGN;
3710 case CPP_MOD_EQ: yylval.code = TRUNC_MOD_EXPR; return ASSIGN;
3711 case CPP_AND_EQ: yylval.code = BIT_AND_EXPR; return ASSIGN;
3712 case CPP_OR_EQ: yylval.code = BIT_IOR_EXPR; return ASSIGN;
3713 case CPP_XOR_EQ: yylval.code = BIT_XOR_EXPR; return ASSIGN;
3714 case CPP_RSHIFT_EQ: yylval.code = RSHIFT_EXPR; return ASSIGN;
3715 case CPP_LSHIFT_EQ: yylval.code = LSHIFT_EXPR; return ASSIGN;
3717 case CPP_OPEN_SQUARE: return '[';
3718 case CPP_CLOSE_SQUARE: return ']';
3719 case CPP_OPEN_BRACE: return '{';
3720 case CPP_CLOSE_BRACE: return '}';
3721 case CPP_SEMICOLON: return ';';
3722 case CPP_ELLIPSIS: return ELLIPSIS;
3724 case CPP_PLUS_PLUS: return PLUSPLUS;
3725 case CPP_MINUS_MINUS: return MINUSMINUS;
3726 case CPP_DEREF: return POINTSAT;
3727 case CPP_DOT: return '.';
3730 if (cpp_pop_buffer (parse_in) == 0)
3735 return yylexname ();
3748 /* This token is Objective-C specific. It gives the next
3749 token special significance. */
3754 enum cpp_ttype after_at_type;
3756 cpp_start_lookahead (parse_in);
3757 after_at_type = c_lex (&after_at);
3759 if (after_at_type == CPP_NAME
3760 && C_IS_RESERVED_WORD (after_at)
3761 && OBJC_IS_AT_KEYWORD (C_RID_CODE (after_at)))
3763 cpp_stop_lookahead (parse_in, 1); /* accept this token */
3764 yylval.ttype = after_at;
3765 last_token = after_at_type;
3766 return rid_to_yy [(int) C_RID_CODE (after_at)];
3768 cpp_stop_lookahead (parse_in, 0); /* put back this token */
3773 /* These tokens are C++ specific (and will not be generated
3774 in C mode, but let's be cautious). */
3776 case CPP_DEREF_STAR:
3782 /* These tokens should not survive translation phase 4. */
3785 error ("syntax error at '%s' token", NAME(last_token));
3798 timevar_push (TV_LEX);
3800 timevar_pop (TV_LEX);
3804 /* Sets the value of the 'yydebug' variable to VALUE.
3805 This is a function so we don't have to have YYDEBUG defined
3806 in order to build the compiler. */
3815 warning ("YYDEBUG not defined.");
3819 /* Function used when yydebug is set, to print a token in more detail. */
3822 yyprint (file, yychar, yyl)
3829 fprintf (file, " [%s]", NAME(last_token));
3839 if (IDENTIFIER_POINTER (t))
3840 fprintf (file, " `%s'", IDENTIFIER_POINTER (t));
3844 fprintf (file, " %s", GET_MODE_NAME (TYPE_MODE (TREE_TYPE (t))));
3845 if (TREE_CODE (t) == INTEGER_CST)
3847 #if HOST_BITS_PER_WIDE_INT == 64
3848 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
3851 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
3858 #if HOST_BITS_PER_WIDE_INT != HOST_BITS_PER_INT
3864 TREE_INT_CST_HIGH (t), TREE_INT_CST_LOW (t));
3869 /* This is not the ideal place to put these, but we have to get them out
3870 of c-lex.c because cp/lex.c has its own versions. */
3872 /* Return something to represent absolute declarators containing a *.
3873 TARGET is the absolute declarator that the * contains.
3874 TYPE_QUALS is a list of modifiers such as const or volatile
3875 to apply to the pointer type, represented as identifiers.
3877 We return an INDIRECT_REF whose "contents" are TARGET
3878 and whose type is the modifier list. */
3881 make_pointer_declarator (type_quals, target)
3882 tree type_quals, target;
3884 return build1 (INDIRECT_REF, type_quals, target);