oops - omitted from previous delta fixing UNIQUE_SECTION
[official-gcc.git] / gcc / c-parse.y
blob33dd371d74a728155cb2509756d17959346680a6
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-99, 2000 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 53
34 #include "config.h"
35 #include "system.h"
36 #include <setjmp.h>
37 #include "tree.h"
38 #include "input.h"
39 #include "c-lex.h"
40 #include "c-tree.h"
41 #include "flags.h"
42 #include "output.h"
43 #include "toplev.h"
44 #include "ggc.h"
46 #ifdef MULTIBYTE_CHARS
47 #include <locale.h>
48 #endif
51 /* Since parsers are distinct for each language, put the language string
52 definition here. */
53 const char * const language_string = "GNU C";
55 /* Like YYERROR but do call yyerror. */
56 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
58 /* Cause the `yydebug' variable to be defined. */
59 #define YYDEBUG 1
62 %start program
64 %union {long itype; tree ttype; enum tree_code code;
65 char *filename; int lineno; int ends_in_label; }
67 /* All identifiers that are not reserved words
68 and are not declared typedefs in the current block */
69 %token IDENTIFIER
71 /* All identifiers that are declared typedefs in the current block.
72 In some contexts, they are treated just like IDENTIFIER,
73 but they can also serve as typespecs in declarations. */
74 %token TYPENAME
76 /* Reserved words that specify storage class.
77 yylval contains an IDENTIFIER_NODE which indicates which one. */
78 %token SCSPEC
80 /* Reserved words that specify type.
81 yylval contains an IDENTIFIER_NODE which indicates which one. */
82 %token TYPESPEC
84 /* Reserved words that qualify type: "const", "volatile", or "restrict".
85 yylval contains an IDENTIFIER_NODE which indicates which one. */
86 %token TYPE_QUAL
88 /* Character or numeric constants.
89 yylval is the node for the constant. */
90 %token CONSTANT
92 /* String constants in raw form.
93 yylval is a STRING_CST node. */
94 %token STRING
96 /* "...", used for functions with variable arglists. */
97 %token ELLIPSIS
99 /* the reserved words */
100 /* SCO include files test "ASM", so use something else. */
101 %token SIZEOF ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
102 %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD TYPEOF ALIGNOF
103 %token ATTRIBUTE EXTENSION LABEL
104 %token REALPART IMAGPART VA_ARG
106 /* Used in c-lex.c for parsing pragmas. */
107 %token END_OF_LINE
109 /* Add precedence rules to solve dangling else s/r conflict */
110 %nonassoc IF
111 %nonassoc ELSE
113 /* Define the operator tokens and their precedences.
114 The value is an integer because, if used, it is the tree code
115 to use in the expression made from the operator. */
117 %right <code> ASSIGN '='
118 %right <code> '?' ':'
119 %left <code> OROR
120 %left <code> ANDAND
121 %left <code> '|'
122 %left <code> '^'
123 %left <code> '&'
124 %left <code> EQCOMPARE
125 %left <code> ARITHCOMPARE
126 %left <code> LSHIFT RSHIFT
127 %left <code> '+' '-'
128 %left <code> '*' '/' '%'
129 %right <code> UNARY PLUSPLUS MINUSMINUS
130 %left HYPERUNARY
131 %left <code> POINTSAT '.' '(' '['
133 /* The Objective-C keywords. These are included in C and in
134 Objective C, so that the token codes are the same in both. */
135 %token INTERFACE IMPLEMENTATION END SELECTOR DEFS ENCODE
136 %token CLASSNAME PUBLIC PRIVATE PROTECTED PROTOCOL OBJECTNAME CLASS ALIAS
138 /* Objective-C string constants in raw form.
139 yylval is an OBJC_STRING_CST node. */
140 %token OBJC_STRING
143 %type <code> unop
145 %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist exprlist
146 %type <ttype> expr_no_commas cast_expr unary_expr primary string STRING
147 %type <ttype> typed_declspecs reserved_declspecs
148 %type <ttype> typed_typespecs reserved_typespecquals
149 %type <ttype> declmods typespec typespecqual_reserved
150 %type <ttype> typed_declspecs_no_prefix_attr reserved_declspecs_no_prefix_attr
151 %type <ttype> declmods_no_prefix_attr
152 %type <ttype> SCSPEC TYPESPEC TYPE_QUAL nonempty_type_quals maybe_type_qual
153 %type <ttype> initdecls notype_initdecls initdcl notype_initdcl
154 %type <ttype> init maybeasm
155 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
156 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
157 %type <ttype> any_word extension
159 %type <ttype> compstmt compstmt_nostart compstmt_primary_start
161 %type <ttype> declarator
162 %type <ttype> notype_declarator after_type_declarator
163 %type <ttype> parm_declarator
165 %type <ttype> structsp component_decl_list component_decl_list2
166 %type <ttype> component_decl components component_declarator
167 %type <ttype> enumlist enumerator
168 %type <ttype> struct_head union_head enum_head
169 %type <ttype> typename absdcl absdcl1 type_quals
170 %type <ttype> xexpr parms parm identifiers
172 %type <ttype> parmlist parmlist_1 parmlist_2
173 %type <ttype> parmlist_or_identifiers parmlist_or_identifiers_1
174 %type <ttype> identifiers_or_typenames
176 %type <itype> setspecs
178 %type <ends_in_label> lineno_stmt_or_label lineno_stmt_or_labels stmt_or_label
180 %type <filename> save_filename
181 %type <lineno> save_lineno
185 /* Number of statements (loosely speaking) and compound statements
186 seen so far. */
187 static int stmt_count;
188 static int compstmt_count;
190 /* Input file and line number of the end of the body of last simple_if;
191 used by the stmt-rule immediately after simple_if returns. */
192 static char *if_stmt_file;
193 static int if_stmt_line;
195 /* List of types and structure classes of the current declaration. */
196 static tree current_declspecs = NULL_TREE;
197 static tree prefix_attributes = NULL_TREE;
199 /* Stack of saved values of current_declspecs and prefix_attributes. */
200 static tree declspec_stack;
202 /* 1 if we explained undeclared var errors. */
203 static int undeclared_variable_notice;
205 /* For __extension__, save/restore the warning flags which are
206 controlled by __extension__. */
207 #define SAVE_WARN_FLAGS() \
208 build_int_2 (pedantic | (warn_pointer_arith << 1), 0)
209 #define RESTORE_WARN_FLAGS(tval) \
210 do { \
211 int val = TREE_INT_CST_LOW (tval); \
212 pedantic = val & 1; \
213 warn_pointer_arith = (val >> 1) & 1; \
214 } while (0)
217 /* Tell yyparse how to print a token's value, if yydebug is set. */
219 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
220 extern void yyprint PARAMS ((FILE *, int, YYSTYPE));
222 /* Add GC roots for variables local to this file. */
223 void
224 c_parse_init ()
226 ggc_add_tree_root (&declspec_stack, 1);
227 ggc_add_tree_root (&current_declspecs, 1);
228 ggc_add_tree_root (&prefix_attributes, 1);
234 program: /* empty */
235 { if (pedantic)
236 pedwarn ("ANSI C forbids an empty source file");
237 finish_file ();
239 | extdefs
241 /* In case there were missing closebraces,
242 get us back to the global binding level. */
243 while (! global_bindings_p ())
244 poplevel (0, 0, 0);
245 finish_file ();
249 /* the reason for the strange actions in this rule
250 is so that notype_initdecls when reached via datadef
251 can find a valid list of type and sc specs in $0. */
253 extdefs:
254 {$<ttype>$ = NULL_TREE; } extdef
255 | extdefs {$<ttype>$ = NULL_TREE; } extdef
258 extdef:
259 fndef
260 | datadef
261 | ASM_KEYWORD '(' expr ')' ';'
262 { STRIP_NOPS ($3);
263 if ((TREE_CODE ($3) == ADDR_EXPR
264 && TREE_CODE (TREE_OPERAND ($3, 0)) == STRING_CST)
265 || TREE_CODE ($3) == STRING_CST)
266 assemble_asm ($3);
267 else
268 error ("argument of `asm' is not a constant string"); }
269 | extension extdef
270 { RESTORE_WARN_FLAGS ($1); }
273 datadef:
274 setspecs notype_initdecls ';'
275 { if (pedantic)
276 error ("ANSI C forbids data definition with no type or storage class");
277 else if (!flag_traditional)
278 warning ("data definition has no type or storage class");
280 current_declspecs = TREE_VALUE (declspec_stack);
281 prefix_attributes = TREE_PURPOSE (declspec_stack);
282 declspec_stack = TREE_CHAIN (declspec_stack); }
283 | declmods setspecs notype_initdecls ';'
284 { current_declspecs = TREE_VALUE (declspec_stack);
285 prefix_attributes = TREE_PURPOSE (declspec_stack);
286 declspec_stack = TREE_CHAIN (declspec_stack); }
287 | 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 | declmods ';'
292 { pedwarn ("empty declaration"); }
293 | typed_declspecs ';'
294 { shadow_tag ($1); }
295 | error ';'
296 | error '}'
297 | ';'
298 { if (pedantic)
299 pedwarn ("ANSI C does not allow extra `;' outside of a function"); }
302 fndef:
303 typed_declspecs setspecs declarator
304 { if (! start_function (current_declspecs, $3,
305 prefix_attributes, NULL_TREE))
306 YYERROR1;
307 reinit_parse_for_function (); }
308 old_style_parm_decls
309 { store_parm_decls (); }
310 compstmt_or_error
311 { finish_function (0);
312 current_declspecs = TREE_VALUE (declspec_stack);
313 prefix_attributes = TREE_PURPOSE (declspec_stack);
314 declspec_stack = TREE_CHAIN (declspec_stack); }
315 | typed_declspecs setspecs declarator error
316 { current_declspecs = TREE_VALUE (declspec_stack);
317 prefix_attributes = TREE_PURPOSE (declspec_stack);
318 declspec_stack = TREE_CHAIN (declspec_stack); }
319 | declmods setspecs notype_declarator
320 { if (! start_function (current_declspecs, $3,
321 prefix_attributes, NULL_TREE))
322 YYERROR1;
323 reinit_parse_for_function (); }
324 old_style_parm_decls
325 { store_parm_decls (); }
326 compstmt_or_error
327 { finish_function (0);
328 current_declspecs = TREE_VALUE (declspec_stack);
329 prefix_attributes = TREE_PURPOSE (declspec_stack);
330 declspec_stack = TREE_CHAIN (declspec_stack); }
331 | declmods setspecs notype_declarator error
332 { current_declspecs = TREE_VALUE (declspec_stack);
333 prefix_attributes = TREE_PURPOSE (declspec_stack);
334 declspec_stack = TREE_CHAIN (declspec_stack); }
335 | setspecs notype_declarator
336 { if (! start_function (NULL_TREE, $2,
337 prefix_attributes, NULL_TREE))
338 YYERROR1;
339 reinit_parse_for_function (); }
340 old_style_parm_decls
341 { store_parm_decls (); }
342 compstmt_or_error
343 { finish_function (0);
344 current_declspecs = TREE_VALUE (declspec_stack);
345 prefix_attributes = TREE_PURPOSE (declspec_stack);
346 declspec_stack = TREE_CHAIN (declspec_stack); }
347 | setspecs notype_declarator error
348 { current_declspecs = TREE_VALUE (declspec_stack);
349 prefix_attributes = TREE_PURPOSE (declspec_stack);
350 declspec_stack = TREE_CHAIN (declspec_stack); }
353 identifier:
354 IDENTIFIER
355 | TYPENAME
358 unop: '&'
359 { $$ = ADDR_EXPR; }
360 | '-'
361 { $$ = NEGATE_EXPR; }
362 | '+'
363 { $$ = CONVERT_EXPR; }
364 | PLUSPLUS
365 { $$ = PREINCREMENT_EXPR; }
366 | MINUSMINUS
367 { $$ = PREDECREMENT_EXPR; }
368 | '~'
369 { $$ = BIT_NOT_EXPR; }
370 | '!'
371 { $$ = TRUTH_NOT_EXPR; }
374 expr: nonnull_exprlist
375 { $$ = build_compound_expr ($1); }
378 exprlist:
379 /* empty */
380 { $$ = NULL_TREE; }
381 | nonnull_exprlist
384 nonnull_exprlist:
385 expr_no_commas
386 { $$ = build_tree_list (NULL_TREE, $1); }
387 | nonnull_exprlist ',' expr_no_commas
388 { chainon ($1, build_tree_list (NULL_TREE, $3)); }
391 unary_expr:
392 primary
393 | '*' cast_expr %prec UNARY
394 { $$ = build_indirect_ref ($2, "unary *"); }
395 /* __extension__ turns off -pedantic for following primary. */
396 | extension cast_expr %prec UNARY
397 { $$ = $2;
398 RESTORE_WARN_FLAGS ($1); }
399 | unop cast_expr %prec UNARY
400 { $$ = build_unary_op ($1, $2, 0);
401 overflow_warning ($$); }
402 /* Refer to the address of a label as a pointer. */
403 | ANDAND identifier
404 { tree label = lookup_label ($2);
405 if (pedantic)
406 pedwarn ("ANSI C forbids `&&'");
407 if (label == 0)
408 $$ = null_pointer_node;
409 else
411 TREE_USED (label) = 1;
412 $$ = build1 (ADDR_EXPR, ptr_type_node, label);
413 TREE_CONSTANT ($$) = 1;
416 /* This seems to be impossible on some machines, so let's turn it off.
417 You can use __builtin_next_arg to find the anonymous stack args.
418 | '&' ELLIPSIS
419 { tree types = TYPE_ARG_TYPES (TREE_TYPE (current_function_decl));
420 $$ = error_mark_node;
421 if (TREE_VALUE (tree_last (types)) == void_type_node)
422 error ("`&...' used in function with fixed number of arguments");
423 else
425 if (pedantic)
426 pedwarn ("ANSI C forbids `&...'");
427 $$ = tree_last (DECL_ARGUMENTS (current_function_decl));
428 $$ = build_unary_op (ADDR_EXPR, $$, 0);
431 | sizeof unary_expr %prec UNARY
432 { skip_evaluation--;
433 if (TREE_CODE ($2) == COMPONENT_REF
434 && DECL_C_BIT_FIELD (TREE_OPERAND ($2, 1)))
435 error ("`sizeof' applied to a bit-field");
436 $$ = c_sizeof (TREE_TYPE ($2)); }
437 | sizeof '(' typename ')' %prec HYPERUNARY
438 { skip_evaluation--;
439 $$ = c_sizeof (groktypename ($3)); }
440 | alignof unary_expr %prec UNARY
441 { skip_evaluation--;
442 $$ = c_alignof_expr ($2); }
443 | alignof '(' typename ')' %prec HYPERUNARY
444 { skip_evaluation--;
445 $$ = c_alignof (groktypename ($3)); }
446 | REALPART cast_expr %prec UNARY
447 { $$ = build_unary_op (REALPART_EXPR, $2, 0); }
448 | IMAGPART cast_expr %prec UNARY
449 { $$ = build_unary_op (IMAGPART_EXPR, $2, 0); }
450 | VA_ARG '(' expr_no_commas ',' typename ')'
451 { $$ = build_va_arg ($3, groktypename ($5)); }
454 sizeof:
455 SIZEOF { skip_evaluation++; }
458 alignof:
459 ALIGNOF { skip_evaluation++; }
462 cast_expr:
463 unary_expr
464 | '(' typename ')' cast_expr %prec UNARY
465 { tree type = groktypename ($2);
466 $$ = build_c_cast (type, $4); }
467 | '(' typename ')' '{'
468 { start_init (NULL_TREE, NULL, 0);
469 $2 = groktypename ($2);
470 really_start_incremental_init ($2); }
471 initlist_maybe_comma '}' %prec UNARY
472 { const char *name;
473 tree result = pop_init_level (0);
474 tree type = $2;
475 finish_init ();
477 if (pedantic && ! flag_isoc99)
478 pedwarn ("ANSI C forbids constructor expressions");
479 if (TYPE_NAME (type) != 0)
481 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
482 name = IDENTIFIER_POINTER (TYPE_NAME (type));
483 else
484 name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
486 else
487 name = "";
488 $$ = result;
489 if (TREE_CODE (type) == ARRAY_TYPE && TYPE_SIZE (type) == 0)
491 int failure = complete_array_type (type, $$, 1);
492 if (failure)
493 abort ();
498 expr_no_commas:
499 cast_expr
500 | expr_no_commas '+' expr_no_commas
501 { $$ = parser_build_binary_op ($2, $1, $3); }
502 | expr_no_commas '-' expr_no_commas
503 { $$ = parser_build_binary_op ($2, $1, $3); }
504 | expr_no_commas '*' expr_no_commas
505 { $$ = parser_build_binary_op ($2, $1, $3); }
506 | expr_no_commas '/' expr_no_commas
507 { $$ = parser_build_binary_op ($2, $1, $3); }
508 | expr_no_commas '%' expr_no_commas
509 { $$ = parser_build_binary_op ($2, $1, $3); }
510 | expr_no_commas LSHIFT expr_no_commas
511 { $$ = parser_build_binary_op ($2, $1, $3); }
512 | expr_no_commas RSHIFT expr_no_commas
513 { $$ = parser_build_binary_op ($2, $1, $3); }
514 | expr_no_commas ARITHCOMPARE expr_no_commas
515 { $$ = parser_build_binary_op ($2, $1, $3); }
516 | expr_no_commas EQCOMPARE expr_no_commas
517 { $$ = parser_build_binary_op ($2, $1, $3); }
518 | expr_no_commas '&' expr_no_commas
519 { $$ = parser_build_binary_op ($2, $1, $3); }
520 | expr_no_commas '|' expr_no_commas
521 { $$ = parser_build_binary_op ($2, $1, $3); }
522 | expr_no_commas '^' expr_no_commas
523 { $$ = parser_build_binary_op ($2, $1, $3); }
524 | expr_no_commas ANDAND
525 { $1 = truthvalue_conversion (default_conversion ($1));
526 skip_evaluation += $1 == boolean_false_node; }
527 expr_no_commas
528 { skip_evaluation -= $1 == boolean_false_node;
529 $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $4); }
530 | expr_no_commas OROR
531 { $1 = truthvalue_conversion (default_conversion ($1));
532 skip_evaluation += $1 == boolean_true_node; }
533 expr_no_commas
534 { skip_evaluation -= $1 == boolean_true_node;
535 $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $4); }
536 | expr_no_commas '?'
537 { $1 = truthvalue_conversion (default_conversion ($1));
538 skip_evaluation += $1 == boolean_false_node; }
539 expr ':'
540 { skip_evaluation += (($1 == boolean_true_node)
541 - ($1 == boolean_false_node)); }
542 expr_no_commas
543 { skip_evaluation -= $1 == boolean_true_node;
544 $$ = build_conditional_expr ($1, $4, $7); }
545 | expr_no_commas '?'
546 { if (pedantic)
547 pedwarn ("ANSI C forbids omitting the middle term of a ?: expression");
548 /* Make sure first operand is calculated only once. */
549 $<ttype>2 = save_expr ($1);
550 $1 = truthvalue_conversion (default_conversion ($<ttype>2));
551 skip_evaluation += $1 == boolean_true_node; }
552 ':' expr_no_commas
553 { skip_evaluation -= $1 == boolean_true_node;
554 $$ = build_conditional_expr ($1, $<ttype>2, $5); }
555 | expr_no_commas '=' expr_no_commas
556 { char class;
557 $$ = build_modify_expr ($1, NOP_EXPR, $3);
558 class = TREE_CODE_CLASS (TREE_CODE ($$));
559 if (class == 'e' || class == '1'
560 || class == '2' || class == '<')
561 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR);
563 | expr_no_commas ASSIGN expr_no_commas
564 { char class;
565 $$ = build_modify_expr ($1, $2, $3);
566 /* This inhibits warnings in truthvalue_conversion. */
567 class = TREE_CODE_CLASS (TREE_CODE ($$));
568 if (class == 'e' || class == '1'
569 || class == '2' || class == '<')
570 C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK);
574 primary:
575 IDENTIFIER
577 $$ = lastiddecl;
578 if (!$$ || $$ == error_mark_node)
580 if (yychar == YYEMPTY)
581 yychar = YYLEX;
582 if (yychar == '(')
585 /* Ordinary implicit function declaration. */
586 $$ = implicitly_declare ($1);
587 assemble_external ($$);
588 TREE_USED ($$) = 1;
591 else if (current_function_decl == 0)
593 error ("`%s' undeclared here (not in a function)",
594 IDENTIFIER_POINTER ($1));
595 $$ = error_mark_node;
597 else
600 if (IDENTIFIER_GLOBAL_VALUE ($1) != error_mark_node
601 || IDENTIFIER_ERROR_LOCUS ($1) != current_function_decl)
603 error ("`%s' undeclared (first use in this function)",
604 IDENTIFIER_POINTER ($1));
606 if (! undeclared_variable_notice)
608 error ("(Each undeclared identifier is reported only once");
609 error ("for each function it appears in.)");
610 undeclared_variable_notice = 1;
613 $$ = error_mark_node;
614 /* Prevent repeated error messages. */
615 IDENTIFIER_GLOBAL_VALUE ($1) = error_mark_node;
616 IDENTIFIER_ERROR_LOCUS ($1) = current_function_decl;
620 else if (TREE_TYPE ($$) == error_mark_node)
621 $$ = error_mark_node;
622 else if (C_DECL_ANTICIPATED ($$))
624 /* The first time we see a build-in function used,
625 if it has not been declared. */
626 C_DECL_ANTICIPATED ($$) = 0;
627 if (yychar == YYEMPTY)
628 yychar = YYLEX;
629 if (yychar == '(')
631 /* Omit the implicit declaration we
632 would ordinarily do, so we don't lose
633 the actual built in type.
634 But print a diagnostic for the mismatch. */
635 if (TREE_CODE ($$) != FUNCTION_DECL)
636 error ("`%s' implicitly declared as function",
637 IDENTIFIER_POINTER (DECL_NAME ($$)));
638 else if ((TYPE_MODE (TREE_TYPE (TREE_TYPE ($$)))
639 != TYPE_MODE (integer_type_node))
640 && (TREE_TYPE (TREE_TYPE ($$))
641 != void_type_node))
642 pedwarn ("type mismatch in implicit declaration for built-in function `%s'",
643 IDENTIFIER_POINTER (DECL_NAME ($$)));
644 /* If it really returns void, change that to int. */
645 if (TREE_TYPE (TREE_TYPE ($$)) == void_type_node)
646 TREE_TYPE ($$)
647 = build_function_type (integer_type_node,
648 TYPE_ARG_TYPES (TREE_TYPE ($$)));
650 else
651 pedwarn ("built-in function `%s' used without declaration",
652 IDENTIFIER_POINTER (DECL_NAME ($$)));
654 /* Do what we would ordinarily do when a fn is used. */
655 assemble_external ($$);
656 TREE_USED ($$) = 1;
658 else
660 assemble_external ($$);
661 TREE_USED ($$) = 1;
664 if (TREE_CODE ($$) == CONST_DECL)
666 $$ = DECL_INITIAL ($$);
667 /* This is to prevent an enum whose value is 0
668 from being considered a null pointer constant. */
669 $$ = build1 (NOP_EXPR, TREE_TYPE ($$), $$);
670 TREE_CONSTANT ($$) = 1;
673 | CONSTANT
674 | string
675 { $$ = combine_strings ($1); }
676 | '(' expr ')'
677 { char class = TREE_CODE_CLASS (TREE_CODE ($2));
678 if (class == 'e' || class == '1'
679 || class == '2' || class == '<')
680 C_SET_EXP_ORIGINAL_CODE ($2, ERROR_MARK);
681 $$ = $2; }
682 | '(' error ')'
683 { $$ = error_mark_node; }
684 | compstmt_primary_start compstmt_nostart ')'
685 { tree rtl_exp;
686 if (pedantic)
687 pedwarn ("ANSI C forbids braced-groups within expressions");
688 pop_iterator_stack ();
689 pop_label_level ();
690 rtl_exp = expand_end_stmt_expr ($1);
691 /* The statements have side effects, so the group does. */
692 TREE_SIDE_EFFECTS (rtl_exp) = 1;
694 if (TREE_CODE ($2) == BLOCK)
696 /* Make a BIND_EXPR for the BLOCK already made. */
697 $$ = build (BIND_EXPR, TREE_TYPE (rtl_exp),
698 NULL_TREE, rtl_exp, $2);
699 /* Remove the block from the tree at this point.
700 It gets put back at the proper place
701 when the BIND_EXPR is expanded. */
702 delete_block ($2);
704 else
705 $$ = $2;
707 | compstmt_primary_start error ')'
709 /* Make sure we call expand_end_stmt_expr. Otherwise
710 we are likely to lose sequences and crash later. */
711 pop_iterator_stack ();
712 pop_label_level ();
713 expand_end_stmt_expr ($1);
714 $$ = error_mark_node;
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);
741 if (warn_traditional && !in_system_header)
742 warning ("Use of ANSI string concatenation");
747 old_style_parm_decls:
748 /* empty */
749 | datadecls
750 | datadecls ELLIPSIS
751 /* ... is used here to indicate a varargs function. */
752 { c_mark_varargs ();
753 if (pedantic)
754 pedwarn ("ANSI C does not permit use of `varargs.h'"); }
757 /* The following are analogous to lineno_decl, decls and decl
758 except that they do not allow nested functions.
759 They are used for old-style parm decls. */
760 lineno_datadecl:
761 save_filename save_lineno datadecl
765 datadecls:
766 lineno_datadecl
767 | errstmt
768 | datadecls lineno_datadecl
769 | lineno_datadecl errstmt
772 /* We don't allow prefix attributes here because they cause reduce/reduce
773 conflicts: we can't know whether we're parsing a function decl with
774 attribute suffix, or function defn with attribute prefix on first old
775 style parm. */
776 datadecl:
777 typed_declspecs_no_prefix_attr setspecs initdecls ';'
778 { current_declspecs = TREE_VALUE (declspec_stack);
779 prefix_attributes = TREE_PURPOSE (declspec_stack);
780 declspec_stack = TREE_CHAIN (declspec_stack); }
781 | declmods_no_prefix_attr setspecs notype_initdecls ';'
782 { current_declspecs = TREE_VALUE (declspec_stack);
783 prefix_attributes = TREE_PURPOSE (declspec_stack);
784 declspec_stack = TREE_CHAIN (declspec_stack); }
785 | typed_declspecs_no_prefix_attr ';'
786 { shadow_tag_warned ($1, 1);
787 pedwarn ("empty declaration"); }
788 | declmods_no_prefix_attr ';'
789 { pedwarn ("empty declaration"); }
792 /* This combination which saves a lineno before a decl
793 is the normal thing to use, rather than decl itself.
794 This is to avoid shift/reduce conflicts in contexts
795 where statement labels are allowed. */
796 lineno_decl:
797 save_filename save_lineno decl
801 decls:
802 lineno_decl
803 | errstmt
804 | decls lineno_decl
805 | lineno_decl errstmt
808 /* records the type and storage class specs to use for processing
809 the declarators that follow.
810 Maintains a stack of outer-level values of current_declspecs,
811 for the sake of parm declarations nested in function declarators. */
812 setspecs: /* empty */
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 | declmods setspecs notype_initdecls ';'
832 { current_declspecs = TREE_VALUE (declspec_stack);
833 prefix_attributes = TREE_PURPOSE (declspec_stack);
834 declspec_stack = TREE_CHAIN (declspec_stack); }
835 | typed_declspecs setspecs nested_function
836 { current_declspecs = TREE_VALUE (declspec_stack);
837 prefix_attributes = TREE_PURPOSE (declspec_stack);
838 declspec_stack = TREE_CHAIN (declspec_stack); }
839 | declmods setspecs notype_nested_function
840 { current_declspecs = TREE_VALUE (declspec_stack);
841 prefix_attributes = TREE_PURPOSE (declspec_stack);
842 declspec_stack = TREE_CHAIN (declspec_stack); }
843 | typed_declspecs ';'
844 { shadow_tag ($1); }
845 | declmods ';'
846 { pedwarn ("empty declaration"); }
847 | extension decl
848 { RESTORE_WARN_FLAGS ($1); }
851 /* Declspecs which contain at least one type specifier or typedef name.
852 (Just `const' or `volatile' is not enough.)
853 A typedef'd name following these is taken as a name to be declared.
854 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
856 typed_declspecs:
857 typespec reserved_declspecs
858 { $$ = tree_cons (NULL_TREE, $1, $2); }
859 | declmods typespec reserved_declspecs
860 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
863 reserved_declspecs: /* empty */
864 { $$ = NULL_TREE; }
865 | reserved_declspecs typespecqual_reserved
866 { $$ = tree_cons (NULL_TREE, $2, $1); }
867 | reserved_declspecs SCSPEC
868 { if (extra_warnings)
869 warning ("`%s' is not at beginning of declaration",
870 IDENTIFIER_POINTER ($2));
871 $$ = tree_cons (NULL_TREE, $2, $1); }
872 | reserved_declspecs attributes
873 { $$ = tree_cons ($2, NULL_TREE, $1); }
876 typed_declspecs_no_prefix_attr:
877 typespec reserved_declspecs_no_prefix_attr
878 { $$ = tree_cons (NULL_TREE, $1, $2); }
879 | declmods_no_prefix_attr typespec reserved_declspecs_no_prefix_attr
880 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
883 reserved_declspecs_no_prefix_attr:
884 /* empty */
885 { $$ = NULL_TREE; }
886 | reserved_declspecs_no_prefix_attr typespecqual_reserved
887 { $$ = tree_cons (NULL_TREE, $2, $1); }
888 | reserved_declspecs_no_prefix_attr SCSPEC
889 { if (extra_warnings)
890 warning ("`%s' is not at beginning of declaration",
891 IDENTIFIER_POINTER ($2));
892 $$ = tree_cons (NULL_TREE, $2, $1); }
895 /* List of just storage classes, type modifiers, and prefix attributes.
896 A declaration can start with just this, but then it cannot be used
897 to redeclare a typedef-name.
898 Declspecs have a non-NULL TREE_VALUE, attributes do not. */
900 declmods:
901 declmods_no_prefix_attr
902 { $$ = $1; }
903 | attributes
904 { $$ = tree_cons ($1, NULL_TREE, NULL_TREE); }
905 | declmods declmods_no_prefix_attr
906 { $$ = chainon ($2, $1); }
907 | declmods attributes
908 { $$ = tree_cons ($2, NULL_TREE, $1); }
911 declmods_no_prefix_attr:
912 TYPE_QUAL
913 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
914 TREE_STATIC ($$) = 1; }
915 | SCSPEC
916 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
917 | declmods_no_prefix_attr TYPE_QUAL
918 { $$ = tree_cons (NULL_TREE, $2, $1);
919 TREE_STATIC ($$) = 1; }
920 | declmods_no_prefix_attr SCSPEC
921 { if (extra_warnings && TREE_STATIC ($1))
922 warning ("`%s' is not at beginning of declaration",
923 IDENTIFIER_POINTER ($2));
924 $$ = tree_cons (NULL_TREE, $2, $1);
925 TREE_STATIC ($$) = TREE_STATIC ($1); }
929 /* Used instead of declspecs where storage classes are not allowed
930 (that is, for typenames and structure components).
931 Don't accept a typedef-name if anything but a modifier precedes it. */
933 typed_typespecs:
934 typespec reserved_typespecquals
935 { $$ = tree_cons (NULL_TREE, $1, $2); }
936 | nonempty_type_quals typespec reserved_typespecquals
937 { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
940 reserved_typespecquals: /* empty */
941 { $$ = NULL_TREE; }
942 | reserved_typespecquals typespecqual_reserved
943 { $$ = tree_cons (NULL_TREE, $2, $1); }
946 /* A typespec (but not a type qualifier).
947 Once we have seen one of these in a declaration,
948 if a typedef name appears then it is being redeclared. */
950 typespec: TYPESPEC
951 | structsp
952 | TYPENAME
953 { /* For a typedef name, record the meaning, not the name.
954 In case of `foo foo, bar;'. */
955 $$ = lookup_name ($1); }
956 | TYPEOF '(' expr ')'
957 { $$ = TREE_TYPE ($3); }
958 | TYPEOF '(' typename ')'
959 { $$ = groktypename ($3); }
962 /* A typespec that is a reserved word, or a type qualifier. */
964 typespecqual_reserved: TYPESPEC
965 | TYPE_QUAL
966 | structsp
969 initdecls:
970 initdcl
971 | initdecls ',' initdcl
974 notype_initdecls:
975 notype_initdcl
976 | notype_initdecls ',' initdcl
979 maybeasm:
980 /* empty */
981 { $$ = NULL_TREE; }
982 | ASM_KEYWORD '(' string ')'
983 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
984 $$ = $3;
988 initdcl:
989 declarator maybeasm maybe_attribute '='
990 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
991 $3, prefix_attributes);
992 start_init ($<ttype>$, $2, global_bindings_p ()); }
993 init
994 /* Note how the declaration of the variable is in effect while its init is parsed! */
995 { finish_init ();
996 finish_decl ($<ttype>5, $6, $2); }
997 | declarator maybeasm maybe_attribute
998 { tree d = start_decl ($1, current_declspecs, 0,
999 $3, prefix_attributes);
1000 finish_decl (d, NULL_TREE, $2);
1004 notype_initdcl:
1005 notype_declarator maybeasm maybe_attribute '='
1006 { $<ttype>$ = start_decl ($1, current_declspecs, 1,
1007 $3, prefix_attributes);
1008 start_init ($<ttype>$, $2, global_bindings_p ()); }
1009 init
1010 /* Note how the declaration of the variable is in effect while its init is parsed! */
1011 { finish_init ();
1012 decl_attributes ($<ttype>5, $3, prefix_attributes);
1013 finish_decl ($<ttype>5, $6, $2); }
1014 | notype_declarator maybeasm maybe_attribute
1015 { tree d = start_decl ($1, current_declspecs, 0,
1016 $3, prefix_attributes);
1017 finish_decl (d, NULL_TREE, $2); }
1019 /* the * rules are dummies to accept the Apollo extended syntax
1020 so that the header files compile. */
1021 maybe_attribute:
1022 /* empty */
1023 { $$ = NULL_TREE; }
1024 | attributes
1025 { $$ = $1; }
1028 attributes:
1029 attribute
1030 { $$ = $1; }
1031 | attributes attribute
1032 { $$ = chainon ($1, $2); }
1035 attribute:
1036 ATTRIBUTE '(' '(' attribute_list ')' ')'
1037 { $$ = $4; }
1040 attribute_list:
1041 attrib
1042 { $$ = $1; }
1043 | attribute_list ',' attrib
1044 { $$ = chainon ($1, $3); }
1047 attrib:
1048 /* empty */
1049 { $$ = NULL_TREE; }
1050 | any_word
1051 { $$ = build_tree_list ($1, NULL_TREE); }
1052 | any_word '(' IDENTIFIER ')'
1053 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1054 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1055 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1056 | any_word '(' exprlist ')'
1057 { $$ = build_tree_list ($1, $3); }
1060 /* This still leaves out most reserved keywords,
1061 shouldn't we include them? */
1063 any_word:
1064 identifier
1065 | SCSPEC
1066 | TYPESPEC
1067 | TYPE_QUAL
1070 /* Initializers. `init' is the entry point. */
1072 init:
1073 expr_no_commas
1074 | '{'
1075 { really_start_incremental_init (NULL_TREE); }
1076 initlist_maybe_comma '}'
1077 { $$ = pop_init_level (0); }
1078 | error
1079 { $$ = error_mark_node; }
1082 /* `initlist_maybe_comma' is the guts of an initializer in braces. */
1083 initlist_maybe_comma:
1084 /* empty */
1085 { if (pedantic)
1086 pedwarn ("ANSI C forbids empty initializer braces"); }
1087 | initlist1 maybecomma
1090 initlist1:
1091 initelt
1092 | initlist1 ',' initelt
1095 /* `initelt' is a single element of an initializer.
1096 It may use braces. */
1097 initelt:
1098 designator_list '=' initval
1099 | designator initval
1100 | identifier ':'
1101 { set_init_label ($1); }
1102 initval
1103 | initval
1106 initval:
1108 { push_init_level (0); }
1109 initlist_maybe_comma '}'
1110 { process_init_element (pop_init_level (0)); }
1111 | expr_no_commas
1112 { process_init_element ($1); }
1113 | error
1116 designator_list:
1117 designator
1118 | designator_list designator
1121 designator:
1122 '.' identifier
1123 { set_init_label ($2); }
1124 /* These are for labeled elements. The syntax for an array element
1125 initializer conflicts with the syntax for an Objective-C message,
1126 so don't include these productions in the Objective-C grammar. */
1127 | '[' expr_no_commas ELLIPSIS expr_no_commas ']'
1128 { set_init_index ($2, $4); }
1129 | '[' expr_no_commas ']'
1130 { set_init_index ($2, NULL_TREE); }
1133 nested_function:
1134 declarator
1135 { if (pedantic)
1136 pedwarn ("ANSI C forbids nested functions");
1138 push_function_context ();
1139 if (! start_function (current_declspecs, $1,
1140 prefix_attributes, NULL_TREE))
1142 pop_function_context ();
1143 YYERROR1;
1145 reinit_parse_for_function (); }
1146 old_style_parm_decls
1147 { store_parm_decls (); }
1148 /* This used to use compstmt_or_error.
1149 That caused a bug with input `f(g) int g {}',
1150 where the use of YYERROR1 above caused an error
1151 which then was handled by compstmt_or_error.
1152 There followed a repeated execution of that same rule,
1153 which called YYERROR1 again, and so on. */
1154 compstmt
1155 { finish_function (1);
1156 pop_function_context (); }
1159 notype_nested_function:
1160 notype_declarator
1161 { if (pedantic)
1162 pedwarn ("ANSI C forbids nested functions");
1164 push_function_context ();
1165 if (! start_function (current_declspecs, $1,
1166 prefix_attributes, NULL_TREE))
1168 pop_function_context ();
1169 YYERROR1;
1171 reinit_parse_for_function (); }
1172 old_style_parm_decls
1173 { store_parm_decls (); }
1174 /* This used to use compstmt_or_error.
1175 That caused a bug with input `f(g) int g {}',
1176 where the use of YYERROR1 above caused an error
1177 which then was handled by compstmt_or_error.
1178 There followed a repeated execution of that same rule,
1179 which called YYERROR1 again, and so on. */
1180 compstmt
1181 { finish_function (1);
1182 pop_function_context (); }
1185 /* Any kind of declarator (thus, all declarators allowed
1186 after an explicit typespec). */
1188 declarator:
1189 after_type_declarator
1190 | notype_declarator
1193 /* A declarator that is allowed only after an explicit typespec. */
1195 after_type_declarator:
1196 '(' after_type_declarator ')'
1197 { $$ = $2; }
1198 | after_type_declarator '(' parmlist_or_identifiers %prec '.'
1199 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1200 /* | after_type_declarator '(' error ')' %prec '.'
1201 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1202 poplevel (0, 0, 0); } */
1203 | after_type_declarator '[' expr ']' %prec '.'
1204 { $$ = build_nt (ARRAY_REF, $1, $3); }
1205 | after_type_declarator '[' ']' %prec '.'
1206 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1207 | '*' type_quals after_type_declarator %prec UNARY
1208 { $$ = make_pointer_declarator ($2, $3); }
1209 /* ??? Yuck. setattrs is a quick hack. We can't use
1210 prefix_attributes because $1 only applies to this
1211 declarator. We assume setspecs has already been done.
1212 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1213 attributes could be recognized here or in `attributes'). */
1214 | attributes setattrs after_type_declarator
1215 { $$ = $3; }
1216 | TYPENAME
1219 /* Kinds of declarator that can appear in a parameter list
1220 in addition to notype_declarator. This is like after_type_declarator
1221 but does not allow a typedef name in parentheses as an identifier
1222 (because it would conflict with a function with that typedef as arg). */
1224 parm_declarator:
1225 parm_declarator '(' parmlist_or_identifiers %prec '.'
1226 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1227 /* | parm_declarator '(' error ')' %prec '.'
1228 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1229 poplevel (0, 0, 0); } */
1230 | parm_declarator '[' '*' ']' %prec '.'
1231 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE);
1232 if (! flag_isoc99)
1233 error ("`[*]' in parameter declaration only allowed in ISO C 99");
1235 | parm_declarator '[' expr ']' %prec '.'
1236 { $$ = build_nt (ARRAY_REF, $1, $3); }
1237 | parm_declarator '[' ']' %prec '.'
1238 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1239 | '*' type_quals parm_declarator %prec UNARY
1240 { $$ = make_pointer_declarator ($2, $3); }
1241 /* ??? Yuck. setattrs is a quick hack. We can't use
1242 prefix_attributes because $1 only applies to this
1243 declarator. We assume setspecs has already been done.
1244 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1245 attributes could be recognized here or in `attributes'). */
1246 | attributes setattrs parm_declarator
1247 { $$ = $3; }
1248 | TYPENAME
1251 /* A declarator allowed whether or not there has been
1252 an explicit typespec. These cannot redeclare a typedef-name. */
1254 notype_declarator:
1255 notype_declarator '(' parmlist_or_identifiers %prec '.'
1256 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1257 /* | notype_declarator '(' error ')' %prec '.'
1258 { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
1259 poplevel (0, 0, 0); } */
1260 | '(' notype_declarator ')'
1261 { $$ = $2; }
1262 | '*' type_quals notype_declarator %prec UNARY
1263 { $$ = make_pointer_declarator ($2, $3); }
1264 | notype_declarator '[' '*' ']' %prec '.'
1265 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE);
1266 if (! flag_isoc99)
1267 error ("`[*]' in parameter declaration only allowed in ISO C 99");
1269 | notype_declarator '[' expr ']' %prec '.'
1270 { $$ = build_nt (ARRAY_REF, $1, $3); }
1271 | notype_declarator '[' ']' %prec '.'
1272 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1273 /* ??? Yuck. setattrs is a quick hack. We can't use
1274 prefix_attributes because $1 only applies to this
1275 declarator. We assume setspecs has already been done.
1276 setattrs also avoids 5 reduce/reduce conflicts (otherwise multiple
1277 attributes could be recognized here or in `attributes'). */
1278 | attributes setattrs notype_declarator
1279 { $$ = $3; }
1280 | IDENTIFIER
1283 struct_head:
1284 STRUCT
1285 { $$ = NULL_TREE; }
1286 | STRUCT attributes
1287 { $$ = $2; }
1290 union_head:
1291 UNION
1292 { $$ = NULL_TREE; }
1293 | UNION attributes
1294 { $$ = $2; }
1297 enum_head:
1298 ENUM
1299 { $$ = NULL_TREE; }
1300 | ENUM attributes
1301 { $$ = $2; }
1304 structsp:
1305 struct_head identifier '{'
1306 { $$ = start_struct (RECORD_TYPE, $2);
1307 /* Start scope of tag before parsing components. */
1309 component_decl_list '}' maybe_attribute
1310 { $$ = finish_struct ($<ttype>4, $5, chainon ($1, $7)); }
1311 | struct_head '{' component_decl_list '}' maybe_attribute
1312 { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
1313 $3, chainon ($1, $5));
1315 | struct_head identifier
1316 { $$ = xref_tag (RECORD_TYPE, $2); }
1317 | union_head identifier '{'
1318 { $$ = start_struct (UNION_TYPE, $2); }
1319 component_decl_list '}' maybe_attribute
1320 { $$ = finish_struct ($<ttype>4, $5, chainon ($1, $7)); }
1321 | union_head '{' component_decl_list '}' maybe_attribute
1322 { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
1323 $3, chainon ($1, $5));
1325 | union_head identifier
1326 { $$ = xref_tag (UNION_TYPE, $2); }
1327 | enum_head identifier '{'
1328 { $$ = start_enum ($2); }
1329 enumlist maybecomma_warn '}' maybe_attribute
1330 { $$ = finish_enum ($<ttype>4, nreverse ($5),
1331 chainon ($1, $8)); }
1332 | enum_head '{'
1333 { $$ = start_enum (NULL_TREE); }
1334 enumlist maybecomma_warn '}' maybe_attribute
1335 { $$ = finish_enum ($<ttype>3, nreverse ($4),
1336 chainon ($1, $7)); }
1337 | enum_head identifier
1338 { $$ = xref_tag (ENUMERAL_TYPE, $2); }
1341 maybecomma:
1342 /* empty */
1343 | ','
1346 maybecomma_warn:
1347 /* empty */
1348 | ','
1349 { if (pedantic && ! flag_isoc99)
1350 pedwarn ("comma at end of enumerator list"); }
1353 component_decl_list:
1354 component_decl_list2
1355 { $$ = $1; }
1356 | component_decl_list2 component_decl
1357 { $$ = chainon ($1, $2);
1358 pedwarn ("no semicolon at end of struct or union"); }
1361 component_decl_list2: /* empty */
1362 { $$ = NULL_TREE; }
1363 | component_decl_list2 component_decl ';'
1364 { $$ = chainon ($1, $2); }
1365 | component_decl_list2 ';'
1366 { if (pedantic)
1367 pedwarn ("extra semicolon in struct or union specified"); }
1370 /* There is a shift-reduce conflict here, because `components' may
1371 start with a `typename'. It happens that shifting (the default resolution)
1372 does the right thing, because it treats the `typename' as part of
1373 a `typed_typespecs'.
1375 It is possible that this same technique would allow the distinction
1376 between `notype_initdecls' and `initdecls' to be eliminated.
1377 But I am being cautious and not trying it. */
1379 component_decl:
1380 typed_typespecs setspecs components
1381 { $$ = $3;
1382 current_declspecs = TREE_VALUE (declspec_stack);
1383 prefix_attributes = TREE_PURPOSE (declspec_stack);
1384 declspec_stack = TREE_CHAIN (declspec_stack); }
1385 | typed_typespecs setspecs save_filename save_lineno maybe_attribute
1387 /* Support for unnamed structs or unions as members of
1388 structs or unions (which is [a] useful and [b] supports
1389 MS P-SDK). */
1390 if (pedantic)
1391 pedwarn ("ANSI C doesn't support unnamed structs/unions");
1393 $$ = grokfield($3, $4, NULL, current_declspecs, NULL_TREE);
1394 current_declspecs = TREE_VALUE (declspec_stack);
1395 prefix_attributes = TREE_PURPOSE (declspec_stack);
1396 declspec_stack = TREE_CHAIN (declspec_stack);
1398 | nonempty_type_quals setspecs components
1399 { $$ = $3;
1400 current_declspecs = TREE_VALUE (declspec_stack);
1401 prefix_attributes = TREE_PURPOSE (declspec_stack);
1402 declspec_stack = TREE_CHAIN (declspec_stack); }
1403 | nonempty_type_quals
1404 { if (pedantic)
1405 pedwarn ("ANSI C forbids member declarations with no members");
1406 shadow_tag($1);
1407 $$ = NULL_TREE; }
1408 | error
1409 { $$ = NULL_TREE; }
1410 | extension component_decl
1411 { $$ = $2;
1412 RESTORE_WARN_FLAGS ($1); }
1415 components:
1416 component_declarator
1417 | components ',' component_declarator
1418 { $$ = chainon ($1, $3); }
1421 component_declarator:
1422 save_filename save_lineno declarator maybe_attribute
1423 { $$ = grokfield ($1, $2, $3, current_declspecs, NULL_TREE);
1424 decl_attributes ($$, $4, prefix_attributes); }
1425 | save_filename save_lineno
1426 declarator ':' expr_no_commas maybe_attribute
1427 { $$ = grokfield ($1, $2, $3, current_declspecs, $5);
1428 decl_attributes ($$, $6, prefix_attributes); }
1429 | save_filename save_lineno ':' expr_no_commas maybe_attribute
1430 { $$ = grokfield ($1, $2, NULL_TREE, current_declspecs, $4);
1431 decl_attributes ($$, $5, prefix_attributes); }
1434 /* We chain the enumerators in reverse order.
1435 They are put in forward order where enumlist is used.
1436 (The order used to be significant, but no longer is so.
1437 However, we still maintain the order, just to be clean.) */
1439 enumlist:
1440 enumerator
1441 | enumlist ',' enumerator
1442 { if ($1 == error_mark_node)
1443 $$ = $1;
1444 else
1445 $$ = chainon ($3, $1); }
1446 | error
1447 { $$ = error_mark_node; }
1451 enumerator:
1452 identifier
1453 { $$ = build_enumerator ($1, NULL_TREE); }
1454 | identifier '=' expr_no_commas
1455 { $$ = build_enumerator ($1, $3); }
1458 typename:
1459 typed_typespecs absdcl
1460 { $$ = build_tree_list ($1, $2); }
1461 | nonempty_type_quals absdcl
1462 { $$ = build_tree_list ($1, $2); }
1465 absdcl: /* an absolute declarator */
1466 /* empty */
1467 { $$ = NULL_TREE; }
1468 | absdcl1
1471 nonempty_type_quals:
1472 TYPE_QUAL
1473 { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
1474 | nonempty_type_quals TYPE_QUAL
1475 { $$ = tree_cons (NULL_TREE, $2, $1); }
1478 type_quals:
1479 /* empty */
1480 { $$ = NULL_TREE; }
1481 | type_quals TYPE_QUAL
1482 { $$ = tree_cons (NULL_TREE, $2, $1); }
1485 absdcl1: /* a nonempty absolute declarator */
1486 '(' absdcl1 ')'
1487 { $$ = $2; }
1488 /* `(typedef)1' is `int'. */
1489 | '*' type_quals absdcl1 %prec UNARY
1490 { $$ = make_pointer_declarator ($2, $3); }
1491 | '*' type_quals %prec UNARY
1492 { $$ = make_pointer_declarator ($2, NULL_TREE); }
1493 | absdcl1 '(' parmlist %prec '.'
1494 { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
1495 | absdcl1 '[' expr ']' %prec '.'
1496 { $$ = build_nt (ARRAY_REF, $1, $3); }
1497 | absdcl1 '[' ']' %prec '.'
1498 { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
1499 | '(' parmlist %prec '.'
1500 { $$ = build_nt (CALL_EXPR, NULL_TREE, $2, NULL_TREE); }
1501 | '[' expr ']' %prec '.'
1502 { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
1503 | '[' ']' %prec '.'
1504 { $$ = build_nt (ARRAY_REF, NULL_TREE, NULL_TREE); }
1505 /* ??? It appears we have to support attributes here, however
1506 using prefix_attributes is wrong. */
1507 | attributes setattrs absdcl1
1508 { $$ = $3; }
1511 /* at least one statement, the first of which parses without error. */
1512 /* stmts is used only after decls, so an invalid first statement
1513 is actually regarded as an invalid decl and part of the decls. */
1515 stmts:
1516 lineno_stmt_or_labels
1518 if (pedantic && $1)
1519 pedwarn ("ANSI C forbids label at end of compound statement");
1523 lineno_stmt_or_labels:
1524 lineno_stmt_or_label
1525 | lineno_stmt_or_labels lineno_stmt_or_label
1526 { $$ = $2; }
1527 | lineno_stmt_or_labels errstmt
1528 { $$ = 0; }
1531 xstmts:
1532 /* empty */
1533 | stmts
1536 errstmt: error ';'
1539 pushlevel: /* empty */
1540 { emit_line_note (input_filename, lineno);
1541 pushlevel (0);
1542 clear_last_expr ();
1543 expand_start_bindings (0);
1547 /* Read zero or more forward-declarations for labels
1548 that nested functions can jump to. */
1549 maybe_label_decls:
1550 /* empty */
1551 | label_decls
1552 { if (pedantic)
1553 pedwarn ("ANSI C forbids label declarations"); }
1556 label_decls:
1557 label_decl
1558 | label_decls label_decl
1561 label_decl:
1562 LABEL identifiers_or_typenames ';'
1563 { tree link;
1564 for (link = $2; link; link = TREE_CHAIN (link))
1566 tree label = shadow_label (TREE_VALUE (link));
1567 C_DECLARED_LABEL_FLAG (label) = 1;
1568 declare_nonlocal_label (label);
1573 /* This is the body of a function definition.
1574 It causes syntax errors to ignore to the next openbrace. */
1575 compstmt_or_error:
1576 compstmt
1578 | error compstmt
1581 compstmt_start: '{' { compstmt_count++; }
1583 compstmt_nostart: '}'
1584 { $$ = convert (void_type_node, integer_zero_node); }
1585 | pushlevel maybe_label_decls decls xstmts '}'
1586 { emit_line_note (input_filename, lineno);
1587 expand_end_bindings (getdecls (), 1, 0);
1588 $$ = poplevel (1, 1, 0); }
1589 | pushlevel maybe_label_decls error '}'
1590 { emit_line_note (input_filename, lineno);
1591 expand_end_bindings (getdecls (), kept_level_p (), 0);
1592 $$ = poplevel (kept_level_p (), 0, 0); }
1593 | pushlevel maybe_label_decls stmts '}'
1594 { emit_line_note (input_filename, lineno);
1595 expand_end_bindings (getdecls (), kept_level_p (), 0);
1596 $$ = poplevel (kept_level_p (), 0, 0); }
1599 compstmt_primary_start:
1600 '(' '{'
1601 { if (current_function_decl == 0)
1603 error ("braced-group within expression allowed only inside a function");
1604 YYERROR;
1606 /* We must force a BLOCK for this level
1607 so that, if it is not expanded later,
1608 there is a way to turn off the entire subtree of blocks
1609 that are contained in it. */
1610 keep_next_level ();
1611 push_iterator_stack ();
1612 push_label_level ();
1613 $$ = expand_start_stmt_expr ();
1614 compstmt_count++;
1617 compstmt: compstmt_start compstmt_nostart
1618 { $$ = $2; }
1621 /* Value is number of statements counted as of the closeparen. */
1622 simple_if:
1623 if_prefix lineno_labeled_stmt
1624 /* Make sure c_expand_end_cond is run once
1625 for each call to c_expand_start_cond.
1626 Otherwise a crash is likely. */
1627 | if_prefix error
1630 if_prefix:
1631 IF '(' expr ')'
1632 { emit_line_note ($<filename>-1, $<lineno>0);
1633 c_expand_start_cond (truthvalue_conversion ($3), 0,
1634 compstmt_count);
1635 $<itype>$ = stmt_count;
1636 if_stmt_file = $<filename>-1;
1637 if_stmt_line = $<lineno>0;
1638 position_after_white_space (); }
1641 /* This is a subroutine of stmt.
1642 It is used twice, once for valid DO statements
1643 and once for catching errors in parsing the end test. */
1644 do_stmt_start:
1646 { stmt_count++;
1647 compstmt_count++;
1648 emit_line_note ($<filename>-1, $<lineno>0);
1649 /* See comment in `while' alternative, above. */
1650 emit_nop ();
1651 expand_start_loop_continue_elsewhere (1);
1652 position_after_white_space (); }
1653 lineno_labeled_stmt WHILE
1654 { expand_loop_continue_here (); }
1657 save_filename:
1658 { $$ = input_filename; }
1661 save_lineno:
1662 { $$ = lineno; }
1665 lineno_labeled_stmt:
1666 save_filename save_lineno stmt
1668 /* | save_filename save_lineno error
1671 | save_filename save_lineno label lineno_labeled_stmt
1675 lineno_stmt_or_label:
1676 save_filename save_lineno stmt_or_label
1677 { $$ = $3; }
1680 stmt_or_label:
1681 stmt
1682 { $$ = 0; }
1683 | label
1684 { $$ = 1; }
1687 /* Parse a single real statement, not including any labels. */
1688 stmt:
1689 compstmt
1690 { stmt_count++; }
1691 | all_iter_stmt
1692 | expr ';'
1693 { stmt_count++;
1694 emit_line_note ($<filename>-1, $<lineno>0);
1695 /* It appears that this should not be done--that a non-lvalue array
1696 shouldn't get an error if the value isn't used.
1697 Section 3.2.2.1 says that an array lvalue gets converted to a pointer
1698 if it appears as a top-level expression,
1699 but says nothing about non-lvalue arrays. */
1700 #if 0
1701 /* Call default_conversion to get an error
1702 on referring to a register array if pedantic. */
1703 if (TREE_CODE (TREE_TYPE ($1)) == ARRAY_TYPE
1704 || TREE_CODE (TREE_TYPE ($1)) == FUNCTION_TYPE)
1705 $1 = default_conversion ($1);
1706 #endif
1707 iterator_expand ($1); }
1708 | simple_if ELSE
1709 { c_expand_start_else ();
1710 $<itype>1 = stmt_count;
1711 position_after_white_space (); }
1712 lineno_labeled_stmt
1713 { c_expand_end_cond ();
1714 if (extra_warnings && stmt_count == $<itype>1)
1715 warning ("empty body in an else-statement"); }
1716 | simple_if %prec IF
1717 { c_expand_end_cond ();
1718 /* This warning is here instead of in simple_if, because we
1719 do not want a warning if an empty if is followed by an
1720 else statement. Increment stmt_count so we don't
1721 give a second error if this is a nested `if'. */
1722 if (extra_warnings && stmt_count++ == $<itype>1)
1723 warning_with_file_and_line (if_stmt_file, if_stmt_line,
1724 "empty body in an if-statement"); }
1725 /* Make sure c_expand_end_cond is run once
1726 for each call to c_expand_start_cond.
1727 Otherwise a crash is likely. */
1728 | simple_if ELSE error
1729 { c_expand_end_cond (); }
1730 | WHILE
1731 { stmt_count++;
1732 emit_line_note ($<filename>-1, $<lineno>0);
1733 /* The emit_nop used to come before emit_line_note,
1734 but that made the nop seem like part of the preceding line.
1735 And that was confusing when the preceding line was
1736 inside of an if statement and was not really executed.
1737 I think it ought to work to put the nop after the line number.
1738 We will see. --rms, July 15, 1991. */
1739 emit_nop (); }
1740 '(' expr ')'
1741 { /* Don't start the loop till we have succeeded
1742 in parsing the end test. This is to make sure
1743 that we end every loop we start. */
1744 expand_start_loop (1);
1745 emit_line_note (input_filename, lineno);
1746 expand_exit_loop_if_false (NULL_PTR,
1747 truthvalue_conversion ($4));
1748 position_after_white_space (); }
1749 lineno_labeled_stmt
1750 { expand_end_loop (); }
1751 | do_stmt_start
1752 '(' expr ')' ';'
1753 { emit_line_note (input_filename, lineno);
1754 expand_exit_loop_if_false (NULL_PTR,
1755 truthvalue_conversion ($3));
1756 expand_end_loop (); }
1757 /* This rule is needed to make sure we end every loop we start. */
1758 | do_stmt_start error
1759 { expand_end_loop (); }
1760 | FOR
1761 '(' xexpr ';'
1762 { stmt_count++;
1763 emit_line_note ($<filename>-1, $<lineno>0);
1764 /* See comment in `while' alternative, above. */
1765 emit_nop ();
1766 if ($3) c_expand_expr_stmt ($3);
1767 /* Next step is to call expand_start_loop_continue_elsewhere,
1768 but wait till after we parse the entire for (...).
1769 Otherwise, invalid input might cause us to call that
1770 fn without calling expand_end_loop. */
1772 xexpr ';'
1773 /* Can't emit now; wait till after expand_start_loop... */
1774 { $<lineno>7 = lineno;
1775 $<filename>$ = input_filename; }
1776 xexpr ')'
1778 /* Start the loop. Doing this after parsing
1779 all the expressions ensures we will end the loop. */
1780 expand_start_loop_continue_elsewhere (1);
1781 /* Emit the end-test, with a line number. */
1782 emit_line_note ($<filename>8, $<lineno>7);
1783 if ($6)
1784 expand_exit_loop_if_false (NULL_PTR,
1785 truthvalue_conversion ($6));
1786 $<lineno>7 = lineno;
1787 $<filename>8 = input_filename;
1788 position_after_white_space (); }
1789 lineno_labeled_stmt
1790 { /* Emit the increment expression, with a line number. */
1791 emit_line_note ($<filename>8, $<lineno>7);
1792 expand_loop_continue_here ();
1793 if ($9)
1794 c_expand_expr_stmt ($9);
1795 expand_end_loop (); }
1796 | SWITCH '(' expr ')'
1797 { stmt_count++;
1798 emit_line_note ($<filename>-1, $<lineno>0);
1799 c_expand_start_case ($3);
1800 position_after_white_space (); }
1801 lineno_labeled_stmt
1802 { expand_end_case ($3); }
1803 | BREAK ';'
1804 { stmt_count++;
1805 emit_line_note ($<filename>-1, $<lineno>0);
1806 if ( ! expand_exit_something ())
1807 error ("break statement not within loop or switch"); }
1808 | CONTINUE ';'
1809 { stmt_count++;
1810 emit_line_note ($<filename>-1, $<lineno>0);
1811 if (! expand_continue_loop (NULL_PTR))
1812 error ("continue statement not within a loop"); }
1813 | RETURN ';'
1814 { stmt_count++;
1815 emit_line_note ($<filename>-1, $<lineno>0);
1816 c_expand_return (NULL_TREE); }
1817 | RETURN expr ';'
1818 { stmt_count++;
1819 emit_line_note ($<filename>-1, $<lineno>0);
1820 c_expand_return ($2); }
1821 | ASM_KEYWORD maybe_type_qual '(' expr ')' ';'
1822 { stmt_count++;
1823 emit_line_note ($<filename>-1, $<lineno>0);
1824 STRIP_NOPS ($4);
1825 if ((TREE_CODE ($4) == ADDR_EXPR
1826 && TREE_CODE (TREE_OPERAND ($4, 0)) == STRING_CST)
1827 || TREE_CODE ($4) == STRING_CST)
1828 expand_asm ($4);
1829 else
1830 error ("argument of `asm' is not a constant string"); }
1831 /* This is the case with just output operands. */
1832 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ')' ';'
1833 { stmt_count++;
1834 emit_line_note ($<filename>-1, $<lineno>0);
1835 c_expand_asm_operands ($4, $6, NULL_TREE, NULL_TREE,
1836 $2 == ridpointers[(int)RID_VOLATILE],
1837 input_filename, lineno); }
1838 /* This is the case with input operands as well. */
1839 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':' asm_operands ')' ';'
1840 { stmt_count++;
1841 emit_line_note ($<filename>-1, $<lineno>0);
1842 c_expand_asm_operands ($4, $6, $8, NULL_TREE,
1843 $2 == ridpointers[(int)RID_VOLATILE],
1844 input_filename, lineno); }
1845 /* This is the case with clobbered registers as well. */
1846 | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':'
1847 asm_operands ':' asm_clobbers ')' ';'
1848 { stmt_count++;
1849 emit_line_note ($<filename>-1, $<lineno>0);
1850 c_expand_asm_operands ($4, $6, $8, $10,
1851 $2 == ridpointers[(int)RID_VOLATILE],
1852 input_filename, lineno); }
1853 | GOTO identifier ';'
1854 { tree decl;
1855 stmt_count++;
1856 emit_line_note ($<filename>-1, $<lineno>0);
1857 decl = lookup_label ($2);
1858 if (decl != 0)
1860 TREE_USED (decl) = 1;
1861 expand_goto (decl);
1864 | GOTO '*' expr ';'
1865 { if (pedantic)
1866 pedwarn ("ANSI C forbids `goto *expr;'");
1867 stmt_count++;
1868 emit_line_note ($<filename>-1, $<lineno>0);
1869 expand_computed_goto (convert (ptr_type_node, $3)); }
1870 | ';'
1873 all_iter_stmt:
1874 all_iter_stmt_simple
1875 /* | all_iter_stmt_with_decl */
1878 all_iter_stmt_simple:
1879 FOR '(' primary ')'
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 $<itype>$ = 0;
1886 if (TREE_CODE ($3) != VAR_DECL)
1887 error ("invalid `for (ITERATOR)' syntax");
1888 else if (! ITERATOR_P ($3))
1889 error ("`%s' is not an iterator",
1890 IDENTIFIER_POINTER (DECL_NAME ($3)));
1891 else if (ITERATOR_BOUND_P ($3))
1892 error ("`for (%s)' inside expansion of same iterator",
1893 IDENTIFIER_POINTER (DECL_NAME ($3)));
1894 else
1896 $<itype>$ = 1;
1897 iterator_for_loop_start ($3);
1900 lineno_labeled_stmt
1902 if ($<itype>5)
1903 iterator_for_loop_end ($3);
1906 /* This really should allow any kind of declaration,
1907 for generality. Fix it before turning it back on.
1909 all_iter_stmt_with_decl:
1910 FOR '(' ITERATOR pushlevel setspecs iterator_spec ')'
1912 */ /* The value returned by this action is */
1913 /* 1 if everything is OK */
1914 /* 0 in case of error or already bound iterator */
1916 iterator_for_loop_start ($6);
1918 lineno_labeled_stmt
1920 iterator_for_loop_end ($6);
1921 emit_line_note (input_filename, lineno);
1922 expand_end_bindings (getdecls (), 1, 0);
1923 $<ttype>$ = poplevel (1, 1, 0);
1927 /* Any kind of label, including jump labels and case labels.
1928 ANSI C accepts labels only before statements, but we allow them
1929 also at the end of a compound statement. */
1931 label: CASE expr_no_commas ':'
1932 { register tree value = check_case_value ($2);
1933 register tree label
1934 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
1936 stmt_count++;
1938 if (value != error_mark_node)
1940 tree duplicate;
1941 int success;
1943 if (pedantic && ! INTEGRAL_TYPE_P (TREE_TYPE (value)))
1944 pedwarn ("label must have integral type in ANSI C");
1946 success = pushcase (value, convert_and_check,
1947 label, &duplicate);
1949 if (success == 1)
1950 error ("case label not within a switch statement");
1951 else if (success == 2)
1953 error ("duplicate case value");
1954 error_with_decl (duplicate, "this is the first entry for that value");
1956 else if (success == 3)
1957 warning ("case value out of range");
1958 else if (success == 5)
1959 error ("case label within scope of cleanup or variable array");
1961 position_after_white_space (); }
1962 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
1963 { register tree value1 = check_case_value ($2);
1964 register tree value2 = check_case_value ($4);
1965 register tree label
1966 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
1968 if (pedantic)
1969 pedwarn ("ANSI C forbids case ranges");
1970 stmt_count++;
1972 if (value1 != error_mark_node && value2 != error_mark_node)
1974 tree duplicate;
1975 int success = pushcase_range (value1, value2,
1976 convert_and_check, label,
1977 &duplicate);
1978 if (success == 1)
1979 error ("case label not within a switch statement");
1980 else if (success == 2)
1982 error ("duplicate case value");
1983 error_with_decl (duplicate, "this is the first entry for that value");
1985 else if (success == 3)
1986 warning ("case value out of range");
1987 else if (success == 4)
1988 warning ("empty case range");
1989 else if (success == 5)
1990 error ("case label within scope of cleanup or variable array");
1992 position_after_white_space (); }
1993 | DEFAULT ':'
1995 tree duplicate;
1996 register tree label
1997 = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
1998 int success = pushcase (NULL_TREE, 0, label, &duplicate);
1999 stmt_count++;
2000 if (success == 1)
2001 error ("default label not within a switch statement");
2002 else if (success == 2)
2004 error ("multiple default labels in one switch");
2005 error_with_decl (duplicate, "this is the first default label");
2007 position_after_white_space (); }
2008 | identifier ':' maybe_attribute
2009 { tree label = define_label (input_filename, lineno, $1);
2010 stmt_count++;
2011 emit_nop ();
2012 if (label)
2014 expand_label (label);
2015 decl_attributes (label, $3, NULL_TREE);
2017 position_after_white_space (); }
2020 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
2022 maybe_type_qual:
2023 /* empty */
2024 { emit_line_note (input_filename, lineno);
2025 $$ = NULL_TREE; }
2026 | TYPE_QUAL
2027 { emit_line_note (input_filename, lineno); }
2030 xexpr:
2031 /* empty */
2032 { $$ = NULL_TREE; }
2033 | expr
2036 /* These are the operands other than the first string and colon
2037 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
2038 asm_operands: /* empty */
2039 { $$ = NULL_TREE; }
2040 | nonnull_asm_operands
2043 nonnull_asm_operands:
2044 asm_operand
2045 | nonnull_asm_operands ',' asm_operand
2046 { $$ = chainon ($1, $3); }
2049 asm_operand:
2050 STRING '(' expr ')'
2051 { $$ = build_tree_list ($1, $3); }
2054 asm_clobbers:
2055 string
2056 { $$ = tree_cons (NULL_TREE, combine_strings ($1), NULL_TREE); }
2057 | asm_clobbers ',' string
2058 { $$ = tree_cons (NULL_TREE, combine_strings ($3), $1); }
2061 /* This is what appears inside the parens in a function declarator.
2062 Its value is a list of ..._TYPE nodes. */
2063 parmlist:
2064 { pushlevel (0);
2065 clear_parm_order ();
2066 declare_parm_level (0); }
2067 parmlist_1
2068 { $$ = $2;
2069 parmlist_tags_warning ();
2070 poplevel (0, 0, 0); }
2073 parmlist_1:
2074 parmlist_2 ')'
2075 | parms ';'
2076 { tree parm;
2077 if (pedantic)
2078 pedwarn ("ANSI C forbids forward parameter declarations");
2079 /* Mark the forward decls as such. */
2080 for (parm = getdecls (); parm; parm = TREE_CHAIN (parm))
2081 TREE_ASM_WRITTEN (parm) = 1;
2082 clear_parm_order (); }
2083 parmlist_1
2084 { $$ = $4; }
2085 | error ')'
2086 { $$ = tree_cons (NULL_TREE, NULL_TREE, NULL_TREE); }
2089 /* This is what appears inside the parens in a function declarator.
2090 Is value is represented in the format that grokdeclarator expects. */
2091 parmlist_2: /* empty */
2092 { $$ = get_parm_info (0); }
2093 | ELLIPSIS
2094 { $$ = get_parm_info (0);
2095 /* Gcc used to allow this as an extension. However, it does
2096 not work for all targets, and thus has been disabled.
2097 Also, since func (...) and func () are indistinguishable,
2098 it caused problems with the code in expand_builtin which
2099 tries to verify that BUILT_IN_NEXT_ARG is being used
2100 correctly. */
2101 error ("ANSI C requires a named argument before `...'");
2103 | parms
2104 { $$ = get_parm_info (1); }
2105 | parms ',' ELLIPSIS
2106 { $$ = get_parm_info (0); }
2109 parms:
2110 parm
2111 { push_parm_decl ($1); }
2112 | parms ',' parm
2113 { push_parm_decl ($3); }
2116 /* A single parameter declaration or parameter type name,
2117 as found in a parmlist. */
2118 parm:
2119 typed_declspecs setspecs parm_declarator maybe_attribute
2120 { $$ = build_tree_list (build_tree_list (current_declspecs,
2121 $3),
2122 build_tree_list (prefix_attributes,
2123 $4));
2124 current_declspecs = TREE_VALUE (declspec_stack);
2125 prefix_attributes = TREE_PURPOSE (declspec_stack);
2126 declspec_stack = TREE_CHAIN (declspec_stack); }
2127 | typed_declspecs setspecs notype_declarator maybe_attribute
2128 { $$ = build_tree_list (build_tree_list (current_declspecs,
2129 $3),
2130 build_tree_list (prefix_attributes,
2131 $4));
2132 current_declspecs = TREE_VALUE (declspec_stack);
2133 prefix_attributes = TREE_PURPOSE (declspec_stack);
2134 declspec_stack = TREE_CHAIN (declspec_stack); }
2135 | typed_declspecs setspecs absdcl maybe_attribute
2136 { $$ = build_tree_list (build_tree_list (current_declspecs,
2137 $3),
2138 build_tree_list (prefix_attributes,
2139 $4));
2140 current_declspecs = TREE_VALUE (declspec_stack);
2141 prefix_attributes = TREE_PURPOSE (declspec_stack);
2142 declspec_stack = TREE_CHAIN (declspec_stack); }
2143 | declmods setspecs notype_declarator maybe_attribute
2144 { $$ = build_tree_list (build_tree_list (current_declspecs,
2145 $3),
2146 build_tree_list (prefix_attributes,
2147 $4));
2148 current_declspecs = TREE_VALUE (declspec_stack);
2149 prefix_attributes = TREE_PURPOSE (declspec_stack);
2150 declspec_stack = TREE_CHAIN (declspec_stack); }
2152 | declmods setspecs absdcl maybe_attribute
2153 { $$ = build_tree_list (build_tree_list (current_declspecs,
2154 $3),
2155 build_tree_list (prefix_attributes,
2156 $4));
2157 current_declspecs = TREE_VALUE (declspec_stack);
2158 prefix_attributes = TREE_PURPOSE (declspec_stack);
2159 declspec_stack = TREE_CHAIN (declspec_stack); }
2162 /* This is used in a function definition
2163 where either a parmlist or an identifier list is ok.
2164 Its value is a list of ..._TYPE nodes or a list of identifiers. */
2165 parmlist_or_identifiers:
2166 { pushlevel (0);
2167 clear_parm_order ();
2168 declare_parm_level (1); }
2169 parmlist_or_identifiers_1
2170 { $$ = $2;
2171 parmlist_tags_warning ();
2172 poplevel (0, 0, 0); }
2175 parmlist_or_identifiers_1:
2176 parmlist_1
2177 | identifiers ')'
2178 { tree t;
2179 for (t = $1; t; t = TREE_CHAIN (t))
2180 if (TREE_VALUE (t) == NULL_TREE)
2181 error ("`...' in old-style identifier list");
2182 $$ = tree_cons (NULL_TREE, NULL_TREE, $1); }
2185 /* A nonempty list of identifiers. */
2186 identifiers:
2187 IDENTIFIER
2188 { $$ = build_tree_list (NULL_TREE, $1); }
2189 | identifiers ',' IDENTIFIER
2190 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2193 /* A nonempty list of identifiers, including typenames. */
2194 identifiers_or_typenames:
2195 identifier
2196 { $$ = build_tree_list (NULL_TREE, $1); }
2197 | identifiers_or_typenames ',' identifier
2198 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2201 extension:
2202 EXTENSION
2203 { $$ = SAVE_WARN_FLAGS();
2204 pedantic = 0;
2205 warn_pointer_arith = 0; }