1 /*WARNING: This file is automatically generated!*/
2 /* YACC parser for C syntax and for Objective C. -*-c-*-
3 Copyright (C) 1987, 88, 89, 92-97, 1998 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. */
45 #ifdef MULTIBYTE_CHARS
51 /* Since parsers are distinct for each language, put the language string
53 char *language_string
= "GNU Obj-C";
55 /* Like YYERROR but do call yyerror. */
56 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
58 /* Cause the `yydebug' variable to be defined. */
64 %
union {long itype
; tree ttype
; enum tree_code code
;
65 char *filename
; int lineno
; int ends_in_label
; }
67 /* All identifiers that are not reserved words
68 and are not declared typedefs in the current block */
71 /* All identifiers that are declared typedefs in the current block.
72 In some contexts, they are treated just like IDENTIFIER,
73 but they can also serve as typespecs in declarations. */
76 /* Reserved words that specify storage class.
77 yylval contains an IDENTIFIER_NODE which indicates which one. */
80 /* Reserved words that specify type.
81 yylval contains an IDENTIFIER_NODE which indicates which one. */
84 /* Reserved words that qualify type: "const" or "volatile".
85 yylval contains an IDENTIFIER_NODE which indicates which one. */
88 /* Character or numeric constants.
89 yylval is the node for the constant. */
92 /* String constants in raw form.
93 yylval is a STRING_CST node. */
96 /* "...", used for functions with variable arglists. */
99 /* the reserved words */
100 /* SCO include files test "ASM", so use something else. */
101 %token SIZEOF ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
102 %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD TYPEOF ALIGNOF
103 %token ATTRIBUTE EXTENSION LABEL
104 %token REALPART IMAGPART
106 /* Add precedence rules to solve dangling else s/r conflict */
110 /* Define the operator tokens and their precedences.
111 The value is an integer because, if used, it is the tree code
112 to use in the expression made from the operator. */
114 %right
<code
> ASSIGN
'='
115 %right
<code
> '?' ':'
121 %left
<code
> EQCOMPARE
122 %left
<code
> ARITHCOMPARE
123 %left
<code
> LSHIFT RSHIFT
125 %left
<code
> '*' '/' '%'
126 %right
<code
> UNARY PLUSPLUS MINUSMINUS
128 %left
<code
> POINTSAT
'.' '(' '['
130 /* The Objective-C keywords. These are included in C and in
131 Objective C, so that the token codes are the same in both. */
132 %token INTERFACE IMPLEMENTATION END SELECTOR DEFS ENCODE
133 %token CLASSNAME PUBLIC PRIVATE PROTECTED PROTOCOL OBJECTNAME CLASS ALIAS
135 /* Objective-C string constants in raw form.
136 yylval is an OBJC_STRING_CST node. */
142 %type
<ttype
> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist exprlist
143 %type
<ttype
> expr_no_commas cast_expr unary_expr primary
string STRING
144 %type
<ttype
> typed_declspecs reserved_declspecs
145 %type
<ttype
> typed_typespecs reserved_typespecquals
146 %type
<ttype
> declmods typespec typespecqual_reserved
147 %type
<ttype
> typed_declspecs_no_prefix_attr reserved_declspecs_no_prefix_attr
148 %type
<ttype
> declmods_no_prefix_attr
149 %type
<ttype
> SCSPEC TYPESPEC TYPE_QUAL nonempty_type_quals maybe_type_qual
150 %type
<ttype
> initdecls notype_initdecls initdcl notype_initdcl
151 %type
<ttype
> init maybeasm
152 %type
<ttype
> asm_operands nonnull_asm_operands asm_operand asm_clobbers
153 %type
<ttype
> maybe_attribute attributes attribute attribute_list attrib
154 %type
<ttype
> any_word
156 %type
<ttype
> compstmt
158 %type
<ttype
> declarator
159 %type
<ttype
> notype_declarator after_type_declarator
160 %type
<ttype
> parm_declarator
162 %type
<ttype
> structsp component_decl_list component_decl_list2
163 %type
<ttype
> component_decl components component_declarator
164 %type
<ttype
> enumlist enumerator
165 %type
<ttype
> typename absdcl absdcl1 type_quals
166 %type
<ttype
> xexpr parms parm identifiers
168 %type
<ttype
> parmlist parmlist_1 parmlist_2
169 %type
<ttype
> parmlist_or_identifiers parmlist_or_identifiers_1
170 %type
<ttype
> identifiers_or_typenames
172 %type
<itype
> setspecs
174 %type
<ends_in_label
> lineno_stmt_or_label lineno_stmt_or_labels stmt_or_label
176 %type
<filename
> save_filename
177 %type
<lineno
> save_lineno
179 /* the Objective-C nonterminals */
181 %type
<ttype
> ivar_decl_list ivar_decls ivar_decl ivars ivar_declarator
182 %type
<ttype
> methoddecl unaryselector keywordselector selector
183 %type
<ttype
> keyworddecl receiver objcmessageexpr messageargs
184 %type
<ttype
> keywordexpr keywordarglist keywordarg
185 %type
<ttype
> myparms myparm optparmlist reservedwords objcselectorexpr
186 %type
<ttype
> selectorarg keywordnamelist keywordname objcencodeexpr
187 %type
<ttype
> objc_string non_empty_protocolrefs protocolrefs identifier_list objcprotocolexpr
189 %type
<ttype
> CLASSNAME OBJC_STRING OBJECTNAME
192 /* Number of statements (loosely speaking) and compound statements
194 static int stmt_count
;
195 static int compstmt_count
;
197 /* Input file and line number of the end of the body of last simple_if;
198 used by the stmt-rule immediately after simple_if returns. */
199 static char *if_stmt_file
;
200 static int if_stmt_line
;
202 /* List of types and structure classes of the current declaration. */
203 static tree current_declspecs
= NULL_TREE
;
204 static tree prefix_attributes
= NULL_TREE
;
206 /* Stack of saved values of current_declspecs and prefix_attributes. */
207 static tree declspec_stack
;
209 /* 1 if we explained undeclared var errors. */
210 static int undeclared_variable_notice
;
212 /* Objective-C specific information */
214 tree objc_interface_context
;
215 tree objc_implementation_context
;
216 tree objc_method_context
;
217 tree objc_ivar_chain
;
218 tree objc_ivar_context
;
219 enum tree_code objc_inherit_code
;
220 int objc_receiver_context
;
221 int objc_public_flag
;
224 /* Tell yyparse how to print a token's value, if yydebug is set. */
226 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
227 extern
void yyprint PROTO
((FILE *, int, YYSTYPE));
233 pedwarn
("ANSI C forbids an empty source file");
238 /* In case there were missing closebraces,
239 get us back to the global binding level. */
240 while
(! global_bindings_p
())
246 /* the reason for the strange actions in this rule
247 is so that notype_initdecls when reached via datadef
248 can find a valid list of type and sc specs in $0. */
251 {$
<ttype
>$
= NULL_TREE
; } extdef
252 | extdefs
{$
<ttype
>$
= NULL_TREE
; } extdef
259 | ASM_KEYWORD
'(' expr
')' ';'
261 if
((TREE_CODE
($3) == ADDR_EXPR
262 && TREE_CODE
(TREE_OPERAND
($3, 0)) == STRING_CST
)
263 || TREE_CODE
($3) == STRING_CST
)
266 error ("argument of `asm' is not a constant string"); }
268 { pedantic
= $
<itype
>1; }
272 setspecs notype_initdecls
';'
274 error ("ANSI C forbids data definition with no type or storage class");
275 else if
(!flag_traditional
)
276 warning
("data definition has no type or storage class");
278 current_declspecs
= TREE_VALUE
(declspec_stack
);
279 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
280 declspec_stack
= TREE_CHAIN
(declspec_stack
);
281 resume_momentary
($1); }
282 | declmods setspecs notype_initdecls
';'
283 { current_declspecs
= TREE_VALUE
(declspec_stack
);
284 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
285 declspec_stack
= TREE_CHAIN
(declspec_stack
);
286 resume_momentary
($2); }
287 | typed_declspecs setspecs initdecls
';'
288 { current_declspecs
= TREE_VALUE
(declspec_stack
);
289 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
290 declspec_stack
= TREE_CHAIN
(declspec_stack
);
291 resume_momentary
($2); }
293 { pedwarn
("empty declaration"); }
294 | typed_declspecs
';'
300 pedwarn
("ANSI C does not allow extra `;' outside of a function"); }
304 typed_declspecs setspecs declarator
305 { if
(! start_function
(current_declspecs
, $3,
306 prefix_attributes
, NULL_TREE
, 0))
308 reinit_parse_for_function
(); }
310 { store_parm_decls
(); }
312 { finish_function
(0);
313 current_declspecs
= TREE_VALUE
(declspec_stack
);
314 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
315 declspec_stack
= TREE_CHAIN
(declspec_stack
);
316 resume_momentary
($2); }
317 | typed_declspecs setspecs declarator
error
318 { current_declspecs
= TREE_VALUE
(declspec_stack
);
319 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
320 declspec_stack
= TREE_CHAIN
(declspec_stack
);
321 resume_momentary
($2); }
322 | declmods setspecs notype_declarator
323 { if
(! start_function
(current_declspecs
, $3,
324 prefix_attributes
, NULL_TREE
, 0))
326 reinit_parse_for_function
(); }
328 { store_parm_decls
(); }
330 { finish_function
(0);
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); }
335 | declmods setspecs notype_declarator
error
336 { current_declspecs
= TREE_VALUE
(declspec_stack
);
337 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
338 declspec_stack
= TREE_CHAIN
(declspec_stack
);
339 resume_momentary
($2); }
340 | setspecs notype_declarator
341 { if
(! start_function
(NULL_TREE
, $2,
342 prefix_attributes
, NULL_TREE
, 0))
344 reinit_parse_for_function
(); }
346 { store_parm_decls
(); }
348 { finish_function
(0);
349 current_declspecs
= TREE_VALUE
(declspec_stack
);
350 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
351 declspec_stack
= TREE_CHAIN
(declspec_stack
);
352 resume_momentary
($1); }
353 | setspecs notype_declarator
error
354 { current_declspecs
= TREE_VALUE
(declspec_stack
);
355 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
356 declspec_stack
= TREE_CHAIN
(declspec_stack
);
357 resume_momentary
($1); }
370 { $$
= NEGATE_EXPR
; }
372 { $$
= CONVERT_EXPR
; }
374 { $$
= PREINCREMENT_EXPR
; }
376 { $$
= PREDECREMENT_EXPR
; }
378 { $$
= BIT_NOT_EXPR
; }
380 { $$
= TRUTH_NOT_EXPR
; }
383 expr: nonnull_exprlist
384 { $$
= build_compound_expr
($1); }
395 { $$
= build_tree_list
(NULL_TREE
, $1); }
396 | nonnull_exprlist
',' expr_no_commas
397 { chainon
($1, build_tree_list
(NULL_TREE
, $3)); }
402 |
'*' cast_expr %prec UNARY
403 { $$
= build_indirect_ref
($2, "unary *"); }
404 /* __extension__ turns off -pedantic for following primary. */
405 | extension cast_expr %prec UNARY
407 pedantic
= $
<itype
>1; }
408 | unop cast_expr %prec UNARY
409 { $$
= build_unary_op
($1, $2, 0);
410 overflow_warning
($$
); }
411 /* Refer to the address of a label as a pointer. */
413 { tree label
= lookup_label
($2);
415 pedwarn
("ANSI C forbids `&&'");
417 $$
= null_pointer_node
;
420 TREE_USED
(label
) = 1;
421 $$
= build1
(ADDR_EXPR
, ptr_type_node
, label
);
422 TREE_CONSTANT
($$
) = 1;
425 /* This seems to be impossible on some machines, so let's turn it off.
426 You can use __builtin_next_arg to find the anonymous stack args.
428 { tree types = TYPE_ARG_TYPES (TREE_TYPE (current_function_decl));
429 $$ = error_mark_node;
430 if (TREE_VALUE (tree_last (types)) == void_type_node)
431 error ("`&...' used in function with fixed number of arguments");
435 pedwarn ("ANSI C forbids `&...'");
436 $$ = tree_last (DECL_ARGUMENTS (current_function_decl));
437 $$ = build_unary_op (ADDR_EXPR, $$, 0);
440 | sizeof unary_expr %prec UNARY
442 if
(TREE_CODE
($2) == COMPONENT_REF
443 && DECL_C_BIT_FIELD
(TREE_OPERAND
($2, 1)))
444 error ("`sizeof' applied to a bit-field");
445 $$
= c_sizeof
(TREE_TYPE
($2)); }
446 | sizeof
'(' typename
')' %prec HYPERUNARY
448 $$
= c_sizeof
(groktypename
($3)); }
449 | alignof unary_expr %prec UNARY
451 $$
= c_alignof_expr
($2); }
452 | alignof
'(' typename
')' %prec HYPERUNARY
454 $$
= c_alignof
(groktypename
($3)); }
455 | REALPART cast_expr %prec UNARY
456 { $$
= build_unary_op
(REALPART_EXPR
, $2, 0); }
457 | IMAGPART cast_expr %prec UNARY
458 { $$
= build_unary_op
(IMAGPART_EXPR
, $2, 0); }
462 SIZEOF
{ skip_evaluation
++; }
466 ALIGNOF
{ skip_evaluation
++; }
471 |
'(' typename
')' cast_expr %prec UNARY
472 { tree type
= groktypename
($2);
473 $$
= build_c_cast
(type
, $4); }
474 |
'(' typename
')' '{'
475 { start_init
(NULL_TREE
, NULL
, 0);
476 $2 = groktypename
($2);
477 really_start_incremental_init
($2); }
478 initlist_maybe_comma
'}' %prec UNARY
480 tree result
= pop_init_level
(0);
485 pedwarn
("ANSI C forbids constructor expressions");
486 if
(TYPE_NAME
(type
) != 0)
488 if
(TREE_CODE
(TYPE_NAME
(type
)) == IDENTIFIER_NODE
)
489 name
= IDENTIFIER_POINTER
(TYPE_NAME
(type
));
491 name
= IDENTIFIER_POINTER
(DECL_NAME
(TYPE_NAME
(type
)));
496 if
(TREE_CODE
(type
) == ARRAY_TYPE
&& TYPE_SIZE
(type
) == 0)
498 int failure
= complete_array_type
(type
, $$
, 1);
507 | expr_no_commas
'+' expr_no_commas
508 { $$
= parser_build_binary_op
($2, $1, $3); }
509 | expr_no_commas
'-' expr_no_commas
510 { $$
= parser_build_binary_op
($2, $1, $3); }
511 | expr_no_commas
'*' expr_no_commas
512 { $$
= parser_build_binary_op
($2, $1, $3); }
513 | expr_no_commas
'/' expr_no_commas
514 { $$
= parser_build_binary_op
($2, $1, $3); }
515 | expr_no_commas
'%' expr_no_commas
516 { $$
= parser_build_binary_op
($2, $1, $3); }
517 | expr_no_commas LSHIFT expr_no_commas
518 { $$
= parser_build_binary_op
($2, $1, $3); }
519 | expr_no_commas RSHIFT expr_no_commas
520 { $$
= parser_build_binary_op
($2, $1, $3); }
521 | expr_no_commas ARITHCOMPARE expr_no_commas
522 { $$
= parser_build_binary_op
($2, $1, $3); }
523 | expr_no_commas EQCOMPARE expr_no_commas
524 { $$
= parser_build_binary_op
($2, $1, $3); }
525 | expr_no_commas
'&' expr_no_commas
526 { $$
= parser_build_binary_op
($2, $1, $3); }
527 | expr_no_commas
'|' expr_no_commas
528 { $$
= parser_build_binary_op
($2, $1, $3); }
529 | expr_no_commas
'^' expr_no_commas
530 { $$
= parser_build_binary_op
($2, $1, $3); }
531 | expr_no_commas ANDAND
532 { $1 = truthvalue_conversion
(default_conversion
($1));
533 skip_evaluation
+= $1 == boolean_false_node
; }
535 { skip_evaluation
-= $1 == boolean_false_node
;
536 $$
= parser_build_binary_op
(TRUTH_ANDIF_EXPR
, $1, $4); }
537 | expr_no_commas OROR
538 { $1 = truthvalue_conversion
(default_conversion
($1));
539 skip_evaluation
+= $1 == boolean_true_node
; }
541 { skip_evaluation
-= $1 == boolean_true_node
;
542 $$
= parser_build_binary_op
(TRUTH_ORIF_EXPR
, $1, $4); }
544 { $1 = truthvalue_conversion
(default_conversion
($1));
545 skip_evaluation
+= $1 == boolean_false_node
; }
547 { skip_evaluation
+= (($1 == boolean_true_node
)
548 - ($1 == boolean_false_node
)); }
550 { skip_evaluation
-= $1 == boolean_true_node
;
551 $$
= build_conditional_expr
($1, $4, $7); }
554 pedwarn
("ANSI C forbids omitting the middle term of a ?: expression");
555 /* Make sure first operand is calculated only once. */
556 $
<ttype
>2 = save_expr
($1);
557 $1 = truthvalue_conversion
(default_conversion
($
<ttype
>2));
558 skip_evaluation
+= $1 == boolean_true_node
; }
560 { skip_evaluation
-= $1 == boolean_true_node
;
561 $$
= build_conditional_expr
($1, $
<ttype
>2, $5); }
562 | expr_no_commas
'=' expr_no_commas
563 { $$
= build_modify_expr
($1, NOP_EXPR
, $3);
564 C_SET_EXP_ORIGINAL_CODE
($$
, MODIFY_EXPR
); }
565 | expr_no_commas ASSIGN expr_no_commas
566 { $$
= build_modify_expr
($1, $2, $3);
567 /* This inhibits warnings in truthvalue_conversion. */
568 C_SET_EXP_ORIGINAL_CODE
($$
, ERROR_MARK
); }
575 if
(!$$ || $$
== error_mark_node
)
577 if
(yychar == YYEMPTY
)
583 if
(objc_receiver_context
584 && ! (objc_receiver_context
585 && strcmp
(IDENTIFIER_POINTER
($1), "super")))
586 /* we have a message to super */
587 $$
= get_super_receiver
();
588 else if
(objc_method_context
589 && (decl
= is_ivar
(objc_ivar_chain
, $1)))
591 if
(is_private
(decl
))
592 $$
= error_mark_node
;
594 $$
= build_ivar_reference
($1);
598 /* Ordinary implicit function declaration. */
599 $$
= implicitly_declare
($1);
600 assemble_external
($$
);
604 else if
(current_function_decl
== 0)
606 error ("`%s' undeclared here (not in a function)",
607 IDENTIFIER_POINTER
($1));
608 $$
= error_mark_node
;
614 if
(objc_receiver_context
615 && ! strcmp
(IDENTIFIER_POINTER
($1), "super"))
616 /* we have a message to super */
617 $$
= get_super_receiver
();
618 else if
(objc_method_context
619 && (decl
= is_ivar
(objc_ivar_chain
, $1)))
621 if
(is_private
(decl
))
622 $$
= error_mark_node
;
624 $$
= build_ivar_reference
($1);
628 if
(IDENTIFIER_GLOBAL_VALUE
($1) != error_mark_node
629 || IDENTIFIER_ERROR_LOCUS
($1) != current_function_decl
)
631 error ("`%s' undeclared (first use in this function)",
632 IDENTIFIER_POINTER
($1));
634 if
(! undeclared_variable_notice
)
636 error ("(Each undeclared identifier is reported only once");
637 error ("for each function it appears in.)");
638 undeclared_variable_notice
= 1;
641 $$
= error_mark_node
;
642 /* Prevent repeated error messages. */
643 IDENTIFIER_GLOBAL_VALUE
($1) = error_mark_node
;
644 IDENTIFIER_ERROR_LOCUS
($1) = current_function_decl
;
648 else if
(TREE_TYPE
($$
) == error_mark_node
)
649 $$
= error_mark_node
;
650 else if
(C_DECL_ANTICIPATED
($$
))
652 /* The first time we see a build-in function used,
653 if it has not been declared. */
654 C_DECL_ANTICIPATED
($$
) = 0;
655 if
(yychar == YYEMPTY
)
659 /* Omit the implicit declaration we
660 would ordinarily do, so we don't lose
661 the actual built in type.
662 But print a diagnostic for the mismatch. */
663 if
(objc_method_context
664 && is_ivar
(objc_ivar_chain
, $1))
665 error ("Instance variable `%s' implicitly declared as function",
666 IDENTIFIER_POINTER
(DECL_NAME
($$
)));
668 if
(TREE_CODE
($$
) != FUNCTION_DECL
)
669 error ("`%s' implicitly declared as function",
670 IDENTIFIER_POINTER
(DECL_NAME
($$
)));
671 else if
((TYPE_MODE
(TREE_TYPE
(TREE_TYPE
($$
)))
672 != TYPE_MODE
(integer_type_node
))
673 && (TREE_TYPE
(TREE_TYPE
($$
))
675 pedwarn
("type mismatch in implicit declaration for built-in function `%s'",
676 IDENTIFIER_POINTER
(DECL_NAME
($$
)));
677 /* If it really returns void, change that to int. */
678 if
(TREE_TYPE
(TREE_TYPE
($$
)) == void_type_node
)
680 = build_function_type
(integer_type_node
,
681 TYPE_ARG_TYPES
(TREE_TYPE
($$
)));
684 pedwarn
("built-in function `%s' used without declaration",
685 IDENTIFIER_POINTER
(DECL_NAME
($$
)));
687 /* Do what we would ordinarily do when a fn is used. */
688 assemble_external
($$
);
693 assemble_external
($$
);
695 /* we have a definition - still check if iVariable */
697 if
(!objc_receiver_context
698 ||
(objc_receiver_context
699 && strcmp
(IDENTIFIER_POINTER
($1), "super")))
703 if
(objc_method_context
704 && (decl
= is_ivar
(objc_ivar_chain
, $1)))
706 if
(IDENTIFIER_LOCAL_VALUE
($1))
707 warning
("local declaration of `%s' hides instance variable",
708 IDENTIFIER_POINTER
($1));
711 if
(is_private
(decl
))
712 $$
= error_mark_node
;
714 $$
= build_ivar_reference
($1);
718 else
/* we have a message to super */
719 $$
= get_super_receiver
();
722 if
(TREE_CODE
($$
) == CONST_DECL
)
724 $$
= DECL_INITIAL
($$
);
725 /* This is to prevent an enum whose value is 0
726 from being considered a null pointer constant. */
727 $$
= build1
(NOP_EXPR
, TREE_TYPE
($$
), $$
);
728 TREE_CONSTANT
($$
) = 1;
733 { $$
= combine_strings
($1); }
735 { char class
= TREE_CODE_CLASS
(TREE_CODE
($2));
736 if
(class
== 'e' || class
== '1'
737 || class
== '2' || class
== '<')
738 C_SET_EXP_ORIGINAL_CODE
($2, ERROR_MARK
);
741 { $$
= error_mark_node
; }
743 { if
(current_function_decl
== 0)
745 error ("braced-group within expression allowed only inside a function");
748 /* We must force a BLOCK for this level
749 so that, if it is not expanded later,
750 there is a way to turn off the entire subtree of blocks
751 that are contained in it. */
753 push_iterator_stack
();
755 $
<ttype
>$
= expand_start_stmt_expr
(); }
759 pedwarn
("ANSI C forbids braced-groups within expressions");
760 pop_iterator_stack
();
762 rtl_exp
= expand_end_stmt_expr
($
<ttype
>2);
763 /* The statements have side effects, so the group does. */
764 TREE_SIDE_EFFECTS
(rtl_exp
) = 1;
766 if
(TREE_CODE
($3) == BLOCK
)
768 /* Make a BIND_EXPR for the BLOCK already made. */
769 $$
= build
(BIND_EXPR
, TREE_TYPE
(rtl_exp
),
770 NULL_TREE
, rtl_exp
, $3);
771 /* Remove the block from the tree at this point.
772 It gets put back at the proper place
773 when the BIND_EXPR is expanded. */
779 | primary
'(' exprlist
')' %prec
'.'
780 { $$
= build_function_call
($1, $3); }
781 | primary
'[' expr
']' %prec
'.'
782 { $$
= build_array_ref
($1, $3); }
783 | primary
'.' identifier
785 if
(doing_objc_thang
)
787 if
(is_public
($1, $3))
788 $$
= build_component_ref
($1, $3);
790 $$
= error_mark_node
;
793 $$
= build_component_ref
($1, $3);
795 | primary POINTSAT identifier
797 tree expr
= build_indirect_ref
($1, "->");
799 if
(doing_objc_thang
)
801 if
(is_public
(expr
, $3))
802 $$
= build_component_ref
(expr
, $3);
804 $$
= error_mark_node
;
807 $$
= build_component_ref
(expr
, $3);
810 { $$
= build_unary_op
(POSTINCREMENT_EXPR
, $1, 0); }
812 { $$
= build_unary_op
(POSTDECREMENT_EXPR
, $1, 0); }
814 { $$
= build_message_expr
($1); }
816 { $$
= build_selector_expr
($1); }
818 { $$
= build_protocol_expr
($1); }
820 { $$
= build_encode_expr
($1); }
822 { $$
= build_objc_string_object
($1); }
825 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
829 { $$
= chainon
($1, $2); }
832 /* Produces an OBJC_STRING_CST with perhaps more OBJC_STRING_CSTs chained
836 | objc_string OBJC_STRING
837 { $$
= chainon
($1, $2); }
840 old_style_parm_decls:
844 /* ... is used here to indicate a varargs function. */
847 pedwarn
("ANSI C does not permit use of `varargs.h'"); }
850 /* The following are analogous to lineno_decl, decls and decl
851 except that they do not allow nested functions.
852 They are used for old-style parm decls. */
854 save_filename save_lineno datadecl
861 | datadecls lineno_datadecl
862 | lineno_datadecl errstmt
865 /* We don't allow prefix attributes here because they cause reduce/reduce
866 conflicts: we can't know whether we're parsing a function decl with
867 attribute suffix, or function defn with attribute prefix on first old
870 typed_declspecs_no_prefix_attr setspecs initdecls
';'
871 { current_declspecs
= TREE_VALUE
(declspec_stack
);
872 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
873 declspec_stack
= TREE_CHAIN
(declspec_stack
);
874 resume_momentary
($2); }
875 | declmods_no_prefix_attr setspecs notype_initdecls
';'
876 { current_declspecs
= TREE_VALUE
(declspec_stack
);
877 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
878 declspec_stack
= TREE_CHAIN
(declspec_stack
);
879 resume_momentary
($2); }
880 | typed_declspecs_no_prefix_attr
';'
881 { shadow_tag_warned
($1, 1);
882 pedwarn
("empty declaration"); }
883 | declmods_no_prefix_attr
';'
884 { pedwarn
("empty declaration"); }
887 /* This combination which saves a lineno before a decl
888 is the normal thing to use, rather than decl itself.
889 This is to avoid shift/reduce conflicts in contexts
890 where statement labels are allowed. */
892 save_filename save_lineno decl
900 | lineno_decl errstmt
903 /* records the type and storage class specs to use for processing
904 the declarators that follow.
905 Maintains a stack of outer-level values of current_declspecs,
906 for the sake of parm declarations nested in function declarators. */
907 setspecs: /* empty */
908 { $$
= suspend_momentary
();
909 pending_xref_error
();
910 declspec_stack
= tree_cons
(prefix_attributes
,
913 split_specs_attrs
($
<ttype
>0,
914 ¤t_declspecs
, &prefix_attributes
); }
917 /* ??? Yuck. See after_type_declarator. */
918 setattrs: /* empty */
919 { prefix_attributes
= chainon
(prefix_attributes
, $
<ttype
>0); }
923 typed_declspecs setspecs initdecls
';'
924 { current_declspecs
= TREE_VALUE
(declspec_stack
);
925 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
926 declspec_stack
= TREE_CHAIN
(declspec_stack
);
927 resume_momentary
($2); }
928 | declmods setspecs notype_initdecls
';'
929 { current_declspecs
= TREE_VALUE
(declspec_stack
);
930 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
931 declspec_stack
= TREE_CHAIN
(declspec_stack
);
932 resume_momentary
($2); }
933 | typed_declspecs setspecs nested_function
934 { current_declspecs
= TREE_VALUE
(declspec_stack
);
935 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
936 declspec_stack
= TREE_CHAIN
(declspec_stack
);
937 resume_momentary
($2); }
938 | declmods setspecs notype_nested_function
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 | typed_declspecs
';'
946 { pedwarn
("empty declaration"); }
948 { pedantic
= $
<itype
>1; }
951 /* Declspecs which contain at least one type specifier or typedef name.
952 (Just `const' or `volatile' is not enough.)
953 A typedef'd name following these is taken as a name to be declared.
954 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
957 typespec reserved_declspecs
958 { $$
= tree_cons
(NULL_TREE
, $1, $2); }
959 | declmods typespec reserved_declspecs
960 { $$
= chainon
($3, tree_cons
(NULL_TREE
, $2, $1)); }
963 reserved_declspecs: /* empty */
965 | reserved_declspecs typespecqual_reserved
966 { $$
= tree_cons
(NULL_TREE
, $2, $1); }
967 | reserved_declspecs SCSPEC
968 { if
(extra_warnings
)
969 warning
("`%s' is not at beginning of declaration",
970 IDENTIFIER_POINTER
($2));
971 $$
= tree_cons
(NULL_TREE
, $2, $1); }
972 | reserved_declspecs attributes
973 { $$
= tree_cons
($2, NULL_TREE
, $1); }
976 typed_declspecs_no_prefix_attr:
977 typespec reserved_declspecs_no_prefix_attr
978 { $$
= tree_cons
(NULL_TREE
, $1, $2); }
979 | declmods_no_prefix_attr typespec reserved_declspecs_no_prefix_attr
980 { $$
= chainon
($3, tree_cons
(NULL_TREE
, $2, $1)); }
983 reserved_declspecs_no_prefix_attr:
986 | reserved_declspecs_no_prefix_attr typespecqual_reserved
987 { $$
= tree_cons
(NULL_TREE
, $2, $1); }
988 | reserved_declspecs_no_prefix_attr SCSPEC
989 { if
(extra_warnings
)
990 warning
("`%s' is not at beginning of declaration",
991 IDENTIFIER_POINTER
($2));
992 $$
= tree_cons
(NULL_TREE
, $2, $1); }
995 /* List of just storage classes, type modifiers, and prefix attributes.
996 A declaration can start with just this, but then it cannot be used
997 to redeclare a typedef-name.
998 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
1001 declmods_no_prefix_attr
1004 { $$
= tree_cons
($1, NULL_TREE
, NULL_TREE
); }
1005 | declmods declmods_no_prefix_attr
1006 { $$
= chainon
($2, $1); }
1007 | declmods attributes
1008 { $$
= tree_cons
($2, NULL_TREE
, $1); }
1011 declmods_no_prefix_attr:
1013 { $$
= tree_cons
(NULL_TREE
, $1, NULL_TREE
);
1014 TREE_STATIC
($$
) = 1; }
1016 { $$
= tree_cons
(NULL_TREE
, $1, NULL_TREE
); }
1017 | declmods_no_prefix_attr TYPE_QUAL
1018 { $$
= tree_cons
(NULL_TREE
, $2, $1);
1019 TREE_STATIC
($$
) = 1; }
1020 | declmods_no_prefix_attr SCSPEC
1021 { if
(extra_warnings
&& TREE_STATIC
($1))
1022 warning
("`%s' is not at beginning of declaration",
1023 IDENTIFIER_POINTER
($2));
1024 $$
= tree_cons
(NULL_TREE
, $2, $1);
1025 TREE_STATIC
($$
) = TREE_STATIC
($1); }
1029 /* Used instead of declspecs where storage classes are not allowed
1030 (that is, for typenames and structure components).
1031 Don't accept a typedef-name if anything but a modifier precedes it. */
1034 typespec reserved_typespecquals
1035 { $$
= tree_cons
(NULL_TREE
, $1, $2); }
1036 | nonempty_type_quals typespec reserved_typespecquals
1037 { $$
= chainon
($3, tree_cons
(NULL_TREE
, $2, $1)); }
1040 reserved_typespecquals: /* empty */
1042 | reserved_typespecquals typespecqual_reserved
1043 { $$
= tree_cons
(NULL_TREE
, $2, $1); }
1046 /* A typespec (but not a type qualifier).
1047 Once we have seen one of these in a declaration,
1048 if a typedef name appears then it is being redeclared. */
1053 { /* For a typedef name, record the meaning, not the name.
1054 In case of `foo foo, bar;'. */
1055 $$
= lookup_name
($1); }
1056 | CLASSNAME protocolrefs
1057 { $$
= get_static_reference
($1, $2); }
1058 | OBJECTNAME protocolrefs
1059 { $$
= get_object_reference
($2); }
1061 /* Make "<SomeProtocol>" equivalent to "id <SomeProtocol>"
1062 - nisse@lysator.liu.se */
1063 | non_empty_protocolrefs
1064 { $$
= get_object_reference
($1); }
1065 | TYPEOF
'(' expr
')'
1066 { $$
= TREE_TYPE
($3); }
1067 | TYPEOF
'(' typename
')'
1068 { $$
= groktypename
($3); }
1071 /* A typespec that is a reserved word, or a type qualifier. */
1073 typespecqual_reserved: TYPESPEC
1080 | initdecls
',' initdcl
1085 | notype_initdecls
',' initdcl
1091 | ASM_KEYWORD
'(' string ')'
1092 { if
(TREE_CHAIN
($3)) $3 = combine_strings
($3);
1098 declarator maybeasm maybe_attribute
'='
1099 { $
<ttype
>$
= start_decl
($1, current_declspecs
, 1,
1100 $3, prefix_attributes
);
1101 start_init
($
<ttype
>$
, $2, global_bindings_p
()); }
1103 /* Note how the declaration of the variable is in effect while its init is parsed! */
1105 finish_decl
($
<ttype
>5, $6, $2); }
1106 | declarator maybeasm maybe_attribute
1107 { tree d
= start_decl
($1, current_declspecs
, 0,
1108 $3, prefix_attributes
);
1109 finish_decl
(d
, NULL_TREE
, $2);
1114 notype_declarator maybeasm maybe_attribute
'='
1115 { $
<ttype
>$
= start_decl
($1, current_declspecs
, 1,
1116 $3, prefix_attributes
);
1117 start_init
($
<ttype
>$
, $2, global_bindings_p
()); }
1119 /* Note how the declaration of the variable is in effect while its init is parsed! */
1121 decl_attributes
($
<ttype
>5, $3, prefix_attributes
);
1122 finish_decl
($
<ttype
>5, $6, $2); }
1123 | notype_declarator maybeasm maybe_attribute
1124 { tree d
= start_decl
($1, current_declspecs
, 0,
1125 $3, prefix_attributes
);
1126 finish_decl
(d
, NULL_TREE
, $2); }
1128 /* the * rules are dummies to accept the Apollo extended syntax
1129 so that the header files compile. */
1140 | attributes attribute
1141 { $$
= chainon
($1, $2); }
1145 ATTRIBUTE
'(' '(' attribute_list
')' ')'
1152 | attribute_list
',' attrib
1153 { $$
= chainon
($1, $3); }
1160 { $$
= build_tree_list
($1, NULL_TREE
); }
1161 | any_word
'(' IDENTIFIER
')'
1162 { $$
= build_tree_list
($1, build_tree_list
(NULL_TREE
, $3)); }
1163 | any_word
'(' IDENTIFIER
',' nonnull_exprlist
')'
1164 { $$
= build_tree_list
($1, tree_cons
(NULL_TREE
, $3, $5)); }
1165 | any_word
'(' exprlist
')'
1166 { $$
= build_tree_list
($1, $3); }
1169 /* This still leaves out most reserved keywords,
1170 shouldn't we include them? */
1179 /* Initializers. `init' is the entry point. */
1184 { really_start_incremental_init
(NULL_TREE
);
1185 /* Note that the call to clear_momentary
1186 is in process_init_element. */
1187 push_momentary
(); }
1188 initlist_maybe_comma
'}'
1189 { $$
= pop_init_level
(0);
1190 if
($$
== error_mark_node
1191 && ! (yychar == STRING ||
yychar == CONSTANT
))
1194 pop_momentary_nofree
(); }
1197 { $$
= error_mark_node
; }
1200 /* `initlist_maybe_comma' is the guts of an initializer in braces. */
1201 initlist_maybe_comma:
1204 pedwarn
("ANSI C forbids empty initializer braces"); }
1205 | initlist1 maybecomma
1210 | initlist1
',' initelt
1213 /* `initelt' is a single element of an initializer.
1214 It may use braces. */
1217 { process_init_element
($1); }
1219 { push_init_level
(0); }
1220 initlist_maybe_comma
'}'
1221 { process_init_element
(pop_init_level
(0)); }
1223 /* These are for labeled elements. The syntax for an array element
1224 initializer conflicts with the syntax for an Objective-C message,
1225 so don't include these productions in the Objective-C grammar. */
1227 { set_init_label
($1); }
1229 |
'.' identifier
'='
1230 { set_init_label
($2); }
1236 { push_c_function_context
();
1237 if
(! start_function
(current_declspecs
, $1,
1238 prefix_attributes
, NULL_TREE
, 1))
1240 pop_c_function_context
();
1243 reinit_parse_for_function
(); }
1244 old_style_parm_decls
1245 { store_parm_decls
(); }
1246 /* This used to use compstmt_or_error.
1247 That caused a bug with input `f(g) int g {}',
1248 where the use of YYERROR1 above caused an error
1249 which then was handled by compstmt_or_error.
1250 There followed a repeated execution of that same rule,
1251 which called YYERROR1 again, and so on. */
1253 { finish_function
(1);
1254 pop_c_function_context
(); }
1257 notype_nested_function:
1259 { push_c_function_context
();
1260 if
(! start_function
(current_declspecs
, $1,
1261 prefix_attributes
, NULL_TREE
, 1))
1263 pop_c_function_context
();
1266 reinit_parse_for_function
(); }
1267 old_style_parm_decls
1268 { store_parm_decls
(); }
1269 /* This used to use compstmt_or_error.
1270 That caused a bug with input `f(g) int g {}',
1271 where the use of YYERROR1 above caused an error
1272 which then was handled by compstmt_or_error.
1273 There followed a repeated execution of that same rule,
1274 which called YYERROR1 again, and so on. */
1276 { finish_function
(1);
1277 pop_c_function_context
(); }
1280 /* Any kind of declarator (thus, all declarators allowed
1281 after an explicit typespec). */
1284 after_type_declarator
1288 /* A declarator that is allowed only after an explicit typespec. */
1290 after_type_declarator:
1291 '(' after_type_declarator
')'
1293 | after_type_declarator
'(' parmlist_or_identifiers %prec
'.'
1294 { $$
= build_nt
(CALL_EXPR
, $1, $3, NULL_TREE
); }
1295 /* | after_type_declarator '(' error ')' %prec '.'
1296 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1297 poplevel (0, 0, 0); } */
1298 | after_type_declarator
'[' expr
']' %prec
'.'
1299 { $$
= build_nt
(ARRAY_REF
, $1, $3); }
1300 | after_type_declarator
'[' ']' %prec
'.'
1301 { $$
= build_nt
(ARRAY_REF
, $1, NULL_TREE
); }
1302 |
'*' type_quals after_type_declarator %prec UNARY
1303 { $$
= make_pointer_declarator
($2, $3); }
1304 /* ??? Yuck. setattrs is a quick hack. We can't use
1305 prefix_attributes because $1 only applies to this
1306 declarator. We assume setspecs has already been done.
1307 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1308 attributes could be recognized here or in `attributes'). */
1309 | attributes setattrs after_type_declarator
1315 /* Kinds of declarator that can appear in a parameter list
1316 in addition to notype_declarator. This is like after_type_declarator
1317 but does not allow a typedef name in parentheses as an identifier
1318 (because it would conflict with a function with that typedef as arg). */
1321 parm_declarator
'(' parmlist_or_identifiers %prec
'.'
1322 { $$
= build_nt
(CALL_EXPR
, $1, $3, NULL_TREE
); }
1323 /* | parm_declarator '(' error ')' %prec '.'
1324 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1325 poplevel (0, 0, 0); } */
1326 | parm_declarator
'[' expr
']' %prec
'.'
1327 { $$
= build_nt
(ARRAY_REF
, $1, $3); }
1328 | parm_declarator
'[' ']' %prec
'.'
1329 { $$
= build_nt
(ARRAY_REF
, $1, NULL_TREE
); }
1330 |
'*' type_quals parm_declarator %prec UNARY
1331 { $$
= make_pointer_declarator
($2, $3); }
1332 /* ??? Yuck. setattrs is a quick hack. We can't use
1333 prefix_attributes because $1 only applies to this
1334 declarator. We assume setspecs has already been done.
1335 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1336 attributes could be recognized here or in `attributes'). */
1337 | attributes setattrs parm_declarator
1342 /* A declarator allowed whether or not there has been
1343 an explicit typespec. These cannot redeclare a typedef-name. */
1346 notype_declarator
'(' parmlist_or_identifiers %prec
'.'
1347 { $$
= build_nt
(CALL_EXPR
, $1, $3, NULL_TREE
); }
1348 /* | notype_declarator '(' error ')' %prec '.'
1349 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1350 poplevel (0, 0, 0); } */
1351 |
'(' notype_declarator
')'
1353 |
'*' type_quals notype_declarator %prec UNARY
1354 { $$
= make_pointer_declarator
($2, $3); }
1355 | notype_declarator
'[' expr
']' %prec
'.'
1356 { $$
= build_nt
(ARRAY_REF
, $1, $3); }
1357 | notype_declarator
'[' ']' %prec
'.'
1358 { $$
= build_nt
(ARRAY_REF
, $1, NULL_TREE
); }
1359 /* ??? Yuck. setattrs is a quick hack. We can't use
1360 prefix_attributes because $1 only applies to this
1361 declarator. We assume setspecs has already been done.
1362 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1363 attributes could be recognized here or in `attributes'). */
1364 | attributes setattrs notype_declarator
1370 STRUCT identifier
'{'
1371 { $$
= start_struct
(RECORD_TYPE
, $2);
1372 /* Start scope of tag before parsing components. */
1374 component_decl_list
'}' maybe_attribute
1375 { $$
= finish_struct
($
<ttype
>4, $5, $7); }
1376 | STRUCT
'{' component_decl_list
'}' maybe_attribute
1377 { $$
= finish_struct
(start_struct
(RECORD_TYPE
, NULL_TREE
),
1381 { $$
= xref_tag
(RECORD_TYPE
, $2); }
1382 | UNION identifier
'{'
1383 { $$
= start_struct
(UNION_TYPE
, $2); }
1384 component_decl_list
'}' maybe_attribute
1385 { $$
= finish_struct
($
<ttype
>4, $5, $7); }
1386 | UNION
'{' component_decl_list
'}' maybe_attribute
1387 { $$
= finish_struct
(start_struct
(UNION_TYPE
, NULL_TREE
),
1391 { $$
= xref_tag
(UNION_TYPE
, $2); }
1392 | ENUM identifier
'{'
1393 { $
<itype
>3 = suspend_momentary
();
1394 $$
= start_enum
($2); }
1395 enumlist maybecomma_warn
'}' maybe_attribute
1396 { $$
= finish_enum
($
<ttype
>4, nreverse
($5), $8);
1397 resume_momentary
($
<itype
>3); }
1399 { $
<itype
>2 = suspend_momentary
();
1400 $$
= start_enum
(NULL_TREE
); }
1401 enumlist maybecomma_warn
'}' maybe_attribute
1402 { $$
= finish_enum
($
<ttype
>3, nreverse
($4), $7);
1403 resume_momentary
($
<itype
>2); }
1405 { $$
= xref_tag
(ENUMERAL_TYPE
, $2); }
1416 { if
(pedantic
) 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"); }
1434 /* foo(sizeof(struct{ @defs(ClassName)})); */
1435 | DEFS
'(' CLASSNAME
')'
1437 tree interface
= lookup_interface
($3);
1440 $$
= get_class_ivars
(interface
);
1443 error ("Cannot find interface declaration for `%s'",
1444 IDENTIFIER_POINTER
($3));
1450 /* There is a shift-reduce conflict here, because `components' may
1451 start with a `typename'. It happens that shifting (the default resolution)
1452 does the right thing, because it treats the `typename' as part of
1453 a `typed_typespecs'.
1455 It is possible that this same technique would allow the distinction
1456 between `notype_initdecls' and `initdecls' to be eliminated.
1457 But I am being cautious and not trying it. */
1460 typed_typespecs setspecs components
1462 current_declspecs
= TREE_VALUE
(declspec_stack
);
1463 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
1464 declspec_stack
= TREE_CHAIN
(declspec_stack
);
1465 resume_momentary
($2); }
1468 pedwarn
("ANSI C forbids member declarations with no members");
1471 | nonempty_type_quals setspecs components
1473 current_declspecs
= TREE_VALUE
(declspec_stack
);
1474 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
1475 declspec_stack
= TREE_CHAIN
(declspec_stack
);
1476 resume_momentary
($2); }
1477 | nonempty_type_quals
1479 pedwarn
("ANSI C forbids member declarations with no members");
1484 | extension component_decl
1486 pedantic
= $
<itype
>1; }
1490 component_declarator
1491 | components
',' component_declarator
1492 { $$
= chainon
($1, $3); }
1495 component_declarator:
1496 save_filename save_lineno declarator maybe_attribute
1497 { $$
= grokfield
($1, $2, $3, current_declspecs
, NULL_TREE
);
1498 decl_attributes
($$
, $4, prefix_attributes
); }
1499 | save_filename save_lineno
1500 declarator
':' expr_no_commas maybe_attribute
1501 { $$
= grokfield
($1, $2, $3, current_declspecs
, $5);
1502 decl_attributes
($$
, $6, prefix_attributes
); }
1503 | save_filename save_lineno
':' expr_no_commas maybe_attribute
1504 { $$
= grokfield
($1, $2, NULL_TREE
, current_declspecs
, $4);
1505 decl_attributes
($$
, $5, prefix_attributes
); }
1508 /* We chain the enumerators in reverse order.
1509 They are put in forward order where enumlist is used.
1510 (The order used to be significant, but no longer is so.
1511 However, we still maintain the order, just to be clean.) */
1515 | enumlist
',' enumerator
1516 { if
($1 == error_mark_node
)
1519 $$
= chainon
($3, $1); }
1521 { $$
= error_mark_node
; }
1527 { $$
= build_enumerator
($1, NULL_TREE
); }
1528 | identifier
'=' expr_no_commas
1529 { $$
= build_enumerator
($1, $3); }
1533 typed_typespecs absdcl
1534 { $$
= build_tree_list
($1, $2); }
1535 | nonempty_type_quals absdcl
1536 { $$
= build_tree_list
($1, $2); }
1539 absdcl: /* an absolute declarator */
1545 nonempty_type_quals:
1547 { $$
= tree_cons
(NULL_TREE
, $1, NULL_TREE
); }
1548 | nonempty_type_quals TYPE_QUAL
1549 { $$
= tree_cons
(NULL_TREE
, $2, $1); }
1555 | type_quals TYPE_QUAL
1556 { $$
= tree_cons
(NULL_TREE
, $2, $1); }
1559 absdcl1: /* a nonempty absolute declarator */
1562 /* `(typedef)1' is `int'. */
1563 |
'*' type_quals absdcl1 %prec UNARY
1564 { $$
= make_pointer_declarator
($2, $3); }
1565 |
'*' type_quals %prec UNARY
1566 { $$
= make_pointer_declarator
($2, NULL_TREE
); }
1567 | absdcl1
'(' parmlist %prec
'.'
1568 { $$
= build_nt
(CALL_EXPR
, $1, $3, NULL_TREE
); }
1569 | absdcl1
'[' expr
']' %prec
'.'
1570 { $$
= build_nt
(ARRAY_REF
, $1, $3); }
1571 | absdcl1
'[' ']' %prec
'.'
1572 { $$
= build_nt
(ARRAY_REF
, $1, NULL_TREE
); }
1573 |
'(' parmlist %prec
'.'
1574 { $$
= build_nt
(CALL_EXPR
, NULL_TREE
, $2, NULL_TREE
); }
1575 |
'[' expr
']' %prec
'.'
1576 { $$
= build_nt
(ARRAY_REF
, NULL_TREE
, $2); }
1578 { $$
= build_nt
(ARRAY_REF
, NULL_TREE
, NULL_TREE
); }
1579 /* ??? It appears we have to support attributes here, however
1580 using prefix_attributes is wrong. */
1583 /* at least one statement, the first of which parses without error. */
1584 /* stmts is used only after decls, so an invalid first statement
1585 is actually regarded as an invalid decl and part of the decls. */
1588 lineno_stmt_or_labels
1591 pedwarn
("ANSI C forbids label at end of compound statement");
1595 lineno_stmt_or_labels:
1596 lineno_stmt_or_label
1597 | lineno_stmt_or_labels lineno_stmt_or_label
1599 | lineno_stmt_or_labels errstmt
1611 pushlevel: /* empty */
1612 { emit_line_note
(input_filename
, lineno
);
1616 expand_start_bindings
(0);
1617 if
(objc_method_context
)
1622 /* Read zero or more forward-declarations for labels
1623 that nested functions can jump to. */
1628 pedwarn
("ANSI C forbids label declarations"); }
1633 | label_decls label_decl
1637 LABEL identifiers_or_typenames
';'
1639 for
(link
= $2; link
; link
= TREE_CHAIN
(link
))
1641 tree label
= shadow_label
(TREE_VALUE
(link
));
1642 C_DECLARED_LABEL_FLAG
(label
) = 1;
1643 declare_nonlocal_label
(label
);
1648 /* This is the body of a function definition.
1649 It causes syntax errors to ignore to the next openbrace. */
1656 compstmt_start: '{' { compstmt_count
++; }
1658 compstmt: compstmt_start
'}'
1659 { $$
= convert
(void_type_node
, integer_zero_node
); }
1660 | compstmt_start pushlevel maybe_label_decls decls xstmts
'}'
1661 { emit_line_note
(input_filename
, lineno
);
1662 expand_end_bindings
(getdecls
(), 1, 0);
1663 $$
= poplevel
(1, 1, 0);
1664 if
(yychar == CONSTANT ||
yychar == STRING
)
1665 pop_momentary_nofree
();
1668 | compstmt_start pushlevel maybe_label_decls
error '}'
1669 { emit_line_note
(input_filename
, lineno
);
1670 expand_end_bindings
(getdecls
(), kept_level_p
(), 0);
1671 $$
= poplevel
(kept_level_p
(), 0, 0);
1672 if
(yychar == CONSTANT ||
yychar == STRING
)
1673 pop_momentary_nofree
();
1676 | compstmt_start pushlevel maybe_label_decls stmts
'}'
1677 { emit_line_note
(input_filename
, lineno
);
1678 expand_end_bindings
(getdecls
(), kept_level_p
(), 0);
1679 $$
= poplevel
(kept_level_p
(), 0, 0);
1680 if
(yychar == CONSTANT ||
yychar == STRING
)
1681 pop_momentary_nofree
();
1686 /* Value is number of statements counted as of the closeparen. */
1688 if_prefix lineno_labeled_stmt
1689 /* Make sure c_expand_end_cond is run once
1690 for each call to c_expand_start_cond.
1691 Otherwise a crash is likely. */
1697 { emit_line_note
($
<filename
>-1, $
<lineno
>0);
1698 c_expand_start_cond
(truthvalue_conversion
($3), 0,
1700 $
<itype
>$
= stmt_count
;
1701 if_stmt_file
= $
<filename
>-1;
1702 if_stmt_line
= $
<lineno
>0;
1703 position_after_white_space
(); }
1706 /* This is a subroutine of stmt.
1707 It is used twice, once for valid DO statements
1708 and once for catching errors in parsing the end test. */
1713 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1714 /* See comment in `while' alternative, above. */
1716 expand_start_loop_continue_elsewhere
(1);
1717 position_after_white_space
(); }
1718 lineno_labeled_stmt WHILE
1719 { expand_loop_continue_here
(); }
1723 { $$
= input_filename
; }
1730 lineno_labeled_stmt:
1731 save_filename save_lineno stmt
1733 /* | save_filename save_lineno error
1736 | save_filename save_lineno label lineno_labeled_stmt
1740 lineno_stmt_or_label:
1741 save_filename save_lineno stmt_or_label
1752 /* Parse a single real statement, not including any labels. */
1759 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1760 /* It appears that this should not be done--that a non-lvalue array
1761 shouldn't get an error if the value isn't used.
1762 Section 3.2.2.1 says that an array lvalue gets converted to a pointer
1763 if it appears as a top-level expression,
1764 but says nothing about non-lvalue arrays. */
1766 /* Call default_conversion to get an error
1767 on referring to a register array if pedantic. */
1768 if
(TREE_CODE
(TREE_TYPE
($1)) == ARRAY_TYPE
1769 || TREE_CODE
(TREE_TYPE
($1)) == FUNCTION_TYPE
)
1770 $1 = default_conversion
($1);
1772 iterator_expand
($1);
1773 clear_momentary
(); }
1775 { c_expand_start_else
();
1776 $
<itype
>1 = stmt_count
;
1777 position_after_white_space
(); }
1779 { c_expand_end_cond
();
1780 if
(extra_warnings
&& stmt_count
== $
<itype
>1)
1781 warning
("empty body in an else-statement"); }
1782 | simple_if %prec IF
1783 { c_expand_end_cond
();
1784 /* This warning is here instead of in simple_if, because we
1785 do not want a warning if an empty if is followed by an
1786 else statement. Increment stmt_count so we don't
1787 give a second error if this is a nested `if'. */
1788 if
(extra_warnings
&& stmt_count
++ == $
<itype
>1)
1789 warning_with_file_and_line
(if_stmt_file
, if_stmt_line
,
1790 "empty body in an if-statement"); }
1791 /* Make sure c_expand_end_cond is run once
1792 for each call to c_expand_start_cond.
1793 Otherwise a crash is likely. */
1794 | simple_if ELSE
error
1795 { c_expand_end_cond
(); }
1798 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1799 /* The emit_nop used to come before emit_line_note,
1800 but that made the nop seem like part of the preceding line.
1801 And that was confusing when the preceding line was
1802 inside of an if statement and was not really executed.
1803 I think it ought to work to put the nop after the line number.
1804 We will see. --rms, July 15, 1991. */
1807 { /* Don't start the loop till we have succeeded
1808 in parsing the end test. This is to make sure
1809 that we end every loop we start. */
1810 expand_start_loop
(1);
1811 emit_line_note
(input_filename
, lineno
);
1812 expand_exit_loop_if_false
(NULL_PTR
,
1813 truthvalue_conversion
($4));
1814 position_after_white_space
(); }
1816 { expand_end_loop
(); }
1819 { emit_line_note
(input_filename
, lineno
);
1820 expand_exit_loop_if_false
(NULL_PTR
,
1821 truthvalue_conversion
($3));
1823 clear_momentary
(); }
1824 /* This rule is needed to make sure we end every loop we start. */
1825 | do_stmt_start
error
1826 { expand_end_loop
();
1827 clear_momentary
(); }
1831 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1832 /* See comment in `while' alternative, above. */
1834 if
($3) c_expand_expr_stmt
($3);
1835 /* Next step is to call expand_start_loop_continue_elsewhere,
1836 but wait till after we parse the entire for (...).
1837 Otherwise, invalid input might cause us to call that
1838 fn without calling expand_end_loop. */
1841 /* Can't emit now; wait till after expand_start_loop... */
1842 { $
<lineno
>7 = lineno
;
1843 $
<filename
>$
= input_filename
; }
1846 /* Start the loop. Doing this after parsing
1847 all the expressions ensures we will end the loop. */
1848 expand_start_loop_continue_elsewhere
(1);
1849 /* Emit the end-test, with a line number. */
1850 emit_line_note
($
<filename
>8, $
<lineno
>7);
1852 expand_exit_loop_if_false
(NULL_PTR
,
1853 truthvalue_conversion
($6));
1854 /* Don't let the tree nodes for $9 be discarded by
1855 clear_momentary during the parsing of the next stmt. */
1857 $
<lineno
>7 = lineno
;
1858 $
<filename
>8 = input_filename
;
1859 position_after_white_space
(); }
1861 { /* Emit the increment expression, with a line number. */
1862 emit_line_note
($
<filename
>8, $
<lineno
>7);
1863 expand_loop_continue_here
();
1865 c_expand_expr_stmt
($9);
1866 if
(yychar == CONSTANT ||
yychar == STRING
)
1867 pop_momentary_nofree
();
1870 expand_end_loop
(); }
1871 | SWITCH
'(' expr
')'
1873 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1874 c_expand_start_case
($3);
1875 /* Don't let the tree nodes for $3 be discarded by
1876 clear_momentary during the parsing of the next stmt. */
1878 position_after_white_space
(); }
1880 { expand_end_case
($3);
1881 if
(yychar == CONSTANT ||
yychar == STRING
)
1882 pop_momentary_nofree
();
1887 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1888 if
( ! expand_exit_something
())
1889 error ("break statement not within loop or switch"); }
1892 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1893 if
(! expand_continue_loop
(NULL_PTR
))
1894 error ("continue statement not within a loop"); }
1897 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1898 c_expand_return
(NULL_TREE
); }
1901 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1902 c_expand_return
($2); }
1903 | ASM_KEYWORD maybe_type_qual
'(' expr
')' ';'
1905 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1907 if
((TREE_CODE
($4) == ADDR_EXPR
1908 && TREE_CODE
(TREE_OPERAND
($4, 0)) == STRING_CST
)
1909 || TREE_CODE
($4) == STRING_CST
)
1912 error ("argument of `asm' is not a constant string"); }
1913 /* This is the case with just output operands. */
1914 | ASM_KEYWORD maybe_type_qual
'(' expr
':' asm_operands
')' ';'
1916 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1917 c_expand_asm_operands
($4, $6, NULL_TREE
, NULL_TREE
,
1918 $2 == ridpointers
[(int)RID_VOLATILE
],
1919 input_filename
, lineno
); }
1920 /* This is the case with input operands as well. */
1921 | ASM_KEYWORD maybe_type_qual
'(' expr
':' asm_operands
':' asm_operands
')' ';'
1923 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1924 c_expand_asm_operands
($4, $6, $8, NULL_TREE
,
1925 $2 == ridpointers
[(int)RID_VOLATILE
],
1926 input_filename
, lineno
); }
1927 /* This is the case with clobbered registers as well. */
1928 | ASM_KEYWORD maybe_type_qual
'(' expr
':' asm_operands
':'
1929 asm_operands
':' asm_clobbers
')' ';'
1931 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1932 c_expand_asm_operands
($4, $6, $8, $10,
1933 $2 == ridpointers
[(int)RID_VOLATILE
],
1934 input_filename
, lineno
); }
1935 | GOTO identifier
';'
1938 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1939 decl
= lookup_label
($2);
1942 TREE_USED
(decl
) = 1;
1948 pedwarn
("ANSI C forbids `goto *expr;'");
1950 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1951 expand_computed_goto
(convert
(ptr_type_node
, $3)); }
1956 all_iter_stmt_simple
1957 /* | all_iter_stmt_with_decl */
1960 all_iter_stmt_simple:
1963 /* The value returned by this action is */
1964 /* 1 if everything is OK */
1965 /* 0 in case of error or already bound iterator */
1968 if
(TREE_CODE
($3) != VAR_DECL
)
1969 error ("invalid `for (ITERATOR)' syntax");
1970 else if
(! ITERATOR_P
($3))
1971 error ("`%s' is not an iterator",
1972 IDENTIFIER_POINTER
(DECL_NAME
($3)));
1973 else if
(ITERATOR_BOUND_P
($3))
1974 error ("`for (%s)' inside expansion of same iterator",
1975 IDENTIFIER_POINTER
(DECL_NAME
($3)));
1979 iterator_for_loop_start
($3);
1985 iterator_for_loop_end
($3);
1988 /* This really should allow any kind of declaration,
1989 for generality. Fix it before turning it back on.
1991 all_iter_stmt_with_decl:
1992 FOR '(' ITERATOR pushlevel setspecs iterator_spec ')'
1994 */ /* The value returned by this action is */
1995 /* 1 if everything is OK */
1996 /* 0 in case of error or already bound iterator */
1998 iterator_for_loop_start ($6);
2002 iterator_for_loop_end ($6);
2003 emit_line_note (input_filename, lineno);
2004 expand_end_bindings (getdecls (), 1, 0);
2005 $<ttype>$ = poplevel (1, 1, 0);
2006 if (yychar == CONSTANT || yychar == STRING)
2007 pop_momentary_nofree ();
2013 /* Any kind of label, including jump labels and case labels.
2014 ANSI C accepts labels only before statements, but we allow them
2015 also at the end of a compound statement. */
2017 label: CASE expr_no_commas
':'
2018 { register tree value
= check_case_value
($2);
2020 = build_decl
(LABEL_DECL
, NULL_TREE
, NULL_TREE
);
2024 if
(value
!= error_mark_node
)
2027 int success
= pushcase
(value
, convert_and_check
,
2030 error ("case label not within a switch statement");
2031 else if
(success
== 2)
2033 error ("duplicate case value");
2034 error_with_decl
(duplicate
, "this is the first entry for that value");
2036 else if
(success
== 3)
2037 warning
("case value out of range");
2038 else if
(success
== 5)
2039 error ("case label within scope of cleanup or variable array");
2041 position_after_white_space
(); }
2042 | CASE expr_no_commas ELLIPSIS expr_no_commas
':'
2043 { register tree value1
= check_case_value
($2);
2044 register tree value2
= check_case_value
($4);
2046 = build_decl
(LABEL_DECL
, NULL_TREE
, NULL_TREE
);
2049 pedwarn
("ANSI C forbids case ranges");
2052 if
(value1
!= error_mark_node
&& value2
!= error_mark_node
)
2055 int success
= pushcase_range
(value1
, value2
,
2056 convert_and_check
, label
,
2059 error ("case label not within a switch statement");
2060 else if
(success
== 2)
2062 error ("duplicate case value");
2063 error_with_decl
(duplicate
, "this is the first entry for that value");
2065 else if
(success
== 3)
2066 warning
("case value out of range");
2067 else if
(success
== 4)
2068 warning
("empty case range");
2069 else if
(success
== 5)
2070 error ("case label within scope of cleanup or variable array");
2072 position_after_white_space
(); }
2077 = build_decl
(LABEL_DECL
, NULL_TREE
, NULL_TREE
);
2078 int success
= pushcase
(NULL_TREE
, 0, label
, &duplicate
);
2081 error ("default label not within a switch statement");
2082 else if
(success
== 2)
2084 error ("multiple default labels in one switch");
2085 error_with_decl
(duplicate
, "this is the first default label");
2087 position_after_white_space
(); }
2089 { tree label
= define_label
(input_filename
, lineno
, $1);
2093 expand_label
(label
);
2094 position_after_white_space
(); }
2097 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
2101 { emit_line_note
(input_filename
, lineno
);
2104 { emit_line_note
(input_filename
, lineno
); }
2113 /* These are the operands other than the first string and colon
2114 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
2115 asm_operands: /* empty */
2117 | nonnull_asm_operands
2120 nonnull_asm_operands:
2122 | nonnull_asm_operands
',' asm_operand
2123 { $$
= chainon
($1, $3); }
2128 { $$
= build_tree_list
($1, $3); }
2133 { $$
= tree_cons
(NULL_TREE
, combine_strings
($1), NULL_TREE
); }
2134 | asm_clobbers
',' string
2135 { $$
= tree_cons
(NULL_TREE
, combine_strings
($3), $1); }
2138 /* This is what appears inside the parens in a function declarator.
2139 Its value is a list of ..._TYPE nodes. */
2142 clear_parm_order
();
2143 declare_parm_level
(0); }
2146 parmlist_tags_warning
();
2147 poplevel
(0, 0, 0); }
2155 pedwarn
("ANSI C forbids forward parameter declarations");
2156 /* Mark the forward decls as such. */
2157 for
(parm
= getdecls
(); parm
; parm
= TREE_CHAIN
(parm
))
2158 TREE_ASM_WRITTEN
(parm
) = 1;
2159 clear_parm_order
(); }
2163 { $$
= tree_cons
(NULL_TREE
, NULL_TREE
, NULL_TREE
); }
2166 /* This is what appears inside the parens in a function declarator.
2167 Is value is represented in the format that grokdeclarator expects. */
2168 parmlist_2: /* empty */
2169 { $$
= get_parm_info
(0); }
2171 { $$
= get_parm_info
(0);
2172 /* Gcc used to allow this as an extension. However, it does
2173 not work for all targets, and thus has been disabled.
2174 Also, since func (...) and func () are indistinguishable,
2175 it caused problems with the code in expand_builtin which
2176 tries to verify that BUILT_IN_NEXT_ARG is being used
2178 error ("ANSI C requires a named argument before `...'");
2181 { $$
= get_parm_info
(1); }
2182 | parms
',' ELLIPSIS
2183 { $$
= get_parm_info
(0); }
2188 { push_parm_decl
($1); }
2190 { push_parm_decl
($3); }
2193 /* A single parameter declaration or parameter type name,
2194 as found in a parmlist. */
2196 typed_declspecs setspecs parm_declarator maybe_attribute
2197 { $$
= build_tree_list
(build_tree_list
(current_declspecs
,
2199 build_tree_list
(prefix_attributes
,
2201 current_declspecs
= TREE_VALUE
(declspec_stack
);
2202 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
2203 declspec_stack
= TREE_CHAIN
(declspec_stack
);
2204 resume_momentary
($2); }
2205 | typed_declspecs setspecs notype_declarator maybe_attribute
2206 { $$
= build_tree_list
(build_tree_list
(current_declspecs
,
2208 build_tree_list
(prefix_attributes
,
2210 current_declspecs
= TREE_VALUE
(declspec_stack
);
2211 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
2212 declspec_stack
= TREE_CHAIN
(declspec_stack
);
2213 resume_momentary
($2); }
2214 | typed_declspecs setspecs absdcl maybe_attribute
2215 { $$
= build_tree_list
(build_tree_list
(current_declspecs
,
2217 build_tree_list
(prefix_attributes
,
2219 current_declspecs
= TREE_VALUE
(declspec_stack
);
2220 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
2221 declspec_stack
= TREE_CHAIN
(declspec_stack
);
2222 resume_momentary
($2); }
2223 | declmods setspecs notype_declarator maybe_attribute
2224 { $$
= build_tree_list
(build_tree_list
(current_declspecs
,
2226 build_tree_list
(prefix_attributes
,
2228 current_declspecs
= TREE_VALUE
(declspec_stack
);
2229 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
2230 declspec_stack
= TREE_CHAIN
(declspec_stack
);
2231 resume_momentary
($2); }
2233 | declmods setspecs absdcl maybe_attribute
2234 { $$
= build_tree_list
(build_tree_list
(current_declspecs
,
2236 build_tree_list
(prefix_attributes
,
2238 current_declspecs
= TREE_VALUE
(declspec_stack
);
2239 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
2240 declspec_stack
= TREE_CHAIN
(declspec_stack
);
2241 resume_momentary
($2); }
2244 /* This is used in a function definition
2245 where either a parmlist or an identifier list is ok.
2246 Its value is a list of ..._TYPE nodes or a list of identifiers. */
2247 parmlist_or_identifiers:
2249 clear_parm_order
();
2250 declare_parm_level
(1); }
2251 parmlist_or_identifiers_1
2253 parmlist_tags_warning
();
2254 poplevel
(0, 0, 0); }
2257 parmlist_or_identifiers_1:
2261 for
(t
= $1; t
; t
= TREE_CHAIN
(t
))
2262 if
(TREE_VALUE
(t
) == NULL_TREE
)
2263 error ("`...' in old-style identifier list");
2264 $$
= tree_cons
(NULL_TREE
, NULL_TREE
, $1); }
2267 /* A nonempty list of identifiers. */
2270 { $$
= build_tree_list
(NULL_TREE
, $1); }
2271 | identifiers
',' IDENTIFIER
2272 { $$
= chainon
($1, build_tree_list
(NULL_TREE
, $3)); }
2275 /* A nonempty list of identifiers, including typenames. */
2276 identifiers_or_typenames:
2278 { $$
= build_tree_list
(NULL_TREE
, $1); }
2279 | identifiers_or_typenames
',' identifier
2280 { $$
= chainon
($1, build_tree_list
(NULL_TREE
, $3)); }
2285 { $
<itype
>$
= pedantic
;
2289 /* Objective-C productions. */
2299 if
(objc_implementation_context
)
2301 finish_class
(objc_implementation_context
);
2302 objc_ivar_chain
= NULL_TREE
;
2303 objc_implementation_context
= NULL_TREE
;
2306 warning
("`@end' must appear in an implementation context");
2310 /* A nonempty list of identifiers. */
2313 { $$
= build_tree_list
(NULL_TREE
, $1); }
2314 | identifier_list
',' identifier
2315 { $$
= chainon
($1, build_tree_list
(NULL_TREE
, $3)); }
2319 CLASS identifier_list
';'
2321 objc_declare_class
($2);
2325 ALIAS identifier identifier
';'
2327 objc_declare_alias
($2, $3);
2331 INTERFACE identifier protocolrefs
'{'
2333 objc_interface_context
= objc_ivar_context
2334 = start_class
(CLASS_INTERFACE_TYPE
, $2, NULL_TREE
, $3);
2335 objc_public_flag
= 0;
2339 continue_class
(objc_interface_context
);
2344 finish_class
(objc_interface_context
);
2345 objc_interface_context
= NULL_TREE
;
2348 | INTERFACE identifier protocolrefs
2350 objc_interface_context
2351 = start_class
(CLASS_INTERFACE_TYPE
, $2, NULL_TREE
, $3);
2352 continue_class
(objc_interface_context
);
2357 finish_class
(objc_interface_context
);
2358 objc_interface_context
= NULL_TREE
;
2361 | INTERFACE identifier
':' identifier protocolrefs
'{'
2363 objc_interface_context
= objc_ivar_context
2364 = start_class
(CLASS_INTERFACE_TYPE
, $2, $4, $5);
2365 objc_public_flag
= 0;
2369 continue_class
(objc_interface_context
);
2374 finish_class
(objc_interface_context
);
2375 objc_interface_context
= NULL_TREE
;
2378 | INTERFACE identifier
':' identifier protocolrefs
2380 objc_interface_context
2381 = start_class
(CLASS_INTERFACE_TYPE
, $2, $4, $5);
2382 continue_class
(objc_interface_context
);
2387 finish_class
(objc_interface_context
);
2388 objc_interface_context
= NULL_TREE
;
2391 | IMPLEMENTATION identifier
'{'
2393 objc_implementation_context
= objc_ivar_context
2394 = start_class
(CLASS_IMPLEMENTATION_TYPE
, $2, NULL_TREE
, NULL_TREE
);
2395 objc_public_flag
= 0;
2400 = continue_class
(objc_implementation_context
);
2403 | IMPLEMENTATION identifier
2405 objc_implementation_context
2406 = start_class
(CLASS_IMPLEMENTATION_TYPE
, $2, NULL_TREE
, NULL_TREE
);
2408 = continue_class
(objc_implementation_context
);
2411 | IMPLEMENTATION identifier
':' identifier
'{'
2413 objc_implementation_context
= objc_ivar_context
2414 = start_class
(CLASS_IMPLEMENTATION_TYPE
, $2, $4, NULL_TREE
);
2415 objc_public_flag
= 0;
2420 = continue_class
(objc_implementation_context
);
2423 | IMPLEMENTATION identifier
':' identifier
2425 objc_implementation_context
2426 = start_class
(CLASS_IMPLEMENTATION_TYPE
, $2, $4, NULL_TREE
);
2428 = continue_class
(objc_implementation_context
);
2431 | INTERFACE identifier
'(' identifier
')' protocolrefs
2433 objc_interface_context
2434 = start_class
(CATEGORY_INTERFACE_TYPE
, $2, $4, $6);
2435 continue_class
(objc_interface_context
);
2440 finish_class
(objc_interface_context
);
2441 objc_interface_context
= NULL_TREE
;
2444 | IMPLEMENTATION identifier
'(' identifier
')'
2446 objc_implementation_context
2447 = start_class
(CATEGORY_IMPLEMENTATION_TYPE
, $2, $4, NULL_TREE
);
2449 = continue_class
(objc_implementation_context
);
2454 PROTOCOL identifier protocolrefs
2456 remember_protocol_qualifiers
();
2457 objc_interface_context
2458 = start_protocol
(PROTOCOL_INTERFACE_TYPE
, $2, $3);
2462 forget_protocol_qualifiers
();
2463 finish_protocol
(objc_interface_context
);
2464 objc_interface_context
= NULL_TREE
;
2473 | non_empty_protocolrefs
2476 non_empty_protocolrefs:
2477 ARITHCOMPARE identifier_list ARITHCOMPARE
2479 if
($1 == LT_EXPR
&& $3 == GT_EXPR
)
2487 ivar_decl_list visibility_spec ivar_decls
2492 PRIVATE
{ objc_public_flag
= 2; }
2493 | PROTECTED
{ objc_public_flag
= 0; }
2494 | PUBLIC
{ objc_public_flag
= 1; }
2502 | ivar_decls ivar_decl
';'
2506 pedwarn
("extra semicolon in struct or union specified");
2511 /* There is a shift-reduce conflict here, because `components' may
2512 start with a `typename'. It happens that shifting (the default resolution)
2513 does the right thing, because it treats the `typename' as part of
2514 a `typed_typespecs'.
2516 It is possible that this same technique would allow the distinction
2517 between `notype_initdecls' and `initdecls' to be eliminated.
2518 But I am being cautious and not trying it. */
2521 typed_typespecs setspecs ivars
2523 current_declspecs
= TREE_VALUE
(declspec_stack
);
2524 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
2525 declspec_stack
= TREE_CHAIN
(declspec_stack
);
2526 resume_momentary
($2); }
2527 | nonempty_type_quals setspecs ivars
2529 current_declspecs
= TREE_VALUE
(declspec_stack
);
2530 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
2531 declspec_stack
= TREE_CHAIN
(declspec_stack
);
2532 resume_momentary
($2); }
2541 | ivars
',' ivar_declarator
2547 $$
= add_instance_variable
(objc_ivar_context
,
2549 $1, current_declspecs
,
2552 | declarator
':' expr_no_commas
2554 $$
= add_instance_variable
(objc_ivar_context
,
2556 $1, current_declspecs
, $3);
2558 |
':' expr_no_commas
2560 $$
= add_instance_variable
(objc_ivar_context
,
2563 current_declspecs
, $2);
2570 remember_protocol_qualifiers
();
2571 if
(objc_implementation_context
)
2572 objc_inherit_code
= CLASS_METHOD_DECL
;
2574 fatal
("method definition not in class context");
2578 forget_protocol_qualifiers
();
2579 add_class_method
(objc_implementation_context
, $3);
2580 start_method_def
($3);
2581 objc_method_context
= $3;
2585 continue_method_def
();
2589 finish_method_def
();
2590 objc_method_context
= NULL_TREE
;
2595 remember_protocol_qualifiers
();
2596 if
(objc_implementation_context
)
2597 objc_inherit_code
= INSTANCE_METHOD_DECL
;
2599 fatal
("method definition not in class context");
2603 forget_protocol_qualifiers
();
2604 add_instance_method
(objc_implementation_context
, $3);
2605 start_method_def
($3);
2606 objc_method_context
= $3;
2610 continue_method_def
();
2614 finish_method_def
();
2615 objc_method_context
= NULL_TREE
;
2619 /* the reason for the strange actions in this rule
2620 is so that notype_initdecls when reached via datadef
2621 can find a valid list of type and sc specs in $0. */
2625 |
{$
<ttype
>$
= NULL_TREE
; } methodprotolist2
2628 methodprotolist2: /* eliminates a shift/reduce conflict */
2631 | methodprotolist2 methodproto
2632 | methodprotolist2
{$
<ttype
>$
= NULL_TREE
; } datadef
2643 /* Remember protocol qualifiers in prototypes. */
2644 remember_protocol_qualifiers
();
2645 objc_inherit_code
= CLASS_METHOD_DECL
;
2649 /* Forget protocol qualifiers here. */
2650 forget_protocol_qualifiers
();
2651 add_class_method
(objc_interface_context
, $3);
2657 /* Remember protocol qualifiers in prototypes. */
2658 remember_protocol_qualifiers
();
2659 objc_inherit_code
= INSTANCE_METHOD_DECL
;
2663 /* Forget protocol qualifiers here. */
2664 forget_protocol_qualifiers
();
2665 add_instance_method
(objc_interface_context
, $3);
2671 '(' typename
')' unaryselector
2673 $$
= build_method_decl
(objc_inherit_code
, $2, $4, NULL_TREE
);
2678 $$
= build_method_decl
(objc_inherit_code
, NULL_TREE
, $1, NULL_TREE
);
2681 |
'(' typename
')' keywordselector optparmlist
2683 $$
= build_method_decl
(objc_inherit_code
, $2, $4, $5);
2686 | keywordselector optparmlist
2688 $$
= build_method_decl
(objc_inherit_code
, NULL_TREE
, $1, $2);
2692 /* "optarglist" assumes that start_method_def has already been called...
2693 if it is not, the "xdecls" will not be placed in the proper scope */
2700 /* to get around the following situation: "int foo (int a) int b; {}" that
2701 is synthesized when parsing "- a:a b:b; id c; id d; { ... }" */
2716 typed_declspecs setspecs myparms
';'
2717 { current_declspecs
= TREE_VALUE
(declspec_stack
);
2718 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
2719 declspec_stack
= TREE_CHAIN
(declspec_stack
);
2720 resume_momentary
($2); }
2721 | typed_declspecs
';'
2722 { shadow_tag
($1); }
2724 { pedwarn
("empty declaration"); }
2729 { push_parm_decl
($1); }
2730 | myparms
',' myparm
2731 { push_parm_decl
($3); }
2734 /* A single parameter declaration or parameter type name,
2735 as found in a parmlist. DOES NOT ALLOW AN INITIALIZER OR ASMSPEC */
2738 parm_declarator maybe_attribute
2739 { $$
= build_tree_list
(build_tree_list
(current_declspecs
,
2741 build_tree_list
(prefix_attributes
,
2743 | notype_declarator maybe_attribute
2744 { $$
= build_tree_list
(build_tree_list
(current_declspecs
,
2746 build_tree_list
(prefix_attributes
,
2748 | absdcl maybe_attribute
2749 { $$
= build_tree_list
(build_tree_list
(current_declspecs
,
2751 build_tree_list
(prefix_attributes
,
2762 /* oh what a kludge! */
2771 /* returns a tree list node generated by get_parm_info */
2784 | keywordselector keyworddecl
2786 $$
= chainon
($1, $2);
2798 ENUM
{ $$
= get_identifier
(token_buffer
); }
2799 | STRUCT
{ $$
= get_identifier
(token_buffer
); }
2800 | UNION
{ $$
= get_identifier
(token_buffer
); }
2801 | IF
{ $$
= get_identifier
(token_buffer
); }
2802 | ELSE
{ $$
= get_identifier
(token_buffer
); }
2803 | WHILE
{ $$
= get_identifier
(token_buffer
); }
2804 | DO
{ $$
= get_identifier
(token_buffer
); }
2805 | FOR
{ $$
= get_identifier
(token_buffer
); }
2806 | SWITCH
{ $$
= get_identifier
(token_buffer
); }
2807 | CASE
{ $$
= get_identifier
(token_buffer
); }
2808 | DEFAULT
{ $$
= get_identifier
(token_buffer
); }
2809 | BREAK
{ $$
= get_identifier
(token_buffer
); }
2810 | CONTINUE
{ $$
= get_identifier
(token_buffer
); }
2811 | RETURN
{ $$
= get_identifier
(token_buffer
); }
2812 | GOTO
{ $$
= get_identifier
(token_buffer
); }
2813 | ASM_KEYWORD
{ $$
= get_identifier
(token_buffer
); }
2814 | SIZEOF
{ $$
= get_identifier
(token_buffer
); }
2815 | TYPEOF
{ $$
= get_identifier
(token_buffer
); }
2816 | ALIGNOF
{ $$
= get_identifier
(token_buffer
); }
2817 | TYPESPEC | TYPE_QUAL
2821 selector
':' '(' typename
')' identifier
2823 $$
= build_keyword_decl
($1, $4, $6);
2826 | selector
':' identifier
2828 $$
= build_keyword_decl
($1, NULL_TREE
, $3);
2831 |
':' '(' typename
')' identifier
2833 $$
= build_keyword_decl
(NULL_TREE
, $3, $5);
2838 $$
= build_keyword_decl
(NULL_TREE
, NULL_TREE
, $2);
2849 | keywordarglist keywordarg
2851 $$
= chainon
($1, $2);
2859 if
(TREE_CHAIN
($1) == NULL_TREE
)
2860 /* just return the expr., remove a level of indirection */
2861 $$
= TREE_VALUE
($1);
2863 /* we have a comma expr., we will collapse later */
2869 selector
':' keywordexpr
2871 $$
= build_tree_list
($1, $3);
2875 $$
= build_tree_list
(NULL_TREE
, $2);
2883 $$
= get_class_reference
($1);
2889 { objc_receiver_context
= 1; }
2891 { objc_receiver_context
= 0; }
2894 $$
= build_tree_list
($3, $5);
2905 | keywordnamelist keywordname
2907 $$
= chainon
($1, $2);
2914 $$
= build_tree_list
($1, NULL_TREE
);
2918 $$
= build_tree_list
(NULL_TREE
, NULL_TREE
);
2923 SELECTOR
'(' selectorarg
')'
2930 PROTOCOL
'(' identifier
')'
2936 /* extension to support C-structures in the archiver */
2939 ENCODE
'(' typename
')'
2941 $$
= groktypename
($3);