1 /* YACC parser for C syntax and for Objective C. -*-c-*-
2 Copyright (C) 1987, 88, 89, 92-98, 1999 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 /* This file defines the grammar of C and that of Objective C.
22 ifobjc ... end ifobjc conditionals contain code for Objective C only.
23 ifc ... end ifc conditionals contain code for C only.
24 Sed commands in Makefile.in are used to convert this file into
25 c-parse.y and into objc-parse.y. */
27 /* To whomever it may concern: I have heard that such a thing was once
28 written by AT&T, but I have never seen it. */
50 #ifdef MULTIBYTE_CHARS
58 /* Since parsers are distinct for each language, put the language string
61 const char * const language_string = "GNU Obj-C";
64 const char * const language_string = "GNU C";
67 /* Like YYERROR but do call yyerror. */
68 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
70 /* Cause the `yydebug' variable to be defined. */
76 %union {long itype; tree ttype; enum tree_code code;
77 char *filename; int lineno; int ends_in_label; }
79 /* All identifiers that are not reserved words
80 and are not declared typedefs in the current block */
83 /* All identifiers that are declared typedefs in the current block.
84 In some contexts, they are treated just like IDENTIFIER,
85 but they can also serve as typespecs in declarations. */
88 /* Reserved words that specify storage class.
89 yylval contains an IDENTIFIER_NODE which indicates which one. */
92 /* Reserved words that specify type.
93 yylval contains an IDENTIFIER_NODE which indicates which one. */
96 /* Reserved words that qualify type: "const", "volatile", or "restrict".
97 yylval contains an IDENTIFIER_NODE which indicates which one. */
100 /* Character or numeric constants.
101 yylval is the node for the constant. */
104 /* String constants in raw form.
105 yylval is a STRING_CST node. */
108 /* "...", used for functions with variable arglists. */
111 /* the reserved words */
112 /* SCO include files test "ASM", so use something else. */
113 %token SIZEOF ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
114 %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD TYPEOF ALIGNOF
115 %token ATTRIBUTE EXTENSION LABEL
116 %token REALPART IMAGPART VA_ARG
118 /* Used in c-lex.c for parsing pragmas. */
121 /* Add precedence rules to solve dangling else s/r conflict */
125 /* Define the operator tokens and their precedences.
126 The value is an integer because, if used, it is the tree code
127 to use in the expression made from the operator. */
129 %right <code> ASSIGN '='
130 %right <code> '?' ':'
136 %left <code> EQCOMPARE
137 %left <code> ARITHCOMPARE
138 %left <code> LSHIFT RSHIFT
140 %left <code> '*' '/' '%'
141 %right <code> UNARY PLUSPLUS MINUSMINUS
143 %left <code> POINTSAT '.' '(' '['
145 /* The Objective-C keywords. These are included in C and in
146 Objective C, so that the token codes are the same in both. */
147 %token INTERFACE IMPLEMENTATION END SELECTOR DEFS ENCODE
148 %token CLASSNAME PUBLIC PRIVATE PROTECTED PROTOCOL OBJECTNAME CLASS ALIAS
150 /* Objective-C string constants in raw form.
151 yylval is an OBJC_STRING_CST node. */
157 %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist exprlist
158 %type <ttype> expr_no_commas cast_expr unary_expr primary string STRING
159 %type <ttype> typed_declspecs reserved_declspecs
160 %type <ttype> typed_typespecs reserved_typespecquals
161 %type <ttype> declmods typespec typespecqual_reserved
162 %type <ttype> typed_declspecs_no_prefix_attr reserved_declspecs_no_prefix_attr
163 %type <ttype> declmods_no_prefix_attr
164 %type <ttype> SCSPEC TYPESPEC TYPE_QUAL nonempty_type_quals maybe_type_qual
165 %type <ttype> initdecls notype_initdecls initdcl notype_initdcl
166 %type <ttype> init maybeasm
167 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
168 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
169 %type <ttype> any_word
171 %type <ttype> compstmt compstmt_nostart compstmt_primary_start
173 %type <ttype> declarator
174 %type <ttype> notype_declarator after_type_declarator
175 %type <ttype> parm_declarator
177 %type <ttype> structsp component_decl_list component_decl_list2
178 %type <ttype> component_decl components component_declarator
179 %type <ttype> enumlist enumerator
180 %type <ttype> struct_head union_head enum_head
181 %type <ttype> typename absdcl absdcl1 type_quals
182 %type <ttype> xexpr parms parm identifiers
184 %type <ttype> parmlist parmlist_1 parmlist_2
185 %type <ttype> parmlist_or_identifiers parmlist_or_identifiers_1
186 %type <ttype> identifiers_or_typenames
188 %type <itype> extension
190 %type <itype> setspecs
192 %type <ends_in_label> lineno_stmt_or_label lineno_stmt_or_labels stmt_or_label
194 %type <filename> save_filename
195 %type <lineno> save_lineno
198 /* the Objective-C nonterminals */
200 %type <ttype> ivar_decl_list ivar_decls ivar_decl ivars ivar_declarator
201 %type <ttype> methoddecl unaryselector keywordselector selector
202 %type <ttype> keyworddecl receiver objcmessageexpr messageargs
203 %type <ttype> keywordexpr keywordarglist keywordarg
204 %type <ttype> myparms myparm optparmlist reservedwords objcselectorexpr
205 %type <ttype> selectorarg keywordnamelist keywordname objcencodeexpr
206 %type <ttype> objc_string non_empty_protocolrefs protocolrefs identifier_list objcprotocolexpr
208 %type <ttype> CLASSNAME OBJC_STRING OBJECTNAME
212 /* Number of statements (loosely speaking) and compound statements
214 static int stmt_count;
215 static int compstmt_count;
217 /* Input file and line number of the end of the body of last simple_if;
218 used by the stmt-rule immediately after simple_if returns. */
219 static char *if_stmt_file;
220 static int if_stmt_line;
222 /* List of types and structure classes of the current declaration. */
223 static tree current_declspecs = NULL_TREE;
224 static tree prefix_attributes = NULL_TREE;
226 /* Stack of saved values of current_declspecs and prefix_attributes. */
227 static tree declspec_stack;
229 /* 1 if we explained undeclared var errors. */
230 static int undeclared_variable_notice;
232 /* For __extension__, save/restore the warning flags which are
233 controlled by __extension__. */
234 #define SAVE_WARN_FLAGS() (pedantic | (warn_pointer_arith << 1))
235 #define RESTORE_WARN_FLAGS(val) \
237 pedantic = val & 1; \
238 warn_pointer_arith = (val >> 1) & 1; \
242 /* Objective-C specific information */
244 tree objc_interface_context;
245 tree objc_implementation_context;
246 tree objc_method_context;
247 tree objc_ivar_chain;
248 tree objc_ivar_context;
249 enum tree_code objc_inherit_code;
250 int objc_receiver_context;
251 int objc_public_flag;
255 /* Tell yyparse how to print a token's value, if yydebug is set. */
257 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
258 extern void yyprint PROTO ((FILE *, int, YYSTYPE));
260 /* Add GC roots for variables local to this file. */
264 ggc_add_tree_root (&declspec_stack, 1);
265 ggc_add_tree_root (¤t_declspecs, 1);
266 ggc_add_tree_root (&prefix_attributes, 1);
274 pedwarn ("ANSI C forbids an empty source file");
279 /* In case there were missing closebraces,
280 get us back to the global binding level. */
281 while (! global_bindings_p ())
287 /* the reason for the strange actions in this rule
288 is so that notype_initdecls when reached via datadef
289 can find a valid list of type and sc specs in $0. */
292 {$<ttype>$ = NULL_TREE; } extdef
293 | extdefs {$<ttype>$ = NULL_TREE; } extdef
302 | ASM_KEYWORD '(' expr ')' ';'
304 if ((TREE_CODE ($3) == ADDR_EXPR
305 && TREE_CODE (TREE_OPERAND ($3, 0)) == STRING_CST)
306 || TREE_CODE ($3) == STRING_CST)
309 error ("argument of `asm' is not a constant string"); }
311 { RESTORE_WARN_FLAGS ($1); }
315 setspecs notype_initdecls ';'
317 error ("ANSI C forbids data definition with no type or storage class");
318 else if (!flag_traditional)
319 warning ("data definition has no type or storage class");
321 current_declspecs = TREE_VALUE (declspec_stack);
322 prefix_attributes = TREE_PURPOSE (declspec_stack);
323 declspec_stack = TREE_CHAIN (declspec_stack);
324 resume_momentary ($1); }
325 | declmods setspecs notype_initdecls ';'
326 { current_declspecs = TREE_VALUE (declspec_stack);
327 prefix_attributes = TREE_PURPOSE (declspec_stack);
328 declspec_stack = TREE_CHAIN (declspec_stack);
329 resume_momentary ($2); }
330 | typed_declspecs setspecs initdecls ';'
331 { current_declspecs = TREE_VALUE (declspec_stack);
332 prefix_attributes = TREE_PURPOSE (declspec_stack);
333 declspec_stack = TREE_CHAIN (declspec_stack);
334 resume_momentary ($2); }
336 { pedwarn ("empty declaration"); }
337 | typed_declspecs ';'
343 pedwarn ("ANSI C does not allow extra `;' outside of a function"); }
347 typed_declspecs setspecs declarator
348 { if (! start_function (current_declspecs, $3,
349 prefix_attributes, NULL_TREE, 0))
351 reinit_parse_for_function (); }
353 { store_parm_decls (); }
355 { finish_function (0);
356 current_declspecs = TREE_VALUE (declspec_stack);
357 prefix_attributes = TREE_PURPOSE (declspec_stack);
358 declspec_stack = TREE_CHAIN (declspec_stack);
359 resume_momentary ($2); }
360 | typed_declspecs setspecs declarator error
361 { current_declspecs = TREE_VALUE (declspec_stack);
362 prefix_attributes = TREE_PURPOSE (declspec_stack);
363 declspec_stack = TREE_CHAIN (declspec_stack);
364 resume_momentary ($2); }
365 | declmods setspecs notype_declarator
366 { if (! start_function (current_declspecs, $3,
367 prefix_attributes, NULL_TREE, 0))
369 reinit_parse_for_function (); }
371 { store_parm_decls (); }
373 { finish_function (0);
374 current_declspecs = TREE_VALUE (declspec_stack);
375 prefix_attributes = TREE_PURPOSE (declspec_stack);
376 declspec_stack = TREE_CHAIN (declspec_stack);
377 resume_momentary ($2); }
378 | declmods setspecs notype_declarator error
379 { current_declspecs = TREE_VALUE (declspec_stack);
380 prefix_attributes = TREE_PURPOSE (declspec_stack);
381 declspec_stack = TREE_CHAIN (declspec_stack);
382 resume_momentary ($2); }
383 | setspecs notype_declarator
384 { if (! start_function (NULL_TREE, $2,
385 prefix_attributes, NULL_TREE, 0))
387 reinit_parse_for_function (); }
389 { store_parm_decls (); }
391 { finish_function (0);
392 current_declspecs = TREE_VALUE (declspec_stack);
393 prefix_attributes = TREE_PURPOSE (declspec_stack);
394 declspec_stack = TREE_CHAIN (declspec_stack);
395 resume_momentary ($1); }
396 | setspecs notype_declarator error
397 { current_declspecs = TREE_VALUE (declspec_stack);
398 prefix_attributes = TREE_PURPOSE (declspec_stack);
399 declspec_stack = TREE_CHAIN (declspec_stack);
400 resume_momentary ($1); }
415 { $$ = NEGATE_EXPR; }
417 { $$ = CONVERT_EXPR; }
419 { $$ = PREINCREMENT_EXPR; }
421 { $$ = PREDECREMENT_EXPR; }
423 { $$ = BIT_NOT_EXPR; }
425 { $$ = TRUTH_NOT_EXPR; }
428 expr: nonnull_exprlist
429 { $$ = build_compound_expr ($1); }
440 { $$ = build_tree_list (NULL_TREE, $1); }
441 | nonnull_exprlist ',' expr_no_commas
442 { chainon ($1, build_tree_list (NULL_TREE, $3)); }
447 | '*' cast_expr %prec UNARY
448 { $$ = build_indirect_ref ($2, "unary *"); }
449 /* __extension__ turns off -pedantic for following primary. */
450 | extension cast_expr %prec UNARY
452 RESTORE_WARN_FLAGS ($1); }
453 | unop cast_expr %prec UNARY
454 { $$ = build_unary_op ($1, $2, 0);
455 overflow_warning ($$); }
456 /* Refer to the address of a label as a pointer. */
458 { tree label = lookup_label ($2);
460 pedwarn ("ANSI C forbids `&&'");
462 $$ = null_pointer_node;
465 TREE_USED (label) = 1;
466 $$ = build1 (ADDR_EXPR, ptr_type_node, label);
467 TREE_CONSTANT ($$) = 1;
470 /* This seems to be impossible on some machines, so let's turn it off.
471 You can use __builtin_next_arg to find the anonymous stack args.
473 { tree types = TYPE_ARG_TYPES (TREE_TYPE (current_function_decl));
474 $$ = error_mark_node;
475 if (TREE_VALUE (tree_last (types)) == void_type_node)
476 error ("`&...' used in function with fixed number of arguments");
480 pedwarn ("ANSI C forbids `&...'");
481 $$ = tree_last (DECL_ARGUMENTS (current_function_decl));
482 $$ = build_unary_op (ADDR_EXPR, $$, 0);
485 | sizeof unary_expr %prec UNARY
487 if (TREE_CODE ($2) == COMPONENT_REF
488 && DECL_C_BIT_FIELD (TREE_OPERAND ($2, 1)))
489 error ("`sizeof' applied to a bit-field");
490 $$ = c_sizeof (TREE_TYPE ($2)); }
491 | sizeof '(' typename ')' %prec HYPERUNARY
493 $$ = c_sizeof (groktypename ($3)); }
494 | alignof unary_expr %prec UNARY
496 $$ = c_alignof_expr ($2); }
497 | alignof '(' typename ')' %prec HYPERUNARY
499 $$ = c_alignof (groktypename ($3)); }
500 | REALPART cast_expr %prec UNARY
501 { $$ = build_unary_op (REALPART_EXPR, $2, 0); }
502 | IMAGPART cast_expr %prec UNARY
503 { $$ = build_unary_op (IMAGPART_EXPR, $2, 0); }
504 | VA_ARG '(' expr_no_commas ',' typename ')'
505 { $$ = build_va_arg ($3, groktypename ($5)); }
509 SIZEOF { skip_evaluation++; }
513 ALIGNOF { skip_evaluation++; }
518 | '(' typename ')' cast_expr %prec UNARY
519 { tree type = groktypename ($2);
520 $$ = build_c_cast (type, $4); }
521 | '(' typename ')' '{'
522 { start_init (NULL_TREE, NULL, 0);
523 $2 = groktypename ($2);
524 really_start_incremental_init ($2); }
525 initlist_maybe_comma '}' %prec UNARY
527 tree result = pop_init_level (0);
531 if (pedantic && ! flag_isoc9x)
532 pedwarn ("ANSI C forbids constructor expressions");
533 if (TYPE_NAME (type) != 0)
535 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
536 name = IDENTIFIER_POINTER (TYPE_NAME (type));
538 name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
543 if (TREE_CODE (type) == ARRAY_TYPE && TYPE_SIZE (type) == 0)
545 int failure = complete_array_type (type, $$, 1);
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 '/' expr_no_commas
561 { $$ = parser_build_binary_op ($2, $1, $3); }
562 | expr_no_commas '%' expr_no_commas
563 { $$ = parser_build_binary_op ($2, $1, $3); }
564 | expr_no_commas LSHIFT expr_no_commas
565 { $$ = parser_build_binary_op ($2, $1, $3); }
566 | expr_no_commas RSHIFT expr_no_commas
567 { $$ = parser_build_binary_op ($2, $1, $3); }
568 | expr_no_commas ARITHCOMPARE expr_no_commas
569 { $$ = parser_build_binary_op ($2, $1, $3); }
570 | expr_no_commas EQCOMPARE 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 '|' expr_no_commas
575 { $$ = parser_build_binary_op ($2, $1, $3); }
576 | expr_no_commas '^' expr_no_commas
577 { $$ = parser_build_binary_op ($2, $1, $3); }
578 | expr_no_commas ANDAND
579 { $1 = truthvalue_conversion (default_conversion ($1));
580 skip_evaluation += $1 == boolean_false_node; }
582 { skip_evaluation -= $1 == boolean_false_node;
583 $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $4); }
584 | expr_no_commas OROR
585 { $1 = truthvalue_conversion (default_conversion ($1));
586 skip_evaluation += $1 == boolean_true_node; }
588 { skip_evaluation -= $1 == boolean_true_node;
589 $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $4); }
591 { $1 = truthvalue_conversion (default_conversion ($1));
592 skip_evaluation += $1 == boolean_false_node; }
594 { skip_evaluation += (($1 == boolean_true_node)
595 - ($1 == boolean_false_node)); }
597 { skip_evaluation -= $1 == boolean_true_node;
598 $$ = build_conditional_expr ($1, $4, $7); }
601 pedwarn ("ANSI C forbids omitting the middle term of a ?: expression");
602 /* Make sure first operand is calculated only once. */
603 $<ttype>2 = save_expr ($1);
604 $1 = truthvalue_conversion (default_conversion ($<ttype>2));
605 skip_evaluation += $1 == boolean_true_node; }
607 { skip_evaluation -= $1 == boolean_true_node;
608 $$ = build_conditional_expr ($1, $<ttype>2, $5); }
609 | expr_no_commas '=' expr_no_commas
611 $$ = build_modify_expr ($1, NOP_EXPR, $3);
612 class = TREE_CODE_CLASS (TREE_CODE ($$));
613 if (class == 'e' || class == '1'
614 || class == '2' || class == '<')
615 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR);
617 | expr_no_commas ASSIGN expr_no_commas
619 $$ = build_modify_expr ($1, $2, $3);
620 /* This inhibits warnings in truthvalue_conversion. */
621 class = TREE_CODE_CLASS (TREE_CODE ($$));
622 if (class == 'e' || class == '1'
623 || class == '2' || class == '<')
624 C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK);
632 if (!$$ || $$ == error_mark_node)
634 if (yychar == YYEMPTY)
641 if (objc_receiver_context
642 && ! (objc_receiver_context
643 && strcmp (IDENTIFIER_POINTER ($1), "super")))
644 /* we have a message to super */
645 $$ = get_super_receiver ();
646 else if (objc_method_context
647 && (decl = is_ivar (objc_ivar_chain, $1)))
649 if (is_private (decl))
650 $$ = error_mark_node;
652 $$ = build_ivar_reference ($1);
657 /* Ordinary implicit function declaration. */
658 $$ = implicitly_declare ($1);
659 assemble_external ($$);
663 else if (current_function_decl == 0)
665 error ("`%s' undeclared here (not in a function)",
666 IDENTIFIER_POINTER ($1));
667 $$ = error_mark_node;
674 if (objc_receiver_context
675 && ! strcmp (IDENTIFIER_POINTER ($1), "super"))
676 /* we have a message to super */
677 $$ = get_super_receiver ();
678 else if (objc_method_context
679 && (decl = is_ivar (objc_ivar_chain, $1)))
681 if (is_private (decl))
682 $$ = error_mark_node;
684 $$ = build_ivar_reference ($1);
689 if (IDENTIFIER_GLOBAL_VALUE ($1) != error_mark_node
690 || IDENTIFIER_ERROR_LOCUS ($1) != current_function_decl)
692 error ("`%s' undeclared (first use in this function)",
693 IDENTIFIER_POINTER ($1));
695 if (! undeclared_variable_notice)
697 error ("(Each undeclared identifier is reported only once");
698 error ("for each function it appears in.)");
699 undeclared_variable_notice = 1;
702 $$ = error_mark_node;
703 /* Prevent repeated error messages. */
704 IDENTIFIER_GLOBAL_VALUE ($1) = error_mark_node;
705 IDENTIFIER_ERROR_LOCUS ($1) = current_function_decl;
709 else if (TREE_TYPE ($$) == error_mark_node)
710 $$ = error_mark_node;
711 else if (C_DECL_ANTICIPATED ($$))
713 /* The first time we see a build-in function used,
714 if it has not been declared. */
715 C_DECL_ANTICIPATED ($$) = 0;
716 if (yychar == YYEMPTY)
720 /* Omit the implicit declaration we
721 would ordinarily do, so we don't lose
722 the actual built in type.
723 But print a diagnostic for the mismatch. */
725 if (objc_method_context
726 && is_ivar (objc_ivar_chain, $1))
727 error ("Instance variable `%s' implicitly declared as function",
728 IDENTIFIER_POINTER (DECL_NAME ($$)));
731 if (TREE_CODE ($$) != FUNCTION_DECL)
732 error ("`%s' implicitly declared as function",
733 IDENTIFIER_POINTER (DECL_NAME ($$)));
734 else if ((TYPE_MODE (TREE_TYPE (TREE_TYPE ($$)))
735 != TYPE_MODE (integer_type_node))
736 && (TREE_TYPE (TREE_TYPE ($$))
738 pedwarn ("type mismatch in implicit declaration for built-in function `%s'",
739 IDENTIFIER_POINTER (DECL_NAME ($$)));
740 /* If it really returns void, change that to int. */
741 if (TREE_TYPE (TREE_TYPE ($$)) == void_type_node)
743 = build_function_type (integer_type_node,
744 TYPE_ARG_TYPES (TREE_TYPE ($$)));
747 pedwarn ("built-in function `%s' used without declaration",
748 IDENTIFIER_POINTER (DECL_NAME ($$)));
750 /* Do what we would ordinarily do when a fn is used. */
751 assemble_external ($$);
756 assemble_external ($$);
759 /* we have a definition - still check if iVariable */
761 if (!objc_receiver_context
762 || (objc_receiver_context
763 && strcmp (IDENTIFIER_POINTER ($1), "super")))
767 if (objc_method_context
768 && (decl = is_ivar (objc_ivar_chain, $1)))
770 if (IDENTIFIER_LOCAL_VALUE ($1))
771 warning ("local declaration of `%s' hides instance variable",
772 IDENTIFIER_POINTER ($1));
775 if (is_private (decl))
776 $$ = error_mark_node;
778 $$ = build_ivar_reference ($1);
782 else /* we have a message to super */
783 $$ = get_super_receiver ();
787 if (TREE_CODE ($$) == CONST_DECL)
789 $$ = DECL_INITIAL ($$);
790 /* This is to prevent an enum whose value is 0
791 from being considered a null pointer constant. */
792 $$ = build1 (NOP_EXPR, TREE_TYPE ($$), $$);
793 TREE_CONSTANT ($$) = 1;
798 { $$ = combine_strings ($1); }
800 { char class = TREE_CODE_CLASS (TREE_CODE ($2));
801 if (class == 'e' || class == '1'
802 || class == '2' || class == '<')
803 C_SET_EXP_ORIGINAL_CODE ($2, ERROR_MARK);
806 { $$ = error_mark_node; }
807 | compstmt_primary_start compstmt_nostart ')'
810 pedwarn ("ANSI C forbids braced-groups within expressions");
811 pop_iterator_stack ();
813 rtl_exp = expand_end_stmt_expr ($1);
814 /* The statements have side effects, so the group does. */
815 TREE_SIDE_EFFECTS (rtl_exp) = 1;
817 if (TREE_CODE ($2) == BLOCK)
819 /* Make a BIND_EXPR for the BLOCK already made. */
820 $$ = build (BIND_EXPR, TREE_TYPE (rtl_exp),
821 NULL_TREE, rtl_exp, $2);
822 /* Remove the block from the tree at this point.
823 It gets put back at the proper place
824 when the BIND_EXPR is expanded. */
830 | compstmt_primary_start error ')'
832 /* Make sure we call expand_end_stmt_expr. Otherwise
833 we are likely to lose sequences and crash later. */
834 pop_iterator_stack ();
836 expand_end_stmt_expr ($1);
837 $$ = error_mark_node;
839 | primary '(' exprlist ')' %prec '.'
840 { $$ = build_function_call ($1, $3); }
841 | primary '[' expr ']' %prec '.'
842 { $$ = build_array_ref ($1, $3); }
843 | primary '.' identifier
846 if (doing_objc_thang)
848 if (is_public ($1, $3))
849 $$ = build_component_ref ($1, $3);
851 $$ = error_mark_node;
855 $$ = build_component_ref ($1, $3);
857 | primary POINTSAT identifier
859 tree expr = build_indirect_ref ($1, "->");
862 if (doing_objc_thang)
864 if (is_public (expr, $3))
865 $$ = build_component_ref (expr, $3);
867 $$ = error_mark_node;
871 $$ = build_component_ref (expr, $3);
874 { $$ = build_unary_op (POSTINCREMENT_EXPR, $1, 0); }
876 { $$ = build_unary_op (POSTDECREMENT_EXPR, $1, 0); }
879 { $$ = build_message_expr ($1); }
881 { $$ = build_selector_expr ($1); }
883 { $$ = build_protocol_expr ($1); }
885 { $$ = build_encode_expr ($1); }
887 { $$ = build_objc_string_object ($1); }
891 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
895 { $$ = chainon ($1, $2); }
899 /* Produces an OBJC_STRING_CST with perhaps more OBJC_STRING_CSTs chained
903 | objc_string OBJC_STRING
904 { $$ = chainon ($1, $2); }
908 old_style_parm_decls:
912 /* ... is used here to indicate a varargs function. */
915 pedwarn ("ANSI C does not permit use of `varargs.h'"); }
918 /* The following are analogous to lineno_decl, decls and decl
919 except that they do not allow nested functions.
920 They are used for old-style parm decls. */
922 save_filename save_lineno datadecl
929 | datadecls lineno_datadecl
930 | lineno_datadecl errstmt
933 /* We don't allow prefix attributes here because they cause reduce/reduce
934 conflicts: we can't know whether we're parsing a function decl with
935 attribute suffix, or function defn with attribute prefix on first old
938 typed_declspecs_no_prefix_attr setspecs initdecls ';'
939 { current_declspecs = TREE_VALUE (declspec_stack);
940 prefix_attributes = TREE_PURPOSE (declspec_stack);
941 declspec_stack = TREE_CHAIN (declspec_stack);
942 resume_momentary ($2); }
943 | declmods_no_prefix_attr setspecs notype_initdecls ';'
944 { current_declspecs = TREE_VALUE (declspec_stack);
945 prefix_attributes = TREE_PURPOSE (declspec_stack);
946 declspec_stack = TREE_CHAIN (declspec_stack);
947 resume_momentary ($2); }
948 | typed_declspecs_no_prefix_attr ';'
949 { shadow_tag_warned ($1, 1);
950 pedwarn ("empty declaration"); }
951 | declmods_no_prefix_attr ';'
952 { pedwarn ("empty declaration"); }
955 /* This combination which saves a lineno before a decl
956 is the normal thing to use, rather than decl itself.
957 This is to avoid shift/reduce conflicts in contexts
958 where statement labels are allowed. */
960 save_filename save_lineno decl
968 | lineno_decl errstmt
971 /* records the type and storage class specs to use for processing
972 the declarators that follow.
973 Maintains a stack of outer-level values of current_declspecs,
974 for the sake of parm declarations nested in function declarators. */
975 setspecs: /* empty */
976 { $$ = suspend_momentary ();
977 pending_xref_error ();
978 declspec_stack = tree_cons (prefix_attributes,
981 split_specs_attrs ($<ttype>0,
982 ¤t_declspecs, &prefix_attributes); }
985 /* ??? Yuck. See after_type_declarator. */
986 setattrs: /* empty */
987 { prefix_attributes = chainon (prefix_attributes, $<ttype>0); }
991 typed_declspecs setspecs initdecls ';'
992 { current_declspecs = TREE_VALUE (declspec_stack);
993 prefix_attributes = TREE_PURPOSE (declspec_stack);
994 declspec_stack = TREE_CHAIN (declspec_stack);
995 resume_momentary ($2); }
996 | declmods setspecs notype_initdecls ';'
997 { current_declspecs = TREE_VALUE (declspec_stack);
998 prefix_attributes = TREE_PURPOSE (declspec_stack);
999 declspec_stack = TREE_CHAIN (declspec_stack);
1000 resume_momentary ($2); }
1001 | typed_declspecs setspecs nested_function
1002 { current_declspecs = TREE_VALUE (declspec_stack);
1003 prefix_attributes = TREE_PURPOSE (declspec_stack);
1004 declspec_stack = TREE_CHAIN (declspec_stack);
1005 resume_momentary ($2); }
1006 | declmods setspecs notype_nested_function
1007 { current_declspecs = TREE_VALUE (declspec_stack);
1008 prefix_attributes = TREE_PURPOSE (declspec_stack);
1009 declspec_stack = TREE_CHAIN (declspec_stack);
1010 resume_momentary ($2); }
1011 | typed_declspecs ';'
1012 { shadow_tag ($1); }
1014 { pedwarn ("empty declaration"); }
1016 { RESTORE_WARN_FLAGS ($1); }
1019 /* Declspecs which contain at least one type specifier or typedef name.
1020 (Just `const' or `volatile' is not enough.)
1021 A typedef'd name following these is taken as a name to be declared.
1022 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
1025 typespec reserved_declspecs
1026 { $$ = tree_cons (NULL_TREE, $1, $2); }
1027 | declmods typespec reserved_declspecs
1028 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
1031 reserved_declspecs: /* empty */
1033 | reserved_declspecs typespecqual_reserved
1034 { $$ = tree_cons (NULL_TREE, $2, $1); }
1035 | reserved_declspecs SCSPEC
1036 { if (extra_warnings)
1037 warning ("`%s' is not at beginning of declaration",
1038 IDENTIFIER_POINTER ($2));
1039 $$ = tree_cons (NULL_TREE, $2, $1); }
1040 | reserved_declspecs attributes
1041 { $$ = tree_cons ($2, NULL_TREE, $1); }
1044 typed_declspecs_no_prefix_attr:
1045 typespec reserved_declspecs_no_prefix_attr
1046 { $$ = tree_cons (NULL_TREE, $1, $2); }
1047 | declmods_no_prefix_attr typespec reserved_declspecs_no_prefix_attr
1048 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
1051 reserved_declspecs_no_prefix_attr:
1054 | reserved_declspecs_no_prefix_attr typespecqual_reserved
1055 { $$ = tree_cons (NULL_TREE, $2, $1); }
1056 | reserved_declspecs_no_prefix_attr SCSPEC
1057 { if (extra_warnings)
1058 warning ("`%s' is not at beginning of declaration",
1059 IDENTIFIER_POINTER ($2));
1060 $$ = tree_cons (NULL_TREE, $2, $1); }
1063 /* List of just storage classes, type modifiers, and prefix attributes.
1064 A declaration can start with just this, but then it cannot be used
1065 to redeclare a typedef-name.
1066 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
1069 declmods_no_prefix_attr
1072 { $$ = tree_cons ($1, NULL_TREE, NULL_TREE); }
1073 | declmods declmods_no_prefix_attr
1074 { $$ = chainon ($2, $1); }
1075 | declmods attributes
1076 { $$ = tree_cons ($2, NULL_TREE, $1); }
1079 declmods_no_prefix_attr:
1081 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
1082 TREE_STATIC ($$) = 1; }
1084 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
1085 | declmods_no_prefix_attr TYPE_QUAL
1086 { $$ = tree_cons (NULL_TREE, $2, $1);
1087 TREE_STATIC ($$) = 1; }
1088 | declmods_no_prefix_attr SCSPEC
1089 { if (extra_warnings && TREE_STATIC ($1))
1090 warning ("`%s' is not at beginning of declaration",
1091 IDENTIFIER_POINTER ($2));
1092 $$ = tree_cons (NULL_TREE, $2, $1);
1093 TREE_STATIC ($$) = TREE_STATIC ($1); }
1097 /* Used instead of declspecs where storage classes are not allowed
1098 (that is, for typenames and structure components).
1099 Don't accept a typedef-name if anything but a modifier precedes it. */
1102 typespec reserved_typespecquals
1103 { $$ = tree_cons (NULL_TREE, $1, $2); }
1104 | nonempty_type_quals typespec reserved_typespecquals
1105 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
1108 reserved_typespecquals: /* empty */
1110 | reserved_typespecquals typespecqual_reserved
1111 { $$ = tree_cons (NULL_TREE, $2, $1); }
1114 /* A typespec (but not a type qualifier).
1115 Once we have seen one of these in a declaration,
1116 if a typedef name appears then it is being redeclared. */
1121 { /* For a typedef name, record the meaning, not the name.
1122 In case of `foo foo, bar;'. */
1123 $$ = lookup_name ($1); }
1125 | CLASSNAME protocolrefs
1126 { $$ = get_static_reference ($1, $2); }
1127 | OBJECTNAME protocolrefs
1128 { $$ = get_object_reference ($2); }
1130 /* Make "<SomeProtocol>" equivalent to "id <SomeProtocol>"
1131 - nisse@lysator.liu.se */
1132 | non_empty_protocolrefs
1133 { $$ = get_object_reference ($1); }
1135 | TYPEOF '(' expr ')'
1136 { $$ = TREE_TYPE ($3); }
1137 | TYPEOF '(' typename ')'
1138 { $$ = groktypename ($3); }
1141 /* A typespec that is a reserved word, or a type qualifier. */
1143 typespecqual_reserved: TYPESPEC
1150 | initdecls ',' initdcl
1155 | notype_initdecls ',' initdcl
1161 | ASM_KEYWORD '(' string ')'
1162 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
1168 declarator maybeasm maybe_attribute '='
1169 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1170 $3, prefix_attributes);
1171 start_init ($<ttype>$, $2, global_bindings_p ()); }
1173 /* Note how the declaration of the variable is in effect while its init is parsed! */
1175 finish_decl ($<ttype>5, $6, $2); }
1176 | declarator maybeasm maybe_attribute
1177 { tree d = start_decl ($1, current_declspecs, 0,
1178 $3, prefix_attributes);
1179 finish_decl (d, NULL_TREE, $2);
1184 notype_declarator maybeasm maybe_attribute '='
1185 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1186 $3, prefix_attributes);
1187 start_init ($<ttype>$, $2, global_bindings_p ()); }
1189 /* Note how the declaration of the variable is in effect while its init is parsed! */
1191 decl_attributes ($<ttype>5, $3, prefix_attributes);
1192 finish_decl ($<ttype>5, $6, $2); }
1193 | notype_declarator maybeasm maybe_attribute
1194 { tree d = start_decl ($1, current_declspecs, 0,
1195 $3, prefix_attributes);
1196 finish_decl (d, NULL_TREE, $2); }
1198 /* the * rules are dummies to accept the Apollo extended syntax
1199 so that the header files compile. */
1210 | attributes attribute
1211 { $$ = chainon ($1, $2); }
1215 ATTRIBUTE '(' '(' attribute_list ')' ')'
1222 | attribute_list ',' attrib
1223 { $$ = chainon ($1, $3); }
1230 { $$ = build_tree_list ($1, NULL_TREE); }
1231 | any_word '(' IDENTIFIER ')'
1232 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1233 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1234 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1235 | any_word '(' exprlist ')'
1236 { $$ = build_tree_list ($1, $3); }
1239 /* This still leaves out most reserved keywords,
1240 shouldn't we include them? */
1249 /* Initializers. `init' is the entry point. */
1254 { really_start_incremental_init (NULL_TREE);
1255 /* Note that the call to clear_momentary
1256 is in process_init_element. */
1257 push_momentary (); }
1258 initlist_maybe_comma '}'
1259 { $$ = pop_init_level (0);
1260 if ($$ == error_mark_node
1261 && ! (yychar == STRING || yychar == CONSTANT))
1264 pop_momentary_nofree (); }
1267 { $$ = error_mark_node; }
1270 /* `initlist_maybe_comma' is the guts of an initializer in braces. */
1271 initlist_maybe_comma:
1274 pedwarn ("ANSI C forbids empty initializer braces"); }
1275 | initlist1 maybecomma
1280 | initlist1 ',' initelt
1283 /* `initelt' is a single element of an initializer.
1284 It may use braces. */
1286 designator_list '=' initval
1287 | designator initval
1289 { set_init_label ($1); }
1296 { push_init_level (0); }
1297 initlist_maybe_comma '}'
1298 { process_init_element (pop_init_level (0)); }
1300 { process_init_element ($1); }
1306 | designator_list designator
1311 { set_init_label ($2); }
1312 /* These are for labeled elements. The syntax for an array element
1313 initializer conflicts with the syntax for an Objective-C message,
1314 so don't include these productions in the Objective-C grammar. */
1316 | '[' expr_no_commas ELLIPSIS expr_no_commas ']'
1317 { set_init_index ($2, $4); }
1318 | '[' expr_no_commas ']'
1319 { set_init_index ($2, NULL_TREE); }
1326 pedwarn ("ANSI C forbids nested functions");
1328 push_function_context ();
1329 if (! start_function (current_declspecs, $1,
1330 prefix_attributes, NULL_TREE, 1))
1332 pop_function_context ();
1335 reinit_parse_for_function (); }
1336 old_style_parm_decls
1337 { store_parm_decls (); }
1338 /* This used to use compstmt_or_error.
1339 That caused a bug with input `f(g) int g {}',
1340 where the use of YYERROR1 above caused an error
1341 which then was handled by compstmt_or_error.
1342 There followed a repeated execution of that same rule,
1343 which called YYERROR1 again, and so on. */
1345 { finish_function (1);
1346 pop_function_context (); }
1349 notype_nested_function:
1352 pedwarn ("ANSI C forbids nested functions");
1354 push_function_context ();
1355 if (! start_function (current_declspecs, $1,
1356 prefix_attributes, NULL_TREE, 1))
1358 pop_function_context ();
1361 reinit_parse_for_function (); }
1362 old_style_parm_decls
1363 { store_parm_decls (); }
1364 /* This used to use compstmt_or_error.
1365 That caused a bug with input `f(g) int g {}',
1366 where the use of YYERROR1 above caused an error
1367 which then was handled by compstmt_or_error.
1368 There followed a repeated execution of that same rule,
1369 which called YYERROR1 again, and so on. */
1371 { finish_function (1);
1372 pop_function_context (); }
1375 /* Any kind of declarator (thus, all declarators allowed
1376 after an explicit typespec). */
1379 after_type_declarator
1383 /* A declarator that is allowed only after an explicit typespec. */
1385 after_type_declarator:
1386 '(' after_type_declarator ')'
1388 | after_type_declarator '(' parmlist_or_identifiers %prec '.'
1389 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1390 /* | after_type_declarator '(' error ')' %prec '.'
1391 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1392 poplevel (0, 0, 0); } */
1393 | after_type_declarator '[' expr ']' %prec '.'
1394 { $$ = build_nt (ARRAY_REF, $1, $3); }
1395 | after_type_declarator '[' ']' %prec '.'
1396 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1397 | '*' type_quals after_type_declarator %prec UNARY
1398 { $$ = make_pointer_declarator ($2, $3); }
1399 /* ??? Yuck. setattrs is a quick hack. We can't use
1400 prefix_attributes because $1 only applies to this
1401 declarator. We assume setspecs has already been done.
1402 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1403 attributes could be recognized here or in `attributes'). */
1404 | attributes setattrs after_type_declarator
1412 /* Kinds of declarator that can appear in a parameter list
1413 in addition to notype_declarator. This is like after_type_declarator
1414 but does not allow a typedef name in parentheses as an identifier
1415 (because it would conflict with a function with that typedef as arg). */
1418 parm_declarator '(' parmlist_or_identifiers %prec '.'
1419 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1420 /* | parm_declarator '(' error ')' %prec '.'
1421 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1422 poplevel (0, 0, 0); } */
1424 | parm_declarator '[' '*' ']' %prec '.'
1425 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE);
1427 error ("`[*]' in parameter declaration only allowed in ISO C 9x");
1430 | parm_declarator '[' expr ']' %prec '.'
1431 { $$ = build_nt (ARRAY_REF, $1, $3); }
1432 | parm_declarator '[' ']' %prec '.'
1433 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1434 | '*' type_quals parm_declarator %prec UNARY
1435 { $$ = make_pointer_declarator ($2, $3); }
1436 /* ??? Yuck. setattrs is a quick hack. We can't use
1437 prefix_attributes because $1 only applies to this
1438 declarator. We assume setspecs has already been done.
1439 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1440 attributes could be recognized here or in `attributes'). */
1441 | attributes setattrs parm_declarator
1446 /* A declarator allowed whether or not there has been
1447 an explicit typespec. These cannot redeclare a typedef-name. */
1450 notype_declarator '(' parmlist_or_identifiers %prec '.'
1451 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1452 /* | notype_declarator '(' error ')' %prec '.'
1453 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1454 poplevel (0, 0, 0); } */
1455 | '(' notype_declarator ')'
1457 | '*' type_quals notype_declarator %prec UNARY
1458 { $$ = make_pointer_declarator ($2, $3); }
1460 | notype_declarator '[' '*' ']' %prec '.'
1461 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE);
1463 error ("`[*]' in parameter declaration only allowed in ISO C 9x");
1466 | notype_declarator '[' expr ']' %prec '.'
1467 { $$ = build_nt (ARRAY_REF, $1, $3); }
1468 | notype_declarator '[' ']' %prec '.'
1469 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1470 /* ??? Yuck. setattrs is a quick hack. We can't use
1471 prefix_attributes because $1 only applies to this
1472 declarator. We assume setspecs has already been done.
1473 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1474 attributes could be recognized here or in `attributes'). */
1475 | attributes setattrs notype_declarator
1502 struct_head identifier '{'
1503 { $$ = start_struct (RECORD_TYPE, $2);
1504 /* Start scope of tag before parsing components. */
1506 component_decl_list '}' maybe_attribute
1507 { $$ = finish_struct ($<ttype>4, $5, chainon ($1, $7)); }
1508 | struct_head '{' component_decl_list '}' maybe_attribute
1509 { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
1510 $3, chainon ($1, $5));
1512 | struct_head identifier
1513 { $$ = xref_tag (RECORD_TYPE, $2); }
1514 | union_head identifier '{'
1515 { $$ = start_struct (UNION_TYPE, $2); }
1516 component_decl_list '}' maybe_attribute
1517 { $$ = finish_struct ($<ttype>4, $5, chainon ($1, $7)); }
1518 | union_head '{' component_decl_list '}' maybe_attribute
1519 { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
1520 $3, chainon ($1, $5));
1522 | union_head identifier
1523 { $$ = xref_tag (UNION_TYPE, $2); }
1524 | enum_head identifier '{'
1525 { $<itype>3 = suspend_momentary ();
1526 $$ = start_enum ($2); }
1527 enumlist maybecomma_warn '}' maybe_attribute
1528 { $$= finish_enum ($<ttype>4, nreverse ($5), chainon ($1, $8));
1529 resume_momentary ($<itype>3); }
1531 { $<itype>2 = suspend_momentary ();
1532 $$ = start_enum (NULL_TREE); }
1533 enumlist maybecomma_warn '}' maybe_attribute
1534 { $$= finish_enum ($<ttype>3, nreverse ($4), chainon ($1, $7));
1535 resume_momentary ($<itype>2); }
1536 | enum_head identifier
1537 { $$ = xref_tag (ENUMERAL_TYPE, $2); }
1548 { if (pedantic && ! flag_isoc9x)
1549 pedwarn ("comma at end of enumerator list"); }
1552 component_decl_list:
1553 component_decl_list2
1555 | component_decl_list2 component_decl
1556 { $$ = chainon ($1, $2);
1557 pedwarn ("no semicolon at end of struct or union"); }
1560 component_decl_list2: /* empty */
1562 | component_decl_list2 component_decl ';'
1563 { $$ = chainon ($1, $2); }
1564 | component_decl_list2 ';'
1566 pedwarn ("extra semicolon in struct or union specified"); }
1568 /* foo(sizeof(struct{ @defs(ClassName)})); */
1569 | DEFS '(' CLASSNAME ')'
1571 tree interface = lookup_interface ($3);
1574 $$ = get_class_ivars (interface);
1577 error ("Cannot find interface declaration for `%s'",
1578 IDENTIFIER_POINTER ($3));
1585 /* There is a shift-reduce conflict here, because `components' may
1586 start with a `typename'. It happens that shifting (the default resolution)
1587 does the right thing, because it treats the `typename' as part of
1588 a `typed_typespecs'.
1590 It is possible that this same technique would allow the distinction
1591 between `notype_initdecls' and `initdecls' to be eliminated.
1592 But I am being cautious and not trying it. */
1595 typed_typespecs setspecs components
1597 current_declspecs = TREE_VALUE (declspec_stack);
1598 prefix_attributes = TREE_PURPOSE (declspec_stack);
1599 declspec_stack = TREE_CHAIN (declspec_stack);
1600 resume_momentary ($2); }
1601 | typed_typespecs setspecs save_filename save_lineno maybe_attribute
1603 /* Support for unnamed structs or unions as members of
1604 structs or unions (which is [a] useful and [b] supports
1607 pedwarn ("ANSI C doesn't support unnamed structs/unions");
1609 $$ = grokfield($3, $4, NULL, current_declspecs, NULL_TREE);
1610 current_declspecs = TREE_VALUE (declspec_stack);
1611 prefix_attributes = TREE_PURPOSE (declspec_stack);
1612 declspec_stack = TREE_CHAIN (declspec_stack);
1613 resume_momentary ($2);
1615 | nonempty_type_quals setspecs components
1617 current_declspecs = TREE_VALUE (declspec_stack);
1618 prefix_attributes = TREE_PURPOSE (declspec_stack);
1619 declspec_stack = TREE_CHAIN (declspec_stack);
1620 resume_momentary ($2); }
1621 | nonempty_type_quals
1623 pedwarn ("ANSI C forbids member declarations with no members");
1628 | extension component_decl
1630 RESTORE_WARN_FLAGS ($1); }
1634 component_declarator
1635 | components ',' component_declarator
1636 { $$ = chainon ($1, $3); }
1639 component_declarator:
1640 save_filename save_lineno declarator maybe_attribute
1641 { $$ = grokfield ($1, $2, $3, current_declspecs, NULL_TREE);
1642 decl_attributes ($$, $4, prefix_attributes); }
1643 | save_filename save_lineno
1644 declarator ':' expr_no_commas maybe_attribute
1645 { $$ = grokfield ($1, $2, $3, current_declspecs, $5);
1646 decl_attributes ($$, $6, prefix_attributes); }
1647 | save_filename save_lineno ':' expr_no_commas maybe_attribute
1648 { $$ = grokfield ($1, $2, NULL_TREE, current_declspecs, $4);
1649 decl_attributes ($$, $5, prefix_attributes); }
1652 /* We chain the enumerators in reverse order.
1653 They are put in forward order where enumlist is used.
1654 (The order used to be significant, but no longer is so.
1655 However, we still maintain the order, just to be clean.) */
1659 | enumlist ',' enumerator
1660 { if ($1 == error_mark_node)
1663 $$ = chainon ($3, $1); }
1665 { $$ = error_mark_node; }
1671 { $$ = build_enumerator ($1, NULL_TREE); }
1672 | identifier '=' expr_no_commas
1673 { $$ = build_enumerator ($1, $3); }
1677 typed_typespecs absdcl
1678 { $$ = build_tree_list ($1, $2); }
1679 | nonempty_type_quals absdcl
1680 { $$ = build_tree_list ($1, $2); }
1683 absdcl: /* an absolute declarator */
1689 nonempty_type_quals:
1691 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
1692 | nonempty_type_quals TYPE_QUAL
1693 { $$ = tree_cons (NULL_TREE, $2, $1); }
1699 | type_quals TYPE_QUAL
1700 { $$ = tree_cons (NULL_TREE, $2, $1); }
1703 absdcl1: /* a nonempty absolute declarator */
1706 /* `(typedef)1' is `int'. */
1707 | '*' type_quals absdcl1 %prec UNARY
1708 { $$ = make_pointer_declarator ($2, $3); }
1709 | '*' type_quals %prec UNARY
1710 { $$ = make_pointer_declarator ($2, NULL_TREE); }
1711 | absdcl1 '(' parmlist %prec '.'
1712 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1713 | absdcl1 '[' expr ']' %prec '.'
1714 { $$ = build_nt (ARRAY_REF, $1, $3); }
1715 | absdcl1 '[' ']' %prec '.'
1716 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1717 | '(' parmlist %prec '.'
1718 { $$ = build_nt (CALL_EXPR, NULL_TREE, $2, NULL_TREE); }
1719 | '[' expr ']' %prec '.'
1720 { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
1722 { $$ = build_nt (ARRAY_REF, NULL_TREE, NULL_TREE); }
1723 /* ??? It appears we have to support attributes here, however
1724 using prefix_attributes is wrong. */
1725 | attributes setattrs absdcl1
1729 /* at least one statement, the first of which parses without error. */
1730 /* stmts is used only after decls, so an invalid first statement
1731 is actually regarded as an invalid decl and part of the decls. */
1734 lineno_stmt_or_labels
1737 pedwarn ("ANSI C forbids label at end of compound statement");
1741 lineno_stmt_or_labels:
1742 lineno_stmt_or_label
1743 | lineno_stmt_or_labels lineno_stmt_or_label
1745 | lineno_stmt_or_labels errstmt
1757 pushlevel: /* empty */
1758 { emit_line_note (input_filename, lineno);
1762 expand_start_bindings (0);
1764 if (objc_method_context)
1770 /* Read zero or more forward-declarations for labels
1771 that nested functions can jump to. */
1776 pedwarn ("ANSI C forbids label declarations"); }
1781 | label_decls label_decl
1785 LABEL identifiers_or_typenames ';'
1787 for (link = $2; link; link = TREE_CHAIN (link))
1789 tree label = shadow_label (TREE_VALUE (link));
1790 C_DECLARED_LABEL_FLAG (label) = 1;
1791 declare_nonlocal_label (label);
1796 /* This is the body of a function definition.
1797 It causes syntax errors to ignore to the next openbrace. */
1804 compstmt_start: '{' { compstmt_count++; }
1806 compstmt_nostart: '}'
1807 { $$ = convert (void_type_node, integer_zero_node); }
1808 | pushlevel maybe_label_decls decls xstmts '}'
1809 { emit_line_note (input_filename, lineno);
1810 expand_end_bindings (getdecls (), 1, 0);
1811 $$ = poplevel (1, 1, 0);
1812 if (yychar == CONSTANT || yychar == STRING)
1813 pop_momentary_nofree ();
1816 | pushlevel maybe_label_decls error '}'
1817 { emit_line_note (input_filename, lineno);
1818 expand_end_bindings (getdecls (), kept_level_p (), 0);
1819 $$ = poplevel (kept_level_p (), 0, 0);
1820 if (yychar == CONSTANT || yychar == STRING)
1821 pop_momentary_nofree ();
1824 | pushlevel maybe_label_decls stmts '}'
1825 { emit_line_note (input_filename, lineno);
1826 expand_end_bindings (getdecls (), kept_level_p (), 0);
1827 $$ = poplevel (kept_level_p (), 0, 0);
1828 if (yychar == CONSTANT || yychar == STRING)
1829 pop_momentary_nofree ();
1834 compstmt_primary_start:
1836 { if (current_function_decl == 0)
1838 error ("braced-group within expression allowed only inside a function");
1841 /* We must force a BLOCK for this level
1842 so that, if it is not expanded later,
1843 there is a way to turn off the entire subtree of blocks
1844 that are contained in it. */
1846 push_iterator_stack ();
1847 push_label_level ();
1848 $$ = expand_start_stmt_expr ();
1852 compstmt: compstmt_start compstmt_nostart
1856 /* Value is number of statements counted as of the closeparen. */
1858 if_prefix lineno_labeled_stmt
1859 /* Make sure c_expand_end_cond is run once
1860 for each call to c_expand_start_cond.
1861 Otherwise a crash is likely. */
1867 { emit_line_note ($<filename>-1, $<lineno>0);
1868 c_expand_start_cond (truthvalue_conversion ($3), 0,
1870 $<itype>$ = stmt_count;
1871 if_stmt_file = $<filename>-1;
1872 if_stmt_line = $<lineno>0;
1873 position_after_white_space (); }
1876 /* This is a subroutine of stmt.
1877 It is used twice, once for valid DO statements
1878 and once for catching errors in parsing the end test. */
1883 emit_line_note ($<filename>-1, $<lineno>0);
1884 /* See comment in `while' alternative, above. */
1886 expand_start_loop_continue_elsewhere (1);
1887 position_after_white_space (); }
1888 lineno_labeled_stmt WHILE
1889 { expand_loop_continue_here (); }
1893 { $$ = input_filename; }
1900 lineno_labeled_stmt:
1901 save_filename save_lineno stmt
1903 /* | save_filename save_lineno error
1906 | save_filename save_lineno label lineno_labeled_stmt
1910 lineno_stmt_or_label:
1911 save_filename save_lineno stmt_or_label
1922 /* Parse a single real statement, not including any labels. */
1929 emit_line_note ($<filename>-1, $<lineno>0);
1930 /* It appears that this should not be done--that a non-lvalue array
1931 shouldn't get an error if the value isn't used.
1932 Section 3.2.2.1 says that an array lvalue gets converted to a pointer
1933 if it appears as a top-level expression,
1934 but says nothing about non-lvalue arrays. */
1936 /* Call default_conversion to get an error
1937 on referring to a register array if pedantic. */
1938 if (TREE_CODE (TREE_TYPE ($1)) == ARRAY_TYPE
1939 || TREE_CODE (TREE_TYPE ($1)) == FUNCTION_TYPE)
1940 $1 = default_conversion ($1);
1942 iterator_expand ($1);
1943 clear_momentary (); }
1945 { c_expand_start_else ();
1946 $<itype>1 = stmt_count;
1947 position_after_white_space (); }
1949 { c_expand_end_cond ();
1950 if (extra_warnings && stmt_count == $<itype>1)
1951 warning ("empty body in an else-statement"); }
1952 | simple_if %prec IF
1953 { c_expand_end_cond ();
1954 /* This warning is here instead of in simple_if, because we
1955 do not want a warning if an empty if is followed by an
1956 else statement. Increment stmt_count so we don't
1957 give a second error if this is a nested `if'. */
1958 if (extra_warnings && stmt_count++ == $<itype>1)
1959 warning_with_file_and_line (if_stmt_file, if_stmt_line,
1960 "empty body in an if-statement"); }
1961 /* Make sure c_expand_end_cond is run once
1962 for each call to c_expand_start_cond.
1963 Otherwise a crash is likely. */
1964 | simple_if ELSE error
1965 { c_expand_end_cond (); }
1968 emit_line_note ($<filename>-1, $<lineno>0);
1969 /* The emit_nop used to come before emit_line_note,
1970 but that made the nop seem like part of the preceding line.
1971 And that was confusing when the preceding line was
1972 inside of an if statement and was not really executed.
1973 I think it ought to work to put the nop after the line number.
1974 We will see. --rms, July 15, 1991. */
1977 { /* Don't start the loop till we have succeeded
1978 in parsing the end test. This is to make sure
1979 that we end every loop we start. */
1980 expand_start_loop (1);
1981 emit_line_note (input_filename, lineno);
1982 expand_exit_loop_if_false (NULL_PTR,
1983 truthvalue_conversion ($4));
1984 position_after_white_space (); }
1986 { expand_end_loop (); }
1989 { emit_line_note (input_filename, lineno);
1990 expand_exit_loop_if_false (NULL_PTR,
1991 truthvalue_conversion ($3));
1993 clear_momentary (); }
1994 /* This rule is needed to make sure we end every loop we start. */
1995 | do_stmt_start error
1996 { expand_end_loop ();
1997 clear_momentary (); }
2001 emit_line_note ($<filename>-1, $<lineno>0);
2002 /* See comment in `while' alternative, above. */
2004 if ($3) c_expand_expr_stmt ($3);
2005 /* Next step is to call expand_start_loop_continue_elsewhere,
2006 but wait till after we parse the entire for (...).
2007 Otherwise, invalid input might cause us to call that
2008 fn without calling expand_end_loop. */
2011 /* Can't emit now; wait till after expand_start_loop... */
2012 { $<lineno>7 = lineno;
2013 $<filename>$ = input_filename; }
2016 /* Start the loop. Doing this after parsing
2017 all the expressions ensures we will end the loop. */
2018 expand_start_loop_continue_elsewhere (1);
2019 /* Emit the end-test, with a line number. */
2020 emit_line_note ($<filename>8, $<lineno>7);
2022 expand_exit_loop_if_false (NULL_PTR,
2023 truthvalue_conversion ($6));
2024 /* Don't let the tree nodes for $9 be discarded by
2025 clear_momentary during the parsing of the next stmt. */
2027 $<lineno>7 = lineno;
2028 $<filename>8 = input_filename;
2029 position_after_white_space (); }
2031 { /* Emit the increment expression, with a line number. */
2032 emit_line_note ($<filename>8, $<lineno>7);
2033 expand_loop_continue_here ();
2035 c_expand_expr_stmt ($9);
2036 if (yychar == CONSTANT || yychar == STRING)
2037 pop_momentary_nofree ();
2040 expand_end_loop (); }
2041 | SWITCH '(' expr ')'
2043 emit_line_note ($<filename>-1, $<lineno>0);
2044 c_expand_start_case ($3);
2045 /* Don't let the tree nodes for $3 be discarded by
2046 clear_momentary during the parsing of the next stmt. */
2048 position_after_white_space (); }
2050 { expand_end_case ($3);
2051 if (yychar == CONSTANT || yychar == STRING)
2052 pop_momentary_nofree ();
2057 emit_line_note ($<filename>-1, $<lineno>0);
2058 if ( ! expand_exit_something ())
2059 error ("break statement not within loop or switch"); }
2062 emit_line_note ($<filename>-1, $<lineno>0);
2063 if (! expand_continue_loop (NULL_PTR))
2064 error ("continue statement not within a loop"); }
2067 emit_line_note ($<filename>-1, $<lineno>0);
2068 c_expand_return (NULL_TREE); }
2071 emit_line_note ($<filename>-1, $<lineno>0);
2072 c_expand_return ($2); }
2073 | ASM_KEYWORD maybe_type_qual '(' expr ')' ';'
2075 emit_line_note ($<filename>-1, $<lineno>0);
2077 if ((TREE_CODE ($4) == ADDR_EXPR
2078 && TREE_CODE (TREE_OPERAND ($4, 0)) == STRING_CST)
2079 || TREE_CODE ($4) == STRING_CST)
2082 error ("argument of `asm' is not a constant string"); }
2083 /* This is the case with just output operands. */
2084 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ')' ';'
2086 emit_line_note ($<filename>-1, $<lineno>0);
2087 c_expand_asm_operands ($4, $6, NULL_TREE, NULL_TREE,
2088 $2 == ridpointers[(int)RID_VOLATILE],
2089 input_filename, lineno); }
2090 /* This is the case with input operands as well. */
2091 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':' asm_operands ')' ';'
2093 emit_line_note ($<filename>-1, $<lineno>0);
2094 c_expand_asm_operands ($4, $6, $8, NULL_TREE,
2095 $2 == ridpointers[(int)RID_VOLATILE],
2096 input_filename, lineno); }
2097 /* This is the case with clobbered registers as well. */
2098 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':'
2099 asm_operands ':' asm_clobbers ')' ';'
2101 emit_line_note ($<filename>-1, $<lineno>0);
2102 c_expand_asm_operands ($4, $6, $8, $10,
2103 $2 == ridpointers[(int)RID_VOLATILE],
2104 input_filename, lineno); }
2105 | GOTO identifier ';'
2108 emit_line_note ($<filename>-1, $<lineno>0);
2109 decl = lookup_label ($2);
2112 TREE_USED (decl) = 1;
2118 pedwarn ("ANSI C forbids `goto *expr;'");
2120 emit_line_note ($<filename>-1, $<lineno>0);
2121 expand_computed_goto (convert (ptr_type_node, $3)); }
2126 all_iter_stmt_simple
2127 /* | all_iter_stmt_with_decl */
2130 all_iter_stmt_simple:
2133 /* The value returned by this action is */
2134 /* 1 if everything is OK */
2135 /* 0 in case of error or already bound iterator */
2138 if (TREE_CODE ($3) != VAR_DECL)
2139 error ("invalid `for (ITERATOR)' syntax");
2140 else if (! ITERATOR_P ($3))
2141 error ("`%s' is not an iterator",
2142 IDENTIFIER_POINTER (DECL_NAME ($3)));
2143 else if (ITERATOR_BOUND_P ($3))
2144 error ("`for (%s)' inside expansion of same iterator",
2145 IDENTIFIER_POINTER (DECL_NAME ($3)));
2149 iterator_for_loop_start ($3);
2155 iterator_for_loop_end ($3);
2158 /* This really should allow any kind of declaration,
2159 for generality. Fix it before turning it back on.
2161 all_iter_stmt_with_decl:
2162 FOR '(' ITERATOR pushlevel setspecs iterator_spec ')'
2164 */ /* The value returned by this action is */
2165 /* 1 if everything is OK */
2166 /* 0 in case of error or already bound iterator */
2168 iterator_for_loop_start ($6);
2172 iterator_for_loop_end ($6);
2173 emit_line_note (input_filename, lineno);
2174 expand_end_bindings (getdecls (), 1, 0);
2175 $<ttype>$ = poplevel (1, 1, 0);
2176 if (yychar == CONSTANT || yychar == STRING)
2177 pop_momentary_nofree ();
2183 /* Any kind of label, including jump labels and case labels.
2184 ANSI C accepts labels only before statements, but we allow them
2185 also at the end of a compound statement. */
2187 label: CASE expr_no_commas ':'
2188 { register tree value = check_case_value ($2);
2190 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
2194 if (value != error_mark_node)
2199 if (pedantic && ! INTEGRAL_TYPE_P (TREE_TYPE (value)))
2200 pedwarn ("label must have integral type in ANSI C");
2202 success = pushcase (value, convert_and_check,
2206 error ("case label not within a switch statement");
2207 else if (success == 2)
2209 error ("duplicate case value");
2210 error_with_decl (duplicate, "this is the first entry for that value");
2212 else if (success == 3)
2213 warning ("case value out of range");
2214 else if (success == 5)
2215 error ("case label within scope of cleanup or variable array");
2217 position_after_white_space (); }
2218 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
2219 { register tree value1 = check_case_value ($2);
2220 register tree value2 = check_case_value ($4);
2222 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
2225 pedwarn ("ANSI C forbids case ranges");
2228 if (value1 != error_mark_node && value2 != error_mark_node)
2231 int success = pushcase_range (value1, value2,
2232 convert_and_check, label,
2235 error ("case label not within a switch statement");
2236 else if (success == 2)
2238 error ("duplicate case value");
2239 error_with_decl (duplicate, "this is the first entry for that value");
2241 else if (success == 3)
2242 warning ("case value out of range");
2243 else if (success == 4)
2244 warning ("empty case range");
2245 else if (success == 5)
2246 error ("case label within scope of cleanup or variable array");
2248 position_after_white_space (); }
2253 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
2254 int success = pushcase (NULL_TREE, 0, label, &duplicate);
2257 error ("default label not within a switch statement");
2258 else if (success == 2)
2260 error ("multiple default labels in one switch");
2261 error_with_decl (duplicate, "this is the first default label");
2263 position_after_white_space (); }
2264 | identifier ':' maybe_attribute
2265 { tree label = define_label (input_filename, lineno, $1);
2270 expand_label (label);
2271 decl_attributes (label, $3, NULL_TREE);
2273 position_after_white_space (); }
2276 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
2280 { emit_line_note (input_filename, lineno);
2283 { emit_line_note (input_filename, lineno); }
2292 /* These are the operands other than the first string and colon
2293 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
2294 asm_operands: /* empty */
2296 | nonnull_asm_operands
2299 nonnull_asm_operands:
2301 | nonnull_asm_operands ',' asm_operand
2302 { $$ = chainon ($1, $3); }
2307 { $$ = build_tree_list ($1, $3); }
2312 { $$ = tree_cons (NULL_TREE, combine_strings ($1), NULL_TREE); }
2313 | asm_clobbers ',' string
2314 { $$ = tree_cons (NULL_TREE, combine_strings ($3), $1); }
2317 /* This is what appears inside the parens in a function declarator.
2318 Its value is a list of ..._TYPE nodes. */
2321 clear_parm_order ();
2322 declare_parm_level (0); }
2325 parmlist_tags_warning ();
2326 poplevel (0, 0, 0); }
2334 pedwarn ("ANSI C forbids forward parameter declarations");
2335 /* Mark the forward decls as such. */
2336 for (parm = getdecls (); parm; parm = TREE_CHAIN (parm))
2337 TREE_ASM_WRITTEN (parm) = 1;
2338 clear_parm_order (); }
2342 { $$ = tree_cons (NULL_TREE, NULL_TREE, NULL_TREE); }
2345 /* This is what appears inside the parens in a function declarator.
2346 Is value is represented in the format that grokdeclarator expects. */
2347 parmlist_2: /* empty */
2348 { $$ = get_parm_info (0); }
2350 { $$ = get_parm_info (0);
2351 /* Gcc used to allow this as an extension. However, it does
2352 not work for all targets, and thus has been disabled.
2353 Also, since func (...) and func () are indistinguishable,
2354 it caused problems with the code in expand_builtin which
2355 tries to verify that BUILT_IN_NEXT_ARG is being used
2357 error ("ANSI C requires a named argument before `...'");
2360 { $$ = get_parm_info (1); }
2361 | parms ',' ELLIPSIS
2362 { $$ = get_parm_info (0); }
2367 { push_parm_decl ($1); }
2369 { push_parm_decl ($3); }
2372 /* A single parameter declaration or parameter type name,
2373 as found in a parmlist. */
2375 typed_declspecs setspecs parm_declarator maybe_attribute
2376 { $$ = build_tree_list (build_tree_list (current_declspecs,
2378 build_tree_list (prefix_attributes,
2380 current_declspecs = TREE_VALUE (declspec_stack);
2381 prefix_attributes = TREE_PURPOSE (declspec_stack);
2382 declspec_stack = TREE_CHAIN (declspec_stack);
2383 resume_momentary ($2); }
2384 | typed_declspecs setspecs notype_declarator maybe_attribute
2385 { $$ = build_tree_list (build_tree_list (current_declspecs,
2387 build_tree_list (prefix_attributes,
2389 current_declspecs = TREE_VALUE (declspec_stack);
2390 prefix_attributes = TREE_PURPOSE (declspec_stack);
2391 declspec_stack = TREE_CHAIN (declspec_stack);
2392 resume_momentary ($2); }
2393 | typed_declspecs setspecs absdcl maybe_attribute
2394 { $$ = build_tree_list (build_tree_list (current_declspecs,
2396 build_tree_list (prefix_attributes,
2398 current_declspecs = TREE_VALUE (declspec_stack);
2399 prefix_attributes = TREE_PURPOSE (declspec_stack);
2400 declspec_stack = TREE_CHAIN (declspec_stack);
2401 resume_momentary ($2); }
2402 | declmods setspecs notype_declarator maybe_attribute
2403 { $$ = build_tree_list (build_tree_list (current_declspecs,
2405 build_tree_list (prefix_attributes,
2407 current_declspecs = TREE_VALUE (declspec_stack);
2408 prefix_attributes = TREE_PURPOSE (declspec_stack);
2409 declspec_stack = TREE_CHAIN (declspec_stack);
2410 resume_momentary ($2); }
2412 | declmods setspecs absdcl maybe_attribute
2413 { $$ = build_tree_list (build_tree_list (current_declspecs,
2415 build_tree_list (prefix_attributes,
2417 current_declspecs = TREE_VALUE (declspec_stack);
2418 prefix_attributes = TREE_PURPOSE (declspec_stack);
2419 declspec_stack = TREE_CHAIN (declspec_stack);
2420 resume_momentary ($2); }
2423 /* This is used in a function definition
2424 where either a parmlist or an identifier list is ok.
2425 Its value is a list of ..._TYPE nodes or a list of identifiers. */
2426 parmlist_or_identifiers:
2428 clear_parm_order ();
2429 declare_parm_level (1); }
2430 parmlist_or_identifiers_1
2432 parmlist_tags_warning ();
2433 poplevel (0, 0, 0); }
2436 parmlist_or_identifiers_1:
2440 for (t = $1; t; t = TREE_CHAIN (t))
2441 if (TREE_VALUE (t) == NULL_TREE)
2442 error ("`...' in old-style identifier list");
2443 $$ = tree_cons (NULL_TREE, NULL_TREE, $1); }
2446 /* A nonempty list of identifiers. */
2449 { $$ = build_tree_list (NULL_TREE, $1); }
2450 | identifiers ',' IDENTIFIER
2451 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2454 /* A nonempty list of identifiers, including typenames. */
2455 identifiers_or_typenames:
2457 { $$ = build_tree_list (NULL_TREE, $1); }
2458 | identifiers_or_typenames ',' identifier
2459 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2464 { $$ = SAVE_WARN_FLAGS();
2466 warn_pointer_arith = 0; }
2470 /* Objective-C productions. */
2480 if (objc_implementation_context)
2482 finish_class (objc_implementation_context);
2483 objc_ivar_chain = NULL_TREE;
2484 objc_implementation_context = NULL_TREE;
2487 warning ("`@end' must appear in an implementation context");
2491 /* A nonempty list of identifiers. */
2494 { $$ = build_tree_list (NULL_TREE, $1); }
2495 | identifier_list ',' identifier
2496 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2500 CLASS identifier_list ';'
2502 objc_declare_class ($2);
2506 ALIAS identifier identifier ';'
2508 objc_declare_alias ($2, $3);
2512 INTERFACE identifier protocolrefs '{'
2514 objc_interface_context = objc_ivar_context
2515 = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, $3);
2516 objc_public_flag = 0;
2520 continue_class (objc_interface_context);
2525 finish_class (objc_interface_context);
2526 objc_interface_context = NULL_TREE;
2529 | INTERFACE identifier protocolrefs
2531 objc_interface_context
2532 = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, $3);
2533 continue_class (objc_interface_context);
2538 finish_class (objc_interface_context);
2539 objc_interface_context = NULL_TREE;
2542 | INTERFACE identifier ':' identifier protocolrefs '{'
2544 objc_interface_context = objc_ivar_context
2545 = start_class (CLASS_INTERFACE_TYPE, $2, $4, $5);
2546 objc_public_flag = 0;
2550 continue_class (objc_interface_context);
2555 finish_class (objc_interface_context);
2556 objc_interface_context = NULL_TREE;
2559 | INTERFACE identifier ':' identifier protocolrefs
2561 objc_interface_context
2562 = start_class (CLASS_INTERFACE_TYPE, $2, $4, $5);
2563 continue_class (objc_interface_context);
2568 finish_class (objc_interface_context);
2569 objc_interface_context = NULL_TREE;
2572 | IMPLEMENTATION identifier '{'
2574 objc_implementation_context = objc_ivar_context
2575 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, NULL_TREE, NULL_TREE);
2576 objc_public_flag = 0;
2581 = continue_class (objc_implementation_context);
2584 | IMPLEMENTATION identifier
2586 objc_implementation_context
2587 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, NULL_TREE, NULL_TREE);
2589 = continue_class (objc_implementation_context);
2592 | IMPLEMENTATION identifier ':' identifier '{'
2594 objc_implementation_context = objc_ivar_context
2595 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2596 objc_public_flag = 0;
2601 = continue_class (objc_implementation_context);
2604 | IMPLEMENTATION identifier ':' identifier
2606 objc_implementation_context
2607 = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2609 = continue_class (objc_implementation_context);
2612 | INTERFACE identifier '(' identifier ')' protocolrefs
2614 objc_interface_context
2615 = start_class (CATEGORY_INTERFACE_TYPE, $2, $4, $6);
2616 continue_class (objc_interface_context);
2621 finish_class (objc_interface_context);
2622 objc_interface_context = NULL_TREE;
2625 | IMPLEMENTATION identifier '(' identifier ')'
2627 objc_implementation_context
2628 = start_class (CATEGORY_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
2630 = continue_class (objc_implementation_context);
2635 PROTOCOL identifier protocolrefs
2637 remember_protocol_qualifiers ();
2638 objc_interface_context
2639 = start_protocol(PROTOCOL_INTERFACE_TYPE, $2, $3);
2643 forget_protocol_qualifiers();
2644 finish_protocol(objc_interface_context);
2645 objc_interface_context = NULL_TREE;
2654 | non_empty_protocolrefs
2657 non_empty_protocolrefs:
2658 ARITHCOMPARE identifier_list ARITHCOMPARE
2660 if ($1 == LT_EXPR && $3 == GT_EXPR)
2668 ivar_decl_list visibility_spec ivar_decls
2673 PRIVATE { objc_public_flag = 2; }
2674 | PROTECTED { objc_public_flag = 0; }
2675 | PUBLIC { objc_public_flag = 1; }
2683 | ivar_decls ivar_decl ';'
2687 pedwarn ("extra semicolon in struct or union specified");
2692 /* There is a shift-reduce conflict here, because `components' may
2693 start with a `typename'. It happens that shifting (the default resolution)
2694 does the right thing, because it treats the `typename' as part of
2695 a `typed_typespecs'.
2697 It is possible that this same technique would allow the distinction
2698 between `notype_initdecls' and `initdecls' to be eliminated.
2699 But I am being cautious and not trying it. */
2702 typed_typespecs setspecs ivars
2704 current_declspecs = TREE_VALUE (declspec_stack);
2705 prefix_attributes = TREE_PURPOSE (declspec_stack);
2706 declspec_stack = TREE_CHAIN (declspec_stack);
2707 resume_momentary ($2); }
2708 | nonempty_type_quals setspecs ivars
2710 current_declspecs = TREE_VALUE (declspec_stack);
2711 prefix_attributes = TREE_PURPOSE (declspec_stack);
2712 declspec_stack = TREE_CHAIN (declspec_stack);
2713 resume_momentary ($2); }
2722 | ivars ',' ivar_declarator
2728 $$ = add_instance_variable (objc_ivar_context,
2730 $1, current_declspecs,
2733 | declarator ':' expr_no_commas
2735 $$ = add_instance_variable (objc_ivar_context,
2737 $1, current_declspecs, $3);
2739 | ':' expr_no_commas
2741 $$ = add_instance_variable (objc_ivar_context,
2744 current_declspecs, $2);
2751 remember_protocol_qualifiers ();
2752 if (objc_implementation_context)
2753 objc_inherit_code = CLASS_METHOD_DECL;
2755 fatal ("method definition not in class context");
2759 forget_protocol_qualifiers ();
2760 add_class_method (objc_implementation_context, $3);
2761 start_method_def ($3);
2762 objc_method_context = $3;
2766 continue_method_def ();
2770 finish_method_def ();
2771 objc_method_context = NULL_TREE;
2776 remember_protocol_qualifiers ();
2777 if (objc_implementation_context)
2778 objc_inherit_code = INSTANCE_METHOD_DECL;
2780 fatal ("method definition not in class context");
2784 forget_protocol_qualifiers ();
2785 add_instance_method (objc_implementation_context, $3);
2786 start_method_def ($3);
2787 objc_method_context = $3;
2791 continue_method_def ();
2795 finish_method_def ();
2796 objc_method_context = NULL_TREE;
2800 /* the reason for the strange actions in this rule
2801 is so that notype_initdecls when reached via datadef
2802 can find a valid list of type and sc specs in $0. */
2806 | {$<ttype>$ = NULL_TREE; } methodprotolist2
2809 methodprotolist2: /* eliminates a shift/reduce conflict */
2812 | methodprotolist2 methodproto
2813 | methodprotolist2 {$<ttype>$ = NULL_TREE; } datadef
2824 /* Remember protocol qualifiers in prototypes. */
2825 remember_protocol_qualifiers ();
2826 objc_inherit_code = CLASS_METHOD_DECL;
2830 /* Forget protocol qualifiers here. */
2831 forget_protocol_qualifiers ();
2832 add_class_method (objc_interface_context, $3);
2838 /* Remember protocol qualifiers in prototypes. */
2839 remember_protocol_qualifiers ();
2840 objc_inherit_code = INSTANCE_METHOD_DECL;
2844 /* Forget protocol qualifiers here. */
2845 forget_protocol_qualifiers ();
2846 add_instance_method (objc_interface_context, $3);
2852 '(' typename ')' unaryselector
2854 $$ = build_method_decl (objc_inherit_code, $2, $4, NULL_TREE);
2859 $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, NULL_TREE);
2862 | '(' typename ')' keywordselector optparmlist
2864 $$ = build_method_decl (objc_inherit_code, $2, $4, $5);
2867 | keywordselector optparmlist
2869 $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, $2);
2873 /* "optarglist" assumes that start_method_def has already been called...
2874 if it is not, the "xdecls" will not be placed in the proper scope */
2881 /* to get around the following situation: "int foo (int a) int b; {}" that
2882 is synthesized when parsing "- a:a b:b; id c; id d; { ... }" */
2897 typed_declspecs setspecs myparms ';'
2898 { current_declspecs = TREE_VALUE (declspec_stack);
2899 prefix_attributes = TREE_PURPOSE (declspec_stack);
2900 declspec_stack = TREE_CHAIN (declspec_stack);
2901 resume_momentary ($2); }
2902 | typed_declspecs ';'
2903 { shadow_tag ($1); }
2905 { pedwarn ("empty declaration"); }
2910 { push_parm_decl ($1); }
2911 | myparms ',' myparm
2912 { push_parm_decl ($3); }
2915 /* A single parameter declaration or parameter type name,
2916 as found in a parmlist. DOES NOT ALLOW AN INITIALIZER OR ASMSPEC */
2919 parm_declarator maybe_attribute
2920 { $$ = build_tree_list (build_tree_list (current_declspecs,
2922 build_tree_list (prefix_attributes,
2924 | notype_declarator maybe_attribute
2925 { $$ = build_tree_list (build_tree_list (current_declspecs,
2927 build_tree_list (prefix_attributes,
2929 | absdcl maybe_attribute
2930 { $$ = build_tree_list (build_tree_list (current_declspecs,
2932 build_tree_list (prefix_attributes,
2943 /* oh what a kludge! */
2952 /* returns a tree list node generated by get_parm_info */
2965 | keywordselector keyworddecl
2967 $$ = chainon ($1, $2);
2979 ENUM { $$ = get_identifier (token_buffer); }
2980 | STRUCT { $$ = get_identifier (token_buffer); }
2981 | UNION { $$ = get_identifier (token_buffer); }
2982 | IF { $$ = get_identifier (token_buffer); }
2983 | ELSE { $$ = get_identifier (token_buffer); }
2984 | WHILE { $$ = get_identifier (token_buffer); }
2985 | DO { $$ = get_identifier (token_buffer); }
2986 | FOR { $$ = get_identifier (token_buffer); }
2987 | SWITCH { $$ = get_identifier (token_buffer); }
2988 | CASE { $$ = get_identifier (token_buffer); }
2989 | DEFAULT { $$ = get_identifier (token_buffer); }
2990 | BREAK { $$ = get_identifier (token_buffer); }
2991 | CONTINUE { $$ = get_identifier (token_buffer); }
2992 | RETURN { $$ = get_identifier (token_buffer); }
2993 | GOTO { $$ = get_identifier (token_buffer); }
2994 | ASM_KEYWORD { $$ = get_identifier (token_buffer); }
2995 | SIZEOF { $$ = get_identifier (token_buffer); }
2996 | TYPEOF { $$ = get_identifier (token_buffer); }
2997 | ALIGNOF { $$ = get_identifier (token_buffer); }
2998 | TYPESPEC | TYPE_QUAL
3002 selector ':' '(' typename ')' identifier
3004 $$ = build_keyword_decl ($1, $4, $6);
3007 | selector ':' identifier
3009 $$ = build_keyword_decl ($1, NULL_TREE, $3);
3012 | ':' '(' typename ')' identifier
3014 $$ = build_keyword_decl (NULL_TREE, $3, $5);
3019 $$ = build_keyword_decl (NULL_TREE, NULL_TREE, $2);
3030 | keywordarglist keywordarg
3032 $$ = chainon ($1, $2);
3040 if (TREE_CHAIN ($1) == NULL_TREE)
3041 /* just return the expr., remove a level of indirection */
3042 $$ = TREE_VALUE ($1);
3044 /* we have a comma expr., we will collapse later */
3050 selector ':' keywordexpr
3052 $$ = build_tree_list ($1, $3);
3056 $$ = build_tree_list (NULL_TREE, $2);
3064 $$ = get_class_reference ($1);
3070 { objc_receiver_context = 1; }
3072 { objc_receiver_context = 0; }
3075 $$ = build_tree_list ($3, $5);
3086 | keywordnamelist keywordname
3088 $$ = chainon ($1, $2);
3095 $$ = build_tree_list ($1, NULL_TREE);
3099 $$ = build_tree_list (NULL_TREE, NULL_TREE);
3104 SELECTOR '(' selectorarg ')'
3111 PROTOCOL '(' identifier ')'
3117 /* extension to support C-structures in the archiver */
3120 ENCODE '(' typename ')'
3122 $$ = groktypename ($3);