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 inline int _yylex PARAMS ((void));
267 static int yylex PARAMS ((void));
268 static void init_reswords PARAMS ((void));
270 /* Add GC roots for variables local to this file. */
274 ggc_add_tree_root (&declspec_stack, 1);
275 ggc_add_tree_root (¤t_declspecs, 1);
276 ggc_add_tree_root (&prefix_attributes, 1);
278 ggc_add_tree_root (&objc_interface_context, 1);
279 ggc_add_tree_root (&objc_implementation_context, 1);
280 ggc_add_tree_root (&objc_method_context, 1);
281 ggc_add_tree_root (&objc_ivar_chain, 1);
282 ggc_add_tree_root (&objc_ivar_context, 1);
291 pedwarn ("ISO C forbids an empty source file");
296 /* In case there were missing closebraces,
297 get us back to the global binding level. */
298 while (! global_bindings_p ())
304 /* the reason for the strange actions in this rule
305 is so that notype_initdecls when reached via datadef
306 can find a valid list of type and sc specs in $0. */
309 {$<ttype>$ = NULL_TREE; } extdef
310 | extdefs {$<ttype>$ = NULL_TREE; ggc_collect(); } extdef
319 | ASM_KEYWORD '(' expr ')' ';'
321 if ((TREE_CODE ($3) == ADDR_EXPR
322 && TREE_CODE (TREE_OPERAND ($3, 0)) == STRING_CST)
323 || TREE_CODE ($3) == STRING_CST)
326 error ("argument of `asm' is not a constant string"); }
328 { RESTORE_WARN_FLAGS ($1); }
332 setspecs notype_initdecls ';'
334 error ("ISO C forbids data definition with no type or storage class");
335 else if (!flag_traditional)
336 warning ("data definition has no type or storage class");
338 current_declspecs = TREE_VALUE (declspec_stack);
339 prefix_attributes = TREE_PURPOSE (declspec_stack);
340 declspec_stack = TREE_CHAIN (declspec_stack); }
341 | declmods setspecs notype_initdecls ';'
342 { current_declspecs = TREE_VALUE (declspec_stack);
343 prefix_attributes = TREE_PURPOSE (declspec_stack);
344 declspec_stack = TREE_CHAIN (declspec_stack); }
345 | typed_declspecs setspecs initdecls ';'
346 { current_declspecs = TREE_VALUE (declspec_stack);
347 prefix_attributes = TREE_PURPOSE (declspec_stack);
348 declspec_stack = TREE_CHAIN (declspec_stack); }
350 { pedwarn ("empty declaration"); }
351 | typed_declspecs ';'
357 pedwarn ("ISO C does not allow extra `;' outside of a function"); }
361 typed_declspecs setspecs declarator
362 { if (! start_function (current_declspecs, $3,
363 prefix_attributes, NULL_TREE))
367 { store_parm_decls (); }
368 save_filename save_lineno compstmt_or_error
369 { DECL_SOURCE_FILE (current_function_decl) = $7;
370 DECL_SOURCE_LINE (current_function_decl) = $8;
372 current_declspecs = TREE_VALUE (declspec_stack);
373 prefix_attributes = TREE_PURPOSE (declspec_stack);
374 declspec_stack = TREE_CHAIN (declspec_stack); }
375 | typed_declspecs setspecs declarator error
376 { current_declspecs = TREE_VALUE (declspec_stack);
377 prefix_attributes = TREE_PURPOSE (declspec_stack);
378 declspec_stack = TREE_CHAIN (declspec_stack); }
379 | declmods setspecs notype_declarator
380 { if (! start_function (current_declspecs, $3,
381 prefix_attributes, NULL_TREE))
385 { store_parm_decls (); }
386 save_filename save_lineno compstmt_or_error
387 { DECL_SOURCE_FILE (current_function_decl) = $7;
388 DECL_SOURCE_LINE (current_function_decl) = $8;
390 current_declspecs = TREE_VALUE (declspec_stack);
391 prefix_attributes = TREE_PURPOSE (declspec_stack);
392 declspec_stack = TREE_CHAIN (declspec_stack); }
393 | declmods setspecs notype_declarator error
394 { current_declspecs = TREE_VALUE (declspec_stack);
395 prefix_attributes = TREE_PURPOSE (declspec_stack);
396 declspec_stack = TREE_CHAIN (declspec_stack); }
397 | setspecs notype_declarator
398 { if (! start_function (NULL_TREE, $2,
399 prefix_attributes, NULL_TREE))
403 { store_parm_decls (); }
404 save_filename save_lineno compstmt_or_error
405 { DECL_SOURCE_FILE (current_function_decl) = $6;
406 DECL_SOURCE_LINE (current_function_decl) = $7;
408 current_declspecs = TREE_VALUE (declspec_stack);
409 prefix_attributes = TREE_PURPOSE (declspec_stack);
410 declspec_stack = TREE_CHAIN (declspec_stack); }
411 | setspecs notype_declarator error
412 { current_declspecs = TREE_VALUE (declspec_stack);
413 prefix_attributes = TREE_PURPOSE (declspec_stack);
414 declspec_stack = TREE_CHAIN (declspec_stack); }
429 { $$ = NEGATE_EXPR; }
433 if (warn_traditional && !in_system_header)
434 warning ("traditional C rejects the unary plus operator");
438 { $$ = PREINCREMENT_EXPR; }
440 { $$ = PREDECREMENT_EXPR; }
442 { $$ = BIT_NOT_EXPR; }
444 { $$ = TRUTH_NOT_EXPR; }
447 expr: nonnull_exprlist
448 { $$ = build_compound_expr ($1); }
459 { $$ = build_tree_list (NULL_TREE, $1); }
460 | nonnull_exprlist ',' expr_no_commas
461 { chainon ($1, build_tree_list (NULL_TREE, $3)); }
466 | '*' cast_expr %prec UNARY
467 { $$ = build_indirect_ref ($2, "unary *"); }
468 /* __extension__ turns off -pedantic for following primary. */
469 | extension cast_expr %prec UNARY
471 RESTORE_WARN_FLAGS ($1); }
472 | unop cast_expr %prec UNARY
473 { $$ = build_unary_op ($1, $2, 0);
474 overflow_warning ($$); }
475 /* Refer to the address of a label as a pointer. */
477 { tree label = lookup_label ($2);
479 pedwarn ("ISO C forbids `&&'");
481 $$ = null_pointer_node;
484 TREE_USED (label) = 1;
485 $$ = build1 (ADDR_EXPR, ptr_type_node, label);
486 TREE_CONSTANT ($$) = 1;
489 /* This seems to be impossible on some machines, so let's turn it off.
490 You can use __builtin_next_arg to find the anonymous stack args.
492 { tree types = TYPE_ARG_TYPES (TREE_TYPE (current_function_decl));
493 $$ = error_mark_node;
494 if (TREE_VALUE (tree_last (types)) == void_type_node)
495 error ("`&...' used in function with fixed number of arguments");
499 pedwarn ("ISO C forbids `&...'");
500 $$ = tree_last (DECL_ARGUMENTS (current_function_decl));
501 $$ = build_unary_op (ADDR_EXPR, $$, 0);
504 | sizeof unary_expr %prec UNARY
506 if (TREE_CODE ($2) == COMPONENT_REF
507 && DECL_C_BIT_FIELD (TREE_OPERAND ($2, 1)))
508 error ("`sizeof' applied to a bit-field");
509 $$ = c_sizeof (TREE_TYPE ($2)); }
510 | sizeof '(' typename ')' %prec HYPERUNARY
512 $$ = c_sizeof (groktypename ($3)); }
513 | alignof unary_expr %prec UNARY
515 $$ = c_alignof_expr ($2); }
516 | alignof '(' typename ')' %prec HYPERUNARY
518 $$ = c_alignof (groktypename ($3)); }
519 | REALPART cast_expr %prec UNARY
520 { $$ = build_unary_op (REALPART_EXPR, $2, 0); }
521 | IMAGPART cast_expr %prec UNARY
522 { $$ = build_unary_op (IMAGPART_EXPR, $2, 0); }
526 SIZEOF { skip_evaluation++; }
530 ALIGNOF { skip_evaluation++; }
535 | '(' typename ')' cast_expr %prec UNARY
537 int SAVED_warn_strict_prototypes = warn_strict_prototypes;
538 /* This avoids warnings about unprototyped casts on
539 integers. E.g. "#define SIG_DFL (void(*)())0". */
540 if (TREE_CODE ($4) == INTEGER_CST)
541 warn_strict_prototypes = 0;
542 type = groktypename ($2);
543 warn_strict_prototypes = SAVED_warn_strict_prototypes;
544 $$ = build_c_cast (type, $4); }
549 | expr_no_commas '+' expr_no_commas
550 { $$ = parser_build_binary_op ($2, $1, $3); }
551 | expr_no_commas '-' expr_no_commas
552 { $$ = parser_build_binary_op ($2, $1, $3); }
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 LSHIFT expr_no_commas
560 { $$ = parser_build_binary_op ($2, $1, $3); }
561 | expr_no_commas RSHIFT expr_no_commas
562 { $$ = parser_build_binary_op ($2, $1, $3); }
563 | expr_no_commas ARITHCOMPARE expr_no_commas
564 { $$ = parser_build_binary_op ($2, $1, $3); }
565 | expr_no_commas EQCOMPARE expr_no_commas
566 { $$ = parser_build_binary_op ($2, $1, $3); }
567 | expr_no_commas '&' expr_no_commas
568 { $$ = parser_build_binary_op ($2, $1, $3); }
569 | expr_no_commas '|' 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 ANDAND
574 { $1 = truthvalue_conversion (default_conversion ($1));
575 skip_evaluation += $1 == boolean_false_node; }
577 { skip_evaluation -= $1 == boolean_false_node;
578 $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $4); }
579 | expr_no_commas OROR
580 { $1 = truthvalue_conversion (default_conversion ($1));
581 skip_evaluation += $1 == boolean_true_node; }
583 { skip_evaluation -= $1 == boolean_true_node;
584 $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $4); }
586 { $1 = truthvalue_conversion (default_conversion ($1));
587 skip_evaluation += $1 == boolean_false_node; }
589 { skip_evaluation += (($1 == boolean_true_node)
590 - ($1 == boolean_false_node)); }
592 { skip_evaluation -= $1 == boolean_true_node;
593 $$ = build_conditional_expr ($1, $4, $7); }
596 pedwarn ("ISO C forbids omitting the middle term of a ?: expression");
597 /* Make sure first operand is calculated only once. */
598 $<ttype>2 = save_expr ($1);
599 $1 = truthvalue_conversion (default_conversion ($<ttype>2));
600 skip_evaluation += $1 == boolean_true_node; }
602 { skip_evaluation -= $1 == boolean_true_node;
603 $$ = build_conditional_expr ($1, $<ttype>2, $5); }
604 | expr_no_commas '=' expr_no_commas
606 $$ = build_modify_expr ($1, NOP_EXPR, $3);
607 class = TREE_CODE_CLASS (TREE_CODE ($$));
608 if (class == 'e' || class == '1'
609 || class == '2' || class == '<')
610 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR);
612 | expr_no_commas ASSIGN expr_no_commas
614 $$ = build_modify_expr ($1, $2, $3);
615 /* This inhibits warnings in truthvalue_conversion. */
616 class = TREE_CODE_CLASS (TREE_CODE ($$));
617 if (class == 'e' || class == '1'
618 || class == '2' || class == '<')
619 C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK);
626 if (yychar == YYEMPTY)
628 $$ = build_external_ref ($1, yychar == '(');
632 { $$ = combine_strings ($1); }
633 | '(' typename ')' '{'
634 { start_init (NULL_TREE, NULL, 0);
635 $2 = groktypename ($2);
636 really_start_incremental_init ($2); }
637 initlist_maybe_comma '}' %prec UNARY
639 tree result = pop_init_level (0);
643 if (pedantic && ! flag_isoc99)
644 pedwarn ("ISO C89 forbids compound literals");
645 if (TYPE_NAME (type) != 0)
647 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
648 name = IDENTIFIER_POINTER (TYPE_NAME (type));
650 name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
655 if (TREE_CODE (type) == ARRAY_TYPE && !COMPLETE_TYPE_P (type))
657 int failure = complete_array_type (type, $$, 1);
663 { char class = TREE_CODE_CLASS (TREE_CODE ($2));
664 if (class == 'e' || class == '1'
665 || class == '2' || class == '<')
666 C_SET_EXP_ORIGINAL_CODE ($2, ERROR_MARK);
669 { $$ = error_mark_node; }
670 | compstmt_primary_start compstmt_nostart ')'
671 { tree saved_last_tree;
674 pedwarn ("ISO C forbids braced-groups within expressions");
677 saved_last_tree = COMPOUND_BODY ($1);
678 RECHAIN_STMTS ($1, COMPOUND_BODY ($1));
679 last_tree = saved_last_tree;
680 TREE_CHAIN (last_tree) = NULL_TREE;
682 last_expr_type = void_type_node;
683 $$ = build1 (STMT_EXPR, last_expr_type, $1);
684 TREE_SIDE_EFFECTS ($$) = 1;
686 | compstmt_primary_start error ')'
689 last_tree = COMPOUND_BODY ($1);
690 TREE_CHAIN (last_tree) = NULL_TREE;
691 $$ = error_mark_node;
693 | primary '(' exprlist ')' %prec '.'
694 { $$ = build_function_call ($1, $3); }
695 | VA_ARG '(' expr_no_commas ',' typename ')'
696 { $$ = build_va_arg ($3, groktypename ($5)); }
697 | primary '[' expr ']' %prec '.'
698 { $$ = build_array_ref ($1, $3); }
699 | primary '.' identifier
702 if (doing_objc_thang)
704 if (is_public ($1, $3))
705 $$ = build_component_ref ($1, $3);
707 $$ = error_mark_node;
711 $$ = build_component_ref ($1, $3);
713 | primary POINTSAT identifier
715 tree expr = build_indirect_ref ($1, "->");
718 if (doing_objc_thang)
720 if (is_public (expr, $3))
721 $$ = build_component_ref (expr, $3);
723 $$ = error_mark_node;
727 $$ = build_component_ref (expr, $3);
730 { $$ = build_unary_op (POSTINCREMENT_EXPR, $1, 0); }
732 { $$ = build_unary_op (POSTDECREMENT_EXPR, $1, 0); }
735 { $$ = build_message_expr ($1); }
737 { $$ = build_selector_expr ($1); }
739 { $$ = build_protocol_expr ($1); }
741 { $$ = build_encode_expr ($1); }
743 { $$ = build_objc_string_object ($1); }
747 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
753 static int last_lineno = 0;
754 static const char *last_input_filename = 0;
756 $$ = chainon ($1, $2);
758 if (warn_traditional && !in_system_header
759 && (lineno != last_lineno || !last_input_filename ||
760 strcmp (last_input_filename, input_filename)))
762 warning ("traditional C rejects string concatenation");
763 last_lineno = lineno;
764 last_input_filename = input_filename;
771 /* Produces an STRING_CST with perhaps more STRING_CSTs chained
772 onto it, which is to be read as an ObjC string object. */
775 | objc_string OBJC_STRING
776 { $$ = chainon ($1, $2); }
780 old_style_parm_decls:
784 /* ... is used here to indicate a varargs function. */
787 pedwarn ("ISO C does not permit use of `varargs.h'"); }
790 /* The following are analogous to lineno_decl, decls and decl
791 except that they do not allow nested functions.
792 They are used for old-style parm decls. */
794 save_filename save_lineno datadecl
801 | datadecls lineno_datadecl
802 | lineno_datadecl errstmt
805 /* We don't allow prefix attributes here because they cause reduce/reduce
806 conflicts: we can't know whether we're parsing a function decl with
807 attribute suffix, or function defn with attribute prefix on first old
810 typed_declspecs_no_prefix_attr setspecs initdecls ';'
811 { current_declspecs = TREE_VALUE (declspec_stack);
812 prefix_attributes = TREE_PURPOSE (declspec_stack);
813 declspec_stack = TREE_CHAIN (declspec_stack); }
814 | declmods_no_prefix_attr setspecs notype_initdecls ';'
815 { current_declspecs = TREE_VALUE (declspec_stack);
816 prefix_attributes = TREE_PURPOSE (declspec_stack);
817 declspec_stack = TREE_CHAIN (declspec_stack); }
818 | typed_declspecs_no_prefix_attr ';'
819 { shadow_tag_warned ($1, 1);
820 pedwarn ("empty declaration"); }
821 | declmods_no_prefix_attr ';'
822 { pedwarn ("empty declaration"); }
825 /* This combination which saves a lineno before a decl
826 is the normal thing to use, rather than decl itself.
827 This is to avoid shift/reduce conflicts in contexts
828 where statement labels are allowed. */
830 save_filename save_lineno decl
834 /* records the type and storage class specs to use for processing
835 the declarators that follow.
836 Maintains a stack of outer-level values of current_declspecs,
837 for the sake of parm declarations nested in function declarators. */
838 setspecs: /* empty */
839 { pending_xref_error ();
840 declspec_stack = tree_cons (prefix_attributes,
843 split_specs_attrs ($<ttype>0,
844 ¤t_declspecs, &prefix_attributes); }
847 /* ??? Yuck. See after_type_declarator. */
848 setattrs: /* empty */
849 { prefix_attributes = chainon (prefix_attributes, $<ttype>0); }
853 typed_declspecs setspecs initdecls ';'
854 { current_declspecs = TREE_VALUE (declspec_stack);
855 prefix_attributes = TREE_PURPOSE (declspec_stack);
856 declspec_stack = TREE_CHAIN (declspec_stack); }
857 | declmods setspecs notype_initdecls ';'
858 { current_declspecs = TREE_VALUE (declspec_stack);
859 prefix_attributes = TREE_PURPOSE (declspec_stack);
860 declspec_stack = TREE_CHAIN (declspec_stack); }
861 | typed_declspecs setspecs nested_function
862 { current_declspecs = TREE_VALUE (declspec_stack);
863 prefix_attributes = TREE_PURPOSE (declspec_stack);
864 declspec_stack = TREE_CHAIN (declspec_stack); }
865 | declmods setspecs notype_nested_function
866 { current_declspecs = TREE_VALUE (declspec_stack);
867 prefix_attributes = TREE_PURPOSE (declspec_stack);
868 declspec_stack = TREE_CHAIN (declspec_stack); }
869 | typed_declspecs ';'
872 { pedwarn ("empty declaration"); }
874 { RESTORE_WARN_FLAGS ($1); }
877 /* Declspecs which contain at least one type specifier or typedef name.
878 (Just `const' or `volatile' is not enough.)
879 A typedef'd name following these is taken as a name to be declared.
880 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
883 typespec reserved_declspecs
884 { $$ = tree_cons (NULL_TREE, $1, $2); }
885 | declmods typespec reserved_declspecs
886 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
889 reserved_declspecs: /* empty */
891 | reserved_declspecs typespecqual_reserved
892 { $$ = tree_cons (NULL_TREE, $2, $1); }
893 | reserved_declspecs SCSPEC
894 { if (extra_warnings)
895 warning ("`%s' is not at beginning of declaration",
896 IDENTIFIER_POINTER ($2));
897 $$ = tree_cons (NULL_TREE, $2, $1); }
898 | reserved_declspecs attributes
899 { $$ = tree_cons ($2, NULL_TREE, $1); }
902 typed_declspecs_no_prefix_attr:
903 typespec reserved_declspecs_no_prefix_attr
904 { $$ = tree_cons (NULL_TREE, $1, $2); }
905 | declmods_no_prefix_attr typespec reserved_declspecs_no_prefix_attr
906 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
909 reserved_declspecs_no_prefix_attr:
912 | reserved_declspecs_no_prefix_attr typespecqual_reserved
913 { $$ = tree_cons (NULL_TREE, $2, $1); }
914 | reserved_declspecs_no_prefix_attr SCSPEC
915 { if (extra_warnings)
916 warning ("`%s' is not at beginning of declaration",
917 IDENTIFIER_POINTER ($2));
918 $$ = tree_cons (NULL_TREE, $2, $1); }
921 /* List of just storage classes, type modifiers, and prefix attributes.
922 A declaration can start with just this, but then it cannot be used
923 to redeclare a typedef-name.
924 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
927 declmods_no_prefix_attr
930 { $$ = tree_cons ($1, NULL_TREE, NULL_TREE); }
931 | declmods declmods_no_prefix_attr
932 { $$ = chainon ($2, $1); }
933 | declmods attributes
934 { $$ = tree_cons ($2, NULL_TREE, $1); }
937 declmods_no_prefix_attr:
939 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
940 TREE_STATIC ($$) = 1; }
942 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
943 | declmods_no_prefix_attr TYPE_QUAL
944 { $$ = tree_cons (NULL_TREE, $2, $1);
945 TREE_STATIC ($$) = 1; }
946 | declmods_no_prefix_attr SCSPEC
947 { if (extra_warnings && TREE_STATIC ($1))
948 warning ("`%s' is not at beginning of declaration",
949 IDENTIFIER_POINTER ($2));
950 $$ = tree_cons (NULL_TREE, $2, $1);
951 TREE_STATIC ($$) = TREE_STATIC ($1); }
955 /* Used instead of declspecs where storage classes are not allowed
956 (that is, for typenames and structure components).
957 Don't accept a typedef-name if anything but a modifier precedes it. */
960 typespec reserved_typespecquals
961 { $$ = tree_cons (NULL_TREE, $1, $2); }
962 | nonempty_type_quals typespec reserved_typespecquals
963 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
966 reserved_typespecquals: /* empty */
968 | reserved_typespecquals typespecqual_reserved
969 { $$ = tree_cons (NULL_TREE, $2, $1); }
972 /* A typespec (but not a type qualifier).
973 Once we have seen one of these in a declaration,
974 if a typedef name appears then it is being redeclared. */
979 { /* For a typedef name, record the meaning, not the name.
980 In case of `foo foo, bar;'. */
981 $$ = lookup_name ($1); }
983 | CLASSNAME protocolrefs
984 { $$ = get_static_reference ($1, $2); }
985 | OBJECTNAME protocolrefs
986 { $$ = get_object_reference ($2); }
988 /* Make "<SomeProtocol>" equivalent to "id <SomeProtocol>"
989 - nisse@lysator.liu.se */
990 | non_empty_protocolrefs
991 { $$ = get_object_reference ($1); }
993 | TYPEOF '(' expr ')'
994 { $$ = TREE_TYPE ($3); }
995 | TYPEOF '(' typename ')'
996 { $$ = groktypename ($3); }
999 /* A typespec that is a reserved word, or a type qualifier. */
1001 typespecqual_reserved: TYPESPEC
1008 | initdecls ',' initdcl
1013 | notype_initdecls ',' initdcl
1019 | ASM_KEYWORD '(' string ')'
1020 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
1026 declarator maybeasm maybe_attribute '='
1027 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1028 $3, prefix_attributes);
1029 start_init ($<ttype>$, $2, global_bindings_p ()); }
1031 /* Note how the declaration of the variable is in effect while its init is parsed! */
1033 finish_decl ($<ttype>5, $6, $2); }
1034 | declarator maybeasm maybe_attribute
1035 { tree d = start_decl ($1, current_declspecs, 0,
1036 $3, prefix_attributes);
1037 finish_decl (d, NULL_TREE, $2);
1042 notype_declarator maybeasm maybe_attribute '='
1043 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1044 $3, prefix_attributes);
1045 start_init ($<ttype>$, $2, global_bindings_p ()); }
1047 /* Note how the declaration of the variable is in effect while its init is parsed! */
1049 decl_attributes ($<ttype>5, $3, prefix_attributes);
1050 finish_decl ($<ttype>5, $6, $2); }
1051 | notype_declarator maybeasm maybe_attribute
1052 { tree d = start_decl ($1, current_declspecs, 0,
1053 $3, prefix_attributes);
1054 finish_decl (d, NULL_TREE, $2); }
1056 /* the * rules are dummies to accept the Apollo extended syntax
1057 so that the header files compile. */
1068 | attributes attribute
1069 { $$ = chainon ($1, $2); }
1073 ATTRIBUTE '(' '(' attribute_list ')' ')'
1080 | attribute_list ',' attrib
1081 { $$ = chainon ($1, $3); }
1088 { $$ = build_tree_list ($1, NULL_TREE); }
1089 | any_word '(' IDENTIFIER ')'
1090 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1091 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1092 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1093 | any_word '(' exprlist ')'
1094 { $$ = build_tree_list ($1, $3); }
1097 /* This still leaves out most reserved keywords,
1098 shouldn't we include them? */
1107 /* Initializers. `init' is the entry point. */
1112 { really_start_incremental_init (NULL_TREE); }
1113 initlist_maybe_comma '}'
1114 { $$ = pop_init_level (0); }
1116 { $$ = error_mark_node; }
1119 /* `initlist_maybe_comma' is the guts of an initializer in braces. */
1120 initlist_maybe_comma:
1123 pedwarn ("ISO C forbids empty initializer braces"); }
1124 | initlist1 maybecomma
1129 | initlist1 ',' initelt
1132 /* `initelt' is a single element of an initializer.
1133 It may use braces. */
1135 designator_list '=' initval
1136 { if (pedantic && ! flag_isoc99)
1137 pedwarn ("ISO C89 forbids specifying subobject to initialize"); }
1138 | designator initval
1140 pedwarn ("obsolete use of designated initializer without `='"); }
1142 { set_init_label ($1);
1144 pedwarn ("obsolete use of designated initializer with `:'"); }
1151 { push_init_level (0); }
1152 initlist_maybe_comma '}'
1153 { process_init_element (pop_init_level (0)); }
1155 { process_init_element ($1); }
1161 | designator_list designator
1166 { set_init_label ($2); }
1167 /* These are for labeled elements. The syntax for an array element
1168 initializer conflicts with the syntax for an Objective-C message,
1169 so don't include these productions in the Objective-C grammar. */
1171 | '[' expr_no_commas ELLIPSIS expr_no_commas ']'
1172 { set_init_index ($2, $4);
1174 pedwarn ("ISO C forbids specifying range of elements to initialize"); }
1175 | '[' expr_no_commas ']'
1176 { set_init_index ($2, NULL_TREE); }
1183 pedwarn ("ISO C forbids nested functions");
1185 push_function_context ();
1186 if (! start_function (current_declspecs, $1,
1187 prefix_attributes, NULL_TREE))
1189 pop_function_context ();
1193 old_style_parm_decls
1194 { store_parm_decls (); }
1195 /* This used to use compstmt_or_error.
1196 That caused a bug with input `f(g) int g {}',
1197 where the use of YYERROR1 above caused an error
1198 which then was handled by compstmt_or_error.
1199 There followed a repeated execution of that same rule,
1200 which called YYERROR1 again, and so on. */
1201 save_filename save_lineno compstmt
1202 { tree decl = current_function_decl;
1203 DECL_SOURCE_FILE (decl) = $5;
1204 DECL_SOURCE_LINE (decl) = $6;
1205 finish_function (1);
1206 pop_function_context ();
1207 add_decl_stmt (decl); }
1210 notype_nested_function:
1213 pedwarn ("ISO C forbids nested functions");
1215 push_function_context ();
1216 if (! start_function (current_declspecs, $1,
1217 prefix_attributes, NULL_TREE))
1219 pop_function_context ();
1223 old_style_parm_decls
1224 { store_parm_decls (); }
1225 /* This used to use compstmt_or_error.
1226 That caused a bug with input `f(g) int g {}',
1227 where the use of YYERROR1 above caused an error
1228 which then was handled by compstmt_or_error.
1229 There followed a repeated execution of that same rule,
1230 which called YYERROR1 again, and so on. */
1231 save_filename save_lineno compstmt
1232 { tree decl = current_function_decl;
1233 DECL_SOURCE_FILE (decl) = $5;
1234 DECL_SOURCE_LINE (decl) = $6;
1235 finish_function (1);
1236 pop_function_context ();
1237 add_decl_stmt (decl); }
1240 /* Any kind of declarator (thus, all declarators allowed
1241 after an explicit typespec). */
1244 after_type_declarator
1248 /* A declarator that is allowed only after an explicit typespec. */
1250 after_type_declarator:
1251 '(' after_type_declarator ')'
1253 | after_type_declarator '(' parmlist_or_identifiers %prec '.'
1254 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1255 /* | after_type_declarator '(' error ')' %prec '.'
1256 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1257 poplevel (0, 0, 0); } */
1258 | after_type_declarator '[' expr ']' %prec '.'
1259 { $$ = build_nt (ARRAY_REF, $1, $3); }
1260 | after_type_declarator '[' ']' %prec '.'
1261 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1262 | '*' type_quals after_type_declarator %prec UNARY
1263 { $$ = make_pointer_declarator ($2, $3); }
1264 /* ??? Yuck. setattrs is a quick hack. We can't use
1265 prefix_attributes because $1 only applies to this
1266 declarator. We assume setspecs has already been done.
1267 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1268 attributes could be recognized here or in `attributes'). */
1269 | attributes setattrs after_type_declarator
1277 /* Kinds of declarator that can appear in a parameter list
1278 in addition to notype_declarator. This is like after_type_declarator
1279 but does not allow a typedef name in parentheses as an identifier
1280 (because it would conflict with a function with that typedef as arg). */
1283 parm_declarator '(' parmlist_or_identifiers %prec '.'
1284 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1285 /* | parm_declarator '(' error ')' %prec '.'
1286 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1287 poplevel (0, 0, 0); } */
1289 | parm_declarator '[' '*' ']' %prec '.'
1290 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE);
1292 error ("`[*]' in parameter declaration only allowed in ISO C 99");
1295 | parm_declarator '[' expr ']' %prec '.'
1296 { $$ = build_nt (ARRAY_REF, $1, $3); }
1297 | parm_declarator '[' ']' %prec '.'
1298 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1299 | '*' type_quals parm_declarator %prec UNARY
1300 { $$ = make_pointer_declarator ($2, $3); }
1301 /* ??? Yuck. setattrs is a quick hack. We can't use
1302 prefix_attributes because $1 only applies to this
1303 declarator. We assume setspecs has already been done.
1304 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1305 attributes could be recognized here or in `attributes'). */
1306 | attributes setattrs parm_declarator
1311 /* A declarator allowed whether or not there has been
1312 an explicit typespec. These cannot redeclare a typedef-name. */
1315 notype_declarator '(' parmlist_or_identifiers %prec '.'
1316 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1317 /* | notype_declarator '(' error ')' %prec '.'
1318 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1319 poplevel (0, 0, 0); } */
1320 | '(' notype_declarator ')'
1322 | '*' type_quals notype_declarator %prec UNARY
1323 { $$ = make_pointer_declarator ($2, $3); }
1325 | notype_declarator '[' '*' ']' %prec '.'
1326 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE);
1328 error ("`[*]' in parameter declaration only allowed in ISO C 99");
1331 | notype_declarator '[' expr ']' %prec '.'
1332 { $$ = build_nt (ARRAY_REF, $1, $3); }
1333 | notype_declarator '[' ']' %prec '.'
1334 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1335 /* ??? Yuck. setattrs is a quick hack. We can't use
1336 prefix_attributes because $1 only applies to this
1337 declarator. We assume setspecs has already been done.
1338 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1339 attributes could be recognized here or in `attributes'). */
1340 | attributes setattrs notype_declarator
1367 struct_head identifier '{'
1368 { $$ = start_struct (RECORD_TYPE, $2);
1369 /* Start scope of tag before parsing components. */
1371 component_decl_list '}' maybe_attribute
1372 { $$ = finish_struct ($<ttype>4, $5, chainon ($1, $7)); }
1373 | struct_head '{' component_decl_list '}' maybe_attribute
1374 { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
1375 $3, chainon ($1, $5));
1377 | struct_head identifier
1378 { $$ = xref_tag (RECORD_TYPE, $2); }
1379 | union_head identifier '{'
1380 { $$ = start_struct (UNION_TYPE, $2); }
1381 component_decl_list '}' maybe_attribute
1382 { $$ = finish_struct ($<ttype>4, $5, chainon ($1, $7)); }
1383 | union_head '{' component_decl_list '}' maybe_attribute
1384 { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
1385 $3, chainon ($1, $5));
1387 | union_head identifier
1388 { $$ = xref_tag (UNION_TYPE, $2); }
1389 | enum_head identifier '{'
1390 { $$ = start_enum ($2); }
1391 enumlist maybecomma_warn '}' maybe_attribute
1392 { $$ = finish_enum ($<ttype>4, nreverse ($5),
1393 chainon ($1, $8)); }
1395 { $$ = start_enum (NULL_TREE); }
1396 enumlist maybecomma_warn '}' maybe_attribute
1397 { $$ = finish_enum ($<ttype>3, nreverse ($4),
1398 chainon ($1, $7)); }
1399 | enum_head identifier
1400 { $$ = xref_tag (ENUMERAL_TYPE, $2);
1401 /* In ISO C, enumerated types can be referred to
1402 only if already defined. */
1403 if (pedantic && !COMPLETE_TYPE_P ($$))
1404 pedwarn ("ISO C forbids forward references to `enum' types"); }
1415 { if (pedantic && ! flag_isoc99)
1416 pedwarn ("comma at end of enumerator list"); }
1419 component_decl_list:
1420 component_decl_list2
1422 | component_decl_list2 component_decl
1423 { $$ = chainon ($1, $2);
1424 pedwarn ("no semicolon at end of struct or union"); }
1427 component_decl_list2: /* empty */
1429 | component_decl_list2 component_decl ';'
1430 { $$ = chainon ($1, $2); }
1431 | component_decl_list2 ';'
1433 pedwarn ("extra semicolon in struct or union specified"); }
1435 /* foo(sizeof(struct{ @defs(ClassName)})); */
1436 | DEFS '(' CLASSNAME ')'
1438 tree interface = lookup_interface ($3);
1441 $$ = get_class_ivars (interface);
1444 error ("Cannot find interface declaration for `%s'",
1445 IDENTIFIER_POINTER ($3));
1452 /* There is a shift-reduce conflict here, because `components' may
1453 start with a `typename'. It happens that shifting (the default resolution)
1454 does the right thing, because it treats the `typename' as part of
1455 a `typed_typespecs'.
1457 It is possible that this same technique would allow the distinction
1458 between `notype_initdecls' and `initdecls' to be eliminated.
1459 But I am being cautious and not trying it. */
1462 typed_typespecs setspecs components
1464 current_declspecs = TREE_VALUE (declspec_stack);
1465 prefix_attributes = TREE_PURPOSE (declspec_stack);
1466 declspec_stack = TREE_CHAIN (declspec_stack); }
1467 | typed_typespecs setspecs save_filename save_lineno maybe_attribute
1469 /* Support for unnamed structs or unions as members of
1470 structs or unions (which is [a] useful and [b] supports
1473 pedwarn ("ISO C doesn't support unnamed structs/unions");
1475 $$ = grokfield($3, $4, NULL, current_declspecs, NULL_TREE);
1476 current_declspecs = TREE_VALUE (declspec_stack);
1477 prefix_attributes = TREE_PURPOSE (declspec_stack);
1478 declspec_stack = TREE_CHAIN (declspec_stack);
1480 | nonempty_type_quals setspecs components
1482 current_declspecs = TREE_VALUE (declspec_stack);
1483 prefix_attributes = TREE_PURPOSE (declspec_stack);
1484 declspec_stack = TREE_CHAIN (declspec_stack); }
1485 | nonempty_type_quals
1487 pedwarn ("ISO C forbids member declarations with no members");
1492 | extension component_decl
1494 RESTORE_WARN_FLAGS ($1); }
1498 component_declarator
1499 | components ',' component_declarator
1500 { $$ = chainon ($1, $3); }
1503 component_declarator:
1504 save_filename save_lineno declarator maybe_attribute
1505 { $$ = grokfield ($1, $2, $3, current_declspecs, NULL_TREE);
1506 decl_attributes ($$, $4, prefix_attributes); }
1507 | save_filename save_lineno
1508 declarator ':' expr_no_commas maybe_attribute
1509 { $$ = grokfield ($1, $2, $3, current_declspecs, $5);
1510 decl_attributes ($$, $6, prefix_attributes); }
1511 | save_filename save_lineno ':' expr_no_commas maybe_attribute
1512 { $$ = grokfield ($1, $2, NULL_TREE, current_declspecs, $4);
1513 decl_attributes ($$, $5, prefix_attributes); }
1516 /* We chain the enumerators in reverse order.
1517 They are put in forward order where enumlist is used.
1518 (The order used to be significant, but no longer is so.
1519 However, we still maintain the order, just to be clean.) */
1523 | enumlist ',' enumerator
1524 { if ($1 == error_mark_node)
1527 $$ = chainon ($3, $1); }
1529 { $$ = error_mark_node; }
1535 { $$ = build_enumerator ($1, NULL_TREE); }
1536 | identifier '=' expr_no_commas
1537 { $$ = build_enumerator ($1, $3); }
1542 { pending_xref_error (); }
1544 { $$ = build_tree_list ($1, $3); }
1545 | nonempty_type_quals absdcl
1546 { $$ = build_tree_list ($1, $2); }
1549 absdcl: /* an absolute declarator */
1555 nonempty_type_quals:
1557 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
1558 | nonempty_type_quals TYPE_QUAL
1559 { $$ = tree_cons (NULL_TREE, $2, $1); }
1565 | type_quals TYPE_QUAL
1566 { $$ = tree_cons (NULL_TREE, $2, $1); }
1569 absdcl1: /* a nonempty absolute declarator */
1572 /* `(typedef)1' is `int'. */
1573 | '*' type_quals absdcl1 %prec UNARY
1574 { $$ = make_pointer_declarator ($2, $3); }
1575 | '*' type_quals %prec UNARY
1576 { $$ = make_pointer_declarator ($2, NULL_TREE); }
1577 | absdcl1 '(' parmlist %prec '.'
1578 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1579 | absdcl1 '[' expr ']' %prec '.'
1580 { $$ = build_nt (ARRAY_REF, $1, $3); }
1581 | absdcl1 '[' ']' %prec '.'
1582 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1583 | '(' parmlist %prec '.'
1584 { $$ = build_nt (CALL_EXPR, NULL_TREE, $2, NULL_TREE); }
1585 | '[' expr ']' %prec '.'
1586 { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
1588 { $$ = build_nt (ARRAY_REF, NULL_TREE, NULL_TREE); }
1589 /* ??? It appears we have to support attributes here, however
1590 using prefix_attributes is wrong. */
1591 | attributes setattrs absdcl1
1595 /* A nonempty series of declarations and statements (possibly followed by
1596 some labels) that can form the body of a compound statement.
1597 NOTE: we don't allow labels on declarations; this might seem like a
1598 natural extension, but there would be a conflict between attributes
1599 on the label and prefix attributes on the declaration. */
1602 lineno_stmt_decl_or_labels_ending_stmt
1603 | lineno_stmt_decl_or_labels_ending_decl
1604 | lineno_stmt_decl_or_labels_ending_label
1606 pedwarn ("deprecated use of label at end of compound statement");
1608 | lineno_stmt_decl_or_labels_ending_error
1611 lineno_stmt_decl_or_labels_ending_stmt:
1613 | lineno_stmt_decl_or_labels_ending_stmt lineno_stmt
1614 | lineno_stmt_decl_or_labels_ending_decl lineno_stmt
1615 | lineno_stmt_decl_or_labels_ending_label lineno_stmt
1616 | lineno_stmt_decl_or_labels_ending_error lineno_stmt
1619 lineno_stmt_decl_or_labels_ending_decl:
1621 | lineno_stmt_decl_or_labels_ending_stmt lineno_decl
1622 { if (pedantic && !flag_isoc99)
1623 pedwarn ("ISO C89 forbids mixed declarations and code"); }
1624 | lineno_stmt_decl_or_labels_ending_decl lineno_decl
1625 | lineno_stmt_decl_or_labels_ending_error lineno_decl
1628 lineno_stmt_decl_or_labels_ending_label:
1630 | lineno_stmt_decl_or_labels_ending_stmt lineno_label
1631 | lineno_stmt_decl_or_labels_ending_decl lineno_label
1632 | lineno_stmt_decl_or_labels_ending_label lineno_label
1633 | lineno_stmt_decl_or_labels_ending_error lineno_label
1636 lineno_stmt_decl_or_labels_ending_error:
1638 | lineno_stmt_decl_or_labels errstmt
1641 lineno_stmt_decl_or_labels:
1642 lineno_stmt_decl_or_labels_ending_stmt
1643 | lineno_stmt_decl_or_labels_ending_decl
1644 | lineno_stmt_decl_or_labels_ending_label
1645 | lineno_stmt_decl_or_labels_ending_error
1651 pushlevel: /* empty */
1654 add_scope_stmt (/*begin_p=*/1, /*partial_p=*/0);
1656 if (objc_method_context)
1662 poplevel: /* empty */
1663 { $$ = add_scope_stmt (/*begin_p=*/0, /*partial_p=*/0); }
1665 /* Start and end blocks created for the new scopes of C99. */
1666 c99_block_start: /* empty */
1669 $$ = c_begin_compound_stmt ();
1672 add_scope_stmt (/*begin_p=*/1, /*partial_p=*/0);
1674 if (objc_method_context)
1683 /* Productions using c99_block_start and c99_block_end will need to do what's
1684 in compstmt: RECHAIN_STMTS ($1, COMPOUND_BODY ($1)); $$ = $2; where
1685 $1 is the value of c99_block_start and $2 of c99_block_end. */
1686 c99_block_end: /* empty */
1689 tree scope_stmt = add_scope_stmt (/*begin_p=*/0, /*partial_p=*/0);
1690 $$ = poplevel (kept_level_p (), 0, 0);
1691 SCOPE_STMT_BLOCK (TREE_PURPOSE (scope_stmt))
1692 = SCOPE_STMT_BLOCK (TREE_VALUE (scope_stmt))
1699 /* Read zero or more forward-declarations for labels
1700 that nested functions can jump to. */
1705 pedwarn ("ISO C forbids label declarations"); }
1710 | label_decls label_decl
1714 LABEL identifiers_or_typenames ';'
1716 for (link = $2; link; link = TREE_CHAIN (link))
1718 tree label = shadow_label (TREE_VALUE (link));
1719 C_DECLARED_LABEL_FLAG (label) = 1;
1720 add_decl_stmt (label);
1725 /* This is the body of a function definition.
1726 It causes syntax errors to ignore to the next openbrace. */
1733 compstmt_start: '{' { compstmt_count++;
1734 $$ = c_begin_compound_stmt (); }
1736 compstmt_nostart: '}'
1737 { $$ = convert (void_type_node, integer_zero_node); }
1738 | pushlevel maybe_label_decls compstmt_contents_nonempty '}' poplevel
1739 { $$ = poplevel (kept_level_p (), 1, 0);
1740 SCOPE_STMT_BLOCK (TREE_PURPOSE ($5))
1741 = SCOPE_STMT_BLOCK (TREE_VALUE ($5))
1745 compstmt_contents_nonempty:
1750 compstmt_primary_start:
1752 { if (current_function_decl == 0)
1754 error ("braced-group within expression allowed only inside a function");
1757 /* We must force a BLOCK for this level
1758 so that, if it is not expanded later,
1759 there is a way to turn off the entire subtree of blocks
1760 that are contained in it. */
1762 push_label_level ();
1764 $$ = add_stmt (build_stmt (COMPOUND_STMT, last_tree));
1767 compstmt: compstmt_start compstmt_nostart
1768 { RECHAIN_STMTS ($1, COMPOUND_BODY ($1));
1772 /* Value is number of statements counted as of the closeparen. */
1774 if_prefix c99_block_lineno_labeled_stmt
1775 { c_finish_then (); }
1776 /* Make sure c_expand_end_cond is run once
1777 for each call to c_expand_start_cond.
1778 Otherwise a crash is likely. */
1784 { c_expand_start_cond (truthvalue_conversion ($3),
1786 $<itype>$ = stmt_count;
1787 if_stmt_file = $<filename>-2;
1788 if_stmt_line = $<lineno>-1; }
1791 /* This is a subroutine of stmt.
1792 It is used twice, once for valid DO statements
1793 and once for catching errors in parsing the end test. */
1799 = add_stmt (build_stmt (DO_STMT, NULL_TREE,
1801 /* In the event that a parse error prevents
1802 parsing the complete do-statement, set the
1803 condition now. Otherwise, we can get crashes at
1804 RTL-generation time. */
1805 DO_COND ($<ttype>$) = error_mark_node; }
1806 c99_block_lineno_labeled_stmt WHILE
1808 RECHAIN_STMTS ($$, DO_BODY ($$)); }
1811 /* The forced readahead in here is because we might be at the end of a
1812 line, and the line and file won't be bumped until yylex absorbs the
1813 first token on the next line. */
1815 { if (yychar == YYEMPTY)
1817 $$ = input_filename; }
1821 { if (yychar == YYEMPTY)
1826 lineno_labeled_stmt:
1828 | lineno_label lineno_labeled_stmt
1831 /* Like lineno_labeled_stmt, but a block in C99. */
1832 c99_block_lineno_labeled_stmt:
1833 c99_block_start lineno_labeled_stmt c99_block_end
1835 RECHAIN_STMTS ($1, COMPOUND_BODY ($1)); }
1839 save_filename save_lineno stmt
1842 STMT_LINENO ($3) = $2;
1843 /* ??? We currently have no way of recording
1844 the filename for a statement. This probably
1845 matters little in practice at the moment,
1846 but I suspect that problems will ocurr when
1847 doing inlining at the tree level. */
1853 save_filename save_lineno label
1856 STMT_LINENO ($3) = $2;
1861 select_or_iter_stmt:
1863 { c_expand_start_else ();
1864 $<itype>1 = stmt_count; }
1865 c99_block_lineno_labeled_stmt
1867 c_expand_end_cond ();
1868 if (extra_warnings && stmt_count == $<itype>1)
1869 warning ("empty body in an else-statement"); }
1870 | simple_if %prec IF
1871 { c_expand_end_cond ();
1872 /* This warning is here instead of in simple_if, because we
1873 do not want a warning if an empty if is followed by an
1874 else statement. Increment stmt_count so we don't
1875 give a second error if this is a nested `if'. */
1876 if (extra_warnings && stmt_count++ == $<itype>1)
1877 warning_with_file_and_line (if_stmt_file, if_stmt_line,
1878 "empty body in an if-statement"); }
1879 /* Make sure c_expand_end_cond is run once
1880 for each call to c_expand_start_cond.
1881 Otherwise a crash is likely. */
1882 | simple_if ELSE error
1883 { c_expand_end_cond (); }
1887 { $4 = truthvalue_conversion ($4);
1889 = add_stmt (build_stmt (WHILE_STMT, $4, NULL_TREE)); }
1890 c99_block_lineno_labeled_stmt
1891 { RECHAIN_STMTS ($<ttype>6, WHILE_BODY ($<ttype>6)); }
1894 { DO_COND ($1) = truthvalue_conversion ($3); }
1895 | do_stmt_start error
1898 { $<ttype>$ = build_stmt (FOR_STMT, NULL_TREE, NULL_TREE,
1899 NULL_TREE, NULL_TREE);
1900 add_stmt ($<ttype>$); }
1903 RECHAIN_STMTS ($<ttype>2, FOR_INIT_STMT ($<ttype>2)); }
1906 FOR_COND ($<ttype>2) = truthvalue_conversion ($6); }
1908 { FOR_EXPR ($<ttype>2) = $9; }
1909 c99_block_lineno_labeled_stmt
1910 { RECHAIN_STMTS ($<ttype>2, FOR_BODY ($<ttype>2)); }
1911 | SWITCH '(' expr ')'
1913 $<ttype>$ = c_start_case ($3); }
1914 c99_block_lineno_labeled_stmt
1915 { c_finish_case (); }
1920 { add_stmt (build_stmt (EXPR_STMT, $1)); }
1922 { check_for_loop_decls (); }
1925 /* Parse a single real statement, not including any labels. */
1928 { stmt_count++; $$ = $1; }
1931 $$ = c_expand_expr_stmt ($1); }
1932 | c99_block_start select_or_iter_stmt c99_block_end
1934 RECHAIN_STMTS ($1, COMPOUND_BODY ($1));
1938 $$ = add_stmt (build_break_stmt ()); }
1941 $$ = add_stmt (build_continue_stmt ()); }
1944 $$ = c_expand_return (NULL_TREE); }
1947 $$ = c_expand_return ($2); }
1948 | ASM_KEYWORD maybe_type_qual '(' expr ')' ';'
1951 if ((TREE_CODE ($4) == ADDR_EXPR
1952 && TREE_CODE (TREE_OPERAND ($4, 0)) == STRING_CST)
1953 || TREE_CODE ($4) == STRING_CST)
1955 if (TREE_CODE ($4) == ADDR_EXPR)
1956 $4 = TREE_OPERAND ($4, 0);
1957 if (TREE_CHAIN ($4))
1958 $4 = combine_strings ($4);
1959 $$ = add_stmt (build_stmt (ASM_STMT, NULL_TREE, $4,
1960 NULL_TREE, NULL_TREE,
1962 ASM_INPUT_P ($$) = 1;
1966 error ("argument of `asm' is not a constant string");
1970 /* This is the case with just output operands. */
1971 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ')' ';'
1973 $$ = build_asm_stmt ($2, $4, $6, NULL_TREE, NULL_TREE); }
1974 /* This is the case with input operands as well. */
1975 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':'
1976 asm_operands ')' ';'
1978 $$ = build_asm_stmt ($2, $4, $6, $8, NULL_TREE); }
1979 /* This is the case with clobbered registers as well. */
1980 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':'
1981 asm_operands ':' asm_clobbers ')' ';'
1983 $$ = build_asm_stmt ($2, $4, $6, $8, $10); }
1984 | GOTO identifier ';'
1987 decl = lookup_label ($2);
1990 TREE_USED (decl) = 1;
1991 $$ = add_stmt (build_stmt (GOTO_STMT, decl));
1998 pedwarn ("ISO C forbids `goto *expr;'");
2000 $3 = convert (ptr_type_node, $3);
2001 $$ = add_stmt (build_stmt (GOTO_STMT, $3)); }
2006 /* Any kind of label, including jump labels and case labels.
2007 ANSI C accepts labels only before statements, but we allow them
2008 also at the end of a compound statement. */
2010 label: CASE expr_no_commas ':'
2012 $$ = do_case ($2, NULL_TREE); }
2013 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
2015 $$ = do_case ($2, $4); }
2018 $$ = do_case (NULL_TREE, NULL_TREE); }
2019 | identifier save_filename save_lineno ':' maybe_attribute
2020 { tree label = define_label ($2, $3, $1);
2024 decl_attributes (label, $5, NULL_TREE);
2025 $$ = add_stmt (build_stmt (LABEL_STMT, label));
2032 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
2036 { emit_line_note (input_filename, lineno);
2039 { emit_line_note (input_filename, lineno); }
2048 /* These are the operands other than the first string and colon
2049 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
2050 asm_operands: /* empty */
2052 | nonnull_asm_operands
2055 nonnull_asm_operands:
2057 | nonnull_asm_operands ',' asm_operand
2058 { $$ = chainon ($1, $3); }
2063 { $$ = build_tree_list ($1, $3); }
2068 { $$ = tree_cons (NULL_TREE, combine_strings ($1), NULL_TREE); }
2069 | asm_clobbers ',' string
2070 { $$ = tree_cons (NULL_TREE, combine_strings ($3), $1); }
2073 /* This is what appears inside the parens in a function declarator.
2074 Its value is a list of ..._TYPE nodes. */
2077 clear_parm_order ();
2078 declare_parm_level (0); }
2081 parmlist_tags_warning ();
2082 poplevel (0, 0, 0); }
2090 pedwarn ("ISO C forbids forward parameter declarations");
2091 /* Mark the forward decls as such. */
2092 for (parm = getdecls (); parm; parm = TREE_CHAIN (parm))
2093 TREE_ASM_WRITTEN (parm) = 1;
2094 clear_parm_order (); }
2098 { $$ = tree_cons (NULL_TREE, NULL_TREE, NULL_TREE); }
2101 /* This is what appears inside the parens in a function declarator.
2102 Is value is represented in the format that grokdeclarator expects. */
2103 parmlist_2: /* empty */
2104 { $$ = get_parm_info (0); }
2106 { $$ = get_parm_info (0);
2107 /* Gcc used to allow this as an extension. However, it does
2108 not work for all targets, and thus has been disabled.
2109 Also, since func (...) and func () are indistinguishable,
2110 it caused problems with the code in expand_builtin which
2111 tries to verify that BUILT_IN_NEXT_ARG is being used
2113 error ("ISO C requires a named argument before `...'");
2116 { $$ = get_parm_info (1); }
2117 | parms ',' ELLIPSIS
2118 { $$ = get_parm_info (0); }
2123 { push_parm_decl ($1); }
2125 { push_parm_decl ($3); }
2128 /* A single parameter declaration or parameter type name,
2129 as found in a parmlist. */
2131 typed_declspecs setspecs parm_declarator maybe_attribute
2132 { $$ = build_tree_list (build_tree_list (current_declspecs,
2134 build_tree_list (prefix_attributes,
2136 current_declspecs = TREE_VALUE (declspec_stack);
2137 prefix_attributes = TREE_PURPOSE (declspec_stack);
2138 declspec_stack = TREE_CHAIN (declspec_stack); }
2139 | typed_declspecs setspecs notype_declarator maybe_attribute
2140 { $$ = build_tree_list (build_tree_list (current_declspecs,
2142 build_tree_list (prefix_attributes,
2144 current_declspecs = TREE_VALUE (declspec_stack);
2145 prefix_attributes = TREE_PURPOSE (declspec_stack);
2146 declspec_stack = TREE_CHAIN (declspec_stack); }
2147 | typed_declspecs setspecs absdcl maybe_attribute
2148 { $$ = build_tree_list (build_tree_list (current_declspecs,
2150 build_tree_list (prefix_attributes,
2152 current_declspecs = TREE_VALUE (declspec_stack);
2153 prefix_attributes = TREE_PURPOSE (declspec_stack);
2154 declspec_stack = TREE_CHAIN (declspec_stack); }
2155 | declmods setspecs notype_declarator maybe_attribute
2156 { $$ = build_tree_list (build_tree_list (current_declspecs,
2158 build_tree_list (prefix_attributes,
2160 current_declspecs = TREE_VALUE (declspec_stack);
2161 prefix_attributes = TREE_PURPOSE (declspec_stack);
2162 declspec_stack = TREE_CHAIN (declspec_stack); }
2164 | declmods setspecs absdcl maybe_attribute
2165 { $$ = build_tree_list (build_tree_list (current_declspecs,
2167 build_tree_list (prefix_attributes,
2169 current_declspecs = TREE_VALUE (declspec_stack);
2170 prefix_attributes = TREE_PURPOSE (declspec_stack);
2171 declspec_stack = TREE_CHAIN (declspec_stack); }
2174 /* This is used in a function definition
2175 where either a parmlist or an identifier list is ok.
2176 Its value is a list of ..._TYPE nodes or a list of identifiers. */
2177 parmlist_or_identifiers:
2179 clear_parm_order ();
2180 declare_parm_level (1); }
2181 parmlist_or_identifiers_1
2183 parmlist_tags_warning ();
2184 poplevel (0, 0, 0); }
2187 parmlist_or_identifiers_1:
2191 for (t = $1; t; t = TREE_CHAIN (t))
2192 if (TREE_VALUE (t) == NULL_TREE)
2193 error ("`...' in old-style identifier list");
2194 $$ = tree_cons (NULL_TREE, NULL_TREE, $1); }
2197 /* A nonempty list of identifiers. */
2200 { $$ = build_tree_list (NULL_TREE, $1); }
2201 | identifiers ',' IDENTIFIER
2202 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2205 /* A nonempty list of identifiers, including typenames. */
2206 identifiers_or_typenames:
2208 { $$ = build_tree_list (NULL_TREE, $1); }
2209 | identifiers_or_typenames ',' identifier
2210 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2215 { $$ = SAVE_WARN_FLAGS();
2217 warn_pointer_arith = 0; }
2221 /* Objective-C productions. */
2231 if (objc_implementation_context)
2233 finish_class (objc_implementation_context);
2234 objc_ivar_chain = NULL_TREE;
2235 objc_implementation_context = NULL_TREE;
2238 warning ("`@end' must appear in an implementation context");
2242 /* A nonempty list of identifiers. */
2245 { $$ = build_tree_list (NULL_TREE, $1); }
2246 | identifier_list ',' identifier
2247 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2251 CLASS identifier_list ';'
2253 objc_declare_class ($2);
2257 ALIAS identifier identifier ';'
2259 objc_declare_alias ($2, $3);
2263 INTERFACE identifier protocolrefs '{'
2265 objc_interface_context = objc_ivar_context
2266 = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, $3);
2267 objc_public_flag = 0;
2271 continue_class (objc_interface_context);
2276 finish_class (objc_interface_context);
2277 objc_interface_context = NULL_TREE;
2280 | INTERFACE identifier protocolrefs
2282 objc_interface_context
2283 = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, $3);
2284 continue_class (objc_interface_context);
2289 finish_class (objc_interface_context);
2290 objc_interface_context = NULL_TREE;
2293 | INTERFACE identifier ':' identifier protocolrefs '{'
2295 objc_interface_context = objc_ivar_context
2296 = start_class (CLASS_INTERFACE_TYPE, $2, $4, $5);
2297 objc_public_flag = 0;
2301 continue_class (objc_interface_context);
2306 finish_class (objc_interface_context);
2307 objc_interface_context = NULL_TREE;
2310 | INTERFACE identifier ':' identifier protocolrefs
2312 objc_interface_context
2313 = start_class (CLASS_INTERFACE_TYPE, $2, $4, $5);
2314 continue_class (objc_interface_context);
2319 finish_class (objc_interface_context);
2320 objc_interface_context = NULL_TREE;
2323 | IMPLEMENTATION identifier '{'
2325 objc_implementation_context = objc_ivar_context
2326 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, NULL_TREE, NULL_TREE);
2327 objc_public_flag = 0;
2332 = continue_class (objc_implementation_context);
2335 | IMPLEMENTATION identifier
2337 objc_implementation_context
2338 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, NULL_TREE, NULL_TREE);
2340 = continue_class (objc_implementation_context);
2343 | IMPLEMENTATION identifier ':' identifier '{'
2345 objc_implementation_context = objc_ivar_context
2346 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2347 objc_public_flag = 0;
2352 = continue_class (objc_implementation_context);
2355 | IMPLEMENTATION identifier ':' identifier
2357 objc_implementation_context
2358 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2360 = continue_class (objc_implementation_context);
2363 | INTERFACE identifier '(' identifier ')' protocolrefs
2365 objc_interface_context
2366 = start_class (CATEGORY_INTERFACE_TYPE, $2, $4, $6);
2367 continue_class (objc_interface_context);
2372 finish_class (objc_interface_context);
2373 objc_interface_context = NULL_TREE;
2376 | IMPLEMENTATION identifier '(' identifier ')'
2378 objc_implementation_context
2379 = start_class (CATEGORY_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2381 = continue_class (objc_implementation_context);
2386 PROTOCOL identifier protocolrefs
2388 remember_protocol_qualifiers ();
2389 objc_interface_context
2390 = start_protocol(PROTOCOL_INTERFACE_TYPE, $2, $3);
2394 forget_protocol_qualifiers();
2395 finish_protocol(objc_interface_context);
2396 objc_interface_context = NULL_TREE;
2405 | non_empty_protocolrefs
2408 non_empty_protocolrefs:
2409 ARITHCOMPARE identifier_list ARITHCOMPARE
2411 if ($1 == LT_EXPR && $3 == GT_EXPR)
2419 ivar_decl_list visibility_spec ivar_decls
2424 PRIVATE { objc_public_flag = 2; }
2425 | PROTECTED { objc_public_flag = 0; }
2426 | PUBLIC { objc_public_flag = 1; }
2434 | ivar_decls ivar_decl ';'
2438 pedwarn ("extra semicolon in struct or union specified");
2443 /* There is a shift-reduce conflict here, because `components' may
2444 start with a `typename'. It happens that shifting (the default resolution)
2445 does the right thing, because it treats the `typename' as part of
2446 a `typed_typespecs'.
2448 It is possible that this same technique would allow the distinction
2449 between `notype_initdecls' and `initdecls' to be eliminated.
2450 But I am being cautious and not trying it. */
2453 typed_typespecs setspecs ivars
2455 current_declspecs = TREE_VALUE (declspec_stack);
2456 prefix_attributes = TREE_PURPOSE (declspec_stack);
2457 declspec_stack = TREE_CHAIN (declspec_stack); }
2458 | nonempty_type_quals setspecs ivars
2460 current_declspecs = TREE_VALUE (declspec_stack);
2461 prefix_attributes = TREE_PURPOSE (declspec_stack);
2462 declspec_stack = TREE_CHAIN (declspec_stack); }
2471 | ivars ',' ivar_declarator
2477 $$ = add_instance_variable (objc_ivar_context,
2479 $1, current_declspecs,
2482 | declarator ':' expr_no_commas
2484 $$ = add_instance_variable (objc_ivar_context,
2486 $1, current_declspecs, $3);
2488 | ':' expr_no_commas
2490 $$ = add_instance_variable (objc_ivar_context,
2493 current_declspecs, $2);
2500 remember_protocol_qualifiers ();
2501 if (objc_implementation_context)
2502 objc_inherit_code = CLASS_METHOD_DECL;
2504 fatal ("method definition not in class context");
2508 forget_protocol_qualifiers ();
2509 add_class_method (objc_implementation_context, $3);
2510 start_method_def ($3);
2511 objc_method_context = $3;
2515 continue_method_def ();
2519 finish_method_def ();
2520 objc_method_context = NULL_TREE;
2525 remember_protocol_qualifiers ();
2526 if (objc_implementation_context)
2527 objc_inherit_code = INSTANCE_METHOD_DECL;
2529 fatal ("method definition not in class context");
2533 forget_protocol_qualifiers ();
2534 add_instance_method (objc_implementation_context, $3);
2535 start_method_def ($3);
2536 objc_method_context = $3;
2540 continue_method_def ();
2544 finish_method_def ();
2545 objc_method_context = NULL_TREE;
2549 /* the reason for the strange actions in this rule
2550 is so that notype_initdecls when reached via datadef
2551 can find a valid list of type and sc specs in $0. */
2555 | {$<ttype>$ = NULL_TREE; } methodprotolist2
2558 methodprotolist2: /* eliminates a shift/reduce conflict */
2561 | methodprotolist2 methodproto
2562 | methodprotolist2 {$<ttype>$ = NULL_TREE; } datadef
2573 /* Remember protocol qualifiers in prototypes. */
2574 remember_protocol_qualifiers ();
2575 objc_inherit_code = CLASS_METHOD_DECL;
2579 /* Forget protocol qualifiers here. */
2580 forget_protocol_qualifiers ();
2581 add_class_method (objc_interface_context, $3);
2587 /* Remember protocol qualifiers in prototypes. */
2588 remember_protocol_qualifiers ();
2589 objc_inherit_code = INSTANCE_METHOD_DECL;
2593 /* Forget protocol qualifiers here. */
2594 forget_protocol_qualifiers ();
2595 add_instance_method (objc_interface_context, $3);
2601 '(' typename ')' unaryselector
2603 $$ = build_method_decl (objc_inherit_code, $2, $4, NULL_TREE);
2608 $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, NULL_TREE);
2611 | '(' typename ')' keywordselector optparmlist
2613 $$ = build_method_decl (objc_inherit_code, $2, $4, $5);
2616 | keywordselector optparmlist
2618 $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, $2);
2622 /* "optarglist" assumes that start_method_def has already been called...
2623 if it is not, the "xdecls" will not be placed in the proper scope */
2630 /* to get around the following situation: "int foo (int a) int b; {}" that
2631 is synthesized when parsing "- a:a b:b; id c; id d; { ... }" */
2646 typed_declspecs setspecs myparms ';'
2647 { current_declspecs = TREE_VALUE (declspec_stack);
2648 prefix_attributes = TREE_PURPOSE (declspec_stack);
2649 declspec_stack = TREE_CHAIN (declspec_stack); }
2650 | typed_declspecs ';'
2651 { shadow_tag ($1); }
2653 { pedwarn ("empty declaration"); }
2658 { push_parm_decl ($1); }
2659 | myparms ',' myparm
2660 { push_parm_decl ($3); }
2663 /* A single parameter declaration or parameter type name,
2664 as found in a parmlist. DOES NOT ALLOW AN INITIALIZER OR ASMSPEC */
2667 parm_declarator maybe_attribute
2668 { $$ = build_tree_list (build_tree_list (current_declspecs,
2670 build_tree_list (prefix_attributes,
2672 | notype_declarator maybe_attribute
2673 { $$ = build_tree_list (build_tree_list (current_declspecs,
2675 build_tree_list (prefix_attributes,
2677 | absdcl maybe_attribute
2678 { $$ = build_tree_list (build_tree_list (current_declspecs,
2680 build_tree_list (prefix_attributes,
2691 /* oh what a kludge! */
2692 $$ = objc_ellipsis_node;
2700 /* returns a tree list node generated by get_parm_info */
2713 | keywordselector keyworddecl
2715 $$ = chainon ($1, $2);
2727 ENUM | STRUCT | UNION | IF | ELSE | WHILE | DO | FOR
2728 | SWITCH | CASE | DEFAULT | BREAK | CONTINUE | RETURN
2729 | GOTO | ASM_KEYWORD | SIZEOF | TYPEOF | ALIGNOF
2730 | TYPESPEC | TYPE_QUAL
2734 selector ':' '(' typename ')' identifier
2736 $$ = build_keyword_decl ($1, $4, $6);
2739 | selector ':' identifier
2741 $$ = build_keyword_decl ($1, NULL_TREE, $3);
2744 | ':' '(' typename ')' identifier
2746 $$ = build_keyword_decl (NULL_TREE, $3, $5);
2751 $$ = build_keyword_decl (NULL_TREE, NULL_TREE, $2);
2762 | keywordarglist keywordarg
2764 $$ = chainon ($1, $2);
2772 if (TREE_CHAIN ($1) == NULL_TREE)
2773 /* just return the expr., remove a level of indirection */
2774 $$ = TREE_VALUE ($1);
2776 /* we have a comma expr., we will collapse later */
2782 selector ':' keywordexpr
2784 $$ = build_tree_list ($1, $3);
2788 $$ = build_tree_list (NULL_TREE, $2);
2796 $$ = get_class_reference ($1);
2802 { objc_receiver_context = 1; }
2804 { objc_receiver_context = 0; }
2807 $$ = build_tree_list ($3, $5);
2818 | keywordnamelist keywordname
2820 $$ = chainon ($1, $2);
2827 $$ = build_tree_list ($1, NULL_TREE);
2831 $$ = build_tree_list (NULL_TREE, NULL_TREE);
2836 SELECTOR '(' selectorarg ')'
2843 PROTOCOL '(' identifier ')'
2849 /* extension to support C-structures in the archiver */
2852 ENCODE '(' typename ')'
2854 $$ = groktypename ($3);
2861 /* yylex() is a thin wrapper around c_lex(), all it does is translate
2862 cpplib.h's token codes into yacc's token codes. */
2864 static enum cpp_ttype last_token;
2866 /* The reserved keyword table. */
2870 ENUM_BITFIELD(rid) rid : 16;
2871 unsigned int disable : 16;
2874 /* Disable mask. Keywords are disabled if (reswords[i].disable & mask) is
2876 #define D_TRAD 0x01 /* not in traditional C */
2877 #define D_C89 0x02 /* not in C89 */
2878 #define D_EXT 0x04 /* GCC extension */
2879 #define D_EXT89 0x08 /* GCC extension incorporated in C99 */
2880 #define D_OBJC 0x10 /* Objective C only */
2881 #define D_YES 0x20 /* always starts disabled */
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|D_YES },
2975 { "byref", RID_BYREF, D_OBJC|D_YES },
2976 { "in", RID_IN, D_OBJC|D_YES },
2977 { "inout", RID_INOUT, D_OBJC|D_YES },
2978 { "oneway", RID_ONEWAY, D_OBJC|D_YES },
2979 { "out", RID_OUT, D_OBJC|D_YES },
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
3123 int mask = ((doing_objc_thang ? 0 : D_OBJC)
3124 | (flag_isoc99 ? 0 : D_C89)
3125 | (flag_traditional ? D_TRAD : 0)
3126 | (flag_no_asm ? (flag_isoc99 ? D_EXT : D_EXT|D_EXT89) : 0));
3128 /* It is not necessary to register ridpointers as a GC root, because
3129 all the trees it points to are permanently interned in the
3130 get_identifier hash anyway. */
3131 ridpointers = (tree *) xcalloc ((int) RID_MAX, sizeof (tree));
3132 for (i = 0; i < N_reswords; i++)
3134 /* If a keyword is disabled, do not enter it into the table
3135 and so create a canonical spelling that isn't a keyword. */
3136 if (reswords[i].disable & mask)
3139 id = get_identifier (reswords[i].word);
3140 C_RID_CODE (id) = reswords[i].rid;
3141 ridpointers [(int) reswords[i].rid] = id;
3143 /* Objective C does tricky things with enabling and disabling
3144 keywords. So these we must not elide in the test above, but
3145 wait and not mark them reserved now. */
3146 if (! (reswords[i].disable & D_YES))
3147 C_IS_RESERVED_WORD (id) = 1;
3152 init_parse (filename)
3153 const char *filename;
3155 add_c_tree_codes ();
3157 /* Make identifier nodes long enough for the language-specific slots. */
3158 set_identifier_size (sizeof (struct lang_identifier));
3163 return init_c_lex (filename);
3169 cpp_finish (parse_in);
3170 /* Call to cpp_destroy () omitted for performance reasons. */
3171 errorcount += cpp_errors (parse_in);
3174 #define NAME(type) cpp_type2name (type)
3180 const char *string = _(msgid);
3182 if (last_token == CPP_EOF)
3183 error ("%s at end of input", string);
3184 else if (last_token == CPP_CHAR || last_token == CPP_WCHAR)
3186 unsigned int val = TREE_INT_CST_LOW (yylval.ttype);
3187 const char *ell = (last_token == CPP_CHAR) ? "" : "L";
3188 if (val <= UCHAR_MAX && ISGRAPH (val))
3189 error ("%s before %s'%c'", string, ell, val);
3191 error ("%s before %s'\\x%x'", string, ell, val);
3193 else if (last_token == CPP_STRING
3194 || last_token == CPP_WSTRING
3195 || last_token == CPP_OSTRING)
3196 error ("%s before string constant", string);
3197 else if (last_token == CPP_NUMBER
3198 || last_token == CPP_INT
3199 || last_token == CPP_FLOAT)
3200 error ("%s before numeric constant", string);
3201 else if (last_token == CPP_NAME)
3202 error ("%s before \"%s\"", string, IDENTIFIER_POINTER (yylval.ttype));
3204 error ("%s before '%s' token", string, NAME(last_token));
3211 last_token = c_lex (&yylval.ttype);
3215 case CPP_EQ: return '=';
3216 case CPP_NOT: return '!';
3217 case CPP_GREATER: yylval.code = GT_EXPR; return ARITHCOMPARE;
3218 case CPP_LESS: yylval.code = LT_EXPR; return ARITHCOMPARE;
3219 case CPP_PLUS: yylval.code = PLUS_EXPR; return '+';
3220 case CPP_MINUS: yylval.code = MINUS_EXPR; return '-';
3221 case CPP_MULT: yylval.code = MULT_EXPR; return '*';
3222 case CPP_DIV: yylval.code = TRUNC_DIV_EXPR; return '/';
3223 case CPP_MOD: yylval.code = TRUNC_MOD_EXPR; return '%';
3224 case CPP_AND: yylval.code = BIT_AND_EXPR; return '&';
3225 case CPP_OR: yylval.code = BIT_IOR_EXPR; return '|';
3226 case CPP_XOR: yylval.code = BIT_XOR_EXPR; return '^';
3227 case CPP_RSHIFT: yylval.code = RSHIFT_EXPR; return RSHIFT;
3228 case CPP_LSHIFT: yylval.code = LSHIFT_EXPR; return LSHIFT;
3230 case CPP_COMPL: return '~';
3231 case CPP_AND_AND: return ANDAND;
3232 case CPP_OR_OR: return OROR;
3233 case CPP_QUERY: return '?';
3234 case CPP_COLON: return ':';
3235 case CPP_COMMA: return ',';
3236 case CPP_OPEN_PAREN: return '(';
3237 case CPP_CLOSE_PAREN: return ')';
3238 case CPP_EQ_EQ: yylval.code = EQ_EXPR; return EQCOMPARE;
3239 case CPP_NOT_EQ: yylval.code = NE_EXPR; return EQCOMPARE;
3240 case CPP_GREATER_EQ:yylval.code = GE_EXPR; return ARITHCOMPARE;
3241 case CPP_LESS_EQ: yylval.code = LE_EXPR; return ARITHCOMPARE;
3243 case CPP_PLUS_EQ: yylval.code = PLUS_EXPR; return ASSIGN;
3244 case CPP_MINUS_EQ: yylval.code = MINUS_EXPR; return ASSIGN;
3245 case CPP_MULT_EQ: yylval.code = MULT_EXPR; return ASSIGN;
3246 case CPP_DIV_EQ: yylval.code = TRUNC_DIV_EXPR; return ASSIGN;
3247 case CPP_MOD_EQ: yylval.code = TRUNC_MOD_EXPR; return ASSIGN;
3248 case CPP_AND_EQ: yylval.code = BIT_AND_EXPR; return ASSIGN;
3249 case CPP_OR_EQ: yylval.code = BIT_IOR_EXPR; return ASSIGN;
3250 case CPP_XOR_EQ: yylval.code = BIT_XOR_EXPR; return ASSIGN;
3251 case CPP_RSHIFT_EQ: yylval.code = RSHIFT_EXPR; return ASSIGN;
3252 case CPP_LSHIFT_EQ: yylval.code = LSHIFT_EXPR; return ASSIGN;
3254 case CPP_OPEN_SQUARE: return '[';
3255 case CPP_CLOSE_SQUARE: return ']';
3256 case CPP_OPEN_BRACE: return '{';
3257 case CPP_CLOSE_BRACE: return '}';
3258 case CPP_SEMICOLON: return ';';
3259 case CPP_ELLIPSIS: return ELLIPSIS;
3261 case CPP_PLUS_PLUS: return PLUSPLUS;
3262 case CPP_MINUS_MINUS: return MINUSMINUS;
3263 case CPP_DEREF: return POINTSAT;
3264 case CPP_DOT: return '.';
3267 if (cpp_pop_buffer (parse_in) == 0)
3272 if (C_IS_RESERVED_WORD (yylval.ttype))
3274 enum rid rid_code = C_RID_CODE (yylval.ttype);
3275 /* Return the canonical spelling for this keyword. */
3276 yylval.ttype = ridpointers[(int) rid_code];
3277 return rid_to_yy[(int) rid_code];
3280 if (IDENTIFIER_POINTER (yylval.ttype)[0] == '@')
3282 error ("invalid identifier `%s'", IDENTIFIER_POINTER (yylval.ttype));
3289 decl = lookup_name (yylval.ttype);
3293 if (TREE_CODE (decl) == TYPE_DECL)
3295 /* A user-invisible read-only initialized variable
3296 should be replaced by its value.
3297 We handle only strings since that's the only case used in C. */
3298 else if (TREE_CODE (decl) == VAR_DECL
3299 && DECL_IGNORED_P (decl)
3300 && TREE_READONLY (decl)
3301 && DECL_INITIAL (decl) != 0
3302 && TREE_CODE (DECL_INITIAL (decl)) == STRING_CST)
3304 tree stringval = DECL_INITIAL (decl);
3306 /* Copy the string value so that we won't clobber anything
3307 if we put something in the TREE_CHAIN of this one. */
3308 yylval.ttype = build_string (TREE_STRING_LENGTH (stringval),
3309 TREE_STRING_POINTER (stringval));
3313 else if (doing_objc_thang)
3315 tree objc_interface_decl = is_class_name (yylval.ttype);
3317 if (objc_interface_decl)
3319 yylval.ttype = objc_interface_decl;
3341 /* These tokens are C++ specific (and will not be generated
3342 in C mode, but let's be cautious). */
3344 case CPP_DEREF_STAR:
3350 /* These tokens should not survive translation phase 4. */
3353 error ("syntax error before '%s' token", NAME(last_token));
3367 timevar_push (TV_LEX);
3369 timevar_pop (TV_LEX);
3373 /* Sets the value of the 'yydebug' variable to VALUE.
3374 This is a function so we don't have to have YYDEBUG defined
3375 in order to build the compiler. */
3384 warning ("YYDEBUG not defined.");
3388 /* Function used when yydebug is set, to print a token in more detail. */
3391 yyprint (file, yychar, yyl)
3398 fprintf (file, " [%s]", NAME(last_token));
3408 if (IDENTIFIER_POINTER (t))
3409 fprintf (file, " `%s'", IDENTIFIER_POINTER (t));
3413 fprintf (file, " %s", GET_MODE_NAME (TYPE_MODE (TREE_TYPE (t))));
3414 if (TREE_CODE (t) == INTEGER_CST)
3416 #if HOST_BITS_PER_WIDE_INT == 64
3417 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
3420 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
3427 #if HOST_BITS_PER_WIDE_INT != HOST_BITS_PER_INT
3433 TREE_INT_CST_HIGH (t), TREE_INT_CST_LOW (t));
3438 /* This is not the ideal place to put these, but we have to get them out
3439 of c-lex.c because cp/lex.c has its own versions. */
3441 /* Return something to represent absolute declarators containing a *.
3442 TARGET is the absolute declarator that the * contains.
3443 TYPE_QUALS is a list of modifiers such as const or volatile
3444 to apply to the pointer type, represented as identifiers.
3446 We return an INDIRECT_REF whose "contents" are TARGET
3447 and whose type is the modifier list. */
3450 make_pointer_declarator (type_quals, target)
3451 tree type_quals, target;
3453 return build1 (INDIRECT_REF, type_quals, target);