Undo June 11th change
[official-gcc.git] / gcc / c-parse.y
bloba67718984cbd1826012bd473b09345af6cc03aab
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>
61 #include "tree.h"
62 #include "input.h"
63 #include "c-lex.h"
64 #include "c-tree.h"
65 #include "flags.h"
66 #include "output.h"
67 #include "toplev.h"
69 #ifdef MULTIBYTE_CHARS
70 #include <locale.h>
71 #endif
74 /* Since parsers are distinct for each language, put the language string
75 definition here. */
76 char *language_string = "GNU C";
78 /* Like YYERROR but do call yyerror. */
79 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
81 /* Cause the `yydebug' variable to be defined. */
82 #define YYDEBUG 1
85 %start program
87 %union {long itype; tree ttype; enum tree_code code;
88 char *filename; int lineno; int ends_in_label; }
90 /* All identifiers that are not reserved words
91 and are not declared typedefs in the current block */
92 %token IDENTIFIER
94 /* All identifiers that are declared typedefs in the current block.
95 In some contexts, they are treated just like IDENTIFIER,
96 but they can also serve as typespecs in declarations. */
97 %token TYPENAME
99 /* Reserved words that specify storage class.
100 yylval contains an IDENTIFIER_NODE which indicates which one. */
101 %token SCSPEC
103 /* Reserved words that specify type.
104 yylval contains an IDENTIFIER_NODE which indicates which one. */
105 %token TYPESPEC
107 /* Reserved words that qualify type: "const" or "volatile".
108 yylval contains an IDENTIFIER_NODE which indicates which one. */
109 %token TYPE_QUAL
111 /* Character or numeric constants.
112 yylval is the node for the constant. */
113 %token CONSTANT
115 /* String constants in raw form.
116 yylval is a STRING_CST node. */
117 %token STRING
119 /* "...", used for functions with variable arglists. */
120 %token ELLIPSIS
122 /* the reserved words */
123 /* SCO include files test "ASM", so use something else. */
124 %token SIZEOF ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
125 %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD TYPEOF ALIGNOF
126 %token ATTRIBUTE EXTENSION LABEL
127 %token REALPART IMAGPART
129 /* Add precedence rules to solve dangling else s/r conflict */
130 %nonassoc IF
131 %nonassoc ELSE
133 /* Define the operator tokens and their precedences.
134 The value is an integer because, if used, it is the tree code
135 to use in the expression made from the operator. */
137 %right <code> ASSIGN '='
138 %right <code> '?' ':'
139 %left <code> OROR
140 %left <code> ANDAND
141 %left <code> '|'
142 %left <code> '^'
143 %left <code> '&'
144 %left <code> EQCOMPARE
145 %left <code> ARITHCOMPARE
146 %left <code> LSHIFT RSHIFT
147 %left <code> '+' '-'
148 %left <code> '*' '/' '%'
149 %right <code> UNARY PLUSPLUS MINUSMINUS
150 %left HYPERUNARY
151 %left <code> POINTSAT '.' '(' '['
153 /* The Objective-C keywords. These are included in C and in
154 Objective C, so that the token codes are the same in both. */
155 %token INTERFACE IMPLEMENTATION END SELECTOR DEFS ENCODE
156 %token CLASSNAME PUBLIC PRIVATE PROTECTED PROTOCOL OBJECTNAME CLASS ALIAS
158 /* Objective-C string constants in raw form.
159 yylval is an OBJC_STRING_CST node. */
160 %token OBJC_STRING
163 %type <code> unop
165 %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist exprlist
166 %type <ttype> expr_no_commas cast_expr unary_expr primary string STRING
167 %type <ttype> typed_declspecs reserved_declspecs
168 %type <ttype> typed_typespecs reserved_typespecquals
169 %type <ttype> declmods typespec typespecqual_reserved
170 %type <ttype> typed_declspecs_no_prefix_attr reserved_declspecs_no_prefix_attr
171 %type <ttype> declmods_no_prefix_attr
172 %type <ttype> SCSPEC TYPESPEC TYPE_QUAL nonempty_type_quals maybe_type_qual
173 %type <ttype> initdecls notype_initdecls initdcl notype_initdcl
174 %type <ttype> init maybeasm
175 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
176 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
177 %type <ttype> any_word
179 %type <ttype> compstmt
181 %type <ttype> declarator
182 %type <ttype> notype_declarator after_type_declarator
183 %type <ttype> parm_declarator
185 %type <ttype> structsp component_decl_list component_decl_list2
186 %type <ttype> component_decl components component_declarator
187 %type <ttype> enumlist enumerator
188 %type <ttype> typename absdcl absdcl1 type_quals
189 %type <ttype> xexpr parms parm identifiers
191 %type <ttype> parmlist parmlist_1 parmlist_2
192 %type <ttype> parmlist_or_identifiers parmlist_or_identifiers_1
193 %type <ttype> identifiers_or_typenames
195 %type <itype> setspecs
197 %type <ends_in_label> lineno_stmt_or_label lineno_stmt_or_labels stmt_or_label
199 %type <filename> save_filename
200 %type <lineno> save_lineno
204 /* Number of statements (loosely speaking) and compound statements
205 seen so far. */
206 static int stmt_count;
207 static int compstmt_count;
209 /* Input file and line number of the end of the body of last simple_if;
210 used by the stmt-rule immediately after simple_if returns. */
211 static char *if_stmt_file;
212 static int if_stmt_line;
214 /* List of types and structure classes of the current declaration. */
215 static tree current_declspecs = NULL_TREE;
216 static tree prefix_attributes = NULL_TREE;
218 /* Stack of saved values of current_declspecs and prefix_attributes. */
219 static tree declspec_stack;
221 /* 1 if we explained undeclared var errors. */
222 static int undeclared_variable_notice;
225 /* Tell yyparse how to print a token's value, if yydebug is set. */
227 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
228 extern void yyprint PROTO ((FILE *, int, YYSTYPE));
232 program: /* empty */
233 { if (pedantic)
234 pedwarn ("ANSI C forbids an empty source file");
235 finish_file ();
237 | extdefs
239 /* In case there were missing closebraces,
240 get us back to the global binding level. */
241 while (! global_bindings_p ())
242 poplevel (0, 0, 0);
243 finish_file ();
247 /* the reason for the strange actions in this rule
248 is so that notype_initdecls when reached via datadef
249 can find a valid list of type and sc specs in $0. */
251 extdefs:
252 {$<ttype>$ = NULL_TREE; } extdef
253 | extdefs {$<ttype>$ = NULL_TREE; } extdef
256 extdef:
257 fndef
258 | datadef
259 | ASM_KEYWORD '(' expr ')' ';'
260 { STRIP_NOPS ($3);
261 if ((TREE_CODE ($3) == ADDR_EXPR
262 && TREE_CODE (TREE_OPERAND ($3, 0)) == STRING_CST)
263 || TREE_CODE ($3) == STRING_CST)
264 assemble_asm ($3);
265 else
266 error ("argument of `asm' is not a constant string"); }
267 | extension extdef
268 { pedantic = $<itype>1; }
271 datadef:
272 setspecs notype_initdecls ';'
273 { if (pedantic)
274 error ("ANSI C forbids data definition with no type or storage class");
275 else if (!flag_traditional)
276 warning ("data definition has no type or storage class");
278 current_declspecs = TREE_VALUE (declspec_stack);
279 prefix_attributes = TREE_PURPOSE (declspec_stack);
280 declspec_stack = TREE_CHAIN (declspec_stack);
281 resume_momentary ($1); }
282 | declmods setspecs notype_initdecls ';'
283 { current_declspecs = TREE_VALUE (declspec_stack);
284 prefix_attributes = TREE_PURPOSE (declspec_stack);
285 declspec_stack = TREE_CHAIN (declspec_stack);
286 resume_momentary ($2); }
287 | typed_declspecs setspecs initdecls ';'
288 { current_declspecs = TREE_VALUE (declspec_stack);
289 prefix_attributes = TREE_PURPOSE (declspec_stack);
290 declspec_stack = TREE_CHAIN (declspec_stack);
291 resume_momentary ($2); }
292 | declmods ';'
293 { pedwarn ("empty declaration"); }
294 | typed_declspecs ';'
295 { shadow_tag ($1); }
296 | error ';'
297 | error '}'
298 | ';'
299 { if (pedantic)
300 pedwarn ("ANSI C does not allow extra `;' outside of a function"); }
303 fndef:
304 typed_declspecs setspecs declarator
305 { if (! start_function (current_declspecs, $3,
306 prefix_attributes, NULL_TREE, 0))
307 YYERROR1;
308 reinit_parse_for_function (); }
309 old_style_parm_decls
310 { store_parm_decls (); }
311 compstmt_or_error
312 { finish_function (0);
313 current_declspecs = TREE_VALUE (declspec_stack);
314 prefix_attributes = TREE_PURPOSE (declspec_stack);
315 declspec_stack = TREE_CHAIN (declspec_stack);
316 resume_momentary ($2); }
317 | typed_declspecs setspecs declarator error
318 { current_declspecs = TREE_VALUE (declspec_stack);
319 prefix_attributes = TREE_PURPOSE (declspec_stack);
320 declspec_stack = TREE_CHAIN (declspec_stack);
321 resume_momentary ($2); }
322 | declmods setspecs notype_declarator
323 { if (! start_function (current_declspecs, $3,
324 prefix_attributes, NULL_TREE, 0))
325 YYERROR1;
326 reinit_parse_for_function (); }
327 old_style_parm_decls
328 { store_parm_decls (); }
329 compstmt_or_error
330 { finish_function (0);
331 current_declspecs = TREE_VALUE (declspec_stack);
332 prefix_attributes = TREE_PURPOSE (declspec_stack);
333 declspec_stack = TREE_CHAIN (declspec_stack);
334 resume_momentary ($2); }
335 | declmods setspecs notype_declarator error
336 { current_declspecs = TREE_VALUE (declspec_stack);
337 prefix_attributes = TREE_PURPOSE (declspec_stack);
338 declspec_stack = TREE_CHAIN (declspec_stack);
339 resume_momentary ($2); }
340 | setspecs notype_declarator
341 { if (! start_function (NULL_TREE, $2,
342 prefix_attributes, NULL_TREE, 0))
343 YYERROR1;
344 reinit_parse_for_function (); }
345 old_style_parm_decls
346 { store_parm_decls (); }
347 compstmt_or_error
348 { finish_function (0);
349 current_declspecs = TREE_VALUE (declspec_stack);
350 prefix_attributes = TREE_PURPOSE (declspec_stack);
351 declspec_stack = TREE_CHAIN (declspec_stack);
352 resume_momentary ($1); }
353 | setspecs notype_declarator error
354 { current_declspecs = TREE_VALUE (declspec_stack);
355 prefix_attributes = TREE_PURPOSE (declspec_stack);
356 declspec_stack = TREE_CHAIN (declspec_stack);
357 resume_momentary ($1); }
360 identifier:
361 IDENTIFIER
362 | TYPENAME
365 unop: '&'
366 { $$ = ADDR_EXPR; }
367 | '-'
368 { $$ = NEGATE_EXPR; }
369 | '+'
370 { $$ = CONVERT_EXPR; }
371 | PLUSPLUS
372 { $$ = PREINCREMENT_EXPR; }
373 | MINUSMINUS
374 { $$ = PREDECREMENT_EXPR; }
375 | '~'
376 { $$ = BIT_NOT_EXPR; }
377 | '!'
378 { $$ = TRUTH_NOT_EXPR; }
381 expr: nonnull_exprlist
382 { $$ = build_compound_expr ($1); }
385 exprlist:
386 /* empty */
387 { $$ = NULL_TREE; }
388 | nonnull_exprlist
391 nonnull_exprlist:
392 expr_no_commas
393 { $$ = build_tree_list (NULL_TREE, $1); }
394 | nonnull_exprlist ',' expr_no_commas
395 { chainon ($1, build_tree_list (NULL_TREE, $3)); }
398 unary_expr:
399 primary
400 | '*' cast_expr %prec UNARY
401 { $$ = build_indirect_ref ($2, "unary *"); }
402 /* __extension__ turns off -pedantic for following primary. */
403 | extension cast_expr %prec UNARY
404 { $$ = $2;
405 pedantic = $<itype>1; }
406 | unop cast_expr %prec UNARY
407 { $$ = build_unary_op ($1, $2, 0);
408 overflow_warning ($$); }
409 /* Refer to the address of a label as a pointer. */
410 | ANDAND identifier
411 { tree label = lookup_label ($2);
412 if (pedantic)
413 pedwarn ("ANSI C forbids `&&'");
414 if (label == 0)
415 $$ = null_pointer_node;
416 else
418 TREE_USED (label) = 1;
419 $$ = build1 (ADDR_EXPR, ptr_type_node, label);
420 TREE_CONSTANT ($$) = 1;
423 /* This seems to be impossible on some machines, so let's turn it off.
424 You can use __builtin_next_arg to find the anonymous stack args.
425 | '&' ELLIPSIS
426 { tree types = TYPE_ARG_TYPES (TREE_TYPE (current_function_decl));
427 $$ = error_mark_node;
428 if (TREE_VALUE (tree_last (types)) == void_type_node)
429 error ("`&...' used in function with fixed number of arguments");
430 else
432 if (pedantic)
433 pedwarn ("ANSI C forbids `&...'");
434 $$ = tree_last (DECL_ARGUMENTS (current_function_decl));
435 $$ = build_unary_op (ADDR_EXPR, $$, 0);
438 | sizeof unary_expr %prec UNARY
439 { skip_evaluation--;
440 if (TREE_CODE ($2) == COMPONENT_REF
441 && DECL_C_BIT_FIELD (TREE_OPERAND ($2, 1)))
442 error ("`sizeof' applied to a bit-field");
443 $$ = c_sizeof (TREE_TYPE ($2)); }
444 | sizeof '(' typename ')' %prec HYPERUNARY
445 { skip_evaluation--;
446 $$ = c_sizeof (groktypename ($3)); }
447 | alignof unary_expr %prec UNARY
448 { skip_evaluation--;
449 $$ = c_alignof_expr ($2); }
450 | alignof '(' typename ')' %prec HYPERUNARY
451 { skip_evaluation--;
452 $$ = c_alignof (groktypename ($3)); }
453 | REALPART cast_expr %prec UNARY
454 { $$ = build_unary_op (REALPART_EXPR, $2, 0); }
455 | IMAGPART cast_expr %prec UNARY
456 { $$ = build_unary_op (IMAGPART_EXPR, $2, 0); }
459 sizeof:
460 SIZEOF { skip_evaluation++; }
463 alignof:
464 ALIGNOF { skip_evaluation++; }
467 cast_expr:
468 unary_expr
469 | '(' typename ')' cast_expr %prec UNARY
470 { tree type = groktypename ($2);
471 $$ = build_c_cast (type, $4); }
472 | '(' typename ')' '{'
473 { start_init (NULL_TREE, NULL, 0);
474 $2 = groktypename ($2);
475 really_start_incremental_init ($2); }
476 initlist_maybe_comma '}' %prec UNARY
477 { char *name;
478 tree result = pop_init_level (0);
479 tree type = $2;
480 finish_init ();
482 if (pedantic)
483 pedwarn ("ANSI C forbids constructor expressions");
484 if (TYPE_NAME (type) != 0)
486 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
487 name = IDENTIFIER_POINTER (TYPE_NAME (type));
488 else
489 name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
491 else
492 name = "";
493 $$ = result;
494 if (TREE_CODE (type) == ARRAY_TYPE && TYPE_SIZE (type) == 0)
496 int failure = complete_array_type (type, $$, 1);
497 if (failure)
498 abort ();
503 expr_no_commas:
504 cast_expr
505 | expr_no_commas '+' expr_no_commas
506 { $$ = parser_build_binary_op ($2, $1, $3); }
507 | expr_no_commas '-' expr_no_commas
508 { $$ = parser_build_binary_op ($2, $1, $3); }
509 | expr_no_commas '*' expr_no_commas
510 { $$ = parser_build_binary_op ($2, $1, $3); }
511 | expr_no_commas '/' expr_no_commas
512 { $$ = parser_build_binary_op ($2, $1, $3); }
513 | expr_no_commas '%' expr_no_commas
514 { $$ = parser_build_binary_op ($2, $1, $3); }
515 | expr_no_commas LSHIFT expr_no_commas
516 { $$ = parser_build_binary_op ($2, $1, $3); }
517 | expr_no_commas RSHIFT expr_no_commas
518 { $$ = parser_build_binary_op ($2, $1, $3); }
519 | expr_no_commas ARITHCOMPARE expr_no_commas
520 { $$ = parser_build_binary_op ($2, $1, $3); }
521 | expr_no_commas EQCOMPARE expr_no_commas
522 { $$ = parser_build_binary_op ($2, $1, $3); }
523 | expr_no_commas '&' expr_no_commas
524 { $$ = parser_build_binary_op ($2, $1, $3); }
525 | expr_no_commas '|' expr_no_commas
526 { $$ = parser_build_binary_op ($2, $1, $3); }
527 | expr_no_commas '^' expr_no_commas
528 { $$ = parser_build_binary_op ($2, $1, $3); }
529 | expr_no_commas ANDAND
530 { $1 = truthvalue_conversion (default_conversion ($1));
531 skip_evaluation += $1 == boolean_false_node; }
532 expr_no_commas
533 { skip_evaluation -= $1 == boolean_false_node;
534 $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $4); }
535 | expr_no_commas OROR
536 { $1 = truthvalue_conversion (default_conversion ($1));
537 skip_evaluation += $1 == boolean_true_node; }
538 expr_no_commas
539 { skip_evaluation -= $1 == boolean_true_node;
540 $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $4); }
541 | expr_no_commas '?'
542 { $1 = truthvalue_conversion (default_conversion ($1));
543 skip_evaluation += $1 == boolean_false_node; }
544 expr ':'
545 { skip_evaluation += (($1 == boolean_true_node)
546 - ($1 == boolean_false_node)); }
547 expr_no_commas
548 { skip_evaluation -= $1 == boolean_true_node;
549 $$ = build_conditional_expr ($1, $4, $7); }
550 | expr_no_commas '?'
551 { if (pedantic)
552 pedwarn ("ANSI C forbids omitting the middle term of a ?: expression");
553 /* Make sure first operand is calculated only once. */
554 $<ttype>2 = save_expr ($1);
555 $1 = truthvalue_conversion (default_conversion ($<ttype>2));
556 skip_evaluation += $1 == boolean_true_node; }
557 ':' expr_no_commas
558 { skip_evaluation -= $1 == boolean_true_node;
559 $$ = build_conditional_expr ($1, $<ttype>2, $5); }
560 | expr_no_commas '=' expr_no_commas
561 { $$ = build_modify_expr ($1, NOP_EXPR, $3);
562 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
563 | expr_no_commas ASSIGN expr_no_commas
564 { $$ = build_modify_expr ($1, $2, $3);
565 /* This inhibits warnings in truthvalue_conversion. */
566 C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK); }
569 primary:
570 IDENTIFIER
572 $$ = lastiddecl;
573 if (!$$ || $$ == error_mark_node)
575 if (yychar == YYEMPTY)
576 yychar = YYLEX;
577 if (yychar == '(')
580 /* Ordinary implicit function declaration. */
581 $$ = implicitly_declare ($1);
582 assemble_external ($$);
583 TREE_USED ($$) = 1;
586 else if (current_function_decl == 0)
588 error ("`%s' undeclared here (not in a function)",
589 IDENTIFIER_POINTER ($1));
590 $$ = error_mark_node;
592 else
595 if (IDENTIFIER_GLOBAL_VALUE ($1) != error_mark_node
596 || IDENTIFIER_ERROR_LOCUS ($1) != current_function_decl)
598 error ("`%s' undeclared (first use in this function)",
599 IDENTIFIER_POINTER ($1));
601 if (! undeclared_variable_notice)
603 error ("(Each undeclared identifier is reported only once");
604 error ("for each function it appears in.)");
605 undeclared_variable_notice = 1;
608 $$ = error_mark_node;
609 /* Prevent repeated error messages. */
610 IDENTIFIER_GLOBAL_VALUE ($1) = error_mark_node;
611 IDENTIFIER_ERROR_LOCUS ($1) = current_function_decl;
615 else if (TREE_TYPE ($$) == error_mark_node)
616 $$ = error_mark_node;
617 else if (C_DECL_ANTICIPATED ($$))
619 /* The first time we see a build-in function used,
620 if it has not been declared. */
621 C_DECL_ANTICIPATED ($$) = 0;
622 if (yychar == YYEMPTY)
623 yychar = YYLEX;
624 if (yychar == '(')
626 /* Omit the implicit declaration we
627 would ordinarily do, so we don't lose
628 the actual built in type.
629 But print a diagnostic for the mismatch. */
630 if (TREE_CODE ($$) != FUNCTION_DECL)
631 error ("`%s' implicitly declared as function",
632 IDENTIFIER_POINTER (DECL_NAME ($$)));
633 else if ((TYPE_MODE (TREE_TYPE (TREE_TYPE ($$)))
634 != TYPE_MODE (integer_type_node))
635 && (TREE_TYPE (TREE_TYPE ($$))
636 != void_type_node))
637 pedwarn ("type mismatch in implicit declaration for built-in function `%s'",
638 IDENTIFIER_POINTER (DECL_NAME ($$)));
639 /* If it really returns void, change that to int. */
640 if (TREE_TYPE (TREE_TYPE ($$)) == void_type_node)
641 TREE_TYPE ($$)
642 = build_function_type (integer_type_node,
643 TYPE_ARG_TYPES (TREE_TYPE ($$)));
645 else
646 pedwarn ("built-in function `%s' used without declaration",
647 IDENTIFIER_POINTER (DECL_NAME ($$)));
649 /* Do what we would ordinarily do when a fn is used. */
650 assemble_external ($$);
651 TREE_USED ($$) = 1;
653 else
655 assemble_external ($$);
656 TREE_USED ($$) = 1;
659 if (TREE_CODE ($$) == CONST_DECL)
661 $$ = DECL_INITIAL ($$);
662 /* This is to prevent an enum whose value is 0
663 from being considered a null pointer constant. */
664 $$ = build1 (NOP_EXPR, TREE_TYPE ($$), $$);
665 TREE_CONSTANT ($$) = 1;
668 | CONSTANT
669 | string
670 { $$ = combine_strings ($1); }
671 | '(' expr ')'
672 { char class = TREE_CODE_CLASS (TREE_CODE ($2));
673 if (class == 'e' || class == '1'
674 || class == '2' || class == '<')
675 C_SET_EXP_ORIGINAL_CODE ($2, ERROR_MARK);
676 $$ = $2; }
677 | '(' error ')'
678 { $$ = error_mark_node; }
679 | '('
680 { if (current_function_decl == 0)
682 error ("braced-group within expression allowed only inside a function");
683 YYERROR;
685 /* We must force a BLOCK for this level
686 so that, if it is not expanded later,
687 there is a way to turn off the entire subtree of blocks
688 that are contained in it. */
689 keep_next_level ();
690 push_iterator_stack ();
691 push_label_level ();
692 $<ttype>$ = expand_start_stmt_expr (); }
693 compstmt ')'
694 { tree rtl_exp;
695 if (pedantic)
696 pedwarn ("ANSI C forbids braced-groups within expressions");
697 pop_iterator_stack ();
698 pop_label_level ();
699 rtl_exp = expand_end_stmt_expr ($<ttype>2);
700 /* The statements have side effects, so the group does. */
701 TREE_SIDE_EFFECTS (rtl_exp) = 1;
703 if (TREE_CODE ($3) == BLOCK)
705 /* Make a BIND_EXPR for the BLOCK already made. */
706 $$ = build (BIND_EXPR, TREE_TYPE (rtl_exp),
707 NULL_TREE, rtl_exp, $3);
708 /* Remove the block from the tree at this point.
709 It gets put back at the proper place
710 when the BIND_EXPR is expanded. */
711 delete_block ($3);
713 else
714 $$ = $3;
716 | primary '(' exprlist ')' %prec '.'
717 { $$ = build_function_call ($1, $3); }
718 | primary '[' expr ']' %prec '.'
719 { $$ = build_array_ref ($1, $3); }
720 | primary '.' identifier
722 $$ = build_component_ref ($1, $3);
724 | primary POINTSAT identifier
726 tree expr = build_indirect_ref ($1, "->");
728 $$ = build_component_ref (expr, $3);
730 | primary PLUSPLUS
731 { $$ = build_unary_op (POSTINCREMENT_EXPR, $1, 0); }
732 | primary MINUSMINUS
733 { $$ = build_unary_op (POSTDECREMENT_EXPR, $1, 0); }
736 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
737 string:
738 STRING
739 | string STRING
740 { $$ = chainon ($1, $2); }
744 old_style_parm_decls:
745 /* empty */
746 | datadecls
747 | datadecls ELLIPSIS
748 /* ... is used here to indicate a varargs function. */
749 { c_mark_varargs ();
750 if (pedantic)
751 pedwarn ("ANSI C does not permit use of `varargs.h'"); }
754 /* The following are analogous to lineno_decl, decls and decl
755 except that they do not allow nested functions.
756 They are used for old-style parm decls. */
757 lineno_datadecl:
758 save_filename save_lineno datadecl
762 datadecls:
763 lineno_datadecl
764 | errstmt
765 | datadecls lineno_datadecl
766 | lineno_datadecl errstmt
769 /* We don't allow prefix attributes here because they cause reduce/reduce
770 conflicts: we can't know whether we're parsing a function decl with
771 attribute suffix, or function defn with attribute prefix on first old
772 style parm. */
773 datadecl:
774 typed_declspecs_no_prefix_attr setspecs initdecls ';'
775 { current_declspecs = TREE_VALUE (declspec_stack);
776 prefix_attributes = TREE_PURPOSE (declspec_stack);
777 declspec_stack = TREE_CHAIN (declspec_stack);
778 resume_momentary ($2); }
779 | declmods_no_prefix_attr setspecs notype_initdecls ';'
780 { current_declspecs = TREE_VALUE (declspec_stack);
781 prefix_attributes = TREE_PURPOSE (declspec_stack);
782 declspec_stack = TREE_CHAIN (declspec_stack);
783 resume_momentary ($2); }
784 | typed_declspecs_no_prefix_attr ';'
785 { shadow_tag_warned ($1, 1);
786 pedwarn ("empty declaration"); }
787 | declmods_no_prefix_attr ';'
788 { pedwarn ("empty declaration"); }
791 /* This combination which saves a lineno before a decl
792 is the normal thing to use, rather than decl itself.
793 This is to avoid shift/reduce conflicts in contexts
794 where statement labels are allowed. */
795 lineno_decl:
796 save_filename save_lineno decl
800 decls:
801 lineno_decl
802 | errstmt
803 | decls lineno_decl
804 | lineno_decl errstmt
807 /* records the type and storage class specs to use for processing
808 the declarators that follow.
809 Maintains a stack of outer-level values of current_declspecs,
810 for the sake of parm declarations nested in function declarators. */
811 setspecs: /* empty */
812 { $$ = suspend_momentary ();
813 pending_xref_error ();
814 declspec_stack = tree_cons (prefix_attributes,
815 current_declspecs,
816 declspec_stack);
817 split_specs_attrs ($<ttype>0,
818 &current_declspecs, &prefix_attributes); }
821 /* ??? Yuck. See after_type_declarator. */
822 setattrs: /* empty */
823 { prefix_attributes = chainon (prefix_attributes, $<ttype>0); }
826 decl:
827 typed_declspecs setspecs initdecls ';'
828 { current_declspecs = TREE_VALUE (declspec_stack);
829 prefix_attributes = TREE_PURPOSE (declspec_stack);
830 declspec_stack = TREE_CHAIN (declspec_stack);
831 resume_momentary ($2); }
832 | declmods setspecs notype_initdecls ';'
833 { current_declspecs = TREE_VALUE (declspec_stack);
834 prefix_attributes = TREE_PURPOSE (declspec_stack);
835 declspec_stack = TREE_CHAIN (declspec_stack);
836 resume_momentary ($2); }
837 | typed_declspecs setspecs nested_function
838 { current_declspecs = TREE_VALUE (declspec_stack);
839 prefix_attributes = TREE_PURPOSE (declspec_stack);
840 declspec_stack = TREE_CHAIN (declspec_stack);
841 resume_momentary ($2); }
842 | declmods setspecs notype_nested_function
843 { current_declspecs = TREE_VALUE (declspec_stack);
844 prefix_attributes = TREE_PURPOSE (declspec_stack);
845 declspec_stack = TREE_CHAIN (declspec_stack);
846 resume_momentary ($2); }
847 | typed_declspecs ';'
848 { shadow_tag ($1); }
849 | declmods ';'
850 { pedwarn ("empty declaration"); }
851 | extension decl
852 { pedantic = $<itype>1; }
855 /* Declspecs which contain at least one type specifier or typedef name.
856 (Just `const' or `volatile' is not enough.)
857 A typedef'd name following these is taken as a name to be declared.
858 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
860 typed_declspecs:
861 typespec reserved_declspecs
862 { $$ = tree_cons (NULL_TREE, $1, $2); }
863 | declmods typespec reserved_declspecs
864 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
867 reserved_declspecs: /* empty */
868 { $$ = NULL_TREE; }
869 | reserved_declspecs typespecqual_reserved
870 { $$ = tree_cons (NULL_TREE, $2, $1); }
871 | reserved_declspecs SCSPEC
872 { if (extra_warnings)
873 warning ("`%s' is not at beginning of declaration",
874 IDENTIFIER_POINTER ($2));
875 $$ = tree_cons (NULL_TREE, $2, $1); }
876 | reserved_declspecs attributes
877 { $$ = tree_cons ($2, NULL_TREE, $1); }
880 typed_declspecs_no_prefix_attr:
881 typespec reserved_declspecs_no_prefix_attr
882 { $$ = tree_cons (NULL_TREE, $1, $2); }
883 | declmods_no_prefix_attr typespec reserved_declspecs_no_prefix_attr
884 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
887 reserved_declspecs_no_prefix_attr:
888 /* empty */
889 { $$ = NULL_TREE; }
890 | reserved_declspecs_no_prefix_attr typespecqual_reserved
891 { $$ = tree_cons (NULL_TREE, $2, $1); }
892 | reserved_declspecs_no_prefix_attr SCSPEC
893 { if (extra_warnings)
894 warning ("`%s' is not at beginning of declaration",
895 IDENTIFIER_POINTER ($2));
896 $$ = tree_cons (NULL_TREE, $2, $1); }
899 /* List of just storage classes, type modifiers, and prefix attributes.
900 A declaration can start with just this, but then it cannot be used
901 to redeclare a typedef-name.
902 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
904 declmods:
905 declmods_no_prefix_attr
906 { $$ = $1; }
907 | attributes
908 { $$ = tree_cons ($1, NULL_TREE, NULL_TREE); }
909 | declmods declmods_no_prefix_attr
910 { $$ = chainon ($2, $1); }
911 | declmods attributes
912 { $$ = tree_cons ($2, NULL_TREE, $1); }
915 declmods_no_prefix_attr:
916 TYPE_QUAL
917 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
918 TREE_STATIC ($$) = 1; }
919 | SCSPEC
920 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
921 | declmods_no_prefix_attr TYPE_QUAL
922 { $$ = tree_cons (NULL_TREE, $2, $1);
923 TREE_STATIC ($$) = 1; }
924 | declmods_no_prefix_attr SCSPEC
925 { if (extra_warnings && TREE_STATIC ($1))
926 warning ("`%s' is not at beginning of declaration",
927 IDENTIFIER_POINTER ($2));
928 $$ = tree_cons (NULL_TREE, $2, $1);
929 TREE_STATIC ($$) = TREE_STATIC ($1); }
933 /* Used instead of declspecs where storage classes are not allowed
934 (that is, for typenames and structure components).
935 Don't accept a typedef-name if anything but a modifier precedes it. */
937 typed_typespecs:
938 typespec reserved_typespecquals
939 { $$ = tree_cons (NULL_TREE, $1, $2); }
940 | nonempty_type_quals typespec reserved_typespecquals
941 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
944 reserved_typespecquals: /* empty */
945 { $$ = NULL_TREE; }
946 | reserved_typespecquals typespecqual_reserved
947 { $$ = tree_cons (NULL_TREE, $2, $1); }
950 /* A typespec (but not a type qualifier).
951 Once we have seen one of these in a declaration,
952 if a typedef name appears then it is being redeclared. */
954 typespec: TYPESPEC
955 | structsp
956 | TYPENAME
957 { /* For a typedef name, record the meaning, not the name.
958 In case of `foo foo, bar;'. */
959 $$ = lookup_name ($1); }
960 | TYPEOF '(' expr ')'
961 { $$ = TREE_TYPE ($3); }
962 | TYPEOF '(' typename ')'
963 { $$ = groktypename ($3); }
966 /* A typespec that is a reserved word, or a type qualifier. */
968 typespecqual_reserved: TYPESPEC
969 | TYPE_QUAL
970 | structsp
973 initdecls:
974 initdcl
975 | initdecls ',' initdcl
978 notype_initdecls:
979 notype_initdcl
980 | notype_initdecls ',' initdcl
983 maybeasm:
984 /* empty */
985 { $$ = NULL_TREE; }
986 | ASM_KEYWORD '(' string ')'
987 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
988 $$ = $3;
992 initdcl:
993 declarator maybeasm maybe_attribute '='
994 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
995 $3, prefix_attributes);
996 start_init ($<ttype>$, $2, global_bindings_p ()); }
997 init
998 /* Note how the declaration of the variable is in effect while its init is parsed! */
999 { finish_init ();
1000 finish_decl ($<ttype>5, $6, $2); }
1001 | declarator maybeasm maybe_attribute
1002 { tree d = start_decl ($1, current_declspecs, 0,
1003 $3, prefix_attributes);
1004 finish_decl (d, NULL_TREE, $2);
1008 notype_initdcl:
1009 notype_declarator maybeasm maybe_attribute '='
1010 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1011 $3, prefix_attributes);
1012 start_init ($<ttype>$, $2, global_bindings_p ()); }
1013 init
1014 /* Note how the declaration of the variable is in effect while its init is parsed! */
1015 { finish_init ();
1016 decl_attributes ($<ttype>5, $3, prefix_attributes);
1017 finish_decl ($<ttype>5, $6, $2); }
1018 | notype_declarator maybeasm maybe_attribute
1019 { tree d = start_decl ($1, current_declspecs, 0,
1020 $3, prefix_attributes);
1021 finish_decl (d, NULL_TREE, $2); }
1023 /* the * rules are dummies to accept the Apollo extended syntax
1024 so that the header files compile. */
1025 maybe_attribute:
1026 /* empty */
1027 { $$ = NULL_TREE; }
1028 | attributes
1029 { $$ = $1; }
1032 attributes:
1033 attribute
1034 { $$ = $1; }
1035 | attributes attribute
1036 { $$ = chainon ($1, $2); }
1039 attribute:
1040 ATTRIBUTE '(' '(' attribute_list ')' ')'
1041 { $$ = $4; }
1044 attribute_list:
1045 attrib
1046 { $$ = $1; }
1047 | attribute_list ',' attrib
1048 { $$ = chainon ($1, $3); }
1051 attrib:
1052 /* empty */
1053 { $$ = NULL_TREE; }
1054 | any_word
1055 { $$ = build_tree_list ($1, NULL_TREE); }
1056 | any_word '(' IDENTIFIER ')'
1057 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1058 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1059 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1060 | any_word '(' exprlist ')'
1061 { $$ = build_tree_list ($1, $3); }
1064 /* This still leaves out most reserved keywords,
1065 shouldn't we include them? */
1067 any_word:
1068 identifier
1069 | SCSPEC
1070 | TYPESPEC
1071 | TYPE_QUAL
1074 /* Initializers. `init' is the entry point. */
1076 init:
1077 expr_no_commas
1078 | '{'
1079 { really_start_incremental_init (NULL_TREE);
1080 /* Note that the call to clear_momentary
1081 is in process_init_element. */
1082 push_momentary (); }
1083 initlist_maybe_comma '}'
1084 { $$ = pop_init_level (0);
1085 if ($$ == error_mark_node
1086 && ! (yychar == STRING || yychar == CONSTANT))
1087 pop_momentary ();
1088 else
1089 pop_momentary_nofree (); }
1091 | error
1092 { $$ = error_mark_node; }
1095 /* `initlist_maybe_comma' is the guts of an initializer in braces. */
1096 initlist_maybe_comma:
1097 /* empty */
1098 { if (pedantic)
1099 pedwarn ("ANSI C forbids empty initializer braces"); }
1100 | initlist1 maybecomma
1103 initlist1:
1104 initelt
1105 | initlist1 ',' initelt
1108 /* `initelt' is a single element of an initializer.
1109 It may use braces. */
1110 initelt:
1111 expr_no_commas
1112 { process_init_element ($1); }
1113 | '{'
1114 { push_init_level (0); }
1115 initlist_maybe_comma '}'
1116 { process_init_element (pop_init_level (0)); }
1117 | error
1118 /* These are for labeled elements. The syntax for an array element
1119 initializer conflicts with the syntax for an Objective-C message,
1120 so don't include these productions in the Objective-C grammar. */
1121 | '[' expr_no_commas ELLIPSIS expr_no_commas ']' '='
1122 { set_init_index ($2, $4); }
1123 initelt
1124 | '[' expr_no_commas ']' '='
1125 { set_init_index ($2, NULL_TREE); }
1126 initelt
1127 | '[' expr_no_commas ']'
1128 { set_init_index ($2, NULL_TREE); }
1129 initelt
1130 | identifier ':'
1131 { set_init_label ($1); }
1132 initelt
1133 | '.' identifier '='
1134 { set_init_label ($2); }
1135 initelt
1138 nested_function:
1139 declarator
1140 { push_c_function_context ();
1141 if (! start_function (current_declspecs, $1,
1142 prefix_attributes, NULL_TREE, 1))
1144 pop_c_function_context ();
1145 YYERROR1;
1147 reinit_parse_for_function (); }
1148 old_style_parm_decls
1149 { store_parm_decls (); }
1150 /* This used to use compstmt_or_error.
1151 That caused a bug with input `f(g) int g {}',
1152 where the use of YYERROR1 above caused an error
1153 which then was handled by compstmt_or_error.
1154 There followed a repeated execution of that same rule,
1155 which called YYERROR1 again, and so on. */
1156 compstmt
1157 { finish_function (1);
1158 pop_c_function_context (); }
1161 notype_nested_function:
1162 notype_declarator
1163 { push_c_function_context ();
1164 if (! start_function (current_declspecs, $1,
1165 prefix_attributes, NULL_TREE, 1))
1167 pop_c_function_context ();
1168 YYERROR1;
1170 reinit_parse_for_function (); }
1171 old_style_parm_decls
1172 { store_parm_decls (); }
1173 /* This used to use compstmt_or_error.
1174 That caused a bug with input `f(g) int g {}',
1175 where the use of YYERROR1 above caused an error
1176 which then was handled by compstmt_or_error.
1177 There followed a repeated execution of that same rule,
1178 which called YYERROR1 again, and so on. */
1179 compstmt
1180 { finish_function (1);
1181 pop_c_function_context (); }
1184 /* Any kind of declarator (thus, all declarators allowed
1185 after an explicit typespec). */
1187 declarator:
1188 after_type_declarator
1189 | notype_declarator
1192 /* A declarator that is allowed only after an explicit typespec. */
1194 after_type_declarator:
1195 '(' after_type_declarator ')'
1196 { $$ = $2; }
1197 | after_type_declarator '(' parmlist_or_identifiers %prec '.'
1198 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1199 /* | after_type_declarator '(' error ')' %prec '.'
1200 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1201 poplevel (0, 0, 0); } */
1202 | after_type_declarator '[' expr ']' %prec '.'
1203 { $$ = build_nt (ARRAY_REF, $1, $3); }
1204 | after_type_declarator '[' ']' %prec '.'
1205 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1206 | '*' type_quals after_type_declarator %prec UNARY
1207 { $$ = make_pointer_declarator ($2, $3); }
1208 /* ??? Yuck. setattrs is a quick hack. We can't use
1209 prefix_attributes because $1 only applies to this
1210 declarator. We assume setspecs has already been done.
1211 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1212 attributes could be recognized here or in `attributes'). */
1213 | attributes setattrs after_type_declarator
1214 { $$ = $3; }
1215 | TYPENAME
1218 /* Kinds of declarator that can appear in a parameter list
1219 in addition to notype_declarator. This is like after_type_declarator
1220 but does not allow a typedef name in parentheses as an identifier
1221 (because it would conflict with a function with that typedef as arg). */
1223 parm_declarator:
1224 parm_declarator '(' parmlist_or_identifiers %prec '.'
1225 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1226 /* | parm_declarator '(' error ')' %prec '.'
1227 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1228 poplevel (0, 0, 0); } */
1229 | parm_declarator '[' expr ']' %prec '.'
1230 { $$ = build_nt (ARRAY_REF, $1, $3); }
1231 | parm_declarator '[' ']' %prec '.'
1232 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1233 | '*' type_quals parm_declarator %prec UNARY
1234 { $$ = make_pointer_declarator ($2, $3); }
1235 /* ??? Yuck. setattrs is a quick hack. We can't use
1236 prefix_attributes because $1 only applies to this
1237 declarator. We assume setspecs has already been done.
1238 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1239 attributes could be recognized here or in `attributes'). */
1240 | attributes setattrs parm_declarator
1241 { $$ = $3; }
1242 | TYPENAME
1245 /* A declarator allowed whether or not there has been
1246 an explicit typespec. These cannot redeclare a typedef-name. */
1248 notype_declarator:
1249 notype_declarator '(' parmlist_or_identifiers %prec '.'
1250 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1251 /* | notype_declarator '(' error ')' %prec '.'
1252 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1253 poplevel (0, 0, 0); } */
1254 | '(' notype_declarator ')'
1255 { $$ = $2; }
1256 | '*' type_quals notype_declarator %prec UNARY
1257 { $$ = make_pointer_declarator ($2, $3); }
1258 | notype_declarator '[' expr ']' %prec '.'
1259 { $$ = build_nt (ARRAY_REF, $1, $3); }
1260 | notype_declarator '[' ']' %prec '.'
1261 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1262 /* ??? Yuck. setattrs is a quick hack. We can't use
1263 prefix_attributes because $1 only applies to this
1264 declarator. We assume setspecs has already been done.
1265 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1266 attributes could be recognized here or in `attributes'). */
1267 | attributes setattrs notype_declarator
1268 { $$ = $3; }
1269 | IDENTIFIER
1272 structsp:
1273 STRUCT identifier '{'
1274 { $$ = start_struct (RECORD_TYPE, $2);
1275 /* Start scope of tag before parsing components. */
1277 component_decl_list '}' maybe_attribute
1278 { $$ = finish_struct ($<ttype>4, $5, $7); }
1279 | STRUCT '{' component_decl_list '}' maybe_attribute
1280 { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
1281 $3, $5);
1283 | STRUCT identifier
1284 { $$ = xref_tag (RECORD_TYPE, $2); }
1285 | UNION identifier '{'
1286 { $$ = start_struct (UNION_TYPE, $2); }
1287 component_decl_list '}' maybe_attribute
1288 { $$ = finish_struct ($<ttype>4, $5, $7); }
1289 | UNION '{' component_decl_list '}' maybe_attribute
1290 { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
1291 $3, $5);
1293 | UNION identifier
1294 { $$ = xref_tag (UNION_TYPE, $2); }
1295 | ENUM identifier '{'
1296 { $<itype>3 = suspend_momentary ();
1297 $$ = start_enum ($2); }
1298 enumlist maybecomma_warn '}' maybe_attribute
1299 { $$ = finish_enum ($<ttype>4, nreverse ($5), $8);
1300 resume_momentary ($<itype>3); }
1301 | ENUM '{'
1302 { $<itype>2 = suspend_momentary ();
1303 $$ = start_enum (NULL_TREE); }
1304 enumlist maybecomma_warn '}' maybe_attribute
1305 { $$ = finish_enum ($<ttype>3, nreverse ($4), $7);
1306 resume_momentary ($<itype>2); }
1307 | ENUM identifier
1308 { $$ = xref_tag (ENUMERAL_TYPE, $2); }
1311 maybecomma:
1312 /* empty */
1313 | ','
1316 maybecomma_warn:
1317 /* empty */
1318 | ','
1319 { if (pedantic) pedwarn ("comma at end of enumerator list"); }
1322 component_decl_list:
1323 component_decl_list2
1324 { $$ = $1; }
1325 | component_decl_list2 component_decl
1326 { $$ = chainon ($1, $2);
1327 pedwarn ("no semicolon at end of struct or union"); }
1330 component_decl_list2: /* empty */
1331 { $$ = NULL_TREE; }
1332 | component_decl_list2 component_decl ';'
1333 { $$ = chainon ($1, $2); }
1334 | component_decl_list2 ';'
1335 { if (pedantic)
1336 pedwarn ("extra semicolon in struct or union specified"); }
1339 /* There is a shift-reduce conflict here, because `components' may
1340 start with a `typename'. It happens that shifting (the default resolution)
1341 does the right thing, because it treats the `typename' as part of
1342 a `typed_typespecs'.
1344 It is possible that this same technique would allow the distinction
1345 between `notype_initdecls' and `initdecls' to be eliminated.
1346 But I am being cautious and not trying it. */
1348 component_decl:
1349 typed_typespecs setspecs components
1350 { $$ = $3;
1351 current_declspecs = TREE_VALUE (declspec_stack);
1352 prefix_attributes = TREE_PURPOSE (declspec_stack);
1353 declspec_stack = TREE_CHAIN (declspec_stack);
1354 resume_momentary ($2); }
1355 | typed_typespecs
1356 { if (pedantic)
1357 pedwarn ("ANSI C forbids member declarations with no members");
1358 shadow_tag($1);
1359 $$ = NULL_TREE; }
1360 | nonempty_type_quals setspecs components
1361 { $$ = $3;
1362 current_declspecs = TREE_VALUE (declspec_stack);
1363 prefix_attributes = TREE_PURPOSE (declspec_stack);
1364 declspec_stack = TREE_CHAIN (declspec_stack);
1365 resume_momentary ($2); }
1366 | nonempty_type_quals
1367 { if (pedantic)
1368 pedwarn ("ANSI C forbids member declarations with no members");
1369 shadow_tag($1);
1370 $$ = NULL_TREE; }
1371 | error
1372 { $$ = NULL_TREE; }
1373 | extension component_decl
1374 { $$ = $2;
1375 pedantic = $<itype>1; }
1378 components:
1379 component_declarator
1380 | components ',' component_declarator
1381 { $$ = chainon ($1, $3); }
1384 component_declarator:
1385 save_filename save_lineno declarator maybe_attribute
1386 { $$ = grokfield ($1, $2, $3, current_declspecs, NULL_TREE);
1387 decl_attributes ($$, $4, prefix_attributes); }
1388 | save_filename save_lineno
1389 declarator ':' expr_no_commas maybe_attribute
1390 { $$ = grokfield ($1, $2, $3, current_declspecs, $5);
1391 decl_attributes ($$, $6, prefix_attributes); }
1392 | save_filename save_lineno ':' expr_no_commas maybe_attribute
1393 { $$ = grokfield ($1, $2, NULL_TREE, current_declspecs, $4);
1394 decl_attributes ($$, $5, prefix_attributes); }
1397 /* We chain the enumerators in reverse order.
1398 They are put in forward order where enumlist is used.
1399 (The order used to be significant, but no longer is so.
1400 However, we still maintain the order, just to be clean.) */
1402 enumlist:
1403 enumerator
1404 | enumlist ',' enumerator
1405 { if ($1 == error_mark_node)
1406 $$ = $1;
1407 else
1408 $$ = chainon ($3, $1); }
1409 | error
1410 { $$ = error_mark_node; }
1414 enumerator:
1415 identifier
1416 { $$ = build_enumerator ($1, NULL_TREE); }
1417 | identifier '=' expr_no_commas
1418 { $$ = build_enumerator ($1, $3); }
1421 typename:
1422 typed_typespecs absdcl
1423 { $$ = build_tree_list ($1, $2); }
1424 | nonempty_type_quals absdcl
1425 { $$ = build_tree_list ($1, $2); }
1428 absdcl: /* an absolute declarator */
1429 /* empty */
1430 { $$ = NULL_TREE; }
1431 | absdcl1
1434 nonempty_type_quals:
1435 TYPE_QUAL
1436 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
1437 | nonempty_type_quals TYPE_QUAL
1438 { $$ = tree_cons (NULL_TREE, $2, $1); }
1441 type_quals:
1442 /* empty */
1443 { $$ = NULL_TREE; }
1444 | type_quals TYPE_QUAL
1445 { $$ = tree_cons (NULL_TREE, $2, $1); }
1448 absdcl1: /* a nonempty absolute declarator */
1449 '(' absdcl1 ')'
1450 { $$ = $2; }
1451 /* `(typedef)1' is `int'. */
1452 | '*' type_quals absdcl1 %prec UNARY
1453 { $$ = make_pointer_declarator ($2, $3); }
1454 | '*' type_quals %prec UNARY
1455 { $$ = make_pointer_declarator ($2, NULL_TREE); }
1456 | absdcl1 '(' parmlist %prec '.'
1457 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1458 | absdcl1 '[' expr ']' %prec '.'
1459 { $$ = build_nt (ARRAY_REF, $1, $3); }
1460 | absdcl1 '[' ']' %prec '.'
1461 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1462 | '(' parmlist %prec '.'
1463 { $$ = build_nt (CALL_EXPR, NULL_TREE, $2, NULL_TREE); }
1464 | '[' expr ']' %prec '.'
1465 { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
1466 | '[' ']' %prec '.'
1467 { $$ = build_nt (ARRAY_REF, NULL_TREE, NULL_TREE); }
1468 /* ??? It appears we have to support attributes here, however
1469 using prefix_attributes is wrong. */
1472 /* at least one statement, the first of which parses without error. */
1473 /* stmts is used only after decls, so an invalid first statement
1474 is actually regarded as an invalid decl and part of the decls. */
1476 stmts:
1477 lineno_stmt_or_labels
1479 if (pedantic && $1)
1480 pedwarn ("ANSI C forbids label at end of compound statement");
1484 lineno_stmt_or_labels:
1485 lineno_stmt_or_label
1486 | lineno_stmt_or_labels lineno_stmt_or_label
1487 { $$ = $2; }
1488 | lineno_stmt_or_labels errstmt
1489 { $$ = 0; }
1492 xstmts:
1493 /* empty */
1494 | stmts
1497 errstmt: error ';'
1500 pushlevel: /* empty */
1501 { emit_line_note (input_filename, lineno);
1502 pushlevel (0);
1503 clear_last_expr ();
1504 push_momentary ();
1505 expand_start_bindings (0);
1509 /* Read zero or more forward-declarations for labels
1510 that nested functions can jump to. */
1511 maybe_label_decls:
1512 /* empty */
1513 | label_decls
1514 { if (pedantic)
1515 pedwarn ("ANSI C forbids label declarations"); }
1518 label_decls:
1519 label_decl
1520 | label_decls label_decl
1523 label_decl:
1524 LABEL identifiers_or_typenames ';'
1525 { tree link;
1526 for (link = $2; link; link = TREE_CHAIN (link))
1528 tree label = shadow_label (TREE_VALUE (link));
1529 C_DECLARED_LABEL_FLAG (label) = 1;
1530 declare_nonlocal_label (label);
1535 /* This is the body of a function definition.
1536 It causes syntax errors to ignore to the next openbrace. */
1537 compstmt_or_error:
1538 compstmt
1540 | error compstmt
1543 compstmt_start: '{' { compstmt_count++; }
1545 compstmt: compstmt_start '}'
1546 { $$ = convert (void_type_node, integer_zero_node); }
1547 | compstmt_start pushlevel maybe_label_decls decls xstmts '}'
1548 { emit_line_note (input_filename, lineno);
1549 expand_end_bindings (getdecls (), 1, 0);
1550 $$ = poplevel (1, 1, 0);
1551 if (yychar == CONSTANT || yychar == STRING)
1552 pop_momentary_nofree ();
1553 else
1554 pop_momentary (); }
1555 | compstmt_start pushlevel maybe_label_decls error '}'
1556 { emit_line_note (input_filename, lineno);
1557 expand_end_bindings (getdecls (), kept_level_p (), 0);
1558 $$ = poplevel (kept_level_p (), 0, 0);
1559 if (yychar == CONSTANT || yychar == STRING)
1560 pop_momentary_nofree ();
1561 else
1562 pop_momentary (); }
1563 | compstmt_start pushlevel maybe_label_decls stmts '}'
1564 { emit_line_note (input_filename, lineno);
1565 expand_end_bindings (getdecls (), kept_level_p (), 0);
1566 $$ = poplevel (kept_level_p (), 0, 0);
1567 if (yychar == CONSTANT || yychar == STRING)
1568 pop_momentary_nofree ();
1569 else
1570 pop_momentary (); }
1573 /* Value is number of statements counted as of the closeparen. */
1574 simple_if:
1575 if_prefix lineno_labeled_stmt
1576 /* Make sure c_expand_end_cond is run once
1577 for each call to c_expand_start_cond.
1578 Otherwise a crash is likely. */
1579 | if_prefix error
1582 if_prefix:
1583 IF '(' expr ')'
1584 { emit_line_note ($<filename>-1, $<lineno>0);
1585 c_expand_start_cond (truthvalue_conversion ($3), 0,
1586 compstmt_count);
1587 $<itype>$ = stmt_count;
1588 if_stmt_file = $<filename>-1;
1589 if_stmt_line = $<lineno>0;
1590 position_after_white_space (); }
1593 /* This is a subroutine of stmt.
1594 It is used twice, once for valid DO statements
1595 and once for catching errors in parsing the end test. */
1596 do_stmt_start:
1598 { stmt_count++;
1599 compstmt_count++;
1600 emit_line_note ($<filename>-1, $<lineno>0);
1601 /* See comment in `while' alternative, above. */
1602 emit_nop ();
1603 expand_start_loop_continue_elsewhere (1);
1604 position_after_white_space (); }
1605 lineno_labeled_stmt WHILE
1606 { expand_loop_continue_here (); }
1609 save_filename:
1610 { $$ = input_filename; }
1613 save_lineno:
1614 { $$ = lineno; }
1617 lineno_labeled_stmt:
1618 save_filename save_lineno stmt
1620 /* | save_filename save_lineno error
1623 | save_filename save_lineno label lineno_labeled_stmt
1627 lineno_stmt_or_label:
1628 save_filename save_lineno stmt_or_label
1629 { $$ = $3; }
1632 stmt_or_label:
1633 stmt
1634 { $$ = 0; }
1635 | label
1636 { $$ = 1; }
1639 /* Parse a single real statement, not including any labels. */
1640 stmt:
1641 compstmt
1642 { stmt_count++; }
1643 | all_iter_stmt
1644 | expr ';'
1645 { stmt_count++;
1646 emit_line_note ($<filename>-1, $<lineno>0);
1647 /* It appears that this should not be done--that a non-lvalue array
1648 shouldn't get an error if the value isn't used.
1649 Section 3.2.2.1 says that an array lvalue gets converted to a pointer
1650 if it appears as a top-level expression,
1651 but says nothing about non-lvalue arrays. */
1652 #if 0
1653 /* Call default_conversion to get an error
1654 on referring to a register array if pedantic. */
1655 if (TREE_CODE (TREE_TYPE ($1)) == ARRAY_TYPE
1656 || TREE_CODE (TREE_TYPE ($1)) == FUNCTION_TYPE)
1657 $1 = default_conversion ($1);
1658 #endif
1659 iterator_expand ($1);
1660 clear_momentary (); }
1661 | simple_if ELSE
1662 { c_expand_start_else ();
1663 $<itype>1 = stmt_count;
1664 position_after_white_space (); }
1665 lineno_labeled_stmt
1666 { c_expand_end_cond ();
1667 if (extra_warnings && stmt_count == $<itype>1)
1668 warning ("empty body in an else-statement"); }
1669 | simple_if %prec IF
1670 { c_expand_end_cond ();
1671 /* This warning is here instead of in simple_if, because we
1672 do not want a warning if an empty if is followed by an
1673 else statement. Increment stmt_count so we don't
1674 give a second error if this is a nested `if'. */
1675 if (extra_warnings && stmt_count++ == $<itype>1)
1676 warning_with_file_and_line (if_stmt_file, if_stmt_line,
1677 "empty body in an if-statement"); }
1678 /* Make sure c_expand_end_cond is run once
1679 for each call to c_expand_start_cond.
1680 Otherwise a crash is likely. */
1681 | simple_if ELSE error
1682 { c_expand_end_cond (); }
1683 | WHILE
1684 { stmt_count++;
1685 emit_line_note ($<filename>-1, $<lineno>0);
1686 /* The emit_nop used to come before emit_line_note,
1687 but that made the nop seem like part of the preceding line.
1688 And that was confusing when the preceding line was
1689 inside of an if statement and was not really executed.
1690 I think it ought to work to put the nop after the line number.
1691 We will see. --rms, July 15, 1991. */
1692 emit_nop (); }
1693 '(' expr ')'
1694 { /* Don't start the loop till we have succeeded
1695 in parsing the end test. This is to make sure
1696 that we end every loop we start. */
1697 expand_start_loop (1);
1698 emit_line_note (input_filename, lineno);
1699 expand_exit_loop_if_false (NULL_PTR,
1700 truthvalue_conversion ($4));
1701 position_after_white_space (); }
1702 lineno_labeled_stmt
1703 { expand_end_loop (); }
1704 | do_stmt_start
1705 '(' expr ')' ';'
1706 { emit_line_note (input_filename, lineno);
1707 expand_exit_loop_if_false (NULL_PTR,
1708 truthvalue_conversion ($3));
1709 expand_end_loop ();
1710 clear_momentary (); }
1711 /* This rule is needed to make sure we end every loop we start. */
1712 | do_stmt_start error
1713 { expand_end_loop ();
1714 clear_momentary (); }
1715 | FOR
1716 '(' xexpr ';'
1717 { stmt_count++;
1718 emit_line_note ($<filename>-1, $<lineno>0);
1719 /* See comment in `while' alternative, above. */
1720 emit_nop ();
1721 if ($3) c_expand_expr_stmt ($3);
1722 /* Next step is to call expand_start_loop_continue_elsewhere,
1723 but wait till after we parse the entire for (...).
1724 Otherwise, invalid input might cause us to call that
1725 fn without calling expand_end_loop. */
1727 xexpr ';'
1728 /* Can't emit now; wait till after expand_start_loop... */
1729 { $<lineno>7 = lineno;
1730 $<filename>$ = input_filename; }
1731 xexpr ')'
1733 /* Start the loop. Doing this after parsing
1734 all the expressions ensures we will end the loop. */
1735 expand_start_loop_continue_elsewhere (1);
1736 /* Emit the end-test, with a line number. */
1737 emit_line_note ($<filename>8, $<lineno>7);
1738 if ($6)
1739 expand_exit_loop_if_false (NULL_PTR,
1740 truthvalue_conversion ($6));
1741 /* Don't let the tree nodes for $9 be discarded by
1742 clear_momentary during the parsing of the next stmt. */
1743 push_momentary ();
1744 $<lineno>7 = lineno;
1745 $<filename>8 = input_filename;
1746 position_after_white_space (); }
1747 lineno_labeled_stmt
1748 { /* Emit the increment expression, with a line number. */
1749 emit_line_note ($<filename>8, $<lineno>7);
1750 expand_loop_continue_here ();
1751 if ($9)
1752 c_expand_expr_stmt ($9);
1753 if (yychar == CONSTANT || yychar == STRING)
1754 pop_momentary_nofree ();
1755 else
1756 pop_momentary ();
1757 expand_end_loop (); }
1758 | SWITCH '(' expr ')'
1759 { stmt_count++;
1760 emit_line_note ($<filename>-1, $<lineno>0);
1761 c_expand_start_case ($3);
1762 /* Don't let the tree nodes for $3 be discarded by
1763 clear_momentary during the parsing of the next stmt. */
1764 push_momentary ();
1765 position_after_white_space (); }
1766 lineno_labeled_stmt
1767 { expand_end_case ($3);
1768 if (yychar == CONSTANT || yychar == STRING)
1769 pop_momentary_nofree ();
1770 else
1771 pop_momentary (); }
1772 | BREAK ';'
1773 { stmt_count++;
1774 emit_line_note ($<filename>-1, $<lineno>0);
1775 if ( ! expand_exit_something ())
1776 error ("break statement not within loop or switch"); }
1777 | CONTINUE ';'
1778 { stmt_count++;
1779 emit_line_note ($<filename>-1, $<lineno>0);
1780 if (! expand_continue_loop (NULL_PTR))
1781 error ("continue statement not within a loop"); }
1782 | RETURN ';'
1783 { stmt_count++;
1784 emit_line_note ($<filename>-1, $<lineno>0);
1785 c_expand_return (NULL_TREE); }
1786 | RETURN expr ';'
1787 { stmt_count++;
1788 emit_line_note ($<filename>-1, $<lineno>0);
1789 c_expand_return ($2); }
1790 | ASM_KEYWORD maybe_type_qual '(' expr ')' ';'
1791 { stmt_count++;
1792 emit_line_note ($<filename>-1, $<lineno>0);
1793 STRIP_NOPS ($4);
1794 if ((TREE_CODE ($4) == ADDR_EXPR
1795 && TREE_CODE (TREE_OPERAND ($4, 0)) == STRING_CST)
1796 || TREE_CODE ($4) == STRING_CST)
1797 expand_asm ($4);
1798 else
1799 error ("argument of `asm' is not a constant string"); }
1800 /* This is the case with just output operands. */
1801 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ')' ';'
1802 { stmt_count++;
1803 emit_line_note ($<filename>-1, $<lineno>0);
1804 c_expand_asm_operands ($4, $6, NULL_TREE, NULL_TREE,
1805 $2 == ridpointers[(int)RID_VOLATILE],
1806 input_filename, lineno); }
1807 /* This is the case with input operands as well. */
1808 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':' asm_operands ')' ';'
1809 { stmt_count++;
1810 emit_line_note ($<filename>-1, $<lineno>0);
1811 c_expand_asm_operands ($4, $6, $8, NULL_TREE,
1812 $2 == ridpointers[(int)RID_VOLATILE],
1813 input_filename, lineno); }
1814 /* This is the case with clobbered registers as well. */
1815 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':'
1816 asm_operands ':' asm_clobbers ')' ';'
1817 { stmt_count++;
1818 emit_line_note ($<filename>-1, $<lineno>0);
1819 c_expand_asm_operands ($4, $6, $8, $10,
1820 $2 == ridpointers[(int)RID_VOLATILE],
1821 input_filename, lineno); }
1822 | GOTO identifier ';'
1823 { tree decl;
1824 stmt_count++;
1825 emit_line_note ($<filename>-1, $<lineno>0);
1826 decl = lookup_label ($2);
1827 if (decl != 0)
1829 TREE_USED (decl) = 1;
1830 expand_goto (decl);
1833 | GOTO '*' expr ';'
1834 { if (pedantic)
1835 pedwarn ("ANSI C forbids `goto *expr;'");
1836 stmt_count++;
1837 emit_line_note ($<filename>-1, $<lineno>0);
1838 expand_computed_goto (convert (ptr_type_node, $3)); }
1839 | ';'
1842 all_iter_stmt:
1843 all_iter_stmt_simple
1844 /* | all_iter_stmt_with_decl */
1847 all_iter_stmt_simple:
1848 FOR '(' primary ')'
1850 /* The value returned by this action is */
1851 /* 1 if everything is OK */
1852 /* 0 in case of error or already bound iterator */
1854 $<itype>$ = 0;
1855 if (TREE_CODE ($3) != VAR_DECL)
1856 error ("invalid `for (ITERATOR)' syntax");
1857 else if (! ITERATOR_P ($3))
1858 error ("`%s' is not an iterator",
1859 IDENTIFIER_POINTER (DECL_NAME ($3)));
1860 else if (ITERATOR_BOUND_P ($3))
1861 error ("`for (%s)' inside expansion of same iterator",
1862 IDENTIFIER_POINTER (DECL_NAME ($3)));
1863 else
1865 $<itype>$ = 1;
1866 iterator_for_loop_start ($3);
1869 lineno_labeled_stmt
1871 if ($<itype>5)
1872 iterator_for_loop_end ($3);
1875 /* This really should allow any kind of declaration,
1876 for generality. Fix it before turning it back on.
1878 all_iter_stmt_with_decl:
1879 FOR '(' ITERATOR pushlevel setspecs iterator_spec ')'
1881 */ /* The value returned by this action is */
1882 /* 1 if everything is OK */
1883 /* 0 in case of error or already bound iterator */
1885 iterator_for_loop_start ($6);
1887 lineno_labeled_stmt
1889 iterator_for_loop_end ($6);
1890 emit_line_note (input_filename, lineno);
1891 expand_end_bindings (getdecls (), 1, 0);
1892 $<ttype>$ = poplevel (1, 1, 0);
1893 if (yychar == CONSTANT || yychar == STRING)
1894 pop_momentary_nofree ();
1895 else
1896 pop_momentary ();
1900 /* Any kind of label, including jump labels and case labels.
1901 ANSI C accepts labels only before statements, but we allow them
1902 also at the end of a compound statement. */
1904 label: CASE expr_no_commas ':'
1905 { register tree value = check_case_value ($2);
1906 register tree label
1907 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
1909 stmt_count++;
1911 if (value != error_mark_node)
1913 tree duplicate;
1914 int success;
1916 if (pedantic && ! INTEGRAL_TYPE_P (TREE_TYPE (value)))
1917 pedwarn ("label must have integral type in ANSI C");
1919 success = pushcase (value, convert_and_check,
1920 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; }