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
160 /* Objective-C string constants in raw form.
161 yylval is an STRING_CST node. */
166 %type <ttype> ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
167 %type <ttype> BREAK CONTINUE RETURN GOTO ASM_KEYWORD SIZEOF TYPEOF ALIGNOF
169 %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist exprlist
170 %type <ttype> expr_no_commas cast_expr unary_expr primary string STRING
171 %type <ttype> declspecs_nosc_nots_nosa_noea declspecs_nosc_nots_nosa_ea
172 %type <ttype> declspecs_nosc_nots_sa_noea declspecs_nosc_nots_sa_ea
173 %type <ttype> declspecs_nosc_ts_nosa_noea declspecs_nosc_ts_nosa_ea
174 %type <ttype> declspecs_nosc_ts_sa_noea declspecs_nosc_ts_sa_ea
175 %type <ttype> declspecs_sc_nots_nosa_noea declspecs_sc_nots_nosa_ea
176 %type <ttype> declspecs_sc_nots_sa_noea declspecs_sc_nots_sa_ea
177 %type <ttype> declspecs_sc_ts_nosa_noea declspecs_sc_ts_nosa_ea
178 %type <ttype> declspecs_sc_ts_sa_noea declspecs_sc_ts_sa_ea
179 %type <ttype> declspecs_ts declspecs_nots
180 %type <ttype> declspecs_ts_nosa declspecs_nots_nosa
181 %type <ttype> declspecs_nosc_ts declspecs_nosc_nots declspecs_nosc declspecs
182 %type <ttype> maybe_type_quals_setattrs typespec_nonattr typespec_attr
183 %type <ttype> typespec_reserved_nonattr typespec_reserved_attr
184 %type <ttype> typespec_nonreserved_nonattr
186 %type <ttype> SCSPEC TYPESPEC TYPE_QUAL maybe_type_qual
187 %type <ttype> initdecls notype_initdecls initdcl notype_initdcl
188 %type <ttype> init maybeasm
189 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
190 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
191 %type <ttype> maybe_setattrs
192 %type <ttype> any_word extension
194 %type <ttype> compstmt compstmt_start compstmt_nostart compstmt_primary_start
195 %type <ttype> do_stmt_start poplevel stmt label
197 %type <ttype> c99_block_start c99_block_end
198 %type <ttype> declarator
199 %type <ttype> notype_declarator after_type_declarator
200 %type <ttype> parm_declarator
201 %type <ttype> parm_declarator_starttypename parm_declarator_nostarttypename
202 %type <ttype> array_declarator
204 %type <ttype> structsp_attr structsp_nonattr
205 %type <ttype> component_decl_list component_decl_list2
206 %type <ttype> component_decl components components_notype component_declarator
207 %type <ttype> component_notype_declarator
208 %type <ttype> enumlist enumerator
209 %type <ttype> struct_head union_head enum_head
210 %type <ttype> typename absdcl absdcl1 absdcl1_ea absdcl1_noea
211 %type <ttype> direct_absdcl1 absdcl_maybe_attribute
212 %type <ttype> xexpr parms parm firstparm identifiers
214 %type <ttype> parmlist parmlist_1 parmlist_2
215 %type <ttype> parmlist_or_identifiers parmlist_or_identifiers_1
216 %type <ttype> identifiers_or_typenames
218 %type <itype> setspecs setspecs_fp
220 %type <filename> save_filename
221 %type <lineno> save_lineno
224 /* the Objective-C nonterminals */
226 %type <ttype> ivar_decl_list ivar_decls ivar_decl ivars ivar_declarator
227 %type <ttype> methoddecl unaryselector keywordselector selector
228 %type <ttype> keyworddecl receiver objcmessageexpr messageargs
229 %type <ttype> keywordexpr keywordarglist keywordarg
230 %type <ttype> myparms myparm optparmlist reservedwords objcselectorexpr
231 %type <ttype> selectorarg keywordnamelist keywordname objcencodeexpr
232 %type <ttype> objc_string non_empty_protocolrefs protocolrefs identifier_list objcprotocolexpr
234 %type <ttype> CLASSNAME OBJC_STRING OBJECTNAME
238 /* Number of statements (loosely speaking) and compound statements
240 static int stmt_count;
241 static int compstmt_count;
243 /* Input file and line number of the end of the body of last simple_if;
244 used by the stmt-rule immediately after simple_if returns. */
245 static const char *if_stmt_file;
246 static int if_stmt_line;
248 /* List of types and structure classes of the current declaration. */
249 static tree current_declspecs = NULL_TREE;
250 static tree prefix_attributes = NULL_TREE;
252 /* Stack of saved values of current_declspecs and prefix_attributes. */
253 static tree declspec_stack;
255 /* For __extension__, save/restore the warning flags which are
256 controlled by __extension__. */
257 #define SAVE_WARN_FLAGS() \
258 size_int (pedantic | (warn_pointer_arith << 1))
259 #define RESTORE_WARN_FLAGS(tval) \
261 int val = tree_low_cst (tval, 0); \
262 pedantic = val & 1; \
263 warn_pointer_arith = (val >> 1) & 1; \
267 /* Objective-C specific information */
269 tree objc_interface_context;
270 tree objc_implementation_context;
271 tree objc_method_context;
272 tree objc_ivar_chain;
273 tree objc_ivar_context;
274 enum tree_code objc_inherit_code;
275 int objc_receiver_context;
276 int objc_public_flag;
281 /* Tell yyparse how to print a token's value, if yydebug is set. */
283 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
285 static void yyprint PARAMS ((FILE *, int, YYSTYPE));
286 static void yyerror PARAMS ((const char *));
287 static int yylexname PARAMS ((void));
288 static inline int _yylex PARAMS ((void));
289 static int yylex PARAMS ((void));
290 static void init_reswords PARAMS ((void));
292 /* Add GC roots for variables local to this file. */
296 ggc_add_tree_root (&declspec_stack, 1);
297 ggc_add_tree_root (¤t_declspecs, 1);
298 ggc_add_tree_root (&prefix_attributes, 1);
300 ggc_add_tree_root (&objc_interface_context, 1);
301 ggc_add_tree_root (&objc_implementation_context, 1);
302 ggc_add_tree_root (&objc_method_context, 1);
303 ggc_add_tree_root (&objc_ivar_chain, 1);
304 ggc_add_tree_root (&objc_ivar_context, 1);
313 pedwarn ("ISO C forbids an empty source file");
318 /* In case there were missing closebraces,
319 get us back to the global binding level. */
320 while (! global_bindings_p ())
323 finish_fname_decls ();
329 /* the reason for the strange actions in this rule
330 is so that notype_initdecls when reached via datadef
331 can find a valid list of type and sc specs in $0. */
334 {$<ttype>$ = NULL_TREE; } extdef
335 | extdefs {$<ttype>$ = NULL_TREE; ggc_collect(); } extdef
344 | ASM_KEYWORD '(' expr ')' ';'
346 if ((TREE_CODE ($3) == ADDR_EXPR
347 && TREE_CODE (TREE_OPERAND ($3, 0)) == STRING_CST)
348 || TREE_CODE ($3) == STRING_CST)
351 error ("argument of `asm' is not a constant string"); }
353 { RESTORE_WARN_FLAGS ($1); }
357 setspecs notype_initdecls ';'
359 error ("ISO C forbids data definition with no type or storage class");
360 else if (!flag_traditional)
361 warning ("data definition has no type or storage class");
363 current_declspecs = TREE_VALUE (declspec_stack);
364 prefix_attributes = TREE_PURPOSE (declspec_stack);
365 declspec_stack = TREE_CHAIN (declspec_stack); }
366 | declspecs_nots setspecs notype_initdecls ';'
367 { current_declspecs = TREE_VALUE (declspec_stack);
368 prefix_attributes = TREE_PURPOSE (declspec_stack);
369 declspec_stack = TREE_CHAIN (declspec_stack); }
370 | declspecs_ts setspecs initdecls ';'
371 { current_declspecs = TREE_VALUE (declspec_stack);
372 prefix_attributes = TREE_PURPOSE (declspec_stack);
373 declspec_stack = TREE_CHAIN (declspec_stack); }
380 pedwarn ("ISO C does not allow extra `;' outside of a function"); }
384 declspecs_ts setspecs declarator
385 { if (! start_function (current_declspecs, $3,
386 prefix_attributes, NULL_TREE))
390 { store_parm_decls (); }
391 save_filename save_lineno compstmt_or_error
392 { DECL_SOURCE_FILE (current_function_decl) = $7;
393 DECL_SOURCE_LINE (current_function_decl) = $8;
395 current_declspecs = TREE_VALUE (declspec_stack);
396 prefix_attributes = TREE_PURPOSE (declspec_stack);
397 declspec_stack = TREE_CHAIN (declspec_stack); }
398 | declspecs_ts setspecs declarator error
399 { current_declspecs = TREE_VALUE (declspec_stack);
400 prefix_attributes = TREE_PURPOSE (declspec_stack);
401 declspec_stack = TREE_CHAIN (declspec_stack); }
402 | declspecs_nots setspecs notype_declarator
403 { if (! start_function (current_declspecs, $3,
404 prefix_attributes, NULL_TREE))
408 { store_parm_decls (); }
409 save_filename save_lineno compstmt_or_error
410 { DECL_SOURCE_FILE (current_function_decl) = $7;
411 DECL_SOURCE_LINE (current_function_decl) = $8;
413 current_declspecs = TREE_VALUE (declspec_stack);
414 prefix_attributes = TREE_PURPOSE (declspec_stack);
415 declspec_stack = TREE_CHAIN (declspec_stack); }
416 | declspecs_nots setspecs notype_declarator error
417 { current_declspecs = TREE_VALUE (declspec_stack);
418 prefix_attributes = TREE_PURPOSE (declspec_stack);
419 declspec_stack = TREE_CHAIN (declspec_stack); }
420 | setspecs notype_declarator
421 { if (! start_function (NULL_TREE, $2,
422 prefix_attributes, NULL_TREE))
426 { store_parm_decls (); }
427 save_filename save_lineno compstmt_or_error
428 { DECL_SOURCE_FILE (current_function_decl) = $6;
429 DECL_SOURCE_LINE (current_function_decl) = $7;
431 current_declspecs = TREE_VALUE (declspec_stack);
432 prefix_attributes = TREE_PURPOSE (declspec_stack);
433 declspec_stack = TREE_CHAIN (declspec_stack); }
434 | setspecs notype_declarator error
435 { current_declspecs = TREE_VALUE (declspec_stack);
436 prefix_attributes = TREE_PURPOSE (declspec_stack);
437 declspec_stack = TREE_CHAIN (declspec_stack); }
452 { $$ = NEGATE_EXPR; }
456 if (warn_traditional && !in_system_header)
457 warning ("traditional C rejects the unary plus operator");
461 { $$ = PREINCREMENT_EXPR; }
463 { $$ = PREDECREMENT_EXPR; }
465 { $$ = BIT_NOT_EXPR; }
467 { $$ = TRUTH_NOT_EXPR; }
470 expr: nonnull_exprlist
471 { $$ = build_compound_expr ($1); }
482 { $$ = build_tree_list (NULL_TREE, $1); }
483 | nonnull_exprlist ',' expr_no_commas
484 { chainon ($1, build_tree_list (NULL_TREE, $3)); }
489 | '*' cast_expr %prec UNARY
490 { $$ = build_indirect_ref ($2, "unary *"); }
491 /* __extension__ turns off -pedantic for following primary. */
492 | extension cast_expr %prec UNARY
494 RESTORE_WARN_FLAGS ($1); }
495 | unop cast_expr %prec UNARY
496 { $$ = build_unary_op ($1, $2, 0);
497 overflow_warning ($$); }
498 /* Refer to the address of a label as a pointer. */
500 { $$ = finish_label_address_expr ($2); }
501 /* This seems to be impossible on some machines, so let's turn it off.
502 You can use __builtin_next_arg to find the anonymous stack args.
504 { tree types = TYPE_ARG_TYPES (TREE_TYPE (current_function_decl));
505 $$ = error_mark_node;
506 if (TREE_VALUE (tree_last (types)) == void_type_node)
507 error ("`&...' used in function with fixed number of arguments");
511 pedwarn ("ISO C forbids `&...'");
512 $$ = tree_last (DECL_ARGUMENTS (current_function_decl));
513 $$ = build_unary_op (ADDR_EXPR, $$, 0);
516 | sizeof unary_expr %prec UNARY
518 if (TREE_CODE ($2) == COMPONENT_REF
519 && DECL_C_BIT_FIELD (TREE_OPERAND ($2, 1)))
520 error ("`sizeof' applied to a bit-field");
521 $$ = c_sizeof (TREE_TYPE ($2)); }
522 | sizeof '(' typename ')' %prec HYPERUNARY
524 $$ = c_sizeof (groktypename ($3)); }
525 | alignof unary_expr %prec UNARY
527 $$ = c_alignof_expr ($2); }
528 | alignof '(' typename ')' %prec HYPERUNARY
530 $$ = c_alignof (groktypename ($3)); }
531 | REALPART cast_expr %prec UNARY
532 { $$ = build_unary_op (REALPART_EXPR, $2, 0); }
533 | IMAGPART cast_expr %prec UNARY
534 { $$ = build_unary_op (IMAGPART_EXPR, $2, 0); }
538 SIZEOF { skip_evaluation++; }
542 ALIGNOF { skip_evaluation++; }
547 | '(' typename ')' cast_expr %prec UNARY
548 { $$ = c_cast_expr ($2, $4); }
553 | expr_no_commas '+' expr_no_commas
554 { $$ = parser_build_binary_op ($2, $1, $3); }
555 | expr_no_commas '-' expr_no_commas
556 { $$ = parser_build_binary_op ($2, $1, $3); }
557 | expr_no_commas '*' expr_no_commas
558 { $$ = parser_build_binary_op ($2, $1, $3); }
559 | expr_no_commas '/' expr_no_commas
560 { $$ = parser_build_binary_op ($2, $1, $3); }
561 | expr_no_commas '%' expr_no_commas
562 { $$ = parser_build_binary_op ($2, $1, $3); }
563 | expr_no_commas LSHIFT expr_no_commas
564 { $$ = parser_build_binary_op ($2, $1, $3); }
565 | expr_no_commas RSHIFT expr_no_commas
566 { $$ = parser_build_binary_op ($2, $1, $3); }
567 | expr_no_commas ARITHCOMPARE expr_no_commas
568 { $$ = parser_build_binary_op ($2, $1, $3); }
569 | expr_no_commas EQCOMPARE expr_no_commas
570 { $$ = parser_build_binary_op ($2, $1, $3); }
571 | expr_no_commas '&' expr_no_commas
572 { $$ = parser_build_binary_op ($2, $1, $3); }
573 | expr_no_commas '|' expr_no_commas
574 { $$ = parser_build_binary_op ($2, $1, $3); }
575 | expr_no_commas '^' expr_no_commas
576 { $$ = parser_build_binary_op ($2, $1, $3); }
577 | expr_no_commas ANDAND
578 { $1 = truthvalue_conversion (default_conversion ($1));
579 skip_evaluation += $1 == boolean_false_node; }
581 { skip_evaluation -= $1 == boolean_false_node;
582 $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $4); }
583 | expr_no_commas OROR
584 { $1 = truthvalue_conversion (default_conversion ($1));
585 skip_evaluation += $1 == boolean_true_node; }
587 { skip_evaluation -= $1 == boolean_true_node;
588 $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $4); }
590 { $1 = truthvalue_conversion (default_conversion ($1));
591 skip_evaluation += $1 == boolean_false_node; }
593 { skip_evaluation += (($1 == boolean_true_node)
594 - ($1 == boolean_false_node)); }
596 { skip_evaluation -= $1 == boolean_true_node;
597 $$ = build_conditional_expr ($1, $4, $7); }
600 pedwarn ("ISO C forbids omitting the middle term of a ?: expression");
601 /* Make sure first operand is calculated only once. */
602 $<ttype>2 = save_expr ($1);
603 $1 = truthvalue_conversion (default_conversion ($<ttype>2));
604 skip_evaluation += $1 == boolean_true_node; }
606 { skip_evaluation -= $1 == boolean_true_node;
607 $$ = build_conditional_expr ($1, $<ttype>2, $5); }
608 | expr_no_commas '=' expr_no_commas
610 $$ = build_modify_expr ($1, NOP_EXPR, $3);
611 class = TREE_CODE_CLASS (TREE_CODE ($$));
612 if (class == 'e' || class == '1'
613 || class == '2' || class == '<')
614 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR);
616 | expr_no_commas ASSIGN expr_no_commas
618 $$ = build_modify_expr ($1, $2, $3);
619 /* This inhibits warnings in truthvalue_conversion. */
620 class = TREE_CODE_CLASS (TREE_CODE ($$));
621 if (class == 'e' || class == '1'
622 || class == '2' || class == '<')
623 C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK);
630 if (yychar == YYEMPTY)
632 $$ = build_external_ref ($1, yychar == '(');
636 { $$ = combine_strings ($1); }
638 { $$ = fname_decl (C_RID_CODE ($$), $$); }
639 | '(' typename ')' '{'
640 { start_init (NULL_TREE, NULL, 0);
641 $2 = groktypename ($2);
642 really_start_incremental_init ($2); }
643 initlist_maybe_comma '}' %prec UNARY
645 tree result = pop_init_level (0);
649 if (pedantic && ! flag_isoc99)
650 pedwarn ("ISO C89 forbids compound literals");
651 if (TYPE_NAME (type) != 0)
653 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
654 name = IDENTIFIER_POINTER (TYPE_NAME (type));
656 name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
661 if (TREE_CODE (type) == ARRAY_TYPE && !COMPLETE_TYPE_P (type))
663 int failure = complete_array_type (type, $$, 1);
669 { char class = TREE_CODE_CLASS (TREE_CODE ($2));
670 if (class == 'e' || class == '1'
671 || class == '2' || class == '<')
672 C_SET_EXP_ORIGINAL_CODE ($2, ERROR_MARK);
675 { $$ = error_mark_node; }
676 | compstmt_primary_start compstmt_nostart ')'
677 { tree saved_last_tree;
680 pedwarn ("ISO C forbids braced-groups within expressions");
683 saved_last_tree = COMPOUND_BODY ($1);
684 RECHAIN_STMTS ($1, COMPOUND_BODY ($1));
685 last_tree = saved_last_tree;
686 TREE_CHAIN (last_tree) = NULL_TREE;
688 last_expr_type = void_type_node;
689 $$ = build1 (STMT_EXPR, last_expr_type, $1);
690 TREE_SIDE_EFFECTS ($$) = 1;
692 | compstmt_primary_start error ')'
695 last_tree = COMPOUND_BODY ($1);
696 TREE_CHAIN (last_tree) = NULL_TREE;
697 $$ = error_mark_node;
699 | primary '(' exprlist ')' %prec '.'
700 { $$ = build_function_call ($1, $3); }
701 | VA_ARG '(' expr_no_commas ',' typename ')'
702 { $$ = build_va_arg ($3, groktypename ($5)); }
703 | primary '[' expr ']' %prec '.'
704 { $$ = build_array_ref ($1, $3); }
705 | primary '.' identifier
708 if (!is_public ($1, $3))
709 $$ = error_mark_node;
712 $$ = build_component_ref ($1, $3);
714 | primary POINTSAT identifier
716 tree expr = build_indirect_ref ($1, "->");
719 if (!is_public (expr, $3))
720 $$ = error_mark_node;
723 $$ = build_component_ref (expr, $3);
726 { $$ = build_unary_op (POSTINCREMENT_EXPR, $1, 0); }
728 { $$ = build_unary_op (POSTDECREMENT_EXPR, $1, 0); }
731 { $$ = build_message_expr ($1); }
733 { $$ = build_selector_expr ($1); }
735 { $$ = build_protocol_expr ($1); }
737 { $$ = build_encode_expr ($1); }
739 { $$ = build_objc_string_object ($1); }
743 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
749 static int last_lineno = 0;
750 static const char *last_input_filename = 0;
752 $$ = chainon ($1, $2);
754 if (warn_traditional && !in_system_header
755 && (lineno != last_lineno || !last_input_filename ||
756 strcmp (last_input_filename, input_filename)))
758 warning ("traditional C rejects string concatenation");
759 last_lineno = lineno;
760 last_input_filename = input_filename;
767 /* Produces an STRING_CST with perhaps more STRING_CSTs chained
768 onto it, which is to be read as an ObjC string object. */
771 | objc_string OBJC_STRING
772 { $$ = chainon ($1, $2); }
776 old_style_parm_decls:
780 /* ... is used here to indicate a varargs function. */
783 pedwarn ("ISO C does not permit use of `varargs.h'"); }
786 /* The following are analogous to lineno_decl, decls and decl
787 except that they do not allow nested functions.
788 They are used for old-style parm decls. */
790 save_filename save_lineno datadecl
797 | datadecls lineno_datadecl
798 | lineno_datadecl errstmt
801 /* We don't allow prefix attributes here because they cause reduce/reduce
802 conflicts: we can't know whether we're parsing a function decl with
803 attribute suffix, or function defn with attribute prefix on first old
806 declspecs_ts_nosa setspecs initdecls ';'
807 { current_declspecs = TREE_VALUE (declspec_stack);
808 prefix_attributes = TREE_PURPOSE (declspec_stack);
809 declspec_stack = TREE_CHAIN (declspec_stack); }
810 | declspecs_nots_nosa setspecs notype_initdecls ';'
811 { current_declspecs = TREE_VALUE (declspec_stack);
812 prefix_attributes = TREE_PURPOSE (declspec_stack);
813 declspec_stack = TREE_CHAIN (declspec_stack); }
814 | declspecs_ts_nosa ';'
815 { shadow_tag_warned ($1, 1);
816 pedwarn ("empty declaration"); }
817 | declspecs_nots_nosa ';'
818 { pedwarn ("empty declaration"); }
821 /* This combination which saves a lineno before a decl
822 is the normal thing to use, rather than decl itself.
823 This is to avoid shift/reduce conflicts in contexts
824 where statement labels are allowed. */
826 save_filename save_lineno decl
830 /* records the type and storage class specs to use for processing
831 the declarators that follow.
832 Maintains a stack of outer-level values of current_declspecs,
833 for the sake of parm declarations nested in function declarators. */
834 setspecs: /* empty */
835 { pending_xref_error ();
836 declspec_stack = tree_cons (prefix_attributes,
839 split_specs_attrs ($<ttype>0,
840 ¤t_declspecs, &prefix_attributes); }
843 /* ??? Yuck. See maybe_setattrs. */
844 setattrs: /* empty */
845 { prefix_attributes = chainon (prefix_attributes, $<ttype>0); }
849 /* ??? Yuck. setattrs is a quick hack. We can't use
850 prefix_attributes because $1 only applies to this
851 declarator. We assume setspecs has already been done.
852 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
853 attributes could be recognized here or in `attributes').
854 Properly attributes ought to be able to apply to any level of
855 nested declarator, but the necessary compiler support isn't
856 present, so the attributes apply to a declaration (which may be
858 maybe_attribute setattrs
862 declspecs_ts setspecs initdecls ';'
863 { current_declspecs = TREE_VALUE (declspec_stack);
864 prefix_attributes = TREE_PURPOSE (declspec_stack);
865 declspec_stack = TREE_CHAIN (declspec_stack); }
866 | declspecs_nots setspecs notype_initdecls ';'
867 { current_declspecs = TREE_VALUE (declspec_stack);
868 prefix_attributes = TREE_PURPOSE (declspec_stack);
869 declspec_stack = TREE_CHAIN (declspec_stack); }
870 | declspecs_ts setspecs nested_function
871 { current_declspecs = TREE_VALUE (declspec_stack);
872 prefix_attributes = TREE_PURPOSE (declspec_stack);
873 declspec_stack = TREE_CHAIN (declspec_stack); }
874 | declspecs_nots setspecs notype_nested_function
875 { current_declspecs = TREE_VALUE (declspec_stack);
876 prefix_attributes = TREE_PURPOSE (declspec_stack);
877 declspec_stack = TREE_CHAIN (declspec_stack); }
881 { RESTORE_WARN_FLAGS ($1); }
884 /* A list of declaration specifiers. These are:
886 - Storage class specifiers (SCSPEC), which for GCC currently include
887 function specifiers ("inline").
889 - Type specifiers (typespec_*).
891 - Type qualifiers (TYPE_QUAL).
893 - Attribute specifier lists (attributes).
895 These are stored as a TREE_LIST; the head of the list is the last
896 item in the specifier list. Each entry in the list has either a
897 TREE_PURPOSE that is an attribute specifier list, or a TREE_VALUE that
898 is a single other specifier or qualifier; and a TREE_CHAIN that is the
899 rest of the list. TREE_STATIC is set on the list if something other
900 than a storage class specifier or attribute has been seen; this is used
901 to warn for the obsolescent usage of storage class specifiers other than
902 at the start of the list. (Doing this properly would require function
903 specifiers to be handled separately from storage class specifiers.)
905 The various cases below are classified according to:
907 (a) Whether a storage class specifier is included or not; some
908 places in the grammar disallow storage class specifiers (_sc or _nosc).
910 (b) Whether a type specifier has been seen; after a type specifier,
911 a typedef name is an identifier to redeclare (_ts or _nots).
913 (c) Whether the list starts with an attribute; in certain places,
914 the grammar requires specifiers that don't start with an attribute
917 (d) Whether the list ends with an attribute (or a specifier such that
918 any following attribute would have been parsed as part of that specifier);
919 this avoids shift-reduce conflicts in the parsing of attributes
924 (i) Distinguish between function specifiers and storage class specifiers,
925 at least for the purpose of warnings about obsolescent usage.
927 (ii) Halve the number of productions here by eliminating the _sc/_nosc
928 distinction and instead checking where required that storage class
929 specifiers aren't present. */
931 /* Declspecs which contain at least one type specifier or typedef name.
932 (Just `const' or `volatile' is not enough.)
933 A typedef'd name following these is taken as a name to be declared.
934 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
936 declspecs_nosc_nots_nosa_noea:
938 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
939 TREE_STATIC ($$) = 1; }
940 | declspecs_nosc_nots_nosa_noea TYPE_QUAL
941 { $$ = tree_cons (NULL_TREE, $2, $1);
942 TREE_STATIC ($$) = 1; }
943 | declspecs_nosc_nots_nosa_ea TYPE_QUAL
944 { $$ = tree_cons (NULL_TREE, $2, $1);
945 TREE_STATIC ($$) = 1; }
948 declspecs_nosc_nots_nosa_ea:
949 declspecs_nosc_nots_nosa_noea attributes
950 { $$ = tree_cons ($2, NULL_TREE, $1);
951 TREE_STATIC ($$) = TREE_STATIC ($1); }
954 declspecs_nosc_nots_sa_noea:
955 declspecs_nosc_nots_sa_noea TYPE_QUAL
956 { $$ = tree_cons (NULL_TREE, $2, $1);
957 TREE_STATIC ($$) = 1; }
958 | declspecs_nosc_nots_sa_ea TYPE_QUAL
959 { $$ = tree_cons (NULL_TREE, $2, $1);
960 TREE_STATIC ($$) = 1; }
963 declspecs_nosc_nots_sa_ea:
965 { $$ = tree_cons ($1, NULL_TREE, NULL_TREE);
966 TREE_STATIC ($$) = 0; }
967 | declspecs_nosc_nots_sa_noea attributes
968 { $$ = tree_cons ($2, NULL_TREE, $1);
969 TREE_STATIC ($$) = TREE_STATIC ($1); }
972 declspecs_nosc_ts_nosa_noea:
974 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
975 TREE_STATIC ($$) = 1; }
976 | declspecs_nosc_ts_nosa_noea TYPE_QUAL
977 { $$ = tree_cons (NULL_TREE, $2, $1);
978 TREE_STATIC ($$) = 1; }
979 | declspecs_nosc_ts_nosa_ea TYPE_QUAL
980 { $$ = tree_cons (NULL_TREE, $2, $1);
981 TREE_STATIC ($$) = 1; }
982 | declspecs_nosc_ts_nosa_noea typespec_reserved_nonattr
983 { $$ = tree_cons (NULL_TREE, $2, $1);
984 TREE_STATIC ($$) = 1; }
985 | declspecs_nosc_ts_nosa_ea typespec_reserved_nonattr
986 { $$ = tree_cons (NULL_TREE, $2, $1);
987 TREE_STATIC ($$) = 1; }
988 | declspecs_nosc_nots_nosa_noea typespec_nonattr
989 { $$ = tree_cons (NULL_TREE, $2, $1);
990 TREE_STATIC ($$) = 1; }
991 | declspecs_nosc_nots_nosa_ea typespec_nonattr
992 { $$ = tree_cons (NULL_TREE, $2, $1);
993 TREE_STATIC ($$) = 1; }
996 declspecs_nosc_ts_nosa_ea:
998 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
999 TREE_STATIC ($$) = 1; }
1000 | declspecs_nosc_ts_nosa_noea attributes
1001 { $$ = tree_cons ($2, NULL_TREE, $1);
1002 TREE_STATIC ($$) = TREE_STATIC ($1); }
1003 | declspecs_nosc_ts_nosa_noea typespec_reserved_attr
1004 { $$ = tree_cons (NULL_TREE, $2, $1);
1005 TREE_STATIC ($$) = 1; }
1006 | declspecs_nosc_ts_nosa_ea typespec_reserved_attr
1007 { $$ = tree_cons (NULL_TREE, $2, $1);
1008 TREE_STATIC ($$) = 1; }
1009 | declspecs_nosc_nots_nosa_noea typespec_attr
1010 { $$ = tree_cons (NULL_TREE, $2, $1);
1011 TREE_STATIC ($$) = 1; }
1012 | declspecs_nosc_nots_nosa_ea typespec_attr
1013 { $$ = tree_cons (NULL_TREE, $2, $1);
1014 TREE_STATIC ($$) = 1; }
1017 declspecs_nosc_ts_sa_noea:
1018 declspecs_nosc_ts_sa_noea TYPE_QUAL
1019 { $$ = tree_cons (NULL_TREE, $2, $1);
1020 TREE_STATIC ($$) = 1; }
1021 | declspecs_nosc_ts_sa_ea TYPE_QUAL
1022 { $$ = tree_cons (NULL_TREE, $2, $1);
1023 TREE_STATIC ($$) = 1; }
1024 | declspecs_nosc_ts_sa_noea typespec_reserved_nonattr
1025 { $$ = tree_cons (NULL_TREE, $2, $1);
1026 TREE_STATIC ($$) = 1; }
1027 | declspecs_nosc_ts_sa_ea typespec_reserved_nonattr
1028 { $$ = tree_cons (NULL_TREE, $2, $1);
1029 TREE_STATIC ($$) = 1; }
1030 | declspecs_nosc_nots_sa_noea typespec_nonattr
1031 { $$ = tree_cons (NULL_TREE, $2, $1);
1032 TREE_STATIC ($$) = 1; }
1033 | declspecs_nosc_nots_sa_ea typespec_nonattr
1034 { $$ = tree_cons (NULL_TREE, $2, $1);
1035 TREE_STATIC ($$) = 1; }
1038 declspecs_nosc_ts_sa_ea:
1039 declspecs_nosc_ts_sa_noea attributes
1040 { $$ = tree_cons ($2, NULL_TREE, $1);
1041 TREE_STATIC ($$) = TREE_STATIC ($1); }
1042 | declspecs_nosc_ts_sa_noea typespec_reserved_attr
1043 { $$ = tree_cons (NULL_TREE, $2, $1);
1044 TREE_STATIC ($$) = 1; }
1045 | declspecs_nosc_ts_sa_ea typespec_reserved_attr
1046 { $$ = tree_cons (NULL_TREE, $2, $1);
1047 TREE_STATIC ($$) = 1; }
1048 | declspecs_nosc_nots_sa_noea typespec_attr
1049 { $$ = tree_cons (NULL_TREE, $2, $1);
1050 TREE_STATIC ($$) = 1; }
1051 | declspecs_nosc_nots_sa_ea typespec_attr
1052 { $$ = tree_cons (NULL_TREE, $2, $1);
1053 TREE_STATIC ($$) = 1; }
1056 declspecs_sc_nots_nosa_noea:
1058 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
1059 TREE_STATIC ($$) = 0; }
1060 | declspecs_sc_nots_nosa_noea TYPE_QUAL
1061 { $$ = tree_cons (NULL_TREE, $2, $1);
1062 TREE_STATIC ($$) = 1; }
1063 | declspecs_sc_nots_nosa_ea TYPE_QUAL
1064 { $$ = tree_cons (NULL_TREE, $2, $1);
1065 TREE_STATIC ($$) = 1; }
1066 | declspecs_nosc_nots_nosa_noea SCSPEC
1067 { if (extra_warnings && TREE_STATIC ($1))
1068 warning ("`%s' is not at beginning of declaration",
1069 IDENTIFIER_POINTER ($2));
1070 $$ = tree_cons (NULL_TREE, $2, $1);
1071 TREE_STATIC ($$) = TREE_STATIC ($1); }
1072 | declspecs_nosc_nots_nosa_ea SCSPEC
1073 { if (extra_warnings && TREE_STATIC ($1))
1074 warning ("`%s' is not at beginning of declaration",
1075 IDENTIFIER_POINTER ($2));
1076 $$ = tree_cons (NULL_TREE, $2, $1);
1077 TREE_STATIC ($$) = TREE_STATIC ($1); }
1078 | declspecs_sc_nots_nosa_noea SCSPEC
1079 { if (extra_warnings && TREE_STATIC ($1))
1080 warning ("`%s' is not at beginning of declaration",
1081 IDENTIFIER_POINTER ($2));
1082 $$ = tree_cons (NULL_TREE, $2, $1);
1083 TREE_STATIC ($$) = TREE_STATIC ($1); }
1084 | declspecs_sc_nots_nosa_ea SCSPEC
1085 { if (extra_warnings && TREE_STATIC ($1))
1086 warning ("`%s' is not at beginning of declaration",
1087 IDENTIFIER_POINTER ($2));
1088 $$ = tree_cons (NULL_TREE, $2, $1);
1089 TREE_STATIC ($$) = TREE_STATIC ($1); }
1092 declspecs_sc_nots_nosa_ea:
1093 declspecs_sc_nots_nosa_noea attributes
1094 { $$ = tree_cons ($2, NULL_TREE, $1);
1095 TREE_STATIC ($$) = TREE_STATIC ($1); }
1098 declspecs_sc_nots_sa_noea:
1099 declspecs_sc_nots_sa_noea TYPE_QUAL
1100 { $$ = tree_cons (NULL_TREE, $2, $1);
1101 TREE_STATIC ($$) = 1; }
1102 | declspecs_sc_nots_sa_ea TYPE_QUAL
1103 { $$ = tree_cons (NULL_TREE, $2, $1);
1104 TREE_STATIC ($$) = 1; }
1105 | declspecs_nosc_nots_sa_noea SCSPEC
1106 { if (extra_warnings && TREE_STATIC ($1))
1107 warning ("`%s' is not at beginning of declaration",
1108 IDENTIFIER_POINTER ($2));
1109 $$ = tree_cons (NULL_TREE, $2, $1);
1110 TREE_STATIC ($$) = TREE_STATIC ($1); }
1111 | declspecs_nosc_nots_sa_ea SCSPEC
1112 { if (extra_warnings && TREE_STATIC ($1))
1113 warning ("`%s' is not at beginning of declaration",
1114 IDENTIFIER_POINTER ($2));
1115 $$ = tree_cons (NULL_TREE, $2, $1);
1116 TREE_STATIC ($$) = TREE_STATIC ($1); }
1117 | declspecs_sc_nots_sa_noea SCSPEC
1118 { if (extra_warnings && TREE_STATIC ($1))
1119 warning ("`%s' is not at beginning of declaration",
1120 IDENTIFIER_POINTER ($2));
1121 $$ = tree_cons (NULL_TREE, $2, $1);
1122 TREE_STATIC ($$) = TREE_STATIC ($1); }
1123 | declspecs_sc_nots_sa_ea SCSPEC
1124 { if (extra_warnings && TREE_STATIC ($1))
1125 warning ("`%s' is not at beginning of declaration",
1126 IDENTIFIER_POINTER ($2));
1127 $$ = tree_cons (NULL_TREE, $2, $1);
1128 TREE_STATIC ($$) = TREE_STATIC ($1); }
1131 declspecs_sc_nots_sa_ea:
1132 declspecs_sc_nots_sa_noea attributes
1133 { $$ = tree_cons ($2, NULL_TREE, $1);
1134 TREE_STATIC ($$) = TREE_STATIC ($1); }
1137 declspecs_sc_ts_nosa_noea:
1138 declspecs_sc_ts_nosa_noea TYPE_QUAL
1139 { $$ = tree_cons (NULL_TREE, $2, $1);
1140 TREE_STATIC ($$) = 1; }
1141 | declspecs_sc_ts_nosa_ea TYPE_QUAL
1142 { $$ = tree_cons (NULL_TREE, $2, $1);
1143 TREE_STATIC ($$) = 1; }
1144 | declspecs_sc_ts_nosa_noea typespec_reserved_nonattr
1145 { $$ = tree_cons (NULL_TREE, $2, $1);
1146 TREE_STATIC ($$) = 1; }
1147 | declspecs_sc_ts_nosa_ea typespec_reserved_nonattr
1148 { $$ = tree_cons (NULL_TREE, $2, $1);
1149 TREE_STATIC ($$) = 1; }
1150 | declspecs_sc_nots_nosa_noea typespec_nonattr
1151 { $$ = tree_cons (NULL_TREE, $2, $1);
1152 TREE_STATIC ($$) = 1; }
1153 | declspecs_sc_nots_nosa_ea typespec_nonattr
1154 { $$ = tree_cons (NULL_TREE, $2, $1);
1155 TREE_STATIC ($$) = 1; }
1156 | declspecs_nosc_ts_nosa_noea SCSPEC
1157 { if (extra_warnings && TREE_STATIC ($1))
1158 warning ("`%s' is not at beginning of declaration",
1159 IDENTIFIER_POINTER ($2));
1160 $$ = tree_cons (NULL_TREE, $2, $1);
1161 TREE_STATIC ($$) = TREE_STATIC ($1); }
1162 | declspecs_nosc_ts_nosa_ea SCSPEC
1163 { if (extra_warnings && TREE_STATIC ($1))
1164 warning ("`%s' is not at beginning of declaration",
1165 IDENTIFIER_POINTER ($2));
1166 $$ = tree_cons (NULL_TREE, $2, $1);
1167 TREE_STATIC ($$) = TREE_STATIC ($1); }
1168 | declspecs_sc_ts_nosa_noea SCSPEC
1169 { if (extra_warnings && TREE_STATIC ($1))
1170 warning ("`%s' is not at beginning of declaration",
1171 IDENTIFIER_POINTER ($2));
1172 $$ = tree_cons (NULL_TREE, $2, $1);
1173 TREE_STATIC ($$) = TREE_STATIC ($1); }
1174 | declspecs_sc_ts_nosa_ea SCSPEC
1175 { if (extra_warnings && TREE_STATIC ($1))
1176 warning ("`%s' is not at beginning of declaration",
1177 IDENTIFIER_POINTER ($2));
1178 $$ = tree_cons (NULL_TREE, $2, $1);
1179 TREE_STATIC ($$) = TREE_STATIC ($1); }
1182 declspecs_sc_ts_nosa_ea:
1183 declspecs_sc_ts_nosa_noea attributes
1184 { $$ = tree_cons ($2, NULL_TREE, $1);
1185 TREE_STATIC ($$) = TREE_STATIC ($1); }
1186 | declspecs_sc_ts_nosa_noea typespec_reserved_attr
1187 { $$ = tree_cons (NULL_TREE, $2, $1);
1188 TREE_STATIC ($$) = 1; }
1189 | declspecs_sc_ts_nosa_ea typespec_reserved_attr
1190 { $$ = tree_cons (NULL_TREE, $2, $1);
1191 TREE_STATIC ($$) = 1; }
1192 | declspecs_sc_nots_nosa_noea typespec_attr
1193 { $$ = tree_cons (NULL_TREE, $2, $1);
1194 TREE_STATIC ($$) = 1; }
1195 | declspecs_sc_nots_nosa_ea typespec_attr
1196 { $$ = tree_cons (NULL_TREE, $2, $1);
1197 TREE_STATIC ($$) = 1; }
1200 declspecs_sc_ts_sa_noea:
1201 declspecs_sc_ts_sa_noea TYPE_QUAL
1202 { $$ = tree_cons (NULL_TREE, $2, $1);
1203 TREE_STATIC ($$) = 1; }
1204 | declspecs_sc_ts_sa_ea TYPE_QUAL
1205 { $$ = tree_cons (NULL_TREE, $2, $1);
1206 TREE_STATIC ($$) = 1; }
1207 | declspecs_sc_ts_sa_noea typespec_reserved_nonattr
1208 { $$ = tree_cons (NULL_TREE, $2, $1);
1209 TREE_STATIC ($$) = 1; }
1210 | declspecs_sc_ts_sa_ea typespec_reserved_nonattr
1211 { $$ = tree_cons (NULL_TREE, $2, $1);
1212 TREE_STATIC ($$) = 1; }
1213 | declspecs_sc_nots_sa_noea typespec_nonattr
1214 { $$ = tree_cons (NULL_TREE, $2, $1);
1215 TREE_STATIC ($$) = 1; }
1216 | declspecs_sc_nots_sa_ea typespec_nonattr
1217 { $$ = tree_cons (NULL_TREE, $2, $1);
1218 TREE_STATIC ($$) = 1; }
1219 | declspecs_nosc_ts_sa_noea SCSPEC
1220 { if (extra_warnings && TREE_STATIC ($1))
1221 warning ("`%s' is not at beginning of declaration",
1222 IDENTIFIER_POINTER ($2));
1223 $$ = tree_cons (NULL_TREE, $2, $1);
1224 TREE_STATIC ($$) = TREE_STATIC ($1); }
1225 | declspecs_nosc_ts_sa_ea SCSPEC
1226 { if (extra_warnings && TREE_STATIC ($1))
1227 warning ("`%s' is not at beginning of declaration",
1228 IDENTIFIER_POINTER ($2));
1229 $$ = tree_cons (NULL_TREE, $2, $1);
1230 TREE_STATIC ($$) = TREE_STATIC ($1); }
1231 | declspecs_sc_ts_sa_noea SCSPEC
1232 { if (extra_warnings && TREE_STATIC ($1))
1233 warning ("`%s' is not at beginning of declaration",
1234 IDENTIFIER_POINTER ($2));
1235 $$ = tree_cons (NULL_TREE, $2, $1);
1236 TREE_STATIC ($$) = TREE_STATIC ($1); }
1237 | declspecs_sc_ts_sa_ea SCSPEC
1238 { if (extra_warnings && TREE_STATIC ($1))
1239 warning ("`%s' is not at beginning of declaration",
1240 IDENTIFIER_POINTER ($2));
1241 $$ = tree_cons (NULL_TREE, $2, $1);
1242 TREE_STATIC ($$) = TREE_STATIC ($1); }
1245 declspecs_sc_ts_sa_ea:
1246 declspecs_sc_ts_sa_noea attributes
1247 { $$ = tree_cons ($2, NULL_TREE, $1);
1248 TREE_STATIC ($$) = TREE_STATIC ($1); }
1249 | declspecs_sc_ts_sa_noea typespec_reserved_attr
1250 { $$ = tree_cons (NULL_TREE, $2, $1);
1251 TREE_STATIC ($$) = 1; }
1252 | declspecs_sc_ts_sa_ea typespec_reserved_attr
1253 { $$ = tree_cons (NULL_TREE, $2, $1);
1254 TREE_STATIC ($$) = 1; }
1255 | declspecs_sc_nots_sa_noea typespec_attr
1256 { $$ = tree_cons (NULL_TREE, $2, $1);
1257 TREE_STATIC ($$) = 1; }
1258 | declspecs_sc_nots_sa_ea typespec_attr
1259 { $$ = tree_cons (NULL_TREE, $2, $1);
1260 TREE_STATIC ($$) = 1; }
1263 /* Particular useful classes of declspecs. */
1265 declspecs_nosc_ts_nosa_noea
1266 | declspecs_nosc_ts_nosa_ea
1267 | declspecs_nosc_ts_sa_noea
1268 | declspecs_nosc_ts_sa_ea
1269 | declspecs_sc_ts_nosa_noea
1270 | declspecs_sc_ts_nosa_ea
1271 | declspecs_sc_ts_sa_noea
1272 | declspecs_sc_ts_sa_ea
1276 declspecs_nosc_nots_nosa_noea
1277 | declspecs_nosc_nots_nosa_ea
1278 | declspecs_nosc_nots_sa_noea
1279 | declspecs_nosc_nots_sa_ea
1280 | declspecs_sc_nots_nosa_noea
1281 | declspecs_sc_nots_nosa_ea
1282 | declspecs_sc_nots_sa_noea
1283 | declspecs_sc_nots_sa_ea
1287 declspecs_nosc_ts_nosa_noea
1288 | declspecs_nosc_ts_nosa_ea
1289 | declspecs_sc_ts_nosa_noea
1290 | declspecs_sc_ts_nosa_ea
1293 declspecs_nots_nosa:
1294 declspecs_nosc_nots_nosa_noea
1295 | declspecs_nosc_nots_nosa_ea
1296 | declspecs_sc_nots_nosa_noea
1297 | declspecs_sc_nots_nosa_ea
1301 declspecs_nosc_ts_nosa_noea
1302 | declspecs_nosc_ts_nosa_ea
1303 | declspecs_nosc_ts_sa_noea
1304 | declspecs_nosc_ts_sa_ea
1307 declspecs_nosc_nots:
1308 declspecs_nosc_nots_nosa_noea
1309 | declspecs_nosc_nots_nosa_ea
1310 | declspecs_nosc_nots_sa_noea
1311 | declspecs_nosc_nots_sa_ea
1315 declspecs_nosc_ts_nosa_noea
1316 | declspecs_nosc_ts_nosa_ea
1317 | declspecs_nosc_ts_sa_noea
1318 | declspecs_nosc_ts_sa_ea
1319 | declspecs_nosc_nots_nosa_noea
1320 | declspecs_nosc_nots_nosa_ea
1321 | declspecs_nosc_nots_sa_noea
1322 | declspecs_nosc_nots_sa_ea
1326 declspecs_nosc_nots_nosa_noea
1327 | declspecs_nosc_nots_nosa_ea
1328 | declspecs_nosc_nots_sa_noea
1329 | declspecs_nosc_nots_sa_ea
1330 | declspecs_nosc_ts_nosa_noea
1331 | declspecs_nosc_ts_nosa_ea
1332 | declspecs_nosc_ts_sa_noea
1333 | declspecs_nosc_ts_sa_ea
1334 | declspecs_sc_nots_nosa_noea
1335 | declspecs_sc_nots_nosa_ea
1336 | declspecs_sc_nots_sa_noea
1337 | declspecs_sc_nots_sa_ea
1338 | declspecs_sc_ts_nosa_noea
1339 | declspecs_sc_ts_nosa_ea
1340 | declspecs_sc_ts_sa_noea
1341 | declspecs_sc_ts_sa_ea
1344 /* A (possibly empty) sequence of type qualifiers and attributes, to be
1345 followed by the effect of setattrs if any attributes were present. */
1346 maybe_type_quals_setattrs:
1349 | declspecs_nosc_nots
1350 { tree specs, attrs;
1351 split_specs_attrs ($1, &specs, &attrs);
1352 /* ??? Yuck. See maybe_setattrs. */
1353 if (attrs != NULL_TREE)
1354 prefix_attributes = chainon (prefix_attributes, attrs);
1358 /* A type specifier (but not a type qualifier).
1359 Once we have seen one of these in a declaration,
1360 if a typedef name appears then it is being redeclared.
1362 The _reserved versions start with a reserved word and may appear anywhere
1363 in the declaration specifiers; the _nonreserved versions may only
1364 appear before any other type specifiers, and after that are (if names)
1367 FIXME: should the _nonreserved version be restricted to names being
1368 redeclared only? The other entries there relate only the GNU extensions
1369 and Objective C, and are historically parsed thus, and don't make sense
1370 after other type specifiers, but it might be cleaner to count them as
1373 _attr means: specifiers that either end with attributes,
1374 or are such that any following attributes would
1375 be parsed as part of the specifier.
1377 _nonattr: specifiers. */
1380 typespec_reserved_nonattr
1381 | typespec_nonreserved_nonattr
1385 typespec_reserved_attr
1388 typespec_reserved_nonattr:
1393 typespec_reserved_attr:
1397 typespec_nonreserved_nonattr:
1399 { /* For a typedef name, record the meaning, not the name.
1400 In case of `foo foo, bar;'. */
1401 $$ = lookup_name ($1); }
1403 | CLASSNAME protocolrefs
1404 { $$ = get_static_reference ($1, $2); }
1405 | OBJECTNAME protocolrefs
1406 { $$ = get_object_reference ($2); }
1408 /* Make "<SomeProtocol>" equivalent to "id <SomeProtocol>"
1409 - nisse@lysator.liu.se */
1410 | non_empty_protocolrefs
1411 { $$ = get_object_reference ($1); }
1413 | TYPEOF '(' expr ')'
1414 { $$ = TREE_TYPE ($3); }
1415 | TYPEOF '(' typename ')'
1416 { $$ = groktypename ($3); }
1419 /* typespec_nonreserved_attr does not exist. */
1423 | initdecls ',' maybe_setattrs initdcl
1428 | notype_initdecls ',' maybe_setattrs notype_initdcl
1434 | ASM_KEYWORD '(' string ')'
1435 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
1441 declarator maybeasm maybe_attribute '='
1442 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1443 $3, prefix_attributes);
1444 start_init ($<ttype>$, $2, global_bindings_p ()); }
1446 /* Note how the declaration of the variable is in effect while its init is parsed! */
1448 finish_decl ($<ttype>5, $6, $2); }
1449 | declarator maybeasm maybe_attribute
1450 { tree d = start_decl ($1, current_declspecs, 0,
1451 $3, prefix_attributes);
1452 finish_decl (d, NULL_TREE, $2);
1457 notype_declarator maybeasm maybe_attribute '='
1458 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1459 $3, prefix_attributes);
1460 start_init ($<ttype>$, $2, global_bindings_p ()); }
1462 /* Note how the declaration of the variable is in effect while its init is parsed! */
1464 finish_decl ($<ttype>5, $6, $2); }
1465 | notype_declarator maybeasm maybe_attribute
1466 { tree d = start_decl ($1, current_declspecs, 0,
1467 $3, prefix_attributes);
1468 finish_decl (d, NULL_TREE, $2); }
1470 /* the * rules are dummies to accept the Apollo extended syntax
1471 so that the header files compile. */
1482 | attributes attribute
1483 { $$ = chainon ($1, $2); }
1487 ATTRIBUTE '(' '(' attribute_list ')' ')'
1494 | attribute_list ',' attrib
1495 { $$ = chainon ($1, $3); }
1502 { $$ = build_tree_list ($1, NULL_TREE); }
1503 | any_word '(' IDENTIFIER ')'
1504 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1505 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1506 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1507 | any_word '(' exprlist ')'
1508 { $$ = build_tree_list ($1, $3); }
1511 /* This still leaves out most reserved keywords,
1512 shouldn't we include them? */
1521 /* Initializers. `init' is the entry point. */
1526 { really_start_incremental_init (NULL_TREE); }
1527 initlist_maybe_comma '}'
1528 { $$ = pop_init_level (0); }
1530 { $$ = error_mark_node; }
1533 /* `initlist_maybe_comma' is the guts of an initializer in braces. */
1534 initlist_maybe_comma:
1537 pedwarn ("ISO C forbids empty initializer braces"); }
1538 | initlist1 maybecomma
1543 | initlist1 ',' initelt
1546 /* `initelt' is a single element of an initializer.
1547 It may use braces. */
1549 designator_list '=' initval
1550 { if (pedantic && ! flag_isoc99)
1551 pedwarn ("ISO C89 forbids specifying subobject to initialize"); }
1552 | designator initval
1554 pedwarn ("obsolete use of designated initializer without `='"); }
1556 { set_init_label ($1);
1558 pedwarn ("obsolete use of designated initializer with `:'"); }
1565 { push_init_level (0); }
1566 initlist_maybe_comma '}'
1567 { process_init_element (pop_init_level (0)); }
1569 { process_init_element ($1); }
1575 | designator_list designator
1580 { set_init_label ($2); }
1581 /* These are for labeled elements. The syntax for an array element
1582 initializer conflicts with the syntax for an Objective-C message,
1583 so don't include these productions in the Objective-C grammar. */
1585 | '[' expr_no_commas ELLIPSIS expr_no_commas ']'
1586 { set_init_index ($2, $4);
1588 pedwarn ("ISO C forbids specifying range of elements to initialize"); }
1589 | '[' expr_no_commas ']'
1590 { set_init_index ($2, NULL_TREE); }
1597 pedwarn ("ISO C forbids nested functions");
1599 push_function_context ();
1600 if (! start_function (current_declspecs, $1,
1601 prefix_attributes, NULL_TREE))
1603 pop_function_context ();
1607 old_style_parm_decls
1608 { store_parm_decls (); }
1609 /* This used to use compstmt_or_error.
1610 That caused a bug with input `f(g) int g {}',
1611 where the use of YYERROR1 above caused an error
1612 which then was handled by compstmt_or_error.
1613 There followed a repeated execution of that same rule,
1614 which called YYERROR1 again, and so on. */
1615 save_filename save_lineno compstmt
1616 { tree decl = current_function_decl;
1617 DECL_SOURCE_FILE (decl) = $5;
1618 DECL_SOURCE_LINE (decl) = $6;
1619 finish_function (1);
1620 pop_function_context ();
1621 add_decl_stmt (decl); }
1624 notype_nested_function:
1627 pedwarn ("ISO C forbids nested functions");
1629 push_function_context ();
1630 if (! start_function (current_declspecs, $1,
1631 prefix_attributes, NULL_TREE))
1633 pop_function_context ();
1637 old_style_parm_decls
1638 { store_parm_decls (); }
1639 /* This used to use compstmt_or_error.
1640 That caused a bug with input `f(g) int g {}',
1641 where the use of YYERROR1 above caused an error
1642 which then was handled by compstmt_or_error.
1643 There followed a repeated execution of that same rule,
1644 which called YYERROR1 again, and so on. */
1645 save_filename save_lineno compstmt
1646 { tree decl = current_function_decl;
1647 DECL_SOURCE_FILE (decl) = $5;
1648 DECL_SOURCE_LINE (decl) = $6;
1649 finish_function (1);
1650 pop_function_context ();
1651 add_decl_stmt (decl); }
1654 /* Any kind of declarator (thus, all declarators allowed
1655 after an explicit typespec). */
1658 after_type_declarator
1662 /* A declarator that is allowed only after an explicit typespec. */
1664 after_type_declarator:
1665 '(' maybe_setattrs after_type_declarator ')'
1667 | after_type_declarator '(' parmlist_or_identifiers %prec '.'
1668 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1669 /* | after_type_declarator '(' error ')' %prec '.'
1670 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1671 poplevel (0, 0, 0); } */
1672 | after_type_declarator array_declarator %prec '.'
1673 { $$ = set_array_declarator_type ($2, $1, 0); }
1674 | '*' maybe_type_quals_setattrs after_type_declarator %prec UNARY
1675 { $$ = make_pointer_declarator ($2, $3); }
1682 /* Kinds of declarator that can appear in a parameter list
1683 in addition to notype_declarator. This is like after_type_declarator
1684 but does not allow a typedef name in parentheses as an identifier
1685 (because it would conflict with a function with that typedef as arg). */
1687 parm_declarator_starttypename
1688 | parm_declarator_nostarttypename
1691 parm_declarator_starttypename:
1692 parm_declarator_starttypename '(' parmlist_or_identifiers %prec '.'
1693 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1694 /* | parm_declarator_starttypename '(' error ')' %prec '.'
1695 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1696 poplevel (0, 0, 0); } */
1697 | parm_declarator_starttypename array_declarator %prec '.'
1698 { $$ = set_array_declarator_type ($2, $1, 0); }
1702 parm_declarator_nostarttypename:
1703 parm_declarator_nostarttypename '(' parmlist_or_identifiers %prec '.'
1704 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1705 /* | parm_declarator_nostarttypename '(' error ')' %prec '.'
1706 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1707 poplevel (0, 0, 0); } */
1708 | parm_declarator_nostarttypename array_declarator %prec '.'
1709 { $$ = set_array_declarator_type ($2, $1, 0); }
1710 | '*' maybe_type_quals_setattrs parm_declarator_starttypename %prec UNARY
1711 { $$ = make_pointer_declarator ($2, $3); }
1712 | '*' maybe_type_quals_setattrs parm_declarator_nostarttypename %prec UNARY
1713 { $$ = make_pointer_declarator ($2, $3); }
1714 | '(' maybe_setattrs parm_declarator_nostarttypename ')'
1718 /* A declarator allowed whether or not there has been
1719 an explicit typespec. These cannot redeclare a typedef-name. */
1722 notype_declarator '(' parmlist_or_identifiers %prec '.'
1723 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1724 /* | notype_declarator '(' error ')' %prec '.'
1725 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1726 poplevel (0, 0, 0); } */
1727 | '(' maybe_setattrs notype_declarator ')'
1729 | '*' maybe_type_quals_setattrs notype_declarator %prec UNARY
1730 { $$ = make_pointer_declarator ($2, $3); }
1731 | notype_declarator array_declarator %prec '.'
1732 { $$ = set_array_declarator_type ($2, $1, 0); }
1757 /* structsp_attr: struct/union/enum specifiers that either
1758 end with attributes, or are such that any following attributes would
1759 be parsed as part of the struct/union/enum specifier.
1761 structsp_nonattr: other struct/union/enum specifiers. */
1764 struct_head identifier '{'
1765 { $$ = start_struct (RECORD_TYPE, $2);
1766 /* Start scope of tag before parsing components. */
1768 component_decl_list '}' maybe_attribute
1769 { $$ = finish_struct ($<ttype>4, $5, chainon ($1, $7)); }
1770 | struct_head '{' component_decl_list '}' maybe_attribute
1771 { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
1772 $3, chainon ($1, $5));
1774 | union_head identifier '{'
1775 { $$ = start_struct (UNION_TYPE, $2); }
1776 component_decl_list '}' maybe_attribute
1777 { $$ = finish_struct ($<ttype>4, $5, chainon ($1, $7)); }
1778 | union_head '{' component_decl_list '}' maybe_attribute
1779 { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
1780 $3, chainon ($1, $5));
1782 | enum_head identifier '{'
1783 { $$ = start_enum ($2); }
1784 enumlist maybecomma_warn '}' maybe_attribute
1785 { $$ = finish_enum ($<ttype>4, nreverse ($5),
1786 chainon ($1, $8)); }
1788 { $$ = start_enum (NULL_TREE); }
1789 enumlist maybecomma_warn '}' maybe_attribute
1790 { $$ = finish_enum ($<ttype>3, nreverse ($4),
1791 chainon ($1, $7)); }
1795 struct_head identifier
1796 { $$ = xref_tag (RECORD_TYPE, $2); }
1797 | union_head identifier
1798 { $$ = xref_tag (UNION_TYPE, $2); }
1799 | enum_head identifier
1800 { $$ = xref_tag (ENUMERAL_TYPE, $2);
1801 /* In ISO C, enumerated types can be referred to
1802 only if already defined. */
1803 if (pedantic && !COMPLETE_TYPE_P ($$))
1804 pedwarn ("ISO C forbids forward references to `enum' types"); }
1815 { if (pedantic && ! flag_isoc99)
1816 pedwarn ("comma at end of enumerator list"); }
1819 component_decl_list:
1820 component_decl_list2
1822 | component_decl_list2 component_decl
1823 { $$ = chainon ($1, $2);
1824 pedwarn ("no semicolon at end of struct or union"); }
1827 component_decl_list2: /* empty */
1829 | component_decl_list2 component_decl ';'
1830 { $$ = chainon ($1, $2); }
1831 | component_decl_list2 ';'
1833 pedwarn ("extra semicolon in struct or union specified"); }
1835 /* foo(sizeof(struct{ @defs(ClassName)})); */
1836 | DEFS '(' CLASSNAME ')'
1838 tree interface = lookup_interface ($3);
1841 $$ = get_class_ivars (interface);
1844 error ("Cannot find interface declaration for `%s'",
1845 IDENTIFIER_POINTER ($3));
1853 declspecs_nosc_ts setspecs components
1855 current_declspecs = TREE_VALUE (declspec_stack);
1856 prefix_attributes = TREE_PURPOSE (declspec_stack);
1857 declspec_stack = TREE_CHAIN (declspec_stack); }
1858 | declspecs_nosc_ts setspecs save_filename save_lineno
1860 /* Support for unnamed structs or unions as members of
1861 structs or unions (which is [a] useful and [b] supports
1864 pedwarn ("ISO C doesn't support unnamed structs/unions");
1866 $$ = grokfield($3, $4, NULL, current_declspecs, NULL_TREE);
1867 current_declspecs = TREE_VALUE (declspec_stack);
1868 prefix_attributes = TREE_PURPOSE (declspec_stack);
1869 declspec_stack = TREE_CHAIN (declspec_stack);
1871 | declspecs_nosc_nots setspecs components_notype
1873 current_declspecs = TREE_VALUE (declspec_stack);
1874 prefix_attributes = TREE_PURPOSE (declspec_stack);
1875 declspec_stack = TREE_CHAIN (declspec_stack); }
1876 | declspecs_nosc_nots
1878 pedwarn ("ISO C forbids member declarations with no members");
1883 | extension component_decl
1885 RESTORE_WARN_FLAGS ($1); }
1889 component_declarator
1890 | components ',' maybe_setattrs component_declarator
1891 { $$ = chainon ($1, $4); }
1895 component_notype_declarator
1896 | components_notype ',' maybe_setattrs component_notype_declarator
1897 { $$ = chainon ($1, $4); }
1900 component_declarator:
1901 save_filename save_lineno declarator maybe_attribute
1902 { $$ = grokfield ($1, $2, $3, current_declspecs, NULL_TREE);
1903 decl_attributes ($$, $4, prefix_attributes); }
1904 | save_filename save_lineno
1905 declarator ':' expr_no_commas maybe_attribute
1906 { $$ = grokfield ($1, $2, $3, current_declspecs, $5);
1907 decl_attributes ($$, $6, prefix_attributes); }
1908 | save_filename save_lineno ':' expr_no_commas maybe_attribute
1909 { $$ = grokfield ($1, $2, NULL_TREE, current_declspecs, $4);
1910 decl_attributes ($$, $5, prefix_attributes); }
1913 component_notype_declarator:
1914 save_filename save_lineno notype_declarator maybe_attribute
1915 { $$ = grokfield ($1, $2, $3, current_declspecs, NULL_TREE);
1916 decl_attributes ($$, $4, prefix_attributes); }
1917 | save_filename save_lineno
1918 notype_declarator ':' expr_no_commas maybe_attribute
1919 { $$ = grokfield ($1, $2, $3, current_declspecs, $5);
1920 decl_attributes ($$, $6, prefix_attributes); }
1921 | save_filename save_lineno ':' expr_no_commas maybe_attribute
1922 { $$ = grokfield ($1, $2, NULL_TREE, current_declspecs, $4);
1923 decl_attributes ($$, $5, prefix_attributes); }
1926 /* We chain the enumerators in reverse order.
1927 They are put in forward order where enumlist is used.
1928 (The order used to be significant, but no longer is so.
1929 However, we still maintain the order, just to be clean.) */
1933 | enumlist ',' enumerator
1934 { if ($1 == error_mark_node)
1937 $$ = chainon ($3, $1); }
1939 { $$ = error_mark_node; }
1945 { $$ = build_enumerator ($1, NULL_TREE); }
1946 | identifier '=' expr_no_commas
1947 { $$ = build_enumerator ($1, $3); }
1952 { tree specs, attrs;
1953 pending_xref_error ();
1954 split_specs_attrs ($1, &specs, &attrs);
1955 /* We don't yet support attributes here. */
1956 if (attrs != NULL_TREE)
1957 warning ("attributes on type name ignored");
1958 $<ttype>$ = specs; }
1960 { $$ = build_tree_list ($<ttype>2, $3); }
1963 absdcl: /* an absolute declarator */
1969 absdcl_maybe_attribute: /* absdcl maybe_attribute, but not just attributes */
1971 { $$ = build_tree_list (build_tree_list (current_declspecs,
1973 build_tree_list (prefix_attributes,
1976 { $$ = build_tree_list (build_tree_list (current_declspecs,
1978 build_tree_list (prefix_attributes,
1980 | absdcl1_noea attributes
1981 { $$ = build_tree_list (build_tree_list (current_declspecs,
1983 build_tree_list (prefix_attributes,
1987 absdcl1: /* a nonempty absolute declarator */
1994 | '*' maybe_type_quals_setattrs absdcl1_noea
1995 { $$ = make_pointer_declarator ($2, $3); }
1999 '*' maybe_type_quals_setattrs
2000 { $$ = make_pointer_declarator ($2, NULL_TREE); }
2001 | '*' maybe_type_quals_setattrs absdcl1_ea
2002 { $$ = make_pointer_declarator ($2, $3); }
2006 '(' maybe_setattrs absdcl1 ')'
2008 | direct_absdcl1 '(' parmlist
2009 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
2010 | direct_absdcl1 array_declarator
2011 { $$ = set_array_declarator_type ($2, $1, 1); }
2013 { $$ = build_nt (CALL_EXPR, NULL_TREE, $2, NULL_TREE); }
2015 { $$ = set_array_declarator_type ($1, NULL_TREE, 1); }
2018 /* The [...] part of a declarator for an array type. */
2022 { $$ = build_array_declarator ($2, NULL_TREE, 0, 0); }
2023 | '[' declspecs_nosc expr ']'
2024 { $$ = build_array_declarator ($3, $2, 0, 0); }
2026 { $$ = build_array_declarator (NULL_TREE, NULL_TREE, 0, 0); }
2027 | '[' declspecs_nosc ']'
2028 { $$ = build_array_declarator (NULL_TREE, $2, 0, 0); }
2030 { $$ = build_array_declarator (NULL_TREE, NULL_TREE, 0, 1); }
2031 | '[' declspecs_nosc '*' ']'
2032 { $$ = build_array_declarator (NULL_TREE, $2, 0, 1); }
2033 | '[' SCSPEC expr ']'
2034 { if (C_RID_CODE ($2) != RID_STATIC)
2035 error ("storage class specifier in array declarator");
2036 $$ = build_array_declarator ($3, NULL_TREE, 1, 0); }
2037 | '[' SCSPEC declspecs_nosc expr ']'
2038 { if (C_RID_CODE ($2) != RID_STATIC)
2039 error ("storage class specifier in array declarator");
2040 $$ = build_array_declarator ($4, $3, 1, 0); }
2041 | '[' declspecs_nosc SCSPEC expr ']'
2042 { if (C_RID_CODE ($3) != RID_STATIC)
2043 error ("storage class specifier in array declarator");
2044 $$ = build_array_declarator ($4, $2, 1, 0); }
2047 /* A nonempty series of declarations and statements (possibly followed by
2048 some labels) that can form the body of a compound statement.
2049 NOTE: we don't allow labels on declarations; this might seem like a
2050 natural extension, but there would be a conflict between attributes
2051 on the label and prefix attributes on the declaration. */
2054 lineno_stmt_decl_or_labels_ending_stmt
2055 | lineno_stmt_decl_or_labels_ending_decl
2056 | lineno_stmt_decl_or_labels_ending_label
2058 pedwarn ("deprecated use of label at end of compound statement");
2060 | lineno_stmt_decl_or_labels_ending_error
2063 lineno_stmt_decl_or_labels_ending_stmt:
2065 | lineno_stmt_decl_or_labels_ending_stmt lineno_stmt
2066 | lineno_stmt_decl_or_labels_ending_decl lineno_stmt
2067 | lineno_stmt_decl_or_labels_ending_label lineno_stmt
2068 | lineno_stmt_decl_or_labels_ending_error lineno_stmt
2071 lineno_stmt_decl_or_labels_ending_decl:
2073 | lineno_stmt_decl_or_labels_ending_stmt lineno_decl
2074 { if (pedantic && !flag_isoc99)
2075 pedwarn ("ISO C89 forbids mixed declarations and code"); }
2076 | lineno_stmt_decl_or_labels_ending_decl lineno_decl
2077 | lineno_stmt_decl_or_labels_ending_error lineno_decl
2080 lineno_stmt_decl_or_labels_ending_label:
2082 | lineno_stmt_decl_or_labels_ending_stmt lineno_label
2083 | lineno_stmt_decl_or_labels_ending_decl lineno_label
2084 | lineno_stmt_decl_or_labels_ending_label lineno_label
2085 | lineno_stmt_decl_or_labels_ending_error lineno_label
2088 lineno_stmt_decl_or_labels_ending_error:
2090 | lineno_stmt_decl_or_labels errstmt
2093 lineno_stmt_decl_or_labels:
2094 lineno_stmt_decl_or_labels_ending_stmt
2095 | lineno_stmt_decl_or_labels_ending_decl
2096 | lineno_stmt_decl_or_labels_ending_label
2097 | lineno_stmt_decl_or_labels_ending_error
2103 pushlevel: /* empty */
2106 add_scope_stmt (/*begin_p=*/1, /*partial_p=*/0);
2108 if (objc_method_context)
2114 poplevel: /* empty */
2115 { $$ = add_scope_stmt (/*begin_p=*/0, /*partial_p=*/0); }
2117 /* Start and end blocks created for the new scopes of C99. */
2118 c99_block_start: /* empty */
2121 $$ = c_begin_compound_stmt ();
2124 add_scope_stmt (/*begin_p=*/1, /*partial_p=*/0);
2126 if (objc_method_context)
2135 /* Productions using c99_block_start and c99_block_end will need to do what's
2136 in compstmt: RECHAIN_STMTS ($1, COMPOUND_BODY ($1)); $$ = $2; where
2137 $1 is the value of c99_block_start and $2 of c99_block_end. */
2138 c99_block_end: /* empty */
2141 tree scope_stmt = add_scope_stmt (/*begin_p=*/0, /*partial_p=*/0);
2142 $$ = poplevel (kept_level_p (), 0, 0);
2143 SCOPE_STMT_BLOCK (TREE_PURPOSE (scope_stmt))
2144 = SCOPE_STMT_BLOCK (TREE_VALUE (scope_stmt))
2151 /* Read zero or more forward-declarations for labels
2152 that nested functions can jump to. */
2157 pedwarn ("ISO C forbids label declarations"); }
2162 | label_decls label_decl
2166 LABEL identifiers_or_typenames ';'
2168 for (link = $2; link; link = TREE_CHAIN (link))
2170 tree label = shadow_label (TREE_VALUE (link));
2171 C_DECLARED_LABEL_FLAG (label) = 1;
2172 add_decl_stmt (label);
2177 /* This is the body of a function definition.
2178 It causes syntax errors to ignore to the next openbrace. */
2185 compstmt_start: '{' { compstmt_count++;
2186 $$ = c_begin_compound_stmt (); }
2188 compstmt_nostart: '}'
2189 { $$ = convert (void_type_node, integer_zero_node); }
2190 | pushlevel maybe_label_decls compstmt_contents_nonempty '}' poplevel
2191 { $$ = poplevel (kept_level_p (), 1, 0);
2192 SCOPE_STMT_BLOCK (TREE_PURPOSE ($5))
2193 = SCOPE_STMT_BLOCK (TREE_VALUE ($5))
2197 compstmt_contents_nonempty:
2202 compstmt_primary_start:
2204 { if (current_function_decl == 0)
2206 error ("braced-group within expression allowed only inside a function");
2209 /* We must force a BLOCK for this level
2210 so that, if it is not expanded later,
2211 there is a way to turn off the entire subtree of blocks
2212 that are contained in it. */
2214 push_label_level ();
2216 $$ = add_stmt (build_stmt (COMPOUND_STMT, last_tree));
2219 compstmt: compstmt_start compstmt_nostart
2220 { RECHAIN_STMTS ($1, COMPOUND_BODY ($1));
2224 /* Value is number of statements counted as of the closeparen. */
2226 if_prefix c99_block_lineno_labeled_stmt
2227 { c_finish_then (); }
2228 /* Make sure c_expand_end_cond is run once
2229 for each call to c_expand_start_cond.
2230 Otherwise a crash is likely. */
2236 { c_expand_start_cond (truthvalue_conversion ($3),
2238 $<itype>$ = stmt_count;
2239 if_stmt_file = $<filename>-2;
2240 if_stmt_line = $<lineno>-1; }
2243 /* This is a subroutine of stmt.
2244 It is used twice, once for valid DO statements
2245 and once for catching errors in parsing the end test. */
2251 = add_stmt (build_stmt (DO_STMT, NULL_TREE,
2253 /* In the event that a parse error prevents
2254 parsing the complete do-statement, set the
2255 condition now. Otherwise, we can get crashes at
2256 RTL-generation time. */
2257 DO_COND ($<ttype>$) = error_mark_node; }
2258 c99_block_lineno_labeled_stmt WHILE
2260 RECHAIN_STMTS ($$, DO_BODY ($$)); }
2263 /* The forced readahead in here is because we might be at the end of a
2264 line, and the line and file won't be bumped until yylex absorbs the
2265 first token on the next line. */
2267 { if (yychar == YYEMPTY)
2269 $$ = input_filename; }
2273 { if (yychar == YYEMPTY)
2278 lineno_labeled_stmt:
2280 | lineno_label lineno_labeled_stmt
2283 /* Like lineno_labeled_stmt, but a block in C99. */
2284 c99_block_lineno_labeled_stmt:
2285 c99_block_start lineno_labeled_stmt c99_block_end
2287 RECHAIN_STMTS ($1, COMPOUND_BODY ($1)); }
2291 save_filename save_lineno stmt
2294 STMT_LINENO ($3) = $2;
2295 /* ??? We currently have no way of recording
2296 the filename for a statement. This probably
2297 matters little in practice at the moment,
2298 but I suspect that problems will ocurr when
2299 doing inlining at the tree level. */
2305 save_filename save_lineno label
2308 STMT_LINENO ($3) = $2;
2313 select_or_iter_stmt:
2315 { c_expand_start_else ();
2316 $<itype>1 = stmt_count; }
2317 c99_block_lineno_labeled_stmt
2319 c_expand_end_cond ();
2320 if (extra_warnings && stmt_count == $<itype>1)
2321 warning ("empty body in an else-statement"); }
2322 | simple_if %prec IF
2323 { c_expand_end_cond ();
2324 /* This warning is here instead of in simple_if, because we
2325 do not want a warning if an empty if is followed by an
2326 else statement. Increment stmt_count so we don't
2327 give a second error if this is a nested `if'. */
2328 if (extra_warnings && stmt_count++ == $<itype>1)
2329 warning_with_file_and_line (if_stmt_file, if_stmt_line,
2330 "empty body in an if-statement"); }
2331 /* Make sure c_expand_end_cond is run once
2332 for each call to c_expand_start_cond.
2333 Otherwise a crash is likely. */
2334 | simple_if ELSE error
2335 { c_expand_end_cond (); }
2339 { $4 = truthvalue_conversion ($4);
2341 = add_stmt (build_stmt (WHILE_STMT, $4, NULL_TREE)); }
2342 c99_block_lineno_labeled_stmt
2343 { RECHAIN_STMTS ($<ttype>6, WHILE_BODY ($<ttype>6)); }
2346 { DO_COND ($1) = truthvalue_conversion ($3); }
2347 | do_stmt_start error
2350 { $<ttype>$ = build_stmt (FOR_STMT, NULL_TREE, NULL_TREE,
2351 NULL_TREE, NULL_TREE);
2352 add_stmt ($<ttype>$); }
2355 RECHAIN_STMTS ($<ttype>2, FOR_INIT_STMT ($<ttype>2)); }
2358 FOR_COND ($<ttype>2) = truthvalue_conversion ($6); }
2360 { FOR_EXPR ($<ttype>2) = $9; }
2361 c99_block_lineno_labeled_stmt
2362 { RECHAIN_STMTS ($<ttype>2, FOR_BODY ($<ttype>2)); }
2363 | SWITCH '(' expr ')'
2365 $<ttype>$ = c_start_case ($3); }
2366 c99_block_lineno_labeled_stmt
2367 { c_finish_case (); }
2372 { add_stmt (build_stmt (EXPR_STMT, $1)); }
2374 { check_for_loop_decls (); }
2377 /* Parse a single real statement, not including any labels. */
2380 { stmt_count++; $$ = $1; }
2383 $$ = c_expand_expr_stmt ($1); }
2384 | c99_block_start select_or_iter_stmt c99_block_end
2386 RECHAIN_STMTS ($1, COMPOUND_BODY ($1));
2390 $$ = add_stmt (build_break_stmt ()); }
2393 $$ = add_stmt (build_continue_stmt ()); }
2396 $$ = c_expand_return (NULL_TREE); }
2399 $$ = c_expand_return ($2); }
2400 | ASM_KEYWORD maybe_type_qual '(' expr ')' ';'
2402 $$ = simple_asm_stmt ($4); }
2403 /* This is the case with just output operands. */
2404 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ')' ';'
2406 $$ = build_asm_stmt ($2, $4, $6, NULL_TREE, NULL_TREE); }
2407 /* This is the case with input operands as well. */
2408 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':'
2409 asm_operands ')' ';'
2411 $$ = build_asm_stmt ($2, $4, $6, $8, NULL_TREE); }
2412 /* This is the case with clobbered registers as well. */
2413 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':'
2414 asm_operands ':' asm_clobbers ')' ';'
2416 $$ = build_asm_stmt ($2, $4, $6, $8, $10); }
2417 | GOTO identifier ';'
2420 decl = lookup_label ($2);
2423 TREE_USED (decl) = 1;
2424 $$ = add_stmt (build_stmt (GOTO_STMT, decl));
2431 pedwarn ("ISO C forbids `goto *expr;'");
2433 $3 = convert (ptr_type_node, $3);
2434 $$ = add_stmt (build_stmt (GOTO_STMT, $3)); }
2439 /* Any kind of label, including jump labels and case labels.
2440 ANSI C accepts labels only before statements, but we allow them
2441 also at the end of a compound statement. */
2443 label: CASE expr_no_commas ':'
2445 $$ = do_case ($2, NULL_TREE); }
2446 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
2448 $$ = do_case ($2, $4); }
2451 $$ = do_case (NULL_TREE, NULL_TREE); }
2452 | identifier save_filename save_lineno ':' maybe_attribute
2453 { tree label = define_label ($2, $3, $1);
2457 decl_attributes (label, $5, NULL_TREE);
2458 $$ = add_stmt (build_stmt (LABEL_STMT, label));
2465 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
2469 { emit_line_note (input_filename, lineno);
2472 { emit_line_note (input_filename, lineno); }
2481 /* These are the operands other than the first string and colon
2482 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
2483 asm_operands: /* empty */
2485 | nonnull_asm_operands
2488 nonnull_asm_operands:
2490 | nonnull_asm_operands ',' asm_operand
2491 { $$ = chainon ($1, $3); }
2496 { $$ = build_tree_list ($1, $3); }
2501 { $$ = tree_cons (NULL_TREE, combine_strings ($1), NULL_TREE); }
2502 | asm_clobbers ',' string
2503 { $$ = tree_cons (NULL_TREE, combine_strings ($3), $1); }
2506 /* This is what appears inside the parens in a function declarator.
2507 Its value is a list of ..._TYPE nodes. Attributes must appear here
2508 to avoid a conflict with their appearance after an open parenthesis
2509 in an abstract declarator, as in
2510 "void bar (int (__attribute__((__mode__(SI))) int foo));". */
2514 clear_parm_order ();
2515 declare_parm_level (0); }
2518 parmlist_tags_warning ();
2519 poplevel (0, 0, 0); }
2527 pedwarn ("ISO C forbids forward parameter declarations");
2528 /* Mark the forward decls as such. */
2529 for (parm = getdecls (); parm; parm = TREE_CHAIN (parm))
2530 TREE_ASM_WRITTEN (parm) = 1;
2531 clear_parm_order (); }
2533 { /* Dummy action so attributes are in known place
2534 on parser stack. */ }
2538 { $$ = tree_cons (NULL_TREE, NULL_TREE, NULL_TREE); }
2541 /* This is what appears inside the parens in a function declarator.
2542 Is value is represented in the format that grokdeclarator expects. */
2543 parmlist_2: /* empty */
2544 { $$ = get_parm_info (0); }
2546 { $$ = get_parm_info (0);
2547 /* Gcc used to allow this as an extension. However, it does
2548 not work for all targets, and thus has been disabled.
2549 Also, since func (...) and func () are indistinguishable,
2550 it caused problems with the code in expand_builtin which
2551 tries to verify that BUILT_IN_NEXT_ARG is being used
2553 error ("ISO C requires a named argument before `...'");
2556 { $$ = get_parm_info (1); }
2557 | parms ',' ELLIPSIS
2558 { $$ = get_parm_info (0); }
2563 { push_parm_decl ($1); }
2565 { push_parm_decl ($3); }
2568 /* A single parameter declaration or parameter type name,
2569 as found in a parmlist. */
2571 declspecs_ts setspecs parm_declarator maybe_attribute
2572 { $$ = build_tree_list (build_tree_list (current_declspecs,
2574 build_tree_list (prefix_attributes,
2576 current_declspecs = TREE_VALUE (declspec_stack);
2577 prefix_attributes = TREE_PURPOSE (declspec_stack);
2578 declspec_stack = TREE_CHAIN (declspec_stack); }
2579 | declspecs_ts setspecs notype_declarator maybe_attribute
2580 { $$ = build_tree_list (build_tree_list (current_declspecs,
2582 build_tree_list (prefix_attributes,
2584 current_declspecs = TREE_VALUE (declspec_stack);
2585 prefix_attributes = TREE_PURPOSE (declspec_stack);
2586 declspec_stack = TREE_CHAIN (declspec_stack); }
2587 | declspecs_ts setspecs absdcl_maybe_attribute
2589 current_declspecs = TREE_VALUE (declspec_stack);
2590 prefix_attributes = TREE_PURPOSE (declspec_stack);
2591 declspec_stack = TREE_CHAIN (declspec_stack); }
2592 | declspecs_nots setspecs notype_declarator maybe_attribute
2593 { $$ = build_tree_list (build_tree_list (current_declspecs,
2595 build_tree_list (prefix_attributes,
2597 current_declspecs = TREE_VALUE (declspec_stack);
2598 prefix_attributes = TREE_PURPOSE (declspec_stack);
2599 declspec_stack = TREE_CHAIN (declspec_stack); }
2601 | declspecs_nots setspecs absdcl_maybe_attribute
2603 current_declspecs = TREE_VALUE (declspec_stack);
2604 prefix_attributes = TREE_PURPOSE (declspec_stack);
2605 declspec_stack = TREE_CHAIN (declspec_stack); }
2608 /* The first parm, which must suck attributes from off the top of the parser
2611 declspecs_ts_nosa setspecs_fp parm_declarator maybe_attribute
2612 { $$ = build_tree_list (build_tree_list (current_declspecs,
2614 build_tree_list (prefix_attributes,
2616 current_declspecs = TREE_VALUE (declspec_stack);
2617 prefix_attributes = TREE_PURPOSE (declspec_stack);
2618 declspec_stack = TREE_CHAIN (declspec_stack); }
2619 | declspecs_ts_nosa setspecs_fp notype_declarator maybe_attribute
2620 { $$ = build_tree_list (build_tree_list (current_declspecs,
2622 build_tree_list (prefix_attributes,
2624 current_declspecs = TREE_VALUE (declspec_stack);
2625 prefix_attributes = TREE_PURPOSE (declspec_stack);
2626 declspec_stack = TREE_CHAIN (declspec_stack); }
2627 | declspecs_ts_nosa setspecs_fp absdcl_maybe_attribute
2629 current_declspecs = TREE_VALUE (declspec_stack);
2630 prefix_attributes = TREE_PURPOSE (declspec_stack);
2631 declspec_stack = TREE_CHAIN (declspec_stack); }
2632 | declspecs_nots_nosa setspecs_fp notype_declarator maybe_attribute
2633 { $$ = build_tree_list (build_tree_list (current_declspecs,
2635 build_tree_list (prefix_attributes,
2637 current_declspecs = TREE_VALUE (declspec_stack);
2638 prefix_attributes = TREE_PURPOSE (declspec_stack);
2639 declspec_stack = TREE_CHAIN (declspec_stack); }
2641 | declspecs_nots_nosa setspecs_fp absdcl_maybe_attribute
2643 current_declspecs = TREE_VALUE (declspec_stack);
2644 prefix_attributes = TREE_PURPOSE (declspec_stack);
2645 declspec_stack = TREE_CHAIN (declspec_stack); }
2650 { prefix_attributes = chainon (prefix_attributes, $<ttype>-2); }
2653 /* This is used in a function definition
2654 where either a parmlist or an identifier list is ok.
2655 Its value is a list of ..._TYPE nodes or a list of identifiers. */
2656 parmlist_or_identifiers:
2658 clear_parm_order ();
2659 declare_parm_level (1); }
2660 parmlist_or_identifiers_1
2662 parmlist_tags_warning ();
2663 poplevel (0, 0, 0); }
2666 parmlist_or_identifiers_1:
2670 for (t = $1; t; t = TREE_CHAIN (t))
2671 if (TREE_VALUE (t) == NULL_TREE)
2672 error ("`...' in old-style identifier list");
2673 $$ = tree_cons (NULL_TREE, NULL_TREE, $1); }
2676 /* A nonempty list of identifiers. */
2679 { $$ = build_tree_list (NULL_TREE, $1); }
2680 | identifiers ',' IDENTIFIER
2681 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2684 /* A nonempty list of identifiers, including typenames. */
2685 identifiers_or_typenames:
2687 { $$ = build_tree_list (NULL_TREE, $1); }
2688 | identifiers_or_typenames ',' identifier
2689 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2694 { $$ = SAVE_WARN_FLAGS();
2696 warn_pointer_arith = 0; }
2700 /* Objective-C productions. */
2710 if (objc_implementation_context)
2712 finish_class (objc_implementation_context);
2713 objc_ivar_chain = NULL_TREE;
2714 objc_implementation_context = NULL_TREE;
2717 warning ("`@end' must appear in an implementation context");
2721 /* A nonempty list of identifiers. */
2724 { $$ = build_tree_list (NULL_TREE, $1); }
2725 | identifier_list ',' identifier
2726 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2730 CLASS identifier_list ';'
2732 objc_declare_class ($2);
2736 ALIAS identifier identifier ';'
2738 objc_declare_alias ($2, $3);
2742 INTERFACE identifier protocolrefs '{'
2744 objc_interface_context = objc_ivar_context
2745 = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, $3);
2746 objc_public_flag = 0;
2750 continue_class (objc_interface_context);
2755 finish_class (objc_interface_context);
2756 objc_interface_context = NULL_TREE;
2759 | INTERFACE identifier protocolrefs
2761 objc_interface_context
2762 = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, $3);
2763 continue_class (objc_interface_context);
2768 finish_class (objc_interface_context);
2769 objc_interface_context = NULL_TREE;
2772 | INTERFACE identifier ':' identifier protocolrefs '{'
2774 objc_interface_context = objc_ivar_context
2775 = start_class (CLASS_INTERFACE_TYPE, $2, $4, $5);
2776 objc_public_flag = 0;
2780 continue_class (objc_interface_context);
2785 finish_class (objc_interface_context);
2786 objc_interface_context = NULL_TREE;
2789 | INTERFACE identifier ':' identifier protocolrefs
2791 objc_interface_context
2792 = start_class (CLASS_INTERFACE_TYPE, $2, $4, $5);
2793 continue_class (objc_interface_context);
2798 finish_class (objc_interface_context);
2799 objc_interface_context = NULL_TREE;
2802 | IMPLEMENTATION identifier '{'
2804 objc_implementation_context = objc_ivar_context
2805 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, NULL_TREE, NULL_TREE);
2806 objc_public_flag = 0;
2811 = continue_class (objc_implementation_context);
2814 | IMPLEMENTATION identifier
2816 objc_implementation_context
2817 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, NULL_TREE, NULL_TREE);
2819 = continue_class (objc_implementation_context);
2822 | IMPLEMENTATION identifier ':' identifier '{'
2824 objc_implementation_context = objc_ivar_context
2825 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2826 objc_public_flag = 0;
2831 = continue_class (objc_implementation_context);
2834 | IMPLEMENTATION identifier ':' identifier
2836 objc_implementation_context
2837 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2839 = continue_class (objc_implementation_context);
2842 | INTERFACE identifier '(' identifier ')' protocolrefs
2844 objc_interface_context
2845 = start_class (CATEGORY_INTERFACE_TYPE, $2, $4, $6);
2846 continue_class (objc_interface_context);
2851 finish_class (objc_interface_context);
2852 objc_interface_context = NULL_TREE;
2855 | IMPLEMENTATION identifier '(' identifier ')'
2857 objc_implementation_context
2858 = start_class (CATEGORY_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2860 = continue_class (objc_implementation_context);
2865 PROTOCOL identifier protocolrefs
2867 objc_pq_context = 1;
2868 objc_interface_context
2869 = start_protocol(PROTOCOL_INTERFACE_TYPE, $2, $3);
2873 objc_pq_context = 0;
2874 finish_protocol(objc_interface_context);
2875 objc_interface_context = NULL_TREE;
2884 | non_empty_protocolrefs
2887 non_empty_protocolrefs:
2888 ARITHCOMPARE identifier_list ARITHCOMPARE
2890 if ($1 == LT_EXPR && $3 == GT_EXPR)
2898 ivar_decl_list visibility_spec ivar_decls
2903 PRIVATE { objc_public_flag = 2; }
2904 | PROTECTED { objc_public_flag = 0; }
2905 | PUBLIC { objc_public_flag = 1; }
2913 | ivar_decls ivar_decl ';'
2917 pedwarn ("extra semicolon in struct or union specified");
2922 /* There is a shift-reduce conflict here, because `components' may
2923 start with a `typename'. It happens that shifting (the default resolution)
2924 does the right thing, because it treats the `typename' as part of
2925 a `typed_typespecs'.
2927 It is possible that this same technique would allow the distinction
2928 between `notype_initdecls' and `initdecls' to be eliminated.
2929 But I am being cautious and not trying it. */
2932 declspecs_nosc_ts setspecs ivars
2934 current_declspecs = TREE_VALUE (declspec_stack);
2935 prefix_attributes = TREE_PURPOSE (declspec_stack);
2936 declspec_stack = TREE_CHAIN (declspec_stack); }
2937 | declspecs_nosc_nots setspecs ivars
2939 current_declspecs = TREE_VALUE (declspec_stack);
2940 prefix_attributes = TREE_PURPOSE (declspec_stack);
2941 declspec_stack = TREE_CHAIN (declspec_stack); }
2950 | ivars ',' maybe_setattrs ivar_declarator
2956 $$ = add_instance_variable (objc_ivar_context,
2958 $1, current_declspecs,
2961 | declarator ':' expr_no_commas
2963 $$ = add_instance_variable (objc_ivar_context,
2965 $1, current_declspecs, $3);
2967 | ':' expr_no_commas
2969 $$ = add_instance_variable (objc_ivar_context,
2972 current_declspecs, $2);
2978 { objc_inherit_code = CLASS_METHOD_DECL; }
2980 { objc_inherit_code = INSTANCE_METHOD_DECL; }
2986 objc_pq_context = 1;
2987 if (!objc_implementation_context)
2988 fatal_error ("method definition not in class context");
2992 objc_pq_context = 0;
2993 if (objc_inherit_code == CLASS_METHOD_DECL)
2994 add_class_method (objc_implementation_context, $3);
2996 add_instance_method (objc_implementation_context, $3);
2997 start_method_def ($3);
2998 objc_method_context = $3;
3002 continue_method_def ();
3006 finish_method_def ();
3007 objc_method_context = NULL_TREE;
3011 /* the reason for the strange actions in this rule
3012 is so that notype_initdecls when reached via datadef
3013 can find a valid list of type and sc specs in $0. */
3017 | {$<ttype>$ = NULL_TREE; } methodprotolist2
3020 methodprotolist2: /* eliminates a shift/reduce conflict */
3023 | methodprotolist2 methodproto
3024 | methodprotolist2 {$<ttype>$ = NULL_TREE; } datadef
3035 /* Remember protocol qualifiers in prototypes. */
3036 objc_pq_context = 1;
3040 /* Forget protocol qualifiers here. */
3041 objc_pq_context = 0;
3042 if (objc_inherit_code == CLASS_METHOD_DECL)
3043 add_class_method (objc_interface_context, $3);
3045 add_instance_method (objc_interface_context, $3);
3051 '(' typename ')' unaryselector
3053 $$ = build_method_decl (objc_inherit_code, $2, $4, NULL_TREE);
3058 $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, NULL_TREE);
3061 | '(' typename ')' keywordselector optparmlist
3063 $$ = build_method_decl (objc_inherit_code, $2, $4, $5);
3066 | keywordselector optparmlist
3068 $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, $2);
3072 /* "optarglist" assumes that start_method_def has already been called...
3073 if it is not, the "xdecls" will not be placed in the proper scope */
3080 /* to get around the following situation: "int foo (int a) int b; {}" that
3081 is synthesized when parsing "- a:a b:b; id c; id d; { ... }" */
3096 declspecs_ts setspecs myparms ';'
3097 { current_declspecs = TREE_VALUE (declspec_stack);
3098 prefix_attributes = TREE_PURPOSE (declspec_stack);
3099 declspec_stack = TREE_CHAIN (declspec_stack); }
3101 { shadow_tag ($1); }
3102 | declspecs_nots ';'
3103 { pedwarn ("empty declaration"); }
3108 { push_parm_decl ($1); }
3109 | myparms ',' myparm
3110 { push_parm_decl ($3); }
3113 /* A single parameter declaration or parameter type name,
3114 as found in a parmlist. DOES NOT ALLOW AN INITIALIZER OR ASMSPEC */
3117 parm_declarator maybe_attribute
3118 { $$ = build_tree_list (build_tree_list (current_declspecs,
3120 build_tree_list (prefix_attributes,
3122 | notype_declarator maybe_attribute
3123 { $$ = build_tree_list (build_tree_list (current_declspecs,
3125 build_tree_list (prefix_attributes,
3127 | absdcl_maybe_attribute
3138 /* oh what a kludge! */
3139 $$ = objc_ellipsis_node;
3147 /* returns a tree list node generated by get_parm_info */
3160 | keywordselector keyworddecl
3162 $$ = chainon ($1, $2);
3174 ENUM | STRUCT | UNION | IF | ELSE | WHILE | DO | FOR
3175 | SWITCH | CASE | DEFAULT | BREAK | CONTINUE | RETURN
3176 | GOTO | ASM_KEYWORD | SIZEOF | TYPEOF | ALIGNOF
3177 | TYPESPEC | TYPE_QUAL
3181 selector ':' '(' typename ')' identifier
3183 $$ = build_keyword_decl ($1, $4, $6);
3186 | selector ':' identifier
3188 $$ = build_keyword_decl ($1, NULL_TREE, $3);
3191 | ':' '(' typename ')' identifier
3193 $$ = build_keyword_decl (NULL_TREE, $3, $5);
3198 $$ = build_keyword_decl (NULL_TREE, NULL_TREE, $2);
3209 | keywordarglist keywordarg
3211 $$ = chainon ($1, $2);
3219 if (TREE_CHAIN ($1) == NULL_TREE)
3220 /* just return the expr., remove a level of indirection */
3221 $$ = TREE_VALUE ($1);
3223 /* we have a comma expr., we will collapse later */
3229 selector ':' keywordexpr
3231 $$ = build_tree_list ($1, $3);
3235 $$ = build_tree_list (NULL_TREE, $2);
3243 $$ = get_class_reference ($1);
3249 { objc_receiver_context = 1; }
3251 { objc_receiver_context = 0; }
3254 $$ = build_tree_list ($3, $5);
3265 | keywordnamelist keywordname
3267 $$ = chainon ($1, $2);
3274 $$ = build_tree_list ($1, NULL_TREE);
3278 $$ = build_tree_list (NULL_TREE, NULL_TREE);
3283 SELECTOR '(' selectorarg ')'
3290 PROTOCOL '(' identifier ')'
3296 /* extension to support C-structures in the archiver */
3299 ENCODE '(' typename ')'
3301 $$ = groktypename ($3);
3308 /* yylex() is a thin wrapper around c_lex(), all it does is translate
3309 cpplib.h's token codes into yacc's token codes. */
3311 static enum cpp_ttype last_token;
3313 /* The reserved keyword table. */
3317 ENUM_BITFIELD(rid) rid : 16;
3318 unsigned int disable : 16;
3321 /* Disable mask. Keywords are disabled if (reswords[i].disable & mask) is
3323 #define D_TRAD 0x01 /* not in traditional C */
3324 #define D_C89 0x02 /* not in C89 */
3325 #define D_EXT 0x04 /* GCC extension */
3326 #define D_EXT89 0x08 /* GCC extension incorporated in C99 */
3327 #define D_OBJC 0x10 /* Objective C only */
3329 static const struct resword reswords[] =
3331 { "_Bool", RID_BOOL, 0 },
3332 { "_Complex", RID_COMPLEX, 0 },
3333 { "__FUNCTION__", RID_FUNCTION_NAME, 0 },
3334 { "__PRETTY_FUNCTION__", RID_PRETTY_FUNCTION_NAME, 0 },
3335 { "__alignof", RID_ALIGNOF, 0 },
3336 { "__alignof__", RID_ALIGNOF, 0 },
3337 { "__asm", RID_ASM, 0 },
3338 { "__asm__", RID_ASM, 0 },
3339 { "__attribute", RID_ATTRIBUTE, 0 },
3340 { "__attribute__", RID_ATTRIBUTE, 0 },
3341 { "__bounded", RID_BOUNDED, 0 },
3342 { "__bounded__", RID_BOUNDED, 0 },
3343 { "__builtin_va_arg", RID_VA_ARG, 0 },
3344 { "__complex", RID_COMPLEX, 0 },
3345 { "__complex__", RID_COMPLEX, 0 },
3346 { "__const", RID_CONST, 0 },
3347 { "__const__", RID_CONST, 0 },
3348 { "__extension__", RID_EXTENSION, 0 },
3349 { "__func__", RID_C99_FUNCTION_NAME, 0 },
3350 { "__imag", RID_IMAGPART, 0 },
3351 { "__imag__", RID_IMAGPART, 0 },
3352 { "__inline", RID_INLINE, 0 },
3353 { "__inline__", RID_INLINE, 0 },
3354 { "__label__", RID_LABEL, 0 },
3355 { "__ptrbase", RID_PTRBASE, 0 },
3356 { "__ptrbase__", RID_PTRBASE, 0 },
3357 { "__ptrextent", RID_PTREXTENT, 0 },
3358 { "__ptrextent__", RID_PTREXTENT, 0 },
3359 { "__ptrvalue", RID_PTRVALUE, 0 },
3360 { "__ptrvalue__", RID_PTRVALUE, 0 },
3361 { "__real", RID_REALPART, 0 },
3362 { "__real__", RID_REALPART, 0 },
3363 { "__restrict", RID_RESTRICT, 0 },
3364 { "__restrict__", RID_RESTRICT, 0 },
3365 { "__signed", RID_SIGNED, 0 },
3366 { "__signed__", RID_SIGNED, 0 },
3367 { "__typeof", RID_TYPEOF, 0 },
3368 { "__typeof__", RID_TYPEOF, 0 },
3369 { "__unbounded", RID_UNBOUNDED, 0 },
3370 { "__unbounded__", RID_UNBOUNDED, 0 },
3371 { "__volatile", RID_VOLATILE, 0 },
3372 { "__volatile__", RID_VOLATILE, 0 },
3373 { "asm", RID_ASM, D_EXT },
3374 { "auto", RID_AUTO, 0 },
3375 { "break", RID_BREAK, 0 },
3376 { "case", RID_CASE, 0 },
3377 { "char", RID_CHAR, 0 },
3378 { "const", RID_CONST, D_TRAD },
3379 { "continue", RID_CONTINUE, 0 },
3380 { "default", RID_DEFAULT, 0 },
3381 { "do", RID_DO, 0 },
3382 { "double", RID_DOUBLE, 0 },
3383 { "else", RID_ELSE, 0 },
3384 { "enum", RID_ENUM, 0 },
3385 { "extern", RID_EXTERN, 0 },
3386 { "float", RID_FLOAT, 0 },
3387 { "for", RID_FOR, 0 },
3388 { "goto", RID_GOTO, 0 },
3389 { "if", RID_IF, 0 },
3390 { "inline", RID_INLINE, D_TRAD|D_EXT89 },
3391 { "int", RID_INT, 0 },
3392 { "long", RID_LONG, 0 },
3393 { "register", RID_REGISTER, 0 },
3394 { "restrict", RID_RESTRICT, D_TRAD|D_C89 },
3395 { "return", RID_RETURN, 0 },
3396 { "short", RID_SHORT, 0 },
3397 { "signed", RID_SIGNED, D_TRAD },
3398 { "sizeof", RID_SIZEOF, 0 },
3399 { "static", RID_STATIC, 0 },
3400 { "struct", RID_STRUCT, 0 },
3401 { "switch", RID_SWITCH, 0 },
3402 { "typedef", RID_TYPEDEF, 0 },
3403 { "typeof", RID_TYPEOF, D_TRAD|D_EXT },
3404 { "union", RID_UNION, 0 },
3405 { "unsigned", RID_UNSIGNED, 0 },
3406 { "void", RID_VOID, 0 },
3407 { "volatile", RID_VOLATILE, D_TRAD },
3408 { "while", RID_WHILE, 0 },
3410 { "@class", RID_AT_CLASS, D_OBJC },
3411 { "@compatibility_alias", RID_AT_ALIAS, D_OBJC },
3412 { "@defs", RID_AT_DEFS, D_OBJC },
3413 { "@encode", RID_AT_ENCODE, D_OBJC },
3414 { "@end", RID_AT_END, D_OBJC },
3415 { "@implementation", RID_AT_IMPLEMENTATION, D_OBJC },
3416 { "@interface", RID_AT_INTERFACE, D_OBJC },
3417 { "@private", RID_AT_PRIVATE, D_OBJC },
3418 { "@protected", RID_AT_PROTECTED, D_OBJC },
3419 { "@protocol", RID_AT_PROTOCOL, D_OBJC },
3420 { "@public", RID_AT_PUBLIC, D_OBJC },
3421 { "@selector", RID_AT_SELECTOR, D_OBJC },
3422 { "id", RID_ID, D_OBJC },
3423 { "bycopy", RID_BYCOPY, D_OBJC },
3424 { "byref", RID_BYREF, D_OBJC },
3425 { "in", RID_IN, D_OBJC },
3426 { "inout", RID_INOUT, D_OBJC },
3427 { "oneway", RID_ONEWAY, D_OBJC },
3428 { "out", RID_OUT, D_OBJC },
3431 #define N_reswords (sizeof reswords / sizeof (struct resword))
3433 /* Table mapping from RID_* constants to yacc token numbers.
3434 Unfortunately we have to have entries for all the keywords in all
3436 static const short rid_to_yy[RID_MAX] =
3438 /* RID_STATIC */ SCSPEC,
3439 /* RID_UNSIGNED */ TYPESPEC,
3440 /* RID_LONG */ TYPESPEC,
3441 /* RID_CONST */ TYPE_QUAL,
3442 /* RID_EXTERN */ SCSPEC,
3443 /* RID_REGISTER */ SCSPEC,
3444 /* RID_TYPEDEF */ SCSPEC,
3445 /* RID_SHORT */ TYPESPEC,
3446 /* RID_INLINE */ SCSPEC,
3447 /* RID_VOLATILE */ TYPE_QUAL,
3448 /* RID_SIGNED */ TYPESPEC,
3449 /* RID_AUTO */ SCSPEC,
3450 /* RID_RESTRICT */ TYPE_QUAL,
3453 /* RID_BOUNDED */ TYPE_QUAL,
3454 /* RID_UNBOUNDED */ TYPE_QUAL,
3455 /* RID_COMPLEX */ TYPESPEC,
3459 /* RID_VIRTUAL */ 0,
3460 /* RID_EXPLICIT */ 0,
3462 /* RID_MUTABLE */ 0,
3465 /* RID_IN */ TYPE_QUAL,
3466 /* RID_OUT */ TYPE_QUAL,
3467 /* RID_INOUT */ TYPE_QUAL,
3468 /* RID_BYCOPY */ TYPE_QUAL,
3469 /* RID_BYREF */ TYPE_QUAL,
3470 /* RID_ONEWAY */ TYPE_QUAL,
3473 /* RID_INT */ TYPESPEC,
3474 /* RID_CHAR */ TYPESPEC,
3475 /* RID_FLOAT */ TYPESPEC,
3476 /* RID_DOUBLE */ TYPESPEC,
3477 /* RID_VOID */ TYPESPEC,
3478 /* RID_ENUM */ ENUM,
3479 /* RID_STRUCT */ STRUCT,
3480 /* RID_UNION */ UNION,
3482 /* RID_ELSE */ ELSE,
3483 /* RID_WHILE */ WHILE,
3486 /* RID_SWITCH */ SWITCH,
3487 /* RID_CASE */ CASE,
3488 /* RID_DEFAULT */ DEFAULT,
3489 /* RID_BREAK */ BREAK,
3490 /* RID_CONTINUE */ CONTINUE,
3491 /* RID_RETURN */ RETURN,
3492 /* RID_GOTO */ GOTO,
3493 /* RID_SIZEOF */ SIZEOF,
3496 /* RID_ASM */ ASM_KEYWORD,
3497 /* RID_TYPEOF */ TYPEOF,
3498 /* RID_ALIGNOF */ ALIGNOF,
3499 /* RID_ATTRIBUTE */ ATTRIBUTE,
3500 /* RID_VA_ARG */ VA_ARG,
3501 /* RID_EXTENSION */ EXTENSION,
3502 /* RID_IMAGPART */ IMAGPART,
3503 /* RID_REALPART */ REALPART,
3504 /* RID_LABEL */ LABEL,
3505 /* RID_PTRBASE */ PTR_BASE,
3506 /* RID_PTREXTENT */ PTR_EXTENT,
3507 /* RID_PTRVALUE */ PTR_VALUE,
3509 /* RID_FUNCTION_NAME */ STRING_FUNC_NAME,
3510 /* RID_PRETTY_FUNCTION_NAME */ STRING_FUNC_NAME,
3511 /* RID_C99_FUNCTION_NAME */ VAR_FUNC_NAME,
3514 /* RID_BOOL */ TYPESPEC,
3518 /* RID_PRIVATE */ 0,
3519 /* RID_PROTECTED */ 0,
3520 /* RID_TEMPLATE */ 0,
3525 /* RID_NAMESPACE */ 0,
3527 /* RID_OPERATOR */ 0,
3532 /* RID_TYPENAME */ 0,
3537 /* RID_CONSTCAST */ 0,
3538 /* RID_DYNCAST */ 0,
3539 /* RID_REINTCAST */ 0,
3540 /* RID_STATCAST */ 0,
3542 /* alternate spellings */
3556 /* RID_ID */ OBJECTNAME,
3557 /* RID_AT_ENCODE */ ENCODE,
3558 /* RID_AT_END */ END,
3559 /* RID_AT_CLASS */ CLASS,
3560 /* RID_AT_ALIAS */ ALIAS,
3561 /* RID_AT_DEFS */ DEFS,
3562 /* RID_AT_PRIVATE */ PRIVATE,
3563 /* RID_AT_PROTECTED */ PROTECTED,
3564 /* RID_AT_PUBLIC */ PUBLIC,
3565 /* RID_AT_PROTOCOL */ PROTOCOL,
3566 /* RID_AT_SELECTOR */ SELECTOR,
3567 /* RID_AT_INTERFACE */ INTERFACE,
3568 /* RID_AT_IMPLEMENTATION */ IMPLEMENTATION
3572 /* Lookup table for ObjC keywords beginning with '@'. Crude but
3573 hopefully effective. */
3574 #define N_at_reswords ((int) RID_AT_IMPLEMENTATION - (int)RID_AT_ENCODE + 1)
3575 static tree objc_rid_sans_at[N_at_reswords];
3583 int mask = (flag_isoc99 ? 0 : D_C89)
3584 | (flag_traditional ? D_TRAD : 0)
3585 | (flag_no_asm ? (flag_isoc99 ? D_EXT : D_EXT|D_EXT89) : 0);
3587 if (c_language != clk_objective_c)
3590 /* It is not necessary to register ridpointers as a GC root, because
3591 all the trees it points to are permanently interned in the
3592 get_identifier hash anyway. */
3593 ridpointers = (tree *) xcalloc ((int) RID_MAX, sizeof (tree));
3594 for (i = 0; i < N_reswords; i++)
3596 /* If a keyword is disabled, do not enter it into the table
3597 and so create a canonical spelling that isn't a keyword. */
3598 if (reswords[i].disable & mask)
3601 id = get_identifier (reswords[i].word);
3602 C_RID_CODE (id) = reswords[i].rid;
3603 C_IS_RESERVED_WORD (id) = 1;
3604 ridpointers [(int) reswords[i].rid] = id;
3607 /* Enter ObjC @-prefixed keywords into the "sans" table
3608 _without_ their leading at-sign. Again, all these
3609 identifiers are reachable by the get_identifer table, so it's
3610 not necessary to make objc_rid_sans_at a GC root. */
3611 if (reswords[i].word[0] == '@')
3612 objc_rid_sans_at[(int) reswords[i].rid - (int) RID_AT_ENCODE]
3613 = get_identifier (reswords[i].word + 1);
3619 init_parse (filename)
3620 const char *filename;
3622 add_c_tree_codes ();
3624 /* Make identifier nodes long enough for the language-specific slots. */
3625 set_identifier_size (sizeof (struct lang_identifier));
3630 return init_c_lex (filename);
3636 cpp_finish (parse_in);
3637 /* Call to cpp_destroy () omitted for performance reasons. */
3638 errorcount += cpp_errors (parse_in);
3641 #define NAME(type) cpp_type2name (type)
3647 const char *string = _(msgid);
3649 if (last_token == CPP_EOF)
3650 error ("%s at end of input", string);
3651 else if (last_token == CPP_CHAR || last_token == CPP_WCHAR)
3653 unsigned int val = TREE_INT_CST_LOW (yylval.ttype);
3654 const char *ell = (last_token == CPP_CHAR) ? "" : "L";
3655 if (val <= UCHAR_MAX && ISGRAPH (val))
3656 error ("%s before %s'%c'", string, ell, val);
3658 error ("%s before %s'\\x%x'", string, ell, val);
3660 else if (last_token == CPP_STRING
3661 || last_token == CPP_WSTRING)
3662 error ("%s before string constant", string);
3663 else if (last_token == CPP_NUMBER
3664 || last_token == CPP_INT
3665 || last_token == CPP_FLOAT)
3666 error ("%s before numeric constant", string);
3667 else if (last_token == CPP_NAME)
3668 error ("%s before \"%s\"", string, IDENTIFIER_POINTER (yylval.ttype));
3670 error ("%s before '%s' token", string, NAME(last_token));
3678 if (C_IS_RESERVED_WORD (yylval.ttype))
3680 enum rid rid_code = C_RID_CODE (yylval.ttype);
3683 if (!((unsigned int) rid_code - (unsigned int) RID_FIRST_PQ < 6)
3687 int yycode = rid_to_yy[(int) rid_code];
3688 if (yycode == STRING_FUNC_NAME)
3690 /* __FUNCTION__ and __PRETTY_FUNCTION__ get converted
3691 to string constants. */
3692 const char *name = fname_string (rid_code);
3694 yylval.ttype = build_string (strlen (name) + 1, name);
3695 last_token = CPP_STRING; /* so yyerror won't choke */
3699 /* Return the canonical spelling for this keyword. */
3700 yylval.ttype = ridpointers[(int) rid_code];
3705 decl = lookup_name (yylval.ttype);
3708 if (TREE_CODE (decl) == TYPE_DECL)
3714 tree objc_interface_decl = is_class_name (yylval.ttype);
3716 if (objc_interface_decl)
3718 yylval.ttype = objc_interface_decl;
3732 last_token = c_lex (&yylval.ttype);
3738 case CPP_EQ: return '=';
3739 case CPP_NOT: return '!';
3740 case CPP_GREATER: yylval.code = GT_EXPR; return ARITHCOMPARE;
3741 case CPP_LESS: yylval.code = LT_EXPR; return ARITHCOMPARE;
3742 case CPP_PLUS: yylval.code = PLUS_EXPR; return '+';
3743 case CPP_MINUS: yylval.code = MINUS_EXPR; return '-';
3744 case CPP_MULT: yylval.code = MULT_EXPR; return '*';
3745 case CPP_DIV: yylval.code = TRUNC_DIV_EXPR; return '/';
3746 case CPP_MOD: yylval.code = TRUNC_MOD_EXPR; return '%';
3747 case CPP_AND: yylval.code = BIT_AND_EXPR; return '&';
3748 case CPP_OR: yylval.code = BIT_IOR_EXPR; return '|';
3749 case CPP_XOR: yylval.code = BIT_XOR_EXPR; return '^';
3750 case CPP_RSHIFT: yylval.code = RSHIFT_EXPR; return RSHIFT;
3751 case CPP_LSHIFT: yylval.code = LSHIFT_EXPR; return LSHIFT;
3753 case CPP_COMPL: return '~';
3754 case CPP_AND_AND: return ANDAND;
3755 case CPP_OR_OR: return OROR;
3756 case CPP_QUERY: return '?';
3757 case CPP_COLON: return ':';
3758 case CPP_COMMA: return ',';
3759 case CPP_OPEN_PAREN: return '(';
3760 case CPP_CLOSE_PAREN: return ')';
3761 case CPP_EQ_EQ: yylval.code = EQ_EXPR; return EQCOMPARE;
3762 case CPP_NOT_EQ: yylval.code = NE_EXPR; return EQCOMPARE;
3763 case CPP_GREATER_EQ:yylval.code = GE_EXPR; return ARITHCOMPARE;
3764 case CPP_LESS_EQ: yylval.code = LE_EXPR; return ARITHCOMPARE;
3766 case CPP_PLUS_EQ: yylval.code = PLUS_EXPR; return ASSIGN;
3767 case CPP_MINUS_EQ: yylval.code = MINUS_EXPR; return ASSIGN;
3768 case CPP_MULT_EQ: yylval.code = MULT_EXPR; return ASSIGN;
3769 case CPP_DIV_EQ: yylval.code = TRUNC_DIV_EXPR; return ASSIGN;
3770 case CPP_MOD_EQ: yylval.code = TRUNC_MOD_EXPR; return ASSIGN;
3771 case CPP_AND_EQ: yylval.code = BIT_AND_EXPR; return ASSIGN;
3772 case CPP_OR_EQ: yylval.code = BIT_IOR_EXPR; return ASSIGN;
3773 case CPP_XOR_EQ: yylval.code = BIT_XOR_EXPR; return ASSIGN;
3774 case CPP_RSHIFT_EQ: yylval.code = RSHIFT_EXPR; return ASSIGN;
3775 case CPP_LSHIFT_EQ: yylval.code = LSHIFT_EXPR; return ASSIGN;
3777 case CPP_OPEN_SQUARE: return '[';
3778 case CPP_CLOSE_SQUARE: return ']';
3779 case CPP_OPEN_BRACE: return '{';
3780 case CPP_CLOSE_BRACE: return '}';
3781 case CPP_SEMICOLON: return ';';
3782 case CPP_ELLIPSIS: return ELLIPSIS;
3784 case CPP_PLUS_PLUS: return PLUSPLUS;
3785 case CPP_MINUS_MINUS: return MINUSMINUS;
3786 case CPP_DEREF: return POINTSAT;
3787 case CPP_DOT: return '.';
3790 if (cpp_pop_buffer (parse_in) == 0)
3795 return yylexname ();
3808 /* This token is Objective-C specific. It gives the next
3809 token special significance. */
3812 last_token = c_lex (&yylval.ttype);
3813 if (last_token == CPP_STRING)
3815 else if (last_token == CPP_NAME)
3818 for (i = 0; i < N_at_reswords; i++)
3819 if (objc_rid_sans_at[i] == yylval.ttype)
3821 int rid_code = i + (int) RID_AT_ENCODE;
3822 yylval.ttype = ridpointers[rid_code];
3823 return rid_to_yy[rid_code];
3826 error ("syntax error at '@' token");
3829 /* These tokens are C++ specific (and will not be generated
3830 in C mode, but let's be cautious). */
3832 case CPP_DEREF_STAR:
3838 /* These tokens should not survive translation phase 4. */
3841 error ("syntax error at '%s' token", NAME(last_token));
3854 timevar_push (TV_LEX);
3856 timevar_pop (TV_LEX);
3860 /* Sets the value of the 'yydebug' variable to VALUE.
3861 This is a function so we don't have to have YYDEBUG defined
3862 in order to build the compiler. */
3871 warning ("YYDEBUG not defined.");
3875 /* Function used when yydebug is set, to print a token in more detail. */
3878 yyprint (file, yychar, yyl)
3885 fprintf (file, " [%s]", NAME(last_token));
3895 if (IDENTIFIER_POINTER (t))
3896 fprintf (file, " `%s'", IDENTIFIER_POINTER (t));
3900 fprintf (file, " %s", GET_MODE_NAME (TYPE_MODE (TREE_TYPE (t))));
3901 if (TREE_CODE (t) == INTEGER_CST)
3903 #if HOST_BITS_PER_WIDE_INT == 64
3904 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
3907 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
3914 #if HOST_BITS_PER_WIDE_INT != HOST_BITS_PER_INT
3920 TREE_INT_CST_HIGH (t), TREE_INT_CST_LOW (t));
3925 /* This is not the ideal place to put these, but we have to get them out
3926 of c-lex.c because cp/lex.c has its own versions. */
3928 /* Return something to represent absolute declarators containing a *.
3929 TARGET is the absolute declarator that the * contains.
3930 TYPE_QUALS is a list of modifiers such as const or volatile
3931 to apply to the pointer type, represented as identifiers.
3933 We return an INDIRECT_REF whose "contents" are TARGET
3934 and whose type is the modifier list. */
3937 make_pointer_declarator (type_quals, target)
3938 tree type_quals, target;
3940 return build1 (INDIRECT_REF, type_quals, target);