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. */
55 #ifdef MULTIBYTE_CHARS
63 /* Since parsers are distinct for each language, put the language string
66 const char * const language_string = "GNU Objective-C";
69 const char * const language_string = "GNU C";
72 /* Like YYERROR but do call yyerror. */
73 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
75 /* Cause the "yydebug" variable to be defined. */
78 /* Rename the "yyparse" function so that we can override it elsewhere. */
79 #define yyparse yyparse_1
84 %union {long itype; tree ttype; enum tree_code code;
85 const char *filename; int lineno; }
87 /* All identifiers that are not reserved words
88 and are not declared typedefs in the current block */
91 /* All identifiers that are declared typedefs in the current block.
92 In some contexts, they are treated just like IDENTIFIER,
93 but they can also serve as typespecs in declarations. */
96 /* Reserved words that specify storage class.
97 yylval contains an IDENTIFIER_NODE which indicates which one. */
100 /* Reserved words that specify type.
101 yylval contains an IDENTIFIER_NODE which indicates which one. */
104 /* Reserved words that qualify type: "const", "volatile", or "restrict".
105 yylval contains an IDENTIFIER_NODE which indicates which one. */
108 /* Character or numeric constants.
109 yylval is the node for the constant. */
112 /* String constants in raw form.
113 yylval is a STRING_CST node. */
116 /* "...", used for functions with variable arglists. */
119 /* the reserved words */
120 /* SCO include files test "ASM", so use something else. */
121 %token SIZEOF ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
122 %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD TYPEOF ALIGNOF
123 %token ATTRIBUTE EXTENSION LABEL
124 %token REALPART IMAGPART VA_ARG
125 %token PTR_VALUE PTR_BASE PTR_EXTENT
127 /* Add precedence rules to solve dangling else s/r conflict */
131 /* Define the operator tokens and their precedences.
132 The value is an integer because, if used, it is the tree code
133 to use in the expression made from the operator. */
135 %right <code> ASSIGN '='
136 %right <code> '?' ':'
142 %left <code> EQCOMPARE
143 %left <code> ARITHCOMPARE
144 %left <code> LSHIFT RSHIFT
146 %left <code> '*' '/' '%'
147 %right <code> UNARY PLUSPLUS MINUSMINUS
149 %left <code> POINTSAT '.' '(' '['
151 /* The Objective-C keywords. These are included in C and in
152 Objective C, so that the token codes are the same in both. */
153 %token INTERFACE IMPLEMENTATION END SELECTOR DEFS ENCODE
154 %token CLASSNAME PUBLIC PRIVATE PROTECTED PROTOCOL OBJECTNAME CLASS ALIAS
156 /* Objective-C string constants in raw form.
157 yylval is an STRING_CST node. */
162 %type <ttype> ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
163 %type <ttype> BREAK CONTINUE RETURN GOTO ASM_KEYWORD SIZEOF TYPEOF ALIGNOF
165 %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist exprlist
166 %type <ttype> expr_no_commas cast_expr unary_expr primary string STRING
167 %type <ttype> typed_declspecs reserved_declspecs
168 %type <ttype> typed_typespecs reserved_typespecquals
169 %type <ttype> declmods typespec typespecqual_reserved
170 %type <ttype> typed_declspecs_no_prefix_attr reserved_declspecs_no_prefix_attr
171 %type <ttype> declmods_no_prefix_attr
172 %type <ttype> SCSPEC TYPESPEC TYPE_QUAL nonempty_type_quals maybe_type_qual
173 %type <ttype> initdecls notype_initdecls initdcl notype_initdcl
174 %type <ttype> init maybeasm
175 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
176 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
177 %type <ttype> any_word extension
179 %type <ttype> compstmt compstmt_start compstmt_nostart compstmt_primary_start
180 %type <ttype> do_stmt_start poplevel stmt label
182 %type <ttype> c99_block_start c99_block_end
183 %type <ttype> declarator
184 %type <ttype> notype_declarator after_type_declarator
185 %type <ttype> parm_declarator
187 %type <ttype> structsp component_decl_list component_decl_list2
188 %type <ttype> component_decl components component_declarator
189 %type <ttype> enumlist enumerator
190 %type <ttype> struct_head union_head enum_head
191 %type <ttype> typename absdcl absdcl1 type_quals
192 %type <ttype> xexpr parms parm identifiers
194 %type <ttype> parmlist parmlist_1 parmlist_2
195 %type <ttype> parmlist_or_identifiers parmlist_or_identifiers_1
196 %type <ttype> identifiers_or_typenames
198 %type <itype> setspecs
200 %type <filename> save_filename
201 %type <lineno> save_lineno
204 /* the Objective-C nonterminals */
206 %type <ttype> ivar_decl_list ivar_decls ivar_decl ivars ivar_declarator
207 %type <ttype> methoddecl unaryselector keywordselector selector
208 %type <ttype> keyworddecl receiver objcmessageexpr messageargs
209 %type <ttype> keywordexpr keywordarglist keywordarg
210 %type <ttype> myparms myparm optparmlist reservedwords objcselectorexpr
211 %type <ttype> selectorarg keywordnamelist keywordname objcencodeexpr
212 %type <ttype> objc_string non_empty_protocolrefs protocolrefs identifier_list objcprotocolexpr
214 %type <ttype> CLASSNAME OBJC_STRING OBJECTNAME
218 /* Number of statements (loosely speaking) and compound statements
220 static int stmt_count;
221 static int compstmt_count;
223 /* Input file and line number of the end of the body of last simple_if;
224 used by the stmt-rule immediately after simple_if returns. */
225 static const char *if_stmt_file;
226 static int if_stmt_line;
228 /* List of types and structure classes of the current declaration. */
229 static tree current_declspecs = NULL_TREE;
230 static tree prefix_attributes = NULL_TREE;
232 /* Stack of saved values of current_declspecs and prefix_attributes. */
233 static tree declspec_stack;
235 /* For __extension__, save/restore the warning flags which are
236 controlled by __extension__. */
237 #define SAVE_WARN_FLAGS() \
238 size_int (pedantic | (warn_pointer_arith << 1))
239 #define RESTORE_WARN_FLAGS(tval) \
241 int val = tree_low_cst (tval, 0); \
242 pedantic = val & 1; \
243 warn_pointer_arith = (val >> 1) & 1; \
247 /* Objective-C specific information */
249 tree objc_interface_context;
250 tree objc_implementation_context;
251 tree objc_method_context;
252 tree objc_ivar_chain;
253 tree objc_ivar_context;
254 enum tree_code objc_inherit_code;
255 int objc_receiver_context;
256 int objc_public_flag;
260 /* Tell yyparse how to print a token's value, if yydebug is set. */
262 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
264 static void yyprint PARAMS ((FILE *, int, YYSTYPE));
265 static void yyerror PARAMS ((const char *));
266 static int yylexname PARAMS ((void));
267 static inline int _yylex PARAMS ((void));
268 static int yylex PARAMS ((void));
269 static void init_reswords PARAMS ((void));
271 /* Add GC roots for variables local to this file. */
275 ggc_add_tree_root (&declspec_stack, 1);
276 ggc_add_tree_root (¤t_declspecs, 1);
277 ggc_add_tree_root (&prefix_attributes, 1);
279 ggc_add_tree_root (&objc_interface_context, 1);
280 ggc_add_tree_root (&objc_implementation_context, 1);
281 ggc_add_tree_root (&objc_method_context, 1);
282 ggc_add_tree_root (&objc_ivar_chain, 1);
283 ggc_add_tree_root (&objc_ivar_context, 1);
292 pedwarn ("ISO C forbids an empty source file");
297 /* In case there were missing closebraces,
298 get us back to the global binding level. */
299 while (! global_bindings_p ())
305 /* the reason for the strange actions in this rule
306 is so that notype_initdecls when reached via datadef
307 can find a valid list of type and sc specs in $0. */
310 {$<ttype>$ = NULL_TREE; } extdef
311 | extdefs {$<ttype>$ = NULL_TREE; ggc_collect(); } extdef
320 | ASM_KEYWORD '(' expr ')' ';'
322 if ((TREE_CODE ($3) == ADDR_EXPR
323 && TREE_CODE (TREE_OPERAND ($3, 0)) == STRING_CST)
324 || TREE_CODE ($3) == STRING_CST)
327 error ("argument of `asm' is not a constant string"); }
329 { RESTORE_WARN_FLAGS ($1); }
333 setspecs notype_initdecls ';'
335 error ("ISO C forbids data definition with no type or storage class");
336 else if (!flag_traditional)
337 warning ("data definition has no type or storage class");
339 current_declspecs = TREE_VALUE (declspec_stack);
340 prefix_attributes = TREE_PURPOSE (declspec_stack);
341 declspec_stack = TREE_CHAIN (declspec_stack); }
342 | declmods setspecs notype_initdecls ';'
343 { current_declspecs = TREE_VALUE (declspec_stack);
344 prefix_attributes = TREE_PURPOSE (declspec_stack);
345 declspec_stack = TREE_CHAIN (declspec_stack); }
346 | typed_declspecs setspecs initdecls ';'
347 { current_declspecs = TREE_VALUE (declspec_stack);
348 prefix_attributes = TREE_PURPOSE (declspec_stack);
349 declspec_stack = TREE_CHAIN (declspec_stack); }
351 { pedwarn ("empty declaration"); }
352 | typed_declspecs ';'
358 pedwarn ("ISO C does not allow extra `;' outside of a function"); }
362 typed_declspecs setspecs declarator
363 { if (! start_function (current_declspecs, $3,
364 prefix_attributes, NULL_TREE))
368 { store_parm_decls (); }
369 save_filename save_lineno compstmt_or_error
370 { DECL_SOURCE_FILE (current_function_decl) = $7;
371 DECL_SOURCE_LINE (current_function_decl) = $8;
373 current_declspecs = TREE_VALUE (declspec_stack);
374 prefix_attributes = TREE_PURPOSE (declspec_stack);
375 declspec_stack = TREE_CHAIN (declspec_stack); }
376 | typed_declspecs setspecs declarator error
377 { current_declspecs = TREE_VALUE (declspec_stack);
378 prefix_attributes = TREE_PURPOSE (declspec_stack);
379 declspec_stack = TREE_CHAIN (declspec_stack); }
380 | declmods setspecs notype_declarator
381 { if (! start_function (current_declspecs, $3,
382 prefix_attributes, NULL_TREE))
386 { store_parm_decls (); }
387 save_filename save_lineno compstmt_or_error
388 { DECL_SOURCE_FILE (current_function_decl) = $7;
389 DECL_SOURCE_LINE (current_function_decl) = $8;
391 current_declspecs = TREE_VALUE (declspec_stack);
392 prefix_attributes = TREE_PURPOSE (declspec_stack);
393 declspec_stack = TREE_CHAIN (declspec_stack); }
394 | declmods setspecs notype_declarator error
395 { current_declspecs = TREE_VALUE (declspec_stack);
396 prefix_attributes = TREE_PURPOSE (declspec_stack);
397 declspec_stack = TREE_CHAIN (declspec_stack); }
398 | setspecs notype_declarator
399 { if (! start_function (NULL_TREE, $2,
400 prefix_attributes, NULL_TREE))
404 { store_parm_decls (); }
405 save_filename save_lineno compstmt_or_error
406 { DECL_SOURCE_FILE (current_function_decl) = $6;
407 DECL_SOURCE_LINE (current_function_decl) = $7;
409 current_declspecs = TREE_VALUE (declspec_stack);
410 prefix_attributes = TREE_PURPOSE (declspec_stack);
411 declspec_stack = TREE_CHAIN (declspec_stack); }
412 | setspecs notype_declarator error
413 { current_declspecs = TREE_VALUE (declspec_stack);
414 prefix_attributes = TREE_PURPOSE (declspec_stack);
415 declspec_stack = TREE_CHAIN (declspec_stack); }
430 { $$ = NEGATE_EXPR; }
434 if (warn_traditional && !in_system_header)
435 warning ("traditional C rejects the unary plus operator");
439 { $$ = PREINCREMENT_EXPR; }
441 { $$ = PREDECREMENT_EXPR; }
443 { $$ = BIT_NOT_EXPR; }
445 { $$ = TRUTH_NOT_EXPR; }
448 expr: nonnull_exprlist
449 { $$ = build_compound_expr ($1); }
460 { $$ = build_tree_list (NULL_TREE, $1); }
461 | nonnull_exprlist ',' expr_no_commas
462 { chainon ($1, build_tree_list (NULL_TREE, $3)); }
467 | '*' cast_expr %prec UNARY
468 { $$ = build_indirect_ref ($2, "unary *"); }
469 /* __extension__ turns off -pedantic for following primary. */
470 | extension cast_expr %prec UNARY
472 RESTORE_WARN_FLAGS ($1); }
473 | unop cast_expr %prec UNARY
474 { $$ = build_unary_op ($1, $2, 0);
475 overflow_warning ($$); }
476 /* Refer to the address of a label as a pointer. */
478 { tree label = lookup_label ($2);
480 pedwarn ("ISO C forbids `&&'");
482 $$ = null_pointer_node;
485 TREE_USED (label) = 1;
486 $$ = build1 (ADDR_EXPR, ptr_type_node, label);
487 TREE_CONSTANT ($$) = 1;
490 /* This seems to be impossible on some machines, so let's turn it off.
491 You can use __builtin_next_arg to find the anonymous stack args.
493 { tree types = TYPE_ARG_TYPES (TREE_TYPE (current_function_decl));
494 $$ = error_mark_node;
495 if (TREE_VALUE (tree_last (types)) == void_type_node)
496 error ("`&...' used in function with fixed number of arguments");
500 pedwarn ("ISO C forbids `&...'");
501 $$ = tree_last (DECL_ARGUMENTS (current_function_decl));
502 $$ = build_unary_op (ADDR_EXPR, $$, 0);
505 | sizeof unary_expr %prec UNARY
507 if (TREE_CODE ($2) == COMPONENT_REF
508 && DECL_C_BIT_FIELD (TREE_OPERAND ($2, 1)))
509 error ("`sizeof' applied to a bit-field");
510 $$ = c_sizeof (TREE_TYPE ($2)); }
511 | sizeof '(' typename ')' %prec HYPERUNARY
513 $$ = c_sizeof (groktypename ($3)); }
514 | alignof unary_expr %prec UNARY
516 $$ = c_alignof_expr ($2); }
517 | alignof '(' typename ')' %prec HYPERUNARY
519 $$ = c_alignof (groktypename ($3)); }
520 | REALPART cast_expr %prec UNARY
521 { $$ = build_unary_op (REALPART_EXPR, $2, 0); }
522 | IMAGPART cast_expr %prec UNARY
523 { $$ = build_unary_op (IMAGPART_EXPR, $2, 0); }
527 SIZEOF { skip_evaluation++; }
531 ALIGNOF { skip_evaluation++; }
536 | '(' typename ')' cast_expr %prec UNARY
538 int SAVED_warn_strict_prototypes = warn_strict_prototypes;
539 /* This avoids warnings about unprototyped casts on
540 integers. E.g. "#define SIG_DFL (void(*)())0". */
541 if (TREE_CODE ($4) == INTEGER_CST)
542 warn_strict_prototypes = 0;
543 type = groktypename ($2);
544 warn_strict_prototypes = SAVED_warn_strict_prototypes;
545 $$ = build_c_cast (type, $4); }
550 | expr_no_commas '+' expr_no_commas
551 { $$ = parser_build_binary_op ($2, $1, $3); }
552 | expr_no_commas '-' expr_no_commas
553 { $$ = parser_build_binary_op ($2, $1, $3); }
554 | expr_no_commas '*' expr_no_commas
555 { $$ = parser_build_binary_op ($2, $1, $3); }
556 | expr_no_commas '/' expr_no_commas
557 { $$ = parser_build_binary_op ($2, $1, $3); }
558 | expr_no_commas '%' expr_no_commas
559 { $$ = parser_build_binary_op ($2, $1, $3); }
560 | expr_no_commas LSHIFT expr_no_commas
561 { $$ = parser_build_binary_op ($2, $1, $3); }
562 | expr_no_commas RSHIFT expr_no_commas
563 { $$ = parser_build_binary_op ($2, $1, $3); }
564 | expr_no_commas ARITHCOMPARE expr_no_commas
565 { $$ = parser_build_binary_op ($2, $1, $3); }
566 | expr_no_commas EQCOMPARE expr_no_commas
567 { $$ = parser_build_binary_op ($2, $1, $3); }
568 | expr_no_commas '&' expr_no_commas
569 { $$ = parser_build_binary_op ($2, $1, $3); }
570 | expr_no_commas '|' expr_no_commas
571 { $$ = parser_build_binary_op ($2, $1, $3); }
572 | expr_no_commas '^' expr_no_commas
573 { $$ = parser_build_binary_op ($2, $1, $3); }
574 | expr_no_commas ANDAND
575 { $1 = truthvalue_conversion (default_conversion ($1));
576 skip_evaluation += $1 == boolean_false_node; }
578 { skip_evaluation -= $1 == boolean_false_node;
579 $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $4); }
580 | expr_no_commas OROR
581 { $1 = truthvalue_conversion (default_conversion ($1));
582 skip_evaluation += $1 == boolean_true_node; }
584 { skip_evaluation -= $1 == boolean_true_node;
585 $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $4); }
587 { $1 = truthvalue_conversion (default_conversion ($1));
588 skip_evaluation += $1 == boolean_false_node; }
590 { skip_evaluation += (($1 == boolean_true_node)
591 - ($1 == boolean_false_node)); }
593 { skip_evaluation -= $1 == boolean_true_node;
594 $$ = build_conditional_expr ($1, $4, $7); }
597 pedwarn ("ISO C forbids omitting the middle term of a ?: expression");
598 /* Make sure first operand is calculated only once. */
599 $<ttype>2 = save_expr ($1);
600 $1 = truthvalue_conversion (default_conversion ($<ttype>2));
601 skip_evaluation += $1 == boolean_true_node; }
603 { skip_evaluation -= $1 == boolean_true_node;
604 $$ = build_conditional_expr ($1, $<ttype>2, $5); }
605 | expr_no_commas '=' expr_no_commas
607 $$ = build_modify_expr ($1, NOP_EXPR, $3);
608 class = TREE_CODE_CLASS (TREE_CODE ($$));
609 if (class == 'e' || class == '1'
610 || class == '2' || class == '<')
611 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR);
613 | expr_no_commas ASSIGN expr_no_commas
615 $$ = build_modify_expr ($1, $2, $3);
616 /* This inhibits warnings in truthvalue_conversion. */
617 class = TREE_CODE_CLASS (TREE_CODE ($$));
618 if (class == 'e' || class == '1'
619 || class == '2' || class == '<')
620 C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK);
627 if (yychar == YYEMPTY)
629 $$ = build_external_ref ($1, yychar == '(');
633 { $$ = combine_strings ($1); }
634 | '(' typename ')' '{'
635 { start_init (NULL_TREE, NULL, 0);
636 $2 = groktypename ($2);
637 really_start_incremental_init ($2); }
638 initlist_maybe_comma '}' %prec UNARY
640 tree result = pop_init_level (0);
644 if (pedantic && ! flag_isoc99)
645 pedwarn ("ISO C89 forbids compound literals");
646 if (TYPE_NAME (type) != 0)
648 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
649 name = IDENTIFIER_POINTER (TYPE_NAME (type));
651 name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
656 if (TREE_CODE (type) == ARRAY_TYPE && !COMPLETE_TYPE_P (type))
658 int failure = complete_array_type (type, $$, 1);
664 { char class = TREE_CODE_CLASS (TREE_CODE ($2));
665 if (class == 'e' || class == '1'
666 || class == '2' || class == '<')
667 C_SET_EXP_ORIGINAL_CODE ($2, ERROR_MARK);
670 { $$ = error_mark_node; }
671 | compstmt_primary_start compstmt_nostart ')'
672 { tree saved_last_tree;
675 pedwarn ("ISO C forbids braced-groups within expressions");
678 saved_last_tree = COMPOUND_BODY ($1);
679 RECHAIN_STMTS ($1, COMPOUND_BODY ($1));
680 last_tree = saved_last_tree;
681 TREE_CHAIN (last_tree) = NULL_TREE;
683 last_expr_type = void_type_node;
684 $$ = build1 (STMT_EXPR, last_expr_type, $1);
685 TREE_SIDE_EFFECTS ($$) = 1;
687 | compstmt_primary_start error ')'
690 last_tree = COMPOUND_BODY ($1);
691 TREE_CHAIN (last_tree) = NULL_TREE;
692 $$ = error_mark_node;
694 | primary '(' exprlist ')' %prec '.'
695 { $$ = build_function_call ($1, $3); }
696 | VA_ARG '(' expr_no_commas ',' typename ')'
697 { $$ = build_va_arg ($3, groktypename ($5)); }
698 | primary '[' expr ']' %prec '.'
699 { $$ = build_array_ref ($1, $3); }
700 | primary '.' identifier
703 if (doing_objc_thang)
705 if (is_public ($1, $3))
706 $$ = build_component_ref ($1, $3);
708 $$ = error_mark_node;
712 $$ = build_component_ref ($1, $3);
714 | primary POINTSAT identifier
716 tree expr = build_indirect_ref ($1, "->");
719 if (doing_objc_thang)
721 if (is_public (expr, $3))
722 $$ = build_component_ref (expr, $3);
724 $$ = error_mark_node;
728 $$ = build_component_ref (expr, $3);
731 { $$ = build_unary_op (POSTINCREMENT_EXPR, $1, 0); }
733 { $$ = build_unary_op (POSTDECREMENT_EXPR, $1, 0); }
736 { $$ = build_message_expr ($1); }
738 { $$ = build_selector_expr ($1); }
740 { $$ = build_protocol_expr ($1); }
742 { $$ = build_encode_expr ($1); }
744 { $$ = build_objc_string_object ($1); }
748 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
754 static int last_lineno = 0;
755 static const char *last_input_filename = 0;
757 $$ = chainon ($1, $2);
759 if (warn_traditional && !in_system_header
760 && (lineno != last_lineno || !last_input_filename ||
761 strcmp (last_input_filename, input_filename)))
763 warning ("traditional C rejects string concatenation");
764 last_lineno = lineno;
765 last_input_filename = input_filename;
772 /* Produces an STRING_CST with perhaps more STRING_CSTs chained
773 onto it, which is to be read as an ObjC string object. */
776 | objc_string OBJC_STRING
777 { $$ = chainon ($1, $2); }
781 old_style_parm_decls:
785 /* ... is used here to indicate a varargs function. */
788 pedwarn ("ISO C does not permit use of `varargs.h'"); }
791 /* The following are analogous to lineno_decl, decls and decl
792 except that they do not allow nested functions.
793 They are used for old-style parm decls. */
795 save_filename save_lineno datadecl
802 | datadecls lineno_datadecl
803 | lineno_datadecl errstmt
806 /* We don't allow prefix attributes here because they cause reduce/reduce
807 conflicts: we can't know whether we're parsing a function decl with
808 attribute suffix, or function defn with attribute prefix on first old
811 typed_declspecs_no_prefix_attr setspecs initdecls ';'
812 { current_declspecs = TREE_VALUE (declspec_stack);
813 prefix_attributes = TREE_PURPOSE (declspec_stack);
814 declspec_stack = TREE_CHAIN (declspec_stack); }
815 | declmods_no_prefix_attr setspecs notype_initdecls ';'
816 { current_declspecs = TREE_VALUE (declspec_stack);
817 prefix_attributes = TREE_PURPOSE (declspec_stack);
818 declspec_stack = TREE_CHAIN (declspec_stack); }
819 | typed_declspecs_no_prefix_attr ';'
820 { shadow_tag_warned ($1, 1);
821 pedwarn ("empty declaration"); }
822 | declmods_no_prefix_attr ';'
823 { pedwarn ("empty declaration"); }
826 /* This combination which saves a lineno before a decl
827 is the normal thing to use, rather than decl itself.
828 This is to avoid shift/reduce conflicts in contexts
829 where statement labels are allowed. */
831 save_filename save_lineno decl
835 /* records the type and storage class specs to use for processing
836 the declarators that follow.
837 Maintains a stack of outer-level values of current_declspecs,
838 for the sake of parm declarations nested in function declarators. */
839 setspecs: /* empty */
840 { pending_xref_error ();
841 declspec_stack = tree_cons (prefix_attributes,
844 split_specs_attrs ($<ttype>0,
845 ¤t_declspecs, &prefix_attributes); }
848 /* ??? Yuck. See after_type_declarator. */
849 setattrs: /* empty */
850 { prefix_attributes = chainon (prefix_attributes, $<ttype>0); }
854 typed_declspecs setspecs initdecls ';'
855 { current_declspecs = TREE_VALUE (declspec_stack);
856 prefix_attributes = TREE_PURPOSE (declspec_stack);
857 declspec_stack = TREE_CHAIN (declspec_stack); }
858 | declmods setspecs notype_initdecls ';'
859 { current_declspecs = TREE_VALUE (declspec_stack);
860 prefix_attributes = TREE_PURPOSE (declspec_stack);
861 declspec_stack = TREE_CHAIN (declspec_stack); }
862 | typed_declspecs setspecs nested_function
863 { current_declspecs = TREE_VALUE (declspec_stack);
864 prefix_attributes = TREE_PURPOSE (declspec_stack);
865 declspec_stack = TREE_CHAIN (declspec_stack); }
866 | declmods setspecs notype_nested_function
867 { current_declspecs = TREE_VALUE (declspec_stack);
868 prefix_attributes = TREE_PURPOSE (declspec_stack);
869 declspec_stack = TREE_CHAIN (declspec_stack); }
870 | typed_declspecs ';'
873 { pedwarn ("empty declaration"); }
875 { RESTORE_WARN_FLAGS ($1); }
878 /* Declspecs which contain at least one type specifier or typedef name.
879 (Just `const' or `volatile' is not enough.)
880 A typedef'd name following these is taken as a name to be declared.
881 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
884 typespec reserved_declspecs
885 { $$ = tree_cons (NULL_TREE, $1, $2); }
886 | declmods typespec reserved_declspecs
887 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
890 reserved_declspecs: /* empty */
892 | reserved_declspecs typespecqual_reserved
893 { $$ = tree_cons (NULL_TREE, $2, $1); }
894 | reserved_declspecs SCSPEC
895 { if (extra_warnings)
896 warning ("`%s' is not at beginning of declaration",
897 IDENTIFIER_POINTER ($2));
898 $$ = tree_cons (NULL_TREE, $2, $1); }
899 | reserved_declspecs attributes
900 { $$ = tree_cons ($2, NULL_TREE, $1); }
903 typed_declspecs_no_prefix_attr:
904 typespec reserved_declspecs_no_prefix_attr
905 { $$ = tree_cons (NULL_TREE, $1, $2); }
906 | declmods_no_prefix_attr typespec reserved_declspecs_no_prefix_attr
907 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
910 reserved_declspecs_no_prefix_attr:
913 | reserved_declspecs_no_prefix_attr typespecqual_reserved
914 { $$ = tree_cons (NULL_TREE, $2, $1); }
915 | reserved_declspecs_no_prefix_attr SCSPEC
916 { if (extra_warnings)
917 warning ("`%s' is not at beginning of declaration",
918 IDENTIFIER_POINTER ($2));
919 $$ = tree_cons (NULL_TREE, $2, $1); }
922 /* List of just storage classes, type modifiers, and prefix attributes.
923 A declaration can start with just this, but then it cannot be used
924 to redeclare a typedef-name.
925 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
928 declmods_no_prefix_attr
931 { $$ = tree_cons ($1, NULL_TREE, NULL_TREE); }
932 | declmods declmods_no_prefix_attr
933 { $$ = chainon ($2, $1); }
934 | declmods attributes
935 { $$ = tree_cons ($2, NULL_TREE, $1); }
938 declmods_no_prefix_attr:
940 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
941 TREE_STATIC ($$) = 1; }
943 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
944 | declmods_no_prefix_attr TYPE_QUAL
945 { $$ = tree_cons (NULL_TREE, $2, $1);
946 TREE_STATIC ($$) = 1; }
947 | declmods_no_prefix_attr SCSPEC
948 { if (extra_warnings && TREE_STATIC ($1))
949 warning ("`%s' is not at beginning of declaration",
950 IDENTIFIER_POINTER ($2));
951 $$ = tree_cons (NULL_TREE, $2, $1);
952 TREE_STATIC ($$) = TREE_STATIC ($1); }
956 /* Used instead of declspecs where storage classes are not allowed
957 (that is, for typenames and structure components).
958 Don't accept a typedef-name if anything but a modifier precedes it. */
961 typespec reserved_typespecquals
962 { $$ = tree_cons (NULL_TREE, $1, $2); }
963 | nonempty_type_quals typespec reserved_typespecquals
964 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
967 reserved_typespecquals: /* empty */
969 | reserved_typespecquals typespecqual_reserved
970 { $$ = tree_cons (NULL_TREE, $2, $1); }
973 /* A typespec (but not a type qualifier).
974 Once we have seen one of these in a declaration,
975 if a typedef name appears then it is being redeclared. */
980 { /* For a typedef name, record the meaning, not the name.
981 In case of `foo foo, bar;'. */
982 $$ = lookup_name ($1); }
984 | CLASSNAME protocolrefs
985 { $$ = get_static_reference ($1, $2); }
986 | OBJECTNAME protocolrefs
987 { $$ = get_object_reference ($2); }
989 /* Make "<SomeProtocol>" equivalent to "id <SomeProtocol>"
990 - nisse@lysator.liu.se */
991 | non_empty_protocolrefs
992 { $$ = get_object_reference ($1); }
994 | TYPEOF '(' expr ')'
995 { $$ = TREE_TYPE ($3); }
996 | TYPEOF '(' typename ')'
997 { $$ = groktypename ($3); }
1000 /* A typespec that is a reserved word, or a type qualifier. */
1002 typespecqual_reserved: TYPESPEC
1009 | initdecls ',' initdcl
1014 | notype_initdecls ',' initdcl
1020 | ASM_KEYWORD '(' string ')'
1021 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
1027 declarator maybeasm maybe_attribute '='
1028 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1029 $3, prefix_attributes);
1030 start_init ($<ttype>$, $2, global_bindings_p ()); }
1032 /* Note how the declaration of the variable is in effect while its init is parsed! */
1034 finish_decl ($<ttype>5, $6, $2); }
1035 | declarator maybeasm maybe_attribute
1036 { tree d = start_decl ($1, current_declspecs, 0,
1037 $3, prefix_attributes);
1038 finish_decl (d, NULL_TREE, $2);
1043 notype_declarator maybeasm maybe_attribute '='
1044 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1045 $3, prefix_attributes);
1046 start_init ($<ttype>$, $2, global_bindings_p ()); }
1048 /* Note how the declaration of the variable is in effect while its init is parsed! */
1050 decl_attributes ($<ttype>5, $3, prefix_attributes);
1051 finish_decl ($<ttype>5, $6, $2); }
1052 | notype_declarator maybeasm maybe_attribute
1053 { tree d = start_decl ($1, current_declspecs, 0,
1054 $3, prefix_attributes);
1055 finish_decl (d, NULL_TREE, $2); }
1057 /* the * rules are dummies to accept the Apollo extended syntax
1058 so that the header files compile. */
1069 | attributes attribute
1070 { $$ = chainon ($1, $2); }
1074 ATTRIBUTE '(' '(' attribute_list ')' ')'
1081 | attribute_list ',' attrib
1082 { $$ = chainon ($1, $3); }
1089 { $$ = build_tree_list ($1, NULL_TREE); }
1090 | any_word '(' IDENTIFIER ')'
1091 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1092 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1093 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1094 | any_word '(' exprlist ')'
1095 { $$ = build_tree_list ($1, $3); }
1098 /* This still leaves out most reserved keywords,
1099 shouldn't we include them? */
1108 /* Initializers. `init' is the entry point. */
1113 { really_start_incremental_init (NULL_TREE); }
1114 initlist_maybe_comma '}'
1115 { $$ = pop_init_level (0); }
1117 { $$ = error_mark_node; }
1120 /* `initlist_maybe_comma' is the guts of an initializer in braces. */
1121 initlist_maybe_comma:
1124 pedwarn ("ISO C forbids empty initializer braces"); }
1125 | initlist1 maybecomma
1130 | initlist1 ',' initelt
1133 /* `initelt' is a single element of an initializer.
1134 It may use braces. */
1136 designator_list '=' initval
1137 { if (pedantic && ! flag_isoc99)
1138 pedwarn ("ISO C89 forbids specifying subobject to initialize"); }
1139 | designator initval
1141 pedwarn ("obsolete use of designated initializer without `='"); }
1143 { set_init_label ($1);
1145 pedwarn ("obsolete use of designated initializer with `:'"); }
1152 { push_init_level (0); }
1153 initlist_maybe_comma '}'
1154 { process_init_element (pop_init_level (0)); }
1156 { process_init_element ($1); }
1162 | designator_list designator
1167 { set_init_label ($2); }
1168 /* These are for labeled elements. The syntax for an array element
1169 initializer conflicts with the syntax for an Objective-C message,
1170 so don't include these productions in the Objective-C grammar. */
1172 | '[' expr_no_commas ELLIPSIS expr_no_commas ']'
1173 { set_init_index ($2, $4);
1175 pedwarn ("ISO C forbids specifying range of elements to initialize"); }
1176 | '[' expr_no_commas ']'
1177 { set_init_index ($2, NULL_TREE); }
1184 pedwarn ("ISO C forbids nested functions");
1186 push_function_context ();
1187 if (! start_function (current_declspecs, $1,
1188 prefix_attributes, NULL_TREE))
1190 pop_function_context ();
1194 old_style_parm_decls
1195 { store_parm_decls (); }
1196 /* This used to use compstmt_or_error.
1197 That caused a bug with input `f(g) int g {}',
1198 where the use of YYERROR1 above caused an error
1199 which then was handled by compstmt_or_error.
1200 There followed a repeated execution of that same rule,
1201 which called YYERROR1 again, and so on. */
1202 save_filename save_lineno compstmt
1203 { tree decl = current_function_decl;
1204 DECL_SOURCE_FILE (decl) = $5;
1205 DECL_SOURCE_LINE (decl) = $6;
1206 finish_function (1);
1207 pop_function_context ();
1208 add_decl_stmt (decl); }
1211 notype_nested_function:
1214 pedwarn ("ISO C forbids nested functions");
1216 push_function_context ();
1217 if (! start_function (current_declspecs, $1,
1218 prefix_attributes, NULL_TREE))
1220 pop_function_context ();
1224 old_style_parm_decls
1225 { store_parm_decls (); }
1226 /* This used to use compstmt_or_error.
1227 That caused a bug with input `f(g) int g {}',
1228 where the use of YYERROR1 above caused an error
1229 which then was handled by compstmt_or_error.
1230 There followed a repeated execution of that same rule,
1231 which called YYERROR1 again, and so on. */
1232 save_filename save_lineno compstmt
1233 { tree decl = current_function_decl;
1234 DECL_SOURCE_FILE (decl) = $5;
1235 DECL_SOURCE_LINE (decl) = $6;
1236 finish_function (1);
1237 pop_function_context ();
1238 add_decl_stmt (decl); }
1241 /* Any kind of declarator (thus, all declarators allowed
1242 after an explicit typespec). */
1245 after_type_declarator
1249 /* A declarator that is allowed only after an explicit typespec. */
1251 after_type_declarator:
1252 '(' after_type_declarator ')'
1254 | after_type_declarator '(' parmlist_or_identifiers %prec '.'
1255 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1256 /* | after_type_declarator '(' error ')' %prec '.'
1257 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1258 poplevel (0, 0, 0); } */
1259 | after_type_declarator '[' expr ']' %prec '.'
1260 { $$ = build_nt (ARRAY_REF, $1, $3); }
1261 | after_type_declarator '[' ']' %prec '.'
1262 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1263 | '*' type_quals after_type_declarator %prec UNARY
1264 { $$ = make_pointer_declarator ($2, $3); }
1265 /* ??? Yuck. setattrs is a quick hack. We can't use
1266 prefix_attributes because $1 only applies to this
1267 declarator. We assume setspecs has already been done.
1268 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1269 attributes could be recognized here or in `attributes'). */
1270 | attributes setattrs after_type_declarator
1278 /* Kinds of declarator that can appear in a parameter list
1279 in addition to notype_declarator. This is like after_type_declarator
1280 but does not allow a typedef name in parentheses as an identifier
1281 (because it would conflict with a function with that typedef as arg). */
1284 parm_declarator '(' parmlist_or_identifiers %prec '.'
1285 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1286 /* | parm_declarator '(' error ')' %prec '.'
1287 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1288 poplevel (0, 0, 0); } */
1290 | parm_declarator '[' '*' ']' %prec '.'
1291 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE);
1293 error ("`[*]' in parameter declaration only allowed in ISO C 99");
1296 | parm_declarator '[' expr ']' %prec '.'
1297 { $$ = build_nt (ARRAY_REF, $1, $3); }
1298 | parm_declarator '[' ']' %prec '.'
1299 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1300 | '*' type_quals parm_declarator %prec UNARY
1301 { $$ = make_pointer_declarator ($2, $3); }
1302 /* ??? Yuck. setattrs is a quick hack. We can't use
1303 prefix_attributes because $1 only applies to this
1304 declarator. We assume setspecs has already been done.
1305 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1306 attributes could be recognized here or in `attributes'). */
1307 | attributes setattrs parm_declarator
1312 /* A declarator allowed whether or not there has been
1313 an explicit typespec. These cannot redeclare a typedef-name. */
1316 notype_declarator '(' parmlist_or_identifiers %prec '.'
1317 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1318 /* | notype_declarator '(' error ')' %prec '.'
1319 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1320 poplevel (0, 0, 0); } */
1321 | '(' notype_declarator ')'
1323 | '*' type_quals notype_declarator %prec UNARY
1324 { $$ = make_pointer_declarator ($2, $3); }
1326 | notype_declarator '[' '*' ']' %prec '.'
1327 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE);
1329 error ("`[*]' in parameter declaration only allowed in ISO C 99");
1332 | notype_declarator '[' expr ']' %prec '.'
1333 { $$ = build_nt (ARRAY_REF, $1, $3); }
1334 | notype_declarator '[' ']' %prec '.'
1335 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1336 /* ??? Yuck. setattrs is a quick hack. We can't use
1337 prefix_attributes because $1 only applies to this
1338 declarator. We assume setspecs has already been done.
1339 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1340 attributes could be recognized here or in `attributes'). */
1341 | attributes setattrs notype_declarator
1368 struct_head identifier '{'
1369 { $$ = start_struct (RECORD_TYPE, $2);
1370 /* Start scope of tag before parsing components. */
1372 component_decl_list '}' maybe_attribute
1373 { $$ = finish_struct ($<ttype>4, $5, chainon ($1, $7)); }
1374 | struct_head '{' component_decl_list '}' maybe_attribute
1375 { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
1376 $3, chainon ($1, $5));
1378 | struct_head identifier
1379 { $$ = xref_tag (RECORD_TYPE, $2); }
1380 | union_head identifier '{'
1381 { $$ = start_struct (UNION_TYPE, $2); }
1382 component_decl_list '}' maybe_attribute
1383 { $$ = finish_struct ($<ttype>4, $5, chainon ($1, $7)); }
1384 | union_head '{' component_decl_list '}' maybe_attribute
1385 { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
1386 $3, chainon ($1, $5));
1388 | union_head identifier
1389 { $$ = xref_tag (UNION_TYPE, $2); }
1390 | enum_head identifier '{'
1391 { $$ = start_enum ($2); }
1392 enumlist maybecomma_warn '}' maybe_attribute
1393 { $$ = finish_enum ($<ttype>4, nreverse ($5),
1394 chainon ($1, $8)); }
1396 { $$ = start_enum (NULL_TREE); }
1397 enumlist maybecomma_warn '}' maybe_attribute
1398 { $$ = finish_enum ($<ttype>3, nreverse ($4),
1399 chainon ($1, $7)); }
1400 | enum_head identifier
1401 { $$ = xref_tag (ENUMERAL_TYPE, $2);
1402 /* In ISO C, enumerated types can be referred to
1403 only if already defined. */
1404 if (pedantic && !COMPLETE_TYPE_P ($$))
1405 pedwarn ("ISO C forbids forward references to `enum' types"); }
1416 { if (pedantic && ! flag_isoc99)
1417 pedwarn ("comma at end of enumerator list"); }
1420 component_decl_list:
1421 component_decl_list2
1423 | component_decl_list2 component_decl
1424 { $$ = chainon ($1, $2);
1425 pedwarn ("no semicolon at end of struct or union"); }
1428 component_decl_list2: /* empty */
1430 | component_decl_list2 component_decl ';'
1431 { $$ = chainon ($1, $2); }
1432 | component_decl_list2 ';'
1434 pedwarn ("extra semicolon in struct or union specified"); }
1436 /* foo(sizeof(struct{ @defs(ClassName)})); */
1437 | DEFS '(' CLASSNAME ')'
1439 tree interface = lookup_interface ($3);
1442 $$ = get_class_ivars (interface);
1445 error ("Cannot find interface declaration for `%s'",
1446 IDENTIFIER_POINTER ($3));
1453 /* There is a shift-reduce conflict here, because `components' may
1454 start with a `typename'. It happens that shifting (the default resolution)
1455 does the right thing, because it treats the `typename' as part of
1456 a `typed_typespecs'.
1458 It is possible that this same technique would allow the distinction
1459 between `notype_initdecls' and `initdecls' to be eliminated.
1460 But I am being cautious and not trying it. */
1463 typed_typespecs setspecs components
1465 current_declspecs = TREE_VALUE (declspec_stack);
1466 prefix_attributes = TREE_PURPOSE (declspec_stack);
1467 declspec_stack = TREE_CHAIN (declspec_stack); }
1468 | typed_typespecs setspecs save_filename save_lineno maybe_attribute
1470 /* Support for unnamed structs or unions as members of
1471 structs or unions (which is [a] useful and [b] supports
1474 pedwarn ("ISO C doesn't support unnamed structs/unions");
1476 $$ = grokfield($3, $4, NULL, current_declspecs, NULL_TREE);
1477 current_declspecs = TREE_VALUE (declspec_stack);
1478 prefix_attributes = TREE_PURPOSE (declspec_stack);
1479 declspec_stack = TREE_CHAIN (declspec_stack);
1481 | nonempty_type_quals setspecs components
1483 current_declspecs = TREE_VALUE (declspec_stack);
1484 prefix_attributes = TREE_PURPOSE (declspec_stack);
1485 declspec_stack = TREE_CHAIN (declspec_stack); }
1486 | nonempty_type_quals
1488 pedwarn ("ISO C forbids member declarations with no members");
1493 | extension component_decl
1495 RESTORE_WARN_FLAGS ($1); }
1499 component_declarator
1500 | components ',' component_declarator
1501 { $$ = chainon ($1, $3); }
1504 component_declarator:
1505 save_filename save_lineno declarator maybe_attribute
1506 { $$ = grokfield ($1, $2, $3, current_declspecs, NULL_TREE);
1507 decl_attributes ($$, $4, prefix_attributes); }
1508 | save_filename save_lineno
1509 declarator ':' expr_no_commas maybe_attribute
1510 { $$ = grokfield ($1, $2, $3, current_declspecs, $5);
1511 decl_attributes ($$, $6, prefix_attributes); }
1512 | save_filename save_lineno ':' expr_no_commas maybe_attribute
1513 { $$ = grokfield ($1, $2, NULL_TREE, current_declspecs, $4);
1514 decl_attributes ($$, $5, prefix_attributes); }
1517 /* We chain the enumerators in reverse order.
1518 They are put in forward order where enumlist is used.
1519 (The order used to be significant, but no longer is so.
1520 However, we still maintain the order, just to be clean.) */
1524 | enumlist ',' enumerator
1525 { if ($1 == error_mark_node)
1528 $$ = chainon ($3, $1); }
1530 { $$ = error_mark_node; }
1536 { $$ = build_enumerator ($1, NULL_TREE); }
1537 | identifier '=' expr_no_commas
1538 { $$ = build_enumerator ($1, $3); }
1543 { pending_xref_error (); }
1545 { $$ = build_tree_list ($1, $3); }
1546 | nonempty_type_quals absdcl
1547 { $$ = build_tree_list ($1, $2); }
1550 absdcl: /* an absolute declarator */
1556 nonempty_type_quals:
1558 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
1559 | nonempty_type_quals TYPE_QUAL
1560 { $$ = tree_cons (NULL_TREE, $2, $1); }
1566 | type_quals TYPE_QUAL
1567 { $$ = tree_cons (NULL_TREE, $2, $1); }
1570 absdcl1: /* a nonempty absolute declarator */
1573 /* `(typedef)1' is `int'. */
1574 | '*' type_quals absdcl1 %prec UNARY
1575 { $$ = make_pointer_declarator ($2, $3); }
1576 | '*' type_quals %prec UNARY
1577 { $$ = make_pointer_declarator ($2, NULL_TREE); }
1578 | absdcl1 '(' parmlist %prec '.'
1579 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1580 | absdcl1 '[' expr ']' %prec '.'
1581 { $$ = build_nt (ARRAY_REF, $1, $3); }
1582 | absdcl1 '[' ']' %prec '.'
1583 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1584 | '(' parmlist %prec '.'
1585 { $$ = build_nt (CALL_EXPR, NULL_TREE, $2, NULL_TREE); }
1586 | '[' expr ']' %prec '.'
1587 { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
1589 { $$ = build_nt (ARRAY_REF, NULL_TREE, NULL_TREE); }
1590 /* ??? It appears we have to support attributes here, however
1591 using prefix_attributes is wrong. */
1592 | attributes setattrs absdcl1
1596 /* A nonempty series of declarations and statements (possibly followed by
1597 some labels) that can form the body of a compound statement.
1598 NOTE: we don't allow labels on declarations; this might seem like a
1599 natural extension, but there would be a conflict between attributes
1600 on the label and prefix attributes on the declaration. */
1603 lineno_stmt_decl_or_labels_ending_stmt
1604 | lineno_stmt_decl_or_labels_ending_decl
1605 | lineno_stmt_decl_or_labels_ending_label
1607 pedwarn ("deprecated use of label at end of compound statement");
1609 | lineno_stmt_decl_or_labels_ending_error
1612 lineno_stmt_decl_or_labels_ending_stmt:
1614 | lineno_stmt_decl_or_labels_ending_stmt lineno_stmt
1615 | lineno_stmt_decl_or_labels_ending_decl lineno_stmt
1616 | lineno_stmt_decl_or_labels_ending_label lineno_stmt
1617 | lineno_stmt_decl_or_labels_ending_error lineno_stmt
1620 lineno_stmt_decl_or_labels_ending_decl:
1622 | lineno_stmt_decl_or_labels_ending_stmt lineno_decl
1623 { if (pedantic && !flag_isoc99)
1624 pedwarn ("ISO C89 forbids mixed declarations and code"); }
1625 | lineno_stmt_decl_or_labels_ending_decl lineno_decl
1626 | lineno_stmt_decl_or_labels_ending_error lineno_decl
1629 lineno_stmt_decl_or_labels_ending_label:
1631 | lineno_stmt_decl_or_labels_ending_stmt lineno_label
1632 | lineno_stmt_decl_or_labels_ending_decl lineno_label
1633 | lineno_stmt_decl_or_labels_ending_label lineno_label
1634 | lineno_stmt_decl_or_labels_ending_error lineno_label
1637 lineno_stmt_decl_or_labels_ending_error:
1639 | lineno_stmt_decl_or_labels errstmt
1642 lineno_stmt_decl_or_labels:
1643 lineno_stmt_decl_or_labels_ending_stmt
1644 | lineno_stmt_decl_or_labels_ending_decl
1645 | lineno_stmt_decl_or_labels_ending_label
1646 | lineno_stmt_decl_or_labels_ending_error
1652 pushlevel: /* empty */
1655 add_scope_stmt (/*begin_p=*/1, /*partial_p=*/0);
1657 if (objc_method_context)
1663 poplevel: /* empty */
1664 { $$ = add_scope_stmt (/*begin_p=*/0, /*partial_p=*/0); }
1666 /* Start and end blocks created for the new scopes of C99. */
1667 c99_block_start: /* empty */
1670 $$ = c_begin_compound_stmt ();
1673 add_scope_stmt (/*begin_p=*/1, /*partial_p=*/0);
1675 if (objc_method_context)
1684 /* Productions using c99_block_start and c99_block_end will need to do what's
1685 in compstmt: RECHAIN_STMTS ($1, COMPOUND_BODY ($1)); $$ = $2; where
1686 $1 is the value of c99_block_start and $2 of c99_block_end. */
1687 c99_block_end: /* empty */
1690 tree scope_stmt = add_scope_stmt (/*begin_p=*/0, /*partial_p=*/0);
1691 $$ = poplevel (kept_level_p (), 0, 0);
1692 SCOPE_STMT_BLOCK (TREE_PURPOSE (scope_stmt))
1693 = SCOPE_STMT_BLOCK (TREE_VALUE (scope_stmt))
1700 /* Read zero or more forward-declarations for labels
1701 that nested functions can jump to. */
1706 pedwarn ("ISO C forbids label declarations"); }
1711 | label_decls label_decl
1715 LABEL identifiers_or_typenames ';'
1717 for (link = $2; link; link = TREE_CHAIN (link))
1719 tree label = shadow_label (TREE_VALUE (link));
1720 C_DECLARED_LABEL_FLAG (label) = 1;
1721 add_decl_stmt (label);
1726 /* This is the body of a function definition.
1727 It causes syntax errors to ignore to the next openbrace. */
1734 compstmt_start: '{' { compstmt_count++;
1735 $$ = c_begin_compound_stmt (); }
1737 compstmt_nostart: '}'
1738 { $$ = convert (void_type_node, integer_zero_node); }
1739 | pushlevel maybe_label_decls compstmt_contents_nonempty '}' poplevel
1740 { $$ = poplevel (kept_level_p (), 1, 0);
1741 SCOPE_STMT_BLOCK (TREE_PURPOSE ($5))
1742 = SCOPE_STMT_BLOCK (TREE_VALUE ($5))
1746 compstmt_contents_nonempty:
1751 compstmt_primary_start:
1753 { if (current_function_decl == 0)
1755 error ("braced-group within expression allowed only inside a function");
1758 /* We must force a BLOCK for this level
1759 so that, if it is not expanded later,
1760 there is a way to turn off the entire subtree of blocks
1761 that are contained in it. */
1763 push_label_level ();
1765 $$ = add_stmt (build_stmt (COMPOUND_STMT, last_tree));
1768 compstmt: compstmt_start compstmt_nostart
1769 { RECHAIN_STMTS ($1, COMPOUND_BODY ($1));
1773 /* Value is number of statements counted as of the closeparen. */
1775 if_prefix c99_block_lineno_labeled_stmt
1776 { c_finish_then (); }
1777 /* Make sure c_expand_end_cond is run once
1778 for each call to c_expand_start_cond.
1779 Otherwise a crash is likely. */
1785 { c_expand_start_cond (truthvalue_conversion ($3),
1787 $<itype>$ = stmt_count;
1788 if_stmt_file = $<filename>-2;
1789 if_stmt_line = $<lineno>-1; }
1792 /* This is a subroutine of stmt.
1793 It is used twice, once for valid DO statements
1794 and once for catching errors in parsing the end test. */
1800 = add_stmt (build_stmt (DO_STMT, NULL_TREE,
1802 /* In the event that a parse error prevents
1803 parsing the complete do-statement, set the
1804 condition now. Otherwise, we can get crashes at
1805 RTL-generation time. */
1806 DO_COND ($<ttype>$) = error_mark_node; }
1807 c99_block_lineno_labeled_stmt WHILE
1809 RECHAIN_STMTS ($$, DO_BODY ($$)); }
1812 /* The forced readahead in here is because we might be at the end of a
1813 line, and the line and file won't be bumped until yylex absorbs the
1814 first token on the next line. */
1816 { if (yychar == YYEMPTY)
1818 $$ = input_filename; }
1822 { if (yychar == YYEMPTY)
1827 lineno_labeled_stmt:
1829 | lineno_label lineno_labeled_stmt
1832 /* Like lineno_labeled_stmt, but a block in C99. */
1833 c99_block_lineno_labeled_stmt:
1834 c99_block_start lineno_labeled_stmt c99_block_end
1836 RECHAIN_STMTS ($1, COMPOUND_BODY ($1)); }
1840 save_filename save_lineno stmt
1843 STMT_LINENO ($3) = $2;
1844 /* ??? We currently have no way of recording
1845 the filename for a statement. This probably
1846 matters little in practice at the moment,
1847 but I suspect that problems will ocurr when
1848 doing inlining at the tree level. */
1854 save_filename save_lineno label
1857 STMT_LINENO ($3) = $2;
1862 select_or_iter_stmt:
1864 { c_expand_start_else ();
1865 $<itype>1 = stmt_count; }
1866 c99_block_lineno_labeled_stmt
1868 c_expand_end_cond ();
1869 if (extra_warnings && stmt_count == $<itype>1)
1870 warning ("empty body in an else-statement"); }
1871 | simple_if %prec IF
1872 { c_expand_end_cond ();
1873 /* This warning is here instead of in simple_if, because we
1874 do not want a warning if an empty if is followed by an
1875 else statement. Increment stmt_count so we don't
1876 give a second error if this is a nested `if'. */
1877 if (extra_warnings && stmt_count++ == $<itype>1)
1878 warning_with_file_and_line (if_stmt_file, if_stmt_line,
1879 "empty body in an if-statement"); }
1880 /* Make sure c_expand_end_cond is run once
1881 for each call to c_expand_start_cond.
1882 Otherwise a crash is likely. */
1883 | simple_if ELSE error
1884 { c_expand_end_cond (); }
1888 { $4 = truthvalue_conversion ($4);
1890 = add_stmt (build_stmt (WHILE_STMT, $4, NULL_TREE)); }
1891 c99_block_lineno_labeled_stmt
1892 { RECHAIN_STMTS ($<ttype>6, WHILE_BODY ($<ttype>6)); }
1895 { DO_COND ($1) = truthvalue_conversion ($3); }
1896 | do_stmt_start error
1899 { $<ttype>$ = build_stmt (FOR_STMT, NULL_TREE, NULL_TREE,
1900 NULL_TREE, NULL_TREE);
1901 add_stmt ($<ttype>$); }
1904 RECHAIN_STMTS ($<ttype>2, FOR_INIT_STMT ($<ttype>2)); }
1907 FOR_COND ($<ttype>2) = truthvalue_conversion ($6); }
1909 { FOR_EXPR ($<ttype>2) = $9; }
1910 c99_block_lineno_labeled_stmt
1911 { RECHAIN_STMTS ($<ttype>2, FOR_BODY ($<ttype>2)); }
1912 | SWITCH '(' expr ')'
1914 $<ttype>$ = c_start_case ($3); }
1915 c99_block_lineno_labeled_stmt
1916 { c_finish_case (); }
1921 { add_stmt (build_stmt (EXPR_STMT, $1)); }
1923 { check_for_loop_decls (); }
1926 /* Parse a single real statement, not including any labels. */
1929 { stmt_count++; $$ = $1; }
1932 $$ = c_expand_expr_stmt ($1); }
1933 | c99_block_start select_or_iter_stmt c99_block_end
1935 RECHAIN_STMTS ($1, COMPOUND_BODY ($1));
1939 $$ = add_stmt (build_break_stmt ()); }
1942 $$ = add_stmt (build_continue_stmt ()); }
1945 $$ = c_expand_return (NULL_TREE); }
1948 $$ = c_expand_return ($2); }
1949 | ASM_KEYWORD maybe_type_qual '(' expr ')' ';'
1952 if ((TREE_CODE ($4) == ADDR_EXPR
1953 && TREE_CODE (TREE_OPERAND ($4, 0)) == STRING_CST)
1954 || TREE_CODE ($4) == STRING_CST)
1956 if (TREE_CODE ($4) == ADDR_EXPR)
1957 $4 = TREE_OPERAND ($4, 0);
1958 if (TREE_CHAIN ($4))
1959 $4 = combine_strings ($4);
1960 $$ = add_stmt (build_stmt (ASM_STMT, NULL_TREE, $4,
1961 NULL_TREE, NULL_TREE,
1963 ASM_INPUT_P ($$) = 1;
1967 error ("argument of `asm' is not a constant string");
1971 /* This is the case with just output operands. */
1972 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ')' ';'
1974 $$ = build_asm_stmt ($2, $4, $6, NULL_TREE, NULL_TREE); }
1975 /* This is the case with input operands as well. */
1976 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':'
1977 asm_operands ')' ';'
1979 $$ = build_asm_stmt ($2, $4, $6, $8, NULL_TREE); }
1980 /* This is the case with clobbered registers as well. */
1981 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':'
1982 asm_operands ':' asm_clobbers ')' ';'
1984 $$ = build_asm_stmt ($2, $4, $6, $8, $10); }
1985 | GOTO identifier ';'
1988 decl = lookup_label ($2);
1991 TREE_USED (decl) = 1;
1992 $$ = add_stmt (build_stmt (GOTO_STMT, decl));
1999 pedwarn ("ISO C forbids `goto *expr;'");
2001 $3 = convert (ptr_type_node, $3);
2002 $$ = add_stmt (build_stmt (GOTO_STMT, $3)); }
2007 /* Any kind of label, including jump labels and case labels.
2008 ANSI C accepts labels only before statements, but we allow them
2009 also at the end of a compound statement. */
2011 label: CASE expr_no_commas ':'
2013 $$ = do_case ($2, NULL_TREE); }
2014 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
2016 $$ = do_case ($2, $4); }
2019 $$ = do_case (NULL_TREE, NULL_TREE); }
2020 | identifier save_filename save_lineno ':' maybe_attribute
2021 { tree label = define_label ($2, $3, $1);
2025 decl_attributes (label, $5, NULL_TREE);
2026 $$ = add_stmt (build_stmt (LABEL_STMT, label));
2033 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
2037 { emit_line_note (input_filename, lineno);
2040 { emit_line_note (input_filename, lineno); }
2049 /* These are the operands other than the first string and colon
2050 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
2051 asm_operands: /* empty */
2053 | nonnull_asm_operands
2056 nonnull_asm_operands:
2058 | nonnull_asm_operands ',' asm_operand
2059 { $$ = chainon ($1, $3); }
2064 { $$ = build_tree_list ($1, $3); }
2069 { $$ = tree_cons (NULL_TREE, combine_strings ($1), NULL_TREE); }
2070 | asm_clobbers ',' string
2071 { $$ = tree_cons (NULL_TREE, combine_strings ($3), $1); }
2074 /* This is what appears inside the parens in a function declarator.
2075 Its value is a list of ..._TYPE nodes. */
2078 clear_parm_order ();
2079 declare_parm_level (0); }
2082 parmlist_tags_warning ();
2083 poplevel (0, 0, 0); }
2091 pedwarn ("ISO C forbids forward parameter declarations");
2092 /* Mark the forward decls as such. */
2093 for (parm = getdecls (); parm; parm = TREE_CHAIN (parm))
2094 TREE_ASM_WRITTEN (parm) = 1;
2095 clear_parm_order (); }
2099 { $$ = tree_cons (NULL_TREE, NULL_TREE, NULL_TREE); }
2102 /* This is what appears inside the parens in a function declarator.
2103 Is value is represented in the format that grokdeclarator expects. */
2104 parmlist_2: /* empty */
2105 { $$ = get_parm_info (0); }
2107 { $$ = get_parm_info (0);
2108 /* Gcc used to allow this as an extension. However, it does
2109 not work for all targets, and thus has been disabled.
2110 Also, since func (...) and func () are indistinguishable,
2111 it caused problems with the code in expand_builtin which
2112 tries to verify that BUILT_IN_NEXT_ARG is being used
2114 error ("ISO C requires a named argument before `...'");
2117 { $$ = get_parm_info (1); }
2118 | parms ',' ELLIPSIS
2119 { $$ = get_parm_info (0); }
2124 { push_parm_decl ($1); }
2126 { push_parm_decl ($3); }
2129 /* A single parameter declaration or parameter type name,
2130 as found in a parmlist. */
2132 typed_declspecs setspecs parm_declarator maybe_attribute
2133 { $$ = build_tree_list (build_tree_list (current_declspecs,
2135 build_tree_list (prefix_attributes,
2137 current_declspecs = TREE_VALUE (declspec_stack);
2138 prefix_attributes = TREE_PURPOSE (declspec_stack);
2139 declspec_stack = TREE_CHAIN (declspec_stack); }
2140 | typed_declspecs setspecs notype_declarator maybe_attribute
2141 { $$ = build_tree_list (build_tree_list (current_declspecs,
2143 build_tree_list (prefix_attributes,
2145 current_declspecs = TREE_VALUE (declspec_stack);
2146 prefix_attributes = TREE_PURPOSE (declspec_stack);
2147 declspec_stack = TREE_CHAIN (declspec_stack); }
2148 | typed_declspecs setspecs absdcl maybe_attribute
2149 { $$ = build_tree_list (build_tree_list (current_declspecs,
2151 build_tree_list (prefix_attributes,
2153 current_declspecs = TREE_VALUE (declspec_stack);
2154 prefix_attributes = TREE_PURPOSE (declspec_stack);
2155 declspec_stack = TREE_CHAIN (declspec_stack); }
2156 | declmods setspecs notype_declarator maybe_attribute
2157 { $$ = build_tree_list (build_tree_list (current_declspecs,
2159 build_tree_list (prefix_attributes,
2161 current_declspecs = TREE_VALUE (declspec_stack);
2162 prefix_attributes = TREE_PURPOSE (declspec_stack);
2163 declspec_stack = TREE_CHAIN (declspec_stack); }
2165 | declmods setspecs absdcl maybe_attribute
2166 { $$ = build_tree_list (build_tree_list (current_declspecs,
2168 build_tree_list (prefix_attributes,
2170 current_declspecs = TREE_VALUE (declspec_stack);
2171 prefix_attributes = TREE_PURPOSE (declspec_stack);
2172 declspec_stack = TREE_CHAIN (declspec_stack); }
2175 /* This is used in a function definition
2176 where either a parmlist or an identifier list is ok.
2177 Its value is a list of ..._TYPE nodes or a list of identifiers. */
2178 parmlist_or_identifiers:
2180 clear_parm_order ();
2181 declare_parm_level (1); }
2182 parmlist_or_identifiers_1
2184 parmlist_tags_warning ();
2185 poplevel (0, 0, 0); }
2188 parmlist_or_identifiers_1:
2192 for (t = $1; t; t = TREE_CHAIN (t))
2193 if (TREE_VALUE (t) == NULL_TREE)
2194 error ("`...' in old-style identifier list");
2195 $$ = tree_cons (NULL_TREE, NULL_TREE, $1); }
2198 /* A nonempty list of identifiers. */
2201 { $$ = build_tree_list (NULL_TREE, $1); }
2202 | identifiers ',' IDENTIFIER
2203 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2206 /* A nonempty list of identifiers, including typenames. */
2207 identifiers_or_typenames:
2209 { $$ = build_tree_list (NULL_TREE, $1); }
2210 | identifiers_or_typenames ',' identifier
2211 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2216 { $$ = SAVE_WARN_FLAGS();
2218 warn_pointer_arith = 0; }
2222 /* Objective-C productions. */
2232 if (objc_implementation_context)
2234 finish_class (objc_implementation_context);
2235 objc_ivar_chain = NULL_TREE;
2236 objc_implementation_context = NULL_TREE;
2239 warning ("`@end' must appear in an implementation context");
2243 /* A nonempty list of identifiers. */
2246 { $$ = build_tree_list (NULL_TREE, $1); }
2247 | identifier_list ',' identifier
2248 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2252 CLASS identifier_list ';'
2254 objc_declare_class ($2);
2258 ALIAS identifier identifier ';'
2260 objc_declare_alias ($2, $3);
2264 INTERFACE identifier protocolrefs '{'
2266 objc_interface_context = objc_ivar_context
2267 = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, $3);
2268 objc_public_flag = 0;
2272 continue_class (objc_interface_context);
2277 finish_class (objc_interface_context);
2278 objc_interface_context = NULL_TREE;
2281 | INTERFACE identifier protocolrefs
2283 objc_interface_context
2284 = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, $3);
2285 continue_class (objc_interface_context);
2290 finish_class (objc_interface_context);
2291 objc_interface_context = NULL_TREE;
2294 | INTERFACE identifier ':' identifier protocolrefs '{'
2296 objc_interface_context = objc_ivar_context
2297 = start_class (CLASS_INTERFACE_TYPE, $2, $4, $5);
2298 objc_public_flag = 0;
2302 continue_class (objc_interface_context);
2307 finish_class (objc_interface_context);
2308 objc_interface_context = NULL_TREE;
2311 | INTERFACE identifier ':' identifier protocolrefs
2313 objc_interface_context
2314 = start_class (CLASS_INTERFACE_TYPE, $2, $4, $5);
2315 continue_class (objc_interface_context);
2320 finish_class (objc_interface_context);
2321 objc_interface_context = NULL_TREE;
2324 | IMPLEMENTATION identifier '{'
2326 objc_implementation_context = objc_ivar_context
2327 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, NULL_TREE, NULL_TREE);
2328 objc_public_flag = 0;
2333 = continue_class (objc_implementation_context);
2336 | IMPLEMENTATION identifier
2338 objc_implementation_context
2339 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, NULL_TREE, NULL_TREE);
2341 = continue_class (objc_implementation_context);
2344 | IMPLEMENTATION identifier ':' identifier '{'
2346 objc_implementation_context = objc_ivar_context
2347 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2348 objc_public_flag = 0;
2353 = continue_class (objc_implementation_context);
2356 | IMPLEMENTATION identifier ':' identifier
2358 objc_implementation_context
2359 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2361 = continue_class (objc_implementation_context);
2364 | INTERFACE identifier '(' identifier ')' protocolrefs
2366 objc_interface_context
2367 = start_class (CATEGORY_INTERFACE_TYPE, $2, $4, $6);
2368 continue_class (objc_interface_context);
2373 finish_class (objc_interface_context);
2374 objc_interface_context = NULL_TREE;
2377 | IMPLEMENTATION identifier '(' identifier ')'
2379 objc_implementation_context
2380 = start_class (CATEGORY_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2382 = continue_class (objc_implementation_context);
2387 PROTOCOL identifier protocolrefs
2389 remember_protocol_qualifiers ();
2390 objc_interface_context
2391 = start_protocol(PROTOCOL_INTERFACE_TYPE, $2, $3);
2395 forget_protocol_qualifiers();
2396 finish_protocol(objc_interface_context);
2397 objc_interface_context = NULL_TREE;
2406 | non_empty_protocolrefs
2409 non_empty_protocolrefs:
2410 ARITHCOMPARE identifier_list ARITHCOMPARE
2412 if ($1 == LT_EXPR && $3 == GT_EXPR)
2420 ivar_decl_list visibility_spec ivar_decls
2425 PRIVATE { objc_public_flag = 2; }
2426 | PROTECTED { objc_public_flag = 0; }
2427 | PUBLIC { objc_public_flag = 1; }
2435 | ivar_decls ivar_decl ';'
2439 pedwarn ("extra semicolon in struct or union specified");
2444 /* There is a shift-reduce conflict here, because `components' may
2445 start with a `typename'. It happens that shifting (the default resolution)
2446 does the right thing, because it treats the `typename' as part of
2447 a `typed_typespecs'.
2449 It is possible that this same technique would allow the distinction
2450 between `notype_initdecls' and `initdecls' to be eliminated.
2451 But I am being cautious and not trying it. */
2454 typed_typespecs setspecs ivars
2456 current_declspecs = TREE_VALUE (declspec_stack);
2457 prefix_attributes = TREE_PURPOSE (declspec_stack);
2458 declspec_stack = TREE_CHAIN (declspec_stack); }
2459 | nonempty_type_quals setspecs ivars
2461 current_declspecs = TREE_VALUE (declspec_stack);
2462 prefix_attributes = TREE_PURPOSE (declspec_stack);
2463 declspec_stack = TREE_CHAIN (declspec_stack); }
2472 | ivars ',' ivar_declarator
2478 $$ = add_instance_variable (objc_ivar_context,
2480 $1, current_declspecs,
2483 | declarator ':' expr_no_commas
2485 $$ = add_instance_variable (objc_ivar_context,
2487 $1, current_declspecs, $3);
2489 | ':' expr_no_commas
2491 $$ = add_instance_variable (objc_ivar_context,
2494 current_declspecs, $2);
2501 remember_protocol_qualifiers ();
2502 if (objc_implementation_context)
2503 objc_inherit_code = CLASS_METHOD_DECL;
2505 fatal_error ("method definition not in class context");
2509 forget_protocol_qualifiers ();
2510 add_class_method (objc_implementation_context, $3);
2511 start_method_def ($3);
2512 objc_method_context = $3;
2516 continue_method_def ();
2520 finish_method_def ();
2521 objc_method_context = NULL_TREE;
2526 remember_protocol_qualifiers ();
2527 if (objc_implementation_context)
2528 objc_inherit_code = INSTANCE_METHOD_DECL;
2530 fatal_error ("method definition not in class context");
2534 forget_protocol_qualifiers ();
2535 add_instance_method (objc_implementation_context, $3);
2536 start_method_def ($3);
2537 objc_method_context = $3;
2541 continue_method_def ();
2545 finish_method_def ();
2546 objc_method_context = NULL_TREE;
2550 /* the reason for the strange actions in this rule
2551 is so that notype_initdecls when reached via datadef
2552 can find a valid list of type and sc specs in $0. */
2556 | {$<ttype>$ = NULL_TREE; } methodprotolist2
2559 methodprotolist2: /* eliminates a shift/reduce conflict */
2562 | methodprotolist2 methodproto
2563 | methodprotolist2 {$<ttype>$ = NULL_TREE; } datadef
2574 /* Remember protocol qualifiers in prototypes. */
2575 remember_protocol_qualifiers ();
2576 objc_inherit_code = CLASS_METHOD_DECL;
2580 /* Forget protocol qualifiers here. */
2581 forget_protocol_qualifiers ();
2582 add_class_method (objc_interface_context, $3);
2588 /* Remember protocol qualifiers in prototypes. */
2589 remember_protocol_qualifiers ();
2590 objc_inherit_code = INSTANCE_METHOD_DECL;
2594 /* Forget protocol qualifiers here. */
2595 forget_protocol_qualifiers ();
2596 add_instance_method (objc_interface_context, $3);
2602 '(' typename ')' unaryselector
2604 $$ = build_method_decl (objc_inherit_code, $2, $4, NULL_TREE);
2609 $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, NULL_TREE);
2612 | '(' typename ')' keywordselector optparmlist
2614 $$ = build_method_decl (objc_inherit_code, $2, $4, $5);
2617 | keywordselector optparmlist
2619 $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, $2);
2623 /* "optarglist" assumes that start_method_def has already been called...
2624 if it is not, the "xdecls" will not be placed in the proper scope */
2631 /* to get around the following situation: "int foo (int a) int b; {}" that
2632 is synthesized when parsing "- a:a b:b; id c; id d; { ... }" */
2647 typed_declspecs setspecs myparms ';'
2648 { current_declspecs = TREE_VALUE (declspec_stack);
2649 prefix_attributes = TREE_PURPOSE (declspec_stack);
2650 declspec_stack = TREE_CHAIN (declspec_stack); }
2651 | typed_declspecs ';'
2652 { shadow_tag ($1); }
2654 { pedwarn ("empty declaration"); }
2659 { push_parm_decl ($1); }
2660 | myparms ',' myparm
2661 { push_parm_decl ($3); }
2664 /* A single parameter declaration or parameter type name,
2665 as found in a parmlist. DOES NOT ALLOW AN INITIALIZER OR ASMSPEC */
2668 parm_declarator maybe_attribute
2669 { $$ = build_tree_list (build_tree_list (current_declspecs,
2671 build_tree_list (prefix_attributes,
2673 | notype_declarator maybe_attribute
2674 { $$ = build_tree_list (build_tree_list (current_declspecs,
2676 build_tree_list (prefix_attributes,
2678 | absdcl maybe_attribute
2679 { $$ = build_tree_list (build_tree_list (current_declspecs,
2681 build_tree_list (prefix_attributes,
2692 /* oh what a kludge! */
2693 $$ = objc_ellipsis_node;
2701 /* returns a tree list node generated by get_parm_info */
2714 | keywordselector keyworddecl
2716 $$ = chainon ($1, $2);
2728 ENUM | STRUCT | UNION | IF | ELSE | WHILE | DO | FOR
2729 | SWITCH | CASE | DEFAULT | BREAK | CONTINUE | RETURN
2730 | GOTO | ASM_KEYWORD | SIZEOF | TYPEOF | ALIGNOF
2731 | TYPESPEC | TYPE_QUAL
2735 selector ':' '(' typename ')' identifier
2737 $$ = build_keyword_decl ($1, $4, $6);
2740 | selector ':' identifier
2742 $$ = build_keyword_decl ($1, NULL_TREE, $3);
2745 | ':' '(' typename ')' identifier
2747 $$ = build_keyword_decl (NULL_TREE, $3, $5);
2752 $$ = build_keyword_decl (NULL_TREE, NULL_TREE, $2);
2763 | keywordarglist keywordarg
2765 $$ = chainon ($1, $2);
2773 if (TREE_CHAIN ($1) == NULL_TREE)
2774 /* just return the expr., remove a level of indirection */
2775 $$ = TREE_VALUE ($1);
2777 /* we have a comma expr., we will collapse later */
2783 selector ':' keywordexpr
2785 $$ = build_tree_list ($1, $3);
2789 $$ = build_tree_list (NULL_TREE, $2);
2797 $$ = get_class_reference ($1);
2803 { objc_receiver_context = 1; }
2805 { objc_receiver_context = 0; }
2808 $$ = build_tree_list ($3, $5);
2819 | keywordnamelist keywordname
2821 $$ = chainon ($1, $2);
2828 $$ = build_tree_list ($1, NULL_TREE);
2832 $$ = build_tree_list (NULL_TREE, NULL_TREE);
2837 SELECTOR '(' selectorarg ')'
2844 PROTOCOL '(' identifier ')'
2850 /* extension to support C-structures in the archiver */
2853 ENCODE '(' typename ')'
2855 $$ = groktypename ($3);
2862 /* yylex() is a thin wrapper around c_lex(), all it does is translate
2863 cpplib.h's token codes into yacc's token codes. */
2865 static enum cpp_ttype last_token;
2867 /* The reserved keyword table. */
2871 ENUM_BITFIELD(rid) rid : 16;
2872 unsigned int disable : 16;
2875 /* Disable mask. Keywords are disabled if (reswords[i].disable & mask) is
2877 #define D_TRAD 0x01 /* not in traditional C */
2878 #define D_C89 0x02 /* not in C89 */
2879 #define D_EXT 0x04 /* GCC extension */
2880 #define D_EXT89 0x08 /* GCC extension incorporated in C99 */
2881 #define D_OBJC 0x10 /* Objective C only */
2883 static const struct resword reswords[] =
2885 { "_Bool", RID_BOOL, 0 },
2886 { "_Complex", RID_COMPLEX, 0 },
2887 { "__alignof", RID_ALIGNOF, 0 },
2888 { "__alignof__", RID_ALIGNOF, 0 },
2889 { "__asm", RID_ASM, 0 },
2890 { "__asm__", RID_ASM, 0 },
2891 { "__attribute", RID_ATTRIBUTE, 0 },
2892 { "__attribute__", RID_ATTRIBUTE, 0 },
2893 { "__bounded", RID_BOUNDED, 0 },
2894 { "__bounded__", RID_BOUNDED, 0 },
2895 { "__builtin_va_arg", RID_VA_ARG, 0 },
2896 { "__complex", RID_COMPLEX, 0 },
2897 { "__complex__", RID_COMPLEX, 0 },
2898 { "__const", RID_CONST, 0 },
2899 { "__const__", RID_CONST, 0 },
2900 { "__extension__", RID_EXTENSION, 0 },
2901 { "__imag", RID_IMAGPART, 0 },
2902 { "__imag__", RID_IMAGPART, 0 },
2903 { "__inline", RID_INLINE, 0 },
2904 { "__inline__", RID_INLINE, 0 },
2905 { "__label__", RID_LABEL, 0 },
2906 { "__ptrbase", RID_PTRBASE, 0 },
2907 { "__ptrbase__", RID_PTRBASE, 0 },
2908 { "__ptrextent", RID_PTREXTENT, 0 },
2909 { "__ptrextent__", RID_PTREXTENT, 0 },
2910 { "__ptrvalue", RID_PTRVALUE, 0 },
2911 { "__ptrvalue__", RID_PTRVALUE, 0 },
2912 { "__real", RID_REALPART, 0 },
2913 { "__real__", RID_REALPART, 0 },
2914 { "__restrict", RID_RESTRICT, 0 },
2915 { "__restrict__", RID_RESTRICT, 0 },
2916 { "__signed", RID_SIGNED, 0 },
2917 { "__signed__", RID_SIGNED, 0 },
2918 { "__typeof", RID_TYPEOF, 0 },
2919 { "__typeof__", RID_TYPEOF, 0 },
2920 { "__unbounded", RID_UNBOUNDED, 0 },
2921 { "__unbounded__", RID_UNBOUNDED, 0 },
2922 { "__volatile", RID_VOLATILE, 0 },
2923 { "__volatile__", RID_VOLATILE, 0 },
2924 { "asm", RID_ASM, D_EXT },
2925 { "auto", RID_AUTO, 0 },
2926 { "break", RID_BREAK, 0 },
2927 { "case", RID_CASE, 0 },
2928 { "char", RID_CHAR, 0 },
2929 { "const", RID_CONST, D_TRAD },
2930 { "continue", RID_CONTINUE, 0 },
2931 { "default", RID_DEFAULT, 0 },
2932 { "do", RID_DO, 0 },
2933 { "double", RID_DOUBLE, 0 },
2934 { "else", RID_ELSE, 0 },
2935 { "enum", RID_ENUM, 0 },
2936 { "extern", RID_EXTERN, 0 },
2937 { "float", RID_FLOAT, 0 },
2938 { "for", RID_FOR, 0 },
2939 { "goto", RID_GOTO, 0 },
2940 { "if", RID_IF, 0 },
2941 { "inline", RID_INLINE, D_TRAD|D_EXT89 },
2942 { "int", RID_INT, 0 },
2943 { "long", RID_LONG, 0 },
2944 { "register", RID_REGISTER, 0 },
2945 { "restrict", RID_RESTRICT, D_TRAD|D_C89 },
2946 { "return", RID_RETURN, 0 },
2947 { "short", RID_SHORT, 0 },
2948 { "signed", RID_SIGNED, D_TRAD },
2949 { "sizeof", RID_SIZEOF, 0 },
2950 { "static", RID_STATIC, 0 },
2951 { "struct", RID_STRUCT, 0 },
2952 { "switch", RID_SWITCH, 0 },
2953 { "typedef", RID_TYPEDEF, 0 },
2954 { "typeof", RID_TYPEOF, D_TRAD|D_EXT },
2955 { "union", RID_UNION, 0 },
2956 { "unsigned", RID_UNSIGNED, 0 },
2957 { "void", RID_VOID, 0 },
2958 { "volatile", RID_VOLATILE, D_TRAD },
2959 { "while", RID_WHILE, 0 },
2961 { "@class", RID_AT_CLASS, D_OBJC },
2962 { "@compatibility_alias", RID_AT_ALIAS, D_OBJC },
2963 { "@defs", RID_AT_DEFS, D_OBJC },
2964 { "@encode", RID_AT_ENCODE, D_OBJC },
2965 { "@end", RID_AT_END, D_OBJC },
2966 { "@implementation", RID_AT_IMPLEMENTATION, D_OBJC },
2967 { "@interface", RID_AT_INTERFACE, D_OBJC },
2968 { "@private", RID_AT_PRIVATE, D_OBJC },
2969 { "@protected", RID_AT_PROTECTED, D_OBJC },
2970 { "@protocol", RID_AT_PROTOCOL, D_OBJC },
2971 { "@public", RID_AT_PUBLIC, D_OBJC },
2972 { "@selector", RID_AT_SELECTOR, D_OBJC },
2973 { "id", RID_ID, D_OBJC },
2974 { "bycopy", RID_BYCOPY, D_OBJC },
2975 { "byref", RID_BYREF, D_OBJC },
2976 { "in", RID_IN, D_OBJC },
2977 { "inout", RID_INOUT, D_OBJC },
2978 { "oneway", RID_ONEWAY, D_OBJC },
2979 { "out", RID_OUT, D_OBJC },
2982 #define N_reswords (sizeof reswords / sizeof (struct resword))
2984 /* Table mapping from RID_* constants to yacc token numbers.
2985 Unfortunately we have to have entries for all the keywords in all
2987 static const short rid_to_yy[RID_MAX] =
2989 /* RID_STATIC */ SCSPEC,
2990 /* RID_UNSIGNED */ TYPESPEC,
2991 /* RID_LONG */ TYPESPEC,
2992 /* RID_CONST */ TYPE_QUAL,
2993 /* RID_EXTERN */ SCSPEC,
2994 /* RID_REGISTER */ SCSPEC,
2995 /* RID_TYPEDEF */ SCSPEC,
2996 /* RID_SHORT */ TYPESPEC,
2997 /* RID_INLINE */ SCSPEC,
2998 /* RID_VOLATILE */ TYPE_QUAL,
2999 /* RID_SIGNED */ TYPESPEC,
3000 /* RID_AUTO */ SCSPEC,
3001 /* RID_RESTRICT */ TYPE_QUAL,
3004 /* RID_BOUNDED */ TYPE_QUAL,
3005 /* RID_UNBOUNDED */ TYPE_QUAL,
3006 /* RID_COMPLEX */ TYPESPEC,
3010 /* RID_VIRTUAL */ 0,
3011 /* RID_EXPLICIT */ 0,
3013 /* RID_MUTABLE */ 0,
3016 /* RID_IN */ TYPE_QUAL,
3017 /* RID_OUT */ TYPE_QUAL,
3018 /* RID_INOUT */ TYPE_QUAL,
3019 /* RID_BYCOPY */ TYPE_QUAL,
3020 /* RID_BYREF */ TYPE_QUAL,
3021 /* RID_ONEWAY */ TYPE_QUAL,
3024 /* RID_INT */ TYPESPEC,
3025 /* RID_CHAR */ TYPESPEC,
3026 /* RID_FLOAT */ TYPESPEC,
3027 /* RID_DOUBLE */ TYPESPEC,
3028 /* RID_VOID */ TYPESPEC,
3029 /* RID_ENUM */ ENUM,
3030 /* RID_STRUCT */ STRUCT,
3031 /* RID_UNION */ UNION,
3033 /* RID_ELSE */ ELSE,
3034 /* RID_WHILE */ WHILE,
3037 /* RID_SWITCH */ SWITCH,
3038 /* RID_CASE */ CASE,
3039 /* RID_DEFAULT */ DEFAULT,
3040 /* RID_BREAK */ BREAK,
3041 /* RID_CONTINUE */ CONTINUE,
3042 /* RID_RETURN */ RETURN,
3043 /* RID_GOTO */ GOTO,
3044 /* RID_SIZEOF */ SIZEOF,
3047 /* RID_ASM */ ASM_KEYWORD,
3048 /* RID_TYPEOF */ TYPEOF,
3049 /* RID_ALIGNOF */ ALIGNOF,
3050 /* RID_ATTRIBUTE */ ATTRIBUTE,
3051 /* RID_VA_ARG */ VA_ARG,
3052 /* RID_EXTENSION */ EXTENSION,
3053 /* RID_IMAGPART */ IMAGPART,
3054 /* RID_REALPART */ REALPART,
3055 /* RID_LABEL */ LABEL,
3056 /* RID_PTRBASE */ PTR_BASE,
3057 /* RID_PTREXTENT */ PTR_EXTENT,
3058 /* RID_PTRVALUE */ PTR_VALUE,
3061 /* RID_BOOL */ TYPESPEC,
3065 /* RID_PRIVATE */ 0,
3066 /* RID_PROTECTED */ 0,
3067 /* RID_TEMPLATE */ 0,
3072 /* RID_NAMESPACE */ 0,
3074 /* RID_OPERATOR */ 0,
3079 /* RID_TYPENAME */ 0,
3084 /* RID_CONSTCAST */ 0,
3085 /* RID_DYNCAST */ 0,
3086 /* RID_REINTCAST */ 0,
3087 /* RID_STATCAST */ 0,
3089 /* alternate spellings */
3103 /* RID_ID */ OBJECTNAME,
3104 /* RID_AT_ENCODE */ ENCODE,
3105 /* RID_AT_END */ END,
3106 /* RID_AT_CLASS */ CLASS,
3107 /* RID_AT_ALIAS */ ALIAS,
3108 /* RID_AT_DEFS */ DEFS,
3109 /* RID_AT_PRIVATE */ PRIVATE,
3110 /* RID_AT_PROTECTED */ PROTECTED,
3111 /* RID_AT_PUBLIC */ PUBLIC,
3112 /* RID_AT_PROTOCOL */ PROTOCOL,
3113 /* RID_AT_SELECTOR */ SELECTOR,
3114 /* RID_AT_INTERFACE */ INTERFACE,
3115 /* RID_AT_IMPLEMENTATION */ IMPLEMENTATION
3119 /* Lookup table for ObjC keywords beginning with '@'. Crude but
3120 hopefully effective. */
3121 #define N_at_reswords ((int) RID_AT_IMPLEMENTATION - (int)RID_AT_ENCODE + 1)
3122 static tree objc_rid_sans_at[N_at_reswords];
3130 int mask = ((doing_objc_thang ? 0 : D_OBJC)
3131 | (flag_isoc99 ? 0 : D_C89)
3132 | (flag_traditional ? D_TRAD : 0)
3133 | (flag_no_asm ? (flag_isoc99 ? D_EXT : D_EXT|D_EXT89) : 0));
3135 /* It is not necessary to register ridpointers as a GC root, because
3136 all the trees it points to are permanently interned in the
3137 get_identifier hash anyway. */
3138 ridpointers = (tree *) xcalloc ((int) RID_MAX, sizeof (tree));
3139 for (i = 0; i < N_reswords; i++)
3141 /* If a keyword is disabled, do not enter it into the table
3142 and so create a canonical spelling that isn't a keyword. */
3143 if (reswords[i].disable & mask)
3146 id = get_identifier (reswords[i].word);
3147 C_RID_CODE (id) = reswords[i].rid;
3148 C_IS_RESERVED_WORD (id) = 1;
3149 ridpointers [(int) reswords[i].rid] = id;
3152 /* Enter ObjC @-prefixed keywords into the "sans" table
3153 _without_ their leading at-sign. Again, all these
3154 identifiers are reachable by the get_identifer table, so it's
3155 not necessary to make objc_rid_sans_at a GC root. */
3156 if (reswords[i].word[0] == '@')
3157 objc_rid_sans_at[(int) reswords[i].rid - (int) RID_AT_ENCODE]
3158 = get_identifier (reswords[i].word + 1);
3162 save_and_forget_protocol_qualifiers ();
3167 init_parse (filename)
3168 const char *filename;
3170 add_c_tree_codes ();
3172 /* Make identifier nodes long enough for the language-specific slots. */
3173 set_identifier_size (sizeof (struct lang_identifier));
3178 return init_c_lex (filename);
3184 cpp_finish (parse_in);
3185 /* Call to cpp_destroy () omitted for performance reasons. */
3186 errorcount += cpp_errors (parse_in);
3189 #define NAME(type) cpp_type2name (type)
3195 const char *string = _(msgid);
3197 if (last_token == CPP_EOF)
3198 error ("%s at end of input", string);
3199 else if (last_token == CPP_CHAR || last_token == CPP_WCHAR)
3201 unsigned int val = TREE_INT_CST_LOW (yylval.ttype);
3202 const char *ell = (last_token == CPP_CHAR) ? "" : "L";
3203 if (val <= UCHAR_MAX && ISGRAPH (val))
3204 error ("%s before %s'%c'", string, ell, val);
3206 error ("%s before %s'\\x%x'", string, ell, val);
3208 else if (last_token == CPP_STRING
3209 || last_token == CPP_WSTRING)
3210 error ("%s before string constant", string);
3211 else if (last_token == CPP_NUMBER
3212 || last_token == CPP_INT
3213 || last_token == CPP_FLOAT)
3214 error ("%s before numeric constant", string);
3215 else if (last_token == CPP_NAME)
3216 error ("%s before \"%s\"", string, IDENTIFIER_POINTER (yylval.ttype));
3218 error ("%s before '%s' token", string, NAME(last_token));
3226 if (C_IS_RESERVED_WORD (yylval.ttype))
3228 enum rid rid_code = C_RID_CODE (yylval.ttype);
3229 /* Return the canonical spelling for this keyword. */
3230 yylval.ttype = ridpointers[(int) rid_code];
3231 return rid_to_yy[(int) rid_code];
3234 decl = lookup_name (yylval.ttype);
3237 if (TREE_CODE (decl) == TYPE_DECL)
3239 /* A user-invisible read-only initialized variable
3240 should be replaced by its value.
3241 We handle only strings since that's the only case used in C. */
3242 else if (TREE_CODE (decl) == VAR_DECL
3243 && DECL_IGNORED_P (decl)
3244 && TREE_READONLY (decl)
3245 && DECL_INITIAL (decl) != 0
3246 && TREE_CODE (DECL_INITIAL (decl)) == STRING_CST)
3248 tree stringval = DECL_INITIAL (decl);
3250 /* Copy the string value so that we won't clobber anything
3251 if we put something in the TREE_CHAIN of this one. */
3252 yylval.ttype = build_string (TREE_STRING_LENGTH (stringval),
3253 TREE_STRING_POINTER (stringval));
3257 else if (doing_objc_thang)
3259 tree objc_interface_decl = is_class_name (yylval.ttype);
3261 if (objc_interface_decl)
3263 yylval.ttype = objc_interface_decl;
3276 last_token = c_lex (&yylval.ttype);
3282 case CPP_EQ: return '=';
3283 case CPP_NOT: return '!';
3284 case CPP_GREATER: yylval.code = GT_EXPR; return ARITHCOMPARE;
3285 case CPP_LESS: yylval.code = LT_EXPR; return ARITHCOMPARE;
3286 case CPP_PLUS: yylval.code = PLUS_EXPR; return '+';
3287 case CPP_MINUS: yylval.code = MINUS_EXPR; return '-';
3288 case CPP_MULT: yylval.code = MULT_EXPR; return '*';
3289 case CPP_DIV: yylval.code = TRUNC_DIV_EXPR; return '/';
3290 case CPP_MOD: yylval.code = TRUNC_MOD_EXPR; return '%';
3291 case CPP_AND: yylval.code = BIT_AND_EXPR; return '&';
3292 case CPP_OR: yylval.code = BIT_IOR_EXPR; return '|';
3293 case CPP_XOR: yylval.code = BIT_XOR_EXPR; return '^';
3294 case CPP_RSHIFT: yylval.code = RSHIFT_EXPR; return RSHIFT;
3295 case CPP_LSHIFT: yylval.code = LSHIFT_EXPR; return LSHIFT;
3297 case CPP_COMPL: return '~';
3298 case CPP_AND_AND: return ANDAND;
3299 case CPP_OR_OR: return OROR;
3300 case CPP_QUERY: return '?';
3301 case CPP_COLON: return ':';
3302 case CPP_COMMA: return ',';
3303 case CPP_OPEN_PAREN: return '(';
3304 case CPP_CLOSE_PAREN: return ')';
3305 case CPP_EQ_EQ: yylval.code = EQ_EXPR; return EQCOMPARE;
3306 case CPP_NOT_EQ: yylval.code = NE_EXPR; return EQCOMPARE;
3307 case CPP_GREATER_EQ:yylval.code = GE_EXPR; return ARITHCOMPARE;
3308 case CPP_LESS_EQ: yylval.code = LE_EXPR; return ARITHCOMPARE;
3310 case CPP_PLUS_EQ: yylval.code = PLUS_EXPR; return ASSIGN;
3311 case CPP_MINUS_EQ: yylval.code = MINUS_EXPR; return ASSIGN;
3312 case CPP_MULT_EQ: yylval.code = MULT_EXPR; return ASSIGN;
3313 case CPP_DIV_EQ: yylval.code = TRUNC_DIV_EXPR; return ASSIGN;
3314 case CPP_MOD_EQ: yylval.code = TRUNC_MOD_EXPR; return ASSIGN;
3315 case CPP_AND_EQ: yylval.code = BIT_AND_EXPR; return ASSIGN;
3316 case CPP_OR_EQ: yylval.code = BIT_IOR_EXPR; return ASSIGN;
3317 case CPP_XOR_EQ: yylval.code = BIT_XOR_EXPR; return ASSIGN;
3318 case CPP_RSHIFT_EQ: yylval.code = RSHIFT_EXPR; return ASSIGN;
3319 case CPP_LSHIFT_EQ: yylval.code = LSHIFT_EXPR; return ASSIGN;
3321 case CPP_OPEN_SQUARE: return '[';
3322 case CPP_CLOSE_SQUARE: return ']';
3323 case CPP_OPEN_BRACE: return '{';
3324 case CPP_CLOSE_BRACE: return '}';
3325 case CPP_SEMICOLON: return ';';
3326 case CPP_ELLIPSIS: return ELLIPSIS;
3328 case CPP_PLUS_PLUS: return PLUSPLUS;
3329 case CPP_MINUS_MINUS: return MINUSMINUS;
3330 case CPP_DEREF: return POINTSAT;
3331 case CPP_DOT: return '.';
3334 if (cpp_pop_buffer (parse_in) == 0)
3339 return yylexname ();
3352 /* This token is Objective-C specific. It gives the next
3353 token special significance. */
3356 last_token = c_lex (&yylval.ttype);
3357 if (last_token == CPP_STRING)
3359 else if (last_token == CPP_NAME)
3362 for (i = 0; i < N_at_reswords; i++)
3363 if (objc_rid_sans_at[i] == yylval.ttype)
3365 int rid_code = i + (int) RID_AT_ENCODE;
3366 yylval.ttype = ridpointers[rid_code];
3367 return rid_to_yy[rid_code];
3370 error ("syntax error at '@' token");
3373 /* These tokens are C++ specific (and will not be generated
3374 in C mode, but let's be cautious). */
3376 case CPP_DEREF_STAR:
3382 /* These tokens should not survive translation phase 4. */
3385 error ("syntax error at '%s' token", NAME(last_token));
3398 timevar_push (TV_LEX);
3400 timevar_pop (TV_LEX);
3404 /* Sets the value of the 'yydebug' variable to VALUE.
3405 This is a function so we don't have to have YYDEBUG defined
3406 in order to build the compiler. */
3415 warning ("YYDEBUG not defined.");
3419 /* Function used when yydebug is set, to print a token in more detail. */
3422 yyprint (file, yychar, yyl)
3429 fprintf (file, " [%s]", NAME(last_token));
3439 if (IDENTIFIER_POINTER (t))
3440 fprintf (file, " `%s'", IDENTIFIER_POINTER (t));
3444 fprintf (file, " %s", GET_MODE_NAME (TYPE_MODE (TREE_TYPE (t))));
3445 if (TREE_CODE (t) == INTEGER_CST)
3447 #if HOST_BITS_PER_WIDE_INT == 64
3448 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
3451 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
3458 #if HOST_BITS_PER_WIDE_INT != HOST_BITS_PER_INT
3464 TREE_INT_CST_HIGH (t), TREE_INT_CST_LOW (t));
3469 /* This is not the ideal place to put these, but we have to get them out
3470 of c-lex.c because cp/lex.c has its own versions. */
3472 /* Return something to represent absolute declarators containing a *.
3473 TARGET is the absolute declarator that the * contains.
3474 TYPE_QUALS is a list of modifiers such as const or volatile
3475 to apply to the pointer type, represented as identifiers.
3477 We return an INDIRECT_REF whose "contents" are TARGET
3478 and whose type is the modifier list. */
3481 make_pointer_declarator (type_quals, target)
3482 tree type_quals, target;
3484 return build1 (INDIRECT_REF, type_quals, target);