Annotation of gcc/c-parse.y, revision 1.1.1.6

1.1.1.4   root        1: /* YACC parser for C syntax and for Objective C.  -*-c-*-
1.1       root        2:    Copyright (C) 1987, 1988, 1989, 1992 Free Software Foundation, Inc.
                      3: 
                      4: This file is part of GNU CC.
                      5: 
                      6: GNU CC is free software; you can redistribute it and/or modify
                      7: it under the terms of the GNU General Public License as published by
                      8: the Free Software Foundation; either version 2, or (at your option)
                      9: any later version.
                     10: 
                     11: GNU CC is distributed in the hope that it will be useful,
                     12: but WITHOUT ANY WARRANTY; without even the implied warranty of
                     13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     14: GNU General Public License for more details.
                     15: 
                     16: You should have received a copy of the GNU General Public License
                     17: along with GNU CC; see the file COPYING.  If not, write to
                     18: the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
                     19: 
1.1.1.4   root       20: /* This file defines the grammar of C and that of Objective C.
                     21:    ifobjc ... end ifobjc  conditionals contain code for Objective C only.
                     22:    ifc ... end ifc  conditionals contain code for C only.
1.1.1.5   root       23:    Sed commands in Makefile.in are used to convert this file into
1.1.1.4   root       24:    c-parse.y and into objc-parse.y.  */
1.1       root       25: 
                     26: /* To whomever it may concern: I have heard that such a thing was once
                     27: written by AT&T, but I have never seen it.  */
                     28: 
                     29: %expect 8
                     30: 
                     31: /* These are the 8 conflicts you should get in parse.output;
                     32:    the state numbers may vary if minor changes in the grammar are made.
                     33: 
                     34: State 41 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
                     35: State 92 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
                     36: State 99 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
                     37: State 103 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
                     38: State 119 contains 1 shift/reduce conflict.  (See comment at component_decl.)
                     39: State 183 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
                     40: State 193 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
                     41: State 199 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
                     42: */
                     43: 
                     44: %{
                     45: #include <stdio.h>
                     46: #include <errno.h>
                     47: #include <setjmp.h>
                     48: 
                     49: #include "config.h"
                     50: #include "tree.h"
                     51: #include "input.h"
                     52: #include "c-lex.h"
                     53: #include "c-tree.h"
                     54: #include "flags.h"
                     55: 
                     56: #ifdef MULTIBYTE_CHARS
                     57: #include <stdlib.h>
                     58: #include <locale.h>
                     59: #endif
                     60: 
1.1.1.4   root       61: 
1.1.1.5   root       62: /* Since parsers are distinct for each language, put the language string
                     63:    definition here.  */
                     64: char *language_string = "GNU C";
                     65: 
1.1       root       66: #ifndef errno
                     67: extern int errno;
                     68: #endif
                     69: 
                     70: void yyerror ();
                     71: 
                     72: /* Like YYERROR but do call yyerror.  */
                     73: #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
                     74: 
                     75: /* Cause the `yydebug' variable to be defined.  */
                     76: #define YYDEBUG 1
                     77: %}
                     78: 
                     79: %start program
                     80: 
                     81: %union {long itype; tree ttype; enum tree_code code;
                     82:        char *filename; int lineno; }
                     83: 
                     84: /* All identifiers that are not reserved words
                     85:    and are not declared typedefs in the current block */
                     86: %token IDENTIFIER
                     87: 
                     88: /* All identifiers that are declared typedefs in the current block.
                     89:    In some contexts, they are treated just like IDENTIFIER,
                     90:    but they can also serve as typespecs in declarations.  */
                     91: %token TYPENAME
                     92: 
                     93: /* Reserved words that specify storage class.
                     94:    yylval contains an IDENTIFIER_NODE which indicates which one.  */
                     95: %token SCSPEC
                     96: 
                     97: /* Reserved words that specify type.
                     98:    yylval contains an IDENTIFIER_NODE which indicates which one.  */
                     99: %token TYPESPEC
                    100: 
                    101: /* Reserved words that qualify type: "const" or "volatile".
                    102:    yylval contains an IDENTIFIER_NODE which indicates which one.  */
                    103: %token TYPE_QUAL
                    104: 
                    105: /* Character or numeric constants.
                    106:    yylval is the node for the constant.  */
                    107: %token CONSTANT
                    108: 
                    109: /* String constants in raw form.
                    110:    yylval is a STRING_CST node.  */
                    111: %token STRING
                    112: 
                    113: /* "...", used for functions with variable arglists.  */
                    114: %token ELLIPSIS
                    115: 
                    116: /* the reserved words */
1.1.1.2   root      117: /* SCO include files test "ASM", so use something else. */
1.1       root      118: %token SIZEOF ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
1.1.1.2   root      119: %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD TYPEOF ALIGNOF ALIGN
1.1       root      120: %token ATTRIBUTE EXTENSION LABEL
1.1.1.5   root      121: %token REALPART IMAGPART
1.1       root      122: 
                    123: /* Add precedence rules to solve dangling else s/r conflict */
                    124: %nonassoc IF
                    125: %nonassoc ELSE
                    126: 
                    127: /* Define the operator tokens and their precedences.
                    128:    The value is an integer because, if used, it is the tree code
                    129:    to use in the expression made from the operator.  */
                    130: 
                    131: %right <code> ASSIGN '='
                    132: %right <code> '?' ':'
                    133: %left <code> OROR
                    134: %left <code> ANDAND
                    135: %left <code> '|'
                    136: %left <code> '^'
                    137: %left <code> '&'
                    138: %left <code> EQCOMPARE
                    139: %left <code> ARITHCOMPARE
                    140: %left <code> LSHIFT RSHIFT
                    141: %left <code> '+' '-'
                    142: %left <code> '*' '/' '%'
                    143: %right <code> UNARY PLUSPLUS MINUSMINUS
                    144: %left HYPERUNARY
                    145: %left <code> POINTSAT '.' '(' '['
                    146: 
1.1.1.4   root      147: /* The Objective-C keywords.  These are included in C and in
                    148:    Objective C, so that the token codes are the same in both.  */
1.1       root      149: %token INTERFACE IMPLEMENTATION END SELECTOR DEFS ENCODE
1.1.1.5   root      150: %token CLASSNAME PUBLIC PRIVATE PROTECTED PROTOCOL OBJECTNAME CLASS ALIAS
                    151: 
                    152: /* Objective-C string constants in raw form.
                    153:    yylval is an OBJC_STRING_CST node.  */
                    154: %token OBJC_STRING
1.1       root      155: 
                    156: 
                    157: %type <code> unop
                    158: 
                    159: %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist exprlist
                    160: %type <ttype> expr_no_commas cast_expr unary_expr primary string STRING
                    161: %type <ttype> typed_declspecs reserved_declspecs
                    162: %type <ttype> typed_typespecs reserved_typespecquals
                    163: %type <ttype> declmods typespec typespecqual_reserved
                    164: %type <ttype> SCSPEC TYPESPEC TYPE_QUAL nonempty_type_quals maybe_type_qual
                    165: %type <ttype> initdecls notype_initdecls initdcl notype_initdcl
1.1.1.6 ! root      166: %type <ttype> init maybeasm
1.1       root      167: %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
                    168: %type <ttype> maybe_attribute attribute_list attrib
                    169: 
                    170: %type <ttype> compstmt
                    171: 
                    172: %type <ttype> declarator
                    173: %type <ttype> notype_declarator after_type_declarator
                    174: %type <ttype> parm_declarator
                    175: 
                    176: %type <ttype> structsp component_decl_list component_decl_list2
                    177: %type <ttype> component_decl components component_declarator
                    178: %type <ttype> enumlist enumerator
                    179: %type <ttype> typename absdcl absdcl1 type_quals
                    180: %type <ttype> xexpr parms parm identifiers
                    181: 
                    182: %type <ttype> parmlist parmlist_1 parmlist_2
                    183: %type <ttype> parmlist_or_identifiers parmlist_or_identifiers_1
                    184: %type <ttype> identifiers_or_typenames
                    185: 
                    186: %type <itype> setspecs
                    187: 
                    188: %type <filename> save_filename
                    189: %type <lineno> save_lineno
                    190: 
1.1.1.4   root      191: 
1.1       root      192: %{
                    193: /* Number of statements (loosely speaking) seen so far.  */
                    194: static int stmt_count;
                    195: 
                    196: /* Input file and line number of the end of the body of last simple_if;
                    197:    used by the stmt-rule immediately after simple_if returns.  */
                    198: static char *if_stmt_file;
                    199: static int if_stmt_line;
                    200: 
                    201: /* List of types and structure classes of the current declaration.  */
                    202: static tree current_declspecs;
                    203: 
                    204: /* Stack of saved values of current_declspecs.  */
                    205: static tree declspec_stack;
                    206: 
                    207: /* 1 if we explained undeclared var errors.  */
                    208: static int undeclared_variable_notice;
                    209: 
1.1.1.4   root      210: 
1.1       root      211: /* Tell yyparse how to print a token's value, if yydebug is set.  */
                    212: 
                    213: #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
                    214: extern void yyprint ();
                    215: %}
                    216: 
                    217: %%
                    218: program: /* empty */
                    219:                { if (pedantic)
1.1.1.4   root      220:                    pedwarn ("ANSI C forbids an empty source file");
                    221:                }
1.1       root      222:        | extdefs
1.1.1.4   root      223:                {
1.1.1.5   root      224:                  /* In case there were missing closebraces,
                    225:                     get us back to the global binding level.  */
                    226:                  while (! global_bindings_p ())
                    227:                    poplevel (0, 0, 0);
1.1.1.4   root      228:                }
1.1       root      229:        ;
                    230: 
                    231: /* the reason for the strange actions in this rule
                    232:  is so that notype_initdecls when reached via datadef
                    233:  can find a valid list of type and sc specs in $0. */
                    234: 
                    235: extdefs:
                    236:        {$<ttype>$ = NULL_TREE; } extdef
                    237:        | extdefs {$<ttype>$ = NULL_TREE; } extdef
                    238:        ;
                    239: 
                    240: extdef:
                    241:        fndef
                    242:        | datadef
1.1.1.2   root      243:        | ASM_KEYWORD '(' expr ')' ';'
1.1       root      244:                { STRIP_NOPS ($3);
                    245:                  if ((TREE_CODE ($3) == ADDR_EXPR
                    246:                       && TREE_CODE (TREE_OPERAND ($3, 0)) == STRING_CST)
                    247:                      || TREE_CODE ($3) == STRING_CST)
                    248:                    assemble_asm ($3);
                    249:                  else
                    250:                    error ("argument of `asm' is not a constant string"); }
                    251:        ;
                    252: 
                    253: datadef:
                    254:          setspecs notype_initdecls ';'
                    255:                { if (pedantic)
                    256:                    error ("ANSI C forbids data definition with no type or storage class");
                    257:                  else if (!flag_traditional)
                    258:                    warning ("data definition has no type or storage class"); }
                    259:         | declmods setspecs notype_initdecls ';'
                    260:          {}
                    261:        | typed_declspecs setspecs initdecls ';'
                    262:          {}
                    263:         | declmods ';'
1.1.1.4   root      264:          { pedwarn ("empty declaration"); }
1.1       root      265:        | typed_declspecs ';'
                    266:          { shadow_tag ($1); }
                    267:        | error ';'
                    268:        | error '}'
                    269:        | ';'
                    270:                { if (pedantic)
                    271:                    pedwarn ("ANSI C does not allow extra `;' outside of a function"); }
                    272:        ;
                    273: 
                    274: fndef:
                    275:          typed_declspecs setspecs declarator
                    276:                { if (! start_function ($1, $3, 0))
                    277:                    YYERROR1;
                    278:                  reinit_parse_for_function (); }
                    279:          xdecls
                    280:                { store_parm_decls (); }
                    281:          compstmt_or_error
                    282:                { finish_function (0); }
                    283:        | typed_declspecs setspecs declarator error
                    284:                { }
                    285:        | declmods setspecs notype_declarator
                    286:                { if (! start_function ($1, $3, 0))
                    287:                    YYERROR1;
                    288:                  reinit_parse_for_function (); }
                    289:          xdecls
                    290:                { store_parm_decls (); }
                    291:          compstmt_or_error
                    292:                { finish_function (0); }
                    293:        | declmods setspecs notype_declarator error
                    294:                { }
                    295:        | setspecs notype_declarator
1.1.1.4   root      296:                { if (! start_function (NULL_TREE, $2, 0))
1.1       root      297:                    YYERROR1;
                    298:                  reinit_parse_for_function (); }
                    299:          xdecls
                    300:                { store_parm_decls (); }
                    301:          compstmt_or_error
                    302:                { finish_function (0); }
                    303:        | setspecs notype_declarator error
                    304:                { }
                    305:        ;
                    306: 
                    307: identifier:
                    308:        IDENTIFIER
                    309:        | TYPENAME
                    310:        ;
                    311: 
                    312: unop:     '&'
                    313:                { $$ = ADDR_EXPR; }
                    314:        | '-'
                    315:                { $$ = NEGATE_EXPR; }
                    316:        | '+'
                    317:                { $$ = CONVERT_EXPR; }
                    318:        | PLUSPLUS
                    319:                { $$ = PREINCREMENT_EXPR; }
                    320:        | MINUSMINUS
                    321:                { $$ = PREDECREMENT_EXPR; }
                    322:        | '~'
                    323:                { $$ = BIT_NOT_EXPR; }
                    324:        | '!'
                    325:                { $$ = TRUTH_NOT_EXPR; }
                    326:        ;
                    327: 
                    328: expr:  nonnull_exprlist
                    329:                { $$ = build_compound_expr ($1); }
                    330:        ;
                    331: 
                    332: exprlist:
                    333:          /* empty */
                    334:                { $$ = NULL_TREE; }
                    335:        | nonnull_exprlist
                    336:        ;
                    337: 
                    338: nonnull_exprlist:
                    339:        expr_no_commas
                    340:                { $$ = build_tree_list (NULL_TREE, $1); }
                    341:        | nonnull_exprlist ',' expr_no_commas
                    342:                { chainon ($1, build_tree_list (NULL_TREE, $3)); }
                    343:        ;
                    344: 
                    345: unary_expr:
                    346:        primary
                    347:        | '*' cast_expr   %prec UNARY
                    348:                { $$ = build_indirect_ref ($2, "unary *"); }
                    349:        /* __extension__ turns off -pedantic for following primary.  */
                    350:        | EXTENSION
                    351:                { $<itype>1 = pedantic;
                    352:                  pedantic = 0; }
                    353:          cast_expr       %prec UNARY
                    354:                { $$ = $3;
                    355:                  pedantic = $<itype>1; }
                    356:        | unop cast_expr  %prec UNARY
1.1.1.5   root      357:                { $$ = build_unary_op ($1, $2, 0);
                    358:                  overflow_warning ($$); }
1.1       root      359:        /* Refer to the address of a label as a pointer.  */
                    360:        | ANDAND identifier
                    361:                { tree label = lookup_label ($2);
1.1.1.5   root      362:                  if (label == 0)
                    363:                    $$ = null_pointer_node;
                    364:                  else
                    365:                    {
                    366:                      TREE_USED (label) = 1;
                    367:                      $$ = build1 (ADDR_EXPR, ptr_type_node, label);
                    368:                      TREE_CONSTANT ($$) = 1;
                    369:                    }
                    370:                }
1.1       root      371: /* This seems to be impossible on some machines, so let's turn it off.
1.1.1.3   root      372:    You can use __builtin_next_arg to find the anonymous stack args.
1.1       root      373:        | '&' ELLIPSIS
                    374:                { tree types = TYPE_ARG_TYPES (TREE_TYPE (current_function_decl));
                    375:                  $$ = error_mark_node;
                    376:                  if (TREE_VALUE (tree_last (types)) == void_type_node)
                    377:                    error ("`&...' used in function with fixed number of arguments");
                    378:                  else
                    379:                    {
                    380:                      if (pedantic)
                    381:                        pedwarn ("ANSI C forbids `&...'");
                    382:                      $$ = tree_last (DECL_ARGUMENTS (current_function_decl));
                    383:                      $$ = build_unary_op (ADDR_EXPR, $$, 0);
                    384:                    } }
                    385: */
                    386:        | SIZEOF unary_expr  %prec UNARY
                    387:                { if (TREE_CODE ($2) == COMPONENT_REF
                    388:                      && DECL_BIT_FIELD (TREE_OPERAND ($2, 1)))
                    389:                    error ("`sizeof' applied to a bit-field");
                    390:                  $$ = c_sizeof (TREE_TYPE ($2)); }
                    391:        | SIZEOF '(' typename ')'  %prec HYPERUNARY
                    392:                { $$ = c_sizeof (groktypename ($3)); }
                    393:        | ALIGNOF unary_expr  %prec UNARY
                    394:                { $$ = c_alignof_expr ($2); }
                    395:        | ALIGNOF '(' typename ')'  %prec HYPERUNARY
                    396:                { $$ = c_alignof (groktypename ($3)); }
1.1.1.5   root      397:        | REALPART cast_expr %prec UNARY
                    398:                { $$ = build_unary_op (REALPART_EXPR, $2, 0); }
                    399:        | IMAGPART cast_expr %prec UNARY
                    400:                { $$ = build_unary_op (IMAGPART_EXPR, $2, 0); }
1.1       root      401:        ;
                    402: 
                    403: cast_expr:
                    404:        unary_expr
                    405:        | '(' typename ')' cast_expr  %prec UNARY
                    406:                { tree type = groktypename ($2);
                    407:                  $$ = build_c_cast (type, $4); }
1.1.1.6 ! root      408:        | '(' typename ')' '{' 
        !           409:                { start_init (NULL_TREE, NULL, 0);
        !           410:                  $2 = groktypename ($2);
        !           411:                  really_start_incremental_init ($2); }
        !           412:          initlist_maybe_comma '}'  %prec UNARY
        !           413:                { char *name;
        !           414:                  tree result = pop_init_level (0);
        !           415:                  tree type = $2;
        !           416:                  finish_init ();
        !           417: 
1.1       root      418:                  if (pedantic)
                    419:                    pedwarn ("ANSI C forbids constructor expressions");
                    420:                  if (TYPE_NAME (type) != 0)
                    421:                    {
                    422:                      if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
                    423:                        name = IDENTIFIER_POINTER (TYPE_NAME (type));
                    424:                      else
                    425:                        name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
                    426:                    }
                    427:                  else
                    428:                    name = "";
1.1.1.6 ! root      429:                  $$ = result;
1.1       root      430:                  if (TREE_CODE (type) == ARRAY_TYPE && TYPE_SIZE (type) == 0)
                    431:                    {
                    432:                      int failure = complete_array_type (type, $$, 1);
                    433:                      if (failure)
                    434:                        abort ();
                    435:                    }
                    436:                }
                    437:        ;
                    438: 
                    439: expr_no_commas:
                    440:          cast_expr
                    441:        | expr_no_commas '+' expr_no_commas
                    442:                { $$ = parser_build_binary_op ($2, $1, $3); }
                    443:        | expr_no_commas '-' expr_no_commas
                    444:                { $$ = parser_build_binary_op ($2, $1, $3); }
                    445:        | expr_no_commas '*' expr_no_commas
                    446:                { $$ = parser_build_binary_op ($2, $1, $3); }
                    447:        | expr_no_commas '/' expr_no_commas
                    448:                { $$ = parser_build_binary_op ($2, $1, $3); }
                    449:        | expr_no_commas '%' expr_no_commas
                    450:                { $$ = parser_build_binary_op ($2, $1, $3); }
                    451:        | expr_no_commas LSHIFT expr_no_commas
                    452:                { $$ = parser_build_binary_op ($2, $1, $3); }
                    453:        | expr_no_commas RSHIFT expr_no_commas
                    454:                { $$ = parser_build_binary_op ($2, $1, $3); }
                    455:        | expr_no_commas ARITHCOMPARE expr_no_commas
                    456:                { $$ = parser_build_binary_op ($2, $1, $3); }
                    457:        | expr_no_commas EQCOMPARE expr_no_commas
                    458:                { $$ = parser_build_binary_op ($2, $1, $3); }
                    459:        | expr_no_commas '&' expr_no_commas
                    460:                { $$ = parser_build_binary_op ($2, $1, $3); }
                    461:        | expr_no_commas '|' expr_no_commas
                    462:                { $$ = parser_build_binary_op ($2, $1, $3); }
                    463:        | expr_no_commas '^' expr_no_commas
                    464:                { $$ = parser_build_binary_op ($2, $1, $3); }
                    465:        | expr_no_commas ANDAND expr_no_commas
                    466:                { $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $3); }
                    467:        | expr_no_commas OROR expr_no_commas
                    468:                { $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $3); }
                    469:        | expr_no_commas '?' xexpr ':' expr_no_commas
                    470:                { $$ = build_conditional_expr ($1, $3, $5); }
                    471:        | expr_no_commas '=' expr_no_commas
1.1.1.4   root      472:                { $$ = build_modify_expr ($1, NOP_EXPR, $3);
                    473:                  C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
1.1       root      474:        | expr_no_commas ASSIGN expr_no_commas
1.1.1.4   root      475:                { $$ = build_modify_expr ($1, $2, $3);
1.1.1.5   root      476:                  /* This inhibits warnings in truthvalue_conversion.  */
                    477:                  C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK); }
1.1       root      478:        ;
                    479: 
                    480: primary:
                    481:        IDENTIFIER
                    482:                {
                    483:                  tree context;
                    484: 
                    485:                  $$ = lastiddecl;
                    486:                  if (!$$ || $$ == error_mark_node)
                    487:                    {
                    488:                      if (yychar == YYEMPTY)
                    489:                        yychar = YYLEX;
                    490:                      if (yychar == '(')
                    491:                        {
1.1.1.4   root      492:                            {
                    493:                              /* Ordinary implicit function declaration.  */
                    494:                              $$ = implicitly_declare ($1);
                    495:                              assemble_external ($$);
                    496:                              TREE_USED ($$) = 1;
                    497:                            }
1.1       root      498:                        }
                    499:                      else if (current_function_decl == 0)
                    500:                        {
1.1.1.5   root      501:                          error ("`%s' undeclared here (not in a function)",
1.1       root      502:                                 IDENTIFIER_POINTER ($1));
                    503:                          $$ = error_mark_node;
                    504:                        }
                    505:                      else
                    506:                        {
                    507:                            {
1.1.1.4   root      508:                              if (IDENTIFIER_GLOBAL_VALUE ($1) != error_mark_node
                    509:                                  || IDENTIFIER_ERROR_LOCUS ($1) != current_function_decl)
1.1       root      510:                                {
1.1.1.4   root      511:                                  error ("`%s' undeclared (first use this function)",
                    512:                                         IDENTIFIER_POINTER ($1));
                    513: 
                    514:                                  if (! undeclared_variable_notice)
                    515:                                    {
                    516:                                      error ("(Each undeclared identifier is reported only once");
                    517:                                      error ("for each function it appears in.)");
                    518:                                      undeclared_variable_notice = 1;
                    519:                                    }
1.1       root      520:                                }
1.1.1.4   root      521:                              $$ = error_mark_node;
                    522:                              /* Prevent repeated error messages.  */
                    523:                              IDENTIFIER_GLOBAL_VALUE ($1) = error_mark_node;
                    524:                              IDENTIFIER_ERROR_LOCUS ($1) = current_function_decl;
1.1       root      525:                            }
                    526:                        }
                    527:                    }
                    528:                  else if (TREE_TYPE ($$) == error_mark_node)
                    529:                    $$ = error_mark_node;
1.1.1.4   root      530:                  else if (C_DECL_ANTICIPATED ($$))
                    531:                    {
                    532:                      /* The first time we see a build-in function used,
                    533:                         if it has not been declared.  */
                    534:                      C_DECL_ANTICIPATED ($$) = 0;
                    535:                      if (yychar == YYEMPTY)
                    536:                        yychar = YYLEX;
                    537:                      if (yychar == '(')
                    538:                        {
                    539:                          /* Omit the implicit declaration we
                    540:                             would ordinarily do, so we don't lose
                    541:                             the actual built in type.
                    542:                             But print a diagnostic for the mismatch.  */
                    543:                            if (TREE_CODE ($$) != FUNCTION_DECL)
                    544:                              error ("`%s' implicitly declared as function",
                    545:                                     IDENTIFIER_POINTER (DECL_NAME ($$)));
                    546:                          else if ((TYPE_MODE (TREE_TYPE (TREE_TYPE ($$)))
                    547:                                    != TYPE_MODE (integer_type_node))
                    548:                                   && (TREE_TYPE (TREE_TYPE ($$))
                    549:                                       != void_type_node))
                    550:                            pedwarn ("type mismatch in implicit declaration for built-in function `%s'",
                    551:                                     IDENTIFIER_POINTER (DECL_NAME ($$)));
                    552:                          /* If it really returns void, change that to int.  */
                    553:                          if (TREE_TYPE (TREE_TYPE ($$)) == void_type_node)
                    554:                            TREE_TYPE ($$)
                    555:                              = build_function_type (integer_type_node,
                    556:                                                     TYPE_ARG_TYPES (TREE_TYPE ($$)));
                    557:                        }
                    558:                      else
                    559:                        pedwarn ("built-in function `%s' used without declaration",
                    560:                                 IDENTIFIER_POINTER (DECL_NAME ($$)));
                    561: 
                    562:                      /* Do what we would ordinarily do when a fn is used.  */
                    563:                      assemble_external ($$);
                    564:                      TREE_USED ($$) = 1;
                    565:                    }
1.1.1.2   root      566:                  else
1.1       root      567:                    {
1.1.1.2   root      568:                      assemble_external ($$);
1.1       root      569:                      TREE_USED ($$) = 1;
                    570:                    }
1.1.1.4   root      571: 
1.1       root      572:                  if (TREE_CODE ($$) == CONST_DECL)
1.1.1.4   root      573:                    {
                    574:                      $$ = DECL_INITIAL ($$);
                    575:                      /* This is to prevent an enum whose value is 0
                    576:                         from being considered a null pointer constant.  */
                    577:                      $$ = build1 (NOP_EXPR, TREE_TYPE ($$), $$);
                    578:                      TREE_CONSTANT ($$) = 1;
                    579:                    }
1.1       root      580:                }
                    581:        | CONSTANT
                    582:        | string
                    583:                { $$ = combine_strings ($1); }
                    584:        | '(' expr ')'
                    585:                { char class = TREE_CODE_CLASS (TREE_CODE ($2));
                    586:                  if (class == 'e' || class == '1'
                    587:                      || class == '2' || class == '<')
                    588:                    C_SET_EXP_ORIGINAL_CODE ($2, ERROR_MARK);
                    589:                  $$ = $2; }
                    590:        | '(' error ')'
                    591:                { $$ = error_mark_node; }
                    592:        | '('
                    593:                { if (current_function_decl == 0)
                    594:                    {
                    595:                      error ("braced-group within expression allowed only inside a function");
                    596:                      YYERROR;
                    597:                    }
                    598:                  /* We must force a BLOCK for this level
                    599:                     so that, if it is not expanded later,
                    600:                     there is a way to turn off the entire subtree of blocks
                    601:                     that are contained in it.  */
                    602:                  keep_next_level ();
1.1.1.5   root      603:                  push_iterator_stack ();
1.1       root      604:                  push_label_level ();
                    605:                  $<ttype>$ = expand_start_stmt_expr (); }
                    606:          compstmt ')'
                    607:                { tree rtl_exp;
                    608:                  if (pedantic)
                    609:                    pedwarn ("ANSI C forbids braced-groups within expressions");
1.1.1.5   root      610:                  pop_iterator_stack ();
1.1       root      611:                  pop_label_level ();
                    612:                  rtl_exp = expand_end_stmt_expr ($<ttype>2);
                    613:                  /* The statements have side effects, so the group does.  */
                    614:                  TREE_SIDE_EFFECTS (rtl_exp) = 1;
                    615: 
1.1.1.6 ! root      616:                  if (TREE_CODE ($3) == BLOCK)
        !           617:                    {
        !           618:                      /* Make a BIND_EXPR for the BLOCK already made.  */
        !           619:                      $$ = build (BIND_EXPR, TREE_TYPE (rtl_exp),
        !           620:                                  NULL_TREE, rtl_exp, $3);
        !           621:                      /* Remove the block from the tree at this point.
        !           622:                         It gets put back at the proper place
        !           623:                         when the BIND_EXPR is expanded.  */
        !           624:                      delete_block ($3);
        !           625:                    }
        !           626:                  else
        !           627:                    $$ = $3;
1.1       root      628:                }
                    629:        | primary '(' exprlist ')'   %prec '.'
                    630:                { $$ = build_function_call ($1, $3); }
                    631:        | primary '[' expr ']'   %prec '.'
                    632:                { $$ = build_array_ref ($1, $3); }
                    633:        | primary '.' identifier
1.1.1.4   root      634:                {
                    635:                    $$ = build_component_ref ($1, $3);
                    636:                }
1.1       root      637:        | primary POINTSAT identifier
1.1.1.4   root      638:                {
                    639:                   tree expr = build_indirect_ref ($1, "->");
                    640: 
                    641:                     $$ = build_component_ref (expr, $3);
                    642:                }
1.1       root      643:        | primary PLUSPLUS
                    644:                { $$ = build_unary_op (POSTINCREMENT_EXPR, $1, 0); }
                    645:        | primary MINUSMINUS
                    646:                { $$ = build_unary_op (POSTDECREMENT_EXPR, $1, 0); }
                    647:        ;
                    648: 
                    649: /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it.  */
                    650: string:
                    651:          STRING
                    652:        | string STRING
                    653:                { $$ = chainon ($1, $2); }
                    654:        ;
                    655: 
1.1.1.5   root      656: 
1.1       root      657: xdecls:
                    658:        /* empty */
                    659:        | datadecls
                    660:        | datadecls ELLIPSIS
                    661:                /* ... is used here to indicate a varargs function.  */
                    662:                { c_mark_varargs ();
                    663:                  if (pedantic)
                    664:                    pedwarn ("ANSI C does not permit use of `varargs.h'"); }
                    665:        ;
                    666: 
                    667: /* The following are analogous to lineno_decl, decls and decl
                    668:    except that they do not allow nested functions.
                    669:    They are used for old-style parm decls.  */
                    670: lineno_datadecl:
                    671:          save_filename save_lineno datadecl
                    672:                { }
                    673:        ;
                    674: 
                    675: datadecls:
                    676:        lineno_datadecl
                    677:        | errstmt
                    678:        | datadecls lineno_datadecl
                    679:        | lineno_datadecl errstmt
                    680:        ;
                    681: 
                    682: datadecl:
                    683:        typed_declspecs setspecs initdecls ';'
                    684:                { current_declspecs = TREE_VALUE (declspec_stack);
                    685:                  declspec_stack = TREE_CHAIN (declspec_stack);
                    686:                  resume_momentary ($2); }
                    687:        | declmods setspecs notype_initdecls ';'
                    688:                { current_declspecs = TREE_VALUE (declspec_stack);
                    689:                  declspec_stack = TREE_CHAIN (declspec_stack);
                    690:                  resume_momentary ($2); }
                    691:        | typed_declspecs ';'
1.1.1.4   root      692:                { shadow_tag_warned ($1, 1);
                    693:                  pedwarn ("empty declaration"); }
1.1       root      694:        | declmods ';'
                    695:                { pedwarn ("empty declaration"); }
                    696:        ;
                    697: 
                    698: /* This combination which saves a lineno before a decl
                    699:    is the normal thing to use, rather than decl itself.
                    700:    This is to avoid shift/reduce conflicts in contexts
                    701:    where statement labels are allowed.  */
                    702: lineno_decl:
                    703:          save_filename save_lineno decl
                    704:                { }
                    705:        ;
                    706: 
                    707: decls:
                    708:        lineno_decl
                    709:        | errstmt
                    710:        | decls lineno_decl
                    711:        | lineno_decl errstmt
                    712:        ;
                    713: 
                    714: /* records the type and storage class specs to use for processing
                    715:    the declarators that follow.
                    716:    Maintains a stack of outer-level values of current_declspecs,
                    717:    for the sake of parm declarations nested in function declarators.  */
                    718: setspecs: /* empty */
                    719:                { $$ = suspend_momentary ();
                    720:                  pending_xref_error ();
1.1.1.4   root      721:                  declspec_stack = tree_cons (NULL_TREE, current_declspecs,
1.1       root      722:                                              declspec_stack);
                    723:                  current_declspecs = $<ttype>0; }
                    724:        ;
                    725: 
                    726: decl:
                    727:        typed_declspecs setspecs initdecls ';'
                    728:                { current_declspecs = TREE_VALUE (declspec_stack);
                    729:                  declspec_stack = TREE_CHAIN (declspec_stack);
                    730:                  resume_momentary ($2); }
                    731:        | declmods setspecs notype_initdecls ';'
                    732:                { current_declspecs = TREE_VALUE (declspec_stack);
                    733:                  declspec_stack = TREE_CHAIN (declspec_stack);
                    734:                  resume_momentary ($2); }
                    735:        | typed_declspecs setspecs nested_function
                    736:                { current_declspecs = TREE_VALUE (declspec_stack);
                    737:                  declspec_stack = TREE_CHAIN (declspec_stack);
                    738:                  resume_momentary ($2); }
                    739:        | declmods setspecs notype_nested_function
                    740:                { current_declspecs = TREE_VALUE (declspec_stack);
                    741:                  declspec_stack = TREE_CHAIN (declspec_stack);
                    742:                  resume_momentary ($2); }
                    743:        | typed_declspecs ';'
                    744:                { shadow_tag ($1); }
                    745:        | declmods ';'
                    746:                { pedwarn ("empty declaration"); }
                    747:        ;
                    748: 
                    749: /* Declspecs which contain at least one type specifier or typedef name.
                    750:    (Just `const' or `volatile' is not enough.)
                    751:    A typedef'd name following these is taken as a name to be declared.  */
                    752: 
                    753: typed_declspecs:
                    754:          typespec reserved_declspecs
                    755:                { $$ = tree_cons (NULL_TREE, $1, $2); }
                    756:        | declmods typespec reserved_declspecs
                    757:                { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
                    758:        ;
                    759: 
                    760: reserved_declspecs:  /* empty */
                    761:                { $$ = NULL_TREE; }
                    762:        | reserved_declspecs typespecqual_reserved
                    763:                { $$ = tree_cons (NULL_TREE, $2, $1); }
                    764:        | reserved_declspecs SCSPEC
1.1.1.4   root      765:                { if (extra_warnings)
                    766:                    warning ("`%s' is not at beginning of declaration",
                    767:                             IDENTIFIER_POINTER ($2));
                    768:                  $$ = tree_cons (NULL_TREE, $2, $1); }
1.1       root      769:        ;
                    770: 
                    771: /* List of just storage classes and type modifiers.
                    772:    A declaration can start with just this, but then it cannot be used
                    773:    to redeclare a typedef-name.  */
                    774: 
                    775: declmods:
                    776:          TYPE_QUAL
1.1.1.4   root      777:                { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
                    778:                  TREE_STATIC ($$) = 1; }
1.1       root      779:        | SCSPEC
                    780:                { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
                    781:        | declmods TYPE_QUAL
1.1.1.4   root      782:                { $$ = tree_cons (NULL_TREE, $2, $1);
                    783:                  TREE_STATIC ($$) = 1; }
1.1       root      784:        | declmods SCSPEC
1.1.1.4   root      785:                { if (extra_warnings && TREE_STATIC ($1))
                    786:                    warning ("`%s' is not at beginning of declaration",
                    787:                             IDENTIFIER_POINTER ($2));
                    788:                  $$ = tree_cons (NULL_TREE, $2, $1);
                    789:                  TREE_STATIC ($$) = TREE_STATIC ($1); }
1.1       root      790:        ;
                    791: 
                    792: 
                    793: /* Used instead of declspecs where storage classes are not allowed
                    794:    (that is, for typenames and structure components).
                    795:    Don't accept a typedef-name if anything but a modifier precedes it.  */
                    796: 
                    797: typed_typespecs:
                    798:          typespec reserved_typespecquals
                    799:                { $$ = tree_cons (NULL_TREE, $1, $2); }
                    800:        | nonempty_type_quals typespec reserved_typespecquals
                    801:                { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
                    802:        ;
                    803: 
                    804: reserved_typespecquals:  /* empty */
                    805:                { $$ = NULL_TREE; }
                    806:        | reserved_typespecquals typespecqual_reserved
                    807:                { $$ = tree_cons (NULL_TREE, $2, $1); }
                    808:        ;
                    809: 
                    810: /* A typespec (but not a type qualifier).
                    811:    Once we have seen one of these in a declaration,
                    812:    if a typedef name appears then it is being redeclared.  */
                    813: 
                    814: typespec: TYPESPEC
                    815:        | structsp
                    816:        | TYPENAME
                    817:                { /* For a typedef name, record the meaning, not the name.
                    818:                     In case of `foo foo, bar;'.  */
                    819:                  $$ = lookup_name ($1); }
                    820:        | TYPEOF '(' expr ')'
1.1.1.4   root      821:                { $$ = TREE_TYPE ($3); }
1.1       root      822:        | TYPEOF '(' typename ')'
1.1.1.4   root      823:                { $$ = groktypename ($3); }
1.1       root      824:        ;
                    825: 
                    826: /* A typespec that is a reserved word, or a type qualifier.  */
                    827: 
                    828: typespecqual_reserved: TYPESPEC
                    829:        | TYPE_QUAL
                    830:        | structsp
                    831:        ;
                    832: 
                    833: initdecls:
                    834:        initdcl
                    835:        | initdecls ',' initdcl
                    836:        ;
                    837: 
                    838: notype_initdecls:
                    839:        notype_initdcl
                    840:        | notype_initdecls ',' initdcl
                    841:        ;
                    842: 
                    843: maybeasm:
                    844:          /* empty */
                    845:                { $$ = NULL_TREE; }
1.1.1.2   root      846:        | ASM_KEYWORD '(' string ')'
1.1       root      847:                { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
                    848:                  $$ = $3;
                    849:                }
                    850:        ;
                    851: 
                    852: initdcl:
                    853:          declarator maybeasm maybe_attribute '='
1.1.1.6 ! root      854:                { $<ttype>$ = start_decl ($1, current_declspecs, 1);
        !           855:                  decl_attributes ($<ttype>$, $3);
        !           856:                  start_init ($<ttype>$, $2, global_bindings_p ()); }
1.1       root      857:          init
                    858: /* Note how the declaration of the variable is in effect while its init is parsed! */
1.1.1.6 ! root      859:                { finish_init ();
        !           860:                  decl_attributes ($<ttype>5, $3);
1.1       root      861:                  finish_decl ($<ttype>5, $6, $2); }
                    862:        | declarator maybeasm maybe_attribute
                    863:                { tree d = start_decl ($1, current_declspecs, 0);
                    864:                  decl_attributes (d, $3);
                    865:                  finish_decl (d, NULL_TREE, $2); }
                    866:        ;
                    867: 
                    868: notype_initdcl:
                    869:          notype_declarator maybeasm maybe_attribute '='
1.1.1.6 ! root      870:                { $<ttype>$ = start_decl ($1, current_declspecs, 1);
        !           871:                  decl_attributes ($<ttype>$, $3);
        !           872:                  start_init ($<ttype>$, $2, global_bindings_p ()); }
1.1       root      873:          init
                    874: /* Note how the declaration of the variable is in effect while its init is parsed! */
1.1.1.6 ! root      875:                { finish_init ();
        !           876:                  decl_attributes ($<ttype>5, $3);
1.1       root      877:                  finish_decl ($<ttype>5, $6, $2); }
                    878:        | notype_declarator maybeasm maybe_attribute
                    879:                { tree d = start_decl ($1, current_declspecs, 0);
                    880:                  decl_attributes (d, $3);
                    881:                  finish_decl (d, NULL_TREE, $2); }
                    882:        ;
                    883: /* the * rules are dummies to accept the Apollo extended syntax
                    884:    so that the header files compile. */
                    885: maybe_attribute:
                    886:     /* empty */
                    887:                { $$ = NULL_TREE; }
                    888:     | ATTRIBUTE '(' '(' attribute_list ')' ')'
                    889:                { $$ = $4; }
                    890:     ;
                    891: 
                    892: attribute_list
                    893:     : attrib
                    894:        { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
                    895:     | attribute_list ',' attrib
                    896:        { $$ = tree_cons (NULL_TREE, $3, $1); }
                    897:     ;
                    898: 
                    899: attrib
                    900:     : IDENTIFIER
1.1.1.6 ! root      901:        { if (strcmp (IDENTIFIER_POINTER ($1), "packed")
        !           902:              && strcmp (IDENTIFIER_POINTER ($1), "noreturn"))
1.1       root      903:            warning ("`%s' attribute directive ignored",
                    904:                     IDENTIFIER_POINTER ($1));
                    905:          $$ = $1; }
1.1.1.6 ! root      906:     | TYPE_QUAL
1.1.1.3   root      907:     | IDENTIFIER '(' IDENTIFIER ')'
                    908:        { /* If not "mode (m)", then issue warning.  */
                    909:          if (strcmp (IDENTIFIER_POINTER ($1), "mode") != 0)
                    910:            {
                    911:              warning ("`%s' attribute directive ignored",
                    912:                       IDENTIFIER_POINTER ($1));
                    913:              $$ = $1;
                    914:            }
                    915:          else
1.1.1.4   root      916:            $$ = tree_cons ($1, $3, NULL_TREE); }
1.1       root      917:     | IDENTIFIER '(' CONSTANT ')'
                    918:        { /* if not "aligned(n)", then issue warning */
                    919:          if (strcmp (IDENTIFIER_POINTER ($1), "aligned") != 0
                    920:              || TREE_CODE ($3) != INTEGER_CST)
                    921:            {
                    922:              warning ("`%s' attribute directive ignored",
                    923:                       IDENTIFIER_POINTER ($1));
                    924:              $$ = $1;
                    925:            }
                    926:          else
1.1.1.4   root      927:            $$ = tree_cons ($1, $3, NULL_TREE); }
1.1       root      928:     | IDENTIFIER '(' IDENTIFIER ',' CONSTANT ',' CONSTANT ')'
                    929:        { /* if not "format(...)", then issue warning */
                    930:          if (strcmp (IDENTIFIER_POINTER ($1), "format") != 0
                    931:              || TREE_CODE ($5) != INTEGER_CST
                    932:              || TREE_CODE ($7) != INTEGER_CST)
                    933:            {
                    934:              warning ("`%s' attribute directive ignored",
                    935:                       IDENTIFIER_POINTER ($1));
                    936:              $$ = $1;
                    937:            }
                    938:          else
1.1.1.4   root      939:            $$ = tree_cons ($1,
                    940:                            tree_cons ($3,
                    941:                                       tree_cons ($5, $7, NULL_TREE),
                    942:                                       NULL_TREE),
                    943:                            NULL_TREE); }
1.1       root      944:     ;
1.1.1.6 ! root      945: 
        !           946: /* Initializers.  `init' is the entry point.  */
1.1       root      947: 
                    948: init:
                    949:        expr_no_commas
1.1.1.6 ! root      950:        | '{'
        !           951:                { really_start_incremental_init (NULL_TREE);
        !           952:                  /* Note that the call to clear_momentary
        !           953:                     is in process_init_element.  */
        !           954:                  push_momentary (); }
        !           955:          initlist_maybe_comma '}'
        !           956:                { $$ = pop_init_level (0);
        !           957:                  if ($$ == error_mark_node)
        !           958:                    pop_momentary ();
        !           959:                  else
        !           960:                    pop_momentary_nofree (); }
        !           961: 
1.1       root      962:        | error
1.1.1.6 ! root      963:                { $$ = error_mark_node; }
1.1       root      964:        ;
                    965: 
1.1.1.6 ! root      966: /* `initlist_maybe_comma' is the guts of an initializer in braces.  */
        !           967: initlist_maybe_comma:
        !           968:          /* empty */
        !           969:                { if (pedantic)
        !           970:                    pedwarn ("ANSI C forbids empty initializer braces"); }
        !           971:        | initlist1 maybecomma
        !           972:        ;
        !           973: 
        !           974: initlist1:
        !           975:          initelt
        !           976:        | initlist1 ',' initelt
        !           977:        ;
        !           978: 
        !           979: /* `initelt' is a single element of an initializer.
        !           980:    It may use braces.  */
        !           981: initelt:
        !           982:        expr_no_commas
        !           983:                { process_init_element ($1); }
        !           984:        | '{' 
        !           985:                { push_init_level (0); }
        !           986:          initlist_maybe_comma '}'
        !           987:                { process_init_element (pop_init_level (0)); }
        !           988:        | error
1.1.1.5   root      989:        /* These are for labeled elements.  The syntax for an array element
                    990:           initializer conflicts with the syntax for an Objective-C message,
                    991:           so don't include these productions in the Objective-C grammer.  */
1.1.1.6 ! root      992:        | '[' expr_no_commas ELLIPSIS expr_no_commas ']' '='
        !           993:                { set_init_index ($2, $4); }
        !           994:          initelt
        !           995:        | '[' expr_no_commas ']' '='
        !           996:                { set_init_index ($2, NULL_TREE); }
        !           997:          initelt
        !           998:        | identifier ':'
        !           999:                { set_init_label ($1); }
        !          1000:          initelt
        !          1001:        | '.' identifier '='
        !          1002:                { set_init_label ($2); }
        !          1003:          initelt
1.1       root     1004:        ;
1.1.1.6 ! root     1005: 
1.1       root     1006: nested_function:
                   1007:          declarator
                   1008:                { push_c_function_context ();
                   1009:                  if (! start_function (current_declspecs, $1, 1))
                   1010:                    {
                   1011:                      pop_c_function_context ();
                   1012:                      YYERROR1;
                   1013:                    }
                   1014:                  reinit_parse_for_function ();
                   1015:                  store_parm_decls (); }
                   1016: /* This used to use compstmt_or_error.
                   1017:    That caused a bug with input `f(g) int g {}',
                   1018:    where the use of YYERROR1 above caused an error
                   1019:    which then was handled by compstmt_or_error.
                   1020:    There followed a repeated execution of that same rule,
                   1021:    which called YYERROR1 again, and so on.  */
                   1022:          compstmt
                   1023:                { finish_function (1);
                   1024:                  pop_c_function_context (); }
                   1025:        ;
                   1026: 
                   1027: notype_nested_function:
                   1028:          notype_declarator
                   1029:                { push_c_function_context ();
                   1030:                  if (! start_function (current_declspecs, $1, 1))
                   1031:                    {
                   1032:                      pop_c_function_context ();
                   1033:                      YYERROR1;
                   1034:                    }
                   1035:                  reinit_parse_for_function ();
                   1036:                  store_parm_decls (); }
                   1037: /* This used to use compstmt_or_error.
                   1038:    That caused a bug with input `f(g) int g {}',
                   1039:    where the use of YYERROR1 above caused an error
                   1040:    which then was handled by compstmt_or_error.
                   1041:    There followed a repeated execution of that same rule,
                   1042:    which called YYERROR1 again, and so on.  */
                   1043:          compstmt
                   1044:                { finish_function (1);
                   1045:                  pop_c_function_context (); }
                   1046:        ;
                   1047: 
                   1048: /* Any kind of declarator (thus, all declarators allowed
                   1049:    after an explicit typespec).  */
                   1050: 
                   1051: declarator:
                   1052:          after_type_declarator
                   1053:        | notype_declarator
                   1054:        ;
                   1055: 
                   1056: /* A declarator that is allowed only after an explicit typespec.  */
                   1057: 
                   1058: after_type_declarator:
                   1059:          '(' after_type_declarator ')'
                   1060:                { $$ = $2; }
                   1061:        | after_type_declarator '(' parmlist_or_identifiers  %prec '.'
                   1062:                { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
                   1063: /*     | after_type_declarator '(' error ')'  %prec '.'
                   1064:                { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
                   1065:                  poplevel (0, 0, 0); }  */
                   1066:        | after_type_declarator '[' expr ']'  %prec '.'
                   1067:                { $$ = build_nt (ARRAY_REF, $1, $3); }
                   1068:        | after_type_declarator '[' ']'  %prec '.'
                   1069:                { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
                   1070:        | '*' type_quals after_type_declarator  %prec UNARY
                   1071:                { $$ = make_pointer_declarator ($2, $3); }
                   1072:        | TYPENAME
                   1073:        ;
                   1074: 
                   1075: /* Kinds of declarator that can appear in a parameter list
                   1076:    in addition to notype_declarator.  This is like after_type_declarator
                   1077:    but does not allow a typedef name in parentheses as an identifier
                   1078:    (because it would conflict with a function with that typedef as arg).  */
                   1079: 
                   1080: parm_declarator:
                   1081:          parm_declarator '(' parmlist_or_identifiers  %prec '.'
                   1082:                { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
                   1083: /*     | parm_declarator '(' error ')'  %prec '.'
                   1084:                { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
                   1085:                  poplevel (0, 0, 0); }  */
                   1086:        | parm_declarator '[' expr ']'  %prec '.'
                   1087:                { $$ = build_nt (ARRAY_REF, $1, $3); }
                   1088:        | parm_declarator '[' ']'  %prec '.'
                   1089:                { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
                   1090:        | '*' type_quals parm_declarator  %prec UNARY
                   1091:                { $$ = make_pointer_declarator ($2, $3); }
                   1092:        | TYPENAME
                   1093:        ;
                   1094: 
                   1095: /* A declarator allowed whether or not there has been
                   1096:    an explicit typespec.  These cannot redeclare a typedef-name.  */
                   1097: 
                   1098: notype_declarator:
                   1099:          notype_declarator '(' parmlist_or_identifiers  %prec '.'
                   1100:                { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
                   1101: /*     | notype_declarator '(' error ')'  %prec '.'
                   1102:                { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
                   1103:                  poplevel (0, 0, 0); }  */
                   1104:        | '(' notype_declarator ')'
                   1105:                { $$ = $2; }
                   1106:        | '*' type_quals notype_declarator  %prec UNARY
                   1107:                { $$ = make_pointer_declarator ($2, $3); }
                   1108:        | notype_declarator '[' expr ']'  %prec '.'
                   1109:                { $$ = build_nt (ARRAY_REF, $1, $3); }
                   1110:        | notype_declarator '[' ']'  %prec '.'
                   1111:                { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
                   1112:        | IDENTIFIER
                   1113:        ;
                   1114: 
                   1115: structsp:
                   1116:          STRUCT identifier '{'
                   1117:                { $$ = start_struct (RECORD_TYPE, $2);
                   1118:                  /* Start scope of tag before parsing components.  */
                   1119:                }
                   1120:          component_decl_list '}'
                   1121:                { $$ = finish_struct ($<ttype>4, $5);
                   1122:                  /* Really define the structure.  */
                   1123:                }
                   1124:        | STRUCT '{' component_decl_list '}'
                   1125:                { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
                   1126:                                      $3); }
                   1127:        | STRUCT identifier
                   1128:                { $$ = xref_tag (RECORD_TYPE, $2); }
                   1129:        | UNION identifier '{'
                   1130:                { $$ = start_struct (UNION_TYPE, $2); }
                   1131:          component_decl_list '}'
                   1132:                { $$ = finish_struct ($<ttype>4, $5); }
                   1133:        | UNION '{' component_decl_list '}'
                   1134:                { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
                   1135:                                      $3); }
                   1136:        | UNION identifier
                   1137:                { $$ = xref_tag (UNION_TYPE, $2); }
                   1138:        | ENUM identifier '{'
                   1139:                { $<itype>3 = suspend_momentary ();
                   1140:                  $$ = start_enum ($2); }
                   1141:          enumlist maybecomma_warn '}'
                   1142:                { $$ = finish_enum ($<ttype>4, nreverse ($5));
                   1143:                  resume_momentary ($<itype>3); }
                   1144:        | ENUM '{'
                   1145:                { $<itype>2 = suspend_momentary ();
                   1146:                  $$ = start_enum (NULL_TREE); }
                   1147:          enumlist maybecomma_warn '}'
                   1148:                { $$ = finish_enum ($<ttype>3, nreverse ($4));
                   1149:                  resume_momentary ($<itype>2); }
                   1150:        | ENUM identifier
                   1151:                { $$ = xref_tag (ENUMERAL_TYPE, $2); }
                   1152:        ;
                   1153: 
                   1154: maybecomma:
                   1155:          /* empty */
                   1156:        | ','
                   1157:        ;
                   1158: 
                   1159: maybecomma_warn:
                   1160:          /* empty */
                   1161:        | ','
                   1162:                { if (pedantic) pedwarn ("comma at end of enumerator list"); }
                   1163:        ;
                   1164: 
                   1165: component_decl_list:
                   1166:          component_decl_list2
                   1167:                { $$ = $1; }
                   1168:        | component_decl_list2 component_decl
                   1169:                { $$ = chainon ($1, $2);
1.1.1.4   root     1170:                  pedwarn ("no semicolon at end of struct or union"); }
1.1       root     1171:        ;
                   1172: 
                   1173: component_decl_list2:  /* empty */
                   1174:                { $$ = NULL_TREE; }
                   1175:        | component_decl_list2 component_decl ';'
                   1176:                { $$ = chainon ($1, $2); }
                   1177:        | component_decl_list2 ';'
                   1178:                { if (pedantic)
                   1179:                    pedwarn ("extra semicolon in struct or union specified"); }
                   1180:        ;
                   1181: 
                   1182: /* There is a shift-reduce conflict here, because `components' may
                   1183:    start with a `typename'.  It happens that shifting (the default resolution)
                   1184:    does the right thing, because it treats the `typename' as part of
                   1185:    a `typed_typespecs'.
                   1186: 
                   1187:    It is possible that this same technique would allow the distinction
                   1188:    between `notype_initdecls' and `initdecls' to be eliminated.
                   1189:    But I am being cautious and not trying it.  */
                   1190: 
                   1191: component_decl:
                   1192:          typed_typespecs setspecs components
                   1193:                { $$ = $3;
                   1194:                  current_declspecs = TREE_VALUE (declspec_stack);
                   1195:                  declspec_stack = TREE_CHAIN (declspec_stack);
                   1196:                  resume_momentary ($2); }
                   1197:        | typed_typespecs
                   1198:                { if (pedantic)
                   1199:                    pedwarn ("ANSI C forbids member declarations with no members");
                   1200:                  shadow_tag($1);
                   1201:                  $$ = NULL_TREE; }
                   1202:        | nonempty_type_quals setspecs components
                   1203:                { $$ = $3;
                   1204:                  current_declspecs = TREE_VALUE (declspec_stack);
                   1205:                  declspec_stack = TREE_CHAIN (declspec_stack);
                   1206:                  resume_momentary ($2); }
                   1207:        | nonempty_type_quals
                   1208:                { if (pedantic)
                   1209:                    pedwarn ("ANSI C forbids member declarations with no members");
                   1210:                  shadow_tag($1);
                   1211:                  $$ = NULL_TREE; }
                   1212:        | error
                   1213:                { $$ = NULL_TREE; }
                   1214:        ;
                   1215: 
                   1216: components:
                   1217:          component_declarator
                   1218:        | components ',' component_declarator
                   1219:                { $$ = chainon ($1, $3); }
                   1220:        ;
                   1221: 
                   1222: component_declarator:
                   1223:          save_filename save_lineno declarator maybe_attribute
                   1224:                { $$ = grokfield ($1, $2, $3, current_declspecs, NULL_TREE);
                   1225:                  decl_attributes ($$, $4); }
                   1226:        | save_filename save_lineno
                   1227:          declarator ':' expr_no_commas maybe_attribute
                   1228:                { $$ = grokfield ($1, $2, $3, current_declspecs, $5);
                   1229:                  decl_attributes ($$, $6); }
1.1.1.5   root     1230:        | save_filename save_lineno ':' expr_no_commas maybe_attribute
                   1231:                { $$ = grokfield ($1, $2, NULL_TREE, current_declspecs, $4);
                   1232:                  decl_attributes ($$, $5); }
1.1       root     1233:        ;
                   1234: 
                   1235: /* We chain the enumerators in reverse order.
                   1236:    They are put in forward order where enumlist is used.
                   1237:    (The order used to be significant, but no longer is so.
                   1238:    However, we still maintain the order, just to be clean.)  */
                   1239: 
                   1240: enumlist:
                   1241:          enumerator
                   1242:        | enumlist ',' enumerator
                   1243:                { $$ = chainon ($3, $1); }
                   1244:        ;
                   1245: 
                   1246: 
                   1247: enumerator:
                   1248:          identifier
                   1249:                { $$ = build_enumerator ($1, NULL_TREE); }
                   1250:        | identifier '=' expr_no_commas
                   1251:                { $$ = build_enumerator ($1, $3); }
                   1252:        ;
                   1253: 
                   1254: typename:
                   1255:        typed_typespecs absdcl
                   1256:                { $$ = build_tree_list ($1, $2); }
                   1257:        | nonempty_type_quals absdcl
                   1258:                { $$ = build_tree_list ($1, $2); }
                   1259:        ;
                   1260: 
                   1261: absdcl:   /* an absolute declarator */
                   1262:        /* empty */
                   1263:                { $$ = NULL_TREE; }
                   1264:        | absdcl1
                   1265:        ;
                   1266: 
                   1267: nonempty_type_quals:
                   1268:          TYPE_QUAL
                   1269:                { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
                   1270:        | nonempty_type_quals TYPE_QUAL
                   1271:                { $$ = tree_cons (NULL_TREE, $2, $1); }
                   1272:        ;
                   1273: 
                   1274: type_quals:
                   1275:          /* empty */
                   1276:                { $$ = NULL_TREE; }
                   1277:        | type_quals TYPE_QUAL
                   1278:                { $$ = tree_cons (NULL_TREE, $2, $1); }
                   1279:        ;
                   1280: 
                   1281: absdcl1:  /* a nonempty absolute declarator */
                   1282:          '(' absdcl1 ')'
                   1283:                { $$ = $2; }
                   1284:          /* `(typedef)1' is `int'.  */
                   1285:        | '*' type_quals absdcl1  %prec UNARY
                   1286:                { $$ = make_pointer_declarator ($2, $3); }
                   1287:        | '*' type_quals  %prec UNARY
                   1288:                { $$ = make_pointer_declarator ($2, NULL_TREE); }
                   1289:        | absdcl1 '(' parmlist  %prec '.'
                   1290:                { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
                   1291:        | absdcl1 '[' expr ']'  %prec '.'
                   1292:                { $$ = build_nt (ARRAY_REF, $1, $3); }
                   1293:        | absdcl1 '[' ']'  %prec '.'
                   1294:                { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
                   1295:        | '(' parmlist  %prec '.'
                   1296:                { $$ = build_nt (CALL_EXPR, NULL_TREE, $2, NULL_TREE); }
                   1297:        | '[' expr ']'  %prec '.'
                   1298:                { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
                   1299:        | '[' ']'  %prec '.'
                   1300:                { $$ = build_nt (ARRAY_REF, NULL_TREE, NULL_TREE); }
                   1301:        ;
                   1302: 
                   1303: /* at least one statement, the first of which parses without error.  */
                   1304: /* stmts is used only after decls, so an invalid first statement
                   1305:    is actually regarded as an invalid decl and part of the decls.  */
                   1306: 
                   1307: stmts:
                   1308:          lineno_stmt_or_label
                   1309:        | stmts lineno_stmt_or_label
                   1310:        | stmts errstmt
                   1311:        ;
                   1312: 
                   1313: xstmts:
                   1314:        /* empty */
                   1315:        | stmts
                   1316:        ;
                   1317: 
                   1318: errstmt:  error ';'
                   1319:        ;
                   1320: 
                   1321: pushlevel:  /* empty */
                   1322:                { emit_line_note (input_filename, lineno);
                   1323:                  pushlevel (0);
                   1324:                  clear_last_expr ();
                   1325:                  push_momentary ();
1.1.1.4   root     1326:                  expand_start_bindings (0);
                   1327:                }
1.1       root     1328:        ;
                   1329: 
                   1330: /* Read zero or more forward-declarations for labels
                   1331:    that nested functions can jump to.  */
                   1332: maybe_label_decls:
                   1333:          /* empty */
                   1334:        | label_decls
                   1335:                { if (pedantic)
                   1336:                    pedwarn ("ANSI C forbids label declarations"); }
                   1337:        ;
                   1338: 
                   1339: label_decls:
                   1340:          label_decl
                   1341:        | label_decls label_decl
                   1342:        ;
                   1343: 
                   1344: label_decl:
                   1345:          LABEL identifiers_or_typenames ';'
                   1346:                { tree link;
                   1347:                  for (link = $2; link; link = TREE_CHAIN (link))
                   1348:                    {
                   1349:                      tree label = shadow_label (TREE_VALUE (link));
                   1350:                      C_DECLARED_LABEL_FLAG (label) = 1;
                   1351:                      declare_nonlocal_label (label);
                   1352:                    }
                   1353:                }
                   1354:        ;
                   1355: 
                   1356: /* This is the body of a function definition.
                   1357:    It causes syntax errors to ignore to the next openbrace.  */
                   1358: compstmt_or_error:
                   1359:          compstmt
                   1360:                {}
                   1361:        | error compstmt
                   1362:        ;
                   1363: 
                   1364: compstmt: '{' '}'
                   1365:                { $$ = convert (void_type_node, integer_zero_node); }
                   1366:        | '{' pushlevel maybe_label_decls decls xstmts '}'
                   1367:                { emit_line_note (input_filename, lineno);
                   1368:                  expand_end_bindings (getdecls (), 1, 0);
                   1369:                  $$ = poplevel (1, 1, 0);
                   1370:                  pop_momentary (); }
                   1371:        | '{' pushlevel maybe_label_decls error '}'
                   1372:                { emit_line_note (input_filename, lineno);
                   1373:                  expand_end_bindings (getdecls (), kept_level_p (), 0);
                   1374:                  $$ = poplevel (kept_level_p (), 0, 0);
                   1375:                  pop_momentary (); }
                   1376:        | '{' pushlevel maybe_label_decls stmts '}'
                   1377:                { emit_line_note (input_filename, lineno);
                   1378:                  expand_end_bindings (getdecls (), kept_level_p (), 0);
                   1379:                  $$ = poplevel (kept_level_p (), 0, 0);
                   1380:                  pop_momentary (); }
                   1381:        ;
                   1382: 
                   1383: /* Value is number of statements counted as of the closeparen.  */
                   1384: simple_if:
                   1385:          if_prefix lineno_labeled_stmt
                   1386: /* Make sure expand_end_cond is run once
                   1387:    for each call to expand_start_cond.
                   1388:    Otherwise a crash is likely.  */
                   1389:        | if_prefix error
                   1390:        ;
                   1391: 
                   1392: if_prefix:
                   1393:          IF '(' expr ')'
                   1394:                { emit_line_note ($<filename>-1, $<lineno>0);
                   1395:                  expand_start_cond (truthvalue_conversion ($3), 0);
1.1.1.6 ! root     1396:                  $<itype>$ = stmt_count;
1.1       root     1397:                  if_stmt_file = $<filename>-1;
                   1398:                  if_stmt_line = $<lineno>0;
                   1399:                  position_after_white_space (); }
                   1400:        ;
                   1401: 
1.1.1.3   root     1402: /* This is a subroutine of stmt.
                   1403:    It is used twice, once for valid DO statements
                   1404:    and once for catching errors in parsing the end test.  */
                   1405: do_stmt_start:
                   1406:          DO
                   1407:                { stmt_count++;
                   1408:                  emit_line_note ($<filename>-1, $<lineno>0);
                   1409:                  /* See comment in `while' alternative, above.  */
                   1410:                  emit_nop ();
                   1411:                  expand_start_loop_continue_elsewhere (1);
                   1412:                  position_after_white_space (); }
                   1413:          lineno_labeled_stmt WHILE
                   1414:                { expand_loop_continue_here (); }
                   1415:        ;
                   1416: 
1.1       root     1417: save_filename:
                   1418:                { $$ = input_filename; }
                   1419:        ;
                   1420: 
                   1421: save_lineno:
                   1422:                { $$ = lineno; }
                   1423:        ;
                   1424: 
                   1425: lineno_labeled_stmt:
                   1426:          save_filename save_lineno stmt
                   1427:                { }
                   1428: /*     | save_filename save_lineno error
                   1429:                { }
                   1430: */
                   1431:        | save_filename save_lineno label lineno_labeled_stmt
                   1432:                { }
                   1433:        ;
                   1434: 
                   1435: lineno_stmt_or_label:
                   1436:          save_filename save_lineno stmt_or_label
                   1437:                { }
                   1438:        ;
                   1439: 
                   1440: stmt_or_label:
                   1441:          stmt
                   1442:        | label
                   1443:                { int next;
                   1444:                  position_after_white_space ();
                   1445:                  next = getc (finput);
                   1446:                  ungetc (next, finput);
                   1447:                  if (pedantic && next == '}')
                   1448:                    pedwarn ("ANSI C forbids label at end of compound statement");
                   1449:                }
                   1450:        ;
                   1451: 
                   1452: /* Parse a single real statement, not including any labels.  */
                   1453: stmt:
                   1454:          compstmt
                   1455:                { stmt_count++; }
1.1.1.5   root     1456:         | all_iter_stmt 
1.1       root     1457:        | expr ';'
                   1458:                { stmt_count++;
                   1459:                  emit_line_note ($<filename>-1, $<lineno>0);
1.1.1.6 ! root     1460: /* It appears that this should not be done--that a non-lvalue array
        !          1461:    shouldn't get an error if the value isn't used.
        !          1462:    Section 3.2.2.1 says that an array lvalue gets converted to a pointer
        !          1463:    if it appears as a top-level expression,
        !          1464:    but says nothing about non-lvalue arrays.  */
        !          1465: #if 0
        !          1466:                  /* Call default_conversion to get an error
        !          1467:                     on referring to a register array if pedantic.  */
        !          1468:                  if (TREE_CODE (TREE_TYPE ($1)) == ARRAY_TYPE
        !          1469:                      || TREE_CODE (TREE_TYPE ($1)) == FUNCTION_TYPE)
        !          1470:                    $1 = default_conversion ($1);
        !          1471: #endif
1.1.1.5   root     1472:                  iterator_expand ($1);
1.1       root     1473:                  clear_momentary (); }
                   1474:        | simple_if ELSE
                   1475:                { expand_start_else ();
                   1476:                  $<itype>1 = stmt_count;
                   1477:                  position_after_white_space (); }
                   1478:          lineno_labeled_stmt
                   1479:                { expand_end_cond ();
                   1480:                  if (extra_warnings && stmt_count == $<itype>1)
                   1481:                    warning ("empty body in an else-statement"); }
                   1482:        | simple_if %prec IF
                   1483:                { expand_end_cond ();
1.1.1.6 ! root     1484:                  /* This warning is here instead of in simple_if, because we
        !          1485:                     do not want a warning if an empty if is followed by an
        !          1486:                     else statement.  */
1.1       root     1487:                  if (extra_warnings && stmt_count == $<itype>1)
                   1488:                    warning_with_file_and_line (if_stmt_file, if_stmt_line,
                   1489:                                                "empty body in an if-statement"); }
                   1490: /* Make sure expand_end_cond is run once
                   1491:    for each call to expand_start_cond.
                   1492:    Otherwise a crash is likely.  */
                   1493:        | simple_if ELSE error
                   1494:                { expand_end_cond (); }
                   1495:        | WHILE
                   1496:                { stmt_count++;
                   1497:                  emit_line_note ($<filename>-1, $<lineno>0);
                   1498:                  /* The emit_nop used to come before emit_line_note,
                   1499:                     but that made the nop seem like part of the preceding line.
                   1500:                     And that was confusing when the preceding line was
                   1501:                     inside of an if statement and was not really executed.
                   1502:                     I think it ought to work to put the nop after the line number.
                   1503:                     We will see.  --rms, July 15, 1991.  */
1.1.1.3   root     1504:                  emit_nop (); }
1.1       root     1505:          '(' expr ')'
1.1.1.3   root     1506:                { /* Don't start the loop till we have succeeded
                   1507:                     in parsing the end test.  This is to make sure
                   1508:                     that we end every loop we start.  */
                   1509:                  expand_start_loop (1);
                   1510:                  emit_line_note (input_filename, lineno);
1.1.1.4   root     1511:                  expand_exit_loop_if_false (NULL_PTR,
                   1512:                                             truthvalue_conversion ($4));
1.1       root     1513:                  position_after_white_space (); }
                   1514:          lineno_labeled_stmt
                   1515:                { expand_end_loop (); }
1.1.1.3   root     1516:        | do_stmt_start
1.1       root     1517:          '(' expr ')' ';'
                   1518:                { emit_line_note (input_filename, lineno);
1.1.1.4   root     1519:                  expand_exit_loop_if_false (NULL_PTR,
                   1520:                                             truthvalue_conversion ($3));
1.1       root     1521:                  expand_end_loop ();
                   1522:                  clear_momentary (); }
1.1.1.3   root     1523: /* This rule is needed to make sure we end every loop we start.  */
                   1524:        | do_stmt_start error
                   1525:                { expand_end_loop ();
                   1526:                  clear_momentary (); }
1.1       root     1527:        | FOR
                   1528:          '(' xexpr ';'
                   1529:                { stmt_count++;
                   1530:                  emit_line_note ($<filename>-1, $<lineno>0);
                   1531:                  /* See comment in `while' alternative, above.  */
                   1532:                  emit_nop ();
                   1533:                  if ($3) c_expand_expr_stmt ($3);
1.1.1.3   root     1534:                  /* Next step is to call expand_start_loop_continue_elsewhere,
                   1535:                     but wait till after we parse the entire for (...).
                   1536:                     Otherwise, invalid input might cause us to call that
                   1537:                     fn without calling expand_end_loop.  */
                   1538:                }
1.1       root     1539:          xexpr ';'
1.1.1.3   root     1540:                /* Can't emit now; wait till after expand_start_loop...  */
                   1541:                { $<lineno>7 = lineno;
                   1542:                  $<filename>$ = input_filename; }
1.1       root     1543:          xexpr ')'
1.1.1.3   root     1544:                { 
                   1545:                  /* Start the loop.  Doing this after parsing
                   1546:                     all the expressions ensures we will end the loop.  */
                   1547:                  expand_start_loop_continue_elsewhere (1);
                   1548:                  /* Emit the end-test, with a line number.  */
                   1549:                  emit_line_note ($<filename>8, $<lineno>7);
                   1550:                  if ($6)
1.1.1.4   root     1551:                    expand_exit_loop_if_false (NULL_PTR,
                   1552:                                               truthvalue_conversion ($6));
1.1.1.3   root     1553:                  /* Don't let the tree nodes for $9 be discarded by
                   1554:                     clear_momentary during the parsing of the next stmt.  */
                   1555:                  push_momentary ();
1.1.1.4   root     1556:                  $<lineno>7 = lineno;
1.1.1.5   root     1557:                  $<filename>8 = input_filename;
                   1558:                  position_after_white_space (); }
1.1       root     1559:          lineno_labeled_stmt
1.1.1.4   root     1560:                { /* Emit the increment expression, with a line number.  */
                   1561:                  emit_line_note ($<filename>8, $<lineno>7);
1.1       root     1562:                  expand_loop_continue_here ();
                   1563:                  if ($9)
                   1564:                    c_expand_expr_stmt ($9);
                   1565:                  pop_momentary ();
                   1566:                  expand_end_loop (); }
                   1567:        | SWITCH '(' expr ')'
                   1568:                { stmt_count++;
                   1569:                  emit_line_note ($<filename>-1, $<lineno>0);
                   1570:                  c_expand_start_case ($3);
                   1571:                  /* Don't let the tree nodes for $3 be discarded by
                   1572:                     clear_momentary during the parsing of the next stmt.  */
                   1573:                  push_momentary ();
                   1574:                  position_after_white_space (); }
                   1575:          lineno_labeled_stmt
                   1576:                { expand_end_case ($3);
                   1577:                  pop_momentary (); }
                   1578:        | BREAK ';'
                   1579:                { stmt_count++;
                   1580:                  emit_line_note ($<filename>-1, $<lineno>0);
                   1581:                  if ( ! expand_exit_something ())
                   1582:                    error ("break statement not within loop or switch"); }
                   1583:        | CONTINUE ';'
                   1584:                { stmt_count++;
                   1585:                  emit_line_note ($<filename>-1, $<lineno>0);
1.1.1.4   root     1586:                  if (! expand_continue_loop (NULL_PTR))
1.1       root     1587:                    error ("continue statement not within a loop"); }
                   1588:        | RETURN ';'
                   1589:                { stmt_count++;
                   1590:                  emit_line_note ($<filename>-1, $<lineno>0);
                   1591:                  c_expand_return (NULL_TREE); }
                   1592:        | RETURN expr ';'
                   1593:                { stmt_count++;
                   1594:                  emit_line_note ($<filename>-1, $<lineno>0);
                   1595:                  c_expand_return ($2); }
1.1.1.2   root     1596:        | ASM_KEYWORD maybe_type_qual '(' expr ')' ';'
1.1       root     1597:                { stmt_count++;
                   1598:                  emit_line_note ($<filename>-1, $<lineno>0);
                   1599:                  STRIP_NOPS ($4);
                   1600:                  if ((TREE_CODE ($4) == ADDR_EXPR
                   1601:                       && TREE_CODE (TREE_OPERAND ($4, 0)) == STRING_CST)
                   1602:                      || TREE_CODE ($4) == STRING_CST)
                   1603:                    expand_asm ($4);
                   1604:                  else
                   1605:                    error ("argument of `asm' is not a constant string"); }
                   1606:        /* This is the case with just output operands.  */
1.1.1.2   root     1607:        | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ')' ';'
1.1       root     1608:                { stmt_count++;
                   1609:                  emit_line_note ($<filename>-1, $<lineno>0);
                   1610:                  c_expand_asm_operands ($4, $6, NULL_TREE, NULL_TREE,
                   1611:                                         $2 == ridpointers[(int)RID_VOLATILE],
                   1612:                                         input_filename, lineno); }
                   1613:        /* This is the case with input operands as well.  */
1.1.1.2   root     1614:        | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':' asm_operands ')' ';'
1.1       root     1615:                { stmt_count++;
                   1616:                  emit_line_note ($<filename>-1, $<lineno>0);
                   1617:                  c_expand_asm_operands ($4, $6, $8, NULL_TREE,
                   1618:                                         $2 == ridpointers[(int)RID_VOLATILE],
                   1619:                                         input_filename, lineno); }
                   1620:        /* This is the case with clobbered registers as well.  */
1.1.1.2   root     1621:        | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':'
1.1       root     1622:          asm_operands ':' asm_clobbers ')' ';'
                   1623:                { stmt_count++;
                   1624:                  emit_line_note ($<filename>-1, $<lineno>0);
                   1625:                  c_expand_asm_operands ($4, $6, $8, $10,
                   1626:                                         $2 == ridpointers[(int)RID_VOLATILE],
                   1627:                                         input_filename, lineno); }
                   1628:        | GOTO identifier ';'
                   1629:                { tree decl;
                   1630:                  stmt_count++;
                   1631:                  emit_line_note ($<filename>-1, $<lineno>0);
                   1632:                  decl = lookup_label ($2);
                   1633:                  if (decl != 0)
                   1634:                    {
                   1635:                      TREE_USED (decl) = 1;
                   1636:                      expand_goto (decl);
                   1637:                    }
                   1638:                }
                   1639:        | GOTO '*' expr ';'
                   1640:                { stmt_count++;
                   1641:                  emit_line_note ($<filename>-1, $<lineno>0);
1.1.1.4   root     1642:                  expand_computed_goto (convert (ptr_type_node, $3)); }
1.1       root     1643:        | ';'
                   1644:        ;
                   1645: 
1.1.1.5   root     1646: all_iter_stmt:
                   1647:          all_iter_stmt_simple
                   1648: /*     | all_iter_stmt_with_decl */
                   1649:        ;
                   1650: 
                   1651: all_iter_stmt_simple:
                   1652:          FOR '(' primary ')' 
                   1653:          {
                   1654:            /* The value returned by this action is  */
                   1655:            /*      1 if everything is OK */ 
                   1656:            /*      0 in case of error or already bound iterator */
                   1657: 
                   1658:            $<itype>$ = 0;
                   1659:            if (TREE_CODE ($3) != VAR_DECL)
                   1660:              error ("invalid `for (ITERATOR)' syntax");
1.1.1.6 ! root     1661:            else if (! ITERATOR_P ($3))
1.1.1.5   root     1662:              error ("`%s' is not an iterator",
                   1663:                     IDENTIFIER_POINTER (DECL_NAME ($3)));
                   1664:            else if (ITERATOR_BOUND_P ($3))
                   1665:              error ("`for (%s)' inside expansion of same iterator",
                   1666:                     IDENTIFIER_POINTER (DECL_NAME ($3)));
                   1667:            else
                   1668:              {
                   1669:                $<itype>$ = 1;
                   1670:                iterator_for_loop_start ($3);
                   1671:              }
                   1672:          }
                   1673:          lineno_labeled_stmt
                   1674:          {
                   1675:            if ($<itype>5)
                   1676:              iterator_for_loop_end ($3);
                   1677:          }
                   1678: 
                   1679: /*  This really should allow any kind of declaration,
                   1680:     for generality.  Fix it before turning it back on.
                   1681: 
                   1682: all_iter_stmt_with_decl:
                   1683:          FOR '(' ITERATOR pushlevel setspecs iterator_spec ')' 
                   1684:          {
                   1685: */         /* The value returned by this action is  */
                   1686:            /*      1 if everything is OK */ 
                   1687:            /*      0 in case of error or already bound iterator */
                   1688: /*
                   1689:            iterator_for_loop_start ($6);
                   1690:          }
                   1691:          lineno_labeled_stmt
                   1692:          {
                   1693:            iterator_for_loop_end ($6);
                   1694:            emit_line_note (input_filename, lineno);
                   1695:            expand_end_bindings (getdecls (), 1, 0);
                   1696:            $<ttype>$ = poplevel (1, 1, 0);
                   1697:            pop_momentary ();       
                   1698:          }
                   1699: */
                   1700: 
1.1       root     1701: /* Any kind of label, including jump labels and case labels.
                   1702:    ANSI C accepts labels only before statements, but we allow them
                   1703:    also at the end of a compound statement.  */
                   1704: 
1.1.1.5   root     1705: label:   CASE expr_no_commas ':'
1.1       root     1706:                { register tree value = check_case_value ($2);
                   1707:                  register tree label
                   1708:                    = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
                   1709: 
                   1710:                  stmt_count++;
                   1711: 
                   1712:                  if (value != error_mark_node)
                   1713:                    {
                   1714:                      tree duplicate;
1.1.1.6 ! root     1715:                      int success = pushcase (value, convert_and_check,
        !          1716:                                              label, &duplicate);
1.1       root     1717:                      if (success == 1)
                   1718:                        error ("case label not within a switch statement");
                   1719:                      else if (success == 2)
                   1720:                        {
                   1721:                          error ("duplicate case value");
                   1722:                          error_with_decl (duplicate, "this is the first entry for that value");
                   1723:                        }
                   1724:                      else if (success == 3)
                   1725:                        warning ("case value out of range");
                   1726:                      else if (success == 5)
                   1727:                        error ("case label within scope of cleanup or variable array");
                   1728:                    }
                   1729:                  position_after_white_space (); }
1.1.1.5   root     1730:        | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
1.1       root     1731:                { register tree value1 = check_case_value ($2);
                   1732:                  register tree value2 = check_case_value ($4);
                   1733:                  register tree label
                   1734:                    = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
                   1735: 
                   1736:                  stmt_count++;
                   1737: 
                   1738:                  if (value1 != error_mark_node && value2 != error_mark_node)
                   1739:                    {
                   1740:                      tree duplicate;
1.1.1.6 ! root     1741:                      int success = pushcase_range (value1, value2,
        !          1742:                                                    convert_and_check, label,
1.1       root     1743:                                                    &duplicate);
                   1744:                      if (success == 1)
                   1745:                        error ("case label not within a switch statement");
                   1746:                      else if (success == 2)
                   1747:                        {
                   1748:                          error ("duplicate case value");
                   1749:                          error_with_decl (duplicate, "this is the first entry for that value");
                   1750:                        }
                   1751:                      else if (success == 3)
                   1752:                        warning ("case value out of range");
                   1753:                      else if (success == 4)
                   1754:                        warning ("empty case range");
                   1755:                      else if (success == 5)
                   1756:                        error ("case label within scope of cleanup or variable array");
                   1757:                    }
                   1758:                  position_after_white_space (); }
                   1759:        | DEFAULT ':'
                   1760:                {
                   1761:                  tree duplicate;
                   1762:                  register tree label
                   1763:                    = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
1.1.1.6 ! root     1764:                  int success = pushcase (NULL_TREE, 0, label, &duplicate);
1.1       root     1765:                  stmt_count++;
                   1766:                  if (success == 1)
                   1767:                    error ("default label not within a switch statement");
                   1768:                  else if (success == 2)
                   1769:                    {
                   1770:                      error ("multiple default labels in one switch");
                   1771:                      error_with_decl (duplicate, "this is the first default label");
                   1772:                    }
                   1773:                  position_after_white_space (); }
                   1774:        | identifier ':'
                   1775:                { tree label = define_label (input_filename, lineno, $1);
                   1776:                  stmt_count++;
                   1777:                  emit_nop ();
                   1778:                  if (label)
                   1779:                    expand_label (label);
                   1780:                  position_after_white_space (); }
                   1781:        ;
                   1782: 
                   1783: /* Either a type-qualifier or nothing.  First thing in an `asm' statement.  */
                   1784: 
                   1785: maybe_type_qual:
                   1786:        /* empty */
1.1.1.6 ! root     1787:                { emit_line_note (input_filename, lineno);
        !          1788:                  $$ = NULL_TREE; }
1.1       root     1789:        | TYPE_QUAL
                   1790:                { emit_line_note (input_filename, lineno); }
                   1791:        ;
                   1792: 
                   1793: xexpr:
                   1794:        /* empty */
                   1795:                { $$ = NULL_TREE; }
                   1796:        | expr
                   1797:        ;
                   1798: 
                   1799: /* These are the operands other than the first string and colon
                   1800:    in  asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x))  */
                   1801: asm_operands: /* empty */
                   1802:                { $$ = NULL_TREE; }
                   1803:        | nonnull_asm_operands
                   1804:        ;
                   1805: 
                   1806: nonnull_asm_operands:
                   1807:          asm_operand
                   1808:        | nonnull_asm_operands ',' asm_operand
                   1809:                { $$ = chainon ($1, $3); }
                   1810:        ;
                   1811: 
                   1812: asm_operand:
                   1813:          STRING '(' expr ')'
                   1814:                { $$ = build_tree_list ($1, $3); }
                   1815:        ;
                   1816: 
                   1817: asm_clobbers:
                   1818:          string
                   1819:                { $$ = tree_cons (NULL_TREE, combine_strings ($1), NULL_TREE); }
                   1820:        | asm_clobbers ',' string
                   1821:                { $$ = tree_cons (NULL_TREE, combine_strings ($3), $1); }
                   1822:        ;
                   1823: 
                   1824: /* This is what appears inside the parens in a function declarator.
                   1825:    Its value is a list of ..._TYPE nodes.  */
                   1826: parmlist:
                   1827:                { pushlevel (0);
                   1828:                  clear_parm_order ();
                   1829:                  declare_parm_level (0); }
                   1830:          parmlist_1
                   1831:                { $$ = $2;
                   1832:                  parmlist_tags_warning ();
                   1833:                  poplevel (0, 0, 0); }
                   1834:        ;
                   1835: 
                   1836: parmlist_1:
                   1837:          parmlist_2 ')'
                   1838:        | parms ';'
                   1839:                { tree parm;
1.1.1.3   root     1840:                  if (pedantic)
                   1841:                    pedwarn ("ANSI C forbids forward parameter declarations");
1.1       root     1842:                  /* Mark the forward decls as such.  */
                   1843:                  for (parm = getdecls (); parm; parm = TREE_CHAIN (parm))
                   1844:                    TREE_ASM_WRITTEN (parm) = 1;
                   1845:                  clear_parm_order (); }
                   1846:          parmlist_1
                   1847:                { $$ = $4; }
                   1848:        | error ')'
                   1849:                { $$ = tree_cons (NULL_TREE, NULL_TREE, NULL_TREE); }
                   1850:        ;
                   1851: 
                   1852: /* This is what appears inside the parens in a function declarator.
                   1853:    Is value is represented in the format that grokdeclarator expects.  */
                   1854: parmlist_2:  /* empty */
                   1855:                { $$ = get_parm_info (0); }
                   1856:        | ELLIPSIS
                   1857:                { $$ = get_parm_info (0);
                   1858:                  if (pedantic)
                   1859:                    pedwarn ("ANSI C requires a named argument before `...'");
                   1860:                }
                   1861:        | parms
                   1862:                { $$ = get_parm_info (1); }
                   1863:        | parms ',' ELLIPSIS
                   1864:                { $$ = get_parm_info (0); }
                   1865:        ;
                   1866: 
                   1867: parms:
                   1868:        parm
                   1869:                { push_parm_decl ($1); }
                   1870:        | parms ',' parm
                   1871:                { push_parm_decl ($3); }
                   1872:        ;
                   1873: 
                   1874: /* A single parameter declaration or parameter type name,
                   1875:    as found in a parmlist.  */
                   1876: parm:
                   1877:          typed_declspecs parm_declarator
                   1878:                { $$ = build_tree_list ($1, $2) ; }
                   1879:        | typed_declspecs notype_declarator
                   1880:                { $$ = build_tree_list ($1, $2) ; }
                   1881:        | typed_declspecs absdcl
                   1882:                { $$ = build_tree_list ($1, $2); }
                   1883:        | declmods notype_declarator
                   1884:                { $$ = build_tree_list ($1, $2) ; }
                   1885:        | declmods absdcl
                   1886:                { $$ = build_tree_list ($1, $2); }
                   1887:        ;
                   1888: 
                   1889: /* This is used in a function definition
                   1890:    where either a parmlist or an identifier list is ok.
                   1891:    Its value is a list of ..._TYPE nodes or a list of identifiers.  */
                   1892: parmlist_or_identifiers:
                   1893:                { pushlevel (0);
                   1894:                  clear_parm_order ();
                   1895:                  declare_parm_level (1); }
                   1896:          parmlist_or_identifiers_1
                   1897:                { $$ = $2;
                   1898:                  parmlist_tags_warning ();
                   1899:                  poplevel (0, 0, 0); }
                   1900:        ;
                   1901: 
                   1902: parmlist_or_identifiers_1:
1.1.1.3   root     1903:          parmlist_1
1.1       root     1904:        | identifiers ')'
                   1905:                { tree t;
                   1906:                  for (t = $1; t; t = TREE_CHAIN (t))
                   1907:                    if (TREE_VALUE (t) == NULL_TREE)
                   1908:                      error ("`...' in old-style identifier list");
                   1909:                  $$ = tree_cons (NULL_TREE, NULL_TREE, $1); }
                   1910:        ;
                   1911: 
                   1912: /* A nonempty list of identifiers.  */
                   1913: identifiers:
                   1914:        IDENTIFIER
                   1915:                { $$ = build_tree_list (NULL_TREE, $1); }
                   1916:        | identifiers ',' IDENTIFIER
                   1917:                { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
                   1918:        ;
                   1919: 
                   1920: /* A nonempty list of identifiers, including typenames.  */
                   1921: identifiers_or_typenames:
                   1922:        identifier
                   1923:                { $$ = build_tree_list (NULL_TREE, $1); }
                   1924:        | identifiers_or_typenames ',' identifier
                   1925:                { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
                   1926:        ;
1.1.1.4   root     1927: 
1.1       root     1928: %%

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.