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. */
46 #ifdef MULTIBYTE_CHARS
52 /* Since parsers are distinct for each language, put the language string
54 char *language_string
= "GNU Obj-C";
56 /* Like YYERROR but do call yyerror. */
57 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
59 /* Cause the `yydebug' variable to be defined. */
65 %
union {long itype
; tree ttype
; enum tree_code code
;
66 char *filename
; int lineno
; int ends_in_label
; }
68 /* All identifiers that are not reserved words
69 and are not declared typedefs in the current block */
72 /* All identifiers that are declared typedefs in the current block.
73 In some contexts, they are treated just like IDENTIFIER,
74 but they can also serve as typespecs in declarations. */
77 /* Reserved words that specify storage class.
78 yylval contains an IDENTIFIER_NODE which indicates which one. */
81 /* Reserved words that specify type.
82 yylval contains an IDENTIFIER_NODE which indicates which one. */
85 /* Reserved words that qualify type: "const" or "volatile".
86 yylval contains an IDENTIFIER_NODE which indicates which one. */
89 /* Character or numeric constants.
90 yylval is the node for the constant. */
93 /* String constants in raw form.
94 yylval is a STRING_CST node. */
97 /* "...", used for functions with variable arglists. */
100 /* the reserved words */
101 /* SCO include files test "ASM", so use something else. */
102 %token SIZEOF ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
103 %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD TYPEOF ALIGNOF
104 %token ATTRIBUTE EXTENSION LABEL
105 %token REALPART IMAGPART
107 /* Add precedence rules to solve dangling else s/r conflict */
111 /* Define the operator tokens and their precedences.
112 The value is an integer because, if used, it is the tree code
113 to use in the expression made from the operator. */
115 %right
<code
> ASSIGN
'='
116 %right
<code
> '?' ':'
122 %left
<code
> EQCOMPARE
123 %left
<code
> ARITHCOMPARE
124 %left
<code
> LSHIFT RSHIFT
126 %left
<code
> '*' '/' '%'
127 %right
<code
> UNARY PLUSPLUS MINUSMINUS
129 %left
<code
> POINTSAT
'.' '(' '['
131 /* The Objective-C keywords. These are included in C and in
132 Objective C, so that the token codes are the same in both. */
133 %token INTERFACE IMPLEMENTATION END SELECTOR DEFS ENCODE
134 %token CLASSNAME PUBLIC PRIVATE PROTECTED PROTOCOL OBJECTNAME CLASS ALIAS
136 /* Objective-C string constants in raw form.
137 yylval is an OBJC_STRING_CST node. */
143 %type
<ttype
> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist exprlist
144 %type
<ttype
> expr_no_commas cast_expr unary_expr primary
string STRING
145 %type
<ttype
> typed_declspecs reserved_declspecs
146 %type
<ttype
> typed_typespecs reserved_typespecquals
147 %type
<ttype
> declmods typespec typespecqual_reserved
148 %type
<ttype
> typed_declspecs_no_prefix_attr reserved_declspecs_no_prefix_attr
149 %type
<ttype
> declmods_no_prefix_attr
150 %type
<ttype
> SCSPEC TYPESPEC TYPE_QUAL nonempty_type_quals maybe_type_qual
151 %type
<ttype
> initdecls notype_initdecls initdcl notype_initdcl
152 %type
<ttype
> init maybeasm
153 %type
<ttype
> asm_operands nonnull_asm_operands asm_operand asm_clobbers
154 %type
<ttype
> maybe_attribute attributes attribute attribute_list attrib
155 %type
<ttype
> any_word
157 %type
<ttype
> compstmt
159 %type
<ttype
> declarator
160 %type
<ttype
> notype_declarator after_type_declarator
161 %type
<ttype
> parm_declarator
163 %type
<ttype
> structsp component_decl_list component_decl_list2
164 %type
<ttype
> component_decl components component_declarator
165 %type
<ttype
> enumlist enumerator
166 %type
<ttype
> typename absdcl absdcl1 type_quals
167 %type
<ttype
> xexpr parms parm identifiers
169 %type
<ttype
> parmlist parmlist_1 parmlist_2
170 %type
<ttype
> parmlist_or_identifiers parmlist_or_identifiers_1
171 %type
<ttype
> identifiers_or_typenames
173 %type
<itype
> setspecs
175 %type
<ends_in_label
> lineno_stmt_or_label lineno_stmt_or_labels stmt_or_label
177 %type
<filename
> save_filename
178 %type
<lineno
> save_lineno
180 /* the Objective-C nonterminals */
182 %type
<ttype
> ivar_decl_list ivar_decls ivar_decl ivars ivar_declarator
183 %type
<ttype
> methoddecl unaryselector keywordselector selector
184 %type
<ttype
> keyworddecl receiver objcmessageexpr messageargs
185 %type
<ttype
> keywordexpr keywordarglist keywordarg
186 %type
<ttype
> myparms myparm optparmlist reservedwords objcselectorexpr
187 %type
<ttype
> selectorarg keywordnamelist keywordname objcencodeexpr
188 %type
<ttype
> objc_string non_empty_protocolrefs protocolrefs identifier_list objcprotocolexpr
190 %type
<ttype
> CLASSNAME OBJC_STRING OBJECTNAME
193 /* Number of statements (loosely speaking) and compound statements
195 static int stmt_count
;
196 static int compstmt_count
;
198 /* Input file and line number of the end of the body of last simple_if;
199 used by the stmt-rule immediately after simple_if returns. */
200 static char *if_stmt_file
;
201 static int if_stmt_line
;
203 /* List of types and structure classes of the current declaration. */
204 static tree current_declspecs
= NULL_TREE
;
205 static tree prefix_attributes
= NULL_TREE
;
207 /* Stack of saved values of current_declspecs and prefix_attributes. */
208 static tree declspec_stack
;
210 /* 1 if we explained undeclared var errors. */
211 static int undeclared_variable_notice
;
213 /* Objective-C specific information */
215 tree objc_interface_context
;
216 tree objc_implementation_context
;
217 tree objc_method_context
;
218 tree objc_ivar_chain
;
219 tree objc_ivar_context
;
220 enum tree_code objc_inherit_code
;
221 int objc_receiver_context
;
222 int objc_public_flag
;
225 /* Tell yyparse how to print a token's value, if yydebug is set. */
227 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
228 extern
void yyprint PROTO
((FILE *, int, YYSTYPE));
234 pedwarn
("ANSI C forbids an empty source file");
239 /* In case there were missing closebraces,
240 get us back to the global binding level. */
241 while
(! global_bindings_p
())
247 /* the reason for the strange actions in this rule
248 is so that notype_initdecls when reached via datadef
249 can find a valid list of type and sc specs in $0. */
252 {$
<ttype
>$
= NULL_TREE
; } extdef
253 | extdefs
{$
<ttype
>$
= NULL_TREE
; } extdef
260 | ASM_KEYWORD
'(' expr
')' ';'
262 if
((TREE_CODE
($3) == ADDR_EXPR
263 && TREE_CODE
(TREE_OPERAND
($3, 0)) == STRING_CST
)
264 || TREE_CODE
($3) == STRING_CST
)
267 error ("argument of `asm' is not a constant string"); }
269 { pedantic
= $
<itype
>1; }
273 setspecs notype_initdecls
';'
275 error ("ANSI C forbids data definition with no type or storage class");
276 else if
(!flag_traditional
)
277 warning
("data definition has no type or storage class");
279 current_declspecs
= TREE_VALUE
(declspec_stack
);
280 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
281 declspec_stack
= TREE_CHAIN
(declspec_stack
);
282 resume_momentary
($1); }
283 | declmods setspecs notype_initdecls
';'
284 { current_declspecs
= TREE_VALUE
(declspec_stack
);
285 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
286 declspec_stack
= TREE_CHAIN
(declspec_stack
);
287 resume_momentary
($2); }
288 | typed_declspecs setspecs initdecls
';'
289 { current_declspecs
= TREE_VALUE
(declspec_stack
);
290 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
291 declspec_stack
= TREE_CHAIN
(declspec_stack
);
292 resume_momentary
($2); }
294 { pedwarn
("empty declaration"); }
295 | typed_declspecs
';'
301 pedwarn
("ANSI C does not allow extra `;' outside of a function"); }
305 typed_declspecs setspecs declarator
306 { if
(! start_function
(current_declspecs
, $3,
307 prefix_attributes
, NULL_TREE
, 0))
309 reinit_parse_for_function
(); }
311 { store_parm_decls
(); }
313 { finish_function
(0);
314 current_declspecs
= TREE_VALUE
(declspec_stack
);
315 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
316 declspec_stack
= TREE_CHAIN
(declspec_stack
);
317 resume_momentary
($2); }
318 | typed_declspecs setspecs declarator
error
319 { current_declspecs
= TREE_VALUE
(declspec_stack
);
320 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
321 declspec_stack
= TREE_CHAIN
(declspec_stack
);
322 resume_momentary
($2); }
323 | declmods setspecs notype_declarator
324 { if
(! start_function
(current_declspecs
, $3,
325 prefix_attributes
, NULL_TREE
, 0))
327 reinit_parse_for_function
(); }
329 { store_parm_decls
(); }
331 { finish_function
(0);
332 current_declspecs
= TREE_VALUE
(declspec_stack
);
333 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
334 declspec_stack
= TREE_CHAIN
(declspec_stack
);
335 resume_momentary
($2); }
336 | declmods setspecs notype_declarator
error
337 { current_declspecs
= TREE_VALUE
(declspec_stack
);
338 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
339 declspec_stack
= TREE_CHAIN
(declspec_stack
);
340 resume_momentary
($2); }
341 | setspecs notype_declarator
342 { if
(! start_function
(NULL_TREE
, $2,
343 prefix_attributes
, NULL_TREE
, 0))
345 reinit_parse_for_function
(); }
347 { store_parm_decls
(); }
349 { finish_function
(0);
350 current_declspecs
= TREE_VALUE
(declspec_stack
);
351 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
352 declspec_stack
= TREE_CHAIN
(declspec_stack
);
353 resume_momentary
($1); }
354 | setspecs notype_declarator
error
355 { current_declspecs
= TREE_VALUE
(declspec_stack
);
356 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
357 declspec_stack
= TREE_CHAIN
(declspec_stack
);
358 resume_momentary
($1); }
371 { $$
= NEGATE_EXPR
; }
373 { $$
= CONVERT_EXPR
; }
375 { $$
= PREINCREMENT_EXPR
; }
377 { $$
= PREDECREMENT_EXPR
; }
379 { $$
= BIT_NOT_EXPR
; }
381 { $$
= TRUTH_NOT_EXPR
; }
384 expr: nonnull_exprlist
385 { $$
= build_compound_expr
($1); }
396 { $$
= build_tree_list
(NULL_TREE
, $1); }
397 | nonnull_exprlist
',' expr_no_commas
398 { chainon
($1, build_tree_list
(NULL_TREE
, $3)); }
403 |
'*' cast_expr %prec UNARY
404 { $$
= build_indirect_ref
($2, "unary *"); }
405 /* __extension__ turns off -pedantic for following primary. */
406 | extension cast_expr %prec UNARY
408 pedantic
= $
<itype
>1; }
409 | unop cast_expr %prec UNARY
410 { $$
= build_unary_op
($1, $2, 0);
411 overflow_warning
($$
); }
412 /* Refer to the address of a label as a pointer. */
414 { tree label
= lookup_label
($2);
416 pedwarn
("ANSI C forbids `&&'");
418 $$
= null_pointer_node
;
421 TREE_USED
(label
) = 1;
422 $$
= build1
(ADDR_EXPR
, ptr_type_node
, label
);
423 TREE_CONSTANT
($$
) = 1;
426 /* This seems to be impossible on some machines, so let's turn it off.
427 You can use __builtin_next_arg to find the anonymous stack args.
429 { tree types = TYPE_ARG_TYPES (TREE_TYPE (current_function_decl));
430 $$ = error_mark_node;
431 if (TREE_VALUE (tree_last (types)) == void_type_node)
432 error ("`&...' used in function with fixed number of arguments");
436 pedwarn ("ANSI C forbids `&...'");
437 $$ = tree_last (DECL_ARGUMENTS (current_function_decl));
438 $$ = build_unary_op (ADDR_EXPR, $$, 0);
441 | sizeof unary_expr %prec UNARY
443 if
(TREE_CODE
($2) == COMPONENT_REF
444 && DECL_C_BIT_FIELD
(TREE_OPERAND
($2, 1)))
445 error ("`sizeof' applied to a bit-field");
446 $$
= c_sizeof
(TREE_TYPE
($2)); }
447 | sizeof
'(' typename
')' %prec HYPERUNARY
449 $$
= c_sizeof
(groktypename
($3)); }
450 | alignof unary_expr %prec UNARY
452 $$
= c_alignof_expr
($2); }
453 | alignof
'(' typename
')' %prec HYPERUNARY
455 $$
= c_alignof
(groktypename
($3)); }
456 | REALPART cast_expr %prec UNARY
457 { $$
= build_unary_op
(REALPART_EXPR
, $2, 0); }
458 | IMAGPART cast_expr %prec UNARY
459 { $$
= build_unary_op
(IMAGPART_EXPR
, $2, 0); }
463 SIZEOF
{ skip_evaluation
++; }
467 ALIGNOF
{ skip_evaluation
++; }
472 |
'(' typename
')' cast_expr %prec UNARY
473 { tree type
= groktypename
($2);
474 $$
= build_c_cast
(type
, $4); }
475 |
'(' typename
')' '{'
476 { start_init
(NULL_TREE
, NULL
, 0);
477 $2 = groktypename
($2);
478 really_start_incremental_init
($2); }
479 initlist_maybe_comma
'}' %prec UNARY
481 tree result
= pop_init_level
(0);
486 pedwarn
("ANSI C forbids constructor expressions");
487 if
(TYPE_NAME
(type
) != 0)
489 if
(TREE_CODE
(TYPE_NAME
(type
)) == IDENTIFIER_NODE
)
490 name
= IDENTIFIER_POINTER
(TYPE_NAME
(type
));
492 name
= IDENTIFIER_POINTER
(DECL_NAME
(TYPE_NAME
(type
)));
497 if
(TREE_CODE
(type
) == ARRAY_TYPE
&& TYPE_SIZE
(type
) == 0)
499 int failure
= complete_array_type
(type
, $$
, 1);
508 | expr_no_commas
'+' expr_no_commas
509 { $$
= parser_build_binary_op
($2, $1, $3); }
510 | expr_no_commas
'-' expr_no_commas
511 { $$
= parser_build_binary_op
($2, $1, $3); }
512 | expr_no_commas
'*' expr_no_commas
513 { $$
= parser_build_binary_op
($2, $1, $3); }
514 | expr_no_commas
'/' expr_no_commas
515 { $$
= parser_build_binary_op
($2, $1, $3); }
516 | expr_no_commas
'%' expr_no_commas
517 { $$
= parser_build_binary_op
($2, $1, $3); }
518 | expr_no_commas LSHIFT expr_no_commas
519 { $$
= parser_build_binary_op
($2, $1, $3); }
520 | expr_no_commas RSHIFT expr_no_commas
521 { $$
= parser_build_binary_op
($2, $1, $3); }
522 | expr_no_commas ARITHCOMPARE expr_no_commas
523 { $$
= parser_build_binary_op
($2, $1, $3); }
524 | expr_no_commas EQCOMPARE expr_no_commas
525 { $$
= parser_build_binary_op
($2, $1, $3); }
526 | expr_no_commas
'&' expr_no_commas
527 { $$
= parser_build_binary_op
($2, $1, $3); }
528 | expr_no_commas
'|' expr_no_commas
529 { $$
= parser_build_binary_op
($2, $1, $3); }
530 | expr_no_commas
'^' expr_no_commas
531 { $$
= parser_build_binary_op
($2, $1, $3); }
532 | expr_no_commas ANDAND
533 { $1 = truthvalue_conversion
(default_conversion
($1));
534 skip_evaluation
+= $1 == boolean_false_node
; }
536 { skip_evaluation
-= $1 == boolean_false_node
;
537 $$
= parser_build_binary_op
(TRUTH_ANDIF_EXPR
, $1, $4); }
538 | expr_no_commas OROR
539 { $1 = truthvalue_conversion
(default_conversion
($1));
540 skip_evaluation
+= $1 == boolean_true_node
; }
542 { skip_evaluation
-= $1 == boolean_true_node
;
543 $$
= parser_build_binary_op
(TRUTH_ORIF_EXPR
, $1, $4); }
545 { $1 = truthvalue_conversion
(default_conversion
($1));
546 skip_evaluation
+= $1 == boolean_false_node
; }
548 { skip_evaluation
+= (($1 == boolean_true_node
)
549 - ($1 == boolean_false_node
)); }
551 { skip_evaluation
-= $1 == boolean_true_node
;
552 $$
= build_conditional_expr
($1, $4, $7); }
555 pedwarn
("ANSI C forbids omitting the middle term of a ?: expression");
556 /* Make sure first operand is calculated only once. */
557 $
<ttype
>2 = save_expr
($1);
558 $1 = truthvalue_conversion
(default_conversion
($
<ttype
>2));
559 skip_evaluation
+= $1 == boolean_true_node
; }
561 { skip_evaluation
-= $1 == boolean_true_node
;
562 $$
= build_conditional_expr
($1, $
<ttype
>2, $5); }
563 | expr_no_commas
'=' expr_no_commas
564 { $$
= build_modify_expr
($1, NOP_EXPR
, $3);
565 C_SET_EXP_ORIGINAL_CODE
($$
, MODIFY_EXPR
); }
566 | expr_no_commas ASSIGN expr_no_commas
567 { $$
= build_modify_expr
($1, $2, $3);
568 /* This inhibits warnings in truthvalue_conversion. */
569 C_SET_EXP_ORIGINAL_CODE
($$
, ERROR_MARK
); }
576 if
(!$$ || $$
== error_mark_node
)
578 if
(yychar == YYEMPTY
)
584 if
(objc_receiver_context
585 && ! (objc_receiver_context
586 && strcmp
(IDENTIFIER_POINTER
($1), "super")))
587 /* we have a message to super */
588 $$
= get_super_receiver
();
589 else if
(objc_method_context
590 && (decl
= is_ivar
(objc_ivar_chain
, $1)))
592 if
(is_private
(decl
))
593 $$
= error_mark_node
;
595 $$
= build_ivar_reference
($1);
599 /* Ordinary implicit function declaration. */
600 $$
= implicitly_declare
($1);
601 assemble_external
($$
);
605 else if
(current_function_decl
== 0)
607 error ("`%s' undeclared here (not in a function)",
608 IDENTIFIER_POINTER
($1));
609 $$
= error_mark_node
;
615 if
(objc_receiver_context
616 && ! strcmp
(IDENTIFIER_POINTER
($1), "super"))
617 /* we have a message to super */
618 $$
= get_super_receiver
();
619 else if
(objc_method_context
620 && (decl
= is_ivar
(objc_ivar_chain
, $1)))
622 if
(is_private
(decl
))
623 $$
= error_mark_node
;
625 $$
= build_ivar_reference
($1);
629 if
(IDENTIFIER_GLOBAL_VALUE
($1) != error_mark_node
630 || IDENTIFIER_ERROR_LOCUS
($1) != current_function_decl
)
632 error ("`%s' undeclared (first use in this function)",
633 IDENTIFIER_POINTER
($1));
635 if
(! undeclared_variable_notice
)
637 error ("(Each undeclared identifier is reported only once");
638 error ("for each function it appears in.)");
639 undeclared_variable_notice
= 1;
642 $$
= error_mark_node
;
643 /* Prevent repeated error messages. */
644 IDENTIFIER_GLOBAL_VALUE
($1) = error_mark_node
;
645 IDENTIFIER_ERROR_LOCUS
($1) = current_function_decl
;
649 else if
(TREE_TYPE
($$
) == error_mark_node
)
650 $$
= error_mark_node
;
651 else if
(C_DECL_ANTICIPATED
($$
))
653 /* The first time we see a build-in function used,
654 if it has not been declared. */
655 C_DECL_ANTICIPATED
($$
) = 0;
656 if
(yychar == YYEMPTY
)
660 /* Omit the implicit declaration we
661 would ordinarily do, so we don't lose
662 the actual built in type.
663 But print a diagnostic for the mismatch. */
664 if
(objc_method_context
665 && is_ivar
(objc_ivar_chain
, $1))
666 error ("Instance variable `%s' implicitly declared as function",
667 IDENTIFIER_POINTER
(DECL_NAME
($$
)));
669 if
(TREE_CODE
($$
) != FUNCTION_DECL
)
670 error ("`%s' implicitly declared as function",
671 IDENTIFIER_POINTER
(DECL_NAME
($$
)));
672 else if
((TYPE_MODE
(TREE_TYPE
(TREE_TYPE
($$
)))
673 != TYPE_MODE
(integer_type_node
))
674 && (TREE_TYPE
(TREE_TYPE
($$
))
676 pedwarn
("type mismatch in implicit declaration for built-in function `%s'",
677 IDENTIFIER_POINTER
(DECL_NAME
($$
)));
678 /* If it really returns void, change that to int. */
679 if
(TREE_TYPE
(TREE_TYPE
($$
)) == void_type_node
)
681 = build_function_type
(integer_type_node
,
682 TYPE_ARG_TYPES
(TREE_TYPE
($$
)));
685 pedwarn
("built-in function `%s' used without declaration",
686 IDENTIFIER_POINTER
(DECL_NAME
($$
)));
688 /* Do what we would ordinarily do when a fn is used. */
689 assemble_external
($$
);
694 assemble_external
($$
);
696 /* we have a definition - still check if iVariable */
698 if
(!objc_receiver_context
699 ||
(objc_receiver_context
700 && strcmp
(IDENTIFIER_POINTER
($1), "super")))
704 if
(objc_method_context
705 && (decl
= is_ivar
(objc_ivar_chain
, $1)))
707 if
(IDENTIFIER_LOCAL_VALUE
($1))
708 warning
("local declaration of `%s' hides instance variable",
709 IDENTIFIER_POINTER
($1));
712 if
(is_private
(decl
))
713 $$
= error_mark_node
;
715 $$
= build_ivar_reference
($1);
719 else
/* we have a message to super */
720 $$
= get_super_receiver
();
723 if
(TREE_CODE
($$
) == CONST_DECL
)
725 $$
= DECL_INITIAL
($$
);
726 /* This is to prevent an enum whose value is 0
727 from being considered a null pointer constant. */
728 $$
= build1
(NOP_EXPR
, TREE_TYPE
($$
), $$
);
729 TREE_CONSTANT
($$
) = 1;
734 { $$
= combine_strings
($1); }
736 { char class
= TREE_CODE_CLASS
(TREE_CODE
($2));
737 if
(class
== 'e' || class
== '1'
738 || class
== '2' || class
== '<')
739 C_SET_EXP_ORIGINAL_CODE
($2, ERROR_MARK
);
742 { $$
= error_mark_node
; }
744 { if
(current_function_decl
== 0)
746 error ("braced-group within expression allowed only inside a function");
749 /* We must force a BLOCK for this level
750 so that, if it is not expanded later,
751 there is a way to turn off the entire subtree of blocks
752 that are contained in it. */
754 push_iterator_stack
();
756 $
<ttype
>$
= expand_start_stmt_expr
(); }
760 pedwarn
("ANSI C forbids braced-groups within expressions");
761 pop_iterator_stack
();
763 rtl_exp
= expand_end_stmt_expr
($
<ttype
>2);
764 /* The statements have side effects, so the group does. */
765 TREE_SIDE_EFFECTS
(rtl_exp
) = 1;
767 if
(TREE_CODE
($3) == BLOCK
)
769 /* Make a BIND_EXPR for the BLOCK already made. */
770 $$
= build
(BIND_EXPR
, TREE_TYPE
(rtl_exp
),
771 NULL_TREE
, rtl_exp
, $3);
772 /* Remove the block from the tree at this point.
773 It gets put back at the proper place
774 when the BIND_EXPR is expanded. */
780 | primary
'(' exprlist
')' %prec
'.'
781 { $$
= build_function_call
($1, $3); }
782 | primary
'[' expr
']' %prec
'.'
783 { $$
= build_array_ref
($1, $3); }
784 | primary
'.' identifier
786 if
(doing_objc_thang
)
788 if
(is_public
($1, $3))
789 $$
= build_component_ref
($1, $3);
791 $$
= error_mark_node
;
794 $$
= build_component_ref
($1, $3);
796 | primary POINTSAT identifier
798 tree expr
= build_indirect_ref
($1, "->");
800 if
(doing_objc_thang
)
802 if
(is_public
(expr
, $3))
803 $$
= build_component_ref
(expr
, $3);
805 $$
= error_mark_node
;
808 $$
= build_component_ref
(expr
, $3);
811 { $$
= build_unary_op
(POSTINCREMENT_EXPR
, $1, 0); }
813 { $$
= build_unary_op
(POSTDECREMENT_EXPR
, $1, 0); }
815 { $$
= build_message_expr
($1); }
817 { $$
= build_selector_expr
($1); }
819 { $$
= build_protocol_expr
($1); }
821 { $$
= build_encode_expr
($1); }
823 { $$
= build_objc_string_object
($1); }
826 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
830 { $$
= chainon
($1, $2); }
833 /* Produces an OBJC_STRING_CST with perhaps more OBJC_STRING_CSTs chained
837 | objc_string OBJC_STRING
838 { $$
= chainon
($1, $2); }
841 old_style_parm_decls:
845 /* ... is used here to indicate a varargs function. */
848 pedwarn
("ANSI C does not permit use of `varargs.h'"); }
851 /* The following are analogous to lineno_decl, decls and decl
852 except that they do not allow nested functions.
853 They are used for old-style parm decls. */
855 save_filename save_lineno datadecl
862 | datadecls lineno_datadecl
863 | lineno_datadecl errstmt
866 /* We don't allow prefix attributes here because they cause reduce/reduce
867 conflicts: we can't know whether we're parsing a function decl with
868 attribute suffix, or function defn with attribute prefix on first old
871 typed_declspecs_no_prefix_attr setspecs initdecls
';'
872 { current_declspecs
= TREE_VALUE
(declspec_stack
);
873 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
874 declspec_stack
= TREE_CHAIN
(declspec_stack
);
875 resume_momentary
($2); }
876 | declmods_no_prefix_attr setspecs notype_initdecls
';'
877 { current_declspecs
= TREE_VALUE
(declspec_stack
);
878 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
879 declspec_stack
= TREE_CHAIN
(declspec_stack
);
880 resume_momentary
($2); }
881 | typed_declspecs_no_prefix_attr
';'
882 { shadow_tag_warned
($1, 1);
883 pedwarn
("empty declaration"); }
884 | declmods_no_prefix_attr
';'
885 { pedwarn
("empty declaration"); }
888 /* This combination which saves a lineno before a decl
889 is the normal thing to use, rather than decl itself.
890 This is to avoid shift/reduce conflicts in contexts
891 where statement labels are allowed. */
893 save_filename save_lineno decl
901 | lineno_decl errstmt
904 /* records the type and storage class specs to use for processing
905 the declarators that follow.
906 Maintains a stack of outer-level values of current_declspecs,
907 for the sake of parm declarations nested in function declarators. */
908 setspecs: /* empty */
909 { $$
= suspend_momentary
();
910 pending_xref_error
();
911 declspec_stack
= tree_cons
(prefix_attributes
,
914 split_specs_attrs
($
<ttype
>0,
915 ¤t_declspecs
, &prefix_attributes
); }
918 /* ??? Yuck. See after_type_declarator. */
919 setattrs: /* empty */
920 { prefix_attributes
= chainon
(prefix_attributes
, $
<ttype
>0); }
924 typed_declspecs setspecs initdecls
';'
925 { current_declspecs
= TREE_VALUE
(declspec_stack
);
926 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
927 declspec_stack
= TREE_CHAIN
(declspec_stack
);
928 resume_momentary
($2); }
929 | declmods setspecs notype_initdecls
';'
930 { current_declspecs
= TREE_VALUE
(declspec_stack
);
931 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
932 declspec_stack
= TREE_CHAIN
(declspec_stack
);
933 resume_momentary
($2); }
934 | typed_declspecs setspecs nested_function
935 { current_declspecs
= TREE_VALUE
(declspec_stack
);
936 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
937 declspec_stack
= TREE_CHAIN
(declspec_stack
);
938 resume_momentary
($2); }
939 | declmods setspecs notype_nested_function
940 { current_declspecs
= TREE_VALUE
(declspec_stack
);
941 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
942 declspec_stack
= TREE_CHAIN
(declspec_stack
);
943 resume_momentary
($2); }
944 | typed_declspecs
';'
947 { pedwarn
("empty declaration"); }
949 { pedantic
= $
<itype
>1; }
952 /* Declspecs which contain at least one type specifier or typedef name.
953 (Just `const' or `volatile' is not enough.)
954 A typedef'd name following these is taken as a name to be declared.
955 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
958 typespec reserved_declspecs
959 { $$
= tree_cons
(NULL_TREE
, $1, $2); }
960 | declmods typespec reserved_declspecs
961 { $$
= chainon
($3, tree_cons
(NULL_TREE
, $2, $1)); }
964 reserved_declspecs: /* empty */
966 | reserved_declspecs typespecqual_reserved
967 { $$
= tree_cons
(NULL_TREE
, $2, $1); }
968 | reserved_declspecs SCSPEC
969 { if
(extra_warnings
)
970 warning
("`%s' is not at beginning of declaration",
971 IDENTIFIER_POINTER
($2));
972 $$
= tree_cons
(NULL_TREE
, $2, $1); }
973 | reserved_declspecs attributes
974 { $$
= tree_cons
($2, NULL_TREE
, $1); }
977 typed_declspecs_no_prefix_attr:
978 typespec reserved_declspecs_no_prefix_attr
979 { $$
= tree_cons
(NULL_TREE
, $1, $2); }
980 | declmods_no_prefix_attr typespec reserved_declspecs_no_prefix_attr
981 { $$
= chainon
($3, tree_cons
(NULL_TREE
, $2, $1)); }
984 reserved_declspecs_no_prefix_attr:
987 | reserved_declspecs_no_prefix_attr typespecqual_reserved
988 { $$
= tree_cons
(NULL_TREE
, $2, $1); }
989 | reserved_declspecs_no_prefix_attr SCSPEC
990 { if
(extra_warnings
)
991 warning
("`%s' is not at beginning of declaration",
992 IDENTIFIER_POINTER
($2));
993 $$
= tree_cons
(NULL_TREE
, $2, $1); }
996 /* List of just storage classes, type modifiers, and prefix attributes.
997 A declaration can start with just this, but then it cannot be used
998 to redeclare a typedef-name.
999 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
1002 declmods_no_prefix_attr
1005 { $$
= tree_cons
($1, NULL_TREE
, NULL_TREE
); }
1006 | declmods declmods_no_prefix_attr
1007 { $$
= chainon
($2, $1); }
1008 | declmods attributes
1009 { $$
= tree_cons
($2, NULL_TREE
, $1); }
1012 declmods_no_prefix_attr:
1014 { $$
= tree_cons
(NULL_TREE
, $1, NULL_TREE
);
1015 TREE_STATIC
($$
) = 1; }
1017 { $$
= tree_cons
(NULL_TREE
, $1, NULL_TREE
); }
1018 | declmods_no_prefix_attr TYPE_QUAL
1019 { $$
= tree_cons
(NULL_TREE
, $2, $1);
1020 TREE_STATIC
($$
) = 1; }
1021 | declmods_no_prefix_attr SCSPEC
1022 { if
(extra_warnings
&& TREE_STATIC
($1))
1023 warning
("`%s' is not at beginning of declaration",
1024 IDENTIFIER_POINTER
($2));
1025 $$
= tree_cons
(NULL_TREE
, $2, $1);
1026 TREE_STATIC
($$
) = TREE_STATIC
($1); }
1030 /* Used instead of declspecs where storage classes are not allowed
1031 (that is, for typenames and structure components).
1032 Don't accept a typedef-name if anything but a modifier precedes it. */
1035 typespec reserved_typespecquals
1036 { $$
= tree_cons
(NULL_TREE
, $1, $2); }
1037 | nonempty_type_quals typespec reserved_typespecquals
1038 { $$
= chainon
($3, tree_cons
(NULL_TREE
, $2, $1)); }
1041 reserved_typespecquals: /* empty */
1043 | reserved_typespecquals typespecqual_reserved
1044 { $$
= tree_cons
(NULL_TREE
, $2, $1); }
1047 /* A typespec (but not a type qualifier).
1048 Once we have seen one of these in a declaration,
1049 if a typedef name appears then it is being redeclared. */
1054 { /* For a typedef name, record the meaning, not the name.
1055 In case of `foo foo, bar;'. */
1056 $$
= lookup_name
($1); }
1057 | CLASSNAME protocolrefs
1058 { $$
= get_static_reference
($1, $2); }
1059 | OBJECTNAME protocolrefs
1060 { $$
= get_object_reference
($2); }
1062 /* Make "<SomeProtocol>" equivalent to "id <SomeProtocol>"
1063 - nisse@lysator.liu.se */
1064 | non_empty_protocolrefs
1065 { $$
= get_object_reference
($1); }
1066 | TYPEOF
'(' expr
')'
1067 { $$
= TREE_TYPE
($3); }
1068 | TYPEOF
'(' typename
')'
1069 { $$
= groktypename
($3); }
1072 /* A typespec that is a reserved word, or a type qualifier. */
1074 typespecqual_reserved: TYPESPEC
1081 | initdecls
',' initdcl
1086 | notype_initdecls
',' initdcl
1092 | ASM_KEYWORD
'(' string ')'
1093 { if
(TREE_CHAIN
($3)) $3 = combine_strings
($3);
1099 declarator maybeasm maybe_attribute
'='
1100 { $
<ttype
>$
= start_decl
($1, current_declspecs
, 1,
1101 $3, prefix_attributes
);
1102 start_init
($
<ttype
>$
, $2, global_bindings_p
()); }
1104 /* Note how the declaration of the variable is in effect while its init is parsed! */
1106 finish_decl
($
<ttype
>5, $6, $2); }
1107 | declarator maybeasm maybe_attribute
1108 { tree d
= start_decl
($1, current_declspecs
, 0,
1109 $3, prefix_attributes
);
1110 finish_decl
(d
, NULL_TREE
, $2);
1115 notype_declarator maybeasm maybe_attribute
'='
1116 { $
<ttype
>$
= start_decl
($1, current_declspecs
, 1,
1117 $3, prefix_attributes
);
1118 start_init
($
<ttype
>$
, $2, global_bindings_p
()); }
1120 /* Note how the declaration of the variable is in effect while its init is parsed! */
1122 decl_attributes
($
<ttype
>5, $3, prefix_attributes
);
1123 finish_decl
($
<ttype
>5, $6, $2); }
1124 | notype_declarator maybeasm maybe_attribute
1125 { tree d
= start_decl
($1, current_declspecs
, 0,
1126 $3, prefix_attributes
);
1127 finish_decl
(d
, NULL_TREE
, $2); }
1129 /* the * rules are dummies to accept the Apollo extended syntax
1130 so that the header files compile. */
1141 | attributes attribute
1142 { $$
= chainon
($1, $2); }
1146 ATTRIBUTE
'(' '(' attribute_list
')' ')'
1153 | attribute_list
',' attrib
1154 { $$
= chainon
($1, $3); }
1161 { $$
= build_tree_list
($1, NULL_TREE
); }
1162 | any_word
'(' IDENTIFIER
')'
1163 { $$
= build_tree_list
($1, build_tree_list
(NULL_TREE
, $3)); }
1164 | any_word
'(' IDENTIFIER
',' nonnull_exprlist
')'
1165 { $$
= build_tree_list
($1, tree_cons
(NULL_TREE
, $3, $5)); }
1166 | any_word
'(' exprlist
')'
1167 { $$
= build_tree_list
($1, $3); }
1170 /* This still leaves out most reserved keywords,
1171 shouldn't we include them? */
1180 /* Initializers. `init' is the entry point. */
1185 { really_start_incremental_init
(NULL_TREE
);
1186 /* Note that the call to clear_momentary
1187 is in process_init_element. */
1188 push_momentary
(); }
1189 initlist_maybe_comma
'}'
1190 { $$
= pop_init_level
(0);
1191 if
($$
== error_mark_node
1192 && ! (yychar == STRING ||
yychar == CONSTANT
))
1195 pop_momentary_nofree
(); }
1198 { $$
= error_mark_node
; }
1201 /* `initlist_maybe_comma' is the guts of an initializer in braces. */
1202 initlist_maybe_comma:
1205 pedwarn
("ANSI C forbids empty initializer braces"); }
1206 | initlist1 maybecomma
1211 | initlist1
',' initelt
1214 /* `initelt' is a single element of an initializer.
1215 It may use braces. */
1218 { process_init_element
($1); }
1220 { push_init_level
(0); }
1221 initlist_maybe_comma
'}'
1222 { process_init_element
(pop_init_level
(0)); }
1224 /* These are for labeled elements. The syntax for an array element
1225 initializer conflicts with the syntax for an Objective-C message,
1226 so don't include these productions in the Objective-C grammar. */
1228 { set_init_label
($1); }
1230 |
'.' identifier
'='
1231 { set_init_label
($2); }
1237 { push_c_function_context
();
1238 if
(! start_function
(current_declspecs
, $1,
1239 prefix_attributes
, NULL_TREE
, 1))
1241 pop_c_function_context
();
1244 reinit_parse_for_function
(); }
1245 old_style_parm_decls
1246 { store_parm_decls
(); }
1247 /* This used to use compstmt_or_error.
1248 That caused a bug with input `f(g) int g {}',
1249 where the use of YYERROR1 above caused an error
1250 which then was handled by compstmt_or_error.
1251 There followed a repeated execution of that same rule,
1252 which called YYERROR1 again, and so on. */
1254 { finish_function
(1);
1255 pop_c_function_context
(); }
1258 notype_nested_function:
1260 { push_c_function_context
();
1261 if
(! start_function
(current_declspecs
, $1,
1262 prefix_attributes
, NULL_TREE
, 1))
1264 pop_c_function_context
();
1267 reinit_parse_for_function
(); }
1268 old_style_parm_decls
1269 { store_parm_decls
(); }
1270 /* This used to use compstmt_or_error.
1271 That caused a bug with input `f(g) int g {}',
1272 where the use of YYERROR1 above caused an error
1273 which then was handled by compstmt_or_error.
1274 There followed a repeated execution of that same rule,
1275 which called YYERROR1 again, and so on. */
1277 { finish_function
(1);
1278 pop_c_function_context
(); }
1281 /* Any kind of declarator (thus, all declarators allowed
1282 after an explicit typespec). */
1285 after_type_declarator
1289 /* A declarator that is allowed only after an explicit typespec. */
1291 after_type_declarator:
1292 '(' after_type_declarator
')'
1294 | after_type_declarator
'(' parmlist_or_identifiers %prec
'.'
1295 { $$
= build_nt
(CALL_EXPR
, $1, $3, NULL_TREE
); }
1296 /* | after_type_declarator '(' error ')' %prec '.'
1297 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1298 poplevel (0, 0, 0); } */
1299 | after_type_declarator
'[' expr
']' %prec
'.'
1300 { $$
= build_nt
(ARRAY_REF
, $1, $3); }
1301 | after_type_declarator
'[' ']' %prec
'.'
1302 { $$
= build_nt
(ARRAY_REF
, $1, NULL_TREE
); }
1303 |
'*' type_quals after_type_declarator %prec UNARY
1304 { $$
= make_pointer_declarator
($2, $3); }
1305 /* ??? Yuck. setattrs is a quick hack. We can't use
1306 prefix_attributes because $1 only applies to this
1307 declarator. We assume setspecs has already been done.
1308 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1309 attributes could be recognized here or in `attributes'). */
1310 | attributes setattrs after_type_declarator
1316 /* Kinds of declarator that can appear in a parameter list
1317 in addition to notype_declarator. This is like after_type_declarator
1318 but does not allow a typedef name in parentheses as an identifier
1319 (because it would conflict with a function with that typedef as arg). */
1322 parm_declarator
'(' parmlist_or_identifiers %prec
'.'
1323 { $$
= build_nt
(CALL_EXPR
, $1, $3, NULL_TREE
); }
1324 /* | parm_declarator '(' error ')' %prec '.'
1325 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1326 poplevel (0, 0, 0); } */
1327 | parm_declarator
'[' expr
']' %prec
'.'
1328 { $$
= build_nt
(ARRAY_REF
, $1, $3); }
1329 | parm_declarator
'[' ']' %prec
'.'
1330 { $$
= build_nt
(ARRAY_REF
, $1, NULL_TREE
); }
1331 |
'*' type_quals parm_declarator %prec UNARY
1332 { $$
= make_pointer_declarator
($2, $3); }
1333 /* ??? Yuck. setattrs is a quick hack. We can't use
1334 prefix_attributes because $1 only applies to this
1335 declarator. We assume setspecs has already been done.
1336 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1337 attributes could be recognized here or in `attributes'). */
1338 | attributes setattrs parm_declarator
1343 /* A declarator allowed whether or not there has been
1344 an explicit typespec. These cannot redeclare a typedef-name. */
1347 notype_declarator
'(' parmlist_or_identifiers %prec
'.'
1348 { $$
= build_nt
(CALL_EXPR
, $1, $3, NULL_TREE
); }
1349 /* | notype_declarator '(' error ')' %prec '.'
1350 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1351 poplevel (0, 0, 0); } */
1352 |
'(' notype_declarator
')'
1354 |
'*' type_quals notype_declarator %prec UNARY
1355 { $$
= make_pointer_declarator
($2, $3); }
1356 | notype_declarator
'[' expr
']' %prec
'.'
1357 { $$
= build_nt
(ARRAY_REF
, $1, $3); }
1358 | notype_declarator
'[' ']' %prec
'.'
1359 { $$
= build_nt
(ARRAY_REF
, $1, NULL_TREE
); }
1360 /* ??? Yuck. setattrs is a quick hack. We can't use
1361 prefix_attributes because $1 only applies to this
1362 declarator. We assume setspecs has already been done.
1363 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1364 attributes could be recognized here or in `attributes'). */
1365 | attributes setattrs notype_declarator
1371 STRUCT identifier
'{'
1372 { $$
= start_struct
(RECORD_TYPE
, $2);
1373 /* Start scope of tag before parsing components. */
1375 component_decl_list
'}' maybe_attribute
1376 { $$
= finish_struct
($
<ttype
>4, $5, $7); }
1377 | STRUCT
'{' component_decl_list
'}' maybe_attribute
1378 { $$
= finish_struct
(start_struct
(RECORD_TYPE
, NULL_TREE
),
1382 { $$
= xref_tag
(RECORD_TYPE
, $2); }
1383 | UNION identifier
'{'
1384 { $$
= start_struct
(UNION_TYPE
, $2); }
1385 component_decl_list
'}' maybe_attribute
1386 { $$
= finish_struct
($
<ttype
>4, $5, $7); }
1387 | UNION
'{' component_decl_list
'}' maybe_attribute
1388 { $$
= finish_struct
(start_struct
(UNION_TYPE
, NULL_TREE
),
1392 { $$
= xref_tag
(UNION_TYPE
, $2); }
1393 | ENUM identifier
'{'
1394 { $
<itype
>3 = suspend_momentary
();
1395 $$
= start_enum
($2); }
1396 enumlist maybecomma_warn
'}' maybe_attribute
1397 { $$
= finish_enum
($
<ttype
>4, nreverse
($5), $8);
1398 resume_momentary
($
<itype
>3); }
1400 { $
<itype
>2 = suspend_momentary
();
1401 $$
= start_enum
(NULL_TREE
); }
1402 enumlist maybecomma_warn
'}' maybe_attribute
1403 { $$
= finish_enum
($
<ttype
>3, nreverse
($4), $7);
1404 resume_momentary
($
<itype
>2); }
1406 { $$
= xref_tag
(ENUMERAL_TYPE
, $2); }
1417 { if
(pedantic
) pedwarn
("comma at end of enumerator list"); }
1420 component_decl_list:
1421 component_decl_list2
1423 | component_decl_list2 component_decl
1424 { $$
= chainon
($1, $2);
1425 pedwarn
("no semicolon at end of struct or union"); }
1428 component_decl_list2: /* empty */
1430 | component_decl_list2 component_decl
';'
1431 { $$
= chainon
($1, $2); }
1432 | component_decl_list2
';'
1434 pedwarn
("extra semicolon in struct or union specified"); }
1435 /* foo(sizeof(struct{ @defs(ClassName)})); */
1436 | DEFS
'(' CLASSNAME
')'
1438 tree interface
= lookup_interface
($3);
1441 $$
= get_class_ivars
(interface
);
1444 error ("Cannot find interface declaration for `%s'",
1445 IDENTIFIER_POINTER
($3));
1451 /* There is a shift-reduce conflict here, because `components' may
1452 start with a `typename'. It happens that shifting (the default resolution)
1453 does the right thing, because it treats the `typename' as part of
1454 a `typed_typespecs'.
1456 It is possible that this same technique would allow the distinction
1457 between `notype_initdecls' and `initdecls' to be eliminated.
1458 But I am being cautious and not trying it. */
1461 typed_typespecs setspecs components
1463 current_declspecs
= TREE_VALUE
(declspec_stack
);
1464 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
1465 declspec_stack
= TREE_CHAIN
(declspec_stack
);
1466 resume_momentary
($2); }
1469 pedwarn
("ANSI C forbids member declarations with no members");
1472 | nonempty_type_quals setspecs components
1474 current_declspecs
= TREE_VALUE
(declspec_stack
);
1475 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
1476 declspec_stack
= TREE_CHAIN
(declspec_stack
);
1477 resume_momentary
($2); }
1478 | nonempty_type_quals
1480 pedwarn
("ANSI C forbids member declarations with no members");
1485 | extension component_decl
1487 pedantic
= $
<itype
>1; }
1491 component_declarator
1492 | components
',' component_declarator
1493 { $$
= chainon
($1, $3); }
1496 component_declarator:
1497 save_filename save_lineno declarator maybe_attribute
1498 { $$
= grokfield
($1, $2, $3, current_declspecs
, NULL_TREE
);
1499 decl_attributes
($$
, $4, prefix_attributes
); }
1500 | save_filename save_lineno
1501 declarator
':' expr_no_commas maybe_attribute
1502 { $$
= grokfield
($1, $2, $3, current_declspecs
, $5);
1503 decl_attributes
($$
, $6, prefix_attributes
); }
1504 | save_filename save_lineno
':' expr_no_commas maybe_attribute
1505 { $$
= grokfield
($1, $2, NULL_TREE
, current_declspecs
, $4);
1506 decl_attributes
($$
, $5, prefix_attributes
); }
1509 /* We chain the enumerators in reverse order.
1510 They are put in forward order where enumlist is used.
1511 (The order used to be significant, but no longer is so.
1512 However, we still maintain the order, just to be clean.) */
1516 | enumlist
',' enumerator
1517 { if
($1 == error_mark_node
)
1520 $$
= chainon
($3, $1); }
1522 { $$
= error_mark_node
; }
1528 { $$
= build_enumerator
($1, NULL_TREE
); }
1529 | identifier
'=' expr_no_commas
1530 { $$
= build_enumerator
($1, $3); }
1534 typed_typespecs absdcl
1535 { $$
= build_tree_list
($1, $2); }
1536 | nonempty_type_quals absdcl
1537 { $$
= build_tree_list
($1, $2); }
1540 absdcl: /* an absolute declarator */
1546 nonempty_type_quals:
1548 { $$
= tree_cons
(NULL_TREE
, $1, NULL_TREE
); }
1549 | nonempty_type_quals TYPE_QUAL
1550 { $$
= tree_cons
(NULL_TREE
, $2, $1); }
1556 | type_quals TYPE_QUAL
1557 { $$
= tree_cons
(NULL_TREE
, $2, $1); }
1560 absdcl1: /* a nonempty absolute declarator */
1563 /* `(typedef)1' is `int'. */
1564 |
'*' type_quals absdcl1 %prec UNARY
1565 { $$
= make_pointer_declarator
($2, $3); }
1566 |
'*' type_quals %prec UNARY
1567 { $$
= make_pointer_declarator
($2, NULL_TREE
); }
1568 | absdcl1
'(' parmlist %prec
'.'
1569 { $$
= build_nt
(CALL_EXPR
, $1, $3, NULL_TREE
); }
1570 | absdcl1
'[' expr
']' %prec
'.'
1571 { $$
= build_nt
(ARRAY_REF
, $1, $3); }
1572 | absdcl1
'[' ']' %prec
'.'
1573 { $$
= build_nt
(ARRAY_REF
, $1, NULL_TREE
); }
1574 |
'(' parmlist %prec
'.'
1575 { $$
= build_nt
(CALL_EXPR
, NULL_TREE
, $2, NULL_TREE
); }
1576 |
'[' expr
']' %prec
'.'
1577 { $$
= build_nt
(ARRAY_REF
, NULL_TREE
, $2); }
1579 { $$
= build_nt
(ARRAY_REF
, NULL_TREE
, NULL_TREE
); }
1580 /* ??? It appears we have to support attributes here, however
1581 using prefix_attributes is wrong. */
1584 /* at least one statement, the first of which parses without error. */
1585 /* stmts is used only after decls, so an invalid first statement
1586 is actually regarded as an invalid decl and part of the decls. */
1589 lineno_stmt_or_labels
1592 pedwarn
("ANSI C forbids label at end of compound statement");
1596 lineno_stmt_or_labels:
1597 lineno_stmt_or_label
1598 | lineno_stmt_or_labels lineno_stmt_or_label
1600 | lineno_stmt_or_labels errstmt
1612 pushlevel: /* empty */
1613 { emit_line_note
(input_filename
, lineno
);
1617 expand_start_bindings
(0);
1618 if
(objc_method_context
)
1623 /* Read zero or more forward-declarations for labels
1624 that nested functions can jump to. */
1629 pedwarn
("ANSI C forbids label declarations"); }
1634 | label_decls label_decl
1638 LABEL identifiers_or_typenames
';'
1640 for
(link
= $2; link
; link
= TREE_CHAIN
(link
))
1642 tree label
= shadow_label
(TREE_VALUE
(link
));
1643 C_DECLARED_LABEL_FLAG
(label
) = 1;
1644 declare_nonlocal_label
(label
);
1649 /* This is the body of a function definition.
1650 It causes syntax errors to ignore to the next openbrace. */
1657 compstmt_start: '{' { compstmt_count
++; }
1659 compstmt: compstmt_start
'}'
1660 { $$
= convert
(void_type_node
, integer_zero_node
); }
1661 | compstmt_start pushlevel maybe_label_decls decls xstmts
'}'
1662 { emit_line_note
(input_filename
, lineno
);
1663 expand_end_bindings
(getdecls
(), 1, 0);
1664 $$
= poplevel
(1, 1, 0);
1665 if
(yychar == CONSTANT ||
yychar == STRING
)
1666 pop_momentary_nofree
();
1669 | compstmt_start pushlevel maybe_label_decls
error '}'
1670 { emit_line_note
(input_filename
, lineno
);
1671 expand_end_bindings
(getdecls
(), kept_level_p
(), 0);
1672 $$
= poplevel
(kept_level_p
(), 0, 0);
1673 if
(yychar == CONSTANT ||
yychar == STRING
)
1674 pop_momentary_nofree
();
1677 | compstmt_start pushlevel maybe_label_decls stmts
'}'
1678 { emit_line_note
(input_filename
, lineno
);
1679 expand_end_bindings
(getdecls
(), kept_level_p
(), 0);
1680 $$
= poplevel
(kept_level_p
(), 0, 0);
1681 if
(yychar == CONSTANT ||
yychar == STRING
)
1682 pop_momentary_nofree
();
1687 /* Value is number of statements counted as of the closeparen. */
1689 if_prefix lineno_labeled_stmt
1690 /* Make sure c_expand_end_cond is run once
1691 for each call to c_expand_start_cond.
1692 Otherwise a crash is likely. */
1698 { emit_line_note
($
<filename
>-1, $
<lineno
>0);
1699 c_expand_start_cond
(truthvalue_conversion
($3), 0,
1701 $
<itype
>$
= stmt_count
;
1702 if_stmt_file
= $
<filename
>-1;
1703 if_stmt_line
= $
<lineno
>0;
1704 position_after_white_space
(); }
1707 /* This is a subroutine of stmt.
1708 It is used twice, once for valid DO statements
1709 and once for catching errors in parsing the end test. */
1714 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1715 /* See comment in `while' alternative, above. */
1717 expand_start_loop_continue_elsewhere
(1);
1718 position_after_white_space
(); }
1719 lineno_labeled_stmt WHILE
1720 { expand_loop_continue_here
(); }
1724 { $$
= input_filename
; }
1731 lineno_labeled_stmt:
1732 save_filename save_lineno stmt
1734 /* | save_filename save_lineno error
1737 | save_filename save_lineno label lineno_labeled_stmt
1741 lineno_stmt_or_label:
1742 save_filename save_lineno stmt_or_label
1753 /* Parse a single real statement, not including any labels. */
1760 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1761 /* It appears that this should not be done--that a non-lvalue array
1762 shouldn't get an error if the value isn't used.
1763 Section 3.2.2.1 says that an array lvalue gets converted to a pointer
1764 if it appears as a top-level expression,
1765 but says nothing about non-lvalue arrays. */
1767 /* Call default_conversion to get an error
1768 on referring to a register array if pedantic. */
1769 if
(TREE_CODE
(TREE_TYPE
($1)) == ARRAY_TYPE
1770 || TREE_CODE
(TREE_TYPE
($1)) == FUNCTION_TYPE
)
1771 $1 = default_conversion
($1);
1773 iterator_expand
($1);
1774 clear_momentary
(); }
1776 { c_expand_start_else
();
1777 $
<itype
>1 = stmt_count
;
1778 position_after_white_space
(); }
1780 { c_expand_end_cond
();
1781 if
(extra_warnings
&& stmt_count
== $
<itype
>1)
1782 warning
("empty body in an else-statement"); }
1783 | simple_if %prec IF
1784 { c_expand_end_cond
();
1785 /* This warning is here instead of in simple_if, because we
1786 do not want a warning if an empty if is followed by an
1787 else statement. Increment stmt_count so we don't
1788 give a second error if this is a nested `if'. */
1789 if
(extra_warnings
&& stmt_count
++ == $
<itype
>1)
1790 warning_with_file_and_line
(if_stmt_file
, if_stmt_line
,
1791 "empty body in an if-statement"); }
1792 /* Make sure c_expand_end_cond is run once
1793 for each call to c_expand_start_cond.
1794 Otherwise a crash is likely. */
1795 | simple_if ELSE
error
1796 { c_expand_end_cond
(); }
1799 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1800 /* The emit_nop used to come before emit_line_note,
1801 but that made the nop seem like part of the preceding line.
1802 And that was confusing when the preceding line was
1803 inside of an if statement and was not really executed.
1804 I think it ought to work to put the nop after the line number.
1805 We will see. --rms, July 15, 1991. */
1808 { /* Don't start the loop till we have succeeded
1809 in parsing the end test. This is to make sure
1810 that we end every loop we start. */
1811 expand_start_loop
(1);
1812 emit_line_note
(input_filename
, lineno
);
1813 expand_exit_loop_if_false
(NULL_PTR
,
1814 truthvalue_conversion
($4));
1815 position_after_white_space
(); }
1817 { expand_end_loop
(); }
1820 { emit_line_note
(input_filename
, lineno
);
1821 expand_exit_loop_if_false
(NULL_PTR
,
1822 truthvalue_conversion
($3));
1824 clear_momentary
(); }
1825 /* This rule is needed to make sure we end every loop we start. */
1826 | do_stmt_start
error
1827 { expand_end_loop
();
1828 clear_momentary
(); }
1832 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1833 /* See comment in `while' alternative, above. */
1835 if
($3) c_expand_expr_stmt
($3);
1836 /* Next step is to call expand_start_loop_continue_elsewhere,
1837 but wait till after we parse the entire for (...).
1838 Otherwise, invalid input might cause us to call that
1839 fn without calling expand_end_loop. */
1842 /* Can't emit now; wait till after expand_start_loop... */
1843 { $
<lineno
>7 = lineno
;
1844 $
<filename
>$
= input_filename
; }
1847 /* Start the loop. Doing this after parsing
1848 all the expressions ensures we will end the loop. */
1849 expand_start_loop_continue_elsewhere
(1);
1850 /* Emit the end-test, with a line number. */
1851 emit_line_note
($
<filename
>8, $
<lineno
>7);
1853 expand_exit_loop_if_false
(NULL_PTR
,
1854 truthvalue_conversion
($6));
1855 /* Don't let the tree nodes for $9 be discarded by
1856 clear_momentary during the parsing of the next stmt. */
1858 $
<lineno
>7 = lineno
;
1859 $
<filename
>8 = input_filename
;
1860 position_after_white_space
(); }
1862 { /* Emit the increment expression, with a line number. */
1863 emit_line_note
($
<filename
>8, $
<lineno
>7);
1864 expand_loop_continue_here
();
1866 c_expand_expr_stmt
($9);
1867 if
(yychar == CONSTANT ||
yychar == STRING
)
1868 pop_momentary_nofree
();
1871 expand_end_loop
(); }
1872 | SWITCH
'(' expr
')'
1874 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1875 c_expand_start_case
($3);
1876 /* Don't let the tree nodes for $3 be discarded by
1877 clear_momentary during the parsing of the next stmt. */
1879 position_after_white_space
(); }
1881 { expand_end_case
($3);
1882 if
(yychar == CONSTANT ||
yychar == STRING
)
1883 pop_momentary_nofree
();
1888 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1889 if
( ! expand_exit_something
())
1890 error ("break statement not within loop or switch"); }
1893 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1894 if
(! expand_continue_loop
(NULL_PTR
))
1895 error ("continue statement not within a loop"); }
1898 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1899 c_expand_return
(NULL_TREE
); }
1902 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1903 c_expand_return
($2); }
1904 | ASM_KEYWORD maybe_type_qual
'(' expr
')' ';'
1906 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1908 if
((TREE_CODE
($4) == ADDR_EXPR
1909 && TREE_CODE
(TREE_OPERAND
($4, 0)) == STRING_CST
)
1910 || TREE_CODE
($4) == STRING_CST
)
1913 error ("argument of `asm' is not a constant string"); }
1914 /* This is the case with just output operands. */
1915 | ASM_KEYWORD maybe_type_qual
'(' expr
':' asm_operands
')' ';'
1917 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1918 c_expand_asm_operands
($4, $6, NULL_TREE
, NULL_TREE
,
1919 $2 == ridpointers
[(int)RID_VOLATILE
],
1920 input_filename
, lineno
); }
1921 /* This is the case with input operands as well. */
1922 | ASM_KEYWORD maybe_type_qual
'(' expr
':' asm_operands
':' asm_operands
')' ';'
1924 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1925 c_expand_asm_operands
($4, $6, $8, NULL_TREE
,
1926 $2 == ridpointers
[(int)RID_VOLATILE
],
1927 input_filename
, lineno
); }
1928 /* This is the case with clobbered registers as well. */
1929 | ASM_KEYWORD maybe_type_qual
'(' expr
':' asm_operands
':'
1930 asm_operands
':' asm_clobbers
')' ';'
1932 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1933 c_expand_asm_operands
($4, $6, $8, $10,
1934 $2 == ridpointers
[(int)RID_VOLATILE
],
1935 input_filename
, lineno
); }
1936 | GOTO identifier
';'
1939 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1940 decl
= lookup_label
($2);
1943 TREE_USED
(decl
) = 1;
1949 pedwarn
("ANSI C forbids `goto *expr;'");
1951 emit_line_note
($
<filename
>-1, $
<lineno
>0);
1952 expand_computed_goto
(convert
(ptr_type_node
, $3)); }
1957 all_iter_stmt_simple
1958 /* | all_iter_stmt_with_decl */
1961 all_iter_stmt_simple:
1964 /* The value returned by this action is */
1965 /* 1 if everything is OK */
1966 /* 0 in case of error or already bound iterator */
1969 if
(TREE_CODE
($3) != VAR_DECL
)
1970 error ("invalid `for (ITERATOR)' syntax");
1971 else if
(! ITERATOR_P
($3))
1972 error ("`%s' is not an iterator",
1973 IDENTIFIER_POINTER
(DECL_NAME
($3)));
1974 else if
(ITERATOR_BOUND_P
($3))
1975 error ("`for (%s)' inside expansion of same iterator",
1976 IDENTIFIER_POINTER
(DECL_NAME
($3)));
1980 iterator_for_loop_start
($3);
1986 iterator_for_loop_end
($3);
1989 /* This really should allow any kind of declaration,
1990 for generality. Fix it before turning it back on.
1992 all_iter_stmt_with_decl:
1993 FOR '(' ITERATOR pushlevel setspecs iterator_spec ')'
1995 */ /* The value returned by this action is */
1996 /* 1 if everything is OK */
1997 /* 0 in case of error or already bound iterator */
1999 iterator_for_loop_start ($6);
2003 iterator_for_loop_end ($6);
2004 emit_line_note (input_filename, lineno);
2005 expand_end_bindings (getdecls (), 1, 0);
2006 $<ttype>$ = poplevel (1, 1, 0);
2007 if (yychar == CONSTANT || yychar == STRING)
2008 pop_momentary_nofree ();
2014 /* Any kind of label, including jump labels and case labels.
2015 ANSI C accepts labels only before statements, but we allow them
2016 also at the end of a compound statement. */
2018 label: CASE expr_no_commas
':'
2019 { register tree value
= check_case_value
($2);
2021 = build_decl
(LABEL_DECL
, NULL_TREE
, NULL_TREE
);
2025 if
(value
!= error_mark_node
)
2030 if
(pedantic
&& ! INTEGRAL_TYPE_P
(TREE_TYPE
(value
)))
2031 pedwarn
("label must have integral type in ANSI C");
2033 success
= pushcase
(value
, convert_and_check
,
2037 error ("case label not within a switch statement");
2038 else if
(success
== 2)
2040 error ("duplicate case value");
2041 error_with_decl
(duplicate
, "this is the first entry for that value");
2043 else if
(success
== 3)
2044 warning
("case value out of range");
2045 else if
(success
== 5)
2046 error ("case label within scope of cleanup or variable array");
2048 position_after_white_space
(); }
2049 | CASE expr_no_commas ELLIPSIS expr_no_commas
':'
2050 { register tree value1
= check_case_value
($2);
2051 register tree value2
= check_case_value
($4);
2053 = build_decl
(LABEL_DECL
, NULL_TREE
, NULL_TREE
);
2056 pedwarn
("ANSI C forbids case ranges");
2059 if
(value1
!= error_mark_node
&& value2
!= error_mark_node
)
2062 int success
= pushcase_range
(value1
, value2
,
2063 convert_and_check
, label
,
2066 error ("case label not within a switch statement");
2067 else if
(success
== 2)
2069 error ("duplicate case value");
2070 error_with_decl
(duplicate
, "this is the first entry for that value");
2072 else if
(success
== 3)
2073 warning
("case value out of range");
2074 else if
(success
== 4)
2075 warning
("empty case range");
2076 else if
(success
== 5)
2077 error ("case label within scope of cleanup or variable array");
2079 position_after_white_space
(); }
2084 = build_decl
(LABEL_DECL
, NULL_TREE
, NULL_TREE
);
2085 int success
= pushcase
(NULL_TREE
, 0, label
, &duplicate
);
2088 error ("default label not within a switch statement");
2089 else if
(success
== 2)
2091 error ("multiple default labels in one switch");
2092 error_with_decl
(duplicate
, "this is the first default label");
2094 position_after_white_space
(); }
2096 { tree label
= define_label
(input_filename
, lineno
, $1);
2100 expand_label
(label
);
2101 position_after_white_space
(); }
2104 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
2108 { emit_line_note
(input_filename
, lineno
);
2111 { emit_line_note
(input_filename
, lineno
); }
2120 /* These are the operands other than the first string and colon
2121 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
2122 asm_operands: /* empty */
2124 | nonnull_asm_operands
2127 nonnull_asm_operands:
2129 | nonnull_asm_operands
',' asm_operand
2130 { $$
= chainon
($1, $3); }
2135 { $$
= build_tree_list
($1, $3); }
2140 { $$
= tree_cons
(NULL_TREE
, combine_strings
($1), NULL_TREE
); }
2141 | asm_clobbers
',' string
2142 { $$
= tree_cons
(NULL_TREE
, combine_strings
($3), $1); }
2145 /* This is what appears inside the parens in a function declarator.
2146 Its value is a list of ..._TYPE nodes. */
2149 clear_parm_order
();
2150 declare_parm_level
(0); }
2153 parmlist_tags_warning
();
2154 poplevel
(0, 0, 0); }
2162 pedwarn
("ANSI C forbids forward parameter declarations");
2163 /* Mark the forward decls as such. */
2164 for
(parm
= getdecls
(); parm
; parm
= TREE_CHAIN
(parm
))
2165 TREE_ASM_WRITTEN
(parm
) = 1;
2166 clear_parm_order
(); }
2170 { $$
= tree_cons
(NULL_TREE
, NULL_TREE
, NULL_TREE
); }
2173 /* This is what appears inside the parens in a function declarator.
2174 Is value is represented in the format that grokdeclarator expects. */
2175 parmlist_2: /* empty */
2176 { $$
= get_parm_info
(0); }
2178 { $$
= get_parm_info
(0);
2179 /* Gcc used to allow this as an extension. However, it does
2180 not work for all targets, and thus has been disabled.
2181 Also, since func (...) and func () are indistinguishable,
2182 it caused problems with the code in expand_builtin which
2183 tries to verify that BUILT_IN_NEXT_ARG is being used
2185 error ("ANSI C requires a named argument before `...'");
2188 { $$
= get_parm_info
(1); }
2189 | parms
',' ELLIPSIS
2190 { $$
= get_parm_info
(0); }
2195 { push_parm_decl
($1); }
2197 { push_parm_decl
($3); }
2200 /* A single parameter declaration or parameter type name,
2201 as found in a parmlist. */
2203 typed_declspecs setspecs parm_declarator maybe_attribute
2204 { $$
= build_tree_list
(build_tree_list
(current_declspecs
,
2206 build_tree_list
(prefix_attributes
,
2208 current_declspecs
= TREE_VALUE
(declspec_stack
);
2209 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
2210 declspec_stack
= TREE_CHAIN
(declspec_stack
);
2211 resume_momentary
($2); }
2212 | typed_declspecs setspecs notype_declarator maybe_attribute
2213 { $$
= build_tree_list
(build_tree_list
(current_declspecs
,
2215 build_tree_list
(prefix_attributes
,
2217 current_declspecs
= TREE_VALUE
(declspec_stack
);
2218 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
2219 declspec_stack
= TREE_CHAIN
(declspec_stack
);
2220 resume_momentary
($2); }
2221 | typed_declspecs setspecs absdcl maybe_attribute
2222 { $$
= build_tree_list
(build_tree_list
(current_declspecs
,
2224 build_tree_list
(prefix_attributes
,
2226 current_declspecs
= TREE_VALUE
(declspec_stack
);
2227 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
2228 declspec_stack
= TREE_CHAIN
(declspec_stack
);
2229 resume_momentary
($2); }
2230 | declmods setspecs notype_declarator maybe_attribute
2231 { $$
= build_tree_list
(build_tree_list
(current_declspecs
,
2233 build_tree_list
(prefix_attributes
,
2235 current_declspecs
= TREE_VALUE
(declspec_stack
);
2236 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
2237 declspec_stack
= TREE_CHAIN
(declspec_stack
);
2238 resume_momentary
($2); }
2240 | declmods setspecs absdcl maybe_attribute
2241 { $$
= build_tree_list
(build_tree_list
(current_declspecs
,
2243 build_tree_list
(prefix_attributes
,
2245 current_declspecs
= TREE_VALUE
(declspec_stack
);
2246 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
2247 declspec_stack
= TREE_CHAIN
(declspec_stack
);
2248 resume_momentary
($2); }
2251 /* This is used in a function definition
2252 where either a parmlist or an identifier list is ok.
2253 Its value is a list of ..._TYPE nodes or a list of identifiers. */
2254 parmlist_or_identifiers:
2256 clear_parm_order
();
2257 declare_parm_level
(1); }
2258 parmlist_or_identifiers_1
2260 parmlist_tags_warning
();
2261 poplevel
(0, 0, 0); }
2264 parmlist_or_identifiers_1:
2268 for
(t
= $1; t
; t
= TREE_CHAIN
(t
))
2269 if
(TREE_VALUE
(t
) == NULL_TREE
)
2270 error ("`...' in old-style identifier list");
2271 $$
= tree_cons
(NULL_TREE
, NULL_TREE
, $1); }
2274 /* A nonempty list of identifiers. */
2277 { $$
= build_tree_list
(NULL_TREE
, $1); }
2278 | identifiers
',' IDENTIFIER
2279 { $$
= chainon
($1, build_tree_list
(NULL_TREE
, $3)); }
2282 /* A nonempty list of identifiers, including typenames. */
2283 identifiers_or_typenames:
2285 { $$
= build_tree_list
(NULL_TREE
, $1); }
2286 | identifiers_or_typenames
',' identifier
2287 { $$
= chainon
($1, build_tree_list
(NULL_TREE
, $3)); }
2292 { $
<itype
>$
= pedantic
;
2296 /* Objective-C productions. */
2306 if
(objc_implementation_context
)
2308 finish_class
(objc_implementation_context
);
2309 objc_ivar_chain
= NULL_TREE
;
2310 objc_implementation_context
= NULL_TREE
;
2313 warning
("`@end' must appear in an implementation context");
2317 /* A nonempty list of identifiers. */
2320 { $$
= build_tree_list
(NULL_TREE
, $1); }
2321 | identifier_list
',' identifier
2322 { $$
= chainon
($1, build_tree_list
(NULL_TREE
, $3)); }
2326 CLASS identifier_list
';'
2328 objc_declare_class
($2);
2332 ALIAS identifier identifier
';'
2334 objc_declare_alias
($2, $3);
2338 INTERFACE identifier protocolrefs
'{'
2340 objc_interface_context
= objc_ivar_context
2341 = start_class
(CLASS_INTERFACE_TYPE
, $2, NULL_TREE
, $3);
2342 objc_public_flag
= 0;
2346 continue_class
(objc_interface_context
);
2351 finish_class
(objc_interface_context
);
2352 objc_interface_context
= NULL_TREE
;
2355 | INTERFACE identifier protocolrefs
2357 objc_interface_context
2358 = start_class
(CLASS_INTERFACE_TYPE
, $2, NULL_TREE
, $3);
2359 continue_class
(objc_interface_context
);
2364 finish_class
(objc_interface_context
);
2365 objc_interface_context
= NULL_TREE
;
2368 | INTERFACE identifier
':' identifier protocolrefs
'{'
2370 objc_interface_context
= objc_ivar_context
2371 = start_class
(CLASS_INTERFACE_TYPE
, $2, $4, $5);
2372 objc_public_flag
= 0;
2376 continue_class
(objc_interface_context
);
2381 finish_class
(objc_interface_context
);
2382 objc_interface_context
= NULL_TREE
;
2385 | INTERFACE identifier
':' identifier protocolrefs
2387 objc_interface_context
2388 = start_class
(CLASS_INTERFACE_TYPE
, $2, $4, $5);
2389 continue_class
(objc_interface_context
);
2394 finish_class
(objc_interface_context
);
2395 objc_interface_context
= NULL_TREE
;
2398 | IMPLEMENTATION identifier
'{'
2400 objc_implementation_context
= objc_ivar_context
2401 = start_class
(CLASS_IMPLEMENTATION_TYPE
, $2, NULL_TREE
, NULL_TREE
);
2402 objc_public_flag
= 0;
2407 = continue_class
(objc_implementation_context
);
2410 | IMPLEMENTATION identifier
2412 objc_implementation_context
2413 = start_class
(CLASS_IMPLEMENTATION_TYPE
, $2, NULL_TREE
, NULL_TREE
);
2415 = continue_class
(objc_implementation_context
);
2418 | IMPLEMENTATION identifier
':' identifier
'{'
2420 objc_implementation_context
= objc_ivar_context
2421 = start_class
(CLASS_IMPLEMENTATION_TYPE
, $2, $4, NULL_TREE
);
2422 objc_public_flag
= 0;
2427 = continue_class
(objc_implementation_context
);
2430 | IMPLEMENTATION identifier
':' identifier
2432 objc_implementation_context
2433 = start_class
(CLASS_IMPLEMENTATION_TYPE
, $2, $4, NULL_TREE
);
2435 = continue_class
(objc_implementation_context
);
2438 | INTERFACE identifier
'(' identifier
')' protocolrefs
2440 objc_interface_context
2441 = start_class
(CATEGORY_INTERFACE_TYPE
, $2, $4, $6);
2442 continue_class
(objc_interface_context
);
2447 finish_class
(objc_interface_context
);
2448 objc_interface_context
= NULL_TREE
;
2451 | IMPLEMENTATION identifier
'(' identifier
')'
2453 objc_implementation_context
2454 = start_class
(CATEGORY_IMPLEMENTATION_TYPE
, $2, $4, NULL_TREE
);
2456 = continue_class
(objc_implementation_context
);
2461 PROTOCOL identifier protocolrefs
2463 remember_protocol_qualifiers
();
2464 objc_interface_context
2465 = start_protocol
(PROTOCOL_INTERFACE_TYPE
, $2, $3);
2469 forget_protocol_qualifiers
();
2470 finish_protocol
(objc_interface_context
);
2471 objc_interface_context
= NULL_TREE
;
2480 | non_empty_protocolrefs
2483 non_empty_protocolrefs:
2484 ARITHCOMPARE identifier_list ARITHCOMPARE
2486 if
($1 == LT_EXPR
&& $3 == GT_EXPR
)
2494 ivar_decl_list visibility_spec ivar_decls
2499 PRIVATE
{ objc_public_flag
= 2; }
2500 | PROTECTED
{ objc_public_flag
= 0; }
2501 | PUBLIC
{ objc_public_flag
= 1; }
2509 | ivar_decls ivar_decl
';'
2513 pedwarn
("extra semicolon in struct or union specified");
2518 /* There is a shift-reduce conflict here, because `components' may
2519 start with a `typename'. It happens that shifting (the default resolution)
2520 does the right thing, because it treats the `typename' as part of
2521 a `typed_typespecs'.
2523 It is possible that this same technique would allow the distinction
2524 between `notype_initdecls' and `initdecls' to be eliminated.
2525 But I am being cautious and not trying it. */
2528 typed_typespecs setspecs ivars
2530 current_declspecs
= TREE_VALUE
(declspec_stack
);
2531 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
2532 declspec_stack
= TREE_CHAIN
(declspec_stack
);
2533 resume_momentary
($2); }
2534 | nonempty_type_quals setspecs ivars
2536 current_declspecs
= TREE_VALUE
(declspec_stack
);
2537 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
2538 declspec_stack
= TREE_CHAIN
(declspec_stack
);
2539 resume_momentary
($2); }
2548 | ivars
',' ivar_declarator
2554 $$
= add_instance_variable
(objc_ivar_context
,
2556 $1, current_declspecs
,
2559 | declarator
':' expr_no_commas
2561 $$
= add_instance_variable
(objc_ivar_context
,
2563 $1, current_declspecs
, $3);
2565 |
':' expr_no_commas
2567 $$
= add_instance_variable
(objc_ivar_context
,
2570 current_declspecs
, $2);
2577 remember_protocol_qualifiers
();
2578 if
(objc_implementation_context
)
2579 objc_inherit_code
= CLASS_METHOD_DECL
;
2581 fatal
("method definition not in class context");
2585 forget_protocol_qualifiers
();
2586 add_class_method
(objc_implementation_context
, $3);
2587 start_method_def
($3);
2588 objc_method_context
= $3;
2592 continue_method_def
();
2596 finish_method_def
();
2597 objc_method_context
= NULL_TREE
;
2602 remember_protocol_qualifiers
();
2603 if
(objc_implementation_context
)
2604 objc_inherit_code
= INSTANCE_METHOD_DECL
;
2606 fatal
("method definition not in class context");
2610 forget_protocol_qualifiers
();
2611 add_instance_method
(objc_implementation_context
, $3);
2612 start_method_def
($3);
2613 objc_method_context
= $3;
2617 continue_method_def
();
2621 finish_method_def
();
2622 objc_method_context
= NULL_TREE
;
2626 /* the reason for the strange actions in this rule
2627 is so that notype_initdecls when reached via datadef
2628 can find a valid list of type and sc specs in $0. */
2632 |
{$
<ttype
>$
= NULL_TREE
; } methodprotolist2
2635 methodprotolist2: /* eliminates a shift/reduce conflict */
2638 | methodprotolist2 methodproto
2639 | methodprotolist2
{$
<ttype
>$
= NULL_TREE
; } datadef
2650 /* Remember protocol qualifiers in prototypes. */
2651 remember_protocol_qualifiers
();
2652 objc_inherit_code
= CLASS_METHOD_DECL
;
2656 /* Forget protocol qualifiers here. */
2657 forget_protocol_qualifiers
();
2658 add_class_method
(objc_interface_context
, $3);
2664 /* Remember protocol qualifiers in prototypes. */
2665 remember_protocol_qualifiers
();
2666 objc_inherit_code
= INSTANCE_METHOD_DECL
;
2670 /* Forget protocol qualifiers here. */
2671 forget_protocol_qualifiers
();
2672 add_instance_method
(objc_interface_context
, $3);
2678 '(' typename
')' unaryselector
2680 $$
= build_method_decl
(objc_inherit_code
, $2, $4, NULL_TREE
);
2685 $$
= build_method_decl
(objc_inherit_code
, NULL_TREE
, $1, NULL_TREE
);
2688 |
'(' typename
')' keywordselector optparmlist
2690 $$
= build_method_decl
(objc_inherit_code
, $2, $4, $5);
2693 | keywordselector optparmlist
2695 $$
= build_method_decl
(objc_inherit_code
, NULL_TREE
, $1, $2);
2699 /* "optarglist" assumes that start_method_def has already been called...
2700 if it is not, the "xdecls" will not be placed in the proper scope */
2707 /* to get around the following situation: "int foo (int a) int b; {}" that
2708 is synthesized when parsing "- a:a b:b; id c; id d; { ... }" */
2723 typed_declspecs setspecs myparms
';'
2724 { current_declspecs
= TREE_VALUE
(declspec_stack
);
2725 prefix_attributes
= TREE_PURPOSE
(declspec_stack
);
2726 declspec_stack
= TREE_CHAIN
(declspec_stack
);
2727 resume_momentary
($2); }
2728 | typed_declspecs
';'
2729 { shadow_tag
($1); }
2731 { pedwarn
("empty declaration"); }
2736 { push_parm_decl
($1); }
2737 | myparms
',' myparm
2738 { push_parm_decl
($3); }
2741 /* A single parameter declaration or parameter type name,
2742 as found in a parmlist. DOES NOT ALLOW AN INITIALIZER OR ASMSPEC */
2745 parm_declarator maybe_attribute
2746 { $$
= build_tree_list
(build_tree_list
(current_declspecs
,
2748 build_tree_list
(prefix_attributes
,
2750 | notype_declarator maybe_attribute
2751 { $$
= build_tree_list
(build_tree_list
(current_declspecs
,
2753 build_tree_list
(prefix_attributes
,
2755 | absdcl maybe_attribute
2756 { $$
= build_tree_list
(build_tree_list
(current_declspecs
,
2758 build_tree_list
(prefix_attributes
,
2769 /* oh what a kludge! */
2778 /* returns a tree list node generated by get_parm_info */
2791 | keywordselector keyworddecl
2793 $$
= chainon
($1, $2);
2805 ENUM
{ $$
= get_identifier
(token_buffer
); }
2806 | STRUCT
{ $$
= get_identifier
(token_buffer
); }
2807 | UNION
{ $$
= get_identifier
(token_buffer
); }
2808 | IF
{ $$
= get_identifier
(token_buffer
); }
2809 | ELSE
{ $$
= get_identifier
(token_buffer
); }
2810 | WHILE
{ $$
= get_identifier
(token_buffer
); }
2811 | DO
{ $$
= get_identifier
(token_buffer
); }
2812 | FOR
{ $$
= get_identifier
(token_buffer
); }
2813 | SWITCH
{ $$
= get_identifier
(token_buffer
); }
2814 | CASE
{ $$
= get_identifier
(token_buffer
); }
2815 | DEFAULT
{ $$
= get_identifier
(token_buffer
); }
2816 | BREAK
{ $$
= get_identifier
(token_buffer
); }
2817 | CONTINUE
{ $$
= get_identifier
(token_buffer
); }
2818 | RETURN
{ $$
= get_identifier
(token_buffer
); }
2819 | GOTO
{ $$
= get_identifier
(token_buffer
); }
2820 | ASM_KEYWORD
{ $$
= get_identifier
(token_buffer
); }
2821 | SIZEOF
{ $$
= get_identifier
(token_buffer
); }
2822 | TYPEOF
{ $$
= get_identifier
(token_buffer
); }
2823 | ALIGNOF
{ $$
= get_identifier
(token_buffer
); }
2824 | TYPESPEC | TYPE_QUAL
2828 selector
':' '(' typename
')' identifier
2830 $$
= build_keyword_decl
($1, $4, $6);
2833 | selector
':' identifier
2835 $$
= build_keyword_decl
($1, NULL_TREE
, $3);
2838 |
':' '(' typename
')' identifier
2840 $$
= build_keyword_decl
(NULL_TREE
, $3, $5);
2845 $$
= build_keyword_decl
(NULL_TREE
, NULL_TREE
, $2);
2856 | keywordarglist keywordarg
2858 $$
= chainon
($1, $2);
2866 if
(TREE_CHAIN
($1) == NULL_TREE
)
2867 /* just return the expr., remove a level of indirection */
2868 $$
= TREE_VALUE
($1);
2870 /* we have a comma expr., we will collapse later */
2876 selector
':' keywordexpr
2878 $$
= build_tree_list
($1, $3);
2882 $$
= build_tree_list
(NULL_TREE
, $2);
2890 $$
= get_class_reference
($1);
2896 { objc_receiver_context
= 1; }
2898 { objc_receiver_context
= 0; }
2901 $$
= build_tree_list
($3, $5);
2912 | keywordnamelist keywordname
2914 $$
= chainon
($1, $2);
2921 $$
= build_tree_list
($1, NULL_TREE
);
2925 $$
= build_tree_list
(NULL_TREE
, NULL_TREE
);
2930 SELECTOR
'(' selectorarg
')'
2937 PROTOCOL
'(' identifier
')'
2943 /* extension to support C-structures in the archiver */
2946 ENCODE
'(' typename
')'
2948 $$
= groktypename
($3);