Import final gcc2 snapshot (990109)
[official-gcc.git] / gcc / c-parse.y
bloba10582b4376fa5c62f31b04b694b324a1e435c6f
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)
10 any later version.
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. */
31 %expect 46
33 /* These are the 23 conflicts you should get in parse.output;
34 the state numbers may vary if minor changes in the grammar are made.
36 State 42 contains 1 shift/reduce conflict. (Two ways to parse ATTRIBUTE.)
37 State 44 contains 1 shift/reduce conflict. (Two ways to recover from error.)
38 State 103 contains 1 shift/reduce conflict. (Two ways to recover from error.)
39 State 110 contains 1 shift/reduce conflict. (Two ways to parse ATTRIBUTE.)
40 State 111 contains 1 shift/reduce conflict. (Two ways to recover from error.)
41 State 115 contains 1 shift/reduce conflict. (Two ways to recover from error.)
42 State 132 contains 1 shift/reduce conflict. (See comment at component_decl.)
43 State 180 contains 1 shift/reduce conflict. (Two ways to parse ATTRIBUTE.)
44 State 194 contains 2 shift/reduce conflict. (Four ways to parse this.)
45 State 202 contains 1 shift/reduce conflict. (Two ways to recover from error.)
46 State 214 contains 1 shift/reduce conflict. (Two ways to recover from error.)
47 State 220 contains 1 shift/reduce conflict. (Two ways to recover from error.)
48 State 304 contains 2 shift/reduce conflicts. (Four ways to parse this.)
49 State 335 contains 2 shift/reduce conflicts. (Four ways to parse this.)
50 State 347 contains 1 shift/reduce conflict. (Two ways to parse ATTRIBUTES.)
51 State 352 contains 1 shift/reduce conflict. (Two ways to parse ATTRIBUTES.)
52 State 383 contains 2 shift/reduce conflicts. (Four ways to parse this.)
53 State 434 contains 2 shift/reduce conflicts. (Four ways to parse this.) */
57 #include "config.h"
58 #include "system.h"
59 #include <setjmp.h>
60 #include "tree.h"
61 #include "input.h"
62 #include "c-lex.h"
63 #include "c-tree.h"
64 #include "flags.h"
66 #ifdef MULTIBYTE_CHARS
67 #include <stdlib.h>
68 #include <locale.h>
69 #endif
72 /* Since parsers are distinct for each language, put the language string
73 definition here. */
74 char *language_string = "GNU C";
76 #ifndef errno
77 extern int errno;
78 #endif
80 void yyerror ();
82 /* Like YYERROR but do call yyerror. */
83 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
85 /* Cause the `yydebug' variable to be defined. */
86 #define YYDEBUG 1
89 %start program
91 %union {long itype; tree ttype; enum tree_code code;
92 char *filename; int lineno; int ends_in_label; }
94 /* All identifiers that are not reserved words
95 and are not declared typedefs in the current block */
96 %token IDENTIFIER
98 /* All identifiers that are declared typedefs in the current block.
99 In some contexts, they are treated just like IDENTIFIER,
100 but they can also serve as typespecs in declarations. */
101 %token TYPENAME
103 /* Reserved words that specify storage class.
104 yylval contains an IDENTIFIER_NODE which indicates which one. */
105 %token SCSPEC
107 /* Reserved words that specify type.
108 yylval contains an IDENTIFIER_NODE which indicates which one. */
109 %token TYPESPEC
111 /* Reserved words that qualify type: "const" or "volatile".
112 yylval contains an IDENTIFIER_NODE which indicates which one. */
113 %token TYPE_QUAL
115 /* Character or numeric constants.
116 yylval is the node for the constant. */
117 %token CONSTANT
119 /* String constants in raw form.
120 yylval is a STRING_CST node. */
121 %token STRING
123 /* "...", used for functions with variable arglists. */
124 %token ELLIPSIS
126 /* the reserved words */
127 /* SCO include files test "ASM", so use something else. */
128 %token SIZEOF ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
129 %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD TYPEOF ALIGNOF
130 %token ATTRIBUTE EXTENSION LABEL
131 %token REALPART IMAGPART
133 /* Add precedence rules to solve dangling else s/r conflict */
134 %nonassoc IF
135 %nonassoc ELSE
137 /* Define the operator tokens and their precedences.
138 The value is an integer because, if used, it is the tree code
139 to use in the expression made from the operator. */
141 %right <code> ASSIGN '='
142 %right <code> '?' ':'
143 %left <code> OROR
144 %left <code> ANDAND
145 %left <code> '|'
146 %left <code> '^'
147 %left <code> '&'
148 %left <code> EQCOMPARE
149 %left <code> ARITHCOMPARE
150 %left <code> LSHIFT RSHIFT
151 %left <code> '+' '-'
152 %left <code> '*' '/' '%'
153 %right <code> UNARY PLUSPLUS MINUSMINUS
154 %left HYPERUNARY
155 %left <code> POINTSAT '.' '(' '['
157 /* The Objective-C keywords. These are included in C and in
158 Objective C, so that the token codes are the same in both. */
159 %token INTERFACE IMPLEMENTATION END SELECTOR DEFS ENCODE
160 %token CLASSNAME PUBLIC PRIVATE PROTECTED PROTOCOL OBJECTNAME CLASS ALIAS
162 /* Objective-C string constants in raw form.
163 yylval is an OBJC_STRING_CST node. */
164 %token OBJC_STRING
167 %type <code> unop
169 %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist exprlist
170 %type <ttype> expr_no_commas cast_expr unary_expr primary string STRING
171 %type <ttype> typed_declspecs reserved_declspecs
172 %type <ttype> typed_typespecs reserved_typespecquals
173 %type <ttype> declmods typespec typespecqual_reserved
174 %type <ttype> typed_declspecs_no_prefix_attr reserved_declspecs_no_prefix_attr
175 %type <ttype> declmods_no_prefix_attr
176 %type <ttype> SCSPEC TYPESPEC TYPE_QUAL nonempty_type_quals maybe_type_qual
177 %type <ttype> initdecls notype_initdecls initdcl notype_initdcl
178 %type <ttype> init maybeasm
179 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
180 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
181 %type <ttype> any_word
183 %type <ttype> compstmt
185 %type <ttype> declarator
186 %type <ttype> notype_declarator after_type_declarator
187 %type <ttype> parm_declarator
189 %type <ttype> structsp component_decl_list component_decl_list2
190 %type <ttype> component_decl components component_declarator
191 %type <ttype> enumlist enumerator
192 %type <ttype> typename absdcl absdcl1 type_quals
193 %type <ttype> xexpr parms parm identifiers
195 %type <ttype> parmlist parmlist_1 parmlist_2
196 %type <ttype> parmlist_or_identifiers parmlist_or_identifiers_1
197 %type <ttype> identifiers_or_typenames
199 %type <itype> setspecs
201 %type <ends_in_label> lineno_stmt_or_label lineno_stmt_or_labels stmt_or_label
203 %type <filename> save_filename
204 %type <lineno> save_lineno
208 /* Number of statements (loosely speaking) and compound statements
209 seen so far. */
210 static int stmt_count;
211 static int compstmt_count;
213 /* Input file and line number of the end of the body of last simple_if;
214 used by the stmt-rule immediately after simple_if returns. */
215 static char *if_stmt_file;
216 static int if_stmt_line;
218 /* List of types and structure classes of the current declaration. */
219 static tree current_declspecs = NULL_TREE;
220 static tree prefix_attributes = NULL_TREE;
222 /* Stack of saved values of current_declspecs and prefix_attributes. */
223 static tree declspec_stack;
225 /* 1 if we explained undeclared var errors. */
226 static int undeclared_variable_notice;
229 /* Tell yyparse how to print a token's value, if yydebug is set. */
231 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
232 extern void yyprint ();
236 program: /* empty */
237 { if (pedantic)
238 pedwarn ("ANSI C forbids an empty source file");
239 finish_file ();
241 | extdefs
243 /* In case there were missing closebraces,
244 get us back to the global binding level. */
245 while (! global_bindings_p ())
246 poplevel (0, 0, 0);
247 finish_file ();
251 /* the reason for the strange actions in this rule
252 is so that notype_initdecls when reached via datadef
253 can find a valid list of type and sc specs in $0. */
255 extdefs:
256 {$<ttype>$ = NULL_TREE; } extdef
257 | extdefs {$<ttype>$ = NULL_TREE; } extdef
260 extdef:
261 fndef
262 | datadef
263 | ASM_KEYWORD '(' expr ')' ';'
264 { STRIP_NOPS ($3);
265 if ((TREE_CODE ($3) == ADDR_EXPR
266 && TREE_CODE (TREE_OPERAND ($3, 0)) == STRING_CST)
267 || TREE_CODE ($3) == STRING_CST)
268 assemble_asm ($3);
269 else
270 error ("argument of `asm' is not a constant string"); }
271 | extension extdef
272 { pedantic = $<itype>1; }
275 datadef:
276 setspecs notype_initdecls ';'
277 { if (pedantic)
278 error ("ANSI C forbids data definition with no type or storage class");
279 else if (!flag_traditional)
280 warning ("data definition has no type or storage class");
282 current_declspecs = TREE_VALUE (declspec_stack);
283 prefix_attributes = TREE_PURPOSE (declspec_stack);
284 declspec_stack = TREE_CHAIN (declspec_stack);
285 resume_momentary ($1); }
286 | declmods setspecs notype_initdecls ';'
287 { current_declspecs = TREE_VALUE (declspec_stack);
288 prefix_attributes = TREE_PURPOSE (declspec_stack);
289 declspec_stack = TREE_CHAIN (declspec_stack);
290 resume_momentary ($2); }
291 | typed_declspecs setspecs initdecls ';'
292 { current_declspecs = TREE_VALUE (declspec_stack);
293 prefix_attributes = TREE_PURPOSE (declspec_stack);
294 declspec_stack = TREE_CHAIN (declspec_stack);
295 resume_momentary ($2); }
296 | declmods ';'
297 { pedwarn ("empty declaration"); }
298 | typed_declspecs ';'
299 { shadow_tag ($1); }
300 | error ';'
301 | error '}'
302 | ';'
303 { if (pedantic)
304 pedwarn ("ANSI C does not allow extra `;' outside of a function"); }
307 fndef:
308 typed_declspecs setspecs declarator
309 { if (! start_function (current_declspecs, $3,
310 prefix_attributes, NULL_TREE, 0))
311 YYERROR1;
312 reinit_parse_for_function (); }
313 old_style_parm_decls
314 { store_parm_decls (); }
315 compstmt_or_error
316 { finish_function (0);
317 current_declspecs = TREE_VALUE (declspec_stack);
318 prefix_attributes = TREE_PURPOSE (declspec_stack);
319 declspec_stack = TREE_CHAIN (declspec_stack);
320 resume_momentary ($2); }
321 | typed_declspecs setspecs declarator error
322 { current_declspecs = TREE_VALUE (declspec_stack);
323 prefix_attributes = TREE_PURPOSE (declspec_stack);
324 declspec_stack = TREE_CHAIN (declspec_stack);
325 resume_momentary ($2); }
326 | declmods setspecs notype_declarator
327 { if (! start_function (current_declspecs, $3,
328 prefix_attributes, NULL_TREE, 0))
329 YYERROR1;
330 reinit_parse_for_function (); }
331 old_style_parm_decls
332 { store_parm_decls (); }
333 compstmt_or_error
334 { finish_function (0);
335 current_declspecs = TREE_VALUE (declspec_stack);
336 prefix_attributes = TREE_PURPOSE (declspec_stack);
337 declspec_stack = TREE_CHAIN (declspec_stack);
338 resume_momentary ($2); }
339 | declmods setspecs notype_declarator error
340 { current_declspecs = TREE_VALUE (declspec_stack);
341 prefix_attributes = TREE_PURPOSE (declspec_stack);
342 declspec_stack = TREE_CHAIN (declspec_stack);
343 resume_momentary ($2); }
344 | setspecs notype_declarator
345 { if (! start_function (NULL_TREE, $2,
346 prefix_attributes, NULL_TREE, 0))
347 YYERROR1;
348 reinit_parse_for_function (); }
349 old_style_parm_decls
350 { store_parm_decls (); }
351 compstmt_or_error
352 { finish_function (0);
353 current_declspecs = TREE_VALUE (declspec_stack);
354 prefix_attributes = TREE_PURPOSE (declspec_stack);
355 declspec_stack = TREE_CHAIN (declspec_stack);
356 resume_momentary ($1); }
357 | setspecs notype_declarator error
358 { current_declspecs = TREE_VALUE (declspec_stack);
359 prefix_attributes = TREE_PURPOSE (declspec_stack);
360 declspec_stack = TREE_CHAIN (declspec_stack);
361 resume_momentary ($1); }
364 identifier:
365 IDENTIFIER
366 | TYPENAME
369 unop: '&'
370 { $$ = ADDR_EXPR; }
371 | '-'
372 { $$ = NEGATE_EXPR; }
373 | '+'
374 { $$ = CONVERT_EXPR; }
375 | PLUSPLUS
376 { $$ = PREINCREMENT_EXPR; }
377 | MINUSMINUS
378 { $$ = PREDECREMENT_EXPR; }
379 | '~'
380 { $$ = BIT_NOT_EXPR; }
381 | '!'
382 { $$ = TRUTH_NOT_EXPR; }
385 expr: nonnull_exprlist
386 { $$ = build_compound_expr ($1); }
389 exprlist:
390 /* empty */
391 { $$ = NULL_TREE; }
392 | nonnull_exprlist
395 nonnull_exprlist:
396 expr_no_commas
397 { $$ = build_tree_list (NULL_TREE, $1); }
398 | nonnull_exprlist ',' expr_no_commas
399 { chainon ($1, build_tree_list (NULL_TREE, $3)); }
402 unary_expr:
403 primary
404 | '*' cast_expr %prec UNARY
405 { $$ = build_indirect_ref ($2, "unary *"); }
406 /* __extension__ turns off -pedantic for following primary. */
407 | extension cast_expr %prec UNARY
408 { $$ = $2;
409 pedantic = $<itype>1; }
410 | unop cast_expr %prec UNARY
411 { $$ = build_unary_op ($1, $2, 0);
412 overflow_warning ($$); }
413 /* Refer to the address of a label as a pointer. */
414 | ANDAND identifier
415 { tree label = lookup_label ($2);
416 if (pedantic)
417 pedwarn ("ANSI C forbids `&&'");
418 if (label == 0)
419 $$ = null_pointer_node;
420 else
422 TREE_USED (label) = 1;
423 $$ = build1 (ADDR_EXPR, ptr_type_node, label);
424 TREE_CONSTANT ($$) = 1;
427 /* This seems to be impossible on some machines, so let's turn it off.
428 You can use __builtin_next_arg to find the anonymous stack args.
429 | '&' ELLIPSIS
430 { tree types = TYPE_ARG_TYPES (TREE_TYPE (current_function_decl));
431 $$ = error_mark_node;
432 if (TREE_VALUE (tree_last (types)) == void_type_node)
433 error ("`&...' used in function with fixed number of arguments");
434 else
436 if (pedantic)
437 pedwarn ("ANSI C forbids `&...'");
438 $$ = tree_last (DECL_ARGUMENTS (current_function_decl));
439 $$ = build_unary_op (ADDR_EXPR, $$, 0);
442 | sizeof unary_expr %prec UNARY
443 { skip_evaluation--;
444 if (TREE_CODE ($2) == COMPONENT_REF
445 && DECL_C_BIT_FIELD (TREE_OPERAND ($2, 1)))
446 error ("`sizeof' applied to a bit-field");
447 $$ = c_sizeof (TREE_TYPE ($2)); }
448 | sizeof '(' typename ')' %prec HYPERUNARY
449 { skip_evaluation--;
450 $$ = c_sizeof (groktypename ($3)); }
451 | alignof unary_expr %prec UNARY
452 { skip_evaluation--;
453 $$ = c_alignof_expr ($2); }
454 | alignof '(' typename ')' %prec HYPERUNARY
455 { skip_evaluation--;
456 $$ = c_alignof (groktypename ($3)); }
457 | REALPART cast_expr %prec UNARY
458 { $$ = build_unary_op (REALPART_EXPR, $2, 0); }
459 | IMAGPART cast_expr %prec UNARY
460 { $$ = build_unary_op (IMAGPART_EXPR, $2, 0); }
463 sizeof:
464 SIZEOF { skip_evaluation++; }
467 alignof:
468 ALIGNOF { skip_evaluation++; }
471 cast_expr:
472 unary_expr
473 | '(' typename ')' cast_expr %prec UNARY
474 { tree type = groktypename ($2);
475 $$ = build_c_cast (type, $4); }
476 | '(' typename ')' '{'
477 { start_init (NULL_TREE, NULL, 0);
478 $2 = groktypename ($2);
479 really_start_incremental_init ($2); }
480 initlist_maybe_comma '}' %prec UNARY
481 { char *name;
482 tree result = pop_init_level (0);
483 tree type = $2;
484 finish_init ();
486 if (pedantic)
487 pedwarn ("ANSI C forbids constructor expressions");
488 if (TYPE_NAME (type) != 0)
490 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
491 name = IDENTIFIER_POINTER (TYPE_NAME (type));
492 else
493 name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
495 else
496 name = "";
497 $$ = result;
498 if (TREE_CODE (type) == ARRAY_TYPE && TYPE_SIZE (type) == 0)
500 int failure = complete_array_type (type, $$, 1);
501 if (failure)
502 abort ();
507 expr_no_commas:
508 cast_expr
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 '%' expr_no_commas
518 { $$ = parser_build_binary_op ($2, $1, $3); }
519 | expr_no_commas LSHIFT expr_no_commas
520 { $$ = parser_build_binary_op ($2, $1, $3); }
521 | expr_no_commas RSHIFT expr_no_commas
522 { $$ = parser_build_binary_op ($2, $1, $3); }
523 | expr_no_commas ARITHCOMPARE expr_no_commas
524 { $$ = parser_build_binary_op ($2, $1, $3); }
525 | expr_no_commas EQCOMPARE 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 '^' expr_no_commas
532 { $$ = parser_build_binary_op ($2, $1, $3); }
533 | expr_no_commas ANDAND
534 { $1 = truthvalue_conversion (default_conversion ($1));
535 skip_evaluation += $1 == boolean_false_node; }
536 expr_no_commas
537 { skip_evaluation -= $1 == boolean_false_node;
538 $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $4); }
539 | expr_no_commas OROR
540 { $1 = truthvalue_conversion (default_conversion ($1));
541 skip_evaluation += $1 == boolean_true_node; }
542 expr_no_commas
543 { skip_evaluation -= $1 == boolean_true_node;
544 $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $4); }
545 | expr_no_commas '?'
546 { $1 = truthvalue_conversion (default_conversion ($1));
547 skip_evaluation += $1 == boolean_false_node; }
548 expr ':'
549 { skip_evaluation += (($1 == boolean_true_node)
550 - ($1 == boolean_false_node)); }
551 expr_no_commas
552 { skip_evaluation -= $1 == boolean_true_node;
553 $$ = build_conditional_expr ($1, $4, $7); }
554 | expr_no_commas '?'
555 { if (pedantic)
556 pedwarn ("ANSI C forbids omitting the middle term of a ?: expression");
557 /* Make sure first operand is calculated only once. */
558 $<ttype>2 = save_expr ($1);
559 $1 = truthvalue_conversion (default_conversion ($<ttype>2));
560 skip_evaluation += $1 == boolean_true_node; }
561 ':' expr_no_commas
562 { skip_evaluation -= $1 == boolean_true_node;
563 $$ = build_conditional_expr ($1, $<ttype>2, $5); }
564 | expr_no_commas '=' expr_no_commas
565 { $$ = build_modify_expr ($1, NOP_EXPR, $3);
566 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
567 | expr_no_commas ASSIGN expr_no_commas
568 { $$ = build_modify_expr ($1, $2, $3);
569 /* This inhibits warnings in truthvalue_conversion. */
570 C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK); }
573 primary:
574 IDENTIFIER
576 $$ = lastiddecl;
577 if (!$$ || $$ == error_mark_node)
579 if (yychar == YYEMPTY)
580 yychar = YYLEX;
581 if (yychar == '(')
584 /* Ordinary implicit function declaration. */
585 $$ = implicitly_declare ($1);
586 assemble_external ($$);
587 TREE_USED ($$) = 1;
590 else if (current_function_decl == 0)
592 error ("`%s' undeclared here (not in a function)",
593 IDENTIFIER_POINTER ($1));
594 $$ = error_mark_node;
596 else
599 if (IDENTIFIER_GLOBAL_VALUE ($1) != error_mark_node
600 || IDENTIFIER_ERROR_LOCUS ($1) != current_function_decl)
602 error ("`%s' undeclared (first use in this function)",
603 IDENTIFIER_POINTER ($1));
605 if (! undeclared_variable_notice)
607 error ("(Each undeclared identifier is reported only once");
608 error ("for each function it appears in.)");
609 undeclared_variable_notice = 1;
612 $$ = error_mark_node;
613 /* Prevent repeated error messages. */
614 IDENTIFIER_GLOBAL_VALUE ($1) = error_mark_node;
615 IDENTIFIER_ERROR_LOCUS ($1) = current_function_decl;
619 else if (TREE_TYPE ($$) == error_mark_node)
620 $$ = error_mark_node;
621 else if (C_DECL_ANTICIPATED ($$))
623 /* The first time we see a build-in function used,
624 if it has not been declared. */
625 C_DECL_ANTICIPATED ($$) = 0;
626 if (yychar == YYEMPTY)
627 yychar = YYLEX;
628 if (yychar == '(')
630 /* Omit the implicit declaration we
631 would ordinarily do, so we don't lose
632 the actual built in type.
633 But print a diagnostic for the mismatch. */
634 if (TREE_CODE ($$) != FUNCTION_DECL)
635 error ("`%s' implicitly declared as function",
636 IDENTIFIER_POINTER (DECL_NAME ($$)));
637 else if ((TYPE_MODE (TREE_TYPE (TREE_TYPE ($$)))
638 != TYPE_MODE (integer_type_node))
639 && (TREE_TYPE (TREE_TYPE ($$))
640 != void_type_node))
641 pedwarn ("type mismatch in implicit declaration for built-in function `%s'",
642 IDENTIFIER_POINTER (DECL_NAME ($$)));
643 /* If it really returns void, change that to int. */
644 if (TREE_TYPE (TREE_TYPE ($$)) == void_type_node)
645 TREE_TYPE ($$)
646 = build_function_type (integer_type_node,
647 TYPE_ARG_TYPES (TREE_TYPE ($$)));
649 else
650 pedwarn ("built-in function `%s' used without declaration",
651 IDENTIFIER_POINTER (DECL_NAME ($$)));
653 /* Do what we would ordinarily do when a fn is used. */
654 assemble_external ($$);
655 TREE_USED ($$) = 1;
657 else
659 assemble_external ($$);
660 TREE_USED ($$) = 1;
663 if (TREE_CODE ($$) == CONST_DECL)
665 $$ = DECL_INITIAL ($$);
666 /* This is to prevent an enum whose value is 0
667 from being considered a null pointer constant. */
668 $$ = build1 (NOP_EXPR, TREE_TYPE ($$), $$);
669 TREE_CONSTANT ($$) = 1;
672 | CONSTANT
673 | string
674 { $$ = combine_strings ($1); }
675 | '(' expr ')'
676 { char class = TREE_CODE_CLASS (TREE_CODE ($2));
677 if (class == 'e' || class == '1'
678 || class == '2' || class == '<')
679 C_SET_EXP_ORIGINAL_CODE ($2, ERROR_MARK);
680 $$ = $2; }
681 | '(' error ')'
682 { $$ = error_mark_node; }
683 | '('
684 { if (current_function_decl == 0)
686 error ("braced-group within expression allowed only inside a function");
687 YYERROR;
689 /* We must force a BLOCK for this level
690 so that, if it is not expanded later,
691 there is a way to turn off the entire subtree of blocks
692 that are contained in it. */
693 keep_next_level ();
694 push_iterator_stack ();
695 push_label_level ();
696 $<ttype>$ = expand_start_stmt_expr (); }
697 compstmt ')'
698 { tree rtl_exp;
699 if (pedantic)
700 pedwarn ("ANSI C forbids braced-groups within expressions");
701 pop_iterator_stack ();
702 pop_label_level ();
703 rtl_exp = expand_end_stmt_expr ($<ttype>2);
704 /* The statements have side effects, so the group does. */
705 TREE_SIDE_EFFECTS (rtl_exp) = 1;
707 if (TREE_CODE ($3) == BLOCK)
709 /* Make a BIND_EXPR for the BLOCK already made. */
710 $$ = build (BIND_EXPR, TREE_TYPE (rtl_exp),
711 NULL_TREE, rtl_exp, $3);
712 /* Remove the block from the tree at this point.
713 It gets put back at the proper place
714 when the BIND_EXPR is expanded. */
715 delete_block ($3);
717 else
718 $$ = $3;
720 | primary '(' exprlist ')' %prec '.'
721 { $$ = build_function_call ($1, $3); }
722 | primary '[' expr ']' %prec '.'
723 { $$ = build_array_ref ($1, $3); }
724 | primary '.' identifier
726 $$ = build_component_ref ($1, $3);
728 | primary POINTSAT identifier
730 tree expr = build_indirect_ref ($1, "->");
732 $$ = build_component_ref (expr, $3);
734 | primary PLUSPLUS
735 { $$ = build_unary_op (POSTINCREMENT_EXPR, $1, 0); }
736 | primary MINUSMINUS
737 { $$ = build_unary_op (POSTDECREMENT_EXPR, $1, 0); }
740 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
741 string:
742 STRING
743 | string STRING
744 { $$ = chainon ($1, $2); }
748 old_style_parm_decls:
749 /* empty */
750 | datadecls
751 | datadecls ELLIPSIS
752 /* ... is used here to indicate a varargs function. */
753 { c_mark_varargs ();
754 if (pedantic)
755 pedwarn ("ANSI C does not permit use of `varargs.h'"); }
758 /* The following are analogous to lineno_decl, decls and decl
759 except that they do not allow nested functions.
760 They are used for old-style parm decls. */
761 lineno_datadecl:
762 save_filename save_lineno datadecl
766 datadecls:
767 lineno_datadecl
768 | errstmt
769 | datadecls lineno_datadecl
770 | lineno_datadecl errstmt
773 /* We don't allow prefix attributes here because they cause reduce/reduce
774 conflicts: we can't know whether we're parsing a function decl with
775 attribute suffix, or function defn with attribute prefix on first old
776 style parm. */
777 datadecl:
778 typed_declspecs_no_prefix_attr setspecs initdecls ';'
779 { current_declspecs = TREE_VALUE (declspec_stack);
780 prefix_attributes = TREE_PURPOSE (declspec_stack);
781 declspec_stack = TREE_CHAIN (declspec_stack);
782 resume_momentary ($2); }
783 | declmods_no_prefix_attr setspecs notype_initdecls ';'
784 { current_declspecs = TREE_VALUE (declspec_stack);
785 prefix_attributes = TREE_PURPOSE (declspec_stack);
786 declspec_stack = TREE_CHAIN (declspec_stack);
787 resume_momentary ($2); }
788 | typed_declspecs_no_prefix_attr ';'
789 { shadow_tag_warned ($1, 1);
790 pedwarn ("empty declaration"); }
791 | declmods_no_prefix_attr ';'
792 { pedwarn ("empty declaration"); }
795 /* This combination which saves a lineno before a decl
796 is the normal thing to use, rather than decl itself.
797 This is to avoid shift/reduce conflicts in contexts
798 where statement labels are allowed. */
799 lineno_decl:
800 save_filename save_lineno decl
804 decls:
805 lineno_decl
806 | errstmt
807 | decls lineno_decl
808 | lineno_decl errstmt
811 /* records the type and storage class specs to use for processing
812 the declarators that follow.
813 Maintains a stack of outer-level values of current_declspecs,
814 for the sake of parm declarations nested in function declarators. */
815 setspecs: /* empty */
816 { $$ = suspend_momentary ();
817 pending_xref_error ();
818 declspec_stack = tree_cons (prefix_attributes,
819 current_declspecs,
820 declspec_stack);
821 split_specs_attrs ($<ttype>0,
822 &current_declspecs, &prefix_attributes); }
825 /* ??? Yuck. See after_type_declarator. */
826 setattrs: /* empty */
827 { prefix_attributes = chainon (prefix_attributes, $<ttype>0); }
830 decl:
831 typed_declspecs setspecs initdecls ';'
832 { current_declspecs = TREE_VALUE (declspec_stack);
833 prefix_attributes = TREE_PURPOSE (declspec_stack);
834 declspec_stack = TREE_CHAIN (declspec_stack);
835 resume_momentary ($2); }
836 | declmods setspecs notype_initdecls ';'
837 { current_declspecs = TREE_VALUE (declspec_stack);
838 prefix_attributes = TREE_PURPOSE (declspec_stack);
839 declspec_stack = TREE_CHAIN (declspec_stack);
840 resume_momentary ($2); }
841 | typed_declspecs setspecs nested_function
842 { current_declspecs = TREE_VALUE (declspec_stack);
843 prefix_attributes = TREE_PURPOSE (declspec_stack);
844 declspec_stack = TREE_CHAIN (declspec_stack);
845 resume_momentary ($2); }
846 | declmods setspecs notype_nested_function
847 { current_declspecs = TREE_VALUE (declspec_stack);
848 prefix_attributes = TREE_PURPOSE (declspec_stack);
849 declspec_stack = TREE_CHAIN (declspec_stack);
850 resume_momentary ($2); }
851 | typed_declspecs ';'
852 { shadow_tag ($1); }
853 | declmods ';'
854 { pedwarn ("empty declaration"); }
855 | extension decl
856 { pedantic = $<itype>1; }
859 /* Declspecs which contain at least one type specifier or typedef name.
860 (Just `const' or `volatile' is not enough.)
861 A typedef'd name following these is taken as a name to be declared.
862 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
864 typed_declspecs:
865 typespec reserved_declspecs
866 { $$ = tree_cons (NULL_TREE, $1, $2); }
867 | declmods typespec reserved_declspecs
868 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
871 reserved_declspecs: /* empty */
872 { $$ = NULL_TREE; }
873 | reserved_declspecs typespecqual_reserved
874 { $$ = tree_cons (NULL_TREE, $2, $1); }
875 | reserved_declspecs SCSPEC
876 { if (extra_warnings)
877 warning ("`%s' is not at beginning of declaration",
878 IDENTIFIER_POINTER ($2));
879 $$ = tree_cons (NULL_TREE, $2, $1); }
880 | reserved_declspecs attributes
881 { $$ = tree_cons ($2, NULL_TREE, $1); }
884 typed_declspecs_no_prefix_attr:
885 typespec reserved_declspecs_no_prefix_attr
886 { $$ = tree_cons (NULL_TREE, $1, $2); }
887 | declmods_no_prefix_attr typespec reserved_declspecs_no_prefix_attr
888 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
891 reserved_declspecs_no_prefix_attr:
892 /* empty */
893 { $$ = NULL_TREE; }
894 | reserved_declspecs_no_prefix_attr typespecqual_reserved
895 { $$ = tree_cons (NULL_TREE, $2, $1); }
896 | reserved_declspecs_no_prefix_attr SCSPEC
897 { if (extra_warnings)
898 warning ("`%s' is not at beginning of declaration",
899 IDENTIFIER_POINTER ($2));
900 $$ = tree_cons (NULL_TREE, $2, $1); }
903 /* List of just storage classes, type modifiers, and prefix attributes.
904 A declaration can start with just this, but then it cannot be used
905 to redeclare a typedef-name.
906 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
908 declmods:
909 declmods_no_prefix_attr
910 { $$ = $1; }
911 | attributes
912 { $$ = tree_cons ($1, NULL_TREE, NULL_TREE); }
913 | declmods declmods_no_prefix_attr
914 { $$ = chainon ($2, $1); }
915 | declmods attributes
916 { $$ = tree_cons ($2, NULL_TREE, $1); }
919 declmods_no_prefix_attr:
920 TYPE_QUAL
921 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
922 TREE_STATIC ($$) = 1; }
923 | SCSPEC
924 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
925 | declmods_no_prefix_attr TYPE_QUAL
926 { $$ = tree_cons (NULL_TREE, $2, $1);
927 TREE_STATIC ($$) = 1; }
928 | declmods_no_prefix_attr SCSPEC
929 { if (extra_warnings && TREE_STATIC ($1))
930 warning ("`%s' is not at beginning of declaration",
931 IDENTIFIER_POINTER ($2));
932 $$ = tree_cons (NULL_TREE, $2, $1);
933 TREE_STATIC ($$) = TREE_STATIC ($1); }
937 /* Used instead of declspecs where storage classes are not allowed
938 (that is, for typenames and structure components).
939 Don't accept a typedef-name if anything but a modifier precedes it. */
941 typed_typespecs:
942 typespec reserved_typespecquals
943 { $$ = tree_cons (NULL_TREE, $1, $2); }
944 | nonempty_type_quals typespec reserved_typespecquals
945 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
948 reserved_typespecquals: /* empty */
949 { $$ = NULL_TREE; }
950 | reserved_typespecquals typespecqual_reserved
951 { $$ = tree_cons (NULL_TREE, $2, $1); }
954 /* A typespec (but not a type qualifier).
955 Once we have seen one of these in a declaration,
956 if a typedef name appears then it is being redeclared. */
958 typespec: TYPESPEC
959 | structsp
960 | TYPENAME
961 { /* For a typedef name, record the meaning, not the name.
962 In case of `foo foo, bar;'. */
963 $$ = lookup_name ($1); }
964 | TYPEOF '(' expr ')'
965 { $$ = TREE_TYPE ($3); }
966 | TYPEOF '(' typename ')'
967 { $$ = groktypename ($3); }
970 /* A typespec that is a reserved word, or a type qualifier. */
972 typespecqual_reserved: TYPESPEC
973 | TYPE_QUAL
974 | structsp
977 initdecls:
978 initdcl
979 | initdecls ',' initdcl
982 notype_initdecls:
983 notype_initdcl
984 | notype_initdecls ',' initdcl
987 maybeasm:
988 /* empty */
989 { $$ = NULL_TREE; }
990 | ASM_KEYWORD '(' string ')'
991 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
992 $$ = $3;
996 initdcl:
997 declarator maybeasm maybe_attribute '='
998 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
999 $3, prefix_attributes);
1000 start_init ($<ttype>$, $2, global_bindings_p ()); }
1001 init
1002 /* Note how the declaration of the variable is in effect while its init is parsed! */
1003 { finish_init ();
1004 finish_decl ($<ttype>5, $6, $2); }
1005 | declarator maybeasm maybe_attribute
1006 { tree d = start_decl ($1, current_declspecs, 0,
1007 $3, prefix_attributes);
1008 finish_decl (d, NULL_TREE, $2);
1012 notype_initdcl:
1013 notype_declarator maybeasm maybe_attribute '='
1014 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1015 $3, prefix_attributes);
1016 start_init ($<ttype>$, $2, global_bindings_p ()); }
1017 init
1018 /* Note how the declaration of the variable is in effect while its init is parsed! */
1019 { finish_init ();
1020 decl_attributes ($<ttype>5, $3, prefix_attributes);
1021 finish_decl ($<ttype>5, $6, $2); }
1022 | notype_declarator maybeasm maybe_attribute
1023 { tree d = start_decl ($1, current_declspecs, 0,
1024 $3, prefix_attributes);
1025 finish_decl (d, NULL_TREE, $2); }
1027 /* the * rules are dummies to accept the Apollo extended syntax
1028 so that the header files compile. */
1029 maybe_attribute:
1030 /* empty */
1031 { $$ = NULL_TREE; }
1032 | attributes
1033 { $$ = $1; }
1036 attributes:
1037 attribute
1038 { $$ = $1; }
1039 | attributes attribute
1040 { $$ = chainon ($1, $2); }
1043 attribute:
1044 ATTRIBUTE '(' '(' attribute_list ')' ')'
1045 { $$ = $4; }
1048 attribute_list:
1049 attrib
1050 { $$ = $1; }
1051 | attribute_list ',' attrib
1052 { $$ = chainon ($1, $3); }
1055 attrib:
1056 /* empty */
1057 { $$ = NULL_TREE; }
1058 | any_word
1059 { $$ = build_tree_list ($1, NULL_TREE); }
1060 | any_word '(' IDENTIFIER ')'
1061 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1062 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1063 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1064 | any_word '(' exprlist ')'
1065 { $$ = build_tree_list ($1, $3); }
1068 /* This still leaves out most reserved keywords,
1069 shouldn't we include them? */
1071 any_word:
1072 identifier
1073 | SCSPEC
1074 | TYPESPEC
1075 | TYPE_QUAL
1078 /* Initializers. `init' is the entry point. */
1080 init:
1081 expr_no_commas
1082 | '{'
1083 { really_start_incremental_init (NULL_TREE);
1084 /* Note that the call to clear_momentary
1085 is in process_init_element. */
1086 push_momentary (); }
1087 initlist_maybe_comma '}'
1088 { $$ = pop_init_level (0);
1089 if ($$ == error_mark_node
1090 && ! (yychar == STRING || yychar == CONSTANT))
1091 pop_momentary ();
1092 else
1093 pop_momentary_nofree (); }
1095 | error
1096 { $$ = error_mark_node; }
1099 /* `initlist_maybe_comma' is the guts of an initializer in braces. */
1100 initlist_maybe_comma:
1101 /* empty */
1102 { if (pedantic)
1103 pedwarn ("ANSI C forbids empty initializer braces"); }
1104 | initlist1 maybecomma
1107 initlist1:
1108 initelt
1109 | initlist1 ',' initelt
1112 /* `initelt' is a single element of an initializer.
1113 It may use braces. */
1114 initelt:
1115 expr_no_commas
1116 { process_init_element ($1); }
1117 | '{'
1118 { push_init_level (0); }
1119 initlist_maybe_comma '}'
1120 { process_init_element (pop_init_level (0)); }
1121 | error
1122 /* These are for labeled elements. The syntax for an array element
1123 initializer conflicts with the syntax for an Objective-C message,
1124 so don't include these productions in the Objective-C grammar. */
1125 | '[' expr_no_commas ELLIPSIS expr_no_commas ']' '='
1126 { set_init_index ($2, $4); }
1127 initelt
1128 | '[' expr_no_commas ']' '='
1129 { set_init_index ($2, NULL_TREE); }
1130 initelt
1131 | '[' expr_no_commas ']'
1132 { set_init_index ($2, NULL_TREE); }
1133 initelt
1134 | identifier ':'
1135 { set_init_label ($1); }
1136 initelt
1137 | '.' identifier '='
1138 { set_init_label ($2); }
1139 initelt
1142 nested_function:
1143 declarator
1144 { push_c_function_context ();
1145 if (! start_function (current_declspecs, $1,
1146 prefix_attributes, NULL_TREE, 1))
1148 pop_c_function_context ();
1149 YYERROR1;
1151 reinit_parse_for_function (); }
1152 old_style_parm_decls
1153 { store_parm_decls (); }
1154 /* This used to use compstmt_or_error.
1155 That caused a bug with input `f(g) int g {}',
1156 where the use of YYERROR1 above caused an error
1157 which then was handled by compstmt_or_error.
1158 There followed a repeated execution of that same rule,
1159 which called YYERROR1 again, and so on. */
1160 compstmt
1161 { finish_function (1);
1162 pop_c_function_context (); }
1165 notype_nested_function:
1166 notype_declarator
1167 { push_c_function_context ();
1168 if (! start_function (current_declspecs, $1,
1169 prefix_attributes, NULL_TREE, 1))
1171 pop_c_function_context ();
1172 YYERROR1;
1174 reinit_parse_for_function (); }
1175 old_style_parm_decls
1176 { store_parm_decls (); }
1177 /* This used to use compstmt_or_error.
1178 That caused a bug with input `f(g) int g {}',
1179 where the use of YYERROR1 above caused an error
1180 which then was handled by compstmt_or_error.
1181 There followed a repeated execution of that same rule,
1182 which called YYERROR1 again, and so on. */
1183 compstmt
1184 { finish_function (1);
1185 pop_c_function_context (); }
1188 /* Any kind of declarator (thus, all declarators allowed
1189 after an explicit typespec). */
1191 declarator:
1192 after_type_declarator
1193 | notype_declarator
1196 /* A declarator that is allowed only after an explicit typespec. */
1198 after_type_declarator:
1199 '(' after_type_declarator ')'
1200 { $$ = $2; }
1201 | after_type_declarator '(' parmlist_or_identifiers %prec '.'
1202 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1203 /* | after_type_declarator '(' error ')' %prec '.'
1204 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1205 poplevel (0, 0, 0); } */
1206 | after_type_declarator '[' expr ']' %prec '.'
1207 { $$ = build_nt (ARRAY_REF, $1, $3); }
1208 | after_type_declarator '[' ']' %prec '.'
1209 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1210 | '*' type_quals after_type_declarator %prec UNARY
1211 { $$ = make_pointer_declarator ($2, $3); }
1212 /* ??? Yuck. setattrs is a quick hack. We can't use
1213 prefix_attributes because $1 only applies to this
1214 declarator. We assume setspecs has already been done.
1215 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1216 attributes could be recognized here or in `attributes'). */
1217 | attributes setattrs after_type_declarator
1218 { $$ = $3; }
1219 | TYPENAME
1222 /* Kinds of declarator that can appear in a parameter list
1223 in addition to notype_declarator. This is like after_type_declarator
1224 but does not allow a typedef name in parentheses as an identifier
1225 (because it would conflict with a function with that typedef as arg). */
1227 parm_declarator:
1228 parm_declarator '(' parmlist_or_identifiers %prec '.'
1229 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1230 /* | parm_declarator '(' error ')' %prec '.'
1231 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1232 poplevel (0, 0, 0); } */
1233 | parm_declarator '[' expr ']' %prec '.'
1234 { $$ = build_nt (ARRAY_REF, $1, $3); }
1235 | parm_declarator '[' ']' %prec '.'
1236 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1237 | '*' type_quals parm_declarator %prec UNARY
1238 { $$ = make_pointer_declarator ($2, $3); }
1239 /* ??? Yuck. setattrs is a quick hack. We can't use
1240 prefix_attributes because $1 only applies to this
1241 declarator. We assume setspecs has already been done.
1242 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1243 attributes could be recognized here or in `attributes'). */
1244 | attributes setattrs parm_declarator
1245 { $$ = $3; }
1246 | TYPENAME
1249 /* A declarator allowed whether or not there has been
1250 an explicit typespec. These cannot redeclare a typedef-name. */
1252 notype_declarator:
1253 notype_declarator '(' parmlist_or_identifiers %prec '.'
1254 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1255 /* | notype_declarator '(' error ')' %prec '.'
1256 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1257 poplevel (0, 0, 0); } */
1258 | '(' notype_declarator ')'
1259 { $$ = $2; }
1260 | '*' type_quals notype_declarator %prec UNARY
1261 { $$ = make_pointer_declarator ($2, $3); }
1262 | notype_declarator '[' expr ']' %prec '.'
1263 { $$ = build_nt (ARRAY_REF, $1, $3); }
1264 | notype_declarator '[' ']' %prec '.'
1265 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1266 /* ??? Yuck. setattrs is a quick hack. We can't use
1267 prefix_attributes because $1 only applies to this
1268 declarator. We assume setspecs has already been done.
1269 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1270 attributes could be recognized here or in `attributes'). */
1271 | attributes setattrs notype_declarator
1272 { $$ = $3; }
1273 | IDENTIFIER
1276 structsp:
1277 STRUCT identifier '{'
1278 { $$ = start_struct (RECORD_TYPE, $2);
1279 /* Start scope of tag before parsing components. */
1281 component_decl_list '}' maybe_attribute
1282 { $$ = finish_struct ($<ttype>4, $5, $7); }
1283 | STRUCT '{' component_decl_list '}' maybe_attribute
1284 { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
1285 $3, $5);
1287 | STRUCT identifier
1288 { $$ = xref_tag (RECORD_TYPE, $2); }
1289 | UNION identifier '{'
1290 { $$ = start_struct (UNION_TYPE, $2); }
1291 component_decl_list '}' maybe_attribute
1292 { $$ = finish_struct ($<ttype>4, $5, $7); }
1293 | UNION '{' component_decl_list '}' maybe_attribute
1294 { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
1295 $3, $5);
1297 | UNION identifier
1298 { $$ = xref_tag (UNION_TYPE, $2); }
1299 | ENUM identifier '{'
1300 { $<itype>3 = suspend_momentary ();
1301 $$ = start_enum ($2); }
1302 enumlist maybecomma_warn '}' maybe_attribute
1303 { $$ = finish_enum ($<ttype>4, nreverse ($5), $8);
1304 resume_momentary ($<itype>3); }
1305 | ENUM '{'
1306 { $<itype>2 = suspend_momentary ();
1307 $$ = start_enum (NULL_TREE); }
1308 enumlist maybecomma_warn '}' maybe_attribute
1309 { $$ = finish_enum ($<ttype>3, nreverse ($4), $7);
1310 resume_momentary ($<itype>2); }
1311 | ENUM identifier
1312 { $$ = xref_tag (ENUMERAL_TYPE, $2); }
1315 maybecomma:
1316 /* empty */
1317 | ','
1320 maybecomma_warn:
1321 /* empty */
1322 | ','
1323 { if (pedantic) pedwarn ("comma at end of enumerator list"); }
1326 component_decl_list:
1327 component_decl_list2
1328 { $$ = $1; }
1329 | component_decl_list2 component_decl
1330 { $$ = chainon ($1, $2);
1331 pedwarn ("no semicolon at end of struct or union"); }
1334 component_decl_list2: /* empty */
1335 { $$ = NULL_TREE; }
1336 | component_decl_list2 component_decl ';'
1337 { $$ = chainon ($1, $2); }
1338 | component_decl_list2 ';'
1339 { if (pedantic)
1340 pedwarn ("extra semicolon in struct or union specified"); }
1343 /* There is a shift-reduce conflict here, because `components' may
1344 start with a `typename'. It happens that shifting (the default resolution)
1345 does the right thing, because it treats the `typename' as part of
1346 a `typed_typespecs'.
1348 It is possible that this same technique would allow the distinction
1349 between `notype_initdecls' and `initdecls' to be eliminated.
1350 But I am being cautious and not trying it. */
1352 component_decl:
1353 typed_typespecs setspecs components
1354 { $$ = $3;
1355 current_declspecs = TREE_VALUE (declspec_stack);
1356 prefix_attributes = TREE_PURPOSE (declspec_stack);
1357 declspec_stack = TREE_CHAIN (declspec_stack);
1358 resume_momentary ($2); }
1359 | typed_typespecs
1360 { if (pedantic)
1361 pedwarn ("ANSI C forbids member declarations with no members");
1362 shadow_tag($1);
1363 $$ = NULL_TREE; }
1364 | nonempty_type_quals setspecs components
1365 { $$ = $3;
1366 current_declspecs = TREE_VALUE (declspec_stack);
1367 prefix_attributes = TREE_PURPOSE (declspec_stack);
1368 declspec_stack = TREE_CHAIN (declspec_stack);
1369 resume_momentary ($2); }
1370 | nonempty_type_quals
1371 { if (pedantic)
1372 pedwarn ("ANSI C forbids member declarations with no members");
1373 shadow_tag($1);
1374 $$ = NULL_TREE; }
1375 | error
1376 { $$ = NULL_TREE; }
1377 | extension component_decl
1378 { $$ = $2;
1379 pedantic = $<itype>1; }
1382 components:
1383 component_declarator
1384 | components ',' component_declarator
1385 { $$ = chainon ($1, $3); }
1388 component_declarator:
1389 save_filename save_lineno declarator maybe_attribute
1390 { $$ = grokfield ($1, $2, $3, current_declspecs, NULL_TREE);
1391 decl_attributes ($$, $4, prefix_attributes); }
1392 | save_filename save_lineno
1393 declarator ':' expr_no_commas maybe_attribute
1394 { $$ = grokfield ($1, $2, $3, current_declspecs, $5);
1395 decl_attributes ($$, $6, prefix_attributes); }
1396 | save_filename save_lineno ':' expr_no_commas maybe_attribute
1397 { $$ = grokfield ($1, $2, NULL_TREE, current_declspecs, $4);
1398 decl_attributes ($$, $5, prefix_attributes); }
1401 /* We chain the enumerators in reverse order.
1402 They are put in forward order where enumlist is used.
1403 (The order used to be significant, but no longer is so.
1404 However, we still maintain the order, just to be clean.) */
1406 enumlist:
1407 enumerator
1408 | enumlist ',' enumerator
1409 { if ($1 == error_mark_node)
1410 $$ = $1;
1411 else
1412 $$ = chainon ($3, $1); }
1413 | error
1414 { $$ = error_mark_node; }
1418 enumerator:
1419 identifier
1420 { $$ = build_enumerator ($1, NULL_TREE); }
1421 | identifier '=' expr_no_commas
1422 { $$ = build_enumerator ($1, $3); }
1425 typename:
1426 typed_typespecs absdcl
1427 { $$ = build_tree_list ($1, $2); }
1428 | nonempty_type_quals absdcl
1429 { $$ = build_tree_list ($1, $2); }
1432 absdcl: /* an absolute declarator */
1433 /* empty */
1434 { $$ = NULL_TREE; }
1435 | absdcl1
1438 nonempty_type_quals:
1439 TYPE_QUAL
1440 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
1441 | nonempty_type_quals TYPE_QUAL
1442 { $$ = tree_cons (NULL_TREE, $2, $1); }
1445 type_quals:
1446 /* empty */
1447 { $$ = NULL_TREE; }
1448 | type_quals TYPE_QUAL
1449 { $$ = tree_cons (NULL_TREE, $2, $1); }
1452 absdcl1: /* a nonempty absolute declarator */
1453 '(' absdcl1 ')'
1454 { $$ = $2; }
1455 /* `(typedef)1' is `int'. */
1456 | '*' type_quals absdcl1 %prec UNARY
1457 { $$ = make_pointer_declarator ($2, $3); }
1458 | '*' type_quals %prec UNARY
1459 { $$ = make_pointer_declarator ($2, NULL_TREE); }
1460 | absdcl1 '(' parmlist %prec '.'
1461 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1462 | absdcl1 '[' expr ']' %prec '.'
1463 { $$ = build_nt (ARRAY_REF, $1, $3); }
1464 | absdcl1 '[' ']' %prec '.'
1465 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1466 | '(' parmlist %prec '.'
1467 { $$ = build_nt (CALL_EXPR, NULL_TREE, $2, NULL_TREE); }
1468 | '[' expr ']' %prec '.'
1469 { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
1470 | '[' ']' %prec '.'
1471 { $$ = build_nt (ARRAY_REF, NULL_TREE, NULL_TREE); }
1472 /* ??? It appears we have to support attributes here, however
1473 using prefix_attributes is wrong. */
1476 /* at least one statement, the first of which parses without error. */
1477 /* stmts is used only after decls, so an invalid first statement
1478 is actually regarded as an invalid decl and part of the decls. */
1480 stmts:
1481 lineno_stmt_or_labels
1483 if (pedantic && $1)
1484 pedwarn ("ANSI C forbids label at end of compound statement");
1488 lineno_stmt_or_labels:
1489 lineno_stmt_or_label
1490 | lineno_stmt_or_labels lineno_stmt_or_label
1491 { $$ = $2; }
1492 | lineno_stmt_or_labels errstmt
1493 { $$ = 0; }
1496 xstmts:
1497 /* empty */
1498 | stmts
1501 errstmt: error ';'
1504 pushlevel: /* empty */
1505 { emit_line_note (input_filename, lineno);
1506 pushlevel (0);
1507 clear_last_expr ();
1508 push_momentary ();
1509 expand_start_bindings (0);
1513 /* Read zero or more forward-declarations for labels
1514 that nested functions can jump to. */
1515 maybe_label_decls:
1516 /* empty */
1517 | label_decls
1518 { if (pedantic)
1519 pedwarn ("ANSI C forbids label declarations"); }
1522 label_decls:
1523 label_decl
1524 | label_decls label_decl
1527 label_decl:
1528 LABEL identifiers_or_typenames ';'
1529 { tree link;
1530 for (link = $2; link; link = TREE_CHAIN (link))
1532 tree label = shadow_label (TREE_VALUE (link));
1533 C_DECLARED_LABEL_FLAG (label) = 1;
1534 declare_nonlocal_label (label);
1539 /* This is the body of a function definition.
1540 It causes syntax errors to ignore to the next openbrace. */
1541 compstmt_or_error:
1542 compstmt
1544 | error compstmt
1547 compstmt_start: '{' { compstmt_count++; }
1549 compstmt: compstmt_start '}'
1550 { $$ = convert (void_type_node, integer_zero_node); }
1551 | compstmt_start pushlevel maybe_label_decls decls xstmts '}'
1552 { emit_line_note (input_filename, lineno);
1553 expand_end_bindings (getdecls (), 1, 0);
1554 $$ = poplevel (1, 1, 0);
1555 if (yychar == CONSTANT || yychar == STRING)
1556 pop_momentary_nofree ();
1557 else
1558 pop_momentary (); }
1559 | compstmt_start pushlevel maybe_label_decls error '}'
1560 { emit_line_note (input_filename, lineno);
1561 expand_end_bindings (getdecls (), kept_level_p (), 0);
1562 $$ = poplevel (kept_level_p (), 0, 0);
1563 if (yychar == CONSTANT || yychar == STRING)
1564 pop_momentary_nofree ();
1565 else
1566 pop_momentary (); }
1567 | compstmt_start pushlevel maybe_label_decls stmts '}'
1568 { emit_line_note (input_filename, lineno);
1569 expand_end_bindings (getdecls (), kept_level_p (), 0);
1570 $$ = poplevel (kept_level_p (), 0, 0);
1571 if (yychar == CONSTANT || yychar == STRING)
1572 pop_momentary_nofree ();
1573 else
1574 pop_momentary (); }
1577 /* Value is number of statements counted as of the closeparen. */
1578 simple_if:
1579 if_prefix lineno_labeled_stmt
1580 /* Make sure c_expand_end_cond is run once
1581 for each call to c_expand_start_cond.
1582 Otherwise a crash is likely. */
1583 | if_prefix error
1586 if_prefix:
1587 IF '(' expr ')'
1588 { emit_line_note ($<filename>-1, $<lineno>0);
1589 c_expand_start_cond (truthvalue_conversion ($3), 0,
1590 compstmt_count);
1591 $<itype>$ = stmt_count;
1592 if_stmt_file = $<filename>-1;
1593 if_stmt_line = $<lineno>0;
1594 position_after_white_space (); }
1597 /* This is a subroutine of stmt.
1598 It is used twice, once for valid DO statements
1599 and once for catching errors in parsing the end test. */
1600 do_stmt_start:
1602 { stmt_count++;
1603 compstmt_count++;
1604 emit_line_note ($<filename>-1, $<lineno>0);
1605 /* See comment in `while' alternative, above. */
1606 emit_nop ();
1607 expand_start_loop_continue_elsewhere (1);
1608 position_after_white_space (); }
1609 lineno_labeled_stmt WHILE
1610 { expand_loop_continue_here (); }
1613 save_filename:
1614 { $$ = input_filename; }
1617 save_lineno:
1618 { $$ = lineno; }
1621 lineno_labeled_stmt:
1622 save_filename save_lineno stmt
1624 /* | save_filename save_lineno error
1627 | save_filename save_lineno label lineno_labeled_stmt
1631 lineno_stmt_or_label:
1632 save_filename save_lineno stmt_or_label
1633 { $$ = $3; }
1636 stmt_or_label:
1637 stmt
1638 { $$ = 0; }
1639 | label
1640 { $$ = 1; }
1643 /* Parse a single real statement, not including any labels. */
1644 stmt:
1645 compstmt
1646 { stmt_count++; }
1647 | all_iter_stmt
1648 | expr ';'
1649 { stmt_count++;
1650 emit_line_note ($<filename>-1, $<lineno>0);
1651 /* It appears that this should not be done--that a non-lvalue array
1652 shouldn't get an error if the value isn't used.
1653 Section 3.2.2.1 says that an array lvalue gets converted to a pointer
1654 if it appears as a top-level expression,
1655 but says nothing about non-lvalue arrays. */
1656 #if 0
1657 /* Call default_conversion to get an error
1658 on referring to a register array if pedantic. */
1659 if (TREE_CODE (TREE_TYPE ($1)) == ARRAY_TYPE
1660 || TREE_CODE (TREE_TYPE ($1)) == FUNCTION_TYPE)
1661 $1 = default_conversion ($1);
1662 #endif
1663 iterator_expand ($1);
1664 clear_momentary (); }
1665 | simple_if ELSE
1666 { c_expand_start_else ();
1667 $<itype>1 = stmt_count;
1668 position_after_white_space (); }
1669 lineno_labeled_stmt
1670 { c_expand_end_cond ();
1671 if (extra_warnings && stmt_count == $<itype>1)
1672 warning ("empty body in an else-statement"); }
1673 | simple_if %prec IF
1674 { c_expand_end_cond ();
1675 /* This warning is here instead of in simple_if, because we
1676 do not want a warning if an empty if is followed by an
1677 else statement. Increment stmt_count so we don't
1678 give a second error if this is a nested `if'. */
1679 if (extra_warnings && stmt_count++ == $<itype>1)
1680 warning_with_file_and_line (if_stmt_file, if_stmt_line,
1681 "empty body in an if-statement"); }
1682 /* Make sure c_expand_end_cond is run once
1683 for each call to c_expand_start_cond.
1684 Otherwise a crash is likely. */
1685 | simple_if ELSE error
1686 { c_expand_end_cond (); }
1687 | WHILE
1688 { stmt_count++;
1689 emit_line_note ($<filename>-1, $<lineno>0);
1690 /* The emit_nop used to come before emit_line_note,
1691 but that made the nop seem like part of the preceding line.
1692 And that was confusing when the preceding line was
1693 inside of an if statement and was not really executed.
1694 I think it ought to work to put the nop after the line number.
1695 We will see. --rms, July 15, 1991. */
1696 emit_nop (); }
1697 '(' expr ')'
1698 { /* Don't start the loop till we have succeeded
1699 in parsing the end test. This is to make sure
1700 that we end every loop we start. */
1701 expand_start_loop (1);
1702 emit_line_note (input_filename, lineno);
1703 expand_exit_loop_if_false (NULL_PTR,
1704 truthvalue_conversion ($4));
1705 position_after_white_space (); }
1706 lineno_labeled_stmt
1707 { expand_end_loop (); }
1708 | do_stmt_start
1709 '(' expr ')' ';'
1710 { emit_line_note (input_filename, lineno);
1711 expand_exit_loop_if_false (NULL_PTR,
1712 truthvalue_conversion ($3));
1713 expand_end_loop ();
1714 clear_momentary (); }
1715 /* This rule is needed to make sure we end every loop we start. */
1716 | do_stmt_start error
1717 { expand_end_loop ();
1718 clear_momentary (); }
1719 | FOR
1720 '(' xexpr ';'
1721 { stmt_count++;
1722 emit_line_note ($<filename>-1, $<lineno>0);
1723 /* See comment in `while' alternative, above. */
1724 emit_nop ();
1725 if ($3) c_expand_expr_stmt ($3);
1726 /* Next step is to call expand_start_loop_continue_elsewhere,
1727 but wait till after we parse the entire for (...).
1728 Otherwise, invalid input might cause us to call that
1729 fn without calling expand_end_loop. */
1731 xexpr ';'
1732 /* Can't emit now; wait till after expand_start_loop... */
1733 { $<lineno>7 = lineno;
1734 $<filename>$ = input_filename; }
1735 xexpr ')'
1737 /* Start the loop. Doing this after parsing
1738 all the expressions ensures we will end the loop. */
1739 expand_start_loop_continue_elsewhere (1);
1740 /* Emit the end-test, with a line number. */
1741 emit_line_note ($<filename>8, $<lineno>7);
1742 if ($6)
1743 expand_exit_loop_if_false (NULL_PTR,
1744 truthvalue_conversion ($6));
1745 /* Don't let the tree nodes for $9 be discarded by
1746 clear_momentary during the parsing of the next stmt. */
1747 push_momentary ();
1748 $<lineno>7 = lineno;
1749 $<filename>8 = input_filename;
1750 position_after_white_space (); }
1751 lineno_labeled_stmt
1752 { /* Emit the increment expression, with a line number. */
1753 emit_line_note ($<filename>8, $<lineno>7);
1754 expand_loop_continue_here ();
1755 if ($9)
1756 c_expand_expr_stmt ($9);
1757 if (yychar == CONSTANT || yychar == STRING)
1758 pop_momentary_nofree ();
1759 else
1760 pop_momentary ();
1761 expand_end_loop (); }
1762 | SWITCH '(' expr ')'
1763 { stmt_count++;
1764 emit_line_note ($<filename>-1, $<lineno>0);
1765 c_expand_start_case ($3);
1766 /* Don't let the tree nodes for $3 be discarded by
1767 clear_momentary during the parsing of the next stmt. */
1768 push_momentary ();
1769 position_after_white_space (); }
1770 lineno_labeled_stmt
1771 { expand_end_case ($3);
1772 if (yychar == CONSTANT || yychar == STRING)
1773 pop_momentary_nofree ();
1774 else
1775 pop_momentary (); }
1776 | BREAK ';'
1777 { stmt_count++;
1778 emit_line_note ($<filename>-1, $<lineno>0);
1779 if ( ! expand_exit_something ())
1780 error ("break statement not within loop or switch"); }
1781 | CONTINUE ';'
1782 { stmt_count++;
1783 emit_line_note ($<filename>-1, $<lineno>0);
1784 if (! expand_continue_loop (NULL_PTR))
1785 error ("continue statement not within a loop"); }
1786 | RETURN ';'
1787 { stmt_count++;
1788 emit_line_note ($<filename>-1, $<lineno>0);
1789 c_expand_return (NULL_TREE); }
1790 | RETURN expr ';'
1791 { stmt_count++;
1792 emit_line_note ($<filename>-1, $<lineno>0);
1793 c_expand_return ($2); }
1794 | ASM_KEYWORD maybe_type_qual '(' expr ')' ';'
1795 { stmt_count++;
1796 emit_line_note ($<filename>-1, $<lineno>0);
1797 STRIP_NOPS ($4);
1798 if ((TREE_CODE ($4) == ADDR_EXPR
1799 && TREE_CODE (TREE_OPERAND ($4, 0)) == STRING_CST)
1800 || TREE_CODE ($4) == STRING_CST)
1801 expand_asm ($4);
1802 else
1803 error ("argument of `asm' is not a constant string"); }
1804 /* This is the case with just output operands. */
1805 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ')' ';'
1806 { stmt_count++;
1807 emit_line_note ($<filename>-1, $<lineno>0);
1808 c_expand_asm_operands ($4, $6, NULL_TREE, NULL_TREE,
1809 $2 == ridpointers[(int)RID_VOLATILE],
1810 input_filename, lineno); }
1811 /* This is the case with input operands as well. */
1812 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':' asm_operands ')' ';'
1813 { stmt_count++;
1814 emit_line_note ($<filename>-1, $<lineno>0);
1815 c_expand_asm_operands ($4, $6, $8, NULL_TREE,
1816 $2 == ridpointers[(int)RID_VOLATILE],
1817 input_filename, lineno); }
1818 /* This is the case with clobbered registers as well. */
1819 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':'
1820 asm_operands ':' asm_clobbers ')' ';'
1821 { stmt_count++;
1822 emit_line_note ($<filename>-1, $<lineno>0);
1823 c_expand_asm_operands ($4, $6, $8, $10,
1824 $2 == ridpointers[(int)RID_VOLATILE],
1825 input_filename, lineno); }
1826 | GOTO identifier ';'
1827 { tree decl;
1828 stmt_count++;
1829 emit_line_note ($<filename>-1, $<lineno>0);
1830 decl = lookup_label ($2);
1831 if (decl != 0)
1833 TREE_USED (decl) = 1;
1834 expand_goto (decl);
1837 | GOTO '*' expr ';'
1838 { if (pedantic)
1839 pedwarn ("ANSI C forbids `goto *expr;'");
1840 stmt_count++;
1841 emit_line_note ($<filename>-1, $<lineno>0);
1842 expand_computed_goto (convert (ptr_type_node, $3)); }
1843 | ';'
1846 all_iter_stmt:
1847 all_iter_stmt_simple
1848 /* | all_iter_stmt_with_decl */
1851 all_iter_stmt_simple:
1852 FOR '(' primary ')'
1854 /* The value returned by this action is */
1855 /* 1 if everything is OK */
1856 /* 0 in case of error or already bound iterator */
1858 $<itype>$ = 0;
1859 if (TREE_CODE ($3) != VAR_DECL)
1860 error ("invalid `for (ITERATOR)' syntax");
1861 else if (! ITERATOR_P ($3))
1862 error ("`%s' is not an iterator",
1863 IDENTIFIER_POINTER (DECL_NAME ($3)));
1864 else if (ITERATOR_BOUND_P ($3))
1865 error ("`for (%s)' inside expansion of same iterator",
1866 IDENTIFIER_POINTER (DECL_NAME ($3)));
1867 else
1869 $<itype>$ = 1;
1870 iterator_for_loop_start ($3);
1873 lineno_labeled_stmt
1875 if ($<itype>5)
1876 iterator_for_loop_end ($3);
1879 /* This really should allow any kind of declaration,
1880 for generality. Fix it before turning it back on.
1882 all_iter_stmt_with_decl:
1883 FOR '(' ITERATOR pushlevel setspecs iterator_spec ')'
1885 */ /* The value returned by this action is */
1886 /* 1 if everything is OK */
1887 /* 0 in case of error or already bound iterator */
1889 iterator_for_loop_start ($6);
1891 lineno_labeled_stmt
1893 iterator_for_loop_end ($6);
1894 emit_line_note (input_filename, lineno);
1895 expand_end_bindings (getdecls (), 1, 0);
1896 $<ttype>$ = poplevel (1, 1, 0);
1897 if (yychar == CONSTANT || yychar == STRING)
1898 pop_momentary_nofree ();
1899 else
1900 pop_momentary ();
1904 /* Any kind of label, including jump labels and case labels.
1905 ANSI C accepts labels only before statements, but we allow them
1906 also at the end of a compound statement. */
1908 label: CASE expr_no_commas ':'
1909 { register tree value = check_case_value ($2);
1910 register tree label
1911 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
1913 stmt_count++;
1915 if (value != error_mark_node)
1917 tree duplicate;
1918 int success;
1920 if (pedantic && ! INTEGRAL_TYPE_P (TREE_TYPE (value)))
1921 pedwarn ("label must have integral type in ANSI C");
1923 success = pushcase (value, convert_and_check,
1924 label, &duplicate);
1926 if (success == 1)
1927 error ("case label not within a switch statement");
1928 else if (success == 2)
1930 error ("duplicate case value");
1931 error_with_decl (duplicate, "this is the first entry for that value");
1933 else if (success == 3)
1934 warning ("case value out of range");
1935 else if (success == 5)
1936 error ("case label within scope of cleanup or variable array");
1938 position_after_white_space (); }
1939 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
1940 { register tree value1 = check_case_value ($2);
1941 register tree value2 = check_case_value ($4);
1942 register tree label
1943 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
1945 if (pedantic)
1946 pedwarn ("ANSI C forbids case ranges");
1947 stmt_count++;
1949 if (value1 != error_mark_node && value2 != error_mark_node)
1951 tree duplicate;
1952 int success = pushcase_range (value1, value2,
1953 convert_and_check, label,
1954 &duplicate);
1955 if (success == 1)
1956 error ("case label not within a switch statement");
1957 else if (success == 2)
1959 error ("duplicate case value");
1960 error_with_decl (duplicate, "this is the first entry for that value");
1962 else if (success == 3)
1963 warning ("case value out of range");
1964 else if (success == 4)
1965 warning ("empty case range");
1966 else if (success == 5)
1967 error ("case label within scope of cleanup or variable array");
1969 position_after_white_space (); }
1970 | DEFAULT ':'
1972 tree duplicate;
1973 register tree label
1974 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
1975 int success = pushcase (NULL_TREE, 0, label, &duplicate);
1976 stmt_count++;
1977 if (success == 1)
1978 error ("default label not within a switch statement");
1979 else if (success == 2)
1981 error ("multiple default labels in one switch");
1982 error_with_decl (duplicate, "this is the first default label");
1984 position_after_white_space (); }
1985 | identifier ':'
1986 { tree label = define_label (input_filename, lineno, $1);
1987 stmt_count++;
1988 emit_nop ();
1989 if (label)
1990 expand_label (label);
1991 position_after_white_space (); }
1994 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
1996 maybe_type_qual:
1997 /* empty */
1998 { emit_line_note (input_filename, lineno);
1999 $$ = NULL_TREE; }
2000 | TYPE_QUAL
2001 { emit_line_note (input_filename, lineno); }
2004 xexpr:
2005 /* empty */
2006 { $$ = NULL_TREE; }
2007 | expr
2010 /* These are the operands other than the first string and colon
2011 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
2012 asm_operands: /* empty */
2013 { $$ = NULL_TREE; }
2014 | nonnull_asm_operands
2017 nonnull_asm_operands:
2018 asm_operand
2019 | nonnull_asm_operands ',' asm_operand
2020 { $$ = chainon ($1, $3); }
2023 asm_operand:
2024 STRING '(' expr ')'
2025 { $$ = build_tree_list ($1, $3); }
2028 asm_clobbers:
2029 string
2030 { $$ = tree_cons (NULL_TREE, combine_strings ($1), NULL_TREE); }
2031 | asm_clobbers ',' string
2032 { $$ = tree_cons (NULL_TREE, combine_strings ($3), $1); }
2035 /* This is what appears inside the parens in a function declarator.
2036 Its value is a list of ..._TYPE nodes. */
2037 parmlist:
2038 { pushlevel (0);
2039 clear_parm_order ();
2040 declare_parm_level (0); }
2041 parmlist_1
2042 { $$ = $2;
2043 parmlist_tags_warning ();
2044 poplevel (0, 0, 0); }
2047 parmlist_1:
2048 parmlist_2 ')'
2049 | parms ';'
2050 { tree parm;
2051 if (pedantic)
2052 pedwarn ("ANSI C forbids forward parameter declarations");
2053 /* Mark the forward decls as such. */
2054 for (parm = getdecls (); parm; parm = TREE_CHAIN (parm))
2055 TREE_ASM_WRITTEN (parm) = 1;
2056 clear_parm_order (); }
2057 parmlist_1
2058 { $$ = $4; }
2059 | error ')'
2060 { $$ = tree_cons (NULL_TREE, NULL_TREE, NULL_TREE); }
2063 /* This is what appears inside the parens in a function declarator.
2064 Is value is represented in the format that grokdeclarator expects. */
2065 parmlist_2: /* empty */
2066 { $$ = get_parm_info (0); }
2067 | ELLIPSIS
2068 { $$ = get_parm_info (0);
2069 /* Gcc used to allow this as an extension. However, it does
2070 not work for all targets, and thus has been disabled.
2071 Also, since func (...) and func () are indistinguishable,
2072 it caused problems with the code in expand_builtin which
2073 tries to verify that BUILT_IN_NEXT_ARG is being used
2074 correctly. */
2075 error ("ANSI C requires a named argument before `...'");
2077 | parms
2078 { $$ = get_parm_info (1); }
2079 | parms ',' ELLIPSIS
2080 { $$ = get_parm_info (0); }
2083 parms:
2084 parm
2085 { push_parm_decl ($1); }
2086 | parms ',' parm
2087 { push_parm_decl ($3); }
2090 /* A single parameter declaration or parameter type name,
2091 as found in a parmlist. */
2092 parm:
2093 typed_declspecs setspecs parm_declarator maybe_attribute
2094 { $$ = build_tree_list (build_tree_list (current_declspecs,
2095 $3),
2096 build_tree_list (prefix_attributes,
2097 $4));
2098 current_declspecs = TREE_VALUE (declspec_stack);
2099 prefix_attributes = TREE_PURPOSE (declspec_stack);
2100 declspec_stack = TREE_CHAIN (declspec_stack);
2101 resume_momentary ($2); }
2102 | typed_declspecs setspecs notype_declarator maybe_attribute
2103 { $$ = build_tree_list (build_tree_list (current_declspecs,
2104 $3),
2105 build_tree_list (prefix_attributes,
2106 $4));
2107 current_declspecs = TREE_VALUE (declspec_stack);
2108 prefix_attributes = TREE_PURPOSE (declspec_stack);
2109 declspec_stack = TREE_CHAIN (declspec_stack);
2110 resume_momentary ($2); }
2111 | typed_declspecs setspecs absdcl maybe_attribute
2112 { $$ = build_tree_list (build_tree_list (current_declspecs,
2113 $3),
2114 build_tree_list (prefix_attributes,
2115 $4));
2116 current_declspecs = TREE_VALUE (declspec_stack);
2117 prefix_attributes = TREE_PURPOSE (declspec_stack);
2118 declspec_stack = TREE_CHAIN (declspec_stack);
2119 resume_momentary ($2); }
2120 | declmods setspecs notype_declarator maybe_attribute
2121 { $$ = build_tree_list (build_tree_list (current_declspecs,
2122 $3),
2123 build_tree_list (prefix_attributes,
2124 $4));
2125 current_declspecs = TREE_VALUE (declspec_stack);
2126 prefix_attributes = TREE_PURPOSE (declspec_stack);
2127 declspec_stack = TREE_CHAIN (declspec_stack);
2128 resume_momentary ($2); }
2130 | declmods setspecs absdcl maybe_attribute
2131 { $$ = build_tree_list (build_tree_list (current_declspecs,
2132 $3),
2133 build_tree_list (prefix_attributes,
2134 $4));
2135 current_declspecs = TREE_VALUE (declspec_stack);
2136 prefix_attributes = TREE_PURPOSE (declspec_stack);
2137 declspec_stack = TREE_CHAIN (declspec_stack);
2138 resume_momentary ($2); }
2141 /* This is used in a function definition
2142 where either a parmlist or an identifier list is ok.
2143 Its value is a list of ..._TYPE nodes or a list of identifiers. */
2144 parmlist_or_identifiers:
2145 { pushlevel (0);
2146 clear_parm_order ();
2147 declare_parm_level (1); }
2148 parmlist_or_identifiers_1
2149 { $$ = $2;
2150 parmlist_tags_warning ();
2151 poplevel (0, 0, 0); }
2154 parmlist_or_identifiers_1:
2155 parmlist_1
2156 | identifiers ')'
2157 { tree t;
2158 for (t = $1; t; t = TREE_CHAIN (t))
2159 if (TREE_VALUE (t) == NULL_TREE)
2160 error ("`...' in old-style identifier list");
2161 $$ = tree_cons (NULL_TREE, NULL_TREE, $1); }
2164 /* A nonempty list of identifiers. */
2165 identifiers:
2166 IDENTIFIER
2167 { $$ = build_tree_list (NULL_TREE, $1); }
2168 | identifiers ',' IDENTIFIER
2169 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2172 /* A nonempty list of identifiers, including typenames. */
2173 identifiers_or_typenames:
2174 identifier
2175 { $$ = build_tree_list (NULL_TREE, $1); }
2176 | identifiers_or_typenames ',' identifier
2177 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2180 extension:
2181 EXTENSION
2182 { $<itype>$ = pedantic;
2183 pedantic = 0; }