* rtl.h (rtunion_def): Constify member `rtstr'.
[official-gcc.git] / gcc / c-parse.y
blob553396b1512709d6ec3e71505ed848010b5975b6
1 /*WARNING: This file is automatically generated!*/
2 /* YACC parser for C syntax and for Objective C. -*-c-*-
3 Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
4 1999, 2000 Free Software Foundation, Inc.
6 This file is part of GNU CC.
8 GNU CC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
13 GNU CC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU CC; see the file COPYING. If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
23 /* This file defines the grammar of C and that of Objective C.
24 ifobjc ... end ifobjc conditionals contain code for Objective C only.
25 ifc ... end ifc conditionals contain code for C only.
26 Sed commands in Makefile.in are used to convert this file into
27 c-parse.y and into objc-parse.y. */
29 /* To whomever it may concern: I have heard that such a thing was once
30 written by AT&T, but I have never seen it. */
32 %expect 53
35 #include "config.h"
36 #include "system.h"
37 #include <setjmp.h>
38 #include "tree.h"
39 #include "input.h"
40 #include "c-lex.h"
41 #include "c-tree.h"
42 #include "flags.h"
43 #include "output.h"
44 #include "toplev.h"
45 #include "ggc.h"
47 #ifdef MULTIBYTE_CHARS
48 #include <locale.h>
49 #endif
52 /* Since parsers are distinct for each language, put the language string
53 definition here. */
54 const char * const language_string = "GNU C";
56 /* Like YYERROR but do call yyerror. */
57 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
59 /* Cause the `yydebug' variable to be defined. */
60 #define YYDEBUG 1
63 %start program
65 %union {long itype; tree ttype; enum tree_code code;
66 char *filename; int lineno; int ends_in_label; }
68 /* All identifiers that are not reserved words
69 and are not declared typedefs in the current block */
70 %token IDENTIFIER
72 /* All identifiers that are declared typedefs in the current block.
73 In some contexts, they are treated just like IDENTIFIER,
74 but they can also serve as typespecs in declarations. */
75 %token TYPENAME
77 /* Reserved words that specify storage class.
78 yylval contains an IDENTIFIER_NODE which indicates which one. */
79 %token SCSPEC
81 /* Reserved words that specify type.
82 yylval contains an IDENTIFIER_NODE which indicates which one. */
83 %token TYPESPEC
85 /* Reserved words that qualify type: "const", "volatile", or "restrict".
86 yylval contains an IDENTIFIER_NODE which indicates which one. */
87 %token TYPE_QUAL
89 /* Character or numeric constants.
90 yylval is the node for the constant. */
91 %token CONSTANT
93 /* String constants in raw form.
94 yylval is a STRING_CST node. */
95 %token STRING
97 /* "...", used for functions with variable arglists. */
98 %token ELLIPSIS
100 /* the reserved words */
101 /* SCO include files test "ASM", so use something else. */
102 %token SIZEOF ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
103 %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD TYPEOF ALIGNOF
104 %token ATTRIBUTE EXTENSION LABEL
105 %token REALPART IMAGPART VA_ARG
107 /* Used in c-lex.c for parsing pragmas. */
108 %token END_OF_LINE
110 /* Add precedence rules to solve dangling else s/r conflict */
111 %nonassoc IF
112 %nonassoc ELSE
114 /* Define the operator tokens and their precedences.
115 The value is an integer because, if used, it is the tree code
116 to use in the expression made from the operator. */
118 %right <code> ASSIGN '='
119 %right <code> '?' ':'
120 %left <code> OROR
121 %left <code> ANDAND
122 %left <code> '|'
123 %left <code> '^'
124 %left <code> '&'
125 %left <code> EQCOMPARE
126 %left <code> ARITHCOMPARE
127 %left <code> LSHIFT RSHIFT
128 %left <code> '+' '-'
129 %left <code> '*' '/' '%'
130 %right <code> UNARY PLUSPLUS MINUSMINUS
131 %left HYPERUNARY
132 %left <code> POINTSAT '.' '(' '['
134 /* The Objective-C keywords. These are included in C and in
135 Objective C, so that the token codes are the same in both. */
136 %token INTERFACE IMPLEMENTATION END SELECTOR DEFS ENCODE
137 %token CLASSNAME PUBLIC PRIVATE PROTECTED PROTOCOL OBJECTNAME CLASS ALIAS
139 /* Objective-C string constants in raw form.
140 yylval is an OBJC_STRING_CST node. */
141 %token OBJC_STRING
144 %type <code> unop
146 %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist exprlist
147 %type <ttype> expr_no_commas cast_expr unary_expr primary string STRING
148 %type <ttype> typed_declspecs reserved_declspecs
149 %type <ttype> typed_typespecs reserved_typespecquals
150 %type <ttype> declmods typespec typespecqual_reserved
151 %type <ttype> typed_declspecs_no_prefix_attr reserved_declspecs_no_prefix_attr
152 %type <ttype> declmods_no_prefix_attr
153 %type <ttype> SCSPEC TYPESPEC TYPE_QUAL nonempty_type_quals maybe_type_qual
154 %type <ttype> initdecls notype_initdecls initdcl notype_initdcl
155 %type <ttype> init maybeasm
156 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
157 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
158 %type <ttype> any_word extension
160 %type <ttype> compstmt compstmt_nostart compstmt_primary_start
162 %type <ttype> declarator
163 %type <ttype> notype_declarator after_type_declarator
164 %type <ttype> parm_declarator
166 %type <ttype> structsp component_decl_list component_decl_list2
167 %type <ttype> component_decl components component_declarator
168 %type <ttype> enumlist enumerator
169 %type <ttype> struct_head union_head enum_head
170 %type <ttype> typename absdcl absdcl1 type_quals
171 %type <ttype> xexpr parms parm identifiers
173 %type <ttype> parmlist parmlist_1 parmlist_2
174 %type <ttype> parmlist_or_identifiers parmlist_or_identifiers_1
175 %type <ttype> identifiers_or_typenames
177 %type <itype> setspecs
179 %type <ends_in_label> lineno_stmt_or_label lineno_stmt_or_labels stmt_or_label
181 %type <filename> save_filename
182 %type <lineno> save_lineno
186 /* Number of statements (loosely speaking) and compound statements
187 seen so far. */
188 static int stmt_count;
189 static int compstmt_count;
191 /* Input file and line number of the end of the body of last simple_if;
192 used by the stmt-rule immediately after simple_if returns. */
193 static char *if_stmt_file;
194 static int if_stmt_line;
196 /* List of types and structure classes of the current declaration. */
197 static tree current_declspecs = NULL_TREE;
198 static tree prefix_attributes = NULL_TREE;
200 /* Stack of saved values of current_declspecs and prefix_attributes. */
201 static tree declspec_stack;
203 /* 1 if we explained undeclared var errors. */
204 static int undeclared_variable_notice;
206 /* For __extension__, save/restore the warning flags which are
207 controlled by __extension__. */
208 #define SAVE_WARN_FLAGS() \
209 build_int_2 (pedantic | (warn_pointer_arith << 1), 0)
210 #define RESTORE_WARN_FLAGS(tval) \
211 do { \
212 int val = TREE_INT_CST_LOW (tval); \
213 pedantic = val & 1; \
214 warn_pointer_arith = (val >> 1) & 1; \
215 } while (0)
218 /* Tell yyparse how to print a token's value, if yydebug is set. */
220 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
221 extern void yyprint PARAMS ((FILE *, int, YYSTYPE));
223 /* Add GC roots for variables local to this file. */
224 void
225 c_parse_init ()
227 ggc_add_tree_root (&declspec_stack, 1);
228 ggc_add_tree_root (&current_declspecs, 1);
229 ggc_add_tree_root (&prefix_attributes, 1);
235 program: /* empty */
236 { if (pedantic)
237 pedwarn ("ANSI C forbids an empty source file");
238 finish_file ();
240 | extdefs
242 /* In case there were missing closebraces,
243 get us back to the global binding level. */
244 while (! global_bindings_p ())
245 poplevel (0, 0, 0);
246 finish_file ();
250 /* the reason for the strange actions in this rule
251 is so that notype_initdecls when reached via datadef
252 can find a valid list of type and sc specs in $0. */
254 extdefs:
255 {$<ttype>$ = NULL_TREE; } extdef
256 | extdefs {$<ttype>$ = NULL_TREE; } extdef
259 extdef:
260 fndef
261 | datadef
262 | ASM_KEYWORD '(' expr ')' ';'
263 { STRIP_NOPS ($3);
264 if ((TREE_CODE ($3) == ADDR_EXPR
265 && TREE_CODE (TREE_OPERAND ($3, 0)) == STRING_CST)
266 || TREE_CODE ($3) == STRING_CST)
267 assemble_asm ($3);
268 else
269 error ("argument of `asm' is not a constant string"); }
270 | extension extdef
271 { RESTORE_WARN_FLAGS ($1); }
274 datadef:
275 setspecs notype_initdecls ';'
276 { if (pedantic)
277 error ("ANSI C forbids data definition with no type or storage class");
278 else if (!flag_traditional)
279 warning ("data definition has no type or storage class");
281 current_declspecs = TREE_VALUE (declspec_stack);
282 prefix_attributes = TREE_PURPOSE (declspec_stack);
283 declspec_stack = TREE_CHAIN (declspec_stack); }
284 | declmods setspecs notype_initdecls ';'
285 { current_declspecs = TREE_VALUE (declspec_stack);
286 prefix_attributes = TREE_PURPOSE (declspec_stack);
287 declspec_stack = TREE_CHAIN (declspec_stack); }
288 | typed_declspecs setspecs initdecls ';'
289 { current_declspecs = TREE_VALUE (declspec_stack);
290 prefix_attributes = TREE_PURPOSE (declspec_stack);
291 declspec_stack = TREE_CHAIN (declspec_stack); }
292 | 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))
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 | typed_declspecs setspecs declarator error
317 { current_declspecs = TREE_VALUE (declspec_stack);
318 prefix_attributes = TREE_PURPOSE (declspec_stack);
319 declspec_stack = TREE_CHAIN (declspec_stack); }
320 | declmods setspecs notype_declarator
321 { if (! start_function (current_declspecs, $3,
322 prefix_attributes, NULL_TREE))
323 YYERROR1;
324 reinit_parse_for_function (); }
325 old_style_parm_decls
326 { store_parm_decls (); }
327 compstmt_or_error
328 { finish_function (0);
329 current_declspecs = TREE_VALUE (declspec_stack);
330 prefix_attributes = TREE_PURPOSE (declspec_stack);
331 declspec_stack = TREE_CHAIN (declspec_stack); }
332 | declmods setspecs notype_declarator error
333 { current_declspecs = TREE_VALUE (declspec_stack);
334 prefix_attributes = TREE_PURPOSE (declspec_stack);
335 declspec_stack = TREE_CHAIN (declspec_stack); }
336 | setspecs notype_declarator
337 { if (! start_function (NULL_TREE, $2,
338 prefix_attributes, NULL_TREE))
339 YYERROR1;
340 reinit_parse_for_function (); }
341 old_style_parm_decls
342 { store_parm_decls (); }
343 compstmt_or_error
344 { finish_function (0);
345 current_declspecs = TREE_VALUE (declspec_stack);
346 prefix_attributes = TREE_PURPOSE (declspec_stack);
347 declspec_stack = TREE_CHAIN (declspec_stack); }
348 | setspecs notype_declarator error
349 { current_declspecs = TREE_VALUE (declspec_stack);
350 prefix_attributes = TREE_PURPOSE (declspec_stack);
351 declspec_stack = TREE_CHAIN (declspec_stack); }
354 identifier:
355 IDENTIFIER
356 | TYPENAME
359 unop: '&'
360 { $$ = ADDR_EXPR; }
361 | '-'
362 { $$ = NEGATE_EXPR; }
363 | '+'
364 { $$ = CONVERT_EXPR; }
365 | PLUSPLUS
366 { $$ = PREINCREMENT_EXPR; }
367 | MINUSMINUS
368 { $$ = PREDECREMENT_EXPR; }
369 | '~'
370 { $$ = BIT_NOT_EXPR; }
371 | '!'
372 { $$ = TRUTH_NOT_EXPR; }
375 expr: nonnull_exprlist
376 { $$ = build_compound_expr ($1); }
379 exprlist:
380 /* empty */
381 { $$ = NULL_TREE; }
382 | nonnull_exprlist
385 nonnull_exprlist:
386 expr_no_commas
387 { $$ = build_tree_list (NULL_TREE, $1); }
388 | nonnull_exprlist ',' expr_no_commas
389 { chainon ($1, build_tree_list (NULL_TREE, $3)); }
392 unary_expr:
393 primary
394 | '*' cast_expr %prec UNARY
395 { $$ = build_indirect_ref ($2, "unary *"); }
396 /* __extension__ turns off -pedantic for following primary. */
397 | extension cast_expr %prec UNARY
398 { $$ = $2;
399 RESTORE_WARN_FLAGS ($1); }
400 | unop cast_expr %prec UNARY
401 { $$ = build_unary_op ($1, $2, 0);
402 overflow_warning ($$); }
403 /* Refer to the address of a label as a pointer. */
404 | ANDAND identifier
405 { tree label = lookup_label ($2);
406 if (pedantic)
407 pedwarn ("ANSI C forbids `&&'");
408 if (label == 0)
409 $$ = null_pointer_node;
410 else
412 TREE_USED (label) = 1;
413 $$ = build1 (ADDR_EXPR, ptr_type_node, label);
414 TREE_CONSTANT ($$) = 1;
417 /* This seems to be impossible on some machines, so let's turn it off.
418 You can use __builtin_next_arg to find the anonymous stack args.
419 | '&' ELLIPSIS
420 { tree types = TYPE_ARG_TYPES (TREE_TYPE (current_function_decl));
421 $$ = error_mark_node;
422 if (TREE_VALUE (tree_last (types)) == void_type_node)
423 error ("`&...' used in function with fixed number of arguments");
424 else
426 if (pedantic)
427 pedwarn ("ANSI C forbids `&...'");
428 $$ = tree_last (DECL_ARGUMENTS (current_function_decl));
429 $$ = build_unary_op (ADDR_EXPR, $$, 0);
432 | sizeof unary_expr %prec UNARY
433 { skip_evaluation--;
434 if (TREE_CODE ($2) == COMPONENT_REF
435 && DECL_C_BIT_FIELD (TREE_OPERAND ($2, 1)))
436 error ("`sizeof' applied to a bit-field");
437 $$ = c_sizeof (TREE_TYPE ($2)); }
438 | sizeof '(' typename ')' %prec HYPERUNARY
439 { skip_evaluation--;
440 $$ = c_sizeof (groktypename ($3)); }
441 | alignof unary_expr %prec UNARY
442 { skip_evaluation--;
443 $$ = c_alignof_expr ($2); }
444 | alignof '(' typename ')' %prec HYPERUNARY
445 { skip_evaluation--;
446 $$ = c_alignof (groktypename ($3)); }
447 | REALPART cast_expr %prec UNARY
448 { $$ = build_unary_op (REALPART_EXPR, $2, 0); }
449 | IMAGPART cast_expr %prec UNARY
450 { $$ = build_unary_op (IMAGPART_EXPR, $2, 0); }
451 | VA_ARG '(' expr_no_commas ',' typename ')'
452 { $$ = build_va_arg ($3, groktypename ($5)); }
455 sizeof:
456 SIZEOF { skip_evaluation++; }
459 alignof:
460 ALIGNOF { skip_evaluation++; }
463 cast_expr:
464 unary_expr
465 | '(' typename ')' cast_expr %prec UNARY
466 { tree type = groktypename ($2);
467 $$ = build_c_cast (type, $4); }
468 | '(' typename ')' '{'
469 { start_init (NULL_TREE, NULL, 0);
470 $2 = groktypename ($2);
471 really_start_incremental_init ($2); }
472 initlist_maybe_comma '}' %prec UNARY
473 { const char *name;
474 tree result = pop_init_level (0);
475 tree type = $2;
476 finish_init ();
478 if (pedantic && ! flag_isoc99)
479 pedwarn ("ANSI C forbids constructor expressions");
480 if (TYPE_NAME (type) != 0)
482 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
483 name = IDENTIFIER_POINTER (TYPE_NAME (type));
484 else
485 name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
487 else
488 name = "";
489 $$ = result;
490 if (TREE_CODE (type) == ARRAY_TYPE && TYPE_SIZE (type) == 0)
492 int failure = complete_array_type (type, $$, 1);
493 if (failure)
494 abort ();
499 expr_no_commas:
500 cast_expr
501 | expr_no_commas '+' expr_no_commas
502 { $$ = parser_build_binary_op ($2, $1, $3); }
503 | expr_no_commas '-' expr_no_commas
504 { $$ = parser_build_binary_op ($2, $1, $3); }
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 LSHIFT expr_no_commas
512 { $$ = parser_build_binary_op ($2, $1, $3); }
513 | expr_no_commas RSHIFT expr_no_commas
514 { $$ = parser_build_binary_op ($2, $1, $3); }
515 | expr_no_commas ARITHCOMPARE expr_no_commas
516 { $$ = parser_build_binary_op ($2, $1, $3); }
517 | expr_no_commas EQCOMPARE 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 '|' 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 ANDAND
526 { $1 = truthvalue_conversion (default_conversion ($1));
527 skip_evaluation += $1 == boolean_false_node; }
528 expr_no_commas
529 { skip_evaluation -= $1 == boolean_false_node;
530 $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $4); }
531 | expr_no_commas OROR
532 { $1 = truthvalue_conversion (default_conversion ($1));
533 skip_evaluation += $1 == boolean_true_node; }
534 expr_no_commas
535 { skip_evaluation -= $1 == boolean_true_node;
536 $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $4); }
537 | expr_no_commas '?'
538 { $1 = truthvalue_conversion (default_conversion ($1));
539 skip_evaluation += $1 == boolean_false_node; }
540 expr ':'
541 { skip_evaluation += (($1 == boolean_true_node)
542 - ($1 == boolean_false_node)); }
543 expr_no_commas
544 { skip_evaluation -= $1 == boolean_true_node;
545 $$ = build_conditional_expr ($1, $4, $7); }
546 | expr_no_commas '?'
547 { if (pedantic)
548 pedwarn ("ANSI C forbids omitting the middle term of a ?: expression");
549 /* Make sure first operand is calculated only once. */
550 $<ttype>2 = save_expr ($1);
551 $1 = truthvalue_conversion (default_conversion ($<ttype>2));
552 skip_evaluation += $1 == boolean_true_node; }
553 ':' expr_no_commas
554 { skip_evaluation -= $1 == boolean_true_node;
555 $$ = build_conditional_expr ($1, $<ttype>2, $5); }
556 | expr_no_commas '=' expr_no_commas
557 { char class;
558 $$ = build_modify_expr ($1, NOP_EXPR, $3);
559 class = TREE_CODE_CLASS (TREE_CODE ($$));
560 if (class == 'e' || class == '1'
561 || class == '2' || class == '<')
562 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR);
564 | expr_no_commas ASSIGN expr_no_commas
565 { char class;
566 $$ = build_modify_expr ($1, $2, $3);
567 /* This inhibits warnings in truthvalue_conversion. */
568 class = TREE_CODE_CLASS (TREE_CODE ($$));
569 if (class == 'e' || class == '1'
570 || class == '2' || class == '<')
571 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 | compstmt_primary_start compstmt_nostart ')'
686 { tree rtl_exp;
687 if (pedantic)
688 pedwarn ("ANSI C forbids braced-groups within expressions");
689 pop_iterator_stack ();
690 pop_label_level ();
691 rtl_exp = expand_end_stmt_expr ($1);
692 /* The statements have side effects, so the group does. */
693 TREE_SIDE_EFFECTS (rtl_exp) = 1;
695 if (TREE_CODE ($2) == BLOCK)
697 /* Make a BIND_EXPR for the BLOCK already made. */
698 $$ = build (BIND_EXPR, TREE_TYPE (rtl_exp),
699 NULL_TREE, rtl_exp, $2);
700 /* Remove the block from the tree at this point.
701 It gets put back at the proper place
702 when the BIND_EXPR is expanded. */
703 delete_block ($2);
705 else
706 $$ = $2;
708 | compstmt_primary_start error ')'
710 /* Make sure we call expand_end_stmt_expr. Otherwise
711 we are likely to lose sequences and crash later. */
712 pop_iterator_stack ();
713 pop_label_level ();
714 expand_end_stmt_expr ($1);
715 $$ = error_mark_node;
717 | primary '(' exprlist ')' %prec '.'
718 { $$ = build_function_call ($1, $3); }
719 | primary '[' expr ']' %prec '.'
720 { $$ = build_array_ref ($1, $3); }
721 | primary '.' identifier
723 $$ = build_component_ref ($1, $3);
725 | primary POINTSAT identifier
727 tree expr = build_indirect_ref ($1, "->");
729 $$ = build_component_ref (expr, $3);
731 | primary PLUSPLUS
732 { $$ = build_unary_op (POSTINCREMENT_EXPR, $1, 0); }
733 | primary MINUSMINUS
734 { $$ = build_unary_op (POSTDECREMENT_EXPR, $1, 0); }
737 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
738 string:
739 STRING
740 | string STRING
741 { $$ = chainon ($1, $2);
742 if (warn_traditional && !in_system_header)
743 warning ("Use of ANSI string concatenation");
748 old_style_parm_decls:
749 /* empty */
750 | datadecls
751 | datadecls ELLIPSIS
752 /* ... is used here to indicate a varargs function. */
753 { c_mark_varargs ();
754 if (pedantic)
755 pedwarn ("ANSI C does not permit use of `varargs.h'"); }
758 /* The following are analogous to lineno_decl, decls and decl
759 except that they do not allow nested functions.
760 They are used for old-style parm decls. */
761 lineno_datadecl:
762 save_filename save_lineno datadecl
766 datadecls:
767 lineno_datadecl
768 | errstmt
769 | datadecls lineno_datadecl
770 | lineno_datadecl errstmt
773 /* We don't allow prefix attributes here because they cause reduce/reduce
774 conflicts: we can't know whether we're parsing a function decl with
775 attribute suffix, or function defn with attribute prefix on first old
776 style parm. */
777 datadecl:
778 typed_declspecs_no_prefix_attr setspecs initdecls ';'
779 { current_declspecs = TREE_VALUE (declspec_stack);
780 prefix_attributes = TREE_PURPOSE (declspec_stack);
781 declspec_stack = TREE_CHAIN (declspec_stack); }
782 | declmods_no_prefix_attr setspecs notype_initdecls ';'
783 { current_declspecs = TREE_VALUE (declspec_stack);
784 prefix_attributes = TREE_PURPOSE (declspec_stack);
785 declspec_stack = TREE_CHAIN (declspec_stack); }
786 | typed_declspecs_no_prefix_attr ';'
787 { shadow_tag_warned ($1, 1);
788 pedwarn ("empty declaration"); }
789 | declmods_no_prefix_attr ';'
790 { pedwarn ("empty declaration"); }
793 /* This combination which saves a lineno before a decl
794 is the normal thing to use, rather than decl itself.
795 This is to avoid shift/reduce conflicts in contexts
796 where statement labels are allowed. */
797 lineno_decl:
798 save_filename save_lineno decl
802 decls:
803 lineno_decl
804 | errstmt
805 | decls lineno_decl
806 | lineno_decl errstmt
809 /* records the type and storage class specs to use for processing
810 the declarators that follow.
811 Maintains a stack of outer-level values of current_declspecs,
812 for the sake of parm declarations nested in function declarators. */
813 setspecs: /* empty */
814 { pending_xref_error ();
815 declspec_stack = tree_cons (prefix_attributes,
816 current_declspecs,
817 declspec_stack);
818 split_specs_attrs ($<ttype>0,
819 &current_declspecs, &prefix_attributes); }
822 /* ??? Yuck. See after_type_declarator. */
823 setattrs: /* empty */
824 { prefix_attributes = chainon (prefix_attributes, $<ttype>0); }
827 decl:
828 typed_declspecs setspecs initdecls ';'
829 { current_declspecs = TREE_VALUE (declspec_stack);
830 prefix_attributes = TREE_PURPOSE (declspec_stack);
831 declspec_stack = TREE_CHAIN (declspec_stack); }
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 | typed_declspecs setspecs nested_function
837 { current_declspecs = TREE_VALUE (declspec_stack);
838 prefix_attributes = TREE_PURPOSE (declspec_stack);
839 declspec_stack = TREE_CHAIN (declspec_stack); }
840 | declmods setspecs notype_nested_function
841 { current_declspecs = TREE_VALUE (declspec_stack);
842 prefix_attributes = TREE_PURPOSE (declspec_stack);
843 declspec_stack = TREE_CHAIN (declspec_stack); }
844 | typed_declspecs ';'
845 { shadow_tag ($1); }
846 | declmods ';'
847 { pedwarn ("empty declaration"); }
848 | extension decl
849 { RESTORE_WARN_FLAGS ($1); }
852 /* Declspecs which contain at least one type specifier or typedef name.
853 (Just `const' or `volatile' is not enough.)
854 A typedef'd name following these is taken as a name to be declared.
855 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
857 typed_declspecs:
858 typespec reserved_declspecs
859 { $$ = tree_cons (NULL_TREE, $1, $2); }
860 | declmods typespec reserved_declspecs
861 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
864 reserved_declspecs: /* empty */
865 { $$ = NULL_TREE; }
866 | reserved_declspecs typespecqual_reserved
867 { $$ = tree_cons (NULL_TREE, $2, $1); }
868 | reserved_declspecs SCSPEC
869 { if (extra_warnings)
870 warning ("`%s' is not at beginning of declaration",
871 IDENTIFIER_POINTER ($2));
872 $$ = tree_cons (NULL_TREE, $2, $1); }
873 | reserved_declspecs attributes
874 { $$ = tree_cons ($2, NULL_TREE, $1); }
877 typed_declspecs_no_prefix_attr:
878 typespec reserved_declspecs_no_prefix_attr
879 { $$ = tree_cons (NULL_TREE, $1, $2); }
880 | declmods_no_prefix_attr typespec reserved_declspecs_no_prefix_attr
881 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
884 reserved_declspecs_no_prefix_attr:
885 /* empty */
886 { $$ = NULL_TREE; }
887 | reserved_declspecs_no_prefix_attr typespecqual_reserved
888 { $$ = tree_cons (NULL_TREE, $2, $1); }
889 | reserved_declspecs_no_prefix_attr SCSPEC
890 { if (extra_warnings)
891 warning ("`%s' is not at beginning of declaration",
892 IDENTIFIER_POINTER ($2));
893 $$ = tree_cons (NULL_TREE, $2, $1); }
896 /* List of just storage classes, type modifiers, and prefix attributes.
897 A declaration can start with just this, but then it cannot be used
898 to redeclare a typedef-name.
899 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
901 declmods:
902 declmods_no_prefix_attr
903 { $$ = $1; }
904 | attributes
905 { $$ = tree_cons ($1, NULL_TREE, NULL_TREE); }
906 | declmods declmods_no_prefix_attr
907 { $$ = chainon ($2, $1); }
908 | declmods attributes
909 { $$ = tree_cons ($2, NULL_TREE, $1); }
912 declmods_no_prefix_attr:
913 TYPE_QUAL
914 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
915 TREE_STATIC ($$) = 1; }
916 | SCSPEC
917 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
918 | declmods_no_prefix_attr TYPE_QUAL
919 { $$ = tree_cons (NULL_TREE, $2, $1);
920 TREE_STATIC ($$) = 1; }
921 | declmods_no_prefix_attr SCSPEC
922 { if (extra_warnings && TREE_STATIC ($1))
923 warning ("`%s' is not at beginning of declaration",
924 IDENTIFIER_POINTER ($2));
925 $$ = tree_cons (NULL_TREE, $2, $1);
926 TREE_STATIC ($$) = TREE_STATIC ($1); }
930 /* Used instead of declspecs where storage classes are not allowed
931 (that is, for typenames and structure components).
932 Don't accept a typedef-name if anything but a modifier precedes it. */
934 typed_typespecs:
935 typespec reserved_typespecquals
936 { $$ = tree_cons (NULL_TREE, $1, $2); }
937 | nonempty_type_quals typespec reserved_typespecquals
938 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
941 reserved_typespecquals: /* empty */
942 { $$ = NULL_TREE; }
943 | reserved_typespecquals typespecqual_reserved
944 { $$ = tree_cons (NULL_TREE, $2, $1); }
947 /* A typespec (but not a type qualifier).
948 Once we have seen one of these in a declaration,
949 if a typedef name appears then it is being redeclared. */
951 typespec: TYPESPEC
952 | structsp
953 | TYPENAME
954 { /* For a typedef name, record the meaning, not the name.
955 In case of `foo foo, bar;'. */
956 $$ = lookup_name ($1); }
957 | TYPEOF '(' expr ')'
958 { $$ = TREE_TYPE ($3); }
959 | TYPEOF '(' typename ')'
960 { $$ = groktypename ($3); }
963 /* A typespec that is a reserved word, or a type qualifier. */
965 typespecqual_reserved: TYPESPEC
966 | TYPE_QUAL
967 | structsp
970 initdecls:
971 initdcl
972 | initdecls ',' initdcl
975 notype_initdecls:
976 notype_initdcl
977 | notype_initdecls ',' initdcl
980 maybeasm:
981 /* empty */
982 { $$ = NULL_TREE; }
983 | ASM_KEYWORD '(' string ')'
984 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
985 $$ = $3;
989 initdcl:
990 declarator maybeasm maybe_attribute '='
991 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
992 $3, prefix_attributes);
993 start_init ($<ttype>$, $2, global_bindings_p ()); }
994 init
995 /* Note how the declaration of the variable is in effect while its init is parsed! */
996 { finish_init ();
997 finish_decl ($<ttype>5, $6, $2); }
998 | declarator maybeasm maybe_attribute
999 { tree d = start_decl ($1, current_declspecs, 0,
1000 $3, prefix_attributes);
1001 finish_decl (d, NULL_TREE, $2);
1005 notype_initdcl:
1006 notype_declarator maybeasm maybe_attribute '='
1007 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1008 $3, prefix_attributes);
1009 start_init ($<ttype>$, $2, global_bindings_p ()); }
1010 init
1011 /* Note how the declaration of the variable is in effect while its init is parsed! */
1012 { finish_init ();
1013 decl_attributes ($<ttype>5, $3, prefix_attributes);
1014 finish_decl ($<ttype>5, $6, $2); }
1015 | notype_declarator maybeasm maybe_attribute
1016 { tree d = start_decl ($1, current_declspecs, 0,
1017 $3, prefix_attributes);
1018 finish_decl (d, NULL_TREE, $2); }
1020 /* the * rules are dummies to accept the Apollo extended syntax
1021 so that the header files compile. */
1022 maybe_attribute:
1023 /* empty */
1024 { $$ = NULL_TREE; }
1025 | attributes
1026 { $$ = $1; }
1029 attributes:
1030 attribute
1031 { $$ = $1; }
1032 | attributes attribute
1033 { $$ = chainon ($1, $2); }
1036 attribute:
1037 ATTRIBUTE '(' '(' attribute_list ')' ')'
1038 { $$ = $4; }
1041 attribute_list:
1042 attrib
1043 { $$ = $1; }
1044 | attribute_list ',' attrib
1045 { $$ = chainon ($1, $3); }
1048 attrib:
1049 /* empty */
1050 { $$ = NULL_TREE; }
1051 | any_word
1052 { $$ = build_tree_list ($1, NULL_TREE); }
1053 | any_word '(' IDENTIFIER ')'
1054 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1055 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1056 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1057 | any_word '(' exprlist ')'
1058 { $$ = build_tree_list ($1, $3); }
1061 /* This still leaves out most reserved keywords,
1062 shouldn't we include them? */
1064 any_word:
1065 identifier
1066 | SCSPEC
1067 | TYPESPEC
1068 | TYPE_QUAL
1071 /* Initializers. `init' is the entry point. */
1073 init:
1074 expr_no_commas
1075 | '{'
1076 { really_start_incremental_init (NULL_TREE); }
1077 initlist_maybe_comma '}'
1078 { $$ = pop_init_level (0); }
1079 | error
1080 { $$ = error_mark_node; }
1083 /* `initlist_maybe_comma' is the guts of an initializer in braces. */
1084 initlist_maybe_comma:
1085 /* empty */
1086 { if (pedantic)
1087 pedwarn ("ANSI C forbids empty initializer braces"); }
1088 | initlist1 maybecomma
1091 initlist1:
1092 initelt
1093 | initlist1 ',' initelt
1096 /* `initelt' is a single element of an initializer.
1097 It may use braces. */
1098 initelt:
1099 designator_list '=' initval
1100 | designator initval
1101 | identifier ':'
1102 { set_init_label ($1); }
1103 initval
1104 | initval
1107 initval:
1109 { push_init_level (0); }
1110 initlist_maybe_comma '}'
1111 { process_init_element (pop_init_level (0)); }
1112 | expr_no_commas
1113 { process_init_element ($1); }
1114 | error
1117 designator_list:
1118 designator
1119 | designator_list designator
1122 designator:
1123 '.' identifier
1124 { set_init_label ($2); }
1125 /* These are for labeled elements. The syntax for an array element
1126 initializer conflicts with the syntax for an Objective-C message,
1127 so don't include these productions in the Objective-C grammar. */
1128 | '[' expr_no_commas ELLIPSIS expr_no_commas ']'
1129 { set_init_index ($2, $4); }
1130 | '[' expr_no_commas ']'
1131 { set_init_index ($2, NULL_TREE); }
1134 nested_function:
1135 declarator
1136 { if (pedantic)
1137 pedwarn ("ANSI C forbids nested functions");
1139 push_function_context ();
1140 if (! start_function (current_declspecs, $1,
1141 prefix_attributes, NULL_TREE))
1143 pop_function_context ();
1144 YYERROR1;
1146 reinit_parse_for_function (); }
1147 old_style_parm_decls
1148 { store_parm_decls (); }
1149 /* This used to use compstmt_or_error.
1150 That caused a bug with input `f(g) int g {}',
1151 where the use of YYERROR1 above caused an error
1152 which then was handled by compstmt_or_error.
1153 There followed a repeated execution of that same rule,
1154 which called YYERROR1 again, and so on. */
1155 compstmt
1156 { finish_function (1);
1157 pop_function_context (); }
1160 notype_nested_function:
1161 notype_declarator
1162 { if (pedantic)
1163 pedwarn ("ANSI C forbids nested functions");
1165 push_function_context ();
1166 if (! start_function (current_declspecs, $1,
1167 prefix_attributes, NULL_TREE))
1169 pop_function_context ();
1170 YYERROR1;
1172 reinit_parse_for_function (); }
1173 old_style_parm_decls
1174 { store_parm_decls (); }
1175 /* This used to use compstmt_or_error.
1176 That caused a bug with input `f(g) int g {}',
1177 where the use of YYERROR1 above caused an error
1178 which then was handled by compstmt_or_error.
1179 There followed a repeated execution of that same rule,
1180 which called YYERROR1 again, and so on. */
1181 compstmt
1182 { finish_function (1);
1183 pop_function_context (); }
1186 /* Any kind of declarator (thus, all declarators allowed
1187 after an explicit typespec). */
1189 declarator:
1190 after_type_declarator
1191 | notype_declarator
1194 /* A declarator that is allowed only after an explicit typespec. */
1196 after_type_declarator:
1197 '(' after_type_declarator ')'
1198 { $$ = $2; }
1199 | after_type_declarator '(' parmlist_or_identifiers %prec '.'
1200 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1201 /* | after_type_declarator '(' error ')' %prec '.'
1202 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1203 poplevel (0, 0, 0); } */
1204 | after_type_declarator '[' expr ']' %prec '.'
1205 { $$ = build_nt (ARRAY_REF, $1, $3); }
1206 | after_type_declarator '[' ']' %prec '.'
1207 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1208 | '*' type_quals after_type_declarator %prec UNARY
1209 { $$ = make_pointer_declarator ($2, $3); }
1210 /* ??? Yuck. setattrs is a quick hack. We can't use
1211 prefix_attributes because $1 only applies to this
1212 declarator. We assume setspecs has already been done.
1213 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1214 attributes could be recognized here or in `attributes'). */
1215 | attributes setattrs after_type_declarator
1216 { $$ = $3; }
1217 | TYPENAME
1220 /* Kinds of declarator that can appear in a parameter list
1221 in addition to notype_declarator. This is like after_type_declarator
1222 but does not allow a typedef name in parentheses as an identifier
1223 (because it would conflict with a function with that typedef as arg). */
1225 parm_declarator:
1226 parm_declarator '(' parmlist_or_identifiers %prec '.'
1227 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1228 /* | parm_declarator '(' error ')' %prec '.'
1229 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1230 poplevel (0, 0, 0); } */
1231 | parm_declarator '[' '*' ']' %prec '.'
1232 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE);
1233 if (! flag_isoc99)
1234 error ("`[*]' in parameter declaration only allowed in ISO C 99");
1236 | parm_declarator '[' expr ']' %prec '.'
1237 { $$ = build_nt (ARRAY_REF, $1, $3); }
1238 | parm_declarator '[' ']' %prec '.'
1239 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1240 | '*' type_quals parm_declarator %prec UNARY
1241 { $$ = make_pointer_declarator ($2, $3); }
1242 /* ??? Yuck. setattrs is a quick hack. We can't use
1243 prefix_attributes because $1 only applies to this
1244 declarator. We assume setspecs has already been done.
1245 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1246 attributes could be recognized here or in `attributes'). */
1247 | attributes setattrs parm_declarator
1248 { $$ = $3; }
1249 | TYPENAME
1252 /* A declarator allowed whether or not there has been
1253 an explicit typespec. These cannot redeclare a typedef-name. */
1255 notype_declarator:
1256 notype_declarator '(' parmlist_or_identifiers %prec '.'
1257 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1258 /* | notype_declarator '(' error ')' %prec '.'
1259 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1260 poplevel (0, 0, 0); } */
1261 | '(' notype_declarator ')'
1262 { $$ = $2; }
1263 | '*' type_quals notype_declarator %prec UNARY
1264 { $$ = make_pointer_declarator ($2, $3); }
1265 | notype_declarator '[' '*' ']' %prec '.'
1266 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE);
1267 if (! flag_isoc99)
1268 error ("`[*]' in parameter declaration only allowed in ISO C 99");
1270 | notype_declarator '[' expr ']' %prec '.'
1271 { $$ = build_nt (ARRAY_REF, $1, $3); }
1272 | notype_declarator '[' ']' %prec '.'
1273 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1274 /* ??? Yuck. setattrs is a quick hack. We can't use
1275 prefix_attributes because $1 only applies to this
1276 declarator. We assume setspecs has already been done.
1277 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1278 attributes could be recognized here or in `attributes'). */
1279 | attributes setattrs notype_declarator
1280 { $$ = $3; }
1281 | IDENTIFIER
1284 struct_head:
1285 STRUCT
1286 { $$ = NULL_TREE; }
1287 | STRUCT attributes
1288 { $$ = $2; }
1291 union_head:
1292 UNION
1293 { $$ = NULL_TREE; }
1294 | UNION attributes
1295 { $$ = $2; }
1298 enum_head:
1299 ENUM
1300 { $$ = NULL_TREE; }
1301 | ENUM attributes
1302 { $$ = $2; }
1305 structsp:
1306 struct_head identifier '{'
1307 { $$ = start_struct (RECORD_TYPE, $2);
1308 /* Start scope of tag before parsing components. */
1310 component_decl_list '}' maybe_attribute
1311 { $$ = finish_struct ($<ttype>4, $5, chainon ($1, $7)); }
1312 | struct_head '{' component_decl_list '}' maybe_attribute
1313 { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
1314 $3, chainon ($1, $5));
1316 | struct_head identifier
1317 { $$ = xref_tag (RECORD_TYPE, $2); }
1318 | union_head identifier '{'
1319 { $$ = start_struct (UNION_TYPE, $2); }
1320 component_decl_list '}' maybe_attribute
1321 { $$ = finish_struct ($<ttype>4, $5, chainon ($1, $7)); }
1322 | union_head '{' component_decl_list '}' maybe_attribute
1323 { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
1324 $3, chainon ($1, $5));
1326 | union_head identifier
1327 { $$ = xref_tag (UNION_TYPE, $2); }
1328 | enum_head identifier '{'
1329 { $$ = start_enum ($2); }
1330 enumlist maybecomma_warn '}' maybe_attribute
1331 { $$ = finish_enum ($<ttype>4, nreverse ($5),
1332 chainon ($1, $8)); }
1333 | enum_head '{'
1334 { $$ = start_enum (NULL_TREE); }
1335 enumlist maybecomma_warn '}' maybe_attribute
1336 { $$ = finish_enum ($<ttype>3, nreverse ($4),
1337 chainon ($1, $7)); }
1338 | enum_head identifier
1339 { $$ = xref_tag (ENUMERAL_TYPE, $2); }
1342 maybecomma:
1343 /* empty */
1344 | ','
1347 maybecomma_warn:
1348 /* empty */
1349 | ','
1350 { if (pedantic && ! flag_isoc99)
1351 pedwarn ("comma at end of enumerator list"); }
1354 component_decl_list:
1355 component_decl_list2
1356 { $$ = $1; }
1357 | component_decl_list2 component_decl
1358 { $$ = chainon ($1, $2);
1359 pedwarn ("no semicolon at end of struct or union"); }
1362 component_decl_list2: /* empty */
1363 { $$ = NULL_TREE; }
1364 | component_decl_list2 component_decl ';'
1365 { $$ = chainon ($1, $2); }
1366 | component_decl_list2 ';'
1367 { if (pedantic)
1368 pedwarn ("extra semicolon in struct or union specified"); }
1371 /* There is a shift-reduce conflict here, because `components' may
1372 start with a `typename'. It happens that shifting (the default resolution)
1373 does the right thing, because it treats the `typename' as part of
1374 a `typed_typespecs'.
1376 It is possible that this same technique would allow the distinction
1377 between `notype_initdecls' and `initdecls' to be eliminated.
1378 But I am being cautious and not trying it. */
1380 component_decl:
1381 typed_typespecs setspecs components
1382 { $$ = $3;
1383 current_declspecs = TREE_VALUE (declspec_stack);
1384 prefix_attributes = TREE_PURPOSE (declspec_stack);
1385 declspec_stack = TREE_CHAIN (declspec_stack); }
1386 | typed_typespecs setspecs save_filename save_lineno maybe_attribute
1388 /* Support for unnamed structs or unions as members of
1389 structs or unions (which is [a] useful and [b] supports
1390 MS P-SDK). */
1391 if (pedantic)
1392 pedwarn ("ANSI C doesn't support unnamed structs/unions");
1394 $$ = grokfield($3, $4, NULL, current_declspecs, NULL_TREE);
1395 current_declspecs = TREE_VALUE (declspec_stack);
1396 prefix_attributes = TREE_PURPOSE (declspec_stack);
1397 declspec_stack = TREE_CHAIN (declspec_stack);
1399 | nonempty_type_quals setspecs components
1400 { $$ = $3;
1401 current_declspecs = TREE_VALUE (declspec_stack);
1402 prefix_attributes = TREE_PURPOSE (declspec_stack);
1403 declspec_stack = TREE_CHAIN (declspec_stack); }
1404 | nonempty_type_quals
1405 { if (pedantic)
1406 pedwarn ("ANSI C forbids member declarations with no members");
1407 shadow_tag($1);
1408 $$ = NULL_TREE; }
1409 | error
1410 { $$ = NULL_TREE; }
1411 | extension component_decl
1412 { $$ = $2;
1413 RESTORE_WARN_FLAGS ($1); }
1416 components:
1417 component_declarator
1418 | components ',' component_declarator
1419 { $$ = chainon ($1, $3); }
1422 component_declarator:
1423 save_filename save_lineno declarator maybe_attribute
1424 { $$ = grokfield ($1, $2, $3, current_declspecs, NULL_TREE);
1425 decl_attributes ($$, $4, prefix_attributes); }
1426 | save_filename save_lineno
1427 declarator ':' expr_no_commas maybe_attribute
1428 { $$ = grokfield ($1, $2, $3, current_declspecs, $5);
1429 decl_attributes ($$, $6, prefix_attributes); }
1430 | save_filename save_lineno ':' expr_no_commas maybe_attribute
1431 { $$ = grokfield ($1, $2, NULL_TREE, current_declspecs, $4);
1432 decl_attributes ($$, $5, prefix_attributes); }
1435 /* We chain the enumerators in reverse order.
1436 They are put in forward order where enumlist is used.
1437 (The order used to be significant, but no longer is so.
1438 However, we still maintain the order, just to be clean.) */
1440 enumlist:
1441 enumerator
1442 | enumlist ',' enumerator
1443 { if ($1 == error_mark_node)
1444 $$ = $1;
1445 else
1446 $$ = chainon ($3, $1); }
1447 | error
1448 { $$ = error_mark_node; }
1452 enumerator:
1453 identifier
1454 { $$ = build_enumerator ($1, NULL_TREE); }
1455 | identifier '=' expr_no_commas
1456 { $$ = build_enumerator ($1, $3); }
1459 typename:
1460 typed_typespecs absdcl
1461 { $$ = build_tree_list ($1, $2); }
1462 | nonempty_type_quals absdcl
1463 { $$ = build_tree_list ($1, $2); }
1466 absdcl: /* an absolute declarator */
1467 /* empty */
1468 { $$ = NULL_TREE; }
1469 | absdcl1
1472 nonempty_type_quals:
1473 TYPE_QUAL
1474 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
1475 | nonempty_type_quals TYPE_QUAL
1476 { $$ = tree_cons (NULL_TREE, $2, $1); }
1479 type_quals:
1480 /* empty */
1481 { $$ = NULL_TREE; }
1482 | type_quals TYPE_QUAL
1483 { $$ = tree_cons (NULL_TREE, $2, $1); }
1486 absdcl1: /* a nonempty absolute declarator */
1487 '(' absdcl1 ')'
1488 { $$ = $2; }
1489 /* `(typedef)1' is `int'. */
1490 | '*' type_quals absdcl1 %prec UNARY
1491 { $$ = make_pointer_declarator ($2, $3); }
1492 | '*' type_quals %prec UNARY
1493 { $$ = make_pointer_declarator ($2, NULL_TREE); }
1494 | absdcl1 '(' parmlist %prec '.'
1495 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1496 | absdcl1 '[' expr ']' %prec '.'
1497 { $$ = build_nt (ARRAY_REF, $1, $3); }
1498 | absdcl1 '[' ']' %prec '.'
1499 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1500 | '(' parmlist %prec '.'
1501 { $$ = build_nt (CALL_EXPR, NULL_TREE, $2, NULL_TREE); }
1502 | '[' expr ']' %prec '.'
1503 { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
1504 | '[' ']' %prec '.'
1505 { $$ = build_nt (ARRAY_REF, NULL_TREE, NULL_TREE); }
1506 /* ??? It appears we have to support attributes here, however
1507 using prefix_attributes is wrong. */
1508 | attributes setattrs absdcl1
1509 { $$ = $3; }
1512 /* at least one statement, the first of which parses without error. */
1513 /* stmts is used only after decls, so an invalid first statement
1514 is actually regarded as an invalid decl and part of the decls. */
1516 stmts:
1517 lineno_stmt_or_labels
1519 if (pedantic && $1)
1520 pedwarn ("ANSI C forbids label at end of compound statement");
1524 lineno_stmt_or_labels:
1525 lineno_stmt_or_label
1526 | lineno_stmt_or_labels lineno_stmt_or_label
1527 { $$ = $2; }
1528 | lineno_stmt_or_labels errstmt
1529 { $$ = 0; }
1532 xstmts:
1533 /* empty */
1534 | stmts
1537 errstmt: error ';'
1540 pushlevel: /* empty */
1541 { emit_line_note (input_filename, lineno);
1542 pushlevel (0);
1543 clear_last_expr ();
1544 expand_start_bindings (0);
1548 /* Read zero or more forward-declarations for labels
1549 that nested functions can jump to. */
1550 maybe_label_decls:
1551 /* empty */
1552 | label_decls
1553 { if (pedantic)
1554 pedwarn ("ANSI C forbids label declarations"); }
1557 label_decls:
1558 label_decl
1559 | label_decls label_decl
1562 label_decl:
1563 LABEL identifiers_or_typenames ';'
1564 { tree link;
1565 for (link = $2; link; link = TREE_CHAIN (link))
1567 tree label = shadow_label (TREE_VALUE (link));
1568 C_DECLARED_LABEL_FLAG (label) = 1;
1569 declare_nonlocal_label (label);
1574 /* This is the body of a function definition.
1575 It causes syntax errors to ignore to the next openbrace. */
1576 compstmt_or_error:
1577 compstmt
1579 | error compstmt
1582 compstmt_start: '{' { compstmt_count++; }
1584 compstmt_nostart: '}'
1585 { $$ = convert (void_type_node, integer_zero_node); }
1586 | pushlevel maybe_label_decls decls xstmts '}'
1587 { emit_line_note (input_filename, lineno);
1588 expand_end_bindings (getdecls (), 1, 0);
1589 $$ = poplevel (1, 1, 0); }
1590 | pushlevel maybe_label_decls error '}'
1591 { emit_line_note (input_filename, lineno);
1592 expand_end_bindings (getdecls (), kept_level_p (), 0);
1593 $$ = poplevel (kept_level_p (), 0, 0); }
1594 | pushlevel maybe_label_decls stmts '}'
1595 { emit_line_note (input_filename, lineno);
1596 expand_end_bindings (getdecls (), kept_level_p (), 0);
1597 $$ = poplevel (kept_level_p (), 0, 0); }
1600 compstmt_primary_start:
1601 '(' '{'
1602 { if (current_function_decl == 0)
1604 error ("braced-group within expression allowed only inside a function");
1605 YYERROR;
1607 /* We must force a BLOCK for this level
1608 so that, if it is not expanded later,
1609 there is a way to turn off the entire subtree of blocks
1610 that are contained in it. */
1611 keep_next_level ();
1612 push_iterator_stack ();
1613 push_label_level ();
1614 $$ = expand_start_stmt_expr ();
1615 compstmt_count++;
1618 compstmt: compstmt_start compstmt_nostart
1619 { $$ = $2; }
1622 /* Value is number of statements counted as of the closeparen. */
1623 simple_if:
1624 if_prefix lineno_labeled_stmt
1625 /* Make sure c_expand_end_cond is run once
1626 for each call to c_expand_start_cond.
1627 Otherwise a crash is likely. */
1628 | if_prefix error
1631 if_prefix:
1632 IF '(' expr ')'
1633 { emit_line_note ($<filename>-1, $<lineno>0);
1634 c_expand_start_cond (truthvalue_conversion ($3), 0,
1635 compstmt_count);
1636 $<itype>$ = stmt_count;
1637 if_stmt_file = $<filename>-1;
1638 if_stmt_line = $<lineno>0;
1639 position_after_white_space (); }
1642 /* This is a subroutine of stmt.
1643 It is used twice, once for valid DO statements
1644 and once for catching errors in parsing the end test. */
1645 do_stmt_start:
1647 { stmt_count++;
1648 compstmt_count++;
1649 emit_line_note ($<filename>-1, $<lineno>0);
1650 /* See comment in `while' alternative, above. */
1651 emit_nop ();
1652 expand_start_loop_continue_elsewhere (1);
1653 position_after_white_space (); }
1654 lineno_labeled_stmt WHILE
1655 { expand_loop_continue_here (); }
1658 save_filename:
1659 { $$ = input_filename; }
1662 save_lineno:
1663 { $$ = lineno; }
1666 lineno_labeled_stmt:
1667 save_filename save_lineno stmt
1669 /* | save_filename save_lineno error
1672 | save_filename save_lineno label lineno_labeled_stmt
1676 lineno_stmt_or_label:
1677 save_filename save_lineno stmt_or_label
1678 { $$ = $3; }
1681 stmt_or_label:
1682 stmt
1683 { $$ = 0; }
1684 | label
1685 { $$ = 1; }
1688 /* Parse a single real statement, not including any labels. */
1689 stmt:
1690 compstmt
1691 { stmt_count++; }
1692 | all_iter_stmt
1693 | expr ';'
1694 { stmt_count++;
1695 emit_line_note ($<filename>-1, $<lineno>0);
1696 /* It appears that this should not be done--that a non-lvalue array
1697 shouldn't get an error if the value isn't used.
1698 Section 3.2.2.1 says that an array lvalue gets converted to a pointer
1699 if it appears as a top-level expression,
1700 but says nothing about non-lvalue arrays. */
1701 #if 0
1702 /* Call default_conversion to get an error
1703 on referring to a register array if pedantic. */
1704 if (TREE_CODE (TREE_TYPE ($1)) == ARRAY_TYPE
1705 || TREE_CODE (TREE_TYPE ($1)) == FUNCTION_TYPE)
1706 $1 = default_conversion ($1);
1707 #endif
1708 iterator_expand ($1); }
1709 | simple_if ELSE
1710 { c_expand_start_else ();
1711 $<itype>1 = stmt_count;
1712 position_after_white_space (); }
1713 lineno_labeled_stmt
1714 { c_expand_end_cond ();
1715 if (extra_warnings && stmt_count == $<itype>1)
1716 warning ("empty body in an else-statement"); }
1717 | simple_if %prec IF
1718 { c_expand_end_cond ();
1719 /* This warning is here instead of in simple_if, because we
1720 do not want a warning if an empty if is followed by an
1721 else statement. Increment stmt_count so we don't
1722 give a second error if this is a nested `if'. */
1723 if (extra_warnings && stmt_count++ == $<itype>1)
1724 warning_with_file_and_line (if_stmt_file, if_stmt_line,
1725 "empty body in an if-statement"); }
1726 /* Make sure c_expand_end_cond is run once
1727 for each call to c_expand_start_cond.
1728 Otherwise a crash is likely. */
1729 | simple_if ELSE error
1730 { c_expand_end_cond (); }
1731 | WHILE
1732 { stmt_count++;
1733 emit_line_note ($<filename>-1, $<lineno>0);
1734 /* The emit_nop used to come before emit_line_note,
1735 but that made the nop seem like part of the preceding line.
1736 And that was confusing when the preceding line was
1737 inside of an if statement and was not really executed.
1738 I think it ought to work to put the nop after the line number.
1739 We will see. --rms, July 15, 1991. */
1740 emit_nop (); }
1741 '(' expr ')'
1742 { /* Don't start the loop till we have succeeded
1743 in parsing the end test. This is to make sure
1744 that we end every loop we start. */
1745 expand_start_loop (1);
1746 emit_line_note (input_filename, lineno);
1747 expand_exit_loop_if_false (NULL_PTR,
1748 truthvalue_conversion ($4));
1749 position_after_white_space (); }
1750 lineno_labeled_stmt
1751 { expand_end_loop (); }
1752 | do_stmt_start
1753 '(' expr ')' ';'
1754 { emit_line_note (input_filename, lineno);
1755 expand_exit_loop_if_false (NULL_PTR,
1756 truthvalue_conversion ($3));
1757 expand_end_loop (); }
1758 /* This rule is needed to make sure we end every loop we start. */
1759 | do_stmt_start error
1760 { expand_end_loop (); }
1761 | FOR
1762 '(' xexpr ';'
1763 { stmt_count++;
1764 emit_line_note ($<filename>-1, $<lineno>0);
1765 /* See comment in `while' alternative, above. */
1766 emit_nop ();
1767 if ($3) c_expand_expr_stmt ($3);
1768 /* Next step is to call expand_start_loop_continue_elsewhere,
1769 but wait till after we parse the entire for (...).
1770 Otherwise, invalid input might cause us to call that
1771 fn without calling expand_end_loop. */
1773 xexpr ';'
1774 /* Can't emit now; wait till after expand_start_loop... */
1775 { $<lineno>7 = lineno;
1776 $<filename>$ = input_filename; }
1777 xexpr ')'
1779 /* Start the loop. Doing this after parsing
1780 all the expressions ensures we will end the loop. */
1781 expand_start_loop_continue_elsewhere (1);
1782 /* Emit the end-test, with a line number. */
1783 emit_line_note ($<filename>8, $<lineno>7);
1784 if ($6)
1785 expand_exit_loop_if_false (NULL_PTR,
1786 truthvalue_conversion ($6));
1787 $<lineno>7 = lineno;
1788 $<filename>8 = input_filename;
1789 position_after_white_space (); }
1790 lineno_labeled_stmt
1791 { /* Emit the increment expression, with a line number. */
1792 emit_line_note ($<filename>8, $<lineno>7);
1793 expand_loop_continue_here ();
1794 if ($9)
1795 c_expand_expr_stmt ($9);
1796 expand_end_loop (); }
1797 | SWITCH '(' expr ')'
1798 { stmt_count++;
1799 emit_line_note ($<filename>-1, $<lineno>0);
1800 c_expand_start_case ($3);
1801 position_after_white_space (); }
1802 lineno_labeled_stmt
1803 { expand_end_case ($3); }
1804 | BREAK ';'
1805 { stmt_count++;
1806 emit_line_note ($<filename>-1, $<lineno>0);
1807 if ( ! expand_exit_something ())
1808 error ("break statement not within loop or switch"); }
1809 | CONTINUE ';'
1810 { stmt_count++;
1811 emit_line_note ($<filename>-1, $<lineno>0);
1812 if (! expand_continue_loop (NULL_PTR))
1813 error ("continue statement not within a loop"); }
1814 | RETURN ';'
1815 { stmt_count++;
1816 emit_line_note ($<filename>-1, $<lineno>0);
1817 c_expand_return (NULL_TREE); }
1818 | RETURN expr ';'
1819 { stmt_count++;
1820 emit_line_note ($<filename>-1, $<lineno>0);
1821 c_expand_return ($2); }
1822 | ASM_KEYWORD maybe_type_qual '(' expr ')' ';'
1823 { stmt_count++;
1824 emit_line_note ($<filename>-1, $<lineno>0);
1825 STRIP_NOPS ($4);
1826 if ((TREE_CODE ($4) == ADDR_EXPR
1827 && TREE_CODE (TREE_OPERAND ($4, 0)) == STRING_CST)
1828 || TREE_CODE ($4) == STRING_CST)
1829 expand_asm ($4);
1830 else
1831 error ("argument of `asm' is not a constant string"); }
1832 /* This is the case with just output operands. */
1833 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ')' ';'
1834 { stmt_count++;
1835 emit_line_note ($<filename>-1, $<lineno>0);
1836 c_expand_asm_operands ($4, $6, NULL_TREE, NULL_TREE,
1837 $2 == ridpointers[(int)RID_VOLATILE],
1838 input_filename, lineno); }
1839 /* This is the case with input operands as well. */
1840 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':' asm_operands ')' ';'
1841 { stmt_count++;
1842 emit_line_note ($<filename>-1, $<lineno>0);
1843 c_expand_asm_operands ($4, $6, $8, NULL_TREE,
1844 $2 == ridpointers[(int)RID_VOLATILE],
1845 input_filename, lineno); }
1846 /* This is the case with clobbered registers as well. */
1847 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':'
1848 asm_operands ':' asm_clobbers ')' ';'
1849 { stmt_count++;
1850 emit_line_note ($<filename>-1, $<lineno>0);
1851 c_expand_asm_operands ($4, $6, $8, $10,
1852 $2 == ridpointers[(int)RID_VOLATILE],
1853 input_filename, lineno); }
1854 | GOTO identifier ';'
1855 { tree decl;
1856 stmt_count++;
1857 emit_line_note ($<filename>-1, $<lineno>0);
1858 decl = lookup_label ($2);
1859 if (decl != 0)
1861 TREE_USED (decl) = 1;
1862 expand_goto (decl);
1865 | GOTO '*' expr ';'
1866 { if (pedantic)
1867 pedwarn ("ANSI C forbids `goto *expr;'");
1868 stmt_count++;
1869 emit_line_note ($<filename>-1, $<lineno>0);
1870 expand_computed_goto (convert (ptr_type_node, $3)); }
1871 | ';'
1874 all_iter_stmt:
1875 all_iter_stmt_simple
1876 /* | all_iter_stmt_with_decl */
1879 all_iter_stmt_simple:
1880 FOR '(' primary ')'
1882 /* The value returned by this action is */
1883 /* 1 if everything is OK */
1884 /* 0 in case of error or already bound iterator */
1886 $<itype>$ = 0;
1887 if (TREE_CODE ($3) != VAR_DECL)
1888 error ("invalid `for (ITERATOR)' syntax");
1889 else if (! ITERATOR_P ($3))
1890 error ("`%s' is not an iterator",
1891 IDENTIFIER_POINTER (DECL_NAME ($3)));
1892 else if (ITERATOR_BOUND_P ($3))
1893 error ("`for (%s)' inside expansion of same iterator",
1894 IDENTIFIER_POINTER (DECL_NAME ($3)));
1895 else
1897 $<itype>$ = 1;
1898 iterator_for_loop_start ($3);
1901 lineno_labeled_stmt
1903 if ($<itype>5)
1904 iterator_for_loop_end ($3);
1907 /* This really should allow any kind of declaration,
1908 for generality. Fix it before turning it back on.
1910 all_iter_stmt_with_decl:
1911 FOR '(' ITERATOR pushlevel setspecs iterator_spec ')'
1913 */ /* The value returned by this action is */
1914 /* 1 if everything is OK */
1915 /* 0 in case of error or already bound iterator */
1917 iterator_for_loop_start ($6);
1919 lineno_labeled_stmt
1921 iterator_for_loop_end ($6);
1922 emit_line_note (input_filename, lineno);
1923 expand_end_bindings (getdecls (), 1, 0);
1924 $<ttype>$ = poplevel (1, 1, 0);
1928 /* Any kind of label, including jump labels and case labels.
1929 ANSI C accepts labels only before statements, but we allow them
1930 also at the end of a compound statement. */
1932 label: CASE expr_no_commas ':'
1933 { register tree value = check_case_value ($2);
1934 register tree label
1935 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
1937 stmt_count++;
1939 if (value != error_mark_node)
1941 tree duplicate;
1942 int success;
1944 if (pedantic && ! INTEGRAL_TYPE_P (TREE_TYPE (value)))
1945 pedwarn ("label must have integral type in ANSI C");
1947 success = pushcase (value, convert_and_check,
1948 label, &duplicate);
1950 if (success == 1)
1951 error ("case label not within a switch statement");
1952 else if (success == 2)
1954 error ("duplicate case value");
1955 error_with_decl (duplicate, "this is the first entry for that value");
1957 else if (success == 3)
1958 warning ("case value out of range");
1959 else if (success == 5)
1960 error ("case label within scope of cleanup or variable array");
1962 position_after_white_space (); }
1963 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
1964 { register tree value1 = check_case_value ($2);
1965 register tree value2 = check_case_value ($4);
1966 register tree label
1967 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
1969 if (pedantic)
1970 pedwarn ("ANSI C forbids case ranges");
1971 stmt_count++;
1973 if (value1 != error_mark_node && value2 != error_mark_node)
1975 tree duplicate;
1976 int success = pushcase_range (value1, value2,
1977 convert_and_check, label,
1978 &duplicate);
1979 if (success == 1)
1980 error ("case label not within a switch statement");
1981 else if (success == 2)
1983 error ("duplicate case value");
1984 error_with_decl (duplicate, "this is the first entry for that value");
1986 else if (success == 3)
1987 warning ("case value out of range");
1988 else if (success == 4)
1989 warning ("empty case range");
1990 else if (success == 5)
1991 error ("case label within scope of cleanup or variable array");
1993 position_after_white_space (); }
1994 | DEFAULT ':'
1996 tree duplicate;
1997 register tree label
1998 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
1999 int success = pushcase (NULL_TREE, 0, label, &duplicate);
2000 stmt_count++;
2001 if (success == 1)
2002 error ("default label not within a switch statement");
2003 else if (success == 2)
2005 error ("multiple default labels in one switch");
2006 error_with_decl (duplicate, "this is the first default label");
2008 position_after_white_space (); }
2009 | identifier ':' maybe_attribute
2010 { tree label = define_label (input_filename, lineno, $1);
2011 stmt_count++;
2012 emit_nop ();
2013 if (label)
2015 expand_label (label);
2016 decl_attributes (label, $3, NULL_TREE);
2018 position_after_white_space (); }
2021 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
2023 maybe_type_qual:
2024 /* empty */
2025 { emit_line_note (input_filename, lineno);
2026 $$ = NULL_TREE; }
2027 | TYPE_QUAL
2028 { emit_line_note (input_filename, lineno); }
2031 xexpr:
2032 /* empty */
2033 { $$ = NULL_TREE; }
2034 | expr
2037 /* These are the operands other than the first string and colon
2038 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
2039 asm_operands: /* empty */
2040 { $$ = NULL_TREE; }
2041 | nonnull_asm_operands
2044 nonnull_asm_operands:
2045 asm_operand
2046 | nonnull_asm_operands ',' asm_operand
2047 { $$ = chainon ($1, $3); }
2050 asm_operand:
2051 STRING '(' expr ')'
2052 { $$ = build_tree_list ($1, $3); }
2055 asm_clobbers:
2056 string
2057 { $$ = tree_cons (NULL_TREE, combine_strings ($1), NULL_TREE); }
2058 | asm_clobbers ',' string
2059 { $$ = tree_cons (NULL_TREE, combine_strings ($3), $1); }
2062 /* This is what appears inside the parens in a function declarator.
2063 Its value is a list of ..._TYPE nodes. */
2064 parmlist:
2065 { pushlevel (0);
2066 clear_parm_order ();
2067 declare_parm_level (0); }
2068 parmlist_1
2069 { $$ = $2;
2070 parmlist_tags_warning ();
2071 poplevel (0, 0, 0); }
2074 parmlist_1:
2075 parmlist_2 ')'
2076 | parms ';'
2077 { tree parm;
2078 if (pedantic)
2079 pedwarn ("ANSI C forbids forward parameter declarations");
2080 /* Mark the forward decls as such. */
2081 for (parm = getdecls (); parm; parm = TREE_CHAIN (parm))
2082 TREE_ASM_WRITTEN (parm) = 1;
2083 clear_parm_order (); }
2084 parmlist_1
2085 { $$ = $4; }
2086 | error ')'
2087 { $$ = tree_cons (NULL_TREE, NULL_TREE, NULL_TREE); }
2090 /* This is what appears inside the parens in a function declarator.
2091 Is value is represented in the format that grokdeclarator expects. */
2092 parmlist_2: /* empty */
2093 { $$ = get_parm_info (0); }
2094 | ELLIPSIS
2095 { $$ = get_parm_info (0);
2096 /* Gcc used to allow this as an extension. However, it does
2097 not work for all targets, and thus has been disabled.
2098 Also, since func (...) and func () are indistinguishable,
2099 it caused problems with the code in expand_builtin which
2100 tries to verify that BUILT_IN_NEXT_ARG is being used
2101 correctly. */
2102 error ("ANSI C requires a named argument before `...'");
2104 | parms
2105 { $$ = get_parm_info (1); }
2106 | parms ',' ELLIPSIS
2107 { $$ = get_parm_info (0); }
2110 parms:
2111 parm
2112 { push_parm_decl ($1); }
2113 | parms ',' parm
2114 { push_parm_decl ($3); }
2117 /* A single parameter declaration or parameter type name,
2118 as found in a parmlist. */
2119 parm:
2120 typed_declspecs setspecs parm_declarator maybe_attribute
2121 { $$ = build_tree_list (build_tree_list (current_declspecs,
2122 $3),
2123 build_tree_list (prefix_attributes,
2124 $4));
2125 current_declspecs = TREE_VALUE (declspec_stack);
2126 prefix_attributes = TREE_PURPOSE (declspec_stack);
2127 declspec_stack = TREE_CHAIN (declspec_stack); }
2128 | typed_declspecs setspecs notype_declarator maybe_attribute
2129 { $$ = build_tree_list (build_tree_list (current_declspecs,
2130 $3),
2131 build_tree_list (prefix_attributes,
2132 $4));
2133 current_declspecs = TREE_VALUE (declspec_stack);
2134 prefix_attributes = TREE_PURPOSE (declspec_stack);
2135 declspec_stack = TREE_CHAIN (declspec_stack); }
2136 | typed_declspecs setspecs absdcl maybe_attribute
2137 { $$ = build_tree_list (build_tree_list (current_declspecs,
2138 $3),
2139 build_tree_list (prefix_attributes,
2140 $4));
2141 current_declspecs = TREE_VALUE (declspec_stack);
2142 prefix_attributes = TREE_PURPOSE (declspec_stack);
2143 declspec_stack = TREE_CHAIN (declspec_stack); }
2144 | declmods setspecs notype_declarator maybe_attribute
2145 { $$ = build_tree_list (build_tree_list (current_declspecs,
2146 $3),
2147 build_tree_list (prefix_attributes,
2148 $4));
2149 current_declspecs = TREE_VALUE (declspec_stack);
2150 prefix_attributes = TREE_PURPOSE (declspec_stack);
2151 declspec_stack = TREE_CHAIN (declspec_stack); }
2153 | declmods setspecs absdcl maybe_attribute
2154 { $$ = build_tree_list (build_tree_list (current_declspecs,
2155 $3),
2156 build_tree_list (prefix_attributes,
2157 $4));
2158 current_declspecs = TREE_VALUE (declspec_stack);
2159 prefix_attributes = TREE_PURPOSE (declspec_stack);
2160 declspec_stack = TREE_CHAIN (declspec_stack); }
2163 /* This is used in a function definition
2164 where either a parmlist or an identifier list is ok.
2165 Its value is a list of ..._TYPE nodes or a list of identifiers. */
2166 parmlist_or_identifiers:
2167 { pushlevel (0);
2168 clear_parm_order ();
2169 declare_parm_level (1); }
2170 parmlist_or_identifiers_1
2171 { $$ = $2;
2172 parmlist_tags_warning ();
2173 poplevel (0, 0, 0); }
2176 parmlist_or_identifiers_1:
2177 parmlist_1
2178 | identifiers ')'
2179 { tree t;
2180 for (t = $1; t; t = TREE_CHAIN (t))
2181 if (TREE_VALUE (t) == NULL_TREE)
2182 error ("`...' in old-style identifier list");
2183 $$ = tree_cons (NULL_TREE, NULL_TREE, $1); }
2186 /* A nonempty list of identifiers. */
2187 identifiers:
2188 IDENTIFIER
2189 { $$ = build_tree_list (NULL_TREE, $1); }
2190 | identifiers ',' IDENTIFIER
2191 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2194 /* A nonempty list of identifiers, including typenames. */
2195 identifiers_or_typenames:
2196 identifier
2197 { $$ = build_tree_list (NULL_TREE, $1); }
2198 | identifiers_or_typenames ',' identifier
2199 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2202 extension:
2203 EXTENSION
2204 { $$ = SAVE_WARN_FLAGS();
2205 pedantic = 0;
2206 warn_pointer_arith = 0; }