* decl.c (grokdeclarator): Remove const and volatile from type after
[official-gcc.git] / gcc / c-parse.y
blobbb783f0acf692d00881efaa00d117cd37ab61468
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-6, 1997 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"
59 #include <stdio.h>
60 #include <errno.h>
61 #include <setjmp.h>
63 #include "tree.h"
64 #include "input.h"
65 #include "c-lex.h"
66 #include "c-tree.h"
67 #include "flags.h"
68 #include "output.h"
70 #ifdef MULTIBYTE_CHARS
71 #include <stdlib.h>
72 #include <locale.h>
73 #endif
76 /* Since parsers are distinct for each language, put the language string
77 definition here. */
78 char *language_string = "GNU C";
80 #ifndef errno
81 extern int errno;
82 #endif
84 /* Like YYERROR but do call yyerror. */
85 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
87 /* Cause the `yydebug' variable to be defined. */
88 #define YYDEBUG 1
91 %start program
93 %union {long itype; tree ttype; enum tree_code code;
94 char *filename; int lineno; int ends_in_label; }
96 /* All identifiers that are not reserved words
97 and are not declared typedefs in the current block */
98 %token IDENTIFIER
100 /* All identifiers that are declared typedefs in the current block.
101 In some contexts, they are treated just like IDENTIFIER,
102 but they can also serve as typespecs in declarations. */
103 %token TYPENAME
105 /* Reserved words that specify storage class.
106 yylval contains an IDENTIFIER_NODE which indicates which one. */
107 %token SCSPEC
109 /* Reserved words that specify type.
110 yylval contains an IDENTIFIER_NODE which indicates which one. */
111 %token TYPESPEC
113 /* Reserved words that qualify type: "const" or "volatile".
114 yylval contains an IDENTIFIER_NODE which indicates which one. */
115 %token TYPE_QUAL
117 /* Character or numeric constants.
118 yylval is the node for the constant. */
119 %token CONSTANT
121 /* String constants in raw form.
122 yylval is a STRING_CST node. */
123 %token STRING
125 /* "...", used for functions with variable arglists. */
126 %token ELLIPSIS
128 /* the reserved words */
129 /* SCO include files test "ASM", so use something else. */
130 %token SIZEOF ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
131 %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD TYPEOF ALIGNOF
132 %token ATTRIBUTE EXTENSION LABEL
133 %token REALPART IMAGPART
135 /* Add precedence rules to solve dangling else s/r conflict */
136 %nonassoc IF
137 %nonassoc ELSE
139 /* Define the operator tokens and their precedences.
140 The value is an integer because, if used, it is the tree code
141 to use in the expression made from the operator. */
143 %right <code> ASSIGN '='
144 %right <code> '?' ':'
145 %left <code> OROR
146 %left <code> ANDAND
147 %left <code> '|'
148 %left <code> '^'
149 %left <code> '&'
150 %left <code> EQCOMPARE
151 %left <code> ARITHCOMPARE
152 %left <code> LSHIFT RSHIFT
153 %left <code> '+' '-'
154 %left <code> '*' '/' '%'
155 %right <code> UNARY PLUSPLUS MINUSMINUS
156 %left HYPERUNARY
157 %left <code> POINTSAT '.' '(' '['
159 /* The Objective-C keywords. These are included in C and in
160 Objective C, so that the token codes are the same in both. */
161 %token INTERFACE IMPLEMENTATION END SELECTOR DEFS ENCODE
162 %token CLASSNAME PUBLIC PRIVATE PROTECTED PROTOCOL OBJECTNAME CLASS ALIAS
164 /* Objective-C string constants in raw form.
165 yylval is an OBJC_STRING_CST node. */
166 %token OBJC_STRING
169 %type <code> unop
171 %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist exprlist
172 %type <ttype> expr_no_commas cast_expr unary_expr primary string STRING
173 %type <ttype> typed_declspecs reserved_declspecs
174 %type <ttype> typed_typespecs reserved_typespecquals
175 %type <ttype> declmods typespec typespecqual_reserved
176 %type <ttype> typed_declspecs_no_prefix_attr reserved_declspecs_no_prefix_attr
177 %type <ttype> declmods_no_prefix_attr
178 %type <ttype> SCSPEC TYPESPEC TYPE_QUAL nonempty_type_quals maybe_type_qual
179 %type <ttype> initdecls notype_initdecls initdcl notype_initdcl
180 %type <ttype> init maybeasm
181 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
182 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
183 %type <ttype> any_word
185 %type <ttype> compstmt
187 %type <ttype> declarator
188 %type <ttype> notype_declarator after_type_declarator
189 %type <ttype> parm_declarator
191 %type <ttype> structsp component_decl_list component_decl_list2
192 %type <ttype> component_decl components component_declarator
193 %type <ttype> enumlist enumerator
194 %type <ttype> typename absdcl absdcl1 type_quals
195 %type <ttype> xexpr parms parm identifiers
197 %type <ttype> parmlist parmlist_1 parmlist_2
198 %type <ttype> parmlist_or_identifiers parmlist_or_identifiers_1
199 %type <ttype> identifiers_or_typenames
201 %type <itype> setspecs
203 %type <ends_in_label> lineno_stmt_or_label lineno_stmt_or_labels stmt_or_label
205 %type <filename> save_filename
206 %type <lineno> save_lineno
210 /* Number of statements (loosely speaking) and compound statements
211 seen so far. */
212 static int stmt_count;
213 static int compstmt_count;
215 /* Input file and line number of the end of the body of last simple_if;
216 used by the stmt-rule immediately after simple_if returns. */
217 static char *if_stmt_file;
218 static int if_stmt_line;
220 /* List of types and structure classes of the current declaration. */
221 static tree current_declspecs = NULL_TREE;
222 static tree prefix_attributes = NULL_TREE;
224 /* Stack of saved values of current_declspecs and prefix_attributes. */
225 static tree declspec_stack;
227 /* 1 if we explained undeclared var errors. */
228 static int undeclared_variable_notice;
231 /* Tell yyparse how to print a token's value, if yydebug is set. */
233 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
234 extern void yyprint PROTO ((FILE *, int, YYSTYPE));
238 program: /* empty */
239 { if (pedantic)
240 pedwarn ("ANSI C forbids an empty source file");
241 finish_file ();
243 | extdefs
245 /* In case there were missing closebraces,
246 get us back to the global binding level. */
247 while (! global_bindings_p ())
248 poplevel (0, 0, 0);
249 finish_file ();
253 /* the reason for the strange actions in this rule
254 is so that notype_initdecls when reached via datadef
255 can find a valid list of type and sc specs in $0. */
257 extdefs:
258 {$<ttype>$ = NULL_TREE; } extdef
259 | extdefs {$<ttype>$ = NULL_TREE; } extdef
262 extdef:
263 fndef
264 | datadef
265 | ASM_KEYWORD '(' expr ')' ';'
266 { STRIP_NOPS ($3);
267 if ((TREE_CODE ($3) == ADDR_EXPR
268 && TREE_CODE (TREE_OPERAND ($3, 0)) == STRING_CST)
269 || TREE_CODE ($3) == STRING_CST)
270 assemble_asm ($3);
271 else
272 error ("argument of `asm' is not a constant string"); }
273 | extension extdef
274 { pedantic = $<itype>1; }
277 datadef:
278 setspecs notype_initdecls ';'
279 { if (pedantic)
280 error ("ANSI C forbids data definition with no type or storage class");
281 else if (!flag_traditional)
282 warning ("data definition has no type or storage class");
284 current_declspecs = TREE_VALUE (declspec_stack);
285 prefix_attributes = TREE_PURPOSE (declspec_stack);
286 declspec_stack = TREE_CHAIN (declspec_stack);
287 resume_momentary ($1); }
288 | declmods setspecs notype_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); }
293 | typed_declspecs setspecs initdecls ';'
294 { current_declspecs = TREE_VALUE (declspec_stack);
295 prefix_attributes = TREE_PURPOSE (declspec_stack);
296 declspec_stack = TREE_CHAIN (declspec_stack);
297 resume_momentary ($2); }
298 | declmods ';'
299 { pedwarn ("empty declaration"); }
300 | typed_declspecs ';'
301 { shadow_tag ($1); }
302 | error ';'
303 | error '}'
304 | ';'
305 { if (pedantic)
306 pedwarn ("ANSI C does not allow extra `;' outside of a function"); }
309 fndef:
310 typed_declspecs setspecs declarator
311 { if (! start_function (current_declspecs, $3,
312 prefix_attributes, NULL_TREE, 0))
313 YYERROR1;
314 reinit_parse_for_function (); }
315 old_style_parm_decls
316 { store_parm_decls (); }
317 compstmt_or_error
318 { finish_function (0);
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 | typed_declspecs setspecs declarator error
324 { current_declspecs = TREE_VALUE (declspec_stack);
325 prefix_attributes = TREE_PURPOSE (declspec_stack);
326 declspec_stack = TREE_CHAIN (declspec_stack);
327 resume_momentary ($2); }
328 | declmods setspecs notype_declarator
329 { if (! start_function (current_declspecs, $3,
330 prefix_attributes, NULL_TREE, 0))
331 YYERROR1;
332 reinit_parse_for_function (); }
333 old_style_parm_decls
334 { store_parm_decls (); }
335 compstmt_or_error
336 { finish_function (0);
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 | declmods setspecs notype_declarator error
342 { current_declspecs = TREE_VALUE (declspec_stack);
343 prefix_attributes = TREE_PURPOSE (declspec_stack);
344 declspec_stack = TREE_CHAIN (declspec_stack);
345 resume_momentary ($2); }
346 | setspecs notype_declarator
347 { if (! start_function (NULL_TREE, $2,
348 prefix_attributes, NULL_TREE, 0))
349 YYERROR1;
350 reinit_parse_for_function (); }
351 old_style_parm_decls
352 { store_parm_decls (); }
353 compstmt_or_error
354 { finish_function (0);
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); }
359 | setspecs notype_declarator error
360 { current_declspecs = TREE_VALUE (declspec_stack);
361 prefix_attributes = TREE_PURPOSE (declspec_stack);
362 declspec_stack = TREE_CHAIN (declspec_stack);
363 resume_momentary ($1); }
366 identifier:
367 IDENTIFIER
368 | TYPENAME
371 unop: '&'
372 { $$ = ADDR_EXPR; }
373 | '-'
374 { $$ = NEGATE_EXPR; }
375 | '+'
376 { $$ = CONVERT_EXPR; }
377 | PLUSPLUS
378 { $$ = PREINCREMENT_EXPR; }
379 | MINUSMINUS
380 { $$ = PREDECREMENT_EXPR; }
381 | '~'
382 { $$ = BIT_NOT_EXPR; }
383 | '!'
384 { $$ = TRUTH_NOT_EXPR; }
387 expr: nonnull_exprlist
388 { $$ = build_compound_expr ($1); }
391 exprlist:
392 /* empty */
393 { $$ = NULL_TREE; }
394 | nonnull_exprlist
397 nonnull_exprlist:
398 expr_no_commas
399 { $$ = build_tree_list (NULL_TREE, $1); }
400 | nonnull_exprlist ',' expr_no_commas
401 { chainon ($1, build_tree_list (NULL_TREE, $3)); }
404 unary_expr:
405 primary
406 | '*' cast_expr %prec UNARY
407 { $$ = build_indirect_ref ($2, "unary *"); }
408 /* __extension__ turns off -pedantic for following primary. */
409 | extension cast_expr %prec UNARY
410 { $$ = $2;
411 pedantic = $<itype>1; }
412 | unop cast_expr %prec UNARY
413 { $$ = build_unary_op ($1, $2, 0);
414 overflow_warning ($$); }
415 /* Refer to the address of a label as a pointer. */
416 | ANDAND identifier
417 { tree label = lookup_label ($2);
418 if (pedantic)
419 pedwarn ("ANSI C forbids `&&'");
420 if (label == 0)
421 $$ = null_pointer_node;
422 else
424 TREE_USED (label) = 1;
425 $$ = build1 (ADDR_EXPR, ptr_type_node, label);
426 TREE_CONSTANT ($$) = 1;
429 /* This seems to be impossible on some machines, so let's turn it off.
430 You can use __builtin_next_arg to find the anonymous stack args.
431 | '&' ELLIPSIS
432 { tree types = TYPE_ARG_TYPES (TREE_TYPE (current_function_decl));
433 $$ = error_mark_node;
434 if (TREE_VALUE (tree_last (types)) == void_type_node)
435 error ("`&...' used in function with fixed number of arguments");
436 else
438 if (pedantic)
439 pedwarn ("ANSI C forbids `&...'");
440 $$ = tree_last (DECL_ARGUMENTS (current_function_decl));
441 $$ = build_unary_op (ADDR_EXPR, $$, 0);
444 | sizeof unary_expr %prec UNARY
445 { skip_evaluation--;
446 if (TREE_CODE ($2) == COMPONENT_REF
447 && DECL_C_BIT_FIELD (TREE_OPERAND ($2, 1)))
448 error ("`sizeof' applied to a bit-field");
449 $$ = c_sizeof (TREE_TYPE ($2)); }
450 | sizeof '(' typename ')' %prec HYPERUNARY
451 { skip_evaluation--;
452 $$ = c_sizeof (groktypename ($3)); }
453 | alignof unary_expr %prec UNARY
454 { skip_evaluation--;
455 $$ = c_alignof_expr ($2); }
456 | alignof '(' typename ')' %prec HYPERUNARY
457 { skip_evaluation--;
458 $$ = c_alignof (groktypename ($3)); }
459 | REALPART cast_expr %prec UNARY
460 { $$ = build_unary_op (REALPART_EXPR, $2, 0); }
461 | IMAGPART cast_expr %prec UNARY
462 { $$ = build_unary_op (IMAGPART_EXPR, $2, 0); }
465 sizeof:
466 SIZEOF { skip_evaluation++; }
469 alignof:
470 ALIGNOF { skip_evaluation++; }
473 cast_expr:
474 unary_expr
475 | '(' typename ')' cast_expr %prec UNARY
476 { tree type = groktypename ($2);
477 $$ = build_c_cast (type, $4); }
478 | '(' typename ')' '{'
479 { start_init (NULL_TREE, NULL, 0);
480 $2 = groktypename ($2);
481 really_start_incremental_init ($2); }
482 initlist_maybe_comma '}' %prec UNARY
483 { char *name;
484 tree result = pop_init_level (0);
485 tree type = $2;
486 finish_init ();
488 if (pedantic)
489 pedwarn ("ANSI C forbids constructor expressions");
490 if (TYPE_NAME (type) != 0)
492 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
493 name = IDENTIFIER_POINTER (TYPE_NAME (type));
494 else
495 name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
497 else
498 name = "";
499 $$ = result;
500 if (TREE_CODE (type) == ARRAY_TYPE && TYPE_SIZE (type) == 0)
502 int failure = complete_array_type (type, $$, 1);
503 if (failure)
504 abort ();
509 expr_no_commas:
510 cast_expr
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 '%' expr_no_commas
520 { $$ = parser_build_binary_op ($2, $1, $3); }
521 | expr_no_commas LSHIFT expr_no_commas
522 { $$ = parser_build_binary_op ($2, $1, $3); }
523 | expr_no_commas RSHIFT expr_no_commas
524 { $$ = parser_build_binary_op ($2, $1, $3); }
525 | expr_no_commas ARITHCOMPARE expr_no_commas
526 { $$ = parser_build_binary_op ($2, $1, $3); }
527 | expr_no_commas EQCOMPARE 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 '^' expr_no_commas
534 { $$ = parser_build_binary_op ($2, $1, $3); }
535 | expr_no_commas ANDAND
536 { $1 = truthvalue_conversion (default_conversion ($1));
537 skip_evaluation += $1 == boolean_false_node; }
538 expr_no_commas
539 { skip_evaluation -= $1 == boolean_false_node;
540 $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $4); }
541 | expr_no_commas OROR
542 { $1 = truthvalue_conversion (default_conversion ($1));
543 skip_evaluation += $1 == boolean_true_node; }
544 expr_no_commas
545 { skip_evaluation -= $1 == boolean_true_node;
546 $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $4); }
547 | expr_no_commas '?'
548 { $1 = truthvalue_conversion (default_conversion ($1));
549 skip_evaluation += $1 == boolean_false_node; }
550 expr ':'
551 { skip_evaluation += (($1 == boolean_true_node)
552 - ($1 == boolean_false_node)); }
553 expr_no_commas
554 { skip_evaluation -= $1 == boolean_true_node;
555 $$ = build_conditional_expr ($1, $4, $7); }
556 | expr_no_commas '?'
557 { if (pedantic)
558 pedwarn ("ANSI C forbids omitting the middle term of a ?: expression");
559 /* Make sure first operand is calculated only once. */
560 $<ttype>2 = save_expr ($1);
561 $1 = truthvalue_conversion (default_conversion ($<ttype>2));
562 skip_evaluation += $1 == boolean_true_node; }
563 ':' expr_no_commas
564 { skip_evaluation -= $1 == boolean_true_node;
565 $$ = build_conditional_expr ($1, $<ttype>2, $5); }
566 | expr_no_commas '=' expr_no_commas
567 { $$ = build_modify_expr ($1, NOP_EXPR, $3);
568 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
569 | expr_no_commas ASSIGN expr_no_commas
570 { $$ = build_modify_expr ($1, $2, $3);
571 /* This inhibits warnings in truthvalue_conversion. */
572 C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK); }
575 primary:
576 IDENTIFIER
578 $$ = lastiddecl;
579 if (!$$ || $$ == error_mark_node)
581 if (yychar == YYEMPTY)
582 yychar = YYLEX;
583 if (yychar == '(')
586 /* Ordinary implicit function declaration. */
587 $$ = implicitly_declare ($1);
588 assemble_external ($$);
589 TREE_USED ($$) = 1;
592 else if (current_function_decl == 0)
594 error ("`%s' undeclared here (not in a function)",
595 IDENTIFIER_POINTER ($1));
596 $$ = error_mark_node;
598 else
601 if (IDENTIFIER_GLOBAL_VALUE ($1) != error_mark_node
602 || IDENTIFIER_ERROR_LOCUS ($1) != current_function_decl)
604 error ("`%s' undeclared (first use in this function)",
605 IDENTIFIER_POINTER ($1));
607 if (! undeclared_variable_notice)
609 error ("(Each undeclared identifier is reported only once");
610 error ("for each function it appears in.)");
611 undeclared_variable_notice = 1;
614 $$ = error_mark_node;
615 /* Prevent repeated error messages. */
616 IDENTIFIER_GLOBAL_VALUE ($1) = error_mark_node;
617 IDENTIFIER_ERROR_LOCUS ($1) = current_function_decl;
621 else if (TREE_TYPE ($$) == error_mark_node)
622 $$ = error_mark_node;
623 else if (C_DECL_ANTICIPATED ($$))
625 /* The first time we see a build-in function used,
626 if it has not been declared. */
627 C_DECL_ANTICIPATED ($$) = 0;
628 if (yychar == YYEMPTY)
629 yychar = YYLEX;
630 if (yychar == '(')
632 /* Omit the implicit declaration we
633 would ordinarily do, so we don't lose
634 the actual built in type.
635 But print a diagnostic for the mismatch. */
636 if (TREE_CODE ($$) != FUNCTION_DECL)
637 error ("`%s' implicitly declared as function",
638 IDENTIFIER_POINTER (DECL_NAME ($$)));
639 else if ((TYPE_MODE (TREE_TYPE (TREE_TYPE ($$)))
640 != TYPE_MODE (integer_type_node))
641 && (TREE_TYPE (TREE_TYPE ($$))
642 != void_type_node))
643 pedwarn ("type mismatch in implicit declaration for built-in function `%s'",
644 IDENTIFIER_POINTER (DECL_NAME ($$)));
645 /* If it really returns void, change that to int. */
646 if (TREE_TYPE (TREE_TYPE ($$)) == void_type_node)
647 TREE_TYPE ($$)
648 = build_function_type (integer_type_node,
649 TYPE_ARG_TYPES (TREE_TYPE ($$)));
651 else
652 pedwarn ("built-in function `%s' used without declaration",
653 IDENTIFIER_POINTER (DECL_NAME ($$)));
655 /* Do what we would ordinarily do when a fn is used. */
656 assemble_external ($$);
657 TREE_USED ($$) = 1;
659 else
661 assemble_external ($$);
662 TREE_USED ($$) = 1;
665 if (TREE_CODE ($$) == CONST_DECL)
667 $$ = DECL_INITIAL ($$);
668 /* This is to prevent an enum whose value is 0
669 from being considered a null pointer constant. */
670 $$ = build1 (NOP_EXPR, TREE_TYPE ($$), $$);
671 TREE_CONSTANT ($$) = 1;
674 | CONSTANT
675 | string
676 { $$ = combine_strings ($1); }
677 | '(' expr ')'
678 { char class = TREE_CODE_CLASS (TREE_CODE ($2));
679 if (class == 'e' || class == '1'
680 || class == '2' || class == '<')
681 C_SET_EXP_ORIGINAL_CODE ($2, ERROR_MARK);
682 $$ = $2; }
683 | '(' error ')'
684 { $$ = error_mark_node; }
685 | '('
686 { if (current_function_decl == 0)
688 error ("braced-group within expression allowed only inside a function");
689 YYERROR;
691 /* We must force a BLOCK for this level
692 so that, if it is not expanded later,
693 there is a way to turn off the entire subtree of blocks
694 that are contained in it. */
695 keep_next_level ();
696 push_iterator_stack ();
697 push_label_level ();
698 $<ttype>$ = expand_start_stmt_expr (); }
699 compstmt ')'
700 { tree rtl_exp;
701 if (pedantic)
702 pedwarn ("ANSI C forbids braced-groups within expressions");
703 pop_iterator_stack ();
704 pop_label_level ();
705 rtl_exp = expand_end_stmt_expr ($<ttype>2);
706 /* The statements have side effects, so the group does. */
707 TREE_SIDE_EFFECTS (rtl_exp) = 1;
709 if (TREE_CODE ($3) == BLOCK)
711 /* Make a BIND_EXPR for the BLOCK already made. */
712 $$ = build (BIND_EXPR, TREE_TYPE (rtl_exp),
713 NULL_TREE, rtl_exp, $3);
714 /* Remove the block from the tree at this point.
715 It gets put back at the proper place
716 when the BIND_EXPR is expanded. */
717 delete_block ($3);
719 else
720 $$ = $3;
722 | primary '(' exprlist ')' %prec '.'
723 { $$ = build_function_call ($1, $3); }
724 | primary '[' expr ']' %prec '.'
725 { $$ = build_array_ref ($1, $3); }
726 | primary '.' identifier
728 $$ = build_component_ref ($1, $3);
730 | primary POINTSAT identifier
732 tree expr = build_indirect_ref ($1, "->");
734 $$ = build_component_ref (expr, $3);
736 | primary PLUSPLUS
737 { $$ = build_unary_op (POSTINCREMENT_EXPR, $1, 0); }
738 | primary MINUSMINUS
739 { $$ = build_unary_op (POSTDECREMENT_EXPR, $1, 0); }
742 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
743 string:
744 STRING
745 | string STRING
746 { $$ = chainon ($1, $2); }
750 old_style_parm_decls:
751 /* empty */
752 | datadecls
753 | datadecls ELLIPSIS
754 /* ... is used here to indicate a varargs function. */
755 { c_mark_varargs ();
756 if (pedantic)
757 pedwarn ("ANSI C does not permit use of `varargs.h'"); }
760 /* The following are analogous to lineno_decl, decls and decl
761 except that they do not allow nested functions.
762 They are used for old-style parm decls. */
763 lineno_datadecl:
764 save_filename save_lineno datadecl
768 datadecls:
769 lineno_datadecl
770 | errstmt
771 | datadecls lineno_datadecl
772 | lineno_datadecl errstmt
775 /* We don't allow prefix attributes here because they cause reduce/reduce
776 conflicts: we can't know whether we're parsing a function decl with
777 attribute suffix, or function defn with attribute prefix on first old
778 style parm. */
779 datadecl:
780 typed_declspecs_no_prefix_attr setspecs initdecls ';'
781 { current_declspecs = TREE_VALUE (declspec_stack);
782 prefix_attributes = TREE_PURPOSE (declspec_stack);
783 declspec_stack = TREE_CHAIN (declspec_stack);
784 resume_momentary ($2); }
785 | declmods_no_prefix_attr setspecs notype_initdecls ';'
786 { current_declspecs = TREE_VALUE (declspec_stack);
787 prefix_attributes = TREE_PURPOSE (declspec_stack);
788 declspec_stack = TREE_CHAIN (declspec_stack);
789 resume_momentary ($2); }
790 | typed_declspecs_no_prefix_attr ';'
791 { shadow_tag_warned ($1, 1);
792 pedwarn ("empty declaration"); }
793 | declmods_no_prefix_attr ';'
794 { pedwarn ("empty declaration"); }
797 /* This combination which saves a lineno before a decl
798 is the normal thing to use, rather than decl itself.
799 This is to avoid shift/reduce conflicts in contexts
800 where statement labels are allowed. */
801 lineno_decl:
802 save_filename save_lineno decl
806 decls:
807 lineno_decl
808 | errstmt
809 | decls lineno_decl
810 | lineno_decl errstmt
813 /* records the type and storage class specs to use for processing
814 the declarators that follow.
815 Maintains a stack of outer-level values of current_declspecs,
816 for the sake of parm declarations nested in function declarators. */
817 setspecs: /* empty */
818 { $$ = suspend_momentary ();
819 pending_xref_error ();
820 declspec_stack = tree_cons (prefix_attributes,
821 current_declspecs,
822 declspec_stack);
823 split_specs_attrs ($<ttype>0,
824 &current_declspecs, &prefix_attributes); }
827 /* ??? Yuck. See after_type_declarator. */
828 setattrs: /* empty */
829 { prefix_attributes = chainon (prefix_attributes, $<ttype>0); }
832 decl:
833 typed_declspecs setspecs initdecls ';'
834 { current_declspecs = TREE_VALUE (declspec_stack);
835 prefix_attributes = TREE_PURPOSE (declspec_stack);
836 declspec_stack = TREE_CHAIN (declspec_stack);
837 resume_momentary ($2); }
838 | declmods setspecs notype_initdecls ';'
839 { current_declspecs = TREE_VALUE (declspec_stack);
840 prefix_attributes = TREE_PURPOSE (declspec_stack);
841 declspec_stack = TREE_CHAIN (declspec_stack);
842 resume_momentary ($2); }
843 | typed_declspecs setspecs nested_function
844 { current_declspecs = TREE_VALUE (declspec_stack);
845 prefix_attributes = TREE_PURPOSE (declspec_stack);
846 declspec_stack = TREE_CHAIN (declspec_stack);
847 resume_momentary ($2); }
848 | declmods setspecs notype_nested_function
849 { current_declspecs = TREE_VALUE (declspec_stack);
850 prefix_attributes = TREE_PURPOSE (declspec_stack);
851 declspec_stack = TREE_CHAIN (declspec_stack);
852 resume_momentary ($2); }
853 | typed_declspecs ';'
854 { shadow_tag ($1); }
855 | declmods ';'
856 { pedwarn ("empty declaration"); }
857 | extension decl
858 { pedantic = $<itype>1; }
861 /* Declspecs which contain at least one type specifier or typedef name.
862 (Just `const' or `volatile' is not enough.)
863 A typedef'd name following these is taken as a name to be declared.
864 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
866 typed_declspecs:
867 typespec reserved_declspecs
868 { $$ = tree_cons (NULL_TREE, $1, $2); }
869 | declmods typespec reserved_declspecs
870 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
873 reserved_declspecs: /* empty */
874 { $$ = NULL_TREE; }
875 | reserved_declspecs typespecqual_reserved
876 { $$ = tree_cons (NULL_TREE, $2, $1); }
877 | reserved_declspecs SCSPEC
878 { if (extra_warnings)
879 warning ("`%s' is not at beginning of declaration",
880 IDENTIFIER_POINTER ($2));
881 $$ = tree_cons (NULL_TREE, $2, $1); }
882 | reserved_declspecs attributes
883 { $$ = tree_cons ($2, NULL_TREE, $1); }
886 typed_declspecs_no_prefix_attr:
887 typespec reserved_declspecs_no_prefix_attr
888 { $$ = tree_cons (NULL_TREE, $1, $2); }
889 | declmods_no_prefix_attr typespec reserved_declspecs_no_prefix_attr
890 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
893 reserved_declspecs_no_prefix_attr:
894 /* empty */
895 { $$ = NULL_TREE; }
896 | reserved_declspecs_no_prefix_attr typespecqual_reserved
897 { $$ = tree_cons (NULL_TREE, $2, $1); }
898 | reserved_declspecs_no_prefix_attr SCSPEC
899 { if (extra_warnings)
900 warning ("`%s' is not at beginning of declaration",
901 IDENTIFIER_POINTER ($2));
902 $$ = tree_cons (NULL_TREE, $2, $1); }
905 /* List of just storage classes, type modifiers, and prefix attributes.
906 A declaration can start with just this, but then it cannot be used
907 to redeclare a typedef-name.
908 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
910 declmods:
911 declmods_no_prefix_attr
912 { $$ = $1; }
913 | attributes
914 { $$ = tree_cons ($1, NULL_TREE, NULL_TREE); }
915 | declmods declmods_no_prefix_attr
916 { $$ = chainon ($2, $1); }
917 | declmods attributes
918 { $$ = tree_cons ($2, NULL_TREE, $1); }
921 declmods_no_prefix_attr:
922 TYPE_QUAL
923 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
924 TREE_STATIC ($$) = 1; }
925 | SCSPEC
926 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
927 | declmods_no_prefix_attr TYPE_QUAL
928 { $$ = tree_cons (NULL_TREE, $2, $1);
929 TREE_STATIC ($$) = 1; }
930 | declmods_no_prefix_attr SCSPEC
931 { if (extra_warnings && TREE_STATIC ($1))
932 warning ("`%s' is not at beginning of declaration",
933 IDENTIFIER_POINTER ($2));
934 $$ = tree_cons (NULL_TREE, $2, $1);
935 TREE_STATIC ($$) = TREE_STATIC ($1); }
939 /* Used instead of declspecs where storage classes are not allowed
940 (that is, for typenames and structure components).
941 Don't accept a typedef-name if anything but a modifier precedes it. */
943 typed_typespecs:
944 typespec reserved_typespecquals
945 { $$ = tree_cons (NULL_TREE, $1, $2); }
946 | nonempty_type_quals typespec reserved_typespecquals
947 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
950 reserved_typespecquals: /* empty */
951 { $$ = NULL_TREE; }
952 | reserved_typespecquals typespecqual_reserved
953 { $$ = tree_cons (NULL_TREE, $2, $1); }
956 /* A typespec (but not a type qualifier).
957 Once we have seen one of these in a declaration,
958 if a typedef name appears then it is being redeclared. */
960 typespec: TYPESPEC
961 | structsp
962 | TYPENAME
963 { /* For a typedef name, record the meaning, not the name.
964 In case of `foo foo, bar;'. */
965 $$ = lookup_name ($1); }
966 | TYPEOF '(' expr ')'
967 { $$ = TREE_TYPE ($3); }
968 | TYPEOF '(' typename ')'
969 { $$ = groktypename ($3); }
972 /* A typespec that is a reserved word, or a type qualifier. */
974 typespecqual_reserved: TYPESPEC
975 | TYPE_QUAL
976 | structsp
979 initdecls:
980 initdcl
981 | initdecls ',' initdcl
984 notype_initdecls:
985 notype_initdcl
986 | notype_initdecls ',' initdcl
989 maybeasm:
990 /* empty */
991 { $$ = NULL_TREE; }
992 | ASM_KEYWORD '(' string ')'
993 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
994 $$ = $3;
998 initdcl:
999 declarator maybeasm maybe_attribute '='
1000 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1001 $3, prefix_attributes);
1002 start_init ($<ttype>$, $2, global_bindings_p ()); }
1003 init
1004 /* Note how the declaration of the variable is in effect while its init is parsed! */
1005 { finish_init ();
1006 finish_decl ($<ttype>5, $6, $2); }
1007 | declarator maybeasm maybe_attribute
1008 { tree d = start_decl ($1, current_declspecs, 0,
1009 $3, prefix_attributes);
1010 finish_decl (d, NULL_TREE, $2);
1014 notype_initdcl:
1015 notype_declarator maybeasm maybe_attribute '='
1016 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1017 $3, prefix_attributes);
1018 start_init ($<ttype>$, $2, global_bindings_p ()); }
1019 init
1020 /* Note how the declaration of the variable is in effect while its init is parsed! */
1021 { finish_init ();
1022 decl_attributes ($<ttype>5, $3, prefix_attributes);
1023 finish_decl ($<ttype>5, $6, $2); }
1024 | notype_declarator maybeasm maybe_attribute
1025 { tree d = start_decl ($1, current_declspecs, 0,
1026 $3, prefix_attributes);
1027 finish_decl (d, NULL_TREE, $2); }
1029 /* the * rules are dummies to accept the Apollo extended syntax
1030 so that the header files compile. */
1031 maybe_attribute:
1032 /* empty */
1033 { $$ = NULL_TREE; }
1034 | attributes
1035 { $$ = $1; }
1038 attributes:
1039 attribute
1040 { $$ = $1; }
1041 | attributes attribute
1042 { $$ = chainon ($1, $2); }
1045 attribute:
1046 ATTRIBUTE '(' '(' attribute_list ')' ')'
1047 { $$ = $4; }
1050 attribute_list:
1051 attrib
1052 { $$ = $1; }
1053 | attribute_list ',' attrib
1054 { $$ = chainon ($1, $3); }
1057 attrib:
1058 /* empty */
1059 { $$ = NULL_TREE; }
1060 | any_word
1061 { $$ = build_tree_list ($1, NULL_TREE); }
1062 | any_word '(' IDENTIFIER ')'
1063 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1064 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1065 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1066 | any_word '(' exprlist ')'
1067 { $$ = build_tree_list ($1, $3); }
1070 /* This still leaves out most reserved keywords,
1071 shouldn't we include them? */
1073 any_word:
1074 identifier
1075 | SCSPEC
1076 | TYPESPEC
1077 | TYPE_QUAL
1080 /* Initializers. `init' is the entry point. */
1082 init:
1083 expr_no_commas
1084 | '{'
1085 { really_start_incremental_init (NULL_TREE);
1086 /* Note that the call to clear_momentary
1087 is in process_init_element. */
1088 push_momentary (); }
1089 initlist_maybe_comma '}'
1090 { $$ = pop_init_level (0);
1091 if ($$ == error_mark_node
1092 && ! (yychar == STRING || yychar == CONSTANT))
1093 pop_momentary ();
1094 else
1095 pop_momentary_nofree (); }
1097 | error
1098 { $$ = error_mark_node; }
1101 /* `initlist_maybe_comma' is the guts of an initializer in braces. */
1102 initlist_maybe_comma:
1103 /* empty */
1104 { if (pedantic)
1105 pedwarn ("ANSI C forbids empty initializer braces"); }
1106 | initlist1 maybecomma
1109 initlist1:
1110 initelt
1111 | initlist1 ',' initelt
1114 /* `initelt' is a single element of an initializer.
1115 It may use braces. */
1116 initelt:
1117 expr_no_commas
1118 { process_init_element ($1); }
1119 | '{'
1120 { push_init_level (0); }
1121 initlist_maybe_comma '}'
1122 { process_init_element (pop_init_level (0)); }
1123 | error
1124 /* These are for labeled elements. The syntax for an array element
1125 initializer conflicts with the syntax for an Objective-C message,
1126 so don't include these productions in the Objective-C grammar. */
1127 | '[' expr_no_commas ELLIPSIS expr_no_commas ']' '='
1128 { set_init_index ($2, $4); }
1129 initelt
1130 | '[' expr_no_commas ']' '='
1131 { set_init_index ($2, NULL_TREE); }
1132 initelt
1133 | '[' expr_no_commas ']'
1134 { set_init_index ($2, NULL_TREE); }
1135 initelt
1136 | identifier ':'
1137 { set_init_label ($1); }
1138 initelt
1139 | '.' identifier '='
1140 { set_init_label ($2); }
1141 initelt
1144 nested_function:
1145 declarator
1146 { push_c_function_context ();
1147 if (! start_function (current_declspecs, $1,
1148 prefix_attributes, NULL_TREE, 1))
1150 pop_c_function_context ();
1151 YYERROR1;
1153 reinit_parse_for_function (); }
1154 old_style_parm_decls
1155 { store_parm_decls (); }
1156 /* This used to use compstmt_or_error.
1157 That caused a bug with input `f(g) int g {}',
1158 where the use of YYERROR1 above caused an error
1159 which then was handled by compstmt_or_error.
1160 There followed a repeated execution of that same rule,
1161 which called YYERROR1 again, and so on. */
1162 compstmt
1163 { finish_function (1);
1164 pop_c_function_context (); }
1167 notype_nested_function:
1168 notype_declarator
1169 { push_c_function_context ();
1170 if (! start_function (current_declspecs, $1,
1171 prefix_attributes, NULL_TREE, 1))
1173 pop_c_function_context ();
1174 YYERROR1;
1176 reinit_parse_for_function (); }
1177 old_style_parm_decls
1178 { store_parm_decls (); }
1179 /* This used to use compstmt_or_error.
1180 That caused a bug with input `f(g) int g {}',
1181 where the use of YYERROR1 above caused an error
1182 which then was handled by compstmt_or_error.
1183 There followed a repeated execution of that same rule,
1184 which called YYERROR1 again, and so on. */
1185 compstmt
1186 { finish_function (1);
1187 pop_c_function_context (); }
1190 /* Any kind of declarator (thus, all declarators allowed
1191 after an explicit typespec). */
1193 declarator:
1194 after_type_declarator
1195 | notype_declarator
1198 /* A declarator that is allowed only after an explicit typespec. */
1200 after_type_declarator:
1201 '(' after_type_declarator ')'
1202 { $$ = $2; }
1203 | after_type_declarator '(' parmlist_or_identifiers %prec '.'
1204 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1205 /* | after_type_declarator '(' error ')' %prec '.'
1206 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1207 poplevel (0, 0, 0); } */
1208 | after_type_declarator '[' expr ']' %prec '.'
1209 { $$ = build_nt (ARRAY_REF, $1, $3); }
1210 | after_type_declarator '[' ']' %prec '.'
1211 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1212 | '*' type_quals after_type_declarator %prec UNARY
1213 { $$ = make_pointer_declarator ($2, $3); }
1214 /* ??? Yuck. setattrs is a quick hack. We can't use
1215 prefix_attributes because $1 only applies to this
1216 declarator. We assume setspecs has already been done.
1217 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1218 attributes could be recognized here or in `attributes'). */
1219 | attributes setattrs after_type_declarator
1220 { $$ = $3; }
1221 | TYPENAME
1224 /* Kinds of declarator that can appear in a parameter list
1225 in addition to notype_declarator. This is like after_type_declarator
1226 but does not allow a typedef name in parentheses as an identifier
1227 (because it would conflict with a function with that typedef as arg). */
1229 parm_declarator:
1230 parm_declarator '(' parmlist_or_identifiers %prec '.'
1231 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1232 /* | parm_declarator '(' error ')' %prec '.'
1233 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1234 poplevel (0, 0, 0); } */
1235 | parm_declarator '[' expr ']' %prec '.'
1236 { $$ = build_nt (ARRAY_REF, $1, $3); }
1237 | parm_declarator '[' ']' %prec '.'
1238 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1239 | '*' type_quals parm_declarator %prec UNARY
1240 { $$ = make_pointer_declarator ($2, $3); }
1241 /* ??? Yuck. setattrs is a quick hack. We can't use
1242 prefix_attributes because $1 only applies to this
1243 declarator. We assume setspecs has already been done.
1244 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1245 attributes could be recognized here or in `attributes'). */
1246 | attributes setattrs parm_declarator
1247 { $$ = $3; }
1248 | TYPENAME
1251 /* A declarator allowed whether or not there has been
1252 an explicit typespec. These cannot redeclare a typedef-name. */
1254 notype_declarator:
1255 notype_declarator '(' parmlist_or_identifiers %prec '.'
1256 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1257 /* | notype_declarator '(' error ')' %prec '.'
1258 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1259 poplevel (0, 0, 0); } */
1260 | '(' notype_declarator ')'
1261 { $$ = $2; }
1262 | '*' type_quals notype_declarator %prec UNARY
1263 { $$ = make_pointer_declarator ($2, $3); }
1264 | notype_declarator '[' expr ']' %prec '.'
1265 { $$ = build_nt (ARRAY_REF, $1, $3); }
1266 | notype_declarator '[' ']' %prec '.'
1267 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1268 /* ??? Yuck. setattrs is a quick hack. We can't use
1269 prefix_attributes because $1 only applies to this
1270 declarator. We assume setspecs has already been done.
1271 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1272 attributes could be recognized here or in `attributes'). */
1273 | attributes setattrs notype_declarator
1274 { $$ = $3; }
1275 | IDENTIFIER
1278 structsp:
1279 STRUCT identifier '{'
1280 { $$ = start_struct (RECORD_TYPE, $2);
1281 /* Start scope of tag before parsing components. */
1283 component_decl_list '}' maybe_attribute
1284 { $$ = finish_struct ($<ttype>4, $5, $7); }
1285 | STRUCT '{' component_decl_list '}' maybe_attribute
1286 { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
1287 $3, $5);
1289 | STRUCT identifier
1290 { $$ = xref_tag (RECORD_TYPE, $2); }
1291 | UNION identifier '{'
1292 { $$ = start_struct (UNION_TYPE, $2); }
1293 component_decl_list '}' maybe_attribute
1294 { $$ = finish_struct ($<ttype>4, $5, $7); }
1295 | UNION '{' component_decl_list '}' maybe_attribute
1296 { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
1297 $3, $5);
1299 | UNION identifier
1300 { $$ = xref_tag (UNION_TYPE, $2); }
1301 | ENUM identifier '{'
1302 { $<itype>3 = suspend_momentary ();
1303 $$ = start_enum ($2); }
1304 enumlist maybecomma_warn '}' maybe_attribute
1305 { $$ = finish_enum ($<ttype>4, nreverse ($5), $8);
1306 resume_momentary ($<itype>3); }
1307 | ENUM '{'
1308 { $<itype>2 = suspend_momentary ();
1309 $$ = start_enum (NULL_TREE); }
1310 enumlist maybecomma_warn '}' maybe_attribute
1311 { $$ = finish_enum ($<ttype>3, nreverse ($4), $7);
1312 resume_momentary ($<itype>2); }
1313 | ENUM identifier
1314 { $$ = xref_tag (ENUMERAL_TYPE, $2); }
1317 maybecomma:
1318 /* empty */
1319 | ','
1322 maybecomma_warn:
1323 /* empty */
1324 | ','
1325 { if (pedantic) pedwarn ("comma at end of enumerator list"); }
1328 component_decl_list:
1329 component_decl_list2
1330 { $$ = $1; }
1331 | component_decl_list2 component_decl
1332 { $$ = chainon ($1, $2);
1333 pedwarn ("no semicolon at end of struct or union"); }
1336 component_decl_list2: /* empty */
1337 { $$ = NULL_TREE; }
1338 | component_decl_list2 component_decl ';'
1339 { $$ = chainon ($1, $2); }
1340 | component_decl_list2 ';'
1341 { if (pedantic)
1342 pedwarn ("extra semicolon in struct or union specified"); }
1345 /* There is a shift-reduce conflict here, because `components' may
1346 start with a `typename'. It happens that shifting (the default resolution)
1347 does the right thing, because it treats the `typename' as part of
1348 a `typed_typespecs'.
1350 It is possible that this same technique would allow the distinction
1351 between `notype_initdecls' and `initdecls' to be eliminated.
1352 But I am being cautious and not trying it. */
1354 component_decl:
1355 typed_typespecs setspecs components
1356 { $$ = $3;
1357 current_declspecs = TREE_VALUE (declspec_stack);
1358 prefix_attributes = TREE_PURPOSE (declspec_stack);
1359 declspec_stack = TREE_CHAIN (declspec_stack);
1360 resume_momentary ($2); }
1361 | typed_typespecs
1362 { if (pedantic)
1363 pedwarn ("ANSI C forbids member declarations with no members");
1364 shadow_tag($1);
1365 $$ = NULL_TREE; }
1366 | nonempty_type_quals setspecs components
1367 { $$ = $3;
1368 current_declspecs = TREE_VALUE (declspec_stack);
1369 prefix_attributes = TREE_PURPOSE (declspec_stack);
1370 declspec_stack = TREE_CHAIN (declspec_stack);
1371 resume_momentary ($2); }
1372 | nonempty_type_quals
1373 { if (pedantic)
1374 pedwarn ("ANSI C forbids member declarations with no members");
1375 shadow_tag($1);
1376 $$ = NULL_TREE; }
1377 | error
1378 { $$ = NULL_TREE; }
1379 | extension component_decl
1380 { $$ = $2;
1381 pedantic = $<itype>1; }
1384 components:
1385 component_declarator
1386 | components ',' component_declarator
1387 { $$ = chainon ($1, $3); }
1390 component_declarator:
1391 save_filename save_lineno declarator maybe_attribute
1392 { $$ = grokfield ($1, $2, $3, current_declspecs, NULL_TREE);
1393 decl_attributes ($$, $4, prefix_attributes); }
1394 | save_filename save_lineno
1395 declarator ':' expr_no_commas maybe_attribute
1396 { $$ = grokfield ($1, $2, $3, current_declspecs, $5);
1397 decl_attributes ($$, $6, prefix_attributes); }
1398 | save_filename save_lineno ':' expr_no_commas maybe_attribute
1399 { $$ = grokfield ($1, $2, NULL_TREE, current_declspecs, $4);
1400 decl_attributes ($$, $5, prefix_attributes); }
1403 /* We chain the enumerators in reverse order.
1404 They are put in forward order where enumlist is used.
1405 (The order used to be significant, but no longer is so.
1406 However, we still maintain the order, just to be clean.) */
1408 enumlist:
1409 enumerator
1410 | enumlist ',' enumerator
1411 { if ($1 == error_mark_node)
1412 $$ = $1;
1413 else
1414 $$ = chainon ($3, $1); }
1415 | error
1416 { $$ = error_mark_node; }
1420 enumerator:
1421 identifier
1422 { $$ = build_enumerator ($1, NULL_TREE); }
1423 | identifier '=' expr_no_commas
1424 { $$ = build_enumerator ($1, $3); }
1427 typename:
1428 typed_typespecs absdcl
1429 { $$ = build_tree_list ($1, $2); }
1430 | nonempty_type_quals absdcl
1431 { $$ = build_tree_list ($1, $2); }
1434 absdcl: /* an absolute declarator */
1435 /* empty */
1436 { $$ = NULL_TREE; }
1437 | absdcl1
1440 nonempty_type_quals:
1441 TYPE_QUAL
1442 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
1443 | nonempty_type_quals TYPE_QUAL
1444 { $$ = tree_cons (NULL_TREE, $2, $1); }
1447 type_quals:
1448 /* empty */
1449 { $$ = NULL_TREE; }
1450 | type_quals TYPE_QUAL
1451 { $$ = tree_cons (NULL_TREE, $2, $1); }
1454 absdcl1: /* a nonempty absolute declarator */
1455 '(' absdcl1 ')'
1456 { $$ = $2; }
1457 /* `(typedef)1' is `int'. */
1458 | '*' type_quals absdcl1 %prec UNARY
1459 { $$ = make_pointer_declarator ($2, $3); }
1460 | '*' type_quals %prec UNARY
1461 { $$ = make_pointer_declarator ($2, NULL_TREE); }
1462 | absdcl1 '(' parmlist %prec '.'
1463 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1464 | absdcl1 '[' expr ']' %prec '.'
1465 { $$ = build_nt (ARRAY_REF, $1, $3); }
1466 | absdcl1 '[' ']' %prec '.'
1467 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1468 | '(' parmlist %prec '.'
1469 { $$ = build_nt (CALL_EXPR, NULL_TREE, $2, NULL_TREE); }
1470 | '[' expr ']' %prec '.'
1471 { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
1472 | '[' ']' %prec '.'
1473 { $$ = build_nt (ARRAY_REF, NULL_TREE, NULL_TREE); }
1474 /* ??? It appears we have to support attributes here, however
1475 using prefix_attributes is wrong. */
1478 /* at least one statement, the first of which parses without error. */
1479 /* stmts is used only after decls, so an invalid first statement
1480 is actually regarded as an invalid decl and part of the decls. */
1482 stmts:
1483 lineno_stmt_or_labels
1485 if (pedantic && $1)
1486 pedwarn ("ANSI C forbids label at end of compound statement");
1490 lineno_stmt_or_labels:
1491 lineno_stmt_or_label
1492 | lineno_stmt_or_labels lineno_stmt_or_label
1493 { $$ = $2; }
1494 | lineno_stmt_or_labels errstmt
1495 { $$ = 0; }
1498 xstmts:
1499 /* empty */
1500 | stmts
1503 errstmt: error ';'
1506 pushlevel: /* empty */
1507 { emit_line_note (input_filename, lineno);
1508 pushlevel (0);
1509 clear_last_expr ();
1510 push_momentary ();
1511 expand_start_bindings (0);
1515 /* Read zero or more forward-declarations for labels
1516 that nested functions can jump to. */
1517 maybe_label_decls:
1518 /* empty */
1519 | label_decls
1520 { if (pedantic)
1521 pedwarn ("ANSI C forbids label declarations"); }
1524 label_decls:
1525 label_decl
1526 | label_decls label_decl
1529 label_decl:
1530 LABEL identifiers_or_typenames ';'
1531 { tree link;
1532 for (link = $2; link; link = TREE_CHAIN (link))
1534 tree label = shadow_label (TREE_VALUE (link));
1535 C_DECLARED_LABEL_FLAG (label) = 1;
1536 declare_nonlocal_label (label);
1541 /* This is the body of a function definition.
1542 It causes syntax errors to ignore to the next openbrace. */
1543 compstmt_or_error:
1544 compstmt
1546 | error compstmt
1549 compstmt_start: '{' { compstmt_count++; }
1551 compstmt: compstmt_start '}'
1552 { $$ = convert (void_type_node, integer_zero_node); }
1553 | compstmt_start pushlevel maybe_label_decls decls xstmts '}'
1554 { emit_line_note (input_filename, lineno);
1555 expand_end_bindings (getdecls (), 1, 0);
1556 $$ = poplevel (1, 1, 0);
1557 if (yychar == CONSTANT || yychar == STRING)
1558 pop_momentary_nofree ();
1559 else
1560 pop_momentary (); }
1561 | compstmt_start pushlevel maybe_label_decls error '}'
1562 { emit_line_note (input_filename, lineno);
1563 expand_end_bindings (getdecls (), kept_level_p (), 0);
1564 $$ = poplevel (kept_level_p (), 0, 0);
1565 if (yychar == CONSTANT || yychar == STRING)
1566 pop_momentary_nofree ();
1567 else
1568 pop_momentary (); }
1569 | compstmt_start pushlevel maybe_label_decls stmts '}'
1570 { emit_line_note (input_filename, lineno);
1571 expand_end_bindings (getdecls (), kept_level_p (), 0);
1572 $$ = poplevel (kept_level_p (), 0, 0);
1573 if (yychar == CONSTANT || yychar == STRING)
1574 pop_momentary_nofree ();
1575 else
1576 pop_momentary (); }
1579 /* Value is number of statements counted as of the closeparen. */
1580 simple_if:
1581 if_prefix lineno_labeled_stmt
1582 /* Make sure c_expand_end_cond is run once
1583 for each call to c_expand_start_cond.
1584 Otherwise a crash is likely. */
1585 | if_prefix error
1588 if_prefix:
1589 IF '(' expr ')'
1590 { emit_line_note ($<filename>-1, $<lineno>0);
1591 c_expand_start_cond (truthvalue_conversion ($3), 0,
1592 compstmt_count);
1593 $<itype>$ = stmt_count;
1594 if_stmt_file = $<filename>-1;
1595 if_stmt_line = $<lineno>0;
1596 position_after_white_space (); }
1599 /* This is a subroutine of stmt.
1600 It is used twice, once for valid DO statements
1601 and once for catching errors in parsing the end test. */
1602 do_stmt_start:
1604 { stmt_count++;
1605 compstmt_count++;
1606 emit_line_note ($<filename>-1, $<lineno>0);
1607 /* See comment in `while' alternative, above. */
1608 emit_nop ();
1609 expand_start_loop_continue_elsewhere (1);
1610 position_after_white_space (); }
1611 lineno_labeled_stmt WHILE
1612 { expand_loop_continue_here (); }
1615 save_filename:
1616 { $$ = input_filename; }
1619 save_lineno:
1620 { $$ = lineno; }
1623 lineno_labeled_stmt:
1624 save_filename save_lineno stmt
1626 /* | save_filename save_lineno error
1629 | save_filename save_lineno label lineno_labeled_stmt
1633 lineno_stmt_or_label:
1634 save_filename save_lineno stmt_or_label
1635 { $$ = $3; }
1638 stmt_or_label:
1639 stmt
1640 { $$ = 0; }
1641 | label
1642 { $$ = 1; }
1645 /* Parse a single real statement, not including any labels. */
1646 stmt:
1647 compstmt
1648 { stmt_count++; }
1649 | all_iter_stmt
1650 | expr ';'
1651 { stmt_count++;
1652 emit_line_note ($<filename>-1, $<lineno>0);
1653 /* It appears that this should not be done--that a non-lvalue array
1654 shouldn't get an error if the value isn't used.
1655 Section 3.2.2.1 says that an array lvalue gets converted to a pointer
1656 if it appears as a top-level expression,
1657 but says nothing about non-lvalue arrays. */
1658 #if 0
1659 /* Call default_conversion to get an error
1660 on referring to a register array if pedantic. */
1661 if (TREE_CODE (TREE_TYPE ($1)) == ARRAY_TYPE
1662 || TREE_CODE (TREE_TYPE ($1)) == FUNCTION_TYPE)
1663 $1 = default_conversion ($1);
1664 #endif
1665 iterator_expand ($1);
1666 clear_momentary (); }
1667 | simple_if ELSE
1668 { c_expand_start_else ();
1669 $<itype>1 = stmt_count;
1670 position_after_white_space (); }
1671 lineno_labeled_stmt
1672 { c_expand_end_cond ();
1673 if (extra_warnings && stmt_count == $<itype>1)
1674 warning ("empty body in an else-statement"); }
1675 | simple_if %prec IF
1676 { c_expand_end_cond ();
1677 /* This warning is here instead of in simple_if, because we
1678 do not want a warning if an empty if is followed by an
1679 else statement. Increment stmt_count so we don't
1680 give a second error if this is a nested `if'. */
1681 if (extra_warnings && stmt_count++ == $<itype>1)
1682 warning_with_file_and_line (if_stmt_file, if_stmt_line,
1683 "empty body in an if-statement"); }
1684 /* Make sure c_expand_end_cond is run once
1685 for each call to c_expand_start_cond.
1686 Otherwise a crash is likely. */
1687 | simple_if ELSE error
1688 { c_expand_end_cond (); }
1689 | WHILE
1690 { stmt_count++;
1691 emit_line_note ($<filename>-1, $<lineno>0);
1692 /* The emit_nop used to come before emit_line_note,
1693 but that made the nop seem like part of the preceding line.
1694 And that was confusing when the preceding line was
1695 inside of an if statement and was not really executed.
1696 I think it ought to work to put the nop after the line number.
1697 We will see. --rms, July 15, 1991. */
1698 emit_nop (); }
1699 '(' expr ')'
1700 { /* Don't start the loop till we have succeeded
1701 in parsing the end test. This is to make sure
1702 that we end every loop we start. */
1703 expand_start_loop (1);
1704 emit_line_note (input_filename, lineno);
1705 expand_exit_loop_if_false (NULL_PTR,
1706 truthvalue_conversion ($4));
1707 position_after_white_space (); }
1708 lineno_labeled_stmt
1709 { expand_end_loop (); }
1710 | do_stmt_start
1711 '(' expr ')' ';'
1712 { emit_line_note (input_filename, lineno);
1713 expand_exit_loop_if_false (NULL_PTR,
1714 truthvalue_conversion ($3));
1715 expand_end_loop ();
1716 clear_momentary (); }
1717 /* This rule is needed to make sure we end every loop we start. */
1718 | do_stmt_start error
1719 { expand_end_loop ();
1720 clear_momentary (); }
1721 | FOR
1722 '(' xexpr ';'
1723 { stmt_count++;
1724 emit_line_note ($<filename>-1, $<lineno>0);
1725 /* See comment in `while' alternative, above. */
1726 emit_nop ();
1727 if ($3) c_expand_expr_stmt ($3);
1728 /* Next step is to call expand_start_loop_continue_elsewhere,
1729 but wait till after we parse the entire for (...).
1730 Otherwise, invalid input might cause us to call that
1731 fn without calling expand_end_loop. */
1733 xexpr ';'
1734 /* Can't emit now; wait till after expand_start_loop... */
1735 { $<lineno>7 = lineno;
1736 $<filename>$ = input_filename; }
1737 xexpr ')'
1739 /* Start the loop. Doing this after parsing
1740 all the expressions ensures we will end the loop. */
1741 expand_start_loop_continue_elsewhere (1);
1742 /* Emit the end-test, with a line number. */
1743 emit_line_note ($<filename>8, $<lineno>7);
1744 if ($6)
1745 expand_exit_loop_if_false (NULL_PTR,
1746 truthvalue_conversion ($6));
1747 /* Don't let the tree nodes for $9 be discarded by
1748 clear_momentary during the parsing of the next stmt. */
1749 push_momentary ();
1750 $<lineno>7 = lineno;
1751 $<filename>8 = input_filename;
1752 position_after_white_space (); }
1753 lineno_labeled_stmt
1754 { /* Emit the increment expression, with a line number. */
1755 emit_line_note ($<filename>8, $<lineno>7);
1756 expand_loop_continue_here ();
1757 if ($9)
1758 c_expand_expr_stmt ($9);
1759 if (yychar == CONSTANT || yychar == STRING)
1760 pop_momentary_nofree ();
1761 else
1762 pop_momentary ();
1763 expand_end_loop (); }
1764 | SWITCH '(' expr ')'
1765 { stmt_count++;
1766 emit_line_note ($<filename>-1, $<lineno>0);
1767 c_expand_start_case ($3);
1768 /* Don't let the tree nodes for $3 be discarded by
1769 clear_momentary during the parsing of the next stmt. */
1770 push_momentary ();
1771 position_after_white_space (); }
1772 lineno_labeled_stmt
1773 { expand_end_case ($3);
1774 if (yychar == CONSTANT || yychar == STRING)
1775 pop_momentary_nofree ();
1776 else
1777 pop_momentary (); }
1778 | BREAK ';'
1779 { stmt_count++;
1780 emit_line_note ($<filename>-1, $<lineno>0);
1781 if ( ! expand_exit_something ())
1782 error ("break statement not within loop or switch"); }
1783 | CONTINUE ';'
1784 { stmt_count++;
1785 emit_line_note ($<filename>-1, $<lineno>0);
1786 if (! expand_continue_loop (NULL_PTR))
1787 error ("continue statement not within a loop"); }
1788 | RETURN ';'
1789 { stmt_count++;
1790 emit_line_note ($<filename>-1, $<lineno>0);
1791 c_expand_return (NULL_TREE); }
1792 | RETURN expr ';'
1793 { stmt_count++;
1794 emit_line_note ($<filename>-1, $<lineno>0);
1795 c_expand_return ($2); }
1796 | ASM_KEYWORD maybe_type_qual '(' expr ')' ';'
1797 { stmt_count++;
1798 emit_line_note ($<filename>-1, $<lineno>0);
1799 STRIP_NOPS ($4);
1800 if ((TREE_CODE ($4) == ADDR_EXPR
1801 && TREE_CODE (TREE_OPERAND ($4, 0)) == STRING_CST)
1802 || TREE_CODE ($4) == STRING_CST)
1803 expand_asm ($4);
1804 else
1805 error ("argument of `asm' is not a constant string"); }
1806 /* This is the case with just output operands. */
1807 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ')' ';'
1808 { stmt_count++;
1809 emit_line_note ($<filename>-1, $<lineno>0);
1810 c_expand_asm_operands ($4, $6, NULL_TREE, NULL_TREE,
1811 $2 == ridpointers[(int)RID_VOLATILE],
1812 input_filename, lineno); }
1813 /* This is the case with input operands as well. */
1814 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':' asm_operands ')' ';'
1815 { stmt_count++;
1816 emit_line_note ($<filename>-1, $<lineno>0);
1817 c_expand_asm_operands ($4, $6, $8, NULL_TREE,
1818 $2 == ridpointers[(int)RID_VOLATILE],
1819 input_filename, lineno); }
1820 /* This is the case with clobbered registers as well. */
1821 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':'
1822 asm_operands ':' asm_clobbers ')' ';'
1823 { stmt_count++;
1824 emit_line_note ($<filename>-1, $<lineno>0);
1825 c_expand_asm_operands ($4, $6, $8, $10,
1826 $2 == ridpointers[(int)RID_VOLATILE],
1827 input_filename, lineno); }
1828 | GOTO identifier ';'
1829 { tree decl;
1830 stmt_count++;
1831 emit_line_note ($<filename>-1, $<lineno>0);
1832 decl = lookup_label ($2);
1833 if (decl != 0)
1835 TREE_USED (decl) = 1;
1836 expand_goto (decl);
1839 | GOTO '*' expr ';'
1840 { if (pedantic)
1841 pedwarn ("ANSI C forbids `goto *expr;'");
1842 stmt_count++;
1843 emit_line_note ($<filename>-1, $<lineno>0);
1844 expand_computed_goto (convert (ptr_type_node, $3)); }
1845 | ';'
1848 all_iter_stmt:
1849 all_iter_stmt_simple
1850 /* | all_iter_stmt_with_decl */
1853 all_iter_stmt_simple:
1854 FOR '(' primary ')'
1856 /* The value returned by this action is */
1857 /* 1 if everything is OK */
1858 /* 0 in case of error or already bound iterator */
1860 $<itype>$ = 0;
1861 if (TREE_CODE ($3) != VAR_DECL)
1862 error ("invalid `for (ITERATOR)' syntax");
1863 else if (! ITERATOR_P ($3))
1864 error ("`%s' is not an iterator",
1865 IDENTIFIER_POINTER (DECL_NAME ($3)));
1866 else if (ITERATOR_BOUND_P ($3))
1867 error ("`for (%s)' inside expansion of same iterator",
1868 IDENTIFIER_POINTER (DECL_NAME ($3)));
1869 else
1871 $<itype>$ = 1;
1872 iterator_for_loop_start ($3);
1875 lineno_labeled_stmt
1877 if ($<itype>5)
1878 iterator_for_loop_end ($3);
1881 /* This really should allow any kind of declaration,
1882 for generality. Fix it before turning it back on.
1884 all_iter_stmt_with_decl:
1885 FOR '(' ITERATOR pushlevel setspecs iterator_spec ')'
1887 */ /* The value returned by this action is */
1888 /* 1 if everything is OK */
1889 /* 0 in case of error or already bound iterator */
1891 iterator_for_loop_start ($6);
1893 lineno_labeled_stmt
1895 iterator_for_loop_end ($6);
1896 emit_line_note (input_filename, lineno);
1897 expand_end_bindings (getdecls (), 1, 0);
1898 $<ttype>$ = poplevel (1, 1, 0);
1899 if (yychar == CONSTANT || yychar == STRING)
1900 pop_momentary_nofree ();
1901 else
1902 pop_momentary ();
1906 /* Any kind of label, including jump labels and case labels.
1907 ANSI C accepts labels only before statements, but we allow them
1908 also at the end of a compound statement. */
1910 label: CASE expr_no_commas ':'
1911 { register tree value = check_case_value ($2);
1912 register tree label
1913 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
1915 stmt_count++;
1917 if (value != error_mark_node)
1919 tree duplicate;
1920 int success = pushcase (value, convert_and_check,
1921 label, &duplicate);
1922 if (success == 1)
1923 error ("case label not within a switch statement");
1924 else if (success == 2)
1926 error ("duplicate case value");
1927 error_with_decl (duplicate, "this is the first entry for that value");
1929 else if (success == 3)
1930 warning ("case value out of range");
1931 else if (success == 5)
1932 error ("case label within scope of cleanup or variable array");
1934 position_after_white_space (); }
1935 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
1936 { register tree value1 = check_case_value ($2);
1937 register tree value2 = check_case_value ($4);
1938 register tree label
1939 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
1941 if (pedantic)
1942 pedwarn ("ANSI C forbids case ranges");
1943 stmt_count++;
1945 if (value1 != error_mark_node && value2 != error_mark_node)
1947 tree duplicate;
1948 int success = pushcase_range (value1, value2,
1949 convert_and_check, label,
1950 &duplicate);
1951 if (success == 1)
1952 error ("case label not within a switch statement");
1953 else if (success == 2)
1955 error ("duplicate case value");
1956 error_with_decl (duplicate, "this is the first entry for that value");
1958 else if (success == 3)
1959 warning ("case value out of range");
1960 else if (success == 4)
1961 warning ("empty case range");
1962 else if (success == 5)
1963 error ("case label within scope of cleanup or variable array");
1965 position_after_white_space (); }
1966 | DEFAULT ':'
1968 tree duplicate;
1969 register tree label
1970 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
1971 int success = pushcase (NULL_TREE, 0, label, &duplicate);
1972 stmt_count++;
1973 if (success == 1)
1974 error ("default label not within a switch statement");
1975 else if (success == 2)
1977 error ("multiple default labels in one switch");
1978 error_with_decl (duplicate, "this is the first default label");
1980 position_after_white_space (); }
1981 | identifier ':'
1982 { tree label = define_label (input_filename, lineno, $1);
1983 stmt_count++;
1984 emit_nop ();
1985 if (label)
1986 expand_label (label);
1987 position_after_white_space (); }
1990 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
1992 maybe_type_qual:
1993 /* empty */
1994 { emit_line_note (input_filename, lineno);
1995 $$ = NULL_TREE; }
1996 | TYPE_QUAL
1997 { emit_line_note (input_filename, lineno); }
2000 xexpr:
2001 /* empty */
2002 { $$ = NULL_TREE; }
2003 | expr
2006 /* These are the operands other than the first string and colon
2007 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
2008 asm_operands: /* empty */
2009 { $$ = NULL_TREE; }
2010 | nonnull_asm_operands
2013 nonnull_asm_operands:
2014 asm_operand
2015 | nonnull_asm_operands ',' asm_operand
2016 { $$ = chainon ($1, $3); }
2019 asm_operand:
2020 STRING '(' expr ')'
2021 { $$ = build_tree_list ($1, $3); }
2024 asm_clobbers:
2025 string
2026 { $$ = tree_cons (NULL_TREE, combine_strings ($1), NULL_TREE); }
2027 | asm_clobbers ',' string
2028 { $$ = tree_cons (NULL_TREE, combine_strings ($3), $1); }
2031 /* This is what appears inside the parens in a function declarator.
2032 Its value is a list of ..._TYPE nodes. */
2033 parmlist:
2034 { pushlevel (0);
2035 clear_parm_order ();
2036 declare_parm_level (0); }
2037 parmlist_1
2038 { $$ = $2;
2039 parmlist_tags_warning ();
2040 poplevel (0, 0, 0); }
2043 parmlist_1:
2044 parmlist_2 ')'
2045 | parms ';'
2046 { tree parm;
2047 if (pedantic)
2048 pedwarn ("ANSI C forbids forward parameter declarations");
2049 /* Mark the forward decls as such. */
2050 for (parm = getdecls (); parm; parm = TREE_CHAIN (parm))
2051 TREE_ASM_WRITTEN (parm) = 1;
2052 clear_parm_order (); }
2053 parmlist_1
2054 { $$ = $4; }
2055 | error ')'
2056 { $$ = tree_cons (NULL_TREE, NULL_TREE, NULL_TREE); }
2059 /* This is what appears inside the parens in a function declarator.
2060 Is value is represented in the format that grokdeclarator expects. */
2061 parmlist_2: /* empty */
2062 { $$ = get_parm_info (0); }
2063 | ELLIPSIS
2064 { $$ = get_parm_info (0);
2065 /* Gcc used to allow this as an extension. However, it does
2066 not work for all targets, and thus has been disabled.
2067 Also, since func (...) and func () are indistinguishable,
2068 it caused problems with the code in expand_builtin which
2069 tries to verify that BUILT_IN_NEXT_ARG is being used
2070 correctly. */
2071 error ("ANSI C requires a named argument before `...'");
2073 | parms
2074 { $$ = get_parm_info (1); }
2075 | parms ',' ELLIPSIS
2076 { $$ = get_parm_info (0); }
2079 parms:
2080 parm
2081 { push_parm_decl ($1); }
2082 | parms ',' parm
2083 { push_parm_decl ($3); }
2086 /* A single parameter declaration or parameter type name,
2087 as found in a parmlist. */
2088 parm:
2089 typed_declspecs setspecs parm_declarator maybe_attribute
2090 { $$ = build_tree_list (build_tree_list (current_declspecs,
2091 $3),
2092 build_tree_list (prefix_attributes,
2093 $4));
2094 current_declspecs = TREE_VALUE (declspec_stack);
2095 prefix_attributes = TREE_PURPOSE (declspec_stack);
2096 declspec_stack = TREE_CHAIN (declspec_stack);
2097 resume_momentary ($2); }
2098 | typed_declspecs setspecs notype_declarator maybe_attribute
2099 { $$ = build_tree_list (build_tree_list (current_declspecs,
2100 $3),
2101 build_tree_list (prefix_attributes,
2102 $4));
2103 current_declspecs = TREE_VALUE (declspec_stack);
2104 prefix_attributes = TREE_PURPOSE (declspec_stack);
2105 declspec_stack = TREE_CHAIN (declspec_stack);
2106 resume_momentary ($2); }
2107 | typed_declspecs setspecs absdcl maybe_attribute
2108 { $$ = build_tree_list (build_tree_list (current_declspecs,
2109 $3),
2110 build_tree_list (prefix_attributes,
2111 $4));
2112 current_declspecs = TREE_VALUE (declspec_stack);
2113 prefix_attributes = TREE_PURPOSE (declspec_stack);
2114 declspec_stack = TREE_CHAIN (declspec_stack);
2115 resume_momentary ($2); }
2116 | declmods setspecs notype_declarator maybe_attribute
2117 { $$ = build_tree_list (build_tree_list (current_declspecs,
2118 $3),
2119 build_tree_list (prefix_attributes,
2120 $4));
2121 current_declspecs = TREE_VALUE (declspec_stack);
2122 prefix_attributes = TREE_PURPOSE (declspec_stack);
2123 declspec_stack = TREE_CHAIN (declspec_stack);
2124 resume_momentary ($2); }
2126 | declmods setspecs absdcl maybe_attribute
2127 { $$ = build_tree_list (build_tree_list (current_declspecs,
2128 $3),
2129 build_tree_list (prefix_attributes,
2130 $4));
2131 current_declspecs = TREE_VALUE (declspec_stack);
2132 prefix_attributes = TREE_PURPOSE (declspec_stack);
2133 declspec_stack = TREE_CHAIN (declspec_stack);
2134 resume_momentary ($2); }
2137 /* This is used in a function definition
2138 where either a parmlist or an identifier list is ok.
2139 Its value is a list of ..._TYPE nodes or a list of identifiers. */
2140 parmlist_or_identifiers:
2141 { pushlevel (0);
2142 clear_parm_order ();
2143 declare_parm_level (1); }
2144 parmlist_or_identifiers_1
2145 { $$ = $2;
2146 parmlist_tags_warning ();
2147 poplevel (0, 0, 0); }
2150 parmlist_or_identifiers_1:
2151 parmlist_1
2152 | identifiers ')'
2153 { tree t;
2154 for (t = $1; t; t = TREE_CHAIN (t))
2155 if (TREE_VALUE (t) == NULL_TREE)
2156 error ("`...' in old-style identifier list");
2157 $$ = tree_cons (NULL_TREE, NULL_TREE, $1); }
2160 /* A nonempty list of identifiers. */
2161 identifiers:
2162 IDENTIFIER
2163 { $$ = build_tree_list (NULL_TREE, $1); }
2164 | identifiers ',' IDENTIFIER
2165 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2168 /* A nonempty list of identifiers, including typenames. */
2169 identifiers_or_typenames:
2170 identifier
2171 { $$ = build_tree_list (NULL_TREE, $1); }
2172 | identifiers_or_typenames ',' identifier
2173 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2176 extension:
2177 EXTENSION
2178 { $<itype>$ = pedantic;
2179 pedantic = 0; }